@gemologic/sheen 0.2.1 → 0.4.0

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 (226) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/dist/ai.d.ts +8 -0
  4. package/dist/ai.js +5 -0
  5. package/dist/core.d.ts +11 -4
  6. package/dist/core.js +32 -28
  7. package/dist/formisch.js +1 -2
  8. package/dist/forms.d.ts +2 -0
  9. package/dist/forms.js +16 -15
  10. package/dist/index.d.ts +27 -5
  11. package/dist/index.js +87 -76
  12. package/dist/layout/Layout.js +1 -2
  13. package/dist/metadata.js +1 -2
  14. package/dist/navigation.d.ts +2 -1
  15. package/dist/navigation.js +16 -16
  16. package/dist/overlays.d.ts +2 -0
  17. package/dist/overlays.js +9 -8
  18. package/dist/primitives/Accordion.js +9 -9
  19. package/dist/primitives/ActivityTimeline.js +57 -49
  20. package/dist/primitives/AlertDialog.js +1 -2
  21. package/dist/primitives/Avatar.js +16 -17
  22. package/dist/primitives/Board.d.ts +39 -0
  23. package/dist/primitives/Board.js +471 -0
  24. package/dist/primitives/Breadcrumb.js +1 -2
  25. package/dist/primitives/Button.js +38 -27
  26. package/dist/primitives/ButtonGroup.js +1 -2
  27. package/dist/primitives/Checkbox.d.ts +16 -2
  28. package/dist/primitives/Checkbox.js +46 -36
  29. package/dist/primitives/CheckboxGroup.js +11 -12
  30. package/dist/primitives/Collapsible.js +6 -6
  31. package/dist/primitives/Combobox.js +203 -201
  32. package/dist/primitives/CommandPalette.d.ts +4 -0
  33. package/dist/primitives/CommandPalette.js +138 -116
  34. package/dist/primitives/ConfirmDialog.js +5 -6
  35. package/dist/primitives/ContextMenu.js +7 -8
  36. package/dist/primitives/Conversation.d.ts +17 -0
  37. package/dist/primitives/Conversation.js +107 -0
  38. package/dist/primitives/DescriptionList.js +1 -2
  39. package/dist/primitives/Dialog.js +101 -68
  40. package/dist/primitives/Drawer.js +12 -13
  41. package/dist/primitives/DropdownMenu.js +163 -157
  42. package/dist/primitives/EditableTextField.js +3 -8
  43. package/dist/primitives/EmptyState.js +1 -2
  44. package/dist/primitives/Field.js +1 -2
  45. package/dist/primitives/FileDropzone.js +19 -18
  46. package/dist/primitives/Form.d.ts +23 -0
  47. package/dist/primitives/Form.js +76 -0
  48. package/dist/primitives/Glyph.d.ts +40 -0
  49. package/dist/primitives/Glyph.js +65 -0
  50. package/dist/primitives/IconButton.js +5 -6
  51. package/dist/primitives/Input.js +1 -2
  52. package/dist/primitives/InputGroup.js +8 -9
  53. package/dist/primitives/Link.d.ts +9 -1
  54. package/dist/primitives/Link.js +23 -17
  55. package/dist/primitives/LinkTooltip.js +6 -7
  56. package/dist/primitives/List.d.ts +34 -0
  57. package/dist/primitives/List.js +135 -0
  58. package/dist/primitives/Message.d.ts +13 -0
  59. package/dist/primitives/Message.js +75 -0
  60. package/dist/primitives/NavList.js +15 -16
  61. package/dist/primitives/Notice.d.ts +15 -1
  62. package/dist/primitives/Notice.js +91 -43
  63. package/dist/primitives/NumberField.js +81 -81
  64. package/dist/primitives/NumberText.d.ts +4 -0
  65. package/dist/primitives/NumberText.js +50 -25
  66. package/dist/primitives/Pagination.js +81 -60
  67. package/dist/primitives/Popover.d.ts +1 -0
  68. package/dist/primitives/Popover.js +65 -57
  69. package/dist/primitives/Progress.js +1 -2
  70. package/dist/primitives/PromptInput.d.ts +23 -0
  71. package/dist/primitives/PromptInput.js +135 -0
  72. package/dist/primitives/RadioGroup.js +12 -17
  73. package/dist/primitives/Resizable.js +1 -2
  74. package/dist/primitives/ScrollArea.js +1 -2
  75. package/dist/primitives/SearchInput.js +45 -38
  76. package/dist/primitives/SegmentedControl.d.ts +2 -0
  77. package/dist/primitives/SegmentedControl.js +92 -78
  78. package/dist/primitives/Select.js +105 -100
  79. package/dist/primitives/Separator.js +1 -2
  80. package/dist/primitives/ShortcutPending.js +11 -12
  81. package/dist/primitives/ShortcutProvider.d.ts +5 -0
  82. package/dist/primitives/ShortcutProvider.js +71 -65
  83. package/dist/primitives/ShortcutScope.js +8 -9
  84. package/dist/primitives/ShortcutSheet.js +30 -24
  85. package/dist/primitives/Skeleton.js +1 -2
  86. package/dist/primitives/Slider.js +1 -2
  87. package/dist/primitives/SortableList.d.ts +19 -0
  88. package/dist/primitives/SortableList.js +235 -0
  89. package/dist/primitives/Spinner.js +1 -2
  90. package/dist/primitives/Status.js +14 -14
  91. package/dist/primitives/Stepper.js +54 -52
  92. package/dist/primitives/StreamingText.d.ts +12 -0
  93. package/dist/primitives/StreamingText.js +42 -0
  94. package/dist/primitives/Surface.js +1 -2
  95. package/dist/primitives/Switch.d.ts +2 -2
  96. package/dist/primitives/Switch.js +1 -2
  97. package/dist/primitives/Table.js +1 -2
  98. package/dist/primitives/Tabs.js +20 -17
  99. package/dist/primitives/TagInput.js +6 -9
  100. package/dist/primitives/Textarea.js +37 -63
  101. package/dist/primitives/Toast.js +42 -41
  102. package/dist/primitives/Toaster.js +27 -28
  103. package/dist/primitives/Tooltip.js +32 -32
  104. package/dist/primitives/TooltipTrigger.d.ts +18 -0
  105. package/dist/primitives/TooltipTrigger.js +76 -0
  106. package/dist/primitives/Tree.js +1 -2
  107. package/dist/primitives/Typography.d.ts +6 -2
  108. package/dist/primitives/Typography.js +20 -12
  109. package/dist/primitives/boolean-input-state.js +3 -8
  110. package/dist/primitives/button-variants.js +2 -3
  111. package/dist/primitives/choice-options.js +1 -2
  112. package/dist/primitives/create-confirm.js +1 -2
  113. package/dist/primitives/create-toaster.js +1 -2
  114. package/dist/primitives/link-focus.js +1 -2
  115. package/dist/primitives/menu-focus.js +1 -2
  116. package/dist/primitives/sortable-core.d.ts +70 -0
  117. package/dist/primitives/sortable-core.js +109 -0
  118. package/dist/primitives/sortable-drag.d.ts +29 -0
  119. package/dist/primitives/sortable-drag.js +50 -0
  120. package/dist/primitives/tooltip-layer.js +26 -27
  121. package/dist/sortable.d.ts +6 -0
  122. package/dist/sortable.js +4 -0
  123. package/dist/theme/ThemeProvider.d.ts +6 -1
  124. package/dist/theme/ThemeProvider.js +65 -58
  125. package/dist/theme/intl.js +1 -2
  126. package/dist/theme/keyboard-script.js +1 -2
  127. package/dist/theme/layers.js +1 -2
  128. package/dist/theme/messages.d.ts +26 -0
  129. package/dist/theme/messages.js +9 -2
  130. package/dist/theme/number-format-cache.js +1 -2
  131. package/dist/theme/script.d.ts +1 -0
  132. package/dist/theme/script.js +3 -3
  133. package/dist/theme/state.d.ts +4 -4
  134. package/dist/theme/state.js +12 -13
  135. package/dist/utils/auto-resize.d.ts +6 -0
  136. package/dist/utils/auto-resize.js +31 -0
  137. package/dist/utils/browser-status.js +1 -2
  138. package/dist/utils/change-motion.d.ts +8 -0
  139. package/dist/utils/change-motion.js +19 -0
  140. package/dist/utils/cn.js +1 -2
  141. package/dist/utils/media-query.d.ts +10 -0
  142. package/dist/utils/media-query.js +16 -0
  143. package/dist/utils/optimistic.js +1 -2
  144. package/dist/utils/shortcut-platform.js +1 -2
  145. package/dist/utils/shortcut-registry.d.ts +5 -0
  146. package/dist/utils/shortcut-registry.js +61 -51
  147. package/dist/vite.js +3 -4
  148. package/package.json +23 -5
  149. package/src/ai.ts +8 -0
  150. package/src/core.ts +11 -4
  151. package/src/forms.ts +2 -0
  152. package/src/index.ts +27 -5
  153. package/src/navigation.ts +2 -1
  154. package/src/overlays.ts +2 -0
  155. package/src/primitives/Accordion.tsx +1 -1
  156. package/src/primitives/ActivityTimeline.tsx +12 -7
  157. package/src/primitives/Board.tsx +406 -0
  158. package/src/primitives/Button.tsx +15 -4
  159. package/src/primitives/Checkbox.tsx +14 -7
  160. package/src/primitives/Collapsible.tsx +1 -1
  161. package/src/primitives/Combobox.tsx +2 -1
  162. package/src/primitives/CommandPalette.tsx +13 -4
  163. package/src/primitives/Conversation.tsx +108 -0
  164. package/src/primitives/Dialog.tsx +5 -1
  165. package/src/primitives/DropdownMenu.tsx +12 -6
  166. package/src/primitives/FileDropzone.tsx +2 -2
  167. package/src/primitives/Form.tsx +58 -0
  168. package/src/primitives/Glyph.tsx +55 -0
  169. package/src/primitives/Link.tsx +15 -6
  170. package/src/primitives/List.tsx +68 -0
  171. package/src/primitives/Message.tsx +40 -0
  172. package/src/primitives/Notice.tsx +45 -12
  173. package/src/primitives/NumberField.tsx +3 -2
  174. package/src/primitives/NumberText.tsx +31 -4
  175. package/src/primitives/Pagination.tsx +6 -5
  176. package/src/primitives/Popover.tsx +7 -5
  177. package/src/primitives/PromptInput.tsx +116 -0
  178. package/src/primitives/SearchInput.tsx +4 -3
  179. package/src/primitives/SegmentedControl.tsx +29 -4
  180. package/src/primitives/Select.tsx +3 -2
  181. package/src/primitives/ShortcutProvider.tsx +14 -1
  182. package/src/primitives/ShortcutSheet.tsx +1 -1
  183. package/src/primitives/SortableList.tsx +208 -0
  184. package/src/primitives/Status.tsx +1 -1
  185. package/src/primitives/Stepper.tsx +7 -7
  186. package/src/primitives/StreamingText.tsx +32 -0
  187. package/src/primitives/Switch.tsx +2 -2
  188. package/src/primitives/Tabs.tsx +2 -1
  189. package/src/primitives/TagInput.tsx +1 -1
  190. package/src/primitives/Textarea.tsx +3 -47
  191. package/src/primitives/Toast.tsx +2 -1
  192. package/src/primitives/Tooltip.tsx +4 -2
  193. package/src/primitives/TooltipTrigger.tsx +60 -0
  194. package/src/primitives/Typography.tsx +11 -2
  195. package/src/primitives/button-variants.ts +1 -1
  196. package/src/primitives/sortable-core.ts +139 -0
  197. package/src/primitives/sortable-drag.ts +75 -0
  198. package/src/sortable.ts +6 -0
  199. package/src/styles/ai.css +57 -0
  200. package/src/styles/core.css +321 -0
  201. package/src/styles/forms.css +263 -0
  202. package/src/styles/navigation.css +137 -0
  203. package/src/styles/overlays.css +107 -0
  204. package/src/styles/sortable.css +87 -0
  205. package/src/styles.css +5 -658
  206. package/src/theme/ThemeProvider.tsx +20 -8
  207. package/src/theme/messages.ts +20 -1
  208. package/src/theme/script.ts +2 -2
  209. package/src/theme/state.ts +5 -5
  210. package/src/utils/auto-resize.ts +58 -0
  211. package/src/utils/change-motion.ts +28 -0
  212. package/src/utils/media-query.ts +26 -0
  213. package/src/utils/shortcut-registry.ts +19 -2
  214. package/src/vite.ts +3 -3
  215. package/vendor/integrity.json +13 -13
  216. package/vendor/kobalte-core/chunk/3D6FM2PJ.js +7 -1
  217. package/vendor/kobalte-core/chunk/G3KI2B4X.js +2 -1
  218. package/vendor/kobalte-core/chunk/KEL2LLJM.jsx +2 -1
  219. package/vendor/kobalte-core/chunk/RFN6X5VH.jsx +7 -1
  220. package/vendor/origins.json +4 -4
  221. package/vendor/solid-web/dev.cjs +21 -17
  222. package/vendor/solid-web/dev.js +21 -17
  223. package/vendor/solid-web/server.cjs +1 -1
  224. package/vendor/solid-web/server.js +1 -1
  225. package/vendor/solid-web/web.cjs +21 -17
  226. package/vendor/solid-web/web.js +21 -17
@@ -0,0 +1,406 @@
1
+ import { For, Show, batch, createEffect, createMemo, createSignal, createUniqueId, onCleanup, onMount, splitProps } from "solid-js";
2
+ import type { Accessor, JSX } from "solid-js";
3
+ import { useTheme } from "../theme/ThemeProvider.tsx";
4
+ import { useNumberFormatter } from "../theme/intl.ts";
5
+ import { cn } from "../utils/cn.ts";
6
+ import { closestEdge, dropIndex, edgeField, formatMessage, isRtl, keyIntent, moveId, resolveSortableMessages, scrollContainers, stringField, validateIds } from "./sortable-core.ts";
7
+ import type { SortableEdge, SortableItem, SortableMessages, SortableReorder } from "./sortable-core.ts";
8
+ import { bindDraggable, bindDropTarget, bindMonitor } from "./sortable-drag.ts";
9
+ import type { DragData } from "./sortable-drag.ts";
10
+ import { Glyph } from "./Glyph.tsx";
11
+
12
+ export interface BoardColumn<Card extends SortableItem = SortableItem> {
13
+ readonly id: string;
14
+ /** Column title, used by the default header and in announcements. */
15
+ readonly label: string;
16
+ readonly cards: readonly Card[];
17
+ /** A disabled column neither accepts cards nor lets its cards or itself be picked up. */
18
+ readonly disabled?: boolean;
19
+ }
20
+
21
+ export interface BoardMove {
22
+ readonly id: string;
23
+ readonly fromColumn: string;
24
+ readonly fromIndex: number;
25
+ readonly toColumn: string;
26
+ /** Final index in `toColumn`, measured after the card leaves its original position. */
27
+ readonly index: number;
28
+ }
29
+
30
+ export type BoardCardOf<Column extends BoardColumn> = Column["cards"][number];
31
+
32
+ export type BoardProps<Column extends BoardColumn> = Omit<JSX.HTMLAttributes<HTMLDivElement>, "children" | "ref" | "onDrop"> & {
33
+ ref?: HTMLDivElement | ((element: HTMLDivElement) => void);
34
+ /** Owner-ordered columns. Column and card ids are stable and unique across the board. */
35
+ columns: readonly Column[];
36
+ children: (card: Accessor<BoardCardOf<Column>>, column: Accessor<Column>) => JSX.Element;
37
+ /** Replaces the default title and count inside each column header. The reorder handle stays Sheen-owned. */
38
+ columnHeader?: (column: Accessor<Column>, count: Accessor<number>) => JSX.Element;
39
+ /** Proposes a card move. The board is controlled: nothing moves until the owner passes updated columns back. */
40
+ onMove: (move: BoardMove) => void;
41
+ /** Enables column reordering through each header's handle. */
42
+ onColumnReorder?: (reorder: SortableReorder) => void;
43
+ /** Accessible name for the board. */
44
+ label: string;
45
+ /** Render a grip button on each card that owns pointer and keyboard dragging. Without it the whole card drags and takes focus. */
46
+ handle?: boolean;
47
+ disabled?: boolean;
48
+ messages?: Partial<SortableMessages>;
49
+ };
50
+
51
+ interface Position { readonly column: string; readonly index: number }
52
+ type Lift =
53
+ | { readonly kind: "card"; readonly id: string; readonly origin: Position; readonly target: Position }
54
+ | { readonly kind: "column"; readonly id: string; readonly origin: number; readonly target: number };
55
+ type Indicator =
56
+ | { readonly kind: "card"; readonly id: string; readonly edge: SortableEdge }
57
+ | { readonly kind: "append"; readonly id: string }
58
+ | { readonly kind: "column"; readonly id: string; readonly edge: SortableEdge };
59
+
60
+ function sameIndicator(first: Indicator | undefined, second: Indicator | undefined): boolean {
61
+ if (!first || !second) return first === second;
62
+ return first.kind === second.kind && first.id === second.id && (first.kind === "append" || second.kind === "append" || first.edge === second.edge);
63
+ }
64
+
65
+ /** A controlled Kanban board: cards move within and between columns, and columns optionally reorder. */
66
+ export function Board<Column extends BoardColumn>(props: BoardProps<Column>): JSX.Element {
67
+ const theme = useTheme();
68
+ const formatter = useNumberFormatter();
69
+ const generatedId = createUniqueId();
70
+ const instance = Symbol("Board");
71
+ const [local, others] = splitProps(props, ["ref", "class", "columns", "children", "columnHeader", "onMove", "onColumnReorder", "label", "handle", "disabled", "messages", "aria-describedby"]);
72
+ const messages = createMemo(() => resolveSortableMessages(theme.messages(), local.messages));
73
+ const columnIndex = createMemo(() => {
74
+ validateIds(local.columns.map(column => column.id), "Board columns");
75
+ validateIds(local.columns.flatMap(column => column.cards.map(card => card.id)), "Board cards");
76
+ return new Map(local.columns.map(column => [column.id, column]));
77
+ });
78
+ const cardIndex = createMemo(() => {
79
+ const map = new Map<string, { readonly card: BoardCardOf<Column>; readonly column: string }>();
80
+ for (const column of local.columns) for (const card of column.cards) map.set(card.id, { card, column: column.id });
81
+ return map;
82
+ });
83
+ const ownedColumns = createMemo(() => [...columnIndex().keys()]);
84
+ const ownedCards = (column: string) => columnIndex().get(column)?.cards.map(card => card.id) ?? [];
85
+ const [lift, setLift] = createSignal<Lift>();
86
+ const [indicator, setIndicator] = createSignal<Indicator>();
87
+ const [dragging, setDragging] = createSignal<string>();
88
+ const [announcement, setAnnouncement] = createSignal("");
89
+ // A refresh that removes the lifted card, its target column, or the lifted column ends the lift.
90
+ const activeLift = createMemo(() => {
91
+ const current = lift();
92
+ if (!current) return undefined;
93
+ if (current.kind === "column") return columnIndex().has(current.id) ? current : undefined;
94
+ return cardIndex().has(current.id) && columnIndex().has(current.target.column) ? current : undefined;
95
+ });
96
+ const columnIds = createMemo(() => {
97
+ const current = activeLift();
98
+ return current?.kind === "column" ? moveId(ownedColumns(), current.id, current.target) : ownedColumns();
99
+ });
100
+ const cardIds = (column: string): string[] => {
101
+ const current = activeLift();
102
+ const owned = ownedCards(column);
103
+ if (current?.kind !== "card") return owned;
104
+ const without = owned.filter(id => id !== current.id);
105
+ if (current.target.column !== column) return without;
106
+ without.splice(Math.min(without.length, current.target.index), 0, current.id);
107
+ return without;
108
+ };
109
+ const instructionsId = `${generatedId}-instructions`;
110
+ let root: HTMLDivElement | undefined;
111
+ let scroller: HTMLDivElement | undefined;
112
+ let relocating = false;
113
+ let disposed = false;
114
+ onCleanup(() => { disposed = true; });
115
+
116
+ const columnDisabled = (column: string) => Boolean(local.disabled || columnIndex().get(column)?.disabled);
117
+ const cardDisabled = (id: string) => {
118
+ const entry = cardIndex().get(id);
119
+ return !entry || columnDisabled(entry.column) || Boolean(entry.card.disabled);
120
+ };
121
+ const columnLabel = (column: string) => columnIndex().get(column)?.label ?? column;
122
+ const accepts = (source: DragData) => source.boardInstance === instance;
123
+ const find = (selector: string, attribute: string, id: string) => [...root?.querySelectorAll<HTMLElement>(selector) ?? []].find(element => element.getAttribute(attribute) === id);
124
+ const keyboardTarget = (kind: Lift["kind"], id: string): HTMLElement | undefined => {
125
+ if (kind === "column") return find(".sheen-board-column", "data-column-id", id)?.querySelector<HTMLElement>(".sheen-board-column-handle") ?? undefined;
126
+ const card = find(".sheen-board-card", "data-card-id", id);
127
+ return local.handle ? card?.querySelector<HTMLElement>(".sheen-board-card-handle") ?? undefined : card;
128
+ };
129
+ const say = (text: string) => {
130
+ setAnnouncement("");
131
+ queueMicrotask(() => { if (!disposed) setAnnouncement(text); });
132
+ };
133
+ const count = (value: number) => formatter().format(value);
134
+ const announceCard = (template: string, id: string, position: Position) => say(formatMessage(template, {
135
+ label: cardIndex().get(id)?.card.label ?? id, column: columnLabel(position.column),
136
+ position: count(position.index + 1), count: count(ownedCards(position.column).filter(card => card !== id).length + 1),
137
+ }));
138
+ const announceColumn = (template: string, id: string, position: number) => say(formatMessage(template, {
139
+ label: columnLabel(id), position: count(position + 1), count: count(ownedColumns().length),
140
+ }));
141
+ const relocate = (kind: Lift["kind"], id: string, update: () => void) => {
142
+ relocating = true;
143
+ try { update(); }
144
+ finally {
145
+ const target = keyboardTarget(kind, id);
146
+ if (target && target.ownerDocument.activeElement !== target) target.focus();
147
+ relocating = false;
148
+ }
149
+ };
150
+ const cardPosition = (id: string): Position | undefined => {
151
+ const entry = cardIndex().get(id);
152
+ return entry ? { column: entry.column, index: ownedCards(entry.column).indexOf(id) } : undefined;
153
+ };
154
+ const proposeCard = (id: string, target: Position) => {
155
+ const origin = cardPosition(id);
156
+ if (!origin || (origin.column === target.column && origin.index === target.index)) return;
157
+ local.onMove({ id, fromColumn: origin.column, fromIndex: origin.index, toColumn: target.column, index: target.index });
158
+ };
159
+ const proposeColumn = (id: string, fromIndex: number, toIndex: number) => {
160
+ if (!local.onColumnReorder || fromIndex === toIndex || fromIndex < 0) return;
161
+ local.onColumnReorder({ id, fromIndex, toIndex, ids: moveId(ownedColumns(), id, toIndex) });
162
+ };
163
+ const cancel = () => {
164
+ const current = activeLift();
165
+ setLift(undefined);
166
+ if (current?.kind === "card") announceCard(messages().boardCancelled, current.id, current.origin);
167
+ else if (current) announceColumn(messages().sortableCancelled, current.id, current.origin);
168
+ };
169
+ const neighbourColumn = (from: string, delta: -1 | 1): string | undefined => {
170
+ const order = columnIds();
171
+ for (let position = order.indexOf(from) + delta; position >= 0 && position < order.length; position += delta) {
172
+ const candidate = order[position];
173
+ if (candidate !== undefined && !columnDisabled(candidate)) return candidate;
174
+ }
175
+ return undefined;
176
+ };
177
+ const moveCard = (current: Extract<Lift, { kind: "card" }>, intent: NonNullable<ReturnType<typeof keyIntent>>): Position | undefined => {
178
+ const room = (column: string) => ownedCards(column).filter(id => id !== current.id).length;
179
+ const { column, index } = current.target;
180
+ if (intent.kind === "edge") return { column, index: intent.to === "start" ? 0 : room(column) };
181
+ if (intent.kind !== "step") return undefined;
182
+ if (intent.axis === "vertical") return { column, index: Math.max(0, Math.min(room(column), index + intent.delta)) };
183
+ const next = neighbourColumn(column, intent.delta);
184
+ return next ? { column: next, index: Math.min(index, room(next)) } : undefined;
185
+ };
186
+ const onKeyDown = (kind: Lift["kind"], id: string, event: KeyboardEvent, element: HTMLElement) => {
187
+ if (event.target !== element || event.altKey || event.ctrlKey || event.metaKey) return;
188
+ const intent = keyIntent(event.key, isRtl(element));
189
+ const current = activeLift();
190
+ if (!intent) return;
191
+ if (!current) {
192
+ if (intent.kind !== "toggle") return;
193
+ if (kind === "card") {
194
+ const origin = cardPosition(id);
195
+ if (!origin || cardDisabled(id)) return;
196
+ event.preventDefault();
197
+ setLift({ kind, id, origin, target: origin });
198
+ announceCard(messages().boardLifted, id, origin);
199
+ } else {
200
+ if (columnDisabled(id)) return;
201
+ event.preventDefault();
202
+ const origin = ownedColumns().indexOf(id);
203
+ setLift({ kind, id, origin, target: origin });
204
+ announceColumn(messages().sortableLifted, id, origin);
205
+ }
206
+ return;
207
+ }
208
+ if (current.id !== id || current.kind !== kind) return;
209
+ event.preventDefault();
210
+ if (intent.kind === "cancel") { relocate(kind, id, cancel); return; }
211
+ if (current.kind === "card") {
212
+ if (intent.kind === "toggle") {
213
+ relocate(kind, id, () => batch(() => { proposeCard(id, current.target); setLift(undefined); }));
214
+ announceCard(messages().boardDropped, id, current.target);
215
+ return;
216
+ }
217
+ const target = moveCard(current, intent);
218
+ if (!target || (target.column === current.target.column && target.index === current.target.index)) return;
219
+ relocate(kind, id, () => setLift({ ...current, target }));
220
+ announceCard(messages().boardMoved, id, target);
221
+ return;
222
+ }
223
+ if (intent.kind === "toggle") {
224
+ relocate(kind, id, () => batch(() => { proposeColumn(id, current.origin, current.target); setLift(undefined); }));
225
+ announceColumn(messages().sortableDropped, id, current.target);
226
+ return;
227
+ }
228
+ if (intent.kind === "step" && intent.axis !== "horizontal") return;
229
+ const last = ownedColumns().length - 1;
230
+ const target = intent.kind === "edge" ? (intent.to === "start" ? 0 : last) : Math.max(0, Math.min(last, current.target + intent.delta));
231
+ if (target === current.target) return;
232
+ relocate(kind, id, () => setLift({ ...current, target }));
233
+ announceColumn(messages().sortableMoved, id, target);
234
+ };
235
+ const onFocusOut = (id: string, event: FocusEvent, element: HTMLElement) => {
236
+ if (relocating || activeLift()?.id !== id) return;
237
+ if (event.relatedTarget instanceof Node && element.contains(event.relatedTarget)) return;
238
+ cancel();
239
+ };
240
+ const resolveCardDrop = (cardId: string, target: DragData): { readonly position: Position; readonly indicator: Indicator } | undefined => {
241
+ const column = stringField(target, "columnId");
242
+ if (!column) return undefined;
243
+ const others = ownedCards(column).filter(id => id !== cardId);
244
+ if (target.kind === "column") return { position: { column, index: others.length }, indicator: { kind: "append", id: column } };
245
+ const over = stringField(target, "cardId");
246
+ const edge = edgeField(target);
247
+ if (!over || !edge || over === cardId) return undefined;
248
+ const index = others.indexOf(over) + (edge === "after" ? 1 : 0);
249
+ return { position: { column, index }, indicator: { kind: "card", id: over, edge } };
250
+ };
251
+ const resolveColumnDrop = (columnId: string, target: DragData) => {
252
+ const over = stringField(target, "columnId");
253
+ const edge = edgeField(target);
254
+ if (target.kind !== "column" || !over || !edge) return undefined;
255
+ const from = ownedColumns().indexOf(columnId);
256
+ const to = dropIndex(from, ownedColumns().indexOf(over), edge);
257
+ return to === from ? undefined : { from, to, indicator: { kind: "column", id: over, edge } satisfies Indicator };
258
+ };
259
+ const isNoop = (cardId: string, position: Position) => {
260
+ const origin = cardPosition(cardId);
261
+ return origin?.column === position.column && origin.index === position.index;
262
+ };
263
+
264
+ onMount(() => {
265
+ if (!scroller) return;
266
+ const columns = scroller;
267
+ onCleanup(bindMonitor({
268
+ accepts,
269
+ scrollers: () => scrollContainers(columns, ...columns.querySelectorAll<HTMLElement>(".sheen-board-cards")),
270
+ onDrag: (source, target) => {
271
+ const sourceId = stringField(source, "sourceId");
272
+ let next: Indicator | undefined;
273
+ if (sourceId && target && source.kind === "card") {
274
+ const drop = resolveCardDrop(sourceId, target);
275
+ next = drop && !isNoop(sourceId, drop.position) ? drop.indicator : undefined;
276
+ } else if (sourceId && target && source.kind === "column") next = resolveColumnDrop(sourceId, target)?.indicator;
277
+ if (!sameIndicator(indicator(), next)) setIndicator(next);
278
+ },
279
+ onDrop: (source, target) => {
280
+ setIndicator(undefined);
281
+ const sourceId = stringField(source, "sourceId");
282
+ if (!sourceId || !target) return;
283
+ if (source.kind === "card") {
284
+ const drop = resolveCardDrop(sourceId, target);
285
+ if (!drop || isNoop(sourceId, drop.position)) return;
286
+ proposeCard(sourceId, drop.position);
287
+ announceCard(messages().boardDropped, sourceId, drop.position);
288
+ } else if (source.kind === "column") {
289
+ const drop = resolveColumnDrop(sourceId, target);
290
+ if (!drop) return;
291
+ proposeColumn(sourceId, drop.from, drop.to);
292
+ announceColumn(messages().sortableDropped, sourceId, drop.to);
293
+ }
294
+ },
295
+ }));
296
+ });
297
+
298
+ return <div {...others} ref={element => { root = element; if (typeof local.ref === "function") local.ref(element); }} class={cn("sheen-board", local.class)}
299
+ role="group" aria-label={local.label} aria-describedby={[instructionsId, local["aria-describedby"]].filter(Boolean).join(" ")}
300
+ data-disabled={local.disabled ? "" : undefined} data-active={activeLift() || dragging() ? "" : undefined}>
301
+ <div ref={scroller} class="sheen-board-columns">
302
+ <For each={columnIds()}>{columnId => {
303
+ const initial = columnIndex().get(columnId);
304
+ if (!initial) throw new Error(`Board: missing column ${JSON.stringify(columnId)}`);
305
+ let lastColumn = initial;
306
+ const column = () => { const value = columnIndex().get(columnId); if (value) lastColumn = value; return lastColumn; };
307
+ const cards = createMemo(() => cardIds(columnId), undefined, { equals: (first, second) => first.length === second.length && first.every((id, position) => id === second[position]) });
308
+ const total = () => cards().length;
309
+ const headerId = createUniqueId();
310
+ const disabled = () => columnDisabled(columnId);
311
+ const lifted = () => activeLift()?.kind === "column" && activeLift()?.id === columnId;
312
+ const columnIndicator = () => { const value = indicator(); return value && value.kind !== "card" && value.id === columnId ? value : undefined; };
313
+ let section: HTMLDivElement | undefined;
314
+ let columnHandle: HTMLButtonElement | undefined;
315
+ createEffect(() => {
316
+ if (!section) return;
317
+ const target = section;
318
+ const reorderable = Boolean(local.onColumnReorder);
319
+ const release = [bindDropTarget({
320
+ element: target,
321
+ accepts: source => accepts(source) && !disabled() && (source.kind === "card" || reorderable),
322
+ data: input => ({ kind: "column", columnId, edge: closestEdge(target, input, "horizontal") }),
323
+ })];
324
+ if (reorderable && columnHandle) release.push(bindDraggable({
325
+ element: target, handle: columnHandle, canDrag: () => !disabled() && !activeLift(),
326
+ data: () => ({ boardInstance: instance, kind: "column", sourceId: columnId }),
327
+ onStart: () => setDragging(columnId), onEnd: () => setDragging(undefined),
328
+ }));
329
+ onCleanup(() => { for (const cleanup of release) cleanup(); });
330
+ });
331
+ return <div ref={section} class="sheen-board-column" role="group" aria-labelledby={headerId} data-column-id={columnId}
332
+ data-disabled={disabled() ? "" : undefined} data-lifted={lifted() ? "" : undefined} data-dragging={dragging() === columnId ? "" : undefined}
333
+ data-drop-target={columnIndicator()?.kind === "append" ? "" : undefined}
334
+ data-drop-edge={(() => { const value = columnIndicator(); return value?.kind === "column" ? value.edge : undefined; })()}>
335
+ <div class="sheen-board-column-header">
336
+ <Show when={local.onColumnReorder}>
337
+ <button ref={columnHandle} type="button" class="sheen-sortable-handle sheen-board-column-handle" aria-label={formatMessage(messages().boardColumnHandle, { label: column().label })}
338
+ aria-describedby={instructionsId} aria-pressed={lifted() ? "true" : "false"} disabled={disabled()}
339
+ onKeyDown={event => onKeyDown("column", columnId, event, event.currentTarget)} onFocusOut={event => onFocusOut(columnId, event, event.currentTarget)}>
340
+ <Glyph class="sheen-sortable-grip" name="grip" />
341
+ </button>
342
+ </Show>
343
+ <div id={headerId} class="sheen-board-column-heading">
344
+ <Show when={local.columnHeader} fallback={<>
345
+ <span class="sheen-board-column-title">{column().label}</span>
346
+ <span class="sheen-board-column-count" aria-label={formatMessage(messages().boardCardCount, { count: count(total()) })}>{count(total())}</span>
347
+ </>}>{render => render()(column, total)}</Show>
348
+ </div>
349
+ </div>
350
+ <ul class="sheen-board-cards" role="list" aria-labelledby={headerId}>
351
+ <For each={cards()}>{cardId => <BoardCardNode cardId={cardId} column={column} />}</For>
352
+ </ul>
353
+ <Show when={total() === 0}><p class="sheen-board-empty">{messages().boardEmptyColumn}</p></Show>
354
+ </div>;
355
+ }}</For>
356
+ </div>
357
+ <span id={instructionsId} class="sheen-sortable-hidden">{messages().boardInstructions}</span>
358
+ <span class="sheen-sortable-hidden" role="status" aria-live="assertive" aria-atomic="true">{announcement()}</span>
359
+ </div>;
360
+
361
+ function BoardCardNode(card: { readonly cardId: string; readonly column: Accessor<Column> }): JSX.Element {
362
+ const id = card.cardId;
363
+ const initial = cardIndex().get(id);
364
+ if (!initial) throw new Error(`Board: missing card ${JSON.stringify(id)}`);
365
+ let last: BoardCardOf<Column> = initial.card;
366
+ const value = (): BoardCardOf<Column> => { const entry = cardIndex().get(id); if (entry) last = entry.card; return last; };
367
+ const disabled = () => cardDisabled(id);
368
+ const lifted = () => activeLift()?.kind === "card" && activeLift()?.id === id;
369
+ const ownKeys = () => !local.handle;
370
+ const cardIndicator = () => { const current = indicator(); return current?.kind === "card" && current.id === id ? current.edge : undefined; };
371
+ let element: HTMLLIElement | undefined;
372
+ let handle: HTMLButtonElement | undefined;
373
+ createEffect(() => {
374
+ if (!element) return;
375
+ const target = element;
376
+ const dragHandle = local.handle ? handle : undefined;
377
+ const release = [
378
+ bindDraggable({
379
+ element: target, handle: dragHandle, canDrag: () => !disabled() && !activeLift(),
380
+ data: () => ({ boardInstance: instance, kind: "card", sourceId: id }),
381
+ onStart: () => setDragging(id), onEnd: () => setDragging(undefined),
382
+ }),
383
+ bindDropTarget({
384
+ element: target,
385
+ accepts: source => accepts(source) && source.kind === "card" && !columnDisabled(card.column().id),
386
+ data: input => ({ kind: "card", cardId: id, columnId: card.column().id, edge: closestEdge(target, input, "vertical") }),
387
+ }),
388
+ ];
389
+ onCleanup(() => { for (const cleanup of release) cleanup(); });
390
+ });
391
+ return <li ref={element} class="sheen-board-card" data-card-id={id}
392
+ data-disabled={disabled() ? "" : undefined} data-lifted={lifted() ? "" : undefined} data-dragging={dragging() === id ? "" : undefined} data-drop-edge={cardIndicator()}
393
+ tabindex={ownKeys() && !disabled() ? 0 : undefined} aria-describedby={ownKeys() ? instructionsId : undefined} aria-disabled={ownKeys() && disabled() ? "true" : undefined}
394
+ onKeyDown={event => { if (ownKeys()) onKeyDown("card", id, event, event.currentTarget); }}
395
+ onFocusOut={event => { if (ownKeys()) onFocusOut(id, event, event.currentTarget); }}>
396
+ <Show when={local.handle}>
397
+ <button ref={handle} type="button" class="sheen-sortable-handle sheen-board-card-handle" aria-label={formatMessage(messages().boardCardHandle, { label: value().label })}
398
+ aria-describedby={instructionsId} aria-pressed={lifted() ? "true" : "false"} disabled={disabled()}
399
+ onKeyDown={event => onKeyDown("card", id, event, event.currentTarget)} onFocusOut={event => onFocusOut(id, event, event.currentTarget)}>
400
+ <Glyph class="sheen-sortable-grip" name="grip" />
401
+ </button>
402
+ </Show>
403
+ <div class="sheen-board-card-content">{local.children(value, card.column)}</div>
404
+ </li>;
405
+ }
406
+ }
@@ -15,13 +15,24 @@ export interface ButtonProps extends JSX.ButtonHTMLAttributes<HTMLButtonElement>
15
15
  }
16
16
 
17
17
  export function Button(props: ButtonProps): JSX.Element {
18
- const [local, others] = splitProps(props, ["class", "variant", "tone", "size", "loading", "disabled", "shortcut", "ref", "children"]);
18
+ const [local, others] = splitProps(props, ["class", "variant", "tone", "size", "loading", "disabled", "shortcut", "ref", "onClick", "children"]);
19
19
  let element: HTMLButtonElement | undefined;
20
20
  const binding = useShortcutAction(() => local.shortcut, () => {
21
21
  if (!local.disabled && !local.loading) element?.click();
22
22
  });
23
- return <button {...others} ref={node => { element = node; if (typeof local.ref === "function") local.ref(node); }} type={others.type ?? "button"}
23
+ // Loading keeps the native button enabled so focus survives the pending work; activation is suppressed here instead.
24
+ const click: JSX.EventHandler<HTMLButtonElement, MouseEvent> = event => {
25
+ if (local.loading) {
26
+ event.preventDefault();
27
+ event.stopPropagation();
28
+ return;
29
+ }
30
+ const handler = local.onClick;
31
+ if (typeof handler === "function") handler(event);
32
+ else if (handler) handler[0](handler[1], event);
33
+ };
34
+ return <button {...others} onClick={click} ref={node => { element = node; if (typeof local.ref === "function") local.ref(node); }} type={others.type ?? "button"}
24
35
  class={cn(buttonVariants({ variant: local.variant, tone: local.tone, size: local.size }), local.class)}
25
- data-variant={local.variant ?? "ghost"} data-tone={local.tone ?? "neutral"} data-size={local.size ?? "md"}
26
- data-sheen-shortcut={binding()?.displayKeys} disabled={local.disabled || local.loading} aria-busy={local.loading || undefined}>{local.children}</button>;
36
+ data-variant={local.variant ?? "outline"} data-tone={local.tone ?? "neutral"} data-size={local.size ?? "md"}
37
+ data-sheen-shortcut={binding()?.displayKeys} disabled={local.disabled} aria-disabled={local.loading && !local.disabled ? "true" : others["aria-disabled"]} aria-busy={local.loading || undefined}>{local.children}</button>;
27
38
  }
@@ -3,11 +3,17 @@ import type { JSX } from "solid-js";
3
3
  import { cn } from "../utils/cn.ts";
4
4
  import { createBooleanInputState } from "./boolean-input-state.ts";
5
5
 
6
- export interface CheckboxProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "children" | "onChange" | "id" | "ref" | "onPointerDown"> {
6
+ /** Exactly one accessible name source for the native input. */
7
+ export type BooleanControlName =
8
+ | { label: string; "aria-label"?: never; "aria-labelledby"?: never }
9
+ | { label?: never; "aria-label": string; "aria-labelledby"?: never }
10
+ | { label?: never; "aria-label"?: never; "aria-labelledby": string };
11
+
12
+ // Directives apply only to native elements, never through a component's props.
13
+ export interface BooleanControlBaseProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "children" | "onChange" | "id" | "ref" | "onPointerDown" | "aria-label" | "aria-labelledby" | `use:${string}`> {
7
14
  id?: string;
8
15
  ref?: HTMLDivElement | ((element: HTMLDivElement) => void);
9
16
  onPointerDown?: NonNullable<JSX.HTMLAttributes<HTMLDivElement>["onPointerDown"]>;
10
- label: string;
11
17
  description?: string;
12
18
  error?: string;
13
19
  checked?: boolean;
@@ -23,23 +29,24 @@ export interface CheckboxProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>,
23
29
  inputRef?: (element: HTMLInputElement) => void;
24
30
  }
25
31
 
32
+ export type CheckboxProps = BooleanControlBaseProps & BooleanControlName;
33
+
26
34
  export function createNativeBooleanControl(props: CheckboxProps, kind: "checkbox" | "switch"): JSX.Element {
27
35
  const [local, state, others] = splitProps(props,
28
- ["label", "description", "error", "class", "onCheckedChange", "inputRef", "form"],
36
+ ["label", "aria-label", "aria-labelledby", "description", "error", "class", "onCheckedChange", "inputRef", "form"],
29
37
  ["checked", "defaultChecked", "indeterminate", "disabled", "readOnly", "required", "name", "value"]);
30
38
  const prefix = `sheen-${kind}`;
31
39
  const generatedId = createUniqueId();
32
40
  const inputId = `${generatedId}-input`;
33
- let input: HTMLInputElement | undefined;
34
41
  const describedBy = () => [local.description ? `${generatedId}-description` : "", local.error ? `${generatedId}-error` : ""].filter(Boolean).join(" ") || undefined;
35
42
  const { checked, requestChange, setInput } = createBooleanInputState(state, next => local.onCheckedChange?.(next));
36
43
  return <div {...others} class={cn(prefix, local.class)} data-checked={checked() || undefined} data-indeterminate={state.indeterminate || undefined} data-disabled={state.disabled || undefined} data-readonly={state.readOnly || undefined} data-invalid={local.error ? "" : undefined}>
37
44
  <div class={`${prefix}-row`}>
38
- <input id={inputId} type="checkbox" role={kind === "switch" ? "switch" : undefined} name={state.name ?? ""} value={state.value} form={local.form} disabled={state.disabled} required={state.required} readOnly={state.readOnly} checked={checked()} aria-readonly={state.readOnly || undefined} aria-invalid={local.error ? "true" : undefined} aria-describedby={describedBy()} class={`${prefix}-input`} ref={element => { input = element; setInput(element); local.inputRef?.(element); }} onChange={event => requestChange(event.currentTarget)} />
39
- <span class={`${prefix}-control`} data-indeterminate={state.indeterminate || undefined} aria-hidden="true" onClick={() => input?.click()}>
45
+ <input id={inputId} type="checkbox" role={kind === "switch" ? "switch" : undefined} name={state.name ?? ""} value={state.value} form={local.form} disabled={state.disabled} required={state.required} readOnly={state.readOnly} checked={checked()} aria-label={local["aria-label"]} aria-labelledby={local["aria-labelledby"]} aria-readonly={state.readOnly || undefined} aria-invalid={local.error ? "true" : undefined} aria-describedby={describedBy()} class={`${prefix}-input`} ref={element => { setInput(element); local.inputRef?.(element); }} onChange={event => requestChange(event.currentTarget)} />
46
+ <span class={`${prefix}-control`} data-indeterminate={state.indeterminate || undefined} aria-hidden="true">
40
47
  {kind === "checkbox" ? <span class="sheen-checkbox-indicator"><span class="sheen-checkbox-mark" /></span> : <span class="sheen-switch-thumb" />}
41
48
  </span>
42
- <label for={inputId} class={`${prefix}-label`}>{local.label}<Show when={state.required}><span aria-hidden="true"> *</span></Show></label>
49
+ <Show when={local.label}>{label => <label for={inputId} class={`${prefix}-label`}>{label()}<Show when={state.required}><span aria-hidden="true"> *</span></Show></label>}</Show>
43
50
  </div>
44
51
  <Show when={local.description}><p id={`${generatedId}-description`} class={`${prefix}-description`}>{local.description}</p></Show>
45
52
  <Show when={local.error}><p id={`${generatedId}-error`} class={`${prefix}-error`}>{local.error}</p></Show>
@@ -33,7 +33,7 @@ export function Collapsible(props: CollapsibleProps): JSX.Element {
33
33
  };
34
34
  createEffect(() => { if (!open()) restoreFocus(); });
35
35
  return <Primitive.Root {...others} id={id()} class={cn("sheen-collapsible", local.class)} open={open()} onOpenChange={change} disabled={local.disabled ?? false}>
36
- <Primitive.Trigger as={Button} ref={trigger} id={`${id()}-trigger`} aria-controls={`${id()}-content`} class="sheen-collapsible-trigger">
36
+ <Primitive.Trigger as={Button} variant="ghost" ref={trigger} id={`${id()}-trigger`} aria-controls={`${id()}-content`} class="sheen-collapsible-trigger">
37
37
  <span class="sheen-collapsible-indicator" aria-hidden="true" />{local.label}
38
38
  </Primitive.Trigger>
39
39
  <div ref={content} id={`${id()}-content`} class="sheen-collapsible-content" data-open={open()} aria-hidden={!open() || undefined} inert={!open()}>
@@ -1,4 +1,5 @@
1
1
  import * as Primitive from "#sheen-kobalte/combobox";
2
+ import { Glyph } from "./Glyph.tsx";
2
3
  import { For, Show, createEffect, createMemo, createSignal, createUniqueId, onCleanup, onMount, splitProps } from "solid-js";
3
4
  import type { Accessor, JSX } from "solid-js";
4
5
  import { useTheme } from "../theme/ThemeProvider.tsx";
@@ -143,7 +144,7 @@ function OptionItem(props: Primitive.ComboboxRootItemComponentProps<ComboboxOpti
143
144
  }}>
144
145
  <Primitive.ItemLabel>{props.item.rawValue.label}</Primitive.ItemLabel>
145
146
  <Show when={props.item.rawValue.description}>{description => <Primitive.ItemDescription class="sheen-select-option-description">{description()}</Primitive.ItemDescription>}</Show>
146
- <Primitive.ItemIndicator class="sheen-select-indicator" aria-hidden="true">✓</Primitive.ItemIndicator>
147
+ <Primitive.ItemIndicator class="sheen-select-indicator" aria-hidden="true"><Glyph name="check" /></Primitive.ItemIndicator>
147
148
  </Primitive.Item>;
148
149
  }
149
150
 
@@ -12,6 +12,10 @@ export interface CommandPaletteCommand {
12
12
  readonly group: string;
13
13
  readonly keywords?: readonly string[];
14
14
  readonly disabled?: boolean;
15
+ /** Renders decorative leading content, hidden from assistive technology. */
16
+ readonly icon?: () => JSX.Element;
17
+ /** Renders trailing content such as a shortcut hint or badge, exposed as the option's description. */
18
+ readonly trailing?: () => JSX.Element;
15
19
  readonly run: () => void | Promise<void>;
16
20
  }
17
21
 
@@ -161,12 +165,12 @@ export function CommandPalette(props: CommandPaletteProps): JSX.Element {
161
165
  onCleanup(() => controller.abort());
162
166
  });
163
167
 
164
- const registeredCommands = createMemo<readonly CommandPaletteCommand[]>(() => shortcuts.bindings().filter(binding => !binding.shadowed).map(binding => Object.freeze({
168
+ // The palette's own open shortcut is not a command inside the palette.
169
+ const registeredCommands = createMemo<readonly CommandPaletteCommand[]>(() => shortcuts.bindings().filter(binding => !binding.shadowed && !(binding.keys === "mod+k" && binding.label === theme.messages().openCommandPalette)).map(binding => Object.freeze({
165
170
  id: `shortcut:${binding.id}`,
166
171
  label: binding.label,
167
172
  group: binding.group,
168
173
  keywords: [binding.keys, binding.displayKeys, binding.scope],
169
- disabled: binding.keys === "mod+k" && binding.label === theme.messages().openCommandPalette,
170
174
  run: () => { shortcuts.run(binding.id); },
171
175
  })));
172
176
  const commands = createMemo(() => {
@@ -208,9 +212,14 @@ export function CommandPalette(props: CommandPaletteProps): JSX.Element {
208
212
  };
209
213
  const item = (command: CommandPaletteCommand) => {
210
214
  const binding = () => shortcuts.bindings().find(value => `shortcut:${value.id}` === command.id);
215
+ const id = createUniqueId();
216
+ const described = () => command.trailing !== undefined || binding() !== undefined;
211
217
  return <Command.Item value={`${command.id} ${command.label}`} keywords={[...(command.keywords ?? [])]}
212
- {...(command.disabled === undefined ? {} : { disabled: command.disabled })} onSelect={() => select(command)}>
213
- <span>{command.label}</span><Show when={binding()}>{value => <Kbd>{value().displayKeys}</Kbd>}</Show>
218
+ {...(command.disabled === undefined ? {} : { disabled: command.disabled })} onSelect={() => select(command)}
219
+ aria-labelledby={`${id}-label`} aria-describedby={described() ? `${id}-trailing` : undefined}>
220
+ <Show when={command.icon !== undefined}><span class="sheen-command-icon" aria-hidden="true">{command.icon?.()}</span></Show>
221
+ <span id={`${id}-label`} class="sheen-command-label">{command.label}</span>
222
+ <Show when={described()}><span id={`${id}-trailing`} class="sheen-command-trailing">{command.trailing?.()}<Show when={binding()}>{value => <Kbd>{value().displayKeys}</Kbd>}</Show></span></Show>
214
223
  </Command.Item>;
215
224
  };
216
225