@c9up/nebula 0.2.2 → 0.2.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.
Files changed (116) hide show
  1. package/README.md +8 -7
  2. package/dist/atoms/Avatar.d.ts +14 -0
  3. package/dist/atoms/Avatar.js +46 -8
  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/cli/add.d.ts +2 -0
  9. package/dist/cli/add.js +4 -1
  10. package/dist/cli/diff.d.ts +2 -0
  11. package/dist/cli/diff.js +4 -1
  12. package/dist/cli/projectConfig.d.ts +16 -0
  13. package/dist/cli/projectConfig.js +61 -0
  14. package/dist/console/AddCommand.js +6 -1
  15. package/dist/console/DiffCommand.js +6 -1
  16. package/dist/lib/children.d.ts +13 -8
  17. package/dist/lib/children.js +5 -0
  18. package/dist/lib/icons.d.ts +8 -0
  19. package/dist/lib/icons.js +8 -0
  20. package/dist/lib/image.js +12 -1
  21. package/dist/molecules/Breadcrumb.d.ts +11 -2
  22. package/dist/molecules/Breadcrumb.js +2 -2
  23. package/dist/molecules/InputOTP.d.ts +14 -0
  24. package/dist/molecules/InputOTP.js +71 -28
  25. package/dist/molecules/Pagination.d.ts +34 -2
  26. package/dist/molecules/Pagination.js +15 -6
  27. package/dist/molecules/PieceMap.d.ts +72 -0
  28. package/dist/molecules/PieceMap.js +78 -0
  29. package/dist/molecules/Resizable.d.ts +2 -0
  30. package/dist/molecules/Resizable.js +1 -1
  31. package/dist/molecules/index.d.ts +4 -3
  32. package/dist/molecules/index.js +2 -1
  33. package/dist/organisms/Calendar.d.ts +13 -0
  34. package/dist/organisms/Calendar.js +2 -2
  35. package/dist/organisms/Carousel.d.ts +8 -0
  36. package/dist/organisms/Carousel.js +8 -5
  37. package/dist/organisms/Combobox.d.ts +13 -0
  38. package/dist/organisms/Combobox.js +5 -2
  39. package/dist/organisms/Command.js +56 -8
  40. package/dist/organisms/DataTable.d.ts +23 -1
  41. package/dist/organisms/DataTable.js +57 -27
  42. package/dist/organisms/DatePicker.d.ts +7 -0
  43. package/dist/organisms/DatePicker.js +2 -1
  44. package/dist/organisms/DateRangePicker.d.ts +2 -0
  45. package/dist/organisms/DateRangePicker.js +2 -1
  46. package/dist/organisms/Dialog.d.ts +13 -3
  47. package/dist/organisms/Dialog.js +12 -5
  48. package/dist/organisms/Form.d.ts +15 -0
  49. package/dist/organisms/Form.js +10 -0
  50. package/dist/organisms/Questionnaire.d.ts +4 -0
  51. package/dist/organisms/Questionnaire.js +5 -2
  52. package/dist/organisms/Select.d.ts +25 -4
  53. package/dist/organisms/Select.js +116 -15
  54. package/dist/organisms/Sheet.d.ts +2 -0
  55. package/dist/organisms/Sheet.js +2 -1
  56. package/dist/organisms/Sidebar.d.ts +10 -2
  57. package/dist/organisms/Sidebar.js +62 -29
  58. package/dist/organisms/Sonner.d.ts +243 -0
  59. package/dist/organisms/Sonner.js +909 -0
  60. package/dist/organisms/Toaster.d.ts +11 -0
  61. package/dist/organisms/Toaster.js +34 -9
  62. package/dist/organisms/Tooltip.d.ts +4 -0
  63. package/dist/organisms/index.d.ts +8 -2
  64. package/dist/organisms/index.js +7 -1
  65. package/dist/primitives/dismissable.d.ts +11 -4
  66. package/dist/primitives/dismissable.js +8 -6
  67. package/dist/primitives/floating.d.ts +5 -1
  68. package/dist/primitives/floating.js +32 -2
  69. package/dist/primitives/menu.js +2 -1
  70. package/dist/primitives/modalSurface.js +70 -36
  71. package/dist/primitives/presence.js +8 -5
  72. package/dist/templates/SettingsLayout.d.ts +2 -0
  73. package/dist/templates/SettingsLayout.js +1 -1
  74. package/nebula.css +2 -2
  75. package/package.json +3 -3
  76. package/registry.json +26 -0
  77. package/src/atoms/Avatar.ts +54 -7
  78. package/src/atoms/Checkbox.ts +1 -1
  79. package/src/atoms/Input.ts +6 -0
  80. package/src/cli/add.ts +7 -1
  81. package/src/cli/diff.ts +7 -1
  82. package/src/cli/projectConfig.ts +71 -0
  83. package/src/console/AddCommand.ts +6 -1
  84. package/src/console/DiffCommand.ts +6 -1
  85. package/src/lib/children.ts +15 -7
  86. package/src/lib/icons.ts +28 -0
  87. package/src/lib/image.ts +13 -1
  88. package/src/molecules/Breadcrumb.ts +15 -4
  89. package/src/molecules/InputOTP.ts +88 -28
  90. package/src/molecules/Pagination.ts +50 -8
  91. package/src/molecules/PieceMap.ts +136 -0
  92. package/src/molecules/Resizable.ts +3 -1
  93. package/src/molecules/index.ts +17 -0
  94. package/src/organisms/Calendar.ts +16 -2
  95. package/src/organisms/Carousel.ts +17 -5
  96. package/src/organisms/Combobox.ts +18 -2
  97. package/src/organisms/Command.ts +66 -7
  98. package/src/organisms/DataTable.ts +95 -30
  99. package/src/organisms/DatePicker.ts +10 -2
  100. package/src/organisms/DateRangePicker.ts +4 -2
  101. package/src/organisms/Dialog.ts +17 -5
  102. package/src/organisms/Form.ts +21 -0
  103. package/src/organisms/Questionnaire.ts +10 -2
  104. package/src/organisms/Select.ts +140 -16
  105. package/src/organisms/Sheet.ts +5 -1
  106. package/src/organisms/Sidebar.ts +62 -23
  107. package/src/organisms/Sonner.ts +1366 -0
  108. package/src/organisms/Toaster.ts +38 -10
  109. package/src/organisms/Tooltip.ts +4 -0
  110. package/src/organisms/index.ts +30 -1
  111. package/src/primitives/dismissable.ts +16 -8
  112. package/src/primitives/floating.ts +40 -3
  113. package/src/primitives/menu.ts +2 -1
  114. package/src/primitives/modalSurface.ts +77 -40
  115. package/src/primitives/presence.ts +12 -9
  116. package/src/templates/SettingsLayout.ts +3 -1
@@ -25,6 +25,10 @@ import { uid } from "../lib/id.js";
25
25
  import { read, readOr } from "../lib/props.js";
26
26
  const slotClasses = "border-input relative flex size-9 items-center justify-center border-y border-r text-center text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md focus:border-ring focus:ring-ring/50 focus:z-10 focus:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50";
27
27
  const InputOTPContext = createContext("InputOTP");
28
+ /** input-otp's patterns, for the `pattern` prop. */
29
+ export const REGEXP_ONLY_DIGITS = "^\\d+$";
30
+ export const REGEXP_ONLY_CHARS = "^[a-zA-Z]+$";
31
+ export const REGEXP_ONLY_DIGITS_AND_CHARS = "^[a-zA-Z0-9]+$";
28
32
  export const InputOTP = component((props) => {
29
33
  const length = props.length ?? 6;
30
34
  const groupId = uid("input-otp");
@@ -58,9 +62,48 @@ export const InputOTP = component((props) => {
58
62
  next[index] = character;
59
63
  commit(next);
60
64
  }
65
+ const pattern = typeof props.pattern === "string"
66
+ ? new RegExp(props.pattern)
67
+ : props.pattern;
68
+ function accepts(next) {
69
+ const joined = next.join("");
70
+ return pattern === undefined || joined === "" || pattern.test(joined);
71
+ }
72
+ /** Put the boxes back to what the code holds. */
73
+ function reflect() {
74
+ const inputs = boxes();
75
+ characters().forEach((character, position) => {
76
+ const input = inputs[position];
77
+ if (input !== undefined)
78
+ input.value = character;
79
+ });
80
+ }
81
+ /**
82
+ * Share a run of characters out over the boxes from `index`: a paste, and
83
+ * a whole code an autofill or an IME put into one box.
84
+ */
85
+ function spread(index, text) {
86
+ const next = [...characters()];
87
+ let cursor = index;
88
+ for (const character of text) {
89
+ if (cursor >= length)
90
+ break;
91
+ next[cursor] = character;
92
+ cursor += 1;
93
+ }
94
+ if (accepts(next))
95
+ commit(next);
96
+ // The boxes are uncontrolled between keystrokes, so writing the signal
97
+ // alone would leave the characters invisible — or a refused fill in place.
98
+ reflect();
99
+ focusBox(Math.min(cursor, length - 1));
100
+ }
61
101
  provide(InputOTPContext, {
62
102
  length,
103
+ inputMode: props.inputMode ?? "numeric",
63
104
  disabled: () => readOr(props.disabled, false),
105
+ slotLabel: props.slotLabel ??
106
+ ((position, total) => `Character ${position} of ${total}`),
64
107
  claimSlot() {
65
108
  const index = claimed;
66
109
  claimed += 1;
@@ -70,12 +113,30 @@ export const InputOTP = component((props) => {
70
113
  const target = event.target;
71
114
  if (!(target instanceof HTMLInputElement))
72
115
  return;
73
- // A box already holding a character receives the new one appended; keep
74
- // the last, which is what the user just typed.
75
- const typed = target.value.slice(-1);
76
- target.value = typed;
77
- write(index, typed);
78
- if (typed !== "" && index < length - 1)
116
+ const value = target.value;
117
+ // One key pressed in a box already holding a character: the box holds
118
+ // both, and the one just typed is what counts.
119
+ const typed = event instanceof InputEvent &&
120
+ event.inputType === "insertText" &&
121
+ event.data !== null &&
122
+ [...event.data].length === 1
123
+ ? event.data
124
+ : undefined;
125
+ if ([...value].length > 1 && typed === undefined) {
126
+ // A whole code at once: autofill, a password manager, an IME.
127
+ spread(index, value);
128
+ return;
129
+ }
130
+ const character = typed ?? value;
131
+ const next = [...characters()];
132
+ next[index] = character;
133
+ if (!accepts(next)) {
134
+ target.value = characters()[index] ?? "";
135
+ return;
136
+ }
137
+ target.value = character;
138
+ commit(next);
139
+ if (character !== "" && index < length - 1)
79
140
  focusBox(index + 1);
80
141
  },
81
142
  onKeyDown(index, event) {
@@ -102,25 +163,7 @@ export const InputOTP = component((props) => {
102
163
  if (pasted === "")
103
164
  return;
104
165
  event.preventDefault();
105
- const next = [...characters()];
106
- let cursor = index;
107
- for (const character of pasted) {
108
- if (cursor >= length)
109
- break;
110
- next[cursor] = character;
111
- cursor += 1;
112
- }
113
- commit(next);
114
- // Reflect into the DOM: the boxes are uncontrolled between keystrokes,
115
- // so writing the signal alone would leave the pasted characters
116
- // invisible.
117
- const inputs = boxes();
118
- next.forEach((character, position) => {
119
- const input = inputs[position];
120
- if (input !== undefined)
121
- input.value = character;
122
- });
123
- focusBox(Math.min(cursor, length - 1));
166
+ spread(index, pasted);
124
167
  },
125
168
  });
126
169
  return html `<div
@@ -153,10 +196,10 @@ export const InputOTPSlot = component((props) => {
153
196
  data-slot="input-otp-slot"
154
197
  data-otp-index="${index}"
155
198
  type="text"
156
- inputmode="numeric"
199
+ inputmode="${otp.inputMode}"
157
200
  autocomplete="${index === 0 ? "one-time-code" : "off"}"
158
- maxlength="1"
159
- aria-label="${`Character ${index + 1} of ${otp.length}`}"
201
+ maxlength="${otp.length}"
202
+ aria-label="${otp.slotLabel(index + 1, otp.length)}"
160
203
  ?disabled="${() => otp.disabled()}"
161
204
  class="${() => cn(slotClasses, read(props.class))}"
162
205
  @input="${(event) => otp.onInput(index, event)}"
@@ -32,7 +32,31 @@ export interface PaginationProps {
32
32
  children?: Slot;
33
33
  class?: Reactive<string>;
34
34
  }
35
- export declare const Pagination: (props?: PaginationProps | undefined) => import("@c9up/aurora").TemplateResult;
35
+ /**
36
+ * Every text the pagination writes, in one place.
37
+ *
38
+ * The defaults are upstream's English. An app in another language passes its
39
+ * own: most of these are read only by a screen reader, which would otherwise
40
+ * switch to English in the middle of the page.
41
+ */
42
+ export interface PaginationLabels {
43
+ /** The `<nav>`'s accessible name. */
44
+ navigation: string;
45
+ /** The visible word beside the previous arrow. */
46
+ previous: string;
47
+ /** The previous link's accessible name. */
48
+ previousPage: string;
49
+ next: string;
50
+ nextPage: string;
51
+ /** The ellipsis's hidden text. */
52
+ morePages: string;
53
+ }
54
+ /** Frozen: the defaults, not a place to set an app's language from. */
55
+ export declare const paginationLabels: Readonly<PaginationLabels>;
56
+ export interface PaginationNavProps extends PaginationProps {
57
+ "aria-label"?: string;
58
+ }
59
+ export declare const Pagination: (props?: PaginationNavProps | undefined) => import("@c9up/aurora").TemplateResult;
36
60
  export declare const PaginationContent: (props?: PaginationProps | undefined) => import("@c9up/aurora").TemplateResult;
37
61
  export declare const PaginationItem: (props?: PaginationProps | undefined) => import("@c9up/aurora").TemplateResult;
38
62
  export interface PaginationLinkProps {
@@ -56,10 +80,18 @@ export interface PaginationLinkProps {
56
80
  * work with JavaScript off.
57
81
  */
58
82
  export declare const PaginationLink: (props?: PaginationLinkProps | undefined) => import("@c9up/aurora").TemplateResult;
59
- export type PaginationStepProps = Omit<PaginationLinkProps, "size" | "isActive" | "aria-label">;
83
+ /**
84
+ * `aria-label` replaces the accessible name, as upstream's prop spread lets it.
85
+ * `children` replaces the visible word and keeps the arrow — upstream writes
86
+ * that word in the file, which an app owning its copy can edit and a package
87
+ * cannot.
88
+ */
89
+ export type PaginationStepProps = Omit<PaginationLinkProps, "size" | "isActive">;
60
90
  export declare const PaginationPrevious: (props?: PaginationStepProps | undefined) => import("@c9up/aurora").TemplateResult;
61
91
  export declare const PaginationNext: (props?: PaginationStepProps | undefined) => import("@c9up/aurora").TemplateResult;
62
92
  export interface PaginationEllipsisProps {
93
+ /** The hidden text. Default `"More pages"`. */
94
+ label?: string;
63
95
  class?: Reactive<string>;
64
96
  }
65
97
  /** Stands in for the pages that did not fit — see `pageWindow`. */
@@ -58,10 +58,19 @@ function range(from, to) {
58
58
  out.push(value);
59
59
  return out;
60
60
  }
61
+ /** Frozen: the defaults, not a place to set an app's language from. */
62
+ export const paginationLabels = Object.freeze({
63
+ navigation: "pagination",
64
+ previous: "Previous",
65
+ previousPage: "Go to previous page",
66
+ next: "Next",
67
+ nextPage: "Go to next page",
68
+ morePages: "More pages",
69
+ });
61
70
  export const Pagination = component((props) => html `<nav
62
71
  data-slot="pagination"
63
72
  role="navigation"
64
- aria-label="pagination"
73
+ aria-label="${props["aria-label"] ?? paginationLabels.navigation}"
65
74
  class="${() => cn("mx-auto flex w-full justify-center", read(props.class))}"
66
75
  >${slot(props.children)}</nav>`);
67
76
  export const PaginationContent = component((props) => html `<ul
@@ -109,20 +118,20 @@ export const PaginationLink = component((props) => {
109
118
  export const PaginationPrevious = component((props) => PaginationLink({
110
119
  ...props,
111
120
  size: "default",
112
- "aria-label": "Go to previous page",
121
+ "aria-label": props["aria-label"] ?? paginationLabels.previousPage,
113
122
  class: () => cn("gap-1 px-2.5 sm:pl-2.5", read(props.class)),
114
- children: html `${ChevronLeftIcon({})}<span class="hidden sm:block">Previous</span>`,
123
+ children: html `${ChevronLeftIcon({})}<span class="hidden sm:block">${slot(props.children ?? paginationLabels.previous)}</span>`,
115
124
  }));
116
125
  export const PaginationNext = component((props) => PaginationLink({
117
126
  ...props,
118
127
  size: "default",
119
- "aria-label": "Go to next page",
128
+ "aria-label": props["aria-label"] ?? paginationLabels.nextPage,
120
129
  class: () => cn("gap-1 px-2.5 sm:pr-2.5", read(props.class)),
121
- children: html `<span class="hidden sm:block">Next</span>${ChevronRightIcon({})}`,
130
+ children: html `<span class="hidden sm:block">${slot(props.children ?? paginationLabels.next)}</span>${ChevronRightIcon({})}`,
122
131
  }));
123
132
  /** Stands in for the pages that did not fit — see `pageWindow`. */
124
133
  export const PaginationEllipsis = component((props) => html `<span
125
134
  data-slot="pagination-ellipsis"
126
135
  aria-hidden="true"
127
136
  class="${() => cn("flex size-9 items-center justify-center", read(props.class))}"
128
- >${MoreHorizontalIcon({ class: "size-4" })}<span class="sr-only">More pages</span></span>`);
137
+ >${MoreHorizontalIcon({ class: "size-4" })}<span class="sr-only">${props.label ?? paginationLabels.morePages}</span></span>`);
@@ -0,0 +1,72 @@
1
+ /**
2
+ * PieceMap — a transfer drawn as one small square per piece.
3
+ *
4
+ * What a torrent client shows under a download: each square is a piece of the
5
+ * whole, coloured by where it stands — here, missing, on its way, taken from a
6
+ * peer. A progress bar says how much; the map says *which*, and that is what
7
+ * a stalled run, a missing layer or a peer serving one half shows at a glance.
8
+ *
9
+ * The states are the caller's, not a fixed set. A download, a replication and
10
+ * a backup do not have the same ones, so the component takes a string type of
11
+ * its own and a class per state — `tones` — and paints nothing it was not
12
+ * told about. The legend reads the same `tones`, so a square and its key can
13
+ * never drift apart.
14
+ *
15
+ * Pieces come in groups: each group after the first is set off by a rule — a
16
+ * torrent's files, an image's layers. A flat map is one group.
17
+ *
18
+ * A generic function rather than `component<P>`, as DataTable: `State` has to
19
+ * stay open so `tones` is checked against the caller's own states.
20
+ *
21
+ * With a `label`, the map is one image to assistive technology and the label
22
+ * is what it says ("12 of 40 pieces"): a screen reader walking hundreds of
23
+ * squares one by one learns nothing the sentence does not. Each square keeps
24
+ * its `title` for the pointer.
25
+ */
26
+ import { type TemplateResult } from "@c9up/aurora";
27
+ import type { Child } from "../lib/children.js";
28
+ import { type VariantProps } from "../lib/cva.js";
29
+ import { type Reactive } from "../lib/props.js";
30
+ export declare const pieceVariants: (props?: (import("../index.js").VariantSelection<{
31
+ size: {
32
+ sm: string;
33
+ default: string;
34
+ lg: string;
35
+ };
36
+ }> & import("../index.js").ClassOverrides) | undefined) => string;
37
+ export type PieceVariants = VariantProps<typeof pieceVariants>;
38
+ export interface Piece<State extends string> {
39
+ state: State;
40
+ /** The square's tooltip: which piece, how big, from where. */
41
+ title?: string;
42
+ }
43
+ export interface PieceMapProps<State extends string> {
44
+ /**
45
+ * The pieces, group after group, or an accessor for pieces that change: the
46
+ * squares are drawn again whenever what it reads changes.
47
+ */
48
+ groups: Reactive<readonly (readonly Piece<State>[])[]>;
49
+ /** The classes that paint each state: a background, a border, a pulse. */
50
+ tones: Readonly<Record<State, string>>;
51
+ size?: Reactive<PieceVariants["size"]>;
52
+ /** What the map says as a whole. Makes it one image; see above. */
53
+ label?: Reactive<string | undefined>;
54
+ class?: Reactive<string>;
55
+ }
56
+ export declare function PieceMap<State extends string>(props: PieceMapProps<State>): TemplateResult;
57
+ export interface PieceMapLegendItem<State extends string> {
58
+ state: State;
59
+ label: Child;
60
+ }
61
+ export interface PieceMapLegendProps<State extends string> {
62
+ /** The same `tones` as the map's. */
63
+ tones: Readonly<Record<State, string>>;
64
+ /** The states to explain, in the order they are read. */
65
+ items: readonly PieceMapLegendItem<State>[];
66
+ /** Said before the keys — the size of the whole, say. */
67
+ children?: Child;
68
+ size?: Reactive<PieceVariants["size"]>;
69
+ class?: Reactive<string>;
70
+ }
71
+ /** What the squares' colours mean. */
72
+ export declare function PieceMapLegend<State extends string>(props: PieceMapLegendProps<State>): TemplateResult;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * PieceMap — a transfer drawn as one small square per piece.
3
+ *
4
+ * What a torrent client shows under a download: each square is a piece of the
5
+ * whole, coloured by where it stands — here, missing, on its way, taken from a
6
+ * peer. A progress bar says how much; the map says *which*, and that is what
7
+ * a stalled run, a missing layer or a peer serving one half shows at a glance.
8
+ *
9
+ * The states are the caller's, not a fixed set. A download, a replication and
10
+ * a backup do not have the same ones, so the component takes a string type of
11
+ * its own and a class per state — `tones` — and paints nothing it was not
12
+ * told about. The legend reads the same `tones`, so a square and its key can
13
+ * never drift apart.
14
+ *
15
+ * Pieces come in groups: each group after the first is set off by a rule — a
16
+ * torrent's files, an image's layers. A flat map is one group.
17
+ *
18
+ * A generic function rather than `component<P>`, as DataTable: `State` has to
19
+ * stay open so `tones` is checked against the caller's own states.
20
+ *
21
+ * With a `label`, the map is one image to assistive technology and the label
22
+ * is what it says ("12 of 40 pieces"): a screen reader walking hundreds of
23
+ * squares one by one learns nothing the sentence does not. Each square keeps
24
+ * its `title` for the pointer.
25
+ */
26
+ import { html } from "@c9up/aurora";
27
+ import { cn } from "../lib/cn.js";
28
+ import { cva } from "../lib/cva.js";
29
+ import { read } from "../lib/props.js";
30
+ export const pieceVariants = cva("inline-block shrink-0 rounded-[2px]", {
31
+ variants: {
32
+ size: {
33
+ sm: "size-2",
34
+ default: "size-2.5",
35
+ lg: "size-3",
36
+ },
37
+ },
38
+ defaultVariants: { size: "default" },
39
+ });
40
+ export function PieceMap(props) {
41
+ return html `<div
42
+ data-slot="piece-map"
43
+ role="${() => (read(props.label) === undefined ? undefined : "img")}"
44
+ aria-label="${() => read(props.label)}"
45
+ class="${() => cn("flex flex-wrap gap-1", read(props.class))}"
46
+ >
47
+ ${() => read(props.groups).map((pieces, index) => html `<span
48
+ data-slot="piece-map-group"
49
+ class="${cn("flex flex-wrap gap-0.5", index > 0 && "border-border border-s ps-1")}"
50
+ >
51
+ ${pieces.map((piece) => html `<span
52
+ data-slot="piece"
53
+ data-state="${piece.state}"
54
+ title="${piece.title}"
55
+ class="${cn(pieceVariants({ size: read(props.size) }), props.tones[piece.state])}"
56
+ ></span>`)}
57
+ </span>`)}
58
+ </div>`;
59
+ }
60
+ /** What the squares' colours mean. */
61
+ export function PieceMapLegend(props) {
62
+ // A space after each key: the gap between them is only drawn, and without
63
+ // one their labels run together for a screen reader and a copy.
64
+ return html `<p
65
+ data-slot="piece-map-legend"
66
+ class="${() => cn("text-muted-foreground flex flex-wrap gap-x-4 gap-y-1 text-xs", read(props.class))}"
67
+ >
68
+ ${props.children}
69
+ ${props.items.map((item) => html `<span class="inline-flex items-center gap-1.5"
70
+ ><span
71
+ aria-hidden="true"
72
+ data-state="${item.state}"
73
+ class="${() => cn(pieceVariants({ size: read(props.size) }), props.tones[item.state])}"
74
+ ></span
75
+ >${item.label}</span
76
+ > `)}
77
+ </p>`;
78
+ }
@@ -50,6 +50,8 @@ export declare const ResizablePanel: (props?: ResizablePanelProps | undefined) =
50
50
  export interface ResizableHandleProps {
51
51
  /** Show the grip dots. */
52
52
  withHandle?: boolean;
53
+ /** The separator's accessible name. Default `"Resize panes"`. */
54
+ label?: string;
53
55
  class?: Reactive<string>;
54
56
  }
55
57
  /**
@@ -148,7 +148,7 @@ export const ResizableHandle = component((props) => {
148
148
  aria-valuemin="${group.min}"
149
149
  aria-valuemax="${group.max}"
150
150
  aria-valuenow="${() => Math.round(group.size())}"
151
- aria-label="Resize panes"
151
+ aria-label="${props.label ?? "Resize panes"}"
152
152
  class="${() => cn("bg-border relative flex shrink-0 items-center justify-center outline-none", "focus-visible:ring-ring focus-visible:ring-1 focus-visible:ring-offset-1", group.horizontal ? "w-px cursor-col-resize" : "h-px cursor-row-resize", read(props.class))}"
153
153
  @pointerdown="${onPointerDown}"
154
154
  @keydown="${onKeyDown}"
@@ -18,7 +18,7 @@
18
18
  export { Accordion, AccordionContent, type AccordionContentProps, AccordionItem, type AccordionItemProps, type AccordionProps, AccordionTrigger, type AccordionTriggerProps, } from "./Accordion.js";
19
19
  export { Alert, AlertDescription, type AlertProps, AlertTitle, type AlertVariants, alertVariants, } from "./Alert.js";
20
20
  export { Attachment, type AttachmentProps, formatBytes, } from "./Attachment.js";
21
- export { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, type BreadcrumbLinkProps, BreadcrumbList, BreadcrumbPage, type BreadcrumbProps, BreadcrumbSeparator, } from "./Breadcrumb.js";
21
+ export { Breadcrumb, BreadcrumbEllipsis, type BreadcrumbEllipsisProps, BreadcrumbItem, BreadcrumbLink, type BreadcrumbLinkProps, BreadcrumbList, type BreadcrumbNavProps, BreadcrumbPage, type BreadcrumbProps, BreadcrumbSeparator, } from "./Breadcrumb.js";
22
22
  export { Bubble, type BubbleProps, type BubbleReaction, type BubbleVariants, bubbleVariants, } from "./Bubble.js";
23
23
  export { ButtonGroup, type ButtonGroupProps, ButtonGroupSeparator, ButtonGroupText, } from "./ButtonGroup.js";
24
24
  export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, type CardProps, CardTitle, } from "./Card.js";
@@ -26,11 +26,12 @@ export { Collapsible, CollapsibleContent, type CollapsibleContentProps, type Col
26
26
  export { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, type EmptyProps, EmptyTitle, } from "./Empty.js";
27
27
  export { Field, FieldContent, FieldDescription, FieldError, type FieldErrorProps, FieldGroup, type FieldIds, FieldLabel, FieldLegend, type FieldLegendProps, type FieldProps, type FieldSectionProps, FieldSeparator, type FieldSeparatorProps, FieldSet, FieldTitle, fieldIds, } from "./Field.js";
28
28
  export { InputGroup, InputGroupAddon, type InputGroupAddonProps, InputGroupButton, type InputGroupButtonProps, InputGroupInput, type InputGroupProps, InputGroupText, InputGroupTextarea, type InputGroupTextProps, inputGroupControlClasses, } from "./InputGroup.js";
29
- export { InputOTP, InputOTPGroup, type InputOTPGroupProps, type InputOTPProps, InputOTPSeparator, type InputOTPSeparatorProps, InputOTPSlot, type InputOTPSlotProps, } from "./InputOTP.js";
29
+ export { InputOTP, InputOTPGroup, type InputOTPGroupProps, type InputOTPProps, InputOTPSeparator, type InputOTPSeparatorProps, InputOTPSlot, type InputOTPSlotProps, REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS, REGEXP_ONLY_DIGITS_AND_CHARS, } from "./InputOTP.js";
30
30
  export { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemMedia, type ItemProps, ItemSeparator, ItemTitle, type ItemVariants, itemVariants, } from "./Item.js";
31
31
  export { Message, type MessageProps } from "./Message.js";
32
- export { type PageSlot, Pagination, PaginationContent, PaginationEllipsis, type PaginationEllipsisProps, PaginationItem, PaginationLink, type PaginationLinkProps, PaginationNext, PaginationPrevious, type PaginationProps, type PaginationStepProps, pageWindow, } from "./Pagination.js";
32
+ export { type PageSlot, Pagination, PaginationContent, PaginationEllipsis, type PaginationEllipsisProps, PaginationItem, type PaginationLabels, PaginationLink, type PaginationLinkProps, type PaginationNavProps, PaginationNext, PaginationPrevious, type PaginationProps, type PaginationStepProps, pageWindow, } from "./Pagination.js";
33
33
  export { Picture, type PictureProps } from "./Picture.js";
34
+ export { type Piece, PieceMap, PieceMapLegend, type PieceMapLegendItem, type PieceMapLegendProps, type PieceMapProps, type PieceVariants, pieceVariants, } from "./PieceMap.js";
34
35
  export { RadioGroup, RadioGroupItem, type RadioGroupItemProps, type RadioGroupProps, } from "./RadioGroup.js";
35
36
  export { ResizableHandle, type ResizableHandleProps, ResizablePanel, ResizablePanelGroup, type ResizablePanelGroupProps, type ResizablePanelProps, } from "./Resizable.js";
36
37
  export { Table, TableBody, TableCaption, TableCell, type TableCellProps, TableFooter, TableHead, TableHeader, type TableProps, TableRow, type TableRowProps, } from "./Table.js";
@@ -26,11 +26,12 @@ export { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "./Collapsi
26
26
  export { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, } from "./Empty.js";
27
27
  export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, fieldIds, } from "./Field.js";
28
28
  export { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, inputGroupControlClasses, } from "./InputGroup.js";
29
- export { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, } from "./InputOTP.js";
29
+ export { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS, REGEXP_ONLY_DIGITS_AND_CHARS, } from "./InputOTP.js";
30
30
  export { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemMedia, ItemSeparator, ItemTitle, itemVariants, } from "./Item.js";
31
31
  export { Message } from "./Message.js";
32
32
  export { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, pageWindow, } from "./Pagination.js";
33
33
  export { Picture } from "./Picture.js";
34
+ export { PieceMap, PieceMapLegend, pieceVariants, } from "./PieceMap.js";
34
35
  export { RadioGroup, RadioGroupItem, } from "./RadioGroup.js";
35
36
  export { ResizableHandle, ResizablePanel, ResizablePanelGroup, } from "./Resizable.js";
36
37
  export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, } from "./Table.js";
@@ -28,6 +28,18 @@ export interface DateRange {
28
28
  readonly from: Date;
29
29
  readonly to?: Date;
30
30
  }
31
+ /**
32
+ * The words the calendar writes itself — react-day-picker's `labels`.
33
+ *
34
+ * Month and weekday names come from `Intl` in `locale`; these two do not, and
35
+ * a screen reader would read them in English in the middle of a French page.
36
+ */
37
+ export interface CalendarLabels {
38
+ /** The previous-month arrow. Default `"Previous month"`. */
39
+ previousMonth: string;
40
+ /** The next-month arrow. Default `"Next month"`. */
41
+ nextMonth: string;
42
+ }
31
43
  export interface CalendarProps {
32
44
  /**
33
45
  * `"range"` picks a span in two clicks. Default `"single"`.
@@ -54,6 +66,7 @@ export interface CalendarProps {
54
66
  /** `0` Sunday, `1` Monday. Defaults to the locale's own first day. */
55
67
  weekStartsOn?: number;
56
68
  locale?: string;
69
+ labels?: Partial<CalendarLabels>;
57
70
  class?: Reactive<string>;
58
71
  /** `"single"` mode. */
59
72
  onValueChange?: (date: Date) => void;
@@ -268,7 +268,7 @@ export const Calendar = component((props) => {
268
268
  <div class="flex items-center justify-between pb-4">
269
269
  <button
270
270
  type="button"
271
- aria-label="Previous month"
271
+ aria-label="${props.labels?.previousMonth ?? "Previous month"}"
272
272
  class="${buttonVariants({ variant: "outline", size: "icon", class: "size-7" })}"
273
273
  @click="${() => month(addMonths(month(), -1))}"
274
274
  >${ChevronLeftIcon({ class: "size-4" })}</button>
@@ -277,7 +277,7 @@ export const Calendar = component((props) => {
277
277
  </div>
278
278
  <button
279
279
  type="button"
280
- aria-label="Next month"
280
+ aria-label="${props.labels?.nextMonth ?? "Next month"}"
281
281
  class="${buttonVariants({ variant: "outline", size: "icon", class: "size-7" })}"
282
282
  @click="${() => month(addMonths(month(), 1))}"
283
283
  >${ChevronRightIcon({ class: "size-4" })}</button>
@@ -21,6 +21,8 @@ import { type Reactive } from "../lib/props.js";
21
21
  export interface CarouselProps {
22
22
  /** Announced before the slides. */
23
23
  label?: string;
24
+ /** What a screen reader calls the region. Default `"carousel"`. */
25
+ roleDescription?: string;
24
26
  orientation?: "horizontal" | "vertical";
25
27
  class?: Reactive<string>;
26
28
  children?: Parts;
@@ -34,6 +36,10 @@ export interface CarouselContentProps {
34
36
  export declare const CarouselContent: (props?: CarouselContentProps | undefined) => import("@c9up/aurora").TemplateResult;
35
37
  export interface CarouselItemProps {
36
38
  children?: Slot;
39
+ /** What a screen reader calls one slide. Default `"slide"`. */
40
+ roleDescription?: string;
41
+ /** The slide's name from its position. Default `"3 of 7"`. */
42
+ label?: (position: number, count: number) => string;
37
43
  class?: Reactive<string>;
38
44
  }
39
45
  /**
@@ -45,6 +51,8 @@ export interface CarouselItemProps {
45
51
  */
46
52
  export declare const CarouselItem: (props?: CarouselItemProps | undefined) => import("@c9up/aurora").TemplateResult;
47
53
  export interface CarouselButtonProps {
54
+ /** The arrow's accessible name. Default `"Previous slide"` / `"Next slide"`. */
55
+ label?: string;
48
56
  class?: Reactive<string>;
49
57
  }
50
58
  export declare const CarouselPrevious: (props?: CarouselButtonProps | undefined) => import("@c9up/aurora").TemplateResult;
@@ -97,7 +97,7 @@ export const Carousel = component((props) => {
97
97
  return html `<div
98
98
  data-slot="carousel"
99
99
  role="region"
100
- aria-roledescription="carousel"
100
+ aria-roledescription="${props.roleDescription ?? "carousel"}"
101
101
  aria-label="${props.label ?? "Carousel"}"
102
102
  class="${() => cn("relative", read(props.class))}"
103
103
  @keydown="${onKeyDown}"
@@ -126,18 +126,21 @@ export const CarouselItem = component((props) => {
126
126
  return html `<div
127
127
  data-slot="carousel-item"
128
128
  role="group"
129
- aria-roledescription="slide"
130
- aria-label="${() => `${position} of ${carousel.slideCount()}`}"
129
+ aria-roledescription="${props.roleDescription ?? "slide"}"
130
+ aria-label="${() => (props.label ?? slideOf)(position, carousel.slideCount())}"
131
131
  class="${() => cn("min-w-0 shrink-0 grow-0 basis-full snap-start", read(props.class))}"
132
132
  >${slot(props.children)}</div>`;
133
133
  });
134
+ function slideOf(position, count) {
135
+ return `${position} of ${count}`;
136
+ }
134
137
  const arrowClasses = "absolute size-8 rounded-full";
135
138
  export const CarouselPrevious = component((props) => {
136
139
  const carousel = inject(CarouselContext);
137
140
  return html `<button
138
141
  type="button"
139
142
  data-slot="carousel-previous"
140
- aria-label="Previous slide"
143
+ aria-label="${props.label ?? "Previous slide"}"
141
144
  ?disabled="${() => carousel.atStart()}"
142
145
  class="${() => cn(buttonVariants({ variant: "outline", size: "icon" }), arrowClasses, carousel.horizontal
143
146
  ? "top-1/2 -left-12 -translate-y-1/2"
@@ -150,7 +153,7 @@ export const CarouselNext = component((props) => {
150
153
  return html `<button
151
154
  type="button"
152
155
  data-slot="carousel-next"
153
- aria-label="Next slide"
156
+ aria-label="${props.label ?? "Next slide"}"
154
157
  ?disabled="${() => carousel.atEnd()}"
155
158
  class="${() => cn(buttonVariants({ variant: "outline", size: "icon" }), arrowClasses, carousel.horizontal
156
159
  ? "top-1/2 -right-12 -translate-y-1/2"
@@ -23,8 +23,21 @@ export interface ComboboxOption {
23
23
  disabled?: boolean;
24
24
  group?: string;
25
25
  }
26
+ /**
27
+ * `id`, `label`, `labelledBy` and `describedBy` name the trigger. Upstream's
28
+ * trigger is a Button that takes every button prop; these are the ones that
29
+ * name it — a `<Label for>` or a `FieldLabel` points at the `id`. Without them
30
+ * the combobox's only name was the value it showed.
31
+ */
26
32
  export interface ComboboxProps {
27
33
  options: readonly ComboboxOption[];
34
+ /** The trigger's id; a unique one is minted when left out. */
35
+ id?: string;
36
+ /** Accessible name (`aria-label`), for a combobox no `<label>` names. */
37
+ label?: Reactive<string | undefined>;
38
+ /** Id(s) of the element(s) that name it (`aria-labelledby`). */
39
+ labelledBy?: Reactive<string | undefined>;
40
+ describedBy?: Reactive<string | undefined>;
28
41
  name?: string;
29
42
  value?: Reactive<string | undefined>;
30
43
  defaultValue?: string;
@@ -19,14 +19,14 @@ import { cn } from "../lib/cn.js";
19
19
  import { ChevronsUpDownIcon } from "../lib/icons.js";
20
20
  import { uid } from "../lib/id.js";
21
21
  import { zoomInOut } from "../lib/motion.js";
22
- import { read, readOr } from "../lib/props.js";
22
+ import { accessor, read, readOr } from "../lib/props.js";
23
23
  import { controllable } from "../primitives/controllable.js";
24
24
  import { floatingSurface } from "../primitives/floatingSurface.js";
25
25
  import { focusSilently } from "../primitives/focusable.js";
26
26
  import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "./Command.js";
27
27
  import { selectTriggerClasses } from "./Select.js";
28
28
  export const Combobox = component((props) => {
29
- const triggerId = uid("combobox-trigger");
29
+ const triggerId = props.id ?? uid("combobox-trigger");
30
30
  const contentId = uid("combobox-content");
31
31
  const open = signal(false);
32
32
  const selection = controllable({
@@ -112,6 +112,9 @@ export const Combobox = component((props) => {
112
112
  type="button"
113
113
  data-slot="combobox-trigger"
114
114
  id="${triggerId}"
115
+ aria-label="${accessor(props.label, undefined)}"
116
+ aria-labelledby="${accessor(props.labelledBy, undefined)}"
117
+ aria-describedby="${accessor(props.describedBy, undefined)}"
115
118
  role="combobox"
116
119
  aria-haspopup="listbox"
117
120
  aria-expanded="${() => (open() ? "true" : "false")}"