@shoplflow/base 0.32.18 → 0.32.20

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
@@ -11,8 +11,8 @@ var Scrollbars = require('react-custom-scrollbars-2');
11
11
  var react = require('@floating-ui/react');
12
12
  var reactDom = require('@floating-ui/react-dom');
13
13
  var ShoplAssets = require('@shoplflow/shopl-assets');
14
- var HadaAssets = require('@shoplflow/hada-assets');
15
14
  var core = require('@floating-ui/core');
15
+ var HadaAssets = require('@shoplflow/hada-assets');
16
16
  var DatePicker2 = require('react-datepicker');
17
17
  require('react-datepicker/dist/react-datepicker.css');
18
18
  var SimpleBarReact = require('simplebar-react');
@@ -1811,65 +1811,26 @@ 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 getPopoverContentStyle = () => {
1815
+ return react$1.css`
1816
+ min-width: 112px;
1817
+ padding: 4px;
1818
+ box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.12);
1819
+ border-radius: 8px;
1820
+ background-color: ${exports.colorTokens.neutral0};
1821
+ `;
1822
+ };
1823
+
1824
+ // src/components/Buttons/DropdownButton/DropdownButton.styled.ts
1825
+ var StyledPopoverContentWrapper = styled6__default.default.div`
1826
+ ${getPopoverContentStyle()}
1842
1827
  `;
1843
- var StyledCalloutIcon = styled6__default.default.svg`
1828
+ var StyledArrowIcon = styled6__default.default(framerMotion.motion.div)`
1844
1829
  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;
1830
+ justify-content: center;
1831
+ align-items: center;
1832
+ flex-shrink: 0;
1852
1833
  `;
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
1834
  var StyledPopper = styled6__default.default.div`
1874
1835
  width: ${({ width }) => width != null ? width : "fit-content"};
1875
1836
  height: ${({ height }) => height && height};
@@ -1974,747 +1935,1122 @@ exports.PopperPortal = React3.forwardRef(
1974
1935
  Popper.Trigger = exports.PopperTrigger;
1975
1936
  Popper.Portal = exports.PopperPortal;
1976
1937
  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
- `;
1938
+ var Container2 = styled6__default.default.div`
1939
+ display: flex;
1940
+ align-items: center;
1941
+ justify-content: center;
1942
+ width: 24px;
1943
+ height: 24px;
1944
+ padding: 4px;
1945
+ `;
1946
+ var IconButton2 = styled6__default.default.button`
1947
+ display: flex;
1948
+ width: 16px;
1949
+ height: 16px;
1950
+ flex-direction: column;
1951
+ justify-content: center;
1952
+ align-items: center;
1953
+ border-radius: ${exports.borderRadiusTokens.borderRadius04};
1954
+ border: none;
1955
+ background: ${({ color }) => exports.colorTokens[color]};
1956
+ cursor: pointer;
1957
+ transition:
1958
+ transform 0.1s ease-out,
1959
+ background 0.1s ease;
1960
+
1961
+ &:hover {
1962
+ background: ${({ color }) => exports.colorTokens[getNextColor(color, 1)]};
2012
1963
  }
2013
- };
2014
- var getDropdownIconSizeBySizeVar = (size2) => {
2015
- switch (size2) {
2016
- case "S":
1964
+ `;
1965
+ var MUNUS_BUTTON_SYMBOL_KEY = Symbol("SHOPLFLOW_MUNUS_BUTTON");
1966
+ var MinusButton = React3.forwardRef((_a, ref) => {
1967
+ var _b = _a, { onClick, color = "neutral300" } = _b, rest = __objRest(_b, ["onClick", "color"]);
1968
+ 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: [
1969
+ /* @__PURE__ */ jsxRuntime.jsx(
1970
+ "path",
1971
+ {
1972
+ 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",
1973
+ fill: "none"
1974
+ }
1975
+ ),
1976
+ /* @__PURE__ */ jsxRuntime.jsx(
1977
+ "path",
1978
+ {
1979
+ fillRule: "evenodd",
1980
+ clipRule: "evenodd",
1981
+ 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",
1982
+ fill: "white"
1983
+ }
1984
+ )
1985
+ ] }) })) });
1986
+ });
1987
+ MinusButton[MUNUS_BUTTON_SYMBOL_KEY] = true;
1988
+ exports.MinusButton = MinusButton;
1989
+ var getStylesByStyleVariant = (styleVariant, isSelected, isHovered) => {
1990
+ switch (styleVariant) {
1991
+ case "PRIMARY":
1992
+ if (isSelected) {
1993
+ return react$1.css`
1994
+ background: ${exports.colorTokens.primary300};
1995
+ border: 1.5px solid ${exports.colorTokens.primary300};
1996
+ & > svg > path {
1997
+ fill: ${exports.colorTokens.neutral0};
1998
+ }
1999
+ ${isHovered && react$1.css`
2000
+ border: 1.5px solid ${exports.colorTokens.primary400};
2001
+ background: ${exports.colorTokens.primary400};
2002
+ `}
2003
+ `;
2004
+ }
2017
2005
  return react$1.css`
2018
- height: 24px;
2019
- width: 24px;
2020
- min-width: 24px;
2021
- min-height: 24px;
2006
+ background: ${exports.colorTokens.neutral200};
2007
+ border: 1.5px solid ${exports.colorTokens.neutral200};
2008
+ border-radius: 4px;
2009
+ ${isHovered && react$1.css`
2010
+ border: 1.5px solid ${exports.colorTokens.neutral300};
2011
+ background: ${exports.colorTokens.neutral300};
2012
+ `}
2013
+
2014
+ & > svg > path {
2015
+ fill: ${exports.colorTokens.neutral0};
2016
+ }
2022
2017
  `;
2023
- case "M":
2018
+ case "LINE":
2019
+ if (isSelected) {
2020
+ return react$1.css`
2021
+ border: 1.5px solid ${exports.colorTokens.primary300};
2022
+ background: transparent;
2023
+ border-radius: 4px;
2024
+ & > svg > path {
2025
+ fill: ${exports.colorTokens.primary300};
2026
+ }
2027
+ ${isHovered && react$1.css`
2028
+ border: 1.5px solid ${exports.colorTokens.primary400};
2029
+ & > svg > path {
2030
+ fill: ${exports.colorTokens.primary400};
2031
+ }
2032
+ `}
2033
+ `;
2034
+ }
2024
2035
  return react$1.css`
2025
- height: 32px;
2026
- width: 32px;
2027
- min-width: 32px;
2028
- min-height: 32px;
2036
+ background: transparent;
2037
+ border: 1.5px solid ${exports.colorTokens.neutral200};
2038
+ border-radius: 4px;
2039
+ & > svg > path {
2040
+ fill: ${exports.colorTokens.neutral200};
2041
+ }
2042
+ ${isHovered && react$1.css`
2043
+ border: 1.5px solid ${exports.colorTokens.neutral300};
2044
+ & > svg > path {
2045
+ fill: ${exports.colorTokens.neutral300};
2046
+ }
2047
+ `}
2029
2048
  `;
2030
2049
  default:
2031
- return react$1.css`
2032
- height: 32px;
2033
- width: 32px;
2034
- min-width: 32px;
2035
- min-height: 32px;
2036
- `;
2050
+ return "";
2037
2051
  }
2038
2052
  };
2039
- var StyledDropdown = styled6__default.default.div`
2040
- width: ${({ width }) => width};
2041
- `;
2042
- var StyledDropdownContent = styled6__default.default.div`
2043
- 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};
2053
+ var StyledCheckHiddenInput = styled6__default.default.input`
2054
+ position: absolute;
2055
+ width: 0;
2056
+ height: 0;
2057
+ opacity: 0;
2058
+ visibility: hidden;
2050
2059
  `;
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)`
2060
+ var StyledCheckbox = styled6__default.default.label`
2068
2061
  display: flex;
2069
2062
  align-items: center;
2070
2063
  justify-content: center;
2071
-
2072
- ${({ sizeVar }) => sizeVar && getDropdownIconSizeBySizeVar(sizeVar)};
2064
+ min-width: 16px;
2065
+ min-height: 16px;
2066
+ width: 16px;
2067
+ height: 16px;
2068
+ background: ${exports.colorTokens.neutral200};
2069
+ border-radius: 4px;
2070
+ box-sizing: border-box;
2071
+ cursor: pointer;
2072
+ ${({ styleVar, isSelected, isHovered }) => getStylesByStyleVariant(styleVar, isSelected, isHovered)};
2073
+ ${({ disabled }) => getDisabledStyle(disabled)}
2073
2074
  `;
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;
2075
+ var Container3 = styled6__default.default.button`
2126
2076
  display: flex;
2127
2077
  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
- }
2078
+ justify-content: center;
2079
+ padding: 4px;
2080
+ width: fit-content;
2081
+ height: fit-content;
2082
+ background-color: transparent;
2186
2083
  `;
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(
2084
+ exports.CHECKBOX_SYMBOL_KEY = Symbol("SHOPLFLOW_CHECKBOX");
2085
+ var Checkbox = React3.forwardRef(
2193
2086
  (_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);
2087
+ var _b = _a, { defaultSelected, isSelected, disabled, onMouseEnter, onClick, onMouseLeave, styleVar = "PRIMARY", id } = _b, rest = __objRest(_b, ["defaultSelected", "isSelected", "disabled", "onMouseEnter", "onClick", "onMouseLeave", "styleVar", "id"]);
2088
+ const [selected, toggleSelected] = useOnToggle(isSelected, defaultSelected);
2089
+ const [isHovered, toggleHovered] = React3.useState(false);
2090
+ const handleMouseLeave = (e) => {
2091
+ toggleHovered(false);
2092
+ onMouseLeave && onMouseLeave(e);
2205
2093
  };
2206
- const handleOnMouseLeave = () => {
2207
- setIsHovered(false);
2094
+ const handleMouseEnter = (e) => {
2095
+ toggleHovered(true);
2096
+ onMouseEnter && onMouseEnter(e);
2208
2097
  };
2209
- const getTextColor = ({ value: value2, disabled: disabled2 }) => {
2210
- if (disabled2) {
2211
- return "neutral350";
2212
- }
2213
- if (!value2) {
2214
- return "neutral400";
2098
+ const handleClick = (e) => {
2099
+ if (disabled) {
2100
+ return;
2215
2101
  }
2216
- return "neutral700";
2102
+ onClick && onClick(e);
2103
+ toggleSelected();
2217
2104
  };
2218
- return /* @__PURE__ */ jsxRuntime.jsx(
2219
- InputWrapper,
2105
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2106
+ Container3,
2220
2107
  {
2221
- onMouseEnter: handleOnMouseEnter,
2222
- onMouseLeave: handleOnMouseLeave,
2223
- isFocused: isOpen,
2224
- isHovered,
2108
+ onClick: handleClick,
2109
+ onMouseLeave: handleMouseLeave,
2110
+ onMouseEnter: handleMouseEnter,
2225
2111
  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
- ),
2112
+ type: "button",
2113
+ "data-shoplflow": "Checkbox",
2114
+ children: [
2115
+ /* @__PURE__ */ jsxRuntime.jsx(StyledCheckHiddenInput, __spreadProps(__spreadValues({ type: "checkbox", disabled, id }, rest), { ref })),
2241
2116
  /* @__PURE__ */ jsxRuntime.jsx(
2242
- DropdownButtonIcon,
2117
+ StyledCheckbox,
2243
2118
  {
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" })
2119
+ styleVar,
2120
+ htmlFor: id,
2121
+ isHovered,
2122
+ isSelected: selected,
2123
+ disabled,
2124
+ 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(
2125
+ "path",
2126
+ {
2127
+ fillRule: "evenodd",
2128
+ clipRule: "evenodd",
2129
+ 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",
2130
+ fill: "white"
2131
+ }
2132
+ ) })
2252
2133
  }
2253
2134
  )
2254
- ] }))
2135
+ ]
2255
2136
  }
2256
2137
  );
2257
2138
  }
2258
2139
  );
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);
2140
+ Checkbox[exports.CHECKBOX_SYMBOL_KEY] = true;
2141
+ exports.Checkbox = Checkbox;
2142
+
2143
+ // src/components/ControlButtons/Checkbox/Checkbox.types.ts
2144
+ exports.CheckboxStyleVariants = {
2145
+ PRIMARY: "PRIMARY",
2146
+ LINE: "LINE"
2147
+ };
2148
+ var getSelectedStyle = (isHovered) => {
2149
+ return react$1.css`
2150
+ & > svg > circle {
2151
+ stroke: ${exports.colorTokens.primary300};
2270
2152
  }
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 })) });
2153
+ ${isHovered && react$1.css`
2154
+ & > svg > circle {
2155
+ stroke: ${exports.colorTokens.primary400};
2156
+ }
2157
+ `}
2158
+ `;
2280
2159
  };
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
- ]
2160
+ var StyledRadio = styled6__default.default.div`
2161
+ display: flex;
2162
+ align-items: center;
2163
+ justify-content: center;
2164
+ min-width: 16px;
2165
+ min-height: 16px;
2166
+ width: 16px;
2167
+ height: 16px;
2168
+ ${({ isHovered }) => react$1.css`
2169
+ & > svg > circle {
2170
+ stroke: ${exports.colorTokens.neutral200};
2316
2171
  }
2317
- ) }) });
2318
- };
2319
- Dropdown.Button = DropdownButton;
2320
- Dropdown.Content = DropdownContent;
2321
- exports.Dropdown = Dropdown;
2322
- var Container2 = styled6__default.default.div`
2172
+ ${isHovered && react$1.css`
2173
+ & > svg > circle {
2174
+ stroke: ${exports.colorTokens.neutral300};
2175
+ }
2176
+ `}
2177
+ `}
2178
+ cursor: pointer;
2179
+ ${({ isSelected, isHovered }) => isSelected && getSelectedStyle(isHovered)}
2180
+ ${({ disabled }) => getDisabledStyle(disabled)}
2181
+ `;
2182
+ var Container4 = styled6__default.default.button`
2323
2183
  display: flex;
2324
2184
  align-items: center;
2325
2185
  justify-content: center;
2326
- width: 24px;
2327
- height: 24px;
2186
+ background: transparent;
2328
2187
  padding: 4px;
2188
+ width: fit-content;
2189
+ height: fit-content;
2329
2190
  `;
2330
- var IconButton2 = styled6__default.default.button`
2191
+ exports.RADIO_SYMBOL_KEY = Symbol("SHOPLFLOW_RADIO");
2192
+ var Radio = (_a) => {
2193
+ var _b = _a, { isSelected, defaultSelected, disabled, onClick, onMouseEnter, onMouseLeave } = _b, rest = __objRest(_b, ["isSelected", "defaultSelected", "disabled", "onClick", "onMouseEnter", "onMouseLeave"]);
2194
+ const [selected, toggleSelected] = useOnToggle(isSelected, defaultSelected);
2195
+ const [isHovered, toggleHovered] = React3.useState(false);
2196
+ const handleMouseLeave = (e) => {
2197
+ toggleHovered(false);
2198
+ onMouseLeave && onMouseLeave(e);
2199
+ };
2200
+ const handleMouseEnter = (e) => {
2201
+ toggleHovered(true);
2202
+ onMouseEnter && onMouseEnter(e);
2203
+ };
2204
+ const handleClick = (e) => {
2205
+ if (disabled) {
2206
+ return;
2207
+ }
2208
+ onClick && onClick(e);
2209
+ toggleSelected();
2210
+ };
2211
+ return /* @__PURE__ */ jsxRuntime.jsx(
2212
+ Container4,
2213
+ __spreadProps(__spreadValues({
2214
+ onClick: handleClick,
2215
+ onMouseEnter: handleMouseEnter,
2216
+ onMouseLeave: handleMouseLeave
2217
+ }, rest), {
2218
+ "data-shoplflow": "Radio",
2219
+ children: /* @__PURE__ */ jsxRuntime.jsx(StyledRadio, { isSelected: selected, isHovered, disabled, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "8", cy: "8", r: "5.5", fill: "white", stroke: "#3299FE", strokeWidth: "5" }) }) })
2220
+ })
2221
+ );
2222
+ };
2223
+ Radio[exports.RADIO_SYMBOL_KEY] = true;
2224
+ exports.Radio = Radio;
2225
+
2226
+ // src/components/Menu/Menu.styled.ts
2227
+ var getStylesBySizeVar = (sizeVar) => {
2228
+ switch (sizeVar) {
2229
+ case "XS":
2230
+ return react$1.css`
2231
+ min-height: 28px;
2232
+ `;
2233
+ case "S":
2234
+ return react$1.css`
2235
+ min-height: 36px;
2236
+ `;
2237
+ case "M":
2238
+ return react$1.css`
2239
+ height: 48px;
2240
+ `;
2241
+ default:
2242
+ return react$1.css`
2243
+ height: 48px;
2244
+ `;
2245
+ }
2246
+ };
2247
+ var getFontStylesBySizeVar = (sizeVar) => {
2248
+ switch (sizeVar) {
2249
+ case "XS":
2250
+ return "body2_400";
2251
+ case "S":
2252
+ return "body1_400";
2253
+ case "M":
2254
+ return "body1_400";
2255
+ default:
2256
+ return "body1_400";
2257
+ }
2258
+ };
2259
+ var StyledMenu = styled6__default.default.li`
2331
2260
  display: flex;
2332
- width: 16px;
2333
- height: 16px;
2334
- flex-direction: column;
2335
- justify-content: center;
2261
+ width: 100%;
2262
+ flex-direction: row;
2336
2263
  align-items: center;
2337
- border-radius: ${exports.borderRadiusTokens.borderRadius04};
2338
- border: none;
2339
- background: ${({ color }) => exports.colorTokens[color]};
2264
+ padding: 6px;
2265
+ gap: 4px;
2266
+ border-radius: 4px;
2340
2267
  cursor: pointer;
2341
- transition:
2342
- transform 0.1s ease-out,
2343
- background 0.1s ease;
2344
-
2268
+ background: transparent;
2269
+ ${({ sizeVar }) => getStylesBySizeVar(sizeVar)};
2345
2270
  &:hover {
2346
- background: ${({ color }) => exports.colorTokens[getNextColor(color, 1)]};
2271
+ background: ${exports.colorTokens.neutral400_5};
2347
2272
  }
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`
2273
+ ${({ disabled }) => disabled && getDisabledStyle(disabled)}
2274
+ ${({ isSelected, leftSource }) => isSelected === true && (!leftSource || leftSource && !leftSource.type[exports.RADIO_SYMBOL_KEY] && !leftSource.type[exports.CHECKBOX_SYMBOL_KEY] && !leftSource.type[MUNUS_BUTTON_SYMBOL_KEY]) && react$1.css`
2275
+ background: ${exports.colorTokens.neutral200};
2276
+ &:hover {
2390
2277
  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
- }
2278
+ }
2279
+ `}
2280
+ `;
2281
+ var Menu = (_a) => {
2282
+ var _b = _a, {
2283
+ leftSource,
2284
+ rightSource,
2285
+ children,
2286
+ isSelected,
2287
+ defaultSelected = false,
2288
+ onClick,
2289
+ sizeVar = "XS",
2290
+ disabled = false
2291
+ } = _b, rest = __objRest(_b, [
2292
+ "leftSource",
2293
+ "rightSource",
2294
+ "children",
2295
+ "isSelected",
2296
+ "defaultSelected",
2297
+ "onClick",
2298
+ "sizeVar",
2299
+ "disabled"
2300
+ ]);
2301
+ const [selected, handleToggle] = useOnToggle(isSelected, defaultSelected);
2302
+ const LeftSourceClone = leftSource ? React3__namespace.default.cloneElement(leftSource, __spreadProps(__spreadValues({}, rest), {
2303
+ isSelected
2304
+ })) : leftSource;
2305
+ const handleOnClick = (e) => {
2306
+ !disabled && handleToggle();
2307
+ !disabled && onClick && onClick(e);
2308
+ };
2309
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2310
+ StyledMenu,
2311
+ __spreadProps(__spreadValues({
2312
+ sizeVar,
2313
+ isSelected: selected,
2314
+ leftSource,
2315
+ onClick: handleOnClick
2316
+ }, rest), {
2317
+ "data-shoplflow": "Menu",
2318
+ children: [
2319
+ leftSource && LeftSourceClone,
2320
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Stack.Horizontal, { width: "100%", height: "100%", align: "center", className: getFontStylesBySizeVar(sizeVar), children }),
2321
+ rightSource && rightSource
2322
+ ]
2323
+ })
2324
+ );
2325
+ };
2326
+ exports.Menu = Menu;
2327
+
2328
+ // src/components/Menu/Menu.types.ts
2329
+ exports.MenuSizeVariants = {
2330
+ XS: "XS",
2331
+ S: "S",
2332
+ M: "M"
2333
+ };
2334
+ exports.DropdownButtonContext = React3.createContext(null);
2335
+ exports.useDropdownButtonContext = () => {
2336
+ const context = React3.useContext(exports.DropdownButtonContext);
2337
+ if (!context) {
2338
+ throw new Error("DropdownButtonContext must be used within a DropdownButton component");
2339
+ }
2340
+ return context;
2341
+ };
2342
+
2343
+ // src/components/Icon/Icon.types.ts
2344
+ exports.IconSizeVariants = {
2345
+ XS: "XS",
2346
+ S: "S",
2347
+ M: "M",
2348
+ L: "L",
2349
+ XL: "XL"
2350
+ };
2351
+
2352
+ // src/components/Icon/Icon.styled.ts
2353
+ var getIconSize = (size2) => {
2354
+ switch (size2) {
2355
+ case exports.IconSizeVariants.XS:
2356
+ return "12px";
2357
+ case exports.IconSizeVariants.S:
2358
+ return "20px";
2359
+ case exports.IconSizeVariants.M:
2360
+ return "24px";
2361
+ case exports.IconSizeVariants.L:
2362
+ return "30px";
2363
+ case exports.IconSizeVariants.XL:
2364
+ return "36px";
2365
+ default:
2366
+ return "fit-content";
2367
+ }
2368
+ };
2369
+ exports.StyledIcon = styled6__default.default.svg`
2370
+ width: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2371
+ min-width: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2372
+ height: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2373
+ min-height: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2374
+ & > path {
2375
+ fill: ${({ color }) => color && exports.colorTokens[color]};
2376
+ }
2377
+ `;
2378
+ var Icon = React3.forwardRef((_a, ref) => {
2379
+ var _b = _a, { iconSource } = _b, rest = __objRest(_b, ["iconSource"]);
2380
+ return /* @__PURE__ */ jsxRuntime.jsx(exports.StyledIcon, __spreadProps(__spreadValues({ as: iconSource, ref }, rest), { "data-shoplflow": "Icon" }));
2381
+ });
2382
+ exports.Icon = Icon;
2383
+ var DropdownButtonMenu = (_a) => {
2384
+ var _b = _a, { onClick, children } = _b, rest = __objRest(_b, ["onClick", "children"]);
2385
+ const { setIsOpen } = exports.useDropdownButtonContext();
2386
+ return /* @__PURE__ */ jsxRuntime.jsx(
2387
+ exports.Menu,
2388
+ __spreadProps(__spreadValues({
2389
+ onClick: (event) => {
2390
+ event.stopPropagation();
2391
+ event.preventDefault();
2392
+ onClick == null ? void 0 : onClick(event);
2393
+ setIsOpen(false);
2394
+ }
2395
+ }, rest), {
2396
+ children
2397
+ })
2398
+ );
2399
+ };
2400
+ var DropdownButton = (_a) => {
2401
+ var _b = _a, {
2402
+ text,
2403
+ sizeVar,
2404
+ className,
2405
+ disabled,
2406
+ children,
2407
+ placement = "bottom-end",
2408
+ styleVar = "PRIMARY",
2409
+ floatingZIndex
2410
+ } = _b, rest = __objRest(_b, [
2411
+ "text",
2412
+ "sizeVar",
2413
+ "className",
2414
+ "disabled",
2415
+ "children",
2416
+ "placement",
2417
+ "styleVar",
2418
+ "floatingZIndex"
2419
+ ]);
2420
+ const selector = React3.useRef(`shoplflow-${crypto.randomUUID()}-dropdown-button`).current;
2421
+ const [isOpen, setIsOpen] = utils.useOutsideClick({
2422
+ selector: `.${selector}`,
2423
+ useOutsideScroll: true
2424
+ });
2425
+ let _className = `${selector}`;
2426
+ if (className) {
2427
+ _className += ` ${className}`;
2428
+ }
2429
+ let _styleVar = styleVar;
2430
+ let color = void 0;
2431
+ if (styleVar === "PRIMARY") {
2432
+ _styleVar = "SOLID";
2433
+ color = "coolgray50";
2434
+ }
2435
+ return /* @__PURE__ */ jsxRuntime.jsx(exports.DropdownButtonContext.Provider, { value: { isOpen, setIsOpen }, "data-shoplflow": "DropdownButton", children: /* @__PURE__ */ jsxRuntime.jsxs(exports.Popper, { placement, offset: 4, middlewares: [core.shift({ crossAxis: true, padding: 4 })], children: [
2436
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Popper.Trigger, { isOpen, className: _className, children: /* @__PURE__ */ jsxRuntime.jsx(
2437
+ exports.Button,
2438
+ __spreadProps(__spreadValues({
2439
+ className: _className,
2440
+ sizeVar,
2441
+ styleVar: _styleVar,
2442
+ disabled,
2443
+ color,
2444
+ rightSource: /* @__PURE__ */ jsxRuntime.jsx(
2445
+ StyledArrowIcon,
2446
+ {
2447
+ animate: {
2448
+ rotate: isOpen ? 180 : 0
2449
+ },
2450
+ transition: {
2451
+ duration: 0.2
2452
+ },
2453
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2454
+ exports.Icon,
2455
+ {
2456
+ iconSource: ShoplAssets.DownArrowSolidXsmallIcon,
2457
+ color: styleVar === "PRIMARY" ? "coolgray300" : "neutral400",
2458
+ sizeVar: "XS"
2459
+ }
2460
+ )
2461
+ }
2462
+ ),
2463
+ onClick: () => {
2464
+ if (disabled) {
2465
+ return;
2466
+ }
2467
+ setIsOpen((prev) => !prev);
2468
+ }
2469
+ }, rest), {
2470
+ children: /* @__PURE__ */ jsxRuntime.jsx(exports.Text, { typography: "body2_400", color: "neutral700", children: text })
2471
+ })
2472
+ ) }),
2473
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Popper.Portal, { zIndex: floatingZIndex, children: /* @__PURE__ */ jsxRuntime.jsx(StyledPopoverContentWrapper, { className: _className, children }) })
2474
+ ] }) });
2475
+ };
2476
+ DropdownButton.Menu = DropdownButtonMenu;
2477
+ exports.DropdownButton = DropdownButton;
2478
+
2479
+ // src/components/Buttons/DropdownButton/DropdownButton.types.ts
2480
+ exports.DropdownButtonSizeVariants = {
2481
+ S: "S",
2482
+ M: "M"
2483
+ };
2484
+ exports.DropdownButtonStyleVariants = {
2485
+ PRIMARY: "PRIMARY",
2486
+ SECONDARY: "SECONDARY"
2487
+ };
2488
+ var getStyleByStyleVar3 = (styleVar, color, disabled) => {
2489
+ switch (styleVar) {
2490
+ case "PRIMARY":
2491
+ return react$1.css`
2492
+ border: 1px solid ${exports.colorTokens.primary400};
2493
+ background-color: ${exports.colorTokens.primary300};
2494
+ :hover {
2495
+ background-color: ${!disabled && exports.colorTokens.primary400};
2496
+ }
2497
+ `;
2498
+ case "SECONDARY":
2499
+ return react$1.css`
2500
+ border: 1px solid ${exports.colorTokens.neutral350};
2501
+ background-color: ${exports.colorTokens.neutral0};
2502
+ :hover {
2503
+ background-color: ${!disabled && exports.colorTokens.neutral100};
2504
+ }
2505
+ `;
2506
+ default:
2507
+ return react$1.css`
2508
+ border: 1px solid ${exports.colorTokens.primary400};
2509
+ background-color: ${exports.colorTokens.primary300};
2510
+ `;
2511
+ }
2512
+ };
2513
+ var getStyleBySizeVar3 = (sizeVar) => {
2514
+ switch (sizeVar) {
2515
+ case "M":
2516
+ return react$1.css`
2517
+ min-width: 72px;
2518
+ min-height: 40px;
2519
+ `;
2520
+ case "S":
2521
+ return react$1.css`
2522
+ min-width: 54px;
2523
+ min-height: 32px;
2524
+ `;
2525
+ default:
2526
+ return react$1.css`
2527
+ min-width: 72px;
2528
+ min-height: 40px;
2529
+ `;
2530
+ }
2531
+ };
2532
+ var StyledPopoverContentWrapper2 = styled6__default.default.div`
2533
+ ${getPopoverContentStyle()}
2534
+ `;
2535
+ var StyledArrowIcon2 = styled6__default.default(framerMotion.motion.div)`
2536
+ display: flex;
2537
+ justify-content: center;
2538
+ align-items: center;
2539
+ flex-shrink: 0;
2540
+ `;
2541
+ var SplitButtonDivider = styled6__default.default.div`
2542
+ height: ${({ sizeVar }) => sizeVar === "M" ? "38px" : "30px"};
2543
+ width: 1px;
2544
+ background-color: ${({ styleVar }) => styleVar === "PRIMARY" ? exports.colorTokens.shopl400 : exports.colorTokens.neutral350};
2545
+ `;
2546
+ var StyledSplitButton = styled6__default.default.button`
2547
+ display: flex;
2548
+ align-items: center;
2549
+ justify-content: center;
2550
+ height: fit-content;
2551
+ width: fit-content;
2552
+ gap: 8px;
2553
+ padding: 0 12px;
2554
+ border-radius: 6px;
2555
+ cursor: pointer;
2556
+ ${({ styleVar, color, disabled }) => getStyleByStyleVar3(styleVar, color, disabled)};
2557
+ ${({ sizeVar }) => getStyleBySizeVar3(sizeVar)};
2558
+ ${({ disabled }) => getDisabledStyle(disabled)}
2559
+ `;
2560
+ exports.SplitButtonContext = React3.createContext(null);
2561
+ exports.useSplitButtonContext = () => {
2562
+ const context = React3.useContext(exports.SplitButtonContext);
2563
+ if (!context) {
2564
+ throw new Error("SplitButtonContext must be used within a SplitButton component");
2565
+ }
2566
+ return context;
2567
+ };
2568
+ var SplitButtonMenu = (_a) => {
2569
+ var _b = _a, { onClick, children } = _b, rest = __objRest(_b, ["onClick", "children"]);
2570
+ const { setIsOpen } = exports.useSplitButtonContext();
2571
+ return /* @__PURE__ */ jsxRuntime.jsx(
2572
+ exports.Menu,
2573
+ __spreadProps(__spreadValues({
2574
+ onClick: (event) => {
2575
+ event.stopPropagation();
2576
+ event.preventDefault();
2577
+ onClick == null ? void 0 : onClick(event);
2578
+ setIsOpen(false);
2579
+ }
2580
+ }, rest), {
2581
+ children
2582
+ })
2583
+ );
2584
+ };
2585
+ var SplitButton = (_a) => {
2586
+ var _b = _a, {
2587
+ children,
2588
+ color,
2589
+ onClick,
2590
+ disabled,
2591
+ placement = "bottom-start",
2592
+ floatingZIndex,
2593
+ leftSource,
2594
+ rightSource,
2595
+ styleVar = "PRIMARY",
2596
+ sizeVar = "M",
2597
+ lineClamp = 1,
2598
+ text
2599
+ } = _b, rest = __objRest(_b, [
2600
+ "children",
2601
+ "color",
2602
+ "onClick",
2603
+ "disabled",
2604
+ "placement",
2605
+ "floatingZIndex",
2606
+ "leftSource",
2607
+ "rightSource",
2608
+ "styleVar",
2609
+ "sizeVar",
2610
+ "lineClamp",
2611
+ "text"
2612
+ ]);
2613
+ const selector = React3.useRef(`shoplflow-${crypto.randomUUID()}-split-button`).current;
2614
+ const [isOpen, setIsOpen] = utils.useOutsideClick({
2615
+ selector: `.${selector}`,
2616
+ useOutsideScroll: true
2617
+ });
2618
+ return /* @__PURE__ */ jsxRuntime.jsx(exports.SplitButtonContext.Provider, { value: { isOpen, setIsOpen }, children: /* @__PURE__ */ jsxRuntime.jsxs(exports.Popper, { placement, offset: 4, middlewares: [core.shift({ crossAxis: true, padding: 4 })], children: [
2619
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Popper.Trigger, { isOpen, className: selector, children: /* @__PURE__ */ jsxRuntime.jsxs(
2620
+ StyledSplitButton,
2621
+ __spreadProps(__spreadValues({
2622
+ "data-shoplflow": "SplitButton",
2623
+ color,
2624
+ styleVar,
2625
+ sizeVar,
2626
+ disabled
2627
+ }, rest), {
2628
+ onClick: (event) => {
2629
+ event.stopPropagation();
2630
+ event.preventDefault();
2631
+ if (disabled) {
2632
+ return;
2633
+ }
2634
+ onClick == null ? void 0 : onClick(event);
2635
+ setIsOpen((prev) => !prev);
2636
+ },
2637
+ children: [
2638
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.Stack.Horizontal, { spacing: "spacing04", align: "center", children: [
2639
+ leftSource,
2640
+ /* @__PURE__ */ jsxRuntime.jsx(
2641
+ exports.Text,
2642
+ {
2643
+ lineClamp,
2644
+ whiteSpace: "nowrap",
2645
+ wordBreak: "keep-all",
2646
+ color: styleVar === "PRIMARY" ? "neutral0" : "neutral700",
2647
+ typography: sizeVar === "M" ? "body1_400" : "body2_400",
2648
+ children: text
2649
+ }
2650
+ ),
2651
+ rightSource
2652
+ ] }),
2653
+ /* @__PURE__ */ jsxRuntime.jsx(SplitButtonDivider, { sizeVar, styleVar }),
2654
+ /* @__PURE__ */ jsxRuntime.jsx(
2655
+ StyledArrowIcon2,
2656
+ {
2657
+ animate: {
2658
+ rotate: isOpen ? 180 : 0
2659
+ },
2660
+ transition: {
2661
+ duration: 0.2
2662
+ },
2663
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2664
+ exports.Icon,
2665
+ {
2666
+ iconSource: ShoplAssets.DownArrowSolidXsmallIcon,
2667
+ color: styleVar === "PRIMARY" ? "neutral0" : "neutral600",
2668
+ sizeVar: "XS"
2669
+ }
2670
+ )
2671
+ }
2672
+ )
2673
+ ]
2674
+ })
2675
+ ) }),
2676
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Popper.Portal, { zIndex: floatingZIndex, children: /* @__PURE__ */ jsxRuntime.jsx(StyledPopoverContentWrapper2, { children }) })
2677
+ ] }) });
2678
+ };
2679
+ SplitButton.Menu = SplitButtonMenu;
2680
+ exports.SplitButton = SplitButton;
2681
+
2682
+ // src/components/Buttons/SplitButton/SplitButton.types.ts
2683
+ exports.SplitButtonSizeVariants = {
2684
+ S: "S",
2685
+ M: "M"
2686
+ };
2687
+ exports.SplitButtonStyleVariants = {
2688
+ PRIMARY: "PRIMARY",
2689
+ SECONDARY: "SECONDARY"
2690
+ };
2691
+ var informationStyle = react$1.css`
2692
+ background: ${exports.colorTokens.neutral100};
2693
+ & > span {
2694
+ color: ${exports.colorTokens.neutral600};
2695
+ }
2696
+ & > svg > path {
2697
+ fill: ${exports.colorTokens.neutral600};
2698
+ }
2699
+ `;
2700
+ var alertStyle = react$1.css`
2701
+ background: ${exports.colorTokens.red100};
2702
+ & > span {
2703
+ align-self: center;
2704
+ color: ${exports.colorTokens.red300};
2705
+ }
2706
+ & > svg > path {
2707
+ fill: ${exports.colorTokens.red300};
2708
+ }
2709
+ `;
2710
+ var StyledCallout = styled6__default.default.div`
2711
+ display: flex;
2712
+ justify-content: flex-start;
2713
+ align-items: start;
2714
+ padding: 6px 8px;
2715
+ gap: 4px;
2716
+ border-radius: ${exports.borderRadiusTokens.borderRadius08};
2717
+ ${({ styleVar }) => styleVar === "INFORMATION" && informationStyle}
2718
+ ${({ styleVar }) => styleVar === "ALERT" && alertStyle}
2719
+ `;
2720
+ var StyledCalloutIcon = styled6__default.default.svg`
2721
+ display: flex;
2722
+ height: 20px;
2723
+ min-height: 20px;
2724
+ width: 20px;
2725
+ min-width: 20px;
2726
+ `;
2727
+ styled6__default.default.div`
2728
+ padding: 2px 0;
2729
+ `;
2730
+ var Callout = (_a) => {
2731
+ var _b = _a, { children, styleVar = "INFORMATION" } = _b, rest = __objRest(_b, ["children", "styleVar"]);
2732
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledCallout, __spreadProps(__spreadValues({}, rest), { styleVar, "data-shoplflow": "Callout", children }));
2733
+ };
2734
+ var CalloutText = (_a) => {
2735
+ var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
2736
+ return /* @__PURE__ */ jsxRuntime.jsx(exports.Text, __spreadProps(__spreadValues({}, rest), { typography: "paragraph2", children }));
2737
+ };
2738
+ var CalloutIcon = ({ iconSource }) => {
2739
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledCalloutIcon, { as: iconSource });
2740
+ };
2741
+ Callout.Text = CalloutText;
2742
+ Callout.Icon = CalloutIcon;
2743
+ exports.Callout = Callout;
2744
+
2745
+ // src/components/Callout/Callout.types.ts
2746
+ exports.CalloutTypes = {
2747
+ INFORMATION: "INFORMATION",
2748
+ ALERT: "ALERT"
2749
+ };
2750
+ var getDropdownHeightBySizeVar = (size2) => {
2751
+ switch (size2) {
2752
+ case "M":
2753
+ return "40px";
2754
+ case "S":
2755
+ return "32px";
2756
+ default:
2757
+ return "40px";
2758
+ }
2759
+ };
2760
+ var getDropdownFontSizeBySizeVar = (size2) => {
2761
+ switch (size2) {
2762
+ case "M":
2763
+ return "body1_400";
2764
+ case "S":
2765
+ return "body2_400";
2766
+ default:
2767
+ return "body1_400";
2768
+ }
2769
+ };
2770
+ var getDropdownStyleBySizeVar = (size2) => {
2771
+ switch (size2) {
2772
+ case "M":
2773
+ return react$1.css`
2774
+ padding: 4px 4px 4px 12px;
2775
+ `;
2776
+ case "S":
2777
+ return react$1.css`
2778
+ padding: 4px 4px 4px 8px;
2779
+ gap: 4px;
2780
+ `;
2781
+ default:
2782
+ return react$1.css`
2783
+ padding: 4px 4px 4px 12px;
2784
+ `;
2785
+ }
2786
+ };
2787
+ var getDropdownIconSizeBySizeVar = (size2) => {
2788
+ switch (size2) {
2789
+ case "S":
2790
+ return react$1.css`
2791
+ height: 24px;
2792
+ width: 24px;
2793
+ min-width: 24px;
2794
+ min-height: 24px;
2401
2795
  `;
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
- `;
2418
- }
2796
+ case "M":
2419
2797
  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
- `}
2798
+ height: 32px;
2799
+ width: 32px;
2800
+ min-width: 32px;
2801
+ min-height: 32px;
2432
2802
  `;
2433
2803
  default:
2434
- return "";
2804
+ return react$1.css`
2805
+ height: 32px;
2806
+ width: 32px;
2807
+ min-width: 32px;
2808
+ min-height: 32px;
2809
+ `;
2435
2810
  }
2436
2811
  };
2437
- var StyledCheckHiddenInput = styled6__default.default.input`
2438
- position: absolute;
2439
- width: 0;
2440
- height: 0;
2441
- opacity: 0;
2442
- visibility: hidden;
2812
+ var StyledDropdown = styled6__default.default.div`
2813
+ width: ${({ width }) => width};
2443
2814
  `;
2444
- var StyledCheckbox = styled6__default.default.label`
2815
+ var StyledDropdownContent = styled6__default.default.div`
2816
+ display: flex;
2817
+ flex-direction: column;
2818
+ background: ${exports.colorTokens.neutral0};
2819
+ width: ${({ width }) => width != null ? width : "240px"};
2820
+ padding: 4px;
2821
+ border-radius: 6px;
2822
+ box-shadow: ${exports.boxShadowTokens.dropShadow};
2823
+ `;
2824
+ var StyledDropdownButton = styled6__default.default.button`
2445
2825
  display: flex;
2826
+ flex-direction: row;
2446
2827
  align-items: center;
2447
- justify-content: center;
2448
- min-width: 16px;
2449
- min-height: 16px;
2450
- width: 16px;
2451
- height: 16px;
2452
- background: ${exports.colorTokens.neutral200};
2453
- border-radius: 4px;
2454
- box-sizing: border-box;
2828
+ justify-content: space-between;
2829
+ width: 100%;
2830
+ height: 100%;
2831
+ gap: 8px;
2455
2832
  cursor: pointer;
2456
- ${({ styleVar, isSelected, isHovered }) => getStylesByStyleVariant(styleVar, isSelected, isHovered)};
2457
- ${({ disabled }) => getDisabledStyle(disabled)}
2833
+ background-color: ${exports.colorTokens.neutral0};
2834
+ ${({ sizeVar }) => sizeVar && getDropdownStyleBySizeVar(sizeVar)};
2835
+ ${({ disabled }) => disabled && react$1.css`
2836
+ background-color: ${exports.colorTokens.neutral100};
2837
+ cursor: not-allowed;
2838
+ `}
2458
2839
  `;
2459
- var Container3 = styled6__default.default.button`
2840
+ var DropdownButtonIcon = styled6__default.default(framerMotion.motion.div)`
2460
2841
  display: flex;
2461
2842
  align-items: center;
2462
2843
  justify-content: center;
2463
- padding: 4px;
2464
- width: fit-content;
2465
- height: fit-content;
2466
- background-color: transparent;
2844
+
2845
+ ${({ sizeVar }) => sizeVar && getDropdownIconSizeBySizeVar(sizeVar)};
2467
2846
  `;
2468
- exports.CHECKBOX_SYMBOL_KEY = Symbol("SHOPLFLOW_CHECKBOX");
2469
- var Checkbox = React3.forwardRef(
2847
+ var DropdownContext = React3.createContext(null);
2848
+ var useDropdown = () => {
2849
+ const context = React3.useContext(DropdownContext);
2850
+ if (context === null) {
2851
+ throw new Error("useDropdown must be used within a DropdownProvider");
2852
+ }
2853
+ return context;
2854
+ };
2855
+ var getBorderColorByStatus = ({ isFocused, isError, isHovered, disabled }) => {
2856
+ if (!disabled) {
2857
+ if (isError) {
2858
+ return exports.colorTokens.red300;
2859
+ }
2860
+ if (isFocused) {
2861
+ return exports.colorTokens.primary300;
2862
+ }
2863
+ if (isHovered) {
2864
+ return exports.colorTokens.neutral700;
2865
+ }
2866
+ }
2867
+ return exports.colorTokens.neutral300;
2868
+ };
2869
+ var getStyleByType = ({
2870
+ type,
2871
+ height,
2872
+ minHeight,
2873
+ maxHeight,
2874
+ width,
2875
+ minWidth,
2876
+ maxWidth,
2877
+ borderRadius,
2878
+ customNumberInputHeight
2879
+ }) => {
2880
+ if (type === "number") {
2881
+ return react$1.css`
2882
+ width: ${width || "64px"};
2883
+ height: ${customNumberInputHeight || "32px"};
2884
+ border-radius: ${borderRadius ? exports.borderRadiusTokens[borderRadius] : "6px"};
2885
+ `;
2886
+ }
2887
+ return react$1.css`
2888
+ width: ${width || "100%"};
2889
+ min-width: ${minWidth || "initial"};
2890
+ max-width: ${maxWidth || "initial"};
2891
+ height: ${height || "initial"};
2892
+ min-height: ${minHeight || "initial"};
2893
+ max-height: ${maxHeight || "initial"};
2894
+ border-radius: ${borderRadius ? exports.borderRadiusTokens[borderRadius] : "6px"};
2895
+ `;
2896
+ };
2897
+ var InputWrapper = styled6__default.default.label`
2898
+ position: relative;
2899
+ display: flex;
2900
+ align-items: center;
2901
+ border-radius: 6px;
2902
+ flex-direction: ${({ direction }) => direction || "row"};
2903
+ ${({ type, height, minHeight, maxHeight, width, maxWidth, minWidth, borderRadius, customNumberInputHeight }) => getStyleByType({
2904
+ customNumberInputHeight,
2905
+ type,
2906
+ height,
2907
+ minHeight,
2908
+ maxHeight,
2909
+ width,
2910
+ maxWidth,
2911
+ minWidth,
2912
+ borderRadius
2913
+ })};
2914
+ justify-content: space-between;
2915
+ gap: ${({ gap }) => gap || "8px"};
2916
+ border: 1px solid ${(props) => getBorderColorByStatus(props)};
2917
+ background-color: ${exports.colorTokens.neutral0};
2918
+ overflow: hidden;
2919
+ ${({ disabled }) => disabled && react$1.css`
2920
+ background-color: ${exports.colorTokens.neutral100};
2921
+ cursor: not-allowed;
2922
+ `};
2923
+ `;
2924
+ var DropdownTriggerButton = React3.forwardRef(
2470
2925
  (_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);
2926
+ 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"]);
2927
+ const { isOpen, setIsOpen } = useDropdown();
2928
+ const [isHovered, setIsHovered] = React3.useState(false);
2929
+ const handleOnClick = (e) => {
2930
+ if (!disabled) {
2931
+ onClick && onClick(e);
2932
+ setIsOpen(!isOpen);
2933
+ }
2477
2934
  };
2478
- const handleMouseEnter = (e) => {
2479
- toggleHovered(true);
2480
- onMouseEnter && onMouseEnter(e);
2935
+ const handleOnMouseEnter = () => {
2936
+ setIsHovered(true);
2481
2937
  };
2482
- const handleClick = (e) => {
2483
- if (disabled) {
2484
- return;
2938
+ const handleOnMouseLeave = () => {
2939
+ setIsHovered(false);
2940
+ };
2941
+ const getTextColor = ({ value: value2, disabled: disabled2 }) => {
2942
+ if (disabled2) {
2943
+ return "neutral350";
2485
2944
  }
2486
- onClick && onClick(e);
2487
- toggleSelected();
2945
+ if (!value2) {
2946
+ return "neutral400";
2947
+ }
2948
+ return "neutral700";
2488
2949
  };
2489
- return /* @__PURE__ */ jsxRuntime.jsxs(
2490
- Container3,
2950
+ return /* @__PURE__ */ jsxRuntime.jsx(
2951
+ InputWrapper,
2491
2952
  {
2492
- onClick: handleClick,
2493
- onMouseLeave: handleMouseLeave,
2494
- onMouseEnter: handleMouseEnter,
2953
+ onMouseEnter: handleOnMouseEnter,
2954
+ onMouseLeave: handleOnMouseLeave,
2955
+ isFocused: isOpen,
2956
+ isHovered,
2495
2957
  disabled,
2496
- type: "button",
2497
- "data-shoplflow": "Checkbox",
2498
- children: [
2499
- /* @__PURE__ */ jsxRuntime.jsx(StyledCheckHiddenInput, __spreadProps(__spreadValues({ type: "checkbox", disabled, id }, rest), { ref })),
2958
+ width,
2959
+ isError,
2960
+ height: getDropdownHeightBySizeVar(sizeVar),
2961
+ children: /* @__PURE__ */ jsxRuntime.jsxs(StyledDropdownButton, __spreadProps(__spreadValues({ ref, onClick: handleOnClick, disabled }, rest), { sizeVar, children: [
2962
+ leftSource && leftSource,
2963
+ value || /* @__PURE__ */ jsxRuntime.jsx(
2964
+ exports.Text,
2965
+ {
2966
+ typography: getDropdownFontSizeBySizeVar(sizeVar),
2967
+ color: getTextColor({ value, disabled }),
2968
+ textOverflow: "ellipsis",
2969
+ lineClamp: 1,
2970
+ children: placeholder
2971
+ }
2972
+ ),
2500
2973
  /* @__PURE__ */ jsxRuntime.jsx(
2501
- StyledCheckbox,
2974
+ DropdownButtonIcon,
2502
2975
  {
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
- ) })
2976
+ sizeVar,
2977
+ animate: {
2978
+ rotate: isOpen ? 180 : 0
2979
+ },
2980
+ transition: {
2981
+ duration: 0.2
2982
+ },
2983
+ children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: ShoplAssets.DownArrowSolidXsmallIcon, color: "neutral400", sizeVar: "XS" })
2517
2984
  }
2518
2985
  )
2519
- ]
2986
+ ] }))
2520
2987
  }
2521
2988
  );
2522
2989
  }
2523
2990
  );
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};
2991
+ var DropdownContent = (_a) => {
2992
+ var _b = _a, { children, width: initialWidth, type, onClick } = _b, rest = __objRest(_b, ["children", "width", "type", "onClick"]);
2993
+ const { width, setIsOpen, option } = useDropdown();
2994
+ const isFillType = type === "FILL";
2995
+ const contentWidth = isFillType ? `${width}px` : initialWidth;
2996
+ const returnCallbackByOption = () => {
2997
+ if (option === "OUTSIDE_CLICK") {
2998
+ return () => setIsOpen(false);
2536
2999
  }
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};
3000
+ if (option === "CLICK") {
3001
+ return () => setIsOpen(false);
2555
3002
  }
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;
2571
- padding: 4px;
2572
- width: fit-content;
2573
- height: fit-content;
2574
- `;
2575
- exports.RADIO_SYMBOL_KEY = Symbol("SHOPLFLOW_RADIO");
2576
- var Radio = (_a) => {
2577
- var _b = _a, { isSelected, defaultSelected, disabled, onClick, onMouseEnter, onMouseLeave } = _b, rest = __objRest(_b, ["isSelected", "defaultSelected", "disabled", "onClick", "onMouseEnter", "onMouseLeave"]);
2578
- const [selected, toggleSelected] = useOnToggle(isSelected, defaultSelected);
2579
- const [isHovered, toggleHovered] = React3.useState(false);
2580
- const handleMouseLeave = (e) => {
2581
- toggleHovered(false);
2582
- onMouseLeave && onMouseLeave(e);
2583
- };
2584
- const handleMouseEnter = (e) => {
2585
- toggleHovered(true);
2586
- onMouseEnter && onMouseEnter(e);
3003
+ return utils.noop;
2587
3004
  };
2588
3005
  const handleClick = (e) => {
2589
- if (disabled) {
2590
- return;
2591
- }
2592
3006
  onClick && onClick(e);
2593
- toggleSelected();
3007
+ if (option === "CLICK") {
3008
+ setIsOpen(false);
3009
+ }
2594
3010
  };
2595
- return /* @__PURE__ */ jsxRuntime.jsx(
2596
- Container4,
2597
- __spreadProps(__spreadValues({
2598
- onClick: handleClick,
2599
- onMouseEnter: handleMouseEnter,
2600
- onMouseLeave: handleMouseLeave
2601
- }, rest), {
2602
- "data-shoplflow": "Radio",
2603
- children: /* @__PURE__ */ jsxRuntime.jsx(StyledRadio, { isSelected: selected, isHovered, disabled, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "8", cy: "8", r: "5.5", fill: "white", stroke: "#3299FE", strokeWidth: "5" }) }) })
2604
- })
2605
- );
2606
- };
2607
- Radio[exports.RADIO_SYMBOL_KEY] = true;
2608
- exports.Radio = Radio;
2609
-
2610
- // src/components/Menu/Menu.styled.ts
2611
- var getStylesBySizeVar = (sizeVar) => {
2612
- switch (sizeVar) {
2613
- case "XS":
2614
- return react$1.css`
2615
- min-height: 28px;
2616
- `;
2617
- case "S":
2618
- return react$1.css`
2619
- min-height: 36px;
2620
- `;
2621
- case "M":
2622
- return react$1.css`
2623
- height: 48px;
2624
- `;
2625
- default:
2626
- return react$1.css`
2627
- height: 48px;
2628
- `;
2629
- }
2630
- };
2631
- var getFontStylesBySizeVar = (sizeVar) => {
2632
- switch (sizeVar) {
2633
- case "XS":
2634
- return "body2_400";
2635
- case "S":
2636
- return "body1_400";
2637
- case "M":
2638
- return "body1_400";
2639
- default:
2640
- return "body1_400";
2641
- }
3011
+ return /* @__PURE__ */ jsxRuntime.jsx(utils.OutSideClick, { outsideClick: returnCallbackByOption(), children: /* @__PURE__ */ jsxRuntime.jsx(StyledDropdownContent, __spreadProps(__spreadValues({ width: contentWidth, onClick: handleClick }, rest), { children })) });
2642
3012
  };
2643
- var StyledMenu = styled6__default.default.li`
2644
- display: flex;
2645
- width: 100%;
2646
- flex-direction: row;
2647
- align-items: center;
2648
- padding: 6px;
2649
- gap: 4px;
2650
- border-radius: 4px;
2651
- cursor: pointer;
2652
- background: transparent;
2653
- ${({ sizeVar }) => getStylesBySizeVar(sizeVar)};
2654
- &:hover {
2655
- background: ${exports.colorTokens.neutral400_5};
2656
- }
2657
- ${({ disabled }) => disabled && getDisabledStyle(disabled)}
2658
- ${({ isSelected, leftSource }) => isSelected === true && (!leftSource || leftSource && !leftSource.type[exports.RADIO_SYMBOL_KEY] && !leftSource.type[exports.CHECKBOX_SYMBOL_KEY] && !leftSource.type[MUNUS_BUTTON_SYMBOL_KEY]) && react$1.css`
2659
- background: ${exports.colorTokens.neutral200};
2660
- &:hover {
2661
- background: ${exports.colorTokens.neutral200};
2662
- }
2663
- `}
2664
- `;
2665
- var Menu = (_a) => {
2666
- var _b = _a, {
2667
- leftSource,
2668
- rightSource,
2669
- children,
2670
- isSelected,
2671
- defaultSelected = false,
2672
- onClick,
2673
- sizeVar = "XS",
2674
- disabled = false
2675
- } = _b, rest = __objRest(_b, [
2676
- "leftSource",
2677
- "rightSource",
2678
- "children",
2679
- "isSelected",
2680
- "defaultSelected",
2681
- "onClick",
2682
- "sizeVar",
2683
- "disabled"
2684
- ]);
2685
- const [selected, handleToggle] = useOnToggle(isSelected, defaultSelected);
2686
- const LeftSourceClone = leftSource ? React3__namespace.default.cloneElement(leftSource, __spreadProps(__spreadValues({}, rest), {
2687
- isSelected
2688
- })) : leftSource;
2689
- const handleOnClick = (e) => {
2690
- !disabled && handleToggle();
2691
- !disabled && onClick && onClick(e);
2692
- };
2693
- return /* @__PURE__ */ jsxRuntime.jsxs(
2694
- StyledMenu,
2695
- __spreadProps(__spreadValues({
2696
- sizeVar,
2697
- isSelected: selected,
2698
- leftSource,
2699
- onClick: handleOnClick
2700
- }, rest), {
2701
- "data-shoplflow": "Menu",
3013
+ var Dropdown = ({
3014
+ isOpen: initialIsOpen = false,
3015
+ trigger,
3016
+ popper,
3017
+ option = "CLICK",
3018
+ width = "100%"
3019
+ }) => {
3020
+ const [triggerRef, setTriggerRef] = React3.useState(null);
3021
+ const [size2, setSize] = React3.useState({ width: 0, height: 0 });
3022
+ const [isOpen, setIsOpen] = React3.useState(false);
3023
+ React3.useEffect(() => {
3024
+ if (triggerRef) {
3025
+ setSize({
3026
+ width: triggerRef.offsetWidth,
3027
+ height: triggerRef.offsetHeight
3028
+ });
3029
+ }
3030
+ }, [triggerRef]);
3031
+ React3.useEffect(() => {
3032
+ if (initialIsOpen === void 0) {
3033
+ return;
3034
+ }
3035
+ setIsOpen(initialIsOpen);
3036
+ }, [initialIsOpen]);
3037
+ 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(
3038
+ exports.Popper,
3039
+ {
3040
+ offset: 4,
3041
+ autoPlacement: {
3042
+ allowedPlacements: ["bottom-start", "top-start"]
3043
+ },
2702
3044
  children: [
2703
- leftSource && LeftSourceClone,
2704
- /* @__PURE__ */ jsxRuntime.jsx(exports.Stack.Horizontal, { width: "100%", height: "100%", align: "center", className: getFontStylesBySizeVar(sizeVar), children }),
2705
- rightSource && rightSource
3045
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Popper.Trigger, { ref: setTriggerRef, isOpen, width, children: trigger }),
3046
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Popper.Portal, { children: popper })
2706
3047
  ]
2707
- })
2708
- );
2709
- };
2710
- exports.Menu = Menu;
2711
-
2712
- // src/components/Menu/Menu.types.ts
2713
- exports.MenuSizeVariants = {
2714
- XS: "XS",
2715
- S: "S",
2716
- M: "M"
3048
+ }
3049
+ ) }) });
2717
3050
  };
3051
+ Dropdown.Button = DropdownTriggerButton;
3052
+ Dropdown.Content = DropdownContent;
3053
+ exports.Dropdown = Dropdown;
2718
3054
  var StyledList = styled6__default.default.li`
2719
3055
  display: flex;
2720
3056
  flex-direction: row;
@@ -3712,22 +4048,32 @@ var Tooltip = (_a) => {
3712
4048
  }
3713
4049
  onOpenChange == null ? void 0 : onOpenChange(false);
3714
4050
  }, [open, onOpenChange]);
3715
- return /* @__PURE__ */ jsxRuntime.jsxs(exports.Popper, __spreadProps(__spreadValues({ offset: offset4, placement, middlewares: [core.flip(), core.shift({ padding: 5 })] }, popperProps), { children: [
3716
- /* @__PURE__ */ jsxRuntime.jsx(
3717
- exports.Popper.Trigger,
3718
- {
3719
- ref: triggerRef,
3720
- isOpen: isOpen || open,
3721
- onMouseOver: showHandler,
3722
- onMouseLeave: hideHandler,
3723
- onFocus: showHandler,
3724
- onBlur: hideHandler,
3725
- style: { display: "flex", alignItems: "center", justifyContent: "center" },
3726
- children: trigger
3727
- }
3728
- ),
3729
- /* @__PURE__ */ jsxRuntime.jsx(exports.Popper.Portal, { ref: portalRef, children: popper })
3730
- ] }));
4051
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4052
+ exports.Popper,
4053
+ __spreadProps(__spreadValues({
4054
+ offset: offset4,
4055
+ placement,
4056
+ middlewares: [core.flip(), core.shift({ padding: 5 })],
4057
+ "data-shoplflow": "Tooltip"
4058
+ }, popperProps), {
4059
+ children: [
4060
+ /* @__PURE__ */ jsxRuntime.jsx(
4061
+ exports.Popper.Trigger,
4062
+ {
4063
+ ref: triggerRef,
4064
+ isOpen: isOpen || open,
4065
+ onMouseOver: showHandler,
4066
+ onMouseLeave: hideHandler,
4067
+ onFocus: showHandler,
4068
+ onBlur: hideHandler,
4069
+ style: { display: "flex", alignItems: "center", justifyContent: "center" },
4070
+ children: trigger
4071
+ }
4072
+ ),
4073
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Popper.Portal, { ref: portalRef, children: popper })
4074
+ ]
4075
+ })
4076
+ );
3731
4077
  };
3732
4078
  Tooltip.Content = TooltipContent;
3733
4079
  exports.Tooltip = Tooltip;