@refraktor/dates 0.0.1 → 0.0.3

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.
Files changed (40) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/build/components/date-input/date-input.d.ts.map +1 -1
  3. package/build/components/date-input/date-input.js +5 -3
  4. package/build/components/index.d.ts +2 -0
  5. package/build/components/index.d.ts.map +1 -1
  6. package/build/components/index.js +2 -0
  7. package/build/components/month-input/month-input.d.ts.map +1 -1
  8. package/build/components/month-input/month-input.js +5 -3
  9. package/build/components/time-input/index.d.ts +3 -0
  10. package/build/components/time-input/index.d.ts.map +1 -0
  11. package/build/components/time-input/index.js +1 -0
  12. package/build/components/time-input/time-input.d.ts +4 -0
  13. package/build/components/time-input/time-input.d.ts.map +1 -0
  14. package/build/components/time-input/time-input.js +207 -0
  15. package/build/components/time-input/time-input.types.d.ts +99 -0
  16. package/build/components/time-input/time-input.types.d.ts.map +1 -0
  17. package/build/components/time-input/time-input.types.js +1 -0
  18. package/build/components/time-picker/index.d.ts +3 -0
  19. package/build/components/time-picker/index.d.ts.map +1 -0
  20. package/build/components/time-picker/index.js +1 -0
  21. package/build/components/time-picker/time-picker.d.ts +4 -0
  22. package/build/components/time-picker/time-picker.d.ts.map +1 -0
  23. package/build/components/time-picker/time-picker.js +405 -0
  24. package/build/components/time-picker/time-picker.types.d.ts +79 -0
  25. package/build/components/time-picker/time-picker.types.d.ts.map +1 -0
  26. package/build/components/time-picker/time-picker.types.js +1 -0
  27. package/build/components/year-input/year-input.d.ts.map +1 -1
  28. package/build/components/year-input/year-input.js +5 -3
  29. package/build/style.css +1 -1
  30. package/package.json +3 -3
  31. package/src/components/date-input/date-input.tsx +5 -2
  32. package/src/components/index.ts +2 -0
  33. package/src/components/month-input/month-input.tsx +5 -2
  34. package/src/components/time-input/index.ts +23 -0
  35. package/src/components/time-input/time-input.tsx +453 -0
  36. package/src/components/time-input/time-input.types.ts +163 -0
  37. package/src/components/time-picker/index.ts +19 -0
  38. package/src/components/time-picker/time-picker.tsx +737 -0
  39. package/src/components/time-picker/time-picker.types.ts +135 -0
  40. package/src/components/year-input/year-input.tsx +5 -2
@@ -1,4 +1,4 @@
1
1
  $ tsc && tailwindcss -i src/style.css -o build/style.css --minify
2
2
  ≈ tailwindcss v4.1.18
3
3
 
4
- Done in 52ms
4
+ Done in 87ms
@@ -1 +1 @@
1
- {"version":3,"file":"date-input.d.ts","sourceRoot":"","sources":["../../../src/components/date-input/date-input.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAEH,uBAAuB,EAE1B,MAAM,oBAAoB,CAAC;AAyC5B,QAAA,MAAM,SAAS,uEAuSb,CAAC;AAMH,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"date-input.d.ts","sourceRoot":"","sources":["../../../src/components/date-input/date-input.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAEH,uBAAuB,EAE1B,MAAM,oBAAoB,CAAC;AAyC5B,QAAA,MAAM,SAAS,uEA0Sb,CAAC;AAMH,eAAe,SAAS,CAAC"}
@@ -93,7 +93,8 @@ const DateInput = factory((_props, ref) => {
93
93
  open: isOpen,
94
94
  onOpenChange: handleOpenChange,
95
95
  middleware,
96
- whileElementsMounted: autoUpdate
96
+ whileElementsMounted: autoUpdate,
97
+ strategy: "fixed"
97
98
  });
98
99
  const focus = useFocus(floating.context, {
99
100
  enabled: !disabled
@@ -152,8 +153,9 @@ const DateInput = factory((_props, ref) => {
152
153
  onClick,
153
154
  onKeyDown: handleInputKeyDown
154
155
  });
155
- const dropdownContent = (_jsx(Transition, { transition: "fade", duration: 150, mounted: isOpen, ...transitionProps, children: _jsx("div", { ref: floating.refs.setFloating, id: dropdownId, style: {
156
- ...floating.floatingStyles
156
+ const dropdownContent = (_jsx(Transition, { transition: "fade", duration: 150, mounted: isOpen, style: { position: "relative", zIndex: 1000 }, ...transitionProps, children: _jsx("div", { ref: floating.refs.setFloating, id: dropdownId, style: {
157
+ ...floating.floatingStyles,
158
+ zIndex: 1000
157
159
  }, className: cx("w-80 z-50 border border-[var(--refraktor-border)] bg-[var(--refraktor-bg)] p-2 text-[var(--refraktor-text)] shadow-md", getRadius(radius), classes.dropdown), ...getFloatingProps(), children: _jsx(DatePicker, { value: selectedDate, onChange: handleDateChange, minDate: minDate, maxDate: maxDate, monthPickerColumns: monthPickerColumns, yearPickerYearsPerPage: yearPickerYearsPerPage, yearPickerColumns: yearPickerColumns, disabled: disabled, size: size, radius: radius, getWeekdayLabel: getWeekdayLabel, getDayLabel: getDayLabel, getDayAriaLabel: getDayAriaLabel, getHeaderLabel: getHeaderLabel, getNavigationAriaLabel: getNavigationAriaLabel, getMonthLabel: getMonthLabel, getMonthAriaLabel: getMonthAriaLabel, getMonthHeaderLabel: getMonthHeaderLabel, getMonthNavigationAriaLabel: getMonthNavigationAriaLabel, className: cx("bg-transparent p-0", classes.datePicker) }) }) }));
158
160
  const wrappedContent = isOpen ? (_jsx(FloatingFocusManager, { context: floating.context, modal: false, initialFocus: -1, returnFocus: false, children: dropdownContent })) : (dropdownContent);
159
161
  return (_jsxs(_Fragment, { children: [_jsx(Input, { ref: setInputRef, id: _id, readOnly: true, value: inputValue, disabled: disabled, size: size, radius: radius, role: "combobox", "aria-haspopup": "dialog", "aria-expanded": isOpen, "aria-controls": isOpen ? dropdownId : undefined, className: cx(classes.input, className), classNames: inputClassNames, ...inputProps, ...mergedReferenceProps }), withinPortal ? (_jsx(FloatingPortal, { children: wrappedContent })) : (wrappedContent)] }));
@@ -5,4 +5,6 @@ export * from "./month-picker";
5
5
  export * from "./month-input";
6
6
  export * from "./year-picker";
7
7
  export * from "./year-input";
8
+ export * from "./time-picker";
9
+ export * from "./time-input";
8
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
@@ -5,3 +5,5 @@ export * from "./month-picker";
5
5
  export * from "./month-input";
6
6
  export * from "./year-picker";
7
7
  export * from "./year-input";
8
+ export * from "./time-picker";
9
+ export * from "./time-input";
@@ -1 +1 @@
1
- {"version":3,"file":"month-input.d.ts","sourceRoot":"","sources":["../../../src/components/month-input/month-input.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAEH,wBAAwB,EAE3B,MAAM,qBAAqB,CAAC;AA0C7B,QAAA,MAAM,UAAU,wEAyRd,CAAC;AAMH,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"month-input.d.ts","sourceRoot":"","sources":["../../../src/components/month-input/month-input.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAEH,wBAAwB,EAE3B,MAAM,qBAAqB,CAAC;AA0C7B,QAAA,MAAM,UAAU,wEA4Rd,CAAC;AAMH,eAAe,UAAU,CAAC"}
@@ -94,7 +94,8 @@ const MonthInput = factory((_props, ref) => {
94
94
  open: isOpen,
95
95
  onOpenChange: handleOpenChange,
96
96
  middleware,
97
- whileElementsMounted: autoUpdate
97
+ whileElementsMounted: autoUpdate,
98
+ strategy: "fixed"
98
99
  });
99
100
  const focus = useFocus(floating.context, {
100
101
  enabled: !disabled
@@ -149,8 +150,9 @@ const MonthInput = factory((_props, ref) => {
149
150
  onClick,
150
151
  onKeyDown: handleInputKeyDown
151
152
  });
152
- const dropdownContent = (_jsx(Transition, { transition: "fade", duration: 150, mounted: isOpen, ...transitionProps, children: _jsx("div", { ref: floating.refs.setFloating, id: dropdownId, style: {
153
- ...floating.floatingStyles
153
+ const dropdownContent = (_jsx(Transition, { transition: "fade", duration: 150, mounted: isOpen, style: { position: "relative", zIndex: 1000 }, ...transitionProps, children: _jsx("div", { ref: floating.refs.setFloating, id: dropdownId, style: {
154
+ ...floating.floatingStyles,
155
+ zIndex: 1000
154
156
  }, className: cx("w-72 z-50 border border-[var(--refraktor-border)] bg-[var(--refraktor-bg)] p-2 text-[var(--refraktor-text)] shadow-md", getRadius(radius), classes.dropdown), ...getFloatingProps(), children: _jsx(MonthPicker, { value: selectedMonth, onChange: handleMonthChange, minYear: minYear, maxYear: maxYear, columns: columns, yearPickerYearsPerPage: yearPickerYearsPerPage, yearPickerColumns: yearPickerColumns, disabled: disabled, size: size, radius: radius, getMonthLabel: getMonthLabel, getMonthAriaLabel: getMonthAriaLabel, getHeaderLabel: getHeaderLabel, getNavigationAriaLabel: getNavigationAriaLabel, className: cx("bg-transparent p-0", classes.monthPicker) }) }) }));
155
157
  const wrappedContent = isOpen ? (_jsx(FloatingFocusManager, { context: floating.context, modal: false, initialFocus: -1, returnFocus: false, children: dropdownContent })) : (dropdownContent);
156
158
  return (_jsxs(_Fragment, { children: [_jsx(Input, { ref: setInputRef, id: _id, readOnly: true, value: inputValue, disabled: disabled, size: size, radius: radius, role: "combobox", "aria-haspopup": "dialog", "aria-expanded": isOpen, "aria-controls": isOpen ? dropdownId : undefined, className: cx(classes.input, className), classNames: inputClassNames, ...inputProps, ...mergedReferenceProps }), withinPortal ? (_jsx(FloatingPortal, { children: wrappedContent })) : (wrappedContent)] }));
@@ -0,0 +1,3 @@
1
+ export { default as TimeInput } from "./time-input";
2
+ export type { TimeInputClassNames, TimeInputFactoryPayload, TimeInputGetHourAriaLabel, TimeInputGetHourLabel, TimeInputGetMinuteAriaLabel, TimeInputGetMinuteLabel, TimeInputGetPeriodAriaLabel, TimeInputGetPeriodLabel, TimeInputGetSecondAriaLabel, TimeInputGetSecondLabel, TimeInputMiddlewares, TimeInputMode, TimeInputOnChange, TimeInputPeriod, TimeInputPositioning, TimeInputProps, TimeInputRadius, TimeInputSize, TimeInputValue, TimeInputValueFormat } from "./time-input.types";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/time-input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EACR,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,EACzB,qBAAqB,EACrB,2BAA2B,EAC3B,uBAAuB,EACvB,2BAA2B,EAC3B,uBAAuB,EACvB,2BAA2B,EAC3B,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,oBAAoB,EACvB,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1 @@
1
+ export { default as TimeInput } from "./time-input";
@@ -0,0 +1,4 @@
1
+ import { TimeInputFactoryPayload } from "./time-input.types";
2
+ declare const TimeInput: import("@refraktor/core").RefraktorComponent<TimeInputFactoryPayload>;
3
+ export default TimeInput;
4
+ //# sourceMappingURL=time-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-input.d.ts","sourceRoot":"","sources":["../../../src/components/time-input/time-input.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAEH,uBAAuB,EAI1B,MAAM,oBAAoB,CAAC;AA2G5B,QAAA,MAAM,SAAS,uEAgTb,CAAC;AAMH,eAAe,SAAS,CAAC"}
@@ -0,0 +1,207 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId, useUncontrolled } from "@refraktor/utils";
3
+ import { useCallback, useMemo } from "react";
4
+ import { createClassNamesConfig, createComponentConfig, factory, Input, Transition, useClassNames, useProps, useTheme } from "@refraktor/core";
5
+ import { autoUpdate, flip, FloatingFocusManager, FloatingPortal, inline, offset, shift, useDismiss, useFloating, useFocus, useInteractions, useRole } from "@floating-ui/react";
6
+ import { useDates } from "../dates-provider";
7
+ import { TimePicker } from "../time-picker";
8
+ const DEFAULT_MODE = "24h";
9
+ const DEFAULT_VALUE_FORMAT = "HH:mm:ss";
10
+ const HOURS_IN_DAY = 24;
11
+ const MINUTES_IN_HOUR = 60;
12
+ const SECONDS_IN_MINUTE = 60;
13
+ const TIME_SEGMENT_PATTERN = /^\d{1,2}$/;
14
+ const defaultProps = {
15
+ mode: DEFAULT_MODE,
16
+ valueFormat: DEFAULT_VALUE_FORMAT,
17
+ disabled: false,
18
+ size: "md",
19
+ radius: "default",
20
+ positioning: {
21
+ placement: "bottom-start",
22
+ offset: 4
23
+ },
24
+ middlewares: {
25
+ flip: true,
26
+ shift: true
27
+ },
28
+ withinPortal: true,
29
+ closeOnClickOutside: true,
30
+ closeOnEscape: true
31
+ };
32
+ const pad = (value) => String(value).padStart(2, "0");
33
+ const parseTimeValue = (value) => {
34
+ if (typeof value !== "string") {
35
+ return undefined;
36
+ }
37
+ const segments = value.trim().split(":");
38
+ if (segments.length !== 3 ||
39
+ !segments.every((segment) => TIME_SEGMENT_PATTERN.test(segment))) {
40
+ return undefined;
41
+ }
42
+ const [hoursText, minutesText, secondsText] = segments;
43
+ const hours24 = Number.parseInt(hoursText, 10);
44
+ const minutes = Number.parseInt(minutesText, 10);
45
+ const seconds = Number.parseInt(secondsText, 10);
46
+ if (hours24 < 0 ||
47
+ hours24 >= HOURS_IN_DAY ||
48
+ minutes < 0 ||
49
+ minutes >= MINUTES_IN_HOUR ||
50
+ seconds < 0 ||
51
+ seconds >= SECONDS_IN_MINUTE) {
52
+ return undefined;
53
+ }
54
+ return {
55
+ hours24,
56
+ minutes,
57
+ seconds
58
+ };
59
+ };
60
+ const normalizeTimeValue = (value) => {
61
+ const parsed = parseTimeValue(value);
62
+ if (!parsed) {
63
+ return undefined;
64
+ }
65
+ return `${pad(parsed.hours24)}:${pad(parsed.minutes)}:${pad(parsed.seconds)}`;
66
+ };
67
+ const formatInputValue = (value, valueFormat, createDate) => {
68
+ if (value === undefined) {
69
+ return "";
70
+ }
71
+ if (valueFormat === DEFAULT_VALUE_FORMAT) {
72
+ return value;
73
+ }
74
+ const parsed = parseTimeValue(value);
75
+ if (!parsed) {
76
+ return value;
77
+ }
78
+ return createDate(new Date(2000, 0, 1, parsed.hours24, parsed.minutes, parsed.seconds, 0)).format(valueFormat);
79
+ };
80
+ const TimeInput = factory((_props, ref) => {
81
+ const { cx, getRadius } = useTheme();
82
+ const { createDate } = useDates();
83
+ const { id, value, defaultValue, onChange, opened, defaultOpened, onOpenedChange, minTime, maxTime, mode, getHourLabel, getMinuteLabel, getSecondLabel, getPeriodLabel, getHourAriaLabel, getMinuteAriaLabel, getSecondAriaLabel, getPeriodAriaLabel, valueFormat, disabled, size, radius, positioning, middlewares, withinPortal, closeOnClickOutside, closeOnEscape, transitionProps, inputClassNames, className, classNames, onFocus, onBlur, onClick, onKeyDown, ...inputProps } = useProps("TimeInput", defaultProps, _props);
84
+ const classes = useClassNames("TimeInput", classNames);
85
+ const _id = useId(id);
86
+ const dropdownId = `${_id}-dropdown`;
87
+ const [selectedTimeState, setSelectedTime] = useUncontrolled({
88
+ value,
89
+ defaultValue,
90
+ finalValue: undefined,
91
+ onChange: (nextTime) => {
92
+ if (nextTime !== undefined) {
93
+ onChange?.(nextTime);
94
+ }
95
+ }
96
+ });
97
+ const [isOpenState, setIsOpen] = useUncontrolled({
98
+ value: opened,
99
+ defaultValue: defaultOpened,
100
+ finalValue: false,
101
+ onChange: onOpenedChange
102
+ });
103
+ const isOpen = isOpenState && !disabled;
104
+ const middleware = useMemo(() => {
105
+ const middlewareList = [];
106
+ middlewareList.push(offset(positioning?.offset ?? 4));
107
+ if (middlewares?.flip ?? true) {
108
+ middlewareList.push(flip(typeof middlewares?.flip === "boolean"
109
+ ? undefined
110
+ : middlewares.flip));
111
+ }
112
+ if (middlewares?.shift ?? true) {
113
+ middlewareList.push(shift(typeof middlewares?.shift === "boolean"
114
+ ? undefined
115
+ : middlewares.shift));
116
+ }
117
+ if (middlewares?.inline) {
118
+ middlewareList.push(inline(typeof middlewares.inline === "boolean"
119
+ ? undefined
120
+ : middlewares.inline));
121
+ }
122
+ return middlewareList;
123
+ }, [middlewares, positioning?.offset]);
124
+ const handleOpenChange = useCallback((nextOpen) => {
125
+ if (disabled && nextOpen) {
126
+ return;
127
+ }
128
+ setIsOpen(nextOpen);
129
+ }, [disabled, setIsOpen]);
130
+ const floating = useFloating({
131
+ placement: positioning?.placement ?? "bottom-start",
132
+ open: isOpen,
133
+ onOpenChange: handleOpenChange,
134
+ middleware,
135
+ whileElementsMounted: autoUpdate,
136
+ strategy: "fixed"
137
+ });
138
+ const focus = useFocus(floating.context, {
139
+ enabled: !disabled
140
+ });
141
+ const dismiss = useDismiss(floating.context, {
142
+ outsidePress: closeOnClickOutside,
143
+ escapeKey: closeOnEscape
144
+ });
145
+ const role = useRole(floating.context, {
146
+ role: "dialog"
147
+ });
148
+ const { getReferenceProps, getFloatingProps } = useInteractions([
149
+ focus,
150
+ dismiss,
151
+ role
152
+ ]);
153
+ const setInputRef = useCallback((node) => {
154
+ floating.refs.setReference(node);
155
+ if (typeof ref === "function") {
156
+ ref(node);
157
+ }
158
+ else if (ref) {
159
+ ref.current = node;
160
+ }
161
+ }, [floating.refs, ref]);
162
+ const handleInputKeyDown = useCallback((event) => {
163
+ onKeyDown?.(event);
164
+ if (event.defaultPrevented || disabled) {
165
+ return;
166
+ }
167
+ if (event.key === "ArrowDown" ||
168
+ event.key === "Enter" ||
169
+ event.key === " ") {
170
+ event.preventDefault();
171
+ setIsOpen(true);
172
+ return;
173
+ }
174
+ if (event.key === "Escape") {
175
+ event.preventDefault();
176
+ setIsOpen(false);
177
+ }
178
+ }, [disabled, onKeyDown, setIsOpen]);
179
+ const handleTimeChange = useCallback((nextTime) => {
180
+ const normalizedTime = normalizeTimeValue(nextTime);
181
+ if (normalizedTime === undefined) {
182
+ return;
183
+ }
184
+ setSelectedTime(normalizedTime);
185
+ }, [setSelectedTime]);
186
+ const selectedTime = useMemo(() => normalizeTimeValue(selectedTimeState), [selectedTimeState]);
187
+ const inputValue = useMemo(() => formatInputValue(selectedTime, valueFormat, createDate), [createDate, selectedTime, valueFormat]);
188
+ const mergedReferenceProps = getReferenceProps({
189
+ onFocus,
190
+ onBlur,
191
+ onClick,
192
+ onKeyDown: handleInputKeyDown
193
+ });
194
+ const dropdownWidth = mode === "12h"
195
+ ? "w-[calc(100vw-1rem)] max-w-[28rem]"
196
+ : "w-[calc(100vw-1rem)] max-w-[22rem]";
197
+ const dropdownContent = (_jsx(Transition, { transition: "fade", duration: 150, mounted: isOpen, style: { position: "relative", zIndex: 1000 }, ...transitionProps, children: _jsx("div", { ref: floating.refs.setFloating, id: dropdownId, style: {
198
+ ...floating.floatingStyles,
199
+ zIndex: 1000
200
+ }, className: cx(dropdownWidth, "z-50 border border-[var(--refraktor-border)] bg-[var(--refraktor-bg)] p-2 text-[var(--refraktor-text)] shadow-md", getRadius(radius), classes.dropdown), ...getFloatingProps(), children: _jsx(TimePicker, { value: selectedTime, onChange: handleTimeChange, minTime: minTime, maxTime: maxTime, mode: mode, disabled: disabled, size: size, radius: radius, getHourLabel: getHourLabel, getMinuteLabel: getMinuteLabel, getSecondLabel: getSecondLabel, getPeriodLabel: getPeriodLabel, getHourAriaLabel: getHourAriaLabel, getMinuteAriaLabel: getMinuteAriaLabel, getSecondAriaLabel: getSecondAriaLabel, getPeriodAriaLabel: getPeriodAriaLabel, className: cx("bg-transparent p-0", classes.timePicker) }) }) }));
201
+ const wrappedContent = isOpen ? (_jsx(FloatingFocusManager, { context: floating.context, modal: false, initialFocus: -1, returnFocus: false, children: dropdownContent })) : (dropdownContent);
202
+ return (_jsxs(_Fragment, { children: [_jsx(Input, { ref: setInputRef, id: _id, readOnly: true, value: inputValue, disabled: disabled, size: size, radius: radius, role: "combobox", "aria-haspopup": "dialog", "aria-expanded": isOpen, "aria-controls": isOpen ? dropdownId : undefined, className: cx(classes.input, className), classNames: inputClassNames, ...inputProps, ...mergedReferenceProps }), withinPortal ? (_jsx(FloatingPortal, { children: wrappedContent })) : (wrappedContent)] }));
203
+ });
204
+ TimeInput.displayName = "@refraktor/dates/TimeInput";
205
+ TimeInput.configure = createComponentConfig();
206
+ TimeInput.classNames = createClassNamesConfig();
207
+ export default TimeInput;
@@ -0,0 +1,99 @@
1
+ import type { FlipOptions, InlineOptions, Placement, ShiftOptions } from "@floating-ui/react";
2
+ import { createClassNamesConfig, createComponentConfig, FactoryPayload, InputFieldClassNames, InputProps, RefraktorRadius, RefraktorSize, TransitionProps } from "@refraktor/core";
3
+ import type { TimePickerGetHourAriaLabel, TimePickerGetHourLabel, TimePickerGetMinuteAriaLabel, TimePickerGetMinuteLabel, TimePickerGetPeriodAriaLabel, TimePickerGetPeriodLabel, TimePickerGetSecondAriaLabel, TimePickerGetSecondLabel, TimePickerMode, TimePickerOnChange, TimePickerPeriod, TimePickerValue } from "../time-picker";
4
+ export type TimeInputValue = TimePickerValue;
5
+ export type TimeInputMode = TimePickerMode;
6
+ export type TimeInputPeriod = TimePickerPeriod;
7
+ export type TimeInputSize = RefraktorSize;
8
+ export type TimeInputRadius = RefraktorRadius;
9
+ export type TimeInputOnChange = TimePickerOnChange;
10
+ export type TimeInputValueFormat = string;
11
+ export type TimeInputGetHourLabel = TimePickerGetHourLabel;
12
+ export type TimeInputGetMinuteLabel = TimePickerGetMinuteLabel;
13
+ export type TimeInputGetSecondLabel = TimePickerGetSecondLabel;
14
+ export type TimeInputGetPeriodLabel = TimePickerGetPeriodLabel;
15
+ export type TimeInputGetHourAriaLabel = TimePickerGetHourAriaLabel;
16
+ export type TimeInputGetMinuteAriaLabel = TimePickerGetMinuteAriaLabel;
17
+ export type TimeInputGetSecondAriaLabel = TimePickerGetSecondAriaLabel;
18
+ export type TimeInputGetPeriodAriaLabel = TimePickerGetPeriodAriaLabel;
19
+ export type TimeInputPositioning = {
20
+ /** The placement of the dropdown relative to the input @default `bottom-start` */
21
+ placement?: Placement;
22
+ /** Offset distance from the input in pixels @default `4` */
23
+ offset?: number;
24
+ };
25
+ export type TimeInputMiddlewares = {
26
+ shift?: boolean | ShiftOptions;
27
+ flip?: boolean | FlipOptions;
28
+ inline?: boolean | InlineOptions;
29
+ };
30
+ export type TimeInputClassNames = {
31
+ input?: string;
32
+ dropdown?: string;
33
+ timePicker?: string;
34
+ };
35
+ interface _TimeInputProps {
36
+ /** Selected time (controlled), accepts `H:mm:ss` or `HH:mm:ss` (24h). */
37
+ value?: TimeInputValue;
38
+ /** Initial selected time (uncontrolled), accepts `H:mm:ss` or `HH:mm:ss` (24h). */
39
+ defaultValue?: TimeInputValue;
40
+ /** Callback called when selected time changes in normalized `HH:mm:ss` format (24h). */
41
+ onChange?: TimeInputOnChange;
42
+ /** Dropdown open state (controlled). */
43
+ opened?: boolean;
44
+ /** Initial dropdown open state (uncontrolled). */
45
+ defaultOpened?: boolean;
46
+ /** Callback called when dropdown open state changes. */
47
+ onOpenedChange?: (opened: boolean) => void;
48
+ /** Lower selectable bound for time-of-day, accepts `H:mm:ss` or `HH:mm:ss` (24h). */
49
+ minTime?: TimeInputValue;
50
+ /** Upper selectable bound for time-of-day, accepts `H:mm:ss` or `HH:mm:ss` (24h). */
51
+ maxTime?: TimeInputValue;
52
+ /** Time display mode @default `24h` */
53
+ mode?: TimeInputMode;
54
+ /** Custom hour label renderer. */
55
+ getHourLabel?: TimeInputGetHourLabel;
56
+ /** Custom minute label renderer. */
57
+ getMinuteLabel?: TimeInputGetMinuteLabel;
58
+ /** Custom second label renderer. */
59
+ getSecondLabel?: TimeInputGetSecondLabel;
60
+ /** Custom AM/PM label renderer in 12h mode. */
61
+ getPeriodLabel?: TimeInputGetPeriodLabel;
62
+ /** Custom aria-label generator for hour options. */
63
+ getHourAriaLabel?: TimeInputGetHourAriaLabel;
64
+ /** Custom aria-label generator for minute options. */
65
+ getMinuteAriaLabel?: TimeInputGetMinuteAriaLabel;
66
+ /** Custom aria-label generator for second options. */
67
+ getSecondAriaLabel?: TimeInputGetSecondAriaLabel;
68
+ /** Custom aria-label generator for period options. */
69
+ getPeriodAriaLabel?: TimeInputGetPeriodAriaLabel;
70
+ /** Dayjs format used to render selected time in the input @default `HH:mm:ss` */
71
+ valueFormat?: TimeInputValueFormat;
72
+ /** Positioning settings for the dropdown. */
73
+ positioning?: TimeInputPositioning;
74
+ /** Floating middleware settings. */
75
+ middlewares?: TimeInputMiddlewares;
76
+ /** Whether to render dropdown in a portal @default `true` */
77
+ withinPortal?: boolean;
78
+ /** Whether to close on click outside @default `true` */
79
+ closeOnClickOutside?: boolean;
80
+ /** Whether to close on Escape key @default `true` */
81
+ closeOnEscape?: boolean;
82
+ /** Transition props for dropdown, uses Transition internally */
83
+ transitionProps?: Omit<TransitionProps, "children" | "mounted">;
84
+ /** Used for styling the core Input field parts. */
85
+ inputClassNames?: InputFieldClassNames;
86
+ /** Used for styling TimeInput parts. */
87
+ classNames?: TimeInputClassNames;
88
+ }
89
+ export type TimeInputProps = _TimeInputProps & Omit<InputProps, "value" | "defaultValue" | "onChange" | "readOnly" | "classNames">;
90
+ export interface TimeInputFactoryPayload extends FactoryPayload {
91
+ props: TimeInputProps;
92
+ ref: HTMLInputElement;
93
+ compound: {
94
+ configure: ReturnType<typeof createComponentConfig<TimeInputProps>>;
95
+ classNames: ReturnType<typeof createClassNamesConfig<TimeInputClassNames>>;
96
+ };
97
+ }
98
+ export {};
99
+ //# sourceMappingURL=time-input.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-input.types.d.ts","sourceRoot":"","sources":["../../../src/components/time-input/time-input.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,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AsD;IACtD,kBAAkB,CAAC,EAAE,2BAA2B,CAAC;IAEjD,sDAAsD;IACtD,kBAAkB,CAAC,EAAE,2BAA2B,CAAC;IAEjD,iFAAiF;IACjF,WAAW,CAAC,EAAE,oBAAoB,CAAC;IAEnC,6CAA6C;IAC7C,WAAW,CAAC,EAAE,oBAAoB,CAAC;IAEnC,oCAAoC;IACpC,WAAW,CAAC,EAAE,oBAAoB,CAAC;IAEnC,6DAA6D;IAC7D,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,wDAAwD;IACxD,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B,qDAAqD;IACrD,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,gEAAgE;IAChE,eAAe,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,SAAS,CAAC,CAAC;IAEhE,mDAAmD;IACnD,eAAe,CAAC,EAAE,oBAAoB,CAAC;IAEvC,wCAAwC;IACxC,UAAU,CAAC,EAAE,mBAAmB,CAAC;CACpC;AAED,MAAM,MAAM,cAAc,GAAG,eAAe,GACxC,IAAI,CACA,UAAU,EACV,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,CACpE,CAAC;AAEN,MAAM,WAAW,uBAAwB,SAAQ,cAAc;IAC3D,KAAK,EAAE,cAAc,CAAC;IACtB,GAAG,EAAE,gBAAgB,CAAC;IACtB,QAAQ,EAAE;QACN,SAAS,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,cAAc,CAAC,CAAC,CAAC;QACpE,UAAU,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,mBAAmB,CAAC,CAAC,CAAC;KAC9E,CAAC;CACL"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export { default as TimePicker } from "./time-picker";
2
+ export type { TimePickerClassNames, TimePickerGetHourAriaLabel, TimePickerGetHourLabel, TimePickerGetMinuteAriaLabel, TimePickerGetMinuteLabel, TimePickerGetPeriodAriaLabel, TimePickerGetPeriodLabel, TimePickerGetSecondAriaLabel, TimePickerGetSecondLabel, TimePickerMode, TimePickerOnChange, TimePickerPeriod, TimePickerProps, TimePickerRadius, TimePickerSize, TimePickerValue } from "./time-picker.types";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/time-picker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,YAAY,EACR,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,EACxB,4BAA4B,EAC5B,wBAAwB,EACxB,4BAA4B,EAC5B,wBAAwB,EACxB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,eAAe,EAClB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1 @@
1
+ export { default as TimePicker } from "./time-picker";
@@ -0,0 +1,4 @@
1
+ import { TimePickerFactoryPayload } from "./time-picker.types";
2
+ declare const TimePicker: import("@refraktor/core").RefraktorComponent<TimePickerFactoryPayload>;
3
+ export default TimePicker;
4
+ //# sourceMappingURL=time-picker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-picker.d.ts","sourceRoot":"","sources":["../../../src/components/time-picker/time-picker.tsx"],"names":[],"mappings":"AAWA,OAAO,EAEH,wBAAwB,EAK3B,MAAM,qBAAqB,CAAC;AA4S7B,QAAA,MAAM,UAAU,wEA4Zd,CAAC;AAMH,eAAe,UAAU,CAAC"}