@eqtylab/equality 4.4.2 → 4.5.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
@@ -3931,6 +3931,7 @@ var SegmentedControls = ({
3931
3931
  value,
3932
3932
  onValueChange,
3933
3933
  display = "both",
3934
+ size = "md",
3934
3935
  className
3935
3936
  }) => {
3936
3937
  const allHaveIcons = options.every((option) => option.icon != null);
@@ -3942,6 +3943,7 @@ var SegmentedControls = ({
3942
3943
  left: 0,
3943
3944
  width: 0
3944
3945
  });
3946
+ const [animateIndicator, setAnimateIndicator] = React15.useState(false);
3945
3947
  const updateIndicator = React15.useCallback(() => {
3946
3948
  const activeSegment = segmentRefs.current[value];
3947
3949
  if (activeSegment) {
@@ -3950,7 +3952,11 @@ var SegmentedControls = ({
3950
3952
  }, [value]);
3951
3953
  React15.useLayoutEffect(() => {
3952
3954
  updateIndicator();
3953
- }, [updateIndicator, options, effectiveDisplay]);
3955
+ }, [updateIndicator, options, effectiveDisplay, size]);
3956
+ React15.useEffect(() => {
3957
+ const frame = requestAnimationFrame(() => setAnimateIndicator(true));
3958
+ return () => cancelAnimationFrame(frame);
3959
+ }, []);
3954
3960
  React15.useLayoutEffect(() => {
3955
3961
  const container = containerRef.current;
3956
3962
  if (!container) return;
@@ -3958,44 +3964,57 @@ var SegmentedControls = ({
3958
3964
  observer.observe(container);
3959
3965
  return () => observer.disconnect();
3960
3966
  }, [updateIndicator]);
3961
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: cn(styles49__default.default["segmented-controls"], className), children: [
3962
- options.map((option) => {
3963
- const currentlyActive = option.value === value;
3964
- const showIcon = option.icon != null && effectiveDisplay !== "text-only";
3965
- const showLabel = effectiveDisplay !== "icon-only";
3966
- return /* @__PURE__ */ jsxRuntime.jsxs(
3967
- "button",
3968
- {
3969
- ref: (el) => {
3970
- segmentRefs.current[option.value] = el;
3971
- },
3972
- type: "button",
3973
- "aria-pressed": currentlyActive,
3974
- "aria-label": isIconOnly ? option.label : void 0,
3975
- title: isIconOnly ? option.label : void 0,
3976
- className: cn(
3977
- styles49__default.default["segment"],
3978
- isIconOnly && styles49__default.default["segment--icon-only"],
3979
- currentlyActive ? styles49__default.default["segment--active"] : styles49__default.default["segment--inactive"]
3980
- ),
3981
- onClick: () => onValueChange(option.value),
3982
- children: [
3983
- showIcon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { icon: option.icon, size: "xs", className: styles49__default.default["segment-icon"] }),
3984
- showLabel && /* @__PURE__ */ jsxRuntime.jsx("span", { children: option.label }),
3985
- !isIconOnly && option.suffix && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles49__default.default["segment-suffix"], children: option.suffix })
3986
- ]
3987
- },
3988
- option.value
3989
- );
3990
- }),
3991
- /* @__PURE__ */ jsxRuntime.jsx(
3992
- "div",
3993
- {
3994
- className: styles49__default.default["active-segment-indicator"],
3995
- style: { transform: `translateX(${indicator.left}px)`, width: `${indicator.width}px` }
3996
- }
3997
- )
3998
- ] });
3967
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3968
+ "div",
3969
+ {
3970
+ ref: containerRef,
3971
+ className: cn(styles49__default.default["segmented-controls"], styles49__default.default[`size--${size}`], className),
3972
+ children: [
3973
+ options.map((option) => {
3974
+ const currentlyActive = option.value === value;
3975
+ const showIcon = option.icon != null && effectiveDisplay !== "text-only";
3976
+ const showLabel = effectiveDisplay !== "icon-only";
3977
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3978
+ "button",
3979
+ {
3980
+ ref: (el) => {
3981
+ segmentRefs.current[option.value] = el;
3982
+ },
3983
+ type: "button",
3984
+ "aria-pressed": currentlyActive,
3985
+ "aria-label": isIconOnly ? option.label : void 0,
3986
+ title: isIconOnly ? option.label : void 0,
3987
+ className: cn(
3988
+ styles49__default.default["segment"],
3989
+ isIconOnly && styles49__default.default["segment--icon-only"],
3990
+ currentlyActive ? styles49__default.default["segment--active"] : styles49__default.default["segment--inactive"]
3991
+ ),
3992
+ onClick: () => onValueChange(option.value),
3993
+ children: [
3994
+ showIcon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { icon: option.icon, size: "xs", className: styles49__default.default["segment-icon"] }),
3995
+ showLabel && /* @__PURE__ */ jsxRuntime.jsx("span", { children: option.label }),
3996
+ !isIconOnly && option.suffix && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles49__default.default["segment-suffix"], children: option.suffix })
3997
+ ]
3998
+ },
3999
+ option.value
4000
+ );
4001
+ }),
4002
+ /* @__PURE__ */ jsxRuntime.jsx(
4003
+ "div",
4004
+ {
4005
+ className: cn(
4006
+ styles49__default.default["active-segment-indicator"],
4007
+ animateIndicator && styles49__default.default["active-segment-indicator--animated"]
4008
+ ),
4009
+ style: {
4010
+ transform: `translateX(${indicator.left}px)`,
4011
+ "--indicator-width": `${indicator.width}px`
4012
+ }
4013
+ }
4014
+ )
4015
+ ]
4016
+ }
4017
+ );
3999
4018
  };
4000
4019
  var Separator3 = React15__namespace.forwardRef(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
4001
4020
  SeparatorPrimitive__namespace.Root,