@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.
- package/README.md +11 -9
- package/dist/atoms/AccessibleIcon.d.ts +24 -0
- package/dist/atoms/AccessibleIcon.js +27 -0
- package/dist/atoms/Checkbox.d.ts +1 -1
- package/dist/atoms/Checkbox.js +1 -1
- package/dist/atoms/Input.d.ts +5 -0
- package/dist/atoms/Input.js +1 -0
- package/dist/atoms/VisuallyHidden.d.ts +30 -0
- package/dist/atoms/VisuallyHidden.js +35 -0
- package/dist/atoms/index.d.ts +2 -0
- package/dist/atoms/index.js +2 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.js +7 -4
- package/dist/lib/children.d.ts +13 -8
- package/dist/lib/children.js +5 -0
- package/dist/molecules/Breadcrumb.d.ts +11 -2
- package/dist/molecules/Breadcrumb.js +2 -2
- package/dist/molecules/InputOTP.d.ts +2 -0
- package/dist/molecules/InputOTP.js +3 -1
- package/dist/molecules/Pagination.d.ts +34 -2
- package/dist/molecules/Pagination.js +15 -6
- package/dist/molecules/PieceMap.d.ts +72 -0
- package/dist/molecules/PieceMap.js +78 -0
- package/dist/molecules/Resizable.d.ts +2 -0
- package/dist/molecules/Resizable.js +1 -1
- package/dist/molecules/Toolbar.d.ts +50 -0
- package/dist/molecules/Toolbar.js +70 -0
- package/dist/molecules/index.d.ts +10 -7
- package/dist/molecules/index.js +8 -5
- package/dist/organisms/Calendar.d.ts +13 -0
- package/dist/organisms/Calendar.js +2 -2
- package/dist/organisms/Carousel.d.ts +8 -0
- package/dist/organisms/Carousel.js +8 -5
- package/dist/organisms/DataTable.d.ts +23 -1
- package/dist/organisms/DataTable.js +57 -27
- package/dist/organisms/DatePicker.d.ts +7 -0
- package/dist/organisms/DatePicker.js +2 -1
- package/dist/organisms/DateRangePicker.d.ts +2 -0
- package/dist/organisms/DateRangePicker.js +2 -1
- package/dist/organisms/Dialog.d.ts +13 -3
- package/dist/organisms/Dialog.js +12 -5
- package/dist/organisms/Questionnaire.d.ts +4 -0
- package/dist/organisms/Questionnaire.js +5 -2
- package/dist/organisms/Select.d.ts +23 -4
- package/dist/organisms/Select.js +115 -15
- package/dist/organisms/Sheet.d.ts +2 -0
- package/dist/organisms/Sheet.js +2 -1
- package/dist/organisms/Sidebar.d.ts +6 -0
- package/dist/organisms/Sidebar.js +9 -4
- package/dist/organisms/Toaster.d.ts +80 -10
- package/dist/organisms/Toaster.js +152 -24
- package/dist/organisms/index.d.ts +3 -3
- package/dist/organisms/index.js +1 -1
- package/dist/primitives/direction.d.ts +38 -0
- package/dist/primitives/direction.js +57 -0
- package/dist/primitives/floating.js +25 -13
- package/dist/primitives/focusable.d.ts +10 -0
- package/dist/primitives/focusable.js +10 -1
- package/dist/primitives/index.d.ts +2 -1
- package/dist/primitives/index.js +2 -1
- package/dist/primitives/rovingFocus.js +14 -7
- package/dist/templates/SettingsLayout.d.ts +2 -0
- package/dist/templates/SettingsLayout.js +1 -1
- package/nebula.css +1 -1
- package/package.json +3 -3
- package/registry.json +76 -0
- package/src/atoms/AccessibleIcon.ts +39 -0
- package/src/atoms/Checkbox.ts +1 -1
- package/src/atoms/Input.ts +6 -0
- package/src/atoms/VisuallyHidden.ts +45 -0
- package/src/atoms/index.ts +8 -0
- package/src/index.ts +7 -4
- package/src/lib/children.ts +15 -7
- package/src/molecules/Breadcrumb.ts +15 -4
- package/src/molecules/InputOTP.ts +7 -1
- package/src/molecules/Pagination.ts +50 -8
- package/src/molecules/PieceMap.ts +136 -0
- package/src/molecules/Resizable.ts +3 -1
- package/src/molecules/Toolbar.ts +100 -0
- package/src/molecules/index.ts +28 -5
- package/src/organisms/Calendar.ts +16 -2
- package/src/organisms/Carousel.ts +17 -5
- package/src/organisms/DataTable.ts +95 -30
- package/src/organisms/DatePicker.ts +10 -2
- package/src/organisms/DateRangePicker.ts +4 -2
- package/src/organisms/Dialog.ts +17 -5
- package/src/organisms/Questionnaire.ts +10 -2
- package/src/organisms/Select.ts +137 -16
- package/src/organisms/Sheet.ts +5 -1
- package/src/organisms/Sidebar.ts +15 -4
- package/src/organisms/Toaster.ts +215 -37
- package/src/organisms/index.ts +9 -1
- package/src/primitives/direction.ts +61 -0
- package/src/primitives/floating.ts +29 -13
- package/src/primitives/focusable.ts +10 -1
- package/src/primitives/index.ts +7 -0
- package/src/primitives/rovingFocus.ts +18 -5
- package/src/templates/SettingsLayout.ts +3 -1
package/src/organisms/Select.ts
CHANGED
|
@@ -19,10 +19,19 @@
|
|
|
19
19
|
* ` })}
|
|
20
20
|
* ` })
|
|
21
21
|
*
|
|
22
|
-
* The items REGISTER themselves as they are built
|
|
23
|
-
*
|
|
24
|
-
* the
|
|
25
|
-
*
|
|
22
|
+
* The items REGISTER themselves as they are built: what each one is called and
|
|
23
|
+
* whether it is disabled, by value. WHICH options exist and in what order is
|
|
24
|
+
* read from the mounted list, as Radix's collection reads it — so options built
|
|
25
|
+
* in an accessor follow a signal:
|
|
26
|
+
*
|
|
27
|
+
* SelectContent({ children: () => html`${() => roles().map((role) =>
|
|
28
|
+
* SelectItem({ value: role.id, children: role.name }))}` })
|
|
29
|
+
*
|
|
30
|
+
* Closed, the list is still mounted, outside the document, as Radix renders a
|
|
31
|
+
* closed select's content into a DocumentFragment: the options exist, so the
|
|
32
|
+
* trigger shows the chosen one's label and the keyboard can walk them. Focus
|
|
33
|
+
* stays on the trigger and only `aria-activedescendant` moves, so the walk is
|
|
34
|
+
* over those options, not over focusable elements.
|
|
26
35
|
*
|
|
27
36
|
* What a native `<select>` was doing for free, and all of which has to be put
|
|
28
37
|
* back by hand:
|
|
@@ -42,12 +51,16 @@
|
|
|
42
51
|
import {
|
|
43
52
|
component,
|
|
44
53
|
createContext,
|
|
54
|
+
effect,
|
|
45
55
|
html,
|
|
46
56
|
inject,
|
|
57
|
+
onMount,
|
|
47
58
|
onUnmount,
|
|
48
59
|
provide,
|
|
60
|
+
render,
|
|
49
61
|
signal,
|
|
50
62
|
type TemplateResult,
|
|
63
|
+
untrack,
|
|
51
64
|
} from "@c9up/aurora";
|
|
52
65
|
import type { Child, Parts, Slot } from "../lib/children.js";
|
|
53
66
|
import { slot } from "../lib/children.js";
|
|
@@ -55,7 +68,7 @@ import { cn } from "../lib/cn.js";
|
|
|
55
68
|
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "../lib/icons.js";
|
|
56
69
|
import { uid } from "../lib/id.js";
|
|
57
70
|
import { slideInFromSide, zoomInOut } from "../lib/motion.js";
|
|
58
|
-
import { type Reactive, read, readOr } from "../lib/props.js";
|
|
71
|
+
import { accessor, type Reactive, read, readOr } from "../lib/props.js";
|
|
59
72
|
import { controllable } from "../primitives/controllable.js";
|
|
60
73
|
import type { Align, Placement, Side } from "../primitives/floating.js";
|
|
61
74
|
import { floatingSurface } from "../primitives/floatingSurface.js";
|
|
@@ -91,7 +104,12 @@ interface RegisteredContent {
|
|
|
91
104
|
}
|
|
92
105
|
|
|
93
106
|
interface SelectApi {
|
|
94
|
-
|
|
107
|
+
/**
|
|
108
|
+
* The trigger's id: the one it was given, or one minted here. Claimed as the
|
|
109
|
+
* trigger is built, which is before anything that reads it — the anchor,
|
|
110
|
+
* the list's `aria-labelledby`, the focus return — first runs.
|
|
111
|
+
*/
|
|
112
|
+
claimTriggerId(id: string | undefined): string;
|
|
95
113
|
readonly listId: string;
|
|
96
114
|
readonly open: () => boolean;
|
|
97
115
|
readonly value: () => string | undefined;
|
|
@@ -108,6 +126,12 @@ interface SelectApi {
|
|
|
108
126
|
setActive(value: string | undefined): void;
|
|
109
127
|
onTriggerKeyDown(event: KeyboardEvent): void;
|
|
110
128
|
registerItem(item: RegisteredItem): void;
|
|
129
|
+
/**
|
|
130
|
+
* An option's element is in a mounted list; the returned function says it
|
|
131
|
+
* left. Counted, because the list can be mounted twice for a moment — the
|
|
132
|
+
* closing panel still fading out, the closed copy already in place.
|
|
133
|
+
*/
|
|
134
|
+
attachItem(value: string): () => void;
|
|
111
135
|
registerContent(content: RegisteredContent): void;
|
|
112
136
|
}
|
|
113
137
|
|
|
@@ -126,9 +150,25 @@ export interface SelectProps {
|
|
|
126
150
|
}
|
|
127
151
|
|
|
128
152
|
export const Select = component<SelectProps>((props) => {
|
|
129
|
-
|
|
153
|
+
let triggerId = uid("select-trigger");
|
|
130
154
|
const listId = uid("select-list");
|
|
131
|
-
|
|
155
|
+
/** What each value's option is called, latest registration first. */
|
|
156
|
+
const registry = new Map<string, RegisteredItem>();
|
|
157
|
+
/** Moves whenever an option registers, so the chosen label follows. */
|
|
158
|
+
const revision = signal(0);
|
|
159
|
+
/** How many mounted lists hold each value's option. */
|
|
160
|
+
const attached = new Map<string, number>();
|
|
161
|
+
/** Whether a list has been mounted at all — never, on the server. */
|
|
162
|
+
let mountedOnce = false;
|
|
163
|
+
// Untracked read: called while the accessor building an option runs, and
|
|
164
|
+
// reading the counter there would make that accessor re-run on every change.
|
|
165
|
+
const bump = (): void => {
|
|
166
|
+
revision(untrack(() => revision()) + 1);
|
|
167
|
+
};
|
|
168
|
+
/** The open panel, once it has rendered. */
|
|
169
|
+
let panel: HTMLElement | null = null;
|
|
170
|
+
/** Where the list is mounted while closed — outside the document. */
|
|
171
|
+
let closedHost: HTMLElement | null = null;
|
|
132
172
|
/** Per instance, not per module: two selects may offer the same value. */
|
|
133
173
|
const optionIds = new Map<string, string>();
|
|
134
174
|
let content: RegisteredContent | undefined;
|
|
@@ -144,8 +184,26 @@ export const Select = component<SelectProps>((props) => {
|
|
|
144
184
|
/** The option the keyboard is on. Distinct from the selected one. */
|
|
145
185
|
const active = signal<string | undefined>(undefined);
|
|
146
186
|
|
|
187
|
+
/**
|
|
188
|
+
* The options the list holds now, in its order. Read from the mounted list,
|
|
189
|
+
* which is what drops an option a signal removed and places one it added;
|
|
190
|
+
* before anything is mounted (on the server), in registration order.
|
|
191
|
+
*/
|
|
192
|
+
function items(): readonly RegisteredItem[] {
|
|
193
|
+
const root = open() && panel?.isConnected === true ? panel : closedHost;
|
|
194
|
+
if (root === null) return [...registry.values()];
|
|
195
|
+
const out: RegisteredItem[] = [];
|
|
196
|
+
for (const element of root.querySelectorAll<HTMLElement>(
|
|
197
|
+
"[data-slot=select-item]",
|
|
198
|
+
)) {
|
|
199
|
+
const item = registry.get(element.dataset.value ?? "");
|
|
200
|
+
if (item !== undefined && item.id === element.id) out.push(item);
|
|
201
|
+
}
|
|
202
|
+
return out;
|
|
203
|
+
}
|
|
204
|
+
|
|
147
205
|
const enabled = (): readonly RegisteredItem[] =>
|
|
148
|
-
items.filter((item) => !item.disabled);
|
|
206
|
+
items().filter((item) => !item.disabled);
|
|
149
207
|
|
|
150
208
|
function choose(value: string): void {
|
|
151
209
|
selection.set(value);
|
|
@@ -235,7 +293,10 @@ export const Select = component<SelectProps>((props) => {
|
|
|
235
293
|
}
|
|
236
294
|
|
|
237
295
|
provide<SelectApi>(SelectContext, {
|
|
238
|
-
|
|
296
|
+
claimTriggerId(id) {
|
|
297
|
+
if (id !== undefined) triggerId = id;
|
|
298
|
+
return triggerId;
|
|
299
|
+
},
|
|
239
300
|
listId,
|
|
240
301
|
open: () => open(),
|
|
241
302
|
value: () => selection.current(),
|
|
@@ -243,8 +304,15 @@ export const Select = component<SelectProps>((props) => {
|
|
|
243
304
|
disabled: () => readOr(props.disabled, false),
|
|
244
305
|
invalid: () => read(props.invalid) === true,
|
|
245
306
|
required: props.required === true,
|
|
246
|
-
chosenLabel: () =>
|
|
247
|
-
|
|
307
|
+
chosenLabel: () => {
|
|
308
|
+
revision();
|
|
309
|
+
const current = selection.current();
|
|
310
|
+
if (current === undefined) return undefined;
|
|
311
|
+
// An option a signal removed keeps its registration, but not its
|
|
312
|
+
// place in a list: its label must not stay on the trigger.
|
|
313
|
+
if (mountedOnce && !attached.has(current)) return undefined;
|
|
314
|
+
return registry.get(current)?.textValue;
|
|
315
|
+
},
|
|
248
316
|
itemId(value) {
|
|
249
317
|
let id = optionIds.get(value);
|
|
250
318
|
if (id === undefined) {
|
|
@@ -261,7 +329,19 @@ export const Select = component<SelectProps>((props) => {
|
|
|
261
329
|
setActive: (value) => active(value),
|
|
262
330
|
onTriggerKeyDown,
|
|
263
331
|
registerItem(item) {
|
|
264
|
-
|
|
332
|
+
registry.set(item.value, item);
|
|
333
|
+
bump();
|
|
334
|
+
},
|
|
335
|
+
attachItem(value) {
|
|
336
|
+
mountedOnce = true;
|
|
337
|
+
attached.set(value, (attached.get(value) ?? 0) + 1);
|
|
338
|
+
bump();
|
|
339
|
+
return () => {
|
|
340
|
+
const left = (attached.get(value) ?? 1) - 1;
|
|
341
|
+
if (left > 0) attached.set(value, left);
|
|
342
|
+
else attached.delete(value);
|
|
343
|
+
bump();
|
|
344
|
+
};
|
|
265
345
|
},
|
|
266
346
|
registerContent(registered) {
|
|
267
347
|
content = registered;
|
|
@@ -288,7 +368,32 @@ export const Select = component<SelectProps>((props) => {
|
|
|
288
368
|
// Focus never enters the panel — the listbox pattern keeps it on the
|
|
289
369
|
// trigger — so nothing here traps or moves it.
|
|
290
370
|
content: () => renderList(registered, { listId, triggerId }),
|
|
291
|
-
onOpened:
|
|
371
|
+
onOpened: (element) => {
|
|
372
|
+
panel = element;
|
|
373
|
+
scrollActiveIntoView(element);
|
|
374
|
+
},
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
onMount(() => {
|
|
378
|
+
let unmountClosed: (() => void) | null = null;
|
|
379
|
+
const stop = effect(() => {
|
|
380
|
+
if (open()) {
|
|
381
|
+
unmountClosed?.();
|
|
382
|
+
unmountClosed = null;
|
|
383
|
+
closedHost = null;
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (unmountClosed !== null) return;
|
|
387
|
+
const host = document.createElement("div");
|
|
388
|
+
// Untracked: what the options read belongs to their own bindings,
|
|
389
|
+
// not to this effect, which only follows `open`.
|
|
390
|
+
unmountClosed = untrack(() => render(html`${registered.body}`, host));
|
|
391
|
+
closedHost = host;
|
|
392
|
+
});
|
|
393
|
+
return () => {
|
|
394
|
+
stop();
|
|
395
|
+
unmountClosed?.();
|
|
396
|
+
};
|
|
292
397
|
});
|
|
293
398
|
}
|
|
294
399
|
|
|
@@ -301,7 +406,7 @@ export const Select = component<SelectProps>((props) => {
|
|
|
301
406
|
function scrollActiveIntoView(panel: HTMLElement): void {
|
|
302
407
|
const current = active() ?? selection.current();
|
|
303
408
|
if (current === undefined) return;
|
|
304
|
-
const id =
|
|
409
|
+
const id = registry.get(current)?.id;
|
|
305
410
|
if (id === undefined) return;
|
|
306
411
|
panel
|
|
307
412
|
.querySelector(`#${CSS.escape(id)}`)
|
|
@@ -318,9 +423,19 @@ export const Select = component<SelectProps>((props) => {
|
|
|
318
423
|
/></div>`;
|
|
319
424
|
});
|
|
320
425
|
|
|
426
|
+
/**
|
|
427
|
+
* `id`, `label` and `describedBy` as on `Input`: upstream's trigger takes every
|
|
428
|
+
* button prop, and these are the ones that name it — a `FieldLabel` points its
|
|
429
|
+
* `for` at the `id`, and a `<label for>` names a `<button>`. Without them the
|
|
430
|
+
* combobox's only name was the value it showed.
|
|
431
|
+
*/
|
|
321
432
|
export interface SelectTriggerProps {
|
|
322
433
|
children?: Slot;
|
|
323
434
|
size?: "default" | "sm";
|
|
435
|
+
id?: string;
|
|
436
|
+
/** Accessible name (`aria-label`), for a select no `<label>` names. */
|
|
437
|
+
label?: Reactive<string | undefined>;
|
|
438
|
+
describedBy?: Reactive<string | undefined>;
|
|
324
439
|
class?: Reactive<string>;
|
|
325
440
|
}
|
|
326
441
|
|
|
@@ -329,7 +444,9 @@ export const SelectTrigger = component<SelectTriggerProps>((props) => {
|
|
|
329
444
|
return html`<button
|
|
330
445
|
type="button"
|
|
331
446
|
data-slot="select-trigger"
|
|
332
|
-
id="${select.
|
|
447
|
+
id="${select.claimTriggerId(props.id)}"
|
|
448
|
+
aria-label="${accessor(props.label, undefined)}"
|
|
449
|
+
aria-describedby="${accessor(props.describedBy, undefined)}"
|
|
333
450
|
role="combobox"
|
|
334
451
|
aria-haspopup="listbox"
|
|
335
452
|
aria-expanded="${() => (select.open() ? "true" : "false")}"
|
|
@@ -449,6 +566,10 @@ export const SelectItem = component<SelectItemProps>((props) => {
|
|
|
449
566
|
disabled: props.disabled === true,
|
|
450
567
|
});
|
|
451
568
|
|
|
569
|
+
// On each mount, not once: the same option is mounted again every time the
|
|
570
|
+
// list opens or closes, and unmounted when a signal drops it.
|
|
571
|
+
onMount(() => select.attachItem(props.value));
|
|
572
|
+
|
|
452
573
|
const chosen = (): boolean => select.value() === props.value;
|
|
453
574
|
return html`<div
|
|
454
575
|
data-slot="select-item"
|
package/src/organisms/Sheet.ts
CHANGED
|
@@ -51,6 +51,7 @@ interface RegisteredContent {
|
|
|
51
51
|
readonly body: Child;
|
|
52
52
|
readonly side: Side;
|
|
53
53
|
readonly showCloseButton: boolean;
|
|
54
|
+
readonly closeLabel: string;
|
|
54
55
|
readonly class?: Reactive<string>;
|
|
55
56
|
}
|
|
56
57
|
|
|
@@ -197,6 +198,8 @@ export interface SheetContentProps {
|
|
|
197
198
|
/** Which edge it comes from. Default `"right"`. */
|
|
198
199
|
side?: Side;
|
|
199
200
|
showCloseButton?: boolean;
|
|
201
|
+
/** The corner cross's accessible name. Default `"Close"`. */
|
|
202
|
+
closeLabel?: string;
|
|
200
203
|
class?: Reactive<string>;
|
|
201
204
|
}
|
|
202
205
|
|
|
@@ -216,6 +219,7 @@ export const SheetContent = component<SheetContentProps>((props) => {
|
|
|
216
219
|
body,
|
|
217
220
|
side: props.side ?? "right",
|
|
218
221
|
showCloseButton: props.showCloseButton ?? true,
|
|
222
|
+
closeLabel: props.closeLabel ?? "Close",
|
|
219
223
|
class: props.class,
|
|
220
224
|
});
|
|
221
225
|
return html``;
|
|
@@ -289,7 +293,7 @@ function renderSurface(
|
|
|
289
293
|
data-slot="sheet-close"
|
|
290
294
|
class="${closeButtonClasses}"
|
|
291
295
|
@click="${() => ids.close()}"
|
|
292
|
-
>${XIcon({ class: "size-4" })}<span class="sr-only"
|
|
296
|
+
>${XIcon({ class: "size-4" })}<span class="sr-only">${registered.closeLabel}</span></button>`
|
|
293
297
|
: null;
|
|
294
298
|
return html`<div data-slot="sheet-portal" class="${cn("fixed inset-0 z-50", fadeInOut)}">
|
|
295
299
|
<div data-slot="sheet-overlay" class="${dialogBackdropClasses}"></div>
|
package/src/organisms/Sidebar.ts
CHANGED
|
@@ -175,6 +175,8 @@ export interface SidebarProps {
|
|
|
175
175
|
collapsible?: "icon" | "offcanvas" | "none";
|
|
176
176
|
/** Announced as the navigation landmark's name. */
|
|
177
177
|
label?: string;
|
|
178
|
+
/** The close cross of the sheet it turns into on mobile. Default `"Close"`. */
|
|
179
|
+
closeLabel?: string;
|
|
178
180
|
class?: Reactive<string>;
|
|
179
181
|
}
|
|
180
182
|
|
|
@@ -192,6 +194,7 @@ export const Sidebar = component<SidebarProps>((props) => {
|
|
|
192
194
|
children: () =>
|
|
193
195
|
SheetContent({
|
|
194
196
|
side,
|
|
197
|
+
closeLabel: props.closeLabel,
|
|
195
198
|
class: "bg-sidebar text-sidebar-foreground w-[18rem] p-0",
|
|
196
199
|
children: () =>
|
|
197
200
|
html`${SheetHeader({
|
|
@@ -210,7 +213,11 @@ export const Sidebar = component<SidebarProps>((props) => {
|
|
|
210
213
|
data-slot="sidebar"
|
|
211
214
|
data-state="${() => sidebar.state()}"
|
|
212
215
|
data-side="${side}"
|
|
213
|
-
data-collapsible="${
|
|
216
|
+
data-collapsible="${() =>
|
|
217
|
+
// The mode only once collapsed, as upstream: every
|
|
218
|
+
// `group-data-[collapsible=icon]:` class keys off it, and set
|
|
219
|
+
// while expanded it squeezed the full-width bar to icons.
|
|
220
|
+
sidebar.state() === "collapsed" ? collapsible : ""}"
|
|
214
221
|
aria-label="${props.label ?? "Sidebar"}"
|
|
215
222
|
class="${() =>
|
|
216
223
|
cn(
|
|
@@ -234,6 +241,8 @@ export const Sidebar = component<SidebarProps>((props) => {
|
|
|
234
241
|
export interface SidebarTriggerProps {
|
|
235
242
|
/** Overrides the provider's toggle — for a trigger outside the shell. */
|
|
236
243
|
onToggle?: () => void;
|
|
244
|
+
/** The button's accessible name. Default `"Toggle sidebar"`. */
|
|
245
|
+
label?: string;
|
|
237
246
|
class?: Reactive<string>;
|
|
238
247
|
}
|
|
239
248
|
|
|
@@ -241,7 +250,7 @@ export const SidebarTrigger = component<SidebarTriggerProps>((props) =>
|
|
|
241
250
|
Button({
|
|
242
251
|
variant: "ghost",
|
|
243
252
|
size: "icon",
|
|
244
|
-
label: "Toggle sidebar",
|
|
253
|
+
label: props.label ?? "Toggle sidebar",
|
|
245
254
|
class: () => cn("size-7", read(props.class)),
|
|
246
255
|
onClick: () => {
|
|
247
256
|
if (props.onToggle !== undefined) {
|
|
@@ -255,6 +264,8 @@ export const SidebarTrigger = component<SidebarTriggerProps>((props) =>
|
|
|
255
264
|
);
|
|
256
265
|
|
|
257
266
|
export interface SidebarRailProps {
|
|
267
|
+
/** Accessible name and tooltip. Default `"Toggle sidebar"`. */
|
|
268
|
+
label?: string;
|
|
258
269
|
class?: Reactive<string>;
|
|
259
270
|
}
|
|
260
271
|
|
|
@@ -270,9 +281,9 @@ export const SidebarRail = component<SidebarRailProps>(
|
|
|
270
281
|
(props) => html`<button
|
|
271
282
|
type="button"
|
|
272
283
|
data-slot="sidebar-rail"
|
|
273
|
-
aria-label="Toggle sidebar"
|
|
284
|
+
aria-label="${props.label ?? "Toggle sidebar"}"
|
|
274
285
|
tabindex="-1"
|
|
275
|
-
title="Toggle sidebar"
|
|
286
|
+
title="${props.label ?? "Toggle sidebar"}"
|
|
276
287
|
class="${() =>
|
|
277
288
|
cn(
|
|
278
289
|
"hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex",
|