@fuf-stack/pixels 0.29.3 → 0.30.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.
Files changed (92) hide show
  1. package/dist/Accordion/index.cjs +3 -3
  2. package/dist/Accordion/index.js +2 -2
  3. package/dist/Avatar/index.cjs +1 -1
  4. package/dist/Avatar/index.js +1 -1
  5. package/dist/AvatarGroup/index.cjs +3 -3
  6. package/dist/AvatarGroup/index.js +2 -2
  7. package/dist/Badge/index.cjs +1 -1
  8. package/dist/Badge/index.js +1 -1
  9. package/dist/Breadcrumb/index.cjs +3 -3
  10. package/dist/Breadcrumb/index.js +2 -2
  11. package/dist/Button/index.cjs +1 -1
  12. package/dist/Button/index.js +1 -1
  13. package/dist/Card/index.cjs +3 -3
  14. package/dist/Card/index.js +2 -2
  15. package/dist/Json/index.cjs +3 -3
  16. package/dist/Json/index.d.cts +3 -2
  17. package/dist/Json/index.d.ts +3 -2
  18. package/dist/Json/index.js +2 -2
  19. package/dist/Json-DZue23GO.d.cts +24 -0
  20. package/dist/Json-DZue23GO.d.ts +24 -0
  21. package/dist/Label/index.cjs +1 -1
  22. package/dist/Label/index.js +1 -1
  23. package/dist/Menu/index.cjs +3 -3
  24. package/dist/Menu/index.js +2 -2
  25. package/dist/Modal/index.cjs +1 -1
  26. package/dist/Modal/index.js +1 -1
  27. package/dist/Popover/index.cjs +3 -3
  28. package/dist/Popover/index.js +2 -2
  29. package/dist/ScrollShadow/index.cjs +1 -1
  30. package/dist/ScrollShadow/index.js +1 -1
  31. package/dist/Table/index.cjs +112 -0
  32. package/dist/Table/index.cjs.map +1 -0
  33. package/dist/Table/index.d.cts +244 -0
  34. package/dist/Table/index.d.ts +244 -0
  35. package/dist/Table/index.js +112 -0
  36. package/dist/Table/index.js.map +1 -0
  37. package/dist/Tabs/index.cjs +1 -1
  38. package/dist/Tabs/index.js +1 -1
  39. package/dist/Tooltip/index.cjs +1 -1
  40. package/dist/Tooltip/index.js +1 -1
  41. package/dist/{chunk-37C63OKM.cjs → chunk-2WDAJ6ER.cjs} +9 -5
  42. package/dist/chunk-2WDAJ6ER.cjs.map +1 -0
  43. package/dist/{chunk-EIOL2HNA.js → chunk-33DBA7U2.js} +8 -5
  44. package/dist/{chunk-EIOL2HNA.js.map → chunk-33DBA7U2.js.map} +1 -1
  45. package/dist/{chunk-JDLU5AUA.js → chunk-3QI2ODV2.js} +9 -5
  46. package/dist/{chunk-JDLU5AUA.js.map → chunk-3QI2ODV2.js.map} +1 -1
  47. package/dist/{chunk-L2RCVUXK.js → chunk-7LABJBKF.js} +2 -2
  48. package/dist/{chunk-L2RCVUXK.js.map → chunk-7LABJBKF.js.map} +1 -1
  49. package/dist/{chunk-OP6ST4KB.cjs → chunk-7XJHVFT3.cjs} +16 -14
  50. package/dist/chunk-7XJHVFT3.cjs.map +1 -0
  51. package/dist/{chunk-JPALSO5E.cjs → chunk-AVYWDZ7X.cjs} +8 -4
  52. package/dist/chunk-AVYWDZ7X.cjs.map +1 -0
  53. package/dist/{chunk-APEDJG3R.js → chunk-CZJKT7IC.js} +7 -3
  54. package/dist/{chunk-APEDJG3R.js.map → chunk-CZJKT7IC.js.map} +1 -1
  55. package/dist/chunk-D4TLDLEX.cjs +63 -0
  56. package/dist/chunk-D4TLDLEX.cjs.map +1 -0
  57. package/dist/{chunk-5WRI5ZAA.js → chunk-J7N2552D.js} +33 -1
  58. package/dist/{chunk-C2BIHVLT.js → chunk-LCSYN3DI.js} +180 -96
  59. package/dist/chunk-LCSYN3DI.js.map +1 -0
  60. package/dist/{chunk-RMLPCTDU.js → chunk-LPCCBJ2T.js} +8 -5
  61. package/dist/{chunk-RMLPCTDU.js.map → chunk-LPCCBJ2T.js.map} +1 -1
  62. package/dist/{chunk-5HEZFVFG.cjs → chunk-LY45VQ2E.cjs} +3 -3
  63. package/dist/chunk-LY45VQ2E.cjs.map +1 -0
  64. package/dist/{chunk-RJAVAHBK.cjs → chunk-NVNT4PMS.cjs} +9 -6
  65. package/dist/chunk-NVNT4PMS.cjs.map +1 -0
  66. package/dist/{chunk-XFUHF75Z.cjs → chunk-OLKLIWBE.cjs} +213 -129
  67. package/dist/chunk-OLKLIWBE.cjs.map +1 -0
  68. package/dist/{chunk-337S7HUF.js → chunk-XVCKJE3P.js} +14 -12
  69. package/dist/{chunk-337S7HUF.js.map → chunk-XVCKJE3P.js.map} +1 -1
  70. package/dist/{chunk-VHEIRVBB.cjs → chunk-ZXGEK67F.cjs} +9 -6
  71. package/dist/chunk-ZXGEK67F.cjs.map +1 -0
  72. package/dist/hooks/index.cjs +1 -1
  73. package/dist/hooks/index.js +1 -1
  74. package/dist/index.cjs +15 -15
  75. package/dist/index.cjs.map +1 -1
  76. package/dist/index.d.cts +1 -1
  77. package/dist/index.d.ts +1 -1
  78. package/dist/index.js +17 -17
  79. package/package.json +26 -20
  80. package/dist/Json-BbMeuEvE.d.cts +0 -18
  81. package/dist/Json-BbMeuEvE.d.ts +0 -18
  82. package/dist/chunk-37C63OKM.cjs.map +0 -1
  83. package/dist/chunk-5HEZFVFG.cjs.map +0 -1
  84. package/dist/chunk-C2BIHVLT.js.map +0 -1
  85. package/dist/chunk-DZUJEN5N.cjs +0 -31
  86. package/dist/chunk-DZUJEN5N.cjs.map +0 -1
  87. package/dist/chunk-JPALSO5E.cjs.map +0 -1
  88. package/dist/chunk-OP6ST4KB.cjs.map +0 -1
  89. package/dist/chunk-RJAVAHBK.cjs.map +0 -1
  90. package/dist/chunk-VHEIRVBB.cjs.map +0 -1
  91. package/dist/chunk-XFUHF75Z.cjs.map +0 -1
  92. /package/dist/{chunk-5WRI5ZAA.js.map → chunk-J7N2552D.js.map} +0 -0
@@ -3,8 +3,10 @@ import {
3
3
  } from "./chunk-ODLZQXBE.js";
4
4
  import {
5
5
  __commonJS,
6
+ __spreadProps,
7
+ __spreadValues,
6
8
  __toESM
7
- } from "./chunk-5WRI5ZAA.js";
9
+ } from "./chunk-J7N2552D.js";
8
10
 
9
11
  // ../../node_modules/.pnpm/@babel+runtime@7.26.0/node_modules/@babel/runtime/helpers/extends.js
10
12
  var require_extends = __commonJS({
@@ -52,9 +54,7 @@ var require_objectDestructuringEmpty = __commonJS({
52
54
  });
53
55
 
54
56
  // src/Json/Json.tsx
55
- import { useState as useState3 } from "react";
56
- import { FaChevronDown, FaChevronUp, FaTimesCircle } from "react-icons/fa";
57
- import { HiOutlineClipboard, HiOutlineClipboardCheck } from "react-icons/hi";
57
+ import { useMemo as useMemo2, useState as useState3 } from "react";
58
58
 
59
59
  // ../../node_modules/.pnpm/@uiw+react-json-view@2.0.0-alpha.30_@babel+runtime@7.26.0_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/@uiw/react-json-view/esm/index.js
60
60
  var import_extends21 = __toESM(require_extends());
@@ -2562,120 +2562,204 @@ var vscodeTheme = {
2562
2562
 
2563
2563
  // src/Json/Json.tsx
2564
2564
  import { useTheme } from "next-themes";
2565
- import { cn } from "@fuf-stack/pixel-utils";
2566
- import { Fragment as Fragment3, jsx, jsxs } from "react/jsx-runtime";
2565
+ import { cn as cn2 } from "@fuf-stack/pixel-utils";
2566
+
2567
+ // src/Json/jsonParser.ts
2568
+ var JsonParseError = class extends Error {
2569
+ constructor(message) {
2570
+ super(message);
2571
+ this.name = "JsonParseError";
2572
+ }
2573
+ };
2567
2574
  var getValue = (value) => {
2568
2575
  if (typeof value === "string") {
2569
- return JSON.parse(value);
2576
+ try {
2577
+ return JSON.parse(value);
2578
+ } catch (error) {
2579
+ throw new JsonParseError(
2580
+ `Invalid JSON string: ${error.message}`
2581
+ );
2582
+ }
2583
+ }
2584
+ if (value === null || value === void 0) {
2585
+ throw new JsonParseError("Value cannot be null or undefined");
2570
2586
  }
2571
2587
  if (typeof value === "object") {
2572
2588
  return value;
2573
2589
  }
2574
- throw new Error(`${typeof value} can not be visualized`);
2590
+ throw new JsonParseError(`${typeof value} cannot be visualized`);
2591
+ };
2592
+
2593
+ // src/Json/subcomponents/CopiedRenderer.tsx
2594
+ import { HiOutlineClipboard, HiOutlineClipboardCheck } from "react-icons/hi";
2595
+ import { cn } from "@fuf-stack/pixel-utils";
2596
+ import { jsx } from "react/jsx-runtime";
2597
+ var CopiedRenderer = () => {
2598
+ return /* @__PURE__ */ jsx(
2599
+ esm_default.Copied,
2600
+ {
2601
+ render: (props) => {
2602
+ const { style, onClick, className } = props;
2603
+ const isCopied = props["data-copied"];
2604
+ const elmClasses = cn(
2605
+ className,
2606
+ "absolute -right-4 -top-[2px] h-4 w-4 !fill-transparent pl-1",
2607
+ { "text-success": isCopied }
2608
+ );
2609
+ const handleKeyDown = (e) => {
2610
+ if (e.key === "Enter" || e.key === " ") {
2611
+ onClick == null ? void 0 : onClick(e);
2612
+ }
2613
+ };
2614
+ return /* @__PURE__ */ jsx(
2615
+ "span",
2616
+ {
2617
+ className: "relative !ml-0 !h-[1em] !w-0",
2618
+ style,
2619
+ "data-testid": "copy-button",
2620
+ role: "button",
2621
+ tabIndex: 0,
2622
+ onKeyDown: handleKeyDown,
2623
+ onClick: (e) => onClick == null ? void 0 : onClick(e),
2624
+ "aria-label": isCopied ? "Copied to clipboard" : "Copy to clipboard",
2625
+ children: isCopied ? /* @__PURE__ */ jsx(HiOutlineClipboardCheck, { className: elmClasses }) : /* @__PURE__ */ jsx(HiOutlineClipboard, { className: elmClasses })
2626
+ }
2627
+ );
2628
+ }
2629
+ }
2630
+ );
2575
2631
  };
2576
- var Json = ({ className = null, collapsed = false, value }) => {
2632
+ var CopiedRenderer_default = CopiedRenderer;
2633
+
2634
+ // src/Json/subcomponents/ErrorRenderer.tsx
2635
+ import { FaChevronDown, FaChevronUp, FaTimesCircle } from "react-icons/fa";
2636
+ import { Fragment as Fragment3, jsx as jsx2, jsxs } from "react/jsx-runtime";
2637
+ var ErrorRenderer = ({
2638
+ error,
2639
+ data,
2640
+ showDetails,
2641
+ onToggleDetails
2642
+ }) => {
2643
+ return /* @__PURE__ */ jsxs(
2644
+ "div",
2645
+ {
2646
+ className: "mb-4 flex flex-col items-center rounded-lg border border-danger bg-danger-50 p-4 text-sm text-danger",
2647
+ role: "alert",
2648
+ "aria-live": "polite",
2649
+ children: [
2650
+ /* @__PURE__ */ jsxs("div", { className: "flex w-full justify-between gap-6", children: [
2651
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
2652
+ /* @__PURE__ */ jsx2(FaTimesCircle, { className: "mr-2", "aria-hidden": "true" }),
2653
+ /* @__PURE__ */ jsx2("span", { className: "font-medium", children: "Failed to parse JSON data" })
2654
+ ] }),
2655
+ /* @__PURE__ */ jsx2(
2656
+ Button_default,
2657
+ {
2658
+ color: "danger",
2659
+ size: "sm",
2660
+ variant: "light",
2661
+ onClick: onToggleDetails,
2662
+ "aria-expanded": showDetails,
2663
+ "aria-controls": "error-details",
2664
+ children: showDetails ? /* @__PURE__ */ jsxs(Fragment3, { children: [
2665
+ /* @__PURE__ */ jsx2(FaChevronUp, { "aria-hidden": "true" }),
2666
+ " Hide Details"
2667
+ ] }) : /* @__PURE__ */ jsxs(Fragment3, { children: [
2668
+ /* @__PURE__ */ jsx2(FaChevronDown, { "aria-hidden": "true" }),
2669
+ " Show Details"
2670
+ ] })
2671
+ }
2672
+ )
2673
+ ] }),
2674
+ showDetails && /* @__PURE__ */ jsxs("div", { id: "error-details", className: "mt-4 w-full text-left", children: [
2675
+ /* @__PURE__ */ jsxs("div", { children: [
2676
+ /* @__PURE__ */ jsx2("strong", { children: "Error:" }),
2677
+ /* @__PURE__ */ jsx2("pre", { children: error instanceof Error ? `${error.name}: ${error.message}` : "Unknown error" })
2678
+ ] }),
2679
+ /* @__PURE__ */ jsxs("div", { className: "mt-4", children: [
2680
+ /* @__PURE__ */ jsx2("strong", { children: "Data:" }),
2681
+ /* @__PURE__ */ jsx2("pre", { children: typeof data !== "string" ? JSON.stringify(data, null, 2) : data })
2682
+ ] })
2683
+ ] })
2684
+ ]
2685
+ }
2686
+ );
2687
+ };
2688
+ var ErrorRenderer_default = ErrorRenderer;
2689
+
2690
+ // src/Json/subcomponents/NullRenderer.tsx
2691
+ import { jsx as jsx3 } from "react/jsx-runtime";
2692
+ var NullRenderer = () => {
2693
+ return /* @__PURE__ */ jsx3(
2694
+ esm_default.Null,
2695
+ {
2696
+ render: () => /* @__PURE__ */ jsx3("span", { className: "rounded bg-warning-100 px-1 text-xs text-warning-700", children: "null" })
2697
+ }
2698
+ );
2699
+ };
2700
+ var NullRenderer_default = NullRenderer;
2701
+
2702
+ // src/Json/Json.tsx
2703
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
2704
+ var Json = ({
2705
+ className = void 0,
2706
+ collapsed = false,
2707
+ value,
2708
+ maxHeight = void 0,
2709
+ onCopy = void 0,
2710
+ errorRenderer = void 0
2711
+ }) => {
2577
2712
  const [showDetails, setShowDetails] = useState3(false);
2578
2713
  const { resolvedTheme } = useTheme();
2579
- const isDarkMode = resolvedTheme === "dark" || document.body.classList.contains("dark");
2714
+ const isDarkMode = useMemo2(
2715
+ () => resolvedTheme === "dark" || document.body.classList.contains("dark"),
2716
+ [resolvedTheme]
2717
+ );
2718
+ const handleCopy = (event) => {
2719
+ const copiedValue = event.currentTarget.textContent || "";
2720
+ onCopy == null ? void 0 : onCopy(copiedValue);
2721
+ };
2580
2722
  let content = null;
2581
2723
  let error = null;
2582
2724
  try {
2583
- content = /* @__PURE__ */ jsx(
2584
- esm_default,
2725
+ const parsedValue = getValue(value);
2726
+ content = /* @__PURE__ */ jsx4(
2727
+ "div",
2585
2728
  {
2586
- className: "pr-5",
2587
- collapsed,
2588
- displayDataTypes: false,
2589
- style: {
2590
- ...isDarkMode ? vscodeTheme : lightTheme,
2591
- backgroundColor: "unset"
2592
- },
2593
- value: getValue(value),
2594
- children: /* @__PURE__ */ jsx(
2595
- esm_default.Copied,
2729
+ style: { maxHeight, overflowY: maxHeight ? "auto" : void 0 },
2730
+ className: "relative",
2731
+ children: /* @__PURE__ */ jsxs2(
2732
+ esm_default,
2596
2733
  {
2597
- render: ({
2598
- // @ts-expect-error this should be fine
2599
- "data-copied": copied,
2600
- style,
2601
- ...elmProps
2602
- }) => {
2603
- const elmClasses = cn(
2604
- elmProps.className,
2605
- "absolute -right-4 -top-[2px] h-4 w-4 !fill-transparent pl-1",
2606
- { "text-success": copied }
2607
- );
2608
- return /* @__PURE__ */ jsx(
2609
- "span",
2610
- {
2611
- className: "relative !ml-0 !h-[1em] !w-0",
2612
- style,
2613
- "data-testid": "copy-button",
2614
- children: copied ? /* @__PURE__ */ jsx(
2615
- HiOutlineClipboardCheck,
2616
- {
2617
- ...elmProps,
2618
- className: elmClasses
2619
- }
2620
- ) : (
2621
- // eslint-disable-next-line react/jsx-props-no-spreading
2622
- /* @__PURE__ */ jsx(HiOutlineClipboard, { ...elmProps, className: elmClasses })
2623
- )
2624
- }
2625
- );
2626
- }
2734
+ className: "pr-5",
2735
+ collapsed,
2736
+ displayDataTypes: false,
2737
+ style: __spreadProps(__spreadValues({}, isDarkMode ? vscodeTheme : lightTheme), {
2738
+ backgroundColor: "unset"
2739
+ }),
2740
+ value: parsedValue,
2741
+ onCopy: handleCopy,
2742
+ children: [
2743
+ /* @__PURE__ */ jsx4(CopiedRenderer_default, {}),
2744
+ /* @__PURE__ */ jsx4(NullRenderer_default, {})
2745
+ ]
2627
2746
  }
2628
2747
  )
2629
2748
  }
2630
2749
  );
2631
2750
  } catch (err) {
2632
- error = /* @__PURE__ */ jsxs(
2633
- "div",
2751
+ const defaultError = /* @__PURE__ */ jsx4(
2752
+ ErrorRenderer_default,
2634
2753
  {
2635
- className: "mb-4 flex flex-col items-center rounded-lg border border-danger bg-danger-50 p-4 text-sm text-danger",
2636
- role: "alert",
2637
- children: [
2638
- /* @__PURE__ */ jsxs("div", { className: "flex w-full justify-between gap-6", children: [
2639
- /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
2640
- /* @__PURE__ */ jsx(FaTimesCircle, { className: "mr-2" }),
2641
- /* @__PURE__ */ jsx("span", { className: "font-medium", children: "Failed to parse JSON data" })
2642
- ] }),
2643
- /* @__PURE__ */ jsx(
2644
- Button_default,
2645
- {
2646
- color: "danger",
2647
- size: "sm",
2648
- variant: "light",
2649
- onClick: () => setShowDetails(!showDetails),
2650
- children: showDetails ? /* @__PURE__ */ jsxs(Fragment3, { children: [
2651
- /* @__PURE__ */ jsx(FaChevronUp, {}),
2652
- " Hide Details"
2653
- ] }) : /* @__PURE__ */ jsxs(Fragment3, { children: [
2654
- /* @__PURE__ */ jsx(FaChevronDown, {}),
2655
- " Show Details"
2656
- ] })
2657
- }
2658
- )
2659
- ] }),
2660
- showDetails && /* @__PURE__ */ jsxs("div", { className: "mt-4 w-full text-left", children: [
2661
- /* @__PURE__ */ jsxs("div", { children: [
2662
- /* @__PURE__ */ jsx("strong", { children: "Error:" }),
2663
- /* @__PURE__ */ jsxs("pre", { children: [
2664
- err?.name,
2665
- ": ",
2666
- err?.message
2667
- ] })
2668
- ] }),
2669
- /* @__PURE__ */ jsxs("div", { className: "mt-4", children: [
2670
- /* @__PURE__ */ jsx("strong", { children: "Data:" }),
2671
- /* @__PURE__ */ jsx("pre", { children: typeof value !== "string" ? JSON.stringify(value, null, 2) : value })
2672
- ] })
2673
- ] })
2674
- ]
2754
+ error: err,
2755
+ data: value,
2756
+ showDetails,
2757
+ onToggleDetails: () => setShowDetails(!showDetails)
2675
2758
  }
2676
2759
  );
2760
+ error = errorRenderer ? errorRenderer(err, value) : defaultError;
2677
2761
  }
2678
- return /* @__PURE__ */ jsx("div", { className: cn(className), children: error || content });
2762
+ return /* @__PURE__ */ jsx4("div", { "aria-label": "JSON viewer", className: cn2(className), role: "region", children: error || content });
2679
2763
  };
2680
2764
  var Json_default = Json;
2681
2765
 
@@ -2686,4 +2770,4 @@ export {
2686
2770
  Json_default,
2687
2771
  Json_default2
2688
2772
  };
2689
- //# sourceMappingURL=chunk-C2BIHVLT.js.map
2773
+ //# sourceMappingURL=chunk-LCSYN3DI.js.map