@c9up/nebula 0.2.1 → 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 (98) hide show
  1. package/README.md +11 -9
  2. package/dist/atoms/AccessibleIcon.d.ts +24 -0
  3. package/dist/atoms/AccessibleIcon.js +27 -0
  4. package/dist/atoms/Checkbox.d.ts +1 -1
  5. package/dist/atoms/Checkbox.js +1 -1
  6. package/dist/atoms/Input.d.ts +5 -0
  7. package/dist/atoms/Input.js +1 -0
  8. package/dist/atoms/VisuallyHidden.d.ts +30 -0
  9. package/dist/atoms/VisuallyHidden.js +35 -0
  10. package/dist/atoms/index.d.ts +2 -0
  11. package/dist/atoms/index.js +2 -0
  12. package/dist/index.d.ts +7 -4
  13. package/dist/index.js +7 -4
  14. package/dist/lib/children.d.ts +13 -8
  15. package/dist/lib/children.js +5 -0
  16. package/dist/molecules/Breadcrumb.d.ts +11 -2
  17. package/dist/molecules/Breadcrumb.js +2 -2
  18. package/dist/molecules/InputOTP.d.ts +2 -0
  19. package/dist/molecules/InputOTP.js +3 -1
  20. package/dist/molecules/Pagination.d.ts +34 -2
  21. package/dist/molecules/Pagination.js +15 -6
  22. package/dist/molecules/PieceMap.d.ts +72 -0
  23. package/dist/molecules/PieceMap.js +78 -0
  24. package/dist/molecules/Resizable.d.ts +2 -0
  25. package/dist/molecules/Resizable.js +1 -1
  26. package/dist/molecules/Toolbar.d.ts +50 -0
  27. package/dist/molecules/Toolbar.js +70 -0
  28. package/dist/molecules/index.d.ts +10 -7
  29. package/dist/molecules/index.js +8 -5
  30. package/dist/organisms/Calendar.d.ts +13 -0
  31. package/dist/organisms/Calendar.js +2 -2
  32. package/dist/organisms/Carousel.d.ts +8 -0
  33. package/dist/organisms/Carousel.js +8 -5
  34. package/dist/organisms/DataTable.d.ts +23 -1
  35. package/dist/organisms/DataTable.js +57 -27
  36. package/dist/organisms/DatePicker.d.ts +7 -0
  37. package/dist/organisms/DatePicker.js +2 -1
  38. package/dist/organisms/DateRangePicker.d.ts +2 -0
  39. package/dist/organisms/DateRangePicker.js +2 -1
  40. package/dist/organisms/Dialog.d.ts +13 -3
  41. package/dist/organisms/Dialog.js +12 -5
  42. package/dist/organisms/Questionnaire.d.ts +4 -0
  43. package/dist/organisms/Questionnaire.js +5 -2
  44. package/dist/organisms/Select.d.ts +23 -4
  45. package/dist/organisms/Select.js +115 -15
  46. package/dist/organisms/Sheet.d.ts +2 -0
  47. package/dist/organisms/Sheet.js +2 -1
  48. package/dist/organisms/Sidebar.d.ts +6 -0
  49. package/dist/organisms/Sidebar.js +9 -4
  50. package/dist/organisms/Toaster.d.ts +80 -10
  51. package/dist/organisms/Toaster.js +152 -24
  52. package/dist/organisms/index.d.ts +3 -3
  53. package/dist/organisms/index.js +1 -1
  54. package/dist/primitives/direction.d.ts +38 -0
  55. package/dist/primitives/direction.js +57 -0
  56. package/dist/primitives/floating.js +25 -13
  57. package/dist/primitives/focusable.d.ts +10 -0
  58. package/dist/primitives/focusable.js +10 -1
  59. package/dist/primitives/index.d.ts +2 -1
  60. package/dist/primitives/index.js +2 -1
  61. package/dist/primitives/rovingFocus.js +14 -7
  62. package/dist/templates/SettingsLayout.d.ts +2 -0
  63. package/dist/templates/SettingsLayout.js +1 -1
  64. package/nebula.css +1 -1
  65. package/package.json +3 -3
  66. package/registry.json +76 -0
  67. package/src/atoms/AccessibleIcon.ts +39 -0
  68. package/src/atoms/Checkbox.ts +1 -1
  69. package/src/atoms/Input.ts +6 -0
  70. package/src/atoms/VisuallyHidden.ts +45 -0
  71. package/src/atoms/index.ts +8 -0
  72. package/src/index.ts +7 -4
  73. package/src/lib/children.ts +15 -7
  74. package/src/molecules/Breadcrumb.ts +15 -4
  75. package/src/molecules/InputOTP.ts +7 -1
  76. package/src/molecules/Pagination.ts +50 -8
  77. package/src/molecules/PieceMap.ts +136 -0
  78. package/src/molecules/Resizable.ts +3 -1
  79. package/src/molecules/Toolbar.ts +100 -0
  80. package/src/molecules/index.ts +28 -5
  81. package/src/organisms/Calendar.ts +16 -2
  82. package/src/organisms/Carousel.ts +17 -5
  83. package/src/organisms/DataTable.ts +95 -30
  84. package/src/organisms/DatePicker.ts +10 -2
  85. package/src/organisms/DateRangePicker.ts +4 -2
  86. package/src/organisms/Dialog.ts +17 -5
  87. package/src/organisms/Questionnaire.ts +10 -2
  88. package/src/organisms/Select.ts +137 -16
  89. package/src/organisms/Sheet.ts +5 -1
  90. package/src/organisms/Sidebar.ts +15 -4
  91. package/src/organisms/Toaster.ts +215 -37
  92. package/src/organisms/index.ts +9 -1
  93. package/src/primitives/direction.ts +61 -0
  94. package/src/primitives/floating.ts +29 -13
  95. package/src/primitives/focusable.ts +10 -1
  96. package/src/primitives/index.ts +7 -0
  97. package/src/primitives/rovingFocus.ts +18 -5
  98. package/src/templates/SettingsLayout.ts +3 -1
@@ -20,7 +20,14 @@
20
20
  * attribute is what says it to everyone else.
21
21
  */
22
22
 
23
- import { html, signal, type TemplateResult } from "@c9up/aurora";
23
+ import {
24
+ each,
25
+ html,
26
+ memo,
27
+ type ReadSignal,
28
+ signal,
29
+ type TemplateResult,
30
+ } from "@c9up/aurora";
24
31
  import { Checkbox } from "../atoms/Checkbox.js";
25
32
  import { Input } from "../atoms/Input.js";
26
33
  import type { Child } from "../lib/children.js";
@@ -30,15 +37,18 @@ import {
30
37
  ChevronsUpDownIcon,
31
38
  ChevronUpIcon,
32
39
  } from "../lib/icons.js";
40
+ import { type Reactive, read } from "../lib/props.js";
33
41
  import {
34
42
  Pagination,
35
43
  PaginationContent,
36
44
  PaginationEllipsis,
37
45
  PaginationItem,
46
+ type PaginationLabels,
38
47
  PaginationLink,
39
48
  PaginationNext,
40
49
  PaginationPrevious,
41
50
  pageWindow,
51
+ paginationLabels,
42
52
  } from "../molecules/Pagination.js";
43
53
  import {
44
54
  Table,
@@ -62,16 +72,36 @@ export interface Column<Row> {
62
72
 
63
73
  export interface DataTableProps<Row> {
64
74
  columns: readonly Column<Row>[];
65
- rows: readonly Row[];
75
+ /**
76
+ * The rows, or an accessor for rows that change. An accessor must return the
77
+ * same array until the data changes — a new one per read counts as new data
78
+ * on every read, as it does for TanStack's `data`.
79
+ */
80
+ rows: Reactive<readonly Row[]>;
66
81
  /** Stable identity per row — used for selection and as the render key. */
67
82
  rowKey: (row: Row) => string;
68
83
  /** Rows per page. Omit to show everything. */
69
84
  pageSize?: number;
85
+ /**
86
+ * Go back to the first page when the rows change. Default `true`, as
87
+ * TanStack's `autoResetPageIndex`: the page was chosen in data that is
88
+ * gone. Turn it off for rows refreshed in place, such as a polled list.
89
+ * Sorting and the filter always survive a change.
90
+ */
91
+ autoResetPage?: boolean;
70
92
  /** Show a filter box. Provide `filterMatch` to say what it searches. */
71
93
  filterPlaceholder?: string;
94
+ /** The filter box's accessible name. Defaults to the placeholder. */
95
+ filterLabel?: string;
72
96
  filterMatch?: (row: Row, query: string) => boolean;
73
97
  /** Add a checkbox column. */
74
98
  selectable?: boolean;
99
+ /** The header checkbox's accessible name. Default `"Select all rows on this page"`. */
100
+ selectAllLabel?: string;
101
+ /** A row checkbox's accessible name. Default `"Select row <key>"`. */
102
+ selectRowLabel?: (row: Row) => string;
103
+ /** The pager's words — see `PaginationLabels`. */
104
+ paginationLabels?: Partial<PaginationLabels>;
75
105
  onSelectionChange?: (keys: readonly string[]) => void;
76
106
  emptyMessage?: Child;
77
107
  class?: string;
@@ -83,7 +113,13 @@ export function DataTable<Row>(props: DataTableProps<Row>): TemplateResult {
83
113
  const sortKey = signal<string | undefined>(undefined);
84
114
  const sortDirection = signal<SortDirection>("asc");
85
115
  const query = signal("");
86
- const page = signal(1);
116
+ /**
117
+ * The page, and the rows it was chosen in. Derived rather than reset by an
118
+ * effect: when the rows are no longer those, the page reads as the first.
119
+ */
120
+ const page = signal<{ readonly number: number; readonly of: readonly Row[] }>(
121
+ { number: 1, of: read(props.rows) },
122
+ );
87
123
  const selected = signal<readonly string[]>([]);
88
124
 
89
125
  function readCell(row: Row, column: Column<Row>): Child {
@@ -98,11 +134,20 @@ export function DataTable<Row>(props: DataTableProps<Row>): TemplateResult {
98
134
  }
99
135
 
100
136
  function filtered(): readonly Row[] {
137
+ const rows = read(props.rows);
101
138
  const needle = query().trim().toLowerCase();
102
- if (needle === "" || props.filterMatch === undefined) return props.rows;
103
- return props.rows.filter(
104
- (row) => props.filterMatch?.(row, needle) === true,
105
- );
139
+ if (needle === "" || props.filterMatch === undefined) return rows;
140
+ return rows.filter((row) => props.filterMatch?.(row, needle) === true);
141
+ }
142
+
143
+ function pageNumber(): number {
144
+ const { number, of } = page();
145
+ if (props.autoResetPage !== false && of !== read(props.rows)) return 1;
146
+ return number;
147
+ }
148
+
149
+ function goToPage(number: number): void {
150
+ page({ number, of: read(props.rows) });
106
151
  }
107
152
 
108
153
  function sorted(): readonly Row[] {
@@ -135,11 +180,14 @@ export function DataTable<Row>(props: DataTableProps<Row>): TemplateResult {
135
180
  if (props.pageSize === undefined) return rows;
136
181
  // Clamp: filtering down to fewer pages while on the last one would
137
182
  // otherwise show an empty table with no way back.
138
- const current = Math.min(page(), pageCount());
183
+ const current = Math.min(pageNumber(), pageCount());
139
184
  const from = (current - 1) * props.pageSize;
140
185
  return rows.slice(from, from + props.pageSize);
141
186
  }
142
187
 
188
+ /** Whether the body shows the empty row — read apart, so the list survives. */
189
+ const isEmpty = memo(() => visible().length === 0);
190
+
143
191
  function toggleSort(column: Column<Row>): void {
144
192
  if (column.sortable === false) return;
145
193
  if (sortKey() === column.key) {
@@ -210,10 +258,11 @@ export function DataTable<Row>(props: DataTableProps<Row>): TemplateResult {
210
258
  : Input({
211
259
  type: "search",
212
260
  placeholder: props.filterPlaceholder ?? "Filter…",
261
+ label: props.filterLabel ?? props.filterPlaceholder ?? "Filter…",
213
262
  class: "max-w-sm",
214
263
  onInput: (value) => {
215
264
  query(value);
216
- page(1);
265
+ goToPage(1);
217
266
  },
218
267
  })
219
268
  }
@@ -226,7 +275,8 @@ export function DataTable<Row>(props: DataTableProps<Row>): TemplateResult {
226
275
  ? TableHead({
227
276
  class: "w-10",
228
277
  children: Checkbox({
229
- label: "Select all rows on this page",
278
+ label:
279
+ props.selectAllLabel ?? "Select all rows on this page",
230
280
  checked: () => {
231
281
  const keys = visible().map(props.rowKey);
232
282
  return (
@@ -264,19 +314,19 @@ export function DataTable<Row>(props: DataTableProps<Row>): TemplateResult {
264
314
  }),
265
315
  }),
266
316
  TableBody({
267
- children: () => {
268
- const rows = visible();
269
- if (rows.length === 0) {
270
- return TableRow({
271
- children: TableCell({
272
- colspan: columnCount,
273
- class: "h-24 text-center",
274
- children: props.emptyMessage ?? "No results.",
275
- }),
276
- });
277
- }
278
- return rows.map((row) => renderRow(row));
279
- },
317
+ // Rows by key: a re-read, a sort or a page change keeps the rows
318
+ // that stay, with their open menus and focus. The body itself only
319
+ // switches between the list and the empty row.
320
+ children: () =>
321
+ isEmpty()
322
+ ? TableRow({
323
+ children: TableCell({
324
+ colspan: columnCount,
325
+ class: "h-24 text-center",
326
+ children: props.emptyMessage ?? "No results.",
327
+ }),
328
+ })
329
+ : each(visible, props.rowKey, renderRow),
280
330
  }),
281
331
  ],
282
332
  })}
@@ -291,16 +341,21 @@ export function DataTable<Row>(props: DataTableProps<Row>): TemplateResult {
291
341
  * current one and the gaps between — and the parts render that list.
292
342
  */
293
343
  function renderPagination(): Child {
294
- const current = (): number => Math.min(page(), pageCount());
344
+ const current = (): number => Math.min(pageNumber(), pageCount());
295
345
  const go = (target: number) => (): void => {
296
- page(Math.min(Math.max(target, 1), pageCount()));
346
+ goToPage(Math.min(Math.max(target, 1), pageCount()));
297
347
  };
348
+ const word = (key: keyof PaginationLabels): string =>
349
+ props.paginationLabels?.[key] ?? paginationLabels[key];
298
350
  return Pagination({
351
+ "aria-label": word("navigation"),
299
352
  children: () =>
300
353
  PaginationContent({
301
354
  children: [
302
355
  PaginationItem({
303
356
  children: PaginationPrevious({
357
+ "aria-label": word("previousPage"),
358
+ children: word("previous"),
304
359
  disabled: () => current() <= 1,
305
360
  onSelect: go(current() - 1),
306
361
  }),
@@ -309,7 +364,7 @@ export function DataTable<Row>(props: DataTableProps<Row>): TemplateResult {
309
364
  PaginationItem({
310
365
  children:
311
366
  entry === null
312
- ? PaginationEllipsis({})
367
+ ? PaginationEllipsis({ label: word("morePages") })
313
368
  : PaginationLink({
314
369
  children: String(entry),
315
370
  isActive: () => current() === entry,
@@ -319,6 +374,8 @@ export function DataTable<Row>(props: DataTableProps<Row>): TemplateResult {
319
374
  ),
320
375
  PaginationItem({
321
376
  children: PaginationNext({
377
+ "aria-label": word("nextPage"),
378
+ children: word("next"),
322
379
  disabled: () => current() >= pageCount(),
323
380
  onSelect: go(current() + 1),
324
381
  }),
@@ -328,22 +385,30 @@ export function DataTable<Row>(props: DataTableProps<Row>): TemplateResult {
328
385
  });
329
386
  }
330
387
 
331
- function renderRow(row: Row): Child {
332
- const key = props.rowKey(row);
388
+ /**
389
+ * One row, built once for its key. The cells read the row through its
390
+ * accessor, so a row whose data changed redraws its cells and nothing else.
391
+ */
392
+ function renderRow(row: ReadSignal<Row>): Child {
393
+ const key = props.rowKey(row());
333
394
  return TableRow({
334
395
  selected: () => selected().includes(key),
335
396
  children: [
336
397
  props.selectable === true
337
398
  ? TableCell({
338
399
  children: Checkbox({
339
- label: `Select row ${key}`,
400
+ label: () =>
401
+ props.selectRowLabel?.(row()) ?? `Select row ${key}`,
340
402
  checked: () => selected().includes(key),
341
403
  onCheckedChange: () => toggleRow(key),
342
404
  }),
343
405
  })
344
406
  : null,
345
407
  ...props.columns.map((column) =>
346
- TableCell({ class: column.class, children: readCell(row, column) }),
408
+ TableCell({
409
+ class: column.class,
410
+ children: () => readCell(row(), column),
411
+ }),
347
412
  ),
348
413
  ],
349
414
  });
@@ -26,7 +26,13 @@ import { type Reactive, read, readOr } from "../lib/props.js";
26
26
  import { controllable } from "../primitives/controllable.js";
27
27
  import { floatingSurface } from "../primitives/floatingSurface.js";
28
28
  import { focusSilently } from "../primitives/focusable.js";
29
- import { Calendar, startOfDay } from "./Calendar.js";
29
+ import { Calendar, type CalendarLabels, startOfDay } from "./Calendar.js";
30
+
31
+ /** The calendar's words, plus the popup's accessible name. */
32
+ export interface DatePickerLabels extends CalendarLabels {
33
+ /** Default `"Choose a date"`, or `"Choose a date range"`. */
34
+ dialog: string;
35
+ }
30
36
 
31
37
  export interface DatePickerProps {
32
38
  name?: string;
@@ -38,6 +44,7 @@ export interface DatePickerProps {
38
44
  disabled?: Reactive<boolean>;
39
45
  invalid?: Reactive<boolean>;
40
46
  locale?: string;
47
+ labels?: Partial<DatePickerLabels>;
41
48
  class?: Reactive<string>;
42
49
  onValueChange?: (date: Date) => void;
43
50
  }
@@ -86,7 +93,7 @@ export const DatePicker = component<DatePickerProps>((props) => {
86
93
  data-slot="date-picker-content"
87
94
  id="${contentId}"
88
95
  role="dialog"
89
- aria-label="Choose a date"
96
+ aria-label="${props.labels?.dialog ?? "Choose a date"}"
90
97
  class="${cn(
91
98
  "bg-popover text-popover-foreground z-50 rounded-md border p-0 shadow-md outline-none",
92
99
  zoomInOut,
@@ -98,6 +105,7 @@ export const DatePicker = component<DatePickerProps>((props) => {
98
105
  min: props.min,
99
106
  max: props.max,
100
107
  locale: props.locale,
108
+ labels: props.labels,
101
109
  onValueChange: choose,
102
110
  })}
103
111
  </div>`,
@@ -26,7 +26,7 @@ import { controllable } from "../primitives/controllable.js";
26
26
  import { floatingSurface } from "../primitives/floatingSurface.js";
27
27
  import { focusSilently } from "../primitives/focusable.js";
28
28
  import { Calendar, type DateRange, startOfDay } from "./Calendar.js";
29
- import { toISODate } from "./DatePicker.js";
29
+ import { type DatePickerLabels, toISODate } from "./DatePicker.js";
30
30
 
31
31
  export interface DateRangePickerProps {
32
32
  /** Base name for the hidden inputs — `"stay"` posts `stay_from` / `stay_to`. */
@@ -39,6 +39,7 @@ export interface DateRangePickerProps {
39
39
  disabled?: Reactive<boolean>;
40
40
  invalid?: Reactive<boolean>;
41
41
  locale?: string;
42
+ labels?: Partial<DatePickerLabels>;
42
43
  class?: Reactive<string>;
43
44
  /** Fires on both clicks — `to` is absent after the first. */
44
45
  onValueChange?: (range: DateRange) => void;
@@ -90,7 +91,7 @@ export const DateRangePicker = component<DateRangePickerProps>((props) => {
90
91
  data-slot="date-range-picker-content"
91
92
  id="${contentId}"
92
93
  role="dialog"
93
- aria-label="Choose a date range"
94
+ aria-label="${props.labels?.dialog ?? "Choose a date range"}"
94
95
  class="${cn(
95
96
  "bg-popover text-popover-foreground z-50 rounded-md border p-0 shadow-md outline-none",
96
97
  zoomInOut,
@@ -103,6 +104,7 @@ export const DateRangePicker = component<DateRangePickerProps>((props) => {
103
104
  min: props.min,
104
105
  max: props.max,
105
106
  locale: props.locale,
107
+ labels: props.labels,
106
108
  onRangeChange: pick,
107
109
  })}
108
110
  </div>`,
@@ -7,11 +7,11 @@
7
7
  * Dialog({ children: () => html`
8
8
  * ${DialogTrigger({ children: "Edit" })}
9
9
  * ${DialogContent({ children: () => html`
10
- * ${DialogHeader({ children: () => html`
10
+ * ${DialogHeader({ children: html`
11
11
  * ${DialogTitle({ children: "Edit profile" })}
12
12
  * ${DialogDescription({ children: "Change it." })}
13
13
  * ` })}
14
- * ${DialogFooter({ children: () => Button({ children: "Save" }) })}
14
+ * ${DialogFooter({ children: Button({ children: "Save" }) })}
15
15
  * ` })}
16
16
  * ` })
17
17
  *
@@ -21,6 +21,11 @@
21
21
  * with the title's id and a panel rendered first would have had nothing to
22
22
  * point at.
23
23
  *
24
+ * Hence `DialogHeader` gets a VALUE: it takes a `Slot`, which the renderer calls
25
+ * when the panel renders, and a `DialogTitle` built in there registers after
26
+ * the panel has looked for one — it renders, and the panel stays unnamed (see
27
+ * `Parts`). Content that changes goes inside the title, not around it.
28
+ *
24
29
  * The `panel` callback matters more than it looks. The overlay's root spans
25
30
  * the viewport so the backdrop can, which means containment has to be answered
26
31
  * against the panel — check the root and every click on the page counts as
@@ -29,7 +34,8 @@
29
34
  * `aria-labelledby` points at the title and `aria-describedby` at the
30
35
  * description, so a screen reader announces what the dialog is for on open. A
31
36
  * dialog with neither announces only "dialog", which is why a missing
32
- * `DialogTitle` is warned about — as upstream warns — rather than tolerated.
37
+ * `DialogTitle` is warned about rather than tolerated — as Radix did through
38
+ * 1.1; 1.3 counts its titles and no longer warns.
33
39
  */
34
40
 
35
41
  import {
@@ -66,6 +72,7 @@ const closeButtonClasses =
66
72
  interface RegisteredContent {
67
73
  readonly body: Child;
68
74
  readonly showCloseButton: boolean;
75
+ readonly closeLabel: string;
69
76
  readonly dismissOnOutside: boolean;
70
77
  readonly dismissOnEscape: boolean;
71
78
  readonly class?: Reactive<string>;
@@ -238,6 +245,8 @@ export interface DialogContentProps {
238
245
  children?: Parts;
239
246
  /** The corner cross. */
240
247
  showCloseButton?: boolean;
248
+ /** The cross's accessible name. Default `"Close"`. */
249
+ closeLabel?: string;
241
250
  /** A click outside closes. `false` for a decision that must be made. */
242
251
  dismissOnOutside?: boolean;
243
252
  /** Escape closes. `false` for the same reason. */
@@ -258,6 +267,7 @@ export const DialogContent = component<DialogContentProps>((props) => {
258
267
  dialog.register({
259
268
  body,
260
269
  showCloseButton: props.showCloseButton ?? true,
270
+ closeLabel: props.closeLabel ?? "Close",
261
271
  dismissOnOutside: props.dismissOnOutside ?? true,
262
272
  dismissOnEscape: props.dismissOnEscape ?? true,
263
273
  class: props.class,
@@ -280,6 +290,8 @@ export const DialogHeader = component<DialogSectionProps>(
280
290
  export interface DialogFooterProps extends DialogSectionProps {
281
291
  /** Append a "Close" button after the children, as upstream can. */
282
292
  showCloseButton?: boolean;
293
+ /** That button's text. Default `"Close"`. */
294
+ closeLabel?: string;
283
295
  }
284
296
 
285
297
  export const DialogFooter = component<DialogFooterProps>((props) => {
@@ -290,7 +302,7 @@ export const DialogFooter = component<DialogFooterProps>((props) => {
290
302
  type="button"
291
303
  data-slot="dialog-close"
292
304
  @click="${() => dialog.setOpen(false)}"
293
- >${Button({ variant: "outline", children: "Close" })}</button>`
305
+ >${Button({ variant: "outline", children: props.closeLabel ?? "Close" })}</button>`
294
306
  : null;
295
307
  return html`<div
296
308
  data-slot="dialog-footer"
@@ -347,7 +359,7 @@ function renderSurface(
347
359
  data-slot="dialog-close"
348
360
  class="${closeButtonClasses}"
349
361
  @click="${() => ids.close()}"
350
- >${XIcon({ class: "size-4" })}<span class="sr-only">Close</span></button>`
362
+ >${XIcon({ class: "size-4" })}<span class="sr-only">${registered.closeLabel}</span></button>`
351
363
  : null;
352
364
  return html`<div data-slot="dialog-portal" class="${cn("fixed inset-0 z-50", fadeInOut)}">
353
365
  <div data-slot="dialog-overlay" class="${dialogBackdropClasses}"></div>
@@ -87,6 +87,10 @@ export interface QuestionnaireProps {
87
87
  nextLabel?: string;
88
88
  skipLabel?: string;
89
89
  submitLabel?: string;
90
+ /** The progress bar's accessible name. Default `"Questionnaire progress"`. */
91
+ progressLabel?: string;
92
+ /** The counter under the bar. Default `"Question 2 of 5"`. */
93
+ counterLabel?: (position: number, total: number) => string;
90
94
  class?: Reactive<string>;
91
95
  }
92
96
 
@@ -120,6 +124,10 @@ export function isAnswered(
120
124
  return asValue(answer).trim() !== "";
121
125
  }
122
126
 
127
+ function questionOf(position: number, total: number): string {
128
+ return `Question ${position} of ${total}`;
129
+ }
130
+
123
131
  export const Questionnaire = component<QuestionnaireProps>((props) => {
124
132
  const total = props.questions.length;
125
133
  const step = signal(0);
@@ -192,13 +200,13 @@ export const Questionnaire = component<QuestionnaireProps>((props) => {
192
200
  ${Progress({
193
201
  value: () => step() + 1,
194
202
  max: total,
195
- label: "Questionnaire progress",
203
+ label: props.progressLabel ?? "Questionnaire progress",
196
204
  })}
197
205
  <p
198
206
  id="${counterId}"
199
207
  aria-live="polite"
200
208
  class="text-muted-foreground text-xs tabular-nums"
201
- >${() => `Question ${step() + 1} of ${total}`}</p>
209
+ >${() => (props.counterLabel ?? questionOf)(step() + 1, total)}</p>
202
210
  </div>`
203
211
  }
204
212