@caratlogic/design-system 0.1.5 → 0.1.6
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/molecules/TimePicker/TimePicker.d.ts +3 -0
- package/dist/components/molecules/TimePicker/TimePicker.d.ts.map +1 -0
- package/dist/components/molecules/TimePicker/TimePicker.parts.d.ts +8 -0
- package/dist/components/molecules/TimePicker/TimePicker.parts.d.ts.map +1 -0
- package/dist/components/molecules/TimePicker/TimePicker.types.d.ts +33 -0
- package/dist/components/molecules/TimePicker/TimePicker.types.d.ts.map +1 -0
- package/dist/components/molecules/TimePicker/TimePicker.utils.d.ts +20 -0
- package/dist/components/molecules/TimePicker/TimePicker.utils.d.ts.map +1 -0
- package/dist/components/molecules/TimePicker/index.d.ts +3 -0
- package/dist/components/molecules/TimePicker/index.d.ts.map +1 -0
- package/dist/index.cjs.js +154 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +154 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { TimePickerProps } from './TimePicker.types';
|
|
2
|
+
export declare function TimePicker({ value, onChange, onBlur, name, className, disabled, placeholder, use24Hour, minuteStep, hideFooter, }: TimePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
//# sourceMappingURL=TimePicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimePicker.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/TimePicker/TimePicker.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAY1D,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,WAA2B,EAC3B,SAAiB,EACjB,UAAc,EACd,UAAkB,GACnB,EAAE,eAAe,2CAiJjB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TimeColumnProps } from './TimePicker.types';
|
|
2
|
+
/**
|
|
3
|
+
* One scrolling column of the picker (hours, minutes or period). The selected
|
|
4
|
+
* row is scrolled into view whenever it changes, so reopening the popover lands
|
|
5
|
+
* on the current value instead of at midnight.
|
|
6
|
+
*/
|
|
7
|
+
export declare function TimeColumn({ label, options, selected, onSelect, }: TimeColumnProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=TimePicker.parts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimePicker.parts.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/TimePicker/TimePicker.parts.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,EAAE,eAAe,2CAmDjB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface TimePickerProps {
|
|
2
|
+
/** 24-hour `HH:mm` (`HH:mm:ss` is accepted and truncated). Empty when unset. */
|
|
3
|
+
value?: string;
|
|
4
|
+
/** Fires with `HH:mm`, or `undefined` when cleared. */
|
|
5
|
+
onChange: (value: string | undefined) => void;
|
|
6
|
+
onBlur?: () => void;
|
|
7
|
+
name?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
/** Show and pick in 24-hour time. The stored value is always 24-hour. */
|
|
12
|
+
use24Hour?: boolean;
|
|
13
|
+
/** Granularity of the minute column. @default 1 */
|
|
14
|
+
minuteStep?: number;
|
|
15
|
+
/** Hide the Clear / Now row under the columns. */
|
|
16
|
+
hideFooter?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface ParsedTime {
|
|
19
|
+
/** 0–23. */
|
|
20
|
+
hour: number;
|
|
21
|
+
/** 0–59. */
|
|
22
|
+
minute: number;
|
|
23
|
+
}
|
|
24
|
+
export interface TimeColumnProps {
|
|
25
|
+
label: string;
|
|
26
|
+
options: {
|
|
27
|
+
value: number;
|
|
28
|
+
label: string;
|
|
29
|
+
}[];
|
|
30
|
+
selected: number | null;
|
|
31
|
+
onSelect: (value: number) => void;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=TimePicker.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimePicker.types.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/TimePicker/TimePicker.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC9C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,YAAY;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,YAAY;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ParsedTime } from './TimePicker.types';
|
|
2
|
+
/** Reads `HH:mm` / `HH:mm:ss`. Returns null for anything out of range. */
|
|
3
|
+
export declare function parseTimeValue(value?: string): ParsedTime | null;
|
|
4
|
+
/** The stored form — always 24-hour, whatever the display format. */
|
|
5
|
+
export declare function toTimeValue(hour: number, minute: number): string;
|
|
6
|
+
export declare function formatTimeDisplay(time: ParsedTime, use24Hour: boolean): string;
|
|
7
|
+
export declare function buildHourOptions(use24Hour: boolean): {
|
|
8
|
+
value: number;
|
|
9
|
+
label: string;
|
|
10
|
+
}[];
|
|
11
|
+
export declare function buildMinuteOptions(step: number): {
|
|
12
|
+
value: number;
|
|
13
|
+
label: string;
|
|
14
|
+
}[];
|
|
15
|
+
/** The hour as the 12-hour column shows it (12, 1…11). */
|
|
16
|
+
export declare function toHour12(hour: number): number;
|
|
17
|
+
/** Rebuilds a 24-hour hour from a 12-hour column value and its period. */
|
|
18
|
+
export declare function fromHour12(hour12: number, period: 'AM' | 'PM'): number;
|
|
19
|
+
export declare function periodOf(hour: number): 'AM' | 'PM';
|
|
20
|
+
//# sourceMappingURL=TimePicker.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimePicker.utils.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/TimePicker/TimePicker.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMrD,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAShE;AAED,qEAAqE;AACrE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,OAAO,GACjB,MAAM,CAMR;AAED,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,OAAO,GACjB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CAYpC;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,GACX;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CAOpC;AAED,0DAA0D;AAC1D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,CAGtE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAElD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/TimePicker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -28609,7 +28609,7 @@ function Modal({ open, onClose, title, icon, children, footer, size = 'md', hide
|
|
|
28609
28609
|
return (jsxRuntime.jsx(Dialog, { open: open, onOpenChange: (o) => !o && onClose(), children: jsxRuntime.jsxs(DialogContent, { hideCloseButton: true, style: {
|
|
28610
28610
|
width: `min(${maxWidth}px, calc(100vw - 2rem))`,
|
|
28611
28611
|
maxWidth: `${maxWidth}px`,
|
|
28612
|
-
}, className: cn('flex max-h-[calc(100vh-2rem)] flex-col gap-0 overflow-hidden p-0 sm:max-w-none', className), children: [jsxRuntime.jsxs("header", { className: "flex items-center justify-between gap-4 border-b border-border px-6 py-4", children: [jsxRuntime.jsx(DialogPrimitive__namespace.Title, { asChild: true, children: jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-base font-medium text-foreground", children: [icon, jsxRuntime.jsx("span", { children: title })] }) }), !hideCloseButton && (jsxRuntime.jsx(DialogPrimitive__namespace.Close, { "aria-label": "Close", className: "inline-flex h-8 w-8 items-center justify-center rounded-md text-label transition-colors hover:bg-
|
|
28612
|
+
}, className: cn('flex max-h-[calc(100vh-2rem)] flex-col gap-0 overflow-hidden p-0 sm:max-w-none', className), children: [jsxRuntime.jsxs("header", { className: "flex items-center justify-between gap-4 border-b border-border px-6 py-4", children: [jsxRuntime.jsx(DialogPrimitive__namespace.Title, { asChild: true, children: jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-base font-medium text-foreground", children: [icon, jsxRuntime.jsx("span", { children: title })] }) }), !hideCloseButton && (jsxRuntime.jsx(DialogPrimitive__namespace.Close, { "aria-label": "Close", className: "inline-flex h-8 w-8 items-center justify-center rounded-md text-label transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30", children: jsxRuntime.jsx(X$2, { className: "h-4 w-4" }) }))] }), jsxRuntime.jsx("div", { className: cn('flex-1 overflow-y-auto', bodyClassName), children: children }), footer && (jsxRuntime.jsx("footer", { className: "flex items-center justify-end gap-3 border-t border-border px-6 py-4", children: footer }))] }) }));
|
|
28613
28613
|
}
|
|
28614
28614
|
|
|
28615
28615
|
/**
|
|
@@ -57696,6 +57696,158 @@ function TagsInput({ value, onChange, placeholder, helperText, uppercase = false
|
|
|
57696
57696
|
return (jsxRuntime.jsxs("div", { className: "w-full", children: [jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntime.jsx(Input, { value: input, onChange: onInputChange, onKeyDown: onInputKeyDown, placeholder: placeholder || 'Type and Press Enter', className: "flex-1 bg-formInput" }), jsxRuntime.jsxs(Button$1, { type: "button", onClick: addTag, disabled: addDisabled, className: "h-9 gap-1.5 disabled:opacity-50", children: [jsxRuntime.jsx(Plus, { className: "h-4 w-4" }), "Add"] })] }), helperText && (jsxRuntime.jsx("p", { className: "mt-1.5 text-xs text-muted-foreground", children: helperText })), value.length > 0 && (jsxRuntime.jsx("div", { className: "mt-3 flex flex-wrap gap-2", children: value.map((tag, idx) => (jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-1.5 rounded-md border border-border bg-secondary px-2 py-1 text-xs font-medium text-foreground", children: [tag, jsxRuntime.jsx("button", { type: "button", onClick: () => removeTag(idx), "aria-label": `Remove ${tag}`, className: "cursor-pointer text-muted-foreground transition-colors hover:text-foreground", children: jsxRuntime.jsx(X$2, { className: "h-3 w-3" }) })] }, idx))) }))] }));
|
|
57697
57697
|
}
|
|
57698
57698
|
|
|
57699
|
+
/**
|
|
57700
|
+
* One scrolling column of the picker (hours, minutes or period). The selected
|
|
57701
|
+
* row is scrolled into view whenever it changes, so reopening the popover lands
|
|
57702
|
+
* on the current value instead of at midnight.
|
|
57703
|
+
*/
|
|
57704
|
+
function TimeColumn({ label, options, selected, onSelect, }) {
|
|
57705
|
+
const listRef = React.useRef(null);
|
|
57706
|
+
const activeRef = React.useRef(null);
|
|
57707
|
+
React.useEffect(() => {
|
|
57708
|
+
const list = listRef.current;
|
|
57709
|
+
const active = activeRef.current;
|
|
57710
|
+
if (!list || !active)
|
|
57711
|
+
return;
|
|
57712
|
+
// `scrollIntoView` would scroll the page as well as the column.
|
|
57713
|
+
list.scrollTop =
|
|
57714
|
+
active.offsetTop - list.clientHeight / 2 + active.clientHeight / 2;
|
|
57715
|
+
}, [selected]);
|
|
57716
|
+
return (jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-col", children: [jsxRuntime.jsx("span", { className: "px-1 pb-1.5 text-center text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: label }), jsxRuntime.jsx("div", { ref: listRef, role: "listbox", "aria-label": label, className: "scrollbar-thin h-[184px] overflow-y-auto px-1", children: jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: options.map((option) => {
|
|
57717
|
+
const isSelected = option.value === selected;
|
|
57718
|
+
return (jsxRuntime.jsx("button", { ref: isSelected ? activeRef : undefined, type: "button", role: "option", "aria-selected": isSelected, onClick: () => onSelect(option.value), className: cn('rounded-md px-3 py-1.5 text-center text-sm tabular-nums transition-colors', 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', isSelected
|
|
57719
|
+
? 'bg-primary text-primary-foreground'
|
|
57720
|
+
: 'text-foreground hover:bg-muted'), children: option.label }, option.value));
|
|
57721
|
+
}) }) })] }));
|
|
57722
|
+
}
|
|
57723
|
+
|
|
57724
|
+
const TIME_PATTERN = /^(\d{1,2}):(\d{2})(?::\d{2})?$/;
|
|
57725
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
57726
|
+
/** Reads `HH:mm` / `HH:mm:ss`. Returns null for anything out of range. */
|
|
57727
|
+
function parseTimeValue(value) {
|
|
57728
|
+
const match = TIME_PATTERN.exec((value ?? '').trim());
|
|
57729
|
+
if (!match)
|
|
57730
|
+
return null;
|
|
57731
|
+
const hour = Number(match[1]);
|
|
57732
|
+
const minute = Number(match[2]);
|
|
57733
|
+
if (hour > 23 || minute > 59)
|
|
57734
|
+
return null;
|
|
57735
|
+
return { hour, minute };
|
|
57736
|
+
}
|
|
57737
|
+
/** The stored form — always 24-hour, whatever the display format. */
|
|
57738
|
+
function toTimeValue(hour, minute) {
|
|
57739
|
+
return `${pad(hour)}:${pad(minute)}`;
|
|
57740
|
+
}
|
|
57741
|
+
function formatTimeDisplay(time, use24Hour) {
|
|
57742
|
+
if (use24Hour)
|
|
57743
|
+
return toTimeValue(time.hour, time.minute);
|
|
57744
|
+
// 0 and 12 both map to 12 — midnight is 12 AM, noon is 12 PM.
|
|
57745
|
+
const hour12 = time.hour % 12 === 0 ? 12 : time.hour % 12;
|
|
57746
|
+
const period = time.hour < 12 ? 'AM' : 'PM';
|
|
57747
|
+
return `${pad(hour12)}:${pad(time.minute)} ${period}`;
|
|
57748
|
+
}
|
|
57749
|
+
function buildHourOptions(use24Hour) {
|
|
57750
|
+
if (use24Hour) {
|
|
57751
|
+
return Array.from({ length: 24 }, (_, hour) => ({
|
|
57752
|
+
value: hour,
|
|
57753
|
+
label: pad(hour),
|
|
57754
|
+
}));
|
|
57755
|
+
}
|
|
57756
|
+
// 12 first, matching how a clock reads.
|
|
57757
|
+
return Array.from({ length: 12 }, (_, index) => {
|
|
57758
|
+
const hour12 = index === 0 ? 12 : index;
|
|
57759
|
+
return { value: hour12, label: pad(hour12) };
|
|
57760
|
+
});
|
|
57761
|
+
}
|
|
57762
|
+
function buildMinuteOptions(step) {
|
|
57763
|
+
const safeStep = Number.isFinite(step) && step > 0 ? Math.floor(step) : 1;
|
|
57764
|
+
const options = [];
|
|
57765
|
+
for (let minute = 0; minute < 60; minute += safeStep) {
|
|
57766
|
+
options.push({ value: minute, label: pad(minute) });
|
|
57767
|
+
}
|
|
57768
|
+
return options;
|
|
57769
|
+
}
|
|
57770
|
+
/** The hour as the 12-hour column shows it (12, 1…11). */
|
|
57771
|
+
function toHour12(hour) {
|
|
57772
|
+
return hour % 12 === 0 ? 12 : hour % 12;
|
|
57773
|
+
}
|
|
57774
|
+
/** Rebuilds a 24-hour hour from a 12-hour column value and its period. */
|
|
57775
|
+
function fromHour12(hour12, period) {
|
|
57776
|
+
const base = hour12 % 12;
|
|
57777
|
+
return period === 'PM' ? base + 12 : base;
|
|
57778
|
+
}
|
|
57779
|
+
function periodOf(hour) {
|
|
57780
|
+
return hour < 12 ? 'AM' : 'PM';
|
|
57781
|
+
}
|
|
57782
|
+
|
|
57783
|
+
// Only one TimePicker popover should be open at a time — same coordination the
|
|
57784
|
+
// DateInput uses, for the same reason: each is its own `modal` Radix Popover, so
|
|
57785
|
+
// opening a second does not dismiss the first by outside-click.
|
|
57786
|
+
const TIMEPICKER_OPEN_EVENT = 'caratlogic:timepicker-open';
|
|
57787
|
+
const PERIOD_OPTIONS = [
|
|
57788
|
+
{ value: 0, label: 'AM' },
|
|
57789
|
+
{ value: 1, label: 'PM' },
|
|
57790
|
+
];
|
|
57791
|
+
function TimePicker({ value, onChange, onBlur, name, className, disabled, placeholder = 'Select time', use24Hour = false, minuteStep = 1, hideFooter = false, }) {
|
|
57792
|
+
const [open, setOpen] = React.useState(false);
|
|
57793
|
+
const instanceId = React.useId();
|
|
57794
|
+
const parsed = parseTimeValue(value);
|
|
57795
|
+
React.useEffect(() => {
|
|
57796
|
+
const onOtherOpen = (e) => {
|
|
57797
|
+
if (e.detail !== instanceId)
|
|
57798
|
+
setOpen(false);
|
|
57799
|
+
};
|
|
57800
|
+
window.addEventListener(TIMEPICKER_OPEN_EVENT, onOtherOpen);
|
|
57801
|
+
return () => window.removeEventListener(TIMEPICKER_OPEN_EVENT, onOtherOpen);
|
|
57802
|
+
}, [instanceId]);
|
|
57803
|
+
const handleOpenChange = (next) => {
|
|
57804
|
+
setOpen(next);
|
|
57805
|
+
if (next) {
|
|
57806
|
+
window.dispatchEvent(new CustomEvent(TIMEPICKER_OPEN_EVENT, { detail: instanceId }));
|
|
57807
|
+
}
|
|
57808
|
+
};
|
|
57809
|
+
/** Picking one column before the others commits against a 00:00 baseline. */
|
|
57810
|
+
const commit = (hour, minute) => {
|
|
57811
|
+
onChange(toTimeValue(hour, minute));
|
|
57812
|
+
};
|
|
57813
|
+
const handleHour = (picked) => {
|
|
57814
|
+
const minute = parsed?.minute ?? 0;
|
|
57815
|
+
if (use24Hour) {
|
|
57816
|
+
commit(picked, minute);
|
|
57817
|
+
return;
|
|
57818
|
+
}
|
|
57819
|
+
commit(fromHour12(picked, parsed ? periodOf(parsed.hour) : 'AM'), minute);
|
|
57820
|
+
};
|
|
57821
|
+
const handleMinute = (picked) => {
|
|
57822
|
+
commit(parsed?.hour ?? 0, picked);
|
|
57823
|
+
};
|
|
57824
|
+
const handlePeriod = (picked) => {
|
|
57825
|
+
const period = picked === 0 ? 'AM' : 'PM';
|
|
57826
|
+
const hour12 = parsed ? toHour12(parsed.hour) : 12;
|
|
57827
|
+
commit(fromHour12(hour12, period), parsed?.minute ?? 0);
|
|
57828
|
+
};
|
|
57829
|
+
const selectedHour = parsed
|
|
57830
|
+
? use24Hour
|
|
57831
|
+
? parsed.hour
|
|
57832
|
+
: toHour12(parsed.hour)
|
|
57833
|
+
: null;
|
|
57834
|
+
// NOTE: `open` is driven from the button's onClick rather than
|
|
57835
|
+
// <PopoverTrigger>, matching DateInput — inside a modal <SlideOut> the
|
|
57836
|
+
// trigger's built-in toggle does not fire in Safari. <PopoverAnchor> is pure
|
|
57837
|
+
// positioning, so a single controlled toggle stays the only source of truth.
|
|
57838
|
+
return (jsxRuntime.jsxs(Popover, { open: open, onOpenChange: handleOpenChange, modal: true, children: [jsxRuntime.jsx(PopoverAnchor, { asChild: true, children: jsxRuntime.jsxs("button", { type: "button", name: name, onBlur: onBlur, disabled: disabled, "aria-haspopup": "dialog", "aria-expanded": open, onClick: () => {
|
|
57839
|
+
if (!disabled)
|
|
57840
|
+
handleOpenChange(!open);
|
|
57841
|
+
}, "data-slot": "input", "data-empty": !parsed || undefined, className: cn('border-input-border flex h-9 w-full min-w-0 cursor-pointer items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-1 text-left shadow-[0_1px_2px_0_#0000000d] transition-[color,box-shadow] outline-none', 'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]', 'aria-invalid:ring-destructive/20 aria-invalid:border-destructive', disabled && 'cursor-not-allowed bg-muted/50 text-label', className), children: [jsxRuntime.jsx("span", { className: cn('truncate text-sm md:text-sm', parsed ? 'text-foreground' : 'text-placeholder'), children: parsed ? formatTimeDisplay(parsed, use24Hour) : placeholder }), jsxRuntime.jsx("span", { className: "inline-flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground", children: jsxRuntime.jsx(Clock, { className: "h-4 w-4 stroke-[1.75]" }) })] }) }), jsxRuntime.jsxs(PopoverContent, { align: "start", className: "w-auto p-3", children: [jsxRuntime.jsxs("div", { className: "flex gap-1", children: [jsxRuntime.jsx(TimeColumn, { label: "Hour", options: buildHourOptions(use24Hour), selected: selectedHour, onSelect: handleHour }), jsxRuntime.jsx(TimeColumn, { label: "Min", options: buildMinuteOptions(minuteStep), selected: parsed?.minute ?? null, onSelect: handleMinute }), !use24Hour && (jsxRuntime.jsx(TimeColumn, { label: "AM/PM", options: PERIOD_OPTIONS, selected: parsed ? (periodOf(parsed.hour) === 'AM' ? 0 : 1) : null, onSelect: handlePeriod }))] }), !hideFooter && (jsxRuntime.jsxs("div", { className: "mt-2 flex items-center justify-between gap-2 border-t border-border pt-2", children: [jsxRuntime.jsx("button", { type: "button", onClick: () => {
|
|
57842
|
+
onChange(undefined);
|
|
57843
|
+
setOpen(false);
|
|
57844
|
+
}, className: "rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: "Clear" }), jsxRuntime.jsx("button", { type: "button", onClick: () => {
|
|
57845
|
+
const now = new Date();
|
|
57846
|
+
commit(now.getHours(), now.getMinutes());
|
|
57847
|
+
setOpen(false);
|
|
57848
|
+
}, className: "rounded-md px-2 py-1 text-xs font-medium text-primary transition-colors hover:text-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: "Now" })] }))] })] }));
|
|
57849
|
+
}
|
|
57850
|
+
|
|
57699
57851
|
function mapToItem(w, separator) {
|
|
57700
57852
|
const id = w.id || w.warehouseId || '';
|
|
57701
57853
|
if (!id)
|
|
@@ -67858,6 +68010,7 @@ exports.TabsList = TabsList;
|
|
|
67858
68010
|
exports.TabsTrigger = TabsTrigger;
|
|
67859
68011
|
exports.TagsInput = TagsInput;
|
|
67860
68012
|
exports.TextHyperlink = TextHyperlink;
|
|
68013
|
+
exports.TimePicker = TimePicker;
|
|
67861
68014
|
exports.ToggleSwitch = ToggleSwitch;
|
|
67862
68015
|
exports.TruncateTooltip = TruncateTooltip;
|
|
67863
68016
|
exports.WarehouseComboBox = WarehouseComboBox;
|