@cboxdk/cbox-ui 0.17.1 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -120,7 +120,7 @@ Plain CSS in `tokens/controls.css` (`cbx-ui-*` classes in `@layer components`),
120
120
  an app without the tokens import. In a Tailwind v4 app a utility on `className` (`w-full`,
121
121
  `mt-2`) wins over the component's own rule. Light and dark come from the tokens; fields are 16px
122
122
  below 768px so iOS does not zoom. The few words the components say themselves ("Close",
123
- "(required)", "(optional)", "Create “{query}”", "Add “{tag}”", "Remove {tag}", "Add a tag…" and the TagInput messages) go through `CboxLocalizationProvider`; everything else is a prop.
123
+ "(required)", "(optional)", "Create “{query}”", "Add “{tag}”", "Remove {tag}", "Add a tag…", the TagInput messages, and the DatePicker's "Pick a date", "Previous month", "Next month", "Today" and "Clear") go through `CboxLocalizationProvider`; everything else is a prop.
124
124
 
125
125
  | Export | What it does |
126
126
  |---|---|
@@ -133,6 +133,7 @@ below 768px so iOS does not zoom. The few words the components say themselves ("
133
133
  | `Sheet` / `SheetClose` / `useSheetClose` | A modal sheet portalled to `<body>`, never a centred modal: a panel sliding in from the right from 768px (`size` sm / md / lg: 26, 30 or 44rem wide), a bottom sheet on a phone that drags down to close. `title`, `description`, `footer`. Focus moves in (to `autoFocus` / `data-autofocus`, else the first field, else Close, never a footer action), Tab stays inside, the page behind is `inert` and does not scroll, Escape / Close / the scrim close it (`dismissible={false}` keeps the scrim from closing it), and focus goes back to the opener. `SheetClose` is a Button that closes the sheet it is in. `Dialog` / `DialogClose` / `useDialogClose` are deprecated aliases that render the same sheet. |
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
+ | `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`. |
136
137
  | `Spinner` | The indeterminate progress ring. Silent by default; `label` makes it a live status. |
137
138
 
138
139
  ### Charts
package/dist/index.d.ts CHANGED
@@ -1566,6 +1566,48 @@ type CheckboxProps = {
1566
1566
  */
1567
1567
  declare function Checkbox({ checked, onCheckedChange, label, hint, disabled, required, name, value, id: statedId, className }: CheckboxProps): react_jsx_runtime.JSX.Element;
1568
1568
 
1569
+ /**
1570
+ * DatePicker — the Cbox date field. The browser's `<input type="date">` looks different in every
1571
+ * browser, cannot be styled to the tokens and on a phone opens an OS wheel; this is a 36px trigger
1572
+ * like the Combobox and a month calendar in a portalled panel placed by `floating.ts`.
1573
+ *
1574
+ * The value is a calendar day as `YYYY-MM-DD` (or `null`), never a timestamp, so no time zone can
1575
+ * move it. Month and weekday names, the trigger's format and the first day of the week come from
1576
+ * the host's locale (`CboxLocalizationProvider`); the few words go through its translator.
1577
+ *
1578
+ * Keyboard (the WAI-ARIA date picker dialog): the arrows move a day or a week, Page Up/Down a
1579
+ * month (with Shift a year), Home/End the start or end of the week, Enter or Space picks the day,
1580
+ * Escape closes and returns focus to the trigger. Focus moves into the calendar only with a fine
1581
+ * pointer or the keyboard, so a phone does not jump.
1582
+ */
1583
+ type DatePickerProps = Pick<AriaAttributes, 'aria-describedby' | 'aria-invalid'> & {
1584
+ /** The picked day as `YYYY-MM-DD`, or `null`. */
1585
+ value: string | null;
1586
+ /** Called with the picked day, or `null` when cleared. */
1587
+ onChange: (value: string | null) => void;
1588
+ /** The earliest day that can be picked, `YYYY-MM-DD`. */
1589
+ min?: string;
1590
+ /** The latest day that can be picked, `YYYY-MM-DD`. */
1591
+ max?: string;
1592
+ /** Shown in the trigger without a value. Default "Pick a date". */
1593
+ placeholder?: string;
1594
+ /** Offer "Clear" in the panel. Default true; ignored when `required`. */
1595
+ clearable?: boolean;
1596
+ /** Quick picks under the calendar, such as "Tomorrow" or "In a week". */
1597
+ presets?: {
1598
+ label: string;
1599
+ value: string;
1600
+ }[];
1601
+ disabled?: boolean;
1602
+ required?: boolean;
1603
+ ariaLabel?: string;
1604
+ /** Width policy for the trigger. Defaults to `auto` (intrinsic). */
1605
+ triggerWidth?: 'auto' | 'full';
1606
+ id?: string;
1607
+ className?: string;
1608
+ };
1609
+ declare function DatePicker(props: DatePickerProps): react_jsx_runtime.JSX.Element;
1610
+
1569
1611
  type SheetSize = 'sm' | 'md' | 'lg' | 'xl';
1570
1612
  type SheetProps = {
1571
1613
  open: boolean;
@@ -2043,4 +2085,4 @@ declare function Sparkline({ values, color, width, height }: {
2043
2085
  height?: number;
2044
2086
  }): react_jsx_runtime.JSX.Element | null;
2045
2087
 
2046
- 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, 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 };
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 };
package/dist/index.js CHANGED
@@ -4950,7 +4950,7 @@ var MAX_WIDTH = 352;
4950
4950
  function panelContainer(anchor) {
4951
4951
  return anchor?.closest("[data-cbx-dialog-layer], .cbx-overlay") ?? document.body;
4952
4952
  }
4953
- function useAnchoredPanel(open, anchor, panel, remeasure) {
4953
+ function useAnchoredPanel(open, anchor, panel, remeasure, ownWidth = false) {
4954
4954
  useIsoLayoutEffect3(() => {
4955
4955
  const element = panel.current;
4956
4956
  const target = anchor.current;
@@ -4960,8 +4960,8 @@ function useAnchoredPanel(open, anchor, panel, remeasure) {
4960
4960
  const measure = () => {
4961
4961
  const box = target.getBoundingClientRect();
4962
4962
  const room = document.documentElement.clientWidth - 2 * MARGIN2;
4963
- element.style.minWidth = `${Math.min(Math.max(box.width, MIN_WIDTH), room)}px`;
4964
- element.style.maxWidth = `${Math.min(Math.max(box.width, MAX_WIDTH), room)}px`;
4963
+ element.style.minWidth = ownWidth ? "0" : `${Math.min(Math.max(box.width, MIN_WIDTH), room)}px`;
4964
+ element.style.maxWidth = ownWidth ? `${room}px` : `${Math.min(Math.max(box.width, MAX_WIDTH), room)}px`;
4965
4965
  element.style.width = "max-content";
4966
4966
  element.style.maxHeight = "none";
4967
4967
  width = element.offsetWidth;
@@ -4999,7 +4999,7 @@ function useAnchoredPanel(open, anchor, panel, remeasure) {
4999
4999
  window.removeEventListener("resize", resize);
5000
5000
  window.removeEventListener("scroll", place2, true);
5001
5001
  };
5002
- }, [open, anchor, panel, remeasure]);
5002
+ }, [open, anchor, panel, remeasure, ownWidth]);
5003
5003
  }
5004
5004
  var CREATE = "\0create";
5005
5005
  var useIsoLayoutEffect4 = typeof window === "undefined" ? useEffect : useLayoutEffect;
@@ -5922,6 +5922,297 @@ function Checkbox({ checked, onCheckedChange, label, hint, disabled = false, req
5922
5922
  ] })
5923
5923
  ] });
5924
5924
  }
5925
+ var useIsoLayoutEffect5 = typeof window === "undefined" ? useEffect : useLayoutEffect;
5926
+ function DatePicker(props) {
5927
+ const { locale, t } = useCboxLocalization();
5928
+ const field = useFieldControl();
5929
+ const {
5930
+ value,
5931
+ onChange,
5932
+ min,
5933
+ max,
5934
+ placeholder = t("Pick a date"),
5935
+ clearable = true,
5936
+ presets = [],
5937
+ disabled = false,
5938
+ required = field.required ?? false,
5939
+ ariaLabel,
5940
+ triggerWidth = "auto",
5941
+ className
5942
+ } = props;
5943
+ const reactId = useId();
5944
+ const id = props.id ?? field.id ?? reactId;
5945
+ const gridLabelId = `${id}-month`;
5946
+ const picked = isDay(value) ? value : null;
5947
+ const [open, setOpen] = useState(false);
5948
+ const [focused, setFocused] = useState(() => clampDay(picked ?? today(), min, max));
5949
+ const moveFocus = useRef(false);
5950
+ const containerRef = useRef(null);
5951
+ const triggerRef = useRef(null);
5952
+ const panelRef = useRef(null);
5953
+ const gridRef = useRef(null);
5954
+ useAnchoredPanel(open, triggerRef, panelRef, void 0, true);
5955
+ const formats = useMemo(() => formatsFor(locale), [locale]);
5956
+ const firstDay = useMemo(() => firstDayOfWeek(locale), [locale]);
5957
+ const month = focused.slice(0, 7);
5958
+ const weeks = useMemo(() => monthGrid(month, firstDay), [month, firstDay]);
5959
+ const openPanel = useCallback((viaKeyboard) => {
5960
+ setFocused(clampDay(picked ?? today(), min, max));
5961
+ moveFocus.current = viaKeyboard || finePointer();
5962
+ setOpen(true);
5963
+ }, [picked, min, max]);
5964
+ const close = useCallback((refocus) => {
5965
+ setOpen(false);
5966
+ if (refocus) triggerRef.current?.focus();
5967
+ }, []);
5968
+ useIsoLayoutEffect5(() => {
5969
+ if (!open || !moveFocus.current) return;
5970
+ gridRef.current?.querySelector(`[data-day="${focused}"]`)?.focus({ preventScroll: true });
5971
+ }, [open, focused]);
5972
+ useEffect(() => {
5973
+ if (!open) return;
5974
+ function onPointerDown(event) {
5975
+ const target = event.target;
5976
+ if (containerRef.current?.contains(target) || panelRef.current?.contains(target)) return;
5977
+ setOpen(false);
5978
+ }
5979
+ document.addEventListener("pointerdown", onPointerDown, true);
5980
+ return () => document.removeEventListener("pointerdown", onPointerDown, true);
5981
+ }, [open]);
5982
+ const choose = useCallback((day) => {
5983
+ onChange(day);
5984
+ close(true);
5985
+ }, [onChange, close]);
5986
+ const move = useCallback((day) => {
5987
+ moveFocus.current = true;
5988
+ setFocused(clampDay(day, min, max));
5989
+ }, [min, max]);
5990
+ const onGridKeyDown = (event) => {
5991
+ const keys = {
5992
+ ArrowLeft: () => addDays(focused, -1),
5993
+ ArrowRight: () => addDays(focused, 1),
5994
+ ArrowUp: () => addDays(focused, -7),
5995
+ ArrowDown: () => addDays(focused, 7),
5996
+ PageUp: () => addMonths(focused, event.shiftKey ? -12 : -1),
5997
+ PageDown: () => addMonths(focused, event.shiftKey ? 12 : 1),
5998
+ Home: () => addDays(focused, -((weekday(focused) - firstDay + 7) % 7)),
5999
+ End: () => addDays(focused, 6 - (weekday(focused) - firstDay + 7) % 7)
6000
+ };
6001
+ const next = keys[event.key];
6002
+ if (next !== void 0) {
6003
+ event.preventDefault();
6004
+ move(next());
6005
+ }
6006
+ };
6007
+ const canPick = (day) => (min === void 0 || day >= min) && (max === void 0 || day <= max);
6008
+ const prevMonth = addMonths(`${month}-01`, -1);
6009
+ const nextMonth = addMonths(`${month}-01`, 1);
6010
+ const canPrev = min === void 0 || lastOfMonth(prevMonth) >= min;
6011
+ const canNext = max === void 0 || `${nextMonth.slice(0, 7)}-01` <= max;
6012
+ const todayDay = today();
6013
+ const panel = open && typeof document !== "undefined" ? createPortal(
6014
+ /* @__PURE__ */ jsxs(
6015
+ "div",
6016
+ {
6017
+ ref: panelRef,
6018
+ className: "cbx-ui-combo-panel cbx-ui-date-panel",
6019
+ role: "dialog",
6020
+ "aria-modal": "false",
6021
+ "aria-labelledby": gridLabelId,
6022
+ "data-cbx-scroll-layer": "",
6023
+ onBlur: (event) => {
6024
+ const next = event.relatedTarget;
6025
+ if (next !== null && !panelRef.current?.contains(next) && !containerRef.current?.contains(next)) setOpen(false);
6026
+ },
6027
+ children: [
6028
+ /* @__PURE__ */ jsxs("div", { className: "cbx-ui-date-head", children: [
6029
+ /* @__PURE__ */ jsx(
6030
+ "button",
6031
+ {
6032
+ type: "button",
6033
+ className: "cbx-ui-date-nav",
6034
+ "aria-label": t("Previous month"),
6035
+ disabled: !canPrev,
6036
+ onClick: () => setFocused(clampDay(addMonths(focused, -1), min, max)),
6037
+ children: /* @__PURE__ */ jsx(Arrow, { direction: "left" })
6038
+ }
6039
+ ),
6040
+ /* @__PURE__ */ jsx("span", { id: gridLabelId, className: "cbx-ui-date-month", "aria-live": "polite", children: formats.month.format(toDate(`${month}-01`)) }),
6041
+ /* @__PURE__ */ jsx(
6042
+ "button",
6043
+ {
6044
+ type: "button",
6045
+ className: "cbx-ui-date-nav",
6046
+ "aria-label": t("Next month"),
6047
+ disabled: !canNext,
6048
+ onClick: () => setFocused(clampDay(addMonths(focused, 1), min, max)),
6049
+ children: /* @__PURE__ */ jsx(Arrow, { direction: "right" })
6050
+ }
6051
+ )
6052
+ ] }),
6053
+ /* @__PURE__ */ jsxs("table", { ref: gridRef, role: "grid", className: "cbx-ui-date-grid", "aria-labelledby": gridLabelId, onKeyDown: onGridKeyDown, children: [
6054
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: weeks[0]?.map((day) => /* @__PURE__ */ jsx("th", { scope: "col", abbr: formats.weekdayLong.format(toDate(day)), children: formats.weekday.format(toDate(day)) }, day)) }) }),
6055
+ /* @__PURE__ */ jsx("tbody", { children: weeks.map((week) => /* @__PURE__ */ jsx("tr", { children: week.map((day) => {
6056
+ const outside = day.slice(0, 7) !== month;
6057
+ const selected = day === picked;
6058
+ return /* @__PURE__ */ jsx("td", { role: "gridcell", "aria-selected": selected || void 0, children: /* @__PURE__ */ jsx(
6059
+ "button",
6060
+ {
6061
+ type: "button",
6062
+ className: "cbx-ui-date-day",
6063
+ "data-day": day,
6064
+ "data-outside": outside || void 0,
6065
+ "data-today": day === todayDay || void 0,
6066
+ "data-selected": selected || void 0,
6067
+ tabIndex: day === focused ? 0 : -1,
6068
+ disabled: !canPick(day),
6069
+ "aria-label": formats.full.format(toDate(day)),
6070
+ "aria-current": day === todayDay ? "date" : void 0,
6071
+ onClick: () => choose(day),
6072
+ children: Number(day.slice(8))
6073
+ }
6074
+ ) }, day);
6075
+ }) }, week[0])) })
6076
+ ] }),
6077
+ /* @__PURE__ */ jsxs("div", { className: "cbx-ui-date-foot", children: [
6078
+ canPick(todayDay) && /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-ui-date-chip", onClick: () => choose(todayDay), children: t("Today") }),
6079
+ presets.filter((preset) => isDay(preset.value) && canPick(preset.value)).map((preset) => /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-ui-date-chip", onClick: () => choose(preset.value), children: preset.label }, preset.label)),
6080
+ clearable && !required && picked !== null && /* @__PURE__ */ jsx("button", { type: "button", className: "cbx-ui-date-chip cbx-ui-date-clear", onClick: () => choose(null), children: t("Clear") })
6081
+ ] })
6082
+ ]
6083
+ }
6084
+ ),
6085
+ panelContainer(containerRef.current)
6086
+ ) : null;
6087
+ return /* @__PURE__ */ jsxs(
6088
+ "div",
6089
+ {
6090
+ ref: containerRef,
6091
+ className: cn("cbx-ui-combo", triggerWidth === "full" && "cbx-ui-combo--full", className),
6092
+ onKeyDown: (event) => {
6093
+ if (open && event.key === "Escape") {
6094
+ event.preventDefault();
6095
+ event.stopPropagation();
6096
+ close(true);
6097
+ }
6098
+ },
6099
+ children: [
6100
+ /* @__PURE__ */ jsxs(
6101
+ "button",
6102
+ {
6103
+ ref: triggerRef,
6104
+ id,
6105
+ type: "button",
6106
+ disabled,
6107
+ "aria-haspopup": "dialog",
6108
+ "aria-expanded": open,
6109
+ "aria-required": required,
6110
+ "aria-label": ariaLabel !== void 0 ? picked !== null ? `${ariaLabel}: ${formats.full.format(toDate(picked))}` : ariaLabel : void 0,
6111
+ "aria-describedby": props["aria-describedby"] ?? field["aria-describedby"],
6112
+ "aria-invalid": props["aria-invalid"] ?? field["aria-invalid"],
6113
+ className: "cbx-ui-combo-trigger cbx-ui-date-trigger",
6114
+ onClick: (event) => open ? close(false) : openPanel(event.detail === 0),
6115
+ onKeyDown: (event) => {
6116
+ if (!open && event.key === "ArrowDown") {
6117
+ event.preventDefault();
6118
+ openPanel(true);
6119
+ }
6120
+ },
6121
+ children: [
6122
+ /* @__PURE__ */ jsx(CalendarIcon, {}),
6123
+ /* @__PURE__ */ jsx("span", { className: cn("cbx-ui-combo-value", picked === null && "is-placeholder"), children: picked !== null ? formats.short.format(toDate(picked)) : placeholder })
6124
+ ]
6125
+ }
6126
+ ),
6127
+ panel
6128
+ ]
6129
+ }
6130
+ );
6131
+ }
6132
+ function isDay(value) {
6133
+ return typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value) && !Number.isNaN(toDate(value).getTime());
6134
+ }
6135
+ function toDate(day) {
6136
+ return /* @__PURE__ */ new Date(`${day}T00:00:00Z`);
6137
+ }
6138
+ function fromDate(date) {
6139
+ return date.toISOString().slice(0, 10);
6140
+ }
6141
+ function today() {
6142
+ const now = /* @__PURE__ */ new Date();
6143
+ return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`;
6144
+ }
6145
+ function addDays(day, days) {
6146
+ const date = toDate(day);
6147
+ date.setUTCDate(date.getUTCDate() + days);
6148
+ return fromDate(date);
6149
+ }
6150
+ function addMonths(day, months) {
6151
+ const date = toDate(day);
6152
+ const wanted = date.getUTCDate();
6153
+ date.setUTCDate(1);
6154
+ date.setUTCMonth(date.getUTCMonth() + months);
6155
+ const last = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + 1, 0)).getUTCDate();
6156
+ date.setUTCDate(Math.min(wanted, last));
6157
+ return fromDate(date);
6158
+ }
6159
+ function lastOfMonth(day) {
6160
+ const date = toDate(day);
6161
+ return fromDate(new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + 1, 0)));
6162
+ }
6163
+ function weekday(day) {
6164
+ return toDate(day).getUTCDay();
6165
+ }
6166
+ function clampDay(day, min, max) {
6167
+ if (min !== void 0 && isDay(min) && day < min) return min;
6168
+ if (max !== void 0 && isDay(max) && day > max) return max;
6169
+ return day;
6170
+ }
6171
+ function monthGrid(month, firstDay) {
6172
+ const first = `${month}-01`;
6173
+ const start = addDays(first, -((weekday(first) - firstDay + 7) % 7));
6174
+ return Array.from({ length: 6 }, (_, week) => Array.from({ length: 7 }, (_2, day) => addDays(start, week * 7 + day)));
6175
+ }
6176
+ function firstDayOfWeek(locale) {
6177
+ try {
6178
+ const tag = new Intl.Locale(locale.replace("_", "-"));
6179
+ const info = tag.getWeekInfo?.() ?? tag.weekInfo;
6180
+ if (info !== void 0) return info.firstDay % 7;
6181
+ const region = tag.maximize().region;
6182
+ return region !== void 0 && SUNDAY_FIRST.has(region) ? 0 : 1;
6183
+ } catch {
6184
+ return 1;
6185
+ }
6186
+ }
6187
+ var SUNDAY_FIRST = /* @__PURE__ */ new Set(["US", "CA", "MX", "BR", "JP", "KR", "TW", "HK", "IL", "PH", "AU", "ZA", "IN", "SA"]);
6188
+ function formatsFor(locale) {
6189
+ const make = (options) => {
6190
+ try {
6191
+ return new Intl.DateTimeFormat(locale.replace("_", "-") || void 0, { ...options, timeZone: "UTC" });
6192
+ } catch {
6193
+ return new Intl.DateTimeFormat(void 0, { ...options, timeZone: "UTC" });
6194
+ }
6195
+ };
6196
+ return {
6197
+ short: make({ day: "numeric", month: "short", year: "numeric" }),
6198
+ full: make({ weekday: "long", day: "numeric", month: "long", year: "numeric" }),
6199
+ month: make({ month: "long", year: "numeric" }),
6200
+ weekday: make({ weekday: "narrow" }),
6201
+ weekdayLong: make({ weekday: "long" })
6202
+ };
6203
+ }
6204
+ function finePointer() {
6205
+ return typeof window !== "undefined" && window.matchMedia?.("(pointer: fine)").matches === true;
6206
+ }
6207
+ function CalendarIcon() {
6208
+ return /* @__PURE__ */ jsxs("svg", { className: "cbx-ui-combo-icon", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", "aria-hidden": "true", children: [
6209
+ /* @__PURE__ */ jsx("rect", { x: "2.5", y: "3.5", width: "11", height: "10", rx: "2" }),
6210
+ /* @__PURE__ */ jsx("path", { d: "M2.5 6.5h11M5.5 2v3M10.5 2v3" })
6211
+ ] });
6212
+ }
6213
+ function Arrow({ direction }) {
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
+ }
5925
6216
  var Input = forwardRef(function Input2({ scale = "md", className, ...props }, ref) {
5926
6217
  const field = useFieldControl();
5927
6218
  return /* @__PURE__ */ jsx("input", { ref, className: cn("cbx-ui-input", scale === "lg" && "cbx-ui-input--lg", className), ...field, ...props });
@@ -6752,6 +7043,6 @@ function Sparkline({ values, color = "var(--chart-1)", width = 90, height = 20 }
6752
7043
  ] });
6753
7044
  }
6754
7045
 
6755
- export { APP_HUES, AppContent, AppShell, Button, CHART_PALETTE, CboxAppCatalog, CboxAppIcon, CboxBrand, CboxIdProvider, CboxLocalizationProvider, CboxServiceMark, CboxShell, CboxSurfaces, Checkbox, Combobox, CreateField, CreateForm, CreateRefField, CreateSubmit, DataPanel, 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 };
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 };
6756
7047
  //# sourceMappingURL=index.js.map
6757
7048
  //# sourceMappingURL=index.js.map