anvilui 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -161,7 +161,10 @@ function cx(...parts) {
161
161
  return parts.filter(Boolean).join(" ");
162
162
  }
163
163
  function withClass(base, className) {
164
- return (state) => cx(base, typeof className === "function" ? className(state) : className);
164
+ return (state) => cx(
165
+ typeof base === "function" ? base(state) : base,
166
+ typeof className === "function" ? className(state) : className
167
+ );
165
168
  }
166
169
  function splitControlProps(props) {
167
170
  const control = {};
@@ -325,13 +328,15 @@ import 'anvilui/styles.css'
325
328
  "setup.md"
326
329
  );
327
330
  }
328
- function checkName(props, component, example, doc) {
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) {
329
338
  if (props["aria-label"] || props["aria-labelledby"]) return;
330
- devError(
331
- `<${component}> has no accessible name. It shows no text, so screen readers need an \`aria-label\`.`,
332
- example,
333
- doc
334
- );
339
+ devError(`<${component}> has no accessible name. ${reason}`, example, doc);
335
340
  }
336
341
 
337
342
  // src/components/Typography/Typography.tsx
@@ -467,12 +472,13 @@ function Avatar({
467
472
  const groupSize = (0, import_react5.useContext)(AvatarGroupContext);
468
473
  const size = sizeProp ?? groupSize ?? "normal";
469
474
  const letters = name ? initials(name) : "";
475
+ const named = !!(name || props["aria-label"] || props["aria-labelledby"]);
470
476
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
471
477
  import_avatar.Avatar.Root,
472
478
  {
473
- role: name ? "img" : void 0,
479
+ role: named ? "img" : void 0,
474
480
  "aria-label": name,
475
- "aria-hidden": name ? void 0 : true,
481
+ "aria-hidden": named ? void 0 : true,
476
482
  ...props,
477
483
  className: withClass(
478
484
  cx(
@@ -516,6 +522,15 @@ function AvatarGroup({
516
522
  children,
517
523
  ...props
518
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
+ }
519
534
  const avatars = import_react6.Children.toArray(children);
520
535
  const overflow = max !== void 0 && avatars.length > max;
521
536
  const shown = overflow ? avatars.slice(0, Math.max(0, max - 1)) : avatars;
@@ -826,10 +841,9 @@ function HoldButton({
826
841
  "aria-description": "Press and hold to confirm",
827
842
  "data-hold": state === "idle" ? void 0 : state,
828
843
  "data-nudge": nudges % 2 === 0 ? "even" : "odd",
829
- className: (buttonState) => cx(
830
- "avl-hold-button",
831
- nudges > 0 && "avl-hold-button-nudged",
832
- typeof className === "function" ? className(buttonState) : className
844
+ className: withClass(
845
+ cx("avl-hold-button", nudges > 0 && "avl-hold-button-nudged"),
846
+ className
833
847
  ),
834
848
  style: (buttonState) => ({
835
849
  "--avl-hold-duration": `${holdDuration}ms`,
@@ -1094,6 +1108,12 @@ function Calendar({
1094
1108
  const now = /* @__PURE__ */ new Date();
1095
1109
  return selected ?? new Date(now.getFullYear(), now.getMonth(), now.getDate());
1096
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
+ }
1097
1117
  const [weekStart] = (0, import_react12.useState)(localeWeekStart);
1098
1118
  const dayRef = (0, import_react12.useRef)(null);
1099
1119
  const moveFocus = (0, import_react12.useRef)(false);
@@ -1126,7 +1146,6 @@ function Calendar({
1126
1146
  onValueChange?.(iso);
1127
1147
  };
1128
1148
  const today = toIso(/* @__PURE__ */ new Date());
1129
- const selectedIso = selected && toIso(selected);
1130
1149
  const focusedIso = toIso(focused);
1131
1150
  const offset = (new Date(year, month, 1).getDay() - weekStart + 7) % 7;
1132
1151
  const daysInMonth = new Date(year, month + 1, 0).getDate();
@@ -2333,6 +2352,7 @@ function FABMenu({
2333
2352
  align = "end",
2334
2353
  sticky = true,
2335
2354
  className,
2355
+ ref,
2336
2356
  children,
2337
2357
  ...props
2338
2358
  }) {
@@ -2356,7 +2376,7 @@ function FABMenu({
2356
2376
  /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
2357
2377
  import_menu.Menu.Trigger,
2358
2378
  {
2359
- ref: trigger,
2379
+ ref: mergeRefs(trigger, ref),
2360
2380
  "aria-label": ariaLabel,
2361
2381
  className: cx(
2362
2382
  "avl-fab avl-fab-size-normal avl-fab-menu-trigger",
@@ -3143,6 +3163,17 @@ function ToggleGroup({
3143
3163
  }) {
3144
3164
  const groupRef = (0, import_react28.useRef)(null);
3145
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
+ }, []);
3146
3177
  (0, import_react28.useLayoutEffect)(() => {
3147
3178
  const group = groupRef.current;
3148
3179
  const indicator = indicatorRef.current;
@@ -3190,7 +3221,7 @@ function ToggleGroup({
3190
3221
  {
3191
3222
  ...props,
3192
3223
  multiple: true,
3193
- ref,
3224
+ ref: mergeRefs(groupRef, ref),
3194
3225
  className: classes,
3195
3226
  children
3196
3227
  }
@@ -3270,15 +3301,30 @@ function ToggleGroupItem({
3270
3301
  // src/components/RadioGroup/RadioGroup.tsx
3271
3302
  var import_radio2 = require("@base-ui/react/radio");
3272
3303
  var import_radio_group2 = require("@base-ui/react/radio-group");
3304
+ var import_react29 = require("react");
3273
3305
  var import_jsx_runtime35 = require("react/jsx-runtime");
3274
3306
  function RadioGroup({
3275
3307
  className,
3308
+ ref,
3276
3309
  ...props
3277
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
+ }, []);
3278
3323
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3279
3324
  import_radio_group2.RadioGroup,
3280
3325
  {
3281
3326
  ...props,
3327
+ ref: mergeRefs(local, ref),
3282
3328
  className: withClass("avl-radio-group", className)
3283
3329
  }
3284
3330
  );
@@ -3305,7 +3351,7 @@ function Radio({ className, ...props }) {
3305
3351
  }
3306
3352
 
3307
3353
  // src/components/Select/Select.tsx
3308
- var import_react29 = require("react");
3354
+ var import_react30 = require("react");
3309
3355
  var import_select = require("@base-ui/react/select");
3310
3356
  var import_jsx_runtime36 = require("react/jsx-runtime");
3311
3357
  function Select({
@@ -3319,7 +3365,7 @@ function Select({
3319
3365
  ...allProps
3320
3366
  }) {
3321
3367
  const { control, rest: props } = splitControlProps(allProps);
3322
- const avl = (0, import_react29.useContext)(AnvilContext);
3368
+ const avl = (0, import_react30.useContext)(AnvilContext);
3323
3369
  if (process.env.NODE_ENV !== "production") {
3324
3370
  checkRoot(avl !== null, "Select");
3325
3371
  }
@@ -3385,7 +3431,7 @@ function SelectItem({ className, children, ...props }) {
3385
3431
  }
3386
3432
 
3387
3433
  // src/components/TimePicker/TimePicker.tsx
3388
- var import_react30 = require("react");
3434
+ var import_react31 = require("react");
3389
3435
  var import_jsx_runtime37 = require("react/jsx-runtime");
3390
3436
  var pad2 = (n) => String(n).padStart(2, "0");
3391
3437
  function localeHourCycle() {
@@ -3415,12 +3461,22 @@ function TimePicker({
3415
3461
  ...allProps
3416
3462
  }) {
3417
3463
  const { control, rest: props } = splitControlProps(allProps);
3418
- const [internal, setInternal] = (0, import_react30.useState)(defaultValue);
3464
+ const [internal, setInternal] = (0, import_react31.useState)(defaultValue);
3419
3465
  const value = valueProp !== void 0 ? valueProp : internal;
3420
3466
  const time = parseTime(value);
3421
3467
  const cycle = hourCycle ?? localeHourCycle();
3422
- const labelId = (0, import_react30.useId)();
3423
- const valueId = (0, import_react30.useId)();
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
+ }, []);
3424
3480
  const setTime = (t) => {
3425
3481
  const next = t && `${pad2(t.h)}:${pad2(t.m)}`;
3426
3482
  setInternal(next);
@@ -3455,7 +3511,7 @@ function TimePicker({
3455
3511
  PopoverTrigger,
3456
3512
  {
3457
3513
  ...control,
3458
- ref,
3514
+ ref: mergeRefs(trigger, ref),
3459
3515
  id,
3460
3516
  disabled,
3461
3517
  className: "avl-input-field avl-select-trigger",
@@ -3489,7 +3545,7 @@ function TimePicker({
3489
3545
  }
3490
3546
  function TimePanel(props) {
3491
3547
  const { type, time, cycle, onChange, onClear } = props;
3492
- const [mode, setMode] = (0, import_react30.useState)("hour");
3548
+ const [mode, setMode] = (0, import_react31.useState)("hour");
3493
3549
  const pm = time ? time.h >= 12 : false;
3494
3550
  const hourText = time ? pad2(displayHour(time.h, cycle)) : "--";
3495
3551
  const minuteText = time ? pad2(time.m) : "--";
@@ -3590,7 +3646,7 @@ function TimePanel(props) {
3590
3646
  }
3591
3647
  function SpinInput(props) {
3592
3648
  const { label, value, min, max, onChange } = props;
3593
- const [draft, setDraft] = (0, import_react30.useState)(null);
3649
+ const [draft, setDraft] = (0, import_react31.useState)(null);
3594
3650
  const range = max - min + 1;
3595
3651
  return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3596
3652
  "input",
@@ -3639,7 +3695,7 @@ function Dial(props) {
3639
3695
  const h = time?.h ?? 0;
3640
3696
  const m = time?.m ?? 0;
3641
3697
  const isHour = mode === "hour";
3642
- const [dragging, setDragging] = (0, import_react30.useState)(false);
3698
+ const [dragging, setDragging] = (0, import_react31.useState)(false);
3643
3699
  const labels = Array.from(
3644
3700
  { length: 12 },
3645
3701
  (_, i) => !isHour ? [{ value: i * 5, text: pad2(i * 5), inner: false }] : cycle === 12 ? [{ value: i, text: String(i || 12), inner: false }] : [
@@ -3649,7 +3705,7 @@ function Dial(props) {
3649
3705
  ).flat();
3650
3706
  const radius = isHour && cycle === 24 && h >= 12 ? INNER : OUTER;
3651
3707
  const target = isHour ? h % 12 * 30 : m * 6;
3652
- const angleRef = (0, import_react30.useRef)(null);
3708
+ const angleRef = (0, import_react31.useRef)(null);
3653
3709
  const prev = angleRef.current;
3654
3710
  const angle = prev == null ? target : prev + ((target - prev) % 360 + 540) % 360 - 180;
3655
3711
  angleRef.current = angle;
@@ -3798,7 +3854,7 @@ function Dial(props) {
3798
3854
  }
3799
3855
 
3800
3856
  // src/components/DateInput/DateInput.tsx
3801
- var import_react31 = require("react");
3857
+ var import_react32 = require("react");
3802
3858
  var import_input5 = require("@base-ui/react/input");
3803
3859
  var import_jsx_runtime38 = require("react/jsx-runtime");
3804
3860
  var numericFormat = () => new Intl.DateTimeFormat(void 0, {
@@ -3814,25 +3870,26 @@ function DateInput({
3814
3870
  size = "normal",
3815
3871
  disabled,
3816
3872
  id,
3873
+ onChange,
3817
3874
  onBlur,
3818
3875
  className,
3819
3876
  style,
3820
3877
  ref,
3821
3878
  ...props
3822
3879
  }) {
3823
- const [internal, setInternal] = (0, import_react31.useState)(defaultValue);
3880
+ const [internal, setInternal] = (0, import_react32.useState)(defaultValue);
3824
3881
  const value = valueProp !== void 0 ? valueProp : internal;
3825
3882
  const date = fromIso(value);
3826
- const [draft, setDraft] = (0, import_react31.useState)(null);
3827
- const [open, setOpen] = (0, import_react31.useState)(false);
3828
- const fieldRef = (0, import_react31.useRef)(null);
3829
- const popupRef = (0, import_react31.useRef)(null);
3830
- const generatedId = (0, import_react31.useId)();
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)();
3831
3888
  const inputId = id ?? generatedId;
3832
- const inputRef = (0, import_react31.useRef)(null);
3833
- const iso = (0, import_react31.useRef)("");
3889
+ const inputRef = (0, import_react32.useRef)(null);
3890
+ const iso = (0, import_react32.useRef)("");
3834
3891
  iso.current = date ? toIso(date) : "";
3835
- (0, import_react31.useEffect)(() => {
3892
+ (0, import_react32.useEffect)(() => {
3836
3893
  const form = inputRef.current?.form;
3837
3894
  if (!form) return;
3838
3895
  const onFormData = (event) => {
@@ -3886,6 +3943,7 @@ function DateInput({
3886
3943
  const typed = parseTyped(text, order);
3887
3944
  if (typed) commit(typed);
3888
3945
  }
3946
+ onChange?.(e);
3889
3947
  },
3890
3948
  onBlur: (e) => {
3891
3949
  if (!invalid) setDraft(null);
@@ -3940,7 +3998,7 @@ function DateInput({
3940
3998
  }
3941
3999
 
3942
4000
  // src/components/Combobox/Combobox.tsx
3943
- var import_react32 = require("react");
4001
+ var import_react33 = require("react");
3944
4002
  var import_combobox = require("@base-ui/react/combobox");
3945
4003
  var import_jsx_runtime39 = require("react/jsx-runtime");
3946
4004
  function Combobox({
@@ -3956,7 +4014,7 @@ function Combobox({
3956
4014
  ...allProps
3957
4015
  }) {
3958
4016
  const { control, rest: props } = splitControlProps(allProps);
3959
- const avl = (0, import_react32.useContext)(AnvilContext);
4017
+ const avl = (0, import_react33.useContext)(AnvilContext);
3960
4018
  if (process.env.NODE_ENV !== "production") {
3961
4019
  checkRoot(avl !== null, "Combobox");
3962
4020
  if (typeof children !== "function")
@@ -3966,9 +4024,9 @@ function Combobox({
3966
4024
  "combobox.md"
3967
4025
  );
3968
4026
  }
3969
- const generatedId = (0, import_react32.useId)();
4027
+ const generatedId = (0, import_react33.useId)();
3970
4028
  const inputId = id ?? generatedId;
3971
- const labelId = (0, import_react32.useId)();
4029
+ const labelId = (0, import_react33.useId)();
3972
4030
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_combobox.Combobox.Root, { ...props, children: [
3973
4031
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
3974
4032
  import_combobox.Combobox.InputGroup,
@@ -4045,7 +4103,7 @@ function ComboboxItem({
4045
4103
  }
4046
4104
 
4047
4105
  // src/components/PinInput/PinInput.tsx
4048
- var import_react33 = require("react");
4106
+ var import_react34 = require("react");
4049
4107
  var import_otp_field = require("@base-ui/react/otp-field");
4050
4108
  var import_jsx_runtime40 = require("react/jsx-runtime");
4051
4109
  var defaultSlotLabel = (index, length) => `Character ${index + 1} of ${length}`;
@@ -4061,7 +4119,7 @@ function PinInput({
4061
4119
  length,
4062
4120
  ...props
4063
4121
  }) {
4064
- const generatedId = (0, import_react33.useId)();
4122
+ const generatedId = (0, import_react34.useId)();
4065
4123
  const inputId = id ?? generatedId;
4066
4124
  const labelId = `${inputId}-label`;
4067
4125
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
@@ -4138,11 +4196,13 @@ function Toggle2({
4138
4196
  import_toggle3.Toggle,
4139
4197
  {
4140
4198
  ...props,
4141
- className: (state) => cx(
4142
- "avl-toggle",
4143
- icon ? `avl-icon-button avl-icon-button-size-${size}` : `avl-button avl-button-size-${size}`,
4144
- state.pressed ? colorClass(color, "filled") : colorClass("container", fillType),
4145
- typeof className === "function" ? className(state) : className
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
4146
4206
  ),
4147
4207
  children: icon ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Icon, { name: icon }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
4148
4208
  startIcon && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Icon, { name: startIcon }),
@@ -4154,7 +4214,7 @@ function Toggle2({
4154
4214
  }
4155
4215
 
4156
4216
  // src/components/Search/Search.tsx
4157
- var import_react34 = require("react");
4217
+ var import_react35 = require("react");
4158
4218
  var import_autocomplete = require("@base-ui/react/autocomplete");
4159
4219
  var import_jsx_runtime42 = require("react/jsx-runtime");
4160
4220
  function Search({
@@ -4171,7 +4231,7 @@ function Search({
4171
4231
  ...allProps
4172
4232
  }) {
4173
4233
  const { control, rest: props } = splitControlProps(allProps);
4174
- const avl = (0, import_react34.useContext)(AnvilContext);
4234
+ const avl = (0, import_react35.useContext)(AnvilContext);
4175
4235
  const suggests = children !== void 0;
4176
4236
  if (process.env.NODE_ENV !== "production") {
4177
4237
  checkRoot(avl !== null, "Search");
@@ -4269,11 +4329,21 @@ function SearchItem({
4269
4329
  // src/components/Skeleton/Skeleton.tsx
4270
4330
  var import_jsx_runtime43 = require("react/jsx-runtime");
4271
4331
  function Skeleton({
4272
- variant = "text",
4332
+ type = "text",
4273
4333
  animation = "pulse",
4274
4334
  className,
4275
4335
  ...props
4276
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
+ }
4277
4347
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4278
4348
  "span",
4279
4349
  {
@@ -4281,7 +4351,7 @@ function Skeleton({
4281
4351
  ...props,
4282
4352
  className: cx(
4283
4353
  "avl-skeleton",
4284
- `avl-skeleton-${variant}`,
4354
+ `avl-skeleton-${type}`,
4285
4355
  animation === "pulse" && "avl-skeleton-pulse",
4286
4356
  className
4287
4357
  )
@@ -4297,19 +4367,31 @@ function Slider({
4297
4367
  "aria-label": ariaLabel,
4298
4368
  showValue = true,
4299
4369
  squiggly = false,
4370
+ getAriaLabel,
4300
4371
  className,
4301
4372
  ...props
4302
4373
  }) {
4303
- if (process.env.NODE_ENV !== "production" && label == null) {
4304
- checkName(
4305
- { "aria-label": ariaLabel, ...props },
4306
- "Slider",
4307
- '<Slider label="Volume" /> // or <Slider aria-label="Volume" />',
4308
- "slider.md"
4309
- );
4310
- }
4311
4374
  const initial = props.value ?? props.defaultValue;
4312
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
+ }
4313
4395
  const wavy = squiggly && props.orientation !== "vertical";
4314
4396
  const morph2 = useWaveMorph(wavy);
4315
4397
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
@@ -4340,6 +4422,7 @@ function Slider({
4340
4422
  {
4341
4423
  index: i,
4342
4424
  "aria-label": ariaLabel,
4425
+ getAriaLabel,
4343
4426
  className: "avl-slider-thumb",
4344
4427
  render: (thumbProps, state) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4345
4428
  "div",
@@ -4382,11 +4465,11 @@ function handleSpan(width, gap, svg) {
4382
4465
  }
4383
4466
 
4384
4467
  // src/components/Snackbar/Snackbar.tsx
4385
- var import_react35 = require("react");
4468
+ var import_react36 = require("react");
4386
4469
  var import_toast = require("@base-ui/react/toast");
4387
4470
  var import_jsx_runtime45 = require("react/jsx-runtime");
4388
4471
  function useSnackbar() {
4389
- const avl = (0, import_react35.useContext)(AnvilContext);
4472
+ const avl = (0, import_react36.useContext)(AnvilContext);
4390
4473
  if (process.env.NODE_ENV !== "production" && !avl)
4391
4474
  throw new Error(
4392
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"
@@ -4409,17 +4492,17 @@ function useSnackbar() {
4409
4492
  }
4410
4493
  function SnackbarViewport() {
4411
4494
  const { toasts } = import_toast.Toast.useToastManager();
4412
- const viewportRef = (0, import_react35.useRef)(null);
4413
- const [expanded, setExpanded] = (0, import_react35.useState)(false);
4414
- const [hovered, setHovered] = (0, import_react35.useState)(false);
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);
4415
4498
  const visibleCount = toasts.filter(
4416
4499
  (toast) => toast.transitionStatus !== "ending"
4417
4500
  ).length;
4418
4501
  const collapsed = visibleCount > 1 && !expanded && !hovered;
4419
- (0, import_react35.useEffect)(() => {
4502
+ (0, import_react36.useEffect)(() => {
4420
4503
  if (visibleCount <= 1) setExpanded(false);
4421
4504
  }, [visibleCount]);
4422
- (0, import_react35.useEffect)(() => {
4505
+ (0, import_react36.useEffect)(() => {
4423
4506
  if (!expanded) return;
4424
4507
  const viewport = viewportRef.current;
4425
4508
  const close = (event) => {
@@ -4665,6 +4748,15 @@ function FloatingToolbar({
4665
4748
  className,
4666
4749
  ...props
4667
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
+ }
4668
4760
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
4669
4761
  import_toolbar.Toolbar.Root,
4670
4762
  {
@@ -4711,7 +4803,7 @@ function FloatingToolbarSeparator({
4711
4803
  }
4712
4804
 
4713
4805
  // src/components/Tooltip/Tooltip.tsx
4714
- var import_react36 = require("react");
4806
+ var import_react37 = require("react");
4715
4807
  var import_tooltip2 = require("@base-ui/react/tooltip");
4716
4808
  var import_jsx_runtime52 = require("react/jsx-runtime");
4717
4809
  function Tooltip({
@@ -4726,7 +4818,7 @@ function Tooltip({
4726
4818
  className,
4727
4819
  ...props
4728
4820
  }) {
4729
- const avl = (0, import_react36.useContext)(AnvilContext);
4821
+ const avl = (0, import_react37.useContext)(AnvilContext);
4730
4822
  if (process.env.NODE_ENV !== "production") {
4731
4823
  checkRoot(avl !== null, "Tooltip");
4732
4824
  checkProp(
@@ -4745,7 +4837,7 @@ function Tooltip({
4745
4837
  '<Tooltip label="Delete">\n <IconButton icon="delete" aria-label="Delete" />\n</Tooltip>',
4746
4838
  "tooltip.md"
4747
4839
  );
4748
- if (!(0, import_react36.isValidElement)(children))
4840
+ if (!(0, import_react37.isValidElement)(children))
4749
4841
  devError(
4750
4842
  "<Tooltip> needs exactly one element child (the trigger), not text or several elements.",
4751
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>',
@@ -4786,6 +4878,15 @@ var import_use_render2 = require("@base-ui/react/use-render");
4786
4878
  var import_merge_props2 = require("@base-ui/react/merge-props");
4787
4879
  var import_jsx_runtime53 = require("react/jsx-runtime");
4788
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
+ }
4789
4890
  return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("nav", { ...props, className: cx("avl-navigation-bar", className) });
4790
4891
  }
4791
4892
  function NavigationBarItem({
@@ -4815,11 +4916,11 @@ function NavigationBarItem({
4815
4916
  }
4816
4917
 
4817
4918
  // src/components/NavigationRail/NavigationRail.tsx
4818
- var import_react37 = require("react");
4919
+ var import_react38 = require("react");
4819
4920
  var import_use_render3 = require("@base-ui/react/use-render");
4820
4921
  var import_merge_props3 = require("@base-ui/react/merge-props");
4821
4922
  var import_jsx_runtime54 = require("react/jsx-runtime");
4822
- var RailContext = (0, import_react37.createContext)(null);
4923
+ var RailContext = (0, import_react38.createContext)(null);
4823
4924
  function NavigationRail({
4824
4925
  expanded: expandedProp,
4825
4926
  defaultExpanded = false,
@@ -4827,7 +4928,16 @@ function NavigationRail({
4827
4928
  className,
4828
4929
  ...props
4829
4930
  }) {
4830
- const [internal, setInternal] = (0, import_react37.useState)(defaultExpanded);
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);
4831
4941
  const expanded = expandedProp ?? internal;
4832
4942
  const setExpanded = (next) => {
4833
4943
  setInternal(next);
@@ -4847,7 +4957,7 @@ function NavigationRailToggle({
4847
4957
  onClick,
4848
4958
  ...props
4849
4959
  }) {
4850
- const rail = (0, import_react37.useContext)(RailContext);
4960
+ const rail = (0, import_react38.useContext)(RailContext);
4851
4961
  if (process.env.NODE_ENV !== "production" && !rail) {
4852
4962
  devError(
4853
4963
  "<NavigationRailToggle> is rendered outside a <NavigationRail>, so it has nothing to expand.",
@@ -4906,6 +5016,15 @@ var import_use_render4 = require("@base-ui/react/use-render");
4906
5016
  var import_merge_props4 = require("@base-ui/react/merge-props");
4907
5017
  var import_jsx_runtime55 = require("react/jsx-runtime");
4908
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
+ }
4909
5028
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("nav", { ...props, className: cx("avl-navigation-list", className) });
4910
5029
  }
4911
5030
  function NavigationListItem({
@@ -4931,7 +5050,7 @@ function NavigationListItem({
4931
5050
  }
4932
5051
 
4933
5052
  // src/components/NavigationDrawer/NavigationDrawer.tsx
4934
- var import_react38 = require("react");
5053
+ var import_react39 = require("react");
4935
5054
  var import_drawer2 = require("@base-ui/react/drawer");
4936
5055
  var import_jsx_runtime56 = require("react/jsx-runtime");
4937
5056
  function NavigationDrawer(props) {
@@ -4961,7 +5080,7 @@ function NavigationDrawerPopup({
4961
5080
  className,
4962
5081
  ...props
4963
5082
  }) {
4964
- const avl = (0, import_react38.useContext)(AnvilContext);
5083
+ const avl = (0, import_react39.useContext)(AnvilContext);
4965
5084
  if (process.env.NODE_ENV !== "production") {
4966
5085
  checkRoot(avl !== null, "NavigationDrawerPopup");
4967
5086
  }
@@ -5363,7 +5482,7 @@ var monochromeDarkTheme = {
5363
5482
  };
5364
5483
 
5365
5484
  // src/components/AnvilRoot/AnvilRoot.tsx
5366
- var import_react39 = require("react");
5485
+ var import_react40 = require("react");
5367
5486
  var import_toast2 = require("@base-ui/react/toast");
5368
5487
  var import_tooltip4 = require("@base-ui/react/tooltip");
5369
5488
 
@@ -5426,43 +5545,56 @@ function subscribeToOs(onChange) {
5426
5545
  var getOsMode = () => matchMedia(darkQuery).matches ? "dark" : "light";
5427
5546
  var declarations = (vars) => Object.entries(vars).map(([name, value]) => `${name}:${value};`).join("");
5428
5547
  function AnvilRoot(props) {
5429
- const [internalSetting, setInternalSetting] = (0, import_react39.useState)(
5430
- props.defaultColorMode ?? "system"
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"
5431
5563
  );
5432
- const setting = props.colorMode ?? internalSetting;
5433
- const osMode = (0, import_react39.useSyncExternalStore)(
5564
+ const setting = colorModeProp ?? internalSetting;
5565
+ const osMode = (0, import_react40.useSyncExternalStore)(
5434
5566
  subscribeToOs,
5435
5567
  getOsMode,
5436
5568
  () => "light"
5437
5569
  );
5438
5570
  const colorMode = setting === "system" ? osMode : setting;
5439
- const latestSetting = (0, import_react39.useRef)(setting);
5571
+ const latestSetting = (0, import_react40.useRef)(setting);
5440
5572
  latestSetting.current = setting;
5441
- (0, import_react39.useLayoutEffect)(() => {
5442
- if (!props.storageKey) return;
5443
- const stored = readStored(props.storageKey);
5573
+ (0, import_react40.useLayoutEffect)(() => {
5574
+ if (!storageKey) return;
5575
+ const stored = readStored(storageKey);
5444
5576
  if (stored) {
5445
5577
  latestSetting.current = stored;
5446
5578
  setInternalSetting(stored);
5447
5579
  }
5448
- }, [props.storageKey]);
5580
+ }, [storageKey]);
5449
5581
  const setColorMode = (next) => {
5450
5582
  const value = typeof next === "function" ? next(latestSetting.current) : next;
5451
5583
  latestSetting.current = value;
5452
5584
  setInternalSetting(value);
5453
- props.onColorModeChange?.(value);
5454
- if (props.storageKey) {
5585
+ onColorModeChange?.(value);
5586
+ if (storageKey) {
5455
5587
  try {
5456
- localStorage.setItem(props.storageKey, value);
5588
+ localStorage.setItem(storageKey, value);
5457
5589
  } catch {
5458
5590
  }
5459
5591
  }
5460
5592
  };
5461
- const tokens = { ...baseDesignTokens, ...props.tokens };
5462
- const lightTheme = props.lightTheme || baseLightTheme;
5463
- const darkTheme = props.darkTheme || baseDarkTheme;
5464
- const rootRef = (0, import_react39.useRef)(null);
5465
- (0, import_react39.useEffect)(() => {
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)(() => {
5466
5598
  if (process.env.NODE_ENV === "production") return;
5467
5599
  const timer = setTimeout(() => {
5468
5600
  const root2 = rootRef.current;
@@ -5477,12 +5609,12 @@ function AnvilRoot(props) {
5477
5609
  }, 1e3);
5478
5610
  return () => clearTimeout(timer);
5479
5611
  }, []);
5480
- const id = (0, import_react39.useId)();
5612
+ const id = (0, import_react40.useId)();
5481
5613
  const root = `[data-avl-root="${id}"]`;
5482
5614
  const light = `color-scheme:light;${declarations(themeToCssVariables(lightTheme))}`;
5483
5615
  const dark = `color-scheme:dark;${declarations(themeToCssVariables(darkTheme))}`;
5484
5616
  const css = `${root}{${declarations(tokensToCssVariables(tokens))}${light}}${root}[data-color-mode="dark"]{${dark}}@media ${darkQuery}{${root}[data-color-mode="system"]{${dark}}}`;
5485
- 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;
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;
5486
5618
  return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
5487
5619
  AnvilContext,
5488
5620
  {
@@ -5498,8 +5630,9 @@ function AnvilRoot(props) {
5498
5630
  children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
5499
5631
  "div",
5500
5632
  {
5501
- ref: rootRef,
5502
- className: cx("avl-root", props.className),
5633
+ ...divProps,
5634
+ ref: mergeRefs(rootRef, ref),
5635
+ className: cx("avl-root", className),
5503
5636
  "data-avl-root": id,
5504
5637
  "data-color-mode": setting,
5505
5638
  suppressHydrationWarning: true,
@@ -5514,7 +5647,7 @@ function AnvilRoot(props) {
5514
5647
  ),
5515
5648
  /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("style", { children: css }),
5516
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: [
5517
- props.children,
5650
+ children,
5518
5651
  /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(SnackbarViewport, {})
5519
5652
  ] }) })
5520
5653
  ]