@shoplflow/base 0.32.18 → 0.32.19

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
@@ -1811,65 +1811,19 @@ exports.IconButtonStyleVariants = {
1811
1811
  SOLID: "SOLID",
1812
1812
  GHOST: "GHOST"
1813
1813
  };
1814
- var informationStyle = react$1.css`
1815
- background: ${exports.colorTokens.neutral100};
1816
- & > span {
1817
- color: ${exports.colorTokens.neutral600};
1818
- }
1819
- & > svg > path {
1820
- fill: ${exports.colorTokens.neutral600};
1821
- }
1822
- `;
1823
- var alertStyle = react$1.css`
1824
- background: ${exports.colorTokens.red100};
1825
- & > span {
1826
- align-self: center;
1827
- color: ${exports.colorTokens.red300};
1828
- }
1829
- & > svg > path {
1830
- fill: ${exports.colorTokens.red300};
1831
- }
1832
- `;
1833
- var StyledCallout = styled6__default.default.div`
1834
- display: flex;
1835
- justify-content: flex-start;
1836
- align-items: start;
1837
- padding: 6px 8px;
1838
- gap: 4px;
1839
- border-radius: ${exports.borderRadiusTokens.borderRadius08};
1840
- ${({ styleVar }) => styleVar === "INFORMATION" && informationStyle}
1841
- ${({ styleVar }) => styleVar === "ALERT" && alertStyle}
1814
+ var StyledPopoverContentWrapper = styled6__default.default.div`
1815
+ min-width: 112px;
1816
+ padding: 4px;
1817
+ box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.12);
1818
+ border-radius: 8px;
1819
+ background-color: ${exports.colorTokens.neutral0};
1842
1820
  `;
1843
- var StyledCalloutIcon = styled6__default.default.svg`
1821
+ var StyledArrowIcon = styled6__default.default(framerMotion.motion.div)`
1844
1822
  display: flex;
1845
- height: 20px;
1846
- min-height: 20px;
1847
- width: 20px;
1848
- min-width: 20px;
1849
- `;
1850
- styled6__default.default.div`
1851
- padding: 2px 0;
1823
+ justify-content: center;
1824
+ align-items: center;
1825
+ flex-shrink: 0;
1852
1826
  `;
1853
- var Callout = (_a) => {
1854
- var _b = _a, { children, styleVar = "INFORMATION" } = _b, rest = __objRest(_b, ["children", "styleVar"]);
1855
- return /* @__PURE__ */ jsxRuntime.jsx(StyledCallout, __spreadProps(__spreadValues({}, rest), { styleVar, "data-shoplflow": "Callout", children }));
1856
- };
1857
- var CalloutText = (_a) => {
1858
- var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
1859
- return /* @__PURE__ */ jsxRuntime.jsx(exports.Text, __spreadProps(__spreadValues({}, rest), { typography: "paragraph2", children }));
1860
- };
1861
- var CalloutIcon = ({ iconSource }) => {
1862
- return /* @__PURE__ */ jsxRuntime.jsx(StyledCalloutIcon, { as: iconSource });
1863
- };
1864
- Callout.Text = CalloutText;
1865
- Callout.Icon = CalloutIcon;
1866
- exports.Callout = Callout;
1867
-
1868
- // src/components/Callout/Callout.types.ts
1869
- exports.CalloutTypes = {
1870
- INFORMATION: "INFORMATION",
1871
- ALERT: "ALERT"
1872
- };
1873
1827
  var StyledPopper = styled6__default.default.div`
1874
1828
  width: ${({ width }) => width != null ? width : "fit-content"};
1875
1829
  height: ${({ height }) => height && height};
@@ -1974,474 +1928,229 @@ exports.PopperPortal = React3.forwardRef(
1974
1928
  Popper.Trigger = exports.PopperTrigger;
1975
1929
  Popper.Portal = exports.PopperPortal;
1976
1930
  exports.Popper = Popper;
1977
- var getDropdownHeightBySizeVar = (size2) => {
1978
- switch (size2) {
1979
- case "M":
1980
- return "40px";
1981
- case "S":
1982
- return "32px";
1983
- default:
1984
- return "40px";
1985
- }
1986
- };
1987
- var getDropdownFontSizeBySizeVar = (size2) => {
1988
- switch (size2) {
1989
- case "M":
1990
- return "body1_400";
1991
- case "S":
1992
- return "body2_400";
1993
- default:
1994
- return "body1_400";
1995
- }
1996
- };
1997
- var getDropdownStyleBySizeVar = (size2) => {
1998
- switch (size2) {
1999
- case "M":
2000
- return react$1.css`
2001
- padding: 4px 4px 4px 12px;
2002
- `;
2003
- case "S":
2004
- return react$1.css`
2005
- padding: 4px 4px 4px 8px;
2006
- gap: 4px;
2007
- `;
2008
- default:
2009
- return react$1.css`
2010
- padding: 4px 4px 4px 12px;
2011
- `;
1931
+ var Container2 = styled6__default.default.div`
1932
+ display: flex;
1933
+ align-items: center;
1934
+ justify-content: center;
1935
+ width: 24px;
1936
+ height: 24px;
1937
+ padding: 4px;
1938
+ `;
1939
+ var IconButton2 = styled6__default.default.button`
1940
+ display: flex;
1941
+ width: 16px;
1942
+ height: 16px;
1943
+ flex-direction: column;
1944
+ justify-content: center;
1945
+ align-items: center;
1946
+ border-radius: ${exports.borderRadiusTokens.borderRadius04};
1947
+ border: none;
1948
+ background: ${({ color }) => exports.colorTokens[color]};
1949
+ cursor: pointer;
1950
+ transition:
1951
+ transform 0.1s ease-out,
1952
+ background 0.1s ease;
1953
+
1954
+ &:hover {
1955
+ background: ${({ color }) => exports.colorTokens[getNextColor(color, 1)]};
2012
1956
  }
2013
- };
2014
- var getDropdownIconSizeBySizeVar = (size2) => {
2015
- switch (size2) {
2016
- case "S":
1957
+ `;
1958
+ var MUNUS_BUTTON_SYMBOL_KEY = Symbol("SHOPLFLOW_MUNUS_BUTTON");
1959
+ var MinusButton = React3.forwardRef((_a, ref) => {
1960
+ var _b = _a, { onClick, color = "neutral300" } = _b, rest = __objRest(_b, ["onClick", "color"]);
1961
+ return /* @__PURE__ */ jsxRuntime.jsx(Container2, { "data-shoplflow": "minusButton", children: /* @__PURE__ */ jsxRuntime.jsx(IconButton2, __spreadProps(__spreadValues({ color, onClick, ref }, rest), { children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
1962
+ /* @__PURE__ */ jsxRuntime.jsx(
1963
+ "path",
1964
+ {
1965
+ d: "M0 4C0 1.79086 1.79086 0 4 0H12C14.2091 0 16 1.79086 16 4V12C16 14.2091 14.2091 16 12 16H4C1.79086 16 0 14.2091 0 12V4Z",
1966
+ fill: "none"
1967
+ }
1968
+ ),
1969
+ /* @__PURE__ */ jsxRuntime.jsx(
1970
+ "path",
1971
+ {
1972
+ fillRule: "evenodd",
1973
+ clipRule: "evenodd",
1974
+ d: "M3 8C3 7.44772 3.44772 7 4 7H12C12.5523 7 13 7.44772 13 8C13 8.55228 12.5523 9 12 9H4C3.44772 9 3 8.55228 3 8Z",
1975
+ fill: "white"
1976
+ }
1977
+ )
1978
+ ] }) })) });
1979
+ });
1980
+ MinusButton[MUNUS_BUTTON_SYMBOL_KEY] = true;
1981
+ exports.MinusButton = MinusButton;
1982
+ var getStylesByStyleVariant = (styleVariant, isSelected, isHovered) => {
1983
+ switch (styleVariant) {
1984
+ case "PRIMARY":
1985
+ if (isSelected) {
1986
+ return react$1.css`
1987
+ background: ${exports.colorTokens.primary300};
1988
+ border: 1.5px solid ${exports.colorTokens.primary300};
1989
+ & > svg > path {
1990
+ fill: ${exports.colorTokens.neutral0};
1991
+ }
1992
+ ${isHovered && react$1.css`
1993
+ border: 1.5px solid ${exports.colorTokens.primary400};
1994
+ background: ${exports.colorTokens.primary400};
1995
+ `}
1996
+ `;
1997
+ }
2017
1998
  return react$1.css`
2018
- height: 24px;
2019
- width: 24px;
2020
- min-width: 24px;
2021
- min-height: 24px;
1999
+ background: ${exports.colorTokens.neutral200};
2000
+ border: 1.5px solid ${exports.colorTokens.neutral200};
2001
+ border-radius: 4px;
2002
+ ${isHovered && react$1.css`
2003
+ border: 1.5px solid ${exports.colorTokens.neutral300};
2004
+ background: ${exports.colorTokens.neutral300};
2005
+ `}
2006
+
2007
+ & > svg > path {
2008
+ fill: ${exports.colorTokens.neutral0};
2009
+ }
2022
2010
  `;
2023
- case "M":
2011
+ case "LINE":
2012
+ if (isSelected) {
2013
+ return react$1.css`
2014
+ border: 1.5px solid ${exports.colorTokens.primary300};
2015
+ background: transparent;
2016
+ border-radius: 4px;
2017
+ & > svg > path {
2018
+ fill: ${exports.colorTokens.primary300};
2019
+ }
2020
+ ${isHovered && react$1.css`
2021
+ border: 1.5px solid ${exports.colorTokens.primary400};
2022
+ & > svg > path {
2023
+ fill: ${exports.colorTokens.primary400};
2024
+ }
2025
+ `}
2026
+ `;
2027
+ }
2024
2028
  return react$1.css`
2025
- height: 32px;
2026
- width: 32px;
2027
- min-width: 32px;
2028
- min-height: 32px;
2029
+ background: transparent;
2030
+ border: 1.5px solid ${exports.colorTokens.neutral200};
2031
+ border-radius: 4px;
2032
+ & > svg > path {
2033
+ fill: ${exports.colorTokens.neutral200};
2034
+ }
2035
+ ${isHovered && react$1.css`
2036
+ border: 1.5px solid ${exports.colorTokens.neutral300};
2037
+ & > svg > path {
2038
+ fill: ${exports.colorTokens.neutral300};
2039
+ }
2040
+ `}
2029
2041
  `;
2030
2042
  default:
2031
- return react$1.css`
2032
- height: 32px;
2033
- width: 32px;
2034
- min-width: 32px;
2035
- min-height: 32px;
2036
- `;
2043
+ return "";
2037
2044
  }
2038
2045
  };
2039
- var StyledDropdown = styled6__default.default.div`
2040
- width: ${({ width }) => width};
2046
+ var StyledCheckHiddenInput = styled6__default.default.input`
2047
+ position: absolute;
2048
+ width: 0;
2049
+ height: 0;
2050
+ opacity: 0;
2051
+ visibility: hidden;
2041
2052
  `;
2042
- var StyledDropdownContent = styled6__default.default.div`
2053
+ var StyledCheckbox = styled6__default.default.label`
2043
2054
  display: flex;
2044
- flex-direction: column;
2045
- background: ${exports.colorTokens.neutral0};
2046
- width: ${({ width }) => width != null ? width : "240px"};
2047
- padding: 4px;
2048
- border-radius: 6px;
2049
- box-shadow: ${exports.boxShadowTokens.dropShadow};
2055
+ align-items: center;
2056
+ justify-content: center;
2057
+ min-width: 16px;
2058
+ min-height: 16px;
2059
+ width: 16px;
2060
+ height: 16px;
2061
+ background: ${exports.colorTokens.neutral200};
2062
+ border-radius: 4px;
2063
+ box-sizing: border-box;
2064
+ cursor: pointer;
2065
+ ${({ styleVar, isSelected, isHovered }) => getStylesByStyleVariant(styleVar, isSelected, isHovered)};
2066
+ ${({ disabled }) => getDisabledStyle(disabled)}
2050
2067
  `;
2051
- var StyledDropdownButton = styled6__default.default.button`
2052
- display: flex;
2053
- flex-direction: row;
2054
- align-items: center;
2055
- justify-content: space-between;
2056
- width: 100%;
2057
- height: 100%;
2058
- gap: 8px;
2059
- cursor: pointer;
2060
- background-color: ${exports.colorTokens.neutral0};
2061
- ${({ sizeVar }) => sizeVar && getDropdownStyleBySizeVar(sizeVar)};
2062
- ${({ disabled }) => disabled && react$1.css`
2063
- background-color: ${exports.colorTokens.neutral100};
2064
- cursor: not-allowed;
2065
- `}
2066
- `;
2067
- var DropdownButtonIcon = styled6__default.default(framerMotion.motion.div)`
2068
+ var Container3 = styled6__default.default.button`
2068
2069
  display: flex;
2069
2070
  align-items: center;
2070
2071
  justify-content: center;
2071
-
2072
- ${({ sizeVar }) => sizeVar && getDropdownIconSizeBySizeVar(sizeVar)};
2073
- `;
2074
- var DropdownContext = React3.createContext(null);
2075
- var useDropdown = () => {
2076
- const context = React3.useContext(DropdownContext);
2077
- if (context === null) {
2078
- throw new Error("useDropdown must be used within a DropdownProvider");
2079
- }
2080
- return context;
2081
- };
2082
- var getBorderColorByStatus = ({ isFocused, isError, isHovered, disabled }) => {
2083
- if (!disabled) {
2084
- if (isError) {
2085
- return exports.colorTokens.red300;
2086
- }
2087
- if (isFocused) {
2088
- return exports.colorTokens.primary300;
2089
- }
2090
- if (isHovered) {
2091
- return exports.colorTokens.neutral700;
2092
- }
2093
- }
2094
- return exports.colorTokens.neutral300;
2095
- };
2096
- var getStyleByType = ({
2097
- type,
2098
- height,
2099
- minHeight,
2100
- maxHeight,
2101
- width,
2102
- minWidth,
2103
- maxWidth,
2104
- borderRadius,
2105
- customNumberInputHeight
2106
- }) => {
2107
- if (type === "number") {
2108
- return react$1.css`
2109
- width: ${width || "64px"};
2110
- height: ${customNumberInputHeight || "32px"};
2111
- border-radius: ${borderRadius ? exports.borderRadiusTokens[borderRadius] : "6px"};
2112
- `;
2113
- }
2114
- return react$1.css`
2115
- width: ${width || "100%"};
2116
- min-width: ${minWidth || "initial"};
2117
- max-width: ${maxWidth || "initial"};
2118
- height: ${height || "initial"};
2119
- min-height: ${minHeight || "initial"};
2120
- max-height: ${maxHeight || "initial"};
2121
- border-radius: ${borderRadius ? exports.borderRadiusTokens[borderRadius] : "6px"};
2122
- `;
2123
- };
2124
- var InputWrapper = styled6__default.default.label`
2125
- position: relative;
2126
- display: flex;
2127
- align-items: center;
2128
- border-radius: 6px;
2129
- flex-direction: ${({ direction }) => direction || "row"};
2130
- ${({ type, height, minHeight, maxHeight, width, maxWidth, minWidth, borderRadius, customNumberInputHeight }) => getStyleByType({
2131
- customNumberInputHeight,
2132
- type,
2133
- height,
2134
- minHeight,
2135
- maxHeight,
2136
- width,
2137
- maxWidth,
2138
- minWidth,
2139
- borderRadius
2140
- })};
2141
- justify-content: space-between;
2142
- gap: ${({ gap }) => gap || "8px"};
2143
- border: 1px solid ${(props) => getBorderColorByStatus(props)};
2144
- background-color: ${exports.colorTokens.neutral0};
2145
- overflow: hidden;
2146
- ${({ disabled }) => disabled && react$1.css`
2147
- background-color: ${exports.colorTokens.neutral100};
2148
- cursor: not-allowed;
2149
- `};
2150
- `;
2151
-
2152
- // src/components/Icon/Icon.types.ts
2153
- exports.IconSizeVariants = {
2154
- XS: "XS",
2155
- S: "S",
2156
- M: "M",
2157
- L: "L",
2158
- XL: "XL"
2159
- };
2160
-
2161
- // src/components/Icon/Icon.styled.ts
2162
- var getIconSize = (size2) => {
2163
- switch (size2) {
2164
- case exports.IconSizeVariants.XS:
2165
- return "12px";
2166
- case exports.IconSizeVariants.S:
2167
- return "20px";
2168
- case exports.IconSizeVariants.M:
2169
- return "24px";
2170
- case exports.IconSizeVariants.L:
2171
- return "30px";
2172
- case exports.IconSizeVariants.XL:
2173
- return "36px";
2174
- default:
2175
- return "fit-content";
2176
- }
2177
- };
2178
- exports.StyledIcon = styled6__default.default.svg`
2179
- width: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2180
- min-width: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2181
- height: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2182
- min-height: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2183
- & > path {
2184
- fill: ${({ color }) => color && exports.colorTokens[color]};
2185
- }
2072
+ padding: 4px;
2073
+ width: fit-content;
2074
+ height: fit-content;
2075
+ background-color: transparent;
2186
2076
  `;
2187
- var Icon = React3.forwardRef((_a, ref) => {
2188
- var _b = _a, { iconSource } = _b, rest = __objRest(_b, ["iconSource"]);
2189
- return /* @__PURE__ */ jsxRuntime.jsx(exports.StyledIcon, __spreadProps(__spreadValues({ as: iconSource, ref }, rest), { "data-shoplflow": "Icon" }));
2190
- });
2191
- exports.Icon = Icon;
2192
- var DropdownButton = React3.forwardRef(
2077
+ exports.CHECKBOX_SYMBOL_KEY = Symbol("SHOPLFLOW_CHECKBOX");
2078
+ var Checkbox = React3.forwardRef(
2193
2079
  (_a, ref) => {
2194
- var _b = _a, { width = "100%", onClick, sizeVar = "M", isError, placeholder, value, disabled, leftSource } = _b, rest = __objRest(_b, ["width", "onClick", "sizeVar", "isError", "placeholder", "value", "disabled", "leftSource"]);
2195
- const { isOpen, setIsOpen } = useDropdown();
2196
- const [isHovered, setIsHovered] = React3.useState(false);
2197
- const handleOnClick = (e) => {
2198
- if (!disabled) {
2199
- onClick && onClick(e);
2200
- setIsOpen(!isOpen);
2201
- }
2202
- };
2203
- const handleOnMouseEnter = () => {
2204
- setIsHovered(true);
2080
+ var _b = _a, { defaultSelected, isSelected, disabled, onMouseEnter, onClick, onMouseLeave, styleVar = "PRIMARY", id } = _b, rest = __objRest(_b, ["defaultSelected", "isSelected", "disabled", "onMouseEnter", "onClick", "onMouseLeave", "styleVar", "id"]);
2081
+ const [selected, toggleSelected] = useOnToggle(isSelected, defaultSelected);
2082
+ const [isHovered, toggleHovered] = React3.useState(false);
2083
+ const handleMouseLeave = (e) => {
2084
+ toggleHovered(false);
2085
+ onMouseLeave && onMouseLeave(e);
2205
2086
  };
2206
- const handleOnMouseLeave = () => {
2207
- setIsHovered(false);
2087
+ const handleMouseEnter = (e) => {
2088
+ toggleHovered(true);
2089
+ onMouseEnter && onMouseEnter(e);
2208
2090
  };
2209
- const getTextColor = ({ value: value2, disabled: disabled2 }) => {
2210
- if (disabled2) {
2211
- return "neutral350";
2212
- }
2213
- if (!value2) {
2214
- return "neutral400";
2091
+ const handleClick = (e) => {
2092
+ if (disabled) {
2093
+ return;
2215
2094
  }
2216
- return "neutral700";
2095
+ onClick && onClick(e);
2096
+ toggleSelected();
2217
2097
  };
2218
- return /* @__PURE__ */ jsxRuntime.jsx(
2219
- InputWrapper,
2098
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2099
+ Container3,
2220
2100
  {
2221
- onMouseEnter: handleOnMouseEnter,
2222
- onMouseLeave: handleOnMouseLeave,
2223
- isFocused: isOpen,
2224
- isHovered,
2101
+ onClick: handleClick,
2102
+ onMouseLeave: handleMouseLeave,
2103
+ onMouseEnter: handleMouseEnter,
2225
2104
  disabled,
2226
- width,
2227
- isError,
2228
- height: getDropdownHeightBySizeVar(sizeVar),
2229
- children: /* @__PURE__ */ jsxRuntime.jsxs(StyledDropdownButton, __spreadProps(__spreadValues({ ref, onClick: handleOnClick, disabled }, rest), { sizeVar, children: [
2230
- leftSource && leftSource,
2231
- value || /* @__PURE__ */ jsxRuntime.jsx(
2232
- exports.Text,
2233
- {
2234
- typography: getDropdownFontSizeBySizeVar(sizeVar),
2235
- color: getTextColor({ value, disabled }),
2236
- textOverflow: "ellipsis",
2237
- lineClamp: 1,
2238
- children: placeholder
2239
- }
2240
- ),
2105
+ type: "button",
2106
+ "data-shoplflow": "Checkbox",
2107
+ children: [
2108
+ /* @__PURE__ */ jsxRuntime.jsx(StyledCheckHiddenInput, __spreadProps(__spreadValues({ type: "checkbox", disabled, id }, rest), { ref })),
2241
2109
  /* @__PURE__ */ jsxRuntime.jsx(
2242
- DropdownButtonIcon,
2110
+ StyledCheckbox,
2243
2111
  {
2244
- sizeVar,
2245
- animate: {
2246
- rotate: isOpen ? 180 : 0
2247
- },
2248
- transition: {
2249
- duration: 0.2
2250
- },
2251
- children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: ShoplAssets.DownArrowSolidXsmallIcon, color: "neutral400", sizeVar: "XS" })
2112
+ styleVar,
2113
+ htmlFor: id,
2114
+ isHovered,
2115
+ isSelected: selected,
2116
+ disabled,
2117
+ children: /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "8", viewBox: "0 0 12 8", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
2118
+ "path",
2119
+ {
2120
+ fillRule: "evenodd",
2121
+ clipRule: "evenodd",
2122
+ d: "M9.78822 0.297596C10.1761 -0.0955083 10.8093 -0.0997053 11.2024 0.288222C11.5653 0.646308 11.5968 1.21334 11.2943 1.60765L11.2118 1.7024L5.31714 7.7024C4.95248 8.07193 4.37282 8.09687 3.97909 7.77976L3.88476 7.69335L0.779404 4.42669C0.396475 4.02871 0.408672 3.39567 0.806647 3.01274C1.17401 2.65926 1.74167 2.64247 2.12801 2.95499L2.2206 3.03998L4.614 5.567L9.78822 0.297596Z",
2123
+ fill: "white"
2124
+ }
2125
+ ) })
2252
2126
  }
2253
2127
  )
2254
- ] }))
2128
+ ]
2255
2129
  }
2256
2130
  );
2257
2131
  }
2258
2132
  );
2259
- var DropdownContent = (_a) => {
2260
- var _b = _a, { children, width: initialWidth, type, onClick } = _b, rest = __objRest(_b, ["children", "width", "type", "onClick"]);
2261
- const { width, setIsOpen, option } = useDropdown();
2262
- const isFillType = type === "FILL";
2263
- const contentWidth = isFillType ? `${width}px` : initialWidth;
2264
- const returnCallbackByOption = () => {
2265
- if (option === "OUTSIDE_CLICK") {
2266
- return () => setIsOpen(false);
2267
- }
2268
- if (option === "CLICK") {
2269
- return () => setIsOpen(false);
2133
+ Checkbox[exports.CHECKBOX_SYMBOL_KEY] = true;
2134
+ exports.Checkbox = Checkbox;
2135
+
2136
+ // src/components/ControlButtons/Checkbox/Checkbox.types.ts
2137
+ exports.CheckboxStyleVariants = {
2138
+ PRIMARY: "PRIMARY",
2139
+ LINE: "LINE"
2140
+ };
2141
+ var getSelectedStyle = (isHovered) => {
2142
+ return react$1.css`
2143
+ & > svg > circle {
2144
+ stroke: ${exports.colorTokens.primary300};
2270
2145
  }
2271
- return utils.noop;
2272
- };
2273
- const handleClick = (e) => {
2274
- onClick && onClick(e);
2275
- if (option === "CLICK") {
2276
- setIsOpen(false);
2277
- }
2278
- };
2279
- return /* @__PURE__ */ jsxRuntime.jsx(utils.OutSideClick, { outsideClick: returnCallbackByOption(), children: /* @__PURE__ */ jsxRuntime.jsx(StyledDropdownContent, __spreadProps(__spreadValues({ width: contentWidth, onClick: handleClick }, rest), { children })) });
2280
- };
2281
- var Dropdown = ({
2282
- isOpen: initialIsOpen = false,
2283
- trigger,
2284
- popper,
2285
- option = "CLICK",
2286
- width = "100%"
2287
- }) => {
2288
- const [triggerRef, setTriggerRef] = React3.useState(null);
2289
- const [size2, setSize] = React3.useState({ width: 0, height: 0 });
2290
- const [isOpen, setIsOpen] = React3.useState(false);
2291
- React3.useEffect(() => {
2292
- if (triggerRef) {
2293
- setSize({
2294
- width: triggerRef.offsetWidth,
2295
- height: triggerRef.offsetHeight
2296
- });
2297
- }
2298
- }, [triggerRef]);
2299
- React3.useEffect(() => {
2300
- if (initialIsOpen === void 0) {
2301
- return;
2302
- }
2303
- setIsOpen(initialIsOpen);
2304
- }, [initialIsOpen]);
2305
- return /* @__PURE__ */ jsxRuntime.jsx(StyledDropdown, { "data-shoplflow": "Dropdown", width, children: /* @__PURE__ */ jsxRuntime.jsx(DropdownContext.Provider, { value: __spreadProps(__spreadValues({}, size2), { isOpen, setIsOpen, option }), children: /* @__PURE__ */ jsxRuntime.jsxs(
2306
- exports.Popper,
2307
- {
2308
- offset: 4,
2309
- autoPlacement: {
2310
- allowedPlacements: ["bottom-start", "top-start"]
2311
- },
2312
- children: [
2313
- /* @__PURE__ */ jsxRuntime.jsx(exports.Popper.Trigger, { ref: setTriggerRef, isOpen, width, children: trigger }),
2314
- /* @__PURE__ */ jsxRuntime.jsx(exports.Popper.Portal, { children: popper })
2315
- ]
2316
- }
2317
- ) }) });
2318
- };
2319
- Dropdown.Button = DropdownButton;
2320
- Dropdown.Content = DropdownContent;
2321
- exports.Dropdown = Dropdown;
2322
- var Container2 = styled6__default.default.div`
2323
- display: flex;
2324
- align-items: center;
2325
- justify-content: center;
2326
- width: 24px;
2327
- height: 24px;
2328
- padding: 4px;
2329
- `;
2330
- var IconButton2 = styled6__default.default.button`
2331
- display: flex;
2332
- width: 16px;
2333
- height: 16px;
2334
- flex-direction: column;
2335
- justify-content: center;
2336
- align-items: center;
2337
- border-radius: ${exports.borderRadiusTokens.borderRadius04};
2338
- border: none;
2339
- background: ${({ color }) => exports.colorTokens[color]};
2340
- cursor: pointer;
2341
- transition:
2342
- transform 0.1s ease-out,
2343
- background 0.1s ease;
2344
-
2345
- &:hover {
2346
- background: ${({ color }) => exports.colorTokens[getNextColor(color, 1)]};
2347
- }
2348
- `;
2349
- var MUNUS_BUTTON_SYMBOL_KEY = Symbol("SHOPLFLOW_MUNUS_BUTTON");
2350
- var MinusButton = React3.forwardRef((_a, ref) => {
2351
- var _b = _a, { onClick, color = "neutral300" } = _b, rest = __objRest(_b, ["onClick", "color"]);
2352
- return /* @__PURE__ */ jsxRuntime.jsx(Container2, { "data-shoplflow": "minusButton", children: /* @__PURE__ */ jsxRuntime.jsx(IconButton2, __spreadProps(__spreadValues({ color, onClick, ref }, rest), { children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
2353
- /* @__PURE__ */ jsxRuntime.jsx(
2354
- "path",
2355
- {
2356
- d: "M0 4C0 1.79086 1.79086 0 4 0H12C14.2091 0 16 1.79086 16 4V12C16 14.2091 14.2091 16 12 16H4C1.79086 16 0 14.2091 0 12V4Z",
2357
- fill: "none"
2358
- }
2359
- ),
2360
- /* @__PURE__ */ jsxRuntime.jsx(
2361
- "path",
2362
- {
2363
- fillRule: "evenodd",
2364
- clipRule: "evenodd",
2365
- d: "M3 8C3 7.44772 3.44772 7 4 7H12C12.5523 7 13 7.44772 13 8C13 8.55228 12.5523 9 12 9H4C3.44772 9 3 8.55228 3 8Z",
2366
- fill: "white"
2367
- }
2368
- )
2369
- ] }) })) });
2370
- });
2371
- MinusButton[MUNUS_BUTTON_SYMBOL_KEY] = true;
2372
- exports.MinusButton = MinusButton;
2373
- var getStylesByStyleVariant = (styleVariant, isSelected, isHovered) => {
2374
- switch (styleVariant) {
2375
- case "PRIMARY":
2376
- if (isSelected) {
2377
- return react$1.css`
2378
- background: ${exports.colorTokens.primary300};
2379
- border: 1.5px solid ${exports.colorTokens.primary300};
2380
- & > svg > path {
2381
- fill: ${exports.colorTokens.neutral0};
2382
- }
2383
- ${isHovered && react$1.css`
2384
- border: 1.5px solid ${exports.colorTokens.primary400};
2385
- background: ${exports.colorTokens.primary400};
2386
- `}
2387
- `;
2388
- }
2389
- return react$1.css`
2390
- background: ${exports.colorTokens.neutral200};
2391
- border: 1.5px solid ${exports.colorTokens.neutral200};
2392
- border-radius: 4px;
2393
- ${isHovered && react$1.css`
2394
- border: 1.5px solid ${exports.colorTokens.neutral300};
2395
- background: ${exports.colorTokens.neutral300};
2396
- `}
2397
-
2398
- & > svg > path {
2399
- fill: ${exports.colorTokens.neutral0};
2400
- }
2401
- `;
2402
- case "LINE":
2403
- if (isSelected) {
2404
- return react$1.css`
2405
- border: 1.5px solid ${exports.colorTokens.primary300};
2406
- background: transparent;
2407
- border-radius: 4px;
2408
- & > svg > path {
2409
- fill: ${exports.colorTokens.primary300};
2410
- }
2411
- ${isHovered && react$1.css`
2412
- border: 1.5px solid ${exports.colorTokens.primary400};
2413
- & > svg > path {
2414
- fill: ${exports.colorTokens.primary400};
2415
- }
2416
- `}
2417
- `;
2146
+ ${isHovered && react$1.css`
2147
+ & > svg > circle {
2148
+ stroke: ${exports.colorTokens.primary400};
2418
2149
  }
2419
- return react$1.css`
2420
- background: transparent;
2421
- border: 1.5px solid ${exports.colorTokens.neutral200};
2422
- border-radius: 4px;
2423
- & > svg > path {
2424
- fill: ${exports.colorTokens.neutral200};
2425
- }
2426
- ${isHovered && react$1.css`
2427
- border: 1.5px solid ${exports.colorTokens.neutral300};
2428
- & > svg > path {
2429
- fill: ${exports.colorTokens.neutral300};
2430
- }
2431
- `}
2432
- `;
2433
- default:
2434
- return "";
2435
- }
2150
+ `}
2151
+ `;
2436
2152
  };
2437
- var StyledCheckHiddenInput = styled6__default.default.input`
2438
- position: absolute;
2439
- width: 0;
2440
- height: 0;
2441
- opacity: 0;
2442
- visibility: hidden;
2443
- `;
2444
- var StyledCheckbox = styled6__default.default.label`
2153
+ var StyledRadio = styled6__default.default.div`
2445
2154
  display: flex;
2446
2155
  align-items: center;
2447
2156
  justify-content: center;
@@ -2449,125 +2158,25 @@ var StyledCheckbox = styled6__default.default.label`
2449
2158
  min-height: 16px;
2450
2159
  width: 16px;
2451
2160
  height: 16px;
2452
- background: ${exports.colorTokens.neutral200};
2453
- border-radius: 4px;
2454
- box-sizing: border-box;
2161
+ ${({ isHovered }) => react$1.css`
2162
+ & > svg > circle {
2163
+ stroke: ${exports.colorTokens.neutral200};
2164
+ }
2165
+ ${isHovered && react$1.css`
2166
+ & > svg > circle {
2167
+ stroke: ${exports.colorTokens.neutral300};
2168
+ }
2169
+ `}
2170
+ `}
2455
2171
  cursor: pointer;
2456
- ${({ styleVar, isSelected, isHovered }) => getStylesByStyleVariant(styleVar, isSelected, isHovered)};
2172
+ ${({ isSelected, isHovered }) => isSelected && getSelectedStyle(isHovered)}
2457
2173
  ${({ disabled }) => getDisabledStyle(disabled)}
2458
2174
  `;
2459
- var Container3 = styled6__default.default.button`
2175
+ var Container4 = styled6__default.default.button`
2460
2176
  display: flex;
2461
2177
  align-items: center;
2462
2178
  justify-content: center;
2463
- padding: 4px;
2464
- width: fit-content;
2465
- height: fit-content;
2466
- background-color: transparent;
2467
- `;
2468
- exports.CHECKBOX_SYMBOL_KEY = Symbol("SHOPLFLOW_CHECKBOX");
2469
- var Checkbox = React3.forwardRef(
2470
- (_a, ref) => {
2471
- var _b = _a, { defaultSelected, isSelected, disabled, onMouseEnter, onClick, onMouseLeave, styleVar = "PRIMARY", id } = _b, rest = __objRest(_b, ["defaultSelected", "isSelected", "disabled", "onMouseEnter", "onClick", "onMouseLeave", "styleVar", "id"]);
2472
- const [selected, toggleSelected] = useOnToggle(isSelected, defaultSelected);
2473
- const [isHovered, toggleHovered] = React3.useState(false);
2474
- const handleMouseLeave = (e) => {
2475
- toggleHovered(false);
2476
- onMouseLeave && onMouseLeave(e);
2477
- };
2478
- const handleMouseEnter = (e) => {
2479
- toggleHovered(true);
2480
- onMouseEnter && onMouseEnter(e);
2481
- };
2482
- const handleClick = (e) => {
2483
- if (disabled) {
2484
- return;
2485
- }
2486
- onClick && onClick(e);
2487
- toggleSelected();
2488
- };
2489
- return /* @__PURE__ */ jsxRuntime.jsxs(
2490
- Container3,
2491
- {
2492
- onClick: handleClick,
2493
- onMouseLeave: handleMouseLeave,
2494
- onMouseEnter: handleMouseEnter,
2495
- disabled,
2496
- type: "button",
2497
- "data-shoplflow": "Checkbox",
2498
- children: [
2499
- /* @__PURE__ */ jsxRuntime.jsx(StyledCheckHiddenInput, __spreadProps(__spreadValues({ type: "checkbox", disabled, id }, rest), { ref })),
2500
- /* @__PURE__ */ jsxRuntime.jsx(
2501
- StyledCheckbox,
2502
- {
2503
- styleVar,
2504
- htmlFor: id,
2505
- isHovered,
2506
- isSelected: selected,
2507
- disabled,
2508
- children: /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "8", viewBox: "0 0 12 8", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
2509
- "path",
2510
- {
2511
- fillRule: "evenodd",
2512
- clipRule: "evenodd",
2513
- d: "M9.78822 0.297596C10.1761 -0.0955083 10.8093 -0.0997053 11.2024 0.288222C11.5653 0.646308 11.5968 1.21334 11.2943 1.60765L11.2118 1.7024L5.31714 7.7024C4.95248 8.07193 4.37282 8.09687 3.97909 7.77976L3.88476 7.69335L0.779404 4.42669C0.396475 4.02871 0.408672 3.39567 0.806647 3.01274C1.17401 2.65926 1.74167 2.64247 2.12801 2.95499L2.2206 3.03998L4.614 5.567L9.78822 0.297596Z",
2514
- fill: "white"
2515
- }
2516
- ) })
2517
- }
2518
- )
2519
- ]
2520
- }
2521
- );
2522
- }
2523
- );
2524
- Checkbox[exports.CHECKBOX_SYMBOL_KEY] = true;
2525
- exports.Checkbox = Checkbox;
2526
-
2527
- // src/components/ControlButtons/Checkbox/Checkbox.types.ts
2528
- exports.CheckboxStyleVariants = {
2529
- PRIMARY: "PRIMARY",
2530
- LINE: "LINE"
2531
- };
2532
- var getSelectedStyle = (isHovered) => {
2533
- return react$1.css`
2534
- & > svg > circle {
2535
- stroke: ${exports.colorTokens.primary300};
2536
- }
2537
- ${isHovered && react$1.css`
2538
- & > svg > circle {
2539
- stroke: ${exports.colorTokens.primary400};
2540
- }
2541
- `}
2542
- `;
2543
- };
2544
- var StyledRadio = styled6__default.default.div`
2545
- display: flex;
2546
- align-items: center;
2547
- justify-content: center;
2548
- min-width: 16px;
2549
- min-height: 16px;
2550
- width: 16px;
2551
- height: 16px;
2552
- ${({ isHovered }) => react$1.css`
2553
- & > svg > circle {
2554
- stroke: ${exports.colorTokens.neutral200};
2555
- }
2556
- ${isHovered && react$1.css`
2557
- & > svg > circle {
2558
- stroke: ${exports.colorTokens.neutral300};
2559
- }
2560
- `}
2561
- `}
2562
- cursor: pointer;
2563
- ${({ isSelected, isHovered }) => isSelected && getSelectedStyle(isHovered)}
2564
- ${({ disabled }) => getDisabledStyle(disabled)}
2565
- `;
2566
- var Container4 = styled6__default.default.button`
2567
- display: flex;
2568
- align-items: center;
2569
- justify-content: center;
2570
- background: transparent;
2179
+ background: transparent;
2571
2180
  padding: 4px;
2572
2181
  width: fit-content;
2573
2182
  height: fit-content;
@@ -2715,6 +2324,524 @@ exports.MenuSizeVariants = {
2715
2324
  S: "S",
2716
2325
  M: "M"
2717
2326
  };
2327
+ exports.DropdownButtonContext = React3.createContext(null);
2328
+ exports.useDropdownButtonContext = () => {
2329
+ const context = React3.useContext(exports.DropdownButtonContext);
2330
+ if (!context) {
2331
+ throw new Error("DropdownButtonContext must be used within a DropdownButton component");
2332
+ }
2333
+ return context;
2334
+ };
2335
+
2336
+ // src/components/Icon/Icon.types.ts
2337
+ exports.IconSizeVariants = {
2338
+ XS: "XS",
2339
+ S: "S",
2340
+ M: "M",
2341
+ L: "L",
2342
+ XL: "XL"
2343
+ };
2344
+
2345
+ // src/components/Icon/Icon.styled.ts
2346
+ var getIconSize = (size2) => {
2347
+ switch (size2) {
2348
+ case exports.IconSizeVariants.XS:
2349
+ return "12px";
2350
+ case exports.IconSizeVariants.S:
2351
+ return "20px";
2352
+ case exports.IconSizeVariants.M:
2353
+ return "24px";
2354
+ case exports.IconSizeVariants.L:
2355
+ return "30px";
2356
+ case exports.IconSizeVariants.XL:
2357
+ return "36px";
2358
+ default:
2359
+ return "fit-content";
2360
+ }
2361
+ };
2362
+ exports.StyledIcon = styled6__default.default.svg`
2363
+ width: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2364
+ min-width: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2365
+ height: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2366
+ min-height: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2367
+ & > path {
2368
+ fill: ${({ color }) => color && exports.colorTokens[color]};
2369
+ }
2370
+ `;
2371
+ var Icon = React3.forwardRef((_a, ref) => {
2372
+ var _b = _a, { iconSource } = _b, rest = __objRest(_b, ["iconSource"]);
2373
+ return /* @__PURE__ */ jsxRuntime.jsx(exports.StyledIcon, __spreadProps(__spreadValues({ as: iconSource, ref }, rest), { "data-shoplflow": "Icon" }));
2374
+ });
2375
+ exports.Icon = Icon;
2376
+ var DropdownButtonMenu = (_a) => {
2377
+ var _b = _a, { onClick, children } = _b, rest = __objRest(_b, ["onClick", "children"]);
2378
+ const { setIsOpen } = exports.useDropdownButtonContext();
2379
+ return /* @__PURE__ */ jsxRuntime.jsx(
2380
+ exports.Menu,
2381
+ __spreadProps(__spreadValues({
2382
+ onClick: (event) => {
2383
+ event.stopPropagation();
2384
+ event.preventDefault();
2385
+ onClick == null ? void 0 : onClick(event);
2386
+ setIsOpen(false);
2387
+ }
2388
+ }, rest), {
2389
+ children
2390
+ })
2391
+ );
2392
+ };
2393
+ var DropdownButton = (_a) => {
2394
+ var _b = _a, {
2395
+ text,
2396
+ sizeVar,
2397
+ className,
2398
+ disabled,
2399
+ children,
2400
+ placement = "bottom-end",
2401
+ styleVar = "PRIMARY",
2402
+ floatingZIndex
2403
+ } = _b, rest = __objRest(_b, [
2404
+ "text",
2405
+ "sizeVar",
2406
+ "className",
2407
+ "disabled",
2408
+ "children",
2409
+ "placement",
2410
+ "styleVar",
2411
+ "floatingZIndex"
2412
+ ]);
2413
+ const selector = React3.useRef(`shoplflow-${crypto.randomUUID()}-dropdown-button`).current;
2414
+ const [isOpen, setIsOpen] = utils.useOutsideClick({
2415
+ selector: `.${selector}`,
2416
+ useOutsideScroll: true
2417
+ });
2418
+ let _className = `${selector}`;
2419
+ if (className) {
2420
+ _className += ` ${className}`;
2421
+ }
2422
+ let _styleVar = styleVar;
2423
+ let color = void 0;
2424
+ if (styleVar === "PRIMARY") {
2425
+ _styleVar = "SOLID";
2426
+ color = "coolgray50";
2427
+ }
2428
+ return /* @__PURE__ */ jsxRuntime.jsx(exports.DropdownButtonContext.Provider, { value: { isOpen, setIsOpen }, children: /* @__PURE__ */ jsxRuntime.jsxs(exports.Popper, { placement, offset: 4, children: [
2429
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Popper.Trigger, { isOpen, className: _className, children: /* @__PURE__ */ jsxRuntime.jsx(
2430
+ exports.Button,
2431
+ __spreadProps(__spreadValues({
2432
+ "data-shoplflow": "DropdownButton",
2433
+ className: _className,
2434
+ sizeVar,
2435
+ styleVar: _styleVar,
2436
+ disabled,
2437
+ color,
2438
+ rightSource: /* @__PURE__ */ jsxRuntime.jsx(
2439
+ StyledArrowIcon,
2440
+ {
2441
+ animate: {
2442
+ rotate: isOpen ? 180 : 0
2443
+ },
2444
+ transition: {
2445
+ duration: 0.2
2446
+ },
2447
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2448
+ exports.Icon,
2449
+ {
2450
+ iconSource: ShoplAssets.DownArrowSolidXsmallIcon,
2451
+ color: styleVar === "PRIMARY" ? "coolgray300" : "neutral400",
2452
+ sizeVar: "XS"
2453
+ }
2454
+ )
2455
+ }
2456
+ ),
2457
+ onClick: () => {
2458
+ if (disabled) {
2459
+ return;
2460
+ }
2461
+ setIsOpen((prev) => !prev);
2462
+ }
2463
+ }, rest), {
2464
+ children: /* @__PURE__ */ jsxRuntime.jsx(exports.Text, { typography: "body2_400", color: "neutral700", children: text })
2465
+ })
2466
+ ) }),
2467
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Popper.Portal, { zIndex: floatingZIndex, children: /* @__PURE__ */ jsxRuntime.jsx(StyledPopoverContentWrapper, { className: _className, children }) })
2468
+ ] }) });
2469
+ };
2470
+ DropdownButton.Menu = DropdownButtonMenu;
2471
+ exports.DropdownButton = DropdownButton;
2472
+
2473
+ // src/components/Buttons/DropdownButton/DropdownButton.types.ts
2474
+ exports.DropdownButtonSizeVariants = {
2475
+ S: "S",
2476
+ M: "M"
2477
+ };
2478
+ exports.DropdownButtonStyleVariants = {
2479
+ PRIMARY: "PRIMARY",
2480
+ SECONDARY: "SECONDARY"
2481
+ };
2482
+ var informationStyle = react$1.css`
2483
+ background: ${exports.colorTokens.neutral100};
2484
+ & > span {
2485
+ color: ${exports.colorTokens.neutral600};
2486
+ }
2487
+ & > svg > path {
2488
+ fill: ${exports.colorTokens.neutral600};
2489
+ }
2490
+ `;
2491
+ var alertStyle = react$1.css`
2492
+ background: ${exports.colorTokens.red100};
2493
+ & > span {
2494
+ align-self: center;
2495
+ color: ${exports.colorTokens.red300};
2496
+ }
2497
+ & > svg > path {
2498
+ fill: ${exports.colorTokens.red300};
2499
+ }
2500
+ `;
2501
+ var StyledCallout = styled6__default.default.div`
2502
+ display: flex;
2503
+ justify-content: flex-start;
2504
+ align-items: start;
2505
+ padding: 6px 8px;
2506
+ gap: 4px;
2507
+ border-radius: ${exports.borderRadiusTokens.borderRadius08};
2508
+ ${({ styleVar }) => styleVar === "INFORMATION" && informationStyle}
2509
+ ${({ styleVar }) => styleVar === "ALERT" && alertStyle}
2510
+ `;
2511
+ var StyledCalloutIcon = styled6__default.default.svg`
2512
+ display: flex;
2513
+ height: 20px;
2514
+ min-height: 20px;
2515
+ width: 20px;
2516
+ min-width: 20px;
2517
+ `;
2518
+ styled6__default.default.div`
2519
+ padding: 2px 0;
2520
+ `;
2521
+ var Callout = (_a) => {
2522
+ var _b = _a, { children, styleVar = "INFORMATION" } = _b, rest = __objRest(_b, ["children", "styleVar"]);
2523
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledCallout, __spreadProps(__spreadValues({}, rest), { styleVar, "data-shoplflow": "Callout", children }));
2524
+ };
2525
+ var CalloutText = (_a) => {
2526
+ var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
2527
+ return /* @__PURE__ */ jsxRuntime.jsx(exports.Text, __spreadProps(__spreadValues({}, rest), { typography: "paragraph2", children }));
2528
+ };
2529
+ var CalloutIcon = ({ iconSource }) => {
2530
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledCalloutIcon, { as: iconSource });
2531
+ };
2532
+ Callout.Text = CalloutText;
2533
+ Callout.Icon = CalloutIcon;
2534
+ exports.Callout = Callout;
2535
+
2536
+ // src/components/Callout/Callout.types.ts
2537
+ exports.CalloutTypes = {
2538
+ INFORMATION: "INFORMATION",
2539
+ ALERT: "ALERT"
2540
+ };
2541
+ var getDropdownHeightBySizeVar = (size2) => {
2542
+ switch (size2) {
2543
+ case "M":
2544
+ return "40px";
2545
+ case "S":
2546
+ return "32px";
2547
+ default:
2548
+ return "40px";
2549
+ }
2550
+ };
2551
+ var getDropdownFontSizeBySizeVar = (size2) => {
2552
+ switch (size2) {
2553
+ case "M":
2554
+ return "body1_400";
2555
+ case "S":
2556
+ return "body2_400";
2557
+ default:
2558
+ return "body1_400";
2559
+ }
2560
+ };
2561
+ var getDropdownStyleBySizeVar = (size2) => {
2562
+ switch (size2) {
2563
+ case "M":
2564
+ return react$1.css`
2565
+ padding: 4px 4px 4px 12px;
2566
+ `;
2567
+ case "S":
2568
+ return react$1.css`
2569
+ padding: 4px 4px 4px 8px;
2570
+ gap: 4px;
2571
+ `;
2572
+ default:
2573
+ return react$1.css`
2574
+ padding: 4px 4px 4px 12px;
2575
+ `;
2576
+ }
2577
+ };
2578
+ var getDropdownIconSizeBySizeVar = (size2) => {
2579
+ switch (size2) {
2580
+ case "S":
2581
+ return react$1.css`
2582
+ height: 24px;
2583
+ width: 24px;
2584
+ min-width: 24px;
2585
+ min-height: 24px;
2586
+ `;
2587
+ case "M":
2588
+ return react$1.css`
2589
+ height: 32px;
2590
+ width: 32px;
2591
+ min-width: 32px;
2592
+ min-height: 32px;
2593
+ `;
2594
+ default:
2595
+ return react$1.css`
2596
+ height: 32px;
2597
+ width: 32px;
2598
+ min-width: 32px;
2599
+ min-height: 32px;
2600
+ `;
2601
+ }
2602
+ };
2603
+ var StyledDropdown = styled6__default.default.div`
2604
+ width: ${({ width }) => width};
2605
+ `;
2606
+ var StyledDropdownContent = styled6__default.default.div`
2607
+ display: flex;
2608
+ flex-direction: column;
2609
+ background: ${exports.colorTokens.neutral0};
2610
+ width: ${({ width }) => width != null ? width : "240px"};
2611
+ padding: 4px;
2612
+ border-radius: 6px;
2613
+ box-shadow: ${exports.boxShadowTokens.dropShadow};
2614
+ `;
2615
+ var StyledDropdownButton = styled6__default.default.button`
2616
+ display: flex;
2617
+ flex-direction: row;
2618
+ align-items: center;
2619
+ justify-content: space-between;
2620
+ width: 100%;
2621
+ height: 100%;
2622
+ gap: 8px;
2623
+ cursor: pointer;
2624
+ background-color: ${exports.colorTokens.neutral0};
2625
+ ${({ sizeVar }) => sizeVar && getDropdownStyleBySizeVar(sizeVar)};
2626
+ ${({ disabled }) => disabled && react$1.css`
2627
+ background-color: ${exports.colorTokens.neutral100};
2628
+ cursor: not-allowed;
2629
+ `}
2630
+ `;
2631
+ var DropdownButtonIcon = styled6__default.default(framerMotion.motion.div)`
2632
+ display: flex;
2633
+ align-items: center;
2634
+ justify-content: center;
2635
+
2636
+ ${({ sizeVar }) => sizeVar && getDropdownIconSizeBySizeVar(sizeVar)};
2637
+ `;
2638
+ var DropdownContext = React3.createContext(null);
2639
+ var useDropdown = () => {
2640
+ const context = React3.useContext(DropdownContext);
2641
+ if (context === null) {
2642
+ throw new Error("useDropdown must be used within a DropdownProvider");
2643
+ }
2644
+ return context;
2645
+ };
2646
+ var getBorderColorByStatus = ({ isFocused, isError, isHovered, disabled }) => {
2647
+ if (!disabled) {
2648
+ if (isError) {
2649
+ return exports.colorTokens.red300;
2650
+ }
2651
+ if (isFocused) {
2652
+ return exports.colorTokens.primary300;
2653
+ }
2654
+ if (isHovered) {
2655
+ return exports.colorTokens.neutral700;
2656
+ }
2657
+ }
2658
+ return exports.colorTokens.neutral300;
2659
+ };
2660
+ var getStyleByType = ({
2661
+ type,
2662
+ height,
2663
+ minHeight,
2664
+ maxHeight,
2665
+ width,
2666
+ minWidth,
2667
+ maxWidth,
2668
+ borderRadius,
2669
+ customNumberInputHeight
2670
+ }) => {
2671
+ if (type === "number") {
2672
+ return react$1.css`
2673
+ width: ${width || "64px"};
2674
+ height: ${customNumberInputHeight || "32px"};
2675
+ border-radius: ${borderRadius ? exports.borderRadiusTokens[borderRadius] : "6px"};
2676
+ `;
2677
+ }
2678
+ return react$1.css`
2679
+ width: ${width || "100%"};
2680
+ min-width: ${minWidth || "initial"};
2681
+ max-width: ${maxWidth || "initial"};
2682
+ height: ${height || "initial"};
2683
+ min-height: ${minHeight || "initial"};
2684
+ max-height: ${maxHeight || "initial"};
2685
+ border-radius: ${borderRadius ? exports.borderRadiusTokens[borderRadius] : "6px"};
2686
+ `;
2687
+ };
2688
+ var InputWrapper = styled6__default.default.label`
2689
+ position: relative;
2690
+ display: flex;
2691
+ align-items: center;
2692
+ border-radius: 6px;
2693
+ flex-direction: ${({ direction }) => direction || "row"};
2694
+ ${({ type, height, minHeight, maxHeight, width, maxWidth, minWidth, borderRadius, customNumberInputHeight }) => getStyleByType({
2695
+ customNumberInputHeight,
2696
+ type,
2697
+ height,
2698
+ minHeight,
2699
+ maxHeight,
2700
+ width,
2701
+ maxWidth,
2702
+ minWidth,
2703
+ borderRadius
2704
+ })};
2705
+ justify-content: space-between;
2706
+ gap: ${({ gap }) => gap || "8px"};
2707
+ border: 1px solid ${(props) => getBorderColorByStatus(props)};
2708
+ background-color: ${exports.colorTokens.neutral0};
2709
+ overflow: hidden;
2710
+ ${({ disabled }) => disabled && react$1.css`
2711
+ background-color: ${exports.colorTokens.neutral100};
2712
+ cursor: not-allowed;
2713
+ `};
2714
+ `;
2715
+ var DropdownTriggerButton = React3.forwardRef(
2716
+ (_a, ref) => {
2717
+ var _b = _a, { width = "100%", onClick, sizeVar = "M", isError, placeholder, value, disabled, leftSource } = _b, rest = __objRest(_b, ["width", "onClick", "sizeVar", "isError", "placeholder", "value", "disabled", "leftSource"]);
2718
+ const { isOpen, setIsOpen } = useDropdown();
2719
+ const [isHovered, setIsHovered] = React3.useState(false);
2720
+ const handleOnClick = (e) => {
2721
+ if (!disabled) {
2722
+ onClick && onClick(e);
2723
+ setIsOpen(!isOpen);
2724
+ }
2725
+ };
2726
+ const handleOnMouseEnter = () => {
2727
+ setIsHovered(true);
2728
+ };
2729
+ const handleOnMouseLeave = () => {
2730
+ setIsHovered(false);
2731
+ };
2732
+ const getTextColor = ({ value: value2, disabled: disabled2 }) => {
2733
+ if (disabled2) {
2734
+ return "neutral350";
2735
+ }
2736
+ if (!value2) {
2737
+ return "neutral400";
2738
+ }
2739
+ return "neutral700";
2740
+ };
2741
+ return /* @__PURE__ */ jsxRuntime.jsx(
2742
+ InputWrapper,
2743
+ {
2744
+ onMouseEnter: handleOnMouseEnter,
2745
+ onMouseLeave: handleOnMouseLeave,
2746
+ isFocused: isOpen,
2747
+ isHovered,
2748
+ disabled,
2749
+ width,
2750
+ isError,
2751
+ height: getDropdownHeightBySizeVar(sizeVar),
2752
+ children: /* @__PURE__ */ jsxRuntime.jsxs(StyledDropdownButton, __spreadProps(__spreadValues({ ref, onClick: handleOnClick, disabled }, rest), { sizeVar, children: [
2753
+ leftSource && leftSource,
2754
+ value || /* @__PURE__ */ jsxRuntime.jsx(
2755
+ exports.Text,
2756
+ {
2757
+ typography: getDropdownFontSizeBySizeVar(sizeVar),
2758
+ color: getTextColor({ value, disabled }),
2759
+ textOverflow: "ellipsis",
2760
+ lineClamp: 1,
2761
+ children: placeholder
2762
+ }
2763
+ ),
2764
+ /* @__PURE__ */ jsxRuntime.jsx(
2765
+ DropdownButtonIcon,
2766
+ {
2767
+ sizeVar,
2768
+ animate: {
2769
+ rotate: isOpen ? 180 : 0
2770
+ },
2771
+ transition: {
2772
+ duration: 0.2
2773
+ },
2774
+ children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: ShoplAssets.DownArrowSolidXsmallIcon, color: "neutral400", sizeVar: "XS" })
2775
+ }
2776
+ )
2777
+ ] }))
2778
+ }
2779
+ );
2780
+ }
2781
+ );
2782
+ var DropdownContent = (_a) => {
2783
+ var _b = _a, { children, width: initialWidth, type, onClick } = _b, rest = __objRest(_b, ["children", "width", "type", "onClick"]);
2784
+ const { width, setIsOpen, option } = useDropdown();
2785
+ const isFillType = type === "FILL";
2786
+ const contentWidth = isFillType ? `${width}px` : initialWidth;
2787
+ const returnCallbackByOption = () => {
2788
+ if (option === "OUTSIDE_CLICK") {
2789
+ return () => setIsOpen(false);
2790
+ }
2791
+ if (option === "CLICK") {
2792
+ return () => setIsOpen(false);
2793
+ }
2794
+ return utils.noop;
2795
+ };
2796
+ const handleClick = (e) => {
2797
+ onClick && onClick(e);
2798
+ if (option === "CLICK") {
2799
+ setIsOpen(false);
2800
+ }
2801
+ };
2802
+ return /* @__PURE__ */ jsxRuntime.jsx(utils.OutSideClick, { outsideClick: returnCallbackByOption(), children: /* @__PURE__ */ jsxRuntime.jsx(StyledDropdownContent, __spreadProps(__spreadValues({ width: contentWidth, onClick: handleClick }, rest), { children })) });
2803
+ };
2804
+ var Dropdown = ({
2805
+ isOpen: initialIsOpen = false,
2806
+ trigger,
2807
+ popper,
2808
+ option = "CLICK",
2809
+ width = "100%"
2810
+ }) => {
2811
+ const [triggerRef, setTriggerRef] = React3.useState(null);
2812
+ const [size2, setSize] = React3.useState({ width: 0, height: 0 });
2813
+ const [isOpen, setIsOpen] = React3.useState(false);
2814
+ React3.useEffect(() => {
2815
+ if (triggerRef) {
2816
+ setSize({
2817
+ width: triggerRef.offsetWidth,
2818
+ height: triggerRef.offsetHeight
2819
+ });
2820
+ }
2821
+ }, [triggerRef]);
2822
+ React3.useEffect(() => {
2823
+ if (initialIsOpen === void 0) {
2824
+ return;
2825
+ }
2826
+ setIsOpen(initialIsOpen);
2827
+ }, [initialIsOpen]);
2828
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledDropdown, { "data-shoplflow": "Dropdown", width, children: /* @__PURE__ */ jsxRuntime.jsx(DropdownContext.Provider, { value: __spreadProps(__spreadValues({}, size2), { isOpen, setIsOpen, option }), children: /* @__PURE__ */ jsxRuntime.jsxs(
2829
+ exports.Popper,
2830
+ {
2831
+ offset: 4,
2832
+ autoPlacement: {
2833
+ allowedPlacements: ["bottom-start", "top-start"]
2834
+ },
2835
+ children: [
2836
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Popper.Trigger, { ref: setTriggerRef, isOpen, width, children: trigger }),
2837
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Popper.Portal, { children: popper })
2838
+ ]
2839
+ }
2840
+ ) }) });
2841
+ };
2842
+ Dropdown.Button = DropdownTriggerButton;
2843
+ Dropdown.Content = DropdownContent;
2844
+ exports.Dropdown = Dropdown;
2718
2845
  var StyledList = styled6__default.default.li`
2719
2846
  display: flex;
2720
2847
  flex-direction: row;