@eqtylab/equality 4.11.0 → 4.12.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,42 @@
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.12.0 - 2026-10-12
6
+
7
+ `Tabs` respond to hover, and filled `Tabs` match `SegmentedControls`. Two `SegmentedControls`
8
+ fixes come with it. No code needs to change.
9
+
10
+ ### Changed
11
+
12
+ - Hovering an inactive tab brightens its label. Filled tabs also show a faint fill inset inside
13
+ the track, and transparent tabs a faint underline where the active indicator sits. As on
14
+ `Button`, hover only applies on devices that can hover.
15
+ - Filled tabs share the `SegmentedControls` track and indicator: a translucent edge and sunken
16
+ inner shadow on the track, and an active fill inset 2px inside it with 3px corners and the
17
+ raised control shadow.
18
+ - The active indicator is a single element that slides beneath the labels instead of over them.
19
+ A one-tab move takes 250ms with the `SegmentedControls` easing, longer moves take a little
20
+ longer, up to 400ms, and reduced motion turns the slide off.
21
+ - Tab triggers have a pointer cursor and animate only colour, over 250ms. This includes
22
+ `TabsTrigger` used on its own, which no longer fades into its disabled opacity.
23
+
24
+ ### Fixed
25
+
26
+ - The keyboard focus ring on filled tabs is drawn inside the tab. Before, the track clipped it to
27
+ a sliver on one edge.
28
+ - The keyboard focus ring on the active segment of `SegmentedControls` is visible in light mode.
29
+ The background band meant to separate it from the indicator was the same width as the ring, so
30
+ the ring merged into the indicator's fill.
31
+ - Hover on `SegmentedControls` only applies on devices that can hover, as on `Button`, so a tapped
32
+ segment no longer stays highlighted on a touch screen.
33
+ - `SegmentedControls` no longer logs a `useLayoutEffect` warning when server-rendered with
34
+ React 18.
35
+
36
+ ### Deprecated
37
+
38
+ - The `id` prop on `Tabs`. It is optional and ignored, and only existed to pair the old animated
39
+ indicator across renders.
40
+
5
41
  ## 4.11.0 - 2026-10-06
6
42
 
7
43
  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,7 +4294,6 @@ 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",
@@ -4303,6 +4303,43 @@ var Tabs = ({
4303
4303
  }) => {
4304
4304
  const [activeTab, setActiveTab] = React15.useState(defaultValue ?? items[0].value);
4305
4305
  const isFilled = tabsListBackground === "filled";
4306
+ const listRef = React15.useRef(null);
4307
+ const triggerRefs = React15.useRef({});
4308
+ const [indicator, setIndicator] = React15.useState(null);
4309
+ const [animateIndicator, setAnimateIndicator] = React15.useState(false);
4310
+ const itemValues = items.map((item) => item.value).join("\0");
4311
+ const updateIndicator = React15.useCallback(() => {
4312
+ const activeTrigger = triggerRefs.current[activeTab];
4313
+ const width = activeTrigger?.offsetWidth ?? 0;
4314
+ if (!activeTrigger || width === 0) {
4315
+ setIndicator(null);
4316
+ return;
4317
+ }
4318
+ const left = activeTrigger.offsetLeft;
4319
+ setIndicator((previous) => {
4320
+ if (previous?.left === left && previous.width === width) return previous;
4321
+ const hops = previous ? Math.abs(left + width / 2 - (previous.left + previous.width / 2)) / ((width + previous.width) / 2) : 0;
4322
+ const duration = Math.min(400, Math.max(250, 250 + (hops - 1) * 100));
4323
+ return { left, width, duration };
4324
+ });
4325
+ }, [activeTab]);
4326
+ useIsomorphicLayoutEffect(() => {
4327
+ if (!staticRender) updateIndicator();
4328
+ }, [updateIndicator, itemValues, staticRender]);
4329
+ React15.useEffect(() => {
4330
+ const frame = requestAnimationFrame(() => setAnimateIndicator(true));
4331
+ return () => cancelAnimationFrame(frame);
4332
+ }, []);
4333
+ useIsomorphicLayoutEffect(() => {
4334
+ const list = listRef.current;
4335
+ if (!list || staticRender) return;
4336
+ const observer = new ResizeObserver(updateIndicator);
4337
+ observer.observe(list);
4338
+ for (const trigger of Object.values(triggerRefs.current)) {
4339
+ if (trigger) observer.observe(trigger);
4340
+ }
4341
+ return () => observer.disconnect();
4342
+ }, [updateIndicator, itemValues, staticRender]);
4306
4343
  const handleValueChange = (newTab) => {
4307
4344
  setActiveTab(newTab);
4308
4345
  onValueChange?.(newTab);
@@ -4317,20 +4354,20 @@ var Tabs = ({
4317
4354
  styles58__default.default["active-tab-indicator"],
4318
4355
  isFilled ? styles58__default.default["active-tab-indicator--filled"] : styles58__default.default["active-tab-indicator--transparent"]
4319
4356
  );
4320
- const renderActiveStyle = (isActive) => {
4357
+ const renderTriggerIndicator = (value) => {
4321
4358
  if (staticRender) {
4322
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(indicatorClass, styles58__default.default["active-tab-indicator--static"]) });
4323
- }
4324
- if (isActive) {
4325
4359
  return /* @__PURE__ */ jsxRuntime.jsx(
4326
- react.motion.span,
4360
+ "span",
4327
4361
  {
4328
- className: indicatorClass,
4329
- initial: false,
4330
- layoutId: `${id}-active-tab-indicator`
4362
+ "aria-hidden": true,
4363
+ "data-slot": "tabs-indicator",
4364
+ className: cn(indicatorClass, styles58__default.default["active-tab-indicator--static"])
4331
4365
  }
4332
4366
  );
4333
4367
  }
4368
+ if (!indicator && value === activeTab) {
4369
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, "data-slot": "tabs-indicator", className: indicatorClass });
4370
+ }
4334
4371
  return null;
4335
4372
  };
4336
4373
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -4340,33 +4377,55 @@ var Tabs = ({
4340
4377
  onValueChange: handleValueChange,
4341
4378
  className: cn(styles58__default.default["tabs"], className),
4342
4379
  children: [
4343
- /* @__PURE__ */ jsxRuntime.jsx(
4380
+ /* @__PURE__ */ jsxRuntime.jsxs(
4344
4381
  TabsList,
4345
4382
  {
4383
+ ref: listRef,
4346
4384
  className: cn(
4347
4385
  styles58__default.default["tabs-list"],
4348
4386
  isFilled ? styles58__default.default["tabs-list--filled"] : styles58__default.default["tabs-list--transparent"]
4349
4387
  ),
4350
- children: items.map(({ label, value, icon, suffix, triggerProps }) => {
4351
- const isActive = activeTab === value;
4352
- return /* @__PURE__ */ React15.createElement(
4353
- TabsTrigger,
4388
+ children: [
4389
+ items.map(({ label, value, icon, suffix, triggerProps }) => {
4390
+ return /* @__PURE__ */ React15.createElement(
4391
+ TabsTrigger,
4392
+ {
4393
+ ...triggerProps,
4394
+ key: value,
4395
+ ref: (el) => {
4396
+ triggerRefs.current[value] = el;
4397
+ },
4398
+ value,
4399
+ className: cn(
4400
+ styles58__default.default["tabs-trigger"],
4401
+ isFilled ? styles58__default.default["tabs-trigger--filled"] : styles58__default.default["tabs-trigger--transparent"],
4402
+ triggerProps?.className
4403
+ )
4404
+ },
4405
+ renderIcon(icon),
4406
+ label,
4407
+ suffix,
4408
+ renderTriggerIndicator(value)
4409
+ );
4410
+ }),
4411
+ !staticRender && indicator && /* @__PURE__ */ jsxRuntime.jsx(
4412
+ "span",
4354
4413
  {
4355
- ...triggerProps,
4356
- key: value,
4357
- value,
4414
+ "aria-hidden": true,
4415
+ "data-slot": "tabs-indicator",
4358
4416
  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
- })
4417
+ indicatorClass,
4418
+ styles58__default.default["active-tab-indicator--shared"],
4419
+ animateIndicator && styles58__default.default["active-tab-indicator--animated"]
4420
+ ),
4421
+ style: {
4422
+ transform: `translateX(${indicator.left}px)`,
4423
+ "--indicator-width": `${indicator.width}px`,
4424
+ "--indicator-duration": `${indicator.duration}ms`
4425
+ }
4426
+ }
4427
+ )
4428
+ ]
4370
4429
  }
4371
4430
  ),
4372
4431
  items.map(({ value, content }) => /* @__PURE__ */ jsxRuntime.jsx(