@arshad-shah/cynosure 0.3.0 → 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.
- package/README.md +3 -3
- package/dist/adapters/astro/index.d.ts +52 -0
- package/dist/adapters/astro/index.js +27 -0
- package/dist/adapters/astro/index.js.map +1 -0
- package/dist/adapters/vite/index.d.ts +11 -0
- package/dist/adapters/vite/index.js +33 -12
- package/dist/adapters/vite/index.js.map +1 -1
- package/dist/brands/googleplay.d.ts +2 -0
- package/dist/brands/googleplay.js +17 -0
- package/dist/brands/googleplay.js.map +1 -0
- package/dist/brands/index.d.ts +1 -0
- package/dist/brands/index.js +132 -130
- package/dist/components/Announcer/Announcer.js +5 -5
- package/dist/components/Announcer/Announcer.js.map +1 -1
- package/dist/components/AppShell/AppShell.js +50 -53
- package/dist/components/AppShell/AppShell.js.map +1 -1
- package/dist/components/Avatar/Avatar.js +20 -20
- package/dist/components/Avatar/Avatar.js.map +1 -1
- package/dist/components/Button/Button.d.ts +17 -3
- package/dist/components/Button/Button.js +51 -44
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Calendar/Calendar.js +69 -69
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Card/Card.d.ts +8 -1
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.d.ts +4 -4
- package/dist/components/Checkbox/Checkbox.js +33 -8
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Checklist/Checklist.js +21 -21
- package/dist/components/Checklist/Checklist.js.map +1 -1
- package/dist/components/Choice/Choice.d.ts +73 -0
- package/dist/components/Choice/Choice.js +41 -0
- package/dist/components/Choice/Choice.js.map +1 -0
- package/dist/components/Choice/index.d.ts +1 -0
- package/dist/components/ColorField/ColorField.js +198 -207
- package/dist/components/ColorField/ColorField.js.map +1 -1
- package/dist/components/Combobox/Combobox.js +86 -115
- package/dist/components/Combobox/Combobox.js.map +1 -1
- package/dist/components/Container/Container.d.ts +2 -2
- package/dist/components/Container/Container.js +17 -13
- package/dist/components/Container/Container.js.map +1 -1
- package/dist/components/CopyButton/CopyButton.js +29 -28
- package/dist/components/CopyButton/CopyButton.js.map +1 -1
- package/dist/components/DeviceFrame/DeviceFrame.d.ts +63 -0
- package/dist/components/DeviceFrame/DeviceFrame.js +54 -0
- package/dist/components/DeviceFrame/DeviceFrame.js.map +1 -0
- package/dist/components/DeviceFrame/index.d.ts +1 -0
- package/dist/components/Dialog/Dialog.d.ts +10 -1
- package/dist/components/Dialog/Dialog.js +82 -77
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.d.ts +5 -2
- package/dist/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/components/Field/Field.js +31 -33
- package/dist/components/Field/Field.js.map +1 -1
- package/dist/components/FileDrop/FileDrop.js +14 -14
- package/dist/components/FileDrop/FileDrop.js.map +1 -1
- package/dist/components/FloatingToolbar/FloatingToolbar.js +7 -6
- package/dist/components/FloatingToolbar/FloatingToolbar.js.map +1 -1
- package/dist/components/Grid/Grid.d.ts +32 -11
- package/dist/components/Grid/Grid.js +68 -46
- package/dist/components/Grid/Grid.js.map +1 -1
- package/dist/components/Grid/index.d.ts +1 -1
- package/dist/components/Heading/Heading.d.ts +4 -2
- package/dist/components/Heading/Heading.js.map +1 -1
- package/dist/components/IconButton/IconButton.d.ts +16 -1
- package/dist/components/IconButton/IconButton.js +14 -10
- package/dist/components/IconButton/IconButton.js.map +1 -1
- package/dist/components/IconTile/IconTile.d.ts +45 -0
- package/dist/components/IconTile/IconTile.js +25 -0
- package/dist/components/IconTile/IconTile.js.map +1 -0
- package/dist/components/IconTile/index.d.ts +1 -0
- package/dist/components/Image/Image.js.map +1 -1
- package/dist/components/Inline/Inline.d.ts +3 -3
- package/dist/components/Inline/Inline.js +12 -22
- package/dist/components/Inline/Inline.js.map +1 -1
- package/dist/components/KeyValueEditor/KeyValueEditor.js +37 -36
- package/dist/components/KeyValueEditor/KeyValueEditor.js.map +1 -1
- package/dist/components/Link/Link.d.ts +9 -1
- package/dist/components/Link/Link.js +20 -18
- package/dist/components/Link/Link.js.map +1 -1
- package/dist/components/List/List.d.ts +73 -0
- package/dist/components/List/List.js +64 -0
- package/dist/components/List/List.js.map +1 -0
- package/dist/components/List/index.d.ts +1 -0
- package/dist/components/Notice/Notice.js +12 -11
- package/dist/components/Notice/Notice.js.map +1 -1
- package/dist/components/OptionList/OptionList.d.ts +69 -0
- package/dist/components/OptionList/OptionList.js +75 -0
- package/dist/components/OptionList/OptionList.js.map +1 -0
- package/dist/components/OptionList/index.d.ts +1 -0
- package/dist/components/PageHeader/PageHeader.d.ts +6 -0
- package/dist/components/PageHeader/PageHeader.js +27 -27
- package/dist/components/PageHeader/PageHeader.js.map +1 -1
- package/dist/components/Pagination/Pagination.js +31 -30
- package/dist/components/Pagination/Pagination.js.map +1 -1
- package/dist/components/QRCode/QRCode.d.ts +56 -0
- package/dist/components/QRCode/QRCode.js +48 -0
- package/dist/components/QRCode/QRCode.js.map +1 -0
- package/dist/components/QRCode/index.d.ts +1 -0
- package/dist/components/RadioGroup/RadioGroup.js +32 -24
- package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/components/Section/Section.d.ts +57 -0
- package/dist/components/Section/Section.js +27 -0
- package/dist/components/Section/Section.js.map +1 -0
- package/dist/components/Section/index.d.ts +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +12 -12
- package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/components/Select/Select.js +106 -133
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Sheet/Sheet.js +12 -7
- package/dist/components/Sheet/Sheet.js.map +1 -1
- package/dist/components/SideNav/SideNav.js +55 -53
- package/dist/components/SideNav/SideNav.js.map +1 -1
- package/dist/components/SiteFooter/SiteFooter.d.ts +66 -0
- package/dist/components/SiteFooter/SiteFooter.js +80 -0
- package/dist/components/SiteFooter/SiteFooter.js.map +1 -0
- package/dist/components/SiteFooter/index.d.ts +1 -0
- package/dist/components/SiteHeader/SiteHeader.d.ts +78 -0
- package/dist/components/SiteHeader/SiteHeader.js +114 -0
- package/dist/components/SiteHeader/SiteHeader.js.map +1 -0
- package/dist/components/SiteHeader/index.d.ts +1 -0
- package/dist/components/SkipLink/SkipLink.d.ts +42 -0
- package/dist/components/SkipLink/SkipLink.js +43 -0
- package/dist/components/SkipLink/SkipLink.js.map +1 -0
- package/dist/components/SkipLink/index.d.ts +1 -0
- package/dist/components/SortableList/SortableList.js +13 -13
- package/dist/components/SortableList/SortableList.js.map +1 -1
- package/dist/components/Stack/Stack.d.ts +16 -7
- package/dist/components/Stack/Stack.js +25 -18
- package/dist/components/Stack/Stack.js.map +1 -1
- package/dist/components/Stack/index.d.ts +1 -1
- package/dist/components/Stack/space.d.ts +29 -0
- package/dist/components/Stack/space.js +16 -5
- package/dist/components/Stack/space.js.map +1 -1
- package/dist/components/Stat/Stat.d.ts +88 -0
- package/dist/components/Stat/Stat.js +105 -0
- package/dist/components/Stat/Stat.js.map +1 -0
- package/dist/components/Stat/index.d.ts +1 -0
- package/dist/components/Steps/Steps.d.ts +10 -4
- package/dist/components/Steps/Steps.js +31 -30
- package/dist/components/Steps/Steps.js.map +1 -1
- package/dist/components/Switch/Switch.d.ts +4 -4
- package/dist/components/Switch/Switch.js +18 -7
- package/dist/components/Switch/Switch.js.map +1 -1
- package/dist/components/Table/Table.js +11 -12
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +4 -1
- package/dist/components/Tabs/Tabs.js +71 -70
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/TagInput/TagInput.js +76 -97
- package/dist/components/TagInput/TagInput.js.map +1 -1
- package/dist/components/TextField/TextField.d.ts +4 -0
- package/dist/components/TextField/TextField.js +30 -29
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/ThemeToggle/ThemeToggle.d.ts +7 -1
- package/dist/components/ThemeToggle/ThemeToggle.js +33 -30
- package/dist/components/ThemeToggle/ThemeToggle.js.map +1 -1
- package/dist/components/Toast/Toast.js +22 -20
- package/dist/components/Toast/Toast.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +6 -1
- package/dist/components/Tooltip/Tooltip.js +19 -19
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +24 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.js +17 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.js.map +1 -0
- package/dist/components/VisuallyHidden/index.d.ts +1 -0
- package/dist/foundations/ChoiceBase/ChoiceBase.js +8 -8
- package/dist/foundations/ChoiceBase/ChoiceBase.js.map +1 -1
- package/dist/foundations/HiddenValue/HiddenValue.js +5 -5
- package/dist/foundations/HiddenValue/HiddenValue.js.map +1 -1
- package/dist/foundations/Icon/Icon.d.ts +6 -1
- package/dist/foundations/Icon/Icon.js +15 -14
- package/dist/foundations/Icon/Icon.js.map +1 -1
- package/dist/foundations/image-outcome.d.ts +8 -3
- package/dist/foundations/image-outcome.js +12 -8
- package/dist/foundations/image-outcome.js.map +1 -1
- package/dist/foundations/printing.d.ts +6 -0
- package/dist/foundations/printing.js +17 -0
- package/dist/foundations/printing.js.map +1 -0
- package/dist/foundations/qr.d.ts +42 -0
- package/dist/foundations/qr.js +246 -0
- package/dist/foundations/qr.js.map +1 -0
- package/dist/icons/book-marked.d.ts +2 -0
- package/dist/icons/book-marked.js +14 -0
- package/dist/icons/book-marked.js.map +1 -0
- package/dist/icons/calendar-days.d.ts +2 -0
- package/dist/icons/calendar-days.js +24 -0
- package/dist/icons/calendar-days.js.map +1 -0
- package/dist/icons/check-square.d.ts +2 -0
- package/dist/icons/check-square.js +14 -0
- package/dist/icons/check-square.js.map +1 -0
- package/dist/icons/crescent.d.ts +2 -0
- package/dist/icons/crescent.js +14 -0
- package/dist/icons/crescent.js.map +1 -0
- package/dist/icons/index.d.ts +10 -0
- package/dist/icons/index.js +436 -416
- package/dist/icons/kaaba.d.ts +2 -0
- package/dist/icons/kaaba.js +14 -0
- package/dist/icons/kaaba.js.map +1 -0
- package/dist/icons/keywords.d.ts +11 -1
- package/dist/icons/keywords.js +89 -1
- package/dist/icons/keywords.js.map +1 -1
- package/dist/icons/list-tree.d.ts +2 -0
- package/dist/icons/list-tree.js +14 -0
- package/dist/icons/list-tree.js.map +1 -0
- package/dist/icons/mosque.d.ts +2 -0
- package/dist/icons/mosque.js +14 -0
- package/dist/icons/mosque.js.map +1 -0
- package/dist/icons/prayer-beads.d.ts +2 -0
- package/dist/icons/prayer-beads.js +67 -0
- package/dist/icons/prayer-beads.js.map +1 -0
- package/dist/icons/qr-code.d.ts +2 -0
- package/dist/icons/qr-code.js +38 -0
- package/dist/icons/qr-code.js.map +1 -0
- package/dist/icons/refresh-cw.d.ts +2 -0
- package/dist/icons/refresh-cw.js +14 -0
- package/dist/icons/refresh-cw.js.map +1 -0
- package/dist/icons/types.d.ts +1 -1
- package/dist/icons/types.js +2 -1
- package/dist/icons/types.js.map +1 -1
- package/dist/index.d.ts +16 -2
- package/dist/index.js +274 -241
- package/dist/styles/announcer.css +1 -1
- package/dist/styles/app-shell.css +1 -1
- package/dist/styles/avatar.css +1 -1
- package/dist/styles/base.css +1 -1
- package/dist/styles/button.css +1 -1
- package/dist/styles/calendar.css +1 -1
- package/dist/styles/card.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/choice-base.css +1 -0
- package/dist/styles/choice.css +1 -1
- package/dist/styles/color-field.css +1 -1
- package/dist/styles/combobox.css +1 -1
- package/dist/styles/copy-button.css +1 -1
- package/dist/styles/date-field.css +1 -1
- package/dist/styles/device-frame.css +1 -0
- package/dist/styles/dialog.css +1 -1
- package/dist/styles/disclosure.css +1 -1
- package/dist/styles/field.css +1 -1
- package/dist/styles/file-drop.css +1 -1
- package/dist/styles/floating-toolbar.css +1 -1
- package/dist/styles/generated-css.d.ts +1 -1
- package/dist/styles/generated-css.js +1 -1
- package/dist/styles/generated-css.js.map +1 -1
- package/dist/styles/grid.css +1 -1
- package/dist/styles/heading.css +1 -1
- package/dist/styles/icon-tile.css +1 -0
- package/dist/styles/icon.css +1 -1
- package/dist/styles/inline.css +1 -0
- package/dist/styles/key-value-editor.css +1 -1
- package/dist/styles/link.css +1 -1
- package/dist/styles/list.css +1 -0
- package/dist/styles/manifest.json +715 -0
- package/dist/styles/notice.css +1 -1
- package/dist/styles/number-field.css +1 -1
- package/dist/styles/option-list.css +1 -0
- package/dist/styles/pagination.css +1 -1
- package/dist/styles/qr-code.css +1 -0
- package/dist/styles/radio-group.css +1 -1
- package/dist/styles/section.css +1 -0
- package/dist/styles/segmented-control.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/sheet.css +1 -1
- package/dist/styles/side-nav.css +1 -1
- package/dist/styles/site-footer.css +1 -0
- package/dist/styles/site-header.css +1 -0
- package/dist/styles/skip-link.css +1 -0
- package/dist/styles/sortable-list.css +1 -1
- package/dist/styles/stack.css +1 -1
- package/dist/styles/stat.css +1 -0
- package/dist/styles/steps.css +1 -1
- package/dist/styles/switch.css +1 -0
- package/dist/styles/table.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/tag-input.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/time-field.css +1 -1
- package/dist/styles/toast.css +1 -1
- package/dist/styles/visually-hidden.css +1 -0
- package/dist/styles.css +1 -1
- package/dist/tokens/create-theme.js +137 -108
- package/dist/tokens/create-theme.js.map +1 -1
- package/package.json +6 -1
- package/dist/components/Checkbox/ChoiceRow.d.ts +0 -39
- package/dist/components/Checkbox/ChoiceRow.js +0 -58
- package/dist/components/Checkbox/ChoiceRow.js.map +0 -1
- package/dist/styles/hidden-value.css +0 -1
- package/dist/styles/iconbutton.css +0 -1
- package/dist/styles/search-field.css +0 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { menu as x } from "../../icons/menu.js";
|
|
3
|
+
import { IconButton as L } from "../IconButton/IconButton.js";
|
|
4
|
+
import { Sheet as M } from "../Sheet/Sheet.js";
|
|
5
|
+
import { SkipLink as C } from "../SkipLink/SkipLink.js";
|
|
6
|
+
import { Link as h } from "../Link/Link.js";
|
|
7
|
+
import { Container as F } from "../Container/Container.js";
|
|
8
|
+
import { SideNav as O } from "../SideNav/SideNav.js";
|
|
9
|
+
import { forwardRef as $, useState as j } from "react";
|
|
10
|
+
import { Fragment as A, jsx as e, jsxs as m } from "react/jsx-runtime";
|
|
11
|
+
var B = {
|
|
12
|
+
nav: "Main",
|
|
13
|
+
openMenu: "Open menu",
|
|
14
|
+
menu: "Menu",
|
|
15
|
+
skip: "Skip to content"
|
|
16
|
+
}, _ = $(function({ brand: t, brandHref: s = "/", nav: a = [], actions: l, sticky: p = !0, skipLink: u = !0, skipTo: f = "#main", collapseBelow: y = "md", size: N = "lg", labels: g, id: k, className: c, style: v }, S) {
|
|
17
|
+
const n = {
|
|
18
|
+
...B,
|
|
19
|
+
...g
|
|
20
|
+
}, [o, i] = j(!1), d = a.findIndex((r) => r.current);
|
|
21
|
+
return /* @__PURE__ */ m(A, { children: [
|
|
22
|
+
u && /* @__PURE__ */ e(C, {
|
|
23
|
+
href: f,
|
|
24
|
+
labels: { skip: n.skip }
|
|
25
|
+
}),
|
|
26
|
+
/* @__PURE__ */ e("header", {
|
|
27
|
+
ref: S,
|
|
28
|
+
id: k,
|
|
29
|
+
className: `cy-site-header${c ? ` ${c}` : ""}`,
|
|
30
|
+
"data-sticky": p ? "" : void 0,
|
|
31
|
+
"data-collapse": y,
|
|
32
|
+
style: v,
|
|
33
|
+
children: /* @__PURE__ */ m(F, {
|
|
34
|
+
size: N,
|
|
35
|
+
className: "cy-site-header-bar",
|
|
36
|
+
children: [
|
|
37
|
+
t && (s === !1 ? /* @__PURE__ */ e("div", {
|
|
38
|
+
className: "cy-site-header-brand",
|
|
39
|
+
children: t
|
|
40
|
+
}) : /* @__PURE__ */ e(h, {
|
|
41
|
+
href: s,
|
|
42
|
+
tone: "neutral",
|
|
43
|
+
underline: "none",
|
|
44
|
+
className: "cy-site-header-brand-link",
|
|
45
|
+
children: /* @__PURE__ */ e("span", {
|
|
46
|
+
className: "cy-site-header-brand",
|
|
47
|
+
children: t
|
|
48
|
+
})
|
|
49
|
+
})),
|
|
50
|
+
a.length > 0 && /* @__PURE__ */ e("nav", {
|
|
51
|
+
"aria-label": n.nav,
|
|
52
|
+
className: "cy-site-header-nav cy-reset",
|
|
53
|
+
children: /* @__PURE__ */ e("ul", {
|
|
54
|
+
className: "cy-site-header-list cy-reset",
|
|
55
|
+
children: a.map((r) => /* @__PURE__ */ e("li", {
|
|
56
|
+
className: "cy-site-header-item cy-reset",
|
|
57
|
+
children: /* @__PURE__ */ e(h, {
|
|
58
|
+
href: r.href,
|
|
59
|
+
tone: "neutral",
|
|
60
|
+
underline: "none",
|
|
61
|
+
"aria-current": r.current ? "page" : void 0,
|
|
62
|
+
className: "cy-site-header-link-anchor",
|
|
63
|
+
children: /* @__PURE__ */ e("span", {
|
|
64
|
+
className: "cy-site-header-link",
|
|
65
|
+
children: r.label
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
}, r.href))
|
|
69
|
+
})
|
|
70
|
+
}),
|
|
71
|
+
l && /* @__PURE__ */ e("div", {
|
|
72
|
+
className: "cy-site-header-actions cy-reset",
|
|
73
|
+
children: l
|
|
74
|
+
}),
|
|
75
|
+
a.length > 0 && /* @__PURE__ */ e("div", {
|
|
76
|
+
className: "cy-site-header-menu cy-reset",
|
|
77
|
+
children: /* @__PURE__ */ e(L, {
|
|
78
|
+
icon: x,
|
|
79
|
+
label: n.openMenu,
|
|
80
|
+
variant: "ghost",
|
|
81
|
+
tone: "neutral",
|
|
82
|
+
tooltipPlacement: "bottom",
|
|
83
|
+
"aria-expanded": o,
|
|
84
|
+
onClick: () => i(!0)
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
})
|
|
89
|
+
}),
|
|
90
|
+
a.length > 0 && /* @__PURE__ */ e(M, {
|
|
91
|
+
open: o,
|
|
92
|
+
onOpenChange: i,
|
|
93
|
+
side: "end",
|
|
94
|
+
size: "sm",
|
|
95
|
+
title: n.menu,
|
|
96
|
+
children: /* @__PURE__ */ e(O, {
|
|
97
|
+
label: n.nav,
|
|
98
|
+
items: a.map((r, b) => ({
|
|
99
|
+
id: String(b),
|
|
100
|
+
label: r.label,
|
|
101
|
+
href: r.href
|
|
102
|
+
})),
|
|
103
|
+
current: d < 0 ? void 0 : String(d),
|
|
104
|
+
onNavigate: () => i(!1),
|
|
105
|
+
className: "cy-site-header-sheet-nav"
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
] });
|
|
109
|
+
});
|
|
110
|
+
export {
|
|
111
|
+
_ as SiteHeader
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
//# sourceMappingURL=SiteHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SiteHeader.js","names":["_Fragment","menu","IconButton","Sheet","SkipLink","Link","Container","SideNav","forwardRef","useState","Fragment$1","jsx","jsxs","DEFAULT_LABELS","SiteHeader","brand","brandHref","nav","actions","sticky","skipLink","skipTo","collapseBelow","size","labels","id","className","style","ref","text","open","setOpen","current","item","i"],"sources":["../../../src/components/SiteHeader/SiteHeader.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef, type ReactNode, useState } from \"react\";\nimport { menu } from \"../../icons/menu.js\";\nimport { Container, type ContainerProps } from \"../Container/Container.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { Link } from \"../Link/Link.js\";\nimport { Sheet } from \"../Sheet/Sheet.js\";\nimport { SideNav } from \"../SideNav/SideNav.js\";\nimport { SkipLink } from \"../SkipLink/SkipLink.js\";\n\nexport interface SiteHeaderTokens {\n /** Least height of the bar. */\n height: string;\n /** Background of the bar. A sticky bar mixes it with some transparency and blurs the page behind. */\n background: string;\n /** Colour of the hairline under the bar. */\n border: string;\n /** Blur of the page seen through a sticky bar. */\n blur: string;\n /** Text colour of the navigation links. */\n linkColor: string;\n /** Text colour of the link to the current page. */\n linkCurrentColor: string;\n /** Background of a hovered link and of the link to the current page. */\n linkHighlight: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n siteHeader: SiteHeaderTokens;\n }\n}\n\n/** One link of the site navigation. */\nexport interface SiteHeaderLink {\n /** The link text. */\n label: string;\n /** Where it goes. */\n href: string;\n /** This link is the page being shown: it is marked `aria-current=\"page\"`. */\n current?: boolean;\n}\n\nexport interface SiteHeaderLabels {\n /** Name of the navigation landmark, in the bar and in the menu. Default: \"Main\". */\n nav: string;\n /** The menu button shown on narrow screens. Default: \"Open menu\". */\n openMenu: string;\n /** Title of the menu sheet. Default: \"Menu\". */\n menu: string;\n /** The skip link. Default: \"Skip to content\". */\n skip: string;\n}\n\nexport interface SiteHeaderProps {\n /** The logo or the site's name, at the inline start. Give a logo image its text alternative. */\n brand?: ReactNode;\n /** Where the brand links to. `false` shows the brand without a link. Default \"/\". */\n brandHref?: string | false;\n /** The site navigation, as data. Each link is a real link; the `current` one is marked for assistive technology. */\n nav?: SiteHeaderLink[];\n /** Controls at the inline end, such as a ThemeToggle, a search button or a sign-in Button. They stay in the bar. */\n actions?: ReactNode;\n /** Keep the bar at the top of the window while the page scrolls, over a blurred view of the page. Default true. */\n sticky?: boolean;\n /** Render a SkipLink before the bar, the first stop of the Tab order. Default true. */\n skipLink?: boolean;\n /** Where the skip link goes: `#` and the id of the page's main content. Default \"#main\". */\n skipTo?: string;\n /**\n * Width of the header below which the navigation moves into a menu opened from a button: `sm` 40rem, `md` 48rem,\n * `lg` 64rem. CSS only, so the right layout shows before any script runs. Default \"md\".\n */\n collapseBelow?: \"sm\" | \"md\" | \"lg\";\n /** Widest the bar's content gets: the `size` of its Container, to line up with the page. Default \"lg\". */\n size?: ContainerProps[\"size\"];\n /** Replace the built-in English text: the landmark name, the menu button, the menu title and the skip link. */\n labels?: Partial<SiteHeaderLabels>;\n /** Set on the `header` element. */\n id?: string | undefined;\n /** Added to the `header` element, for layout. */\n className?: string | undefined;\n /** Layout only. Restyle through --cy-site-header-* tokens. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: SiteHeaderLabels = {\n nav: \"Main\",\n openMenu: \"Open menu\",\n menu: \"Menu\",\n skip: \"Skip to content\",\n};\n\n/**\n * The top bar of a website that scrolls as a document: a skip link, the brand, the site navigation and actions. On\n * narrow screens the navigation moves into a menu sheet. For an app frame with a side navigation, use AppShell.\n */\nexport const SiteHeader = forwardRef<HTMLElement, SiteHeaderProps>(function SiteHeader(\n {\n brand,\n brandHref = \"/\",\n nav = [],\n actions,\n sticky = true,\n skipLink = true,\n skipTo = \"#main\",\n collapseBelow = \"md\",\n size = \"lg\",\n labels,\n id,\n className,\n style,\n },\n ref,\n) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const [open, setOpen] = useState(false);\n const current = nav.findIndex((item) => item.current);\n\n return (\n <>\n {/* Before the header, not in it: a sticky header's blur would make the link's fixed position relative to it. */}\n {skipLink && <SkipLink href={skipTo} labels={{ skip: text.skip }} />}\n <header\n ref={ref}\n id={id}\n className={`cy-site-header${className ? ` ${className}` : \"\"}`}\n data-sticky={sticky ? \"\" : undefined}\n data-collapse={collapseBelow}\n style={style}\n >\n <Container size={size} className=\"cy-site-header-bar\">\n {brand &&\n (brandHref === false ? (\n <div className=\"cy-site-header-brand\">{brand}</div>\n ) : (\n // A Link (its focus ring and colour), drawn as the brand by the span inside it.\n <Link href={brandHref} tone=\"neutral\" underline=\"none\" className=\"cy-site-header-brand-link\">\n <span className=\"cy-site-header-brand\">{brand}</span>\n </Link>\n ))}\n {nav.length > 0 && (\n <nav aria-label={text.nav} className=\"cy-site-header-nav cy-reset\">\n <ul className=\"cy-site-header-list cy-reset\">\n {nav.map((item) => (\n <li key={item.href} className=\"cy-site-header-item cy-reset\">\n {/* A Link, drawn as a pill by the span inside it. */}\n <Link\n href={item.href}\n tone=\"neutral\"\n underline=\"none\"\n aria-current={item.current ? \"page\" : undefined}\n className=\"cy-site-header-link-anchor\"\n >\n <span className=\"cy-site-header-link\">{item.label}</span>\n </Link>\n </li>\n ))}\n </ul>\n </nav>\n )}\n {actions && <div className=\"cy-site-header-actions cy-reset\">{actions}</div>}\n {nav.length > 0 && (\n <div className=\"cy-site-header-menu cy-reset\">\n <IconButton\n icon={menu}\n label={text.openMenu}\n variant=\"ghost\"\n tone=\"neutral\"\n tooltipPlacement=\"bottom\"\n aria-expanded={open}\n onClick={() => setOpen(true)}\n />\n </div>\n )}\n </Container>\n </header>\n {nav.length > 0 && (\n <Sheet open={open} onOpenChange={setOpen} side=\"end\" size=\"sm\" title={text.menu}>\n <SideNav\n label={text.nav}\n items={nav.map((item, i) => ({ id: String(i), label: item.label, href: item.href }))}\n current={current < 0 ? undefined : String(current)}\n // Choosing a link closes the menu; the browser then follows it.\n onNavigate={() => setOpen(false)}\n className=\"cy-site-header-sheet-nav\"\n />\n </Sheet>\n )}\n </>\n );\n});\n"],"mappings":";;;;;;;;;;AAqFA,IAAMa,IAAmC;AAAA,EACvC,KAAK;AAAA,EACL,UAAU;AAAA,EACV,MAAM;AAAA,EACN,MAAM;AACR,GAMaC,IAAaN,EAAyC,SACjE,EACE,OAAAO,GACA,WAAAC,IAAY,KACZ,KAAAC,IAAM,CAAC,GACP,SAAAC,GACA,QAAAC,IAAS,IACT,UAAAC,IAAW,IACX,QAAAC,IAAS,SACT,eAAAC,IAAgB,MAChB,MAAAC,IAAO,MACP,QAAAC,GACA,IAAAC,GACA,WAAAC,GACA,OAAAC,EAAA,GAEFC,GACA;AACA,QAAMC,IAAO;AAAA,IAAE,GAAGhB;AAAA,IAAgB,GAAGW;AAAA,EAAO,GACtC,CAACM,GAAMC,CAAA,IAAWtB,EAAS,EAAK,GAChCuB,IAAUf,EAAI,UAAA,CAAWgB,MAASA,EAAK,OAAO;AAEpD,SACE,gBA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./SiteHeader.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type CSSProperties } from "react";
|
|
2
|
+
export interface SkipLinkTokens {
|
|
3
|
+
/** Distance of the shown link from the top and inline-start edges of the window. */
|
|
4
|
+
offset: string;
|
|
5
|
+
/** Corner radius of the shown link. */
|
|
6
|
+
radius: string;
|
|
7
|
+
}
|
|
8
|
+
declare module "../../tokens/schema.js" {
|
|
9
|
+
interface ComponentTokens {
|
|
10
|
+
skipLink: SkipLinkTokens;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface SkipLinkLabels {
|
|
14
|
+
/** The link text. Default: "Skip to content". */
|
|
15
|
+
skip: string;
|
|
16
|
+
}
|
|
17
|
+
export interface SkipLinkProps {
|
|
18
|
+
/**
|
|
19
|
+
* Where the link goes: `#` and the id of the page's main content. Default "#main". Without JavaScript it is a plain
|
|
20
|
+
* in-page link; with it, focus moves to the target too.
|
|
21
|
+
*/
|
|
22
|
+
href?: string;
|
|
23
|
+
/** Replace the built-in English text: `skip`, the link text. */
|
|
24
|
+
labels?: Partial<SkipLinkLabels>;
|
|
25
|
+
/** Set on the link element. */
|
|
26
|
+
id?: string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Show at the top-start corner of the nearest positioned ancestor instead of the window's, so the link stays inside
|
|
29
|
+
* a frame such as a side panel (AppShell sets it). Default false.
|
|
30
|
+
*/
|
|
31
|
+
contained?: boolean;
|
|
32
|
+
/** Added to the link, for layout (e.g. to place it inside a positioned frame). */
|
|
33
|
+
className?: string | undefined;
|
|
34
|
+
/** Layout only. Restyle through --cy-skip-link-* tokens. */
|
|
35
|
+
style?: CSSProperties;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* "Skip to content": the first stop of the Tab order, hidden until it has focus and then shown at the top-start corner
|
|
39
|
+
* of the window as a Button. It is a real link, so it works before or without JavaScript; with it, focus also moves to
|
|
40
|
+
* the target.
|
|
41
|
+
*/
|
|
42
|
+
export declare const SkipLink: import("react").ForwardRefExoticComponent<SkipLinkProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Button as u } from "../Button/Button.js";
|
|
3
|
+
import { forwardRef as d } from "react";
|
|
4
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
5
|
+
var k = { skip: "Skip to content" };
|
|
6
|
+
function p(i, e) {
|
|
7
|
+
if (!e.startsWith("#") || e.length < 2) return !1;
|
|
8
|
+
let n = e.slice(1);
|
|
9
|
+
try {
|
|
10
|
+
n = decodeURIComponent(n);
|
|
11
|
+
} catch {
|
|
12
|
+
}
|
|
13
|
+
const t = i.getRootNode().getElementById?.(n) ?? document.getElementById(n);
|
|
14
|
+
return t ? (t.tabIndex < 0 && !t.hasAttribute("tabindex") && t.setAttribute("tabindex", "-1"), t.focus(), !0) : !1;
|
|
15
|
+
}
|
|
16
|
+
var b = d(function({ href: e = "#main", labels: n, id: t, contained: a = !1, className: c, style: o }, l) {
|
|
17
|
+
const s = {
|
|
18
|
+
...k,
|
|
19
|
+
...n
|
|
20
|
+
};
|
|
21
|
+
return /* @__PURE__ */ f(u, {
|
|
22
|
+
href: e,
|
|
23
|
+
linkRef: l,
|
|
24
|
+
id: t,
|
|
25
|
+
variant: "outline",
|
|
26
|
+
tone: "accent",
|
|
27
|
+
onClick: (r) => {
|
|
28
|
+
p(r.currentTarget, e) && r.preventDefault();
|
|
29
|
+
},
|
|
30
|
+
className: [
|
|
31
|
+
"cy-skip-link cy-visually-hidden",
|
|
32
|
+
a ? "cy-skip-link-contained" : void 0,
|
|
33
|
+
c
|
|
34
|
+
].filter(Boolean).join(" "),
|
|
35
|
+
...o ? { style: o } : {},
|
|
36
|
+
children: s.skip
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
export {
|
|
40
|
+
b as SkipLink
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=SkipLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SkipLink.js","names":["Button","forwardRef","jsx","DEFAULT_LABELS","focusTarget","link","href","id","target","SkipLink","labels","contained","className","style","ref","text","event"],"sources":["../../../src/components/SkipLink/SkipLink.tsx"],"sourcesContent":["import { type CSSProperties, forwardRef, type MouseEvent } from \"react\";\nimport { Button } from \"../Button/Button.js\";\n\nexport interface SkipLinkTokens {\n /** Distance of the shown link from the top and inline-start edges of the window. */\n offset: string;\n /** Corner radius of the shown link. */\n radius: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n skipLink: SkipLinkTokens;\n }\n}\n\nexport interface SkipLinkLabels {\n /** The link text. Default: \"Skip to content\". */\n skip: string;\n}\n\nexport interface SkipLinkProps {\n /**\n * Where the link goes: `#` and the id of the page's main content. Default \"#main\". Without JavaScript it is a plain\n * in-page link; with it, focus moves to the target too.\n */\n href?: string;\n /** Replace the built-in English text: `skip`, the link text. */\n labels?: Partial<SkipLinkLabels>;\n /** Set on the link element. */\n id?: string | undefined;\n /**\n * Show at the top-start corner of the nearest positioned ancestor instead of the window's, so the link stays inside\n * a frame such as a side panel (AppShell sets it). Default false.\n */\n contained?: boolean;\n /** Added to the link, for layout (e.g. to place it inside a positioned frame). */\n className?: string | undefined;\n /** Layout only. Restyle through --cy-skip-link-* tokens. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: SkipLinkLabels = { skip: \"Skip to content\" };\n\n/** Moves focus to an in-page target; returns false when there is none, so the browser follows the link. */\nfunction focusTarget(link: HTMLAnchorElement, href: string): boolean {\n if (!href.startsWith(\"#\") || href.length < 2) return false;\n let id = href.slice(1);\n try {\n id = decodeURIComponent(id);\n } catch {\n // Not percent-encoded: use it as written.\n }\n // Look in the link's own shadow root first, where a hash link cannot reach.\n const root = link.getRootNode() as Document | ShadowRoot;\n const target = root.getElementById?.(id) ?? document.getElementById(id);\n if (!target) return false;\n // Not focusable on its own (a `main` or a `div`): focusable from script only, so Tab order does not change.\n if (target.tabIndex < 0 && !target.hasAttribute(\"tabindex\")) target.setAttribute(\"tabindex\", \"-1\");\n target.focus();\n return true;\n}\n\n/**\n * \"Skip to content\": the first stop of the Tab order, hidden until it has focus and then shown at the top-start corner\n * of the window as a Button. It is a real link, so it works before or without JavaScript; with it, focus also moves to\n * the target.\n */\nexport const SkipLink = forwardRef<HTMLAnchorElement, SkipLinkProps>(function SkipLink(\n { href = \"#main\", labels, id, contained = false, className, style },\n ref,\n) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const onClick = (event: MouseEvent<HTMLElement>) => {\n // Focus moves without touching the URL (a client-side router may own it).\n if (focusTarget(event.currentTarget as HTMLAnchorElement, href)) event.preventDefault();\n };\n return (\n <Button\n href={href}\n linkRef={ref}\n id={id}\n variant=\"outline\"\n tone=\"accent\"\n onClick={onClick}\n // Hidden from sight (.cy-visually-hidden) until it has focus; skip-link.css shows it then, without script.\n className={[\n \"cy-skip-link cy-visually-hidden\",\n contained ? \"cy-skip-link-contained\" : undefined,\n className,\n ]\n .filter(Boolean)\n .join(\" \")}\n {...(style ? { style } : {})}\n >\n {text.skip}\n </Button>\n );\n});\n"],"mappings":";;;;AA0CA,IAAMG,IAAiC,EAAE,MAAM,kBAAkB;AAGjE,SAASC,EAAYC,GAAyBC,GAAuB;AACnE,MAAI,CAACA,EAAK,WAAW,GAAG,KAAKA,EAAK,SAAS,EAAG,QAAO;AACrD,MAAIC,IAAKD,EAAK,MAAM,CAAC;AACrB,MAAI;AACF,IAAAC,IAAK,mBAAmBA,CAAE;AAAA,EAC5B,QAAQ;AAAA,EAER;AAGA,QAAMC,IADOH,EAAK,YACH,EAAK,iBAAiBE,CAAE,KAAK,SAAS,eAAeA,CAAE;AACtE,SAAKC,KAEDA,EAAO,WAAW,KAAK,CAACA,EAAO,aAAa,UAAU,KAAGA,EAAO,aAAa,YAAY,IAAI,GACjGA,EAAO,MAAM,GACN,MAJa;AAKtB;AAOA,IAAaC,IAAWR,EAA6C,SACnE,EAAE,MAAAK,IAAO,SAAS,QAAAI,GAAQ,IAAAH,GAAI,WAAAI,IAAY,IAAO,WAAAC,GAAW,OAAAC,EAAA,GAC5DC,GACA;AACA,QAAMC,IAAO;AAAA,IAAE,GAAGZ;AAAA,IAAgB,GAAGO;AAAA,EAAO;AAK5C,SACE,gBAAAR,EAACF,GAAD;AAAA,IACQ,MAAAM;AAAA,IACN,SAASQ;AAAA,IACL,IAAAP;AAAA,IACJ,SAAQ;AAAA,IACR,MAAK;AAAA,IACI,SAXP,CAAWS,MAAmC;AAElD,MAAIZ,EAAYY,EAAM,eAAoCV,CAAI,KAAGU,EAAM,eAAe;AAAA,IACxF;AAAA,IAUI,WAAW;AAAA,MACT;AAAA,MACAL,IAAY,2BAA2B;AAAA,MACvCC;AAAA,IACF,EACG,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,IACX,GAAKC,IAAQ,EAAE,OAAAA,EAAM,IAAI,CAAC;AAAA,IAEzB,UAAAE,EAAK;AAAA,EACA,CAAA;AAEZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SkipLink, type SkipLinkLabels, type SkipLinkProps, type SkipLinkTokens } from "./SkipLink.js";
|
|
@@ -15,14 +15,14 @@ var oe = {
|
|
|
15
15
|
dropped: (i, a, d) => `${i} dropped at position ${a} of ${d}.`,
|
|
16
16
|
cancelled: (i) => `Move cancelled. ${i} is back where it was.`
|
|
17
17
|
}, R = (i, a, d) => {
|
|
18
|
-
const
|
|
19
|
-
return
|
|
18
|
+
const b = [...i], [y] = b.splice(a, 1);
|
|
19
|
+
return b.splice(d, 0, y), b;
|
|
20
20
|
};
|
|
21
|
-
function me({ label: i, items: a, defaultItems: d = [], onReorder:
|
|
21
|
+
function me({ label: i, items: a, defaultItems: d = [], onReorder: b, disabled: y = !1, layout: g = "list", size: U = "md", labels: F, className: A, style: B }) {
|
|
22
22
|
const u = {
|
|
23
23
|
...oe,
|
|
24
24
|
...F
|
|
25
|
-
}, M = ne(), [m, T] = W(a, d,
|
|
25
|
+
}, M = ne(), [m, T] = W(a, d, b), [j, q] = N(null), [D, z] = N(null), E = k(null), f = k(null), x = (e) => {
|
|
26
26
|
E.current = e, q(e);
|
|
27
27
|
}, v = (e) => {
|
|
28
28
|
f.current = e, z(e);
|
|
@@ -40,7 +40,7 @@ function me({ label: i, items: a, defaultItems: d = [], onReorder: h, disabled:
|
|
|
40
40
|
}, G = () => {
|
|
41
41
|
const e = [...S.current.children], t = e[0]?.offsetTop, o = e.findIndex((c) => c.offsetTop !== t);
|
|
42
42
|
return o < 0 ? e.length : o;
|
|
43
|
-
},
|
|
43
|
+
}, h = (e) => {
|
|
44
44
|
const t = f.current, o = E.current, c = o.findIndex((n) => n.id === t.id), r = Math.min(Math.max(c + e, 0), o.length - 1);
|
|
45
45
|
r !== c && (x(R(o, c, r)), p(u.moved(o[c].label, r + 1, o.length)), requestAnimationFrame(() => H(t.id)?.focus()));
|
|
46
46
|
}, J = (e) => (t) => {
|
|
@@ -51,14 +51,14 @@ function me({ label: i, items: a, defaultItems: d = [], onReorder: h, disabled:
|
|
|
51
51
|
}
|
|
52
52
|
if (!c) return;
|
|
53
53
|
const r = Y(t.currentTarget) ? -1 : 1, n = g === "grid" ? G() : 1, s = {
|
|
54
|
-
ArrowUp: () =>
|
|
55
|
-
ArrowDown: () =>
|
|
54
|
+
ArrowUp: () => h(-n),
|
|
55
|
+
ArrowDown: () => h(n),
|
|
56
56
|
...g === "grid" ? {
|
|
57
|
-
ArrowLeft: () =>
|
|
58
|
-
ArrowRight: () =>
|
|
57
|
+
ArrowLeft: () => h(-r),
|
|
58
|
+
ArrowRight: () => h(r)
|
|
59
59
|
} : {},
|
|
60
|
-
Home: () =>
|
|
61
|
-
End: () =>
|
|
60
|
+
Home: () => h(-P),
|
|
61
|
+
End: () => h(P),
|
|
62
62
|
Escape: _,
|
|
63
63
|
Tab: C
|
|
64
64
|
}[t.key];
|
|
@@ -144,11 +144,11 @@ function me({ label: i, items: a, defaultItems: d = [], onReorder: h, disabled:
|
|
|
144
144
|
}),
|
|
145
145
|
/* @__PURE__ */ w("span", {
|
|
146
146
|
id: `${M}-how`,
|
|
147
|
-
className: "cy-
|
|
147
|
+
className: "cy-reset cy-visually-hidden",
|
|
148
148
|
children: u.instructions
|
|
149
149
|
}),
|
|
150
150
|
/* @__PURE__ */ w("span", {
|
|
151
|
-
className: "cy-
|
|
151
|
+
className: "cy-reset cy-visually-hidden",
|
|
152
152
|
role: "status",
|
|
153
153
|
children: K
|
|
154
154
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SortableList.js","names":["sortable","useControllableState","useClientLayoutEffect","isRtl","IconButton","vt","grip","useId","useRef","useState","jsx","jsxs","DEFAULT_LABELS","label","p","n","moveItem","list","from","to","next","item","SortableList","items","defaultItems","onReorder","disabled","layout","size","labels","className","style","text","id","committed","setCommitted","preview","setPreviewState","moving","setMovingState","previewRef","movingRef","setPreview","setMoving","said","setSaid","shown","total","handleOf","itemId","start","drop","i","at","changed","cancel","columns","tiles","top","t","shift","delta","onKeyDown","event","active","across","row","move","latest","el","sorted","itemOf","node","bound","reduced","base","now","words","cancelled"],"sources":["../../../src/components/SortableList/SortableList.tsx"],"sourcesContent":["import { sortable } from \"@arshad-shah/detent\";\nimport { type CSSProperties, type KeyboardEvent, type ReactNode, useId, useRef, useState } from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { isRtl } from \"../../foundations/dir.js\";\nimport { grip } from \"../../icons/grip.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\n\nexport interface SortableListTokens {\n /** Background of a row. */\n itemBackground: string;\n /** Corner radius of a row. */\n radius: string;\n /** Smallest tile width in the grid layout. */\n tileMin: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n sortableList: SortableListTokens;\n }\n}\n\nexport interface SortableItem {\n id: string;\n /** Plain text: used in announcements and the handle's name. Shown when there is no `content`. */\n label: string;\n /** What the row shows, if more than the label. */\n content?: ReactNode;\n}\n\nexport interface SortableListLabels {\n /** Handle name. Default: \"Move Docs\". */\n handle: (label: string) => string;\n /** Read with every handle. */\n instructions: string;\n pickedUp: (label: string, position: number, total: number) => string;\n moved: (label: string, position: number, total: number) => string;\n dropped: (label: string, position: number, total: number) => string;\n cancelled: (label: string) => string;\n}\n\nexport interface SortableListProps {\n /** Accessible name of the list. */\n label: string;\n /** Controlled items, in order: `{ id, label, content? }`. */\n items?: SortableItem[] | undefined;\n /** Starting items when uncontrolled. */\n defaultItems?: SortableItem[];\n /** Called with the items in their new order after a move is dropped. */\n onReorder?: ((items: SortableItem[]) => void) | undefined;\n /** Disables the handles, so nothing can be moved. */\n disabled?: boolean;\n /** `list` (rows, default) or `grid` (tiles that wrap: file grids, page thumbnails). */\n layout?: \"list\" | \"grid\";\n /** Text size of the rows. Default \"md\". */\n size?: Size;\n /** Replace the built-in English text: the handle name, the instructions and the announcements. */\n labels?: Partial<SortableListLabels>;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-sortable-list-* tokens. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: SortableListLabels = {\n handle: (label) => `Move ${label}`,\n instructions: \"Press Space to pick up, the arrow keys to move, Space to drop, Escape to cancel.\",\n pickedUp: (label, p, n) => `${label} picked up. Position ${p} of ${n}.`,\n moved: (label, p, n) => `${label} moved to position ${p} of ${n}.`,\n dropped: (label, p, n) => `${label} dropped at position ${p} of ${n}.`,\n cancelled: (label) => `Move cancelled. ${label} is back where it was.`,\n};\n\nconst moveItem = <T,>(list: T[], from: number, to: number) => {\n const next = [...list];\n const [item] = next.splice(from, 1);\n next.splice(to, 0, item as T);\n return next;\n};\n\n/**\n * A list people put in order: drag a row by its handle (mouse, pen or touch), or focus the handle, press Space and\n * move it with the arrow keys. Every step is announced.\n */\nexport function SortableList({\n label,\n items,\n defaultItems = [],\n onReorder,\n disabled = false,\n layout = \"list\",\n size = \"md\",\n labels,\n className,\n style,\n}: SortableListProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const id = useId();\n const [committed, setCommitted] = useControllableState(items, defaultItems, onReorder);\n /**\n * While moving: the order being previewed, and the row being moved. Kept in refs too, so events that arrive before\n * React re-renders (a fast drag's move and release) always see the latest values.\n */\n type Moving = { id: string; by: \"keyboard\" | \"pointer\" };\n const [preview, setPreviewState] = useState<SortableItem[] | null>(null);\n const [moving, setMovingState] = useState<Moving | null>(null);\n const previewRef = useRef<SortableItem[] | null>(null);\n const movingRef = useRef<Moving | null>(null);\n const setPreview = (next: SortableItem[] | null) => {\n previewRef.current = next;\n setPreviewState(next);\n };\n const setMoving = (next: Moving | null) => {\n movingRef.current = next;\n setMovingState(next);\n };\n const [said, setSaid] = useState(\"\");\n const list = useRef<HTMLUListElement>(null);\n const shown = preview ?? committed;\n const total = shown.length;\n\n const handleOf = (itemId: string) =>\n list.current?.querySelector<HTMLButtonElement>(\n `[data-id=\"${CSS.escape(itemId)}\"] .cy-sortable-list-handle`,\n );\n\n const start = (item: SortableItem) => {\n setPreview(committed);\n setMoving({ id: item.id, by: \"keyboard\" });\n setSaid(text.pickedUp(item.label, committed.indexOf(item) + 1, committed.length));\n };\n // drop, cancel and shift run only while a row is moving (their callers check), so the refs are set.\n const drop = () => {\n const moving = movingRef.current as Moving;\n const preview = previewRef.current as SortableItem[];\n const item = preview.find((i) => i.id === moving.id) as SortableItem;\n const at = preview.indexOf(item);\n const changed = preview.some((i, n) => i.id !== committed[n]?.id);\n setSaid(text.dropped(item.label, at + 1, preview.length));\n if (changed) {\n setCommitted(preview);\n }\n setPreview(null);\n setMoving(null);\n };\n const cancel = () => {\n const moving = movingRef.current as Moving;\n const item = committed.find((i) => i.id === moving.id) as SortableItem;\n setSaid(text.cancelled(item.label));\n setPreview(null);\n setMoving(null);\n };\n /** Tiles in one row of the grid, measured from the layout (1 for a list). */\n const columns = () => {\n const tiles = [...(list.current as HTMLUListElement).children] as HTMLElement[];\n const top = tiles[0]?.offsetTop;\n const n = tiles.findIndex((t) => t.offsetTop !== top);\n return n < 0 ? tiles.length : n;\n };\n const shift = (delta: number) => {\n const moving = movingRef.current as Moving;\n const preview = previewRef.current as SortableItem[];\n const from = preview.findIndex((i) => i.id === moving.id);\n const to = Math.min(Math.max(from + delta, 0), preview.length - 1);\n if (to === from) return;\n setPreview(moveItem(preview, from, to));\n setSaid(text.moved((preview[from] as SortableItem).label, to + 1, preview.length));\n // The moved row's handle keeps focus as it changes place.\n requestAnimationFrame(() => handleOf(moving.id)?.focus());\n };\n\n // A disabled handle cannot be focused, so it never gets key presses.\n const onKeyDown = (item: SortableItem) => (event: KeyboardEvent<HTMLButtonElement>) => {\n const moving = movingRef.current;\n const active = moving?.id === item.id && moving.by === \"keyboard\";\n if (event.key === \" \" || event.key === \"Enter\") {\n event.preventDefault();\n if (active) drop();\n else if (!moving) start(item);\n return;\n }\n if (!active) return;\n // In a grid, Left and Right move one place (following the reading direction) and Up and Down a whole row.\n const across = isRtl(event.currentTarget) ? -1 : 1;\n const row = layout === \"grid\" ? columns() : 1;\n const moves: Record<string, () => void> = {\n ArrowUp: () => shift(-row),\n ArrowDown: () => shift(row),\n ...(layout === \"grid\" ? { ArrowLeft: () => shift(-across), ArrowRight: () => shift(across) } : {}),\n Home: () => shift(-total),\n End: () => shift(total),\n Escape: cancel,\n Tab: drop,\n };\n const move = moves[event.key];\n if (!move) return;\n if (event.key !== \"Tab\") event.preventDefault();\n move();\n };\n\n // Pointer, touch and pen dragging come from detent (one input path, FLIP animation, auto-scroll). Its own keyboard\n // mode stays off: Cynosure's keyboard mode above has labelled, overridable announcements inside the app.\n const latest = useRef({ committed, text, disabled });\n latest.current = { committed, text, disabled };\n useClientLayoutEffect(() => {\n const el = list.current as HTMLUListElement;\n let sorted = false;\n const itemOf = (node: HTMLElement) =>\n latest.current.committed.find((i) => i.id === node.dataset.id) as SortableItem;\n const bound = sortable(el, {\n handle: \".cy-sortable-list-handle\",\n direction: layout === \"grid\" ? \"grid\" : \"y\",\n keyboard: false,\n // The grip is a dedicated handle that never scrolls the page, so touch needs no press-and-hold.\n delay: 0,\n get animation() {\n const reduced = globalThis.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches;\n const base = Number.parseFloat(getComputedStyle(el).getPropertyValue(\"--cy-motion-slow\"));\n return reduced ? 0 : Number.isFinite(base) ? base : 180;\n },\n get disabled() {\n return latest.current.disabled;\n },\n onStart: (node, from) => {\n if (movingRef.current) return false;\n const item = itemOf(node);\n sorted = false;\n setMoving({ id: item.id, by: \"pointer\" });\n setSaid(latest.current.text.pickedUp(item.label, from.index + 1, latest.current.committed.length));\n },\n onSort: ({ item: node, from, to }) => {\n sorted = true;\n // Put the node back where React rendered it, then let React apply the new order: React stays the DOM's owner.\n node.remove();\n el.insertBefore(node, el.children[from.index] ?? null);\n const { committed: now, text: words } = latest.current;\n const next = moveItem(now, from.index, to.index);\n setSaid(words.dropped((now[from.index] as SortableItem).label, to.index + 1, next.length));\n setCommitted(next);\n },\n onEnd: (node, cancelled) => {\n const item = itemOf(node);\n setMoving(null);\n if (cancelled) setSaid(latest.current.text.cancelled(item.label));\n else if (!sorted) {\n const at = latest.current.committed.indexOf(item);\n setSaid(latest.current.text.dropped(item.label, at + 1, latest.current.committed.length));\n }\n },\n });\n return () => bound.destroy();\n }, [layout]);\n\n return (\n <div\n className={className ? `cy-sortable-list ${className}` : \"cy-sortable-list\"}\n data-size={size}\n data-layout={layout}\n style={style}\n >\n <ul ref={list} className=\"cy-sortable-list-items cy-reset\" aria-label={label}>\n {shown.map((item) => (\n <li\n key={item.id}\n data-id={item.id}\n className=\"cy-sortable-list-item cy-reset\"\n data-moving={moving?.id === item.id ? \"\" : undefined}\n >\n <IconButton\n icon={grip}\n label={text.handle(item.label)}\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n disabled={disabled}\n className=\"cy-sortable-list-handle\"\n aria-describedby={`${id}-how`}\n aria-pressed={moving?.id === item.id}\n tooltipPlacement=\"start\"\n onKeyDown={onKeyDown(item)}\n />\n <div className=\"cy-sortable-list-content cy-reset\">{item.content ?? item.label}</div>\n </li>\n ))}\n </ul>\n <span id={`${id}-how`} className=\"cy-sortable-list-hidden cy-reset\">\n {text.instructions}\n </span>\n <span className=\"cy-sortable-list-hidden cy-reset\" role=\"status\">\n {said}\n </span>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAkEA,IAAMY,KAAqC;AAAA,EACzC,QAAA,CAASC,MAAU,QAAQA,CAAA;AAAA,EAC3B,cAAc;AAAA,EACd,UAAA,CAAWA,GAAOC,GAAGC,MAAM,GAAGF,CAAA,wBAA6BC,CAAA,OAAQC,CAAA;AAAA,EACnE,OAAA,CAAQF,GAAOC,GAAGC,MAAM,GAAGF,CAAA,sBAA2BC,CAAA,OAAQC,CAAA;AAAA,EAC9D,SAAA,CAAUF,GAAOC,GAAGC,MAAM,GAAGF,CAAA,wBAA6BC,CAAA,OAAQC,CAAA;AAAA,EAClE,WAAA,CAAYF,MAAU,mBAAmBA,CAAA;AAC3C,GAEMG,IAAA,CAAgBC,GAAWC,GAAcC,MAAe;AAC5D,QAAMC,IAAO,CAAC,GAAGH,CAAI,GACf,CAACI,CAAA,IAAQD,EAAK,OAAOF,GAAM,CAAC;AAClC,SAAAE,EAAK,OAAOD,GAAI,GAAGE,CAAS,GACrBD;AACT;AAMA,SAAgBE,GAAa,EAC3B,OAAAT,GACA,OAAAU,GACA,cAAAC,IAAe,CAAC,GAChB,WAAAC,GACA,UAAAC,IAAW,IACX,QAAAC,IAAS,QACT,MAAAC,IAAO,MACP,QAAAC,GACA,WAAAC,GACA,OAAAC,EAAA,GACoB;AACpB,QAAMC,IAAO;AAAA,IAAE,GAAGpB;AAAA,IAAgB,GAAGiB;AAAA,EAAO,GACtCI,IAAK1B,GAAM,GACX,CAAC2B,GAAWC,CAAA,IAAgBlC,EAAqBsB,GAAOC,GAAc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A,IACH;AAAA,E;AAET"}
|
|
1
|
+
{"version":3,"file":"SortableList.js","names":["sortable","useControllableState","useClientLayoutEffect","isRtl","IconButton","vt","grip","useId","useRef","useState","jsx","jsxs","DEFAULT_LABELS","label","p","n","moveItem","list","from","to","next","item","SortableList","items","defaultItems","onReorder","disabled","layout","size","labels","className","style","text","id","committed","setCommitted","preview","setPreviewState","moving","setMovingState","previewRef","movingRef","setPreview","setMoving","said","setSaid","shown","total","handleOf","itemId","start","drop","i","at","changed","cancel","columns","tiles","top","t","shift","delta","onKeyDown","event","active","across","row","move","latest","el","sorted","itemOf","node","bound","reduced","base","now","words","cancelled"],"sources":["../../../src/components/SortableList/SortableList.tsx"],"sourcesContent":["import { sortable } from \"@arshad-shah/detent\";\nimport { type CSSProperties, type KeyboardEvent, type ReactNode, useId, useRef, useState } from \"react\";\nimport { useClientLayoutEffect } from \"../../foundations/client-layout-effect.js\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { isRtl } from \"../../foundations/dir.js\";\nimport { grip } from \"../../icons/grip.js\";\nimport type { Size } from \"../../tokens/schema.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\n\nexport interface SortableListTokens {\n /** Background of a row. */\n itemBackground: string;\n /** Corner radius of a row. */\n radius: string;\n /** Smallest tile width in the grid layout. */\n tileMin: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n sortableList: SortableListTokens;\n }\n}\n\nexport interface SortableItem {\n id: string;\n /** Plain text: used in announcements and the handle's name. Shown when there is no `content`. */\n label: string;\n /** What the row shows, if more than the label. */\n content?: ReactNode;\n}\n\nexport interface SortableListLabels {\n /** Handle name. Default: \"Move Docs\". */\n handle: (label: string) => string;\n /** Read with every handle. */\n instructions: string;\n pickedUp: (label: string, position: number, total: number) => string;\n moved: (label: string, position: number, total: number) => string;\n dropped: (label: string, position: number, total: number) => string;\n cancelled: (label: string) => string;\n}\n\nexport interface SortableListProps {\n /** Accessible name of the list. */\n label: string;\n /** Controlled items, in order: `{ id, label, content? }`. */\n items?: SortableItem[] | undefined;\n /** Starting items when uncontrolled. */\n defaultItems?: SortableItem[];\n /** Called with the items in their new order after a move is dropped. */\n onReorder?: ((items: SortableItem[]) => void) | undefined;\n /** Disables the handles, so nothing can be moved. */\n disabled?: boolean;\n /** `list` (rows, default) or `grid` (tiles that wrap: file grids, page thumbnails). */\n layout?: \"list\" | \"grid\";\n /** Text size of the rows. Default \"md\". */\n size?: Size;\n /** Replace the built-in English text: the handle name, the instructions and the announcements. */\n labels?: Partial<SortableListLabels>;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-sortable-list-* tokens. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: SortableListLabels = {\n handle: (label) => `Move ${label}`,\n instructions: \"Press Space to pick up, the arrow keys to move, Space to drop, Escape to cancel.\",\n pickedUp: (label, p, n) => `${label} picked up. Position ${p} of ${n}.`,\n moved: (label, p, n) => `${label} moved to position ${p} of ${n}.`,\n dropped: (label, p, n) => `${label} dropped at position ${p} of ${n}.`,\n cancelled: (label) => `Move cancelled. ${label} is back where it was.`,\n};\n\nconst moveItem = <T,>(list: T[], from: number, to: number) => {\n const next = [...list];\n const [item] = next.splice(from, 1);\n next.splice(to, 0, item as T);\n return next;\n};\n\n/**\n * A list people put in order: drag a row by its handle (mouse, pen or touch), or focus the handle, press Space and\n * move it with the arrow keys. Every step is announced.\n */\nexport function SortableList({\n label,\n items,\n defaultItems = [],\n onReorder,\n disabled = false,\n layout = \"list\",\n size = \"md\",\n labels,\n className,\n style,\n}: SortableListProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const id = useId();\n const [committed, setCommitted] = useControllableState(items, defaultItems, onReorder);\n /**\n * While moving: the order being previewed, and the row being moved. Kept in refs too, so events that arrive before\n * React re-renders (a fast drag's move and release) always see the latest values.\n */\n type Moving = { id: string; by: \"keyboard\" | \"pointer\" };\n const [preview, setPreviewState] = useState<SortableItem[] | null>(null);\n const [moving, setMovingState] = useState<Moving | null>(null);\n const previewRef = useRef<SortableItem[] | null>(null);\n const movingRef = useRef<Moving | null>(null);\n const setPreview = (next: SortableItem[] | null) => {\n previewRef.current = next;\n setPreviewState(next);\n };\n const setMoving = (next: Moving | null) => {\n movingRef.current = next;\n setMovingState(next);\n };\n const [said, setSaid] = useState(\"\");\n const list = useRef<HTMLUListElement>(null);\n const shown = preview ?? committed;\n const total = shown.length;\n\n const handleOf = (itemId: string) =>\n list.current?.querySelector<HTMLButtonElement>(\n `[data-id=\"${CSS.escape(itemId)}\"] .cy-sortable-list-handle`,\n );\n\n const start = (item: SortableItem) => {\n setPreview(committed);\n setMoving({ id: item.id, by: \"keyboard\" });\n setSaid(text.pickedUp(item.label, committed.indexOf(item) + 1, committed.length));\n };\n // drop, cancel and shift run only while a row is moving (their callers check), so the refs are set.\n const drop = () => {\n const moving = movingRef.current as Moving;\n const preview = previewRef.current as SortableItem[];\n const item = preview.find((i) => i.id === moving.id) as SortableItem;\n const at = preview.indexOf(item);\n const changed = preview.some((i, n) => i.id !== committed[n]?.id);\n setSaid(text.dropped(item.label, at + 1, preview.length));\n if (changed) {\n setCommitted(preview);\n }\n setPreview(null);\n setMoving(null);\n };\n const cancel = () => {\n const moving = movingRef.current as Moving;\n const item = committed.find((i) => i.id === moving.id) as SortableItem;\n setSaid(text.cancelled(item.label));\n setPreview(null);\n setMoving(null);\n };\n /** Tiles in one row of the grid, measured from the layout (1 for a list). */\n const columns = () => {\n const tiles = [...(list.current as HTMLUListElement).children] as HTMLElement[];\n const top = tiles[0]?.offsetTop;\n const n = tiles.findIndex((t) => t.offsetTop !== top);\n return n < 0 ? tiles.length : n;\n };\n const shift = (delta: number) => {\n const moving = movingRef.current as Moving;\n const preview = previewRef.current as SortableItem[];\n const from = preview.findIndex((i) => i.id === moving.id);\n const to = Math.min(Math.max(from + delta, 0), preview.length - 1);\n if (to === from) return;\n setPreview(moveItem(preview, from, to));\n setSaid(text.moved((preview[from] as SortableItem).label, to + 1, preview.length));\n // The moved row's handle keeps focus as it changes place.\n requestAnimationFrame(() => handleOf(moving.id)?.focus());\n };\n\n // A disabled handle cannot be focused, so it never gets key presses.\n const onKeyDown = (item: SortableItem) => (event: KeyboardEvent<HTMLButtonElement>) => {\n const moving = movingRef.current;\n const active = moving?.id === item.id && moving.by === \"keyboard\";\n if (event.key === \" \" || event.key === \"Enter\") {\n event.preventDefault();\n if (active) drop();\n else if (!moving) start(item);\n return;\n }\n if (!active) return;\n // In a grid, Left and Right move one place (following the reading direction) and Up and Down a whole row.\n const across = isRtl(event.currentTarget) ? -1 : 1;\n const row = layout === \"grid\" ? columns() : 1;\n const moves: Record<string, () => void> = {\n ArrowUp: () => shift(-row),\n ArrowDown: () => shift(row),\n ...(layout === \"grid\" ? { ArrowLeft: () => shift(-across), ArrowRight: () => shift(across) } : {}),\n Home: () => shift(-total),\n End: () => shift(total),\n Escape: cancel,\n Tab: drop,\n };\n const move = moves[event.key];\n if (!move) return;\n if (event.key !== \"Tab\") event.preventDefault();\n move();\n };\n\n // Pointer, touch and pen dragging come from detent (one input path, FLIP animation, auto-scroll). Its own keyboard\n // mode stays off: Cynosure's keyboard mode above has labelled, overridable announcements inside the app.\n const latest = useRef({ committed, text, disabled });\n latest.current = { committed, text, disabled };\n useClientLayoutEffect(() => {\n const el = list.current as HTMLUListElement;\n let sorted = false;\n const itemOf = (node: HTMLElement) =>\n latest.current.committed.find((i) => i.id === node.dataset.id) as SortableItem;\n const bound = sortable(el, {\n handle: \".cy-sortable-list-handle\",\n direction: layout === \"grid\" ? \"grid\" : \"y\",\n keyboard: false,\n // The grip is a dedicated handle that never scrolls the page, so touch needs no press-and-hold.\n delay: 0,\n get animation() {\n const reduced = globalThis.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches;\n const base = Number.parseFloat(getComputedStyle(el).getPropertyValue(\"--cy-motion-slow\"));\n return reduced ? 0 : Number.isFinite(base) ? base : 180;\n },\n get disabled() {\n return latest.current.disabled;\n },\n onStart: (node, from) => {\n if (movingRef.current) return false;\n const item = itemOf(node);\n sorted = false;\n setMoving({ id: item.id, by: \"pointer\" });\n setSaid(latest.current.text.pickedUp(item.label, from.index + 1, latest.current.committed.length));\n },\n onSort: ({ item: node, from, to }) => {\n sorted = true;\n // Put the node back where React rendered it, then let React apply the new order: React stays the DOM's owner.\n node.remove();\n el.insertBefore(node, el.children[from.index] ?? null);\n const { committed: now, text: words } = latest.current;\n const next = moveItem(now, from.index, to.index);\n setSaid(words.dropped((now[from.index] as SortableItem).label, to.index + 1, next.length));\n setCommitted(next);\n },\n onEnd: (node, cancelled) => {\n const item = itemOf(node);\n setMoving(null);\n if (cancelled) setSaid(latest.current.text.cancelled(item.label));\n else if (!sorted) {\n const at = latest.current.committed.indexOf(item);\n setSaid(latest.current.text.dropped(item.label, at + 1, latest.current.committed.length));\n }\n },\n });\n return () => bound.destroy();\n }, [layout]);\n\n return (\n <div\n className={className ? `cy-sortable-list ${className}` : \"cy-sortable-list\"}\n data-size={size}\n data-layout={layout}\n style={style}\n >\n <ul ref={list} className=\"cy-sortable-list-items cy-reset\" aria-label={label}>\n {shown.map((item) => (\n <li\n key={item.id}\n data-id={item.id}\n className=\"cy-sortable-list-item cy-reset\"\n data-moving={moving?.id === item.id ? \"\" : undefined}\n >\n <IconButton\n icon={grip}\n label={text.handle(item.label)}\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n disabled={disabled}\n className=\"cy-sortable-list-handle\"\n aria-describedby={`${id}-how`}\n aria-pressed={moving?.id === item.id}\n tooltipPlacement=\"start\"\n onKeyDown={onKeyDown(item)}\n />\n <div className=\"cy-sortable-list-content cy-reset\">{item.content ?? item.label}</div>\n </li>\n ))}\n </ul>\n <span id={`${id}-how`} className=\"cy-reset cy-visually-hidden\">\n {text.instructions}\n </span>\n <span className=\"cy-reset cy-visually-hidden\" role=\"status\">\n {said}\n </span>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAkEA,IAAMY,KAAqC;AAAA,EACzC,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pE,UAAAiC,EAAM,IAAA,CAAKzB,MACV,gBAAAV,EAAC,MAAD;AAAA,UAEE,WAASU,EAAK;AAAA,UACd,WAAU;AAAA,UACV,eAAaiB,GAAQ,OAAOjB,EAAK,KAAK,KAAK;AAAA,UAJ7C,UAAA,CAME,gBAAAX,EAACN,GAAD;AAAA,YACE,MAAME;AAAA,YACN,OAAO0B,EAAK,OAAOX,EAAK,KAAK;AAAA,YAC7B,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,MAAK;AAAA,YACK,UAAAK;AAAA,YACV,WAAU;AAAA,YACV,oBAAkB,GAAGO,CAAA;AAAA,YACrB,gBAAcK,GAAQ,OAAOjB,EAAK;AAAA,YAClC,kBAAiB;AAAA,YACjB,WAAWyC,EAAUzC,CAAI;AAAA,UAC1B,CAAA,GACD,gBAAAX,EAAC,OAAD;AAAA,YAAK,WAAU;AAAA,YAAqC,UAAAW,EAAK,WAAWA,EAAK;AAAA,UAAW,CAAA,CAClF;AAAA,QAnBG,GAAAA,EAAK,EAmBR,CACL;AAAA,MACC,CAAA;AAAA,MACJ,gBAAAX,EAAC,QAAD;AAAA,QAAM,IAAI,GAAGuB,CAAA;AAAA,QAAU,WAAU;AAAA,QAC9B,UAAAD,EAAK;AAAA,MACF,CAAA;AAAA,MACN,gBAAAtB,EAAC,QAAD;AAAA,QAAM,WAAU;AAAA,QAA8B,MAAK;AAAA,QAChD,UAAAkC;AAAA,MACG,CAAA;AAAA,IACH;AAAA,E;AAET"}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from "react";
|
|
2
|
-
import { type PaddingProps, type Space } from "./space.js";
|
|
3
|
-
export interface StackProps extends PaddingProps {
|
|
2
|
+
import { type LayoutAttributes, type PaddingProps, type Space, type VisibilityProps } from "./space.js";
|
|
3
|
+
export interface StackProps extends PaddingProps, VisibilityProps, LayoutAttributes {
|
|
4
4
|
/** Space token between children. */
|
|
5
5
|
gap?: Space;
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
/** How children
|
|
9
|
-
|
|
6
|
+
/** Lay the children out in a column (the default) or in a row. For a row, Inline adds wrapping and centring. */
|
|
7
|
+
direction?: "column" | "row" | undefined;
|
|
8
|
+
/** How children line up across the stack (horizontally in a column); `baseline` lines up text in a row. */
|
|
9
|
+
align?: "start" | "center" | "end" | "stretch" | "baseline" | undefined;
|
|
10
|
+
/** How children are spread along the stack (vertically in a column); `between` pushes them apart. */
|
|
11
|
+
justify?: "start" | "center" | "end" | "between" | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Stay in view while the page scrolls past (`position: sticky`), inside its parent. In a Grid, make the GridItem
|
|
14
|
+
* sticky instead, or give the Grid `align="start"`: a box stretched to its row has nowhere to move.
|
|
15
|
+
*/
|
|
16
|
+
sticky?: boolean | undefined;
|
|
17
|
+
/** With `sticky`: any CSS length between the top of the scrolling area and the box, e.g. a header's height. Default 0. */
|
|
18
|
+
stickyOffset?: string | undefined;
|
|
10
19
|
/** Neutral layout element to render (never an interactive one). */
|
|
11
20
|
as?: "div" | "section" | "ul" | "ol" | "nav" | "aside" | "header" | "footer" | "span";
|
|
12
21
|
/** Added to the root element, for layout. */
|
|
@@ -18,5 +27,5 @@ export interface StackProps extends PaddingProps {
|
|
|
18
27
|
/** Passed to the root element, for tests. */
|
|
19
28
|
"data-testid"?: string;
|
|
20
29
|
}
|
|
21
|
-
/** Vertical layout with token gaps. */
|
|
30
|
+
/** Vertical layout with token gaps (or a row, with `direction="row"`). */
|
|
22
31
|
export declare const Stack: import("react").ForwardRefExoticComponent<StackProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -1,28 +1,35 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { paddingVars as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { jsx as
|
|
5
|
-
var
|
|
6
|
-
return /* @__PURE__ */
|
|
7
|
-
ref:
|
|
8
|
-
...
|
|
9
|
-
className: `cy-stack${
|
|
10
|
-
"data-
|
|
11
|
-
"data-
|
|
2
|
+
import { paddingVars as g, space as k, visibilityAttrs as w } from "./space.js";
|
|
3
|
+
import { forwardRef as j } from "react";
|
|
4
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
5
|
+
var A = j(function({ gap: r = "4", direction: o = "column", padding: d, paddingInline: c, paddingBlock: n, align: p, justify: s, sticky: t, stickyOffset: a, hideBelow: e, hideAbove: m, as: f = "div", className: i, style: l, children: u, ...v }, y) {
|
|
6
|
+
return /* @__PURE__ */ x(f, {
|
|
7
|
+
ref: y,
|
|
8
|
+
...v,
|
|
9
|
+
className: `cy-stack${i ? ` ${i}` : ""}`,
|
|
10
|
+
"data-direction": o === "row" ? "row" : void 0,
|
|
11
|
+
"data-align": p,
|
|
12
|
+
"data-justify": s,
|
|
13
|
+
"data-sticky": t ? "" : void 0,
|
|
14
|
+
...w({
|
|
15
|
+
hideBelow: e,
|
|
16
|
+
hideAbove: m
|
|
17
|
+
}),
|
|
12
18
|
style: {
|
|
13
|
-
"--_gap":
|
|
14
|
-
...
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
"--_gap": k(r),
|
|
20
|
+
...t && a ? { "--_sticky-top": a } : {},
|
|
21
|
+
...g({
|
|
22
|
+
padding: d,
|
|
23
|
+
paddingInline: c,
|
|
24
|
+
paddingBlock: n
|
|
18
25
|
}),
|
|
19
|
-
...
|
|
26
|
+
...l
|
|
20
27
|
},
|
|
21
|
-
children:
|
|
28
|
+
children: u
|
|
22
29
|
});
|
|
23
30
|
});
|
|
24
31
|
export {
|
|
25
|
-
|
|
32
|
+
A as Stack
|
|
26
33
|
};
|
|
27
34
|
|
|
28
35
|
//# sourceMappingURL=Stack.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stack.js","names":["Tag","paddingVars","space","forwardRef","jsx","Stack","gap","padding","paddingInline","paddingBlock","align","justify","as","className","style","children","rest","ref"],"sources":["../../../src/components/Stack/Stack.tsx"],"sourcesContent":["import { type CSSProperties, type ElementType, forwardRef, type ReactNode } from \"react\";\nimport { type PaddingProps
|
|
1
|
+
{"version":3,"file":"Stack.js","names":["Tag","paddingVars","space","visibilityAttrs","forwardRef","jsx","Stack","gap","direction","padding","paddingInline","paddingBlock","align","justify","sticky","stickyOffset","hideBelow","hideAbove","as","className","style","children","rest","ref"],"sources":["../../../src/components/Stack/Stack.tsx"],"sourcesContent":["import { type CSSProperties, type ElementType, forwardRef, type ReactNode } from \"react\";\nimport {\n type LayoutAttributes,\n type PaddingProps,\n paddingVars,\n type Space,\n space,\n type VisibilityProps,\n visibilityAttrs,\n} from \"./space.js\";\n\nexport interface StackProps extends PaddingProps, VisibilityProps, LayoutAttributes {\n /** Space token between children. */\n gap?: Space;\n /** Lay the children out in a column (the default) or in a row. For a row, Inline adds wrapping and centring. */\n direction?: \"column\" | \"row\" | undefined;\n /** How children line up across the stack (horizontally in a column); `baseline` lines up text in a row. */\n align?: \"start\" | \"center\" | \"end\" | \"stretch\" | \"baseline\" | undefined;\n /** How children are spread along the stack (vertically in a column); `between` pushes them apart. */\n justify?: \"start\" | \"center\" | \"end\" | \"between\" | undefined;\n\n /**\n * Stay in view while the page scrolls past (`position: sticky`), inside its parent. In a Grid, make the GridItem\n * sticky instead, or give the Grid `align=\"start\"`: a box stretched to its row has nowhere to move.\n */\n sticky?: boolean | undefined;\n /** With `sticky`: any CSS length between the top of the scrolling area and the box, e.g. a header's height. Default 0. */\n stickyOffset?: string | undefined;\n /** Neutral layout element to render (never an interactive one). */\n as?: \"div\" | \"section\" | \"ul\" | \"ol\" | \"nav\" | \"aside\" | \"header\" | \"footer\" | \"span\";\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n /** The items to stack. */\n children?: ReactNode;\n /** Passed to the root element, for tests. */\n \"data-testid\"?: string;\n}\n\n/** Vertical layout with token gaps (or a row, with `direction=\"row\"`). */\nexport const Stack = forwardRef<HTMLElement, StackProps>(function Stack(\n {\n gap = \"4\",\n direction = \"column\",\n padding,\n paddingInline,\n paddingBlock,\n align,\n justify,\n sticky,\n stickyOffset,\n hideBelow,\n hideAbove,\n as = \"div\",\n className,\n style,\n children,\n ...rest\n },\n ref,\n) {\n const Tag = as as ElementType;\n return (\n <Tag\n ref={ref}\n {...rest}\n className={`cy-stack${className ? ` ${className}` : \"\"}`}\n data-direction={direction === \"row\" ? \"row\" : undefined}\n data-align={align}\n data-justify={justify}\n data-sticky={sticky ? \"\" : undefined}\n {...visibilityAttrs({ hideBelow, hideAbove })}\n style={\n {\n \"--_gap\": space(gap),\n ...(sticky && stickyOffset ? { \"--_sticky-top\": stickyOffset } : {}),\n ...paddingVars({ padding, paddingInline, paddingBlock }),\n ...style,\n } as CSSProperties\n }\n >\n {children}\n </Tag>\n );\n});\n"],"mappings":";;;;AAyCA,IAAaM,IAAQF,EAAoC,SACvD,EACE,KAAAG,IAAM,KACN,WAAAC,IAAY,UACZ,SAAAC,GACA,eAAAC,GACA,cAAAC,GACA,OAAAC,GACA,SAAAC,GACA,QAAAC,GACA,cAAAC,GACA,WAAAC,GACA,WAAAC,GACA,IAAAC,IAAK,OACL,WAAAC,GACA,OAAAC,GACA,UAAAC,GACA,GAAGC,EAAA,GAELC,GACA;AAEA,SACE,gBAAAlB,EAACL,GAAD;AAAA,IACO,KAAAuB;AAAA,IACL,GAAID;AAAA,IACJ,WAAW,WAAWH,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IACpD,kBAAgBX,MAAc,QAAQ,QAAQ;AAAA,IAC9C,cAAYI;AAAA,IACZ,gBAAcC;AAAA,IACd,eAAaC,IAAS,KAAK;AAAA,IAC3B,GAAIX,EAAgB;AAAA,MAAE,WAAAa;AAAA,MAAW,WAAAC;AAAA,IAAU,CAAC;AAAA,IAC5C,OACE;AAAA,MACE,UAAUf,EAAMK,CAAG;AAAA,MACnB,GAAIO,KAAUC,IAAe,EAAE,iBAAiBA,EAAa,IAAI,CAAC;AAAA,MAClE,GAAGd,EAAY;AAAA,QAAE,SAAAQ;AAAA,QAAS,eAAAC;AAAA,QAAe,cAAAC;AAAA,MAAa,CAAC;AAAA,MACvD,GAAGS;AAAA,IACL;AAAA,IAGD,UAAAC;AAAA,EACE,CAAA;AAET,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Stack, type StackProps } from "./Stack.js";
|
|
2
|
-
export type
|
|
2
|
+
export { BREAKPOINTS, type Breakpoint, type LayoutAttributes, type PaddingProps, type Space, type VisibilityProps, } from "./space.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AriaAttributes, HTMLAttributes } from "react";
|
|
1
2
|
/** A step of the theme's space scale (`--cy-space-0` … `--cy-space-10`). */
|
|
2
3
|
export type Space = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10";
|
|
3
4
|
/** The padding props shared by the layout primitives (Stack, Inline, Grid). */
|
|
@@ -16,3 +17,31 @@ export declare const space: (key: Space) => string;
|
|
|
16
17
|
* not set are left out: the stylesheet resets them to zero on every root, so a nested layout never inherits them.
|
|
17
18
|
*/
|
|
18
19
|
export declare function paddingVars({ padding, paddingInline, paddingBlock }: PaddingProps): Record<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* The named widths of the layout scale. Grid's per-breakpoint `columns` measure the grid's own width; `hideBelow` and
|
|
22
|
+
* `hideAbove` measure the window. A breakpoint applies from its width upwards. `base.css` and `grid.css` repeat these
|
|
23
|
+
* values (a media or container query cannot read a custom property): change them together.
|
|
24
|
+
*/
|
|
25
|
+
export declare const BREAKPOINTS: {
|
|
26
|
+
readonly sm: "30rem";
|
|
27
|
+
readonly md: "45rem";
|
|
28
|
+
readonly lg: "60rem";
|
|
29
|
+
readonly xl: "75rem";
|
|
30
|
+
};
|
|
31
|
+
/** A named width of the layout scale (`BREAKPOINTS`). */
|
|
32
|
+
export type Breakpoint = keyof typeof BREAKPOINTS;
|
|
33
|
+
/** Attributes every layout primitive passes to its element: an id to link to, a role and ARIA attributes. */
|
|
34
|
+
export interface LayoutAttributes extends Pick<HTMLAttributes<HTMLElement>, "id" | "role">, AriaAttributes {
|
|
35
|
+
}
|
|
36
|
+
/** Showing or hiding a layout box by the width of the window, with no script. */
|
|
37
|
+
export interface VisibilityProps {
|
|
38
|
+
/** Hidden while the window is narrower than this breakpoint (`md`: below 45rem). */
|
|
39
|
+
hideBelow?: Breakpoint | undefined;
|
|
40
|
+
/** Hidden from this breakpoint upwards (`md`: 45rem and wider). */
|
|
41
|
+
hideAbove?: Breakpoint | undefined;
|
|
42
|
+
}
|
|
43
|
+
/** The data attributes `base.css` hides a box by. */
|
|
44
|
+
export declare const visibilityAttrs: ({ hideBelow, hideAbove }: VisibilityProps) => {
|
|
45
|
+
"data-cy-hide-below": "sm" | "md" | "lg" | "xl" | undefined;
|
|
46
|
+
"data-cy-hide-above": "sm" | "md" | "lg" | "xl" | undefined;
|
|
47
|
+
};
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var
|
|
3
|
-
function
|
|
2
|
+
var i = (e) => `var(--cy-space-${e})`;
|
|
3
|
+
function s({ padding: e, paddingInline: r = e, paddingBlock: t = e }) {
|
|
4
4
|
const a = {};
|
|
5
|
-
return
|
|
5
|
+
return r && (a["--_pad-inline"] = i(r)), t && (a["--_pad-block"] = i(t)), a;
|
|
6
6
|
}
|
|
7
|
+
var c = {
|
|
8
|
+
sm: "30rem",
|
|
9
|
+
md: "45rem",
|
|
10
|
+
lg: "60rem",
|
|
11
|
+
xl: "75rem"
|
|
12
|
+
}, v = ({ hideBelow: e, hideAbove: r }) => ({
|
|
13
|
+
"data-cy-hide-below": e,
|
|
14
|
+
"data-cy-hide-above": r
|
|
15
|
+
});
|
|
7
16
|
export {
|
|
8
|
-
|
|
9
|
-
s as
|
|
17
|
+
c as BREAKPOINTS,
|
|
18
|
+
s as paddingVars,
|
|
19
|
+
i as space,
|
|
20
|
+
v as visibilityAttrs
|
|
10
21
|
};
|
|
11
22
|
|
|
12
23
|
//# sourceMappingURL=space.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"space.js","names":["space","key","paddingVars","padding","paddingInline","paddingBlock","vars"],"sources":["../../../src/components/Stack/space.ts"],"sourcesContent":["/** A step of the theme's space scale (`--cy-space-0` … `--cy-space-10`). */\nexport type Space = \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\" | \"10\";\n\n/** The padding props shared by the layout primitives (Stack, Inline, Grid). */\nexport interface PaddingProps {\n /** Space token of padding on all four sides of the box. Default: none. */\n padding?: Space | undefined;\n /** Space token of padding at the inline start and end (left and right in English). Wins over `padding`. */\n paddingInline?: Space | undefined;\n /** Space token of padding at the block start and end (top and bottom in English). Wins over `padding`. */\n paddingBlock?: Space | undefined;\n}\n\n/** The space token a key stands for, as a CSS value. */\nexport const space = (key: Space) => `var(--cy-space-${key})`;\n\n/**\n * The private custom properties the layout CSS reads its padding from, for the sides that are set. Sides that are\n * not set are left out: the stylesheet resets them to zero on every root, so a nested layout never inherits them.\n */\nexport function paddingVars({ padding, paddingInline = padding, paddingBlock = padding }: PaddingProps) {\n const vars: Record<string, string> = {};\n if (paddingInline) vars[\"--_pad-inline\"] = space(paddingInline);\n if (paddingBlock) vars[\"--_pad-block\"] = space(paddingBlock);\n return vars;\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"space.js","names":["space","key","paddingVars","padding","paddingInline","paddingBlock","vars","BREAKPOINTS","visibilityAttrs","hideBelow","hideAbove"],"sources":["../../../src/components/Stack/space.ts"],"sourcesContent":["import type { AriaAttributes, HTMLAttributes } from \"react\";\n\n/** A step of the theme's space scale (`--cy-space-0` … `--cy-space-10`). */\nexport type Space = \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\" | \"10\";\n\n/** The padding props shared by the layout primitives (Stack, Inline, Grid). */\nexport interface PaddingProps {\n /** Space token of padding on all four sides of the box. Default: none. */\n padding?: Space | undefined;\n /** Space token of padding at the inline start and end (left and right in English). Wins over `padding`. */\n paddingInline?: Space | undefined;\n /** Space token of padding at the block start and end (top and bottom in English). Wins over `padding`. */\n paddingBlock?: Space | undefined;\n}\n\n/** The space token a key stands for, as a CSS value. */\nexport const space = (key: Space) => `var(--cy-space-${key})`;\n\n/**\n * The private custom properties the layout CSS reads its padding from, for the sides that are set. Sides that are\n * not set are left out: the stylesheet resets them to zero on every root, so a nested layout never inherits them.\n */\nexport function paddingVars({ padding, paddingInline = padding, paddingBlock = padding }: PaddingProps) {\n const vars: Record<string, string> = {};\n if (paddingInline) vars[\"--_pad-inline\"] = space(paddingInline);\n if (paddingBlock) vars[\"--_pad-block\"] = space(paddingBlock);\n return vars;\n}\n\n/**\n * The named widths of the layout scale. Grid's per-breakpoint `columns` measure the grid's own width; `hideBelow` and\n * `hideAbove` measure the window. A breakpoint applies from its width upwards. `base.css` and `grid.css` repeat these\n * values (a media or container query cannot read a custom property): change them together.\n */\nexport const BREAKPOINTS = { sm: \"30rem\", md: \"45rem\", lg: \"60rem\", xl: \"75rem\" } as const;\n\n/** A named width of the layout scale (`BREAKPOINTS`). */\nexport type Breakpoint = keyof typeof BREAKPOINTS;\n\n/** Attributes every layout primitive passes to its element: an id to link to, a role and ARIA attributes. */\nexport interface LayoutAttributes extends Pick<HTMLAttributes<HTMLElement>, \"id\" | \"role\">, AriaAttributes {}\n\n/** Showing or hiding a layout box by the width of the window, with no script. */\nexport interface VisibilityProps {\n /** Hidden while the window is narrower than this breakpoint (`md`: below 45rem). */\n hideBelow?: Breakpoint | undefined;\n /** Hidden from this breakpoint upwards (`md`: 45rem and wider). */\n hideAbove?: Breakpoint | undefined;\n}\n\n/** The data attributes `base.css` hides a box by. */\nexport const visibilityAttrs = ({ hideBelow, hideAbove }: VisibilityProps) => ({\n \"data-cy-hide-below\": hideBelow,\n \"data-cy-hide-above\": hideAbove,\n});\n"],"mappings":";AAgBA,IAAaA,IAAA,CAASC,MAAe,kBAAkBA,CAAA;AAMvD,SAAgBC,EAAY,EAAE,SAAAC,GAAS,eAAAC,IAAgBD,GAAS,cAAAE,IAAeF,EAAA,GAAyB;AACtG,QAAMG,IAA+B,CAAC;AACtC,SAAIF,MAAeE,EAAK,eAAA,IAAmBN,EAAMI,CAAa,IAC1DC,MAAcC,EAAK,cAAA,IAAkBN,EAAMK,CAAY,IACpDC;AACT;AAOA,IAAaC,IAAc;AAAA,EAAE,IAAI;AAAA,EAAS,IAAI;AAAA,EAAS,IAAI;AAAA,EAAS,IAAI;AAAQ,GAiBnEC,IAAA,CAAmB,EAAE,WAAAC,GAAW,WAAAC,EAAA,OAAkC;AAAA,EAC7E,sBAAsBD;AAAA,EACtB,sBAAsBC;AACxB"}
|