@velocis/timepicker1 0.2.0

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.
@@ -0,0 +1,193 @@
1
+ import * as react from 'react';
2
+ import { RefObject, CSSProperties } from 'react';
3
+ import * as class_variance_authority_types from 'class-variance-authority/types';
4
+
5
+ /**
6
+ * Rules for times that cannot be selected.
7
+ */
8
+ type TimePicker1DisabledRule =
9
+ /** وقت محدد */
10
+ {
11
+ type: 'time';
12
+ time: TimeValue;
13
+ }
14
+ /** عدة أوقات محددة */
15
+ | {
16
+ type: 'times';
17
+ times: TimeValue[];
18
+ }
19
+ /** ساعة معينة في كل يوم */
20
+ | {
21
+ type: 'hour';
22
+ hour: number;
23
+ }
24
+ /** دقيقة معينة في كل ساعة (مثلاً :30) */
25
+ | {
26
+ type: 'minute';
27
+ minute: number;
28
+ }
29
+ /** ساعة ودقيقة محددتان */
30
+ | {
31
+ type: 'hourMinute';
32
+ hour: number;
33
+ minute: number;
34
+ }
35
+ /** قاعدة مخصصة */
36
+ | {
37
+ type: 'custom';
38
+ match: (time: TimeValue) => boolean;
39
+ };
40
+ type TimePicker1TimeConstraints = {
41
+ minTime?: TimeValue;
42
+ maxTime?: TimeValue;
43
+ disabledRules?: TimePicker1DisabledRule[];
44
+ };
45
+ declare function isTimeRuleDisabled(time: TimeValue, rule: TimePicker1DisabledRule): boolean;
46
+ declare function isTimeDisabledByRules(time: TimeValue, rules: TimePicker1DisabledRule[] | undefined): boolean;
47
+ declare function isTimePickerTimeDisabled(time: TimeValue, constraints?: TimePicker1TimeConstraints): boolean;
48
+
49
+ type TimeValue = {
50
+ hours: number;
51
+ minutes: number;
52
+ };
53
+ type TimePicker1Colors = {
54
+ /** Main panel background */
55
+ panelBgColor?: string;
56
+ /** Active hour/minute item background */
57
+ activeItemColor?: string;
58
+ /** Scrollbar thumb color (Firefox + WebKit) */
59
+ scrollbarThumbColor?: string;
60
+ /** Scrollbar width in px (default 2) */
61
+ scrollbarWidth?: number;
62
+ };
63
+ type TimePicker1Props = {
64
+ trigger?: React.ReactNode;
65
+ value?: TimeValue | null;
66
+ defaultValue?: TimeValue | null;
67
+ onChange?: (time: TimeValue) => void;
68
+ open?: boolean;
69
+ defaultOpen?: boolean;
70
+ onOpenChange?: (open: boolean) => void;
71
+ colors?: TimePicker1Colors;
72
+ locale?: string;
73
+ use24Hour?: boolean;
74
+ /** Interval between slots in minutes (default 15) */
75
+ minuteStep?: number;
76
+ /** How many slots to show in the list */
77
+ slotCount?: number;
78
+ /** Start list from the next slot after the user's current time */
79
+ startFromNow?: boolean;
80
+ /** أقرب وقت يمكن اختياره */
81
+ minTime?: TimeValue;
82
+ /** آخر وقت يمكن اختياره */
83
+ maxTime?: TimeValue;
84
+ /**
85
+ * أوقات ممنوعة — انظر `TimePicker1DisabledRule`
86
+ * @example
87
+ * disabledRules={[
88
+ * { type: 'hourMinute', hour: 12, minute: 0 },
89
+ * { type: 'minute', minute: 30 },
90
+ * ]}
91
+ */
92
+ disabledRules?: TimePicker1DisabledRule[];
93
+ /** Fixed height of the scrollable time list (px number or CSS length) */
94
+ listHeight?: string | number;
95
+ listClassName?: string;
96
+ triggerClassName?: string;
97
+ contentClassName?: string;
98
+ contentWidth?: string;
99
+ fullWidth?: boolean;
100
+ disabled?: boolean;
101
+ closeOnSelect?: boolean;
102
+ closeOnScroll?: boolean;
103
+ contentZIndex?: number | string;
104
+ testId?: string;
105
+ contentTestId?: string;
106
+ };
107
+
108
+ declare function TimePicker1Root({ trigger, value: controlledValue, defaultValue, onChange, open: controlledOpen, defaultOpen, onOpenChange, colors, locale: localeProp, use24Hour, minuteStep, slotCount, startFromNow, minTime, maxTime, disabledRules, listHeight, listClassName, triggerClassName, contentClassName, contentWidth, fullWidth, disabled, closeOnSelect, closeOnScroll, contentZIndex, testId, contentTestId, }: TimePicker1Props): react.JSX.Element;
109
+
110
+ declare const TIMEPICKER1_DEFAULTS: {
111
+ readonly contentWidth: "w-40";
112
+ readonly contentZIndex: 9999;
113
+ readonly closeOnScroll: true;
114
+ readonly fullWidth: false;
115
+ readonly disabled: false;
116
+ readonly defaultOpen: false;
117
+ readonly closeOnSelect: true;
118
+ readonly minuteStep: 15;
119
+ readonly use24Hour: false;
120
+ readonly slotCount: 48;
121
+ readonly startFromNow: true;
122
+ readonly listHeight: 280;
123
+ };
124
+ declare const TIMEPICKER1_DEFAULT_COLORS: {
125
+ readonly panelBgColor: "#141414";
126
+ readonly activeItemColor: "#FF6B3D";
127
+ readonly scrollbarThumbColor: "rgba(255, 255, 255, 0.18)";
128
+ readonly scrollbarWidth: 2;
129
+ };
130
+
131
+ type UseTimePicker1Options = Partial<Pick<TimePicker1Props, 'value' | 'defaultValue' | 'onChange' | 'open' | 'defaultOpen' | 'onOpenChange' | 'colors' | 'locale' | 'use24Hour' | 'minuteStep' | 'slotCount' | 'startFromNow' | 'minTime' | 'maxTime' | 'disabledRules' | 'listHeight' | 'listClassName' | 'closeOnSelect' | 'contentWidth' | 'fullWidth'>>;
132
+ type UseTimePicker1Result = {
133
+ value: TimeValue | null;
134
+ setValue: (time: TimeValue) => void;
135
+ open: boolean;
136
+ setOpen: (open: boolean) => void;
137
+ show: () => void;
138
+ hide: () => void;
139
+ anchorRef: RefObject<HTMLButtonElement | null>;
140
+ timePickerProps: Pick<TimePicker1Props, 'value' | 'onChange' | 'open' | 'onOpenChange' | 'colors' | 'locale' | 'use24Hour' | 'minuteStep' | 'slotCount' | 'startFromNow' | 'minTime' | 'maxTime' | 'disabledRules' | 'listHeight' | 'listClassName' | 'closeOnSelect' | 'contentWidth' | 'fullWidth'>;
141
+ };
142
+ declare function useTimePicker1(options?: UseTimePicker1Options): UseTimePicker1Result;
143
+
144
+ type TimePickerPanelProps = {
145
+ value: TimeValue | null;
146
+ colors: TimePicker1Colors;
147
+ locale: string;
148
+ use24Hour: boolean;
149
+ minuteStep: number;
150
+ slotCount: number;
151
+ startFromNow: boolean;
152
+ isOpen: boolean;
153
+ minTime?: TimeValue;
154
+ maxTime?: TimeValue;
155
+ disabledRules?: TimePicker1DisabledRule[];
156
+ listHeight: string | number;
157
+ listClassName?: string;
158
+ onChange: (time: TimeValue) => void;
159
+ className?: string;
160
+ };
161
+ declare function TimePickerPanel({ value, colors, locale, use24Hour, minuteStep, slotCount, startFromNow, isOpen, minTime, maxTime, disabledRules, listHeight, listClassName, onChange, className, }: TimePickerPanelProps): react.JSX.Element;
162
+
163
+ declare const timePicker1TriggerVariants: (props?: ({
164
+ fullWidth?: boolean | null | undefined;
165
+ disabled?: boolean | null | undefined;
166
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
167
+ declare const timePicker1ContentVariants: (props?: class_variance_authority_types.ClassProp | undefined) => string;
168
+ declare const timePicker1ItemVariants: (props?: class_variance_authority_types.ClassProp | undefined) => string;
169
+
170
+ declare function isTimeInRange(time: TimeValue, minTime?: TimeValue, maxTime?: TimeValue): boolean;
171
+ /** Next step slot strictly after the user's current time (e.g. 6:04 → 6:15). */
172
+ declare function getNextSlotAfterNow(step?: number): TimeValue;
173
+ declare function generateBoundedTimeSlots(options: {
174
+ startFromNow: boolean;
175
+ minTime?: TimeValue;
176
+ maxTime?: TimeValue;
177
+ disabledRules?: TimePicker1DisabledRule[];
178
+ minuteStep: number;
179
+ slotCount: number;
180
+ }): TimeValue[];
181
+ /** Format like `4:00 م` (Arabic) or `4:00 PM` (English). */
182
+ declare function formatTimeSlot(time: TimeValue | null | undefined, locale: string, use24Hour: boolean): string;
183
+ declare function clampTimeToRange(time: TimeValue, minTime?: TimeValue, maxTime?: TimeValue): TimeValue;
184
+
185
+ declare const TIMEPICKER1_SCROLLBAR_WIDTH_PX = 2;
186
+ /** Class hook for the injected ultra-thin scrollbar styles */
187
+ declare const timepicker1ListScrollbarStyles = "velocis-timepicker1-scroll";
188
+ declare function resolveListHeight(height: string | number): string;
189
+ declare function resolveScrollbarStyle(colors?: Pick<TimePicker1Colors, 'scrollbarThumbColor' | 'scrollbarWidth'>): CSSProperties;
190
+
191
+ declare const TimePicker1: typeof TimePicker1Root;
192
+
193
+ export { TIMEPICKER1_DEFAULTS, TIMEPICKER1_DEFAULT_COLORS, TIMEPICKER1_SCROLLBAR_WIDTH_PX, TimePicker1, type TimePicker1Colors, type TimePicker1DisabledRule, type TimePicker1Props, TimePicker1Root, type TimePicker1TimeConstraints, TimePickerPanel, type TimeValue, type UseTimePicker1Options, type UseTimePicker1Result, clampTimeToRange, formatTimeSlot, generateBoundedTimeSlots, getNextSlotAfterNow, isTimeDisabledByRules, isTimeInRange, isTimePickerTimeDisabled, isTimeRuleDisabled, resolveListHeight, resolveScrollbarStyle, timePicker1ContentVariants, timePicker1ItemVariants, timePicker1TriggerVariants, timepicker1ListScrollbarStyles, useTimePicker1 };
@@ -0,0 +1,193 @@
1
+ import * as react from 'react';
2
+ import { RefObject, CSSProperties } from 'react';
3
+ import * as class_variance_authority_types from 'class-variance-authority/types';
4
+
5
+ /**
6
+ * Rules for times that cannot be selected.
7
+ */
8
+ type TimePicker1DisabledRule =
9
+ /** وقت محدد */
10
+ {
11
+ type: 'time';
12
+ time: TimeValue;
13
+ }
14
+ /** عدة أوقات محددة */
15
+ | {
16
+ type: 'times';
17
+ times: TimeValue[];
18
+ }
19
+ /** ساعة معينة في كل يوم */
20
+ | {
21
+ type: 'hour';
22
+ hour: number;
23
+ }
24
+ /** دقيقة معينة في كل ساعة (مثلاً :30) */
25
+ | {
26
+ type: 'minute';
27
+ minute: number;
28
+ }
29
+ /** ساعة ودقيقة محددتان */
30
+ | {
31
+ type: 'hourMinute';
32
+ hour: number;
33
+ minute: number;
34
+ }
35
+ /** قاعدة مخصصة */
36
+ | {
37
+ type: 'custom';
38
+ match: (time: TimeValue) => boolean;
39
+ };
40
+ type TimePicker1TimeConstraints = {
41
+ minTime?: TimeValue;
42
+ maxTime?: TimeValue;
43
+ disabledRules?: TimePicker1DisabledRule[];
44
+ };
45
+ declare function isTimeRuleDisabled(time: TimeValue, rule: TimePicker1DisabledRule): boolean;
46
+ declare function isTimeDisabledByRules(time: TimeValue, rules: TimePicker1DisabledRule[] | undefined): boolean;
47
+ declare function isTimePickerTimeDisabled(time: TimeValue, constraints?: TimePicker1TimeConstraints): boolean;
48
+
49
+ type TimeValue = {
50
+ hours: number;
51
+ minutes: number;
52
+ };
53
+ type TimePicker1Colors = {
54
+ /** Main panel background */
55
+ panelBgColor?: string;
56
+ /** Active hour/minute item background */
57
+ activeItemColor?: string;
58
+ /** Scrollbar thumb color (Firefox + WebKit) */
59
+ scrollbarThumbColor?: string;
60
+ /** Scrollbar width in px (default 2) */
61
+ scrollbarWidth?: number;
62
+ };
63
+ type TimePicker1Props = {
64
+ trigger?: React.ReactNode;
65
+ value?: TimeValue | null;
66
+ defaultValue?: TimeValue | null;
67
+ onChange?: (time: TimeValue) => void;
68
+ open?: boolean;
69
+ defaultOpen?: boolean;
70
+ onOpenChange?: (open: boolean) => void;
71
+ colors?: TimePicker1Colors;
72
+ locale?: string;
73
+ use24Hour?: boolean;
74
+ /** Interval between slots in minutes (default 15) */
75
+ minuteStep?: number;
76
+ /** How many slots to show in the list */
77
+ slotCount?: number;
78
+ /** Start list from the next slot after the user's current time */
79
+ startFromNow?: boolean;
80
+ /** أقرب وقت يمكن اختياره */
81
+ minTime?: TimeValue;
82
+ /** آخر وقت يمكن اختياره */
83
+ maxTime?: TimeValue;
84
+ /**
85
+ * أوقات ممنوعة — انظر `TimePicker1DisabledRule`
86
+ * @example
87
+ * disabledRules={[
88
+ * { type: 'hourMinute', hour: 12, minute: 0 },
89
+ * { type: 'minute', minute: 30 },
90
+ * ]}
91
+ */
92
+ disabledRules?: TimePicker1DisabledRule[];
93
+ /** Fixed height of the scrollable time list (px number or CSS length) */
94
+ listHeight?: string | number;
95
+ listClassName?: string;
96
+ triggerClassName?: string;
97
+ contentClassName?: string;
98
+ contentWidth?: string;
99
+ fullWidth?: boolean;
100
+ disabled?: boolean;
101
+ closeOnSelect?: boolean;
102
+ closeOnScroll?: boolean;
103
+ contentZIndex?: number | string;
104
+ testId?: string;
105
+ contentTestId?: string;
106
+ };
107
+
108
+ declare function TimePicker1Root({ trigger, value: controlledValue, defaultValue, onChange, open: controlledOpen, defaultOpen, onOpenChange, colors, locale: localeProp, use24Hour, minuteStep, slotCount, startFromNow, minTime, maxTime, disabledRules, listHeight, listClassName, triggerClassName, contentClassName, contentWidth, fullWidth, disabled, closeOnSelect, closeOnScroll, contentZIndex, testId, contentTestId, }: TimePicker1Props): react.JSX.Element;
109
+
110
+ declare const TIMEPICKER1_DEFAULTS: {
111
+ readonly contentWidth: "w-40";
112
+ readonly contentZIndex: 9999;
113
+ readonly closeOnScroll: true;
114
+ readonly fullWidth: false;
115
+ readonly disabled: false;
116
+ readonly defaultOpen: false;
117
+ readonly closeOnSelect: true;
118
+ readonly minuteStep: 15;
119
+ readonly use24Hour: false;
120
+ readonly slotCount: 48;
121
+ readonly startFromNow: true;
122
+ readonly listHeight: 280;
123
+ };
124
+ declare const TIMEPICKER1_DEFAULT_COLORS: {
125
+ readonly panelBgColor: "#141414";
126
+ readonly activeItemColor: "#FF6B3D";
127
+ readonly scrollbarThumbColor: "rgba(255, 255, 255, 0.18)";
128
+ readonly scrollbarWidth: 2;
129
+ };
130
+
131
+ type UseTimePicker1Options = Partial<Pick<TimePicker1Props, 'value' | 'defaultValue' | 'onChange' | 'open' | 'defaultOpen' | 'onOpenChange' | 'colors' | 'locale' | 'use24Hour' | 'minuteStep' | 'slotCount' | 'startFromNow' | 'minTime' | 'maxTime' | 'disabledRules' | 'listHeight' | 'listClassName' | 'closeOnSelect' | 'contentWidth' | 'fullWidth'>>;
132
+ type UseTimePicker1Result = {
133
+ value: TimeValue | null;
134
+ setValue: (time: TimeValue) => void;
135
+ open: boolean;
136
+ setOpen: (open: boolean) => void;
137
+ show: () => void;
138
+ hide: () => void;
139
+ anchorRef: RefObject<HTMLButtonElement | null>;
140
+ timePickerProps: Pick<TimePicker1Props, 'value' | 'onChange' | 'open' | 'onOpenChange' | 'colors' | 'locale' | 'use24Hour' | 'minuteStep' | 'slotCount' | 'startFromNow' | 'minTime' | 'maxTime' | 'disabledRules' | 'listHeight' | 'listClassName' | 'closeOnSelect' | 'contentWidth' | 'fullWidth'>;
141
+ };
142
+ declare function useTimePicker1(options?: UseTimePicker1Options): UseTimePicker1Result;
143
+
144
+ type TimePickerPanelProps = {
145
+ value: TimeValue | null;
146
+ colors: TimePicker1Colors;
147
+ locale: string;
148
+ use24Hour: boolean;
149
+ minuteStep: number;
150
+ slotCount: number;
151
+ startFromNow: boolean;
152
+ isOpen: boolean;
153
+ minTime?: TimeValue;
154
+ maxTime?: TimeValue;
155
+ disabledRules?: TimePicker1DisabledRule[];
156
+ listHeight: string | number;
157
+ listClassName?: string;
158
+ onChange: (time: TimeValue) => void;
159
+ className?: string;
160
+ };
161
+ declare function TimePickerPanel({ value, colors, locale, use24Hour, minuteStep, slotCount, startFromNow, isOpen, minTime, maxTime, disabledRules, listHeight, listClassName, onChange, className, }: TimePickerPanelProps): react.JSX.Element;
162
+
163
+ declare const timePicker1TriggerVariants: (props?: ({
164
+ fullWidth?: boolean | null | undefined;
165
+ disabled?: boolean | null | undefined;
166
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
167
+ declare const timePicker1ContentVariants: (props?: class_variance_authority_types.ClassProp | undefined) => string;
168
+ declare const timePicker1ItemVariants: (props?: class_variance_authority_types.ClassProp | undefined) => string;
169
+
170
+ declare function isTimeInRange(time: TimeValue, minTime?: TimeValue, maxTime?: TimeValue): boolean;
171
+ /** Next step slot strictly after the user's current time (e.g. 6:04 → 6:15). */
172
+ declare function getNextSlotAfterNow(step?: number): TimeValue;
173
+ declare function generateBoundedTimeSlots(options: {
174
+ startFromNow: boolean;
175
+ minTime?: TimeValue;
176
+ maxTime?: TimeValue;
177
+ disabledRules?: TimePicker1DisabledRule[];
178
+ minuteStep: number;
179
+ slotCount: number;
180
+ }): TimeValue[];
181
+ /** Format like `4:00 م` (Arabic) or `4:00 PM` (English). */
182
+ declare function formatTimeSlot(time: TimeValue | null | undefined, locale: string, use24Hour: boolean): string;
183
+ declare function clampTimeToRange(time: TimeValue, minTime?: TimeValue, maxTime?: TimeValue): TimeValue;
184
+
185
+ declare const TIMEPICKER1_SCROLLBAR_WIDTH_PX = 2;
186
+ /** Class hook for the injected ultra-thin scrollbar styles */
187
+ declare const timepicker1ListScrollbarStyles = "velocis-timepicker1-scroll";
188
+ declare function resolveListHeight(height: string | number): string;
189
+ declare function resolveScrollbarStyle(colors?: Pick<TimePicker1Colors, 'scrollbarThumbColor' | 'scrollbarWidth'>): CSSProperties;
190
+
191
+ declare const TimePicker1: typeof TimePicker1Root;
192
+
193
+ export { TIMEPICKER1_DEFAULTS, TIMEPICKER1_DEFAULT_COLORS, TIMEPICKER1_SCROLLBAR_WIDTH_PX, TimePicker1, type TimePicker1Colors, type TimePicker1DisabledRule, type TimePicker1Props, TimePicker1Root, type TimePicker1TimeConstraints, TimePickerPanel, type TimeValue, type UseTimePicker1Options, type UseTimePicker1Result, clampTimeToRange, formatTimeSlot, generateBoundedTimeSlots, getNextSlotAfterNow, isTimeDisabledByRules, isTimeInRange, isTimePickerTimeDisabled, isTimeRuleDisabled, resolveListHeight, resolveScrollbarStyle, timePicker1ContentVariants, timePicker1ItemVariants, timePicker1TriggerVariants, timepicker1ListScrollbarStyles, useTimePicker1 };