@refraktor/dates 0.0.3 → 0.0.5
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/build/components/date-range-picker/date-range-picker.d.ts +4 -0
- package/build/components/date-range-picker/date-range-picker.d.ts.map +1 -0
- package/build/components/date-range-picker/date-range-picker.js +379 -0
- package/build/components/date-range-picker/date-range-picker.types.d.ts +100 -0
- package/build/components/date-range-picker/date-range-picker.types.d.ts.map +1 -0
- package/build/components/date-range-picker/date-range-picker.types.js +1 -0
- package/build/components/date-range-picker/index.d.ts +3 -0
- package/build/components/date-range-picker/index.d.ts.map +1 -0
- package/build/components/date-range-picker/index.js +1 -0
- package/build/components/time-input/index.d.ts +1 -1
- package/build/components/time-input/index.d.ts.map +1 -1
- package/build/components/time-input/time-input.d.ts.map +1 -1
- package/build/components/time-input/time-input.js +7 -196
- package/build/components/time-input/time-input.types.d.ts +5 -83
- package/build/components/time-input/time-input.types.d.ts.map +1 -1
- package/build/components/time-picker/index.d.ts +1 -1
- package/build/components/time-picker/index.d.ts.map +1 -1
- package/build/components/time-picker/time-picker.d.ts.map +1 -1
- package/build/components/time-picker/time-picker.js +498 -350
- package/build/components/time-picker/time-picker.types.d.ts +96 -61
- package/build/components/time-picker/time-picker.types.d.ts.map +1 -1
- package/build/style.css +2 -2
- package/package.json +33 -4
- package/.turbo/turbo-build.log +0 -4
- package/refraktor-dates-0.0.1-alpha.0.tgz +0 -0
- package/src/components/date-input/date-input.tsx +0 -379
- package/src/components/date-input/date-input.types.ts +0 -161
- package/src/components/date-input/index.ts +0 -13
- package/src/components/date-picker/date-picker.tsx +0 -649
- package/src/components/date-picker/date-picker.types.ts +0 -145
- package/src/components/date-picker/index.ts +0 -15
- package/src/components/dates-provider/context.ts +0 -18
- package/src/components/dates-provider/dates-provider.tsx +0 -136
- package/src/components/dates-provider/index.ts +0 -10
- package/src/components/dates-provider/types.ts +0 -33
- package/src/components/dates-provider/use-dates.ts +0 -5
- package/src/components/index.ts +0 -9
- package/src/components/month-input/index.ts +0 -13
- package/src/components/month-input/month-input.tsx +0 -366
- package/src/components/month-input/month-input.types.ts +0 -139
- package/src/components/month-picker/index.ts +0 -14
- package/src/components/month-picker/month-picker.tsx +0 -458
- package/src/components/month-picker/month-picker.types.ts +0 -117
- package/src/components/picker-shared/index.ts +0 -7
- package/src/components/picker-shared/picker-header.tsx +0 -178
- package/src/components/picker-shared/picker-header.types.ts +0 -49
- package/src/components/picker-shared/picker.styles.ts +0 -69
- package/src/components/picker-shared/picker.types.ts +0 -4
- package/src/components/time-input/index.ts +0 -23
- package/src/components/time-input/time-input.tsx +0 -453
- package/src/components/time-input/time-input.types.ts +0 -163
- package/src/components/time-picker/index.ts +0 -19
- package/src/components/time-picker/time-picker.tsx +0 -737
- package/src/components/time-picker/time-picker.types.ts +0 -135
- package/src/components/year-input/index.ts +0 -13
- package/src/components/year-input/year-input.tsx +0 -350
- package/src/components/year-input/year-input.types.ts +0 -118
- package/src/components/year-picker/index.ts +0 -15
- package/src/components/year-picker/year-picker.tsx +0 -504
- package/src/components/year-picker/year-picker.types.ts +0 -108
- package/src/index.ts +0 -3
- package/src/style.css +0 -1
- package/tsconfig.json +0 -13
|
@@ -1,453 +0,0 @@
|
|
|
1
|
-
import { useId, useUncontrolled } from "@refraktor/utils";
|
|
2
|
-
import { useCallback, useMemo } from "react";
|
|
3
|
-
import {
|
|
4
|
-
createClassNamesConfig,
|
|
5
|
-
createComponentConfig,
|
|
6
|
-
factory,
|
|
7
|
-
Input,
|
|
8
|
-
Transition,
|
|
9
|
-
useClassNames,
|
|
10
|
-
useProps,
|
|
11
|
-
useTheme
|
|
12
|
-
} from "@refraktor/core";
|
|
13
|
-
import {
|
|
14
|
-
autoUpdate,
|
|
15
|
-
flip,
|
|
16
|
-
FloatingFocusManager,
|
|
17
|
-
FloatingPortal,
|
|
18
|
-
inline,
|
|
19
|
-
Middleware,
|
|
20
|
-
offset,
|
|
21
|
-
shift,
|
|
22
|
-
useDismiss,
|
|
23
|
-
useFloating,
|
|
24
|
-
useFocus,
|
|
25
|
-
useInteractions,
|
|
26
|
-
useRole
|
|
27
|
-
} from "@floating-ui/react";
|
|
28
|
-
import { useDates } from "../dates-provider";
|
|
29
|
-
import { TimePicker } from "../time-picker";
|
|
30
|
-
import {
|
|
31
|
-
TimeInputClassNames,
|
|
32
|
-
TimeInputFactoryPayload,
|
|
33
|
-
TimeInputMode,
|
|
34
|
-
TimeInputProps,
|
|
35
|
-
TimeInputValue
|
|
36
|
-
} from "./time-input.types";
|
|
37
|
-
|
|
38
|
-
const DEFAULT_MODE: TimeInputMode = "24h";
|
|
39
|
-
const DEFAULT_VALUE_FORMAT = "HH:mm:ss";
|
|
40
|
-
const HOURS_IN_DAY = 24;
|
|
41
|
-
const MINUTES_IN_HOUR = 60;
|
|
42
|
-
const SECONDS_IN_MINUTE = 60;
|
|
43
|
-
const TIME_SEGMENT_PATTERN = /^\d{1,2}$/;
|
|
44
|
-
|
|
45
|
-
const defaultProps = {
|
|
46
|
-
mode: DEFAULT_MODE,
|
|
47
|
-
valueFormat: DEFAULT_VALUE_FORMAT,
|
|
48
|
-
disabled: false,
|
|
49
|
-
size: "md",
|
|
50
|
-
radius: "default",
|
|
51
|
-
positioning: {
|
|
52
|
-
placement: "bottom-start",
|
|
53
|
-
offset: 4
|
|
54
|
-
},
|
|
55
|
-
middlewares: {
|
|
56
|
-
flip: true,
|
|
57
|
-
shift: true
|
|
58
|
-
},
|
|
59
|
-
withinPortal: true,
|
|
60
|
-
closeOnClickOutside: true,
|
|
61
|
-
closeOnEscape: true
|
|
62
|
-
} satisfies Partial<TimeInputProps>;
|
|
63
|
-
|
|
64
|
-
type TimeParts = {
|
|
65
|
-
hours24: number;
|
|
66
|
-
minutes: number;
|
|
67
|
-
seconds: number;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const pad = (value: number) => String(value).padStart(2, "0");
|
|
71
|
-
|
|
72
|
-
const parseTimeValue = (value: unknown): TimeParts | undefined => {
|
|
73
|
-
if (typeof value !== "string") {
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const segments = value.trim().split(":");
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
segments.length !== 3 ||
|
|
81
|
-
!segments.every((segment) => TIME_SEGMENT_PATTERN.test(segment))
|
|
82
|
-
) {
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const [hoursText, minutesText, secondsText] = segments;
|
|
87
|
-
const hours24 = Number.parseInt(hoursText, 10);
|
|
88
|
-
const minutes = Number.parseInt(minutesText, 10);
|
|
89
|
-
const seconds = Number.parseInt(secondsText, 10);
|
|
90
|
-
|
|
91
|
-
if (
|
|
92
|
-
hours24 < 0 ||
|
|
93
|
-
hours24 >= HOURS_IN_DAY ||
|
|
94
|
-
minutes < 0 ||
|
|
95
|
-
minutes >= MINUTES_IN_HOUR ||
|
|
96
|
-
seconds < 0 ||
|
|
97
|
-
seconds >= SECONDS_IN_MINUTE
|
|
98
|
-
) {
|
|
99
|
-
return undefined;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
hours24,
|
|
104
|
-
minutes,
|
|
105
|
-
seconds
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const normalizeTimeValue = (value: TimeInputValue | undefined) => {
|
|
110
|
-
const parsed = parseTimeValue(value);
|
|
111
|
-
|
|
112
|
-
if (!parsed) {
|
|
113
|
-
return undefined;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return `${pad(parsed.hours24)}:${pad(parsed.minutes)}:${pad(parsed.seconds)}`;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const formatInputValue = (
|
|
120
|
-
value: TimeInputValue | undefined,
|
|
121
|
-
valueFormat: string,
|
|
122
|
-
createDate: ReturnType<typeof useDates>["createDate"]
|
|
123
|
-
) => {
|
|
124
|
-
if (value === undefined) {
|
|
125
|
-
return "";
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (valueFormat === DEFAULT_VALUE_FORMAT) {
|
|
129
|
-
return value;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const parsed = parseTimeValue(value);
|
|
133
|
-
|
|
134
|
-
if (!parsed) {
|
|
135
|
-
return value;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return createDate(
|
|
139
|
-
new Date(2000, 0, 1, parsed.hours24, parsed.minutes, parsed.seconds, 0)
|
|
140
|
-
).format(valueFormat);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const TimeInput = factory<TimeInputFactoryPayload>((_props, ref) => {
|
|
144
|
-
const { cx, getRadius } = useTheme();
|
|
145
|
-
const { createDate } = useDates();
|
|
146
|
-
const {
|
|
147
|
-
id,
|
|
148
|
-
value,
|
|
149
|
-
defaultValue,
|
|
150
|
-
onChange,
|
|
151
|
-
opened,
|
|
152
|
-
defaultOpened,
|
|
153
|
-
onOpenedChange,
|
|
154
|
-
minTime,
|
|
155
|
-
maxTime,
|
|
156
|
-
mode,
|
|
157
|
-
getHourLabel,
|
|
158
|
-
getMinuteLabel,
|
|
159
|
-
getSecondLabel,
|
|
160
|
-
getPeriodLabel,
|
|
161
|
-
getHourAriaLabel,
|
|
162
|
-
getMinuteAriaLabel,
|
|
163
|
-
getSecondAriaLabel,
|
|
164
|
-
getPeriodAriaLabel,
|
|
165
|
-
valueFormat,
|
|
166
|
-
disabled,
|
|
167
|
-
size,
|
|
168
|
-
radius,
|
|
169
|
-
positioning,
|
|
170
|
-
middlewares,
|
|
171
|
-
withinPortal,
|
|
172
|
-
closeOnClickOutside,
|
|
173
|
-
closeOnEscape,
|
|
174
|
-
transitionProps,
|
|
175
|
-
inputClassNames,
|
|
176
|
-
className,
|
|
177
|
-
classNames,
|
|
178
|
-
onFocus,
|
|
179
|
-
onBlur,
|
|
180
|
-
onClick,
|
|
181
|
-
onKeyDown,
|
|
182
|
-
...inputProps
|
|
183
|
-
} = useProps("TimeInput", defaultProps, _props);
|
|
184
|
-
const classes = useClassNames("TimeInput", classNames);
|
|
185
|
-
|
|
186
|
-
const _id = useId(id);
|
|
187
|
-
const dropdownId = `${_id}-dropdown`;
|
|
188
|
-
|
|
189
|
-
const [selectedTimeState, setSelectedTime] = useUncontrolled<
|
|
190
|
-
TimeInputValue | undefined
|
|
191
|
-
>({
|
|
192
|
-
value,
|
|
193
|
-
defaultValue,
|
|
194
|
-
finalValue: undefined,
|
|
195
|
-
onChange: (nextTime) => {
|
|
196
|
-
if (nextTime !== undefined) {
|
|
197
|
-
onChange?.(nextTime);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
const [isOpenState, setIsOpen] = useUncontrolled<boolean>({
|
|
203
|
-
value: opened,
|
|
204
|
-
defaultValue: defaultOpened,
|
|
205
|
-
finalValue: false,
|
|
206
|
-
onChange: onOpenedChange
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
const isOpen = isOpenState && !disabled;
|
|
210
|
-
|
|
211
|
-
const middleware = useMemo(() => {
|
|
212
|
-
const middlewareList: Middleware[] = [];
|
|
213
|
-
|
|
214
|
-
middlewareList.push(offset(positioning?.offset ?? 4));
|
|
215
|
-
|
|
216
|
-
if (middlewares?.flip ?? true) {
|
|
217
|
-
middlewareList.push(
|
|
218
|
-
flip(
|
|
219
|
-
typeof middlewares?.flip === "boolean"
|
|
220
|
-
? undefined
|
|
221
|
-
: middlewares.flip
|
|
222
|
-
)
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
if (middlewares?.shift ?? true) {
|
|
227
|
-
middlewareList.push(
|
|
228
|
-
shift(
|
|
229
|
-
typeof middlewares?.shift === "boolean"
|
|
230
|
-
? undefined
|
|
231
|
-
: middlewares.shift
|
|
232
|
-
)
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (middlewares?.inline) {
|
|
237
|
-
middlewareList.push(
|
|
238
|
-
inline(
|
|
239
|
-
typeof middlewares.inline === "boolean"
|
|
240
|
-
? undefined
|
|
241
|
-
: middlewares.inline
|
|
242
|
-
)
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return middlewareList;
|
|
247
|
-
}, [middlewares, positioning?.offset]);
|
|
248
|
-
|
|
249
|
-
const handleOpenChange = useCallback(
|
|
250
|
-
(nextOpen: boolean) => {
|
|
251
|
-
if (disabled && nextOpen) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
setIsOpen(nextOpen);
|
|
256
|
-
},
|
|
257
|
-
[disabled, setIsOpen]
|
|
258
|
-
);
|
|
259
|
-
|
|
260
|
-
const floating = useFloating({
|
|
261
|
-
placement: positioning?.placement ?? "bottom-start",
|
|
262
|
-
open: isOpen,
|
|
263
|
-
onOpenChange: handleOpenChange,
|
|
264
|
-
middleware,
|
|
265
|
-
whileElementsMounted: autoUpdate,
|
|
266
|
-
strategy: "fixed"
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
const focus = useFocus(floating.context, {
|
|
270
|
-
enabled: !disabled
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
const dismiss = useDismiss(floating.context, {
|
|
274
|
-
outsidePress: closeOnClickOutside,
|
|
275
|
-
escapeKey: closeOnEscape
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
const role = useRole(floating.context, {
|
|
279
|
-
role: "dialog"
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
283
|
-
focus,
|
|
284
|
-
dismiss,
|
|
285
|
-
role
|
|
286
|
-
]);
|
|
287
|
-
|
|
288
|
-
const setInputRef = useCallback(
|
|
289
|
-
(node: HTMLInputElement | null) => {
|
|
290
|
-
floating.refs.setReference(node);
|
|
291
|
-
|
|
292
|
-
if (typeof ref === "function") {
|
|
293
|
-
ref(node);
|
|
294
|
-
} else if (ref) {
|
|
295
|
-
ref.current = node;
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
[floating.refs, ref]
|
|
299
|
-
);
|
|
300
|
-
|
|
301
|
-
const handleInputKeyDown = useCallback(
|
|
302
|
-
(event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
303
|
-
onKeyDown?.(event);
|
|
304
|
-
|
|
305
|
-
if (event.defaultPrevented || disabled) {
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if (
|
|
310
|
-
event.key === "ArrowDown" ||
|
|
311
|
-
event.key === "Enter" ||
|
|
312
|
-
event.key === " "
|
|
313
|
-
) {
|
|
314
|
-
event.preventDefault();
|
|
315
|
-
setIsOpen(true);
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (event.key === "Escape") {
|
|
320
|
-
event.preventDefault();
|
|
321
|
-
setIsOpen(false);
|
|
322
|
-
}
|
|
323
|
-
},
|
|
324
|
-
[disabled, onKeyDown, setIsOpen]
|
|
325
|
-
);
|
|
326
|
-
|
|
327
|
-
const handleTimeChange = useCallback(
|
|
328
|
-
(nextTime: TimeInputValue) => {
|
|
329
|
-
const normalizedTime = normalizeTimeValue(nextTime);
|
|
330
|
-
|
|
331
|
-
if (normalizedTime === undefined) {
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
setSelectedTime(normalizedTime);
|
|
336
|
-
},
|
|
337
|
-
[setSelectedTime]
|
|
338
|
-
);
|
|
339
|
-
|
|
340
|
-
const selectedTime = useMemo(
|
|
341
|
-
() => normalizeTimeValue(selectedTimeState),
|
|
342
|
-
[selectedTimeState]
|
|
343
|
-
);
|
|
344
|
-
const inputValue = useMemo(
|
|
345
|
-
() => formatInputValue(selectedTime, valueFormat, createDate),
|
|
346
|
-
[createDate, selectedTime, valueFormat]
|
|
347
|
-
);
|
|
348
|
-
|
|
349
|
-
const mergedReferenceProps = getReferenceProps({
|
|
350
|
-
onFocus,
|
|
351
|
-
onBlur,
|
|
352
|
-
onClick,
|
|
353
|
-
onKeyDown: handleInputKeyDown
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
const dropdownWidth =
|
|
357
|
-
mode === "12h"
|
|
358
|
-
? "w-[calc(100vw-1rem)] max-w-[28rem]"
|
|
359
|
-
: "w-[calc(100vw-1rem)] max-w-[22rem]";
|
|
360
|
-
|
|
361
|
-
const dropdownContent = (
|
|
362
|
-
<Transition
|
|
363
|
-
transition="fade"
|
|
364
|
-
duration={150}
|
|
365
|
-
mounted={isOpen}
|
|
366
|
-
style={{ position: "relative", zIndex: 1000 }}
|
|
367
|
-
{...transitionProps}
|
|
368
|
-
>
|
|
369
|
-
<div
|
|
370
|
-
ref={floating.refs.setFloating}
|
|
371
|
-
id={dropdownId}
|
|
372
|
-
style={{
|
|
373
|
-
...floating.floatingStyles,
|
|
374
|
-
zIndex: 1000
|
|
375
|
-
}}
|
|
376
|
-
className={cx(
|
|
377
|
-
dropdownWidth,
|
|
378
|
-
"z-50 border border-[var(--refraktor-border)] bg-[var(--refraktor-bg)] p-2 text-[var(--refraktor-text)] shadow-md",
|
|
379
|
-
getRadius(radius),
|
|
380
|
-
classes.dropdown
|
|
381
|
-
)}
|
|
382
|
-
{...getFloatingProps()}
|
|
383
|
-
>
|
|
384
|
-
<TimePicker
|
|
385
|
-
value={selectedTime}
|
|
386
|
-
onChange={handleTimeChange}
|
|
387
|
-
minTime={minTime}
|
|
388
|
-
maxTime={maxTime}
|
|
389
|
-
mode={mode}
|
|
390
|
-
disabled={disabled}
|
|
391
|
-
size={size}
|
|
392
|
-
radius={radius}
|
|
393
|
-
getHourLabel={getHourLabel}
|
|
394
|
-
getMinuteLabel={getMinuteLabel}
|
|
395
|
-
getSecondLabel={getSecondLabel}
|
|
396
|
-
getPeriodLabel={getPeriodLabel}
|
|
397
|
-
getHourAriaLabel={getHourAriaLabel}
|
|
398
|
-
getMinuteAriaLabel={getMinuteAriaLabel}
|
|
399
|
-
getSecondAriaLabel={getSecondAriaLabel}
|
|
400
|
-
getPeriodAriaLabel={getPeriodAriaLabel}
|
|
401
|
-
className={cx("bg-transparent p-0", classes.timePicker)}
|
|
402
|
-
/>
|
|
403
|
-
</div>
|
|
404
|
-
</Transition>
|
|
405
|
-
);
|
|
406
|
-
|
|
407
|
-
const wrappedContent = isOpen ? (
|
|
408
|
-
<FloatingFocusManager
|
|
409
|
-
context={floating.context}
|
|
410
|
-
modal={false}
|
|
411
|
-
initialFocus={-1}
|
|
412
|
-
returnFocus={false}
|
|
413
|
-
>
|
|
414
|
-
{dropdownContent}
|
|
415
|
-
</FloatingFocusManager>
|
|
416
|
-
) : (
|
|
417
|
-
dropdownContent
|
|
418
|
-
);
|
|
419
|
-
|
|
420
|
-
return (
|
|
421
|
-
<>
|
|
422
|
-
<Input
|
|
423
|
-
ref={setInputRef}
|
|
424
|
-
id={_id}
|
|
425
|
-
readOnly
|
|
426
|
-
value={inputValue}
|
|
427
|
-
disabled={disabled}
|
|
428
|
-
size={size}
|
|
429
|
-
radius={radius}
|
|
430
|
-
role="combobox"
|
|
431
|
-
aria-haspopup="dialog"
|
|
432
|
-
aria-expanded={isOpen}
|
|
433
|
-
aria-controls={isOpen ? dropdownId : undefined}
|
|
434
|
-
className={cx(classes.input, className)}
|
|
435
|
-
classNames={inputClassNames}
|
|
436
|
-
{...inputProps}
|
|
437
|
-
{...(mergedReferenceProps as any)}
|
|
438
|
-
/>
|
|
439
|
-
|
|
440
|
-
{withinPortal ? (
|
|
441
|
-
<FloatingPortal>{wrappedContent}</FloatingPortal>
|
|
442
|
-
) : (
|
|
443
|
-
wrappedContent
|
|
444
|
-
)}
|
|
445
|
-
</>
|
|
446
|
-
);
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
TimeInput.displayName = "@refraktor/dates/TimeInput";
|
|
450
|
-
TimeInput.configure = createComponentConfig<TimeInputProps>();
|
|
451
|
-
TimeInput.classNames = createClassNamesConfig<TimeInputClassNames>();
|
|
452
|
-
|
|
453
|
-
export default TimeInput;
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
FlipOptions,
|
|
3
|
-
InlineOptions,
|
|
4
|
-
Placement,
|
|
5
|
-
ShiftOptions
|
|
6
|
-
} from "@floating-ui/react";
|
|
7
|
-
import {
|
|
8
|
-
createClassNamesConfig,
|
|
9
|
-
createComponentConfig,
|
|
10
|
-
FactoryPayload,
|
|
11
|
-
InputFieldClassNames,
|
|
12
|
-
InputProps,
|
|
13
|
-
RefraktorRadius,
|
|
14
|
-
RefraktorSize,
|
|
15
|
-
TransitionProps
|
|
16
|
-
} from "@refraktor/core";
|
|
17
|
-
import type {
|
|
18
|
-
TimePickerGetHourAriaLabel,
|
|
19
|
-
TimePickerGetHourLabel,
|
|
20
|
-
TimePickerGetMinuteAriaLabel,
|
|
21
|
-
TimePickerGetMinuteLabel,
|
|
22
|
-
TimePickerGetPeriodAriaLabel,
|
|
23
|
-
TimePickerGetPeriodLabel,
|
|
24
|
-
TimePickerGetSecondAriaLabel,
|
|
25
|
-
TimePickerGetSecondLabel,
|
|
26
|
-
TimePickerMode,
|
|
27
|
-
TimePickerOnChange,
|
|
28
|
-
TimePickerPeriod,
|
|
29
|
-
TimePickerValue
|
|
30
|
-
} from "../time-picker";
|
|
31
|
-
|
|
32
|
-
export type TimeInputValue = TimePickerValue;
|
|
33
|
-
export type TimeInputMode = TimePickerMode;
|
|
34
|
-
export type TimeInputPeriod = TimePickerPeriod;
|
|
35
|
-
export type TimeInputSize = RefraktorSize;
|
|
36
|
-
export type TimeInputRadius = RefraktorRadius;
|
|
37
|
-
export type TimeInputOnChange = TimePickerOnChange;
|
|
38
|
-
export type TimeInputValueFormat = string;
|
|
39
|
-
|
|
40
|
-
export type TimeInputGetHourLabel = TimePickerGetHourLabel;
|
|
41
|
-
export type TimeInputGetMinuteLabel = TimePickerGetMinuteLabel;
|
|
42
|
-
export type TimeInputGetSecondLabel = TimePickerGetSecondLabel;
|
|
43
|
-
export type TimeInputGetPeriodLabel = TimePickerGetPeriodLabel;
|
|
44
|
-
|
|
45
|
-
export type TimeInputGetHourAriaLabel = TimePickerGetHourAriaLabel;
|
|
46
|
-
export type TimeInputGetMinuteAriaLabel = TimePickerGetMinuteAriaLabel;
|
|
47
|
-
export type TimeInputGetSecondAriaLabel = TimePickerGetSecondAriaLabel;
|
|
48
|
-
export type TimeInputGetPeriodAriaLabel = TimePickerGetPeriodAriaLabel;
|
|
49
|
-
|
|
50
|
-
export type TimeInputPositioning = {
|
|
51
|
-
/** The placement of the dropdown relative to the input @default `bottom-start` */
|
|
52
|
-
placement?: Placement;
|
|
53
|
-
|
|
54
|
-
/** Offset distance from the input in pixels @default `4` */
|
|
55
|
-
offset?: number;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export type TimeInputMiddlewares = {
|
|
59
|
-
shift?: boolean | ShiftOptions;
|
|
60
|
-
flip?: boolean | FlipOptions;
|
|
61
|
-
inline?: boolean | InlineOptions;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export type TimeInputClassNames = {
|
|
65
|
-
input?: string;
|
|
66
|
-
dropdown?: string;
|
|
67
|
-
timePicker?: string;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
interface _TimeInputProps {
|
|
71
|
-
/** Selected time (controlled), accepts `H:mm:ss` or `HH:mm:ss` (24h). */
|
|
72
|
-
value?: TimeInputValue;
|
|
73
|
-
|
|
74
|
-
/** Initial selected time (uncontrolled), accepts `H:mm:ss` or `HH:mm:ss` (24h). */
|
|
75
|
-
defaultValue?: TimeInputValue;
|
|
76
|
-
|
|
77
|
-
/** Callback called when selected time changes in normalized `HH:mm:ss` format (24h). */
|
|
78
|
-
onChange?: TimeInputOnChange;
|
|
79
|
-
|
|
80
|
-
/** Dropdown open state (controlled). */
|
|
81
|
-
opened?: boolean;
|
|
82
|
-
|
|
83
|
-
/** Initial dropdown open state (uncontrolled). */
|
|
84
|
-
defaultOpened?: boolean;
|
|
85
|
-
|
|
86
|
-
/** Callback called when dropdown open state changes. */
|
|
87
|
-
onOpenedChange?: (opened: boolean) => void;
|
|
88
|
-
|
|
89
|
-
/** Lower selectable bound for time-of-day, accepts `H:mm:ss` or `HH:mm:ss` (24h). */
|
|
90
|
-
minTime?: TimeInputValue;
|
|
91
|
-
|
|
92
|
-
/** Upper selectable bound for time-of-day, accepts `H:mm:ss` or `HH:mm:ss` (24h). */
|
|
93
|
-
maxTime?: TimeInputValue;
|
|
94
|
-
|
|
95
|
-
/** Time display mode @default `24h` */
|
|
96
|
-
mode?: TimeInputMode;
|
|
97
|
-
|
|
98
|
-
/** Custom hour label renderer. */
|
|
99
|
-
getHourLabel?: TimeInputGetHourLabel;
|
|
100
|
-
|
|
101
|
-
/** Custom minute label renderer. */
|
|
102
|
-
getMinuteLabel?: TimeInputGetMinuteLabel;
|
|
103
|
-
|
|
104
|
-
/** Custom second label renderer. */
|
|
105
|
-
getSecondLabel?: TimeInputGetSecondLabel;
|
|
106
|
-
|
|
107
|
-
/** Custom AM/PM label renderer in 12h mode. */
|
|
108
|
-
getPeriodLabel?: TimeInputGetPeriodLabel;
|
|
109
|
-
|
|
110
|
-
/** Custom aria-label generator for hour options. */
|
|
111
|
-
getHourAriaLabel?: TimeInputGetHourAriaLabel;
|
|
112
|
-
|
|
113
|
-
/** Custom aria-label generator for minute options. */
|
|
114
|
-
getMinuteAriaLabel?: TimeInputGetMinuteAriaLabel;
|
|
115
|
-
|
|
116
|
-
/** Custom aria-label generator for second options. */
|
|
117
|
-
getSecondAriaLabel?: TimeInputGetSecondAriaLabel;
|
|
118
|
-
|
|
119
|
-
/** Custom aria-label generator for period options. */
|
|
120
|
-
getPeriodAriaLabel?: TimeInputGetPeriodAriaLabel;
|
|
121
|
-
|
|
122
|
-
/** Dayjs format used to render selected time in the input @default `HH:mm:ss` */
|
|
123
|
-
valueFormat?: TimeInputValueFormat;
|
|
124
|
-
|
|
125
|
-
/** Positioning settings for the dropdown. */
|
|
126
|
-
positioning?: TimeInputPositioning;
|
|
127
|
-
|
|
128
|
-
/** Floating middleware settings. */
|
|
129
|
-
middlewares?: TimeInputMiddlewares;
|
|
130
|
-
|
|
131
|
-
/** Whether to render dropdown in a portal @default `true` */
|
|
132
|
-
withinPortal?: boolean;
|
|
133
|
-
|
|
134
|
-
/** Whether to close on click outside @default `true` */
|
|
135
|
-
closeOnClickOutside?: boolean;
|
|
136
|
-
|
|
137
|
-
/** Whether to close on Escape key @default `true` */
|
|
138
|
-
closeOnEscape?: boolean;
|
|
139
|
-
|
|
140
|
-
/** Transition props for dropdown, uses Transition internally */
|
|
141
|
-
transitionProps?: Omit<TransitionProps, "children" | "mounted">;
|
|
142
|
-
|
|
143
|
-
/** Used for styling the core Input field parts. */
|
|
144
|
-
inputClassNames?: InputFieldClassNames;
|
|
145
|
-
|
|
146
|
-
/** Used for styling TimeInput parts. */
|
|
147
|
-
classNames?: TimeInputClassNames;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export type TimeInputProps = _TimeInputProps &
|
|
151
|
-
Omit<
|
|
152
|
-
InputProps,
|
|
153
|
-
"value" | "defaultValue" | "onChange" | "readOnly" | "classNames"
|
|
154
|
-
>;
|
|
155
|
-
|
|
156
|
-
export interface TimeInputFactoryPayload extends FactoryPayload {
|
|
157
|
-
props: TimeInputProps;
|
|
158
|
-
ref: HTMLInputElement;
|
|
159
|
-
compound: {
|
|
160
|
-
configure: ReturnType<typeof createComponentConfig<TimeInputProps>>;
|
|
161
|
-
classNames: ReturnType<typeof createClassNamesConfig<TimeInputClassNames>>;
|
|
162
|
-
};
|
|
163
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export { default as TimePicker } from "./time-picker";
|
|
2
|
-
export type {
|
|
3
|
-
TimePickerClassNames,
|
|
4
|
-
TimePickerGetHourAriaLabel,
|
|
5
|
-
TimePickerGetHourLabel,
|
|
6
|
-
TimePickerGetMinuteAriaLabel,
|
|
7
|
-
TimePickerGetMinuteLabel,
|
|
8
|
-
TimePickerGetPeriodAriaLabel,
|
|
9
|
-
TimePickerGetPeriodLabel,
|
|
10
|
-
TimePickerGetSecondAriaLabel,
|
|
11
|
-
TimePickerGetSecondLabel,
|
|
12
|
-
TimePickerMode,
|
|
13
|
-
TimePickerOnChange,
|
|
14
|
-
TimePickerPeriod,
|
|
15
|
-
TimePickerProps,
|
|
16
|
-
TimePickerRadius,
|
|
17
|
-
TimePickerSize,
|
|
18
|
-
TimePickerValue
|
|
19
|
-
} from "./time-picker.types";
|