@eqtylab/equality 3.0.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 = ({
@@ -2801,6 +2853,8 @@ var SelectSeparator = React15__namespace.forwardRef(({ className, ...props }, re
2801
2853
  SelectSeparator.displayName = SelectPrimitive__namespace.Separator.displayName;
2802
2854
  var ChevronLeftIcon2 = LucideIcons.ChevronLeft;
2803
2855
  var ChevronRightIcon3 = LucideIcons.ChevronRight;
2856
+ var ChevronsLeftIcon = LucideIcons.ChevronsLeft;
2857
+ var ChevronsRightIcon = LucideIcons.ChevronsRight;
2804
2858
  var Pagination = ({
2805
2859
  currentPage,
2806
2860
  totalItems,
@@ -2810,6 +2864,7 @@ var Pagination = ({
2810
2864
  onItemsPerPageChange,
2811
2865
  itemsPerPageOptions = [10, 25, 50, 100],
2812
2866
  showInfo = true,
2867
+ showFirstLast = true,
2813
2868
  maxVisiblePages = 5,
2814
2869
  className = "",
2815
2870
  type = "",
@@ -2819,8 +2874,9 @@ var Pagination = ({
2819
2874
  const startItem = Math.min(filteredItems, 1 + (currentPage - 1) * itemsPerPage);
2820
2875
  const endItem = Math.min(currentPage * itemsPerPage, filteredItems);
2821
2876
  const hasFilteredItems = filteredItems > 0;
2822
- const isFirstPage = currentPage === 1;
2823
- const isLastPage = currentPage === totalPages;
2877
+ const isFirstPage = currentPage <= 1;
2878
+ const isLastPage = currentPage >= totalPages;
2879
+ const showFirstLastButtons = showFirstLast && totalPages > maxVisiblePages;
2824
2880
  if (totalItems <= itemsPerPageOptions[0]) {
2825
2881
  return null;
2826
2882
  }
@@ -2848,12 +2904,18 @@ var Pagination = ({
2848
2904
  onItemsPerPageChange?.(newItemsPerPage);
2849
2905
  onPageChange(1);
2850
2906
  };
2907
+ const handleFirstPage = () => {
2908
+ handlePageChange(1);
2909
+ };
2851
2910
  const handlePreviousPage = () => {
2852
2911
  handlePageChange(Math.max(1, currentPage - 1));
2853
2912
  };
2854
2913
  const handleNextPage = () => {
2855
2914
  handlePageChange(Math.min(totalPages, currentPage + 1));
2856
2915
  };
2916
+ const handleLastPage = () => {
2917
+ handlePageChange(totalPages);
2918
+ };
2857
2919
  const getVisiblePages = () => {
2858
2920
  const pageButtons = [];
2859
2921
  let startPage = 1;
@@ -2866,7 +2928,7 @@ var Pagination = ({
2866
2928
  startPage = totalPages - maxVisiblePages + 1;
2867
2929
  } else {
2868
2930
  startPage = currentPage - halfVisible;
2869
- endPage = currentPage + halfVisible;
2931
+ endPage = startPage + maxVisiblePages - 1;
2870
2932
  }
2871
2933
  }
2872
2934
  for (let i = startPage; i <= endPage; i++) {
@@ -2877,6 +2939,8 @@ var Pagination = ({
2877
2939
  variant: currentPage === i ? "primary" : "tertiary",
2878
2940
  size: "sm",
2879
2941
  onClick: () => handlePageChange(i),
2942
+ "aria-label": `Page ${i} of ${totalPages}`,
2943
+ "aria-current": currentPage === i ? "page" : void 0,
2880
2944
  children: i
2881
2945
  },
2882
2946
  i
@@ -2893,7 +2957,14 @@ var Pagination = ({
2893
2957
  " to"
2894
2958
  ] }),
2895
2959
  onItemsPerPageChange ? /* @__PURE__ */ jsxRuntime.jsxs(Select, { value: itemsPerPage.toString(), onValueChange: handleItemsPerPageChange, children: [
2896
- /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, {}) }),
2960
+ /* @__PURE__ */ jsxRuntime.jsx(
2961
+ SelectTrigger,
2962
+ {
2963
+ className: styles36__default.default["items-per-page-trigger"],
2964
+ "aria-label": "Items per page",
2965
+ children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, {})
2966
+ }
2967
+ ),
2897
2968
  /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: itemsPerPageOptions.map((option) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: option.toString(), children: option }, option)) })
2898
2969
  ] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: endItem }),
2899
2970
  /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
@@ -2903,7 +2974,18 @@ var Pagination = ({
2903
2974
  type
2904
2975
  ] })
2905
2976
  ] }) }),
2906
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles36__default.default["page-navigation-container"], children: [
2977
+ /* @__PURE__ */ jsxRuntime.jsxs("nav", { className: styles36__default.default["page-navigation-container"], "aria-label": "Pagination", children: [
2978
+ showFirstLastButtons && /* @__PURE__ */ jsxRuntime.jsx(
2979
+ Button,
2980
+ {
2981
+ variant: "tertiary",
2982
+ size: "sm",
2983
+ onClick: handleFirstPage,
2984
+ disabled: isFirstPage,
2985
+ "aria-label": "First page",
2986
+ children: /* @__PURE__ */ jsxRuntime.jsx(ChevronsLeftIcon, {})
2987
+ }
2988
+ ),
2907
2989
  /* @__PURE__ */ jsxRuntime.jsx(
2908
2990
  Button,
2909
2991
  {
@@ -2926,6 +3008,17 @@ var Pagination = ({
2926
3008
  "aria-label": "Next page",
2927
3009
  children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRightIcon3, {})
2928
3010
  }
3011
+ ),
3012
+ showFirstLastButtons && /* @__PURE__ */ jsxRuntime.jsx(
3013
+ Button,
3014
+ {
3015
+ variant: "tertiary",
3016
+ size: "sm",
3017
+ onClick: handleLastPage,
3018
+ disabled: isLastPage,
3019
+ "aria-label": `Last page (${totalPages})`,
3020
+ children: /* @__PURE__ */ jsxRuntime.jsx(ChevronsRightIcon, {})
3021
+ }
2929
3022
  )
2930
3023
  ] })
2931
3024
  ] });