anvilui 0.1.0 → 0.2.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/AGENTS.md +483 -0
- package/README.md +70 -3
- package/bin/anvilui.mjs +83 -0
- package/dist/colors/colors.d.ts +10 -2
- package/dist/components/Accordion/Accordion.d.ts +36 -0
- package/dist/components/AnimatedNumber/AnimatedNumber.d.ts +17 -0
- package/dist/components/AnvilRoot/AnvilContext.d.ts +22 -2
- package/dist/components/AnvilRoot/AnvilRoot.d.ts +44 -6
- package/dist/components/AppBar/AppBar.d.ts +13 -2
- package/dist/components/Avatar/Avatar.d.ts +6 -2
- package/dist/components/Avatar/AvatarGroupContext.d.ts +1 -0
- package/dist/components/AvatarGroup/AvatarGroup.d.ts +25 -0
- package/dist/components/Badge/Badge.d.ts +4 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts +22 -0
- package/dist/components/Button/Button.d.ts +17 -0
- package/dist/components/Calendar/Calendar.d.ts +19 -0
- package/dist/components/Card/Card.d.ts +36 -0
- package/dist/components/Carousel/Carousel.d.ts +21 -0
- package/dist/components/Checkbox/Checkbox.d.ts +10 -0
- package/dist/components/Chip/Chip.d.ts +25 -2
- package/dist/components/Combobox/Combobox.d.ts +42 -0
- package/dist/components/Confetti/Confetti.d.ts +31 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +24 -0
- package/dist/components/DateInput/DateInput.d.ts +37 -0
- package/dist/components/Dialog/Dialog.d.ts +32 -0
- package/dist/components/Divider/Divider.d.ts +8 -0
- package/dist/components/FAB/FAB.d.ts +4 -0
- package/dist/components/FAB/magnet.d.ts +2 -0
- package/dist/components/FABMenu/FABMenu.d.ts +55 -0
- package/dist/components/Field/Field.d.ts +20 -0
- package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +15 -0
- package/dist/components/HoldButton/HoldButton.d.ts +4 -1
- package/dist/components/Icon/Icon.d.ts +14 -0
- package/dist/components/IconButton/IconButton.d.ts +11 -0
- package/dist/components/Input/Input.d.ts +9 -0
- package/dist/components/Kbd/Kbd.d.ts +21 -0
- package/dist/components/List/List.d.ts +10 -1
- package/dist/components/Menu/Menu.d.ts +32 -0
- package/dist/components/Menubar/Menubar.d.ts +17 -0
- package/dist/components/NavigationBar/NavigationBar.d.ts +10 -0
- package/dist/components/NavigationDrawer/NavigationDrawer.d.ts +22 -0
- package/dist/components/NavigationList/NavigationList.d.ts +27 -0
- package/dist/components/NavigationRail/NavigationRail.d.ts +25 -9
- package/dist/components/PinInput/PinInput.d.ts +31 -0
- package/dist/components/Popover/Popover.d.ts +30 -2
- package/dist/components/PreviewCard/PreviewCard.d.ts +31 -0
- package/dist/components/Progress/Progress.d.ts +8 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +12 -0
- package/dist/components/Search/Search.d.ts +39 -0
- package/dist/components/Select/Select.d.ts +15 -2
- package/dist/components/Skeleton/Skeleton.d.ts +20 -0
- package/dist/components/Slider/Slider.d.ts +5 -0
- package/dist/components/Snackbar/Snackbar.d.ts +7 -2
- package/dist/components/SplitButton/SplitButton.d.ts +13 -0
- package/dist/components/Sticker/Sticker.d.ts +21 -0
- package/dist/components/Switch/Switch.d.ts +11 -0
- package/dist/components/Table/Table.d.ts +36 -0
- package/dist/components/Tabs/Tabs.d.ts +17 -0
- package/dist/components/Textarea/Textarea.d.ts +8 -0
- package/dist/components/TimePicker/TimePicker.d.ts +45 -0
- package/dist/components/Toggle/Toggle.d.ts +41 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +14 -2
- package/dist/components/Tooltip/Tooltip.d.ts +10 -1
- package/dist/components/Typography/Typography.d.ts +13 -1
- package/dist/datetime.d.ts +12 -0
- package/dist/dev.d.ts +15 -0
- package/dist/index.cjs +3105 -634
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1417 -364
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +50 -4
- package/dist/index.js +3038 -591
- package/dist/index.js.map +1 -1
- package/dist/themes/baseTheme.d.ts +2 -0
- package/dist/themes/createTheme.d.ts +22 -0
- package/dist/themes/monochromeTheme.d.ts +2 -0
- package/dist/themes/types.d.ts +15 -6
- package/dist/tokens/baseTokens.d.ts +4 -0
- package/dist/tokens/types.d.ts +34 -0
- package/docs/accordion.md +47 -0
- package/docs/animated-number.md +31 -0
- package/docs/app-bar.md +53 -0
- package/docs/avatar-group.md +35 -0
- package/docs/avatar.md +34 -0
- package/docs/badge.md +41 -0
- package/docs/bottom-sheet.md +65 -0
- package/docs/button.md +63 -0
- package/docs/calendar.md +26 -0
- package/docs/card.md +71 -0
- package/docs/carousel.md +43 -0
- package/docs/checkbox.md +37 -0
- package/docs/chip.md +48 -0
- package/docs/combobox.md +72 -0
- package/docs/composition.md +80 -0
- package/docs/confetti.md +30 -0
- package/docs/context-menu.md +42 -0
- package/docs/date-input.md +41 -0
- package/docs/dialog.md +106 -0
- package/docs/divider.md +31 -0
- package/docs/fab-menu.md +55 -0
- package/docs/fab.md +43 -0
- package/docs/field.md +59 -0
- package/docs/floating-toolbar.md +48 -0
- package/docs/forms.md +81 -0
- package/docs/hold-button.md +32 -0
- package/docs/icon-button.md +54 -0
- package/docs/icons.md +38 -0
- package/docs/input.md +50 -0
- package/docs/kbd.md +25 -0
- package/docs/list.md +65 -0
- package/docs/llms-index.md +82 -0
- package/docs/menu.md +88 -0
- package/docs/menubar.md +34 -0
- package/docs/morph.md +51 -0
- package/docs/navigation-bar.md +48 -0
- package/docs/navigation-drawer.md +72 -0
- package/docs/navigation-list.md +40 -0
- package/docs/navigation-rail.md +53 -0
- package/docs/pin-input.md +38 -0
- package/docs/popover.md +78 -0
- package/docs/preview-card.md +40 -0
- package/docs/progress.md +37 -0
- package/docs/radio-group.md +47 -0
- package/docs/search.md +77 -0
- package/docs/select.md +64 -0
- package/docs/setup.md +106 -0
- package/docs/skeleton.md +33 -0
- package/docs/slider.md +49 -0
- package/docs/snackbar.md +50 -0
- package/docs/split-button.md +44 -0
- package/docs/sticker.md +27 -0
- package/docs/switch.md +44 -0
- package/docs/table.md +66 -0
- package/docs/tabs.md +51 -0
- package/docs/textarea.md +23 -0
- package/docs/theming.md +182 -0
- package/docs/time-picker.md +38 -0
- package/docs/toggle-group.md +70 -0
- package/docs/toggle.md +49 -0
- package/docs/tooltip.md +42 -0
- package/docs/typography.md +41 -0
- package/package.json +25 -5
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// src/components/AnimatedNumber/AnimatedNumber.tsx
|
|
2
|
+
import {
|
|
3
|
+
useMemo,
|
|
4
|
+
useRef,
|
|
5
|
+
useState
|
|
6
|
+
} from "react";
|
|
5
7
|
|
|
6
8
|
// src/utils.ts
|
|
7
9
|
function cx(...parts) {
|
|
@@ -19,8 +21,163 @@ function mergeRefs(...refs) {
|
|
|
19
21
|
};
|
|
20
22
|
}
|
|
21
23
|
|
|
24
|
+
// src/components/AnimatedNumber/AnimatedNumber.tsx
|
|
25
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
26
|
+
var digits = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
|
|
27
|
+
var strip = [...digits, ...digits, ...digits];
|
|
28
|
+
var HOME = 10;
|
|
29
|
+
function AnimatedNumber({
|
|
30
|
+
value,
|
|
31
|
+
format,
|
|
32
|
+
locales,
|
|
33
|
+
className,
|
|
34
|
+
...props
|
|
35
|
+
}) {
|
|
36
|
+
const text = useMemo(
|
|
37
|
+
// Latin digits, so every digit gets a rolling column
|
|
38
|
+
() => new Intl.NumberFormat(locales, {
|
|
39
|
+
...format,
|
|
40
|
+
numberingSystem: "latn"
|
|
41
|
+
}).format(value),
|
|
42
|
+
[value, format, locales]
|
|
43
|
+
);
|
|
44
|
+
const chars = [...text];
|
|
45
|
+
const [previous, setPrevious] = useState(value);
|
|
46
|
+
const [direction, setDirection] = useState(1);
|
|
47
|
+
if (value !== previous) {
|
|
48
|
+
setPrevious(value);
|
|
49
|
+
setDirection(value > previous ? 1 : -1);
|
|
50
|
+
}
|
|
51
|
+
return /* @__PURE__ */ jsxs("span", { ...props, className: cx("avl-animated-number", className), children: [
|
|
52
|
+
/* @__PURE__ */ jsx("span", { className: "avl-animated-number-label", children: text }),
|
|
53
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: chars.map((char, i) => {
|
|
54
|
+
const fromEnd = chars.length - i;
|
|
55
|
+
const digit = digits.indexOf(char);
|
|
56
|
+
if (digit === -1)
|
|
57
|
+
return /* @__PURE__ */ jsx("span", { children: char }, `s${fromEnd}`);
|
|
58
|
+
return /* @__PURE__ */ jsx(
|
|
59
|
+
Digit,
|
|
60
|
+
{
|
|
61
|
+
digit,
|
|
62
|
+
direction
|
|
63
|
+
},
|
|
64
|
+
`d${fromEnd}`
|
|
65
|
+
);
|
|
66
|
+
}) })
|
|
67
|
+
] });
|
|
68
|
+
}
|
|
69
|
+
function Digit(props) {
|
|
70
|
+
const { digit, direction } = props;
|
|
71
|
+
const ref = useRef(null);
|
|
72
|
+
const [shown, setShown] = useState(digit);
|
|
73
|
+
const [position, setPosition] = useState(HOME + digit);
|
|
74
|
+
if (digit !== shown) {
|
|
75
|
+
const steps = direction > 0 ? (digit - shown + 10) % 10 : -((shown - digit + 10) % 10);
|
|
76
|
+
let next = position + steps;
|
|
77
|
+
if (next < 0 || next >= strip.length) next = HOME + digit;
|
|
78
|
+
setShown(digit);
|
|
79
|
+
setPosition(next);
|
|
80
|
+
}
|
|
81
|
+
const settle = (event) => {
|
|
82
|
+
const el = ref.current;
|
|
83
|
+
if (!el || event.target !== el) return;
|
|
84
|
+
const home = HOME + shown;
|
|
85
|
+
if (position === home) return;
|
|
86
|
+
el.style.transition = "none";
|
|
87
|
+
el.style.setProperty("--avl-digit", String(home));
|
|
88
|
+
void el.offsetHeight;
|
|
89
|
+
el.style.transition = "";
|
|
90
|
+
setPosition(home);
|
|
91
|
+
};
|
|
92
|
+
return /* @__PURE__ */ jsxs("span", { className: "avl-animated-number-digit", children: [
|
|
93
|
+
/* @__PURE__ */ jsx("span", { className: "avl-animated-number-sizer", children: digit }),
|
|
94
|
+
/* @__PURE__ */ jsx(
|
|
95
|
+
"span",
|
|
96
|
+
{
|
|
97
|
+
ref,
|
|
98
|
+
className: "avl-animated-number-strip",
|
|
99
|
+
style: { "--avl-digit": position },
|
|
100
|
+
onTransitionEnd: settle,
|
|
101
|
+
children: strip.map((d, i) => /* @__PURE__ */ jsx("span", { children: d }, i))
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
] });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/colors/colors.ts
|
|
108
|
+
function colorClass(color = "primary", fillType = "filled") {
|
|
109
|
+
return `avl-color-${color} avl-fill-${fillType} `;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/components/Typography/Typography.tsx
|
|
113
|
+
import { useContext as useContext2 } from "react";
|
|
114
|
+
|
|
115
|
+
// src/components/AnvilRoot/AnvilContext.ts
|
|
116
|
+
import {
|
|
117
|
+
createContext,
|
|
118
|
+
useContext
|
|
119
|
+
} from "react";
|
|
120
|
+
var AnvilContext = createContext(null);
|
|
121
|
+
function useAnvil() {
|
|
122
|
+
const avl = useContext(AnvilContext);
|
|
123
|
+
if (!avl)
|
|
124
|
+
throw new Error(
|
|
125
|
+
"[anvilui] useAnvil() was called outside <AnvilRoot>.\n\nFix: call it from a component rendered inside <AnvilRoot>, not in the component that renders AnvilRoot:\n<AnvilRoot><App /></AnvilRoot> // useAnvil() inside App works\n\nDocs: node_modules/anvilui/docs/theming.md"
|
|
126
|
+
);
|
|
127
|
+
return avl;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// src/dev.ts
|
|
131
|
+
var reported = /* @__PURE__ */ new Set();
|
|
132
|
+
function devError(message, fix, doc) {
|
|
133
|
+
const text = `[anvilui] ${message}
|
|
134
|
+
|
|
135
|
+
Fix:
|
|
136
|
+
${fix}
|
|
137
|
+
|
|
138
|
+
Docs: node_modules/anvilui/docs/${doc}`;
|
|
139
|
+
if (reported.has(text)) return;
|
|
140
|
+
reported.add(text);
|
|
141
|
+
console.error(text);
|
|
142
|
+
}
|
|
143
|
+
function checkAsChild(props, component, doc, fix = `<${component} render={<Button />}>Open</${component}>`) {
|
|
144
|
+
if (!("asChild" in props)) return;
|
|
145
|
+
devError(
|
|
146
|
+
`<${component}> has no \`asChild\` prop. AnvilUI uses Base UI's \`render\` prop instead.`,
|
|
147
|
+
fix,
|
|
148
|
+
doc
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
function checkProp(props, prop, component, instead, fix, doc) {
|
|
152
|
+
if (!(prop in props)) return;
|
|
153
|
+
devError(`<${component}> has no \`${prop}\` prop. ${instead}`, fix, doc);
|
|
154
|
+
}
|
|
155
|
+
var POPUP_OUTSIDE_ROOT = "Its popup portals to <body>, outside the theme, so it shows unstyled.";
|
|
156
|
+
var OUTSIDE_ROOT = "The theme variables only exist inside AnvilRoot, so it shows without colors, spacing or fonts.";
|
|
157
|
+
function checkRoot(found, component, reason = POPUP_OUTSIDE_ROOT) {
|
|
158
|
+
if (found) return;
|
|
159
|
+
devError(
|
|
160
|
+
`<${component}> is rendered outside <AnvilRoot>. ${reason}`,
|
|
161
|
+
`import { AnvilRoot } from 'anvilui'
|
|
162
|
+
import 'anvilui/styles.css'
|
|
163
|
+
|
|
164
|
+
<AnvilRoot>
|
|
165
|
+
<App />
|
|
166
|
+
</AnvilRoot>`,
|
|
167
|
+
"setup.md"
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
function checkName(props, component, example, doc) {
|
|
171
|
+
if (props["aria-label"] || props["aria-labelledby"]) return;
|
|
172
|
+
devError(
|
|
173
|
+
`<${component}> has no accessible name. It shows no text, so screen readers need an \`aria-label\`.`,
|
|
174
|
+
example,
|
|
175
|
+
doc
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
22
179
|
// src/components/Typography/Typography.tsx
|
|
23
|
-
import { jsx } from "react/jsx-runtime";
|
|
180
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
24
181
|
var tags = {
|
|
25
182
|
body: "p",
|
|
26
183
|
caption: "span",
|
|
@@ -37,8 +194,20 @@ function Typography({
|
|
|
37
194
|
className,
|
|
38
195
|
...props
|
|
39
196
|
}) {
|
|
197
|
+
const avl = useContext2(AnvilContext);
|
|
198
|
+
if (process.env.NODE_ENV !== "production") {
|
|
199
|
+
checkRoot(avl !== null, "Typography", OUTSIDE_ROOT);
|
|
200
|
+
checkProp(
|
|
201
|
+
props,
|
|
202
|
+
"variant",
|
|
203
|
+
"Typography",
|
|
204
|
+
"Use `type` for the look and `as` for the tag.",
|
|
205
|
+
'<Typography type="h4" as="h1">Title</Typography>\n// type: body | caption | h1 | h2 | h3 | h4 | h5 | h6',
|
|
206
|
+
"typography.md"
|
|
207
|
+
);
|
|
208
|
+
}
|
|
40
209
|
const Tag = as ?? tags[type];
|
|
41
|
-
return /* @__PURE__ */
|
|
210
|
+
return /* @__PURE__ */ jsx2(
|
|
42
211
|
Tag,
|
|
43
212
|
{
|
|
44
213
|
...props,
|
|
@@ -48,7 +217,7 @@ function Typography({
|
|
|
48
217
|
}
|
|
49
218
|
|
|
50
219
|
// src/components/AppBar/AppBar.tsx
|
|
51
|
-
import { jsx as
|
|
220
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
52
221
|
function AppBar({
|
|
53
222
|
label,
|
|
54
223
|
labelAs = "div",
|
|
@@ -62,7 +231,7 @@ function AppBar({
|
|
|
62
231
|
className,
|
|
63
232
|
...props
|
|
64
233
|
}) {
|
|
65
|
-
return /* @__PURE__ */
|
|
234
|
+
return /* @__PURE__ */ jsxs2(
|
|
66
235
|
"header",
|
|
67
236
|
{
|
|
68
237
|
...props,
|
|
@@ -74,8 +243,8 @@ function AppBar({
|
|
|
74
243
|
className
|
|
75
244
|
),
|
|
76
245
|
children: [
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
/* @__PURE__ */
|
|
246
|
+
/* @__PURE__ */ jsx3("div", { className: "avl-app-bar-start", children: start }),
|
|
247
|
+
/* @__PURE__ */ jsx3(
|
|
79
248
|
Typography,
|
|
80
249
|
{
|
|
81
250
|
as: labelAs,
|
|
@@ -84,21 +253,22 @@ function AppBar({
|
|
|
84
253
|
children: label
|
|
85
254
|
}
|
|
86
255
|
),
|
|
87
|
-
/* @__PURE__ */
|
|
256
|
+
/* @__PURE__ */ jsx3("div", { className: "avl-app-bar-end", children: end })
|
|
88
257
|
]
|
|
89
258
|
}
|
|
90
259
|
);
|
|
91
260
|
}
|
|
92
261
|
|
|
93
262
|
// src/components/Avatar/Avatar.tsx
|
|
263
|
+
import { useContext as useContext3 } from "react";
|
|
94
264
|
import { Avatar as BaseAvatar } from "@base-ui/react/avatar";
|
|
95
265
|
|
|
96
266
|
// src/components/Icon/Icon.tsx
|
|
97
267
|
import "material-symbols/rounded.css";
|
|
98
|
-
import { jsx as
|
|
268
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
99
269
|
function Icon({ name, ...props }) {
|
|
100
270
|
const labelled = props["aria-label"] || props["aria-labelledby"];
|
|
101
|
-
return /* @__PURE__ */
|
|
271
|
+
return /* @__PURE__ */ jsx4(
|
|
102
272
|
"span",
|
|
103
273
|
{
|
|
104
274
|
"aria-hidden": labelled ? void 0 : true,
|
|
@@ -110,8 +280,14 @@ function Icon({ name, ...props }) {
|
|
|
110
280
|
);
|
|
111
281
|
}
|
|
112
282
|
|
|
283
|
+
// src/components/Avatar/AvatarGroupContext.ts
|
|
284
|
+
import { createContext as createContext2 } from "react";
|
|
285
|
+
var AvatarGroupContext = createContext2(
|
|
286
|
+
null
|
|
287
|
+
);
|
|
288
|
+
|
|
113
289
|
// src/components/Avatar/Avatar.tsx
|
|
114
|
-
import { jsx as
|
|
290
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
115
291
|
function initials(name) {
|
|
116
292
|
const words = name.trim().split(/\s+/).filter(Boolean);
|
|
117
293
|
if (words.length === 0) return "";
|
|
@@ -123,15 +299,17 @@ function Avatar({
|
|
|
123
299
|
src,
|
|
124
300
|
name,
|
|
125
301
|
icon = "person",
|
|
126
|
-
size
|
|
302
|
+
size: sizeProp,
|
|
127
303
|
color,
|
|
128
304
|
fillType,
|
|
129
305
|
className,
|
|
130
306
|
children,
|
|
131
307
|
...props
|
|
132
308
|
}) {
|
|
309
|
+
const groupSize = useContext3(AvatarGroupContext);
|
|
310
|
+
const size = sizeProp ?? groupSize ?? "normal";
|
|
133
311
|
const letters = name ? initials(name) : "";
|
|
134
|
-
return /* @__PURE__ */
|
|
312
|
+
return /* @__PURE__ */ jsxs3(
|
|
135
313
|
BaseAvatar.Root,
|
|
136
314
|
{
|
|
137
315
|
role: name ? "img" : void 0,
|
|
@@ -147,7 +325,7 @@ function Avatar({
|
|
|
147
325
|
className
|
|
148
326
|
),
|
|
149
327
|
children: [
|
|
150
|
-
src && /* @__PURE__ */
|
|
328
|
+
src && /* @__PURE__ */ jsx5(
|
|
151
329
|
BaseAvatar.Image,
|
|
152
330
|
{
|
|
153
331
|
src,
|
|
@@ -155,13 +333,13 @@ function Avatar({
|
|
|
155
333
|
className: "avl-avatar-image"
|
|
156
334
|
}
|
|
157
335
|
),
|
|
158
|
-
/* @__PURE__ */
|
|
336
|
+
/* @__PURE__ */ jsx5(
|
|
159
337
|
BaseAvatar.Fallback,
|
|
160
338
|
{
|
|
161
339
|
delay: src ? 600 : void 0,
|
|
162
340
|
className: "avl-avatar-fallback",
|
|
163
341
|
"aria-hidden": true,
|
|
164
|
-
children: children ?? (letters || /* @__PURE__ */
|
|
342
|
+
children: children ?? (letters || /* @__PURE__ */ jsx5(Icon, { name: icon }))
|
|
165
343
|
}
|
|
166
344
|
)
|
|
167
345
|
]
|
|
@@ -169,8 +347,44 @@ function Avatar({
|
|
|
169
347
|
);
|
|
170
348
|
}
|
|
171
349
|
|
|
350
|
+
// src/components/AvatarGroup/AvatarGroup.tsx
|
|
351
|
+
import { Children } from "react";
|
|
352
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
353
|
+
function AvatarGroup({
|
|
354
|
+
max,
|
|
355
|
+
size = "normal",
|
|
356
|
+
fan = true,
|
|
357
|
+
className,
|
|
358
|
+
children,
|
|
359
|
+
...props
|
|
360
|
+
}) {
|
|
361
|
+
const avatars = Children.toArray(children);
|
|
362
|
+
const overflow = max !== void 0 && avatars.length > max;
|
|
363
|
+
const shown = overflow ? avatars.slice(0, Math.max(0, max - 1)) : avatars;
|
|
364
|
+
const hidden = avatars.length - shown.length;
|
|
365
|
+
return /* @__PURE__ */ jsx6(AvatarGroupContext, { value: size, children: /* @__PURE__ */ jsxs4(
|
|
366
|
+
"div",
|
|
367
|
+
{
|
|
368
|
+
role: "group",
|
|
369
|
+
...props,
|
|
370
|
+
className: cx(
|
|
371
|
+
"avl-avatar-group",
|
|
372
|
+
fan && "avl-avatar-group-fan",
|
|
373
|
+
className
|
|
374
|
+
),
|
|
375
|
+
children: [
|
|
376
|
+
shown,
|
|
377
|
+
overflow && /* @__PURE__ */ jsxs4(Avatar, { name: `${hidden} more`, color: "container", children: [
|
|
378
|
+
"+",
|
|
379
|
+
/* @__PURE__ */ jsx6(AnimatedNumber, { value: hidden })
|
|
380
|
+
] })
|
|
381
|
+
]
|
|
382
|
+
}
|
|
383
|
+
) });
|
|
384
|
+
}
|
|
385
|
+
|
|
172
386
|
// src/components/Badge/Badge.tsx
|
|
173
|
-
import { jsx as
|
|
387
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
174
388
|
function Badge({
|
|
175
389
|
count: count2,
|
|
176
390
|
max = 999,
|
|
@@ -180,7 +394,7 @@ function Badge({
|
|
|
180
394
|
children,
|
|
181
395
|
...props
|
|
182
396
|
}) {
|
|
183
|
-
const badge = count2 === 0 ? null : /* @__PURE__ */
|
|
397
|
+
const badge = count2 === 0 ? null : /* @__PURE__ */ jsx7(
|
|
184
398
|
"span",
|
|
185
399
|
{
|
|
186
400
|
"aria-hidden": true,
|
|
@@ -191,34 +405,34 @@ function Badge({
|
|
|
191
405
|
!children && className
|
|
192
406
|
),
|
|
193
407
|
...!children && props,
|
|
194
|
-
children: count2 !== void 0 &&
|
|
408
|
+
children: count2 !== void 0 && /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
409
|
+
/* @__PURE__ */ jsx7(AnimatedNumber, { value: Math.min(count2, max) }),
|
|
410
|
+
count2 > max && "+"
|
|
411
|
+
] })
|
|
195
412
|
}
|
|
196
413
|
);
|
|
197
414
|
if (!children) return badge;
|
|
198
|
-
return /* @__PURE__ */
|
|
415
|
+
return /* @__PURE__ */ jsxs5("span", { ...props, className: cx("avl-badge-anchor", className), children: [
|
|
199
416
|
children,
|
|
200
417
|
badge
|
|
201
418
|
] });
|
|
202
419
|
}
|
|
203
420
|
|
|
204
421
|
// src/components/BottomSheet/BottomSheet.tsx
|
|
205
|
-
import { useContext } from "react";
|
|
422
|
+
import { useContext as useContext4 } from "react";
|
|
206
423
|
import { Drawer } from "@base-ui/react/drawer";
|
|
207
|
-
|
|
208
|
-
// src/components/AnvilRoot/AnvilContext.ts
|
|
209
|
-
import { createContext } from "react";
|
|
210
|
-
var AnvilContext = createContext(null);
|
|
211
|
-
|
|
212
|
-
// src/components/BottomSheet/BottomSheet.tsx
|
|
213
|
-
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
424
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
214
425
|
function BottomSheet(props) {
|
|
215
|
-
return /* @__PURE__ */
|
|
426
|
+
return /* @__PURE__ */ jsx8(Drawer.Root, { ...props, swipeDirection: "down" });
|
|
216
427
|
}
|
|
217
428
|
function BottomSheetTrigger({
|
|
218
429
|
className,
|
|
219
430
|
...props
|
|
220
431
|
}) {
|
|
221
|
-
|
|
432
|
+
if (process.env.NODE_ENV !== "production") {
|
|
433
|
+
checkAsChild(props, "BottomSheetTrigger", "bottom-sheet.md");
|
|
434
|
+
}
|
|
435
|
+
return /* @__PURE__ */ jsx8(
|
|
222
436
|
Drawer.Trigger,
|
|
223
437
|
{
|
|
224
438
|
...props,
|
|
@@ -231,19 +445,22 @@ function BottomSheetPopup({
|
|
|
231
445
|
children,
|
|
232
446
|
...props
|
|
233
447
|
}) {
|
|
234
|
-
const avl =
|
|
448
|
+
const avl = useContext4(AnvilContext);
|
|
449
|
+
if (process.env.NODE_ENV !== "production") {
|
|
450
|
+
checkRoot(avl !== null, "BottomSheetPopup");
|
|
451
|
+
}
|
|
235
452
|
return (
|
|
236
453
|
// Into the AnvilRoot, not body, so the sheet sees the theme variables
|
|
237
|
-
/* @__PURE__ */
|
|
238
|
-
/* @__PURE__ */
|
|
239
|
-
/* @__PURE__ */
|
|
454
|
+
/* @__PURE__ */ jsxs6(Drawer.Portal, { container: avl?.rootRef, children: [
|
|
455
|
+
/* @__PURE__ */ jsx8(Drawer.Backdrop, { className: "avl-bottom-sheet-backdrop" }),
|
|
456
|
+
/* @__PURE__ */ jsx8(Drawer.Viewport, { className: "avl-bottom-sheet-viewport", children: /* @__PURE__ */ jsxs6(
|
|
240
457
|
Drawer.Popup,
|
|
241
458
|
{
|
|
242
459
|
...props,
|
|
243
460
|
className: withClass("avl-bottom-sheet-popup", className),
|
|
244
461
|
children: [
|
|
245
|
-
/* @__PURE__ */
|
|
246
|
-
/* @__PURE__ */
|
|
462
|
+
/* @__PURE__ */ jsx8("div", { className: "avl-bottom-sheet-handle", "aria-hidden": true }),
|
|
463
|
+
/* @__PURE__ */ jsx8(Drawer.Content, { className: "avl-bottom-sheet-content", children })
|
|
247
464
|
]
|
|
248
465
|
}
|
|
249
466
|
) })
|
|
@@ -254,7 +471,7 @@ function BottomSheetTitle({
|
|
|
254
471
|
className,
|
|
255
472
|
...props
|
|
256
473
|
}) {
|
|
257
|
-
return /* @__PURE__ */
|
|
474
|
+
return /* @__PURE__ */ jsx8(
|
|
258
475
|
Drawer.Title,
|
|
259
476
|
{
|
|
260
477
|
...props,
|
|
@@ -266,7 +483,7 @@ function BottomSheetDescription({
|
|
|
266
483
|
className,
|
|
267
484
|
...props
|
|
268
485
|
}) {
|
|
269
|
-
return /* @__PURE__ */
|
|
486
|
+
return /* @__PURE__ */ jsx8(
|
|
270
487
|
Drawer.Description,
|
|
271
488
|
{
|
|
272
489
|
...props,
|
|
@@ -278,7 +495,10 @@ function BottomSheetClose({
|
|
|
278
495
|
className,
|
|
279
496
|
...props
|
|
280
497
|
}) {
|
|
281
|
-
|
|
498
|
+
if (process.env.NODE_ENV !== "production") {
|
|
499
|
+
checkAsChild(props, "BottomSheetClose", "bottom-sheet.md");
|
|
500
|
+
}
|
|
501
|
+
return /* @__PURE__ */ jsx8(
|
|
282
502
|
Drawer.Close,
|
|
283
503
|
{
|
|
284
504
|
...props,
|
|
@@ -288,11 +508,11 @@ function BottomSheetClose({
|
|
|
288
508
|
}
|
|
289
509
|
|
|
290
510
|
// src/components/Button/Button.tsx
|
|
291
|
-
import { useLayoutEffect, useRef } from "react";
|
|
511
|
+
import { useContext as useContext5, useLayoutEffect, useRef as useRef2 } from "react";
|
|
292
512
|
import {
|
|
293
513
|
Button as BaseButton
|
|
294
514
|
} from "@base-ui/react/button";
|
|
295
|
-
import { jsx as
|
|
515
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
296
516
|
function Button({
|
|
297
517
|
size,
|
|
298
518
|
fillType,
|
|
@@ -306,9 +526,29 @@ function Button({
|
|
|
306
526
|
ref,
|
|
307
527
|
...props
|
|
308
528
|
}) {
|
|
309
|
-
const local =
|
|
529
|
+
const local = useRef2(null);
|
|
530
|
+
const avl = useContext5(AnvilContext);
|
|
531
|
+
if (process.env.NODE_ENV !== "production") {
|
|
532
|
+
checkRoot(avl !== null, "Button", OUTSIDE_ROOT);
|
|
533
|
+
checkProp(
|
|
534
|
+
props,
|
|
535
|
+
"variant",
|
|
536
|
+
"Button",
|
|
537
|
+
"Use `fillType` for the style and `color` for the theme role.",
|
|
538
|
+
`<Button fillType="outlined" color="error">Delete</Button>
|
|
539
|
+
// fillType: 'filled' | 'outlined' | 'text'
|
|
540
|
+
// color: 'primary' | 'tonal' | 'success' | 'warning' | 'error' | 'container' | 'surface'`,
|
|
541
|
+
"button.md"
|
|
542
|
+
);
|
|
543
|
+
checkAsChild(
|
|
544
|
+
props,
|
|
545
|
+
"Button",
|
|
546
|
+
"button.md",
|
|
547
|
+
'<Button render={<a href="/settings" />} nativeButton={false}>Settings</Button>'
|
|
548
|
+
);
|
|
549
|
+
}
|
|
310
550
|
useAnimatedWidth(local, loading !== void 0);
|
|
311
|
-
return /* @__PURE__ */
|
|
551
|
+
return /* @__PURE__ */ jsxs7(
|
|
312
552
|
BaseButton,
|
|
313
553
|
{
|
|
314
554
|
...props,
|
|
@@ -321,24 +561,24 @@ function Button({
|
|
|
321
561
|
className
|
|
322
562
|
),
|
|
323
563
|
children: [
|
|
324
|
-
loading ? /* @__PURE__ */
|
|
564
|
+
loading ? /* @__PURE__ */ jsx9(
|
|
325
565
|
"svg",
|
|
326
566
|
{
|
|
327
567
|
className: "avl-button-spinner",
|
|
328
568
|
viewBox: "0 0 24 24",
|
|
329
569
|
"aria-hidden": true,
|
|
330
|
-
children: /* @__PURE__ */
|
|
570
|
+
children: /* @__PURE__ */ jsx9("circle", { cx: "12", cy: "12", r: "8", pathLength: 100 })
|
|
331
571
|
}
|
|
332
|
-
) : startIcon && /* @__PURE__ */
|
|
572
|
+
) : startIcon && /* @__PURE__ */ jsx9(Icon, { name: startIcon }),
|
|
333
573
|
children,
|
|
334
|
-
endIcon && /* @__PURE__ */
|
|
574
|
+
endIcon && /* @__PURE__ */ jsx9(Icon, { name: endIcon })
|
|
335
575
|
]
|
|
336
576
|
}
|
|
337
577
|
);
|
|
338
578
|
}
|
|
339
579
|
function useAnimatedWidth(ref, enabled) {
|
|
340
|
-
const lastWidth =
|
|
341
|
-
const running =
|
|
580
|
+
const lastWidth = useRef2(null);
|
|
581
|
+
const running = useRef2(null);
|
|
342
582
|
useLayoutEffect(() => {
|
|
343
583
|
const el = ref.current;
|
|
344
584
|
if (!el || !enabled) return;
|
|
@@ -370,9 +610,9 @@ function useAnimatedWidth(ref, enabled) {
|
|
|
370
610
|
}
|
|
371
611
|
|
|
372
612
|
// src/components/SplitButton/SplitButton.tsx
|
|
373
|
-
import { jsx as
|
|
613
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
374
614
|
function SplitButton({ className, ...props }) {
|
|
375
|
-
return /* @__PURE__ */
|
|
615
|
+
return /* @__PURE__ */ jsx10(
|
|
376
616
|
"div",
|
|
377
617
|
{
|
|
378
618
|
role: "group",
|
|
@@ -383,8 +623,8 @@ function SplitButton({ className, ...props }) {
|
|
|
383
623
|
}
|
|
384
624
|
|
|
385
625
|
// src/components/HoldButton/HoldButton.tsx
|
|
386
|
-
import { useEffect, useRef as
|
|
387
|
-
import { jsx as
|
|
626
|
+
import { useEffect, useRef as useRef3, useState as useState2 } from "react";
|
|
627
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
388
628
|
function HoldButton({
|
|
389
629
|
onConfirm,
|
|
390
630
|
holdDuration = 1500,
|
|
@@ -401,10 +641,10 @@ function HoldButton({
|
|
|
401
641
|
onContextMenu,
|
|
402
642
|
...props
|
|
403
643
|
}) {
|
|
404
|
-
const [state, setState] =
|
|
405
|
-
const [nudges, setNudges] =
|
|
406
|
-
const timer =
|
|
407
|
-
const pressed =
|
|
644
|
+
const [state, setState] = useState2("idle");
|
|
645
|
+
const [nudges, setNudges] = useState2(0);
|
|
646
|
+
const timer = useRef3(void 0);
|
|
647
|
+
const pressed = useRef3(false);
|
|
408
648
|
useEffect(() => () => clearTimeout(timer.current), []);
|
|
409
649
|
const confirm = () => {
|
|
410
650
|
setState("confirmed");
|
|
@@ -422,7 +662,7 @@ function HoldButton({
|
|
|
422
662
|
setState("idle");
|
|
423
663
|
setNudges((n) => n + 1);
|
|
424
664
|
};
|
|
425
|
-
return /* @__PURE__ */
|
|
665
|
+
return /* @__PURE__ */ jsx11(
|
|
426
666
|
Button,
|
|
427
667
|
{
|
|
428
668
|
...props,
|
|
@@ -491,7 +731,8 @@ function HoldButton({
|
|
|
491
731
|
import {
|
|
492
732
|
Button as BaseButton2
|
|
493
733
|
} from "@base-ui/react/button";
|
|
494
|
-
import {
|
|
734
|
+
import { useContext as useContext6 } from "react";
|
|
735
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
495
736
|
var nestedControls = [
|
|
496
737
|
"a[href]",
|
|
497
738
|
"button",
|
|
@@ -522,8 +763,12 @@ function isFromNestedControl(event) {
|
|
|
522
763
|
return control !== null && control !== event.currentTarget;
|
|
523
764
|
}
|
|
524
765
|
function Card(props) {
|
|
525
|
-
|
|
526
|
-
|
|
766
|
+
const avl = useContext6(AnvilContext);
|
|
767
|
+
if (process.env.NODE_ENV !== "production") {
|
|
768
|
+
checkRoot(avl !== null, "Card", OUTSIDE_ROOT);
|
|
769
|
+
}
|
|
770
|
+
if (props.clickable) return /* @__PURE__ */ jsx12(ClickableCard, { ...props });
|
|
771
|
+
return /* @__PURE__ */ jsx12(StaticCard, { ...props });
|
|
527
772
|
}
|
|
528
773
|
function StaticCard({
|
|
529
774
|
clickable,
|
|
@@ -532,7 +777,7 @@ function StaticCard({
|
|
|
532
777
|
className,
|
|
533
778
|
...props
|
|
534
779
|
}) {
|
|
535
|
-
return /* @__PURE__ */
|
|
780
|
+
return /* @__PURE__ */ jsx12(
|
|
536
781
|
"div",
|
|
537
782
|
{
|
|
538
783
|
...props,
|
|
@@ -548,11 +793,11 @@ function ClickableCard({
|
|
|
548
793
|
onClick,
|
|
549
794
|
...props
|
|
550
795
|
}) {
|
|
551
|
-
return /* @__PURE__ */
|
|
796
|
+
return /* @__PURE__ */ jsx12(
|
|
552
797
|
BaseButton2,
|
|
553
798
|
{
|
|
554
799
|
nativeButton: false,
|
|
555
|
-
render: /* @__PURE__ */
|
|
800
|
+
render: /* @__PURE__ */ jsx12("div", {}),
|
|
556
801
|
...props,
|
|
557
802
|
onClick: (event) => {
|
|
558
803
|
if (!isFromNestedControl(event)) onClick?.(event);
|
|
@@ -570,7 +815,7 @@ function CardTitle({
|
|
|
570
815
|
className,
|
|
571
816
|
...props
|
|
572
817
|
}) {
|
|
573
|
-
return /* @__PURE__ */
|
|
818
|
+
return /* @__PURE__ */ jsx12(
|
|
574
819
|
Typography,
|
|
575
820
|
{
|
|
576
821
|
...props,
|
|
@@ -581,21 +826,446 @@ function CardTitle({
|
|
|
581
826
|
);
|
|
582
827
|
}
|
|
583
828
|
function CardContent({ className, ...props }) {
|
|
584
|
-
return /* @__PURE__ */
|
|
829
|
+
return /* @__PURE__ */ jsx12("div", { ...props, className: cx("avl-card-content", className) });
|
|
585
830
|
}
|
|
586
831
|
function CardActions({ className, ...props }) {
|
|
587
|
-
return /* @__PURE__ */
|
|
832
|
+
return /* @__PURE__ */ jsx12("div", { ...props, className: cx("avl-card-actions", className) });
|
|
588
833
|
}
|
|
589
834
|
|
|
590
|
-
// src/components/
|
|
835
|
+
// src/components/Calendar/Calendar.tsx
|
|
836
|
+
import { useEffect as useEffect2, useRef as useRef4, useState as useState3 } from "react";
|
|
837
|
+
|
|
838
|
+
// src/components/IconButton/IconButton.tsx
|
|
591
839
|
import {
|
|
592
840
|
Button as BaseButton3
|
|
593
841
|
} from "@base-ui/react/button";
|
|
842
|
+
import { useContext as useContext7 } from "react";
|
|
843
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
844
|
+
function IconButton({
|
|
845
|
+
icon,
|
|
846
|
+
color,
|
|
847
|
+
fillType,
|
|
848
|
+
className,
|
|
849
|
+
...props
|
|
850
|
+
}) {
|
|
851
|
+
const avl = useContext7(AnvilContext);
|
|
852
|
+
if (process.env.NODE_ENV !== "production") {
|
|
853
|
+
checkRoot(avl !== null, "IconButton", OUTSIDE_ROOT);
|
|
854
|
+
checkName(
|
|
855
|
+
props,
|
|
856
|
+
"IconButton",
|
|
857
|
+
'<IconButton icon="delete" aria-label="Delete" />',
|
|
858
|
+
"icon-button.md"
|
|
859
|
+
);
|
|
860
|
+
checkProp(
|
|
861
|
+
props,
|
|
862
|
+
"variant",
|
|
863
|
+
"IconButton",
|
|
864
|
+
"Use `fillType` (filled | outlined | text) and `color`.",
|
|
865
|
+
'<IconButton icon="close" aria-label="Close" fillType="text" color="container" />',
|
|
866
|
+
"icon-button.md"
|
|
867
|
+
);
|
|
868
|
+
checkAsChild(
|
|
869
|
+
props,
|
|
870
|
+
"IconButton",
|
|
871
|
+
"icon-button.md",
|
|
872
|
+
'<IconButton icon="home" aria-label="Home" render={<a href="/" />} nativeButton={false} />'
|
|
873
|
+
);
|
|
874
|
+
}
|
|
875
|
+
return /* @__PURE__ */ jsx13(
|
|
876
|
+
BaseButton3,
|
|
877
|
+
{
|
|
878
|
+
...props,
|
|
879
|
+
className: withClass(
|
|
880
|
+
`avl-icon-button ${colorClass(color, fillType)}`,
|
|
881
|
+
className
|
|
882
|
+
),
|
|
883
|
+
children: /* @__PURE__ */ jsx13(Icon, { name: icon })
|
|
884
|
+
}
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
// src/datetime.ts
|
|
889
|
+
var pad = (n, length = 2) => String(n).padStart(length, "0");
|
|
890
|
+
var toIso = (d) => `${pad(d.getFullYear(), 4)}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
|
|
891
|
+
function makeDate(y, m, d) {
|
|
892
|
+
const date = new Date(y, m, d);
|
|
893
|
+
return date.getFullYear() === y && date.getMonth() === m && date.getDate() === d ? date : null;
|
|
894
|
+
}
|
|
895
|
+
function fromIso(value) {
|
|
896
|
+
const match = value ? /^(\d{4})-(\d{2})-(\d{2})$/.exec(value) : null;
|
|
897
|
+
return match ? makeDate(+match[1], +match[2] - 1, +match[3]) : null;
|
|
898
|
+
}
|
|
899
|
+
var fieldOrder = (fmt) => fmt.formatToParts(new Date(2e3, 10, 22)).filter(
|
|
900
|
+
(p) => p.type === "year" || p.type === "month" || p.type === "day"
|
|
901
|
+
).map((p) => p.type);
|
|
902
|
+
function placeholderFor(fmt) {
|
|
903
|
+
const hint = { year: "YYYY", month: "MM", day: "DD" };
|
|
904
|
+
return fmt.formatToParts(new Date(2e3, 10, 22)).map(
|
|
905
|
+
(p) => p.type === "literal" ? p.value : hint[p.type] ?? ""
|
|
906
|
+
).join("");
|
|
907
|
+
}
|
|
908
|
+
function parseTyped(text, order) {
|
|
909
|
+
const numbers = text.match(/\d+/g);
|
|
910
|
+
if (numbers?.length !== 3) return null;
|
|
911
|
+
const parts = Object.fromEntries(order.map((type, i) => [type, numbers[i]]));
|
|
912
|
+
if (parts.year.length !== 4) return null;
|
|
913
|
+
return makeDate(+parts.year, +parts.month - 1, +parts.day);
|
|
914
|
+
}
|
|
915
|
+
function parseTime(value) {
|
|
916
|
+
const match = value ? /^(\d{1,2}):(\d{2})/.exec(value) : null;
|
|
917
|
+
return match ? { h: +match[1] % 24, m: +match[2] % 60 } : null;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
// src/components/Calendar/Calendar.tsx
|
|
921
|
+
import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
922
|
+
function localeWeekStart() {
|
|
923
|
+
try {
|
|
924
|
+
const locale = new Intl.Locale(navigator.language);
|
|
925
|
+
const info = locale.getWeekInfo?.() ?? locale.weekInfo;
|
|
926
|
+
return info ? info.firstDay % 7 : 0;
|
|
927
|
+
} catch {
|
|
928
|
+
return 0;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
function Calendar({
|
|
932
|
+
value: valueProp,
|
|
933
|
+
defaultValue = null,
|
|
934
|
+
onValueChange,
|
|
935
|
+
className,
|
|
936
|
+
...props
|
|
937
|
+
}) {
|
|
938
|
+
const [internal, setInternal] = useState3(defaultValue);
|
|
939
|
+
const selected = fromIso(valueProp !== void 0 ? valueProp : internal);
|
|
940
|
+
const [focused, setFocused] = useState3(() => {
|
|
941
|
+
const now = /* @__PURE__ */ new Date();
|
|
942
|
+
return selected ?? new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
943
|
+
});
|
|
944
|
+
const [weekStart] = useState3(localeWeekStart);
|
|
945
|
+
const dayRef = useRef4(null);
|
|
946
|
+
const moveFocus = useRef4(false);
|
|
947
|
+
const year = focused.getFullYear();
|
|
948
|
+
const month = focused.getMonth();
|
|
949
|
+
useEffect2(() => {
|
|
950
|
+
if (moveFocus.current) dayRef.current?.focus();
|
|
951
|
+
moveFocus.current = false;
|
|
952
|
+
}, [focused]);
|
|
953
|
+
const go = (d, focus = true) => {
|
|
954
|
+
moveFocus.current = focus;
|
|
955
|
+
setFocused(d);
|
|
956
|
+
};
|
|
957
|
+
const shiftMonths = (n, focus = false) => {
|
|
958
|
+
const first = new Date(year, month + n, 1);
|
|
959
|
+
const last = new Date(first.getFullYear(), first.getMonth() + 1, 0);
|
|
960
|
+
go(
|
|
961
|
+
new Date(
|
|
962
|
+
first.getFullYear(),
|
|
963
|
+
first.getMonth(),
|
|
964
|
+
Math.min(focused.getDate(), last.getDate())
|
|
965
|
+
),
|
|
966
|
+
focus
|
|
967
|
+
);
|
|
968
|
+
};
|
|
969
|
+
const select = (d) => {
|
|
970
|
+
const iso = toIso(d);
|
|
971
|
+
setInternal(iso);
|
|
972
|
+
setFocused(d);
|
|
973
|
+
onValueChange?.(iso);
|
|
974
|
+
};
|
|
975
|
+
const today = toIso(/* @__PURE__ */ new Date());
|
|
976
|
+
const selectedIso = selected && toIso(selected);
|
|
977
|
+
const focusedIso = toIso(focused);
|
|
978
|
+
const offset = (new Date(year, month, 1).getDay() - weekStart + 7) % 7;
|
|
979
|
+
const daysInMonth = new Date(year, month + 1, 0).getDate();
|
|
980
|
+
const cells = [
|
|
981
|
+
...Array(offset).fill(null),
|
|
982
|
+
...Array.from(
|
|
983
|
+
{ length: daysInMonth },
|
|
984
|
+
(_, i) => new Date(year, month, i + 1)
|
|
985
|
+
)
|
|
986
|
+
];
|
|
987
|
+
while (cells.length % 7) cells.push(null);
|
|
988
|
+
const weeks = Array.from(
|
|
989
|
+
{ length: cells.length / 7 },
|
|
990
|
+
(_, i) => cells.slice(i * 7, i * 7 + 7)
|
|
991
|
+
);
|
|
992
|
+
const weekdays = Array.from(
|
|
993
|
+
{ length: 7 },
|
|
994
|
+
(_, i) => new Date(2023, 0, 1 + (weekStart + i) % 7)
|
|
995
|
+
);
|
|
996
|
+
const weekdayShort = new Intl.DateTimeFormat(void 0, {
|
|
997
|
+
weekday: "narrow"
|
|
998
|
+
});
|
|
999
|
+
const weekdayLong = new Intl.DateTimeFormat(void 0, { weekday: "long" });
|
|
1000
|
+
const dayName = new Intl.DateTimeFormat(void 0, { dateStyle: "full" });
|
|
1001
|
+
const monthName = new Intl.DateTimeFormat(void 0, { month: "short" });
|
|
1002
|
+
const monthYear = new Intl.DateTimeFormat(void 0, {
|
|
1003
|
+
month: "long",
|
|
1004
|
+
year: "numeric"
|
|
1005
|
+
});
|
|
1006
|
+
const onKeyDown = (e) => {
|
|
1007
|
+
const steps = {
|
|
1008
|
+
ArrowLeft: -1,
|
|
1009
|
+
ArrowRight: 1,
|
|
1010
|
+
ArrowUp: -7,
|
|
1011
|
+
ArrowDown: 7
|
|
1012
|
+
};
|
|
1013
|
+
const day = focused.getDate();
|
|
1014
|
+
const intoWeek = (focused.getDay() - weekStart + 7) % 7;
|
|
1015
|
+
if (e.key in steps) go(new Date(year, month, day + steps[e.key]));
|
|
1016
|
+
else if (e.key === "PageUp") shiftMonths(e.shiftKey ? -12 : -1, true);
|
|
1017
|
+
else if (e.key === "PageDown") shiftMonths(e.shiftKey ? 12 : 1, true);
|
|
1018
|
+
else if (e.key === "Home") go(new Date(year, month, day - intoWeek));
|
|
1019
|
+
else if (e.key === "End") go(new Date(year, month, day + 6 - intoWeek));
|
|
1020
|
+
else return;
|
|
1021
|
+
e.preventDefault();
|
|
1022
|
+
};
|
|
1023
|
+
return /* @__PURE__ */ jsxs8("div", { ...props, className: cx("avl-calendar", className), children: [
|
|
1024
|
+
/* @__PURE__ */ jsxs8("div", { className: "avl-calendar-header", children: [
|
|
1025
|
+
/* @__PURE__ */ jsxs8("div", { className: "avl-calendar-nav", children: [
|
|
1026
|
+
/* @__PURE__ */ jsx14(
|
|
1027
|
+
IconButton,
|
|
1028
|
+
{
|
|
1029
|
+
icon: "chevron_left",
|
|
1030
|
+
fillType: "text",
|
|
1031
|
+
color: "container",
|
|
1032
|
+
"aria-label": "Previous month",
|
|
1033
|
+
onClick: () => shiftMonths(-1)
|
|
1034
|
+
}
|
|
1035
|
+
),
|
|
1036
|
+
/* @__PURE__ */ jsx14("span", { className: "avl-calendar-nav-label", "aria-live": "polite", children: monthName.format(focused) }),
|
|
1037
|
+
/* @__PURE__ */ jsx14(
|
|
1038
|
+
IconButton,
|
|
1039
|
+
{
|
|
1040
|
+
icon: "chevron_right",
|
|
1041
|
+
fillType: "text",
|
|
1042
|
+
color: "container",
|
|
1043
|
+
"aria-label": "Next month",
|
|
1044
|
+
onClick: () => shiftMonths(1)
|
|
1045
|
+
}
|
|
1046
|
+
)
|
|
1047
|
+
] }),
|
|
1048
|
+
/* @__PURE__ */ jsxs8("div", { className: "avl-calendar-nav", children: [
|
|
1049
|
+
/* @__PURE__ */ jsx14(
|
|
1050
|
+
IconButton,
|
|
1051
|
+
{
|
|
1052
|
+
icon: "chevron_left",
|
|
1053
|
+
fillType: "text",
|
|
1054
|
+
color: "container",
|
|
1055
|
+
"aria-label": "Previous year",
|
|
1056
|
+
onClick: () => shiftMonths(-12)
|
|
1057
|
+
}
|
|
1058
|
+
),
|
|
1059
|
+
/* @__PURE__ */ jsx14("span", { className: "avl-calendar-nav-label", "aria-live": "polite", children: year }),
|
|
1060
|
+
/* @__PURE__ */ jsx14(
|
|
1061
|
+
IconButton,
|
|
1062
|
+
{
|
|
1063
|
+
icon: "chevron_right",
|
|
1064
|
+
fillType: "text",
|
|
1065
|
+
color: "container",
|
|
1066
|
+
"aria-label": "Next year",
|
|
1067
|
+
onClick: () => shiftMonths(12)
|
|
1068
|
+
}
|
|
1069
|
+
)
|
|
1070
|
+
] })
|
|
1071
|
+
] }),
|
|
1072
|
+
/* @__PURE__ */ jsxs8(
|
|
1073
|
+
"table",
|
|
1074
|
+
{
|
|
1075
|
+
className: "avl-calendar-grid",
|
|
1076
|
+
role: "grid",
|
|
1077
|
+
"aria-label": monthYear.format(focused),
|
|
1078
|
+
onKeyDown,
|
|
1079
|
+
children: [
|
|
1080
|
+
/* @__PURE__ */ jsx14("thead", { children: /* @__PURE__ */ jsx14("tr", { children: weekdays.map((d) => /* @__PURE__ */ jsx14(
|
|
1081
|
+
"th",
|
|
1082
|
+
{
|
|
1083
|
+
scope: "col",
|
|
1084
|
+
abbr: weekdayLong.format(d),
|
|
1085
|
+
className: "avl-calendar-weekday",
|
|
1086
|
+
children: weekdayShort.format(d)
|
|
1087
|
+
},
|
|
1088
|
+
d.getDay()
|
|
1089
|
+
)) }) }),
|
|
1090
|
+
/* @__PURE__ */ jsx14("tbody", { children: weeks.map((week, w) => /* @__PURE__ */ jsx14("tr", { children: week.map((d, i) => {
|
|
1091
|
+
if (!d) return /* @__PURE__ */ jsx14("td", {}, i);
|
|
1092
|
+
const iso = toIso(d);
|
|
1093
|
+
const isFocused = iso === focusedIso;
|
|
1094
|
+
return /* @__PURE__ */ jsx14(
|
|
1095
|
+
"td",
|
|
1096
|
+
{
|
|
1097
|
+
role: "gridcell",
|
|
1098
|
+
"aria-selected": iso === selectedIso,
|
|
1099
|
+
children: /* @__PURE__ */ jsx14(
|
|
1100
|
+
"button",
|
|
1101
|
+
{
|
|
1102
|
+
ref: isFocused ? dayRef : void 0,
|
|
1103
|
+
type: "button",
|
|
1104
|
+
className: "avl-calendar-day",
|
|
1105
|
+
tabIndex: isFocused ? 0 : -1,
|
|
1106
|
+
"aria-label": dayName.format(d),
|
|
1107
|
+
"aria-current": iso === today ? "date" : void 0,
|
|
1108
|
+
"data-selected": iso === selectedIso || void 0,
|
|
1109
|
+
onClick: () => select(d),
|
|
1110
|
+
children: d.getDate()
|
|
1111
|
+
}
|
|
1112
|
+
)
|
|
1113
|
+
},
|
|
1114
|
+
i
|
|
1115
|
+
);
|
|
1116
|
+
}) }, w)) })
|
|
1117
|
+
]
|
|
1118
|
+
}
|
|
1119
|
+
)
|
|
1120
|
+
] });
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
// src/components/Carousel/Carousel.tsx
|
|
1124
|
+
import { useEffect as useEffect3, useRef as useRef5 } from "react";
|
|
1125
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1126
|
+
function Carousel({
|
|
1127
|
+
className,
|
|
1128
|
+
ref,
|
|
1129
|
+
children,
|
|
1130
|
+
...props
|
|
1131
|
+
}) {
|
|
1132
|
+
const local = useRef5(null);
|
|
1133
|
+
useDragScroll(local);
|
|
1134
|
+
return /* @__PURE__ */ jsx15(
|
|
1135
|
+
"div",
|
|
1136
|
+
{
|
|
1137
|
+
role: "region",
|
|
1138
|
+
"aria-roledescription": "carousel",
|
|
1139
|
+
tabIndex: 0,
|
|
1140
|
+
...props,
|
|
1141
|
+
ref: mergeRefs(local, ref),
|
|
1142
|
+
className: cx("avl-carousel", className),
|
|
1143
|
+
children
|
|
1144
|
+
}
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1147
|
+
function CarouselItem({
|
|
1148
|
+
className,
|
|
1149
|
+
children,
|
|
1150
|
+
...props
|
|
1151
|
+
}) {
|
|
1152
|
+
return /* @__PURE__ */ jsx15(
|
|
1153
|
+
"div",
|
|
1154
|
+
{
|
|
1155
|
+
role: "group",
|
|
1156
|
+
"aria-roledescription": "slide",
|
|
1157
|
+
...props,
|
|
1158
|
+
className: cx("avl-carousel-item", className),
|
|
1159
|
+
children: /* @__PURE__ */ jsx15("div", { className: "avl-carousel-item-content", children })
|
|
1160
|
+
}
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1163
|
+
var DRAG_THRESHOLD = 5;
|
|
1164
|
+
var FRICTION = 0.95;
|
|
1165
|
+
function useDragScroll(ref) {
|
|
1166
|
+
useEffect3(() => {
|
|
1167
|
+
const el = ref.current;
|
|
1168
|
+
if (!el) return;
|
|
1169
|
+
let startX = 0;
|
|
1170
|
+
let startScroll = 0;
|
|
1171
|
+
let pointer = null;
|
|
1172
|
+
let dragging = false;
|
|
1173
|
+
let samples = [];
|
|
1174
|
+
let glide = 0;
|
|
1175
|
+
const stopGlide = () => cancelAnimationFrame(glide);
|
|
1176
|
+
const onDown = (event) => {
|
|
1177
|
+
if (event.pointerType !== "mouse" || event.button !== 0) return;
|
|
1178
|
+
stopGlide();
|
|
1179
|
+
const top = el.getBoundingClientRect().top + el.clientTop;
|
|
1180
|
+
if (event.clientY > top + el.clientHeight) return;
|
|
1181
|
+
pointer = event.pointerId;
|
|
1182
|
+
startX = event.clientX;
|
|
1183
|
+
startScroll = el.scrollLeft;
|
|
1184
|
+
dragging = false;
|
|
1185
|
+
samples = [{ x: event.clientX, t: event.timeStamp }];
|
|
1186
|
+
};
|
|
1187
|
+
const onMove = (event) => {
|
|
1188
|
+
if (event.pointerId !== pointer) return;
|
|
1189
|
+
const dx = event.clientX - startX;
|
|
1190
|
+
if (!dragging) {
|
|
1191
|
+
if (Math.abs(dx) < DRAG_THRESHOLD) return;
|
|
1192
|
+
dragging = true;
|
|
1193
|
+
el.setPointerCapture(event.pointerId);
|
|
1194
|
+
el.toggleAttribute("data-dragging", true);
|
|
1195
|
+
window.getSelection()?.removeAllRanges();
|
|
1196
|
+
}
|
|
1197
|
+
el.scrollLeft = startScroll - dx;
|
|
1198
|
+
samples.push({ x: event.clientX, t: event.timeStamp });
|
|
1199
|
+
while (samples.length > 2 && event.timeStamp - samples[0].t > 100)
|
|
1200
|
+
samples.shift();
|
|
1201
|
+
};
|
|
1202
|
+
const onUp = (event) => {
|
|
1203
|
+
if (event.pointerId !== pointer) return;
|
|
1204
|
+
pointer = null;
|
|
1205
|
+
if (!dragging) return;
|
|
1206
|
+
el.removeAttribute("data-dragging");
|
|
1207
|
+
el.addEventListener("click", swallowClick, {
|
|
1208
|
+
capture: true,
|
|
1209
|
+
once: true
|
|
1210
|
+
});
|
|
1211
|
+
setTimeout(
|
|
1212
|
+
() => el.removeEventListener("click", swallowClick, true),
|
|
1213
|
+
0
|
|
1214
|
+
);
|
|
1215
|
+
const first = samples[0];
|
|
1216
|
+
const last = samples[samples.length - 1];
|
|
1217
|
+
const elapsed = last.t - first.t;
|
|
1218
|
+
if (event.type === "pointerup" && elapsed > 0 && !matchMedia("(prefers-reduced-motion: reduce)").matches)
|
|
1219
|
+
startGlide((last.x - first.x) / elapsed);
|
|
1220
|
+
};
|
|
1221
|
+
const startGlide = (speed) => {
|
|
1222
|
+
let previous = performance.now();
|
|
1223
|
+
const step = (now) => {
|
|
1224
|
+
const dt = now - previous;
|
|
1225
|
+
previous = now;
|
|
1226
|
+
speed *= FRICTION ** (dt / 16);
|
|
1227
|
+
const before = el.scrollLeft;
|
|
1228
|
+
el.scrollLeft -= speed * dt;
|
|
1229
|
+
if (Math.abs(speed) > 0.02 && el.scrollLeft !== before)
|
|
1230
|
+
glide = requestAnimationFrame(step);
|
|
1231
|
+
};
|
|
1232
|
+
glide = requestAnimationFrame(step);
|
|
1233
|
+
};
|
|
1234
|
+
const onDragStart = (event) => event.preventDefault();
|
|
1235
|
+
el.addEventListener("pointerdown", onDown);
|
|
1236
|
+
el.addEventListener("pointermove", onMove);
|
|
1237
|
+
el.addEventListener("pointerup", onUp);
|
|
1238
|
+
el.addEventListener("pointercancel", onUp);
|
|
1239
|
+
el.addEventListener("dragstart", onDragStart);
|
|
1240
|
+
el.addEventListener("wheel", stopGlide, { passive: true });
|
|
1241
|
+
el.addEventListener("keydown", stopGlide);
|
|
1242
|
+
return () => {
|
|
1243
|
+
stopGlide();
|
|
1244
|
+
el.removeEventListener("pointerdown", onDown);
|
|
1245
|
+
el.removeEventListener("pointermove", onMove);
|
|
1246
|
+
el.removeEventListener("pointerup", onUp);
|
|
1247
|
+
el.removeEventListener("pointercancel", onUp);
|
|
1248
|
+
el.removeEventListener("dragstart", onDragStart);
|
|
1249
|
+
el.removeEventListener("wheel", stopGlide);
|
|
1250
|
+
el.removeEventListener("keydown", stopGlide);
|
|
1251
|
+
};
|
|
1252
|
+
}, [ref]);
|
|
1253
|
+
}
|
|
1254
|
+
function swallowClick(event) {
|
|
1255
|
+
event.preventDefault();
|
|
1256
|
+
event.stopPropagation();
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
// src/components/Chip/Chip.tsx
|
|
1260
|
+
import { useRef as useRef6, useState as useState4 } from "react";
|
|
1261
|
+
import {
|
|
1262
|
+
Button as BaseButton4
|
|
1263
|
+
} from "@base-ui/react/button";
|
|
594
1264
|
import { Toggle } from "@base-ui/react/toggle";
|
|
595
|
-
import { jsx as
|
|
1265
|
+
import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
596
1266
|
function Chip({ startIcon, className, children, ...props }) {
|
|
597
|
-
return /* @__PURE__ */
|
|
598
|
-
|
|
1267
|
+
return /* @__PURE__ */ jsxs9(
|
|
1268
|
+
BaseButton4,
|
|
599
1269
|
{
|
|
600
1270
|
...props,
|
|
601
1271
|
className: withClass(
|
|
@@ -603,20 +1273,20 @@ function Chip({ startIcon, className, children, ...props }) {
|
|
|
603
1273
|
className
|
|
604
1274
|
),
|
|
605
1275
|
children: [
|
|
606
|
-
startIcon && /* @__PURE__ */
|
|
1276
|
+
startIcon && /* @__PURE__ */ jsx16(Icon, { name: startIcon }),
|
|
607
1277
|
children
|
|
608
1278
|
]
|
|
609
1279
|
}
|
|
610
1280
|
);
|
|
611
1281
|
}
|
|
612
1282
|
function FilterChip({ className, children, ...props }) {
|
|
613
|
-
return /* @__PURE__ */
|
|
1283
|
+
return /* @__PURE__ */ jsxs9(
|
|
614
1284
|
Toggle,
|
|
615
1285
|
{
|
|
616
1286
|
...props,
|
|
617
1287
|
className: withClass("avl-chip avl-filter-chip", className),
|
|
618
1288
|
children: [
|
|
619
|
-
/* @__PURE__ */
|
|
1289
|
+
/* @__PURE__ */ jsx16(Icon, { name: "check", className: "avl-filter-chip-check" }),
|
|
620
1290
|
children
|
|
621
1291
|
]
|
|
622
1292
|
}
|
|
@@ -628,49 +1298,105 @@ function InputChip({
|
|
|
628
1298
|
startIcon,
|
|
629
1299
|
disabled,
|
|
630
1300
|
className,
|
|
1301
|
+
ref,
|
|
631
1302
|
children,
|
|
632
1303
|
...props
|
|
633
1304
|
}) {
|
|
634
|
-
|
|
1305
|
+
const local = useRef6(null);
|
|
1306
|
+
const [removing, setRemoving] = useState4(false);
|
|
1307
|
+
const remove = () => {
|
|
1308
|
+
const el = local.current;
|
|
1309
|
+
if (!el || removing) return;
|
|
1310
|
+
setRemoving(true);
|
|
1311
|
+
const exit = el.animate(collapse(el), {
|
|
1312
|
+
...tokenTiming(el),
|
|
1313
|
+
fill: "forwards"
|
|
1314
|
+
});
|
|
1315
|
+
exit.onfinish = () => {
|
|
1316
|
+
onRemove();
|
|
1317
|
+
requestAnimationFrame(() => {
|
|
1318
|
+
if (!el.isConnected) return;
|
|
1319
|
+
exit.cancel();
|
|
1320
|
+
setRemoving(false);
|
|
1321
|
+
});
|
|
1322
|
+
};
|
|
1323
|
+
};
|
|
1324
|
+
return /* @__PURE__ */ jsxs9(
|
|
635
1325
|
"span",
|
|
636
1326
|
{
|
|
637
1327
|
...props,
|
|
1328
|
+
ref: mergeRefs(local, ref),
|
|
638
1329
|
className: cx(
|
|
639
1330
|
"avl-chip avl-input-chip",
|
|
640
1331
|
startIcon && "avl-chip-has-icon",
|
|
641
1332
|
className
|
|
642
1333
|
),
|
|
643
1334
|
"data-disabled": disabled || void 0,
|
|
1335
|
+
"data-removing": removing || void 0,
|
|
644
1336
|
children: [
|
|
645
|
-
startIcon && /* @__PURE__ */
|
|
1337
|
+
startIcon && /* @__PURE__ */ jsx16(Icon, { name: startIcon }),
|
|
646
1338
|
children,
|
|
647
|
-
/* @__PURE__ */
|
|
648
|
-
|
|
1339
|
+
/* @__PURE__ */ jsx16(
|
|
1340
|
+
BaseButton4,
|
|
649
1341
|
{
|
|
650
1342
|
className: "avl-input-chip-remove",
|
|
651
1343
|
"aria-label": removeLabel,
|
|
652
|
-
disabled,
|
|
653
|
-
onClick:
|
|
654
|
-
children: /* @__PURE__ */
|
|
1344
|
+
disabled: disabled || removing,
|
|
1345
|
+
onClick: remove,
|
|
1346
|
+
children: /* @__PURE__ */ jsx16(Icon, { name: "close" })
|
|
655
1347
|
}
|
|
656
1348
|
)
|
|
657
1349
|
]
|
|
658
1350
|
}
|
|
659
1351
|
);
|
|
660
1352
|
}
|
|
1353
|
+
function collapse(el) {
|
|
1354
|
+
const parent = el.parentElement;
|
|
1355
|
+
const gap = parent ? parseFloat(getComputedStyle(parent).columnGap) || 0 : 0;
|
|
1356
|
+
return [
|
|
1357
|
+
{ width: `${el.offsetWidth}px`, opacity: 1, scale: 1 },
|
|
1358
|
+
{
|
|
1359
|
+
width: "0px",
|
|
1360
|
+
paddingInline: "0px",
|
|
1361
|
+
borderInlineWidth: "0px",
|
|
1362
|
+
marginInlineEnd: `${-gap}px`,
|
|
1363
|
+
opacity: 0,
|
|
1364
|
+
scale: 0.6
|
|
1365
|
+
}
|
|
1366
|
+
];
|
|
1367
|
+
}
|
|
1368
|
+
function tokenTiming(el) {
|
|
1369
|
+
const style = getComputedStyle(el);
|
|
1370
|
+
const length = style.getPropertyValue("--avl-ease-length-normal").trim();
|
|
1371
|
+
const duration = length.endsWith("ms") ? parseFloat(length) : parseFloat(length) * 1e3;
|
|
1372
|
+
return {
|
|
1373
|
+
duration: Number.isFinite(duration) ? duration : 300,
|
|
1374
|
+
easing: style.getPropertyValue("--avl-ease-smooth").trim() || "ease"
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
661
1377
|
|
|
662
1378
|
// src/components/Checkbox/Checkbox.tsx
|
|
663
1379
|
import { Checkbox as BaseCheckbox } from "@base-ui/react/checkbox";
|
|
664
|
-
import { jsx as
|
|
1380
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
665
1381
|
var CHECK = "M5 12.5 L9.5 17 L19 7.5";
|
|
666
1382
|
var DASH = "M6 12 L12 12 L18 12";
|
|
667
1383
|
function Checkbox({ className, ...props }) {
|
|
668
|
-
|
|
1384
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1385
|
+
checkProp(
|
|
1386
|
+
props,
|
|
1387
|
+
"label",
|
|
1388
|
+
"Checkbox",
|
|
1389
|
+
"Wrap it in a <label> with the text instead.",
|
|
1390
|
+
'<label>\n <Checkbox name="terms" />\n I agree to the terms\n</label>',
|
|
1391
|
+
"checkbox.md"
|
|
1392
|
+
);
|
|
1393
|
+
}
|
|
1394
|
+
return /* @__PURE__ */ jsx17(
|
|
669
1395
|
BaseCheckbox.Root,
|
|
670
1396
|
{
|
|
671
1397
|
...props,
|
|
672
1398
|
className: withClass("avl-checkbox", className),
|
|
673
|
-
children: /* @__PURE__ */
|
|
1399
|
+
children: /* @__PURE__ */ jsx17(BaseCheckbox.Indicator, { className: "avl-checkbox-indicator", children: /* @__PURE__ */ jsx17("svg", { viewBox: "0 0 24 24", "aria-hidden": true, children: /* @__PURE__ */ jsx17(
|
|
674
1400
|
"path",
|
|
675
1401
|
{
|
|
676
1402
|
d: props.indeterminate ? DASH : CHECK,
|
|
@@ -682,27 +1408,27 @@ function Checkbox({ className, ...props }) {
|
|
|
682
1408
|
}
|
|
683
1409
|
|
|
684
1410
|
// src/components/Dialog/Dialog.tsx
|
|
685
|
-
import { useContext as
|
|
1411
|
+
import { useContext as useContext8 } from "react";
|
|
686
1412
|
import { Dialog as BaseDialog } from "@base-ui/react/dialog";
|
|
687
1413
|
|
|
688
1414
|
// src/morph.ts
|
|
689
1415
|
import {
|
|
690
|
-
createContext as
|
|
1416
|
+
createContext as createContext3,
|
|
691
1417
|
useLayoutEffect as useLayoutEffect2,
|
|
692
|
-
useRef as
|
|
693
|
-
useState as
|
|
1418
|
+
useRef as useRef7,
|
|
1419
|
+
useState as useState5
|
|
694
1420
|
} from "react";
|
|
695
1421
|
import { flushSync } from "react-dom";
|
|
696
|
-
var MorphContext =
|
|
1422
|
+
var MorphContext = createContext3(null);
|
|
697
1423
|
function useMorphOpen({
|
|
698
1424
|
morph: morph2,
|
|
699
1425
|
open: controlledOpen,
|
|
700
1426
|
defaultOpen,
|
|
701
1427
|
onOpenChange
|
|
702
1428
|
}) {
|
|
703
|
-
const trigger =
|
|
704
|
-
const popup =
|
|
705
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
1429
|
+
const trigger = useRef7(null);
|
|
1430
|
+
const popup = useRef7(null);
|
|
1431
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState5(defaultOpen);
|
|
706
1432
|
const open = controlledOpen ?? uncontrolledOpen;
|
|
707
1433
|
const hideTrigger = (hidden) => trigger.current?.toggleAttribute("data-morph-hidden", hidden);
|
|
708
1434
|
useLayoutEffect2(() => {
|
|
@@ -866,7 +1592,7 @@ function morphStyles(name, duration, easing) {
|
|
|
866
1592
|
}
|
|
867
1593
|
|
|
868
1594
|
// src/components/Dialog/Dialog.tsx
|
|
869
|
-
import { jsx as
|
|
1595
|
+
import { jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
870
1596
|
function Dialog({
|
|
871
1597
|
morph: morph2 = false,
|
|
872
1598
|
defaultOpen = false,
|
|
@@ -878,7 +1604,7 @@ function Dialog({
|
|
|
878
1604
|
defaultOpen,
|
|
879
1605
|
onOpenChange: props.onOpenChange
|
|
880
1606
|
});
|
|
881
|
-
return /* @__PURE__ */
|
|
1607
|
+
return /* @__PURE__ */ jsx18(MorphContext, { value: state.refs, children: /* @__PURE__ */ jsx18(
|
|
882
1608
|
BaseDialog.Root,
|
|
883
1609
|
{
|
|
884
1610
|
...props,
|
|
@@ -892,8 +1618,11 @@ function DialogTrigger({
|
|
|
892
1618
|
ref,
|
|
893
1619
|
...props
|
|
894
1620
|
}) {
|
|
895
|
-
const morph2 =
|
|
896
|
-
|
|
1621
|
+
const morph2 = useContext8(MorphContext);
|
|
1622
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1623
|
+
checkAsChild(props, "DialogTrigger", "dialog.md");
|
|
1624
|
+
}
|
|
1625
|
+
return /* @__PURE__ */ jsx18(
|
|
897
1626
|
BaseDialog.Trigger,
|
|
898
1627
|
{
|
|
899
1628
|
...props,
|
|
@@ -903,13 +1632,16 @@ function DialogTrigger({
|
|
|
903
1632
|
);
|
|
904
1633
|
}
|
|
905
1634
|
function DialogPopup({ className, ref, ...props }) {
|
|
906
|
-
const avl =
|
|
907
|
-
const morph2 =
|
|
1635
|
+
const avl = useContext8(AnvilContext);
|
|
1636
|
+
const morph2 = useContext8(MorphContext);
|
|
1637
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1638
|
+
checkRoot(avl !== null, "DialogPopup");
|
|
1639
|
+
}
|
|
908
1640
|
return (
|
|
909
1641
|
// Into the AnvilRoot, not body, so the popup sees the theme variables
|
|
910
|
-
/* @__PURE__ */
|
|
911
|
-
/* @__PURE__ */
|
|
912
|
-
/* @__PURE__ */
|
|
1642
|
+
/* @__PURE__ */ jsxs10(BaseDialog.Portal, { container: avl?.rootRef, children: [
|
|
1643
|
+
/* @__PURE__ */ jsx18(BaseDialog.Backdrop, { className: "avl-dialog-backdrop" }),
|
|
1644
|
+
/* @__PURE__ */ jsx18(
|
|
913
1645
|
BaseDialog.Popup,
|
|
914
1646
|
{
|
|
915
1647
|
...props,
|
|
@@ -921,7 +1653,7 @@ function DialogPopup({ className, ref, ...props }) {
|
|
|
921
1653
|
);
|
|
922
1654
|
}
|
|
923
1655
|
function DialogTitle({ className, ...props }) {
|
|
924
|
-
return /* @__PURE__ */
|
|
1656
|
+
return /* @__PURE__ */ jsx18(
|
|
925
1657
|
BaseDialog.Title,
|
|
926
1658
|
{
|
|
927
1659
|
...props,
|
|
@@ -933,7 +1665,7 @@ function DialogDescription({
|
|
|
933
1665
|
className,
|
|
934
1666
|
...props
|
|
935
1667
|
}) {
|
|
936
|
-
return /* @__PURE__ */
|
|
1668
|
+
return /* @__PURE__ */ jsx18(
|
|
937
1669
|
BaseDialog.Description,
|
|
938
1670
|
{
|
|
939
1671
|
...props,
|
|
@@ -942,10 +1674,13 @@ function DialogDescription({
|
|
|
942
1674
|
);
|
|
943
1675
|
}
|
|
944
1676
|
function DialogActions({ className, ...props }) {
|
|
945
|
-
return /* @__PURE__ */
|
|
1677
|
+
return /* @__PURE__ */ jsx18("div", { ...props, className: cx("avl-dialog-actions", className) });
|
|
946
1678
|
}
|
|
947
1679
|
function DialogClose({ className, ...props }) {
|
|
948
|
-
|
|
1680
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1681
|
+
checkAsChild(props, "DialogClose", "dialog.md");
|
|
1682
|
+
}
|
|
1683
|
+
return /* @__PURE__ */ jsx18(
|
|
949
1684
|
BaseDialog.Close,
|
|
950
1685
|
{
|
|
951
1686
|
...props,
|
|
@@ -954,17 +1689,113 @@ function DialogClose({ className, ...props }) {
|
|
|
954
1689
|
);
|
|
955
1690
|
}
|
|
956
1691
|
|
|
1692
|
+
// src/components/Confetti/Confetti.tsx
|
|
1693
|
+
import { useCallback, useContext as useContext9 } from "react";
|
|
1694
|
+
var defaultColors = [
|
|
1695
|
+
"primary",
|
|
1696
|
+
"tonal",
|
|
1697
|
+
"success",
|
|
1698
|
+
"warning",
|
|
1699
|
+
"error"
|
|
1700
|
+
];
|
|
1701
|
+
var shapes = ["rect", "circle", "strip"];
|
|
1702
|
+
var gravity = 900;
|
|
1703
|
+
var drag = 2.6;
|
|
1704
|
+
var random = (min, max) => min + Math.random() * (max - min);
|
|
1705
|
+
function useConfetti() {
|
|
1706
|
+
const avl = useContext9(AnvilContext);
|
|
1707
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1708
|
+
checkRoot(
|
|
1709
|
+
avl !== null,
|
|
1710
|
+
"useConfetti",
|
|
1711
|
+
"It draws into the AnvilRoot element, so without one nothing fires."
|
|
1712
|
+
);
|
|
1713
|
+
}
|
|
1714
|
+
return useCallback(
|
|
1715
|
+
(origin, options = {}) => {
|
|
1716
|
+
const root = avl?.rootRef.current;
|
|
1717
|
+
if (!root) return;
|
|
1718
|
+
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches)
|
|
1719
|
+
return;
|
|
1720
|
+
const {
|
|
1721
|
+
count: count2 = 80,
|
|
1722
|
+
angle = 0,
|
|
1723
|
+
spread = 70,
|
|
1724
|
+
power = 1,
|
|
1725
|
+
colors = defaultColors
|
|
1726
|
+
} = options;
|
|
1727
|
+
const { x, y } = originPoint(origin);
|
|
1728
|
+
const layer = document.createElement("div");
|
|
1729
|
+
layer.className = "avl-confetti";
|
|
1730
|
+
layer.setAttribute("aria-hidden", "true");
|
|
1731
|
+
root.append(layer);
|
|
1732
|
+
const animations = Array.from({ length: count2 }, (_, i) => {
|
|
1733
|
+
const piece = document.createElement("span");
|
|
1734
|
+
piece.className = "avl-confetti-piece";
|
|
1735
|
+
piece.dataset.shape = shapes[i % shapes.length];
|
|
1736
|
+
const color = colors[Math.floor(Math.random() * colors.length)];
|
|
1737
|
+
piece.style.backgroundColor = `var(--avl-color-${color})`;
|
|
1738
|
+
piece.style.left = `${x}px`;
|
|
1739
|
+
piece.style.top = `${y}px`;
|
|
1740
|
+
layer.append(piece);
|
|
1741
|
+
const direction = (angle + random(-spread, spread) / 2) * Math.PI / 180;
|
|
1742
|
+
const speed = random(700, 1800) * power;
|
|
1743
|
+
return piece.animate(
|
|
1744
|
+
flight(
|
|
1745
|
+
Math.sin(direction) * speed,
|
|
1746
|
+
-Math.cos(direction) * speed
|
|
1747
|
+
),
|
|
1748
|
+
{ duration: random(1800, 2800), fill: "forwards" }
|
|
1749
|
+
);
|
|
1750
|
+
});
|
|
1751
|
+
Promise.all(animations.map((a) => a.finished)).catch(() => {
|
|
1752
|
+
}).finally(() => layer.remove());
|
|
1753
|
+
},
|
|
1754
|
+
[avl]
|
|
1755
|
+
);
|
|
1756
|
+
}
|
|
1757
|
+
function originPoint(origin) {
|
|
1758
|
+
if (!origin)
|
|
1759
|
+
return { x: window.innerWidth / 2, y: window.innerHeight * 0.6 };
|
|
1760
|
+
if (!(origin instanceof Element)) return origin;
|
|
1761
|
+
const rect = origin.getBoundingClientRect();
|
|
1762
|
+
return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };
|
|
1763
|
+
}
|
|
1764
|
+
function flight(vx, vy) {
|
|
1765
|
+
const seconds = 2.5;
|
|
1766
|
+
const steps = 30;
|
|
1767
|
+
const spin = random(-720, 720);
|
|
1768
|
+
const tumble = random(360, 1080);
|
|
1769
|
+
const sway = random(10, 30);
|
|
1770
|
+
const swayRate = random(4, 8);
|
|
1771
|
+
const frames = [];
|
|
1772
|
+
for (let i = 0; i <= steps; i++) {
|
|
1773
|
+
const progress = i / steps;
|
|
1774
|
+
const t = progress * seconds;
|
|
1775
|
+
const slowdown = (1 - Math.exp(-drag * t)) / drag;
|
|
1776
|
+
const px = vx * slowdown + Math.sin(t * swayRate) * sway * Math.min(t, 1);
|
|
1777
|
+
const py = (vy - gravity / drag) * slowdown + gravity / drag * t;
|
|
1778
|
+
frames.push({
|
|
1779
|
+
offset: progress,
|
|
1780
|
+
transform: `translate(${px}px, ${py}px) rotate(${spin * progress}deg) rotateX(${tumble * progress}deg)`,
|
|
1781
|
+
opacity: progress < 0.75 ? 1 : 1 - (progress - 0.75) / 0.25
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1784
|
+
return frames;
|
|
1785
|
+
}
|
|
1786
|
+
|
|
957
1787
|
// src/components/Divider/Divider.tsx
|
|
958
1788
|
import { useId } from "react";
|
|
959
1789
|
import { Separator } from "@base-ui/react/separator";
|
|
960
1790
|
|
|
961
1791
|
// src/components/SquigglyWave/SquigglyWave.tsx
|
|
962
|
-
import { useEffect as
|
|
963
|
-
import { jsx as
|
|
1792
|
+
import { useEffect as useEffect4, useRef as useRef8 } from "react";
|
|
1793
|
+
import { jsx as jsx19, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
964
1794
|
var WAVE_LENGTH = 40;
|
|
965
1795
|
var WAVE_AMPLITUDE = 3;
|
|
966
1796
|
var WAVE_MIDDLE = 6;
|
|
967
1797
|
var STROKE_CAP = 2;
|
|
1798
|
+
var WAVE_PERIOD = 1500;
|
|
968
1799
|
function wavePath(from, to, phase) {
|
|
969
1800
|
const start = from + STROKE_CAP;
|
|
970
1801
|
const end = to - STROKE_CAP;
|
|
@@ -981,15 +1812,15 @@ function linePath(from, to) {
|
|
|
981
1812
|
return end < start ? "" : `M${start} ${WAVE_MIDDLE}L${end} ${WAVE_MIDDLE}`;
|
|
982
1813
|
}
|
|
983
1814
|
function SquigglyWave(props) {
|
|
984
|
-
const svgRef =
|
|
985
|
-
const waveRef =
|
|
986
|
-
const restRef =
|
|
987
|
-
const dotRef =
|
|
988
|
-
const span =
|
|
1815
|
+
const svgRef = useRef8(null);
|
|
1816
|
+
const waveRef = useRef8(null);
|
|
1817
|
+
const restRef = useRef8(null);
|
|
1818
|
+
const dotRef = useRef8(null);
|
|
1819
|
+
const span = useRef8(props.span);
|
|
989
1820
|
span.current = props.span;
|
|
990
1821
|
const still = props.still ?? false;
|
|
991
1822
|
const vertical = props.vertical ?? false;
|
|
992
|
-
|
|
1823
|
+
useEffect4(() => {
|
|
993
1824
|
const svg = svgRef.current;
|
|
994
1825
|
const wave = waveRef.current;
|
|
995
1826
|
const rest = restRef.current;
|
|
@@ -1010,7 +1841,7 @@ function SquigglyWave(props) {
|
|
|
1010
1841
|
current.from += (next.from - current.from) * 0.15;
|
|
1011
1842
|
current.to += (next.to - current.to) * 0.15;
|
|
1012
1843
|
}
|
|
1013
|
-
const phase = reduced ? 0 : now /
|
|
1844
|
+
const phase = reduced ? 0 : now / WAVE_PERIOD * 2 * Math.PI;
|
|
1014
1845
|
wave.setAttribute("d", wavePath(current.from, current.to, phase));
|
|
1015
1846
|
rest.setAttribute(
|
|
1016
1847
|
"d",
|
|
@@ -1032,15 +1863,15 @@ function SquigglyWave(props) {
|
|
|
1032
1863
|
frame = requestAnimationFrame(draw);
|
|
1033
1864
|
return () => cancelAnimationFrame(frame);
|
|
1034
1865
|
}, [still, vertical]);
|
|
1035
|
-
return /* @__PURE__ */
|
|
1036
|
-
/* @__PURE__ */
|
|
1037
|
-
/* @__PURE__ */
|
|
1038
|
-
/* @__PURE__ */
|
|
1866
|
+
return /* @__PURE__ */ jsx19("svg", { ref: svgRef, className: "avl-squiggly-wave", "aria-hidden": true, children: /* @__PURE__ */ jsxs11("g", { transform: vertical ? "matrix(0 1 1 0 0 0)" : void 0, children: [
|
|
1867
|
+
/* @__PURE__ */ jsx19("path", { ref: restRef, className: "avl-squiggly-wave-rest" }),
|
|
1868
|
+
/* @__PURE__ */ jsx19("path", { ref: waveRef }),
|
|
1869
|
+
/* @__PURE__ */ jsx19("path", { ref: dotRef })
|
|
1039
1870
|
] }) });
|
|
1040
1871
|
}
|
|
1041
1872
|
|
|
1042
1873
|
// src/components/Divider/Divider.tsx
|
|
1043
|
-
import { jsx as
|
|
1874
|
+
import { jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1044
1875
|
function Divider({
|
|
1045
1876
|
label,
|
|
1046
1877
|
squiggly = false,
|
|
@@ -1050,7 +1881,7 @@ function Divider({
|
|
|
1050
1881
|
const labelId = useId();
|
|
1051
1882
|
const hasLabel = label != null;
|
|
1052
1883
|
const vertical = props.orientation === "vertical";
|
|
1053
|
-
const wave = squiggly && /* @__PURE__ */
|
|
1884
|
+
const wave = squiggly && /* @__PURE__ */ jsx20("span", { className: "avl-divider-wave", children: /* @__PURE__ */ jsx20(
|
|
1054
1885
|
SquigglyWave,
|
|
1055
1886
|
{
|
|
1056
1887
|
still: true,
|
|
@@ -1058,7 +1889,7 @@ function Divider({
|
|
|
1058
1889
|
span: (width) => ({ from: 0, to: width, snap: true })
|
|
1059
1890
|
}
|
|
1060
1891
|
) });
|
|
1061
|
-
return /* @__PURE__ */
|
|
1892
|
+
return /* @__PURE__ */ jsxs12(
|
|
1062
1893
|
Separator,
|
|
1063
1894
|
{
|
|
1064
1895
|
"aria-labelledby": hasLabel ? labelId : void 0,
|
|
@@ -1073,7 +1904,7 @@ function Divider({
|
|
|
1073
1904
|
),
|
|
1074
1905
|
children: [
|
|
1075
1906
|
wave,
|
|
1076
|
-
hasLabel && /* @__PURE__ */
|
|
1907
|
+
hasLabel && /* @__PURE__ */ jsx20("span", { id: labelId, className: "avl-divider-label", children: label }),
|
|
1077
1908
|
hasLabel && wave
|
|
1078
1909
|
]
|
|
1079
1910
|
}
|
|
@@ -1081,49 +1912,17 @@ function Divider({
|
|
|
1081
1912
|
}
|
|
1082
1913
|
|
|
1083
1914
|
// src/components/FAB/FAB.tsx
|
|
1084
|
-
import {
|
|
1915
|
+
import { useRef as useRef9 } from "react";
|
|
1085
1916
|
import {
|
|
1086
|
-
Button as
|
|
1917
|
+
Button as BaseButton5
|
|
1087
1918
|
} from "@base-ui/react/button";
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
label,
|
|
1092
|
-
size = "normal",
|
|
1093
|
-
sticky = true,
|
|
1094
|
-
color,
|
|
1095
|
-
fillType,
|
|
1096
|
-
className,
|
|
1097
|
-
ref,
|
|
1098
|
-
...props
|
|
1099
|
-
}) {
|
|
1100
|
-
const local = useRef5(null);
|
|
1101
|
-
useMagnet(local, sticky && !props.disabled);
|
|
1102
|
-
return /* @__PURE__ */ jsxs10(
|
|
1103
|
-
BaseButton4,
|
|
1104
|
-
{
|
|
1105
|
-
...props,
|
|
1106
|
-
ref: mergeRefs(local, ref),
|
|
1107
|
-
className: withClass(
|
|
1108
|
-
cx(
|
|
1109
|
-
"avl-fab",
|
|
1110
|
-
colorClass(color, fillType),
|
|
1111
|
-
`avl-fab-size-${size}`,
|
|
1112
|
-
label && "avl-fab-extended"
|
|
1113
|
-
),
|
|
1114
|
-
className
|
|
1115
|
-
),
|
|
1116
|
-
children: [
|
|
1117
|
-
/* @__PURE__ */ jsx16(Icon, { name: icon }),
|
|
1118
|
-
label
|
|
1119
|
-
]
|
|
1120
|
-
}
|
|
1121
|
-
);
|
|
1122
|
-
}
|
|
1919
|
+
|
|
1920
|
+
// src/components/FAB/magnet.ts
|
|
1921
|
+
import { useEffect as useEffect5 } from "react";
|
|
1123
1922
|
var STICK_RANGE = 24;
|
|
1124
1923
|
var STICK_STRENGTH = 0.35;
|
|
1125
1924
|
function useMagnet(ref, enabled) {
|
|
1126
|
-
|
|
1925
|
+
useEffect5(() => {
|
|
1127
1926
|
const el = ref.current;
|
|
1128
1927
|
if (!el || !enabled) return;
|
|
1129
1928
|
if (!matchMedia("(pointer: fine)").matches) return;
|
|
@@ -1180,11 +1979,149 @@ function useMagnet(ref, enabled) {
|
|
|
1180
1979
|
}, [ref, enabled]);
|
|
1181
1980
|
}
|
|
1182
1981
|
|
|
1982
|
+
// src/components/FAB/FAB.tsx
|
|
1983
|
+
import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1984
|
+
function FAB({
|
|
1985
|
+
icon,
|
|
1986
|
+
label,
|
|
1987
|
+
size = "normal",
|
|
1988
|
+
sticky = true,
|
|
1989
|
+
color,
|
|
1990
|
+
fillType,
|
|
1991
|
+
className,
|
|
1992
|
+
ref,
|
|
1993
|
+
...props
|
|
1994
|
+
}) {
|
|
1995
|
+
const local = useRef9(null);
|
|
1996
|
+
if (process.env.NODE_ENV !== "production" && !label) {
|
|
1997
|
+
checkName(
|
|
1998
|
+
props,
|
|
1999
|
+
"FAB",
|
|
2000
|
+
'<FAB icon="add" aria-label="Create" /> // or <FAB icon="add" label="Create" />',
|
|
2001
|
+
"fab.md"
|
|
2002
|
+
);
|
|
2003
|
+
}
|
|
2004
|
+
useMagnet(local, sticky && !props.disabled);
|
|
2005
|
+
return /* @__PURE__ */ jsxs13(
|
|
2006
|
+
BaseButton5,
|
|
2007
|
+
{
|
|
2008
|
+
...props,
|
|
2009
|
+
ref: mergeRefs(local, ref),
|
|
2010
|
+
className: withClass(
|
|
2011
|
+
cx(
|
|
2012
|
+
"avl-fab",
|
|
2013
|
+
colorClass(color, fillType),
|
|
2014
|
+
`avl-fab-size-${size}`,
|
|
2015
|
+
label && "avl-fab-extended"
|
|
2016
|
+
),
|
|
2017
|
+
className
|
|
2018
|
+
),
|
|
2019
|
+
children: [
|
|
2020
|
+
/* @__PURE__ */ jsx21(Icon, { name: icon }),
|
|
2021
|
+
label
|
|
2022
|
+
]
|
|
2023
|
+
}
|
|
2024
|
+
);
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
// src/components/FABMenu/FABMenu.tsx
|
|
2028
|
+
import { createContext as createContext4, useContext as useContext10, useRef as useRef10, useState as useState6 } from "react";
|
|
2029
|
+
import { Menu as BaseMenu } from "@base-ui/react/menu";
|
|
2030
|
+
import { jsx as jsx22, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2031
|
+
var FABMenuColorContext = createContext4("primary");
|
|
2032
|
+
function FABMenu({
|
|
2033
|
+
icon,
|
|
2034
|
+
closeIcon = "close",
|
|
2035
|
+
"aria-label": ariaLabel,
|
|
2036
|
+
color = "primary",
|
|
2037
|
+
fillType,
|
|
2038
|
+
side = "top",
|
|
2039
|
+
align = "end",
|
|
2040
|
+
sticky = true,
|
|
2041
|
+
className,
|
|
2042
|
+
children,
|
|
2043
|
+
...props
|
|
2044
|
+
}) {
|
|
2045
|
+
const avl = useContext10(AnvilContext);
|
|
2046
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2047
|
+
checkRoot(avl !== null, "FABMenu");
|
|
2048
|
+
}
|
|
2049
|
+
const [localOpen, setLocalOpen] = useState6(props.defaultOpen ?? false);
|
|
2050
|
+
const open = props.open ?? localOpen;
|
|
2051
|
+
const trigger = useRef10(null);
|
|
2052
|
+
useMagnet(trigger, sticky && !open && !props.disabled);
|
|
2053
|
+
return /* @__PURE__ */ jsx22(FABMenuColorContext, { value: color, children: /* @__PURE__ */ jsxs14(
|
|
2054
|
+
BaseMenu.Root,
|
|
2055
|
+
{
|
|
2056
|
+
...props,
|
|
2057
|
+
onOpenChange: (next, details) => {
|
|
2058
|
+
setLocalOpen(next);
|
|
2059
|
+
props.onOpenChange?.(next, details);
|
|
2060
|
+
},
|
|
2061
|
+
children: [
|
|
2062
|
+
/* @__PURE__ */ jsxs14(
|
|
2063
|
+
BaseMenu.Trigger,
|
|
2064
|
+
{
|
|
2065
|
+
ref: trigger,
|
|
2066
|
+
"aria-label": ariaLabel,
|
|
2067
|
+
className: cx(
|
|
2068
|
+
"avl-fab avl-fab-size-normal avl-fab-menu-trigger",
|
|
2069
|
+
colorClass(color, fillType),
|
|
2070
|
+
className
|
|
2071
|
+
),
|
|
2072
|
+
children: [
|
|
2073
|
+
/* @__PURE__ */ jsx22(Icon, { name: icon, className: "avl-fab-menu-icon-open" }),
|
|
2074
|
+
/* @__PURE__ */ jsx22(
|
|
2075
|
+
Icon,
|
|
2076
|
+
{
|
|
2077
|
+
name: closeIcon,
|
|
2078
|
+
className: "avl-fab-menu-icon-close"
|
|
2079
|
+
}
|
|
2080
|
+
)
|
|
2081
|
+
]
|
|
2082
|
+
}
|
|
2083
|
+
),
|
|
2084
|
+
/* @__PURE__ */ jsx22(BaseMenu.Portal, { container: avl?.rootRef, children: /* @__PURE__ */ jsx22(
|
|
2085
|
+
BaseMenu.Positioner,
|
|
2086
|
+
{
|
|
2087
|
+
className: "avl-menu-positioner",
|
|
2088
|
+
side,
|
|
2089
|
+
align,
|
|
2090
|
+
sideOffset: 8,
|
|
2091
|
+
children: /* @__PURE__ */ jsx22(BaseMenu.Popup, { className: "avl-fab-menu-popup", children })
|
|
2092
|
+
}
|
|
2093
|
+
) })
|
|
2094
|
+
]
|
|
2095
|
+
}
|
|
2096
|
+
) });
|
|
2097
|
+
}
|
|
2098
|
+
function FABMenuItem({
|
|
2099
|
+
icon,
|
|
2100
|
+
color,
|
|
2101
|
+
className,
|
|
2102
|
+
children,
|
|
2103
|
+
...props
|
|
2104
|
+
}) {
|
|
2105
|
+
const menuColor = useContext10(FABMenuColorContext);
|
|
2106
|
+
return /* @__PURE__ */ jsxs14(
|
|
2107
|
+
BaseMenu.Item,
|
|
2108
|
+
{
|
|
2109
|
+
...props,
|
|
2110
|
+
"data-color": color ?? menuColor,
|
|
2111
|
+
className: withClass("avl-fab-menu-item", className),
|
|
2112
|
+
children: [
|
|
2113
|
+
/* @__PURE__ */ jsx22(Icon, { name: icon }),
|
|
2114
|
+
children
|
|
2115
|
+
]
|
|
2116
|
+
}
|
|
2117
|
+
);
|
|
2118
|
+
}
|
|
2119
|
+
|
|
1183
2120
|
// src/components/Field/Field.tsx
|
|
1184
2121
|
import { Field as BaseField } from "@base-ui/react/field";
|
|
1185
|
-
import { jsx as
|
|
2122
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
1186
2123
|
function Field({ className, ...props }) {
|
|
1187
|
-
return /* @__PURE__ */
|
|
2124
|
+
return /* @__PURE__ */ jsx23(
|
|
1188
2125
|
BaseField.Root,
|
|
1189
2126
|
{
|
|
1190
2127
|
...props,
|
|
@@ -1196,7 +2133,7 @@ function FieldDescription({
|
|
|
1196
2133
|
className,
|
|
1197
2134
|
...props
|
|
1198
2135
|
}) {
|
|
1199
|
-
return /* @__PURE__ */
|
|
2136
|
+
return /* @__PURE__ */ jsx23(
|
|
1200
2137
|
BaseField.Description,
|
|
1201
2138
|
{
|
|
1202
2139
|
...props,
|
|
@@ -1205,7 +2142,7 @@ function FieldDescription({
|
|
|
1205
2142
|
);
|
|
1206
2143
|
}
|
|
1207
2144
|
function FieldError({ className, ...props }) {
|
|
1208
|
-
return /* @__PURE__ */
|
|
2145
|
+
return /* @__PURE__ */ jsx23(
|
|
1209
2146
|
BaseField.Error,
|
|
1210
2147
|
{
|
|
1211
2148
|
...props,
|
|
@@ -1214,34 +2151,10 @@ function FieldError({ className, ...props }) {
|
|
|
1214
2151
|
);
|
|
1215
2152
|
}
|
|
1216
2153
|
|
|
1217
|
-
// src/components/IconButton/IconButton.tsx
|
|
1218
|
-
import {
|
|
1219
|
-
Button as BaseButton5
|
|
1220
|
-
} from "@base-ui/react/button";
|
|
1221
|
-
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1222
|
-
function IconButton({
|
|
1223
|
-
icon,
|
|
1224
|
-
color,
|
|
1225
|
-
fillType,
|
|
1226
|
-
className,
|
|
1227
|
-
...props
|
|
1228
|
-
}) {
|
|
1229
|
-
return /* @__PURE__ */ jsx18(
|
|
1230
|
-
BaseButton5,
|
|
1231
|
-
{
|
|
1232
|
-
...props,
|
|
1233
|
-
className: withClass(
|
|
1234
|
-
`avl-icon-button ${colorClass(color, fillType)}`,
|
|
1235
|
-
className
|
|
1236
|
-
),
|
|
1237
|
-
children: /* @__PURE__ */ jsx18(Icon, { name: icon })
|
|
1238
|
-
}
|
|
1239
|
-
);
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
2154
|
// src/components/Input/Input.tsx
|
|
1243
2155
|
import { Input as BaseInput } from "@base-ui/react/input";
|
|
1244
|
-
import {
|
|
2156
|
+
import { useContext as useContext11 } from "react";
|
|
2157
|
+
import { jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1245
2158
|
function Input({
|
|
1246
2159
|
label,
|
|
1247
2160
|
size = "normal",
|
|
@@ -1249,7 +2162,11 @@ function Input({
|
|
|
1249
2162
|
placeholder,
|
|
1250
2163
|
...props
|
|
1251
2164
|
}) {
|
|
1252
|
-
|
|
2165
|
+
const avl = useContext11(AnvilContext);
|
|
2166
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2167
|
+
checkRoot(avl !== null, "Input", OUTSIDE_ROOT);
|
|
2168
|
+
}
|
|
2169
|
+
return /* @__PURE__ */ jsxs15(
|
|
1253
2170
|
"label",
|
|
1254
2171
|
{
|
|
1255
2172
|
className: cx(
|
|
@@ -1259,7 +2176,7 @@ function Input({
|
|
|
1259
2176
|
className
|
|
1260
2177
|
),
|
|
1261
2178
|
children: [
|
|
1262
|
-
/* @__PURE__ */
|
|
2179
|
+
/* @__PURE__ */ jsx24(
|
|
1263
2180
|
BaseInput,
|
|
1264
2181
|
{
|
|
1265
2182
|
...props,
|
|
@@ -1267,19 +2184,99 @@ function Input({
|
|
|
1267
2184
|
className: "avl-input-field"
|
|
1268
2185
|
}
|
|
1269
2186
|
),
|
|
1270
|
-
label != null && /* @__PURE__ */
|
|
1271
|
-
/* @__PURE__ */
|
|
2187
|
+
label != null && /* @__PURE__ */ jsx24("span", { className: "avl-input-label", children: label }),
|
|
2188
|
+
/* @__PURE__ */ jsx24("fieldset", { "aria-hidden": true, className: "avl-input-outline", children: /* @__PURE__ */ jsx24("legend", { children: label != null && size === "normal" && /* @__PURE__ */ jsx24("span", { children: label }) }) })
|
|
1272
2189
|
]
|
|
1273
2190
|
}
|
|
1274
2191
|
);
|
|
1275
2192
|
}
|
|
1276
2193
|
|
|
2194
|
+
// src/components/Kbd/Kbd.tsx
|
|
2195
|
+
import { useEffect as useEffect6, useState as useState7 } from "react";
|
|
2196
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
2197
|
+
function Kbd({
|
|
2198
|
+
listen = true,
|
|
2199
|
+
listenFor,
|
|
2200
|
+
className,
|
|
2201
|
+
children,
|
|
2202
|
+
...props
|
|
2203
|
+
}) {
|
|
2204
|
+
const key = listen ? listenFor ?? keyFromText(children) : null;
|
|
2205
|
+
const pressed = useKeyHeld(key);
|
|
2206
|
+
return /* @__PURE__ */ jsx25(
|
|
2207
|
+
"kbd",
|
|
2208
|
+
{
|
|
2209
|
+
...props,
|
|
2210
|
+
"data-pressed": pressed || void 0,
|
|
2211
|
+
className: cx("avl-kbd", className),
|
|
2212
|
+
children
|
|
2213
|
+
}
|
|
2214
|
+
);
|
|
2215
|
+
}
|
|
2216
|
+
var aliases = {
|
|
2217
|
+
"\u2318": "meta",
|
|
2218
|
+
cmd: "meta",
|
|
2219
|
+
command: "meta",
|
|
2220
|
+
win: "meta",
|
|
2221
|
+
"\u2325": "alt",
|
|
2222
|
+
opt: "alt",
|
|
2223
|
+
option: "alt",
|
|
2224
|
+
"\u21E7": "shift",
|
|
2225
|
+
"\u2303": "control",
|
|
2226
|
+
ctrl: "control",
|
|
2227
|
+
"\u21B5": "enter",
|
|
2228
|
+
"\u23CE": "enter",
|
|
2229
|
+
return: "enter",
|
|
2230
|
+
"\u238B": "escape",
|
|
2231
|
+
esc: "escape",
|
|
2232
|
+
"\u232B": "backspace",
|
|
2233
|
+
del: "delete",
|
|
2234
|
+
"\u21E5": "tab",
|
|
2235
|
+
space: " ",
|
|
2236
|
+
"\u2423": " ",
|
|
2237
|
+
"\u2190": "arrowleft",
|
|
2238
|
+
"\u2192": "arrowright",
|
|
2239
|
+
"\u2191": "arrowup",
|
|
2240
|
+
"\u2193": "arrowdown"
|
|
2241
|
+
};
|
|
2242
|
+
function keyFromText(children) {
|
|
2243
|
+
if (typeof children !== "string" && typeof children !== "number")
|
|
2244
|
+
return null;
|
|
2245
|
+
const text = String(children).trim().toLowerCase();
|
|
2246
|
+
return aliases[text] ?? (text || null);
|
|
2247
|
+
}
|
|
2248
|
+
function useKeyHeld(key) {
|
|
2249
|
+
const [held, setHeld] = useState7(false);
|
|
2250
|
+
useEffect6(() => {
|
|
2251
|
+
if (!key) return;
|
|
2252
|
+
const target = key.toLowerCase();
|
|
2253
|
+
const matches = (event) => event.key.toLowerCase() === target;
|
|
2254
|
+
const down = (event) => {
|
|
2255
|
+
if (matches(event)) setHeld(true);
|
|
2256
|
+
};
|
|
2257
|
+
const up = (event) => {
|
|
2258
|
+
if (matches(event) || event.key === "Meta") setHeld(false);
|
|
2259
|
+
};
|
|
2260
|
+
const release = () => setHeld(false);
|
|
2261
|
+
document.addEventListener("keydown", down);
|
|
2262
|
+
document.addEventListener("keyup", up);
|
|
2263
|
+
window.addEventListener("blur", release);
|
|
2264
|
+
return () => {
|
|
2265
|
+
document.removeEventListener("keydown", down);
|
|
2266
|
+
document.removeEventListener("keyup", up);
|
|
2267
|
+
window.removeEventListener("blur", release);
|
|
2268
|
+
setHeld(false);
|
|
2269
|
+
};
|
|
2270
|
+
}, [key]);
|
|
2271
|
+
return held;
|
|
2272
|
+
}
|
|
2273
|
+
|
|
1277
2274
|
// src/components/List/List.tsx
|
|
1278
2275
|
import { useRender } from "@base-ui/react/use-render";
|
|
1279
2276
|
import { mergeProps } from "@base-ui/react/merge-props";
|
|
1280
|
-
import { Fragment, jsx as
|
|
2277
|
+
import { Fragment as Fragment2, jsx as jsx26, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1281
2278
|
function List({ divided = false, className, ...props }) {
|
|
1282
|
-
return /* @__PURE__ */
|
|
2279
|
+
return /* @__PURE__ */ jsx26(
|
|
1283
2280
|
"ul",
|
|
1284
2281
|
{
|
|
1285
2282
|
...props,
|
|
@@ -1306,38 +2303,41 @@ function ListItem({
|
|
|
1306
2303
|
description != null && "avl-list-item-two-line",
|
|
1307
2304
|
className
|
|
1308
2305
|
),
|
|
1309
|
-
children: /* @__PURE__ */
|
|
1310
|
-
start != null && /* @__PURE__ */
|
|
1311
|
-
/* @__PURE__ */
|
|
1312
|
-
/* @__PURE__ */
|
|
1313
|
-
description != null && /* @__PURE__ */
|
|
2306
|
+
children: /* @__PURE__ */ jsxs16(Fragment2, { children: [
|
|
2307
|
+
start != null && /* @__PURE__ */ jsx26("span", { className: "avl-list-item-start", children: start }),
|
|
2308
|
+
/* @__PURE__ */ jsxs16("span", { className: "avl-list-item-text", children: [
|
|
2309
|
+
/* @__PURE__ */ jsx26("span", { className: "avl-list-item-label", children: label }),
|
|
2310
|
+
description != null && /* @__PURE__ */ jsx26("span", { className: "avl-list-item-description", children: description })
|
|
1314
2311
|
] }),
|
|
1315
|
-
end != null && /* @__PURE__ */
|
|
2312
|
+
end != null && /* @__PURE__ */ jsx26("span", { className: "avl-list-item-end", children: end })
|
|
1316
2313
|
] })
|
|
1317
2314
|
},
|
|
1318
2315
|
props
|
|
1319
2316
|
)
|
|
1320
2317
|
});
|
|
1321
|
-
return /* @__PURE__ */
|
|
2318
|
+
return /* @__PURE__ */ jsx26("li", { className: "avl-list-item-wrapper", children: row });
|
|
1322
2319
|
}
|
|
1323
2320
|
|
|
1324
2321
|
// src/components/Menu/Menu.tsx
|
|
1325
|
-
import { createContext as
|
|
1326
|
-
import { Menu as
|
|
1327
|
-
import { jsx as
|
|
2322
|
+
import { createContext as createContext5, useContext as useContext12 } from "react";
|
|
2323
|
+
import { Menu as BaseMenu2 } from "@base-ui/react/menu";
|
|
2324
|
+
import { jsx as jsx27, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1328
2325
|
function Menu(props) {
|
|
1329
|
-
return /* @__PURE__ */
|
|
2326
|
+
return /* @__PURE__ */ jsx27(BaseMenu2.Root, { ...props });
|
|
1330
2327
|
}
|
|
1331
2328
|
function MenuTrigger({ className, ...props }) {
|
|
1332
|
-
|
|
1333
|
-
|
|
2329
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2330
|
+
checkAsChild(props, "MenuTrigger", "menu.md");
|
|
2331
|
+
}
|
|
2332
|
+
return /* @__PURE__ */ jsx27(
|
|
2333
|
+
BaseMenu2.Trigger,
|
|
1334
2334
|
{
|
|
1335
2335
|
...props,
|
|
1336
2336
|
className: withClass("avl-menu-trigger", className)
|
|
1337
2337
|
}
|
|
1338
2338
|
);
|
|
1339
2339
|
}
|
|
1340
|
-
var SubmenuContext =
|
|
2340
|
+
var SubmenuContext = createContext5(false);
|
|
1341
2341
|
function MenuPopup({
|
|
1342
2342
|
side,
|
|
1343
2343
|
align,
|
|
@@ -1346,20 +2346,23 @@ function MenuPopup({
|
|
|
1346
2346
|
className,
|
|
1347
2347
|
...props
|
|
1348
2348
|
}) {
|
|
1349
|
-
const avl =
|
|
1350
|
-
|
|
2349
|
+
const avl = useContext12(AnvilContext);
|
|
2350
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2351
|
+
checkRoot(avl !== null, "MenuPopup");
|
|
2352
|
+
}
|
|
2353
|
+
const isSubmenu = useContext12(SubmenuContext);
|
|
1351
2354
|
return (
|
|
1352
2355
|
// Into the AnvilRoot, not `body`, so the popup sees the theme variables
|
|
1353
|
-
/* @__PURE__ */
|
|
1354
|
-
|
|
2356
|
+
/* @__PURE__ */ jsx27(BaseMenu2.Portal, { container: avl?.rootRef, children: /* @__PURE__ */ jsx27(
|
|
2357
|
+
BaseMenu2.Positioner,
|
|
1355
2358
|
{
|
|
1356
2359
|
className: "avl-menu-positioner",
|
|
1357
2360
|
side,
|
|
1358
2361
|
align,
|
|
1359
2362
|
sideOffset: sideOffset ?? (isSubmenu ? 8 : 4),
|
|
1360
2363
|
alignOffset: alignOffset ?? (isSubmenu ? -4 : void 0),
|
|
1361
|
-
children: /* @__PURE__ */
|
|
1362
|
-
|
|
2364
|
+
children: /* @__PURE__ */ jsx27(
|
|
2365
|
+
BaseMenu2.Popup,
|
|
1363
2366
|
{
|
|
1364
2367
|
...props,
|
|
1365
2368
|
className: withClass("avl-menu-popup", className)
|
|
@@ -1370,7 +2373,7 @@ function MenuPopup({
|
|
|
1370
2373
|
);
|
|
1371
2374
|
}
|
|
1372
2375
|
function MenuSubmenu(props) {
|
|
1373
|
-
return /* @__PURE__ */
|
|
2376
|
+
return /* @__PURE__ */ jsx27(SubmenuContext, { value: true, children: /* @__PURE__ */ jsx27(BaseMenu2.SubmenuRoot, { ...props }) });
|
|
1374
2377
|
}
|
|
1375
2378
|
function MenuSubmenuTrigger({
|
|
1376
2379
|
startIcon,
|
|
@@ -1378,22 +2381,22 @@ function MenuSubmenuTrigger({
|
|
|
1378
2381
|
children,
|
|
1379
2382
|
...props
|
|
1380
2383
|
}) {
|
|
1381
|
-
return /* @__PURE__ */
|
|
1382
|
-
|
|
2384
|
+
return /* @__PURE__ */ jsxs17(
|
|
2385
|
+
BaseMenu2.SubmenuTrigger,
|
|
1383
2386
|
{
|
|
1384
2387
|
...props,
|
|
1385
2388
|
className: withClass("avl-menu-item", className),
|
|
1386
2389
|
children: [
|
|
1387
|
-
startIcon && /* @__PURE__ */
|
|
1388
|
-
/* @__PURE__ */
|
|
1389
|
-
/* @__PURE__ */
|
|
2390
|
+
startIcon && /* @__PURE__ */ jsx27(Icon, { name: startIcon }),
|
|
2391
|
+
/* @__PURE__ */ jsx27("span", { className: "avl-menu-item-label", children }),
|
|
2392
|
+
/* @__PURE__ */ jsx27(Icon, { name: "arrow_right" })
|
|
1390
2393
|
]
|
|
1391
2394
|
}
|
|
1392
2395
|
);
|
|
1393
2396
|
}
|
|
1394
2397
|
function MenuGroup({ className, ...props }) {
|
|
1395
|
-
return /* @__PURE__ */
|
|
1396
|
-
|
|
2398
|
+
return /* @__PURE__ */ jsx27(
|
|
2399
|
+
BaseMenu2.Group,
|
|
1397
2400
|
{
|
|
1398
2401
|
...props,
|
|
1399
2402
|
className: withClass("avl-menu-group", className)
|
|
@@ -1407,51 +2410,155 @@ function MenuItem({
|
|
|
1407
2410
|
children,
|
|
1408
2411
|
...props
|
|
1409
2412
|
}) {
|
|
1410
|
-
return /* @__PURE__ */
|
|
1411
|
-
|
|
2413
|
+
return /* @__PURE__ */ jsxs17(
|
|
2414
|
+
BaseMenu2.Item,
|
|
1412
2415
|
{
|
|
1413
2416
|
...props,
|
|
1414
2417
|
className: withClass("avl-menu-item", className),
|
|
1415
2418
|
children: [
|
|
1416
|
-
startIcon && /* @__PURE__ */
|
|
1417
|
-
/* @__PURE__ */
|
|
1418
|
-
endIcon && /* @__PURE__ */
|
|
2419
|
+
startIcon && /* @__PURE__ */ jsx27(Icon, { name: startIcon }),
|
|
2420
|
+
/* @__PURE__ */ jsx27("span", { className: "avl-menu-item-label", children }),
|
|
2421
|
+
endIcon && /* @__PURE__ */ jsx27(Icon, { name: endIcon })
|
|
1419
2422
|
]
|
|
1420
2423
|
}
|
|
1421
2424
|
);
|
|
1422
2425
|
}
|
|
1423
2426
|
|
|
1424
|
-
// src/components/
|
|
1425
|
-
import {
|
|
1426
|
-
import {
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
defaultOpen = false,
|
|
1431
|
-
...props
|
|
1432
|
-
}) {
|
|
1433
|
-
const state = useMorphOpen({
|
|
1434
|
-
morph: morph2,
|
|
1435
|
-
open: props.open,
|
|
1436
|
-
defaultOpen,
|
|
1437
|
-
onOpenChange: props.onOpenChange
|
|
1438
|
-
});
|
|
1439
|
-
return /* @__PURE__ */ jsx22(MorphContext, { value: state.refs, children: /* @__PURE__ */ jsx22(
|
|
1440
|
-
BasePopover.Root,
|
|
2427
|
+
// src/components/Menubar/Menubar.tsx
|
|
2428
|
+
import { Menubar as BaseMenubar } from "@base-ui/react/menubar";
|
|
2429
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
2430
|
+
function Menubar({ className, ...props }) {
|
|
2431
|
+
return /* @__PURE__ */ jsx28(
|
|
2432
|
+
BaseMenubar,
|
|
1441
2433
|
{
|
|
1442
2434
|
...props,
|
|
1443
|
-
|
|
1444
|
-
onOpenChange: state.onOpenChange
|
|
2435
|
+
className: withClass("avl-menubar", className)
|
|
1445
2436
|
}
|
|
1446
|
-
)
|
|
2437
|
+
);
|
|
1447
2438
|
}
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
2439
|
+
|
|
2440
|
+
// src/components/Accordion/Accordion.tsx
|
|
2441
|
+
import { Accordion as BaseAccordion } from "@base-ui/react/accordion";
|
|
2442
|
+
import { jsx as jsx29, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2443
|
+
function Accordion({ className, ...props }) {
|
|
2444
|
+
return /* @__PURE__ */ jsx29(
|
|
2445
|
+
BaseAccordion.Root,
|
|
2446
|
+
{
|
|
2447
|
+
...props,
|
|
2448
|
+
className: withClass("avl-accordion", className)
|
|
2449
|
+
}
|
|
2450
|
+
);
|
|
2451
|
+
}
|
|
2452
|
+
function AccordionItem({ className, ...props }) {
|
|
2453
|
+
return /* @__PURE__ */ jsx29(
|
|
2454
|
+
BaseAccordion.Item,
|
|
2455
|
+
{
|
|
2456
|
+
...props,
|
|
2457
|
+
className: withClass("avl-accordion-item", className)
|
|
2458
|
+
}
|
|
2459
|
+
);
|
|
2460
|
+
}
|
|
2461
|
+
function AccordionTrigger({
|
|
2462
|
+
as: Heading = "h3",
|
|
2463
|
+
className,
|
|
2464
|
+
children,
|
|
2465
|
+
...props
|
|
2466
|
+
}) {
|
|
2467
|
+
return /* @__PURE__ */ jsx29(
|
|
2468
|
+
BaseAccordion.Header,
|
|
2469
|
+
{
|
|
2470
|
+
className: "avl-accordion-header",
|
|
2471
|
+
render: /* @__PURE__ */ jsx29(Heading, {}),
|
|
2472
|
+
children: /* @__PURE__ */ jsxs18(
|
|
2473
|
+
BaseAccordion.Trigger,
|
|
2474
|
+
{
|
|
2475
|
+
...props,
|
|
2476
|
+
className: withClass("avl-accordion-trigger", className),
|
|
2477
|
+
children: [
|
|
2478
|
+
/* @__PURE__ */ jsx29("span", { className: "avl-accordion-trigger-label", children }),
|
|
2479
|
+
/* @__PURE__ */ jsx29(Icon, { name: "keyboard_arrow_down" })
|
|
2480
|
+
]
|
|
2481
|
+
}
|
|
2482
|
+
)
|
|
2483
|
+
}
|
|
2484
|
+
);
|
|
2485
|
+
}
|
|
2486
|
+
function AccordionPanel({
|
|
2487
|
+
className,
|
|
2488
|
+
children,
|
|
2489
|
+
...props
|
|
2490
|
+
}) {
|
|
2491
|
+
return /* @__PURE__ */ jsx29(
|
|
2492
|
+
BaseAccordion.Panel,
|
|
2493
|
+
{
|
|
2494
|
+
...props,
|
|
2495
|
+
className: withClass("avl-accordion-panel", className),
|
|
2496
|
+
children: /* @__PURE__ */ jsx29("div", { className: "avl-accordion-panel-content", children })
|
|
2497
|
+
}
|
|
2498
|
+
);
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
// src/components/ContextMenu/ContextMenu.tsx
|
|
2502
|
+
import { ContextMenu as BaseContextMenu } from "@base-ui/react/context-menu";
|
|
2503
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
2504
|
+
function ContextMenu(props) {
|
|
2505
|
+
return /* @__PURE__ */ jsx30(BaseContextMenu.Root, { ...props });
|
|
2506
|
+
}
|
|
2507
|
+
function ContextMenuTrigger({
|
|
2508
|
+
className,
|
|
2509
|
+
...props
|
|
2510
|
+
}) {
|
|
2511
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2512
|
+
checkAsChild(
|
|
2513
|
+
props,
|
|
2514
|
+
"ContextMenuTrigger",
|
|
2515
|
+
"context-menu.md",
|
|
2516
|
+
"<ContextMenuTrigger render={<Card />}>...</ContextMenuTrigger>"
|
|
2517
|
+
);
|
|
2518
|
+
}
|
|
2519
|
+
return /* @__PURE__ */ jsx30(
|
|
2520
|
+
BaseContextMenu.Trigger,
|
|
2521
|
+
{
|
|
2522
|
+
...props,
|
|
2523
|
+
className: withClass("avl-context-menu-trigger", className)
|
|
2524
|
+
}
|
|
2525
|
+
);
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
// src/components/Popover/Popover.tsx
|
|
2529
|
+
import { useContext as useContext13 } from "react";
|
|
2530
|
+
import { Popover as BasePopover } from "@base-ui/react/popover";
|
|
2531
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
2532
|
+
function Popover({
|
|
2533
|
+
morph: morph2 = false,
|
|
2534
|
+
defaultOpen = false,
|
|
2535
|
+
...props
|
|
1452
2536
|
}) {
|
|
1453
|
-
const
|
|
1454
|
-
|
|
2537
|
+
const state = useMorphOpen({
|
|
2538
|
+
morph: morph2,
|
|
2539
|
+
open: props.open,
|
|
2540
|
+
defaultOpen,
|
|
2541
|
+
onOpenChange: props.onOpenChange
|
|
2542
|
+
});
|
|
2543
|
+
return /* @__PURE__ */ jsx31(MorphContext, { value: state.refs, children: /* @__PURE__ */ jsx31(
|
|
2544
|
+
BasePopover.Root,
|
|
2545
|
+
{
|
|
2546
|
+
...props,
|
|
2547
|
+
open: state.open,
|
|
2548
|
+
onOpenChange: state.onOpenChange
|
|
2549
|
+
}
|
|
2550
|
+
) });
|
|
2551
|
+
}
|
|
2552
|
+
function PopoverTrigger({
|
|
2553
|
+
className,
|
|
2554
|
+
ref,
|
|
2555
|
+
...props
|
|
2556
|
+
}) {
|
|
2557
|
+
const morph2 = useContext13(MorphContext);
|
|
2558
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2559
|
+
checkAsChild(props, "PopoverTrigger", "popover.md");
|
|
2560
|
+
}
|
|
2561
|
+
return /* @__PURE__ */ jsx31(
|
|
1455
2562
|
BasePopover.Trigger,
|
|
1456
2563
|
{
|
|
1457
2564
|
...props,
|
|
@@ -1461,6 +2568,7 @@ function PopoverTrigger({
|
|
|
1461
2568
|
);
|
|
1462
2569
|
}
|
|
1463
2570
|
function PopoverPopup({
|
|
2571
|
+
anchor,
|
|
1464
2572
|
side,
|
|
1465
2573
|
align,
|
|
1466
2574
|
sideOffset,
|
|
@@ -1469,19 +2577,23 @@ function PopoverPopup({
|
|
|
1469
2577
|
ref,
|
|
1470
2578
|
...props
|
|
1471
2579
|
}) {
|
|
1472
|
-
const avl =
|
|
1473
|
-
const morph2 =
|
|
2580
|
+
const avl = useContext13(AnvilContext);
|
|
2581
|
+
const morph2 = useContext13(MorphContext);
|
|
2582
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2583
|
+
checkRoot(avl !== null, "PopoverPopup");
|
|
2584
|
+
}
|
|
1474
2585
|
return (
|
|
1475
2586
|
// Into the AnvilRoot, not body, so the popup sees the theme variables
|
|
1476
|
-
/* @__PURE__ */
|
|
2587
|
+
/* @__PURE__ */ jsx31(BasePopover.Portal, { container: avl?.rootRef, children: /* @__PURE__ */ jsx31(
|
|
1477
2588
|
BasePopover.Positioner,
|
|
1478
2589
|
{
|
|
1479
2590
|
className: "avl-menu-positioner",
|
|
2591
|
+
anchor,
|
|
1480
2592
|
side,
|
|
1481
2593
|
align,
|
|
1482
2594
|
sideOffset: sideOffset ?? 4,
|
|
1483
2595
|
alignOffset,
|
|
1484
|
-
children: /* @__PURE__ */
|
|
2596
|
+
children: /* @__PURE__ */ jsx31(
|
|
1485
2597
|
BasePopover.Popup,
|
|
1486
2598
|
{
|
|
1487
2599
|
...props,
|
|
@@ -1497,7 +2609,7 @@ function PopoverPopup({
|
|
|
1497
2609
|
);
|
|
1498
2610
|
}
|
|
1499
2611
|
function PopoverTitle({ className, ...props }) {
|
|
1500
|
-
return /* @__PURE__ */
|
|
2612
|
+
return /* @__PURE__ */ jsx31(
|
|
1501
2613
|
BasePopover.Title,
|
|
1502
2614
|
{
|
|
1503
2615
|
...props,
|
|
@@ -1509,7 +2621,7 @@ function PopoverDescription({
|
|
|
1509
2621
|
className,
|
|
1510
2622
|
...props
|
|
1511
2623
|
}) {
|
|
1512
|
-
return /* @__PURE__ */
|
|
2624
|
+
return /* @__PURE__ */ jsx31(
|
|
1513
2625
|
BasePopover.Description,
|
|
1514
2626
|
{
|
|
1515
2627
|
...props,
|
|
@@ -1518,7 +2630,10 @@ function PopoverDescription({
|
|
|
1518
2630
|
);
|
|
1519
2631
|
}
|
|
1520
2632
|
function PopoverClose({ className, ...props }) {
|
|
1521
|
-
|
|
2633
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2634
|
+
checkAsChild(props, "PopoverClose", "popover.md");
|
|
2635
|
+
}
|
|
2636
|
+
return /* @__PURE__ */ jsx31(
|
|
1522
2637
|
BasePopover.Close,
|
|
1523
2638
|
{
|
|
1524
2639
|
...props,
|
|
@@ -1527,9 +2642,73 @@ function PopoverClose({ className, ...props }) {
|
|
|
1527
2642
|
);
|
|
1528
2643
|
}
|
|
1529
2644
|
|
|
2645
|
+
// src/components/PreviewCard/PreviewCard.tsx
|
|
2646
|
+
import { useContext as useContext14 } from "react";
|
|
2647
|
+
import { PreviewCard as BasePreviewCard } from "@base-ui/react/preview-card";
|
|
2648
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
2649
|
+
function PreviewCard(props) {
|
|
2650
|
+
return /* @__PURE__ */ jsx32(BasePreviewCard.Root, { ...props });
|
|
2651
|
+
}
|
|
2652
|
+
function PreviewCardTrigger({
|
|
2653
|
+
className,
|
|
2654
|
+
...props
|
|
2655
|
+
}) {
|
|
2656
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2657
|
+
checkAsChild(
|
|
2658
|
+
props,
|
|
2659
|
+
"PreviewCardTrigger",
|
|
2660
|
+
"preview-card.md",
|
|
2661
|
+
'<PreviewCardTrigger render={<Link to="/users/ada" />}>@ada</PreviewCardTrigger>'
|
|
2662
|
+
);
|
|
2663
|
+
}
|
|
2664
|
+
return /* @__PURE__ */ jsx32(
|
|
2665
|
+
BasePreviewCard.Trigger,
|
|
2666
|
+
{
|
|
2667
|
+
...props,
|
|
2668
|
+
className: withClass("avl-preview-card-trigger", className)
|
|
2669
|
+
}
|
|
2670
|
+
);
|
|
2671
|
+
}
|
|
2672
|
+
function PreviewCardPopup({
|
|
2673
|
+
side,
|
|
2674
|
+
align,
|
|
2675
|
+
sideOffset,
|
|
2676
|
+
alignOffset,
|
|
2677
|
+
className,
|
|
2678
|
+
...props
|
|
2679
|
+
}) {
|
|
2680
|
+
const avl = useContext14(AnvilContext);
|
|
2681
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2682
|
+
checkRoot(avl !== null, "PreviewCardPopup");
|
|
2683
|
+
}
|
|
2684
|
+
return (
|
|
2685
|
+
// Into the AnvilRoot, not body, so the popup sees the theme variables
|
|
2686
|
+
/* @__PURE__ */ jsx32(BasePreviewCard.Portal, { container: avl?.rootRef, children: /* @__PURE__ */ jsx32(
|
|
2687
|
+
BasePreviewCard.Positioner,
|
|
2688
|
+
{
|
|
2689
|
+
className: "avl-menu-positioner",
|
|
2690
|
+
side,
|
|
2691
|
+
align,
|
|
2692
|
+
sideOffset: sideOffset ?? 8,
|
|
2693
|
+
alignOffset,
|
|
2694
|
+
children: /* @__PURE__ */ jsx32(
|
|
2695
|
+
BasePreviewCard.Popup,
|
|
2696
|
+
{
|
|
2697
|
+
...props,
|
|
2698
|
+
className: withClass(
|
|
2699
|
+
"avl-menu-popup avl-popover-popup",
|
|
2700
|
+
className
|
|
2701
|
+
)
|
|
2702
|
+
}
|
|
2703
|
+
)
|
|
2704
|
+
}
|
|
2705
|
+
) })
|
|
2706
|
+
);
|
|
2707
|
+
}
|
|
2708
|
+
|
|
1530
2709
|
// src/components/Progress/Progress.tsx
|
|
1531
2710
|
import { Progress as BaseProgress } from "@base-ui/react/progress";
|
|
1532
|
-
import { jsx as
|
|
2711
|
+
import { jsx as jsx33, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
1533
2712
|
var RING = { r: 20, gap: 8 };
|
|
1534
2713
|
var INLINE_RING = { r: 18, gap: 12 };
|
|
1535
2714
|
function Progress({
|
|
@@ -1541,12 +2720,20 @@ function Progress({
|
|
|
1541
2720
|
children,
|
|
1542
2721
|
...props
|
|
1543
2722
|
}) {
|
|
2723
|
+
if (process.env.NODE_ENV !== "production" && label == null) {
|
|
2724
|
+
checkName(
|
|
2725
|
+
props,
|
|
2726
|
+
"Progress",
|
|
2727
|
+
'<Progress label="Uploading" value={40} /> // or aria-label="Uploading"',
|
|
2728
|
+
"progress.md"
|
|
2729
|
+
);
|
|
2730
|
+
}
|
|
1544
2731
|
const { value, min = 0, max = 100 } = props;
|
|
1545
2732
|
const fraction = value == null ? 0 : Math.min(1, Math.max(0, (value - min) / (max - min)));
|
|
1546
2733
|
const pct = fraction * 100;
|
|
1547
2734
|
const ring = type === "inline" ? INLINE_RING : RING;
|
|
1548
2735
|
const ringGap = pct > 0 ? ring.gap : 0;
|
|
1549
|
-
return /* @__PURE__ */
|
|
2736
|
+
return /* @__PURE__ */ jsxs19(
|
|
1550
2737
|
BaseProgress.Root,
|
|
1551
2738
|
{
|
|
1552
2739
|
...props,
|
|
@@ -1565,9 +2752,9 @@ function Progress({
|
|
|
1565
2752
|
...typeof style === "function" ? style(state) : style
|
|
1566
2753
|
}),
|
|
1567
2754
|
children: [
|
|
1568
|
-
label != null && /* @__PURE__ */
|
|
1569
|
-
type === "linear" ? /* @__PURE__ */
|
|
1570
|
-
squiggly ? /* @__PURE__ */
|
|
2755
|
+
label != null && /* @__PURE__ */ jsx33(BaseProgress.Label, { className: "avl-progress-label", children: label }),
|
|
2756
|
+
type === "linear" ? /* @__PURE__ */ jsxs19(BaseProgress.Track, { className: "avl-progress-track", children: [
|
|
2757
|
+
squiggly ? /* @__PURE__ */ jsx33(
|
|
1571
2758
|
SquigglyWave,
|
|
1572
2759
|
{
|
|
1573
2760
|
span: (width, gap, _svg, now) => value == null ? loadingSpan(width, gap, now) : (
|
|
@@ -1576,15 +2763,15 @@ function Progress({
|
|
|
1576
2763
|
{ from: 0, to: fraction * width }
|
|
1577
2764
|
)
|
|
1578
2765
|
}
|
|
1579
|
-
) : /* @__PURE__ */
|
|
1580
|
-
/* @__PURE__ */
|
|
1581
|
-
] }) : /* @__PURE__ */
|
|
2766
|
+
) : /* @__PURE__ */ jsx33(BaseProgress.Indicator, { className: "avl-progress-indicator" }),
|
|
2767
|
+
/* @__PURE__ */ jsx33("span", { className: "avl-progress-rest" })
|
|
2768
|
+
] }) : /* @__PURE__ */ jsxs19(
|
|
1582
2769
|
BaseProgress.Track,
|
|
1583
2770
|
{
|
|
1584
2771
|
className: "avl-progress-ring",
|
|
1585
|
-
render: /* @__PURE__ */
|
|
2772
|
+
render: /* @__PURE__ */ jsx33("svg", { viewBox: "0 0 48 48" }),
|
|
1586
2773
|
children: [
|
|
1587
|
-
/* @__PURE__ */
|
|
2774
|
+
/* @__PURE__ */ jsx33(
|
|
1588
2775
|
"circle",
|
|
1589
2776
|
{
|
|
1590
2777
|
className: "avl-progress-ring-rest",
|
|
@@ -1596,7 +2783,7 @@ function Progress({
|
|
|
1596
2783
|
strokeDashoffset: -(pct + ringGap)
|
|
1597
2784
|
}
|
|
1598
2785
|
),
|
|
1599
|
-
/* @__PURE__ */
|
|
2786
|
+
/* @__PURE__ */ jsx33(
|
|
1600
2787
|
"circle",
|
|
1601
2788
|
{
|
|
1602
2789
|
className: "avl-progress-ring-indicator",
|
|
@@ -1636,13 +2823,13 @@ function loadingSpan(width, gap, now) {
|
|
|
1636
2823
|
}
|
|
1637
2824
|
|
|
1638
2825
|
// src/components/ToggleGroup/ToggleGroup.tsx
|
|
1639
|
-
import { createContext as
|
|
2826
|
+
import { createContext as createContext6, useContext as useContext15, useLayoutEffect as useLayoutEffect3, useRef as useRef11 } from "react";
|
|
1640
2827
|
import { Radio as BaseRadio } from "@base-ui/react/radio";
|
|
1641
2828
|
import { RadioGroup as BaseRadioGroup } from "@base-ui/react/radio-group";
|
|
1642
2829
|
import { Toggle as BaseToggle } from "@base-ui/react/toggle";
|
|
1643
2830
|
import { ToggleGroup as BaseToggleGroup } from "@base-ui/react/toggle-group";
|
|
1644
|
-
import { Fragment as
|
|
1645
|
-
var MultipleContext =
|
|
2831
|
+
import { Fragment as Fragment3, jsx as jsx34, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2832
|
+
var MultipleContext = createContext6(null);
|
|
1646
2833
|
function ToggleGroup({
|
|
1647
2834
|
size = "normal",
|
|
1648
2835
|
color,
|
|
@@ -1653,8 +2840,8 @@ function ToggleGroup({
|
|
|
1653
2840
|
ref,
|
|
1654
2841
|
...props
|
|
1655
2842
|
}) {
|
|
1656
|
-
const groupRef =
|
|
1657
|
-
const indicatorRef =
|
|
2843
|
+
const groupRef = useRef11(null);
|
|
2844
|
+
const indicatorRef = useRef11(null);
|
|
1658
2845
|
useLayoutEffect3(() => {
|
|
1659
2846
|
const group = groupRef.current;
|
|
1660
2847
|
const indicator = indicatorRef.current;
|
|
@@ -1697,7 +2884,7 @@ function ToggleGroup({
|
|
|
1697
2884
|
// Its state type depends on which group renders; both take a string
|
|
1698
2885
|
className
|
|
1699
2886
|
);
|
|
1700
|
-
return /* @__PURE__ */
|
|
2887
|
+
return /* @__PURE__ */ jsx34(MultipleContext, { value: multiple, children: multiple ? /* @__PURE__ */ jsx34(
|
|
1701
2888
|
BaseToggleGroup,
|
|
1702
2889
|
{
|
|
1703
2890
|
...props,
|
|
@@ -1706,14 +2893,14 @@ function ToggleGroup({
|
|
|
1706
2893
|
className: classes,
|
|
1707
2894
|
children
|
|
1708
2895
|
}
|
|
1709
|
-
) : /* @__PURE__ */
|
|
2896
|
+
) : /* @__PURE__ */ jsxs20(
|
|
1710
2897
|
BaseRadioGroup,
|
|
1711
2898
|
{
|
|
1712
2899
|
...props,
|
|
1713
2900
|
ref: mergeRefs(groupRef, ref),
|
|
1714
2901
|
className: classes,
|
|
1715
2902
|
children: [
|
|
1716
|
-
/* @__PURE__ */
|
|
2903
|
+
/* @__PURE__ */ jsx34(
|
|
1717
2904
|
"div",
|
|
1718
2905
|
{
|
|
1719
2906
|
ref: indicatorRef,
|
|
@@ -1734,37 +2921,45 @@ function ToggleGroupItem({
|
|
|
1734
2921
|
value,
|
|
1735
2922
|
...props
|
|
1736
2923
|
}) {
|
|
1737
|
-
const
|
|
2924
|
+
const group = useContext15(MultipleContext);
|
|
2925
|
+
if (process.env.NODE_ENV !== "production" && group === null) {
|
|
2926
|
+
devError(
|
|
2927
|
+
"<ToggleGroupItem> is rendered outside a <ToggleGroup>.",
|
|
2928
|
+
'<ToggleGroup aria-label="View" defaultValue="list">\n <ToggleGroupItem value="list">List</ToggleGroupItem>\n <ToggleGroupItem value="grid">Grid</ToggleGroupItem>\n</ToggleGroup>',
|
|
2929
|
+
"toggle-group.md"
|
|
2930
|
+
);
|
|
2931
|
+
}
|
|
2932
|
+
const multiple = group ?? false;
|
|
1738
2933
|
const classes = withClass(
|
|
1739
2934
|
"avl-toggle-group-item",
|
|
1740
2935
|
className
|
|
1741
2936
|
);
|
|
1742
|
-
const content = /* @__PURE__ */
|
|
1743
|
-
startIcon && /* @__PURE__ */
|
|
2937
|
+
const content = /* @__PURE__ */ jsxs20(Fragment3, { children: [
|
|
2938
|
+
startIcon && /* @__PURE__ */ jsx34(Icon, { name: startIcon }),
|
|
1744
2939
|
children,
|
|
1745
|
-
endIcon && /* @__PURE__ */
|
|
2940
|
+
endIcon && /* @__PURE__ */ jsx34(Icon, { name: endIcon })
|
|
1746
2941
|
] });
|
|
1747
2942
|
if (multiple) {
|
|
1748
|
-
return /* @__PURE__ */
|
|
2943
|
+
return /* @__PURE__ */ jsxs20(
|
|
1749
2944
|
BaseToggle,
|
|
1750
2945
|
{
|
|
1751
2946
|
...props,
|
|
1752
2947
|
value: String(value),
|
|
1753
2948
|
className: classes,
|
|
1754
2949
|
children: [
|
|
1755
|
-
/* @__PURE__ */
|
|
2950
|
+
/* @__PURE__ */ jsx34(Icon, { name: "check", className: "avl-toggle-group-check" }),
|
|
1756
2951
|
content
|
|
1757
2952
|
]
|
|
1758
2953
|
}
|
|
1759
2954
|
);
|
|
1760
2955
|
}
|
|
1761
|
-
return /* @__PURE__ */
|
|
2956
|
+
return /* @__PURE__ */ jsx34(
|
|
1762
2957
|
BaseRadio.Root,
|
|
1763
2958
|
{
|
|
1764
2959
|
...props,
|
|
1765
2960
|
value,
|
|
1766
2961
|
nativeButton: true,
|
|
1767
|
-
render: /* @__PURE__ */
|
|
2962
|
+
render: /* @__PURE__ */ jsx34("button", {}),
|
|
1768
2963
|
className: classes,
|
|
1769
2964
|
children: content
|
|
1770
2965
|
}
|
|
@@ -1774,12 +2969,12 @@ function ToggleGroupItem({
|
|
|
1774
2969
|
// src/components/RadioGroup/RadioGroup.tsx
|
|
1775
2970
|
import { Radio as BaseRadio2 } from "@base-ui/react/radio";
|
|
1776
2971
|
import { RadioGroup as BaseRadioGroup2 } from "@base-ui/react/radio-group";
|
|
1777
|
-
import { jsx as
|
|
2972
|
+
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
1778
2973
|
function RadioGroup({
|
|
1779
2974
|
className,
|
|
1780
2975
|
...props
|
|
1781
2976
|
}) {
|
|
1782
|
-
return /* @__PURE__ */
|
|
2977
|
+
return /* @__PURE__ */ jsx35(
|
|
1783
2978
|
BaseRadioGroup2,
|
|
1784
2979
|
{
|
|
1785
2980
|
...props,
|
|
@@ -1788,20 +2983,30 @@ function RadioGroup({
|
|
|
1788
2983
|
);
|
|
1789
2984
|
}
|
|
1790
2985
|
function Radio({ className, ...props }) {
|
|
1791
|
-
|
|
2986
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2987
|
+
checkProp(
|
|
2988
|
+
props,
|
|
2989
|
+
"label",
|
|
2990
|
+
"Radio",
|
|
2991
|
+
"Wrap it in a <label> with the text instead.",
|
|
2992
|
+
'<label>\n <Radio value="pro" />\n Pro\n</label>',
|
|
2993
|
+
"radio-group.md"
|
|
2994
|
+
);
|
|
2995
|
+
}
|
|
2996
|
+
return /* @__PURE__ */ jsx35(
|
|
1792
2997
|
BaseRadio2.Root,
|
|
1793
2998
|
{
|
|
1794
2999
|
...props,
|
|
1795
3000
|
className: withClass("avl-radio", className),
|
|
1796
|
-
children: /* @__PURE__ */
|
|
3001
|
+
children: /* @__PURE__ */ jsx35(BaseRadio2.Indicator, { className: "avl-radio-indicator" })
|
|
1797
3002
|
}
|
|
1798
3003
|
);
|
|
1799
3004
|
}
|
|
1800
3005
|
|
|
1801
3006
|
// src/components/Select/Select.tsx
|
|
1802
|
-
import { useContext as
|
|
3007
|
+
import { useContext as useContext16 } from "react";
|
|
1803
3008
|
import { Select as BaseSelect } from "@base-ui/react/select";
|
|
1804
|
-
import { jsx as
|
|
3009
|
+
import { jsx as jsx36, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
1805
3010
|
function Select({
|
|
1806
3011
|
label,
|
|
1807
3012
|
placeholder,
|
|
@@ -1810,9 +3015,12 @@ function Select({
|
|
|
1810
3015
|
children,
|
|
1811
3016
|
...props
|
|
1812
3017
|
}) {
|
|
1813
|
-
const avl =
|
|
1814
|
-
|
|
1815
|
-
|
|
3018
|
+
const avl = useContext16(AnvilContext);
|
|
3019
|
+
if (process.env.NODE_ENV !== "production") {
|
|
3020
|
+
checkRoot(avl !== null, "Select");
|
|
3021
|
+
}
|
|
3022
|
+
return /* @__PURE__ */ jsxs21(BaseSelect.Root, { ...props, children: [
|
|
3023
|
+
/* @__PURE__ */ jsxs21(
|
|
1816
3024
|
"div",
|
|
1817
3025
|
{
|
|
1818
3026
|
className: cx(
|
|
@@ -1823,49 +3031,891 @@ function Select({
|
|
|
1823
3031
|
className
|
|
1824
3032
|
),
|
|
1825
3033
|
children: [
|
|
1826
|
-
/* @__PURE__ */
|
|
1827
|
-
/* @__PURE__ */
|
|
3034
|
+
/* @__PURE__ */ jsxs21(BaseSelect.Trigger, { className: "avl-input-field avl-select-trigger", children: [
|
|
3035
|
+
/* @__PURE__ */ jsx36(
|
|
1828
3036
|
BaseSelect.Value,
|
|
1829
3037
|
{
|
|
1830
3038
|
className: "avl-select-value",
|
|
1831
3039
|
placeholder
|
|
1832
3040
|
}
|
|
1833
3041
|
),
|
|
1834
|
-
/* @__PURE__ */
|
|
3042
|
+
/* @__PURE__ */ jsx36(BaseSelect.Icon, { className: "avl-select-icon", children: /* @__PURE__ */ jsx36(Icon, { name: "arrow_drop_down" }) })
|
|
1835
3043
|
] }),
|
|
1836
|
-
label != null && /* @__PURE__ */
|
|
1837
|
-
/* @__PURE__ */
|
|
3044
|
+
label != null && /* @__PURE__ */ jsx36(BaseSelect.Label, { className: "avl-input-label", children: label }),
|
|
3045
|
+
/* @__PURE__ */ jsx36("fieldset", { "aria-hidden": true, className: "avl-input-outline", children: /* @__PURE__ */ jsx36("legend", { children: label != null && size === "normal" && /* @__PURE__ */ jsx36("span", { children: label }) }) })
|
|
1838
3046
|
]
|
|
1839
3047
|
}
|
|
1840
3048
|
),
|
|
1841
|
-
/* @__PURE__ */
|
|
3049
|
+
/* @__PURE__ */ jsx36(BaseSelect.Portal, { container: avl?.rootRef, children: /* @__PURE__ */ jsx36(
|
|
1842
3050
|
BaseSelect.Positioner,
|
|
1843
3051
|
{
|
|
1844
3052
|
className: "avl-menu-positioner",
|
|
1845
3053
|
alignItemWithTrigger: false,
|
|
1846
3054
|
sideOffset: 4,
|
|
1847
|
-
children: /* @__PURE__ */
|
|
3055
|
+
children: /* @__PURE__ */ jsx36(BaseSelect.Popup, { className: "avl-menu-popup avl-select-popup", children })
|
|
1848
3056
|
}
|
|
1849
3057
|
) })
|
|
1850
3058
|
] });
|
|
1851
3059
|
}
|
|
1852
3060
|
function SelectItem({ className, children, ...props }) {
|
|
1853
|
-
return /* @__PURE__ */
|
|
3061
|
+
return /* @__PURE__ */ jsxs21(
|
|
1854
3062
|
BaseSelect.Item,
|
|
1855
3063
|
{
|
|
1856
3064
|
...props,
|
|
1857
3065
|
className: withClass("avl-menu-item avl-select-item", className),
|
|
1858
3066
|
children: [
|
|
1859
|
-
/* @__PURE__ */
|
|
1860
|
-
/* @__PURE__ */
|
|
3067
|
+
/* @__PURE__ */ jsx36(BaseSelect.ItemText, { className: "avl-menu-item-label", children }),
|
|
3068
|
+
/* @__PURE__ */ jsx36(BaseSelect.ItemIndicator, { className: "avl-select-item-indicator", children: /* @__PURE__ */ jsx36(Icon, { name: "check" }) })
|
|
1861
3069
|
]
|
|
1862
3070
|
}
|
|
1863
3071
|
);
|
|
1864
3072
|
}
|
|
1865
3073
|
|
|
3074
|
+
// src/components/TimePicker/TimePicker.tsx
|
|
3075
|
+
import { useId as useId2, useRef as useRef12, useState as useState8 } from "react";
|
|
3076
|
+
import { Fragment as Fragment4, jsx as jsx37, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3077
|
+
var pad2 = (n) => String(n).padStart(2, "0");
|
|
3078
|
+
function localeHourCycle() {
|
|
3079
|
+
const { hour12 } = new Intl.DateTimeFormat(void 0, {
|
|
3080
|
+
hour: "numeric"
|
|
3081
|
+
}).resolvedOptions();
|
|
3082
|
+
return hour12 ? 12 : 24;
|
|
3083
|
+
}
|
|
3084
|
+
var displayHour = (h, cycle) => cycle === 12 ? h % 12 || 12 : h;
|
|
3085
|
+
function TimePicker({
|
|
3086
|
+
type = "dial",
|
|
3087
|
+
value: valueProp,
|
|
3088
|
+
defaultValue = null,
|
|
3089
|
+
onValueChange,
|
|
3090
|
+
hourCycle,
|
|
3091
|
+
label,
|
|
3092
|
+
"aria-label": ariaLabel,
|
|
3093
|
+
disabled,
|
|
3094
|
+
size = "normal",
|
|
3095
|
+
name,
|
|
3096
|
+
open,
|
|
3097
|
+
defaultOpen,
|
|
3098
|
+
onOpenChange,
|
|
3099
|
+
className,
|
|
3100
|
+
...props
|
|
3101
|
+
}) {
|
|
3102
|
+
const [internal, setInternal] = useState8(defaultValue);
|
|
3103
|
+
const value = valueProp !== void 0 ? valueProp : internal;
|
|
3104
|
+
const time = parseTime(value);
|
|
3105
|
+
const cycle = hourCycle ?? localeHourCycle();
|
|
3106
|
+
const labelId = useId2();
|
|
3107
|
+
const valueId = useId2();
|
|
3108
|
+
const setTime = (t) => {
|
|
3109
|
+
const next = `${pad2(t.h)}:${pad2(t.m)}`;
|
|
3110
|
+
setInternal(next);
|
|
3111
|
+
onValueChange?.(next);
|
|
3112
|
+
};
|
|
3113
|
+
const shown = time && new Intl.DateTimeFormat(void 0, {
|
|
3114
|
+
hour: "numeric",
|
|
3115
|
+
minute: "2-digit",
|
|
3116
|
+
hourCycle: cycle === 12 ? "h12" : "h23"
|
|
3117
|
+
}).format(new Date(2e3, 0, 1, time.h, time.m));
|
|
3118
|
+
return /* @__PURE__ */ jsxs22(
|
|
3119
|
+
Popover,
|
|
3120
|
+
{
|
|
3121
|
+
open,
|
|
3122
|
+
defaultOpen,
|
|
3123
|
+
onOpenChange,
|
|
3124
|
+
children: [
|
|
3125
|
+
/* @__PURE__ */ jsxs22(
|
|
3126
|
+
"div",
|
|
3127
|
+
{
|
|
3128
|
+
...props,
|
|
3129
|
+
className: cx(
|
|
3130
|
+
"avl-input",
|
|
3131
|
+
"avl-select",
|
|
3132
|
+
"avl-time-picker",
|
|
3133
|
+
`avl-input-size-${size}`,
|
|
3134
|
+
label != null && "avl-input-labeled",
|
|
3135
|
+
className
|
|
3136
|
+
),
|
|
3137
|
+
children: [
|
|
3138
|
+
/* @__PURE__ */ jsxs22(
|
|
3139
|
+
PopoverTrigger,
|
|
3140
|
+
{
|
|
3141
|
+
disabled,
|
|
3142
|
+
className: "avl-input-field avl-select-trigger",
|
|
3143
|
+
"data-placeholder": time ? void 0 : "",
|
|
3144
|
+
"aria-labelledby": `${labelId} ${valueId}`,
|
|
3145
|
+
children: [
|
|
3146
|
+
/* @__PURE__ */ jsx37("span", { id: valueId, className: "avl-select-value", children: shown }),
|
|
3147
|
+
/* @__PURE__ */ jsx37(Icon, { name: "schedule", className: "avl-time-picker-icon" })
|
|
3148
|
+
]
|
|
3149
|
+
}
|
|
3150
|
+
),
|
|
3151
|
+
label != null ? /* @__PURE__ */ jsx37("span", { id: labelId, className: "avl-input-label", children: label }) : /* @__PURE__ */ jsx37("span", { id: labelId, hidden: true, children: ariaLabel }),
|
|
3152
|
+
/* @__PURE__ */ jsx37("fieldset", { "aria-hidden": true, className: "avl-input-outline", children: /* @__PURE__ */ jsx37("legend", { children: label != null && size === "normal" && /* @__PURE__ */ jsx37("span", { children: label }) }) }),
|
|
3153
|
+
name != null && /* @__PURE__ */ jsx37("input", { type: "hidden", name, value: value ?? "" })
|
|
3154
|
+
]
|
|
3155
|
+
}
|
|
3156
|
+
),
|
|
3157
|
+
/* @__PURE__ */ jsx37(PopoverPopup, { "aria-labelledby": labelId, children: /* @__PURE__ */ jsx37(
|
|
3158
|
+
TimePanel,
|
|
3159
|
+
{
|
|
3160
|
+
type,
|
|
3161
|
+
time,
|
|
3162
|
+
cycle,
|
|
3163
|
+
onChange: setTime
|
|
3164
|
+
}
|
|
3165
|
+
) })
|
|
3166
|
+
]
|
|
3167
|
+
}
|
|
3168
|
+
);
|
|
3169
|
+
}
|
|
3170
|
+
function TimePanel(props) {
|
|
3171
|
+
const { type, time, cycle, onChange } = props;
|
|
3172
|
+
const [mode, setMode] = useState8("hour");
|
|
3173
|
+
const pm = time ? time.h >= 12 : false;
|
|
3174
|
+
const hourText = time ? pad2(displayHour(time.h, cycle)) : "--";
|
|
3175
|
+
const minuteText = time ? pad2(time.m) : "--";
|
|
3176
|
+
const setHour = (shownHour) => onChange({
|
|
3177
|
+
h: cycle === 12 ? shownHour % 12 + (pm ? 12 : 0) : shownHour,
|
|
3178
|
+
m: time?.m ?? 0
|
|
3179
|
+
});
|
|
3180
|
+
const setMinute = (m) => onChange({ h: time?.h ?? 0, m });
|
|
3181
|
+
return /* @__PURE__ */ jsxs22("div", { className: "avl-time-picker-panel", children: [
|
|
3182
|
+
/* @__PURE__ */ jsxs22("div", { className: "avl-time-picker-header", children: [
|
|
3183
|
+
type === "dial" ? /* @__PURE__ */ jsxs22(Fragment4, { children: [
|
|
3184
|
+
/* @__PURE__ */ jsx37(
|
|
3185
|
+
"button",
|
|
3186
|
+
{
|
|
3187
|
+
type: "button",
|
|
3188
|
+
className: "avl-time-picker-box",
|
|
3189
|
+
"data-selected": mode === "hour" || void 0,
|
|
3190
|
+
"aria-pressed": mode === "hour",
|
|
3191
|
+
"aria-label": `Hour ${hourText}`,
|
|
3192
|
+
onClick: () => setMode("hour"),
|
|
3193
|
+
children: hourText
|
|
3194
|
+
}
|
|
3195
|
+
),
|
|
3196
|
+
/* @__PURE__ */ jsx37("span", { className: "avl-time-picker-colon", "aria-hidden": true, children: ":" }),
|
|
3197
|
+
/* @__PURE__ */ jsx37(
|
|
3198
|
+
"button",
|
|
3199
|
+
{
|
|
3200
|
+
type: "button",
|
|
3201
|
+
className: "avl-time-picker-box",
|
|
3202
|
+
"data-selected": mode === "minute" || void 0,
|
|
3203
|
+
"aria-pressed": mode === "minute",
|
|
3204
|
+
"aria-label": `Minute ${minuteText}`,
|
|
3205
|
+
onClick: () => setMode("minute"),
|
|
3206
|
+
children: minuteText
|
|
3207
|
+
}
|
|
3208
|
+
)
|
|
3209
|
+
] }) : /* @__PURE__ */ jsxs22(Fragment4, { children: [
|
|
3210
|
+
/* @__PURE__ */ jsx37(
|
|
3211
|
+
SpinInput,
|
|
3212
|
+
{
|
|
3213
|
+
label: "Hour",
|
|
3214
|
+
value: time && displayHour(time.h, cycle),
|
|
3215
|
+
min: cycle === 12 ? 1 : 0,
|
|
3216
|
+
max: cycle === 12 ? 12 : 23,
|
|
3217
|
+
onChange: setHour
|
|
3218
|
+
}
|
|
3219
|
+
),
|
|
3220
|
+
/* @__PURE__ */ jsx37("span", { className: "avl-time-picker-colon", "aria-hidden": true, children: ":" }),
|
|
3221
|
+
/* @__PURE__ */ jsx37(
|
|
3222
|
+
SpinInput,
|
|
3223
|
+
{
|
|
3224
|
+
label: "Minute",
|
|
3225
|
+
value: time && time.m,
|
|
3226
|
+
min: 0,
|
|
3227
|
+
max: 59,
|
|
3228
|
+
onChange: setMinute
|
|
3229
|
+
}
|
|
3230
|
+
)
|
|
3231
|
+
] }),
|
|
3232
|
+
cycle === 12 && /* @__PURE__ */ jsxs22(
|
|
3233
|
+
ToggleGroup,
|
|
3234
|
+
{
|
|
3235
|
+
size: "small",
|
|
3236
|
+
fillType: "outlined",
|
|
3237
|
+
"aria-label": "AM or PM",
|
|
3238
|
+
className: "avl-time-picker-period",
|
|
3239
|
+
value: time ? pm ? "pm" : "am" : null,
|
|
3240
|
+
onValueChange: (period) => onChange({
|
|
3241
|
+
h: (time?.h ?? 0) % 12 + (period === "pm" ? 12 : 0),
|
|
3242
|
+
m: time?.m ?? 0
|
|
3243
|
+
}),
|
|
3244
|
+
children: [
|
|
3245
|
+
/* @__PURE__ */ jsx37(ToggleGroupItem, { value: "am", children: "AM" }),
|
|
3246
|
+
/* @__PURE__ */ jsx37(ToggleGroupItem, { value: "pm", children: "PM" })
|
|
3247
|
+
]
|
|
3248
|
+
}
|
|
3249
|
+
)
|
|
3250
|
+
] }),
|
|
3251
|
+
type === "dial" && /* @__PURE__ */ jsx37(
|
|
3252
|
+
Dial,
|
|
3253
|
+
{
|
|
3254
|
+
mode,
|
|
3255
|
+
time,
|
|
3256
|
+
cycle,
|
|
3257
|
+
onChange,
|
|
3258
|
+
onHourDone: () => setMode("minute")
|
|
3259
|
+
}
|
|
3260
|
+
)
|
|
3261
|
+
] });
|
|
3262
|
+
}
|
|
3263
|
+
function SpinInput(props) {
|
|
3264
|
+
const { label, value, min, max, onChange } = props;
|
|
3265
|
+
const [draft, setDraft] = useState8(null);
|
|
3266
|
+
const range = max - min + 1;
|
|
3267
|
+
return /* @__PURE__ */ jsx37(
|
|
3268
|
+
"input",
|
|
3269
|
+
{
|
|
3270
|
+
className: "avl-time-picker-box",
|
|
3271
|
+
role: "spinbutton",
|
|
3272
|
+
"aria-label": label,
|
|
3273
|
+
"aria-valuemin": min,
|
|
3274
|
+
"aria-valuemax": max,
|
|
3275
|
+
"aria-valuenow": value ?? void 0,
|
|
3276
|
+
inputMode: "numeric",
|
|
3277
|
+
autoComplete: "off",
|
|
3278
|
+
placeholder: "--",
|
|
3279
|
+
value: draft ?? (value == null ? "" : pad2(value)),
|
|
3280
|
+
onFocus: (e) => e.currentTarget.select(),
|
|
3281
|
+
onBlur: () => setDraft(null),
|
|
3282
|
+
onChange: (e) => {
|
|
3283
|
+
const digits2 = e.target.value.replace(/\D/g, "").slice(-2);
|
|
3284
|
+
setDraft(digits2);
|
|
3285
|
+
const n = Number(digits2);
|
|
3286
|
+
if (digits2 && n >= min && n <= max) onChange(n);
|
|
3287
|
+
},
|
|
3288
|
+
onKeyDown: (e) => {
|
|
3289
|
+
const step = e.key === "ArrowUp" ? 1 : e.key === "ArrowDown" ? -1 : 0;
|
|
3290
|
+
if (!step) return;
|
|
3291
|
+
e.preventDefault();
|
|
3292
|
+
setDraft(null);
|
|
3293
|
+
onChange(
|
|
3294
|
+
value == null ? min : (value - min + step + range) % range + min
|
|
3295
|
+
);
|
|
3296
|
+
}
|
|
3297
|
+
}
|
|
3298
|
+
);
|
|
3299
|
+
}
|
|
3300
|
+
var SIZE = 256;
|
|
3301
|
+
var C = SIZE / 2;
|
|
3302
|
+
var OUTER = 100;
|
|
3303
|
+
var INNER = 64;
|
|
3304
|
+
var KNOB = 20;
|
|
3305
|
+
var point = (index, of, radius) => {
|
|
3306
|
+
const a = index / of * 2 * Math.PI;
|
|
3307
|
+
return { x: C + radius * Math.sin(a), y: C - radius * Math.cos(a) };
|
|
3308
|
+
};
|
|
3309
|
+
function Dial(props) {
|
|
3310
|
+
const { mode, time, cycle, onChange, onHourDone } = props;
|
|
3311
|
+
const h = time?.h ?? 0;
|
|
3312
|
+
const m = time?.m ?? 0;
|
|
3313
|
+
const isHour = mode === "hour";
|
|
3314
|
+
const [dragging, setDragging] = useState8(false);
|
|
3315
|
+
const labels = Array.from(
|
|
3316
|
+
{ length: 12 },
|
|
3317
|
+
(_, i) => !isHour ? [{ value: i * 5, text: pad2(i * 5), inner: false }] : cycle === 12 ? [{ value: i, text: String(i || 12), inner: false }] : [
|
|
3318
|
+
{ value: i, text: i ? String(i) : "00", inner: false },
|
|
3319
|
+
{ value: i + 12, text: String(i + 12), inner: true }
|
|
3320
|
+
]
|
|
3321
|
+
).flat();
|
|
3322
|
+
const radius = isHour && cycle === 24 && h >= 12 ? INNER : OUTER;
|
|
3323
|
+
const target = isHour ? h % 12 * 30 : m * 6;
|
|
3324
|
+
const angleRef = useRef12(null);
|
|
3325
|
+
const prev = angleRef.current;
|
|
3326
|
+
const angle = prev == null ? target : prev + ((target - prev) % 360 + 540) % 360 - 180;
|
|
3327
|
+
angleRef.current = angle;
|
|
3328
|
+
const isSelected = (value) => time != null && (isHour ? value === (cycle === 12 ? h % 12 : h) : value === m);
|
|
3329
|
+
const pick = (e) => {
|
|
3330
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
3331
|
+
const x = (e.clientX - rect.left) / rect.width * SIZE - C;
|
|
3332
|
+
const y = (e.clientY - rect.top) / rect.height * SIZE - C;
|
|
3333
|
+
const turn = (Math.atan2(x, -y) / (2 * Math.PI) + 1) % 1;
|
|
3334
|
+
if (!isHour) {
|
|
3335
|
+
onChange({ h, m: Math.round(turn * 60) % 60 });
|
|
3336
|
+
return;
|
|
3337
|
+
}
|
|
3338
|
+
const i = Math.round(turn * 12) % 12;
|
|
3339
|
+
const inner = cycle === 24 && Math.hypot(x, y) < (OUTER + INNER) / 2;
|
|
3340
|
+
onChange({
|
|
3341
|
+
h: cycle === 12 ? i + (h >= 12 ? 12 : 0) : i + (inner ? 12 : 0),
|
|
3342
|
+
m
|
|
3343
|
+
});
|
|
3344
|
+
};
|
|
3345
|
+
const step = (d) => onChange(
|
|
3346
|
+
isHour ? { h: (h + d + 24) % 24, m } : { h, m: (m + d + 60) % 60 }
|
|
3347
|
+
);
|
|
3348
|
+
const valueText = !time ? void 0 : isHour ? `${displayHour(h, cycle)}${cycle === 12 ? h >= 12 ? " PM" : " AM" : ""}` : `${m} minutes`;
|
|
3349
|
+
return /* @__PURE__ */ jsxs22(
|
|
3350
|
+
"svg",
|
|
3351
|
+
{
|
|
3352
|
+
className: "avl-time-picker-dial",
|
|
3353
|
+
"data-dragging": dragging || void 0,
|
|
3354
|
+
viewBox: `0 0 ${SIZE} ${SIZE}`,
|
|
3355
|
+
tabIndex: 0,
|
|
3356
|
+
role: "slider",
|
|
3357
|
+
"aria-label": isHour ? "Hour" : "Minute",
|
|
3358
|
+
"aria-valuemin": 0,
|
|
3359
|
+
"aria-valuemax": isHour ? 23 : 59,
|
|
3360
|
+
"aria-valuenow": time ? isHour ? h : m : void 0,
|
|
3361
|
+
"aria-valuetext": valueText,
|
|
3362
|
+
onPointerDown: (e) => {
|
|
3363
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
3364
|
+
setDragging(true);
|
|
3365
|
+
pick(e);
|
|
3366
|
+
},
|
|
3367
|
+
onPointerMove: (e) => {
|
|
3368
|
+
if (e.currentTarget.hasPointerCapture(e.pointerId)) pick(e);
|
|
3369
|
+
},
|
|
3370
|
+
onPointerUp: () => {
|
|
3371
|
+
setDragging(false);
|
|
3372
|
+
if (isHour) onHourDone();
|
|
3373
|
+
},
|
|
3374
|
+
onPointerCancel: () => setDragging(false),
|
|
3375
|
+
onKeyDown: (e) => {
|
|
3376
|
+
if (e.key === "ArrowUp" || e.key === "ArrowRight") step(1);
|
|
3377
|
+
else if (e.key === "ArrowDown" || e.key === "ArrowLeft")
|
|
3378
|
+
step(-1);
|
|
3379
|
+
else if (e.key === "Enter" && isHour) onHourDone();
|
|
3380
|
+
else return;
|
|
3381
|
+
e.preventDefault();
|
|
3382
|
+
},
|
|
3383
|
+
children: [
|
|
3384
|
+
/* @__PURE__ */ jsx37("circle", { className: "avl-time-picker-dial-face", cx: C, cy: C, r: C }),
|
|
3385
|
+
time && /* @__PURE__ */ jsxs22(Fragment4, { children: [
|
|
3386
|
+
/* @__PURE__ */ jsx37(
|
|
3387
|
+
"circle",
|
|
3388
|
+
{
|
|
3389
|
+
className: "avl-time-picker-dial-knob",
|
|
3390
|
+
cx: C,
|
|
3391
|
+
cy: C,
|
|
3392
|
+
r: 3
|
|
3393
|
+
}
|
|
3394
|
+
),
|
|
3395
|
+
/* @__PURE__ */ jsxs22(
|
|
3396
|
+
"g",
|
|
3397
|
+
{
|
|
3398
|
+
className: "avl-time-picker-dial-hand",
|
|
3399
|
+
style: {
|
|
3400
|
+
transformOrigin: `${C}px ${C}px`,
|
|
3401
|
+
transform: `rotate(${angle}deg)`
|
|
3402
|
+
},
|
|
3403
|
+
children: [
|
|
3404
|
+
/* @__PURE__ */ jsx37(
|
|
3405
|
+
"rect",
|
|
3406
|
+
{
|
|
3407
|
+
className: "avl-time-picker-dial-arm",
|
|
3408
|
+
x: C - 1,
|
|
3409
|
+
y: C - 1,
|
|
3410
|
+
width: 2,
|
|
3411
|
+
height: 1,
|
|
3412
|
+
style: {
|
|
3413
|
+
transformOrigin: `${C}px ${C}px`,
|
|
3414
|
+
transform: `scaleY(${radius})`
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
),
|
|
3418
|
+
/* @__PURE__ */ jsxs22(
|
|
3419
|
+
"g",
|
|
3420
|
+
{
|
|
3421
|
+
className: "avl-time-picker-dial-tip",
|
|
3422
|
+
style: { transform: `translateY(${-radius}px)` },
|
|
3423
|
+
children: [
|
|
3424
|
+
/* @__PURE__ */ jsx37(
|
|
3425
|
+
"circle",
|
|
3426
|
+
{
|
|
3427
|
+
className: "avl-time-picker-dial-knob",
|
|
3428
|
+
cx: C,
|
|
3429
|
+
cy: C,
|
|
3430
|
+
r: KNOB
|
|
3431
|
+
}
|
|
3432
|
+
),
|
|
3433
|
+
!isHour && m % 5 !== 0 && /* @__PURE__ */ jsx37(
|
|
3434
|
+
"circle",
|
|
3435
|
+
{
|
|
3436
|
+
className: "avl-time-picker-dial-dot",
|
|
3437
|
+
cx: C,
|
|
3438
|
+
cy: C,
|
|
3439
|
+
r: 2
|
|
3440
|
+
}
|
|
3441
|
+
)
|
|
3442
|
+
]
|
|
3443
|
+
}
|
|
3444
|
+
)
|
|
3445
|
+
]
|
|
3446
|
+
}
|
|
3447
|
+
)
|
|
3448
|
+
] }),
|
|
3449
|
+
labels.map((l) => {
|
|
3450
|
+
const p = isHour ? point(l.value % 12, 12, l.inner ? INNER : OUTER) : point(l.value, 60, OUTER);
|
|
3451
|
+
return /* @__PURE__ */ jsx37(
|
|
3452
|
+
"text",
|
|
3453
|
+
{
|
|
3454
|
+
className: cx(
|
|
3455
|
+
"avl-time-picker-dial-label",
|
|
3456
|
+
l.inner && "avl-time-picker-dial-label-inner"
|
|
3457
|
+
),
|
|
3458
|
+
"data-selected": isSelected(l.value) || void 0,
|
|
3459
|
+
x: p.x,
|
|
3460
|
+
y: p.y,
|
|
3461
|
+
"aria-hidden": true,
|
|
3462
|
+
children: l.text
|
|
3463
|
+
},
|
|
3464
|
+
l.value
|
|
3465
|
+
);
|
|
3466
|
+
})
|
|
3467
|
+
]
|
|
3468
|
+
}
|
|
3469
|
+
);
|
|
3470
|
+
}
|
|
3471
|
+
|
|
3472
|
+
// src/components/DateInput/DateInput.tsx
|
|
3473
|
+
import { useId as useId3, useRef as useRef13, useState as useState9 } from "react";
|
|
3474
|
+
import { Input as BaseInput2 } from "@base-ui/react/input";
|
|
3475
|
+
import { jsx as jsx38, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
3476
|
+
var numericFormat = () => new Intl.DateTimeFormat(void 0, {
|
|
3477
|
+
year: "numeric",
|
|
3478
|
+
month: "2-digit",
|
|
3479
|
+
day: "2-digit"
|
|
3480
|
+
});
|
|
3481
|
+
function DateInput({
|
|
3482
|
+
value: valueProp,
|
|
3483
|
+
defaultValue = null,
|
|
3484
|
+
onValueChange,
|
|
3485
|
+
label,
|
|
3486
|
+
size = "normal",
|
|
3487
|
+
disabled,
|
|
3488
|
+
id,
|
|
3489
|
+
onBlur,
|
|
3490
|
+
className,
|
|
3491
|
+
...props
|
|
3492
|
+
}) {
|
|
3493
|
+
const [internal, setInternal] = useState9(defaultValue);
|
|
3494
|
+
const value = valueProp !== void 0 ? valueProp : internal;
|
|
3495
|
+
const date = fromIso(value);
|
|
3496
|
+
const [draft, setDraft] = useState9(null);
|
|
3497
|
+
const [open, setOpen] = useState9(false);
|
|
3498
|
+
const fieldRef = useRef13(null);
|
|
3499
|
+
const popupRef = useRef13(null);
|
|
3500
|
+
const generatedId = useId3();
|
|
3501
|
+
const inputId = id ?? generatedId;
|
|
3502
|
+
const fmt = numericFormat();
|
|
3503
|
+
const order = fieldOrder(fmt);
|
|
3504
|
+
const invalid = draft != null && draft.trim() !== "" && !parseTyped(draft, order);
|
|
3505
|
+
const commit = (d) => {
|
|
3506
|
+
const next = d && toIso(d);
|
|
3507
|
+
setInternal(next);
|
|
3508
|
+
onValueChange?.(next);
|
|
3509
|
+
};
|
|
3510
|
+
return /* @__PURE__ */ jsxs23(Popover, { open, onOpenChange: setOpen, children: [
|
|
3511
|
+
/* @__PURE__ */ jsxs23(
|
|
3512
|
+
"div",
|
|
3513
|
+
{
|
|
3514
|
+
ref: fieldRef,
|
|
3515
|
+
className: cx(
|
|
3516
|
+
"avl-input",
|
|
3517
|
+
"avl-date-input",
|
|
3518
|
+
`avl-input-size-${size}`,
|
|
3519
|
+
label != null && "avl-input-labeled",
|
|
3520
|
+
className
|
|
3521
|
+
),
|
|
3522
|
+
children: [
|
|
3523
|
+
/* @__PURE__ */ jsx38(
|
|
3524
|
+
BaseInput2,
|
|
3525
|
+
{
|
|
3526
|
+
...props,
|
|
3527
|
+
id: inputId,
|
|
3528
|
+
disabled,
|
|
3529
|
+
className: "avl-input-field",
|
|
3530
|
+
inputMode: "numeric",
|
|
3531
|
+
autoComplete: "off",
|
|
3532
|
+
placeholder: placeholderFor(fmt),
|
|
3533
|
+
"aria-invalid": invalid || void 0,
|
|
3534
|
+
value: draft ?? (date ? fmt.format(date) : ""),
|
|
3535
|
+
onChange: (e) => {
|
|
3536
|
+
const text = e.target.value;
|
|
3537
|
+
setDraft(text);
|
|
3538
|
+
if (!text.trim()) commit(null);
|
|
3539
|
+
else {
|
|
3540
|
+
const typed = parseTyped(text, order);
|
|
3541
|
+
if (typed) commit(typed);
|
|
3542
|
+
}
|
|
3543
|
+
},
|
|
3544
|
+
onBlur: (e) => {
|
|
3545
|
+
if (!invalid) setDraft(null);
|
|
3546
|
+
onBlur?.(e);
|
|
3547
|
+
}
|
|
3548
|
+
}
|
|
3549
|
+
),
|
|
3550
|
+
label != null && /* @__PURE__ */ jsx38("label", { htmlFor: inputId, className: "avl-input-label", children: label }),
|
|
3551
|
+
/* @__PURE__ */ jsx38(
|
|
3552
|
+
PopoverTrigger,
|
|
3553
|
+
{
|
|
3554
|
+
disabled,
|
|
3555
|
+
render: /* @__PURE__ */ jsx38(
|
|
3556
|
+
IconButton,
|
|
3557
|
+
{
|
|
3558
|
+
icon: "calendar_today",
|
|
3559
|
+
fillType: "text",
|
|
3560
|
+
color: "container",
|
|
3561
|
+
"aria-label": "Choose date"
|
|
3562
|
+
}
|
|
3563
|
+
)
|
|
3564
|
+
}
|
|
3565
|
+
),
|
|
3566
|
+
/* @__PURE__ */ jsx38("fieldset", { "aria-hidden": true, className: "avl-input-outline", children: /* @__PURE__ */ jsx38("legend", { children: label != null && size === "normal" && /* @__PURE__ */ jsx38("span", { children: label }) }) })
|
|
3567
|
+
]
|
|
3568
|
+
}
|
|
3569
|
+
),
|
|
3570
|
+
/* @__PURE__ */ jsx38(
|
|
3571
|
+
PopoverPopup,
|
|
3572
|
+
{
|
|
3573
|
+
anchor: fieldRef,
|
|
3574
|
+
align: "start",
|
|
3575
|
+
ref: popupRef,
|
|
3576
|
+
initialFocus: () => popupRef.current?.querySelector(
|
|
3577
|
+
'.avl-calendar-day[tabindex="0"]'
|
|
3578
|
+
) ?? true,
|
|
3579
|
+
"aria-label": "Choose date",
|
|
3580
|
+
children: /* @__PURE__ */ jsx38(
|
|
3581
|
+
Calendar,
|
|
3582
|
+
{
|
|
3583
|
+
value: date && toIso(date),
|
|
3584
|
+
onValueChange: (iso) => {
|
|
3585
|
+
commit(fromIso(iso));
|
|
3586
|
+
setDraft(null);
|
|
3587
|
+
setOpen(false);
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
)
|
|
3591
|
+
}
|
|
3592
|
+
)
|
|
3593
|
+
] });
|
|
3594
|
+
}
|
|
3595
|
+
|
|
3596
|
+
// src/components/Combobox/Combobox.tsx
|
|
3597
|
+
import { useContext as useContext17, useId as useId4 } from "react";
|
|
3598
|
+
import { Combobox as BaseCombobox } from "@base-ui/react/combobox";
|
|
3599
|
+
import { jsx as jsx39, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
3600
|
+
function Combobox({
|
|
3601
|
+
children,
|
|
3602
|
+
label,
|
|
3603
|
+
placeholder,
|
|
3604
|
+
empty,
|
|
3605
|
+
size = "normal",
|
|
3606
|
+
className,
|
|
3607
|
+
...props
|
|
3608
|
+
}) {
|
|
3609
|
+
const avl = useContext17(AnvilContext);
|
|
3610
|
+
if (process.env.NODE_ENV !== "production") {
|
|
3611
|
+
checkRoot(avl !== null, "Combobox");
|
|
3612
|
+
if (typeof children !== "function")
|
|
3613
|
+
devError(
|
|
3614
|
+
"<Combobox> children must be a function that renders one item, plus an `items` array to filter.",
|
|
3615
|
+
'<Combobox label="Fruit" items={fruits}>\n {(fruit: string) => <ComboboxItem key={fruit} value={fruit}>{fruit}</ComboboxItem>}\n</Combobox>',
|
|
3616
|
+
"combobox.md"
|
|
3617
|
+
);
|
|
3618
|
+
}
|
|
3619
|
+
const inputId = useId4();
|
|
3620
|
+
const labelId = useId4();
|
|
3621
|
+
return /* @__PURE__ */ jsxs24(BaseCombobox.Root, { ...props, children: [
|
|
3622
|
+
/* @__PURE__ */ jsxs24(
|
|
3623
|
+
BaseCombobox.InputGroup,
|
|
3624
|
+
{
|
|
3625
|
+
className: cx(
|
|
3626
|
+
"avl-input",
|
|
3627
|
+
"avl-combobox",
|
|
3628
|
+
`avl-input-size-${size}`,
|
|
3629
|
+
label != null && "avl-input-labeled",
|
|
3630
|
+
className
|
|
3631
|
+
),
|
|
3632
|
+
children: [
|
|
3633
|
+
/* @__PURE__ */ jsx39(
|
|
3634
|
+
BaseCombobox.Input,
|
|
3635
|
+
{
|
|
3636
|
+
id: inputId,
|
|
3637
|
+
className: "avl-input-field",
|
|
3638
|
+
placeholder: placeholder ?? " "
|
|
3639
|
+
}
|
|
3640
|
+
),
|
|
3641
|
+
label != null && /* @__PURE__ */ jsx39(
|
|
3642
|
+
"label",
|
|
3643
|
+
{
|
|
3644
|
+
id: labelId,
|
|
3645
|
+
htmlFor: inputId,
|
|
3646
|
+
className: "avl-input-label",
|
|
3647
|
+
children: label
|
|
3648
|
+
}
|
|
3649
|
+
),
|
|
3650
|
+
/* @__PURE__ */ jsx39(
|
|
3651
|
+
BaseCombobox.Trigger,
|
|
3652
|
+
{
|
|
3653
|
+
className: "avl-combobox-trigger",
|
|
3654
|
+
"aria-labelledby": label != null ? labelId : void 0,
|
|
3655
|
+
children: /* @__PURE__ */ jsx39(Icon, { name: "arrow_drop_down", className: "avl-select-icon" })
|
|
3656
|
+
}
|
|
3657
|
+
),
|
|
3658
|
+
/* @__PURE__ */ jsx39("fieldset", { "aria-hidden": true, className: "avl-input-outline", children: /* @__PURE__ */ jsx39("legend", { children: label != null && size === "normal" && /* @__PURE__ */ jsx39("span", { children: label }) }) })
|
|
3659
|
+
]
|
|
3660
|
+
}
|
|
3661
|
+
),
|
|
3662
|
+
/* @__PURE__ */ jsx39(BaseCombobox.Portal, { container: avl?.rootRef, children: /* @__PURE__ */ jsx39(
|
|
3663
|
+
BaseCombobox.Positioner,
|
|
3664
|
+
{
|
|
3665
|
+
className: "avl-menu-positioner",
|
|
3666
|
+
sideOffset: 4,
|
|
3667
|
+
children: /* @__PURE__ */ jsxs24(BaseCombobox.Popup, { className: "avl-menu-popup avl-select-popup avl-combobox-popup", children: [
|
|
3668
|
+
empty != null && /* @__PURE__ */ jsx39(BaseCombobox.Empty, { className: "avl-combobox-empty", children: empty }),
|
|
3669
|
+
/* @__PURE__ */ jsx39(BaseCombobox.List, { children })
|
|
3670
|
+
] })
|
|
3671
|
+
}
|
|
3672
|
+
) })
|
|
3673
|
+
] });
|
|
3674
|
+
}
|
|
3675
|
+
function ComboboxItem({
|
|
3676
|
+
className,
|
|
3677
|
+
children,
|
|
3678
|
+
...props
|
|
3679
|
+
}) {
|
|
3680
|
+
return /* @__PURE__ */ jsxs24(
|
|
3681
|
+
BaseCombobox.Item,
|
|
3682
|
+
{
|
|
3683
|
+
...props,
|
|
3684
|
+
className: withClass("avl-menu-item avl-select-item", className),
|
|
3685
|
+
children: [
|
|
3686
|
+
/* @__PURE__ */ jsx39("span", { className: "avl-menu-item-label", children }),
|
|
3687
|
+
/* @__PURE__ */ jsx39(BaseCombobox.ItemIndicator, { className: "avl-select-item-indicator", children: /* @__PURE__ */ jsx39(Icon, { name: "check" }) })
|
|
3688
|
+
]
|
|
3689
|
+
}
|
|
3690
|
+
);
|
|
3691
|
+
}
|
|
3692
|
+
|
|
3693
|
+
// src/components/PinInput/PinInput.tsx
|
|
3694
|
+
import { useId as useId5 } from "react";
|
|
3695
|
+
import { OTPField as BaseOTPField } from "@base-ui/react/otp-field";
|
|
3696
|
+
import { jsx as jsx40, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
3697
|
+
var defaultSlotLabel = (index, length) => `Character ${index + 1} of ${length}`;
|
|
3698
|
+
function PinInput({
|
|
3699
|
+
label,
|
|
3700
|
+
"aria-label": ariaLabel,
|
|
3701
|
+
fillType = "outlined",
|
|
3702
|
+
size = "normal",
|
|
3703
|
+
slotLabel = defaultSlotLabel,
|
|
3704
|
+
className,
|
|
3705
|
+
id,
|
|
3706
|
+
length,
|
|
3707
|
+
...props
|
|
3708
|
+
}) {
|
|
3709
|
+
const generatedId = useId5();
|
|
3710
|
+
const inputId = id ?? generatedId;
|
|
3711
|
+
const labelId = `${inputId}-label`;
|
|
3712
|
+
return /* @__PURE__ */ jsxs25(
|
|
3713
|
+
"div",
|
|
3714
|
+
{
|
|
3715
|
+
className: cx(
|
|
3716
|
+
"avl-pin-input",
|
|
3717
|
+
`avl-pin-input-size-${size}`,
|
|
3718
|
+
`avl-pin-input-fill-${fillType}`,
|
|
3719
|
+
className
|
|
3720
|
+
),
|
|
3721
|
+
children: [
|
|
3722
|
+
label != null ? /* @__PURE__ */ jsx40(
|
|
3723
|
+
"label",
|
|
3724
|
+
{
|
|
3725
|
+
id: labelId,
|
|
3726
|
+
htmlFor: inputId,
|
|
3727
|
+
className: "avl-pin-input-label",
|
|
3728
|
+
children: label
|
|
3729
|
+
}
|
|
3730
|
+
) : (
|
|
3731
|
+
// Base UI ignores aria-label on the first box, but aria-labelledby
|
|
3732
|
+
// still reads hidden elements
|
|
3733
|
+
/* @__PURE__ */ jsx40("span", { id: labelId, hidden: true, children: ariaLabel })
|
|
3734
|
+
),
|
|
3735
|
+
/* @__PURE__ */ jsx40(
|
|
3736
|
+
BaseOTPField.Root,
|
|
3737
|
+
{
|
|
3738
|
+
...props,
|
|
3739
|
+
id: inputId,
|
|
3740
|
+
length,
|
|
3741
|
+
"aria-labelledby": labelId,
|
|
3742
|
+
className: "avl-pin-input-slots",
|
|
3743
|
+
children: Array.from({ length }, (_, i) => /* @__PURE__ */ jsx40(
|
|
3744
|
+
BaseOTPField.Input,
|
|
3745
|
+
{
|
|
3746
|
+
className: "avl-pin-input-slot",
|
|
3747
|
+
"aria-label": i > 0 ? slotLabel(i, length) : void 0,
|
|
3748
|
+
"aria-labelledby": i === 0 && label == null ? labelId : void 0
|
|
3749
|
+
},
|
|
3750
|
+
i
|
|
3751
|
+
))
|
|
3752
|
+
}
|
|
3753
|
+
)
|
|
3754
|
+
]
|
|
3755
|
+
}
|
|
3756
|
+
);
|
|
3757
|
+
}
|
|
3758
|
+
|
|
3759
|
+
// src/components/Toggle/Toggle.tsx
|
|
3760
|
+
import { Toggle as BaseToggle2 } from "@base-ui/react/toggle";
|
|
3761
|
+
import { Fragment as Fragment5, jsx as jsx41, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
3762
|
+
function Toggle2({
|
|
3763
|
+
icon,
|
|
3764
|
+
startIcon,
|
|
3765
|
+
endIcon,
|
|
3766
|
+
size = "normal",
|
|
3767
|
+
color,
|
|
3768
|
+
fillType,
|
|
3769
|
+
children,
|
|
3770
|
+
className,
|
|
3771
|
+
...props
|
|
3772
|
+
}) {
|
|
3773
|
+
if (process.env.NODE_ENV !== "production" && icon) {
|
|
3774
|
+
checkName(
|
|
3775
|
+
props,
|
|
3776
|
+
"Toggle",
|
|
3777
|
+
'<Toggle icon="favorite" aria-label="Favorite" />',
|
|
3778
|
+
"toggle.md"
|
|
3779
|
+
);
|
|
3780
|
+
}
|
|
3781
|
+
return /* @__PURE__ */ jsx41(
|
|
3782
|
+
BaseToggle2,
|
|
3783
|
+
{
|
|
3784
|
+
...props,
|
|
3785
|
+
className: (state) => cx(
|
|
3786
|
+
"avl-toggle",
|
|
3787
|
+
icon ? "avl-icon-button" : `avl-button avl-button-size-${size}`,
|
|
3788
|
+
state.pressed ? colorClass(color, "filled") : colorClass("container", fillType),
|
|
3789
|
+
typeof className === "function" ? className(state) : className
|
|
3790
|
+
),
|
|
3791
|
+
children: icon ? /* @__PURE__ */ jsx41(Icon, { name: icon }) : /* @__PURE__ */ jsxs26(Fragment5, { children: [
|
|
3792
|
+
startIcon && /* @__PURE__ */ jsx41(Icon, { name: startIcon }),
|
|
3793
|
+
children,
|
|
3794
|
+
endIcon && /* @__PURE__ */ jsx41(Icon, { name: endIcon })
|
|
3795
|
+
] })
|
|
3796
|
+
}
|
|
3797
|
+
);
|
|
3798
|
+
}
|
|
3799
|
+
|
|
3800
|
+
// src/components/Search/Search.tsx
|
|
3801
|
+
import { useContext as useContext18 } from "react";
|
|
3802
|
+
import { Autocomplete as BaseAutocomplete } from "@base-ui/react/autocomplete";
|
|
3803
|
+
import { jsx as jsx42, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
3804
|
+
function Search({
|
|
3805
|
+
children,
|
|
3806
|
+
placeholder,
|
|
3807
|
+
"aria-label": ariaLabel,
|
|
3808
|
+
empty,
|
|
3809
|
+
clearLabel = "Clear",
|
|
3810
|
+
className,
|
|
3811
|
+
...props
|
|
3812
|
+
}) {
|
|
3813
|
+
const avl = useContext18(AnvilContext);
|
|
3814
|
+
if (process.env.NODE_ENV !== "production") {
|
|
3815
|
+
checkRoot(avl !== null, "Search");
|
|
3816
|
+
checkName(
|
|
3817
|
+
{ "aria-label": ariaLabel },
|
|
3818
|
+
"Search",
|
|
3819
|
+
'<Search aria-label="Search mail" items={items}>{(item) => ...}</Search>',
|
|
3820
|
+
"search.md"
|
|
3821
|
+
);
|
|
3822
|
+
if (typeof children !== "function")
|
|
3823
|
+
devError(
|
|
3824
|
+
"<Search> children must be a function that renders one suggestion, plus an `items` array to filter.",
|
|
3825
|
+
'<Search aria-label="Search" items={items}>\n {(item: string) => <SearchItem key={item} value={item}>{item}</SearchItem>}\n</Search>',
|
|
3826
|
+
"search.md"
|
|
3827
|
+
);
|
|
3828
|
+
}
|
|
3829
|
+
return /* @__PURE__ */ jsxs27(BaseAutocomplete.Root, { ...props, children: [
|
|
3830
|
+
/* @__PURE__ */ jsxs27(
|
|
3831
|
+
BaseAutocomplete.InputGroup,
|
|
3832
|
+
{
|
|
3833
|
+
className: cx("avl-search", className),
|
|
3834
|
+
children: [
|
|
3835
|
+
/* @__PURE__ */ jsx42(Icon, { name: "search" }),
|
|
3836
|
+
/* @__PURE__ */ jsx42(
|
|
3837
|
+
BaseAutocomplete.Input,
|
|
3838
|
+
{
|
|
3839
|
+
className: "avl-search-input",
|
|
3840
|
+
placeholder,
|
|
3841
|
+
"aria-label": ariaLabel
|
|
3842
|
+
}
|
|
3843
|
+
),
|
|
3844
|
+
/* @__PURE__ */ jsx42(
|
|
3845
|
+
BaseAutocomplete.Clear,
|
|
3846
|
+
{
|
|
3847
|
+
render: /* @__PURE__ */ jsx42(
|
|
3848
|
+
IconButton,
|
|
3849
|
+
{
|
|
3850
|
+
icon: "close",
|
|
3851
|
+
fillType: "text",
|
|
3852
|
+
color: "container",
|
|
3853
|
+
"aria-label": clearLabel
|
|
3854
|
+
}
|
|
3855
|
+
)
|
|
3856
|
+
}
|
|
3857
|
+
)
|
|
3858
|
+
]
|
|
3859
|
+
}
|
|
3860
|
+
),
|
|
3861
|
+
/* @__PURE__ */ jsx42(BaseAutocomplete.Portal, { container: avl?.rootRef, children: /* @__PURE__ */ jsx42(
|
|
3862
|
+
BaseAutocomplete.Positioner,
|
|
3863
|
+
{
|
|
3864
|
+
className: "avl-menu-positioner",
|
|
3865
|
+
sideOffset: 4,
|
|
3866
|
+
children: /* @__PURE__ */ jsxs27(BaseAutocomplete.Popup, { className: "avl-menu-popup avl-search-popup", children: [
|
|
3867
|
+
empty != null && /* @__PURE__ */ jsx42(BaseAutocomplete.Empty, { className: "avl-search-empty", children: empty }),
|
|
3868
|
+
/* @__PURE__ */ jsx42(BaseAutocomplete.List, { children })
|
|
3869
|
+
] })
|
|
3870
|
+
}
|
|
3871
|
+
) })
|
|
3872
|
+
] });
|
|
3873
|
+
}
|
|
3874
|
+
function SearchItem({
|
|
3875
|
+
startIcon,
|
|
3876
|
+
className,
|
|
3877
|
+
children,
|
|
3878
|
+
...props
|
|
3879
|
+
}) {
|
|
3880
|
+
return /* @__PURE__ */ jsxs27(
|
|
3881
|
+
BaseAutocomplete.Item,
|
|
3882
|
+
{
|
|
3883
|
+
...props,
|
|
3884
|
+
className: withClass("avl-menu-item", className),
|
|
3885
|
+
children: [
|
|
3886
|
+
startIcon && /* @__PURE__ */ jsx42(Icon, { name: startIcon }),
|
|
3887
|
+
/* @__PURE__ */ jsx42("span", { className: "avl-menu-item-label", children })
|
|
3888
|
+
]
|
|
3889
|
+
}
|
|
3890
|
+
);
|
|
3891
|
+
}
|
|
3892
|
+
|
|
3893
|
+
// src/components/Skeleton/Skeleton.tsx
|
|
3894
|
+
import { jsx as jsx43 } from "react/jsx-runtime";
|
|
3895
|
+
function Skeleton({
|
|
3896
|
+
variant = "text",
|
|
3897
|
+
animation = "pulse",
|
|
3898
|
+
className,
|
|
3899
|
+
...props
|
|
3900
|
+
}) {
|
|
3901
|
+
return /* @__PURE__ */ jsx43(
|
|
3902
|
+
"span",
|
|
3903
|
+
{
|
|
3904
|
+
"aria-hidden": true,
|
|
3905
|
+
...props,
|
|
3906
|
+
className: cx(
|
|
3907
|
+
"avl-skeleton",
|
|
3908
|
+
`avl-skeleton-${variant}`,
|
|
3909
|
+
animation === "pulse" && "avl-skeleton-pulse",
|
|
3910
|
+
className
|
|
3911
|
+
)
|
|
3912
|
+
}
|
|
3913
|
+
);
|
|
3914
|
+
}
|
|
3915
|
+
|
|
1866
3916
|
// src/components/Slider/Slider.tsx
|
|
1867
3917
|
import { Slider as BaseSlider } from "@base-ui/react/slider";
|
|
1868
|
-
import { jsx as
|
|
3918
|
+
import { jsx as jsx44, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
1869
3919
|
function Slider({
|
|
1870
3920
|
label,
|
|
1871
3921
|
"aria-label": ariaLabel,
|
|
@@ -1874,10 +3924,18 @@ function Slider({
|
|
|
1874
3924
|
className,
|
|
1875
3925
|
...props
|
|
1876
3926
|
}) {
|
|
3927
|
+
if (process.env.NODE_ENV !== "production" && label == null) {
|
|
3928
|
+
checkName(
|
|
3929
|
+
{ "aria-label": ariaLabel, ...props },
|
|
3930
|
+
"Slider",
|
|
3931
|
+
'<Slider label="Volume" /> // or <Slider aria-label="Volume" />',
|
|
3932
|
+
"slider.md"
|
|
3933
|
+
);
|
|
3934
|
+
}
|
|
1877
3935
|
const initial = props.value ?? props.defaultValue;
|
|
1878
3936
|
const thumbCount = Array.isArray(initial) ? initial.length : 1;
|
|
1879
3937
|
const wavy = squiggly && props.orientation !== "vertical";
|
|
1880
|
-
return /* @__PURE__ */
|
|
3938
|
+
return /* @__PURE__ */ jsxs28(
|
|
1881
3939
|
BaseSlider.Root,
|
|
1882
3940
|
{
|
|
1883
3941
|
...props,
|
|
@@ -1890,20 +3948,30 @@ function Slider({
|
|
|
1890
3948
|
className
|
|
1891
3949
|
),
|
|
1892
3950
|
children: [
|
|
1893
|
-
label != null && /* @__PURE__ */
|
|
1894
|
-
/* @__PURE__ */
|
|
1895
|
-
wavy ? /* @__PURE__ */
|
|
3951
|
+
label != null && /* @__PURE__ */ jsx44(BaseSlider.Label, { className: "avl-slider-label", children: label }),
|
|
3952
|
+
/* @__PURE__ */ jsx44(BaseSlider.Control, { className: "avl-slider-control", children: /* @__PURE__ */ jsxs28(BaseSlider.Track, { className: "avl-slider-track", children: [
|
|
3953
|
+
wavy ? /* @__PURE__ */ jsx44(SquigglyWave, { span: handleSpan }) : (
|
|
1896
3954
|
// Clips the track pieces to the rounded track, without
|
|
1897
3955
|
// also clipping the handles, which are taller
|
|
1898
|
-
/* @__PURE__ */
|
|
3956
|
+
/* @__PURE__ */ jsxs28("div", { className: "avl-slider-rail", children: [
|
|
3957
|
+
/* @__PURE__ */ jsx44(BaseSlider.Indicator, { className: "avl-slider-indicator" }),
|
|
3958
|
+
thumbCount > 1 && /* @__PURE__ */ jsx44(BaseSlider.Indicator, { className: "avl-slider-indicator-start" })
|
|
3959
|
+
] })
|
|
1899
3960
|
),
|
|
1900
|
-
Array.from({ length: thumbCount }, (_, i) => /* @__PURE__ */
|
|
3961
|
+
Array.from({ length: thumbCount }, (_, i) => /* @__PURE__ */ jsx44(
|
|
1901
3962
|
BaseSlider.Thumb,
|
|
1902
3963
|
{
|
|
1903
3964
|
index: i,
|
|
1904
3965
|
"aria-label": ariaLabel,
|
|
1905
3966
|
className: "avl-slider-thumb",
|
|
1906
|
-
|
|
3967
|
+
render: (thumbProps, state) => /* @__PURE__ */ jsx44(
|
|
3968
|
+
"div",
|
|
3969
|
+
{
|
|
3970
|
+
...thumbProps,
|
|
3971
|
+
"data-active": state.activeThumbIndex === i ? "" : void 0
|
|
3972
|
+
}
|
|
3973
|
+
),
|
|
3974
|
+
children: showValue && /* @__PURE__ */ jsx44(BaseSlider.Value, { className: "avl-tooltip avl-slider-value", children: (formatted) => formatted[i] })
|
|
1907
3975
|
},
|
|
1908
3976
|
i
|
|
1909
3977
|
))
|
|
@@ -1938,10 +4006,15 @@ function handleSpan(width, gap, svg) {
|
|
|
1938
4006
|
}
|
|
1939
4007
|
|
|
1940
4008
|
// src/components/Snackbar/Snackbar.tsx
|
|
1941
|
-
import { useEffect as
|
|
4009
|
+
import { useContext as useContext19, useEffect as useEffect7, useRef as useRef14, useState as useState10 } from "react";
|
|
1942
4010
|
import { Toast } from "@base-ui/react/toast";
|
|
1943
|
-
import { jsx as
|
|
4011
|
+
import { jsx as jsx45, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
1944
4012
|
function useSnackbar() {
|
|
4013
|
+
const avl = useContext19(AnvilContext);
|
|
4014
|
+
if (process.env.NODE_ENV !== "production" && !avl)
|
|
4015
|
+
throw new Error(
|
|
4016
|
+
"[anvilui] useSnackbar() was called outside <AnvilRoot>.\n\nFix: call it from a component rendered inside <AnvilRoot>, not in the component that renders AnvilRoot:\n<AnvilRoot><App /></AnvilRoot> // useSnackbar() inside App works\n\nDocs: node_modules/anvilui/docs/snackbar.md"
|
|
4017
|
+
);
|
|
1945
4018
|
const manager = Toast.useToastManager();
|
|
1946
4019
|
return {
|
|
1947
4020
|
/** Shows a snackbar at the bottom; open ones move up. Returns its id. */
|
|
@@ -1960,17 +4033,17 @@ function useSnackbar() {
|
|
|
1960
4033
|
}
|
|
1961
4034
|
function SnackbarViewport() {
|
|
1962
4035
|
const { toasts } = Toast.useToastManager();
|
|
1963
|
-
const viewportRef =
|
|
1964
|
-
const [expanded, setExpanded] =
|
|
1965
|
-
const [hovered, setHovered] =
|
|
4036
|
+
const viewportRef = useRef14(null);
|
|
4037
|
+
const [expanded, setExpanded] = useState10(false);
|
|
4038
|
+
const [hovered, setHovered] = useState10(false);
|
|
1966
4039
|
const visibleCount = toasts.filter(
|
|
1967
4040
|
(toast) => toast.transitionStatus !== "ending"
|
|
1968
4041
|
).length;
|
|
1969
4042
|
const collapsed = visibleCount > 1 && !expanded && !hovered;
|
|
1970
|
-
|
|
4043
|
+
useEffect7(() => {
|
|
1971
4044
|
if (visibleCount <= 1) setExpanded(false);
|
|
1972
4045
|
}, [visibleCount]);
|
|
1973
|
-
|
|
4046
|
+
useEffect7(() => {
|
|
1974
4047
|
if (!expanded) return;
|
|
1975
4048
|
const viewport = viewportRef.current;
|
|
1976
4049
|
const close = (event) => {
|
|
@@ -1984,7 +4057,7 @@ function SnackbarViewport() {
|
|
|
1984
4057
|
};
|
|
1985
4058
|
}, [expanded]);
|
|
1986
4059
|
let visibleIndex = 0;
|
|
1987
|
-
return /* @__PURE__ */
|
|
4060
|
+
return /* @__PURE__ */ jsx45(
|
|
1988
4061
|
Toast.Viewport,
|
|
1989
4062
|
{
|
|
1990
4063
|
ref: viewportRef,
|
|
@@ -2002,7 +4075,7 @@ function SnackbarViewport() {
|
|
|
2002
4075
|
},
|
|
2003
4076
|
children: toasts.map((toast) => {
|
|
2004
4077
|
const behind = toast.transitionStatus !== "ending" && visibleIndex++ > 0;
|
|
2005
|
-
return /* @__PURE__ */
|
|
4078
|
+
return /* @__PURE__ */ jsxs29(
|
|
2006
4079
|
Toast.Root,
|
|
2007
4080
|
{
|
|
2008
4081
|
toast,
|
|
@@ -2011,14 +4084,14 @@ function SnackbarViewport() {
|
|
|
2011
4084
|
"data-behind": behind || void 0,
|
|
2012
4085
|
inert: collapsed && behind || void 0,
|
|
2013
4086
|
children: [
|
|
2014
|
-
/* @__PURE__ */
|
|
2015
|
-
toast.actionProps && /* @__PURE__ */
|
|
2016
|
-
toast.data?.closeButton && /* @__PURE__ */
|
|
4087
|
+
/* @__PURE__ */ jsx45(Toast.Description, { className: "avl-snackbar-message" }),
|
|
4088
|
+
toast.actionProps && /* @__PURE__ */ jsx45(Toast.Action, { className: "avl-snackbar-action" }),
|
|
4089
|
+
toast.data?.closeButton && /* @__PURE__ */ jsx45(
|
|
2017
4090
|
Toast.Close,
|
|
2018
4091
|
{
|
|
2019
4092
|
className: "avl-snackbar-close",
|
|
2020
4093
|
"aria-label": "Close",
|
|
2021
|
-
children: /* @__PURE__ */
|
|
4094
|
+
children: /* @__PURE__ */ jsx45(Icon, { name: "close" })
|
|
2022
4095
|
}
|
|
2023
4096
|
)
|
|
2024
4097
|
]
|
|
@@ -2030,25 +4103,102 @@ function SnackbarViewport() {
|
|
|
2030
4103
|
);
|
|
2031
4104
|
}
|
|
2032
4105
|
|
|
4106
|
+
// src/components/Sticker/Sticker.tsx
|
|
4107
|
+
import { jsx as jsx46, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
4108
|
+
function Sticker({
|
|
4109
|
+
color = "primary",
|
|
4110
|
+
startIcon,
|
|
4111
|
+
tilt = -4,
|
|
4112
|
+
className,
|
|
4113
|
+
style,
|
|
4114
|
+
children,
|
|
4115
|
+
...props
|
|
4116
|
+
}) {
|
|
4117
|
+
return /* @__PURE__ */ jsxs30(
|
|
4118
|
+
"span",
|
|
4119
|
+
{
|
|
4120
|
+
...props,
|
|
4121
|
+
className: cx(
|
|
4122
|
+
"avl-sticker",
|
|
4123
|
+
colorClass(color, "filled"),
|
|
4124
|
+
className
|
|
4125
|
+
),
|
|
4126
|
+
style: {
|
|
4127
|
+
"--avl-sticker-tilt": `${tilt}deg`,
|
|
4128
|
+
...style
|
|
4129
|
+
},
|
|
4130
|
+
children: [
|
|
4131
|
+
startIcon && /* @__PURE__ */ jsx46(Icon, { name: startIcon }),
|
|
4132
|
+
children
|
|
4133
|
+
]
|
|
4134
|
+
}
|
|
4135
|
+
);
|
|
4136
|
+
}
|
|
4137
|
+
|
|
2033
4138
|
// src/components/Switch/Switch.tsx
|
|
2034
4139
|
import { Switch as BaseSwitch } from "@base-ui/react/switch";
|
|
2035
|
-
import { jsx as
|
|
4140
|
+
import { jsx as jsx47 } from "react/jsx-runtime";
|
|
2036
4141
|
function Switch({ className, ...props }) {
|
|
2037
|
-
|
|
4142
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4143
|
+
checkProp(
|
|
4144
|
+
props,
|
|
4145
|
+
"label",
|
|
4146
|
+
"Switch",
|
|
4147
|
+
"Wrap it in a <label> with the text instead.",
|
|
4148
|
+
"<label>\n <Switch defaultChecked />\n Wi-Fi\n</label>",
|
|
4149
|
+
"switch.md"
|
|
4150
|
+
);
|
|
4151
|
+
}
|
|
4152
|
+
return /* @__PURE__ */ jsx47(
|
|
2038
4153
|
BaseSwitch.Root,
|
|
2039
4154
|
{
|
|
2040
4155
|
...props,
|
|
2041
4156
|
className: withClass("avl-switch", className),
|
|
2042
|
-
children: /* @__PURE__ */
|
|
4157
|
+
children: /* @__PURE__ */ jsx47(BaseSwitch.Thumb, { className: "avl-switch-thumb" })
|
|
4158
|
+
}
|
|
4159
|
+
);
|
|
4160
|
+
}
|
|
4161
|
+
|
|
4162
|
+
// src/components/Table/Table.tsx
|
|
4163
|
+
import { jsx as jsx48 } from "react/jsx-runtime";
|
|
4164
|
+
function Table({ className, ...props }) {
|
|
4165
|
+
return /* @__PURE__ */ jsx48("table", { ...props, className: cx("avl-table", className) });
|
|
4166
|
+
}
|
|
4167
|
+
function TableCaption({ className, ...props }) {
|
|
4168
|
+
return /* @__PURE__ */ jsx48("caption", { ...props, className: cx("avl-table-caption", className) });
|
|
4169
|
+
}
|
|
4170
|
+
function TableHead({ className, ...props }) {
|
|
4171
|
+
return /* @__PURE__ */ jsx48("thead", { ...props, className: cx("avl-table-head", className) });
|
|
4172
|
+
}
|
|
4173
|
+
function TableBody({ className, ...props }) {
|
|
4174
|
+
return /* @__PURE__ */ jsx48("tbody", { ...props, className: cx("avl-table-body", className) });
|
|
4175
|
+
}
|
|
4176
|
+
function TableRow({ className, ...props }) {
|
|
4177
|
+
return /* @__PURE__ */ jsx48("tr", { ...props, className: cx("avl-table-row", className) });
|
|
4178
|
+
}
|
|
4179
|
+
function TableHeaderCell({
|
|
4180
|
+
scope = "col",
|
|
4181
|
+
className,
|
|
4182
|
+
...props
|
|
4183
|
+
}) {
|
|
4184
|
+
return /* @__PURE__ */ jsx48(
|
|
4185
|
+
"th",
|
|
4186
|
+
{
|
|
4187
|
+
...props,
|
|
4188
|
+
scope,
|
|
4189
|
+
className: cx("avl-table-header-cell", className)
|
|
2043
4190
|
}
|
|
2044
4191
|
);
|
|
2045
4192
|
}
|
|
4193
|
+
function TableCell({ className, ...props }) {
|
|
4194
|
+
return /* @__PURE__ */ jsx48("td", { ...props, className: cx("avl-table-cell", className) });
|
|
4195
|
+
}
|
|
2046
4196
|
|
|
2047
4197
|
// src/components/Tabs/Tabs.tsx
|
|
2048
4198
|
import { Tabs as BaseTabs } from "@base-ui/react/tabs";
|
|
2049
|
-
import { jsx as
|
|
4199
|
+
import { jsx as jsx49, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
2050
4200
|
function Tabs({ className, ...props }) {
|
|
2051
|
-
return /* @__PURE__ */
|
|
4201
|
+
return /* @__PURE__ */ jsx49(
|
|
2052
4202
|
BaseTabs.Root,
|
|
2053
4203
|
{
|
|
2054
4204
|
...props,
|
|
@@ -2057,33 +4207,33 @@ function Tabs({ className, ...props }) {
|
|
|
2057
4207
|
);
|
|
2058
4208
|
}
|
|
2059
4209
|
function TabsList({ className, children, ...props }) {
|
|
2060
|
-
return /* @__PURE__ */
|
|
4210
|
+
return /* @__PURE__ */ jsxs31(
|
|
2061
4211
|
BaseTabs.List,
|
|
2062
4212
|
{
|
|
2063
4213
|
...props,
|
|
2064
4214
|
className: withClass("avl-tabs-list", className),
|
|
2065
4215
|
children: [
|
|
2066
4216
|
children,
|
|
2067
|
-
/* @__PURE__ */
|
|
4217
|
+
/* @__PURE__ */ jsx49(BaseTabs.Indicator, { className: "avl-tabs-indicator" })
|
|
2068
4218
|
]
|
|
2069
4219
|
}
|
|
2070
4220
|
);
|
|
2071
4221
|
}
|
|
2072
4222
|
function TabsTab({ icon, className, children, ...props }) {
|
|
2073
|
-
return /* @__PURE__ */
|
|
4223
|
+
return /* @__PURE__ */ jsx49(
|
|
2074
4224
|
BaseTabs.Tab,
|
|
2075
4225
|
{
|
|
2076
4226
|
...props,
|
|
2077
4227
|
className: withClass("avl-tabs-tab", className),
|
|
2078
|
-
children: /* @__PURE__ */
|
|
2079
|
-
icon && /* @__PURE__ */
|
|
2080
|
-
/* @__PURE__ */
|
|
4228
|
+
children: /* @__PURE__ */ jsxs31("span", { className: "avl-tabs-tab-content", children: [
|
|
4229
|
+
icon && /* @__PURE__ */ jsx49(Icon, { name: icon }),
|
|
4230
|
+
/* @__PURE__ */ jsx49("span", { className: "avl-tabs-tab-label", children })
|
|
2081
4231
|
] })
|
|
2082
4232
|
}
|
|
2083
4233
|
);
|
|
2084
4234
|
}
|
|
2085
4235
|
function TabsPanel({ className, ...props }) {
|
|
2086
|
-
return /* @__PURE__ */
|
|
4236
|
+
return /* @__PURE__ */ jsx49(
|
|
2087
4237
|
BaseTabs.Panel,
|
|
2088
4238
|
{
|
|
2089
4239
|
...props,
|
|
@@ -2093,8 +4243,8 @@ function TabsPanel({ className, ...props }) {
|
|
|
2093
4243
|
}
|
|
2094
4244
|
|
|
2095
4245
|
// src/components/Textarea/Textarea.tsx
|
|
2096
|
-
import { Input as
|
|
2097
|
-
import { jsx as
|
|
4246
|
+
import { Input as BaseInput3 } from "@base-ui/react/input";
|
|
4247
|
+
import { jsx as jsx50, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
2098
4248
|
function Textarea({
|
|
2099
4249
|
label,
|
|
2100
4250
|
size = "normal",
|
|
@@ -2102,7 +4252,7 @@ function Textarea({
|
|
|
2102
4252
|
placeholder,
|
|
2103
4253
|
...props
|
|
2104
4254
|
}) {
|
|
2105
|
-
return /* @__PURE__ */
|
|
4255
|
+
return /* @__PURE__ */ jsxs32(
|
|
2106
4256
|
"label",
|
|
2107
4257
|
{
|
|
2108
4258
|
className: cx(
|
|
@@ -2113,17 +4263,17 @@ function Textarea({
|
|
|
2113
4263
|
className
|
|
2114
4264
|
),
|
|
2115
4265
|
children: [
|
|
2116
|
-
/* @__PURE__ */
|
|
2117
|
-
|
|
4266
|
+
/* @__PURE__ */ jsx50(
|
|
4267
|
+
BaseInput3,
|
|
2118
4268
|
{
|
|
2119
4269
|
...props,
|
|
2120
|
-
render: /* @__PURE__ */
|
|
4270
|
+
render: /* @__PURE__ */ jsx50("textarea", {}),
|
|
2121
4271
|
placeholder: placeholder ?? " ",
|
|
2122
4272
|
className: "avl-input-field"
|
|
2123
4273
|
}
|
|
2124
4274
|
),
|
|
2125
|
-
label != null && /* @__PURE__ */
|
|
2126
|
-
/* @__PURE__ */
|
|
4275
|
+
label != null && /* @__PURE__ */ jsx50("span", { className: "avl-input-label", children: label }),
|
|
4276
|
+
/* @__PURE__ */ jsx50("fieldset", { "aria-hidden": true, className: "avl-input-outline", children: /* @__PURE__ */ jsx50("legend", { children: label != null && size === "normal" && /* @__PURE__ */ jsx50("span", { children: label }) }) })
|
|
2127
4277
|
]
|
|
2128
4278
|
}
|
|
2129
4279
|
);
|
|
@@ -2131,13 +4281,13 @@ function Textarea({
|
|
|
2131
4281
|
|
|
2132
4282
|
// src/components/FloatingToolbar/FloatingToolbar.tsx
|
|
2133
4283
|
import { Toolbar as BaseToolbar } from "@base-ui/react/toolbar";
|
|
2134
|
-
import { jsx as
|
|
4284
|
+
import { jsx as jsx51 } from "react/jsx-runtime";
|
|
2135
4285
|
function FloatingToolbar({
|
|
2136
4286
|
inverseColor = false,
|
|
2137
4287
|
className,
|
|
2138
4288
|
...props
|
|
2139
4289
|
}) {
|
|
2140
|
-
return /* @__PURE__ */
|
|
4290
|
+
return /* @__PURE__ */ jsx51(
|
|
2141
4291
|
BaseToolbar.Root,
|
|
2142
4292
|
{
|
|
2143
4293
|
...props,
|
|
@@ -2158,11 +4308,11 @@ function FloatingToolbarButton({
|
|
|
2158
4308
|
disabled,
|
|
2159
4309
|
...props
|
|
2160
4310
|
}) {
|
|
2161
|
-
return /* @__PURE__ */
|
|
4311
|
+
return /* @__PURE__ */ jsx51(
|
|
2162
4312
|
BaseToolbar.Button,
|
|
2163
4313
|
{
|
|
2164
4314
|
disabled,
|
|
2165
|
-
render: /* @__PURE__ */
|
|
4315
|
+
render: /* @__PURE__ */ jsx51(IconButton, { ...props, color, fillType })
|
|
2166
4316
|
}
|
|
2167
4317
|
);
|
|
2168
4318
|
}
|
|
@@ -2170,7 +4320,7 @@ function FloatingToolbarSeparator({
|
|
|
2170
4320
|
className,
|
|
2171
4321
|
...props
|
|
2172
4322
|
}) {
|
|
2173
|
-
return /* @__PURE__ */
|
|
4323
|
+
return /* @__PURE__ */ jsx51(
|
|
2174
4324
|
BaseToolbar.Separator,
|
|
2175
4325
|
{
|
|
2176
4326
|
...props,
|
|
@@ -2183,9 +4333,12 @@ function FloatingToolbarSeparator({
|
|
|
2183
4333
|
}
|
|
2184
4334
|
|
|
2185
4335
|
// src/components/Tooltip/Tooltip.tsx
|
|
2186
|
-
import {
|
|
4336
|
+
import {
|
|
4337
|
+
isValidElement,
|
|
4338
|
+
useContext as useContext20
|
|
4339
|
+
} from "react";
|
|
2187
4340
|
import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip";
|
|
2188
|
-
import { jsx as
|
|
4341
|
+
import { jsx as jsx52, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
2189
4342
|
function Tooltip({
|
|
2190
4343
|
label,
|
|
2191
4344
|
children,
|
|
@@ -2198,9 +4351,34 @@ function Tooltip({
|
|
|
2198
4351
|
className,
|
|
2199
4352
|
...props
|
|
2200
4353
|
}) {
|
|
2201
|
-
const avl =
|
|
2202
|
-
|
|
2203
|
-
|
|
4354
|
+
const avl = useContext20(AnvilContext);
|
|
4355
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4356
|
+
checkRoot(avl !== null, "Tooltip");
|
|
4357
|
+
checkProp(
|
|
4358
|
+
props,
|
|
4359
|
+
"content",
|
|
4360
|
+
"Tooltip",
|
|
4361
|
+
"The text goes in `label`.",
|
|
4362
|
+
'<Tooltip label="Delete">\n <IconButton icon="delete" aria-label="Delete" />\n</Tooltip>',
|
|
4363
|
+
"tooltip.md"
|
|
4364
|
+
);
|
|
4365
|
+
checkProp(
|
|
4366
|
+
props,
|
|
4367
|
+
"title",
|
|
4368
|
+
"Tooltip",
|
|
4369
|
+
"The text goes in `label`.",
|
|
4370
|
+
'<Tooltip label="Delete">\n <IconButton icon="delete" aria-label="Delete" />\n</Tooltip>',
|
|
4371
|
+
"tooltip.md"
|
|
4372
|
+
);
|
|
4373
|
+
if (!isValidElement(children))
|
|
4374
|
+
devError(
|
|
4375
|
+
"<Tooltip> needs exactly one element child (the trigger), not text or several elements.",
|
|
4376
|
+
'<Tooltip label="Delete">\n <IconButton icon="delete" aria-label="Delete" />\n</Tooltip>\n// for plain text: <Tooltip label="..."><span tabIndex={0}>text</span></Tooltip>',
|
|
4377
|
+
"tooltip.md"
|
|
4378
|
+
);
|
|
4379
|
+
}
|
|
4380
|
+
return /* @__PURE__ */ jsxs33(BaseTooltip.Root, { ...props, children: [
|
|
4381
|
+
/* @__PURE__ */ jsx52(
|
|
2204
4382
|
BaseTooltip.Trigger,
|
|
2205
4383
|
{
|
|
2206
4384
|
render: children,
|
|
@@ -2208,7 +4386,7 @@ function Tooltip({
|
|
|
2208
4386
|
closeDelay
|
|
2209
4387
|
}
|
|
2210
4388
|
),
|
|
2211
|
-
/* @__PURE__ */
|
|
4389
|
+
/* @__PURE__ */ jsx52(BaseTooltip.Portal, { container: avl?.rootRef, children: /* @__PURE__ */ jsx52(
|
|
2212
4390
|
BaseTooltip.Positioner,
|
|
2213
4391
|
{
|
|
2214
4392
|
className: "avl-tooltip-positioner",
|
|
@@ -2216,7 +4394,7 @@ function Tooltip({
|
|
|
2216
4394
|
align,
|
|
2217
4395
|
sideOffset: sideOffset ?? 4,
|
|
2218
4396
|
alignOffset,
|
|
2219
|
-
children: /* @__PURE__ */
|
|
4397
|
+
children: /* @__PURE__ */ jsx52(
|
|
2220
4398
|
BaseTooltip.Popup,
|
|
2221
4399
|
{
|
|
2222
4400
|
className: withClass("avl-tooltip", className),
|
|
@@ -2231,9 +4409,9 @@ function Tooltip({
|
|
|
2231
4409
|
// src/components/NavigationBar/NavigationBar.tsx
|
|
2232
4410
|
import { useRender as useRender2 } from "@base-ui/react/use-render";
|
|
2233
4411
|
import { mergeProps as mergeProps2 } from "@base-ui/react/merge-props";
|
|
2234
|
-
import { Fragment as
|
|
4412
|
+
import { Fragment as Fragment6, jsx as jsx53, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
2235
4413
|
function NavigationBar({ className, ...props }) {
|
|
2236
|
-
return /* @__PURE__ */
|
|
4414
|
+
return /* @__PURE__ */ jsx53("nav", { ...props, className: cx("avl-navigation-bar", className) });
|
|
2237
4415
|
}
|
|
2238
4416
|
function NavigationBarItem({
|
|
2239
4417
|
icon,
|
|
@@ -2251,9 +4429,100 @@ function NavigationBarItem({
|
|
|
2251
4429
|
{
|
|
2252
4430
|
className: cx("avl-navigation-bar-item", className),
|
|
2253
4431
|
"aria-current": active ? "page" : void 0,
|
|
2254
|
-
children: /* @__PURE__ */
|
|
2255
|
-
/* @__PURE__ */
|
|
2256
|
-
/* @__PURE__ */
|
|
4432
|
+
children: /* @__PURE__ */ jsxs34(Fragment6, { children: [
|
|
4433
|
+
/* @__PURE__ */ jsx53("span", { className: "avl-navigation-bar-item-indicator", children: /* @__PURE__ */ jsx53(Icon, { name: icon }) }),
|
|
4434
|
+
/* @__PURE__ */ jsx53("span", { className: "avl-navigation-bar-item-label", children: label })
|
|
4435
|
+
] })
|
|
4436
|
+
},
|
|
4437
|
+
props
|
|
4438
|
+
)
|
|
4439
|
+
});
|
|
4440
|
+
}
|
|
4441
|
+
|
|
4442
|
+
// src/components/NavigationRail/NavigationRail.tsx
|
|
4443
|
+
import {
|
|
4444
|
+
createContext as createContext7,
|
|
4445
|
+
useContext as useContext21,
|
|
4446
|
+
useState as useState11
|
|
4447
|
+
} from "react";
|
|
4448
|
+
import { useRender as useRender3 } from "@base-ui/react/use-render";
|
|
4449
|
+
import { mergeProps as mergeProps3 } from "@base-ui/react/merge-props";
|
|
4450
|
+
import { Fragment as Fragment7, jsx as jsx54, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
4451
|
+
var RailContext = createContext7(null);
|
|
4452
|
+
function NavigationRail({
|
|
4453
|
+
expanded: expandedProp,
|
|
4454
|
+
defaultExpanded = false,
|
|
4455
|
+
onExpandedChange,
|
|
4456
|
+
className,
|
|
4457
|
+
...props
|
|
4458
|
+
}) {
|
|
4459
|
+
const [internal, setInternal] = useState11(defaultExpanded);
|
|
4460
|
+
const expanded = expandedProp ?? internal;
|
|
4461
|
+
const setExpanded = (next) => {
|
|
4462
|
+
setInternal(next);
|
|
4463
|
+
onExpandedChange?.(next);
|
|
4464
|
+
};
|
|
4465
|
+
return /* @__PURE__ */ jsx54(RailContext.Provider, { value: { expanded, setExpanded }, children: /* @__PURE__ */ jsx54(
|
|
4466
|
+
"nav",
|
|
4467
|
+
{
|
|
4468
|
+
...props,
|
|
4469
|
+
"data-expanded": expanded || void 0,
|
|
4470
|
+
className: cx("avl-navigation-rail", className)
|
|
4471
|
+
}
|
|
4472
|
+
) });
|
|
4473
|
+
}
|
|
4474
|
+
function NavigationRailToggle({
|
|
4475
|
+
className,
|
|
4476
|
+
onClick,
|
|
4477
|
+
...props
|
|
4478
|
+
}) {
|
|
4479
|
+
const rail = useContext21(RailContext);
|
|
4480
|
+
if (process.env.NODE_ENV !== "production" && !rail) {
|
|
4481
|
+
devError(
|
|
4482
|
+
"<NavigationRailToggle> is rendered outside a <NavigationRail>, so it has nothing to expand.",
|
|
4483
|
+
'<NavigationRail aria-label="Main">\n <NavigationRailToggle aria-label="Toggle navigation" />\n <NavigationRailItem icon="home" label="Home" href="/" />\n</NavigationRail>',
|
|
4484
|
+
"navigation-rail.md"
|
|
4485
|
+
);
|
|
4486
|
+
}
|
|
4487
|
+
const expanded = rail?.expanded ?? false;
|
|
4488
|
+
return /* @__PURE__ */ jsx54(
|
|
4489
|
+
IconButton,
|
|
4490
|
+
{
|
|
4491
|
+
fillType: "text",
|
|
4492
|
+
color: "container",
|
|
4493
|
+
...props,
|
|
4494
|
+
icon: expanded ? "menu_open" : "menu",
|
|
4495
|
+
"aria-expanded": expanded,
|
|
4496
|
+
onClick: (e) => {
|
|
4497
|
+
onClick?.(e);
|
|
4498
|
+
rail?.setExpanded(!expanded);
|
|
4499
|
+
},
|
|
4500
|
+
className: withClass("avl-navigation-rail-toggle", className)
|
|
4501
|
+
}
|
|
4502
|
+
);
|
|
4503
|
+
}
|
|
4504
|
+
function NavigationRailItem({
|
|
4505
|
+
icon,
|
|
4506
|
+
label,
|
|
4507
|
+
active = false,
|
|
4508
|
+
end,
|
|
4509
|
+
render,
|
|
4510
|
+
className,
|
|
4511
|
+
...props
|
|
4512
|
+
}) {
|
|
4513
|
+
return useRender3({
|
|
4514
|
+
defaultTagName: "a",
|
|
4515
|
+
render,
|
|
4516
|
+
state: { active },
|
|
4517
|
+
props: mergeProps3(
|
|
4518
|
+
{
|
|
4519
|
+
className: cx("avl-navigation-rail-item", className),
|
|
4520
|
+
"aria-current": active ? "page" : void 0,
|
|
4521
|
+
children: /* @__PURE__ */ jsxs35(Fragment7, { children: [
|
|
4522
|
+
/* @__PURE__ */ jsx54("span", { className: "avl-navigation-rail-item-indicator" }),
|
|
4523
|
+
/* @__PURE__ */ jsx54(Icon, { name: icon }),
|
|
4524
|
+
/* @__PURE__ */ jsx54("span", { className: "avl-navigation-rail-item-label", children: label }),
|
|
4525
|
+
end != null && /* @__PURE__ */ jsx54("span", { className: "avl-navigation-rail-item-end", children: end })
|
|
2257
4526
|
] })
|
|
2258
4527
|
},
|
|
2259
4528
|
props
|
|
@@ -2261,18 +4530,55 @@ function NavigationBarItem({
|
|
|
2261
4530
|
});
|
|
2262
4531
|
}
|
|
2263
4532
|
|
|
4533
|
+
// src/components/NavigationList/NavigationList.tsx
|
|
4534
|
+
import { useRender as useRender4 } from "@base-ui/react/use-render";
|
|
4535
|
+
import { mergeProps as mergeProps4 } from "@base-ui/react/merge-props";
|
|
4536
|
+
import { jsx as jsx55 } from "react/jsx-runtime";
|
|
4537
|
+
function NavigationList({ className, ...props }) {
|
|
4538
|
+
return /* @__PURE__ */ jsx55("nav", { ...props, className: cx("avl-navigation-list", className) });
|
|
4539
|
+
}
|
|
4540
|
+
function NavigationListItem({
|
|
4541
|
+
label,
|
|
4542
|
+
active = false,
|
|
4543
|
+
render,
|
|
4544
|
+
className,
|
|
4545
|
+
...props
|
|
4546
|
+
}) {
|
|
4547
|
+
return useRender4({
|
|
4548
|
+
defaultTagName: "a",
|
|
4549
|
+
render,
|
|
4550
|
+
state: { active },
|
|
4551
|
+
props: mergeProps4(
|
|
4552
|
+
{
|
|
4553
|
+
className: cx("avl-navigation-list-item", className),
|
|
4554
|
+
"aria-current": active ? "page" : void 0,
|
|
4555
|
+
children: label
|
|
4556
|
+
},
|
|
4557
|
+
props
|
|
4558
|
+
)
|
|
4559
|
+
});
|
|
4560
|
+
}
|
|
4561
|
+
|
|
2264
4562
|
// src/components/NavigationDrawer/NavigationDrawer.tsx
|
|
2265
|
-
import { useContext as
|
|
4563
|
+
import { useContext as useContext22 } from "react";
|
|
2266
4564
|
import { Drawer as Drawer2 } from "@base-ui/react/drawer";
|
|
2267
|
-
import { jsx as
|
|
4565
|
+
import { jsx as jsx56, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
2268
4566
|
function NavigationDrawer(props) {
|
|
2269
|
-
return /* @__PURE__ */
|
|
4567
|
+
return /* @__PURE__ */ jsx56(Drawer2.Root, { ...props, swipeDirection: "left" });
|
|
2270
4568
|
}
|
|
2271
4569
|
function NavigationDrawerTrigger({
|
|
2272
4570
|
className,
|
|
2273
4571
|
...props
|
|
2274
4572
|
}) {
|
|
2275
|
-
|
|
4573
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4574
|
+
checkAsChild(
|
|
4575
|
+
props,
|
|
4576
|
+
"NavigationDrawerTrigger",
|
|
4577
|
+
"navigation-drawer.md",
|
|
4578
|
+
'<NavigationDrawerTrigger render={<IconButton icon="menu" aria-label="Open navigation" />} />'
|
|
4579
|
+
);
|
|
4580
|
+
}
|
|
4581
|
+
return /* @__PURE__ */ jsx56(
|
|
2276
4582
|
Drawer2.Trigger,
|
|
2277
4583
|
{
|
|
2278
4584
|
...props,
|
|
@@ -2284,12 +4590,15 @@ function NavigationDrawerPopup({
|
|
|
2284
4590
|
className,
|
|
2285
4591
|
...props
|
|
2286
4592
|
}) {
|
|
2287
|
-
const avl =
|
|
4593
|
+
const avl = useContext22(AnvilContext);
|
|
4594
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4595
|
+
checkRoot(avl !== null, "NavigationDrawerPopup");
|
|
4596
|
+
}
|
|
2288
4597
|
return (
|
|
2289
4598
|
// Into the AnvilRoot, not body, so the drawer sees the theme variables
|
|
2290
|
-
/* @__PURE__ */
|
|
2291
|
-
/* @__PURE__ */
|
|
2292
|
-
/* @__PURE__ */
|
|
4599
|
+
/* @__PURE__ */ jsxs36(Drawer2.Portal, { container: avl?.rootRef, children: [
|
|
4600
|
+
/* @__PURE__ */ jsx56(Drawer2.Backdrop, { className: "avl-navigation-drawer-backdrop" }),
|
|
4601
|
+
/* @__PURE__ */ jsx56(Drawer2.Viewport, { className: "avl-navigation-drawer-viewport", children: /* @__PURE__ */ jsx56(
|
|
2293
4602
|
Drawer2.Popup,
|
|
2294
4603
|
{
|
|
2295
4604
|
...props,
|
|
@@ -2306,7 +4615,7 @@ function NavigationDrawerTitle({
|
|
|
2306
4615
|
className,
|
|
2307
4616
|
...props
|
|
2308
4617
|
}) {
|
|
2309
|
-
return /* @__PURE__ */
|
|
4618
|
+
return /* @__PURE__ */ jsx56(
|
|
2310
4619
|
Drawer2.Title,
|
|
2311
4620
|
{
|
|
2312
4621
|
...props,
|
|
@@ -2320,11 +4629,11 @@ function NavigationDrawerItem({
|
|
|
2320
4629
|
active = false,
|
|
2321
4630
|
end,
|
|
2322
4631
|
href,
|
|
2323
|
-
render = /* @__PURE__ */
|
|
4632
|
+
render = /* @__PURE__ */ jsx56("a", { href }),
|
|
2324
4633
|
className,
|
|
2325
4634
|
...props
|
|
2326
4635
|
}) {
|
|
2327
|
-
return /* @__PURE__ */
|
|
4636
|
+
return /* @__PURE__ */ jsxs36(
|
|
2328
4637
|
Drawer2.Close,
|
|
2329
4638
|
{
|
|
2330
4639
|
...props,
|
|
@@ -2333,188 +4642,20 @@ function NavigationDrawerItem({
|
|
|
2333
4642
|
"aria-current": active ? "page" : void 0,
|
|
2334
4643
|
className: withClass("avl-navigation-drawer-item", className),
|
|
2335
4644
|
children: [
|
|
2336
|
-
/* @__PURE__ */
|
|
2337
|
-
/* @__PURE__ */
|
|
2338
|
-
end != null && /* @__PURE__ */
|
|
4645
|
+
/* @__PURE__ */ jsx56(Icon, { name: icon }),
|
|
4646
|
+
/* @__PURE__ */ jsx56("span", { className: "avl-navigation-drawer-item-label", children: label }),
|
|
4647
|
+
end != null && /* @__PURE__ */ jsx56("span", { className: "avl-navigation-drawer-item-end", children: end })
|
|
2339
4648
|
]
|
|
2340
4649
|
}
|
|
2341
4650
|
);
|
|
2342
4651
|
}
|
|
2343
4652
|
|
|
2344
|
-
// src/components/NavigationRail/NavigationRail.tsx
|
|
2345
|
-
import { useLayoutEffect as useLayoutEffect4, useRef as useRef8, useState as useState4 } from "react";
|
|
2346
|
-
import { useRender as useRender3 } from "@base-ui/react/use-render";
|
|
2347
|
-
import { mergeProps as mergeProps3 } from "@base-ui/react/merge-props";
|
|
2348
|
-
import { Fragment as Fragment4, jsx as jsx36, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
2349
|
-
var FLIP_ID = "avl-navigation-rail-flip";
|
|
2350
|
-
function collectParts(rail) {
|
|
2351
|
-
const parts = [];
|
|
2352
|
-
const button = rail.querySelector(
|
|
2353
|
-
".avl-navigation-rail-expand-button"
|
|
2354
|
-
);
|
|
2355
|
-
if (button) parts.push({ el: button });
|
|
2356
|
-
for (const item of rail.querySelectorAll(
|
|
2357
|
-
".avl-navigation-rail-item"
|
|
2358
|
-
)) {
|
|
2359
|
-
parts.push({ el: item });
|
|
2360
|
-
const icon = item.querySelector(
|
|
2361
|
-
".avl-navigation-rail-item-icon"
|
|
2362
|
-
);
|
|
2363
|
-
const text = item.querySelector(
|
|
2364
|
-
".avl-navigation-rail-item-text"
|
|
2365
|
-
);
|
|
2366
|
-
if (icon) parts.push({ el: icon, parent: item });
|
|
2367
|
-
if (text) parts.push({ el: text, parent: item, fade: true });
|
|
2368
|
-
const end = item.querySelector(
|
|
2369
|
-
".avl-navigation-rail-item-end"
|
|
2370
|
-
);
|
|
2371
|
-
if (end) parts.push({ el: end, parent: item, fade: true });
|
|
2372
|
-
}
|
|
2373
|
-
return parts;
|
|
2374
|
-
}
|
|
2375
|
-
function NavigationRail({
|
|
2376
|
-
hasExpandButton,
|
|
2377
|
-
expanded: expandedProp,
|
|
2378
|
-
defaultExpanded = true,
|
|
2379
|
-
onExpandedChange,
|
|
2380
|
-
children,
|
|
2381
|
-
className,
|
|
2382
|
-
ref,
|
|
2383
|
-
...props
|
|
2384
|
-
}) {
|
|
2385
|
-
const [internalExpanded, setInternalExpanded] = useState4(defaultExpanded);
|
|
2386
|
-
const expanded = expandedProp ?? internalExpanded;
|
|
2387
|
-
const toggleExpanded = () => {
|
|
2388
|
-
setInternalExpanded(!expanded);
|
|
2389
|
-
onExpandedChange?.(!expanded);
|
|
2390
|
-
};
|
|
2391
|
-
const railRef = useRef8(null);
|
|
2392
|
-
const lastRects = useRef8(/* @__PURE__ */ new Map());
|
|
2393
|
-
useLayoutEffect4(() => {
|
|
2394
|
-
const rail = railRef.current;
|
|
2395
|
-
if (!rail) return;
|
|
2396
|
-
const style = getComputedStyle(rail);
|
|
2397
|
-
const duration = parseFloat(
|
|
2398
|
-
style.getPropertyValue("--avl-navigation-rail-duration")
|
|
2399
|
-
) || 0;
|
|
2400
|
-
const easing = style.getPropertyValue("--avl-navigation-rail-ease").trim() || "ease";
|
|
2401
|
-
const before = lastRects.current;
|
|
2402
|
-
const after = /* @__PURE__ */ new Map();
|
|
2403
|
-
const parts = collectParts(rail);
|
|
2404
|
-
for (const { el } of parts) {
|
|
2405
|
-
for (const animation of el.getAnimations()) {
|
|
2406
|
-
if (animation.id === FLIP_ID) animation.cancel();
|
|
2407
|
-
}
|
|
2408
|
-
after.set(el, el.getBoundingClientRect());
|
|
2409
|
-
}
|
|
2410
|
-
lastRects.current = after;
|
|
2411
|
-
if (!before.size || !duration) return;
|
|
2412
|
-
for (const { el, parent, fade } of parts) {
|
|
2413
|
-
const from = before.get(el);
|
|
2414
|
-
if (!from) continue;
|
|
2415
|
-
const to = after.get(el);
|
|
2416
|
-
let x = from.left - to.left;
|
|
2417
|
-
let y = from.top - to.top;
|
|
2418
|
-
const parentFrom = parent && before.get(parent);
|
|
2419
|
-
if (parentFrom) {
|
|
2420
|
-
const parentTo = after.get(parent);
|
|
2421
|
-
x -= parentFrom.left - parentTo.left;
|
|
2422
|
-
y -= parentFrom.top - parentTo.top;
|
|
2423
|
-
}
|
|
2424
|
-
if (fade) {
|
|
2425
|
-
el.animate(
|
|
2426
|
-
[
|
|
2427
|
-
{ opacity: 0 },
|
|
2428
|
-
{ opacity: 0, offset: 0.4 },
|
|
2429
|
-
{ opacity: 1 }
|
|
2430
|
-
],
|
|
2431
|
-
{ duration, easing: "ease-out", id: FLIP_ID }
|
|
2432
|
-
);
|
|
2433
|
-
continue;
|
|
2434
|
-
}
|
|
2435
|
-
if (!x && !y) continue;
|
|
2436
|
-
el.animate(
|
|
2437
|
-
[
|
|
2438
|
-
{ transform: `translate(${x}px, ${y}px)` },
|
|
2439
|
-
{ transform: "none" }
|
|
2440
|
-
],
|
|
2441
|
-
{ duration, easing, id: FLIP_ID }
|
|
2442
|
-
);
|
|
2443
|
-
}
|
|
2444
|
-
}, [expanded]);
|
|
2445
|
-
return /* @__PURE__ */ jsx36(
|
|
2446
|
-
"nav",
|
|
2447
|
-
{
|
|
2448
|
-
...props,
|
|
2449
|
-
ref: mergeRefs(railRef, ref),
|
|
2450
|
-
className: cx("avl-navigation-rail", className),
|
|
2451
|
-
"data-expanded": expanded,
|
|
2452
|
-
children: /* @__PURE__ */ jsxs24("div", { className: "avl-navigation-rail-content", children: [
|
|
2453
|
-
hasExpandButton && /* @__PURE__ */ jsx36(
|
|
2454
|
-
IconButton,
|
|
2455
|
-
{
|
|
2456
|
-
className: "avl-navigation-rail-expand-button",
|
|
2457
|
-
icon: expanded ? "menu_open" : "menu",
|
|
2458
|
-
"aria-label": expanded ? "Collapse menu" : "Expand menu",
|
|
2459
|
-
"aria-expanded": expanded,
|
|
2460
|
-
fillType: "text",
|
|
2461
|
-
color: "container",
|
|
2462
|
-
"data-expanded": expanded,
|
|
2463
|
-
onClick: toggleExpanded
|
|
2464
|
-
}
|
|
2465
|
-
),
|
|
2466
|
-
/* @__PURE__ */ jsx36("div", { className: "avl-navigation-rail-item-list", children })
|
|
2467
|
-
] })
|
|
2468
|
-
}
|
|
2469
|
-
);
|
|
2470
|
-
}
|
|
2471
|
-
function NavigationRailItem({
|
|
2472
|
-
icon,
|
|
2473
|
-
label,
|
|
2474
|
-
active = false,
|
|
2475
|
-
end,
|
|
2476
|
-
render,
|
|
2477
|
-
className,
|
|
2478
|
-
...props
|
|
2479
|
-
}) {
|
|
2480
|
-
return useRender3({
|
|
2481
|
-
defaultTagName: "a",
|
|
2482
|
-
render,
|
|
2483
|
-
state: { active },
|
|
2484
|
-
props: mergeProps3(
|
|
2485
|
-
{
|
|
2486
|
-
className: cx("avl-navigation-rail-item", className),
|
|
2487
|
-
"aria-current": active ? "page" : void 0,
|
|
2488
|
-
children: /* @__PURE__ */ jsxs24(Fragment4, { children: [
|
|
2489
|
-
/* @__PURE__ */ jsx36(
|
|
2490
|
-
Icon,
|
|
2491
|
-
{
|
|
2492
|
-
name: icon,
|
|
2493
|
-
className: "avl-navigation-rail-item-icon"
|
|
2494
|
-
}
|
|
2495
|
-
),
|
|
2496
|
-
/* @__PURE__ */ jsx36(
|
|
2497
|
-
Typography,
|
|
2498
|
-
{
|
|
2499
|
-
as: "span",
|
|
2500
|
-
className: "avl-navigation-rail-item-text",
|
|
2501
|
-
children: label
|
|
2502
|
-
}
|
|
2503
|
-
),
|
|
2504
|
-
end != null && /* @__PURE__ */ jsx36("span", { className: "avl-navigation-rail-item-end", children: end })
|
|
2505
|
-
] })
|
|
2506
|
-
},
|
|
2507
|
-
props
|
|
2508
|
-
)
|
|
2509
|
-
});
|
|
2510
|
-
}
|
|
2511
|
-
|
|
2512
4653
|
// src/tokens/baseTokens.ts
|
|
2513
4654
|
var baseDesignTokens = {
|
|
2514
4655
|
font: {
|
|
2515
|
-
main: '"Google Sans", sans-serif',
|
|
2516
|
-
title: '"Google Sans", sans-serif',
|
|
2517
|
-
mono: '"Google Sans Code", monospace'
|
|
4656
|
+
main: '"Google Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',
|
|
4657
|
+
title: '"Google Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',
|
|
4658
|
+
mono: '"Google Sans Code", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace'
|
|
2518
4659
|
},
|
|
2519
4660
|
fontSize: {
|
|
2520
4661
|
body: "16px",
|
|
@@ -2538,11 +4679,25 @@ var baseDesignTokens = {
|
|
|
2538
4679
|
full: "1000px"
|
|
2539
4680
|
},
|
|
2540
4681
|
outlineSize: "1.5px",
|
|
4682
|
+
disabledOpacity: "0.5",
|
|
4683
|
+
fontWeight: {
|
|
4684
|
+
regular: "400",
|
|
4685
|
+
medium: "500",
|
|
4686
|
+
semibold: "600",
|
|
4687
|
+
bold: "700"
|
|
4688
|
+
},
|
|
4689
|
+
shadow: {
|
|
4690
|
+
small: "0 2px 6px var(--avl-color-shadow)",
|
|
4691
|
+
medium: "0 3px 8px var(--avl-color-shadow)",
|
|
4692
|
+
large: "0 4px 16px var(--avl-color-shadow)"
|
|
4693
|
+
},
|
|
2541
4694
|
ease: {
|
|
2542
4695
|
out: "cubic-bezier(0.34, 1.56, 0.64, 1)",
|
|
2543
4696
|
in: "cubic-bezier(0.36, 0, 0.66, -0.56)",
|
|
2544
4697
|
// Material 3's standard curve
|
|
2545
|
-
smooth: "cubic-bezier(0.2, 0, 0, 1)"
|
|
4698
|
+
smooth: "cubic-bezier(0.2, 0, 0, 1)",
|
|
4699
|
+
// A damped spring, sampled into linear() points
|
|
4700
|
+
bounce: "linear(0, 0.009, 0.035 2.1%, 0.141, 0.281 6.7%, 0.723 12.9%, 0.938 16.7%, 1.017, 1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%, 1.129 32.8%, 1.051 39.6%, 1.017 43.1%, 0.991, 0.977 51%, 0.974 53.8%, 0.975 57.1%, 0.997 69.8%, 1.003 76.9%, 1.004 83.8%, 1)"
|
|
2546
4701
|
},
|
|
2547
4702
|
easeLength: {
|
|
2548
4703
|
short: "100ms",
|
|
@@ -2555,11 +4710,13 @@ var baseDesignTokens = {
|
|
|
2555
4710
|
var baseLightTheme = {
|
|
2556
4711
|
background: "#FDF7FF",
|
|
2557
4712
|
onBackground: "#1D1B20",
|
|
4713
|
+
onBackgroundMuted: "#49454E",
|
|
2558
4714
|
container: "#F2ECF4",
|
|
2559
4715
|
onContainer: "#1D1B20",
|
|
2560
|
-
|
|
2561
|
-
|
|
4716
|
+
surface: "#F8F2FA",
|
|
4717
|
+
onSurface: "#49454E",
|
|
2562
4718
|
outline: "#CAC4CF",
|
|
4719
|
+
divider: "#E6E0E9",
|
|
2563
4720
|
primary: "#65558F",
|
|
2564
4721
|
onPrimary: "#FFFFFF",
|
|
2565
4722
|
primaryContainer: "#E9DDFF",
|
|
@@ -2587,11 +4744,13 @@ var baseLightTheme = {
|
|
|
2587
4744
|
var baseDarkTheme = {
|
|
2588
4745
|
background: "#141218",
|
|
2589
4746
|
onBackground: "#E6E0E9",
|
|
4747
|
+
onBackgroundMuted: "#CAC4CF",
|
|
2590
4748
|
container: "#2B292F",
|
|
2591
4749
|
onContainer: "#E6E0E9",
|
|
2592
|
-
|
|
2593
|
-
|
|
4750
|
+
surface: "#1D1B20",
|
|
4751
|
+
onSurface: "#E6E0E9",
|
|
2594
4752
|
outline: "#948F99",
|
|
4753
|
+
divider: "#49454E",
|
|
2595
4754
|
primary: "#CFBDFE",
|
|
2596
4755
|
onPrimary: "#36265D",
|
|
2597
4756
|
primaryContainer: "#4D3D75",
|
|
@@ -2614,19 +4773,188 @@ var baseDarkTheme = {
|
|
|
2614
4773
|
onSuccessContainer: "#A6F5AE",
|
|
2615
4774
|
inverseSurface: "#E6E0E9",
|
|
2616
4775
|
inverseOnSurface: "#322F35",
|
|
2617
|
-
inversePrimary: "#65558F"
|
|
4776
|
+
inversePrimary: "#65558F",
|
|
4777
|
+
shadow: "rgb(0 0 0 / 0.6)",
|
|
4778
|
+
scrim: "rgb(0 0 0 / 0.6)"
|
|
2618
4779
|
};
|
|
2619
4780
|
|
|
4781
|
+
// src/themes/createTheme.ts
|
|
4782
|
+
function createTheme(primary, options = {}) {
|
|
4783
|
+
const p = toOklch(parseHex(primary));
|
|
4784
|
+
const s = options.tonal ? toOklch(parseHex(options.tonal)) : p;
|
|
4785
|
+
return {
|
|
4786
|
+
light: generate(baseLightTheme, p, s),
|
|
4787
|
+
dark: generate(baseDarkTheme, p, s)
|
|
4788
|
+
};
|
|
4789
|
+
}
|
|
4790
|
+
async function createThemeFromImage(image) {
|
|
4791
|
+
const source = typeof image === "string" ? await (await fetch(image)).blob() : image;
|
|
4792
|
+
const size = 64;
|
|
4793
|
+
const bitmap = await createImageBitmap(source, {
|
|
4794
|
+
resizeWidth: size,
|
|
4795
|
+
resizeHeight: size
|
|
4796
|
+
});
|
|
4797
|
+
const ctx = new OffscreenCanvas(size, size).getContext("2d");
|
|
4798
|
+
ctx.drawImage(bitmap, 0, 0);
|
|
4799
|
+
bitmap.close();
|
|
4800
|
+
const [primary, secondary] = mainColors(
|
|
4801
|
+
ctx.getImageData(0, 0, size, size).data
|
|
4802
|
+
);
|
|
4803
|
+
return createTheme(primary, { tonal: secondary });
|
|
4804
|
+
}
|
|
4805
|
+
var primaryRoles = [
|
|
4806
|
+
"primary",
|
|
4807
|
+
"onPrimary",
|
|
4808
|
+
"primaryContainer",
|
|
4809
|
+
"onPrimaryContainer",
|
|
4810
|
+
"inversePrimary"
|
|
4811
|
+
];
|
|
4812
|
+
var tonalRoles = ["tonal", "onTonal", "tonalContainer", "onTonalContainer"];
|
|
4813
|
+
var neutralRoles = [
|
|
4814
|
+
"background",
|
|
4815
|
+
"onBackground",
|
|
4816
|
+
"onBackgroundMuted",
|
|
4817
|
+
"container",
|
|
4818
|
+
"onContainer",
|
|
4819
|
+
"surface",
|
|
4820
|
+
"onSurface",
|
|
4821
|
+
"outline",
|
|
4822
|
+
"divider",
|
|
4823
|
+
"inverseSurface",
|
|
4824
|
+
"inverseOnSurface"
|
|
4825
|
+
];
|
|
4826
|
+
var reference = toOklch(parseHex(baseLightTheme.primary));
|
|
4827
|
+
function generate(base, primary, secondary) {
|
|
4828
|
+
const theme = { ...base };
|
|
4829
|
+
const set = (keys, seed, neutral) => {
|
|
4830
|
+
const scale = seed.c / reference.c;
|
|
4831
|
+
for (const key of keys) {
|
|
4832
|
+
const role = toOklch(parseHex(base[key]));
|
|
4833
|
+
const c = role.c * (neutral ? Math.min(scale, 1) : scale);
|
|
4834
|
+
const h = seed.h + role.h - reference.h;
|
|
4835
|
+
theme[key] = toHex(role.l, c, h);
|
|
4836
|
+
}
|
|
4837
|
+
};
|
|
4838
|
+
set(primaryRoles, primary, false);
|
|
4839
|
+
set(tonalRoles, secondary, false);
|
|
4840
|
+
set(neutralRoles, primary, true);
|
|
4841
|
+
return theme;
|
|
4842
|
+
}
|
|
4843
|
+
function mainColors(pixels) {
|
|
4844
|
+
const bins = Array.from({ length: 36 }, () => ({ w: 0, l: 0, a: 0, b: 0 }));
|
|
4845
|
+
const grey = { w: 0, l: 0, a: 0, b: 0 };
|
|
4846
|
+
for (let i = 0; i < pixels.length; i += 4) {
|
|
4847
|
+
if (pixels[i + 3] < 128) continue;
|
|
4848
|
+
const [l, a, b] = toOklab([pixels[i], pixels[i + 1], pixels[i + 2]]);
|
|
4849
|
+
const c = Math.hypot(a, b);
|
|
4850
|
+
const bin = c < 0.03 || l < 0.15 || l > 0.97 ? grey : bins[Math.floor(hueOf(a, b) / 10) % 36];
|
|
4851
|
+
const w = bin === grey ? 1 : c;
|
|
4852
|
+
bin.w += w;
|
|
4853
|
+
bin.l += l * w;
|
|
4854
|
+
bin.a += a * w;
|
|
4855
|
+
bin.b += b * w;
|
|
4856
|
+
}
|
|
4857
|
+
const toColor = (bin) => {
|
|
4858
|
+
const a = bin.a / bin.w;
|
|
4859
|
+
const b = bin.b / bin.w;
|
|
4860
|
+
return toHex(bin.l / bin.w, Math.hypot(a, b), hueOf(a, b));
|
|
4861
|
+
};
|
|
4862
|
+
const ranked = bins.map((bin, i) => ({ bin, hue: i * 10 + 5 })).filter((x) => x.bin.w > 0).sort((x, y) => y.bin.w - x.bin.w);
|
|
4863
|
+
if (!ranked.length) {
|
|
4864
|
+
const color = grey.w ? toColor(grey) : baseLightTheme.primary;
|
|
4865
|
+
return [color, color];
|
|
4866
|
+
}
|
|
4867
|
+
const first = ranked[0];
|
|
4868
|
+
const second = ranked.find(
|
|
4869
|
+
(x) => hueDistance(x.hue, first.hue) >= 60 && x.bin.w >= first.bin.w * 0.1
|
|
4870
|
+
);
|
|
4871
|
+
const primary = toColor(first.bin);
|
|
4872
|
+
return [primary, second ? toColor(second.bin) : primary];
|
|
4873
|
+
}
|
|
4874
|
+
function hueOf(a, b) {
|
|
4875
|
+
return (Math.atan2(b, a) * 180 / Math.PI + 360) % 360;
|
|
4876
|
+
}
|
|
4877
|
+
function hueDistance(x, y) {
|
|
4878
|
+
const d = Math.abs(x - y) % 360;
|
|
4879
|
+
return d > 180 ? 360 - d : d;
|
|
4880
|
+
}
|
|
4881
|
+
function parseHex(hex) {
|
|
4882
|
+
const m = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
4883
|
+
if (!m)
|
|
4884
|
+
throw new TypeError(`Expected a hex color like '#4355B9', got '${hex}'`);
|
|
4885
|
+
const full = m[1].length === 3 ? m[1].replace(/./g, "$&$&") : m[1];
|
|
4886
|
+
const n = parseInt(full, 16);
|
|
4887
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
4888
|
+
}
|
|
4889
|
+
function toLinear(v) {
|
|
4890
|
+
v /= 255;
|
|
4891
|
+
return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
|
|
4892
|
+
}
|
|
4893
|
+
function fromLinear(v) {
|
|
4894
|
+
return v <= 31308e-7 ? v * 12.92 : 1.055 * v ** (1 / 2.4) - 0.055;
|
|
4895
|
+
}
|
|
4896
|
+
function toOklab([r8, g8, b8]) {
|
|
4897
|
+
const r = toLinear(r8);
|
|
4898
|
+
const g = toLinear(g8);
|
|
4899
|
+
const b = toLinear(b8);
|
|
4900
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
4901
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
4902
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
4903
|
+
return [
|
|
4904
|
+
0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
|
|
4905
|
+
1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
|
|
4906
|
+
0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s
|
|
4907
|
+
];
|
|
4908
|
+
}
|
|
4909
|
+
function toOklch(rgb) {
|
|
4910
|
+
const [l, a, b] = toOklab(rgb);
|
|
4911
|
+
return { l, c: Math.hypot(a, b), h: hueOf(a, b) };
|
|
4912
|
+
}
|
|
4913
|
+
function oklchToLinear(L, C2, H) {
|
|
4914
|
+
const a = C2 * Math.cos(H * Math.PI / 180);
|
|
4915
|
+
const b = C2 * Math.sin(H * Math.PI / 180);
|
|
4916
|
+
const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
4917
|
+
const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
4918
|
+
const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
4919
|
+
return [
|
|
4920
|
+
4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
|
|
4921
|
+
-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
|
|
4922
|
+
-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s
|
|
4923
|
+
];
|
|
4924
|
+
}
|
|
4925
|
+
function inGamut(rgb) {
|
|
4926
|
+
return rgb.every((v) => v >= -1e-4 && v <= 1 + 1e-4);
|
|
4927
|
+
}
|
|
4928
|
+
function toHex(L, C2, H) {
|
|
4929
|
+
L = Math.min(Math.max(L, 0), 1);
|
|
4930
|
+
let rgb = oklchToLinear(L, C2, H);
|
|
4931
|
+
if (!inGamut(rgb)) {
|
|
4932
|
+
let lo = 0;
|
|
4933
|
+
let hi = C2;
|
|
4934
|
+
for (let i = 0; i < 20; i++) {
|
|
4935
|
+
const mid = (lo + hi) / 2;
|
|
4936
|
+
if (inGamut(oklchToLinear(L, mid, H))) lo = mid;
|
|
4937
|
+
else hi = mid;
|
|
4938
|
+
}
|
|
4939
|
+
rgb = oklchToLinear(L, lo, H);
|
|
4940
|
+
}
|
|
4941
|
+
return "#" + rgb.map(
|
|
4942
|
+
(v) => Math.round(Math.min(Math.max(fromLinear(v), 0), 1) * 255).toString(16).padStart(2, "0")
|
|
4943
|
+
).join("").toUpperCase();
|
|
4944
|
+
}
|
|
4945
|
+
|
|
2620
4946
|
// src/themes/monochromeTheme.ts
|
|
2621
4947
|
var monochromeLightTheme = {
|
|
2622
4948
|
...baseLightTheme,
|
|
2623
4949
|
background: "#FFFFFF",
|
|
2624
4950
|
onBackground: "#111111",
|
|
4951
|
+
onBackgroundMuted: "#5E5E5E",
|
|
2625
4952
|
container: "#EEEEEE",
|
|
2626
4953
|
onContainer: "#111111",
|
|
2627
|
-
|
|
2628
|
-
|
|
4954
|
+
surface: "#F6F6F6",
|
|
4955
|
+
onSurface: "#474747",
|
|
2629
4956
|
outline: "#C8C8C8",
|
|
4957
|
+
divider: "#E4E4E4",
|
|
2630
4958
|
primary: "#000000",
|
|
2631
4959
|
onPrimary: "#FFFFFF",
|
|
2632
4960
|
primaryContainer: "#E2E2E2",
|
|
@@ -2643,11 +4971,13 @@ var monochromeDarkTheme = {
|
|
|
2643
4971
|
...baseDarkTheme,
|
|
2644
4972
|
background: "#0F0F0F",
|
|
2645
4973
|
onBackground: "#E8E8E8",
|
|
4974
|
+
onBackgroundMuted: "#B4B4B4",
|
|
2646
4975
|
container: "#2A2A2A",
|
|
2647
4976
|
onContainer: "#E8E8E8",
|
|
2648
|
-
|
|
2649
|
-
|
|
4977
|
+
surface: "#1A1A1A",
|
|
4978
|
+
onSurface: "#E8E8E8",
|
|
2650
4979
|
outline: "#8E8E8E",
|
|
4980
|
+
divider: "#3A3A3A",
|
|
2651
4981
|
primary: "#FFFFFF",
|
|
2652
4982
|
onPrimary: "#000000",
|
|
2653
4983
|
primaryContainer: "#3A3A3A",
|
|
@@ -2663,8 +4993,12 @@ var monochromeDarkTheme = {
|
|
|
2663
4993
|
|
|
2664
4994
|
// src/components/AnvilRoot/AnvilRoot.tsx
|
|
2665
4995
|
import {
|
|
2666
|
-
|
|
2667
|
-
|
|
4996
|
+
useEffect as useEffect8,
|
|
4997
|
+
useId as useId6,
|
|
4998
|
+
useLayoutEffect as useLayoutEffect4,
|
|
4999
|
+
useRef as useRef15,
|
|
5000
|
+
useState as useState12,
|
|
5001
|
+
useSyncExternalStore
|
|
2668
5002
|
} from "react";
|
|
2669
5003
|
import { Toast as Toast2 } from "@base-ui/react/toast";
|
|
2670
5004
|
import { Tooltip as Tooltip2 } from "@base-ui/react/tooltip";
|
|
@@ -2677,17 +5011,19 @@ function themeToCssVariables(theme) {
|
|
|
2677
5011
|
inverseSurface: theme.onBackground,
|
|
2678
5012
|
inverseOnSurface: theme.background,
|
|
2679
5013
|
inversePrimary: `color-mix(in srgb, ${theme.primary} 55%, ${theme.background})`,
|
|
5014
|
+
shadow: "rgb(0 0 0 / 0.3)",
|
|
5015
|
+
scrim: "rgb(0 0 0 / 0.4)",
|
|
2680
5016
|
...rest,
|
|
2681
|
-
|
|
2682
|
-
|
|
5017
|
+
surface: rest.surface ?? surfaceVariant,
|
|
5018
|
+
onSurface: rest.onSurface ?? onSurfaceVariant
|
|
2683
5019
|
};
|
|
2684
5020
|
for (const [key, value] of Object.entries(filled)) {
|
|
2685
5021
|
if (value === void 0) continue;
|
|
2686
5022
|
const kebabKey = key.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
2687
5023
|
cssVars[`--avl-color-${kebabKey}`] = value;
|
|
2688
5024
|
}
|
|
2689
|
-
cssVars["--avl-color-surface-variant"] = "var(--avl-color-
|
|
2690
|
-
cssVars["--avl-color-on-surface-variant"] = "var(--avl-color-on-
|
|
5025
|
+
cssVars["--avl-color-surface-variant"] = "var(--avl-color-surface)";
|
|
5026
|
+
cssVars["--avl-color-on-surface-variant"] = "var(--avl-color-on-surface)";
|
|
2691
5027
|
return cssVars;
|
|
2692
5028
|
}
|
|
2693
5029
|
|
|
@@ -2713,57 +5049,132 @@ function tokensToCssVariables(tokens) {
|
|
|
2713
5049
|
}
|
|
2714
5050
|
|
|
2715
5051
|
// src/components/AnvilRoot/AnvilRoot.tsx
|
|
2716
|
-
import { jsx as
|
|
5052
|
+
import { jsx as jsx57, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
5053
|
+
var isSetting = (v) => v === "light" || v === "dark" || v === "system";
|
|
5054
|
+
function readStored(key) {
|
|
5055
|
+
try {
|
|
5056
|
+
const stored = localStorage.getItem(key);
|
|
5057
|
+
if (isSetting(stored)) return stored;
|
|
5058
|
+
} catch {
|
|
5059
|
+
}
|
|
5060
|
+
}
|
|
5061
|
+
var darkQuery = "(prefers-color-scheme: dark)";
|
|
5062
|
+
function subscribeToOs(onChange) {
|
|
5063
|
+
const query = matchMedia(darkQuery);
|
|
5064
|
+
query.addEventListener("change", onChange);
|
|
5065
|
+
return () => query.removeEventListener("change", onChange);
|
|
5066
|
+
}
|
|
5067
|
+
var getOsMode = () => matchMedia(darkQuery).matches ? "dark" : "light";
|
|
5068
|
+
var declarations = (vars) => Object.entries(vars).map(([name, value]) => `${name}:${value};`).join("");
|
|
2717
5069
|
function AnvilRoot(props) {
|
|
2718
|
-
const [
|
|
2719
|
-
props.defaultColorMode
|
|
5070
|
+
const [internalSetting, setInternalSetting] = useState12(
|
|
5071
|
+
props.defaultColorMode ?? "system"
|
|
5072
|
+
);
|
|
5073
|
+
const setting = props.colorMode ?? internalSetting;
|
|
5074
|
+
const osMode = useSyncExternalStore(
|
|
5075
|
+
subscribeToOs,
|
|
5076
|
+
getOsMode,
|
|
5077
|
+
() => "light"
|
|
2720
5078
|
);
|
|
2721
|
-
const colorMode =
|
|
5079
|
+
const colorMode = setting === "system" ? osMode : setting;
|
|
5080
|
+
const latestSetting = useRef15(setting);
|
|
5081
|
+
latestSetting.current = setting;
|
|
5082
|
+
useLayoutEffect4(() => {
|
|
5083
|
+
if (!props.storageKey) return;
|
|
5084
|
+
const stored = readStored(props.storageKey);
|
|
5085
|
+
if (stored) {
|
|
5086
|
+
latestSetting.current = stored;
|
|
5087
|
+
setInternalSetting(stored);
|
|
5088
|
+
}
|
|
5089
|
+
}, [props.storageKey]);
|
|
2722
5090
|
const setColorMode = (next) => {
|
|
2723
|
-
const value = typeof next === "function" ? next(
|
|
2724
|
-
|
|
5091
|
+
const value = typeof next === "function" ? next(latestSetting.current) : next;
|
|
5092
|
+
latestSetting.current = value;
|
|
5093
|
+
setInternalSetting(value);
|
|
2725
5094
|
props.onColorModeChange?.(value);
|
|
5095
|
+
if (props.storageKey) {
|
|
5096
|
+
try {
|
|
5097
|
+
localStorage.setItem(props.storageKey, value);
|
|
5098
|
+
} catch {
|
|
5099
|
+
}
|
|
5100
|
+
}
|
|
2726
5101
|
};
|
|
2727
|
-
const tokens = props.tokens
|
|
5102
|
+
const tokens = { ...baseDesignTokens, ...props.tokens };
|
|
2728
5103
|
const lightTheme = props.lightTheme || baseLightTheme;
|
|
2729
5104
|
const darkTheme = props.darkTheme || baseDarkTheme;
|
|
2730
|
-
const
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
5105
|
+
const rootRef = useRef15(null);
|
|
5106
|
+
useEffect8(() => {
|
|
5107
|
+
if (process.env.NODE_ENV === "production") return;
|
|
5108
|
+
const timer = setTimeout(() => {
|
|
5109
|
+
const root2 = rootRef.current;
|
|
5110
|
+
if (!root2) return;
|
|
5111
|
+
const loaded = getComputedStyle(root2).getPropertyValue("--avl-styles-loaded").trim();
|
|
5112
|
+
if (!loaded)
|
|
5113
|
+
devError(
|
|
5114
|
+
"The AnvilUI stylesheet isn't loaded, so components show unstyled.",
|
|
5115
|
+
"// once, in your entry file (main.tsx, app/layout.tsx, ...)\nimport 'anvilui/styles.css'",
|
|
5116
|
+
"setup.md"
|
|
5117
|
+
);
|
|
5118
|
+
}, 1e3);
|
|
5119
|
+
return () => clearTimeout(timer);
|
|
5120
|
+
}, []);
|
|
5121
|
+
const id = useId6();
|
|
5122
|
+
const root = `[data-avl-root="${id}"]`;
|
|
5123
|
+
const light = `color-scheme:light;${declarations(themeToCssVariables(lightTheme))}`;
|
|
5124
|
+
const dark = `color-scheme:dark;${declarations(themeToCssVariables(darkTheme))}`;
|
|
5125
|
+
const css = `${root}{${declarations(tokensToCssVariables(tokens))}${light}}${root}[data-color-mode="dark"]{${dark}}@media ${darkQuery}{${root}[data-color-mode="system"]{${dark}}}`;
|
|
5126
|
+
const restoreScript = props.storageKey && props.colorMode === void 0 ? `try{var m=localStorage.getItem(${JSON.stringify(props.storageKey)});if(m==='light'||m==='dark'||m==='system')document.currentScript.parentElement.dataset.colorMode=m}catch(e){}` : void 0;
|
|
5127
|
+
return /* @__PURE__ */ jsx57(
|
|
2737
5128
|
AnvilContext,
|
|
2738
5129
|
{
|
|
2739
5130
|
value: {
|
|
2740
5131
|
colorMode,
|
|
5132
|
+
colorModeSetting: setting,
|
|
2741
5133
|
setColorMode,
|
|
2742
5134
|
tokens,
|
|
2743
5135
|
lightTheme,
|
|
2744
5136
|
darkTheme,
|
|
2745
5137
|
rootRef
|
|
2746
5138
|
},
|
|
2747
|
-
children: /* @__PURE__ */
|
|
5139
|
+
children: /* @__PURE__ */ jsxs37(
|
|
2748
5140
|
"div",
|
|
2749
5141
|
{
|
|
2750
5142
|
ref: rootRef,
|
|
2751
|
-
className: "avl-root",
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
5143
|
+
className: cx("avl-root", props.className),
|
|
5144
|
+
"data-avl-root": id,
|
|
5145
|
+
"data-color-mode": setting,
|
|
5146
|
+
suppressHydrationWarning: true,
|
|
5147
|
+
children: [
|
|
5148
|
+
restoreScript && /* @__PURE__ */ jsx57(
|
|
5149
|
+
"script",
|
|
5150
|
+
{
|
|
5151
|
+
type: typeof window === "undefined" ? void 0 : "text/plain",
|
|
5152
|
+
suppressHydrationWarning: true,
|
|
5153
|
+
dangerouslySetInnerHTML: { __html: restoreScript }
|
|
5154
|
+
}
|
|
5155
|
+
),
|
|
5156
|
+
/* @__PURE__ */ jsx57("style", { children: css }),
|
|
5157
|
+
/* @__PURE__ */ jsx57(Tooltip2.Provider, { children: /* @__PURE__ */ jsxs37(Toast2.Provider, { limit: 3, children: [
|
|
5158
|
+
props.children,
|
|
5159
|
+
/* @__PURE__ */ jsx57(SnackbarViewport, {})
|
|
5160
|
+
] }) })
|
|
5161
|
+
]
|
|
2757
5162
|
}
|
|
2758
5163
|
)
|
|
2759
5164
|
}
|
|
2760
5165
|
);
|
|
2761
5166
|
}
|
|
2762
5167
|
export {
|
|
5168
|
+
Accordion,
|
|
5169
|
+
AccordionItem,
|
|
5170
|
+
AccordionPanel,
|
|
5171
|
+
AccordionTrigger,
|
|
5172
|
+
AnimatedNumber,
|
|
2763
5173
|
AnvilContext,
|
|
2764
5174
|
AnvilRoot,
|
|
2765
5175
|
AppBar,
|
|
2766
5176
|
Avatar,
|
|
5177
|
+
AvatarGroup,
|
|
2767
5178
|
Badge,
|
|
2768
5179
|
BottomSheet,
|
|
2769
5180
|
BottomSheetClose,
|
|
@@ -2772,12 +5183,20 @@ export {
|
|
|
2772
5183
|
BottomSheetTitle,
|
|
2773
5184
|
BottomSheetTrigger,
|
|
2774
5185
|
Button,
|
|
5186
|
+
Calendar,
|
|
2775
5187
|
Card,
|
|
2776
5188
|
CardActions,
|
|
2777
5189
|
CardContent,
|
|
2778
5190
|
CardTitle,
|
|
5191
|
+
Carousel,
|
|
5192
|
+
CarouselItem,
|
|
2779
5193
|
Checkbox,
|
|
2780
5194
|
Chip,
|
|
5195
|
+
Combobox,
|
|
5196
|
+
ComboboxItem,
|
|
5197
|
+
ContextMenu,
|
|
5198
|
+
ContextMenuTrigger,
|
|
5199
|
+
DateInput,
|
|
2781
5200
|
Dialog,
|
|
2782
5201
|
DialogActions,
|
|
2783
5202
|
DialogClose,
|
|
@@ -2787,6 +5206,8 @@ export {
|
|
|
2787
5206
|
DialogTrigger,
|
|
2788
5207
|
Divider,
|
|
2789
5208
|
FAB,
|
|
5209
|
+
FABMenu,
|
|
5210
|
+
FABMenuItem,
|
|
2790
5211
|
Field,
|
|
2791
5212
|
FieldDescription,
|
|
2792
5213
|
FieldError,
|
|
@@ -2799,6 +5220,7 @@ export {
|
|
|
2799
5220
|
IconButton,
|
|
2800
5221
|
Input,
|
|
2801
5222
|
InputChip,
|
|
5223
|
+
Kbd,
|
|
2802
5224
|
List,
|
|
2803
5225
|
ListItem,
|
|
2804
5226
|
Menu,
|
|
@@ -2808,6 +5230,7 @@ export {
|
|
|
2808
5230
|
MenuSubmenu,
|
|
2809
5231
|
MenuSubmenuTrigger,
|
|
2810
5232
|
MenuTrigger,
|
|
5233
|
+
Menubar,
|
|
2811
5234
|
NavigationBar,
|
|
2812
5235
|
NavigationBarItem,
|
|
2813
5236
|
NavigationDrawer,
|
|
@@ -2815,27 +5238,47 @@ export {
|
|
|
2815
5238
|
NavigationDrawerPopup,
|
|
2816
5239
|
NavigationDrawerTitle,
|
|
2817
5240
|
NavigationDrawerTrigger,
|
|
5241
|
+
NavigationList,
|
|
5242
|
+
NavigationListItem,
|
|
2818
5243
|
NavigationRail,
|
|
2819
5244
|
NavigationRailItem,
|
|
5245
|
+
NavigationRailToggle,
|
|
5246
|
+
PinInput,
|
|
2820
5247
|
Popover,
|
|
2821
5248
|
PopoverClose,
|
|
2822
5249
|
PopoverDescription,
|
|
2823
5250
|
PopoverPopup,
|
|
2824
5251
|
PopoverTitle,
|
|
2825
5252
|
PopoverTrigger,
|
|
5253
|
+
PreviewCard,
|
|
5254
|
+
PreviewCardPopup,
|
|
5255
|
+
PreviewCardTrigger,
|
|
2826
5256
|
Progress,
|
|
2827
5257
|
Radio,
|
|
2828
5258
|
RadioGroup,
|
|
5259
|
+
Search,
|
|
5260
|
+
SearchItem,
|
|
2829
5261
|
Select,
|
|
2830
5262
|
SelectItem,
|
|
5263
|
+
Skeleton,
|
|
2831
5264
|
Slider,
|
|
2832
5265
|
SplitButton,
|
|
5266
|
+
Sticker,
|
|
2833
5267
|
Switch,
|
|
5268
|
+
Table,
|
|
5269
|
+
TableBody,
|
|
5270
|
+
TableCaption,
|
|
5271
|
+
TableCell,
|
|
5272
|
+
TableHead,
|
|
5273
|
+
TableHeaderCell,
|
|
5274
|
+
TableRow,
|
|
2834
5275
|
Tabs,
|
|
2835
5276
|
TabsList,
|
|
2836
5277
|
TabsPanel,
|
|
2837
5278
|
TabsTab,
|
|
2838
5279
|
Textarea,
|
|
5280
|
+
TimePicker,
|
|
5281
|
+
Toggle2 as Toggle,
|
|
2839
5282
|
ToggleGroup,
|
|
2840
5283
|
ToggleGroupItem,
|
|
2841
5284
|
Tooltip,
|
|
@@ -2843,10 +5286,14 @@ export {
|
|
|
2843
5286
|
baseDarkTheme,
|
|
2844
5287
|
baseDesignTokens,
|
|
2845
5288
|
baseLightTheme,
|
|
5289
|
+
createTheme,
|
|
5290
|
+
createThemeFromImage,
|
|
2846
5291
|
monochromeDarkTheme,
|
|
2847
5292
|
monochromeLightTheme,
|
|
2848
5293
|
morph,
|
|
2849
5294
|
morphBetween,
|
|
5295
|
+
useAnvil,
|
|
5296
|
+
useConfetti,
|
|
2850
5297
|
useSnackbar
|
|
2851
5298
|
};
|
|
2852
5299
|
//# sourceMappingURL=index.js.map
|