@eqtylab/equality 4.11.0 → 4.13.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/CHANGELOG.md CHANGED
@@ -2,6 +2,59 @@
2
2
 
3
3
  Notable changes to Equality are recorded here, following [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
4
4
 
5
+ ## 4.13.0 - 2026-10-13
6
+
7
+ `Tabs` can be controlled with a `value` prop, so the indicator from 4.12.0 slides when the active
8
+ tab comes from outside, such as the URL. Existing code keeps working, but code that remounts
9
+ `Tabs` with `key` to change the tab has to pass `value` instead to get the slide.
10
+
11
+ ### Added
12
+
13
+ - A `value` prop on `Tabs`, so the active tab can be controlled. Code that remounts `Tabs` with
14
+ `key` to change the tab can pass `value` instead. The indicator then slides to the new tab
15
+ rather than jumping partway through.
16
+
17
+ ### Fixed
18
+
19
+ - A click on a controlled tab calls `onValueChange` once. Radix requests the tab on both mousedown
20
+ and focus, so a parent that commits the new value later, as React Router does, was called twice.
21
+
22
+ ## 4.12.0 - 2026-10-12
23
+
24
+ `Tabs` respond to hover, and filled `Tabs` match `SegmentedControls`. Two `SegmentedControls`
25
+ fixes come with it. No code needs to change.
26
+
27
+ ### Changed
28
+
29
+ - Hovering an inactive tab brightens its label. Filled tabs also show a faint fill inset inside
30
+ the track, and transparent tabs a faint underline where the active indicator sits. As on
31
+ `Button`, hover only applies on devices that can hover.
32
+ - Filled tabs share the `SegmentedControls` track and indicator: a translucent edge and sunken
33
+ inner shadow on the track, and an active fill inset 2px inside it with 3px corners and the
34
+ raised control shadow.
35
+ - The active indicator is a single element that slides beneath the labels instead of over them.
36
+ A one-tab move takes 250ms with the `SegmentedControls` easing, longer moves take a little
37
+ longer, up to 400ms, and reduced motion turns the slide off.
38
+ - Tab triggers have a pointer cursor and animate only colour, over 250ms. This includes
39
+ `TabsTrigger` used on its own, which no longer fades into its disabled opacity.
40
+
41
+ ### Fixed
42
+
43
+ - The keyboard focus ring on filled tabs is drawn inside the tab. Before, the track clipped it to
44
+ a sliver on one edge.
45
+ - The keyboard focus ring on the active segment of `SegmentedControls` is visible in light mode.
46
+ The background band meant to separate it from the indicator was the same width as the ring, so
47
+ the ring merged into the indicator's fill.
48
+ - Hover on `SegmentedControls` only applies on devices that can hover, as on `Button`, so a tapped
49
+ segment no longer stays highlighted on a touch screen.
50
+ - `SegmentedControls` no longer logs a `useLayoutEffect` warning when server-rendered with
51
+ React 18.
52
+
53
+ ### Deprecated
54
+
55
+ - The `id` prop on `Tabs`. It is optional and ignored, and only existed to pair the old animated
56
+ indicator across renders.
57
+
5
58
  ## 4.11.0 - 2026-10-06
6
59
 
7
60
  A visual refresh of `Button`. No props, variants or sizes change and no code needs to change.
package/dist/index.cjs CHANGED
@@ -3932,6 +3932,7 @@ var SectionHeading = ({
3932
3932
  hasRightContent && renderRightContent()
3933
3933
  ] });
3934
3934
  };
3935
+ var useIsomorphicLayoutEffect = typeof window === "undefined" ? React15.useEffect : React15.useLayoutEffect;
3935
3936
  var SegmentedControls = ({
3936
3937
  options,
3937
3938
  value,
@@ -3959,14 +3960,14 @@ var SegmentedControls = ({
3959
3960
  setIndicator({ left: activeSegment.offsetLeft, width: activeSegment.offsetWidth });
3960
3961
  }
3961
3962
  }, [value]);
3962
- React15.useLayoutEffect(() => {
3963
+ useIsomorphicLayoutEffect(() => {
3963
3964
  updateIndicator();
3964
3965
  }, [updateIndicator, options, effectiveDisplay, size]);
3965
3966
  React15.useEffect(() => {
3966
3967
  const frame = requestAnimationFrame(() => setAnimateIndicator(true));
3967
3968
  return () => cancelAnimationFrame(frame);
3968
3969
  }, []);
3969
- React15.useLayoutEffect(() => {
3970
+ useIsomorphicLayoutEffect(() => {
3970
3971
  const container = containerRef.current;
3971
3972
  if (!container) return;
3972
3973
  const observer = new ResizeObserver(updateIndicator);
@@ -4293,18 +4294,62 @@ TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
4293
4294
  var TabsContent = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(TabsPrimitive__namespace.Content, { ref, className: cn(styles57__default.default["tabs-content"], className), ...props }));
4294
4295
  TabsContent.displayName = TabsPrimitive__namespace.Content.displayName;
4295
4296
  var Tabs = ({
4296
- id,
4297
4297
  items,
4298
4298
  className,
4299
4299
  tabsListBackground = "transparent",
4300
+ value,
4300
4301
  defaultValue,
4301
4302
  onValueChange,
4302
4303
  staticRender = false
4303
4304
  }) => {
4304
- const [activeTab, setActiveTab] = React15.useState(defaultValue ?? items[0].value);
4305
+ const [uncontrolledTab, setUncontrolledTab] = React15.useState(defaultValue ?? items[0].value);
4306
+ const activeTab = value ?? uncontrolledTab;
4305
4307
  const isFilled = tabsListBackground === "filled";
4308
+ const listRef = React15.useRef(null);
4309
+ const triggerRefs = React15.useRef({});
4310
+ const [indicator, setIndicator] = React15.useState(null);
4311
+ const [animateIndicator, setAnimateIndicator] = React15.useState(false);
4312
+ const itemValues = items.map((item) => item.value).join("\0");
4313
+ const updateIndicator = React15.useCallback(() => {
4314
+ const activeTrigger = triggerRefs.current[activeTab];
4315
+ const width = activeTrigger?.offsetWidth ?? 0;
4316
+ if (!activeTrigger || width === 0) {
4317
+ setIndicator(null);
4318
+ return;
4319
+ }
4320
+ const left = activeTrigger.offsetLeft;
4321
+ setIndicator((previous) => {
4322
+ if (previous?.left === left && previous.width === width) return previous;
4323
+ const hops = previous ? Math.abs(left + width / 2 - (previous.left + previous.width / 2)) / ((width + previous.width) / 2) : 0;
4324
+ const duration = Math.min(400, Math.max(250, 250 + (hops - 1) * 100));
4325
+ return { left, width, duration };
4326
+ });
4327
+ }, [activeTab]);
4328
+ useIsomorphicLayoutEffect(() => {
4329
+ if (!staticRender) updateIndicator();
4330
+ }, [updateIndicator, itemValues, staticRender]);
4331
+ React15.useEffect(() => {
4332
+ const frame = requestAnimationFrame(() => setAnimateIndicator(true));
4333
+ return () => cancelAnimationFrame(frame);
4334
+ }, []);
4335
+ useIsomorphicLayoutEffect(() => {
4336
+ const list = listRef.current;
4337
+ if (!list || staticRender) return;
4338
+ const observer = new ResizeObserver(updateIndicator);
4339
+ observer.observe(list);
4340
+ for (const trigger of Object.values(triggerRefs.current)) {
4341
+ if (trigger) observer.observe(trigger);
4342
+ }
4343
+ return () => observer.disconnect();
4344
+ }, [updateIndicator, itemValues, staticRender]);
4345
+ const requestedTab = React15.useRef(null);
4306
4346
  const handleValueChange = (newTab) => {
4307
- setActiveTab(newTab);
4347
+ if (newTab === requestedTab.current) return;
4348
+ requestedTab.current = newTab;
4349
+ setTimeout(() => {
4350
+ requestedTab.current = null;
4351
+ });
4352
+ if (value === void 0) setUncontrolledTab(newTab);
4308
4353
  onValueChange?.(newTab);
4309
4354
  };
4310
4355
  const renderIcon = (icon) => {
@@ -4317,20 +4362,20 @@ var Tabs = ({
4317
4362
  styles58__default.default["active-tab-indicator"],
4318
4363
  isFilled ? styles58__default.default["active-tab-indicator--filled"] : styles58__default.default["active-tab-indicator--transparent"]
4319
4364
  );
4320
- const renderActiveStyle = (isActive) => {
4365
+ const renderTriggerIndicator = (value2) => {
4321
4366
  if (staticRender) {
4322
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(indicatorClass, styles58__default.default["active-tab-indicator--static"]) });
4323
- }
4324
- if (isActive) {
4325
4367
  return /* @__PURE__ */ jsxRuntime.jsx(
4326
- react.motion.span,
4368
+ "span",
4327
4369
  {
4328
- className: indicatorClass,
4329
- initial: false,
4330
- layoutId: `${id}-active-tab-indicator`
4370
+ "aria-hidden": true,
4371
+ "data-slot": "tabs-indicator",
4372
+ className: cn(indicatorClass, styles58__default.default["active-tab-indicator--static"])
4331
4373
  }
4332
4374
  );
4333
4375
  }
4376
+ if (!indicator && value2 === activeTab) {
4377
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, "data-slot": "tabs-indicator", className: indicatorClass });
4378
+ }
4334
4379
  return null;
4335
4380
  };
4336
4381
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -4340,44 +4385,66 @@ var Tabs = ({
4340
4385
  onValueChange: handleValueChange,
4341
4386
  className: cn(styles58__default.default["tabs"], className),
4342
4387
  children: [
4343
- /* @__PURE__ */ jsxRuntime.jsx(
4388
+ /* @__PURE__ */ jsxRuntime.jsxs(
4344
4389
  TabsList,
4345
4390
  {
4391
+ ref: listRef,
4346
4392
  className: cn(
4347
4393
  styles58__default.default["tabs-list"],
4348
4394
  isFilled ? styles58__default.default["tabs-list--filled"] : styles58__default.default["tabs-list--transparent"]
4349
4395
  ),
4350
- children: items.map(({ label, value, icon, suffix, triggerProps }) => {
4351
- const isActive = activeTab === value;
4352
- return /* @__PURE__ */ React15.createElement(
4353
- TabsTrigger,
4396
+ children: [
4397
+ items.map(({ label, value: value2, icon, suffix, triggerProps }) => {
4398
+ return /* @__PURE__ */ React15.createElement(
4399
+ TabsTrigger,
4400
+ {
4401
+ ...triggerProps,
4402
+ key: value2,
4403
+ ref: (el) => {
4404
+ triggerRefs.current[value2] = el;
4405
+ },
4406
+ value: value2,
4407
+ className: cn(
4408
+ styles58__default.default["tabs-trigger"],
4409
+ isFilled ? styles58__default.default["tabs-trigger--filled"] : styles58__default.default["tabs-trigger--transparent"],
4410
+ triggerProps?.className
4411
+ )
4412
+ },
4413
+ renderIcon(icon),
4414
+ label,
4415
+ suffix,
4416
+ renderTriggerIndicator(value2)
4417
+ );
4418
+ }),
4419
+ !staticRender && indicator && /* @__PURE__ */ jsxRuntime.jsx(
4420
+ "span",
4354
4421
  {
4355
- ...triggerProps,
4356
- key: value,
4357
- value,
4422
+ "aria-hidden": true,
4423
+ "data-slot": "tabs-indicator",
4358
4424
  className: cn(
4359
- styles58__default.default["tabs-trigger"],
4360
- isFilled ? styles58__default.default["tabs-trigger--filled"] : styles58__default.default["tabs-trigger--transparent"],
4361
- triggerProps?.className
4362
- )
4363
- },
4364
- renderIcon(icon),
4365
- label,
4366
- suffix,
4367
- renderActiveStyle(isActive)
4368
- );
4369
- })
4425
+ indicatorClass,
4426
+ styles58__default.default["active-tab-indicator--shared"],
4427
+ animateIndicator && styles58__default.default["active-tab-indicator--animated"]
4428
+ ),
4429
+ style: {
4430
+ transform: `translateX(${indicator.left}px)`,
4431
+ "--indicator-width": `${indicator.width}px`,
4432
+ "--indicator-duration": `${indicator.duration}ms`
4433
+ }
4434
+ }
4435
+ )
4436
+ ]
4370
4437
  }
4371
4438
  ),
4372
- items.map(({ value, content }) => /* @__PURE__ */ jsxRuntime.jsx(
4439
+ items.map(({ value: value2, content }) => /* @__PURE__ */ jsxRuntime.jsx(
4373
4440
  TabsContent,
4374
4441
  {
4375
- value,
4442
+ value: value2,
4376
4443
  className: styles58__default.default["content"],
4377
4444
  forceMount: staticRender || void 0,
4378
4445
  children: content
4379
4446
  },
4380
- value
4447
+ value2
4381
4448
  ))
4382
4449
  ]
4383
4450
  }