@c9up/nebula 0.2.2 → 0.2.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 (72) hide show
  1. package/README.md +2 -2
  2. package/dist/atoms/Checkbox.d.ts +1 -1
  3. package/dist/atoms/Checkbox.js +1 -1
  4. package/dist/atoms/Input.d.ts +5 -0
  5. package/dist/atoms/Input.js +1 -0
  6. package/dist/lib/children.d.ts +13 -8
  7. package/dist/lib/children.js +5 -0
  8. package/dist/molecules/Breadcrumb.d.ts +11 -2
  9. package/dist/molecules/Breadcrumb.js +2 -2
  10. package/dist/molecules/InputOTP.d.ts +2 -0
  11. package/dist/molecules/InputOTP.js +3 -1
  12. package/dist/molecules/Pagination.d.ts +34 -2
  13. package/dist/molecules/Pagination.js +15 -6
  14. package/dist/molecules/PieceMap.d.ts +72 -0
  15. package/dist/molecules/PieceMap.js +78 -0
  16. package/dist/molecules/Resizable.d.ts +2 -0
  17. package/dist/molecules/Resizable.js +1 -1
  18. package/dist/molecules/index.d.ts +3 -2
  19. package/dist/molecules/index.js +1 -0
  20. package/dist/organisms/Calendar.d.ts +13 -0
  21. package/dist/organisms/Calendar.js +2 -2
  22. package/dist/organisms/Carousel.d.ts +8 -0
  23. package/dist/organisms/Carousel.js +8 -5
  24. package/dist/organisms/DataTable.d.ts +23 -1
  25. package/dist/organisms/DataTable.js +57 -27
  26. package/dist/organisms/DatePicker.d.ts +7 -0
  27. package/dist/organisms/DatePicker.js +2 -1
  28. package/dist/organisms/DateRangePicker.d.ts +2 -0
  29. package/dist/organisms/DateRangePicker.js +2 -1
  30. package/dist/organisms/Dialog.d.ts +13 -3
  31. package/dist/organisms/Dialog.js +12 -5
  32. package/dist/organisms/Questionnaire.d.ts +4 -0
  33. package/dist/organisms/Questionnaire.js +5 -2
  34. package/dist/organisms/Select.d.ts +23 -4
  35. package/dist/organisms/Select.js +115 -15
  36. package/dist/organisms/Sheet.d.ts +2 -0
  37. package/dist/organisms/Sheet.js +2 -1
  38. package/dist/organisms/Sidebar.d.ts +6 -0
  39. package/dist/organisms/Sidebar.js +9 -4
  40. package/dist/organisms/Toaster.d.ts +2 -0
  41. package/dist/organisms/Toaster.js +6 -4
  42. package/dist/organisms/index.d.ts +2 -2
  43. package/dist/organisms/index.js +1 -1
  44. package/dist/primitives/floating.js +24 -1
  45. package/dist/templates/SettingsLayout.d.ts +2 -0
  46. package/dist/templates/SettingsLayout.js +1 -1
  47. package/nebula.css +1 -1
  48. package/package.json +3 -3
  49. package/registry.json +13 -0
  50. package/src/atoms/Checkbox.ts +1 -1
  51. package/src/atoms/Input.ts +6 -0
  52. package/src/lib/children.ts +15 -7
  53. package/src/molecules/Breadcrumb.ts +15 -4
  54. package/src/molecules/InputOTP.ts +7 -1
  55. package/src/molecules/Pagination.ts +50 -8
  56. package/src/molecules/PieceMap.ts +136 -0
  57. package/src/molecules/Resizable.ts +3 -1
  58. package/src/molecules/index.ts +14 -0
  59. package/src/organisms/Calendar.ts +16 -2
  60. package/src/organisms/Carousel.ts +17 -5
  61. package/src/organisms/DataTable.ts +95 -30
  62. package/src/organisms/DatePicker.ts +10 -2
  63. package/src/organisms/DateRangePicker.ts +4 -2
  64. package/src/organisms/Dialog.ts +17 -5
  65. package/src/organisms/Questionnaire.ts +10 -2
  66. package/src/organisms/Select.ts +137 -16
  67. package/src/organisms/Sheet.ts +5 -1
  68. package/src/organisms/Sidebar.ts +15 -4
  69. package/src/organisms/Toaster.ts +8 -4
  70. package/src/organisms/index.ts +7 -1
  71. package/src/primitives/floating.ts +27 -1
  72. package/src/templates/SettingsLayout.ts +3 -1
@@ -19,10 +19,19 @@
19
19
  * ` })}
20
20
  * ` })
21
21
  *
22
- * The items REGISTER themselves as they are built, in document order, and the
23
- * keyboard model then walks that list rather than the DOM. That is deliberate:
24
- * the listbox pattern keeps focus on the trigger and only moves
25
- * `aria-activedescendant`, so there is no focused element to walk from.
22
+ * The items REGISTER themselves as they are built: what each one is called and
23
+ * whether it is disabled, by value. WHICH options exist and in what order is
24
+ * read from the mounted list, as Radix's collection reads it — so options built
25
+ * in an accessor follow a signal:
26
+ *
27
+ * SelectContent({ children: () => html`${() => roles().map((role) =>
28
+ * SelectItem({ value: role.id, children: role.name }))}` })
29
+ *
30
+ * Closed, the list is still mounted, outside the document, as Radix renders a
31
+ * closed select's content into a DocumentFragment: the options exist, so the
32
+ * trigger shows the chosen one's label and the keyboard can walk them. Focus
33
+ * stays on the trigger and only `aria-activedescendant` moves, so the walk is
34
+ * over those options, not over focusable elements.
26
35
  *
27
36
  * What a native `<select>` was doing for free, and all of which has to be put
28
37
  * back by hand:
@@ -38,13 +47,13 @@
38
47
  * The panel is sized to the trigger and capped at the space available below
39
48
  * it, so a hundred-option list scrolls rather than running off the screen.
40
49
  */
41
- import { component, createContext, html, inject, onUnmount, provide, signal, } from "@c9up/aurora";
50
+ import { component, createContext, effect, html, inject, onMount, onUnmount, provide, render, signal, untrack, } from "@c9up/aurora";
42
51
  import { slot } from "../lib/children.js";
43
52
  import { cn } from "../lib/cn.js";
44
53
  import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "../lib/icons.js";
45
54
  import { uid } from "../lib/id.js";
46
55
  import { slideInFromSide, zoomInOut } from "../lib/motion.js";
47
- import { read, readOr } from "../lib/props.js";
56
+ import { accessor, read, readOr } from "../lib/props.js";
48
57
  import { controllable } from "../primitives/controllable.js";
49
58
  import { floatingSurface } from "../primitives/floatingSurface.js";
50
59
  import { focusSilently } from "../primitives/focusable.js";
@@ -54,9 +63,25 @@ const itemClasses = "relative flex w-full cursor-default items-center gap-2 roun
54
63
  const scrollButtonClasses = "flex cursor-default items-center justify-center py-1";
55
64
  const SelectContext = createContext("Select");
56
65
  export const Select = component((props) => {
57
- const triggerId = uid("select-trigger");
66
+ let triggerId = uid("select-trigger");
58
67
  const listId = uid("select-list");
59
- const items = [];
68
+ /** What each value's option is called, latest registration first. */
69
+ const registry = new Map();
70
+ /** Moves whenever an option registers, so the chosen label follows. */
71
+ const revision = signal(0);
72
+ /** How many mounted lists hold each value's option. */
73
+ const attached = new Map();
74
+ /** Whether a list has been mounted at all — never, on the server. */
75
+ let mountedOnce = false;
76
+ // Untracked read: called while the accessor building an option runs, and
77
+ // reading the counter there would make that accessor re-run on every change.
78
+ const bump = () => {
79
+ revision(untrack(() => revision()) + 1);
80
+ };
81
+ /** The open panel, once it has rendered. */
82
+ let panel = null;
83
+ /** Where the list is mounted while closed — outside the document. */
84
+ let closedHost = null;
60
85
  /** Per instance, not per module: two selects may offer the same value. */
61
86
  const optionIds = new Map();
62
87
  let content;
@@ -71,7 +96,24 @@ export const Select = component((props) => {
71
96
  });
72
97
  /** The option the keyboard is on. Distinct from the selected one. */
73
98
  const active = signal(undefined);
74
- const enabled = () => items.filter((item) => !item.disabled);
99
+ /**
100
+ * The options the list holds now, in its order. Read from the mounted list,
101
+ * which is what drops an option a signal removed and places one it added;
102
+ * before anything is mounted (on the server), in registration order.
103
+ */
104
+ function items() {
105
+ const root = open() && panel?.isConnected === true ? panel : closedHost;
106
+ if (root === null)
107
+ return [...registry.values()];
108
+ const out = [];
109
+ for (const element of root.querySelectorAll("[data-slot=select-item]")) {
110
+ const item = registry.get(element.dataset.value ?? "");
111
+ if (item !== undefined && item.id === element.id)
112
+ out.push(item);
113
+ }
114
+ return out;
115
+ }
116
+ const enabled = () => items().filter((item) => !item.disabled);
75
117
  function choose(value) {
76
118
  selection.set(value);
77
119
  active(value);
@@ -161,7 +203,11 @@ export const Select = component((props) => {
161
203
  }
162
204
  }
163
205
  provide(SelectContext, {
164
- triggerId,
206
+ claimTriggerId(id) {
207
+ if (id !== undefined)
208
+ triggerId = id;
209
+ return triggerId;
210
+ },
165
211
  listId,
166
212
  open: () => open(),
167
213
  value: () => selection.current(),
@@ -169,7 +215,17 @@ export const Select = component((props) => {
169
215
  disabled: () => readOr(props.disabled, false),
170
216
  invalid: () => read(props.invalid) === true,
171
217
  required: props.required === true,
172
- chosenLabel: () => items.find((item) => item.value === selection.current())?.textValue,
218
+ chosenLabel: () => {
219
+ revision();
220
+ const current = selection.current();
221
+ if (current === undefined)
222
+ return undefined;
223
+ // An option a signal removed keeps its registration, but not its
224
+ // place in a list: its label must not stay on the trigger.
225
+ if (mountedOnce && !attached.has(current))
226
+ return undefined;
227
+ return registry.get(current)?.textValue;
228
+ },
173
229
  itemId(value) {
174
230
  let id = optionIds.get(value);
175
231
  if (id === undefined) {
@@ -186,7 +242,21 @@ export const Select = component((props) => {
186
242
  setActive: (value) => active(value),
187
243
  onTriggerKeyDown,
188
244
  registerItem(item) {
189
- items.push(item);
245
+ registry.set(item.value, item);
246
+ bump();
247
+ },
248
+ attachItem(value) {
249
+ mountedOnce = true;
250
+ attached.set(value, (attached.get(value) ?? 0) + 1);
251
+ bump();
252
+ return () => {
253
+ const left = (attached.get(value) ?? 1) - 1;
254
+ if (left > 0)
255
+ attached.set(value, left);
256
+ else
257
+ attached.delete(value);
258
+ bump();
259
+ };
190
260
  },
191
261
  registerContent(registered) {
192
262
  content = registered;
@@ -210,7 +280,32 @@ export const Select = component((props) => {
210
280
  // Focus never enters the panel — the listbox pattern keeps it on the
211
281
  // trigger — so nothing here traps or moves it.
212
282
  content: () => renderList(registered, { listId, triggerId }),
213
- onOpened: scrollActiveIntoView,
283
+ onOpened: (element) => {
284
+ panel = element;
285
+ scrollActiveIntoView(element);
286
+ },
287
+ });
288
+ onMount(() => {
289
+ let unmountClosed = null;
290
+ const stop = effect(() => {
291
+ if (open()) {
292
+ unmountClosed?.();
293
+ unmountClosed = null;
294
+ closedHost = null;
295
+ return;
296
+ }
297
+ if (unmountClosed !== null)
298
+ return;
299
+ const host = document.createElement("div");
300
+ // Untracked: what the options read belongs to their own bindings,
301
+ // not to this effect, which only follows `open`.
302
+ unmountClosed = untrack(() => render(html `${registered.body}`, host));
303
+ closedHost = host;
304
+ });
305
+ return () => {
306
+ stop();
307
+ unmountClosed?.();
308
+ };
214
309
  });
215
310
  }
216
311
  /**
@@ -223,7 +318,7 @@ export const Select = component((props) => {
223
318
  const current = active() ?? selection.current();
224
319
  if (current === undefined)
225
320
  return;
226
- const id = items.find((item) => item.value === current)?.id;
321
+ const id = registry.get(current)?.id;
227
322
  if (id === undefined)
228
323
  return;
229
324
  panel
@@ -244,7 +339,9 @@ export const SelectTrigger = component((props) => {
244
339
  return html `<button
245
340
  type="button"
246
341
  data-slot="select-trigger"
247
- id="${select.triggerId}"
342
+ id="${select.claimTriggerId(props.id)}"
343
+ aria-label="${accessor(props.label, undefined)}"
344
+ aria-describedby="${accessor(props.describedBy, undefined)}"
248
345
  role="combobox"
249
346
  aria-haspopup="listbox"
250
347
  aria-expanded="${() => (select.open() ? "true" : "false")}"
@@ -314,6 +411,9 @@ export const SelectItem = component((props) => {
314
411
  (typeof children === "string" ? children : props.value),
315
412
  disabled: props.disabled === true,
316
413
  });
414
+ // On each mount, not once: the same option is mounted again every time the
415
+ // list opens or closes, and unmounted when a signal drops it.
416
+ onMount(() => select.attachItem(props.value));
317
417
  const chosen = () => select.value() === props.value;
318
418
  return html `<div
319
419
  data-slot="select-item"
@@ -50,6 +50,8 @@ export interface SheetContentProps {
50
50
  /** Which edge it comes from. Default `"right"`. */
51
51
  side?: Side;
52
52
  showCloseButton?: boolean;
53
+ /** The corner cross's accessible name. Default `"Close"`. */
54
+ closeLabel?: string;
53
55
  class?: Reactive<string>;
54
56
  }
55
57
  /**
@@ -138,6 +138,7 @@ export const SheetContent = component((props) => {
138
138
  body,
139
139
  side: props.side ?? "right",
140
140
  showCloseButton: props.showCloseButton ?? true,
141
+ closeLabel: props.closeLabel ?? "Close",
141
142
  class: props.class,
142
143
  });
143
144
  return html ``;
@@ -175,7 +176,7 @@ function renderSurface(registered, ids) {
175
176
  data-slot="sheet-close"
176
177
  class="${closeButtonClasses}"
177
178
  @click="${() => ids.close()}"
178
- >${XIcon({ class: "size-4" })}<span class="sr-only">Close</span></button>`
179
+ >${XIcon({ class: "size-4" })}<span class="sr-only">${registered.closeLabel}</span></button>`
179
180
  : null;
180
181
  return html `<div data-slot="sheet-portal" class="${cn("fixed inset-0 z-50", fadeInOut)}">
181
182
  <div data-slot="sheet-overlay" class="${dialogBackdropClasses}"></div>
@@ -70,16 +70,22 @@ export interface SidebarProps {
70
70
  collapsible?: "icon" | "offcanvas" | "none";
71
71
  /** Announced as the navigation landmark's name. */
72
72
  label?: string;
73
+ /** The close cross of the sheet it turns into on mobile. Default `"Close"`. */
74
+ closeLabel?: string;
73
75
  class?: Reactive<string>;
74
76
  }
75
77
  export declare const Sidebar: (props?: SidebarProps | undefined) => import("@c9up/aurora").TemplateResult;
76
78
  export interface SidebarTriggerProps {
77
79
  /** Overrides the provider's toggle — for a trigger outside the shell. */
78
80
  onToggle?: () => void;
81
+ /** The button's accessible name. Default `"Toggle sidebar"`. */
82
+ label?: string;
79
83
  class?: Reactive<string>;
80
84
  }
81
85
  export declare const SidebarTrigger: (props?: SidebarTriggerProps | undefined) => import("@c9up/aurora").TemplateResult;
82
86
  export interface SidebarRailProps {
87
+ /** Accessible name and tooltip. Default `"Toggle sidebar"`. */
88
+ label?: string;
83
89
  class?: Reactive<string>;
84
90
  }
85
91
  /**
@@ -132,6 +132,7 @@ export const Sidebar = component((props) => {
132
132
  onOpenChange: (next) => sidebar.setOpen(next),
133
133
  children: () => SheetContent({
134
134
  side,
135
+ closeLabel: props.closeLabel,
135
136
  class: "bg-sidebar text-sidebar-foreground w-[18rem] p-0",
136
137
  children: () => html `${SheetHeader({
137
138
  class: "p-0",
@@ -149,7 +150,11 @@ export const Sidebar = component((props) => {
149
150
  data-slot="sidebar"
150
151
  data-state="${() => sidebar.state()}"
151
152
  data-side="${side}"
152
- data-collapsible="${collapsible}"
153
+ data-collapsible="${() =>
154
+ // The mode only once collapsed, as upstream: every
155
+ // `group-data-[collapsible=icon]:` class keys off it, and set
156
+ // while expanded it squeezed the full-width bar to icons.
157
+ sidebar.state() === "collapsed" ? collapsible : ""}"
153
158
  aria-label="${props.label ?? "Sidebar"}"
154
159
  class="${() => cn("group bg-sidebar text-sidebar-foreground h-svh shrink-0 overflow-hidden transition-[width] duration-200 ease-linear motion-reduce:transition-none", side === "left" ? "border-r" : "border-l", sidebar.open()
155
160
  ? "w-(--sidebar-width,16rem)"
@@ -166,7 +171,7 @@ export const Sidebar = component((props) => {
166
171
  export const SidebarTrigger = component((props) => Button({
167
172
  variant: "ghost",
168
173
  size: "icon",
169
- label: "Toggle sidebar",
174
+ label: props.label ?? "Toggle sidebar",
170
175
  class: () => cn("size-7", read(props.class)),
171
176
  onClick: () => {
172
177
  if (props.onToggle !== undefined) {
@@ -188,9 +193,9 @@ export const SidebarTrigger = component((props) => Button({
188
193
  export const SidebarRail = component((props) => html `<button
189
194
  type="button"
190
195
  data-slot="sidebar-rail"
191
- aria-label="Toggle sidebar"
196
+ aria-label="${props.label ?? "Toggle sidebar"}"
192
197
  tabindex="-1"
193
- title="Toggle sidebar"
198
+ title="${props.label ?? "Toggle sidebar"}"
194
199
  class="${() => cn("hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex", read(props.class))}"
195
200
  @click="${() => sidebarState()(!sidebarState()())}"
196
201
  ></button>`);
@@ -122,6 +122,8 @@ export declare const toast: {
122
122
  export interface ToasterProps {
123
123
  /** Which corner. Default `"bottom-right"`. */
124
124
  position?: "top-right" | "top-left" | "bottom-right" | "bottom-left";
125
+ /** The dismiss cross's accessible name, as sonner names the prop. */
126
+ closeButtonAriaLabel?: string;
125
127
  class?: Reactive<string>;
126
128
  }
127
129
  /**
@@ -260,6 +260,8 @@ const positionClasses = {
260
260
  */
261
261
  export const Toaster = component((props) => {
262
262
  const position = props.position ?? "bottom-right";
263
+ const closeLabel = props.closeButtonAriaLabel ?? "Dismiss notification";
264
+ const render = (entry) => renderToast(entry, closeLabel);
263
265
  return html `<div
264
266
  data-slot="toaster"
265
267
  data-nebula-live
@@ -270,16 +272,16 @@ export const Toaster = component((props) => {
270
272
  <div role="status" aria-live="polite" aria-atomic="false" class="contents">
271
273
  ${() => queue()
272
274
  .filter((entry) => entry.variant !== "error")
273
- .map(renderToast)}
275
+ .map(render)}
274
276
  </div>
275
277
  <div role="alert" aria-live="assertive" aria-atomic="false" class="contents">
276
278
  ${() => queue()
277
279
  .filter((entry) => entry.variant === "error")
278
- .map(renderToast)}
280
+ .map(render)}
279
281
  </div>
280
282
  </div>`;
281
283
  });
282
- function renderToast(entry) {
284
+ function renderToast(entry, closeLabel) {
283
285
  return html `<div
284
286
  data-slot="toast"
285
287
  data-variant="${entry.variant}"
@@ -307,7 +309,7 @@ function renderToast(entry) {
307
309
  >${entry.action.label}</button>`}
308
310
  <button
309
311
  type="button"
310
- aria-label="Dismiss notification"
312
+ aria-label="${closeLabel}"
311
313
  class="opacity-60 transition-opacity hover:opacity-100"
312
314
  @click="${() => dismiss(entry.id)}"
313
315
  >${XIcon({ class: "size-4" })}</button>
@@ -13,7 +13,7 @@
13
13
  * restoration, hiding the page from assistive technology) exist once.
14
14
  */
15
15
  export { AlertDialog, AlertDialogAction, type AlertDialogButtonProps, AlertDialogCancel, AlertDialogContent, type AlertDialogContentProps, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, type AlertDialogPortalProps, type AlertDialogProps, type AlertDialogSectionProps, AlertDialogTitle, AlertDialogTrigger, type AlertDialogTriggerProps, } from "./AlertDialog.js";
16
- export { addDays, addMonths, Calendar, type CalendarProps, type DateRange, isSameDay, monthGrid, startOfDay, } from "./Calendar.js";
16
+ export { addDays, addMonths, Calendar, type CalendarLabels, type CalendarProps, type DateRange, isSameDay, monthGrid, startOfDay, } from "./Calendar.js";
17
17
  export { Carousel, type CarouselButtonProps, CarouselContent, type CarouselContentProps, CarouselItem, type CarouselItemProps, CarouselNext, CarouselPrevious, type CarouselProps, } from "./Carousel.js";
18
18
  export { Chart, type ChartDatum, type ChartProps, type ChartSeries, valueRange, } from "./Chart.js";
19
19
  export { Combobox, type ComboboxOption, type ComboboxProps, } from "./Combobox.js";
@@ -21,7 +21,7 @@ export { Command, type CommandCandidate, CommandEmpty, type CommandEmptyProps, C
21
21
  export { CommandDialog, type CommandDialogProps } from "./CommandDialog.js";
22
22
  export { ContextMenu, ContextMenuCheckboxItem, type ContextMenuCheckboxItemProps, ContextMenuContent, type ContextMenuContentProps, ContextMenuGroup, type ContextMenuGroupProps, ContextMenuItem, type ContextMenuItemProps, ContextMenuLabel, type ContextMenuLabelProps, ContextMenuPortal, type ContextMenuPortalProps, type ContextMenuProps, ContextMenuRadioGroup, type ContextMenuRadioGroupProps, ContextMenuRadioItem, type ContextMenuRadioItemProps, ContextMenuSeparator, type ContextMenuSeparatorProps, ContextMenuShortcut, type ContextMenuShortcutProps, ContextMenuSub, ContextMenuSubContent, type ContextMenuSubContentProps, type ContextMenuSubProps, ContextMenuSubTrigger, type ContextMenuSubTriggerProps, ContextMenuTrigger, type ContextMenuTriggerProps, } from "./ContextMenu.js";
23
23
  export { type Column, DataTable, type DataTableProps } from "./DataTable.js";
24
- export { DatePicker, type DatePickerProps, toISODate } from "./DatePicker.js";
24
+ export { DatePicker, type DatePickerLabels, type DatePickerProps, toISODate, } from "./DatePicker.js";
25
25
  export { DateRangePicker, type DateRangePickerProps, } from "./DateRangePicker.js";
26
26
  export { Dialog, DialogClose, type DialogCloseProps, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, type DialogFooterProps, DialogHeader, DialogOverlay, type DialogOverlayProps, DialogPortal, type DialogPortalProps, type DialogProps, type DialogSectionProps, DialogTitle, type DialogTitleProps, DialogTrigger, type DialogTriggerProps, dialogBackdropClasses, dialogPanelClasses, useDialog, } from "./Dialog.js";
27
27
  export { Drawer, DrawerClose, type DrawerCloseProps, DrawerContent, type DrawerContentProps, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, type DrawerOverlayProps, type DrawerProps, type DrawerSectionProps, DrawerTitle, DrawerTrigger, type DrawerTriggerProps, } from "./Drawer.js";
@@ -21,7 +21,7 @@ export { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, Command
21
21
  export { CommandDialog } from "./CommandDialog.js";
22
22
  export { ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, } from "./ContextMenu.js";
23
23
  export { DataTable } from "./DataTable.js";
24
- export { DatePicker, toISODate } from "./DatePicker.js";
24
+ export { DatePicker, toISODate, } from "./DatePicker.js";
25
25
  export { DateRangePicker, } from "./DateRangePicker.js";
26
26
  export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, dialogBackdropClasses, dialogPanelClasses, useDialog, } from "./Dialog.js";
27
27
  export { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerTitle, DrawerTrigger, } from "./Drawer.js";
@@ -222,6 +222,29 @@ function clamp(value, min, max) {
222
222
  return min;
223
223
  return Math.min(Math.max(value, min), max);
224
224
  }
225
+ /**
226
+ * The surface's size as laid out, before any transform.
227
+ *
228
+ * `getBoundingClientRect()` includes transforms, and every surface opens under
229
+ * `zoom-in-95`: measured on its first frame it is 5% short, and one placed on
230
+ * the `top` side lands that much too low, over the control that opened it. A
231
+ * transform never changes layout, so the `ResizeObserver` would not correct it
232
+ * afterwards either. floating-ui reads the same two sources in the same order
233
+ * (`getCssDimensions`): the computed size, which keeps sub-pixel widths, and
234
+ * the integer offset size when the two disagree.
235
+ */
236
+ function layoutRect(element) {
237
+ const box = element.getBoundingClientRect();
238
+ const css = getComputedStyle(element);
239
+ let width = Number.parseFloat(css.width) || 0;
240
+ let height = Number.parseFloat(css.height) || 0;
241
+ if (Math.round(width) !== element.offsetWidth ||
242
+ Math.round(height) !== element.offsetHeight) {
243
+ width = element.offsetWidth;
244
+ height = element.offsetHeight;
245
+ }
246
+ return { x: box.x, y: box.y, width, height };
247
+ }
225
248
  /**
226
249
  * Position `floating` against `anchor` and keep it there.
227
250
  *
@@ -240,7 +263,7 @@ export function autoPosition(anchor, floating, options = {}) {
240
263
  if (options.matchWidth === true) {
241
264
  floating.style.width = `${anchorRect.width}px`;
242
265
  }
243
- const floatingRect = floating.getBoundingClientRect();
266
+ const floatingRect = layoutRect(floating);
244
267
  const position = resolvePosition(anchorRect, floatingRect, { width: window.innerWidth, height: window.innerHeight }, { ...options, rtl });
245
268
  floating.style.position = "fixed";
246
269
  floating.style.left = `${Math.round(position.x)}px`;
@@ -21,6 +21,8 @@ export interface SettingsLayoutProps {
21
21
  title: Child;
22
22
  description?: Child;
23
23
  sections: readonly SettingsSection[];
24
+ /** The section list's accessible name. Default `"Settings sections"`. */
25
+ navLabel?: string;
24
26
  children?: Slot;
25
27
  class?: Reactive<string>;
26
28
  }
@@ -27,7 +27,7 @@ export const SettingsLayout = component((props) => {
27
27
  <div class="flex flex-col gap-8 md:flex-row md:gap-12">
28
28
  <nav
29
29
  data-slot="settings-nav"
30
- aria-label="Settings sections"
30
+ aria-label="${props.navLabel ?? "Settings sections"}"
31
31
  class="flex gap-2 overflow-x-auto md:w-48 md:shrink-0 md:flex-col md:overflow-visible"
32
32
  >
33
33
  ${props.sections.map((section) => html `<a