@cboxdk/cbox-ui 0.18.0 → 0.19.1

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/README.md CHANGED
@@ -134,6 +134,8 @@ below 768px so iOS does not zoom. The few words the components say themselves ("
134
134
  | `Combobox` | The select (native `<select>` is not used). A 36px trigger that never changes size; the panel is portalled (into the Sheet it sits in, else `<body>`) and placed against the trigger, so an `overflow: hidden` parent never clips it, it opens upwards near the bottom of the screen, and it is at least 16rem wide (up to 22rem for long labels). Search, groups, avatars, `footerLink`, value mode (`value` + `onChange`) or navigation mode (`href` + `LinkComponent`). `onCreate(query)` adds a "Create “…”" row when what was typed matches no label; return a promise to show a spinner until it settles. `createLabel(query)` changes its text. Escape closes only the panel. |
135
135
  | `TagInput` | Tags as chips in one field: Enter adds the highlighted suggestion or what was typed, a comma (or a pasted list) adds the text as typed, Backspace in the empty input removes the last chip, × removes one. `suggestions` (Combobox options) filter as the person types; `creatable={false}` allows suggestions only. `normalize` cleans what was typed into a tag (do the housekeeping there: lower case, spaces to dashes; the "Add “…”" row shows the result), `maxLength` cuts a longer tag to length, `validate(tag)` for what cannot be cleaned up, `maxTags`: a problem shows in the list's place and is announced, the field does not move. Takes its label, hint and error from a `Field`. |
136
136
  | `DatePicker` | A calendar day as `YYYY-MM-DD` (or `null`), never a timestamp: a 36px trigger like the Combobox and a month calendar in a portalled panel sized to the calendar, not the trigger. Month and weekday names, the format and the first day of the week follow the host's locale. `min`/`max` refuse days outside, `presets` adds quick picks beside "Today", "Clear" empties it unless `required`. Arrows move a day or a week, Page Up/Down a month (Shift: a year), Home/End the week, Enter picks, Escape returns to the trigger; focus moves into the calendar with a keyboard or mouse, never on a tap. Takes its label, hint and error from a `Field`. |
137
+ | `TimePicker` | A time of day as `HH:MM` (24-hour) or `null`, shown in the locale (24-hour or AM/PM): a field to type in and the times at `step` minutes (default 15). Typing understands "930", "9.30", "21:30", "9pm"; Enter takes a typed time even off the step. `min`/`max`, `clearable`, `required`. |
138
+ | `DateTimePicker` | A DatePicker and a TimePicker side by side, valued as `YYYY-MM-DDTHH:MM` like `<input type="datetime-local">`. A day picked first gets `defaultTime` (09:00); `min`/`max` bound both. |
137
139
  | `Spinner` | The indeterminate progress ring. Silent by default; `label` makes it a live status. |
138
140
 
139
141
  ### Charts
package/dist/index.d.ts CHANGED
@@ -1608,6 +1608,67 @@ type DatePickerProps = Pick<AriaAttributes, 'aria-describedby' | 'aria-invalid'>
1608
1608
  };
1609
1609
  declare function DatePicker(props: DatePickerProps): react_jsx_runtime.JSX.Element;
1610
1610
 
1611
+ /**
1612
+ * TimePicker — a time of day as `HH:MM` (24-hour, or `null`), in place of `<input type="time">`.
1613
+ * The Combobox's trigger and a panel with a field to type in and the times at `step` minutes to
1614
+ * pick from. Typing understands how people write a time ("930", "9.30", "21:30", "9pm", "9:30 am");
1615
+ * Enter takes what was typed even off the step, and the list follows it. Shown on a 24-hour clock
1616
+ * unless `hourCycle="h12"` asks for AM/PM; always stored in 24-hour.
1617
+ */
1618
+ type TimePickerProps = Pick<AriaAttributes, 'aria-describedby' | 'aria-invalid'> & {
1619
+ /** The time as `HH:MM`, or `null`. */
1620
+ value: string | null;
1621
+ onChange: (value: string | null) => void;
1622
+ /** Minutes between the times in the list. Default 15. */
1623
+ step?: number;
1624
+ /** `h23` shows 21:30 (default), `h12` shows 9:30 PM. Typing understands both either way. */
1625
+ hourCycle?: HourCycle;
1626
+ /** The earliest time, `HH:MM`. */
1627
+ min?: string;
1628
+ /** The latest time, `HH:MM`. */
1629
+ max?: string;
1630
+ /** Shown in the trigger without a value. Default "Pick a time". */
1631
+ placeholder?: string;
1632
+ /** Offer "Clear" in the panel. Default true; ignored when `required`. */
1633
+ clearable?: boolean;
1634
+ disabled?: boolean;
1635
+ required?: boolean;
1636
+ ariaLabel?: string;
1637
+ triggerWidth?: 'auto' | 'full';
1638
+ id?: string;
1639
+ className?: string;
1640
+ };
1641
+ type HourCycle = 'h23' | 'h12';
1642
+ declare function TimePicker(props: TimePickerProps): react_jsx_runtime.JSX.Element;
1643
+ /**
1644
+ * DateTimePicker — a day and a time as `YYYY-MM-DDTHH:MM` in the reader's own clock (the value of
1645
+ * `<input type="datetime-local">`, so a form swaps one for the other), or `null`. A DatePicker and a
1646
+ * TimePicker side by side: a day picked first gets `defaultTime`, a time picked first gets today.
1647
+ */
1648
+ type DateTimePickerProps = Pick<AriaAttributes, 'aria-describedby' | 'aria-invalid'> & {
1649
+ value: string | null;
1650
+ onChange: (value: string | null) => void;
1651
+ /** The earliest moment, `YYYY-MM-DDTHH:MM`. Days before it cannot be picked. */
1652
+ min?: string;
1653
+ /** The latest moment, `YYYY-MM-DDTHH:MM`. Days after it cannot be picked. */
1654
+ max?: string;
1655
+ /** The time a day gets when it is picked first. Default `09:00`. */
1656
+ defaultTime?: string;
1657
+ /** Minutes between the times in the list. Default 15. */
1658
+ step?: number;
1659
+ /** `h23` (default) or `h12`, as on TimePicker. */
1660
+ hourCycle?: HourCycle;
1661
+ clearable?: boolean;
1662
+ disabled?: boolean;
1663
+ required?: boolean;
1664
+ ariaLabel?: string;
1665
+ id?: string;
1666
+ className?: string;
1667
+ };
1668
+ declare function DateTimePicker({ value, onChange, min, max, defaultTime, step, hourCycle, clearable, disabled, required, ariaLabel, id, className, ...aria }: DateTimePickerProps): react_jsx_runtime.JSX.Element;
1669
+ /** `HH:MM` from how people write a time: "9", "930", "0930", "9:30", "9.30", "9h30", "21 30", "9pm", "9:30 am". */
1670
+ declare function parseTime(text: string): string | null;
1671
+
1611
1672
  type SheetSize = 'sm' | 'md' | 'lg' | 'xl';
1612
1673
  type SheetProps = {
1613
1674
  open: boolean;
@@ -2085,4 +2146,4 @@ declare function Sparkline({ values, color, width, height }: {
2085
2146
  height?: number;
2086
2147
  }): react_jsx_runtime.JSX.Element | null;
2087
2148
 
2088
- export { APP_HUES, AppContent, type AppKey, AppShell, Button, type ButtonProps, type ButtonSize, type ButtonVariant, CHART_PALETTE, CboxAppCatalog, type CboxAppCatalogProps, CboxAppIcon, type CboxAppIconProps, type CboxAppKey, type CboxAppLink, CboxBrand, type CboxBrandProps, type CboxIdContextValue, CboxIdProvider, CboxKnownApp, CboxLocalizationProvider, type CboxNotificationPreviewItem, type CboxNotificationsState, type CboxOrganization, CboxServiceMark, type CboxServiceMarkProps, CboxShell, type CboxShellProps, CboxSurfaces, type CboxSurfacesProps, type CboxTranslationValues, type CboxTranslator, type CboxUser, Checkbox, type CheckboxProps, Combobox, type ComboboxAvatar, type ComboboxGroup, type ComboboxOption, type ComboboxProps, type ContextItem, type ContextLevel, type ContextTone, CreateField, CreateForm, CreateRefField, CreateSubmit, DataPanel, DatePicker, type DatePickerProps, Dialog, DialogClose, type DialogProps, type DialogSize, EmptyState, Field, type FieldControlProps, type FieldProps, Heading, type HelpArticle, type HelpState, type HelpStore, type InboxState, type InferUrlState, Input, type InputProps, KeyValue, KeyValueList, type ListPage, type NavArea, type NavPage, PageHeader, type PageIntent, PageShell, type PageTabSpec, PageTabs, type PageTabsProps, type PageWidth, type PaletteAction, type PaletteRecord, PanelBody, RadioGroup, type RadioGroupProps, type RadioOption, type RealtimeState, type RealtimeStatus, RowLink, type RowLinkProps, SHELL_ICONS, SectionHeader, Sheet, SheetClose, type SheetProps, type SheetSize, type Shell, type ShellAccount, type Link as ShellActionLink, type ShellApp, type ShellBanner, type ShellCatalogState, type ShellCreatable, type ShellCreate, type ShellCreateForm, type ShellCreated, type ShellHelp, type ShellHelpArticle, type ShellIcon, type ShellLinkComponent, type ShellNavigate, type ShellNotifications, type ShellOption, type ShellPreferenceChange, type ShellPreferences, type ShellRecordSearch, type ShellRenderCreate, type ShellTheme, Slider, type SliderProps, Sparkline, Spinner, type SpinnerProps, StatTile, StatusPill, type SupportUpdate, type SurfaceArgs, type SurfaceConfig, type SurfaceController, type SurfaceId, Switch, type SwitchBody, type SwitchProps, TagInput, type TagInputProps, Textarea, type TextareaProps, type Transport, type UrlField, type UrlSchema, applyTheme, buildUrlSearch, buttonClassName, cn, contextTrail, createHelpStore, defineUrlSchema, environmentFor, groupItems, hueFor, initialsOf, interpolate, isLive, pageIntent, parseListPage, parseShellCatalog, parseUrlSearch, quickEnvironments, settingsHref, switchBody, switchPayload, themeBootScript, urlBoolean, urlEnum, urlNumber, urlString, urlStringArray, useCboxId, useCboxIdOptional, useCboxLocalization, useCboxSurfaces, useCboxSurfacesOptional, useDialogClose, useFieldControl, useKnownAppCatalog, useSheetClose, useShellCreate, useShellHelp, useShellPageTitle, withQuery };
2149
+ export { APP_HUES, AppContent, type AppKey, AppShell, Button, type ButtonProps, type ButtonSize, type ButtonVariant, CHART_PALETTE, CboxAppCatalog, type CboxAppCatalogProps, CboxAppIcon, type CboxAppIconProps, type CboxAppKey, type CboxAppLink, CboxBrand, type CboxBrandProps, type CboxIdContextValue, CboxIdProvider, CboxKnownApp, CboxLocalizationProvider, type CboxNotificationPreviewItem, type CboxNotificationsState, type CboxOrganization, CboxServiceMark, type CboxServiceMarkProps, CboxShell, type CboxShellProps, CboxSurfaces, type CboxSurfacesProps, type CboxTranslationValues, type CboxTranslator, type CboxUser, Checkbox, type CheckboxProps, Combobox, type ComboboxAvatar, type ComboboxGroup, type ComboboxOption, type ComboboxProps, type ContextItem, type ContextLevel, type ContextTone, CreateField, CreateForm, CreateRefField, CreateSubmit, DataPanel, DatePicker, type DatePickerProps, DateTimePicker, type DateTimePickerProps, Dialog, DialogClose, type DialogProps, type DialogSize, EmptyState, Field, type FieldControlProps, type FieldProps, Heading, type HelpArticle, type HelpState, type HelpStore, type HourCycle, type InboxState, type InferUrlState, Input, type InputProps, KeyValue, KeyValueList, type ListPage, type NavArea, type NavPage, PageHeader, type PageIntent, PageShell, type PageTabSpec, PageTabs, type PageTabsProps, type PageWidth, type PaletteAction, type PaletteRecord, PanelBody, RadioGroup, type RadioGroupProps, type RadioOption, type RealtimeState, type RealtimeStatus, RowLink, type RowLinkProps, SHELL_ICONS, SectionHeader, Sheet, SheetClose, type SheetProps, type SheetSize, type Shell, type ShellAccount, type Link as ShellActionLink, type ShellApp, type ShellBanner, type ShellCatalogState, type ShellCreatable, type ShellCreate, type ShellCreateForm, type ShellCreated, type ShellHelp, type ShellHelpArticle, type ShellIcon, type ShellLinkComponent, type ShellNavigate, type ShellNotifications, type ShellOption, type ShellPreferenceChange, type ShellPreferences, type ShellRecordSearch, type ShellRenderCreate, type ShellTheme, Slider, type SliderProps, Sparkline, Spinner, type SpinnerProps, StatTile, StatusPill, type SupportUpdate, type SurfaceArgs, type SurfaceConfig, type SurfaceController, type SurfaceId, Switch, type SwitchBody, type SwitchProps, TagInput, type TagInputProps, Textarea, type TextareaProps, TimePicker, type TimePickerProps, type Transport, type UrlField, type UrlSchema, applyTheme, buildUrlSearch, buttonClassName, cn, contextTrail, createHelpStore, defineUrlSchema, environmentFor, groupItems, hueFor, initialsOf, interpolate, isLive, pageIntent, parseListPage, parseShellCatalog, parseTime, parseUrlSearch, quickEnvironments, settingsHref, switchBody, switchPayload, themeBootScript, urlBoolean, urlEnum, urlNumber, urlString, urlStringArray, useCboxId, useCboxIdOptional, useCboxLocalization, useCboxSurfaces, useCboxSurfacesOptional, useDialogClose, useFieldControl, useKnownAppCatalog, useSheetClose, useShellCreate, useShellHelp, useShellPageTitle, withQuery };
package/dist/index.js CHANGED
@@ -6213,6 +6213,289 @@ function CalendarIcon() {
6213
6213
  function Arrow({ direction }) {
6214
6214
  return /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: direction === "left" ? "M8.5 3.5 5 7l3.5 3.5" : "M5.5 3.5 9 7l-3.5 3.5" }) });
6215
6215
  }
6216
+ var useIsoLayoutEffect6 = typeof window === "undefined" ? useEffect : useLayoutEffect;
6217
+ function TimePicker(props) {
6218
+ const { locale, t } = useCboxLocalization();
6219
+ const field = useFieldControl();
6220
+ const {
6221
+ value,
6222
+ onChange,
6223
+ step = 15,
6224
+ hourCycle = "h23",
6225
+ min,
6226
+ max,
6227
+ placeholder = t("Pick a time"),
6228
+ clearable = true,
6229
+ disabled = false,
6230
+ required = field.required ?? false,
6231
+ ariaLabel,
6232
+ triggerWidth = "auto",
6233
+ className
6234
+ } = props;
6235
+ const reactId = useId();
6236
+ const id = props.id ?? field.id ?? reactId;
6237
+ const listId = `${id}-times`;
6238
+ const picked = parseTime(value ?? "");
6239
+ const format = useMemo(() => timeFormat(locale, hourCycle), [locale, hourCycle]);
6240
+ const [open, setOpen] = useState(false);
6241
+ const [query2, setQuery] = useState("");
6242
+ const [highlight, setHighlight] = useState(-1);
6243
+ const containerRef = useRef(null);
6244
+ const triggerRef = useRef(null);
6245
+ const panelRef = useRef(null);
6246
+ const inputRef = useRef(null);
6247
+ const typedFocus = useRef(false);
6248
+ useAnchoredPanel(open, triggerRef, panelRef, void 0, true);
6249
+ const times = useMemo(() => {
6250
+ const every = Math.max(1, Math.min(720, Math.round(step)));
6251
+ return Array.from({ length: Math.ceil(1440 / every) }, (_, i) => fromMinutes(i * every));
6252
+ }, [step]);
6253
+ const allowed = useCallback((time) => (min === void 0 || time >= min) && (max === void 0 || time <= max), [min, max]);
6254
+ const typed = query2.trim() === "" ? null : parseTime(query2);
6255
+ const refused = query2.trim() !== "" && (typed === null || !allowed(typed));
6256
+ const anchor = typed ?? picked;
6257
+ useEffect(() => {
6258
+ if (!open) return;
6259
+ const at = anchor === null ? times.findIndex(allowed) : times.findIndex((time) => time >= anchor && allowed(time));
6260
+ setHighlight(at);
6261
+ if (at >= 0) requestAnimationFrame(() => centerInList(`${listId}-${at}`));
6262
+ }, [open, anchor, times, allowed, listId]);
6263
+ useIsoLayoutEffect6(() => {
6264
+ if (open) {
6265
+ if (typedFocus.current || finePointer2()) inputRef.current?.focus({ preventScroll: true });
6266
+ return;
6267
+ }
6268
+ setQuery("");
6269
+ }, [open]);
6270
+ useEffect(() => {
6271
+ if (!open) return;
6272
+ function onPointerDown(event) {
6273
+ const target = event.target;
6274
+ if (containerRef.current?.contains(target) || panelRef.current?.contains(target)) return;
6275
+ setOpen(false);
6276
+ }
6277
+ document.addEventListener("pointerdown", onPointerDown, true);
6278
+ return () => document.removeEventListener("pointerdown", onPointerDown, true);
6279
+ }, [open]);
6280
+ const choose = useCallback((time) => {
6281
+ onChange(time);
6282
+ setOpen(false);
6283
+ triggerRef.current?.focus();
6284
+ }, [onChange]);
6285
+ const move = (to) => {
6286
+ setHighlight(to);
6287
+ if (to >= 0) revealInList(`${listId}-${to}`);
6288
+ };
6289
+ const onKeyDown = (event) => {
6290
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
6291
+ event.preventDefault();
6292
+ const direction = event.key === "ArrowDown" ? 1 : -1;
6293
+ let next = highlight;
6294
+ do
6295
+ next += direction;
6296
+ while (next >= 0 && next < times.length && !allowed(times[next] ?? ""));
6297
+ if (next >= 0 && next < times.length) move(next);
6298
+ return;
6299
+ }
6300
+ if (event.key === "Enter") {
6301
+ event.preventDefault();
6302
+ if (typed !== null && allowed(typed)) choose(typed);
6303
+ else if (query2.trim() === "" && highlight >= 0 && times[highlight] !== void 0) choose(times[highlight] ?? null);
6304
+ return;
6305
+ }
6306
+ if (event.key === "Tab") {
6307
+ triggerRef.current?.focus();
6308
+ setOpen(false);
6309
+ }
6310
+ };
6311
+ const panel = open && typeof document !== "undefined" ? createPortal(
6312
+ /* @__PURE__ */ jsxs("div", { ref: panelRef, className: "cbx-ui-combo-panel cbx-ui-time-panel", "data-cbx-scroll-layer": "", children: [
6313
+ /* @__PURE__ */ jsxs("div", { className: "cbx-ui-combo-search-row", children: [
6314
+ /* @__PURE__ */ jsx(ClockIcon, { className: "cbx-ui-combo-search-icon" }),
6315
+ /* @__PURE__ */ jsx(
6316
+ "input",
6317
+ {
6318
+ ref: inputRef,
6319
+ type: "text",
6320
+ inputMode: "numeric",
6321
+ autoComplete: "off",
6322
+ value: query2,
6323
+ onChange: (event) => setQuery(event.target.value),
6324
+ onKeyDown,
6325
+ placeholder: t("Type a time"),
6326
+ "aria-label": t("Type a time"),
6327
+ "aria-invalid": refused || void 0,
6328
+ "aria-controls": listId,
6329
+ "aria-activedescendant": highlight >= 0 && query2.trim() === "" ? `${listId}-${highlight}` : void 0,
6330
+ className: "cbx-ui-combo-search"
6331
+ }
6332
+ )
6333
+ ] }),
6334
+ refused ? /* @__PURE__ */ jsx("p", { className: "cbx-ui-combo-note", role: "status", children: typed === null ? t("Not a time. Try 9:30 or 21:30.") : t("Outside the times allowed here.") }) : typed !== null ? /* @__PURE__ */ jsxs("button", { type: "button", className: "cbx-ui-time-typed", onClick: () => choose(typed), children: [
6335
+ t("Use {time}", { time: format.format(asDate(typed)) }),
6336
+ /* @__PURE__ */ jsx("kbd", { children: "\u21B5" })
6337
+ ] }) : null,
6338
+ /* @__PURE__ */ jsx("ul", { id: listId, role: "listbox", "aria-label": ariaLabel ?? placeholder, className: "cbx-ui-combo-list cbx-ui-time-list", children: times.map((time, index) => /* @__PURE__ */ jsx(
6339
+ "li",
6340
+ {
6341
+ id: `${listId}-${index}`,
6342
+ role: "option",
6343
+ tabIndex: -1,
6344
+ "aria-selected": time === picked,
6345
+ "aria-disabled": !allowed(time) || void 0,
6346
+ "data-highlighted": index === highlight ? "" : void 0,
6347
+ "data-active": time === picked ? "" : void 0,
6348
+ className: "cbx-ui-combo-option",
6349
+ onMouseEnter: () => setHighlight(index),
6350
+ onClick: () => allowed(time) && choose(time),
6351
+ children: /* @__PURE__ */ jsx("span", { className: "cbx-ui-combo-label", children: format.format(asDate(time)) })
6352
+ },
6353
+ time
6354
+ )) }),
6355
+ clearable && !required && picked !== null && /* @__PURE__ */ jsx("div", { className: "cbx-ui-date-foot", children: /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-ui-date-chip cbx-ui-date-clear", onClick: () => choose(null), children: t("Clear") }) })
6356
+ ] }),
6357
+ panelContainer(containerRef.current)
6358
+ ) : null;
6359
+ return /* @__PURE__ */ jsxs(
6360
+ "div",
6361
+ {
6362
+ ref: containerRef,
6363
+ className: cn("cbx-ui-combo", triggerWidth === "full" && "cbx-ui-combo--full", className),
6364
+ onKeyDown: (event) => {
6365
+ if (open && event.key === "Escape") {
6366
+ event.preventDefault();
6367
+ event.stopPropagation();
6368
+ setOpen(false);
6369
+ triggerRef.current?.focus();
6370
+ }
6371
+ },
6372
+ children: [
6373
+ /* @__PURE__ */ jsxs(
6374
+ "button",
6375
+ {
6376
+ ref: triggerRef,
6377
+ id,
6378
+ type: "button",
6379
+ disabled,
6380
+ "aria-haspopup": "dialog",
6381
+ "aria-expanded": open,
6382
+ "aria-required": required,
6383
+ "aria-label": ariaLabel !== void 0 ? picked !== null ? `${ariaLabel}: ${format.format(asDate(picked))}` : ariaLabel : void 0,
6384
+ "aria-describedby": props["aria-describedby"] ?? field["aria-describedby"],
6385
+ "aria-invalid": props["aria-invalid"] ?? field["aria-invalid"],
6386
+ className: "cbx-ui-combo-trigger cbx-ui-time-trigger",
6387
+ onClick: (event) => {
6388
+ typedFocus.current = event.detail === 0;
6389
+ setOpen((was) => !was);
6390
+ },
6391
+ onKeyDown: (event) => {
6392
+ if (!open && event.key === "ArrowDown") {
6393
+ event.preventDefault();
6394
+ typedFocus.current = true;
6395
+ setOpen(true);
6396
+ }
6397
+ },
6398
+ children: [
6399
+ /* @__PURE__ */ jsx(ClockIcon, { className: "cbx-ui-combo-icon" }),
6400
+ /* @__PURE__ */ jsx("span", { className: cn("cbx-ui-combo-value", picked === null && "is-placeholder"), children: picked !== null ? format.format(asDate(picked)) : placeholder })
6401
+ ]
6402
+ }
6403
+ ),
6404
+ panel
6405
+ ]
6406
+ }
6407
+ );
6408
+ }
6409
+ function DateTimePicker({ value, onChange, min, max, defaultTime = "09:00", step, hourCycle, clearable = true, disabled, required, ariaLabel, id, className, ...aria }) {
6410
+ const { t } = useCboxLocalization();
6411
+ const [day, time] = splitMoment(value);
6412
+ const minDay = min?.slice(0, 10);
6413
+ const maxDay = max?.slice(0, 10);
6414
+ const minTime = min !== void 0 && day !== null && day === minDay ? min.slice(11, 16) : void 0;
6415
+ const maxTime = max !== void 0 && day !== null && day === maxDay ? max.slice(11, 16) : void 0;
6416
+ return /* @__PURE__ */ jsxs("div", { className: cn("cbx-ui-datetime", className), role: "group", "aria-label": ariaLabel, children: [
6417
+ /* @__PURE__ */ jsx(
6418
+ DatePicker,
6419
+ {
6420
+ ...aria,
6421
+ ...id !== void 0 ? { id } : {},
6422
+ ...minDay !== void 0 ? { min: minDay } : {},
6423
+ ...maxDay !== void 0 ? { max: maxDay } : {},
6424
+ value: day,
6425
+ ariaLabel: t("Date"),
6426
+ clearable,
6427
+ ...disabled !== void 0 ? { disabled } : {},
6428
+ ...required !== void 0 ? { required } : {},
6429
+ onChange: (next) => onChange(next === null ? null : `${next}T${time ?? defaultTime}`)
6430
+ }
6431
+ ),
6432
+ /* @__PURE__ */ jsx(
6433
+ TimePicker,
6434
+ {
6435
+ ...aria,
6436
+ ...minTime !== void 0 ? { min: minTime } : {},
6437
+ ...maxTime !== void 0 ? { max: maxTime } : {},
6438
+ ...step !== void 0 ? { step } : {},
6439
+ ...hourCycle !== void 0 ? { hourCycle } : {},
6440
+ value: time,
6441
+ ariaLabel: t("Time"),
6442
+ clearable: false,
6443
+ ...disabled !== void 0 ? { disabled } : {},
6444
+ onChange: (next) => next !== null && onChange(`${day ?? today2()}T${next}`)
6445
+ }
6446
+ )
6447
+ ] });
6448
+ }
6449
+ function parseTime(text) {
6450
+ const match = /^\s*(\d{1,2})(?:\s*[:.h\s]\s*(\d{2})|(\d{2}))?\s*([ap])?\.?\s*m?\.?\s*$/i.exec(text);
6451
+ if (match === null) return null;
6452
+ let hours = Number(match[1]);
6453
+ const minutes = Number(match[2] ?? match[3] ?? "0");
6454
+ const half = match[4]?.toLowerCase();
6455
+ if (half !== void 0) {
6456
+ if (hours < 1 || hours > 12) return null;
6457
+ hours = hours % 12 + (half === "p" ? 12 : 0);
6458
+ }
6459
+ if (hours > 23 || minutes > 59) return null;
6460
+ return fromMinutes(hours * 60 + minutes);
6461
+ }
6462
+ function fromMinutes(total) {
6463
+ return `${String(Math.floor(total / 60)).padStart(2, "0")}:${String(total % 60).padStart(2, "0")}`;
6464
+ }
6465
+ function asDate(time) {
6466
+ return /* @__PURE__ */ new Date(`1970-01-01T${time}:00Z`);
6467
+ }
6468
+ function splitMoment(value) {
6469
+ const match = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/.exec(value ?? "");
6470
+ return match === null ? [null, null] : [match[1] ?? null, match[2] ?? null];
6471
+ }
6472
+ function today2() {
6473
+ const now = /* @__PURE__ */ new Date();
6474
+ return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`;
6475
+ }
6476
+ function timeFormat(locale, hourCycle) {
6477
+ const options = hourCycle === "h23" ? { hour: "2-digit", minute: "2-digit", hourCycle, timeZone: "UTC" } : { hour: "numeric", minute: "2-digit", hourCycle, timeZone: "UTC" };
6478
+ try {
6479
+ return new Intl.DateTimeFormat(locale.replace("_", "-") || void 0, options);
6480
+ } catch {
6481
+ return new Intl.DateTimeFormat(void 0, options);
6482
+ }
6483
+ }
6484
+ function centerInList(id) {
6485
+ const option = typeof document === "undefined" ? null : document.getElementById(id);
6486
+ const list = option?.closest('[role="listbox"]');
6487
+ if (option == null || list == null) return;
6488
+ list.scrollTop = option.offsetTop - list.clientHeight / 2 + option.offsetHeight / 2;
6489
+ }
6490
+ function finePointer2() {
6491
+ return typeof window !== "undefined" && window.matchMedia?.("(pointer: fine)").matches === true;
6492
+ }
6493
+ function ClockIcon({ className }) {
6494
+ return /* @__PURE__ */ jsxs("svg", { className, width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", "aria-hidden": "true", children: [
6495
+ /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "5.75" }),
6496
+ /* @__PURE__ */ jsx("path", { d: "M8 4.75V8l2.25 1.5" })
6497
+ ] });
6498
+ }
6216
6499
  var Input = forwardRef(function Input2({ scale = "md", className, ...props }, ref) {
6217
6500
  const field = useFieldControl();
6218
6501
  return /* @__PURE__ */ jsx("input", { ref, className: cn("cbx-ui-input", scale === "lg" && "cbx-ui-input--lg", className), ...field, ...props });
@@ -7043,6 +7326,6 @@ function Sparkline({ values, color = "var(--chart-1)", width = 90, height = 20 }
7043
7326
  ] });
7044
7327
  }
7045
7328
 
7046
- export { APP_HUES, AppContent, AppShell, Button, CHART_PALETTE, CboxAppCatalog, CboxAppIcon, CboxBrand, CboxIdProvider, CboxLocalizationProvider, CboxServiceMark, CboxShell, CboxSurfaces, Checkbox, Combobox, CreateField, CreateForm, CreateRefField, CreateSubmit, DataPanel, DatePicker, Dialog, DialogClose, EmptyState, Field, Heading, Input, KeyValue, KeyValueList, PageHeader, PageShell, PageTabs, PanelBody, RadioGroup, RowLink, SHELL_ICONS, SectionHeader, Sheet, SheetClose, Slider, Sparkline, Spinner, StatTile, StatusPill, Switch, TagInput, Textarea, applyTheme, buildUrlSearch, buttonClassName, contextTrail, createHelpStore, defineUrlSchema, environmentFor, groupItems, hueFor, initialsOf, interpolate, isLive, pageIntent, parseListPage, parseShellCatalog, parseUrlSearch, quickEnvironments, settingsHref, switchBody, switchPayload, themeBootScript, urlBoolean, urlEnum, urlNumber, urlString, urlStringArray, useCboxId, useCboxIdOptional, useCboxLocalization, useCboxSurfaces, useCboxSurfacesOptional, useDialogClose, useFieldControl, useKnownAppCatalog, useSheetClose, useShellCreate, useShellHelp, useShellPageTitle, withQuery };
7329
+ export { APP_HUES, AppContent, AppShell, Button, CHART_PALETTE, CboxAppCatalog, CboxAppIcon, CboxBrand, CboxIdProvider, CboxLocalizationProvider, CboxServiceMark, CboxShell, CboxSurfaces, Checkbox, Combobox, CreateField, CreateForm, CreateRefField, CreateSubmit, DataPanel, DatePicker, DateTimePicker, Dialog, DialogClose, EmptyState, Field, Heading, Input, KeyValue, KeyValueList, PageHeader, PageShell, PageTabs, PanelBody, RadioGroup, RowLink, SHELL_ICONS, SectionHeader, Sheet, SheetClose, Slider, Sparkline, Spinner, StatTile, StatusPill, Switch, TagInput, Textarea, TimePicker, applyTheme, buildUrlSearch, buttonClassName, contextTrail, createHelpStore, defineUrlSchema, environmentFor, groupItems, hueFor, initialsOf, interpolate, isLive, pageIntent, parseListPage, parseShellCatalog, parseTime, parseUrlSearch, quickEnvironments, settingsHref, switchBody, switchPayload, themeBootScript, urlBoolean, urlEnum, urlNumber, urlString, urlStringArray, useCboxId, useCboxIdOptional, useCboxLocalization, useCboxSurfaces, useCboxSurfacesOptional, useDialogClose, useFieldControl, useKnownAppCatalog, useSheetClose, useShellCreate, useShellHelp, useShellPageTitle, withQuery };
7047
7330
  //# sourceMappingURL=index.js.map
7048
7331
  //# sourceMappingURL=index.js.map