@c9up/nebula 0.2.2 → 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 +2 -2
- 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/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/index.d.ts +3 -2
- package/dist/molecules/index.js +1 -0
- 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 +2 -0
- package/dist/organisms/Toaster.js +6 -4
- package/dist/organisms/index.d.ts +2 -2
- package/dist/organisms/index.js +1 -1
- package/dist/primitives/floating.js +24 -1
- 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 +13 -0
- package/src/atoms/Checkbox.ts +1 -1
- package/src/atoms/Input.ts +6 -0
- 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/index.ts +14 -0
- 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 +8 -4
- package/src/organisms/index.ts +7 -1
- package/src/primitives/floating.ts +27 -1
- package/src/templates/SettingsLayout.ts +3 -1
package/README.md
CHANGED
|
@@ -194,11 +194,11 @@ resources/pages/
|
|
|
194
194
|
The rule is composition, not complexity. Slider is an atom though it is interactive, because it is one input. Card is a molecule though it is trivial, because it assembles parts.
|
|
195
195
|
|
|
196
196
|
<details>
|
|
197
|
-
<summary><strong>All
|
|
197
|
+
<summary><strong>All 75 components</strong></summary>
|
|
198
198
|
|
|
199
199
|
**atoms (22)** — AccessibleIcon, AspectRatio, Avatar, Badge, Button, Checkbox, Image, Input, Kbd, Label, Marker, NativeSelect, Progress, ScrollArea, Separator, Skeleton, Slider, Spinner, Switch, Textarea, Toggle, VisuallyHidden
|
|
200
200
|
|
|
201
|
-
**molecules (
|
|
201
|
+
**molecules (24)** — Accordion, Alert, Attachment, Breadcrumb, Bubble, ButtonGroup, Card, Collapsible, Empty, Field, InputGroup, InputOTP, Item, Message, Pagination, Picture, PieceMap, RadioGroup, Resizable, Table, Tabs, ToggleGroup, Toolbar, Typography
|
|
202
202
|
|
|
203
203
|
**organisms (26)** — AlertDialog, Calendar, Carousel, Chart, Combobox, Command, CommandDialog, ContextMenu, DataTable, DatePicker, DateRangePicker, Dialog, Drawer, DropdownMenu, Form, HoverCard, Menubar, MessageScroller, NavigationMenu, Popover, Questionnaire, Select, Sheet, Sidebar, Toaster, Tooltip
|
|
204
204
|
|
package/dist/atoms/Checkbox.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* it exists only in the DOM.
|
|
17
17
|
*/
|
|
18
18
|
import { type Reactive } from "../lib/props.js";
|
|
19
|
-
export declare const checkboxClasses = "peer size-4 shrink-0 appearance-none rounded-[4px] border border-input bg-transparent shadow-xs outline-none transition-shadow dark:bg-input/30 checked:border-primary checked:bg-primary indeterminate:border-primary indeterminate:bg-primary focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20";
|
|
19
|
+
export declare const checkboxClasses = "peer size-4 shrink-0 appearance-none rounded-[4px] border border-input bg-transparent shadow-xs outline-none transition-shadow dark:bg-input/30 checked:border-primary checked:bg-primary indeterminate:border-primary indeterminate:bg-primary focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 dark:checked:bg-primary dark:indeterminate:bg-primary";
|
|
20
20
|
export interface CheckboxProps {
|
|
21
21
|
id?: string;
|
|
22
22
|
name?: string;
|
package/dist/atoms/Checkbox.js
CHANGED
|
@@ -19,7 +19,7 @@ import { component, html } from "@c9up/aurora";
|
|
|
19
19
|
import { cn } from "../lib/cn.js";
|
|
20
20
|
import { CheckIcon, MinusIcon } from "../lib/icons.js";
|
|
21
21
|
import { accessor, read } from "../lib/props.js";
|
|
22
|
-
export const checkboxClasses = "peer size-4 shrink-0 appearance-none rounded-[4px] border border-input bg-transparent shadow-xs outline-none transition-shadow dark:bg-input/30 checked:border-primary checked:bg-primary indeterminate:border-primary indeterminate:bg-primary focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20";
|
|
22
|
+
export const checkboxClasses = "peer size-4 shrink-0 appearance-none rounded-[4px] border border-input bg-transparent shadow-xs outline-none transition-shadow dark:bg-input/30 checked:border-primary checked:bg-primary indeterminate:border-primary indeterminate:bg-primary focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 dark:checked:bg-primary dark:indeterminate:bg-primary";
|
|
23
23
|
function inputChecked(event) {
|
|
24
24
|
const target = event.target;
|
|
25
25
|
return target instanceof HTMLInputElement ? target.checked : false;
|
package/dist/atoms/Input.d.ts
CHANGED
|
@@ -27,6 +27,11 @@ export interface InputProps {
|
|
|
27
27
|
invalid?: Reactive<boolean>;
|
|
28
28
|
/** Names the element describing the error, for screen readers. */
|
|
29
29
|
describedBy?: Reactive<string | undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* The field's accessible name (`aria-label`), for a field no `<label>`
|
|
32
|
+
* names. A placeholder is not one: it disappears as soon as the user types.
|
|
33
|
+
*/
|
|
34
|
+
label?: Reactive<string | undefined>;
|
|
30
35
|
class?: Reactive<string>;
|
|
31
36
|
onInput?: (value: string, event: Event) => void;
|
|
32
37
|
onChange?: (value: string, event: Event) => void;
|
package/dist/atoms/Input.js
CHANGED
|
@@ -37,6 +37,7 @@ export const Input = component((props) => {
|
|
|
37
37
|
autocomplete="${props.autocomplete}"
|
|
38
38
|
aria-invalid="${() => (read(props.invalid) === true ? "true" : undefined)}"
|
|
39
39
|
aria-describedby="${accessor(props.describedBy, undefined)}"
|
|
40
|
+
aria-label="${accessor(props.label, undefined)}"
|
|
40
41
|
?disabled="${accessor(props.disabled, false)}"
|
|
41
42
|
?readonly="${accessor(props.readonly, false)}"
|
|
42
43
|
?required="${accessor(props.required, false)}"
|
package/dist/lib/children.d.ts
CHANGED
|
@@ -12,9 +12,11 @@
|
|
|
12
12
|
* — Aurora never re-renders a component, so a plain value read at setup is
|
|
13
13
|
* frozen for the lifetime of the node.
|
|
14
14
|
*/
|
|
15
|
-
import type
|
|
15
|
+
import { type Each, type TemplateResult } from "@c9up/aurora";
|
|
16
16
|
import type { Reactive } from "./props.js";
|
|
17
|
-
export type Child = TemplateResult
|
|
17
|
+
export type Child = TemplateResult
|
|
18
|
+
/** A keyed list from aurora's `each`, which keeps its rows by key. */
|
|
19
|
+
| Each | Node | string | number | boolean | null | undefined | readonly Child[];
|
|
18
20
|
/** Content that may be constant or recomputed. */
|
|
19
21
|
export type Slot = Reactive<Child>;
|
|
20
22
|
/**
|
|
@@ -32,13 +34,16 @@ export type Slot = Reactive<Child>;
|
|
|
32
34
|
* `Parts` names it so the type makes the requirement, rather than a blank
|
|
33
35
|
* surface at runtime.
|
|
34
36
|
*
|
|
35
|
-
* Called ONCE, during setup
|
|
36
|
-
*
|
|
37
|
+
* Called ONCE, during setup. What changes goes in an accessor inside it, and
|
|
38
|
+
* parts built there still reach their provider — Aurora calls the accessor
|
|
39
|
+
* with the providers it was written under — so a list of options can follow a
|
|
40
|
+
* signal:
|
|
37
41
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* there is
|
|
42
|
+
* SelectContent({ children: () => html`${() => roles().map((r) => SelectItem(…))}` })
|
|
43
|
+
*
|
|
44
|
+
* A part that has to be KNOWN at setup is the exception. `DialogTitle` names
|
|
45
|
+
* the panel, and the panel reads whether there is a title before it renders
|
|
46
|
+
* its children, so a title built later in an accessor leaves it unnamed:
|
|
42
47
|
*
|
|
43
48
|
* DialogHeader({ children: html`${DialogTitle(…)}` }) // ✓ a value
|
|
44
49
|
* DialogHeader({ children: () => html`${DialogTitle(…)}` }) // ✗ too late
|
package/dist/lib/children.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* — Aurora never re-renders a component, so a plain value read at setup is
|
|
13
13
|
* frozen for the lifetime of the node.
|
|
14
14
|
*/
|
|
15
|
+
import { isEach } from "@c9up/aurora";
|
|
15
16
|
/**
|
|
16
17
|
* Bind content into a template so it stays live.
|
|
17
18
|
*
|
|
@@ -23,5 +24,9 @@
|
|
|
23
24
|
export function slot(content) {
|
|
24
25
|
if (content === undefined)
|
|
25
26
|
return () => null;
|
|
27
|
+
// A keyed list is a function too, but it is content, not an accessor for
|
|
28
|
+
// content: handed over as the value, it keeps its rows by key.
|
|
29
|
+
if (isEach(content))
|
|
30
|
+
return () => content;
|
|
26
31
|
return typeof content === "function" ? content : () => content;
|
|
27
32
|
}
|
|
@@ -26,7 +26,11 @@ export interface BreadcrumbProps {
|
|
|
26
26
|
children?: Slot;
|
|
27
27
|
class?: Reactive<string>;
|
|
28
28
|
}
|
|
29
|
-
export
|
|
29
|
+
export interface BreadcrumbNavProps extends BreadcrumbProps {
|
|
30
|
+
/** The `<nav>`'s accessible name. Default `"breadcrumb"`. */
|
|
31
|
+
"aria-label"?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare const Breadcrumb: (props?: BreadcrumbNavProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
30
34
|
export declare const BreadcrumbList: (props?: BreadcrumbProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
31
35
|
export declare const BreadcrumbItem: (props?: BreadcrumbProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
32
36
|
export interface BreadcrumbLinkProps extends BreadcrumbProps {
|
|
@@ -43,5 +47,10 @@ export declare const BreadcrumbLink: (props?: BreadcrumbLinkProps | undefined) =
|
|
|
43
47
|
export declare const BreadcrumbPage: (props?: BreadcrumbProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
44
48
|
/** The chevron. Defaults to one; give children to replace it. */
|
|
45
49
|
export declare const BreadcrumbSeparator: (props?: BreadcrumbProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
50
|
+
export interface BreadcrumbEllipsisProps {
|
|
51
|
+
/** The hidden text. Default `"More"`. */
|
|
52
|
+
label?: string;
|
|
53
|
+
class?: Reactive<string>;
|
|
54
|
+
}
|
|
46
55
|
/** Stands in for ancestors that did not fit. */
|
|
47
|
-
export declare const BreadcrumbEllipsis: (props?:
|
|
56
|
+
export declare const BreadcrumbEllipsis: (props?: BreadcrumbEllipsisProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
@@ -27,7 +27,7 @@ import { ChevronRightIcon, MoreHorizontalIcon } from "../lib/icons.js";
|
|
|
27
27
|
import { read } from "../lib/props.js";
|
|
28
28
|
export const Breadcrumb = component((props) => html `<nav
|
|
29
29
|
data-slot="breadcrumb"
|
|
30
|
-
aria-label="breadcrumb"
|
|
30
|
+
aria-label="${props["aria-label"] ?? "breadcrumb"}"
|
|
31
31
|
class="${() => cn(read(props.class))}"
|
|
32
32
|
>${slot(props.children)}</nav>`);
|
|
33
33
|
export const BreadcrumbList = component((props) => html `<ol
|
|
@@ -70,4 +70,4 @@ export const BreadcrumbEllipsis = component((props) => html `<span
|
|
|
70
70
|
role="presentation"
|
|
71
71
|
aria-hidden="true"
|
|
72
72
|
class="${() => cn("flex size-9 items-center justify-center", read(props.class))}"
|
|
73
|
-
>${MoreHorizontalIcon({ class: "size-4" })}<span class="sr-only"
|
|
73
|
+
>${MoreHorizontalIcon({ class: "size-4" })}<span class="sr-only">${props.label ?? "More"}</span></span>`);
|
|
@@ -22,6 +22,8 @@ import { type Reactive } from "../lib/props.js";
|
|
|
22
22
|
export interface InputOTPProps {
|
|
23
23
|
/** Number of boxes. Default `6` — and it must match the slots built. */
|
|
24
24
|
length?: number;
|
|
25
|
+
/** Each box's accessible name from its position. Default `"Character 2 of 6"`. */
|
|
26
|
+
slotLabel?: (position: number, length: number) => string;
|
|
25
27
|
name?: string;
|
|
26
28
|
disabled?: Reactive<boolean>;
|
|
27
29
|
class?: Reactive<string>;
|
|
@@ -61,6 +61,8 @@ export const InputOTP = component((props) => {
|
|
|
61
61
|
provide(InputOTPContext, {
|
|
62
62
|
length,
|
|
63
63
|
disabled: () => readOr(props.disabled, false),
|
|
64
|
+
slotLabel: props.slotLabel ??
|
|
65
|
+
((position, total) => `Character ${position} of ${total}`),
|
|
64
66
|
claimSlot() {
|
|
65
67
|
const index = claimed;
|
|
66
68
|
claimed += 1;
|
|
@@ -156,7 +158,7 @@ export const InputOTPSlot = component((props) => {
|
|
|
156
158
|
inputmode="numeric"
|
|
157
159
|
autocomplete="${index === 0 ? "one-time-code" : "off"}"
|
|
158
160
|
maxlength="1"
|
|
159
|
-
aria-label="${
|
|
161
|
+
aria-label="${otp.slotLabel(index + 1, otp.length)}"
|
|
160
162
|
?disabled="${() => otp.disabled()}"
|
|
161
163
|
class="${() => cn(slotClasses, read(props.class))}"
|
|
162
164
|
@input="${(event) => otp.onInput(index, event)}"
|
|
@@ -32,7 +32,31 @@ export interface PaginationProps {
|
|
|
32
32
|
children?: Slot;
|
|
33
33
|
class?: Reactive<string>;
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Every text the pagination writes, in one place.
|
|
37
|
+
*
|
|
38
|
+
* The defaults are upstream's English. An app in another language passes its
|
|
39
|
+
* own: most of these are read only by a screen reader, which would otherwise
|
|
40
|
+
* switch to English in the middle of the page.
|
|
41
|
+
*/
|
|
42
|
+
export interface PaginationLabels {
|
|
43
|
+
/** The `<nav>`'s accessible name. */
|
|
44
|
+
navigation: string;
|
|
45
|
+
/** The visible word beside the previous arrow. */
|
|
46
|
+
previous: string;
|
|
47
|
+
/** The previous link's accessible name. */
|
|
48
|
+
previousPage: string;
|
|
49
|
+
next: string;
|
|
50
|
+
nextPage: string;
|
|
51
|
+
/** The ellipsis's hidden text. */
|
|
52
|
+
morePages: string;
|
|
53
|
+
}
|
|
54
|
+
/** Frozen: the defaults, not a place to set an app's language from. */
|
|
55
|
+
export declare const paginationLabels: Readonly<PaginationLabels>;
|
|
56
|
+
export interface PaginationNavProps extends PaginationProps {
|
|
57
|
+
"aria-label"?: string;
|
|
58
|
+
}
|
|
59
|
+
export declare const Pagination: (props?: PaginationNavProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
36
60
|
export declare const PaginationContent: (props?: PaginationProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
37
61
|
export declare const PaginationItem: (props?: PaginationProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
38
62
|
export interface PaginationLinkProps {
|
|
@@ -56,10 +80,18 @@ export interface PaginationLinkProps {
|
|
|
56
80
|
* work with JavaScript off.
|
|
57
81
|
*/
|
|
58
82
|
export declare const PaginationLink: (props?: PaginationLinkProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
59
|
-
|
|
83
|
+
/**
|
|
84
|
+
* `aria-label` replaces the accessible name, as upstream's prop spread lets it.
|
|
85
|
+
* `children` replaces the visible word and keeps the arrow — upstream writes
|
|
86
|
+
* that word in the file, which an app owning its copy can edit and a package
|
|
87
|
+
* cannot.
|
|
88
|
+
*/
|
|
89
|
+
export type PaginationStepProps = Omit<PaginationLinkProps, "size" | "isActive">;
|
|
60
90
|
export declare const PaginationPrevious: (props?: PaginationStepProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
61
91
|
export declare const PaginationNext: (props?: PaginationStepProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
62
92
|
export interface PaginationEllipsisProps {
|
|
93
|
+
/** The hidden text. Default `"More pages"`. */
|
|
94
|
+
label?: string;
|
|
63
95
|
class?: Reactive<string>;
|
|
64
96
|
}
|
|
65
97
|
/** Stands in for the pages that did not fit — see `pageWindow`. */
|
|
@@ -58,10 +58,19 @@ function range(from, to) {
|
|
|
58
58
|
out.push(value);
|
|
59
59
|
return out;
|
|
60
60
|
}
|
|
61
|
+
/** Frozen: the defaults, not a place to set an app's language from. */
|
|
62
|
+
export const paginationLabels = Object.freeze({
|
|
63
|
+
navigation: "pagination",
|
|
64
|
+
previous: "Previous",
|
|
65
|
+
previousPage: "Go to previous page",
|
|
66
|
+
next: "Next",
|
|
67
|
+
nextPage: "Go to next page",
|
|
68
|
+
morePages: "More pages",
|
|
69
|
+
});
|
|
61
70
|
export const Pagination = component((props) => html `<nav
|
|
62
71
|
data-slot="pagination"
|
|
63
72
|
role="navigation"
|
|
64
|
-
aria-label="
|
|
73
|
+
aria-label="${props["aria-label"] ?? paginationLabels.navigation}"
|
|
65
74
|
class="${() => cn("mx-auto flex w-full justify-center", read(props.class))}"
|
|
66
75
|
>${slot(props.children)}</nav>`);
|
|
67
76
|
export const PaginationContent = component((props) => html `<ul
|
|
@@ -109,20 +118,20 @@ export const PaginationLink = component((props) => {
|
|
|
109
118
|
export const PaginationPrevious = component((props) => PaginationLink({
|
|
110
119
|
...props,
|
|
111
120
|
size: "default",
|
|
112
|
-
"aria-label": "
|
|
121
|
+
"aria-label": props["aria-label"] ?? paginationLabels.previousPage,
|
|
113
122
|
class: () => cn("gap-1 px-2.5 sm:pl-2.5", read(props.class)),
|
|
114
|
-
children: html `${ChevronLeftIcon({})}<span class="hidden sm:block"
|
|
123
|
+
children: html `${ChevronLeftIcon({})}<span class="hidden sm:block">${slot(props.children ?? paginationLabels.previous)}</span>`,
|
|
115
124
|
}));
|
|
116
125
|
export const PaginationNext = component((props) => PaginationLink({
|
|
117
126
|
...props,
|
|
118
127
|
size: "default",
|
|
119
|
-
"aria-label": "
|
|
128
|
+
"aria-label": props["aria-label"] ?? paginationLabels.nextPage,
|
|
120
129
|
class: () => cn("gap-1 px-2.5 sm:pr-2.5", read(props.class)),
|
|
121
|
-
children: html `<span class="hidden sm:block"
|
|
130
|
+
children: html `<span class="hidden sm:block">${slot(props.children ?? paginationLabels.next)}</span>${ChevronRightIcon({})}`,
|
|
122
131
|
}));
|
|
123
132
|
/** Stands in for the pages that did not fit — see `pageWindow`. */
|
|
124
133
|
export const PaginationEllipsis = component((props) => html `<span
|
|
125
134
|
data-slot="pagination-ellipsis"
|
|
126
135
|
aria-hidden="true"
|
|
127
136
|
class="${() => cn("flex size-9 items-center justify-center", read(props.class))}"
|
|
128
|
-
>${MoreHorizontalIcon({ class: "size-4" })}<span class="sr-only"
|
|
137
|
+
>${MoreHorizontalIcon({ class: "size-4" })}<span class="sr-only">${props.label ?? paginationLabels.morePages}</span></span>`);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PieceMap — a transfer drawn as one small square per piece.
|
|
3
|
+
*
|
|
4
|
+
* What a torrent client shows under a download: each square is a piece of the
|
|
5
|
+
* whole, coloured by where it stands — here, missing, on its way, taken from a
|
|
6
|
+
* peer. A progress bar says how much; the map says *which*, and that is what
|
|
7
|
+
* a stalled run, a missing layer or a peer serving one half shows at a glance.
|
|
8
|
+
*
|
|
9
|
+
* The states are the caller's, not a fixed set. A download, a replication and
|
|
10
|
+
* a backup do not have the same ones, so the component takes a string type of
|
|
11
|
+
* its own and a class per state — `tones` — and paints nothing it was not
|
|
12
|
+
* told about. The legend reads the same `tones`, so a square and its key can
|
|
13
|
+
* never drift apart.
|
|
14
|
+
*
|
|
15
|
+
* Pieces come in groups: each group after the first is set off by a rule — a
|
|
16
|
+
* torrent's files, an image's layers. A flat map is one group.
|
|
17
|
+
*
|
|
18
|
+
* A generic function rather than `component<P>`, as DataTable: `State` has to
|
|
19
|
+
* stay open so `tones` is checked against the caller's own states.
|
|
20
|
+
*
|
|
21
|
+
* With a `label`, the map is one image to assistive technology and the label
|
|
22
|
+
* is what it says ("12 of 40 pieces"): a screen reader walking hundreds of
|
|
23
|
+
* squares one by one learns nothing the sentence does not. Each square keeps
|
|
24
|
+
* its `title` for the pointer.
|
|
25
|
+
*/
|
|
26
|
+
import { type TemplateResult } from "@c9up/aurora";
|
|
27
|
+
import type { Child } from "../lib/children.js";
|
|
28
|
+
import { type VariantProps } from "../lib/cva.js";
|
|
29
|
+
import { type Reactive } from "../lib/props.js";
|
|
30
|
+
export declare const pieceVariants: (props?: (import("../index.js").VariantSelection<{
|
|
31
|
+
size: {
|
|
32
|
+
sm: string;
|
|
33
|
+
default: string;
|
|
34
|
+
lg: string;
|
|
35
|
+
};
|
|
36
|
+
}> & import("../index.js").ClassOverrides) | undefined) => string;
|
|
37
|
+
export type PieceVariants = VariantProps<typeof pieceVariants>;
|
|
38
|
+
export interface Piece<State extends string> {
|
|
39
|
+
state: State;
|
|
40
|
+
/** The square's tooltip: which piece, how big, from where. */
|
|
41
|
+
title?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface PieceMapProps<State extends string> {
|
|
44
|
+
/**
|
|
45
|
+
* The pieces, group after group, or an accessor for pieces that change: the
|
|
46
|
+
* squares are drawn again whenever what it reads changes.
|
|
47
|
+
*/
|
|
48
|
+
groups: Reactive<readonly (readonly Piece<State>[])[]>;
|
|
49
|
+
/** The classes that paint each state: a background, a border, a pulse. */
|
|
50
|
+
tones: Readonly<Record<State, string>>;
|
|
51
|
+
size?: Reactive<PieceVariants["size"]>;
|
|
52
|
+
/** What the map says as a whole. Makes it one image; see above. */
|
|
53
|
+
label?: Reactive<string | undefined>;
|
|
54
|
+
class?: Reactive<string>;
|
|
55
|
+
}
|
|
56
|
+
export declare function PieceMap<State extends string>(props: PieceMapProps<State>): TemplateResult;
|
|
57
|
+
export interface PieceMapLegendItem<State extends string> {
|
|
58
|
+
state: State;
|
|
59
|
+
label: Child;
|
|
60
|
+
}
|
|
61
|
+
export interface PieceMapLegendProps<State extends string> {
|
|
62
|
+
/** The same `tones` as the map's. */
|
|
63
|
+
tones: Readonly<Record<State, string>>;
|
|
64
|
+
/** The states to explain, in the order they are read. */
|
|
65
|
+
items: readonly PieceMapLegendItem<State>[];
|
|
66
|
+
/** Said before the keys — the size of the whole, say. */
|
|
67
|
+
children?: Child;
|
|
68
|
+
size?: Reactive<PieceVariants["size"]>;
|
|
69
|
+
class?: Reactive<string>;
|
|
70
|
+
}
|
|
71
|
+
/** What the squares' colours mean. */
|
|
72
|
+
export declare function PieceMapLegend<State extends string>(props: PieceMapLegendProps<State>): TemplateResult;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PieceMap — a transfer drawn as one small square per piece.
|
|
3
|
+
*
|
|
4
|
+
* What a torrent client shows under a download: each square is a piece of the
|
|
5
|
+
* whole, coloured by where it stands — here, missing, on its way, taken from a
|
|
6
|
+
* peer. A progress bar says how much; the map says *which*, and that is what
|
|
7
|
+
* a stalled run, a missing layer or a peer serving one half shows at a glance.
|
|
8
|
+
*
|
|
9
|
+
* The states are the caller's, not a fixed set. A download, a replication and
|
|
10
|
+
* a backup do not have the same ones, so the component takes a string type of
|
|
11
|
+
* its own and a class per state — `tones` — and paints nothing it was not
|
|
12
|
+
* told about. The legend reads the same `tones`, so a square and its key can
|
|
13
|
+
* never drift apart.
|
|
14
|
+
*
|
|
15
|
+
* Pieces come in groups: each group after the first is set off by a rule — a
|
|
16
|
+
* torrent's files, an image's layers. A flat map is one group.
|
|
17
|
+
*
|
|
18
|
+
* A generic function rather than `component<P>`, as DataTable: `State` has to
|
|
19
|
+
* stay open so `tones` is checked against the caller's own states.
|
|
20
|
+
*
|
|
21
|
+
* With a `label`, the map is one image to assistive technology and the label
|
|
22
|
+
* is what it says ("12 of 40 pieces"): a screen reader walking hundreds of
|
|
23
|
+
* squares one by one learns nothing the sentence does not. Each square keeps
|
|
24
|
+
* its `title` for the pointer.
|
|
25
|
+
*/
|
|
26
|
+
import { html } from "@c9up/aurora";
|
|
27
|
+
import { cn } from "../lib/cn.js";
|
|
28
|
+
import { cva } from "../lib/cva.js";
|
|
29
|
+
import { read } from "../lib/props.js";
|
|
30
|
+
export const pieceVariants = cva("inline-block shrink-0 rounded-[2px]", {
|
|
31
|
+
variants: {
|
|
32
|
+
size: {
|
|
33
|
+
sm: "size-2",
|
|
34
|
+
default: "size-2.5",
|
|
35
|
+
lg: "size-3",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
defaultVariants: { size: "default" },
|
|
39
|
+
});
|
|
40
|
+
export function PieceMap(props) {
|
|
41
|
+
return html `<div
|
|
42
|
+
data-slot="piece-map"
|
|
43
|
+
role="${() => (read(props.label) === undefined ? undefined : "img")}"
|
|
44
|
+
aria-label="${() => read(props.label)}"
|
|
45
|
+
class="${() => cn("flex flex-wrap gap-1", read(props.class))}"
|
|
46
|
+
>
|
|
47
|
+
${() => read(props.groups).map((pieces, index) => html `<span
|
|
48
|
+
data-slot="piece-map-group"
|
|
49
|
+
class="${cn("flex flex-wrap gap-0.5", index > 0 && "border-border border-s ps-1")}"
|
|
50
|
+
>
|
|
51
|
+
${pieces.map((piece) => html `<span
|
|
52
|
+
data-slot="piece"
|
|
53
|
+
data-state="${piece.state}"
|
|
54
|
+
title="${piece.title}"
|
|
55
|
+
class="${cn(pieceVariants({ size: read(props.size) }), props.tones[piece.state])}"
|
|
56
|
+
></span>`)}
|
|
57
|
+
</span>`)}
|
|
58
|
+
</div>`;
|
|
59
|
+
}
|
|
60
|
+
/** What the squares' colours mean. */
|
|
61
|
+
export function PieceMapLegend(props) {
|
|
62
|
+
// A space after each key: the gap between them is only drawn, and without
|
|
63
|
+
// one their labels run together for a screen reader and a copy.
|
|
64
|
+
return html `<p
|
|
65
|
+
data-slot="piece-map-legend"
|
|
66
|
+
class="${() => cn("text-muted-foreground flex flex-wrap gap-x-4 gap-y-1 text-xs", read(props.class))}"
|
|
67
|
+
>
|
|
68
|
+
${props.children}
|
|
69
|
+
${props.items.map((item) => html `<span class="inline-flex items-center gap-1.5"
|
|
70
|
+
><span
|
|
71
|
+
aria-hidden="true"
|
|
72
|
+
data-state="${item.state}"
|
|
73
|
+
class="${() => cn(pieceVariants({ size: read(props.size) }), props.tones[item.state])}"
|
|
74
|
+
></span
|
|
75
|
+
>${item.label}</span
|
|
76
|
+
> `)}
|
|
77
|
+
</p>`;
|
|
78
|
+
}
|
|
@@ -50,6 +50,8 @@ export declare const ResizablePanel: (props?: ResizablePanelProps | undefined) =
|
|
|
50
50
|
export interface ResizableHandleProps {
|
|
51
51
|
/** Show the grip dots. */
|
|
52
52
|
withHandle?: boolean;
|
|
53
|
+
/** The separator's accessible name. Default `"Resize panes"`. */
|
|
54
|
+
label?: string;
|
|
53
55
|
class?: Reactive<string>;
|
|
54
56
|
}
|
|
55
57
|
/**
|
|
@@ -148,7 +148,7 @@ export const ResizableHandle = component((props) => {
|
|
|
148
148
|
aria-valuemin="${group.min}"
|
|
149
149
|
aria-valuemax="${group.max}"
|
|
150
150
|
aria-valuenow="${() => Math.round(group.size())}"
|
|
151
|
-
aria-label="Resize panes"
|
|
151
|
+
aria-label="${props.label ?? "Resize panes"}"
|
|
152
152
|
class="${() => cn("bg-border relative flex shrink-0 items-center justify-center outline-none", "focus-visible:ring-ring focus-visible:ring-1 focus-visible:ring-offset-1", group.horizontal ? "w-px cursor-col-resize" : "h-px cursor-row-resize", read(props.class))}"
|
|
153
153
|
@pointerdown="${onPointerDown}"
|
|
154
154
|
@keydown="${onKeyDown}"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
export { Accordion, AccordionContent, type AccordionContentProps, AccordionItem, type AccordionItemProps, type AccordionProps, AccordionTrigger, type AccordionTriggerProps, } from "./Accordion.js";
|
|
19
19
|
export { Alert, AlertDescription, type AlertProps, AlertTitle, type AlertVariants, alertVariants, } from "./Alert.js";
|
|
20
20
|
export { Attachment, type AttachmentProps, formatBytes, } from "./Attachment.js";
|
|
21
|
-
export { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, type BreadcrumbLinkProps, BreadcrumbList, BreadcrumbPage, type BreadcrumbProps, BreadcrumbSeparator, } from "./Breadcrumb.js";
|
|
21
|
+
export { Breadcrumb, BreadcrumbEllipsis, type BreadcrumbEllipsisProps, BreadcrumbItem, BreadcrumbLink, type BreadcrumbLinkProps, BreadcrumbList, type BreadcrumbNavProps, BreadcrumbPage, type BreadcrumbProps, BreadcrumbSeparator, } from "./Breadcrumb.js";
|
|
22
22
|
export { Bubble, type BubbleProps, type BubbleReaction, type BubbleVariants, bubbleVariants, } from "./Bubble.js";
|
|
23
23
|
export { ButtonGroup, type ButtonGroupProps, ButtonGroupSeparator, ButtonGroupText, } from "./ButtonGroup.js";
|
|
24
24
|
export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, type CardProps, CardTitle, } from "./Card.js";
|
|
@@ -29,8 +29,9 @@ export { InputGroup, InputGroupAddon, type InputGroupAddonProps, InputGroupButto
|
|
|
29
29
|
export { InputOTP, InputOTPGroup, type InputOTPGroupProps, type InputOTPProps, InputOTPSeparator, type InputOTPSeparatorProps, InputOTPSlot, type InputOTPSlotProps, } from "./InputOTP.js";
|
|
30
30
|
export { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemMedia, type ItemProps, ItemSeparator, ItemTitle, type ItemVariants, itemVariants, } from "./Item.js";
|
|
31
31
|
export { Message, type MessageProps } from "./Message.js";
|
|
32
|
-
export { type PageSlot, Pagination, PaginationContent, PaginationEllipsis, type PaginationEllipsisProps, PaginationItem, PaginationLink, type PaginationLinkProps, PaginationNext, PaginationPrevious, type PaginationProps, type PaginationStepProps, pageWindow, } from "./Pagination.js";
|
|
32
|
+
export { type PageSlot, Pagination, PaginationContent, PaginationEllipsis, type PaginationEllipsisProps, PaginationItem, type PaginationLabels, PaginationLink, type PaginationLinkProps, type PaginationNavProps, PaginationNext, PaginationPrevious, type PaginationProps, type PaginationStepProps, pageWindow, } from "./Pagination.js";
|
|
33
33
|
export { Picture, type PictureProps } from "./Picture.js";
|
|
34
|
+
export { type Piece, PieceMap, PieceMapLegend, type PieceMapLegendItem, type PieceMapLegendProps, type PieceMapProps, type PieceVariants, pieceVariants, } from "./PieceMap.js";
|
|
34
35
|
export { RadioGroup, RadioGroupItem, type RadioGroupItemProps, type RadioGroupProps, } from "./RadioGroup.js";
|
|
35
36
|
export { ResizableHandle, type ResizableHandleProps, ResizablePanel, ResizablePanelGroup, type ResizablePanelGroupProps, type ResizablePanelProps, } from "./Resizable.js";
|
|
36
37
|
export { Table, TableBody, TableCaption, TableCell, type TableCellProps, TableFooter, TableHead, TableHeader, type TableProps, TableRow, type TableRowProps, } from "./Table.js";
|
package/dist/molecules/index.js
CHANGED
|
@@ -31,6 +31,7 @@ export { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemMedia,
|
|
|
31
31
|
export { Message } from "./Message.js";
|
|
32
32
|
export { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, pageWindow, } from "./Pagination.js";
|
|
33
33
|
export { Picture } from "./Picture.js";
|
|
34
|
+
export { PieceMap, PieceMapLegend, pieceVariants, } from "./PieceMap.js";
|
|
34
35
|
export { RadioGroup, RadioGroupItem, } from "./RadioGroup.js";
|
|
35
36
|
export { ResizableHandle, ResizablePanel, ResizablePanelGroup, } from "./Resizable.js";
|
|
36
37
|
export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, } from "./Table.js";
|
|
@@ -28,6 +28,18 @@ export interface DateRange {
|
|
|
28
28
|
readonly from: Date;
|
|
29
29
|
readonly to?: Date;
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* The words the calendar writes itself — react-day-picker's `labels`.
|
|
33
|
+
*
|
|
34
|
+
* Month and weekday names come from `Intl` in `locale`; these two do not, and
|
|
35
|
+
* a screen reader would read them in English in the middle of a French page.
|
|
36
|
+
*/
|
|
37
|
+
export interface CalendarLabels {
|
|
38
|
+
/** The previous-month arrow. Default `"Previous month"`. */
|
|
39
|
+
previousMonth: string;
|
|
40
|
+
/** The next-month arrow. Default `"Next month"`. */
|
|
41
|
+
nextMonth: string;
|
|
42
|
+
}
|
|
31
43
|
export interface CalendarProps {
|
|
32
44
|
/**
|
|
33
45
|
* `"range"` picks a span in two clicks. Default `"single"`.
|
|
@@ -54,6 +66,7 @@ export interface CalendarProps {
|
|
|
54
66
|
/** `0` Sunday, `1` Monday. Defaults to the locale's own first day. */
|
|
55
67
|
weekStartsOn?: number;
|
|
56
68
|
locale?: string;
|
|
69
|
+
labels?: Partial<CalendarLabels>;
|
|
57
70
|
class?: Reactive<string>;
|
|
58
71
|
/** `"single"` mode. */
|
|
59
72
|
onValueChange?: (date: Date) => void;
|
|
@@ -268,7 +268,7 @@ export const Calendar = component((props) => {
|
|
|
268
268
|
<div class="flex items-center justify-between pb-4">
|
|
269
269
|
<button
|
|
270
270
|
type="button"
|
|
271
|
-
aria-label="Previous month"
|
|
271
|
+
aria-label="${props.labels?.previousMonth ?? "Previous month"}"
|
|
272
272
|
class="${buttonVariants({ variant: "outline", size: "icon", class: "size-7" })}"
|
|
273
273
|
@click="${() => month(addMonths(month(), -1))}"
|
|
274
274
|
>${ChevronLeftIcon({ class: "size-4" })}</button>
|
|
@@ -277,7 +277,7 @@ export const Calendar = component((props) => {
|
|
|
277
277
|
</div>
|
|
278
278
|
<button
|
|
279
279
|
type="button"
|
|
280
|
-
aria-label="Next month"
|
|
280
|
+
aria-label="${props.labels?.nextMonth ?? "Next month"}"
|
|
281
281
|
class="${buttonVariants({ variant: "outline", size: "icon", class: "size-7" })}"
|
|
282
282
|
@click="${() => month(addMonths(month(), 1))}"
|
|
283
283
|
>${ChevronRightIcon({ class: "size-4" })}</button>
|
|
@@ -21,6 +21,8 @@ import { type Reactive } from "../lib/props.js";
|
|
|
21
21
|
export interface CarouselProps {
|
|
22
22
|
/** Announced before the slides. */
|
|
23
23
|
label?: string;
|
|
24
|
+
/** What a screen reader calls the region. Default `"carousel"`. */
|
|
25
|
+
roleDescription?: string;
|
|
24
26
|
orientation?: "horizontal" | "vertical";
|
|
25
27
|
class?: Reactive<string>;
|
|
26
28
|
children?: Parts;
|
|
@@ -34,6 +36,10 @@ export interface CarouselContentProps {
|
|
|
34
36
|
export declare const CarouselContent: (props?: CarouselContentProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
35
37
|
export interface CarouselItemProps {
|
|
36
38
|
children?: Slot;
|
|
39
|
+
/** What a screen reader calls one slide. Default `"slide"`. */
|
|
40
|
+
roleDescription?: string;
|
|
41
|
+
/** The slide's name from its position. Default `"3 of 7"`. */
|
|
42
|
+
label?: (position: number, count: number) => string;
|
|
37
43
|
class?: Reactive<string>;
|
|
38
44
|
}
|
|
39
45
|
/**
|
|
@@ -45,6 +51,8 @@ export interface CarouselItemProps {
|
|
|
45
51
|
*/
|
|
46
52
|
export declare const CarouselItem: (props?: CarouselItemProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
47
53
|
export interface CarouselButtonProps {
|
|
54
|
+
/** The arrow's accessible name. Default `"Previous slide"` / `"Next slide"`. */
|
|
55
|
+
label?: string;
|
|
48
56
|
class?: Reactive<string>;
|
|
49
57
|
}
|
|
50
58
|
export declare const CarouselPrevious: (props?: CarouselButtonProps | undefined) => import("@c9up/aurora").TemplateResult;
|
|
@@ -97,7 +97,7 @@ export const Carousel = component((props) => {
|
|
|
97
97
|
return html `<div
|
|
98
98
|
data-slot="carousel"
|
|
99
99
|
role="region"
|
|
100
|
-
aria-roledescription="carousel"
|
|
100
|
+
aria-roledescription="${props.roleDescription ?? "carousel"}"
|
|
101
101
|
aria-label="${props.label ?? "Carousel"}"
|
|
102
102
|
class="${() => cn("relative", read(props.class))}"
|
|
103
103
|
@keydown="${onKeyDown}"
|
|
@@ -126,18 +126,21 @@ export const CarouselItem = component((props) => {
|
|
|
126
126
|
return html `<div
|
|
127
127
|
data-slot="carousel-item"
|
|
128
128
|
role="group"
|
|
129
|
-
aria-roledescription="slide"
|
|
130
|
-
aria-label="${() =>
|
|
129
|
+
aria-roledescription="${props.roleDescription ?? "slide"}"
|
|
130
|
+
aria-label="${() => (props.label ?? slideOf)(position, carousel.slideCount())}"
|
|
131
131
|
class="${() => cn("min-w-0 shrink-0 grow-0 basis-full snap-start", read(props.class))}"
|
|
132
132
|
>${slot(props.children)}</div>`;
|
|
133
133
|
});
|
|
134
|
+
function slideOf(position, count) {
|
|
135
|
+
return `${position} of ${count}`;
|
|
136
|
+
}
|
|
134
137
|
const arrowClasses = "absolute size-8 rounded-full";
|
|
135
138
|
export const CarouselPrevious = component((props) => {
|
|
136
139
|
const carousel = inject(CarouselContext);
|
|
137
140
|
return html `<button
|
|
138
141
|
type="button"
|
|
139
142
|
data-slot="carousel-previous"
|
|
140
|
-
aria-label="Previous slide"
|
|
143
|
+
aria-label="${props.label ?? "Previous slide"}"
|
|
141
144
|
?disabled="${() => carousel.atStart()}"
|
|
142
145
|
class="${() => cn(buttonVariants({ variant: "outline", size: "icon" }), arrowClasses, carousel.horizontal
|
|
143
146
|
? "top-1/2 -left-12 -translate-y-1/2"
|
|
@@ -150,7 +153,7 @@ export const CarouselNext = component((props) => {
|
|
|
150
153
|
return html `<button
|
|
151
154
|
type="button"
|
|
152
155
|
data-slot="carousel-next"
|
|
153
|
-
aria-label="Next slide"
|
|
156
|
+
aria-label="${props.label ?? "Next slide"}"
|
|
154
157
|
?disabled="${() => carousel.atEnd()}"
|
|
155
158
|
class="${() => cn(buttonVariants({ variant: "outline", size: "icon" }), arrowClasses, carousel.horizontal
|
|
156
159
|
? "top-1/2 -right-12 -translate-y-1/2"
|