Skip to content

Commit f7e8dff

Browse files
committed
Fix conflicting TimePicker component type
1 parent 1083ecc commit f7e8dff

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

packages/frappe-ui-react/src/components/timePicker/timePicker.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import React from "react";
99
import Popover from "../popover/popover";
1010
import TextInput from "../textInput/textInput";
1111
import FeatherIcon from "../featherIcon";
12-
import type { TimePickerProps, Option } from "./types";
12+
import type { TimePickerProps, TimePickerOption } from "./types";
1313
import { useTimePicker } from "./useTimePicker";
1414

1515
const TimePicker: React.FC<TimePickerProps> = ({
@@ -72,7 +72,7 @@ const TimePicker: React.FC<TimePickerProps> = ({
7272
maxTime,
7373
});
7474

75-
const getButtonClasses = (opt: Option, idx: number): string => {
75+
const getButtonClasses = (opt: TimePickerOption, idx: number): string => {
7676
if (idx === highlightIndex) return "bg-surface-gray-3 text-ink-gray-8";
7777
const { selected, nearest } = selectedAndNearest;
7878
if (isTyping && !selected) {

packages/frappe-ui-react/src/components/timePicker/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ReactNode } from "react";
22
import type { Placement } from "@popperjs/core";
33

4-
export interface Option {
4+
export interface TimePickerOption {
55
value: string;
66
label: string;
77
}

packages/frappe-ui-react/src/components/timePicker/useTimePicker.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
useCallback,
77
useId,
88
} from "react";
9-
import type { Option, TimePickerProps } from "./types";
9+
import type { TimePickerOption, TimePickerProps } from "./types";
1010
import {
1111
findNearestIndex,
1212
formatDisplay,
@@ -76,7 +76,7 @@ export function useTimePicker({
7676
});
7777
}, []);
7878

79-
const displayedOptions = useMemo<Option[]>(() => {
79+
const displayedOptions = useMemo<TimePickerOption[]>(() => {
8080
if (options.length) {
8181
return options.map((o) => {
8282
const val = normalize24(o.value);
@@ -87,7 +87,7 @@ export function useTimePicker({
8787
});
8888
}
8989

90-
const out: Option[] = [];
90+
const out: TimePickerOption[] = [];
9191
for (let m = 0; m < 1440; m += interval) {
9292
if (minMinutes != null && m < minMinutes) continue;
9393
if (maxMinutes != null && m > maxMinutes) continue;
@@ -110,7 +110,7 @@ export function useTimePicker({
110110
* @param valueToMatch - Time value to match against options
111111
* @returns Matching or nearest option, or null if not found
112112
*/
113-
const getTargetOption = useCallback((valueToMatch: string): Option | null => {
113+
const getTargetOption = useCallback((valueToMatch: string): TimePickerOption | null => {
114114
const list = displayedOptions;
115115
if (!list.length || !valueToMatch) return null;
116116

@@ -129,7 +129,7 @@ export function useTimePicker({
129129
/**
130130
* Determines which option should be highlighted
131131
*/
132-
const selectedAndNearest = useMemo((): { selected: Option | null; nearest: Option | null } => {
132+
const selectedAndNearest = useMemo((): { selected: TimePickerOption | null; nearest: TimePickerOption | null } => {
133133
const candidate = isTyping ? displayValue : internalValue;
134134
if (!candidate) return { selected: null, nearest: null };
135135

packages/frappe-ui-react/src/components/timePicker/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Option } from "./types";
1+
import { TimePickerOption } from "./types";
22
import { ParsedTime } from "./types";
33

44
/**
@@ -155,7 +155,7 @@ export const formatDisplay = (val24: string, use12Hr: boolean): string => {
155155
*/
156156
export function findNearestIndex(
157157
targetMinutes: number,
158-
list: Option[]
158+
list: TimePickerOption[]
159159
): number {
160160
if (!list.length) return -1;
161161
const minutesArr = list.map((o) => {

0 commit comments

Comments
 (0)