@shoplflow/base 0.26.10 → 0.27.1

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
@@ -1558,6 +1558,22 @@ var StyledButton = styled6__default.default.button`
1558
1558
  ${({ sizeVar }) => getStyleBySizeVar2(sizeVar)};
1559
1559
  ${({ disabled }) => getDisabledStyle(disabled)};
1560
1560
  `;
1561
+ var LoadingSpinner = ({ color = "neutral0" }) => {
1562
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "24", height: "24", stroke: exports.colorTokens[color], viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: [
1563
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
1564
+ .spinner { transform-origin: center; animation: spinner_rotation 2s linear infinite; }
1565
+ .spinner circle { stroke-linecap: round; animation: spinner_dash 1.5s ease-in-out infinite; }
1566
+ @keyframes spinner_rotation { 100% { transform: rotate(360deg); } }
1567
+ @keyframes spinner_dash {
1568
+ 0% { stroke-dasharray: 0 150; stroke-dashoffset: 0; }
1569
+ 47.5% { stroke-dasharray: 42 150; stroke-dashoffset: -16; }
1570
+ 95%, 100% { stroke-dasharray: 42 150; stroke-dashoffset: -59; }
1571
+ }
1572
+ ` }),
1573
+ /* @__PURE__ */ jsxRuntime.jsx("g", { className: "spinner", children: /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "9.5", fill: "none", strokeWidth: "2" }) })
1574
+ ] });
1575
+ };
1576
+ var LoadingSpinner_default = LoadingSpinner;
1561
1577
  var Button = React3.forwardRef(
1562
1578
  (_a, ref) => {
1563
1579
  var _b = _a, {
@@ -1569,6 +1585,7 @@ var Button = React3.forwardRef(
1569
1585
  children,
1570
1586
  leftSource,
1571
1587
  rightSource,
1588
+ isLoading = false,
1572
1589
  lineClamp
1573
1590
  } = _b, rest = __objRest(_b, [
1574
1591
  "styleVar",
@@ -1579,6 +1596,7 @@ var Button = React3.forwardRef(
1579
1596
  "children",
1580
1597
  "leftSource",
1581
1598
  "rightSource",
1599
+ "isLoading",
1582
1600
  "lineClamp"
1583
1601
  ]);
1584
1602
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1595,7 +1613,7 @@ var Button = React3.forwardRef(
1595
1613
  "data-shoplflow": "Button",
1596
1614
  children: [
1597
1615
  leftSource,
1598
- /* @__PURE__ */ jsxRuntime.jsx(
1616
+ isLoading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner_default, { color: styleVar === "SECONDARY" || styleVar === "GHOST" ? "neutral500" : "neutral0" }) : /* @__PURE__ */ jsxRuntime.jsx(
1599
1617
  exports.Text,
1600
1618
  {
1601
1619
  lineClamp,
@@ -1715,7 +1733,25 @@ var StyledIconButton = styled6__default.default.button`
1715
1733
  `;
1716
1734
  var IconButton = React3.forwardRef(
1717
1735
  (_a, ref) => {
1718
- var _b = _a, { styleVar, sizeVar, disabled, children, color, onMouseEnter, onMouseLeave } = _b, rest = __objRest(_b, ["styleVar", "sizeVar", "disabled", "children", "color", "onMouseEnter", "onMouseLeave"]);
1736
+ var _b = _a, {
1737
+ styleVar,
1738
+ sizeVar,
1739
+ disabled,
1740
+ children,
1741
+ color,
1742
+ onMouseEnter,
1743
+ onMouseLeave,
1744
+ isLoading = false
1745
+ } = _b, rest = __objRest(_b, [
1746
+ "styleVar",
1747
+ "sizeVar",
1748
+ "disabled",
1749
+ "children",
1750
+ "color",
1751
+ "onMouseEnter",
1752
+ "onMouseLeave",
1753
+ "isLoading"
1754
+ ]);
1719
1755
  const [isHovered, setIsHovered] = React3.useState(false);
1720
1756
  const handleOnMouseEnter = (e) => {
1721
1757
  setIsHovered(true);
@@ -1738,7 +1774,7 @@ var IconButton = React3.forwardRef(
1738
1774
  isHovered
1739
1775
  }, rest), {
1740
1776
  "data-shoplflow": "IconButton",
1741
- children
1777
+ children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner_default, { color: styleVar === "SECONDARY" || styleVar === "GHOST" ? "neutral500" : "neutral0" }) : children
1742
1778
  })
1743
1779
  );
1744
1780
  }
@@ -2794,11 +2830,129 @@ exports.TagSizeVariants = {
2794
2830
  S: "S",
2795
2831
  M: "M"
2796
2832
  };
2797
- var StyledTree = styled6__default.default.div``;
2833
+ var StyledTree = styled6__default.default(framerMotion.motion.ul)`
2834
+ display: flex;
2835
+ flex-direction: column;
2836
+ width: 100%;
2837
+ `;
2838
+ var StyledTreeItem = styled6__default.default(framerMotion.motion.li)`
2839
+ display: flex;
2840
+ flex-direction: row;
2841
+ width: 100%;
2842
+ height: 48px;
2843
+ gap: 4px;
2844
+ align-items: center;
2845
+ justify-content: space-between;
2846
+ padding: 8px 0;
2847
+ border-radius: 8px;
2848
+ background: transparent;
2849
+ cursor: initial;
2850
+ ${({ depth }) => depth && react$1.css`
2851
+ padding-left: ${depth * 16}px;
2852
+ `};
2853
+ &:hover {
2854
+ background: ${exports.colorTokens.neutral400_5};
2855
+ }
2856
+ `;
2857
+ var LeftElementWrapper = styled6__default.default.div`
2858
+ display: flex;
2859
+ flex-direction: row;
2860
+ align-items: center;
2861
+ gap: 4px;
2862
+ `;
2863
+ var RightElementWrapper = styled6__default.default.div`
2864
+ display: flex;
2865
+ flex-direction: row;
2866
+ align-items: center;
2867
+ `;
2868
+ var IconWrapper = styled6__default.default(framerMotion.motion.div)`
2869
+ display: flex;
2870
+ width: fit-content;
2871
+ height: fit-content;
2872
+ `;
2873
+
2874
+ // src/components/Tree/Tree.types.ts
2875
+ exports.TREE_SYMBOL_KEY = Symbol("SHOPLFLOW_TREE");
2876
+
2877
+ // src/animation/AnimateKey.ts
2878
+ var AnimateKey = {
2879
+ initial: "initial",
2880
+ animate: "animate",
2881
+ exit: "exit"
2882
+ };
2798
2883
  var Tree = (_a) => {
2799
- var rest = __objRest(_a, []);
2800
- return /* @__PURE__ */ jsxRuntime.jsx(StyledTree, __spreadProps(__spreadValues({}, rest), { "data-shoplflow": "Tree", children: "Tree" }));
2884
+ var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
2885
+ const [isMounted, setIsMounted] = React3__namespace.default.useState(false);
2886
+ React3.useEffect(() => {
2887
+ setIsMounted(true);
2888
+ }, []);
2889
+ if (!isMounted) {
2890
+ return null;
2891
+ }
2892
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledTree, __spreadProps(__spreadValues({}, rest), { "data-shoplflow": "Tree", layout: true, layoutRoot: true, children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.LayoutGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { mode: "sync", children }) }) }));
2801
2893
  };
2894
+ exports.TreeItem = (_a) => {
2895
+ var _b = _a, {
2896
+ children,
2897
+ label,
2898
+ leftSource,
2899
+ rightSource,
2900
+ depth = 0,
2901
+ initialIsOpen,
2902
+ isOpen
2903
+ } = _b, rest = __objRest(_b, [
2904
+ "children",
2905
+ "label",
2906
+ "leftSource",
2907
+ "rightSource",
2908
+ "depth",
2909
+ "initialIsOpen",
2910
+ "isOpen"
2911
+ ]);
2912
+ const [isOpened, setIsOpened] = React3__namespace.default.useState(initialIsOpen != null ? initialIsOpen : false);
2913
+ const CloneChildren = React3__namespace.default.Children.map(children, (child) => {
2914
+ if (!React3__namespace.default.isValidElement(child)) {
2915
+ return child;
2916
+ }
2917
+ if (child.type[exports.TREE_SYMBOL_KEY]) {
2918
+ return React3__namespace.default.cloneElement(child, {
2919
+ depth: depth + 1
2920
+ });
2921
+ }
2922
+ return child;
2923
+ });
2924
+ const handleToggle = () => {
2925
+ setIsOpened((prev) => !prev);
2926
+ };
2927
+ React3.useEffect(() => {
2928
+ if (isOpen !== void 0) {
2929
+ setIsOpened(isOpen);
2930
+ }
2931
+ }, [isOpen]);
2932
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2933
+ /* @__PURE__ */ React3.createElement(StyledTreeItem, __spreadValues(__spreadProps(__spreadValues({ depth, variants: fadeInOut }, AnimateKey), { layout: true, key: String(label) }), rest), /* @__PURE__ */ jsxRuntime.jsxs(LeftElementWrapper, { children: [
2934
+ leftSource,
2935
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Text, { typography: "body1_400", lineClamp: 1, children: label })
2936
+ ] }), /* @__PURE__ */ jsxRuntime.jsxs(RightElementWrapper, { children: [
2937
+ rightSource,
2938
+ children && /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { styleVar: "GHOST", onClick: handleToggle, children: /* @__PURE__ */ jsxRuntime.jsx(
2939
+ IconWrapper,
2940
+ {
2941
+ animate: {
2942
+ rotate: isOpened ? 180 : 0,
2943
+ transition: {
2944
+ duration: 0.2
2945
+ }
2946
+ },
2947
+ children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: ShoplAssets.DownArrowIcon, sizeVar: "S" })
2948
+ }
2949
+ ) })
2950
+ ] })),
2951
+ /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { mode: "sync", children: isOpened && children && /* @__PURE__ */ jsxRuntime.jsx(framerMotion.motion.div, __spreadProps(__spreadValues({ layout: true }, AnimateKey), { variants: fadeInOut, children: CloneChildren }), "children" + String(CloneChildren)) })
2952
+ ] });
2953
+ };
2954
+ exports.TreeItem[exports.TREE_SYMBOL_KEY] = true;
2955
+ Tree.Item = exports.TreeItem;
2802
2956
  exports.Tree = Tree;
2803
2957
  var StyledInput = styled6__default.default.input`
2804
2958
  padding: 4px 0 4px 12px;
@@ -2833,7 +2987,7 @@ var StyledInput = styled6__default.default.input`
2833
2987
  box-sizing: inherit;
2834
2988
  }
2835
2989
  `;
2836
- var RightElementWrapper = styled6__default.default.div`
2990
+ var RightElementWrapper2 = styled6__default.default.div`
2837
2991
  display: flex;
2838
2992
  flex-direction: row;
2839
2993
  align-items: center;
@@ -3024,7 +3178,7 @@ var Input = React3.forwardRef(
3024
3178
  className: "body1_400" + (className ? ` ${className}` : "")
3025
3179
  }, rest)
3026
3180
  ),
3027
- !(type === "number") && /* @__PURE__ */ jsxRuntime.jsxs(RightElementWrapper, { children: [
3181
+ !(type === "number") && /* @__PURE__ */ jsxRuntime.jsxs(RightElementWrapper2, { children: [
3028
3182
  maxLength && isFocused && /* @__PURE__ */ jsxRuntime.jsx(TextCounter_default, { currentLength: String(text).length, maxLength }),
3029
3183
  isFocused && Boolean(String(text).length > 0) && /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { sizeVar: "S", onClick: handleOnClear, styleVar: "GHOST", children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: assetFunction("DeleteIcon"), color: "neutral350" }) }),
3030
3184
  initialType === "password" && /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { sizeVar: "S", onClick: handleTogglePasswordType, styleVar: "GHOST", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -3855,7 +4009,7 @@ var ShoplflowProvider = ({ children, domain = "SHOPL" }) => {
3855
4009
  return /* @__PURE__ */ jsxRuntime.jsxs(ModalProvider_default, { children: [
3856
4010
  /* @__PURE__ */ jsxRuntime.jsx(PopperPortal_default, {}),
3857
4011
  /* @__PURE__ */ jsxRuntime.jsx(exports.ModalProvider, {}),
3858
- children
4012
+ /* @__PURE__ */ jsxRuntime.jsx(framerMotion.LazyMotion, { features: framerMotion.domAnimation, children })
3859
4013
  ] });
3860
4014
  };
3861
4015
  exports.ShoplflowProvider = ShoplflowProvider;