@eqtylab/equality 3.1.0 → 3.2.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
@@ -49,13 +49,13 @@ var styles26 = require('./form.module.module.css.module.css');
49
49
  var LabelPrimitive = require('@radix-ui/react-label');
50
50
  var styles25 = require('./label.module.module.css.module.css');
51
51
  var styles27 = require('./info-card.module.module.css.module.css');
52
- var styles28 = require('./input.module.module.css.module.css');
53
- var styles29 = require('./list-or-grid-view-toggle.module.module.css.module.css');
54
- var styles31 = require('./loading-overlay.module.module.css.module.css');
55
- var styles30 = require('./spinner.module.module.css.module.css');
56
- var styles32 = require('./metric-card.module.module.css.module.css');
52
+ var styles29 = require('./input.module.module.css.module.css');
57
53
  var react = require('motion/react');
58
- var styles33 = require('./motion-collapsible.module.module.css.module.css');
54
+ var styles28 = require('./motion-collapsible.module.module.css.module.css');
55
+ var styles30 = require('./list-or-grid-view-toggle.module.module.css.module.css');
56
+ var styles32 = require('./loading-overlay.module.module.css.module.css');
57
+ var styles31 = require('./spinner.module.module.css.module.css');
58
+ var styles33 = require('./metric-card.module.module.css.module.css');
59
59
  var styles34 = require('./page-not-found.module.module.css.module.css');
60
60
  var styles36 = require('./pagination.module.module.css.module.css');
61
61
  var SelectPrimitive = require('@radix-ui/react-select');
@@ -155,11 +155,11 @@ var styles26__default = /*#__PURE__*/_interopDefault(styles26);
155
155
  var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
156
156
  var styles25__default = /*#__PURE__*/_interopDefault(styles25);
157
157
  var styles27__default = /*#__PURE__*/_interopDefault(styles27);
158
- var styles28__default = /*#__PURE__*/_interopDefault(styles28);
159
158
  var styles29__default = /*#__PURE__*/_interopDefault(styles29);
160
- var styles31__default = /*#__PURE__*/_interopDefault(styles31);
159
+ var styles28__default = /*#__PURE__*/_interopDefault(styles28);
161
160
  var styles30__default = /*#__PURE__*/_interopDefault(styles30);
162
161
  var styles32__default = /*#__PURE__*/_interopDefault(styles32);
162
+ var styles31__default = /*#__PURE__*/_interopDefault(styles31);
163
163
  var styles33__default = /*#__PURE__*/_interopDefault(styles33);
164
164
  var styles34__default = /*#__PURE__*/_interopDefault(styles34);
165
165
  var styles36__default = /*#__PURE__*/_interopDefault(styles36);
@@ -2547,12 +2547,96 @@ var InfoCard = ({
2547
2547
  ] })
2548
2548
  ] }) }) });
2549
2549
  };
2550
+ var MotionCollapsibleContent = ({
2551
+ isOpen,
2552
+ children,
2553
+ className
2554
+ }) => {
2555
+ const [contentHeight, setContentHeight] = React15.useState(0);
2556
+ const contentRef = React15.useRef(null);
2557
+ React15.useEffect(() => {
2558
+ if (contentRef.current) {
2559
+ const resizeObserver = new ResizeObserver(() => {
2560
+ if (contentRef.current) {
2561
+ setContentHeight(contentRef.current.scrollHeight);
2562
+ }
2563
+ });
2564
+ resizeObserver.observe(contentRef.current);
2565
+ setContentHeight(contentRef.current.scrollHeight);
2566
+ return () => resizeObserver.disconnect();
2567
+ }
2568
+ }, [children]);
2569
+ return /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { initial: false, mode: "wait", children: isOpen && /* @__PURE__ */ jsxRuntime.jsx(
2570
+ react.motion.div,
2571
+ {
2572
+ initial: { height: 0, opacity: 0 },
2573
+ animate: { height: contentHeight, opacity: 1 },
2574
+ exit: { height: 0, opacity: 0 },
2575
+ transition: { duration: 0.3, ease: "easeInOut" },
2576
+ className: cn(styles28__default.default["motion-collapsible"], className),
2577
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: contentRef, children })
2578
+ },
2579
+ "motion-content"
2580
+ ) });
2581
+ };
2550
2582
  var Input = React15__namespace.forwardRef(
2551
- ({ className, type, prefix, suffix, ...props }, ref) => {
2552
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(styles28__default.default["input-wrapper"], className), children: [
2553
- prefix && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles28__default.default["input-prefix"], children: prefix }),
2554
- /* @__PURE__ */ jsxRuntime.jsx("input", { type, className: styles28__default.default["input-element"], ref, ...props }),
2555
- suffix && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles28__default.default["input-suffix"], children: suffix })
2583
+ ({
2584
+ className,
2585
+ containerClassName,
2586
+ type,
2587
+ prefix,
2588
+ suffix,
2589
+ helpText,
2590
+ errorText,
2591
+ "aria-describedby": ariaDescribedBy,
2592
+ "aria-invalid": ariaInvalid,
2593
+ ...props
2594
+ }, ref) => {
2595
+ const id = React15__namespace.useId();
2596
+ const helpTextId = `${id}-help-text`;
2597
+ const errorTextId = `${id}-error-text`;
2598
+ const errorList = Array.isArray(errorText) && errorText.every((message) => typeof message === "string") ? [...new Set(errorText.filter((message) => !!message))] : null;
2599
+ const hasErrorText = errorList ? errorList.length > 0 : !!errorText;
2600
+ const isMarkedInvalid = ariaInvalid !== void 0 && ariaInvalid !== false && ariaInvalid !== "false";
2601
+ const hasError = hasErrorText || isMarkedInvalid;
2602
+ const showHelpText = !!helpText && !hasErrorText;
2603
+ const describedBy = [ariaDescribedBy, showHelpText && helpTextId, hasErrorText && errorTextId].filter(Boolean).join(" ") || void 0;
2604
+ const errorIcon = /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.CircleAlert, { className: styles29__default.default["input-error-icon"], "aria-hidden": "true" });
2605
+ const errorMessage = errorList && errorList.length > 1 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { id: errorTextId, role: "alert", className: styles29__default.default["input-error-list"], children: errorList.map((message) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: styles29__default.default["input-error-text"], children: [
2606
+ errorIcon,
2607
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: message })
2608
+ ] }, message)) }) : /* @__PURE__ */ jsxRuntime.jsxs("p", { id: errorTextId, role: "alert", className: styles29__default.default["input-error-text"], children: [
2609
+ errorIcon,
2610
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: errorList ? errorList[0] : errorText })
2611
+ ] });
2612
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(styles29__default.default["input-container"], containerClassName), children: [
2613
+ /* @__PURE__ */ jsxRuntime.jsxs(
2614
+ "div",
2615
+ {
2616
+ className: cn(
2617
+ styles29__default.default["input-wrapper"],
2618
+ hasError && styles29__default.default["input-wrapper--error"],
2619
+ className
2620
+ ),
2621
+ children: [
2622
+ prefix && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles29__default.default["input-prefix"], children: prefix }),
2623
+ /* @__PURE__ */ jsxRuntime.jsx(
2624
+ "input",
2625
+ {
2626
+ type,
2627
+ className: styles29__default.default["input-element"],
2628
+ ref,
2629
+ "aria-invalid": isMarkedInvalid ? ariaInvalid : hasErrorText || void 0,
2630
+ "aria-describedby": describedBy,
2631
+ ...props
2632
+ }
2633
+ ),
2634
+ suffix && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles29__default.default["input-suffix"], children: suffix })
2635
+ ]
2636
+ }
2637
+ ),
2638
+ helpText ? hasErrorText && errorMessage : /* @__PURE__ */ jsxRuntime.jsx(MotionCollapsibleContent, { isOpen: hasErrorText, children: errorMessage }),
2639
+ showHelpText && /* @__PURE__ */ jsxRuntime.jsx("p", { id: helpTextId, className: styles29__default.default["input-help-text"], children: helpText })
2556
2640
  ] });
2557
2641
  }
2558
2642
  );
@@ -2570,7 +2654,7 @@ var ListOrGridViewToggle = ({
2570
2654
  const handleListClick = () => {
2571
2655
  onViewModeChange("list");
2572
2656
  };
2573
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(styles29__default.default["list-or-grid-view-toggle"], className), children: [
2657
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(styles30__default.default["list-or-grid-view-toggle"], className), children: [
2574
2658
  order.map((mode) => {
2575
2659
  const currentlyActive = mode === viewMode;
2576
2660
  const Icon3 = mode === "grid" ? LucideIcons.Grid3X3 : LucideIcons.List;
@@ -2580,8 +2664,8 @@ var ListOrGridViewToggle = ({
2580
2664
  type: "button",
2581
2665
  "aria-label": mode === "grid" ? "Grid view" : "List view",
2582
2666
  className: cn(
2583
- styles29__default.default["icon-button"],
2584
- currentlyActive ? styles29__default.default["icon-button--active"] : styles29__default.default["icon-button--inactive"]
2667
+ styles30__default.default["icon-button"],
2668
+ currentlyActive ? styles30__default.default["icon-button--active"] : styles30__default.default["icon-button--inactive"]
2585
2669
  ),
2586
2670
  onClick: mode === "grid" ? handleGridClick : handleListClick,
2587
2671
  children: /* @__PURE__ */ jsxRuntime.jsx(Icon3, { size: 16 })
@@ -2592,7 +2676,7 @@ var ListOrGridViewToggle = ({
2592
2676
  /* @__PURE__ */ jsxRuntime.jsx(
2593
2677
  "div",
2594
2678
  {
2595
- className: styles29__default.default["active-button-indicator"],
2679
+ className: styles30__default.default["active-button-indicator"],
2596
2680
  style: {
2597
2681
  transform: `translateX(${currentActiveIndex * 100}%)`,
2598
2682
  width: `${100 / order.length}%`
@@ -2602,43 +2686,43 @@ var ListOrGridViewToggle = ({
2602
2686
  ] });
2603
2687
  };
2604
2688
  var Spinner = ({ size = "md", variant = "primary" }) => {
2605
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles30__default.default["spinner-container"], children: [
2606
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(styles30__default.default["spinner"], styles30__default.default[size], styles30__default.default[variant]) }),
2607
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(styles30__default.default["spinner-background"], styles30__default.default[size]) })
2689
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles31__default.default["spinner-container"], children: [
2690
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(styles31__default.default["spinner"], styles31__default.default[size], styles31__default.default[variant]) }),
2691
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(styles31__default.default["spinner-background"], styles31__default.default[size]) })
2608
2692
  ] });
2609
2693
  };
2610
2694
  function LoadingOverlay({ isVisible, message = "Loading..." }) {
2611
2695
  if (!isVisible) return null;
2612
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles31__default.default["loading-overlay"], children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles31__default.default["content"], children: [
2696
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles32__default.default["loading-overlay"], children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles32__default.default["content"], children: [
2613
2697
  /* @__PURE__ */ jsxRuntime.jsx(Spinner, { variant: "primary" }),
2614
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: styles31__default.default["message"], children: message })
2698
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: styles32__default.default["message"], children: message })
2615
2699
  ] }) });
2616
2700
  }
2617
2701
  var metricCardElevationVariants = generateElevationVariants(
2618
- styles32__default.default,
2702
+ styles33__default.default,
2619
2703
  "metric-card",
2620
2704
  ELEVATION.RAISED
2621
2705
  );
2622
2706
  var VARIANTS = {
2623
2707
  default: {
2624
- text: styles32__default.default["text-default"],
2625
- iconBg: styles32__default.default["bg-default"]
2708
+ text: styles33__default.default["text-default"],
2709
+ iconBg: styles33__default.default["bg-default"]
2626
2710
  },
2627
2711
  primary: {
2628
- text: styles32__default.default["text-primary"],
2629
- iconBg: styles32__default.default["bg-primary"]
2712
+ text: styles33__default.default["text-primary"],
2713
+ iconBg: styles33__default.default["bg-primary"]
2630
2714
  },
2631
2715
  danger: {
2632
- text: styles32__default.default["text-danger"],
2633
- iconBg: styles32__default.default["bg-danger"]
2716
+ text: styles33__default.default["text-danger"],
2717
+ iconBg: styles33__default.default["bg-danger"]
2634
2718
  },
2635
2719
  success: {
2636
- text: styles32__default.default["text-success"],
2637
- iconBg: styles32__default.default["bg-success"]
2720
+ text: styles33__default.default["text-success"],
2721
+ iconBg: styles33__default.default["bg-success"]
2638
2722
  },
2639
2723
  warning: {
2640
- text: styles32__default.default["text-warning"],
2641
- iconBg: styles32__default.default["bg-warning"]
2724
+ text: styles33__default.default["text-warning"],
2725
+ iconBg: styles33__default.default["bg-warning"]
2642
2726
  }
2643
2727
  };
2644
2728
  var MetricCard = ({
@@ -2651,8 +2735,8 @@ var MetricCard = ({
2651
2735
  }) => {
2652
2736
  const variantStyles = VARIANTS[variant];
2653
2737
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(metricCardElevationVariants({ elevation }), className), children: [
2654
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles32__default.default["value-container"], children: [
2655
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: cn(styles32__default.default.value), children: value }),
2738
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles33__default.default["value-container"], children: [
2739
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: cn(styles33__default.default.value), children: value }),
2656
2740
  icon && /* @__PURE__ */ jsxRuntime.jsx(
2657
2741
  Icon,
2658
2742
  {
@@ -2663,41 +2747,9 @@ var MetricCard = ({
2663
2747
  }
2664
2748
  )
2665
2749
  ] }),
2666
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: styles32__default.default.label, children: label })
2750
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: styles33__default.default.label, children: label })
2667
2751
  ] });
2668
2752
  };
2669
- var MotionCollapsibleContent = ({
2670
- isOpen,
2671
- children,
2672
- className
2673
- }) => {
2674
- const [contentHeight, setContentHeight] = React15.useState(0);
2675
- const contentRef = React15.useRef(null);
2676
- React15.useEffect(() => {
2677
- if (contentRef.current) {
2678
- const resizeObserver = new ResizeObserver(() => {
2679
- if (contentRef.current) {
2680
- setContentHeight(contentRef.current.scrollHeight);
2681
- }
2682
- });
2683
- resizeObserver.observe(contentRef.current);
2684
- setContentHeight(contentRef.current.scrollHeight);
2685
- return () => resizeObserver.disconnect();
2686
- }
2687
- }, [children]);
2688
- return /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { initial: false, mode: "wait", children: isOpen && /* @__PURE__ */ jsxRuntime.jsx(
2689
- react.motion.div,
2690
- {
2691
- initial: { height: 0, opacity: 0 },
2692
- animate: { height: contentHeight, opacity: 1 },
2693
- exit: { height: 0, opacity: 0 },
2694
- transition: { duration: 0.3, ease: "easeInOut" },
2695
- className: cn(styles33__default.default["motion-collapsible"], className),
2696
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: contentRef, children })
2697
- },
2698
- "motion-content"
2699
- ) });
2700
- };
2701
2753
  var OctagonAlert = LucideIcons.AlertOctagon;
2702
2754
  var HomeIcon = LucideIcons.Home;
2703
2755
  var NotFound = ({