@shoplflow/base 0.26.10 → 0.27.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
@@ -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,122 @@ 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.m.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.m.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
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledTree, __spreadProps(__spreadValues({}, rest), { "data-shoplflow": "Tree", layout: true, layoutRoot: true, children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.LayoutGroup, { children }) }));
2801
2886
  };
2887
+ exports.TreeItem = (_a) => {
2888
+ var _b = _a, {
2889
+ children,
2890
+ label,
2891
+ leftSource,
2892
+ rightSource,
2893
+ depth = 0,
2894
+ initialIsOpen,
2895
+ isOpen
2896
+ } = _b, rest = __objRest(_b, [
2897
+ "children",
2898
+ "label",
2899
+ "leftSource",
2900
+ "rightSource",
2901
+ "depth",
2902
+ "initialIsOpen",
2903
+ "isOpen"
2904
+ ]);
2905
+ const [isOpened, setIsOpened] = React3__namespace.default.useState(initialIsOpen != null ? initialIsOpen : false);
2906
+ const CloneChildren = React3__namespace.default.Children.map(children, (child) => {
2907
+ if (!React3__namespace.default.isValidElement(child)) {
2908
+ return child;
2909
+ }
2910
+ if (child.type[exports.TREE_SYMBOL_KEY]) {
2911
+ return React3__namespace.default.cloneElement(child, {
2912
+ depth: depth + 1
2913
+ });
2914
+ }
2915
+ return child;
2916
+ });
2917
+ const handleToggle = () => {
2918
+ setIsOpened((prev) => !prev);
2919
+ };
2920
+ React3.useEffect(() => {
2921
+ if (isOpen !== void 0) {
2922
+ setIsOpened(isOpen);
2923
+ }
2924
+ }, [isOpen]);
2925
+ return /* @__PURE__ */ jsxRuntime.jsxs(framerMotion.AnimatePresence, { mode: "sync", children: [
2926
+ /* @__PURE__ */ React3.createElement(StyledTreeItem, __spreadValues(__spreadProps(__spreadValues({ depth }, AnimateKey), { variants: fadeInOut, layout: true, key: String(label) }), rest), /* @__PURE__ */ jsxRuntime.jsxs(LeftElementWrapper, { children: [
2927
+ leftSource,
2928
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Text, { typography: "body1_400", lineClamp: 1, children: label })
2929
+ ] }), /* @__PURE__ */ jsxRuntime.jsxs(RightElementWrapper, { children: [
2930
+ rightSource,
2931
+ children && /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { styleVar: "GHOST", onClick: handleToggle, children: /* @__PURE__ */ jsxRuntime.jsx(
2932
+ IconWrapper,
2933
+ {
2934
+ animate: {
2935
+ rotate: isOpened ? 180 : 0,
2936
+ transition: {
2937
+ duration: 0.2
2938
+ }
2939
+ },
2940
+ children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: ShoplAssets.DownArrowIcon, sizeVar: "S" })
2941
+ }
2942
+ ) })
2943
+ ] })),
2944
+ isOpened && children && /* @__PURE__ */ jsxRuntime.jsx(framerMotion.m.div, __spreadProps(__spreadValues({ layout: true }, AnimateKey), { variants: fadeInOut, children: CloneChildren }), "children" + String(CloneChildren))
2945
+ ] });
2946
+ };
2947
+ exports.TreeItem[exports.TREE_SYMBOL_KEY] = true;
2948
+ Tree.Item = exports.TreeItem;
2802
2949
  exports.Tree = Tree;
2803
2950
  var StyledInput = styled6__default.default.input`
2804
2951
  padding: 4px 0 4px 12px;
@@ -2833,7 +2980,7 @@ var StyledInput = styled6__default.default.input`
2833
2980
  box-sizing: inherit;
2834
2981
  }
2835
2982
  `;
2836
- var RightElementWrapper = styled6__default.default.div`
2983
+ var RightElementWrapper2 = styled6__default.default.div`
2837
2984
  display: flex;
2838
2985
  flex-direction: row;
2839
2986
  align-items: center;
@@ -3024,7 +3171,7 @@ var Input = React3.forwardRef(
3024
3171
  className: "body1_400" + (className ? ` ${className}` : "")
3025
3172
  }, rest)
3026
3173
  ),
3027
- !(type === "number") && /* @__PURE__ */ jsxRuntime.jsxs(RightElementWrapper, { children: [
3174
+ !(type === "number") && /* @__PURE__ */ jsxRuntime.jsxs(RightElementWrapper2, { children: [
3028
3175
  maxLength && isFocused && /* @__PURE__ */ jsxRuntime.jsx(TextCounter_default, { currentLength: String(text).length, maxLength }),
3029
3176
  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
3177
  initialType === "password" && /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { sizeVar: "S", onClick: handleTogglePasswordType, styleVar: "GHOST", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -3855,7 +4002,7 @@ var ShoplflowProvider = ({ children, domain = "SHOPL" }) => {
3855
4002
  return /* @__PURE__ */ jsxRuntime.jsxs(ModalProvider_default, { children: [
3856
4003
  /* @__PURE__ */ jsxRuntime.jsx(PopperPortal_default, {}),
3857
4004
  /* @__PURE__ */ jsxRuntime.jsx(exports.ModalProvider, {}),
3858
- children
4005
+ /* @__PURE__ */ jsxRuntime.jsx(framerMotion.LazyMotion, { features: framerMotion.domAnimation, children })
3859
4006
  ] });
3860
4007
  };
3861
4008
  exports.ShoplflowProvider = ShoplflowProvider;