@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
package/registry.json CHANGED
@@ -4,6 +4,20 @@
4
4
  "homepage": "https://github.com/C9up/nebula",
5
5
  "layout": "mirror",
6
6
  "items": [
7
+ {
8
+ "name": "accessible-icon",
9
+ "title": "AccessibleIcon",
10
+ "layer": "atoms",
11
+ "files": [
12
+ "atoms/AccessibleIcon.ts",
13
+ "lib/children.ts",
14
+ "lib/cn.ts",
15
+ "lib/props.ts"
16
+ ],
17
+ "dependencies": [
18
+ "visually-hidden"
19
+ ]
20
+ },
7
21
  {
8
22
  "name": "accordion",
9
23
  "title": "Accordion",
@@ -15,6 +29,7 @@
15
29
  "lib/id.ts",
16
30
  "lib/props.ts",
17
31
  "molecules/Accordion.ts",
32
+ "primitives/direction.ts",
18
33
  "primitives/focusable.ts",
19
34
  "primitives/rovingFocus.ts"
20
35
  ],
@@ -46,6 +61,7 @@
46
61
  "lib/props.ts",
47
62
  "organisms/AlertDialog.ts",
48
63
  "primitives/controllable.ts",
64
+ "primitives/direction.ts",
49
65
  "primitives/dismissable.ts",
50
66
  "primitives/floating.ts",
51
67
  "primitives/focusTrap.ts",
@@ -280,6 +296,7 @@
280
296
  "lib/props.ts",
281
297
  "organisms/Combobox.ts",
282
298
  "primitives/controllable.ts",
299
+ "primitives/direction.ts",
283
300
  "primitives/dismissable.ts",
284
301
  "primitives/floating.ts",
285
302
  "primitives/floatingSurface.ts",
@@ -319,6 +336,7 @@
319
336
  "lib/props.ts",
320
337
  "organisms/CommandDialog.ts",
321
338
  "primitives/controllable.ts",
339
+ "primitives/direction.ts",
322
340
  "primitives/dismissable.ts",
323
341
  "primitives/floating.ts",
324
342
  "primitives/focusTrap.ts",
@@ -345,6 +363,7 @@
345
363
  "lib/motion.ts",
346
364
  "lib/props.ts",
347
365
  "organisms/ContextMenu.ts",
366
+ "primitives/direction.ts",
348
367
  "primitives/dismissable.ts",
349
368
  "primitives/floating.ts",
350
369
  "primitives/floatingSurface.ts",
@@ -389,6 +408,7 @@
389
408
  "lib/props.ts",
390
409
  "organisms/DatePicker.ts",
391
410
  "primitives/controllable.ts",
411
+ "primitives/direction.ts",
392
412
  "primitives/dismissable.ts",
393
413
  "primitives/floating.ts",
394
414
  "primitives/floatingSurface.ts",
@@ -414,6 +434,7 @@
414
434
  "lib/props.ts",
415
435
  "organisms/DateRangePicker.ts",
416
436
  "primitives/controllable.ts",
437
+ "primitives/direction.ts",
417
438
  "primitives/dismissable.ts",
418
439
  "primitives/floating.ts",
419
440
  "primitives/floatingSurface.ts",
@@ -441,6 +462,7 @@
441
462
  "lib/props.ts",
442
463
  "organisms/Dialog.ts",
443
464
  "primitives/controllable.ts",
465
+ "primitives/direction.ts",
444
466
  "primitives/dismissable.ts",
445
467
  "primitives/floating.ts",
446
468
  "primitives/focusTrap.ts",
@@ -466,6 +488,7 @@
466
488
  "lib/props.ts",
467
489
  "organisms/Drawer.ts",
468
490
  "primitives/controllable.ts",
491
+ "primitives/direction.ts",
469
492
  "primitives/dismissable.ts",
470
493
  "primitives/floating.ts",
471
494
  "primitives/focusTrap.ts",
@@ -492,6 +515,7 @@
492
515
  "lib/props.ts",
493
516
  "organisms/DropdownMenu.ts",
494
517
  "primitives/controllable.ts",
518
+ "primitives/direction.ts",
495
519
  "primitives/dismissable.ts",
496
520
  "primitives/floating.ts",
497
521
  "primitives/floatingSurface.ts",
@@ -563,6 +587,7 @@
563
587
  "lib/props.ts",
564
588
  "organisms/HoverCard.ts",
565
589
  "primitives/controllable.ts",
590
+ "primitives/direction.ts",
566
591
  "primitives/dismissable.ts",
567
592
  "primitives/floating.ts",
568
593
  "primitives/floatingSurface.ts",
@@ -689,6 +714,7 @@
689
714
  "lib/motion.ts",
690
715
  "lib/props.ts",
691
716
  "organisms/Menubar.ts",
717
+ "primitives/direction.ts",
692
718
  "primitives/dismissable.ts",
693
719
  "primitives/floating.ts",
694
720
  "primitives/floatingSurface.ts",
@@ -757,6 +783,7 @@
757
783
  "lib/motion.ts",
758
784
  "lib/props.ts",
759
785
  "organisms/NavigationMenu.ts",
786
+ "primitives/direction.ts",
760
787
  "primitives/dismissable.ts",
761
788
  "primitives/floating.ts",
762
789
  "primitives/floatingSurface.ts",
@@ -795,6 +822,19 @@
795
822
  "image"
796
823
  ]
797
824
  },
825
+ {
826
+ "name": "piece-map",
827
+ "title": "PieceMap",
828
+ "layer": "molecules",
829
+ "files": [
830
+ "lib/children.ts",
831
+ "lib/cn.ts",
832
+ "lib/cva.ts",
833
+ "lib/props.ts",
834
+ "molecules/PieceMap.ts"
835
+ ],
836
+ "dependencies": []
837
+ },
798
838
  {
799
839
  "name": "popover",
800
840
  "title": "Popover",
@@ -807,6 +847,7 @@
807
847
  "lib/props.ts",
808
848
  "organisms/Popover.ts",
809
849
  "primitives/controllable.ts",
850
+ "primitives/direction.ts",
810
851
  "primitives/dismissable.ts",
811
852
  "primitives/floating.ts",
812
853
  "primitives/floatingSurface.ts",
@@ -900,6 +941,7 @@
900
941
  "lib/props.ts",
901
942
  "organisms/Select.ts",
902
943
  "primitives/controllable.ts",
944
+ "primitives/direction.ts",
903
945
  "primitives/dismissable.ts",
904
946
  "primitives/floating.ts",
905
947
  "primitives/floatingSurface.ts",
@@ -946,6 +988,7 @@
946
988
  "lib/props.ts",
947
989
  "organisms/Sheet.ts",
948
990
  "primitives/controllable.ts",
991
+ "primitives/direction.ts",
949
992
  "primitives/dismissable.ts",
950
993
  "primitives/floating.ts",
951
994
  "primitives/focusTrap.ts",
@@ -1050,6 +1093,7 @@
1050
1093
  "lib/id.ts",
1051
1094
  "lib/props.ts",
1052
1095
  "molecules/Tabs.ts",
1096
+ "primitives/direction.ts",
1053
1097
  "primitives/focusable.ts",
1054
1098
  "primitives/rovingFocus.ts"
1055
1099
  ],
@@ -1077,6 +1121,7 @@
1077
1121
  "lib/motion.ts",
1078
1122
  "lib/props.ts",
1079
1123
  "organisms/Toaster.ts",
1124
+ "primitives/direction.ts",
1080
1125
  "primitives/floating.ts"
1081
1126
  ],
1082
1127
  "dependencies": []
@@ -1108,6 +1153,24 @@
1108
1153
  "toggle"
1109
1154
  ]
1110
1155
  },
1156
+ {
1157
+ "name": "toolbar",
1158
+ "title": "Toolbar",
1159
+ "layer": "molecules",
1160
+ "files": [
1161
+ "lib/children.ts",
1162
+ "lib/cn.ts",
1163
+ "lib/props.ts",
1164
+ "molecules/Toolbar.ts",
1165
+ "primitives/direction.ts",
1166
+ "primitives/focusable.ts",
1167
+ "primitives/rovingFocus.ts"
1168
+ ],
1169
+ "dependencies": [
1170
+ "button",
1171
+ "separator"
1172
+ ]
1173
+ },
1111
1174
  {
1112
1175
  "name": "tooltip",
1113
1176
  "title": "Tooltip",
@@ -1119,6 +1182,7 @@
1119
1182
  "lib/motion.ts",
1120
1183
  "lib/props.ts",
1121
1184
  "organisms/Tooltip.ts",
1185
+ "primitives/direction.ts",
1122
1186
  "primitives/dismissable.ts",
1123
1187
  "primitives/floating.ts",
1124
1188
  "primitives/floatingSurface.ts",
@@ -1141,6 +1205,18 @@
1141
1205
  "molecules/Typography.ts"
1142
1206
  ],
1143
1207
  "dependencies": []
1208
+ },
1209
+ {
1210
+ "name": "visually-hidden",
1211
+ "title": "VisuallyHidden",
1212
+ "layer": "atoms",
1213
+ "files": [
1214
+ "atoms/VisuallyHidden.ts",
1215
+ "lib/children.ts",
1216
+ "lib/cn.ts",
1217
+ "lib/props.ts"
1218
+ ],
1219
+ "dependencies": []
1144
1220
  }
1145
1221
  ]
1146
1222
  }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * AccessibleIcon — an icon with a name only a screen reader hears.
3
+ *
4
+ * An icon on its own is a picture of a word. Sighted users read the picture;
5
+ * a screen reader reads nothing at all, because an `<svg>` with no label is
6
+ * announced as nothing — which is how a delete button becomes an unlabelled
7
+ * button in the middle of a row of unlabelled buttons.
8
+ *
9
+ * Two halves, and both matter. The icon is marked `aria-hidden` so its own
10
+ * internals — a `<title>`, a stray `<text>` — are not announced on top of the
11
+ * label; the label is visually hidden text beside it. `aria-label` on the
12
+ * parent would do for a plain string, but it does not survive translation
13
+ * tooling the way real text does, and it cannot carry markup.
14
+ */
15
+
16
+ import { component, html } from "@c9up/aurora";
17
+ import { type Slot, slot } from "../lib/children.js";
18
+ import { cn } from "../lib/cn.js";
19
+ import { type Reactive, read } from "../lib/props.js";
20
+ import { VisuallyHidden } from "./VisuallyHidden.js";
21
+
22
+ export interface AccessibleIconProps {
23
+ /** The icon. Hidden from the accessibility tree. */
24
+ children?: Slot;
25
+ /** What the icon means, in words. */
26
+ label: Reactive<string>;
27
+ class?: Reactive<string>;
28
+ }
29
+
30
+ export const AccessibleIcon = component<AccessibleIconProps>((props) => {
31
+ return html`<span
32
+ data-slot="accessible-icon"
33
+ class="${() => cn("contents", read(props.class))}"
34
+ ><span aria-hidden="true" class="contents">${slot(props.children)}</span>${VisuallyHidden(
35
+ {
36
+ children: () => read(props.label),
37
+ },
38
+ )}</span>`;
39
+ });
@@ -22,7 +22,7 @@ import { CheckIcon, MinusIcon } from "../lib/icons.js";
22
22
  import { accessor, type Reactive, read } from "../lib/props.js";
23
23
 
24
24
  export const checkboxClasses =
25
- "peer size-4 shrink-0 appearance-none rounded-[4px] border border-input bg-transparent shadow-xs outline-none transition-shadow dark:bg-input/30 checked:border-primary checked:bg-primary indeterminate:border-primary indeterminate:bg-primary focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20";
25
+ "peer size-4 shrink-0 appearance-none rounded-[4px] border border-input bg-transparent shadow-xs outline-none transition-shadow dark:bg-input/30 checked:border-primary checked:bg-primary indeterminate:border-primary indeterminate:bg-primary focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 dark:checked:bg-primary dark:indeterminate:bg-primary";
26
26
 
27
27
  export interface CheckboxProps {
28
28
  id?: string;
@@ -33,6 +33,11 @@ export interface InputProps {
33
33
  invalid?: Reactive<boolean>;
34
34
  /** Names the element describing the error, for screen readers. */
35
35
  describedBy?: Reactive<string | undefined>;
36
+ /**
37
+ * The field's accessible name (`aria-label`), for a field no `<label>`
38
+ * names. A placeholder is not one: it disappears as soon as the user types.
39
+ */
40
+ label?: Reactive<string | undefined>;
36
41
  class?: Reactive<string>;
37
42
  onInput?: (value: string, event: Event) => void;
38
43
  onChange?: (value: string, event: Event) => void;
@@ -63,6 +68,7 @@ export const Input = component<InputProps>((props) => {
63
68
  autocomplete="${props.autocomplete}"
64
69
  aria-invalid="${() => (read(props.invalid) === true ? "true" : undefined)}"
65
70
  aria-describedby="${accessor(props.describedBy, undefined)}"
71
+ aria-label="${accessor(props.label, undefined)}"
66
72
  ?disabled="${accessor(props.disabled, false)}"
67
73
  ?readonly="${accessor(props.readonly, false)}"
68
74
  ?required="${accessor(props.required, false)}"
@@ -0,0 +1,45 @@
1
+ /**
2
+ * VisuallyHidden — text for a screen reader and nothing else.
3
+ *
4
+ * Not `display: none`, which removes it from the accessibility tree as well,
5
+ * and not `opacity: 0`, which keeps it taking space. The clip rectangle is the
6
+ * one technique that leaves the node announced and unrendered, and it is
7
+ * fiddly enough that hand-writing it in each component is how one of them ends
8
+ * up subtly wrong.
9
+ *
10
+ * Its main job is the label a sighted user does not need: a dialog whose title
11
+ * is a logo, an icon button, a table caption. `aria-label` covers some of
12
+ * those, but not the ones where the content is real markup — a heading that a
13
+ * `aria-labelledby` has to point at, for instance.
14
+ *
15
+ * `focusable` keeps it hidden until it is tabbed to, which is what a skip link
16
+ * needs: invisible in the layout, and visible the moment it has focus.
17
+ *
18
+ * Always a `<span>`. Radix takes an `asChild` here so a hidden heading can be
19
+ * a real `<h2>`; aurora's template parser fixes the tag at compile time, so
20
+ * the equivalent is to put this inside the heading rather than to become one.
21
+ */
22
+
23
+ import { component, html } from "@c9up/aurora";
24
+ import { type Slot, slot } from "../lib/children.js";
25
+ import { cn } from "../lib/cn.js";
26
+ import { type Reactive, read } from "../lib/props.js";
27
+
28
+ export interface VisuallyHiddenProps {
29
+ children?: Slot;
30
+ /** Reveal it once focused — for a skip link. Default `false`. */
31
+ focusable?: boolean;
32
+ class?: Reactive<string>;
33
+ }
34
+
35
+ /** Tailwind's own `sr-only`, plus its counterpart for the focusable case. */
36
+ const HIDDEN = "sr-only";
37
+ const FOCUSABLE = "sr-only focus-within:not-sr-only focus:not-sr-only";
38
+
39
+ export const VisuallyHidden = component<VisuallyHiddenProps>((props) => {
40
+ const base = props.focusable === true ? FOCUSABLE : HIDDEN;
41
+ return html`<span
42
+ data-slot="visually-hidden"
43
+ class="${() => cn(base, read(props.class))}"
44
+ >${slot(props.children)}</span>`;
45
+ });
@@ -12,6 +12,10 @@
12
12
  * Slider is an atom despite being interactive, because it is one input.
13
13
  */
14
14
 
15
+ export {
16
+ AccessibleIcon,
17
+ type AccessibleIconProps,
18
+ } from "./AccessibleIcon.js";
15
19
  export { AspectRatio, type AspectRatioProps } from "./AspectRatio.js";
16
20
  export {
17
21
  Avatar,
@@ -82,3 +86,7 @@ export {
82
86
  type ToggleVariants,
83
87
  toggleVariants,
84
88
  } from "./Toggle.js";
89
+ export {
90
+ VisuallyHidden,
91
+ type VisuallyHiddenProps,
92
+ } from "./VisuallyHidden.js";
package/src/index.ts CHANGED
@@ -13,10 +13,13 @@
13
13
  * icons are inlined, and the date maths is `Date` and `Intl`.
14
14
  *
15
15
  * **Compound components take data, not children.** shadcn composes through
16
- * React context — `<Tabs><TabsList><TabsTrigger>`. Aurora has no context, and
17
- * the workarounds are worse than the problem, so those components take an
18
- * `items` array and named slots. The rendered markup is unchanged, which means
19
- * shadcn's CSS and its examples still read across.
16
+ * React context — `<Tabs><TabsList><TabsTrigger>`. Aurora has context too, and
17
+ * these components use it; what they do not do is take their parts as children.
18
+ * Context here lives on a stack during a component's SETUP, so a part handed in
19
+ * as a `Slot` thunk is built later, once that frame has popped, and reads
20
+ * nothing. An `items` array and named slots keep every part built while the
21
+ * context is still there. The rendered markup is unchanged, which means shadcn's
22
+ * CSS and its examples still read across.
20
23
  *
21
24
  * **The atomic layer is a property of the component.** An atom renders its own
22
25
  * markup and composes nothing from nebula; a molecule assembles atoms or owns
@@ -13,11 +13,13 @@
13
13
  * frozen for the lifetime of the node.
14
14
  */
15
15
 
16
- import type { TemplateResult } from "@c9up/aurora";
16
+ import { type Each, isEach, type TemplateResult } from "@c9up/aurora";
17
17
  import type { Reactive } from "./props.js";
18
18
 
19
19
  export type Child =
20
20
  | TemplateResult
21
+ /** A keyed list from aurora's `each`, which keeps its rows by key. */
22
+ | Each
21
23
  | Node
22
24
  | string
23
25
  | number
@@ -44,13 +46,16 @@ export type Slot = Reactive<Child>;
44
46
  * `Parts` names it so the type makes the requirement, rather than a blank
45
47
  * surface at runtime.
46
48
  *
47
- * Called ONCE, during setup — the structure of a compound component is fixed,
48
- * and its moving pieces are signals inside the parts.
49
+ * Called ONCE, during setup. What changes goes in an accessor inside it, and
50
+ * parts built there still reach their provider — Aurora calls the accessor
51
+ * with the providers it was written under — so a list of options can follow a
52
+ * signal:
49
53
  *
50
- * The same rule read from the other end: a part that READS context must be
51
- * built eagerly too, so it must not be hidden inside a `Slot`. `Slot` exists
52
- * for content that CHANGES, and the renderer calls it later, by which time
53
- * there is no context left to read:
54
+ * SelectContent({ children: () => html`${() => roles().map((r) => SelectItem(…))}` })
55
+ *
56
+ * A part that has to be KNOWN at setup is the exception. `DialogTitle` names
57
+ * the panel, and the panel reads whether there is a title before it renders
58
+ * its children, so a title built later in an accessor leaves it unnamed:
54
59
  *
55
60
  * DialogHeader({ children: html`${DialogTitle(…)}` }) // ✓ a value
56
61
  * DialogHeader({ children: () => html`${DialogTitle(…)}` }) // ✗ too late
@@ -70,5 +75,8 @@ export type Parts = () => Child;
70
75
  */
71
76
  export function slot(content: Slot | undefined): () => Child {
72
77
  if (content === undefined) return () => null;
78
+ // A keyed list is a function too, but it is content, not an accessor for
79
+ // content: handed over as the value, it keeps its rows by key.
80
+ if (isEach(content)) return () => content;
73
81
  return typeof content === "function" ? content : () => content;
74
82
  }
@@ -32,10 +32,15 @@ export interface BreadcrumbProps {
32
32
  class?: Reactive<string>;
33
33
  }
34
34
 
35
- export const Breadcrumb = component<BreadcrumbProps>(
35
+ export interface BreadcrumbNavProps extends BreadcrumbProps {
36
+ /** The `<nav>`'s accessible name. Default `"breadcrumb"`. */
37
+ "aria-label"?: string;
38
+ }
39
+
40
+ export const Breadcrumb = component<BreadcrumbNavProps>(
36
41
  (props) => html`<nav
37
42
  data-slot="breadcrumb"
38
- aria-label="breadcrumb"
43
+ aria-label="${props["aria-label"] ?? "breadcrumb"}"
39
44
  class="${() => cn(read(props.class))}"
40
45
  >${slot(props.children)}</nav>`,
41
46
  );
@@ -97,12 +102,18 @@ export const BreadcrumbSeparator = component<BreadcrumbProps>(
97
102
  >${props.children === undefined ? ChevronRightIcon() : slot(props.children)}</li>`,
98
103
  );
99
104
 
105
+ export interface BreadcrumbEllipsisProps {
106
+ /** The hidden text. Default `"More"`. */
107
+ label?: string;
108
+ class?: Reactive<string>;
109
+ }
110
+
100
111
  /** Stands in for ancestors that did not fit. */
101
- export const BreadcrumbEllipsis = component<BreadcrumbProps>(
112
+ export const BreadcrumbEllipsis = component<BreadcrumbEllipsisProps>(
102
113
  (props) => html`<span
103
114
  data-slot="breadcrumb-ellipsis"
104
115
  role="presentation"
105
116
  aria-hidden="true"
106
117
  class="${() => cn("flex size-9 items-center justify-center", read(props.class))}"
107
- >${MoreHorizontalIcon({ class: "size-4" })}<span class="sr-only">More</span></span>`,
118
+ >${MoreHorizontalIcon({ class: "size-4" })}<span class="sr-only">${props.label ?? "More"}</span></span>`,
108
119
  );
@@ -39,6 +39,7 @@ const slotClasses =
39
39
  interface InputOTPApi {
40
40
  readonly length: number;
41
41
  readonly disabled: () => boolean;
42
+ readonly slotLabel: (position: number, length: number) => string;
42
43
  /** Claim the next box's index, in the order the slots are built. */
43
44
  claimSlot(): number;
44
45
  onInput(index: number, event: Event): void;
@@ -51,6 +52,8 @@ const InputOTPContext = createContext<InputOTPApi>("InputOTP");
51
52
  export interface InputOTPProps {
52
53
  /** Number of boxes. Default `6` — and it must match the slots built. */
53
54
  length?: number;
55
+ /** Each box's accessible name from its position. Default `"Character 2 of 6"`. */
56
+ slotLabel?: (position: number, length: number) => string;
54
57
  name?: string;
55
58
  disabled?: Reactive<boolean>;
56
59
  class?: Reactive<string>;
@@ -99,6 +102,9 @@ export const InputOTP = component<InputOTPProps>((props) => {
99
102
  provide<InputOTPApi>(InputOTPContext, {
100
103
  length,
101
104
  disabled: () => readOr(props.disabled, false),
105
+ slotLabel:
106
+ props.slotLabel ??
107
+ ((position, total) => `Character ${position} of ${total}`),
102
108
  claimSlot() {
103
109
  const index = claimed;
104
110
  claimed += 1;
@@ -206,7 +212,7 @@ export const InputOTPSlot = component<InputOTPSlotProps>((props) => {
206
212
  inputmode="numeric"
207
213
  autocomplete="${index === 0 ? "one-time-code" : "off"}"
208
214
  maxlength="1"
209
- aria-label="${`Character ${index + 1} of ${otp.length}`}"
215
+ aria-label="${otp.slotLabel(index + 1, otp.length)}"
210
216
  ?disabled="${() => otp.disabled()}"
211
217
  class="${() => cn(slotClasses, read(props.class))}"
212
218
  @input="${(event: Event) => otp.onInput(index, event)}"
@@ -79,11 +79,45 @@ export interface PaginationProps {
79
79
  class?: Reactive<string>;
80
80
  }
81
81
 
82
- export const Pagination = component<PaginationProps>(
82
+ /**
83
+ * Every text the pagination writes, in one place.
84
+ *
85
+ * The defaults are upstream's English. An app in another language passes its
86
+ * own: most of these are read only by a screen reader, which would otherwise
87
+ * switch to English in the middle of the page.
88
+ */
89
+ export interface PaginationLabels {
90
+ /** The `<nav>`'s accessible name. */
91
+ navigation: string;
92
+ /** The visible word beside the previous arrow. */
93
+ previous: string;
94
+ /** The previous link's accessible name. */
95
+ previousPage: string;
96
+ next: string;
97
+ nextPage: string;
98
+ /** The ellipsis's hidden text. */
99
+ morePages: string;
100
+ }
101
+
102
+ /** Frozen: the defaults, not a place to set an app's language from. */
103
+ export const paginationLabels: Readonly<PaginationLabels> = Object.freeze({
104
+ navigation: "pagination",
105
+ previous: "Previous",
106
+ previousPage: "Go to previous page",
107
+ next: "Next",
108
+ nextPage: "Go to next page",
109
+ morePages: "More pages",
110
+ });
111
+
112
+ export interface PaginationNavProps extends PaginationProps {
113
+ "aria-label"?: string;
114
+ }
115
+
116
+ export const Pagination = component<PaginationNavProps>(
83
117
  (props) => html`<nav
84
118
  data-slot="pagination"
85
119
  role="navigation"
86
- aria-label="pagination"
120
+ aria-label="${props["aria-label"] ?? paginationLabels.navigation}"
87
121
  class="${() => cn("mx-auto flex w-full justify-center", read(props.class))}"
88
122
  >${slot(props.children)}</nav>`,
89
123
  );
@@ -153,18 +187,24 @@ export const PaginationLink = component<PaginationLinkProps>((props) => {
153
187
  >${slot(props.children)}</a>`;
154
188
  });
155
189
 
190
+ /**
191
+ * `aria-label` replaces the accessible name, as upstream's prop spread lets it.
192
+ * `children` replaces the visible word and keeps the arrow — upstream writes
193
+ * that word in the file, which an app owning its copy can edit and a package
194
+ * cannot.
195
+ */
156
196
  export type PaginationStepProps = Omit<
157
197
  PaginationLinkProps,
158
- "size" | "isActive" | "aria-label"
198
+ "size" | "isActive"
159
199
  >;
160
200
 
161
201
  export const PaginationPrevious = component<PaginationStepProps>((props) =>
162
202
  PaginationLink({
163
203
  ...props,
164
204
  size: "default",
165
- "aria-label": "Go to previous page",
205
+ "aria-label": props["aria-label"] ?? paginationLabels.previousPage,
166
206
  class: () => cn("gap-1 px-2.5 sm:pl-2.5", read(props.class)),
167
- children: html`${ChevronLeftIcon({})}<span class="hidden sm:block">Previous</span>`,
207
+ children: html`${ChevronLeftIcon({})}<span class="hidden sm:block">${slot(props.children ?? paginationLabels.previous)}</span>`,
168
208
  }),
169
209
  );
170
210
 
@@ -172,13 +212,15 @@ export const PaginationNext = component<PaginationStepProps>((props) =>
172
212
  PaginationLink({
173
213
  ...props,
174
214
  size: "default",
175
- "aria-label": "Go to next page",
215
+ "aria-label": props["aria-label"] ?? paginationLabels.nextPage,
176
216
  class: () => cn("gap-1 px-2.5 sm:pr-2.5", read(props.class)),
177
- children: html`<span class="hidden sm:block">Next</span>${ChevronRightIcon({})}`,
217
+ children: html`<span class="hidden sm:block">${slot(props.children ?? paginationLabels.next)}</span>${ChevronRightIcon({})}`,
178
218
  }),
179
219
  );
180
220
 
181
221
  export interface PaginationEllipsisProps {
222
+ /** The hidden text. Default `"More pages"`. */
223
+ label?: string;
182
224
  class?: Reactive<string>;
183
225
  }
184
226
 
@@ -188,5 +230,5 @@ export const PaginationEllipsis = component<PaginationEllipsisProps>(
188
230
  data-slot="pagination-ellipsis"
189
231
  aria-hidden="true"
190
232
  class="${() => cn("flex size-9 items-center justify-center", read(props.class))}"
191
- >${MoreHorizontalIcon({ class: "size-4" })}<span class="sr-only">More pages</span></span>`,
233
+ >${MoreHorizontalIcon({ class: "size-4" })}<span class="sr-only">${props.label ?? paginationLabels.morePages}</span></span>`,
192
234
  );