anvilui 0.2.0 → 0.3.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.
Files changed (45) hide show
  1. package/AGENTS.md +29 -29
  2. package/README.md +42 -89
  3. package/dist/components/Combobox/Combobox.d.ts +8 -2
  4. package/dist/components/DateInput/DateInput.d.ts +5 -3
  5. package/dist/components/IconButton/IconButton.d.ts +5 -3
  6. package/dist/components/Input/Input.d.ts +5 -3
  7. package/dist/components/PinInput/PinInput.d.ts +5 -3
  8. package/dist/components/Progress/Progress.d.ts +4 -1
  9. package/dist/components/RadioGroup/RadioGroup.d.ts +2 -2
  10. package/dist/components/Search/Search.d.ts +22 -6
  11. package/dist/components/Select/Select.d.ts +6 -2
  12. package/dist/components/Slider/Slider.d.ts +2 -1
  13. package/dist/components/SquigglyWave/SquigglyWave.d.ts +26 -4
  14. package/dist/components/Textarea/Textarea.d.ts +6 -3
  15. package/dist/components/TimePicker/TimePicker.d.ts +7 -5
  16. package/dist/components/Toggle/Toggle.d.ts +2 -1
  17. package/dist/components/ToggleGroup/ToggleGroup.d.ts +2 -2
  18. package/dist/index.cjs +302 -62
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.css +48 -25
  21. package/dist/index.css.map +1 -1
  22. package/dist/index.js +336 -88
  23. package/dist/index.js.map +1 -1
  24. package/dist/themes/types.d.ts +0 -4
  25. package/dist/utils.d.ts +4 -0
  26. package/docs/badge.md +41 -41
  27. package/docs/combobox.md +2 -1
  28. package/docs/composition.md +1 -1
  29. package/docs/date-input.md +4 -3
  30. package/docs/forms.md +1 -1
  31. package/docs/icon-button.md +3 -2
  32. package/docs/input.md +1 -0
  33. package/docs/morph.md +4 -1
  34. package/docs/pin-input.md +1 -1
  35. package/docs/progress.md +37 -37
  36. package/docs/radio-group.md +17 -0
  37. package/docs/search.md +7 -7
  38. package/docs/select.md +3 -2
  39. package/docs/slider.md +49 -49
  40. package/docs/textarea.md +1 -1
  41. package/docs/theming.md +2 -1
  42. package/docs/time-picker.md +3 -2
  43. package/docs/toggle-group.md +1 -1
  44. package/docs/toggle.md +2 -2
  45. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -163,6 +163,16 @@ function cx(...parts) {
163
163
  function withClass(base, className) {
164
164
  return (state) => cx(base, typeof className === "function" ? className(state) : className);
165
165
  }
166
+ function splitControlProps(props) {
167
+ const control = {};
168
+ const rest = {};
169
+ for (const [key, value] of Object.entries(props)) {
170
+ if (key.startsWith("aria-") || key.startsWith("data-"))
171
+ control[key] = value;
172
+ else rest[key] = value;
173
+ }
174
+ return { control, rest };
175
+ }
166
176
  function mergeRefs(...refs) {
167
177
  return (value) => {
168
178
  for (const ref of refs) {
@@ -987,6 +997,7 @@ function IconButton({
987
997
  icon,
988
998
  color,
989
999
  fillType,
1000
+ size = "normal",
990
1001
  className,
991
1002
  ...props
992
1003
  }) {
@@ -1019,7 +1030,7 @@ function IconButton({
1019
1030
  {
1020
1031
  ...props,
1021
1032
  className: withClass(
1022
- `avl-icon-button ${colorClass(color, fillType)}`,
1033
+ `avl-icon-button ${colorClass(color, fillType)} avl-icon-button-size-${size}`,
1023
1034
  className
1024
1035
  ),
1025
1036
  children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: icon })
@@ -1928,47 +1939,146 @@ var import_react18 = require("react");
1928
1939
  var import_jsx_runtime19 = require("react/jsx-runtime");
1929
1940
  var WAVE_LENGTH = 40;
1930
1941
  var WAVE_AMPLITUDE = 3;
1931
- var WAVE_MIDDLE = 6;
1932
- var STROKE_CAP = 2;
1942
+ var WAVE_STROKE = 4;
1933
1943
  var WAVE_PERIOD = 1500;
1934
- function wavePath(from, to, phase) {
1935
- const start = from + STROKE_CAP;
1936
- const end = to - STROKE_CAP;
1944
+ var K = 2 * Math.PI / WAVE_LENGTH;
1945
+ var waveY = (x, phase, shape) => (
1946
+ // + phase: the ripple travels from the leading end back to the start
1947
+ shape.middle + shape.amplitude * Math.sin(K * x + phase)
1948
+ );
1949
+ var waveSlope = (x, phase, shape) => shape.amplitude * K * Math.cos(K * x + phase);
1950
+ function wavePath(from, to, phase, shape) {
1951
+ const start = from + shape.cap;
1952
+ const end = to - shape.cap;
1937
1953
  if (end < start) return "";
1938
- const y = (x) => WAVE_MIDDLE + // + phase: the ripple travels from the leading end back to the start
1939
- WAVE_AMPLITUDE * Math.sin(2 * Math.PI * x / WAVE_LENGTH + phase);
1954
+ const y = (x) => waveY(x, phase, shape);
1940
1955
  let d = `M${start} ${y(start)}`;
1941
1956
  for (let x = start + 2; x < end; x += 2) d += `L${x} ${y(x)}`;
1942
1957
  return d + `L${end} ${y(end)}`;
1943
1958
  }
1944
- function linePath(from, to) {
1945
- const start = from + STROKE_CAP;
1946
- const end = to - STROKE_CAP;
1947
- return end < start ? "" : `M${start} ${WAVE_MIDDLE}L${end} ${WAVE_MIDDLE}`;
1959
+ function linePath(from, to, shape) {
1960
+ const start = from + shape.cap;
1961
+ const end = to - shape.cap;
1962
+ return end < start ? "" : `M${start} ${shape.middle}L${end} ${shape.middle}`;
1963
+ }
1964
+ function smoothEasing(style) {
1965
+ const match = style.getPropertyValue("--avl-ease-smooth").match(/cubic-bezier\(([^)]+)\)/);
1966
+ const parts = match?.[1].split(",").map(Number);
1967
+ const [x1, y1, x2, y2] = parts?.length === 4 && parts.every((n) => !Number.isNaN(n)) ? parts : [0.2, 0, 0, 1];
1968
+ const bezier = (a, b, t) => 3 * a * t * (1 - t) ** 2 + 3 * b * t ** 2 * (1 - t) + t ** 3;
1969
+ return (x) => {
1970
+ if (x <= 0 || x >= 1) return x;
1971
+ let lo = 0;
1972
+ let hi = 1;
1973
+ for (let i = 0; i < 20; i++) {
1974
+ const mid = (lo + hi) / 2;
1975
+ if (bezier(x1, x2, mid) < x) lo = mid;
1976
+ else hi = mid;
1977
+ }
1978
+ return bezier(y1, y2, (lo + hi) / 2);
1979
+ };
1980
+ }
1981
+ function cssNumber(style, name, fallback) {
1982
+ const raw = style.getPropertyValue(name).trim();
1983
+ const n = parseFloat(raw);
1984
+ if (Number.isNaN(n)) return fallback;
1985
+ return raw.endsWith("ms") ? n : raw.endsWith("s") ? n * 1e3 : n;
1986
+ }
1987
+ function cssLength(el, name, fallback) {
1988
+ const host = el.parentElement;
1989
+ if (!host || !getComputedStyle(el).getPropertyValue(name).trim())
1990
+ return fallback;
1991
+ const probe = document.createElement("div");
1992
+ probe.style.cssText = `position:absolute;visibility:hidden;width:var(${name})`;
1993
+ host.append(probe);
1994
+ const px = probe.getBoundingClientRect().width;
1995
+ probe.remove();
1996
+ return px;
1997
+ }
1998
+ function capPath(x, y, slope, dir, half, length, radius) {
1999
+ const norm = Math.hypot(1, slope);
2000
+ const tx = dir / norm;
2001
+ const ty = dir * slope / norm;
2002
+ const p = (u, v) => `${x + u * tx - v * ty} ${y + u * ty + v * tx}`;
2003
+ const r = Math.max(0, Math.min(radius, length, half));
2004
+ 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`;
2005
+ }
2006
+ function useWaveMorph(squiggly) {
2007
+ const [previous, setPrevious] = (0, import_react18.useState)(squiggly);
2008
+ const [leaving, setLeaving] = (0, import_react18.useState)(false);
2009
+ const [changed, setChanged] = (0, import_react18.useState)(false);
2010
+ if (squiggly !== previous) {
2011
+ setPrevious(squiggly);
2012
+ setLeaving(!squiggly);
2013
+ setChanged(true);
2014
+ }
2015
+ return {
2016
+ show: squiggly || leaving,
2017
+ wave: {
2018
+ flat: !squiggly,
2019
+ startFlat: changed,
2020
+ onFlat: () => setLeaving(false)
2021
+ }
2022
+ };
1948
2023
  }
1949
2024
  function SquigglyWave(props) {
1950
2025
  const svgRef = (0, import_react18.useRef)(null);
1951
2026
  const waveRef = (0, import_react18.useRef)(null);
1952
2027
  const restRef = (0, import_react18.useRef)(null);
1953
- const dotRef = (0, import_react18.useRef)(null);
2028
+ const waveCapsRef = (0, import_react18.useRef)(null);
2029
+ const restCapsRef = (0, import_react18.useRef)(null);
1954
2030
  const span = (0, import_react18.useRef)(props.span);
1955
2031
  span.current = props.span;
2032
+ const flat = (0, import_react18.useRef)(props.flat ?? false);
2033
+ flat.current = props.flat ?? false;
2034
+ const onFlat = (0, import_react18.useRef)(props.onFlat);
2035
+ onFlat.current = props.onFlat;
2036
+ const startFlat = (0, import_react18.useRef)(props.startFlat ?? false);
1956
2037
  const still = props.still ?? false;
1957
2038
  const vertical = props.vertical ?? false;
1958
2039
  (0, import_react18.useEffect)(() => {
1959
2040
  const svg = svgRef.current;
1960
2041
  const wave = waveRef.current;
1961
2042
  const rest = restRef.current;
1962
- const dot = dotRef.current;
1963
- if (!svg || !wave || !rest || !dot) return;
2043
+ const waveCaps = waveCapsRef.current;
2044
+ const restCaps = restCapsRef.current;
2045
+ if (!svg || !wave || !rest || !waveCaps || !restCaps) return;
1964
2046
  const reduced = still || matchMedia("(prefers-reduced-motion: reduce)").matches;
1965
- const gap = parseFloat(
1966
- getComputedStyle(svg).getPropertyValue("--avl-wave-gap")
1967
- ) || 0;
2047
+ const style = getComputedStyle(svg);
2048
+ const gap = cssLength(svg, "--avl-wave-gap", 0);
2049
+ const flatStroke = cssLength(svg, "--avl-wave-flat-stroke", WAVE_STROKE);
2050
+ const flatRadius = cssLength(svg, "--avl-wave-flat-radius", -1);
2051
+ const flatRestRadius = cssLength(svg, "--avl-wave-flat-rest-radius", -1);
2052
+ const shapedCaps = flatRadius >= 0 || flatRestRadius >= 0;
2053
+ const linecap = shapedCaps ? "butt" : "";
2054
+ wave.style.strokeLinecap = linecap;
2055
+ rest.style.strokeLinecap = linecap;
2056
+ const duration = cssNumber(style, "--avl-ease-length-slow", 300);
2057
+ const ease = smoothEasing(style);
1968
2058
  let current = null;
1969
2059
  let frame = 0;
2060
+ let flatness = startFlat.current ? 1 : 0;
2061
+ let notified = false;
2062
+ let last = null;
1970
2063
  const draw = (now) => {
2064
+ const target = flat.current ? 1 : 0;
2065
+ const step = reduced || last === null || duration <= 0 ? 1 : (now - last) / duration;
2066
+ if (last === null && !reduced) {
2067
+ last = now;
2068
+ } else {
2069
+ last = now;
2070
+ flatness = target > flatness ? Math.min(target, flatness + step) : Math.max(target, flatness - step);
2071
+ }
2072
+ if (flatness < 1) notified = false;
2073
+ const eased = target === 1 ? ease(flatness) : 1 - ease(1 - flatness);
2074
+ const stroke = WAVE_STROKE + (flatStroke - WAVE_STROKE) * eased;
2075
+ svg.style.setProperty("--avl-wave-stroke", `${stroke}px`);
1971
2076
  const width = vertical ? svg.clientHeight : svg.clientWidth;
2077
+ const shape = {
2078
+ middle: (vertical ? svg.clientWidth : svg.clientHeight) / 2,
2079
+ amplitude: WAVE_AMPLITUDE * (1 - eased),
2080
+ cap: stroke / 2
2081
+ };
1972
2082
  const next = span.current(width, gap, svg, now);
1973
2083
  if (!current || next.snap || reduced) {
1974
2084
  current = { from: next.from, to: next.to };
@@ -1977,17 +2087,61 @@ function SquigglyWave(props) {
1977
2087
  current.to += (next.to - current.to) * 0.15;
1978
2088
  }
1979
2089
  const phase = reduced ? 0 : now / WAVE_PERIOD * 2 * Math.PI;
1980
- wave.setAttribute("d", wavePath(current.from, current.to, phase));
2090
+ wave.setAttribute(
2091
+ "d",
2092
+ wavePath(current.from, current.to, phase, shape)
2093
+ );
1981
2094
  rest.setAttribute(
1982
2095
  "d",
1983
2096
  (next.rest ?? []).map(
1984
- ([a, b]) => next.restWave ? wavePath(a, b, phase) : linePath(a, b)
2097
+ ([a, b]) => next.restWave ? wavePath(a, b, phase, shape) : linePath(a, b, shape)
1985
2098
  ).join("")
1986
2099
  );
1987
- dot.setAttribute(
1988
- "d",
1989
- next.dot ? linePath(width - 2 * STROKE_CAP, width) : ""
1990
- );
2100
+ if (shapedCaps) {
2101
+ const half = stroke / 2;
2102
+ const caps = (a, b, wavy, insideRadius) => {
2103
+ if (b - a <= 0) return "";
2104
+ const length = Math.min(half, (b - a) / 2);
2105
+ const radius = (inside) => inside && insideRadius >= 0 ? half + (insideRadius - half) * eased : half;
2106
+ const at = (x) => wavy ? [
2107
+ waveY(x, phase, shape),
2108
+ waveSlope(x, phase, shape)
2109
+ ] : [shape.middle, 0];
2110
+ const [y0, s0] = at(a + length);
2111
+ const [y1, s1] = at(b - length);
2112
+ return capPath(
2113
+ a + length,
2114
+ y0,
2115
+ s0,
2116
+ -1,
2117
+ half,
2118
+ length,
2119
+ radius(a > 0.5)
2120
+ ) + capPath(
2121
+ b - length,
2122
+ y1,
2123
+ s1,
2124
+ 1,
2125
+ half,
2126
+ length,
2127
+ radius(b < width - 0.5)
2128
+ );
2129
+ };
2130
+ waveCaps.setAttribute(
2131
+ "d",
2132
+ caps(current.from, current.to, true, flatRadius)
2133
+ );
2134
+ restCaps.setAttribute(
2135
+ "d",
2136
+ (next.rest ?? []).map(
2137
+ ([a, b]) => caps(a, b, next.restWave ?? false, flatRestRadius)
2138
+ ).join("")
2139
+ );
2140
+ }
2141
+ if (flatness === 1 && target === 1 && !notified) {
2142
+ notified = true;
2143
+ onFlat.current?.();
2144
+ }
1991
2145
  if (!still) frame = requestAnimationFrame(draw);
1992
2146
  };
1993
2147
  if (still) {
@@ -2000,8 +2154,15 @@ function SquigglyWave(props) {
2000
2154
  }, [still, vertical]);
2001
2155
  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
2156
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { ref: restRef, className: "avl-squiggly-wave-rest" }),
2157
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2158
+ "path",
2159
+ {
2160
+ ref: restCapsRef,
2161
+ className: "avl-squiggly-wave-cap avl-squiggly-wave-rest"
2162
+ }
2163
+ ),
2003
2164
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { ref: waveRef }),
2004
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { ref: dotRef })
2165
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { ref: waveCapsRef, className: "avl-squiggly-wave-cap" })
2005
2166
  ] }) });
2006
2167
  }
2007
2168
 
@@ -2292,6 +2453,7 @@ function Input({
2292
2453
  label,
2293
2454
  size = "normal",
2294
2455
  className,
2456
+ style,
2295
2457
  placeholder,
2296
2458
  ...props
2297
2459
  }) {
@@ -2302,6 +2464,7 @@ function Input({
2302
2464
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
2303
2465
  "label",
2304
2466
  {
2467
+ style,
2305
2468
  className: cx(
2306
2469
  "avl-input",
2307
2470
  `avl-input-size-${size}`,
@@ -2862,6 +3025,8 @@ function Progress({
2862
3025
  );
2863
3026
  }
2864
3027
  const { value, min = 0, max = 100 } = props;
3028
+ const wavy = squiggly && type === "linear";
3029
+ const morph2 = useWaveMorph(wavy);
2865
3030
  const fraction = value == null ? 0 : Math.min(1, Math.max(0, (value - min) / (max - min)));
2866
3031
  const pct = fraction * 100;
2867
3032
  const ring = type === "inline" ? INLINE_RING : RING;
@@ -2876,7 +3041,9 @@ function Progress({
2876
3041
  `avl-progress-${type}`,
2877
3042
  // Inline is a smaller ring, so it shares the circular styles
2878
3043
  type === "inline" && "avl-progress-circular",
2879
- squiggly && type === "linear" && "avl-progress-squiggly"
3044
+ wavy && "avl-progress-squiggly",
3045
+ // Also while flattening into the plain bar
3046
+ morph2.show && "avl-progress-wave"
2880
3047
  ),
2881
3048
  className
2882
3049
  ),
@@ -2887,9 +3054,10 @@ function Progress({
2887
3054
  children: [
2888
3055
  label != null && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_progress.Progress.Label, { className: "avl-progress-label", children: label }),
2889
3056
  type === "linear" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_progress.Progress.Track, { className: "avl-progress-track", children: [
2890
- squiggly ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3057
+ morph2.show ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2891
3058
  SquigglyWave,
2892
3059
  {
3060
+ ...morph2.wave,
2893
3061
  span: (width, gap, _svg, now) => value == null ? loadingSpan(width, gap, now) : (
2894
3062
  // Fill up to the value; .avl-progress-rest
2895
3063
  // draws the track one gap after it
@@ -3145,9 +3313,12 @@ function Select({
3145
3313
  placeholder,
3146
3314
  size = "normal",
3147
3315
  className,
3316
+ style,
3317
+ ref,
3148
3318
  children,
3149
- ...props
3319
+ ...allProps
3150
3320
  }) {
3321
+ const { control, rest: props } = splitControlProps(allProps);
3151
3322
  const avl = (0, import_react29.useContext)(AnvilContext);
3152
3323
  if (process.env.NODE_ENV !== "production") {
3153
3324
  checkRoot(avl !== null, "Select");
@@ -3156,6 +3327,7 @@ function Select({
3156
3327
  /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
3157
3328
  "div",
3158
3329
  {
3330
+ style,
3159
3331
  className: cx(
3160
3332
  "avl-input",
3161
3333
  "avl-select",
@@ -3164,16 +3336,24 @@ function Select({
3164
3336
  className
3165
3337
  ),
3166
3338
  children: [
3167
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_select.Select.Trigger, { className: "avl-input-field avl-select-trigger", children: [
3168
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3169
- import_select.Select.Value,
3170
- {
3171
- className: "avl-select-value",
3172
- placeholder
3173
- }
3174
- ),
3175
- /* @__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" }) })
3176
- ] }),
3339
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
3340
+ import_select.Select.Trigger,
3341
+ {
3342
+ ...control,
3343
+ ref,
3344
+ className: "avl-input-field avl-select-trigger",
3345
+ children: [
3346
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3347
+ import_select.Select.Value,
3348
+ {
3349
+ className: "avl-select-value",
3350
+ placeholder
3351
+ }
3352
+ ),
3353
+ /* @__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" }) })
3354
+ ]
3355
+ }
3356
+ ),
3177
3357
  label != null && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_select.Select.Label, { className: "avl-input-label", children: label }),
3178
3358
  /* @__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
3359
  ]
@@ -3230,8 +3410,11 @@ function TimePicker({
3230
3410
  defaultOpen,
3231
3411
  onOpenChange,
3232
3412
  className,
3233
- ...props
3413
+ ref,
3414
+ id,
3415
+ ...allProps
3234
3416
  }) {
3417
+ const { control, rest: props } = splitControlProps(allProps);
3235
3418
  const [internal, setInternal] = (0, import_react30.useState)(defaultValue);
3236
3419
  const value = valueProp !== void 0 ? valueProp : internal;
3237
3420
  const time = parseTime(value);
@@ -3239,7 +3422,7 @@ function TimePicker({
3239
3422
  const labelId = (0, import_react30.useId)();
3240
3423
  const valueId = (0, import_react30.useId)();
3241
3424
  const setTime = (t) => {
3242
- const next = `${pad2(t.h)}:${pad2(t.m)}`;
3425
+ const next = t && `${pad2(t.h)}:${pad2(t.m)}`;
3243
3426
  setInternal(next);
3244
3427
  onValueChange?.(next);
3245
3428
  };
@@ -3271,6 +3454,9 @@ function TimePicker({
3271
3454
  /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
3272
3455
  PopoverTrigger,
3273
3456
  {
3457
+ ...control,
3458
+ ref,
3459
+ id,
3274
3460
  disabled,
3275
3461
  className: "avl-input-field avl-select-trigger",
3276
3462
  "data-placeholder": time ? void 0 : "",
@@ -3293,7 +3479,8 @@ function TimePicker({
3293
3479
  type,
3294
3480
  time,
3295
3481
  cycle,
3296
- onChange: setTime
3482
+ onChange: setTime,
3483
+ onClear: () => setTime(null)
3297
3484
  }
3298
3485
  ) })
3299
3486
  ]
@@ -3301,7 +3488,7 @@ function TimePicker({
3301
3488
  );
3302
3489
  }
3303
3490
  function TimePanel(props) {
3304
- const { type, time, cycle, onChange } = props;
3491
+ const { type, time, cycle, onChange, onClear } = props;
3305
3492
  const [mode, setMode] = (0, import_react30.useState)("hour");
3306
3493
  const pm = time ? time.h >= 12 : false;
3307
3494
  const hourText = time ? pad2(displayHour(time.h, cycle)) : "--";
@@ -3390,7 +3577,15 @@ function TimePanel(props) {
3390
3577
  onChange,
3391
3578
  onHourDone: () => setMode("minute")
3392
3579
  }
3393
- )
3580
+ ),
3581
+ time && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "avl-time-picker-actions", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3582
+ PopoverClose,
3583
+ {
3584
+ render: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Button, { fillType: "text", size: "small" }),
3585
+ onClick: onClear,
3586
+ children: "Clear"
3587
+ }
3588
+ ) })
3394
3589
  ] });
3395
3590
  }
3396
3591
  function SpinInput(props) {
@@ -3621,6 +3816,8 @@ function DateInput({
3621
3816
  id,
3622
3817
  onBlur,
3623
3818
  className,
3819
+ style,
3820
+ ref,
3624
3821
  ...props
3625
3822
  }) {
3626
3823
  const [internal, setInternal] = (0, import_react31.useState)(defaultValue);
@@ -3632,6 +3829,20 @@ function DateInput({
3632
3829
  const popupRef = (0, import_react31.useRef)(null);
3633
3830
  const generatedId = (0, import_react31.useId)();
3634
3831
  const inputId = id ?? generatedId;
3832
+ const inputRef = (0, import_react31.useRef)(null);
3833
+ const iso = (0, import_react31.useRef)("");
3834
+ iso.current = date ? toIso(date) : "";
3835
+ (0, import_react31.useEffect)(() => {
3836
+ const form = inputRef.current?.form;
3837
+ if (!form) return;
3838
+ const onFormData = (event) => {
3839
+ const input = inputRef.current;
3840
+ if (input?.name && !input.disabled)
3841
+ event.formData.set(input.name, iso.current);
3842
+ };
3843
+ form.addEventListener("formdata", onFormData);
3844
+ return () => form.removeEventListener("formdata", onFormData);
3845
+ }, []);
3635
3846
  const fmt = numericFormat();
3636
3847
  const order = fieldOrder(fmt);
3637
3848
  const invalid = draft != null && draft.trim() !== "" && !parseTyped(draft, order);
@@ -3645,6 +3856,7 @@ function DateInput({
3645
3856
  "div",
3646
3857
  {
3647
3858
  ref: fieldRef,
3859
+ style,
3648
3860
  className: cx(
3649
3861
  "avl-input",
3650
3862
  "avl-date-input",
@@ -3657,6 +3869,7 @@ function DateInput({
3657
3869
  import_input5.Input,
3658
3870
  {
3659
3871
  ...props,
3872
+ ref: mergeRefs(inputRef, ref),
3660
3873
  id: inputId,
3661
3874
  disabled,
3662
3875
  className: "avl-input-field",
@@ -3714,8 +3927,8 @@ function DateInput({
3714
3927
  Calendar,
3715
3928
  {
3716
3929
  value: date && toIso(date),
3717
- onValueChange: (iso) => {
3718
- commit(fromIso(iso));
3930
+ onValueChange: (iso2) => {
3931
+ commit(fromIso(iso2));
3719
3932
  setDraft(null);
3720
3933
  setOpen(false);
3721
3934
  }
@@ -3737,8 +3950,12 @@ function Combobox({
3737
3950
  empty,
3738
3951
  size = "normal",
3739
3952
  className,
3740
- ...props
3953
+ style,
3954
+ ref,
3955
+ id,
3956
+ ...allProps
3741
3957
  }) {
3958
+ const { control, rest: props } = splitControlProps(allProps);
3742
3959
  const avl = (0, import_react32.useContext)(AnvilContext);
3743
3960
  if (process.env.NODE_ENV !== "production") {
3744
3961
  checkRoot(avl !== null, "Combobox");
@@ -3749,12 +3966,14 @@ function Combobox({
3749
3966
  "combobox.md"
3750
3967
  );
3751
3968
  }
3752
- const inputId = (0, import_react32.useId)();
3969
+ const generatedId = (0, import_react32.useId)();
3970
+ const inputId = id ?? generatedId;
3753
3971
  const labelId = (0, import_react32.useId)();
3754
3972
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_combobox.Combobox.Root, { ...props, children: [
3755
3973
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
3756
3974
  import_combobox.Combobox.InputGroup,
3757
3975
  {
3976
+ style,
3758
3977
  className: cx(
3759
3978
  "avl-input",
3760
3979
  "avl-combobox",
@@ -3766,6 +3985,8 @@ function Combobox({
3766
3985
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3767
3986
  import_combobox.Combobox.Input,
3768
3987
  {
3988
+ ...control,
3989
+ ref,
3769
3990
  id: inputId,
3770
3991
  className: "avl-input-field",
3771
3992
  placeholder: placeholder ?? " "
@@ -3835,6 +4056,7 @@ function PinInput({
3835
4056
  size = "normal",
3836
4057
  slotLabel = defaultSlotLabel,
3837
4058
  className,
4059
+ style,
3838
4060
  id,
3839
4061
  length,
3840
4062
  ...props
@@ -3845,6 +4067,7 @@ function PinInput({
3845
4067
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
3846
4068
  "div",
3847
4069
  {
4070
+ style,
3848
4071
  className: cx(
3849
4072
  "avl-pin-input",
3850
4073
  `avl-pin-input-size-${size}`,
@@ -3917,7 +4140,7 @@ function Toggle2({
3917
4140
  ...props,
3918
4141
  className: (state) => cx(
3919
4142
  "avl-toggle",
3920
- icon ? "avl-icon-button" : `avl-button avl-button-size-${size}`,
4143
+ icon ? `avl-icon-button avl-icon-button-size-${size}` : `avl-button avl-button-size-${size}`,
3921
4144
  state.pressed ? colorClass(color, "filled") : colorClass("container", fillType),
3922
4145
  typeof className === "function" ? className(state) : className
3923
4146
  ),
@@ -3939,11 +4162,17 @@ function Search({
3939
4162
  placeholder,
3940
4163
  "aria-label": ariaLabel,
3941
4164
  empty,
4165
+ color = "surface",
3942
4166
  clearLabel = "Clear",
3943
4167
  className,
3944
- ...props
4168
+ style,
4169
+ ref,
4170
+ id,
4171
+ ...allProps
3945
4172
  }) {
4173
+ const { control, rest: props } = splitControlProps(allProps);
3946
4174
  const avl = (0, import_react34.useContext)(AnvilContext);
4175
+ const suggests = children !== void 0;
3947
4176
  if (process.env.NODE_ENV !== "production") {
3948
4177
  checkRoot(avl !== null, "Search");
3949
4178
  checkName(
@@ -3952,23 +4181,37 @@ function Search({
3952
4181
  '<Search aria-label="Search mail" items={items}>{(item) => ...}</Search>',
3953
4182
  "search.md"
3954
4183
  );
3955
- if (typeof children !== "function")
4184
+ if (children !== void 0 && typeof children !== "function")
3956
4185
  devError(
3957
4186
  "<Search> children must be a function that renders one suggestion, plus an `items` array to filter.",
3958
4187
  '<Search aria-label="Search" items={items}>\n {(item: string) => <SearchItem key={item} value={item}>{item}</SearchItem>}\n</Search>',
3959
4188
  "search.md"
3960
4189
  );
4190
+ if (children === void 0 && props.items?.length)
4191
+ devError(
4192
+ "<Search> has `items` but no children, so the suggestions never show.",
4193
+ '<Search aria-label="Search" items={items}>\n {(item: string) => <SearchItem key={item} value={item}>{item}</SearchItem>}\n</Search>',
4194
+ "search.md"
4195
+ );
3961
4196
  }
3962
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_autocomplete.Autocomplete.Root, { ...props, children: [
4197
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_autocomplete.Autocomplete.Root, { ...props, ...!suggests && { open: false }, children: [
3963
4198
  /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
3964
4199
  import_autocomplete.Autocomplete.InputGroup,
3965
4200
  {
3966
- className: cx("avl-search", className),
4201
+ style,
4202
+ className: cx(
4203
+ "avl-search",
4204
+ colorClass(color, "filled"),
4205
+ className
4206
+ ),
3967
4207
  children: [
3968
4208
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { name: "search" }),
3969
4209
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
3970
4210
  import_autocomplete.Autocomplete.Input,
3971
4211
  {
4212
+ ...control,
4213
+ ref,
4214
+ id,
3972
4215
  className: "avl-search-input",
3973
4216
  placeholder,
3974
4217
  "aria-label": ariaLabel
@@ -3982,7 +4225,7 @@ function Search({
3982
4225
  {
3983
4226
  icon: "close",
3984
4227
  fillType: "text",
3985
- color: "container",
4228
+ color,
3986
4229
  "aria-label": clearLabel
3987
4230
  }
3988
4231
  )
@@ -3991,7 +4234,7 @@ function Search({
3991
4234
  ]
3992
4235
  }
3993
4236
  ),
3994
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_autocomplete.Autocomplete.Portal, { container: avl?.rootRef, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4237
+ suggests && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_autocomplete.Autocomplete.Portal, { container: avl?.rootRef, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
3995
4238
  import_autocomplete.Autocomplete.Positioner,
3996
4239
  {
3997
4240
  className: "avl-menu-positioner",
@@ -4068,6 +4311,7 @@ function Slider({
4068
4311
  const initial = props.value ?? props.defaultValue;
4069
4312
  const thumbCount = Array.isArray(initial) ? initial.length : 1;
4070
4313
  const wavy = squiggly && props.orientation !== "vertical";
4314
+ const morph2 = useWaveMorph(wavy);
4071
4315
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
4072
4316
  import_slider.Slider.Root,
4073
4317
  {
@@ -4083,7 +4327,7 @@ function Slider({
4083
4327
  children: [
4084
4328
  label != null && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_slider.Slider.Label, { className: "avl-slider-label", children: label }),
4085
4329
  /* @__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
- wavy ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(SquigglyWave, { span: handleSpan }) : (
4330
+ morph2.show ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(SquigglyWave, { span: handleSpan, ...morph2.wave }) : (
4087
4331
  // Clips the track pieces to the rounded track, without
4088
4332
  // also clipping the handles, which are taller
4089
4333
  /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "avl-slider-rail", children: [
@@ -4133,7 +4377,6 @@ function handleSpan(width, gap, svg) {
4133
4377
  [0, first - gap],
4134
4378
  [last + gap, width]
4135
4379
  ] : [[last + gap, width]],
4136
- dot: last + gap < width - gap,
4137
4380
  snap: true
4138
4381
  };
4139
4382
  }
@@ -4382,12 +4625,14 @@ function Textarea({
4382
4625
  label,
4383
4626
  size = "normal",
4384
4627
  className,
4628
+ style,
4385
4629
  placeholder,
4386
4630
  ...props
4387
4631
  }) {
4388
4632
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
4389
4633
  "label",
4390
4634
  {
4635
+ style,
4391
4636
  className: cx(
4392
4637
  "avl-input",
4393
4638
  "avl-textarea",
@@ -5125,24 +5370,19 @@ var import_tooltip4 = require("@base-ui/react/tooltip");
5125
5370
  // src/themes/toCssVariables.ts
5126
5371
  function themeToCssVariables(theme) {
5127
5372
  const cssVars = {};
5128
- const { surfaceVariant, onSurfaceVariant, ...rest } = theme;
5129
5373
  const filled = {
5130
5374
  inverseSurface: theme.onBackground,
5131
5375
  inverseOnSurface: theme.background,
5132
5376
  inversePrimary: `color-mix(in srgb, ${theme.primary} 55%, ${theme.background})`,
5133
5377
  shadow: "rgb(0 0 0 / 0.3)",
5134
5378
  scrim: "rgb(0 0 0 / 0.4)",
5135
- ...rest,
5136
- surface: rest.surface ?? surfaceVariant,
5137
- onSurface: rest.onSurface ?? onSurfaceVariant
5379
+ ...theme
5138
5380
  };
5139
5381
  for (const [key, value] of Object.entries(filled)) {
5140
5382
  if (value === void 0) continue;
5141
5383
  const kebabKey = key.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
5142
5384
  cssVars[`--avl-color-${kebabKey}`] = value;
5143
5385
  }
5144
- cssVars["--avl-color-surface-variant"] = "var(--avl-color-surface)";
5145
- cssVars["--avl-color-on-surface-variant"] = "var(--avl-color-on-surface)";
5146
5386
  return cssVars;
5147
5387
  }
5148
5388