@aic-kits/react 0.34.7 → 0.34.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DatePicker/DatePickerCalendar.d.ts +2 -0
- package/dist/components/DatePicker/DatePickerGrid.d.ts +2 -0
- package/dist/components/DatePicker/DatePickerHeader.d.ts +8 -0
- package/dist/components/DatePicker/DatePickerInput.d.ts +3 -0
- package/dist/components/DatePicker/DatePickerMonthPicker.d.ts +13 -0
- package/dist/components/DatePicker/DatePickerPopup.d.ts +6 -0
- package/dist/components/DatePicker/DatePickerRangeInput.d.ts +26 -0
- package/dist/components/DatePicker/DatePickerTimezone.d.ts +2 -0
- package/dist/components/DatePicker/DatePickerYearPicker.d.ts +11 -0
- package/dist/components/DatePicker/StyledDatePicker.d.ts +26 -0
- package/dist/components/DatePicker/constants.d.ts +23 -0
- package/dist/components/DatePicker/hooks.d.ts +37 -0
- package/dist/components/DatePicker/index.d.ts +4 -0
- package/dist/components/DatePicker/types.d.ts +317 -0
- package/dist/components/DatePicker/utils.d.ts +203 -0
- package/dist/components/Input/types.d.ts +8 -0
- package/dist/components/Select/SelectDropdown.d.ts +2 -2
- package/dist/components/TimePicker/StyledTimePicker.d.ts +15 -0
- package/dist/components/TimePicker/TimePickerInput.d.ts +3 -0
- package/dist/components/TimePicker/TimePickerPopup.d.ts +2 -0
- package/dist/components/TimePicker/TimePickerRangeInput.d.ts +24 -0
- package/dist/components/TimePicker/TimePickerWheel.d.ts +2 -0
- package/dist/components/TimePicker/TimePickerWheels.d.ts +2 -0
- package/dist/components/TimePicker/constants.d.ts +12 -0
- package/dist/components/TimePicker/hooks.d.ts +25 -0
- package/dist/components/TimePicker/index.d.ts +3 -0
- package/dist/components/TimePicker/types.d.ts +177 -0
- package/dist/components/TimePicker/utils.d.ts +73 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/usePopupPosition.d.ts +13 -0
- package/dist/index.cjs +482 -315
- package/dist/index.js +10885 -7699
- package/dist/theme/components/datepicker.d.ts +85 -0
- package/dist/theme/components/index.d.ts +14 -0
- package/dist/theme/components/timepicker.d.ts +50 -0
- package/package.json +2 -2
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { DateConfig, DatePickerValue, WeekStartDay, TimezoneOption, TimeValue } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Get the first day of the month
|
|
4
|
+
*/
|
|
5
|
+
export declare function getFirstDayOfMonth(date: Date): Date;
|
|
6
|
+
/**
|
|
7
|
+
* Get the last day of the month
|
|
8
|
+
*/
|
|
9
|
+
export declare function getLastDayOfMonth(date: Date): Date;
|
|
10
|
+
/**
|
|
11
|
+
* Add months to a date
|
|
12
|
+
*/
|
|
13
|
+
export declare function addMonths(date: Date, months: number): Date;
|
|
14
|
+
/**
|
|
15
|
+
* Add days to a date
|
|
16
|
+
*/
|
|
17
|
+
export declare function addDays(date: Date, days: number): Date;
|
|
18
|
+
/**
|
|
19
|
+
* Check if two dates are the same day
|
|
20
|
+
*/
|
|
21
|
+
export declare function isSameDay(date1: Date | null, date2: Date | null): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Check if two dates are in the same month
|
|
24
|
+
*/
|
|
25
|
+
export declare function isSameMonth(date1: Date, date2: Date): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a date is today
|
|
28
|
+
*/
|
|
29
|
+
export declare function isToday(date: Date): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Check if date is before another date (day comparison)
|
|
32
|
+
*/
|
|
33
|
+
export declare function isBefore(date: Date, compareDate: Date): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Check if date is after another date (day comparison)
|
|
36
|
+
*/
|
|
37
|
+
export declare function isAfter(date: Date, compareDate: Date): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Check if a year is a leap year
|
|
40
|
+
*/
|
|
41
|
+
export declare function isLeapYear(year: number): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Get the number of days in a given month
|
|
44
|
+
* @param month 1-indexed month (1 = January, 12 = December)
|
|
45
|
+
* @param year Full year (e.g., 2024)
|
|
46
|
+
*/
|
|
47
|
+
export declare function getDaysInMonth(month: number, year: number): number;
|
|
48
|
+
/**
|
|
49
|
+
* Get the starting date for the calendar grid (may be in previous month)
|
|
50
|
+
*/
|
|
51
|
+
export declare function getCalendarGridStartDate(month: Date, weekStartDay: WeekStartDay): Date;
|
|
52
|
+
/**
|
|
53
|
+
* Generate calendar grid dates (6 weeks x 7 days = 42 days)
|
|
54
|
+
*/
|
|
55
|
+
export declare function generateCalendarGrid(month: Date, weekStartDay: WeekStartDay): Date[];
|
|
56
|
+
/**
|
|
57
|
+
* Get weekday names starting from the specified day
|
|
58
|
+
*/
|
|
59
|
+
export declare function getWeekdayNames(locale: string, weekStartDay: WeekStartDay, format?: 'narrow' | 'short' | 'long'): string[];
|
|
60
|
+
/**
|
|
61
|
+
* Check if a date is disabled based on configuration
|
|
62
|
+
*/
|
|
63
|
+
export declare function isDateDisabled(date: Date, config?: DateConfig): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Check if an entire month is before/after date constraints
|
|
66
|
+
*/
|
|
67
|
+
export declare function isMonthDisabled(month: Date, direction: 'prev' | 'next', config?: DateConfig): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Parse time string (HH:mm) to minutes from midnight
|
|
70
|
+
*/
|
|
71
|
+
export declare function parseTimeToMinutes(time: string): number;
|
|
72
|
+
/**
|
|
73
|
+
* Format minutes from midnight to time string
|
|
74
|
+
*/
|
|
75
|
+
export declare function formatMinutesToTime(minutes: number, format?: '12h' | '24h'): string;
|
|
76
|
+
/**
|
|
77
|
+
* Format date for display in header (e.g., "December 2024")
|
|
78
|
+
*/
|
|
79
|
+
export declare function formatMonthYear(date: Date, locale: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* Format month only (e.g., "December")
|
|
82
|
+
*/
|
|
83
|
+
export declare function formatMonth(date: Date, locale: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* Format year only (e.g., "2024")
|
|
86
|
+
*/
|
|
87
|
+
export declare function formatYear(date: Date): string;
|
|
88
|
+
/**
|
|
89
|
+
* Get all month names for a locale
|
|
90
|
+
*/
|
|
91
|
+
export declare function getMonthNames(locale: string): string[];
|
|
92
|
+
/**
|
|
93
|
+
* Get year range for year picker (12 years centered on current year)
|
|
94
|
+
*/
|
|
95
|
+
export declare function getYearRange(year: number): number[];
|
|
96
|
+
/**
|
|
97
|
+
* Add years to a date
|
|
98
|
+
*/
|
|
99
|
+
export declare function addYears(date: Date, years: number): Date;
|
|
100
|
+
/**
|
|
101
|
+
* Format date for selected date display (e.g., "Monday, July 22")
|
|
102
|
+
*/
|
|
103
|
+
export declare function formatSelectedDate(date: Date | null, locale: string): string;
|
|
104
|
+
/**
|
|
105
|
+
* Format date for input display (e.g., "Dec 25, 2024 at 10:00am")
|
|
106
|
+
*/
|
|
107
|
+
export declare function formatDateTimeForInput(date: Date | null, locale: string): string;
|
|
108
|
+
/**
|
|
109
|
+
* Format time value to string
|
|
110
|
+
*/
|
|
111
|
+
export declare function formatTimeValue(time: TimeValue | null, format?: '12h' | '24h'): string;
|
|
112
|
+
/**
|
|
113
|
+
* Format date for editable input
|
|
114
|
+
* Always uses DD/MM/YYYY format for consistency with validation
|
|
115
|
+
* Optionally includes time if showTime is true
|
|
116
|
+
*/
|
|
117
|
+
export declare function formatDateForInput(date: Date | null, _locale: string, time?: TimeValue | null, showTime?: boolean, timeFormat?: '12h' | '24h'): string;
|
|
118
|
+
/**
|
|
119
|
+
* Parse result from parseInputDateTime
|
|
120
|
+
*/
|
|
121
|
+
export interface ParsedDateTime {
|
|
122
|
+
date: Date;
|
|
123
|
+
time: TimeValue | null;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Parse user input string to Date and optional time
|
|
127
|
+
* Supports formats:
|
|
128
|
+
* - DD/MM/YYYY HH:mm (date with time suffix)
|
|
129
|
+
* - DD/MM/YYYY h:mm AM/PM (date with 12h time suffix)
|
|
130
|
+
* - DD/MM/YYYY or MM/DD/YYYY (date only)
|
|
131
|
+
* - YYYY-MM-DD (ISO date only)
|
|
132
|
+
* Returns null if parsing fails
|
|
133
|
+
*/
|
|
134
|
+
export declare function parseInputDateTime(input: string, locale: string): ParsedDateTime | null;
|
|
135
|
+
/**
|
|
136
|
+
* Legacy function for backwards compatibility - parses date only
|
|
137
|
+
*/
|
|
138
|
+
export declare function parseInputDate(input: string, locale: string): Date | null;
|
|
139
|
+
/**
|
|
140
|
+
* Get placeholder format based on locale and time format
|
|
141
|
+
* @param locale - locale for date format
|
|
142
|
+
* @param includeTime - if true, includes time placeholder
|
|
143
|
+
* @param timeFormat - '12h' or '24h' for time format
|
|
144
|
+
*/
|
|
145
|
+
export declare function getDateInputPlaceholder(_locale: string, includeTime?: boolean, timeFormat?: '12h' | '24h'): string;
|
|
146
|
+
/**
|
|
147
|
+
* Get timezone offset string (e.g., "GMT-5")
|
|
148
|
+
*/
|
|
149
|
+
export declare function getTimezoneOffset(timezone: string): string;
|
|
150
|
+
export declare function generateTimezoneOptions(): TimezoneOption[];
|
|
151
|
+
/**
|
|
152
|
+
* Convert a date+time from one timezone to another
|
|
153
|
+
* Returns new Date and TimeValue in target timezone
|
|
154
|
+
*
|
|
155
|
+
* Example: 9:00 UTC on Jan 17 → 16:00 UTC+7 on Jan 17
|
|
156
|
+
*/
|
|
157
|
+
export declare function convertDateTimeToTimezone(date: Date, time: TimeValue, fromTimezone: string | null, toTimezone: string | null): {
|
|
158
|
+
date: Date;
|
|
159
|
+
time: TimeValue;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Convert a DatePickerValue to a different timezone
|
|
163
|
+
*/
|
|
164
|
+
export declare function convertSlotToTimezone(slot: DatePickerValue, toTimezone: string | null): DatePickerValue;
|
|
165
|
+
/**
|
|
166
|
+
* Convert all slots to target timezone
|
|
167
|
+
*/
|
|
168
|
+
export declare function convertSlotsToTimezone(slots: DatePickerValue[], toTimezone: string | null): DatePickerValue[];
|
|
169
|
+
/**
|
|
170
|
+
* Get all unique dates from slots array
|
|
171
|
+
*/
|
|
172
|
+
export declare function getDatesFromSlots(slots: DatePickerValue[]): Date[];
|
|
173
|
+
/**
|
|
174
|
+
* Get time slots available for a specific date
|
|
175
|
+
*/
|
|
176
|
+
export declare function getTimeSlotsForDate(slots: DatePickerValue[], date: Date | null): TimeValue[];
|
|
177
|
+
/**
|
|
178
|
+
* Check if a date has any available slots
|
|
179
|
+
*/
|
|
180
|
+
export declare function dateHasSlots(slots: DatePickerValue[], date: Date): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Get all unique time slots from slots array (when no date is selected)
|
|
183
|
+
* Used to show preview of available times before user selects a date
|
|
184
|
+
*/
|
|
185
|
+
export declare function getAllUniqueTimeSlots(slots: DatePickerValue[]): TimeValue[];
|
|
186
|
+
/**
|
|
187
|
+
* Create a DateConfig that disables dates without slots
|
|
188
|
+
*/
|
|
189
|
+
export declare function createSlotsDateConfig(slots: DatePickerValue[], existingConfig?: DateConfig): DateConfig;
|
|
190
|
+
/**
|
|
191
|
+
* Convert DatePickerValue to timestamp (milliseconds) for comparison
|
|
192
|
+
* Combines date and time into single comparable number
|
|
193
|
+
*/
|
|
194
|
+
export declare function datePickerValueToTimestamp(value: DatePickerValue): number;
|
|
195
|
+
/**
|
|
196
|
+
* Compare two DatePickerValues
|
|
197
|
+
* Returns:
|
|
198
|
+
* -1 if a < b
|
|
199
|
+
* 0 if a === b
|
|
200
|
+
* 1 if a > b
|
|
201
|
+
* null if either value has no date (incomparable)
|
|
202
|
+
*/
|
|
203
|
+
export declare function compareDatePickerValues(a: DatePickerValue | undefined, b: DatePickerValue | undefined): -1 | 0 | 1 | null;
|
|
@@ -38,6 +38,14 @@ interface BaseInputProps {
|
|
|
38
38
|
* Icon to display on the right side of the input
|
|
39
39
|
*/
|
|
40
40
|
rightIcon?: Icon;
|
|
41
|
+
/**
|
|
42
|
+
* Show clear button when input has value
|
|
43
|
+
*/
|
|
44
|
+
clearable?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Callback when clear button is clicked
|
|
47
|
+
*/
|
|
48
|
+
onClear?: () => void;
|
|
41
49
|
/**
|
|
42
50
|
* Border color when focused
|
|
43
51
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SelectSize } from '../../theme/components/select';
|
|
2
2
|
import { SelectOption } from './types';
|
|
3
3
|
interface SelectDropdownProps<T extends string | number> {
|
|
4
|
-
|
|
4
|
+
anchorRef: React.RefObject<HTMLDivElement | null>;
|
|
5
5
|
isOpen: boolean;
|
|
6
6
|
options: SelectOption<T>[];
|
|
7
7
|
onSelect: (option: SelectOption<T>) => void;
|
|
@@ -10,5 +10,5 @@ interface SelectDropdownProps<T extends string | number> {
|
|
|
10
10
|
size: SelectSize;
|
|
11
11
|
borderRadius: string;
|
|
12
12
|
}
|
|
13
|
-
export declare function SelectDropdown<T extends string | number>({
|
|
13
|
+
export declare function SelectDropdown<T extends string | number>({ anchorRef, isOpen, options, onSelect, selectedValue, onClose, size, borderRadius, }: SelectDropdownProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
14
14
|
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TimePickerSize } from './types';
|
|
2
|
+
interface StyledWheelItemProps {
|
|
3
|
+
$size: TimePickerSize;
|
|
4
|
+
$isSelected: boolean;
|
|
5
|
+
$offset: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const StyledWheelItem: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledWheelItemProps>> & string;
|
|
8
|
+
interface StyledRangeInputBoxProps {
|
|
9
|
+
$isFocused: boolean;
|
|
10
|
+
$isDisabled: boolean;
|
|
11
|
+
$error: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const StyledRangeInputBox: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledRangeInputBoxProps>> & string;
|
|
14
|
+
export declare const StyledRangeInput: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, never>> & string;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface TimePickerRangeInputProps {
|
|
3
|
+
startValue: string;
|
|
4
|
+
endValue: string;
|
|
5
|
+
onStartChange: (value: string) => void;
|
|
6
|
+
onEndChange: (value: string) => void;
|
|
7
|
+
onStartFocus: () => void;
|
|
8
|
+
onEndFocus: () => void;
|
|
9
|
+
onStartBlur?: () => void;
|
|
10
|
+
onEndBlur?: () => void;
|
|
11
|
+
onStartEnterPress?: () => void;
|
|
12
|
+
onEndEnterPress?: () => void;
|
|
13
|
+
onClear?: () => void;
|
|
14
|
+
hasValue?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
error?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface TimePickerRangeInputHandle {
|
|
19
|
+
focusStart: () => void;
|
|
20
|
+
focusEnd: () => void;
|
|
21
|
+
blurStart: () => void;
|
|
22
|
+
blurEnd: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare const TimePickerRangeInput: React.ForwardRefExoticComponent<TimePickerRangeInputProps & React.RefAttributes<TimePickerRangeInputHandle>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TimeFormat, TimePickerSize } from './types';
|
|
2
|
+
export declare const DEFAULT_SIZE: TimePickerSize;
|
|
3
|
+
export declare const DEFAULT_FORMAT: TimeFormat;
|
|
4
|
+
export declare const DEFAULT_MINUTE_STEP = 1;
|
|
5
|
+
export declare const DEFAULT_PLACEHOLDER = "Select time";
|
|
6
|
+
export declare const DEFAULT_START_LABEL = "Start time";
|
|
7
|
+
export declare const DEFAULT_END_LABEL = "End time";
|
|
8
|
+
export declare const MASK_24H = "HH:mm";
|
|
9
|
+
export declare const MASK_12H = "hh:mm AA";
|
|
10
|
+
export declare const HOURS_24: string[];
|
|
11
|
+
export declare const HOURS_12: string[];
|
|
12
|
+
export declare const PERIODS: string[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TimeFormat, TimeValue } from './types';
|
|
2
|
+
interface UseTimePickerStateProps {
|
|
3
|
+
value?: TimeValue | null;
|
|
4
|
+
onChange?: (value: TimeValue | null) => void;
|
|
5
|
+
format: TimeFormat;
|
|
6
|
+
minuteStep?: number;
|
|
7
|
+
slots?: TimeValue[];
|
|
8
|
+
}
|
|
9
|
+
interface UseTimePickerStateReturn {
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
setIsOpen: (open: boolean) => void;
|
|
12
|
+
inputValue: string;
|
|
13
|
+
setInputValue: (value: string) => void;
|
|
14
|
+
editingValue: TimeValue | null;
|
|
15
|
+
setEditingValue: (value: TimeValue | null) => void;
|
|
16
|
+
handleOpen: () => void;
|
|
17
|
+
handleClose: () => void;
|
|
18
|
+
handleClear: () => void;
|
|
19
|
+
handleInputChange: (inputText: string) => void;
|
|
20
|
+
handleWheelChange: (time: TimeValue) => void;
|
|
21
|
+
handleInputBlur: () => void;
|
|
22
|
+
handleEnterPress: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function useTimePickerState({ value, onChange, format, minuteStep, slots, }: UseTimePickerStateProps): UseTimePickerStateReturn;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { TimePickerProps, TimePickerHandle } from './types';
|
|
2
|
+
export declare const TimePicker: import('react').ForwardRefExoticComponent<TimePickerProps & import('react').RefAttributes<TimePickerHandle>>;
|
|
3
|
+
export type { TimePickerProps, TimePickerHandle, TimeValue } from './types';
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { TimePickerSize, TimeFormat } from '../../theme/components/timepicker';
|
|
2
|
+
import { BoxProps } from '../Box';
|
|
3
|
+
export type { TimePickerSize, TimeFormat };
|
|
4
|
+
/**
|
|
5
|
+
* Represents a time value with hours and minutes
|
|
6
|
+
*/
|
|
7
|
+
export interface TimeValue {
|
|
8
|
+
/** Hours (0-23 for 24h format, 1-12 for 12h format internally stored as 0-23) */
|
|
9
|
+
hours: number;
|
|
10
|
+
/** Minutes (0-59) */
|
|
11
|
+
minutes: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Props for the main TimePicker component
|
|
15
|
+
*/
|
|
16
|
+
export interface TimePickerProps extends Omit<BoxProps, 'onChange'> {
|
|
17
|
+
/**
|
|
18
|
+
* Current time value (single mode)
|
|
19
|
+
*/
|
|
20
|
+
value?: TimeValue | null;
|
|
21
|
+
/**
|
|
22
|
+
* Callback when time changes (single mode)
|
|
23
|
+
*/
|
|
24
|
+
onChange?: (value: TimeValue | null) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Enable range mode (two time inputs: start and end)
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
range?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Start time value (range mode)
|
|
32
|
+
*/
|
|
33
|
+
startValue?: TimeValue | null;
|
|
34
|
+
/**
|
|
35
|
+
* End time value (range mode)
|
|
36
|
+
*/
|
|
37
|
+
endValue?: TimeValue | null;
|
|
38
|
+
/**
|
|
39
|
+
* Callback when start time changes (range mode)
|
|
40
|
+
*/
|
|
41
|
+
onStartChange?: (value: TimeValue | null) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Callback when end time changes (range mode)
|
|
44
|
+
*/
|
|
45
|
+
onEndChange?: (value: TimeValue | null) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Time display format
|
|
48
|
+
* @default '24h'
|
|
49
|
+
*/
|
|
50
|
+
format?: TimeFormat;
|
|
51
|
+
/**
|
|
52
|
+
* Minute step for the wheel picker
|
|
53
|
+
* @default 1
|
|
54
|
+
*/
|
|
55
|
+
minuteStep?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Predefined time slots to choose from.
|
|
58
|
+
* When provided, shows a single wheel with these slots instead of hour/minute wheels.
|
|
59
|
+
* Example: [{ hours: 9, minutes: 0 }, { hours: 12, minutes: 30 }, { hours: 18, minutes: 0 }]
|
|
60
|
+
*/
|
|
61
|
+
slots?: TimeValue[];
|
|
62
|
+
/**
|
|
63
|
+
* Size variant
|
|
64
|
+
* @default 'md'
|
|
65
|
+
*/
|
|
66
|
+
size?: TimePickerSize;
|
|
67
|
+
/**
|
|
68
|
+
* Whether the picker is disabled
|
|
69
|
+
* @default false
|
|
70
|
+
*/
|
|
71
|
+
disabled?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Label text
|
|
74
|
+
*/
|
|
75
|
+
label?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Helper text below the input
|
|
78
|
+
*/
|
|
79
|
+
helperText?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Error message (takes precedence over helperText)
|
|
82
|
+
*/
|
|
83
|
+
error?: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Props for TimePickerInput sub-component
|
|
87
|
+
*/
|
|
88
|
+
export interface TimePickerInputProps {
|
|
89
|
+
/** Current display value */
|
|
90
|
+
value: string;
|
|
91
|
+
/** Callback when input value changes */
|
|
92
|
+
onChange: (value: string) => void;
|
|
93
|
+
/** Callback when input is focused */
|
|
94
|
+
onFocus: () => void;
|
|
95
|
+
/** Callback when input loses focus */
|
|
96
|
+
onBlur?: () => void;
|
|
97
|
+
/** Callback when Enter key is pressed */
|
|
98
|
+
onEnterPress?: () => void;
|
|
99
|
+
/** Callback when clear button is clicked */
|
|
100
|
+
onClear?: () => void;
|
|
101
|
+
/** Label text */
|
|
102
|
+
label?: string;
|
|
103
|
+
/** Helper text */
|
|
104
|
+
helperText?: string;
|
|
105
|
+
/** Error message */
|
|
106
|
+
error?: string;
|
|
107
|
+
/** Whether input is disabled */
|
|
108
|
+
disabled?: boolean;
|
|
109
|
+
/** Whether the input has a value (show clear button) */
|
|
110
|
+
hasValue: boolean;
|
|
111
|
+
/** Placeholder text */
|
|
112
|
+
placeholder?: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Props for TimePickerPopup sub-component
|
|
116
|
+
*/
|
|
117
|
+
export interface TimePickerPopupProps {
|
|
118
|
+
/** Whether popup is open */
|
|
119
|
+
isOpen: boolean;
|
|
120
|
+
/** Anchor element ref */
|
|
121
|
+
anchorRef: React.RefObject<HTMLDivElement | null>;
|
|
122
|
+
/** Close handler */
|
|
123
|
+
onClose: () => void;
|
|
124
|
+
/** Popup content */
|
|
125
|
+
children: React.ReactNode;
|
|
126
|
+
/** Size variant */
|
|
127
|
+
size: TimePickerSize;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Props for TimePickerWheel sub-component
|
|
131
|
+
*/
|
|
132
|
+
export interface TimePickerWheelProps {
|
|
133
|
+
/** Array of values to display */
|
|
134
|
+
items: string[];
|
|
135
|
+
/** Currently selected value */
|
|
136
|
+
selectedValue: string;
|
|
137
|
+
/** Callback when value is selected */
|
|
138
|
+
onSelect: (value: string) => void;
|
|
139
|
+
/** Size variant */
|
|
140
|
+
size: TimePickerSize;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Props for TimePickerWheels container
|
|
144
|
+
*/
|
|
145
|
+
export interface TimePickerWheelsProps {
|
|
146
|
+
/** Current time value */
|
|
147
|
+
value: TimeValue | null;
|
|
148
|
+
/** Callback when time changes */
|
|
149
|
+
onChange: (value: TimeValue) => void;
|
|
150
|
+
/** Time format */
|
|
151
|
+
format: TimeFormat;
|
|
152
|
+
/** Minute step */
|
|
153
|
+
minuteStep: number;
|
|
154
|
+
/** Size variant */
|
|
155
|
+
size: TimePickerSize;
|
|
156
|
+
/** Predefined time slots (shows single wheel when provided) */
|
|
157
|
+
slots?: TimeValue[];
|
|
158
|
+
/** Marker value to show (the other time in range mode) */
|
|
159
|
+
markerValue?: TimeValue | null;
|
|
160
|
+
/** Label for marker (e.g., "Start:" or "End:") */
|
|
161
|
+
markerLabel?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Handle for imperative API access
|
|
165
|
+
*/
|
|
166
|
+
export interface TimePickerHandle {
|
|
167
|
+
/** Open the picker popup */
|
|
168
|
+
open: () => void;
|
|
169
|
+
/** Close the picker popup */
|
|
170
|
+
close: () => void;
|
|
171
|
+
/** Reset to initial value */
|
|
172
|
+
reset: () => void;
|
|
173
|
+
/** Get current value */
|
|
174
|
+
getValue: () => TimeValue | null;
|
|
175
|
+
/** Focus the input */
|
|
176
|
+
focus: () => void;
|
|
177
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { TimeFormat, TimeValue } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Generate minutes array based on step
|
|
4
|
+
*/
|
|
5
|
+
export declare function generateMinutes(step: number): string[];
|
|
6
|
+
/**
|
|
7
|
+
* Convert 24h hours to 12h format
|
|
8
|
+
*/
|
|
9
|
+
export declare function to12Hour(hours24: number): {
|
|
10
|
+
hours: number;
|
|
11
|
+
period: 'AM' | 'PM';
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Convert 12h format to 24h hours
|
|
15
|
+
*/
|
|
16
|
+
export declare function to24Hour(hours12: number, period: 'AM' | 'PM'): number;
|
|
17
|
+
/**
|
|
18
|
+
* Format TimeValue to display string
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatTime(value: TimeValue | null, format: TimeFormat): string;
|
|
21
|
+
/**
|
|
22
|
+
* Parse display string to TimeValue
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseTime(input: string, format: TimeFormat): TimeValue | null;
|
|
25
|
+
/**
|
|
26
|
+
* Check if a string is a valid time input
|
|
27
|
+
*/
|
|
28
|
+
export declare function isValidTimeInput(input: string, format: TimeFormat): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Get the mask pattern for input
|
|
31
|
+
*/
|
|
32
|
+
export declare function getMask(format: TimeFormat): string;
|
|
33
|
+
/**
|
|
34
|
+
* Check if character at position is a mask placeholder
|
|
35
|
+
*/
|
|
36
|
+
export declare function isMaskPlaceholder(char: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Apply typed digits to mask
|
|
39
|
+
*/
|
|
40
|
+
export declare function applyInputToMask(digits: string, mask: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Snap minutes to nearest step
|
|
43
|
+
*/
|
|
44
|
+
export declare function snapToStep(minutes: number, step: number): number;
|
|
45
|
+
/**
|
|
46
|
+
* Create TimeValue with snapped minutes
|
|
47
|
+
*/
|
|
48
|
+
export declare function createTimeValue(hours: number, minutes: number, minuteStep: number): TimeValue;
|
|
49
|
+
/**
|
|
50
|
+
* Format a slot (TimeValue) to display string for wheel
|
|
51
|
+
*/
|
|
52
|
+
export declare function formatSlot(slot: TimeValue, format: TimeFormat): string;
|
|
53
|
+
/**
|
|
54
|
+
* Check if two TimeValue are equal
|
|
55
|
+
*/
|
|
56
|
+
export declare function isTimeEqual(a: TimeValue | null, b: TimeValue | null): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Convert TimeValue to minutes from midnight for comparison
|
|
59
|
+
*/
|
|
60
|
+
export declare function timeValueToMinutes(time: TimeValue): number;
|
|
61
|
+
/**
|
|
62
|
+
* Compare two TimeValues
|
|
63
|
+
* Returns:
|
|
64
|
+
* -1 if a < b
|
|
65
|
+
* 0 if a === b
|
|
66
|
+
* 1 if a > b
|
|
67
|
+
* null if either value is null/undefined (incomparable)
|
|
68
|
+
*/
|
|
69
|
+
export declare function compareTimeValues(a: TimeValue | null | undefined, b: TimeValue | null | undefined): -1 | 0 | 1 | null;
|
|
70
|
+
/**
|
|
71
|
+
* Find index of slot in slots array
|
|
72
|
+
*/
|
|
73
|
+
export declare function findSlotIndex(slots: TimeValue[], value: TimeValue | null): number;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface UsePopupPositionProps<TAnchor extends HTMLElement = HTMLElement, TPopup extends HTMLElement = HTMLElement> {
|
|
2
|
+
anchorRef: React.RefObject<TAnchor | null>;
|
|
3
|
+
popupRef: React.RefObject<TPopup | null>;
|
|
4
|
+
offsetValue: number;
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Hook to calculate and update popup position relative to anchor element
|
|
9
|
+
* Position is calculated relative to container (using position: absolute)
|
|
10
|
+
* Automatically handles initial positioning and resize events
|
|
11
|
+
*/
|
|
12
|
+
export declare function usePopupPosition<TAnchor extends HTMLElement = HTMLElement, TPopup extends HTMLElement = HTMLElement>({ anchorRef, popupRef, offsetValue, isOpen, }: UsePopupPositionProps<TAnchor, TPopup>): void;
|
|
13
|
+
export {};
|