@cboxdk/cbox-ui 0.19.2 → 0.19.4

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
@@ -133,7 +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
+ | `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 (Monday when it names no country, such as `en`). `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
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
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. |
139
139
  | `Spinner` | The indeterminate progress ring. Silent by default; `label` makes it a live status. |
package/dist/index.d.ts CHANGED
@@ -1697,7 +1697,8 @@ declare function SheetClose({ onClick, ...props }: ButtonProps): react_jsx_runti
1697
1697
  * drags down to close. Cbox never centres a modal over the page; forms and confirmations open here.
1698
1698
  *
1699
1699
  * - Focus moves in on open: to an element marked `autoFocus` or `data-autofocus`, else the first
1700
- * field in the body, else the close button (never a destructive footer action).
1700
+ * field in the body, else the close button (never a destructive footer action). On touch a text
1701
+ * field is not focused (the keyboard would cover the sheet); the panel takes focus instead.
1701
1702
  * - Tab and Shift+Tab stay inside; everything behind is `inert` and hidden from assistive
1702
1703
  * technology; the page behind does not scroll (iOS included).
1703
1704
  * - Escape closes it (unless a control inside handled Escape first, an open combobox say), as do
package/dist/index.js CHANGED
@@ -1821,6 +1821,8 @@ var TABBABLE = [
1821
1821
  '[contenteditable]:not([contenteditable="false"])',
1822
1822
  '[tabindex]:not([tabindex="-1"])'
1823
1823
  ].join(",");
1824
+ var TOUCH = "(pointer: coarse)";
1825
+ var TEXT_ENTRY = 'textarea, [contenteditable="true"], input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="range"]):not([type="color"]):not([type="file"])';
1824
1826
  function tabbables(root) {
1825
1827
  const all = Array.from(root.querySelectorAll(TABBABLE)).filter((element) => element.tabIndex >= 0 && element.closest("[hidden], [inert]") === null);
1826
1828
  const checkedGroups = new Set(all.filter((element) => element instanceof HTMLInputElement && element.type === "radio" && element.checked).map((element) => element.name));
@@ -1904,10 +1906,17 @@ function Sheet({ open, onOpenChange, title, description, footer, size = "md", di
1904
1906
  useIsoLayoutEffect2(() => {
1905
1907
  if (!open || panel.current === null) return;
1906
1908
  const root = panel.current;
1907
- if (root.contains(document.activeElement)) return;
1909
+ const touch = matches(TOUCH);
1910
+ const active = document.activeElement;
1911
+ if (root.contains(active)) {
1912
+ if (touch && active instanceof HTMLElement && active.matches(TEXT_ENTRY)) root.focus({ preventScroll: true });
1913
+ return;
1914
+ }
1908
1915
  const marked = root.querySelector("[data-autofocus]");
1909
1916
  const field = body.current?.querySelector('input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), [role="combobox"]');
1910
- (marked ?? field ?? closeButton.current ?? root).focus({ preventScroll: true });
1917
+ const wanted = marked ?? field;
1918
+ if (touch && wanted?.matches(TEXT_ENTRY)) root.focus({ preventScroll: true });
1919
+ else (wanted ?? closeButton.current ?? root).focus({ preventScroll: true });
1911
1920
  }, [open]);
1912
1921
  useEffect(() => {
1913
1922
  if (!open) return;
@@ -6176,6 +6185,7 @@ function monthGrid(month, firstDay) {
6176
6185
  function firstDayOfWeek(locale) {
6177
6186
  try {
6178
6187
  const tag = new Intl.Locale(locale.replace("_", "-"));
6188
+ if (tag.region === void 0) return 1;
6179
6189
  const info = tag.getWeekInfo?.() ?? tag.weekInfo;
6180
6190
  if (info !== void 0) return info.firstDay % 7;
6181
6191
  const region = tag.maximize().region;