anvilui 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +34 -33
- package/README.md +42 -89
- package/dist/components/AnvilRoot/AnvilRoot.d.ts +2 -2
- package/dist/components/Combobox/Combobox.d.ts +8 -2
- package/dist/components/DateInput/DateInput.d.ts +5 -3
- package/dist/components/FABMenu/FABMenu.d.ts +4 -1
- package/dist/components/IconButton/IconButton.d.ts +5 -3
- package/dist/components/Input/Input.d.ts +5 -3
- package/dist/components/NavigationBar/NavigationBar.d.ts +1 -1
- package/dist/components/NavigationList/NavigationList.d.ts +1 -1
- package/dist/components/NavigationRail/NavigationRail.d.ts +1 -1
- package/dist/components/PinInput/PinInput.d.ts +5 -3
- package/dist/components/Progress/Progress.d.ts +4 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +3 -3
- package/dist/components/Search/Search.d.ts +22 -6
- package/dist/components/Select/Select.d.ts +6 -2
- package/dist/components/Skeleton/Skeleton.d.ts +3 -3
- package/dist/components/Slider/Slider.d.ts +9 -2
- package/dist/components/SquigglyWave/SquigglyWave.d.ts +26 -4
- package/dist/components/Textarea/Textarea.d.ts +6 -3
- package/dist/components/TimePicker/TimePicker.d.ts +7 -5
- package/dist/components/Toggle/Toggle.d.ts +2 -1
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +2 -2
- package/dist/dev.d.ts +7 -2
- package/dist/index.cjs +528 -155
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +55 -26
- package/dist/index.css.map +1 -1
- package/dist/index.js +533 -141
- package/dist/index.js.map +1 -1
- package/dist/themes/types.d.ts +0 -4
- package/dist/utils.d.ts +5 -1
- package/docs/avatar.md +1 -1
- package/docs/badge.md +41 -41
- package/docs/calendar.md +1 -1
- package/docs/combobox.md +2 -1
- package/docs/composition.md +1 -1
- package/docs/date-input.md +4 -3
- package/docs/fab-menu.md +1 -0
- package/docs/forms.md +2 -2
- package/docs/icon-button.md +3 -2
- package/docs/input.md +1 -0
- package/docs/morph.md +4 -1
- package/docs/navigation-bar.md +1 -1
- package/docs/navigation-rail.md +1 -1
- package/docs/pin-input.md +1 -1
- package/docs/progress.md +37 -37
- package/docs/radio-group.md +18 -1
- package/docs/search.md +7 -7
- package/docs/select.md +3 -2
- package/docs/skeleton.md +33 -33
- package/docs/slider.md +51 -49
- package/docs/textarea.md +1 -1
- package/docs/theming.md +3 -2
- package/docs/time-picker.md +4 -3
- package/docs/toggle-group.md +1 -1
- package/docs/toggle.md +2 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -161,7 +161,20 @@ function cx(...parts) {
|
|
|
161
161
|
return parts.filter(Boolean).join(" ");
|
|
162
162
|
}
|
|
163
163
|
function withClass(base, className) {
|
|
164
|
-
return (state) => cx(
|
|
164
|
+
return (state) => cx(
|
|
165
|
+
typeof base === "function" ? base(state) : base,
|
|
166
|
+
typeof className === "function" ? className(state) : className
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
function splitControlProps(props) {
|
|
170
|
+
const control = {};
|
|
171
|
+
const rest = {};
|
|
172
|
+
for (const [key, value] of Object.entries(props)) {
|
|
173
|
+
if (key.startsWith("aria-") || key.startsWith("data-"))
|
|
174
|
+
control[key] = value;
|
|
175
|
+
else rest[key] = value;
|
|
176
|
+
}
|
|
177
|
+
return { control, rest };
|
|
165
178
|
}
|
|
166
179
|
function mergeRefs(...refs) {
|
|
167
180
|
return (value) => {
|
|
@@ -315,13 +328,15 @@ import 'anvilui/styles.css'
|
|
|
315
328
|
"setup.md"
|
|
316
329
|
);
|
|
317
330
|
}
|
|
318
|
-
|
|
331
|
+
var NO_TEXT = "It shows no text, so screen readers need an `aria-label`.";
|
|
332
|
+
var UNNAMED_GROUP = "Screen readers announce the group without saying what it's for: give it an `aria-label`.";
|
|
333
|
+
var UNNAMED_NAV = 'Screen readers list it as just "navigation": give it an `aria-label` to tell it apart from other navigation.';
|
|
334
|
+
function inNamedFieldset(el) {
|
|
335
|
+
return !!el?.closest("fieldset")?.querySelector(":scope > legend");
|
|
336
|
+
}
|
|
337
|
+
function checkName(props, component, example, doc, reason = NO_TEXT) {
|
|
319
338
|
if (props["aria-label"] || props["aria-labelledby"]) return;
|
|
320
|
-
devError(
|
|
321
|
-
`<${component}> has no accessible name. It shows no text, so screen readers need an \`aria-label\`.`,
|
|
322
|
-
example,
|
|
323
|
-
doc
|
|
324
|
-
);
|
|
339
|
+
devError(`<${component}> has no accessible name. ${reason}`, example, doc);
|
|
325
340
|
}
|
|
326
341
|
|
|
327
342
|
// src/components/Typography/Typography.tsx
|
|
@@ -457,12 +472,13 @@ function Avatar({
|
|
|
457
472
|
const groupSize = (0, import_react5.useContext)(AvatarGroupContext);
|
|
458
473
|
const size = sizeProp ?? groupSize ?? "normal";
|
|
459
474
|
const letters = name ? initials(name) : "";
|
|
475
|
+
const named = !!(name || props["aria-label"] || props["aria-labelledby"]);
|
|
460
476
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
461
477
|
import_avatar.Avatar.Root,
|
|
462
478
|
{
|
|
463
|
-
role:
|
|
479
|
+
role: named ? "img" : void 0,
|
|
464
480
|
"aria-label": name,
|
|
465
|
-
"aria-hidden":
|
|
481
|
+
"aria-hidden": named ? void 0 : true,
|
|
466
482
|
...props,
|
|
467
483
|
className: withClass(
|
|
468
484
|
cx(
|
|
@@ -506,6 +522,15 @@ function AvatarGroup({
|
|
|
506
522
|
children,
|
|
507
523
|
...props
|
|
508
524
|
}) {
|
|
525
|
+
if (process.env.NODE_ENV !== "production") {
|
|
526
|
+
checkName(
|
|
527
|
+
props,
|
|
528
|
+
"AvatarGroup",
|
|
529
|
+
'<AvatarGroup aria-label="Project members">...</AvatarGroup>',
|
|
530
|
+
"avatar-group.md",
|
|
531
|
+
UNNAMED_GROUP
|
|
532
|
+
);
|
|
533
|
+
}
|
|
509
534
|
const avatars = import_react6.Children.toArray(children);
|
|
510
535
|
const overflow = max !== void 0 && avatars.length > max;
|
|
511
536
|
const shown = overflow ? avatars.slice(0, Math.max(0, max - 1)) : avatars;
|
|
@@ -816,10 +841,9 @@ function HoldButton({
|
|
|
816
841
|
"aria-description": "Press and hold to confirm",
|
|
817
842
|
"data-hold": state === "idle" ? void 0 : state,
|
|
818
843
|
"data-nudge": nudges % 2 === 0 ? "even" : "odd",
|
|
819
|
-
className: (
|
|
820
|
-
"avl-hold-button",
|
|
821
|
-
|
|
822
|
-
typeof className === "function" ? className(buttonState) : className
|
|
844
|
+
className: withClass(
|
|
845
|
+
cx("avl-hold-button", nudges > 0 && "avl-hold-button-nudged"),
|
|
846
|
+
className
|
|
823
847
|
),
|
|
824
848
|
style: (buttonState) => ({
|
|
825
849
|
"--avl-hold-duration": `${holdDuration}ms`,
|
|
@@ -987,6 +1011,7 @@ function IconButton({
|
|
|
987
1011
|
icon,
|
|
988
1012
|
color,
|
|
989
1013
|
fillType,
|
|
1014
|
+
size = "normal",
|
|
990
1015
|
className,
|
|
991
1016
|
...props
|
|
992
1017
|
}) {
|
|
@@ -1019,7 +1044,7 @@ function IconButton({
|
|
|
1019
1044
|
{
|
|
1020
1045
|
...props,
|
|
1021
1046
|
className: withClass(
|
|
1022
|
-
`avl-icon-button ${colorClass(color, fillType)}`,
|
|
1047
|
+
`avl-icon-button ${colorClass(color, fillType)} avl-icon-button-size-${size}`,
|
|
1023
1048
|
className
|
|
1024
1049
|
),
|
|
1025
1050
|
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: icon })
|
|
@@ -1083,6 +1108,12 @@ function Calendar({
|
|
|
1083
1108
|
const now = /* @__PURE__ */ new Date();
|
|
1084
1109
|
return selected ?? new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
1085
1110
|
});
|
|
1111
|
+
const selectedIso = selected && toIso(selected);
|
|
1112
|
+
const [shownSelection, setShownSelection] = (0, import_react12.useState)(selectedIso);
|
|
1113
|
+
if (selectedIso !== shownSelection) {
|
|
1114
|
+
setShownSelection(selectedIso);
|
|
1115
|
+
if (selected) setFocused(selected);
|
|
1116
|
+
}
|
|
1086
1117
|
const [weekStart] = (0, import_react12.useState)(localeWeekStart);
|
|
1087
1118
|
const dayRef = (0, import_react12.useRef)(null);
|
|
1088
1119
|
const moveFocus = (0, import_react12.useRef)(false);
|
|
@@ -1115,7 +1146,6 @@ function Calendar({
|
|
|
1115
1146
|
onValueChange?.(iso);
|
|
1116
1147
|
};
|
|
1117
1148
|
const today = toIso(/* @__PURE__ */ new Date());
|
|
1118
|
-
const selectedIso = selected && toIso(selected);
|
|
1119
1149
|
const focusedIso = toIso(focused);
|
|
1120
1150
|
const offset = (new Date(year, month, 1).getDay() - weekStart + 7) % 7;
|
|
1121
1151
|
const daysInMonth = new Date(year, month + 1, 0).getDate();
|
|
@@ -1928,47 +1958,146 @@ var import_react18 = require("react");
|
|
|
1928
1958
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1929
1959
|
var WAVE_LENGTH = 40;
|
|
1930
1960
|
var WAVE_AMPLITUDE = 3;
|
|
1931
|
-
var
|
|
1932
|
-
var STROKE_CAP = 2;
|
|
1961
|
+
var WAVE_STROKE = 4;
|
|
1933
1962
|
var WAVE_PERIOD = 1500;
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1963
|
+
var K = 2 * Math.PI / WAVE_LENGTH;
|
|
1964
|
+
var waveY = (x, phase, shape) => (
|
|
1965
|
+
// + phase: the ripple travels from the leading end back to the start
|
|
1966
|
+
shape.middle + shape.amplitude * Math.sin(K * x + phase)
|
|
1967
|
+
);
|
|
1968
|
+
var waveSlope = (x, phase, shape) => shape.amplitude * K * Math.cos(K * x + phase);
|
|
1969
|
+
function wavePath(from, to, phase, shape) {
|
|
1970
|
+
const start = from + shape.cap;
|
|
1971
|
+
const end = to - shape.cap;
|
|
1937
1972
|
if (end < start) return "";
|
|
1938
|
-
const y = (x) =>
|
|
1939
|
-
WAVE_AMPLITUDE * Math.sin(2 * Math.PI * x / WAVE_LENGTH + phase);
|
|
1973
|
+
const y = (x) => waveY(x, phase, shape);
|
|
1940
1974
|
let d = `M${start} ${y(start)}`;
|
|
1941
1975
|
for (let x = start + 2; x < end; x += 2) d += `L${x} ${y(x)}`;
|
|
1942
1976
|
return d + `L${end} ${y(end)}`;
|
|
1943
1977
|
}
|
|
1944
|
-
function linePath(from, to) {
|
|
1945
|
-
const start = from +
|
|
1946
|
-
const end = to -
|
|
1947
|
-
return end < start ? "" : `M${start} ${
|
|
1978
|
+
function linePath(from, to, shape) {
|
|
1979
|
+
const start = from + shape.cap;
|
|
1980
|
+
const end = to - shape.cap;
|
|
1981
|
+
return end < start ? "" : `M${start} ${shape.middle}L${end} ${shape.middle}`;
|
|
1982
|
+
}
|
|
1983
|
+
function smoothEasing(style) {
|
|
1984
|
+
const match = style.getPropertyValue("--avl-ease-smooth").match(/cubic-bezier\(([^)]+)\)/);
|
|
1985
|
+
const parts = match?.[1].split(",").map(Number);
|
|
1986
|
+
const [x1, y1, x2, y2] = parts?.length === 4 && parts.every((n) => !Number.isNaN(n)) ? parts : [0.2, 0, 0, 1];
|
|
1987
|
+
const bezier = (a, b, t) => 3 * a * t * (1 - t) ** 2 + 3 * b * t ** 2 * (1 - t) + t ** 3;
|
|
1988
|
+
return (x) => {
|
|
1989
|
+
if (x <= 0 || x >= 1) return x;
|
|
1990
|
+
let lo = 0;
|
|
1991
|
+
let hi = 1;
|
|
1992
|
+
for (let i = 0; i < 20; i++) {
|
|
1993
|
+
const mid = (lo + hi) / 2;
|
|
1994
|
+
if (bezier(x1, x2, mid) < x) lo = mid;
|
|
1995
|
+
else hi = mid;
|
|
1996
|
+
}
|
|
1997
|
+
return bezier(y1, y2, (lo + hi) / 2);
|
|
1998
|
+
};
|
|
1999
|
+
}
|
|
2000
|
+
function cssNumber(style, name, fallback) {
|
|
2001
|
+
const raw = style.getPropertyValue(name).trim();
|
|
2002
|
+
const n = parseFloat(raw);
|
|
2003
|
+
if (Number.isNaN(n)) return fallback;
|
|
2004
|
+
return raw.endsWith("ms") ? n : raw.endsWith("s") ? n * 1e3 : n;
|
|
2005
|
+
}
|
|
2006
|
+
function cssLength(el, name, fallback) {
|
|
2007
|
+
const host = el.parentElement;
|
|
2008
|
+
if (!host || !getComputedStyle(el).getPropertyValue(name).trim())
|
|
2009
|
+
return fallback;
|
|
2010
|
+
const probe = document.createElement("div");
|
|
2011
|
+
probe.style.cssText = `position:absolute;visibility:hidden;width:var(${name})`;
|
|
2012
|
+
host.append(probe);
|
|
2013
|
+
const px = probe.getBoundingClientRect().width;
|
|
2014
|
+
probe.remove();
|
|
2015
|
+
return px;
|
|
2016
|
+
}
|
|
2017
|
+
function capPath(x, y, slope, dir, half, length, radius) {
|
|
2018
|
+
const norm = Math.hypot(1, slope);
|
|
2019
|
+
const tx = dir / norm;
|
|
2020
|
+
const ty = dir * slope / norm;
|
|
2021
|
+
const p = (u, v) => `${x + u * tx - v * ty} ${y + u * ty + v * tx}`;
|
|
2022
|
+
const r = Math.max(0, Math.min(radius, length, half));
|
|
2023
|
+
return `M${p(-0.5, -half)}L${p(length - r, -half)}A${r} ${r} 0 0 1 ${p(length, r - half)}L${p(length, half - r)}A${r} ${r} 0 0 1 ${p(length - r, half)}L${p(-0.5, half)}Z`;
|
|
2024
|
+
}
|
|
2025
|
+
function useWaveMorph(squiggly) {
|
|
2026
|
+
const [previous, setPrevious] = (0, import_react18.useState)(squiggly);
|
|
2027
|
+
const [leaving, setLeaving] = (0, import_react18.useState)(false);
|
|
2028
|
+
const [changed, setChanged] = (0, import_react18.useState)(false);
|
|
2029
|
+
if (squiggly !== previous) {
|
|
2030
|
+
setPrevious(squiggly);
|
|
2031
|
+
setLeaving(!squiggly);
|
|
2032
|
+
setChanged(true);
|
|
2033
|
+
}
|
|
2034
|
+
return {
|
|
2035
|
+
show: squiggly || leaving,
|
|
2036
|
+
wave: {
|
|
2037
|
+
flat: !squiggly,
|
|
2038
|
+
startFlat: changed,
|
|
2039
|
+
onFlat: () => setLeaving(false)
|
|
2040
|
+
}
|
|
2041
|
+
};
|
|
1948
2042
|
}
|
|
1949
2043
|
function SquigglyWave(props) {
|
|
1950
2044
|
const svgRef = (0, import_react18.useRef)(null);
|
|
1951
2045
|
const waveRef = (0, import_react18.useRef)(null);
|
|
1952
2046
|
const restRef = (0, import_react18.useRef)(null);
|
|
1953
|
-
const
|
|
2047
|
+
const waveCapsRef = (0, import_react18.useRef)(null);
|
|
2048
|
+
const restCapsRef = (0, import_react18.useRef)(null);
|
|
1954
2049
|
const span = (0, import_react18.useRef)(props.span);
|
|
1955
2050
|
span.current = props.span;
|
|
2051
|
+
const flat = (0, import_react18.useRef)(props.flat ?? false);
|
|
2052
|
+
flat.current = props.flat ?? false;
|
|
2053
|
+
const onFlat = (0, import_react18.useRef)(props.onFlat);
|
|
2054
|
+
onFlat.current = props.onFlat;
|
|
2055
|
+
const startFlat = (0, import_react18.useRef)(props.startFlat ?? false);
|
|
1956
2056
|
const still = props.still ?? false;
|
|
1957
2057
|
const vertical = props.vertical ?? false;
|
|
1958
2058
|
(0, import_react18.useEffect)(() => {
|
|
1959
2059
|
const svg = svgRef.current;
|
|
1960
2060
|
const wave = waveRef.current;
|
|
1961
2061
|
const rest = restRef.current;
|
|
1962
|
-
const
|
|
1963
|
-
|
|
2062
|
+
const waveCaps = waveCapsRef.current;
|
|
2063
|
+
const restCaps = restCapsRef.current;
|
|
2064
|
+
if (!svg || !wave || !rest || !waveCaps || !restCaps) return;
|
|
1964
2065
|
const reduced = still || matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1965
|
-
const
|
|
1966
|
-
|
|
1967
|
-
|
|
2066
|
+
const style = getComputedStyle(svg);
|
|
2067
|
+
const gap = cssLength(svg, "--avl-wave-gap", 0);
|
|
2068
|
+
const flatStroke = cssLength(svg, "--avl-wave-flat-stroke", WAVE_STROKE);
|
|
2069
|
+
const flatRadius = cssLength(svg, "--avl-wave-flat-radius", -1);
|
|
2070
|
+
const flatRestRadius = cssLength(svg, "--avl-wave-flat-rest-radius", -1);
|
|
2071
|
+
const shapedCaps = flatRadius >= 0 || flatRestRadius >= 0;
|
|
2072
|
+
const linecap = shapedCaps ? "butt" : "";
|
|
2073
|
+
wave.style.strokeLinecap = linecap;
|
|
2074
|
+
rest.style.strokeLinecap = linecap;
|
|
2075
|
+
const duration = cssNumber(style, "--avl-ease-length-slow", 300);
|
|
2076
|
+
const ease = smoothEasing(style);
|
|
1968
2077
|
let current = null;
|
|
1969
2078
|
let frame = 0;
|
|
2079
|
+
let flatness = startFlat.current ? 1 : 0;
|
|
2080
|
+
let notified = false;
|
|
2081
|
+
let last = null;
|
|
1970
2082
|
const draw = (now) => {
|
|
2083
|
+
const target = flat.current ? 1 : 0;
|
|
2084
|
+
const step = reduced || last === null || duration <= 0 ? 1 : (now - last) / duration;
|
|
2085
|
+
if (last === null && !reduced) {
|
|
2086
|
+
last = now;
|
|
2087
|
+
} else {
|
|
2088
|
+
last = now;
|
|
2089
|
+
flatness = target > flatness ? Math.min(target, flatness + step) : Math.max(target, flatness - step);
|
|
2090
|
+
}
|
|
2091
|
+
if (flatness < 1) notified = false;
|
|
2092
|
+
const eased = target === 1 ? ease(flatness) : 1 - ease(1 - flatness);
|
|
2093
|
+
const stroke = WAVE_STROKE + (flatStroke - WAVE_STROKE) * eased;
|
|
2094
|
+
svg.style.setProperty("--avl-wave-stroke", `${stroke}px`);
|
|
1971
2095
|
const width = vertical ? svg.clientHeight : svg.clientWidth;
|
|
2096
|
+
const shape = {
|
|
2097
|
+
middle: (vertical ? svg.clientWidth : svg.clientHeight) / 2,
|
|
2098
|
+
amplitude: WAVE_AMPLITUDE * (1 - eased),
|
|
2099
|
+
cap: stroke / 2
|
|
2100
|
+
};
|
|
1972
2101
|
const next = span.current(width, gap, svg, now);
|
|
1973
2102
|
if (!current || next.snap || reduced) {
|
|
1974
2103
|
current = { from: next.from, to: next.to };
|
|
@@ -1977,17 +2106,61 @@ function SquigglyWave(props) {
|
|
|
1977
2106
|
current.to += (next.to - current.to) * 0.15;
|
|
1978
2107
|
}
|
|
1979
2108
|
const phase = reduced ? 0 : now / WAVE_PERIOD * 2 * Math.PI;
|
|
1980
|
-
wave.setAttribute(
|
|
2109
|
+
wave.setAttribute(
|
|
2110
|
+
"d",
|
|
2111
|
+
wavePath(current.from, current.to, phase, shape)
|
|
2112
|
+
);
|
|
1981
2113
|
rest.setAttribute(
|
|
1982
2114
|
"d",
|
|
1983
2115
|
(next.rest ?? []).map(
|
|
1984
|
-
([a, b]) => next.restWave ? wavePath(a, b, phase) : linePath(a, b)
|
|
2116
|
+
([a, b]) => next.restWave ? wavePath(a, b, phase, shape) : linePath(a, b, shape)
|
|
1985
2117
|
).join("")
|
|
1986
2118
|
);
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
2119
|
+
if (shapedCaps) {
|
|
2120
|
+
const half = stroke / 2;
|
|
2121
|
+
const caps = (a, b, wavy, insideRadius) => {
|
|
2122
|
+
if (b - a <= 0) return "";
|
|
2123
|
+
const length = Math.min(half, (b - a) / 2);
|
|
2124
|
+
const radius = (inside) => inside && insideRadius >= 0 ? half + (insideRadius - half) * eased : half;
|
|
2125
|
+
const at = (x) => wavy ? [
|
|
2126
|
+
waveY(x, phase, shape),
|
|
2127
|
+
waveSlope(x, phase, shape)
|
|
2128
|
+
] : [shape.middle, 0];
|
|
2129
|
+
const [y0, s0] = at(a + length);
|
|
2130
|
+
const [y1, s1] = at(b - length);
|
|
2131
|
+
return capPath(
|
|
2132
|
+
a + length,
|
|
2133
|
+
y0,
|
|
2134
|
+
s0,
|
|
2135
|
+
-1,
|
|
2136
|
+
half,
|
|
2137
|
+
length,
|
|
2138
|
+
radius(a > 0.5)
|
|
2139
|
+
) + capPath(
|
|
2140
|
+
b - length,
|
|
2141
|
+
y1,
|
|
2142
|
+
s1,
|
|
2143
|
+
1,
|
|
2144
|
+
half,
|
|
2145
|
+
length,
|
|
2146
|
+
radius(b < width - 0.5)
|
|
2147
|
+
);
|
|
2148
|
+
};
|
|
2149
|
+
waveCaps.setAttribute(
|
|
2150
|
+
"d",
|
|
2151
|
+
caps(current.from, current.to, true, flatRadius)
|
|
2152
|
+
);
|
|
2153
|
+
restCaps.setAttribute(
|
|
2154
|
+
"d",
|
|
2155
|
+
(next.rest ?? []).map(
|
|
2156
|
+
([a, b]) => caps(a, b, next.restWave ?? false, flatRestRadius)
|
|
2157
|
+
).join("")
|
|
2158
|
+
);
|
|
2159
|
+
}
|
|
2160
|
+
if (flatness === 1 && target === 1 && !notified) {
|
|
2161
|
+
notified = true;
|
|
2162
|
+
onFlat.current?.();
|
|
2163
|
+
}
|
|
1991
2164
|
if (!still) frame = requestAnimationFrame(draw);
|
|
1992
2165
|
};
|
|
1993
2166
|
if (still) {
|
|
@@ -2000,8 +2173,15 @@ function SquigglyWave(props) {
|
|
|
2000
2173
|
}, [still, vertical]);
|
|
2001
2174
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { ref: svgRef, className: "avl-squiggly-wave", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("g", { transform: vertical ? "matrix(0 1 1 0 0 0)" : void 0, children: [
|
|
2002
2175
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { ref: restRef, className: "avl-squiggly-wave-rest" }),
|
|
2176
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2177
|
+
"path",
|
|
2178
|
+
{
|
|
2179
|
+
ref: restCapsRef,
|
|
2180
|
+
className: "avl-squiggly-wave-cap avl-squiggly-wave-rest"
|
|
2181
|
+
}
|
|
2182
|
+
),
|
|
2003
2183
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { ref: waveRef }),
|
|
2004
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { ref:
|
|
2184
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { ref: waveCapsRef, className: "avl-squiggly-wave-cap" })
|
|
2005
2185
|
] }) });
|
|
2006
2186
|
}
|
|
2007
2187
|
|
|
@@ -2172,6 +2352,7 @@ function FABMenu({
|
|
|
2172
2352
|
align = "end",
|
|
2173
2353
|
sticky = true,
|
|
2174
2354
|
className,
|
|
2355
|
+
ref,
|
|
2175
2356
|
children,
|
|
2176
2357
|
...props
|
|
2177
2358
|
}) {
|
|
@@ -2195,7 +2376,7 @@ function FABMenu({
|
|
|
2195
2376
|
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
2196
2377
|
import_menu.Menu.Trigger,
|
|
2197
2378
|
{
|
|
2198
|
-
ref: trigger,
|
|
2379
|
+
ref: mergeRefs(trigger, ref),
|
|
2199
2380
|
"aria-label": ariaLabel,
|
|
2200
2381
|
className: cx(
|
|
2201
2382
|
"avl-fab avl-fab-size-normal avl-fab-menu-trigger",
|
|
@@ -2292,6 +2473,7 @@ function Input({
|
|
|
2292
2473
|
label,
|
|
2293
2474
|
size = "normal",
|
|
2294
2475
|
className,
|
|
2476
|
+
style,
|
|
2295
2477
|
placeholder,
|
|
2296
2478
|
...props
|
|
2297
2479
|
}) {
|
|
@@ -2302,6 +2484,7 @@ function Input({
|
|
|
2302
2484
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2303
2485
|
"label",
|
|
2304
2486
|
{
|
|
2487
|
+
style,
|
|
2305
2488
|
className: cx(
|
|
2306
2489
|
"avl-input",
|
|
2307
2490
|
`avl-input-size-${size}`,
|
|
@@ -2862,6 +3045,8 @@ function Progress({
|
|
|
2862
3045
|
);
|
|
2863
3046
|
}
|
|
2864
3047
|
const { value, min = 0, max = 100 } = props;
|
|
3048
|
+
const wavy = squiggly && type === "linear";
|
|
3049
|
+
const morph2 = useWaveMorph(wavy);
|
|
2865
3050
|
const fraction = value == null ? 0 : Math.min(1, Math.max(0, (value - min) / (max - min)));
|
|
2866
3051
|
const pct = fraction * 100;
|
|
2867
3052
|
const ring = type === "inline" ? INLINE_RING : RING;
|
|
@@ -2876,7 +3061,9 @@ function Progress({
|
|
|
2876
3061
|
`avl-progress-${type}`,
|
|
2877
3062
|
// Inline is a smaller ring, so it shares the circular styles
|
|
2878
3063
|
type === "inline" && "avl-progress-circular",
|
|
2879
|
-
|
|
3064
|
+
wavy && "avl-progress-squiggly",
|
|
3065
|
+
// Also while flattening into the plain bar
|
|
3066
|
+
morph2.show && "avl-progress-wave"
|
|
2880
3067
|
),
|
|
2881
3068
|
className
|
|
2882
3069
|
),
|
|
@@ -2887,9 +3074,10 @@ function Progress({
|
|
|
2887
3074
|
children: [
|
|
2888
3075
|
label != null && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_progress.Progress.Label, { className: "avl-progress-label", children: label }),
|
|
2889
3076
|
type === "linear" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_progress.Progress.Track, { className: "avl-progress-track", children: [
|
|
2890
|
-
|
|
3077
|
+
morph2.show ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
2891
3078
|
SquigglyWave,
|
|
2892
3079
|
{
|
|
3080
|
+
...morph2.wave,
|
|
2893
3081
|
span: (width, gap, _svg, now) => value == null ? loadingSpan(width, gap, now) : (
|
|
2894
3082
|
// Fill up to the value; .avl-progress-rest
|
|
2895
3083
|
// draws the track one gap after it
|
|
@@ -2975,6 +3163,17 @@ function ToggleGroup({
|
|
|
2975
3163
|
}) {
|
|
2976
3164
|
const groupRef = (0, import_react28.useRef)(null);
|
|
2977
3165
|
const indicatorRef = (0, import_react28.useRef)(null);
|
|
3166
|
+
(0, import_react28.useEffect)(() => {
|
|
3167
|
+
if (process.env.NODE_ENV === "production") return;
|
|
3168
|
+
if (inNamedFieldset(groupRef.current)) return;
|
|
3169
|
+
checkName(
|
|
3170
|
+
props,
|
|
3171
|
+
"ToggleGroup",
|
|
3172
|
+
'<ToggleGroup aria-label="View" defaultValue="list">...</ToggleGroup>',
|
|
3173
|
+
"toggle-group.md",
|
|
3174
|
+
UNNAMED_GROUP
|
|
3175
|
+
);
|
|
3176
|
+
}, []);
|
|
2978
3177
|
(0, import_react28.useLayoutEffect)(() => {
|
|
2979
3178
|
const group = groupRef.current;
|
|
2980
3179
|
const indicator = indicatorRef.current;
|
|
@@ -3022,7 +3221,7 @@ function ToggleGroup({
|
|
|
3022
3221
|
{
|
|
3023
3222
|
...props,
|
|
3024
3223
|
multiple: true,
|
|
3025
|
-
ref,
|
|
3224
|
+
ref: mergeRefs(groupRef, ref),
|
|
3026
3225
|
className: classes,
|
|
3027
3226
|
children
|
|
3028
3227
|
}
|
|
@@ -3102,15 +3301,30 @@ function ToggleGroupItem({
|
|
|
3102
3301
|
// src/components/RadioGroup/RadioGroup.tsx
|
|
3103
3302
|
var import_radio2 = require("@base-ui/react/radio");
|
|
3104
3303
|
var import_radio_group2 = require("@base-ui/react/radio-group");
|
|
3304
|
+
var import_react29 = require("react");
|
|
3105
3305
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
3106
3306
|
function RadioGroup({
|
|
3107
3307
|
className,
|
|
3308
|
+
ref,
|
|
3108
3309
|
...props
|
|
3109
3310
|
}) {
|
|
3311
|
+
const local = (0, import_react29.useRef)(null);
|
|
3312
|
+
(0, import_react29.useEffect)(() => {
|
|
3313
|
+
if (process.env.NODE_ENV === "production") return;
|
|
3314
|
+
if (inNamedFieldset(local.current)) return;
|
|
3315
|
+
checkName(
|
|
3316
|
+
props,
|
|
3317
|
+
"RadioGroup",
|
|
3318
|
+
'<RadioGroup aria-label="Plan" defaultValue="free">...</RadioGroup>\n// or inside <fieldset><legend>Plan</legend>...</fieldset>',
|
|
3319
|
+
"radio-group.md",
|
|
3320
|
+
UNNAMED_GROUP
|
|
3321
|
+
);
|
|
3322
|
+
}, []);
|
|
3110
3323
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3111
3324
|
import_radio_group2.RadioGroup,
|
|
3112
3325
|
{
|
|
3113
3326
|
...props,
|
|
3327
|
+
ref: mergeRefs(local, ref),
|
|
3114
3328
|
className: withClass("avl-radio-group", className)
|
|
3115
3329
|
}
|
|
3116
3330
|
);
|
|
@@ -3137,7 +3351,7 @@ function Radio({ className, ...props }) {
|
|
|
3137
3351
|
}
|
|
3138
3352
|
|
|
3139
3353
|
// src/components/Select/Select.tsx
|
|
3140
|
-
var
|
|
3354
|
+
var import_react30 = require("react");
|
|
3141
3355
|
var import_select = require("@base-ui/react/select");
|
|
3142
3356
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
3143
3357
|
function Select({
|
|
@@ -3145,10 +3359,13 @@ function Select({
|
|
|
3145
3359
|
placeholder,
|
|
3146
3360
|
size = "normal",
|
|
3147
3361
|
className,
|
|
3362
|
+
style,
|
|
3363
|
+
ref,
|
|
3148
3364
|
children,
|
|
3149
|
-
...
|
|
3365
|
+
...allProps
|
|
3150
3366
|
}) {
|
|
3151
|
-
const
|
|
3367
|
+
const { control, rest: props } = splitControlProps(allProps);
|
|
3368
|
+
const avl = (0, import_react30.useContext)(AnvilContext);
|
|
3152
3369
|
if (process.env.NODE_ENV !== "production") {
|
|
3153
3370
|
checkRoot(avl !== null, "Select");
|
|
3154
3371
|
}
|
|
@@ -3156,6 +3373,7 @@ function Select({
|
|
|
3156
3373
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
3157
3374
|
"div",
|
|
3158
3375
|
{
|
|
3376
|
+
style,
|
|
3159
3377
|
className: cx(
|
|
3160
3378
|
"avl-input",
|
|
3161
3379
|
"avl-select",
|
|
@@ -3164,16 +3382,24 @@ function Select({
|
|
|
3164
3382
|
className
|
|
3165
3383
|
),
|
|
3166
3384
|
children: [
|
|
3167
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3385
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
3386
|
+
import_select.Select.Trigger,
|
|
3387
|
+
{
|
|
3388
|
+
...control,
|
|
3389
|
+
ref,
|
|
3390
|
+
className: "avl-input-field avl-select-trigger",
|
|
3391
|
+
children: [
|
|
3392
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3393
|
+
import_select.Select.Value,
|
|
3394
|
+
{
|
|
3395
|
+
className: "avl-select-value",
|
|
3396
|
+
placeholder
|
|
3397
|
+
}
|
|
3398
|
+
),
|
|
3399
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_select.Select.Icon, { className: "avl-select-icon", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Icon, { name: "arrow_drop_down" }) })
|
|
3400
|
+
]
|
|
3401
|
+
}
|
|
3402
|
+
),
|
|
3177
3403
|
label != null && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_select.Select.Label, { className: "avl-input-label", children: label }),
|
|
3178
3404
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("fieldset", { "aria-hidden": true, className: "avl-input-outline", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("legend", { children: label != null && size === "normal" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { children: label }) }) })
|
|
3179
3405
|
]
|
|
@@ -3205,7 +3431,7 @@ function SelectItem({ className, children, ...props }) {
|
|
|
3205
3431
|
}
|
|
3206
3432
|
|
|
3207
3433
|
// src/components/TimePicker/TimePicker.tsx
|
|
3208
|
-
var
|
|
3434
|
+
var import_react31 = require("react");
|
|
3209
3435
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
3210
3436
|
var pad2 = (n) => String(n).padStart(2, "0");
|
|
3211
3437
|
function localeHourCycle() {
|
|
@@ -3230,16 +3456,29 @@ function TimePicker({
|
|
|
3230
3456
|
defaultOpen,
|
|
3231
3457
|
onOpenChange,
|
|
3232
3458
|
className,
|
|
3233
|
-
|
|
3459
|
+
ref,
|
|
3460
|
+
id,
|
|
3461
|
+
...allProps
|
|
3234
3462
|
}) {
|
|
3235
|
-
const
|
|
3463
|
+
const { control, rest: props } = splitControlProps(allProps);
|
|
3464
|
+
const [internal, setInternal] = (0, import_react31.useState)(defaultValue);
|
|
3236
3465
|
const value = valueProp !== void 0 ? valueProp : internal;
|
|
3237
3466
|
const time = parseTime(value);
|
|
3238
3467
|
const cycle = hourCycle ?? localeHourCycle();
|
|
3239
|
-
const labelId = (0,
|
|
3240
|
-
const valueId = (0,
|
|
3468
|
+
const labelId = (0, import_react31.useId)();
|
|
3469
|
+
const valueId = (0, import_react31.useId)();
|
|
3470
|
+
const trigger = (0, import_react31.useRef)(null);
|
|
3471
|
+
(0, import_react31.useEffect)(() => {
|
|
3472
|
+
if (process.env.NODE_ENV === "production") return;
|
|
3473
|
+
if (trigger.current?.closest(".avl-field"))
|
|
3474
|
+
devError(
|
|
3475
|
+
"<TimePicker> is inside a <Field>, but it doesn't take the Field's `name`, `disabled` or validation.",
|
|
3476
|
+
'<TimePicker label="Alarm" name="alarm" disabled={locked} /> // outside any Field',
|
|
3477
|
+
"time-picker.md"
|
|
3478
|
+
);
|
|
3479
|
+
}, []);
|
|
3241
3480
|
const setTime = (t) => {
|
|
3242
|
-
const next = `${pad2(t.h)}:${pad2(t.m)}`;
|
|
3481
|
+
const next = t && `${pad2(t.h)}:${pad2(t.m)}`;
|
|
3243
3482
|
setInternal(next);
|
|
3244
3483
|
onValueChange?.(next);
|
|
3245
3484
|
};
|
|
@@ -3271,6 +3510,9 @@ function TimePicker({
|
|
|
3271
3510
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
3272
3511
|
PopoverTrigger,
|
|
3273
3512
|
{
|
|
3513
|
+
...control,
|
|
3514
|
+
ref: mergeRefs(trigger, ref),
|
|
3515
|
+
id,
|
|
3274
3516
|
disabled,
|
|
3275
3517
|
className: "avl-input-field avl-select-trigger",
|
|
3276
3518
|
"data-placeholder": time ? void 0 : "",
|
|
@@ -3293,7 +3535,8 @@ function TimePicker({
|
|
|
3293
3535
|
type,
|
|
3294
3536
|
time,
|
|
3295
3537
|
cycle,
|
|
3296
|
-
onChange: setTime
|
|
3538
|
+
onChange: setTime,
|
|
3539
|
+
onClear: () => setTime(null)
|
|
3297
3540
|
}
|
|
3298
3541
|
) })
|
|
3299
3542
|
]
|
|
@@ -3301,8 +3544,8 @@ function TimePicker({
|
|
|
3301
3544
|
);
|
|
3302
3545
|
}
|
|
3303
3546
|
function TimePanel(props) {
|
|
3304
|
-
const { type, time, cycle, onChange } = props;
|
|
3305
|
-
const [mode, setMode] = (0,
|
|
3547
|
+
const { type, time, cycle, onChange, onClear } = props;
|
|
3548
|
+
const [mode, setMode] = (0, import_react31.useState)("hour");
|
|
3306
3549
|
const pm = time ? time.h >= 12 : false;
|
|
3307
3550
|
const hourText = time ? pad2(displayHour(time.h, cycle)) : "--";
|
|
3308
3551
|
const minuteText = time ? pad2(time.m) : "--";
|
|
@@ -3390,12 +3633,20 @@ function TimePanel(props) {
|
|
|
3390
3633
|
onChange,
|
|
3391
3634
|
onHourDone: () => setMode("minute")
|
|
3392
3635
|
}
|
|
3393
|
-
)
|
|
3636
|
+
),
|
|
3637
|
+
time && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "avl-time-picker-actions", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
3638
|
+
PopoverClose,
|
|
3639
|
+
{
|
|
3640
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Button, { fillType: "text", size: "small" }),
|
|
3641
|
+
onClick: onClear,
|
|
3642
|
+
children: "Clear"
|
|
3643
|
+
}
|
|
3644
|
+
) })
|
|
3394
3645
|
] });
|
|
3395
3646
|
}
|
|
3396
3647
|
function SpinInput(props) {
|
|
3397
3648
|
const { label, value, min, max, onChange } = props;
|
|
3398
|
-
const [draft, setDraft] = (0,
|
|
3649
|
+
const [draft, setDraft] = (0, import_react31.useState)(null);
|
|
3399
3650
|
const range = max - min + 1;
|
|
3400
3651
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
3401
3652
|
"input",
|
|
@@ -3444,7 +3695,7 @@ function Dial(props) {
|
|
|
3444
3695
|
const h = time?.h ?? 0;
|
|
3445
3696
|
const m = time?.m ?? 0;
|
|
3446
3697
|
const isHour = mode === "hour";
|
|
3447
|
-
const [dragging, setDragging] = (0,
|
|
3698
|
+
const [dragging, setDragging] = (0, import_react31.useState)(false);
|
|
3448
3699
|
const labels = Array.from(
|
|
3449
3700
|
{ length: 12 },
|
|
3450
3701
|
(_, i) => !isHour ? [{ value: i * 5, text: pad2(i * 5), inner: false }] : cycle === 12 ? [{ value: i, text: String(i || 12), inner: false }] : [
|
|
@@ -3454,7 +3705,7 @@ function Dial(props) {
|
|
|
3454
3705
|
).flat();
|
|
3455
3706
|
const radius = isHour && cycle === 24 && h >= 12 ? INNER : OUTER;
|
|
3456
3707
|
const target = isHour ? h % 12 * 30 : m * 6;
|
|
3457
|
-
const angleRef = (0,
|
|
3708
|
+
const angleRef = (0, import_react31.useRef)(null);
|
|
3458
3709
|
const prev = angleRef.current;
|
|
3459
3710
|
const angle = prev == null ? target : prev + ((target - prev) % 360 + 540) % 360 - 180;
|
|
3460
3711
|
angleRef.current = angle;
|
|
@@ -3603,7 +3854,7 @@ function Dial(props) {
|
|
|
3603
3854
|
}
|
|
3604
3855
|
|
|
3605
3856
|
// src/components/DateInput/DateInput.tsx
|
|
3606
|
-
var
|
|
3857
|
+
var import_react32 = require("react");
|
|
3607
3858
|
var import_input5 = require("@base-ui/react/input");
|
|
3608
3859
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
3609
3860
|
var numericFormat = () => new Intl.DateTimeFormat(void 0, {
|
|
@@ -3619,19 +3870,36 @@ function DateInput({
|
|
|
3619
3870
|
size = "normal",
|
|
3620
3871
|
disabled,
|
|
3621
3872
|
id,
|
|
3873
|
+
onChange,
|
|
3622
3874
|
onBlur,
|
|
3623
3875
|
className,
|
|
3876
|
+
style,
|
|
3877
|
+
ref,
|
|
3624
3878
|
...props
|
|
3625
3879
|
}) {
|
|
3626
|
-
const [internal, setInternal] = (0,
|
|
3880
|
+
const [internal, setInternal] = (0, import_react32.useState)(defaultValue);
|
|
3627
3881
|
const value = valueProp !== void 0 ? valueProp : internal;
|
|
3628
3882
|
const date = fromIso(value);
|
|
3629
|
-
const [draft, setDraft] = (0,
|
|
3630
|
-
const [open, setOpen] = (0,
|
|
3631
|
-
const fieldRef = (0,
|
|
3632
|
-
const popupRef = (0,
|
|
3633
|
-
const generatedId = (0,
|
|
3883
|
+
const [draft, setDraft] = (0, import_react32.useState)(null);
|
|
3884
|
+
const [open, setOpen] = (0, import_react32.useState)(false);
|
|
3885
|
+
const fieldRef = (0, import_react32.useRef)(null);
|
|
3886
|
+
const popupRef = (0, import_react32.useRef)(null);
|
|
3887
|
+
const generatedId = (0, import_react32.useId)();
|
|
3634
3888
|
const inputId = id ?? generatedId;
|
|
3889
|
+
const inputRef = (0, import_react32.useRef)(null);
|
|
3890
|
+
const iso = (0, import_react32.useRef)("");
|
|
3891
|
+
iso.current = date ? toIso(date) : "";
|
|
3892
|
+
(0, import_react32.useEffect)(() => {
|
|
3893
|
+
const form = inputRef.current?.form;
|
|
3894
|
+
if (!form) return;
|
|
3895
|
+
const onFormData = (event) => {
|
|
3896
|
+
const input = inputRef.current;
|
|
3897
|
+
if (input?.name && !input.disabled)
|
|
3898
|
+
event.formData.set(input.name, iso.current);
|
|
3899
|
+
};
|
|
3900
|
+
form.addEventListener("formdata", onFormData);
|
|
3901
|
+
return () => form.removeEventListener("formdata", onFormData);
|
|
3902
|
+
}, []);
|
|
3635
3903
|
const fmt = numericFormat();
|
|
3636
3904
|
const order = fieldOrder(fmt);
|
|
3637
3905
|
const invalid = draft != null && draft.trim() !== "" && !parseTyped(draft, order);
|
|
@@ -3645,6 +3913,7 @@ function DateInput({
|
|
|
3645
3913
|
"div",
|
|
3646
3914
|
{
|
|
3647
3915
|
ref: fieldRef,
|
|
3916
|
+
style,
|
|
3648
3917
|
className: cx(
|
|
3649
3918
|
"avl-input",
|
|
3650
3919
|
"avl-date-input",
|
|
@@ -3657,6 +3926,7 @@ function DateInput({
|
|
|
3657
3926
|
import_input5.Input,
|
|
3658
3927
|
{
|
|
3659
3928
|
...props,
|
|
3929
|
+
ref: mergeRefs(inputRef, ref),
|
|
3660
3930
|
id: inputId,
|
|
3661
3931
|
disabled,
|
|
3662
3932
|
className: "avl-input-field",
|
|
@@ -3673,6 +3943,7 @@ function DateInput({
|
|
|
3673
3943
|
const typed = parseTyped(text, order);
|
|
3674
3944
|
if (typed) commit(typed);
|
|
3675
3945
|
}
|
|
3946
|
+
onChange?.(e);
|
|
3676
3947
|
},
|
|
3677
3948
|
onBlur: (e) => {
|
|
3678
3949
|
if (!invalid) setDraft(null);
|
|
@@ -3714,8 +3985,8 @@ function DateInput({
|
|
|
3714
3985
|
Calendar,
|
|
3715
3986
|
{
|
|
3716
3987
|
value: date && toIso(date),
|
|
3717
|
-
onValueChange: (
|
|
3718
|
-
commit(fromIso(
|
|
3988
|
+
onValueChange: (iso2) => {
|
|
3989
|
+
commit(fromIso(iso2));
|
|
3719
3990
|
setDraft(null);
|
|
3720
3991
|
setOpen(false);
|
|
3721
3992
|
}
|
|
@@ -3727,7 +3998,7 @@ function DateInput({
|
|
|
3727
3998
|
}
|
|
3728
3999
|
|
|
3729
4000
|
// src/components/Combobox/Combobox.tsx
|
|
3730
|
-
var
|
|
4001
|
+
var import_react33 = require("react");
|
|
3731
4002
|
var import_combobox = require("@base-ui/react/combobox");
|
|
3732
4003
|
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
3733
4004
|
function Combobox({
|
|
@@ -3737,9 +4008,13 @@ function Combobox({
|
|
|
3737
4008
|
empty,
|
|
3738
4009
|
size = "normal",
|
|
3739
4010
|
className,
|
|
3740
|
-
|
|
4011
|
+
style,
|
|
4012
|
+
ref,
|
|
4013
|
+
id,
|
|
4014
|
+
...allProps
|
|
3741
4015
|
}) {
|
|
3742
|
-
const
|
|
4016
|
+
const { control, rest: props } = splitControlProps(allProps);
|
|
4017
|
+
const avl = (0, import_react33.useContext)(AnvilContext);
|
|
3743
4018
|
if (process.env.NODE_ENV !== "production") {
|
|
3744
4019
|
checkRoot(avl !== null, "Combobox");
|
|
3745
4020
|
if (typeof children !== "function")
|
|
@@ -3749,12 +4024,14 @@ function Combobox({
|
|
|
3749
4024
|
"combobox.md"
|
|
3750
4025
|
);
|
|
3751
4026
|
}
|
|
3752
|
-
const
|
|
3753
|
-
const
|
|
4027
|
+
const generatedId = (0, import_react33.useId)();
|
|
4028
|
+
const inputId = id ?? generatedId;
|
|
4029
|
+
const labelId = (0, import_react33.useId)();
|
|
3754
4030
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_combobox.Combobox.Root, { ...props, children: [
|
|
3755
4031
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
3756
4032
|
import_combobox.Combobox.InputGroup,
|
|
3757
4033
|
{
|
|
4034
|
+
style,
|
|
3758
4035
|
className: cx(
|
|
3759
4036
|
"avl-input",
|
|
3760
4037
|
"avl-combobox",
|
|
@@ -3766,6 +4043,8 @@ function Combobox({
|
|
|
3766
4043
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3767
4044
|
import_combobox.Combobox.Input,
|
|
3768
4045
|
{
|
|
4046
|
+
...control,
|
|
4047
|
+
ref,
|
|
3769
4048
|
id: inputId,
|
|
3770
4049
|
className: "avl-input-field",
|
|
3771
4050
|
placeholder: placeholder ?? " "
|
|
@@ -3824,7 +4103,7 @@ function ComboboxItem({
|
|
|
3824
4103
|
}
|
|
3825
4104
|
|
|
3826
4105
|
// src/components/PinInput/PinInput.tsx
|
|
3827
|
-
var
|
|
4106
|
+
var import_react34 = require("react");
|
|
3828
4107
|
var import_otp_field = require("@base-ui/react/otp-field");
|
|
3829
4108
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
3830
4109
|
var defaultSlotLabel = (index, length) => `Character ${index + 1} of ${length}`;
|
|
@@ -3835,16 +4114,18 @@ function PinInput({
|
|
|
3835
4114
|
size = "normal",
|
|
3836
4115
|
slotLabel = defaultSlotLabel,
|
|
3837
4116
|
className,
|
|
4117
|
+
style,
|
|
3838
4118
|
id,
|
|
3839
4119
|
length,
|
|
3840
4120
|
...props
|
|
3841
4121
|
}) {
|
|
3842
|
-
const generatedId = (0,
|
|
4122
|
+
const generatedId = (0, import_react34.useId)();
|
|
3843
4123
|
const inputId = id ?? generatedId;
|
|
3844
4124
|
const labelId = `${inputId}-label`;
|
|
3845
4125
|
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
|
|
3846
4126
|
"div",
|
|
3847
4127
|
{
|
|
4128
|
+
style,
|
|
3848
4129
|
className: cx(
|
|
3849
4130
|
"avl-pin-input",
|
|
3850
4131
|
`avl-pin-input-size-${size}`,
|
|
@@ -3915,11 +4196,13 @@ function Toggle2({
|
|
|
3915
4196
|
import_toggle3.Toggle,
|
|
3916
4197
|
{
|
|
3917
4198
|
...props,
|
|
3918
|
-
className: (
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
4199
|
+
className: withClass(
|
|
4200
|
+
(state) => cx(
|
|
4201
|
+
"avl-toggle",
|
|
4202
|
+
icon ? `avl-icon-button avl-icon-button-size-${size}` : `avl-button avl-button-size-${size}`,
|
|
4203
|
+
state.pressed ? colorClass(color, "filled") : colorClass("container", fillType)
|
|
4204
|
+
),
|
|
4205
|
+
className
|
|
3923
4206
|
),
|
|
3924
4207
|
children: icon ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Icon, { name: icon }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
|
|
3925
4208
|
startIcon && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Icon, { name: startIcon }),
|
|
@@ -3931,7 +4214,7 @@ function Toggle2({
|
|
|
3931
4214
|
}
|
|
3932
4215
|
|
|
3933
4216
|
// src/components/Search/Search.tsx
|
|
3934
|
-
var
|
|
4217
|
+
var import_react35 = require("react");
|
|
3935
4218
|
var import_autocomplete = require("@base-ui/react/autocomplete");
|
|
3936
4219
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
3937
4220
|
function Search({
|
|
@@ -3939,11 +4222,17 @@ function Search({
|
|
|
3939
4222
|
placeholder,
|
|
3940
4223
|
"aria-label": ariaLabel,
|
|
3941
4224
|
empty,
|
|
4225
|
+
color = "surface",
|
|
3942
4226
|
clearLabel = "Clear",
|
|
3943
4227
|
className,
|
|
3944
|
-
|
|
4228
|
+
style,
|
|
4229
|
+
ref,
|
|
4230
|
+
id,
|
|
4231
|
+
...allProps
|
|
3945
4232
|
}) {
|
|
3946
|
-
const
|
|
4233
|
+
const { control, rest: props } = splitControlProps(allProps);
|
|
4234
|
+
const avl = (0, import_react35.useContext)(AnvilContext);
|
|
4235
|
+
const suggests = children !== void 0;
|
|
3947
4236
|
if (process.env.NODE_ENV !== "production") {
|
|
3948
4237
|
checkRoot(avl !== null, "Search");
|
|
3949
4238
|
checkName(
|
|
@@ -3952,23 +4241,37 @@ function Search({
|
|
|
3952
4241
|
'<Search aria-label="Search mail" items={items}>{(item) => ...}</Search>',
|
|
3953
4242
|
"search.md"
|
|
3954
4243
|
);
|
|
3955
|
-
if (typeof children !== "function")
|
|
4244
|
+
if (children !== void 0 && typeof children !== "function")
|
|
3956
4245
|
devError(
|
|
3957
4246
|
"<Search> children must be a function that renders one suggestion, plus an `items` array to filter.",
|
|
3958
4247
|
'<Search aria-label="Search" items={items}>\n {(item: string) => <SearchItem key={item} value={item}>{item}</SearchItem>}\n</Search>',
|
|
3959
4248
|
"search.md"
|
|
3960
4249
|
);
|
|
4250
|
+
if (children === void 0 && props.items?.length)
|
|
4251
|
+
devError(
|
|
4252
|
+
"<Search> has `items` but no children, so the suggestions never show.",
|
|
4253
|
+
'<Search aria-label="Search" items={items}>\n {(item: string) => <SearchItem key={item} value={item}>{item}</SearchItem>}\n</Search>',
|
|
4254
|
+
"search.md"
|
|
4255
|
+
);
|
|
3961
4256
|
}
|
|
3962
|
-
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_autocomplete.Autocomplete.Root, { ...props, children: [
|
|
4257
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_autocomplete.Autocomplete.Root, { ...props, ...!suggests && { open: false }, children: [
|
|
3963
4258
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
3964
4259
|
import_autocomplete.Autocomplete.InputGroup,
|
|
3965
4260
|
{
|
|
3966
|
-
|
|
4261
|
+
style,
|
|
4262
|
+
className: cx(
|
|
4263
|
+
"avl-search",
|
|
4264
|
+
colorClass(color, "filled"),
|
|
4265
|
+
className
|
|
4266
|
+
),
|
|
3967
4267
|
children: [
|
|
3968
4268
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { name: "search" }),
|
|
3969
4269
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
3970
4270
|
import_autocomplete.Autocomplete.Input,
|
|
3971
4271
|
{
|
|
4272
|
+
...control,
|
|
4273
|
+
ref,
|
|
4274
|
+
id,
|
|
3972
4275
|
className: "avl-search-input",
|
|
3973
4276
|
placeholder,
|
|
3974
4277
|
"aria-label": ariaLabel
|
|
@@ -3982,7 +4285,7 @@ function Search({
|
|
|
3982
4285
|
{
|
|
3983
4286
|
icon: "close",
|
|
3984
4287
|
fillType: "text",
|
|
3985
|
-
color
|
|
4288
|
+
color,
|
|
3986
4289
|
"aria-label": clearLabel
|
|
3987
4290
|
}
|
|
3988
4291
|
)
|
|
@@ -3991,7 +4294,7 @@ function Search({
|
|
|
3991
4294
|
]
|
|
3992
4295
|
}
|
|
3993
4296
|
),
|
|
3994
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_autocomplete.Autocomplete.Portal, { container: avl?.rootRef, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
4297
|
+
suggests && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_autocomplete.Autocomplete.Portal, { container: avl?.rootRef, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
3995
4298
|
import_autocomplete.Autocomplete.Positioner,
|
|
3996
4299
|
{
|
|
3997
4300
|
className: "avl-menu-positioner",
|
|
@@ -4026,11 +4329,21 @@ function SearchItem({
|
|
|
4026
4329
|
// src/components/Skeleton/Skeleton.tsx
|
|
4027
4330
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
4028
4331
|
function Skeleton({
|
|
4029
|
-
|
|
4332
|
+
type = "text",
|
|
4030
4333
|
animation = "pulse",
|
|
4031
4334
|
className,
|
|
4032
4335
|
...props
|
|
4033
4336
|
}) {
|
|
4337
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4338
|
+
checkProp(
|
|
4339
|
+
props,
|
|
4340
|
+
"variant",
|
|
4341
|
+
"Skeleton",
|
|
4342
|
+
"The shape is `type`, as on Progress and Typography.",
|
|
4343
|
+
'<Skeleton type="circular" style={{ width: 40, height: 40 }} />\n// type: text | circular | rectangular',
|
|
4344
|
+
"skeleton.md"
|
|
4345
|
+
);
|
|
4346
|
+
}
|
|
4034
4347
|
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
4035
4348
|
"span",
|
|
4036
4349
|
{
|
|
@@ -4038,7 +4351,7 @@ function Skeleton({
|
|
|
4038
4351
|
...props,
|
|
4039
4352
|
className: cx(
|
|
4040
4353
|
"avl-skeleton",
|
|
4041
|
-
`avl-skeleton-${
|
|
4354
|
+
`avl-skeleton-${type}`,
|
|
4042
4355
|
animation === "pulse" && "avl-skeleton-pulse",
|
|
4043
4356
|
className
|
|
4044
4357
|
)
|
|
@@ -4054,20 +4367,33 @@ function Slider({
|
|
|
4054
4367
|
"aria-label": ariaLabel,
|
|
4055
4368
|
showValue = true,
|
|
4056
4369
|
squiggly = false,
|
|
4370
|
+
getAriaLabel,
|
|
4057
4371
|
className,
|
|
4058
4372
|
...props
|
|
4059
4373
|
}) {
|
|
4060
|
-
if (process.env.NODE_ENV !== "production" && label == null) {
|
|
4061
|
-
checkName(
|
|
4062
|
-
{ "aria-label": ariaLabel, ...props },
|
|
4063
|
-
"Slider",
|
|
4064
|
-
'<Slider label="Volume" /> // or <Slider aria-label="Volume" />',
|
|
4065
|
-
"slider.md"
|
|
4066
|
-
);
|
|
4067
|
-
}
|
|
4068
4374
|
const initial = props.value ?? props.defaultValue;
|
|
4069
4375
|
const thumbCount = Array.isArray(initial) ? initial.length : 1;
|
|
4376
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4377
|
+
if (label == null)
|
|
4378
|
+
checkName(
|
|
4379
|
+
{ "aria-label": ariaLabel, ...props },
|
|
4380
|
+
"Slider",
|
|
4381
|
+
'<Slider label="Volume" /> // or <Slider aria-label="Volume" />',
|
|
4382
|
+
"slider.md"
|
|
4383
|
+
);
|
|
4384
|
+
if (thumbCount > 1 && !getAriaLabel)
|
|
4385
|
+
devError(
|
|
4386
|
+
"<Slider> has several handles but no `getAriaLabel`, so screen readers give every handle the same name.",
|
|
4387
|
+
`<Slider
|
|
4388
|
+
label="Price"
|
|
4389
|
+
defaultValue={[20, 80]}
|
|
4390
|
+
getAriaLabel={(i) => (i === 0 ? 'Minimum price' : 'Maximum price')}
|
|
4391
|
+
/>`,
|
|
4392
|
+
"slider.md"
|
|
4393
|
+
);
|
|
4394
|
+
}
|
|
4070
4395
|
const wavy = squiggly && props.orientation !== "vertical";
|
|
4396
|
+
const morph2 = useWaveMorph(wavy);
|
|
4071
4397
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
|
|
4072
4398
|
import_slider.Slider.Root,
|
|
4073
4399
|
{
|
|
@@ -4083,7 +4409,7 @@ function Slider({
|
|
|
4083
4409
|
children: [
|
|
4084
4410
|
label != null && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_slider.Slider.Label, { className: "avl-slider-label", children: label }),
|
|
4085
4411
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_slider.Slider.Control, { className: "avl-slider-control", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_slider.Slider.Track, { className: "avl-slider-track", children: [
|
|
4086
|
-
|
|
4412
|
+
morph2.show ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(SquigglyWave, { span: handleSpan, ...morph2.wave }) : (
|
|
4087
4413
|
// Clips the track pieces to the rounded track, without
|
|
4088
4414
|
// also clipping the handles, which are taller
|
|
4089
4415
|
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "avl-slider-rail", children: [
|
|
@@ -4096,6 +4422,7 @@ function Slider({
|
|
|
4096
4422
|
{
|
|
4097
4423
|
index: i,
|
|
4098
4424
|
"aria-label": ariaLabel,
|
|
4425
|
+
getAriaLabel,
|
|
4099
4426
|
className: "avl-slider-thumb",
|
|
4100
4427
|
render: (thumbProps, state) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
4101
4428
|
"div",
|
|
@@ -4133,17 +4460,16 @@ function handleSpan(width, gap, svg) {
|
|
|
4133
4460
|
[0, first - gap],
|
|
4134
4461
|
[last + gap, width]
|
|
4135
4462
|
] : [[last + gap, width]],
|
|
4136
|
-
dot: last + gap < width - gap,
|
|
4137
4463
|
snap: true
|
|
4138
4464
|
};
|
|
4139
4465
|
}
|
|
4140
4466
|
|
|
4141
4467
|
// src/components/Snackbar/Snackbar.tsx
|
|
4142
|
-
var
|
|
4468
|
+
var import_react36 = require("react");
|
|
4143
4469
|
var import_toast = require("@base-ui/react/toast");
|
|
4144
4470
|
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
4145
4471
|
function useSnackbar() {
|
|
4146
|
-
const avl = (0,
|
|
4472
|
+
const avl = (0, import_react36.useContext)(AnvilContext);
|
|
4147
4473
|
if (process.env.NODE_ENV !== "production" && !avl)
|
|
4148
4474
|
throw new Error(
|
|
4149
4475
|
"[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"
|
|
@@ -4166,17 +4492,17 @@ function useSnackbar() {
|
|
|
4166
4492
|
}
|
|
4167
4493
|
function SnackbarViewport() {
|
|
4168
4494
|
const { toasts } = import_toast.Toast.useToastManager();
|
|
4169
|
-
const viewportRef = (0,
|
|
4170
|
-
const [expanded, setExpanded] = (0,
|
|
4171
|
-
const [hovered, setHovered] = (0,
|
|
4495
|
+
const viewportRef = (0, import_react36.useRef)(null);
|
|
4496
|
+
const [expanded, setExpanded] = (0, import_react36.useState)(false);
|
|
4497
|
+
const [hovered, setHovered] = (0, import_react36.useState)(false);
|
|
4172
4498
|
const visibleCount = toasts.filter(
|
|
4173
4499
|
(toast) => toast.transitionStatus !== "ending"
|
|
4174
4500
|
).length;
|
|
4175
4501
|
const collapsed = visibleCount > 1 && !expanded && !hovered;
|
|
4176
|
-
(0,
|
|
4502
|
+
(0, import_react36.useEffect)(() => {
|
|
4177
4503
|
if (visibleCount <= 1) setExpanded(false);
|
|
4178
4504
|
}, [visibleCount]);
|
|
4179
|
-
(0,
|
|
4505
|
+
(0, import_react36.useEffect)(() => {
|
|
4180
4506
|
if (!expanded) return;
|
|
4181
4507
|
const viewport = viewportRef.current;
|
|
4182
4508
|
const close = (event) => {
|
|
@@ -4382,12 +4708,14 @@ function Textarea({
|
|
|
4382
4708
|
label,
|
|
4383
4709
|
size = "normal",
|
|
4384
4710
|
className,
|
|
4711
|
+
style,
|
|
4385
4712
|
placeholder,
|
|
4386
4713
|
...props
|
|
4387
4714
|
}) {
|
|
4388
4715
|
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
4389
4716
|
"label",
|
|
4390
4717
|
{
|
|
4718
|
+
style,
|
|
4391
4719
|
className: cx(
|
|
4392
4720
|
"avl-input",
|
|
4393
4721
|
"avl-textarea",
|
|
@@ -4420,6 +4748,15 @@ function FloatingToolbar({
|
|
|
4420
4748
|
className,
|
|
4421
4749
|
...props
|
|
4422
4750
|
}) {
|
|
4751
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4752
|
+
checkName(
|
|
4753
|
+
props,
|
|
4754
|
+
"FloatingToolbar",
|
|
4755
|
+
'<FloatingToolbar aria-label="Formatting">...</FloatingToolbar>',
|
|
4756
|
+
"floating-toolbar.md",
|
|
4757
|
+
UNNAMED_GROUP
|
|
4758
|
+
);
|
|
4759
|
+
}
|
|
4423
4760
|
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4424
4761
|
import_toolbar.Toolbar.Root,
|
|
4425
4762
|
{
|
|
@@ -4466,7 +4803,7 @@ function FloatingToolbarSeparator({
|
|
|
4466
4803
|
}
|
|
4467
4804
|
|
|
4468
4805
|
// src/components/Tooltip/Tooltip.tsx
|
|
4469
|
-
var
|
|
4806
|
+
var import_react37 = require("react");
|
|
4470
4807
|
var import_tooltip2 = require("@base-ui/react/tooltip");
|
|
4471
4808
|
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
4472
4809
|
function Tooltip({
|
|
@@ -4481,7 +4818,7 @@ function Tooltip({
|
|
|
4481
4818
|
className,
|
|
4482
4819
|
...props
|
|
4483
4820
|
}) {
|
|
4484
|
-
const avl = (0,
|
|
4821
|
+
const avl = (0, import_react37.useContext)(AnvilContext);
|
|
4485
4822
|
if (process.env.NODE_ENV !== "production") {
|
|
4486
4823
|
checkRoot(avl !== null, "Tooltip");
|
|
4487
4824
|
checkProp(
|
|
@@ -4500,7 +4837,7 @@ function Tooltip({
|
|
|
4500
4837
|
'<Tooltip label="Delete">\n <IconButton icon="delete" aria-label="Delete" />\n</Tooltip>',
|
|
4501
4838
|
"tooltip.md"
|
|
4502
4839
|
);
|
|
4503
|
-
if (!(0,
|
|
4840
|
+
if (!(0, import_react37.isValidElement)(children))
|
|
4504
4841
|
devError(
|
|
4505
4842
|
"<Tooltip> needs exactly one element child (the trigger), not text or several elements.",
|
|
4506
4843
|
'<Tooltip label="Delete">\n <IconButton icon="delete" aria-label="Delete" />\n</Tooltip>\n// for plain text: <Tooltip label="..."><span tabIndex={0}>text</span></Tooltip>',
|
|
@@ -4541,6 +4878,15 @@ var import_use_render2 = require("@base-ui/react/use-render");
|
|
|
4541
4878
|
var import_merge_props2 = require("@base-ui/react/merge-props");
|
|
4542
4879
|
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
4543
4880
|
function NavigationBar({ className, ...props }) {
|
|
4881
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4882
|
+
checkName(
|
|
4883
|
+
props,
|
|
4884
|
+
"NavigationBar",
|
|
4885
|
+
'<NavigationBar aria-label="Main">...</NavigationBar>',
|
|
4886
|
+
"navigation-bar.md",
|
|
4887
|
+
UNNAMED_NAV
|
|
4888
|
+
);
|
|
4889
|
+
}
|
|
4544
4890
|
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("nav", { ...props, className: cx("avl-navigation-bar", className) });
|
|
4545
4891
|
}
|
|
4546
4892
|
function NavigationBarItem({
|
|
@@ -4570,11 +4916,11 @@ function NavigationBarItem({
|
|
|
4570
4916
|
}
|
|
4571
4917
|
|
|
4572
4918
|
// src/components/NavigationRail/NavigationRail.tsx
|
|
4573
|
-
var
|
|
4919
|
+
var import_react38 = require("react");
|
|
4574
4920
|
var import_use_render3 = require("@base-ui/react/use-render");
|
|
4575
4921
|
var import_merge_props3 = require("@base-ui/react/merge-props");
|
|
4576
4922
|
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
4577
|
-
var RailContext = (0,
|
|
4923
|
+
var RailContext = (0, import_react38.createContext)(null);
|
|
4578
4924
|
function NavigationRail({
|
|
4579
4925
|
expanded: expandedProp,
|
|
4580
4926
|
defaultExpanded = false,
|
|
@@ -4582,7 +4928,16 @@ function NavigationRail({
|
|
|
4582
4928
|
className,
|
|
4583
4929
|
...props
|
|
4584
4930
|
}) {
|
|
4585
|
-
|
|
4931
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4932
|
+
checkName(
|
|
4933
|
+
props,
|
|
4934
|
+
"NavigationRail",
|
|
4935
|
+
'<NavigationRail aria-label="Main">...</NavigationRail>',
|
|
4936
|
+
"navigation-rail.md",
|
|
4937
|
+
UNNAMED_NAV
|
|
4938
|
+
);
|
|
4939
|
+
}
|
|
4940
|
+
const [internal, setInternal] = (0, import_react38.useState)(defaultExpanded);
|
|
4586
4941
|
const expanded = expandedProp ?? internal;
|
|
4587
4942
|
const setExpanded = (next) => {
|
|
4588
4943
|
setInternal(next);
|
|
@@ -4602,7 +4957,7 @@ function NavigationRailToggle({
|
|
|
4602
4957
|
onClick,
|
|
4603
4958
|
...props
|
|
4604
4959
|
}) {
|
|
4605
|
-
const rail = (0,
|
|
4960
|
+
const rail = (0, import_react38.useContext)(RailContext);
|
|
4606
4961
|
if (process.env.NODE_ENV !== "production" && !rail) {
|
|
4607
4962
|
devError(
|
|
4608
4963
|
"<NavigationRailToggle> is rendered outside a <NavigationRail>, so it has nothing to expand.",
|
|
@@ -4661,6 +5016,15 @@ var import_use_render4 = require("@base-ui/react/use-render");
|
|
|
4661
5016
|
var import_merge_props4 = require("@base-ui/react/merge-props");
|
|
4662
5017
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
4663
5018
|
function NavigationList({ className, ...props }) {
|
|
5019
|
+
if (process.env.NODE_ENV !== "production") {
|
|
5020
|
+
checkName(
|
|
5021
|
+
props,
|
|
5022
|
+
"NavigationList",
|
|
5023
|
+
'<NavigationList aria-label="Settings">...</NavigationList>',
|
|
5024
|
+
"navigation-list.md",
|
|
5025
|
+
UNNAMED_NAV
|
|
5026
|
+
);
|
|
5027
|
+
}
|
|
4664
5028
|
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("nav", { ...props, className: cx("avl-navigation-list", className) });
|
|
4665
5029
|
}
|
|
4666
5030
|
function NavigationListItem({
|
|
@@ -4686,7 +5050,7 @@ function NavigationListItem({
|
|
|
4686
5050
|
}
|
|
4687
5051
|
|
|
4688
5052
|
// src/components/NavigationDrawer/NavigationDrawer.tsx
|
|
4689
|
-
var
|
|
5053
|
+
var import_react39 = require("react");
|
|
4690
5054
|
var import_drawer2 = require("@base-ui/react/drawer");
|
|
4691
5055
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
4692
5056
|
function NavigationDrawer(props) {
|
|
@@ -4716,7 +5080,7 @@ function NavigationDrawerPopup({
|
|
|
4716
5080
|
className,
|
|
4717
5081
|
...props
|
|
4718
5082
|
}) {
|
|
4719
|
-
const avl = (0,
|
|
5083
|
+
const avl = (0, import_react39.useContext)(AnvilContext);
|
|
4720
5084
|
if (process.env.NODE_ENV !== "production") {
|
|
4721
5085
|
checkRoot(avl !== null, "NavigationDrawerPopup");
|
|
4722
5086
|
}
|
|
@@ -5118,31 +5482,26 @@ var monochromeDarkTheme = {
|
|
|
5118
5482
|
};
|
|
5119
5483
|
|
|
5120
5484
|
// src/components/AnvilRoot/AnvilRoot.tsx
|
|
5121
|
-
var
|
|
5485
|
+
var import_react40 = require("react");
|
|
5122
5486
|
var import_toast2 = require("@base-ui/react/toast");
|
|
5123
5487
|
var import_tooltip4 = require("@base-ui/react/tooltip");
|
|
5124
5488
|
|
|
5125
5489
|
// src/themes/toCssVariables.ts
|
|
5126
5490
|
function themeToCssVariables(theme) {
|
|
5127
5491
|
const cssVars = {};
|
|
5128
|
-
const { surfaceVariant, onSurfaceVariant, ...rest } = theme;
|
|
5129
5492
|
const filled = {
|
|
5130
5493
|
inverseSurface: theme.onBackground,
|
|
5131
5494
|
inverseOnSurface: theme.background,
|
|
5132
5495
|
inversePrimary: `color-mix(in srgb, ${theme.primary} 55%, ${theme.background})`,
|
|
5133
5496
|
shadow: "rgb(0 0 0 / 0.3)",
|
|
5134
5497
|
scrim: "rgb(0 0 0 / 0.4)",
|
|
5135
|
-
...
|
|
5136
|
-
surface: rest.surface ?? surfaceVariant,
|
|
5137
|
-
onSurface: rest.onSurface ?? onSurfaceVariant
|
|
5498
|
+
...theme
|
|
5138
5499
|
};
|
|
5139
5500
|
for (const [key, value] of Object.entries(filled)) {
|
|
5140
5501
|
if (value === void 0) continue;
|
|
5141
5502
|
const kebabKey = key.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
5142
5503
|
cssVars[`--avl-color-${kebabKey}`] = value;
|
|
5143
5504
|
}
|
|
5144
|
-
cssVars["--avl-color-surface-variant"] = "var(--avl-color-surface)";
|
|
5145
|
-
cssVars["--avl-color-on-surface-variant"] = "var(--avl-color-on-surface)";
|
|
5146
5505
|
return cssVars;
|
|
5147
5506
|
}
|
|
5148
5507
|
|
|
@@ -5186,43 +5545,56 @@ function subscribeToOs(onChange) {
|
|
|
5186
5545
|
var getOsMode = () => matchMedia(darkQuery).matches ? "dark" : "light";
|
|
5187
5546
|
var declarations = (vars) => Object.entries(vars).map(([name, value]) => `${name}:${value};`).join("");
|
|
5188
5547
|
function AnvilRoot(props) {
|
|
5189
|
-
const
|
|
5190
|
-
|
|
5548
|
+
const {
|
|
5549
|
+
children,
|
|
5550
|
+
className,
|
|
5551
|
+
colorMode: colorModeProp,
|
|
5552
|
+
defaultColorMode,
|
|
5553
|
+
onColorModeChange,
|
|
5554
|
+
storageKey,
|
|
5555
|
+
lightTheme: lightThemeProp,
|
|
5556
|
+
darkTheme: darkThemeProp,
|
|
5557
|
+
tokens: tokensProp,
|
|
5558
|
+
ref,
|
|
5559
|
+
...divProps
|
|
5560
|
+
} = props;
|
|
5561
|
+
const [internalSetting, setInternalSetting] = (0, import_react40.useState)(
|
|
5562
|
+
defaultColorMode ?? "system"
|
|
5191
5563
|
);
|
|
5192
|
-
const setting =
|
|
5193
|
-
const osMode = (0,
|
|
5564
|
+
const setting = colorModeProp ?? internalSetting;
|
|
5565
|
+
const osMode = (0, import_react40.useSyncExternalStore)(
|
|
5194
5566
|
subscribeToOs,
|
|
5195
5567
|
getOsMode,
|
|
5196
5568
|
() => "light"
|
|
5197
5569
|
);
|
|
5198
5570
|
const colorMode = setting === "system" ? osMode : setting;
|
|
5199
|
-
const latestSetting = (0,
|
|
5571
|
+
const latestSetting = (0, import_react40.useRef)(setting);
|
|
5200
5572
|
latestSetting.current = setting;
|
|
5201
|
-
(0,
|
|
5202
|
-
if (!
|
|
5203
|
-
const stored = readStored(
|
|
5573
|
+
(0, import_react40.useLayoutEffect)(() => {
|
|
5574
|
+
if (!storageKey) return;
|
|
5575
|
+
const stored = readStored(storageKey);
|
|
5204
5576
|
if (stored) {
|
|
5205
5577
|
latestSetting.current = stored;
|
|
5206
5578
|
setInternalSetting(stored);
|
|
5207
5579
|
}
|
|
5208
|
-
}, [
|
|
5580
|
+
}, [storageKey]);
|
|
5209
5581
|
const setColorMode = (next) => {
|
|
5210
5582
|
const value = typeof next === "function" ? next(latestSetting.current) : next;
|
|
5211
5583
|
latestSetting.current = value;
|
|
5212
5584
|
setInternalSetting(value);
|
|
5213
|
-
|
|
5214
|
-
if (
|
|
5585
|
+
onColorModeChange?.(value);
|
|
5586
|
+
if (storageKey) {
|
|
5215
5587
|
try {
|
|
5216
|
-
localStorage.setItem(
|
|
5588
|
+
localStorage.setItem(storageKey, value);
|
|
5217
5589
|
} catch {
|
|
5218
5590
|
}
|
|
5219
5591
|
}
|
|
5220
5592
|
};
|
|
5221
|
-
const tokens = { ...baseDesignTokens, ...
|
|
5222
|
-
const lightTheme =
|
|
5223
|
-
const darkTheme =
|
|
5224
|
-
const rootRef = (0,
|
|
5225
|
-
(0,
|
|
5593
|
+
const tokens = { ...baseDesignTokens, ...tokensProp };
|
|
5594
|
+
const lightTheme = lightThemeProp || baseLightTheme;
|
|
5595
|
+
const darkTheme = darkThemeProp || baseDarkTheme;
|
|
5596
|
+
const rootRef = (0, import_react40.useRef)(null);
|
|
5597
|
+
(0, import_react40.useEffect)(() => {
|
|
5226
5598
|
if (process.env.NODE_ENV === "production") return;
|
|
5227
5599
|
const timer = setTimeout(() => {
|
|
5228
5600
|
const root2 = rootRef.current;
|
|
@@ -5237,12 +5609,12 @@ function AnvilRoot(props) {
|
|
|
5237
5609
|
}, 1e3);
|
|
5238
5610
|
return () => clearTimeout(timer);
|
|
5239
5611
|
}, []);
|
|
5240
|
-
const id = (0,
|
|
5612
|
+
const id = (0, import_react40.useId)();
|
|
5241
5613
|
const root = `[data-avl-root="${id}"]`;
|
|
5242
5614
|
const light = `color-scheme:light;${declarations(themeToCssVariables(lightTheme))}`;
|
|
5243
5615
|
const dark = `color-scheme:dark;${declarations(themeToCssVariables(darkTheme))}`;
|
|
5244
5616
|
const css = `${root}{${declarations(tokensToCssVariables(tokens))}${light}}${root}[data-color-mode="dark"]{${dark}}@media ${darkQuery}{${root}[data-color-mode="system"]{${dark}}}`;
|
|
5245
|
-
const restoreScript =
|
|
5617
|
+
const restoreScript = storageKey && colorModeProp === void 0 ? `try{var m=localStorage.getItem(${JSON.stringify(storageKey)});if(m==='light'||m==='dark'||m==='system')document.currentScript.parentElement.dataset.colorMode=m}catch(e){}` : void 0;
|
|
5246
5618
|
return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
5247
5619
|
AnvilContext,
|
|
5248
5620
|
{
|
|
@@ -5258,8 +5630,9 @@ function AnvilRoot(props) {
|
|
|
5258
5630
|
children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
5259
5631
|
"div",
|
|
5260
5632
|
{
|
|
5261
|
-
|
|
5262
|
-
|
|
5633
|
+
...divProps,
|
|
5634
|
+
ref: mergeRefs(rootRef, ref),
|
|
5635
|
+
className: cx("avl-root", className),
|
|
5263
5636
|
"data-avl-root": id,
|
|
5264
5637
|
"data-color-mode": setting,
|
|
5265
5638
|
suppressHydrationWarning: true,
|
|
@@ -5274,7 +5647,7 @@ function AnvilRoot(props) {
|
|
|
5274
5647
|
),
|
|
5275
5648
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("style", { children: css }),
|
|
5276
5649
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_tooltip4.Tooltip.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_toast2.Toast.Provider, { limit: 3, children: [
|
|
5277
|
-
|
|
5650
|
+
children,
|
|
5278
5651
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(SnackbarViewport, {})
|
|
5279
5652
|
] }) })
|
|
5280
5653
|
]
|