anvilui 0.3.0 → 0.4.1

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/dist/index.js CHANGED
@@ -10,7 +10,10 @@ function cx(...parts) {
10
10
  return parts.filter(Boolean).join(" ");
11
11
  }
12
12
  function withClass(base, className) {
13
- return (state) => cx(base, typeof className === "function" ? className(state) : className);
13
+ return (state) => cx(
14
+ typeof base === "function" ? base(state) : base,
15
+ typeof className === "function" ? className(state) : className
16
+ );
14
17
  }
15
18
  function splitControlProps(props) {
16
19
  const control = {};
@@ -177,13 +180,15 @@ import 'anvilui/styles.css'
177
180
  "setup.md"
178
181
  );
179
182
  }
180
- function checkName(props, component, example, doc) {
183
+ var NO_TEXT = "It shows no text, so screen readers need an `aria-label`.";
184
+ var UNNAMED_GROUP = "Screen readers announce the group without saying what it's for: give it an `aria-label`.";
185
+ var UNNAMED_NAV = 'Screen readers list it as just "navigation": give it an `aria-label` to tell it apart from other navigation.';
186
+ function inNamedFieldset(el) {
187
+ return !!el?.closest("fieldset")?.querySelector(":scope > legend");
188
+ }
189
+ function checkName(props, component, example, doc, reason = NO_TEXT) {
181
190
  if (props["aria-label"] || props["aria-labelledby"]) return;
182
- devError(
183
- `<${component}> has no accessible name. It shows no text, so screen readers need an \`aria-label\`.`,
184
- example,
185
- doc
186
- );
191
+ devError(`<${component}> has no accessible name. ${reason}`, example, doc);
187
192
  }
188
193
 
189
194
  // src/components/Typography/Typography.tsx
@@ -319,12 +324,13 @@ function Avatar({
319
324
  const groupSize = useContext3(AvatarGroupContext);
320
325
  const size = sizeProp ?? groupSize ?? "normal";
321
326
  const letters = name ? initials(name) : "";
327
+ const named = !!(name || props["aria-label"] || props["aria-labelledby"]);
322
328
  return /* @__PURE__ */ jsxs3(
323
329
  BaseAvatar.Root,
324
330
  {
325
- role: name ? "img" : void 0,
331
+ role: named ? "img" : void 0,
326
332
  "aria-label": name,
327
- "aria-hidden": name ? void 0 : true,
333
+ "aria-hidden": named ? void 0 : true,
328
334
  ...props,
329
335
  className: withClass(
330
336
  cx(
@@ -368,6 +374,15 @@ function AvatarGroup({
368
374
  children,
369
375
  ...props
370
376
  }) {
377
+ if (process.env.NODE_ENV !== "production") {
378
+ checkName(
379
+ props,
380
+ "AvatarGroup",
381
+ '<AvatarGroup aria-label="Project members">...</AvatarGroup>',
382
+ "avatar-group.md",
383
+ UNNAMED_GROUP
384
+ );
385
+ }
371
386
  const avatars = Children.toArray(children);
372
387
  const overflow = max !== void 0 && avatars.length > max;
373
388
  const shown = overflow ? avatars.slice(0, Math.max(0, max - 1)) : avatars;
@@ -680,10 +695,9 @@ function HoldButton({
680
695
  "aria-description": "Press and hold to confirm",
681
696
  "data-hold": state === "idle" ? void 0 : state,
682
697
  "data-nudge": nudges % 2 === 0 ? "even" : "odd",
683
- className: (buttonState) => cx(
684
- "avl-hold-button",
685
- nudges > 0 && "avl-hold-button-nudged",
686
- typeof className === "function" ? className(buttonState) : className
698
+ className: withClass(
699
+ cx("avl-hold-button", nudges > 0 && "avl-hold-button-nudged"),
700
+ className
687
701
  ),
688
702
  style: (buttonState) => ({
689
703
  "--avl-hold-duration": `${holdDuration}ms`,
@@ -952,6 +966,12 @@ function Calendar({
952
966
  const now = /* @__PURE__ */ new Date();
953
967
  return selected ?? new Date(now.getFullYear(), now.getMonth(), now.getDate());
954
968
  });
969
+ const selectedIso = selected && toIso(selected);
970
+ const [shownSelection, setShownSelection] = useState3(selectedIso);
971
+ if (selectedIso !== shownSelection) {
972
+ setShownSelection(selectedIso);
973
+ if (selected) setFocused(selected);
974
+ }
955
975
  const [weekStart] = useState3(localeWeekStart);
956
976
  const dayRef = useRef4(null);
957
977
  const moveFocus = useRef4(false);
@@ -984,7 +1004,6 @@ function Calendar({
984
1004
  onValueChange?.(iso);
985
1005
  };
986
1006
  const today = toIso(/* @__PURE__ */ new Date());
987
- const selectedIso = selected && toIso(selected);
988
1007
  const focusedIso = toIso(focused);
989
1008
  const offset = (new Date(year, month, 1).getDay() - weekStart + 7) % 7;
990
1009
  const daysInMonth = new Date(year, month + 1, 0).getDate();
@@ -2200,6 +2219,7 @@ function FABMenu({
2200
2219
  align = "end",
2201
2220
  sticky = true,
2202
2221
  className,
2222
+ ref,
2203
2223
  children,
2204
2224
  ...props
2205
2225
  }) {
@@ -2223,10 +2243,10 @@ function FABMenu({
2223
2243
  /* @__PURE__ */ jsxs14(
2224
2244
  BaseMenu.Trigger,
2225
2245
  {
2226
- ref: trigger,
2246
+ ref: mergeRefs(trigger, ref),
2227
2247
  "aria-label": ariaLabel,
2228
2248
  className: cx(
2229
- "avl-fab avl-fab-size-normal avl-fab-menu-trigger",
2249
+ "avl-fab avl-fab-size-normal avl-fab-menu avl-fab-menu-trigger",
2230
2250
  colorClass(color, fillType),
2231
2251
  className
2232
2252
  ),
@@ -2548,7 +2568,10 @@ function MenuSubmenuTrigger({
2548
2568
  BaseMenu2.SubmenuTrigger,
2549
2569
  {
2550
2570
  ...props,
2551
- className: withClass("avl-menu-item", className),
2571
+ className: withClass(
2572
+ "avl-menu-item avl-menu-submenu-trigger",
2573
+ className
2574
+ ),
2552
2575
  children: [
2553
2576
  startIcon && /* @__PURE__ */ jsx27(Icon, { name: startIcon }),
2554
2577
  /* @__PURE__ */ jsx27("span", { className: "avl-menu-item-label", children }),
@@ -2859,7 +2882,7 @@ function PreviewCardPopup({
2859
2882
  {
2860
2883
  ...props,
2861
2884
  className: withClass(
2862
- "avl-menu-popup avl-popover-popup",
2885
+ "avl-menu-popup avl-popover-popup avl-preview-card-popup",
2863
2886
  className
2864
2887
  )
2865
2888
  }
@@ -2991,7 +3014,13 @@ function loadingSpan(width, gap, now) {
2991
3014
  }
2992
3015
 
2993
3016
  // src/components/ToggleGroup/ToggleGroup.tsx
2994
- import { createContext as createContext6, useContext as useContext15, useLayoutEffect as useLayoutEffect3, useRef as useRef11 } from "react";
3017
+ import {
3018
+ createContext as createContext6,
3019
+ useContext as useContext15,
3020
+ useEffect as useEffect7,
3021
+ useLayoutEffect as useLayoutEffect3,
3022
+ useRef as useRef11
3023
+ } from "react";
2995
3024
  import { Radio as BaseRadio } from "@base-ui/react/radio";
2996
3025
  import { RadioGroup as BaseRadioGroup } from "@base-ui/react/radio-group";
2997
3026
  import { Toggle as BaseToggle } from "@base-ui/react/toggle";
@@ -3010,6 +3039,17 @@ function ToggleGroup({
3010
3039
  }) {
3011
3040
  const groupRef = useRef11(null);
3012
3041
  const indicatorRef = useRef11(null);
3042
+ useEffect7(() => {
3043
+ if (process.env.NODE_ENV === "production") return;
3044
+ if (inNamedFieldset(groupRef.current)) return;
3045
+ checkName(
3046
+ props,
3047
+ "ToggleGroup",
3048
+ '<ToggleGroup aria-label="View" defaultValue="list">...</ToggleGroup>',
3049
+ "toggle-group.md",
3050
+ UNNAMED_GROUP
3051
+ );
3052
+ }, []);
3013
3053
  useLayoutEffect3(() => {
3014
3054
  const group = groupRef.current;
3015
3055
  const indicator = indicatorRef.current;
@@ -3057,7 +3097,7 @@ function ToggleGroup({
3057
3097
  {
3058
3098
  ...props,
3059
3099
  multiple: true,
3060
- ref,
3100
+ ref: mergeRefs(groupRef, ref),
3061
3101
  className: classes,
3062
3102
  children
3063
3103
  }
@@ -3137,15 +3177,30 @@ function ToggleGroupItem({
3137
3177
  // src/components/RadioGroup/RadioGroup.tsx
3138
3178
  import { Radio as BaseRadio2 } from "@base-ui/react/radio";
3139
3179
  import { RadioGroup as BaseRadioGroup2 } from "@base-ui/react/radio-group";
3180
+ import { useEffect as useEffect8, useRef as useRef12 } from "react";
3140
3181
  import { jsx as jsx35 } from "react/jsx-runtime";
3141
3182
  function RadioGroup({
3142
3183
  className,
3184
+ ref,
3143
3185
  ...props
3144
3186
  }) {
3187
+ const local = useRef12(null);
3188
+ useEffect8(() => {
3189
+ if (process.env.NODE_ENV === "production") return;
3190
+ if (inNamedFieldset(local.current)) return;
3191
+ checkName(
3192
+ props,
3193
+ "RadioGroup",
3194
+ '<RadioGroup aria-label="Plan" defaultValue="free">...</RadioGroup>\n// or inside <fieldset><legend>Plan</legend>...</fieldset>',
3195
+ "radio-group.md",
3196
+ UNNAMED_GROUP
3197
+ );
3198
+ }, []);
3145
3199
  return /* @__PURE__ */ jsx35(
3146
3200
  BaseRadioGroup2,
3147
3201
  {
3148
3202
  ...props,
3203
+ ref: mergeRefs(local, ref),
3149
3204
  className: withClass("avl-radio-group", className)
3150
3205
  }
3151
3206
  );
@@ -3252,7 +3307,12 @@ function SelectItem({ className, children, ...props }) {
3252
3307
  }
3253
3308
 
3254
3309
  // src/components/TimePicker/TimePicker.tsx
3255
- import { useId as useId2, useRef as useRef12, useState as useState9 } from "react";
3310
+ import {
3311
+ useEffect as useEffect9,
3312
+ useId as useId2,
3313
+ useRef as useRef13,
3314
+ useState as useState9
3315
+ } from "react";
3256
3316
  import { Fragment as Fragment4, jsx as jsx37, jsxs as jsxs22 } from "react/jsx-runtime";
3257
3317
  var pad2 = (n) => String(n).padStart(2, "0");
3258
3318
  function localeHourCycle() {
@@ -3288,6 +3348,16 @@ function TimePicker({
3288
3348
  const cycle = hourCycle ?? localeHourCycle();
3289
3349
  const labelId = useId2();
3290
3350
  const valueId = useId2();
3351
+ const trigger = useRef13(null);
3352
+ useEffect9(() => {
3353
+ if (process.env.NODE_ENV === "production") return;
3354
+ if (trigger.current?.closest(".avl-field"))
3355
+ devError(
3356
+ "<TimePicker> is inside a <Field>, but it doesn't take the Field's `name`, `disabled` or validation.",
3357
+ '<TimePicker label="Alarm" name="alarm" disabled={locked} /> // outside any Field',
3358
+ "time-picker.md"
3359
+ );
3360
+ }, []);
3291
3361
  const setTime = (t) => {
3292
3362
  const next = t && `${pad2(t.h)}:${pad2(t.m)}`;
3293
3363
  setInternal(next);
@@ -3322,7 +3392,7 @@ function TimePicker({
3322
3392
  PopoverTrigger,
3323
3393
  {
3324
3394
  ...control,
3325
- ref,
3395
+ ref: mergeRefs(trigger, ref),
3326
3396
  id,
3327
3397
  disabled,
3328
3398
  className: "avl-input-field avl-select-trigger",
@@ -3516,7 +3586,7 @@ function Dial(props) {
3516
3586
  ).flat();
3517
3587
  const radius = isHour && cycle === 24 && h >= 12 ? INNER : OUTER;
3518
3588
  const target = isHour ? h % 12 * 30 : m * 6;
3519
- const angleRef = useRef12(null);
3589
+ const angleRef = useRef13(null);
3520
3590
  const prev = angleRef.current;
3521
3591
  const angle = prev == null ? target : prev + ((target - prev) % 360 + 540) % 360 - 180;
3522
3592
  angleRef.current = angle;
@@ -3666,9 +3736,9 @@ function Dial(props) {
3666
3736
 
3667
3737
  // src/components/DateInput/DateInput.tsx
3668
3738
  import {
3669
- useEffect as useEffect7,
3739
+ useEffect as useEffect10,
3670
3740
  useId as useId3,
3671
- useRef as useRef13,
3741
+ useRef as useRef14,
3672
3742
  useState as useState10
3673
3743
  } from "react";
3674
3744
  import { Input as BaseInput2 } from "@base-ui/react/input";
@@ -3686,6 +3756,7 @@ function DateInput({
3686
3756
  size = "normal",
3687
3757
  disabled,
3688
3758
  id,
3759
+ onChange,
3689
3760
  onBlur,
3690
3761
  className,
3691
3762
  style,
@@ -3697,14 +3768,14 @@ function DateInput({
3697
3768
  const date = fromIso(value);
3698
3769
  const [draft, setDraft] = useState10(null);
3699
3770
  const [open, setOpen] = useState10(false);
3700
- const fieldRef = useRef13(null);
3701
- const popupRef = useRef13(null);
3771
+ const fieldRef = useRef14(null);
3772
+ const popupRef = useRef14(null);
3702
3773
  const generatedId = useId3();
3703
3774
  const inputId = id ?? generatedId;
3704
- const inputRef = useRef13(null);
3705
- const iso = useRef13("");
3775
+ const inputRef = useRef14(null);
3776
+ const iso = useRef14("");
3706
3777
  iso.current = date ? toIso(date) : "";
3707
- useEffect7(() => {
3778
+ useEffect10(() => {
3708
3779
  const form = inputRef.current?.form;
3709
3780
  if (!form) return;
3710
3781
  const onFormData = (event) => {
@@ -3758,6 +3829,7 @@ function DateInput({
3758
3829
  const typed = parseTyped(text, order);
3759
3830
  if (typed) commit(typed);
3760
3831
  }
3832
+ onChange?.(e);
3761
3833
  },
3762
3834
  onBlur: (e) => {
3763
3835
  if (!invalid) setDraft(null);
@@ -3910,7 +3982,10 @@ function ComboboxItem({
3910
3982
  BaseCombobox.Item,
3911
3983
  {
3912
3984
  ...props,
3913
- className: withClass("avl-menu-item avl-select-item", className),
3985
+ className: withClass(
3986
+ "avl-menu-item avl-select-item avl-combobox-item",
3987
+ className
3988
+ ),
3914
3989
  children: [
3915
3990
  /* @__PURE__ */ jsx39("span", { className: "avl-menu-item-label", children }),
3916
3991
  /* @__PURE__ */ jsx39(BaseCombobox.ItemIndicator, { className: "avl-select-item-indicator", children: /* @__PURE__ */ jsx39(Icon, { name: "check" }) })
@@ -4013,11 +4088,13 @@ function Toggle2({
4013
4088
  BaseToggle2,
4014
4089
  {
4015
4090
  ...props,
4016
- className: (state) => cx(
4017
- "avl-toggle",
4018
- icon ? `avl-icon-button avl-icon-button-size-${size}` : `avl-button avl-button-size-${size}`,
4019
- state.pressed ? colorClass(color, "filled") : colorClass("container", fillType),
4020
- typeof className === "function" ? className(state) : className
4091
+ className: withClass(
4092
+ (state) => cx(
4093
+ "avl-toggle",
4094
+ icon ? `avl-icon-button avl-icon-button-size-${size}` : `avl-button avl-button-size-${size}`,
4095
+ state.pressed ? colorClass(color, "filled") : colorClass("container", fillType)
4096
+ ),
4097
+ className
4021
4098
  ),
4022
4099
  children: icon ? /* @__PURE__ */ jsx41(Icon, { name: icon }) : /* @__PURE__ */ jsxs26(Fragment5, { children: [
4023
4100
  startIcon && /* @__PURE__ */ jsx41(Icon, { name: startIcon }),
@@ -4132,7 +4209,7 @@ function SearchItem({
4132
4209
  BaseAutocomplete.Item,
4133
4210
  {
4134
4211
  ...props,
4135
- className: withClass("avl-menu-item", className),
4212
+ className: withClass("avl-menu-item avl-search-item", className),
4136
4213
  children: [
4137
4214
  startIcon && /* @__PURE__ */ jsx42(Icon, { name: startIcon }),
4138
4215
  /* @__PURE__ */ jsx42("span", { className: "avl-menu-item-label", children })
@@ -4144,11 +4221,21 @@ function SearchItem({
4144
4221
  // src/components/Skeleton/Skeleton.tsx
4145
4222
  import { jsx as jsx43 } from "react/jsx-runtime";
4146
4223
  function Skeleton({
4147
- variant = "text",
4224
+ type = "text",
4148
4225
  animation = "pulse",
4149
4226
  className,
4150
4227
  ...props
4151
4228
  }) {
4229
+ if (process.env.NODE_ENV !== "production") {
4230
+ checkProp(
4231
+ props,
4232
+ "variant",
4233
+ "Skeleton",
4234
+ "The shape is `type`, as on Progress and Typography.",
4235
+ '<Skeleton type="circular" style={{ width: 40, height: 40 }} />\n// type: text | circular | rectangular',
4236
+ "skeleton.md"
4237
+ );
4238
+ }
4152
4239
  return /* @__PURE__ */ jsx43(
4153
4240
  "span",
4154
4241
  {
@@ -4156,7 +4243,7 @@ function Skeleton({
4156
4243
  ...props,
4157
4244
  className: cx(
4158
4245
  "avl-skeleton",
4159
- `avl-skeleton-${variant}`,
4246
+ `avl-skeleton-${type}`,
4160
4247
  animation === "pulse" && "avl-skeleton-pulse",
4161
4248
  className
4162
4249
  )
@@ -4172,19 +4259,31 @@ function Slider({
4172
4259
  "aria-label": ariaLabel,
4173
4260
  showValue = true,
4174
4261
  squiggly = false,
4262
+ getAriaLabel,
4175
4263
  className,
4176
4264
  ...props
4177
4265
  }) {
4178
- if (process.env.NODE_ENV !== "production" && label == null) {
4179
- checkName(
4180
- { "aria-label": ariaLabel, ...props },
4181
- "Slider",
4182
- '<Slider label="Volume" /> // or <Slider aria-label="Volume" />',
4183
- "slider.md"
4184
- );
4185
- }
4186
4266
  const initial = props.value ?? props.defaultValue;
4187
4267
  const thumbCount = Array.isArray(initial) ? initial.length : 1;
4268
+ if (process.env.NODE_ENV !== "production") {
4269
+ if (label == null)
4270
+ checkName(
4271
+ { "aria-label": ariaLabel, ...props },
4272
+ "Slider",
4273
+ '<Slider label="Volume" /> // or <Slider aria-label="Volume" />',
4274
+ "slider.md"
4275
+ );
4276
+ if (thumbCount > 1 && !getAriaLabel)
4277
+ devError(
4278
+ "<Slider> has several handles but no `getAriaLabel`, so screen readers give every handle the same name.",
4279
+ `<Slider
4280
+ label="Price"
4281
+ defaultValue={[20, 80]}
4282
+ getAriaLabel={(i) => (i === 0 ? 'Minimum price' : 'Maximum price')}
4283
+ />`,
4284
+ "slider.md"
4285
+ );
4286
+ }
4188
4287
  const wavy = squiggly && props.orientation !== "vertical";
4189
4288
  const morph2 = useWaveMorph(wavy);
4190
4289
  return /* @__PURE__ */ jsxs28(
@@ -4215,6 +4314,7 @@ function Slider({
4215
4314
  {
4216
4315
  index: i,
4217
4316
  "aria-label": ariaLabel,
4317
+ getAriaLabel,
4218
4318
  className: "avl-slider-thumb",
4219
4319
  render: (thumbProps, state) => /* @__PURE__ */ jsx44(
4220
4320
  "div",
@@ -4257,7 +4357,7 @@ function handleSpan(width, gap, svg) {
4257
4357
  }
4258
4358
 
4259
4359
  // src/components/Snackbar/Snackbar.tsx
4260
- import { useContext as useContext19, useEffect as useEffect8, useRef as useRef14, useState as useState11 } from "react";
4360
+ import { useContext as useContext19, useEffect as useEffect11, useRef as useRef15, useState as useState11 } from "react";
4261
4361
  import { Toast } from "@base-ui/react/toast";
4262
4362
  import { jsx as jsx45, jsxs as jsxs29 } from "react/jsx-runtime";
4263
4363
  function useSnackbar() {
@@ -4284,17 +4384,17 @@ function useSnackbar() {
4284
4384
  }
4285
4385
  function SnackbarViewport() {
4286
4386
  const { toasts } = Toast.useToastManager();
4287
- const viewportRef = useRef14(null);
4387
+ const viewportRef = useRef15(null);
4288
4388
  const [expanded, setExpanded] = useState11(false);
4289
4389
  const [hovered, setHovered] = useState11(false);
4290
4390
  const visibleCount = toasts.filter(
4291
4391
  (toast) => toast.transitionStatus !== "ending"
4292
4392
  ).length;
4293
4393
  const collapsed = visibleCount > 1 && !expanded && !hovered;
4294
- useEffect8(() => {
4394
+ useEffect11(() => {
4295
4395
  if (visibleCount <= 1) setExpanded(false);
4296
4396
  }, [visibleCount]);
4297
- useEffect8(() => {
4397
+ useEffect11(() => {
4298
4398
  if (!expanded) return;
4299
4399
  const viewport = viewportRef.current;
4300
4400
  const close = (event) => {
@@ -4540,6 +4640,15 @@ function FloatingToolbar({
4540
4640
  className,
4541
4641
  ...props
4542
4642
  }) {
4643
+ if (process.env.NODE_ENV !== "production") {
4644
+ checkName(
4645
+ props,
4646
+ "FloatingToolbar",
4647
+ '<FloatingToolbar aria-label="Formatting">...</FloatingToolbar>',
4648
+ "floating-toolbar.md",
4649
+ UNNAMED_GROUP
4650
+ );
4651
+ }
4543
4652
  return /* @__PURE__ */ jsx51(
4544
4653
  BaseToolbar.Root,
4545
4654
  {
@@ -4559,13 +4668,25 @@ function FloatingToolbarButton({
4559
4668
  // Filled means highlighted: primary stands out on the toolbar's surface
4560
4669
  color = fillType === "filled" ? "primary" : "container",
4561
4670
  disabled,
4671
+ className,
4562
4672
  ...props
4563
4673
  }) {
4564
4674
  return /* @__PURE__ */ jsx51(
4565
4675
  BaseToolbar.Button,
4566
4676
  {
4567
4677
  disabled,
4568
- render: /* @__PURE__ */ jsx51(IconButton, { ...props, color, fillType })
4678
+ render: /* @__PURE__ */ jsx51(
4679
+ IconButton,
4680
+ {
4681
+ ...props,
4682
+ color,
4683
+ fillType,
4684
+ className: withClass(
4685
+ "avl-floating-toolbar-button",
4686
+ className
4687
+ )
4688
+ }
4689
+ )
4569
4690
  }
4570
4691
  );
4571
4692
  }
@@ -4664,6 +4785,15 @@ import { useRender as useRender2 } from "@base-ui/react/use-render";
4664
4785
  import { mergeProps as mergeProps2 } from "@base-ui/react/merge-props";
4665
4786
  import { Fragment as Fragment6, jsx as jsx53, jsxs as jsxs34 } from "react/jsx-runtime";
4666
4787
  function NavigationBar({ className, ...props }) {
4788
+ if (process.env.NODE_ENV !== "production") {
4789
+ checkName(
4790
+ props,
4791
+ "NavigationBar",
4792
+ '<NavigationBar aria-label="Main">...</NavigationBar>',
4793
+ "navigation-bar.md",
4794
+ UNNAMED_NAV
4795
+ );
4796
+ }
4667
4797
  return /* @__PURE__ */ jsx53("nav", { ...props, className: cx("avl-navigation-bar", className) });
4668
4798
  }
4669
4799
  function NavigationBarItem({
@@ -4709,6 +4839,15 @@ function NavigationRail({
4709
4839
  className,
4710
4840
  ...props
4711
4841
  }) {
4842
+ if (process.env.NODE_ENV !== "production") {
4843
+ checkName(
4844
+ props,
4845
+ "NavigationRail",
4846
+ '<NavigationRail aria-label="Main">...</NavigationRail>',
4847
+ "navigation-rail.md",
4848
+ UNNAMED_NAV
4849
+ );
4850
+ }
4712
4851
  const [internal, setInternal] = useState12(defaultExpanded);
4713
4852
  const expanded = expandedProp ?? internal;
4714
4853
  const setExpanded = (next) => {
@@ -4788,6 +4927,15 @@ import { useRender as useRender4 } from "@base-ui/react/use-render";
4788
4927
  import { mergeProps as mergeProps4 } from "@base-ui/react/merge-props";
4789
4928
  import { jsx as jsx55 } from "react/jsx-runtime";
4790
4929
  function NavigationList({ className, ...props }) {
4930
+ if (process.env.NODE_ENV !== "production") {
4931
+ checkName(
4932
+ props,
4933
+ "NavigationList",
4934
+ '<NavigationList aria-label="Settings">...</NavigationList>',
4935
+ "navigation-list.md",
4936
+ UNNAMED_NAV
4937
+ );
4938
+ }
4791
4939
  return /* @__PURE__ */ jsx55("nav", { ...props, className: cx("avl-navigation-list", className) });
4792
4940
  }
4793
4941
  function NavigationListItem({
@@ -5076,23 +5224,72 @@ var neutralRoles = [
5076
5224
  "inverseSurface",
5077
5225
  "inverseOnSurface"
5078
5226
  ];
5227
+ var statusSwaps = [
5228
+ {
5229
+ roles: [
5230
+ "success",
5231
+ "onSuccess",
5232
+ "successContainer",
5233
+ "onSuccessContainer"
5234
+ ],
5235
+ from: 105,
5236
+ to: 190,
5237
+ hue: 255
5238
+ },
5239
+ {
5240
+ roles: ["error", "onError", "errorContainer", "onErrorContainer"],
5241
+ from: 10,
5242
+ to: 60,
5243
+ hue: 350
5244
+ },
5245
+ // Only yellow/gold: past orange there's no hue left that still reads as
5246
+ // a warning without looking like the error color
5247
+ {
5248
+ roles: [
5249
+ "warning",
5250
+ "onWarning",
5251
+ "warningContainer",
5252
+ "onWarningContainer"
5253
+ ],
5254
+ from: 75,
5255
+ to: 105,
5256
+ hue: 55
5257
+ }
5258
+ ];
5079
5259
  var reference = toOklch(parseHex(baseLightTheme.primary));
5080
5260
  function generate(base, primary, secondary) {
5081
5261
  const theme = { ...base };
5262
+ const roleOf = (key) => toOklch(parseHex(base[key]));
5263
+ const write = (key, l, c, h) => {
5264
+ ;
5265
+ theme[key] = toHex(l, c, h);
5266
+ };
5082
5267
  const set = (keys, seed, neutral) => {
5083
5268
  const scale = seed.c / reference.c;
5084
5269
  for (const key of keys) {
5085
- const role = toOklch(parseHex(base[key]));
5270
+ const role = roleOf(key);
5086
5271
  const c = role.c * (neutral ? Math.min(scale, 1) : scale);
5087
- const h = seed.h + role.h - reference.h;
5088
- theme[key] = toHex(role.l, c, h);
5272
+ write(key, role.l, c, seed.h + role.h - reference.h);
5089
5273
  }
5090
5274
  };
5091
5275
  set(primaryRoles, primary, false);
5092
5276
  set(tonalRoles, secondary, false);
5093
5277
  set(neutralRoles, primary, true);
5278
+ if (primary.c >= 0.04) {
5279
+ for (const swap of statusSwaps) {
5280
+ if (!hueInRange(primary.h, swap.from, swap.to)) continue;
5281
+ const shift = swap.hue - roleOf(swap.roles[0]).h;
5282
+ for (const key of swap.roles) {
5283
+ const role = roleOf(key);
5284
+ write(key, role.l, role.c, role.h + shift);
5285
+ }
5286
+ }
5287
+ }
5094
5288
  return theme;
5095
5289
  }
5290
+ function hueInRange(h, from, to) {
5291
+ return from <= to ? h >= from && h <= to : h >= from || h <= to;
5292
+ }
5096
5293
  function mainColors(pixels) {
5097
5294
  const bins = Array.from({ length: 36 }, () => ({ w: 0, l: 0, a: 0, b: 0 }));
5098
5295
  const grey = { w: 0, l: 0, a: 0, b: 0 };
@@ -5246,10 +5443,10 @@ var monochromeDarkTheme = {
5246
5443
 
5247
5444
  // src/components/AnvilRoot/AnvilRoot.tsx
5248
5445
  import {
5249
- useEffect as useEffect9,
5446
+ useEffect as useEffect12,
5250
5447
  useId as useId6,
5251
5448
  useLayoutEffect as useLayoutEffect4,
5252
- useRef as useRef15,
5449
+ useRef as useRef16,
5253
5450
  useState as useState13,
5254
5451
  useSyncExternalStore
5255
5452
  } from "react";
@@ -5315,43 +5512,56 @@ function subscribeToOs(onChange) {
5315
5512
  var getOsMode = () => matchMedia(darkQuery).matches ? "dark" : "light";
5316
5513
  var declarations = (vars) => Object.entries(vars).map(([name, value]) => `${name}:${value};`).join("");
5317
5514
  function AnvilRoot(props) {
5515
+ const {
5516
+ children,
5517
+ className,
5518
+ colorMode: colorModeProp,
5519
+ defaultColorMode,
5520
+ onColorModeChange,
5521
+ storageKey,
5522
+ lightTheme: lightThemeProp,
5523
+ darkTheme: darkThemeProp,
5524
+ tokens: tokensProp,
5525
+ ref,
5526
+ ...divProps
5527
+ } = props;
5318
5528
  const [internalSetting, setInternalSetting] = useState13(
5319
- props.defaultColorMode ?? "system"
5529
+ defaultColorMode ?? "system"
5320
5530
  );
5321
- const setting = props.colorMode ?? internalSetting;
5531
+ const setting = colorModeProp ?? internalSetting;
5322
5532
  const osMode = useSyncExternalStore(
5323
5533
  subscribeToOs,
5324
5534
  getOsMode,
5325
5535
  () => "light"
5326
5536
  );
5327
5537
  const colorMode = setting === "system" ? osMode : setting;
5328
- const latestSetting = useRef15(setting);
5538
+ const latestSetting = useRef16(setting);
5329
5539
  latestSetting.current = setting;
5330
5540
  useLayoutEffect4(() => {
5331
- if (!props.storageKey) return;
5332
- const stored = readStored(props.storageKey);
5541
+ if (!storageKey) return;
5542
+ const stored = readStored(storageKey);
5333
5543
  if (stored) {
5334
5544
  latestSetting.current = stored;
5335
5545
  setInternalSetting(stored);
5336
5546
  }
5337
- }, [props.storageKey]);
5547
+ }, [storageKey]);
5338
5548
  const setColorMode = (next) => {
5339
5549
  const value = typeof next === "function" ? next(latestSetting.current) : next;
5340
5550
  latestSetting.current = value;
5341
5551
  setInternalSetting(value);
5342
- props.onColorModeChange?.(value);
5343
- if (props.storageKey) {
5552
+ onColorModeChange?.(value);
5553
+ if (storageKey) {
5344
5554
  try {
5345
- localStorage.setItem(props.storageKey, value);
5555
+ localStorage.setItem(storageKey, value);
5346
5556
  } catch {
5347
5557
  }
5348
5558
  }
5349
5559
  };
5350
- const tokens = { ...baseDesignTokens, ...props.tokens };
5351
- const lightTheme = props.lightTheme || baseLightTheme;
5352
- const darkTheme = props.darkTheme || baseDarkTheme;
5353
- const rootRef = useRef15(null);
5354
- useEffect9(() => {
5560
+ const tokens = { ...baseDesignTokens, ...tokensProp };
5561
+ const lightTheme = lightThemeProp || baseLightTheme;
5562
+ const darkTheme = darkThemeProp || baseDarkTheme;
5563
+ const rootRef = useRef16(null);
5564
+ useEffect12(() => {
5355
5565
  if (process.env.NODE_ENV === "production") return;
5356
5566
  const timer = setTimeout(() => {
5357
5567
  const root2 = rootRef.current;
@@ -5371,7 +5581,7 @@ function AnvilRoot(props) {
5371
5581
  const light = `color-scheme:light;${declarations(themeToCssVariables(lightTheme))}`;
5372
5582
  const dark = `color-scheme:dark;${declarations(themeToCssVariables(darkTheme))}`;
5373
5583
  const css = `${root}{${declarations(tokensToCssVariables(tokens))}${light}}${root}[data-color-mode="dark"]{${dark}}@media ${darkQuery}{${root}[data-color-mode="system"]{${dark}}}`;
5374
- const restoreScript = props.storageKey && props.colorMode === void 0 ? `try{var m=localStorage.getItem(${JSON.stringify(props.storageKey)});if(m==='light'||m==='dark'||m==='system')document.currentScript.parentElement.dataset.colorMode=m}catch(e){}` : void 0;
5584
+ 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;
5375
5585
  return /* @__PURE__ */ jsx57(
5376
5586
  AnvilContext,
5377
5587
  {
@@ -5387,8 +5597,9 @@ function AnvilRoot(props) {
5387
5597
  children: /* @__PURE__ */ jsxs37(
5388
5598
  "div",
5389
5599
  {
5390
- ref: rootRef,
5391
- className: cx("avl-root", props.className),
5600
+ ...divProps,
5601
+ ref: mergeRefs(rootRef, ref),
5602
+ className: cx("avl-root", className),
5392
5603
  "data-avl-root": id,
5393
5604
  "data-color-mode": setting,
5394
5605
  suppressHydrationWarning: true,
@@ -5403,7 +5614,7 @@ function AnvilRoot(props) {
5403
5614
  ),
5404
5615
  /* @__PURE__ */ jsx57("style", { children: css }),
5405
5616
  /* @__PURE__ */ jsx57(Tooltip2.Provider, { children: /* @__PURE__ */ jsxs37(Toast2.Provider, { limit: 3, children: [
5406
- props.children,
5617
+ children,
5407
5618
  /* @__PURE__ */ jsx57(SnackbarViewport, {})
5408
5619
  ] }) })
5409
5620
  ]