@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
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
|
|
27
|
+
import { html, type TemplateResult } from "@c9up/aurora";
|
|
28
|
+
import type { Child } from "../lib/children.js";
|
|
29
|
+
import { cn } from "../lib/cn.js";
|
|
30
|
+
import { cva, type VariantProps } from "../lib/cva.js";
|
|
31
|
+
import { type Reactive, read } from "../lib/props.js";
|
|
32
|
+
|
|
33
|
+
export const pieceVariants = cva("inline-block shrink-0 rounded-[2px]", {
|
|
34
|
+
variants: {
|
|
35
|
+
size: {
|
|
36
|
+
sm: "size-2",
|
|
37
|
+
default: "size-2.5",
|
|
38
|
+
lg: "size-3",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
defaultVariants: { size: "default" },
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export type PieceVariants = VariantProps<typeof pieceVariants>;
|
|
45
|
+
|
|
46
|
+
export interface Piece<State extends string> {
|
|
47
|
+
state: State;
|
|
48
|
+
/** The square's tooltip: which piece, how big, from where. */
|
|
49
|
+
title?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface PieceMapProps<State extends string> {
|
|
53
|
+
/**
|
|
54
|
+
* The pieces, group after group, or an accessor for pieces that change: the
|
|
55
|
+
* squares are drawn again whenever what it reads changes.
|
|
56
|
+
*/
|
|
57
|
+
groups: Reactive<readonly (readonly Piece<State>[])[]>;
|
|
58
|
+
/** The classes that paint each state: a background, a border, a pulse. */
|
|
59
|
+
tones: Readonly<Record<State, string>>;
|
|
60
|
+
size?: Reactive<PieceVariants["size"]>;
|
|
61
|
+
/** What the map says as a whole. Makes it one image; see above. */
|
|
62
|
+
label?: Reactive<string | undefined>;
|
|
63
|
+
class?: Reactive<string>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function PieceMap<State extends string>(
|
|
67
|
+
props: PieceMapProps<State>,
|
|
68
|
+
): TemplateResult {
|
|
69
|
+
return html`<div
|
|
70
|
+
data-slot="piece-map"
|
|
71
|
+
role="${() => (read(props.label) === undefined ? undefined : "img")}"
|
|
72
|
+
aria-label="${() => read(props.label)}"
|
|
73
|
+
class="${() => cn("flex flex-wrap gap-1", read(props.class))}"
|
|
74
|
+
>
|
|
75
|
+
${() =>
|
|
76
|
+
read(props.groups).map(
|
|
77
|
+
(pieces, index) => html`<span
|
|
78
|
+
data-slot="piece-map-group"
|
|
79
|
+
class="${cn("flex flex-wrap gap-0.5", index > 0 && "border-border border-s ps-1")}"
|
|
80
|
+
>
|
|
81
|
+
${pieces.map(
|
|
82
|
+
(piece) => html`<span
|
|
83
|
+
data-slot="piece"
|
|
84
|
+
data-state="${piece.state}"
|
|
85
|
+
title="${piece.title}"
|
|
86
|
+
class="${cn(pieceVariants({ size: read(props.size) }), props.tones[piece.state])}"
|
|
87
|
+
></span>`,
|
|
88
|
+
)}
|
|
89
|
+
</span>`,
|
|
90
|
+
)}
|
|
91
|
+
</div>`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface PieceMapLegendItem<State extends string> {
|
|
95
|
+
state: State;
|
|
96
|
+
label: Child;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface PieceMapLegendProps<State extends string> {
|
|
100
|
+
/** The same `tones` as the map's. */
|
|
101
|
+
tones: Readonly<Record<State, string>>;
|
|
102
|
+
/** The states to explain, in the order they are read. */
|
|
103
|
+
items: readonly PieceMapLegendItem<State>[];
|
|
104
|
+
/** Said before the keys — the size of the whole, say. */
|
|
105
|
+
children?: Child;
|
|
106
|
+
size?: Reactive<PieceVariants["size"]>;
|
|
107
|
+
class?: Reactive<string>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** What the squares' colours mean. */
|
|
111
|
+
export function PieceMapLegend<State extends string>(
|
|
112
|
+
props: PieceMapLegendProps<State>,
|
|
113
|
+
): TemplateResult {
|
|
114
|
+
// A space after each key: the gap between them is only drawn, and without
|
|
115
|
+
// one their labels run together for a screen reader and a copy.
|
|
116
|
+
return html`<p
|
|
117
|
+
data-slot="piece-map-legend"
|
|
118
|
+
class="${() =>
|
|
119
|
+
cn(
|
|
120
|
+
"text-muted-foreground flex flex-wrap gap-x-4 gap-y-1 text-xs",
|
|
121
|
+
read(props.class),
|
|
122
|
+
)}"
|
|
123
|
+
>
|
|
124
|
+
${props.children}
|
|
125
|
+
${props.items.map(
|
|
126
|
+
(item) => html`<span class="inline-flex items-center gap-1.5"
|
|
127
|
+
><span
|
|
128
|
+
aria-hidden="true"
|
|
129
|
+
data-state="${item.state}"
|
|
130
|
+
class="${() => cn(pieceVariants({ size: read(props.size) }), props.tones[item.state])}"
|
|
131
|
+
></span
|
|
132
|
+
>${item.label}</span
|
|
133
|
+
> `,
|
|
134
|
+
)}
|
|
135
|
+
</p>`;
|
|
136
|
+
}
|
|
@@ -131,6 +131,8 @@ export const ResizablePanel = component<ResizablePanelProps>((props) => {
|
|
|
131
131
|
export interface ResizableHandleProps {
|
|
132
132
|
/** Show the grip dots. */
|
|
133
133
|
withHandle?: boolean;
|
|
134
|
+
/** The separator's accessible name. Default `"Resize panes"`. */
|
|
135
|
+
label?: string;
|
|
134
136
|
class?: Reactive<string>;
|
|
135
137
|
}
|
|
136
138
|
|
|
@@ -205,7 +207,7 @@ export const ResizableHandle = component<ResizableHandleProps>((props) => {
|
|
|
205
207
|
aria-valuemin="${group.min}"
|
|
206
208
|
aria-valuemax="${group.max}"
|
|
207
209
|
aria-valuenow="${() => Math.round(group.size())}"
|
|
208
|
-
aria-label="Resize panes"
|
|
210
|
+
aria-label="${props.label ?? "Resize panes"}"
|
|
209
211
|
class="${() =>
|
|
210
212
|
cn(
|
|
211
213
|
"bg-border relative flex shrink-0 items-center justify-center outline-none",
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toolbar — a row of controls that behaves as one tab stop.
|
|
3
|
+
*
|
|
4
|
+
* Radix ships this as a primitive and shadcn styles no equivalent, which is
|
|
5
|
+
* why it is easy to miss: a page builds a `<div class="flex gap-2">` full of
|
|
6
|
+
* buttons and it looks right. What it is not is navigable. Eleven buttons in a
|
|
7
|
+
* formatting bar are eleven presses of Tab to get past, and a keyboard user
|
|
8
|
+
* reaching the content below pays for every one of them.
|
|
9
|
+
*
|
|
10
|
+
* The WAI-ARIA toolbar pattern says: one tab stop, arrows move inside it. That
|
|
11
|
+
* is `rovingFocus`, which nebula already owns for menus and tab lists — the
|
|
12
|
+
* only thing a toolbar adds is `role="toolbar"`, the orientation, and a
|
|
13
|
+
* separator that is announced as one.
|
|
14
|
+
*
|
|
15
|
+
* The items are whatever the caller puts in — `Button`, `Toggle`, a `Select`
|
|
16
|
+
* trigger, a plain `<a>` — found by the same tabbable selector the focus trap
|
|
17
|
+
* uses. No marker attribute to remember: a control that a keyboard could
|
|
18
|
+
* reach on its own is a control the arrows reach here, and one that could not
|
|
19
|
+
* was never in the tab order to begin with.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { component, html, onMount, onUnmount, uid } from "@c9up/aurora";
|
|
23
|
+
import { Button, type ButtonProps } from "../atoms/Button.js";
|
|
24
|
+
import { Separator } from "../atoms/Separator.js";
|
|
25
|
+
import { type Slot, slot } from "../lib/children.js";
|
|
26
|
+
import { cn } from "../lib/cn.js";
|
|
27
|
+
import { type Reactive, read } from "../lib/props.js";
|
|
28
|
+
import { FOCUSABLE_SELECTOR } from "../primitives/focusable.js";
|
|
29
|
+
import { type RovingFocus, rovingFocus } from "../primitives/rovingFocus.js";
|
|
30
|
+
|
|
31
|
+
export interface ToolbarProps {
|
|
32
|
+
children?: Slot;
|
|
33
|
+
/** Which arrows move focus. Default `"horizontal"`, as a toolbar reads. */
|
|
34
|
+
orientation?: "horizontal" | "vertical";
|
|
35
|
+
/** Wrap from the last control back to the first. Default `true`. */
|
|
36
|
+
loop?: boolean;
|
|
37
|
+
/** Announced name — a page with two toolbars needs to tell them apart. */
|
|
38
|
+
label?: Reactive<string>;
|
|
39
|
+
class?: Reactive<string>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const Toolbar = component<ToolbarProps>((props) => {
|
|
43
|
+
const orientation = props.orientation ?? "horizontal";
|
|
44
|
+
const barId = uid("toolbar");
|
|
45
|
+
let group: RovingFocus | undefined;
|
|
46
|
+
|
|
47
|
+
onMount(() => {
|
|
48
|
+
group = rovingFocus({
|
|
49
|
+
container: () => document.getElementById(barId),
|
|
50
|
+
itemSelector: FOCUSABLE_SELECTOR,
|
|
51
|
+
orientation,
|
|
52
|
+
loop: props.loop !== false,
|
|
53
|
+
});
|
|
54
|
+
// The controls exist by now; without this none of them carries
|
|
55
|
+
// `tabindex="0"` and the bar cannot be reached by Tab at all.
|
|
56
|
+
group.sync();
|
|
57
|
+
});
|
|
58
|
+
onUnmount(() => group?.destroy());
|
|
59
|
+
|
|
60
|
+
return html`<div
|
|
61
|
+
data-slot="toolbar"
|
|
62
|
+
id="${barId}"
|
|
63
|
+
role="toolbar"
|
|
64
|
+
aria-orientation="${orientation}"
|
|
65
|
+
aria-label="${() => read(props.label) ?? ""}"
|
|
66
|
+
class="${() =>
|
|
67
|
+
cn(
|
|
68
|
+
"flex items-center gap-1",
|
|
69
|
+
orientation === "vertical" ? "flex-col" : "flex-row",
|
|
70
|
+
read(props.class),
|
|
71
|
+
)}"
|
|
72
|
+
>${slot(props.children)}</div>`;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export interface ToolbarButtonProps extends ButtonProps {}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* A control inside the bar.
|
|
79
|
+
*
|
|
80
|
+
* `Button` with the defaults a toolbar wants — ghost, small — so a row of them
|
|
81
|
+
* reads as a bar rather than as six primary actions competing for attention.
|
|
82
|
+
* Nothing else: a plain `Button` dropped in the bar navigates identically,
|
|
83
|
+
* which is the point of finding items by focusability.
|
|
84
|
+
*/
|
|
85
|
+
export const ToolbarButton = component<ToolbarButtonProps>((props) =>
|
|
86
|
+
Button({ variant: "ghost", size: "sm", ...props }),
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
export interface ToolbarSeparatorProps {
|
|
90
|
+
class?: Reactive<string>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** A boundary between groups of controls, announced as one. */
|
|
94
|
+
export const ToolbarSeparator = component<ToolbarSeparatorProps>((props) => {
|
|
95
|
+
return Separator({
|
|
96
|
+
orientation: "vertical",
|
|
97
|
+
decorative: false,
|
|
98
|
+
class: () => cn("mx-1 h-6 self-center", read(props.class)),
|
|
99
|
+
});
|
|
100
|
+
});
|
package/src/molecules/index.ts
CHANGED
|
@@ -8,11 +8,12 @@
|
|
|
8
8
|
* organisms.
|
|
9
9
|
*
|
|
10
10
|
* Compound components are data-driven — `Accordion({ items: [...] })`, not
|
|
11
|
-
* `<Accordion><AccordionItem>`.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* `<Accordion><AccordionItem>`. Not for want of context: Aurora has it and these
|
|
12
|
+
* components use it. It lives on a stack during SETUP, so a part passed as a
|
|
13
|
+
* `Slot` thunk is built after that frame has popped and has nothing to read —
|
|
14
|
+
* which is exactly the shape `<Accordion><AccordionItem>` would need. Data keeps
|
|
15
|
+
* every part built while the context is there. The rendered markup is unchanged,
|
|
16
|
+
* so shadcn's CSS and its examples still read across.
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
19
|
export {
|
|
@@ -41,10 +42,12 @@ export {
|
|
|
41
42
|
export {
|
|
42
43
|
Breadcrumb,
|
|
43
44
|
BreadcrumbEllipsis,
|
|
45
|
+
type BreadcrumbEllipsisProps,
|
|
44
46
|
BreadcrumbItem,
|
|
45
47
|
BreadcrumbLink,
|
|
46
48
|
type BreadcrumbLinkProps,
|
|
47
49
|
BreadcrumbList,
|
|
50
|
+
type BreadcrumbNavProps,
|
|
48
51
|
BreadcrumbPage,
|
|
49
52
|
type BreadcrumbProps,
|
|
50
53
|
BreadcrumbSeparator,
|
|
@@ -152,8 +155,10 @@ export {
|
|
|
152
155
|
PaginationEllipsis,
|
|
153
156
|
type PaginationEllipsisProps,
|
|
154
157
|
PaginationItem,
|
|
158
|
+
type PaginationLabels,
|
|
155
159
|
PaginationLink,
|
|
156
160
|
type PaginationLinkProps,
|
|
161
|
+
type PaginationNavProps,
|
|
157
162
|
PaginationNext,
|
|
158
163
|
PaginationPrevious,
|
|
159
164
|
type PaginationProps,
|
|
@@ -161,6 +166,16 @@ export {
|
|
|
161
166
|
pageWindow,
|
|
162
167
|
} from "./Pagination.js";
|
|
163
168
|
export { Picture, type PictureProps } from "./Picture.js";
|
|
169
|
+
export {
|
|
170
|
+
type Piece,
|
|
171
|
+
PieceMap,
|
|
172
|
+
PieceMapLegend,
|
|
173
|
+
type PieceMapLegendItem,
|
|
174
|
+
type PieceMapLegendProps,
|
|
175
|
+
type PieceMapProps,
|
|
176
|
+
type PieceVariants,
|
|
177
|
+
pieceVariants,
|
|
178
|
+
} from "./PieceMap.js";
|
|
164
179
|
export {
|
|
165
180
|
RadioGroup,
|
|
166
181
|
RadioGroupItem,
|
|
@@ -206,6 +221,14 @@ export {
|
|
|
206
221
|
type ToggleGroupItemProps,
|
|
207
222
|
type ToggleGroupProps,
|
|
208
223
|
} from "./ToggleGroup.js";
|
|
224
|
+
export {
|
|
225
|
+
Toolbar,
|
|
226
|
+
ToolbarButton,
|
|
227
|
+
type ToolbarButtonProps,
|
|
228
|
+
type ToolbarProps,
|
|
229
|
+
ToolbarSeparator,
|
|
230
|
+
type ToolbarSeparatorProps,
|
|
231
|
+
} from "./Toolbar.js";
|
|
209
232
|
export {
|
|
210
233
|
Blockquote,
|
|
211
234
|
H1,
|
|
@@ -37,6 +37,19 @@ export interface DateRange {
|
|
|
37
37
|
readonly to?: Date;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* The words the calendar writes itself — react-day-picker's `labels`.
|
|
42
|
+
*
|
|
43
|
+
* Month and weekday names come from `Intl` in `locale`; these two do not, and
|
|
44
|
+
* a screen reader would read them in English in the middle of a French page.
|
|
45
|
+
*/
|
|
46
|
+
export interface CalendarLabels {
|
|
47
|
+
/** The previous-month arrow. Default `"Previous month"`. */
|
|
48
|
+
previousMonth: string;
|
|
49
|
+
/** The next-month arrow. Default `"Next month"`. */
|
|
50
|
+
nextMonth: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
40
53
|
export interface CalendarProps {
|
|
41
54
|
/**
|
|
42
55
|
* `"range"` picks a span in two clicks. Default `"single"`.
|
|
@@ -63,6 +76,7 @@ export interface CalendarProps {
|
|
|
63
76
|
/** `0` Sunday, `1` Monday. Defaults to the locale's own first day. */
|
|
64
77
|
weekStartsOn?: number;
|
|
65
78
|
locale?: string;
|
|
79
|
+
labels?: Partial<CalendarLabels>;
|
|
66
80
|
class?: Reactive<string>;
|
|
67
81
|
/** `"single"` mode. */
|
|
68
82
|
onValueChange?: (date: Date) => void;
|
|
@@ -374,7 +388,7 @@ export const Calendar = component<CalendarProps>((props) => {
|
|
|
374
388
|
<div class="flex items-center justify-between pb-4">
|
|
375
389
|
<button
|
|
376
390
|
type="button"
|
|
377
|
-
aria-label="Previous month"
|
|
391
|
+
aria-label="${props.labels?.previousMonth ?? "Previous month"}"
|
|
378
392
|
class="${buttonVariants({ variant: "outline", size: "icon", class: "size-7" })}"
|
|
379
393
|
@click="${() => month(addMonths(month(), -1))}"
|
|
380
394
|
>${ChevronLeftIcon({ class: "size-4" })}</button>
|
|
@@ -383,7 +397,7 @@ export const Calendar = component<CalendarProps>((props) => {
|
|
|
383
397
|
</div>
|
|
384
398
|
<button
|
|
385
399
|
type="button"
|
|
386
|
-
aria-label="Next month"
|
|
400
|
+
aria-label="${props.labels?.nextMonth ?? "Next month"}"
|
|
387
401
|
class="${buttonVariants({ variant: "outline", size: "icon", class: "size-7" })}"
|
|
388
402
|
@click="${() => month(addMonths(month(), 1))}"
|
|
389
403
|
>${ChevronRightIcon({ class: "size-4" })}</button>
|
|
@@ -52,6 +52,8 @@ const CarouselContext = createContext<CarouselApi>("Carousel");
|
|
|
52
52
|
export interface CarouselProps {
|
|
53
53
|
/** Announced before the slides. */
|
|
54
54
|
label?: string;
|
|
55
|
+
/** What a screen reader calls the region. Default `"carousel"`. */
|
|
56
|
+
roleDescription?: string;
|
|
55
57
|
orientation?: "horizontal" | "vertical";
|
|
56
58
|
class?: Reactive<string>;
|
|
57
59
|
children?: Parts;
|
|
@@ -138,7 +140,7 @@ export const Carousel = component<CarouselProps>((props) => {
|
|
|
138
140
|
return html`<div
|
|
139
141
|
data-slot="carousel"
|
|
140
142
|
role="region"
|
|
141
|
-
aria-roledescription="carousel"
|
|
143
|
+
aria-roledescription="${props.roleDescription ?? "carousel"}"
|
|
142
144
|
aria-label="${props.label ?? "Carousel"}"
|
|
143
145
|
class="${() => cn("relative", read(props.class))}"
|
|
144
146
|
@keydown="${onKeyDown}"
|
|
@@ -168,6 +170,10 @@ export const CarouselContent = component<CarouselContentProps>((props) => {
|
|
|
168
170
|
|
|
169
171
|
export interface CarouselItemProps {
|
|
170
172
|
children?: Slot;
|
|
173
|
+
/** What a screen reader calls one slide. Default `"slide"`. */
|
|
174
|
+
roleDescription?: string;
|
|
175
|
+
/** The slide's name from its position. Default `"3 of 7"`. */
|
|
176
|
+
label?: (position: number, count: number) => string;
|
|
171
177
|
class?: Reactive<string>;
|
|
172
178
|
}
|
|
173
179
|
|
|
@@ -184,14 +190,20 @@ export const CarouselItem = component<CarouselItemProps>((props) => {
|
|
|
184
190
|
return html`<div
|
|
185
191
|
data-slot="carousel-item"
|
|
186
192
|
role="group"
|
|
187
|
-
aria-roledescription="slide"
|
|
188
|
-
aria-label="${() =>
|
|
193
|
+
aria-roledescription="${props.roleDescription ?? "slide"}"
|
|
194
|
+
aria-label="${() => (props.label ?? slideOf)(position, carousel.slideCount())}"
|
|
189
195
|
class="${() =>
|
|
190
196
|
cn("min-w-0 shrink-0 grow-0 basis-full snap-start", read(props.class))}"
|
|
191
197
|
>${slot(props.children)}</div>`;
|
|
192
198
|
});
|
|
193
199
|
|
|
200
|
+
function slideOf(position: number, count: number): string {
|
|
201
|
+
return `${position} of ${count}`;
|
|
202
|
+
}
|
|
203
|
+
|
|
194
204
|
export interface CarouselButtonProps {
|
|
205
|
+
/** The arrow's accessible name. Default `"Previous slide"` / `"Next slide"`. */
|
|
206
|
+
label?: string;
|
|
195
207
|
class?: Reactive<string>;
|
|
196
208
|
}
|
|
197
209
|
|
|
@@ -202,7 +214,7 @@ export const CarouselPrevious = component<CarouselButtonProps>((props) => {
|
|
|
202
214
|
return html`<button
|
|
203
215
|
type="button"
|
|
204
216
|
data-slot="carousel-previous"
|
|
205
|
-
aria-label="Previous slide"
|
|
217
|
+
aria-label="${props.label ?? "Previous slide"}"
|
|
206
218
|
?disabled="${() => carousel.atStart()}"
|
|
207
219
|
class="${() =>
|
|
208
220
|
cn(
|
|
@@ -222,7 +234,7 @@ export const CarouselNext = component<CarouselButtonProps>((props) => {
|
|
|
222
234
|
return html`<button
|
|
223
235
|
type="button"
|
|
224
236
|
data-slot="carousel-next"
|
|
225
|
-
aria-label="Next slide"
|
|
237
|
+
aria-label="${props.label ?? "Next slide"}"
|
|
226
238
|
?disabled="${() => carousel.atEnd()}"
|
|
227
239
|
class="${() =>
|
|
228
240
|
cn(
|