@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.js CHANGED
@@ -5,7 +5,7 @@ import { motion, AnimatePresence, LayoutGroup, LazyMotion, domAnimation } from '
5
5
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
6
6
  import { createPortal } from 'react-dom';
7
7
  import { css } from '@emotion/react';
8
- import { useMergeRefs, noop, OutSideClick, useSelect, useOutsideClick, useParentElementClick, isNullOrUndefined } from '@shoplflow/utils';
8
+ import { useMergeRefs, noop, useOutsideClick, OutSideClick, useSelect, useParentElementClick, isNullOrUndefined } from '@shoplflow/utils';
9
9
  import Scrollbars from 'react-custom-scrollbars-2';
10
10
  import { FloatingPortal, autoUpdate, offset, autoPlacement } from '@floating-ui/react';
11
11
  export { arrow, flip, hide, inline, offset, shift, size } from '@floating-ui/react';
@@ -1784,65 +1784,19 @@ var IconButtonStyleVariants = {
1784
1784
  SOLID: "SOLID",
1785
1785
  GHOST: "GHOST"
1786
1786
  };
1787
- var informationStyle = css`
1788
- background: ${colorTokens.neutral100};
1789
- & > span {
1790
- color: ${colorTokens.neutral600};
1791
- }
1792
- & > svg > path {
1793
- fill: ${colorTokens.neutral600};
1794
- }
1795
- `;
1796
- var alertStyle = css`
1797
- background: ${colorTokens.red100};
1798
- & > span {
1799
- align-self: center;
1800
- color: ${colorTokens.red300};
1801
- }
1802
- & > svg > path {
1803
- fill: ${colorTokens.red300};
1804
- }
1805
- `;
1806
- var StyledCallout = styled6.div`
1807
- display: flex;
1808
- justify-content: flex-start;
1809
- align-items: start;
1810
- padding: 6px 8px;
1811
- gap: 4px;
1812
- border-radius: ${borderRadiusTokens.borderRadius08};
1813
- ${({ styleVar }) => styleVar === "INFORMATION" && informationStyle}
1814
- ${({ styleVar }) => styleVar === "ALERT" && alertStyle}
1787
+ var StyledPopoverContentWrapper = styled6.div`
1788
+ min-width: 112px;
1789
+ padding: 4px;
1790
+ box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.12);
1791
+ border-radius: 8px;
1792
+ background-color: ${colorTokens.neutral0};
1815
1793
  `;
1816
- var StyledCalloutIcon = styled6.svg`
1794
+ var StyledArrowIcon = styled6(motion.div)`
1817
1795
  display: flex;
1818
- height: 20px;
1819
- min-height: 20px;
1820
- width: 20px;
1821
- min-width: 20px;
1822
- `;
1823
- styled6.div`
1824
- padding: 2px 0;
1796
+ justify-content: center;
1797
+ align-items: center;
1798
+ flex-shrink: 0;
1825
1799
  `;
1826
- var Callout = (_a) => {
1827
- var _b = _a, { children, styleVar = "INFORMATION" } = _b, rest = __objRest(_b, ["children", "styleVar"]);
1828
- return /* @__PURE__ */ jsx(StyledCallout, __spreadProps(__spreadValues({}, rest), { styleVar, "data-shoplflow": "Callout", children }));
1829
- };
1830
- var CalloutText = (_a) => {
1831
- var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
1832
- return /* @__PURE__ */ jsx(Text_default, __spreadProps(__spreadValues({}, rest), { typography: "paragraph2", children }));
1833
- };
1834
- var CalloutIcon = ({ iconSource }) => {
1835
- return /* @__PURE__ */ jsx(StyledCalloutIcon, { as: iconSource });
1836
- };
1837
- Callout.Text = CalloutText;
1838
- Callout.Icon = CalloutIcon;
1839
- var Callout_default = Callout;
1840
-
1841
- // src/components/Callout/Callout.types.ts
1842
- var CalloutTypes = {
1843
- INFORMATION: "INFORMATION",
1844
- ALERT: "ALERT"
1845
- };
1846
1800
  var StyledPopper = styled6.div`
1847
1801
  width: ${({ width }) => width != null ? width : "fit-content"};
1848
1802
  height: ${({ height }) => height && height};
@@ -1947,474 +1901,229 @@ var PopperPortal = forwardRef(
1947
1901
  Popper.Trigger = PopperTrigger;
1948
1902
  Popper.Portal = PopperPortal;
1949
1903
  var Popper_default = Popper;
1950
- var getDropdownHeightBySizeVar = (size2) => {
1951
- switch (size2) {
1952
- case "M":
1953
- return "40px";
1954
- case "S":
1955
- return "32px";
1956
- default:
1957
- return "40px";
1958
- }
1959
- };
1960
- var getDropdownFontSizeBySizeVar = (size2) => {
1961
- switch (size2) {
1962
- case "M":
1963
- return "body1_400";
1964
- case "S":
1965
- return "body2_400";
1966
- default:
1967
- return "body1_400";
1968
- }
1969
- };
1970
- var getDropdownStyleBySizeVar = (size2) => {
1971
- switch (size2) {
1972
- case "M":
1973
- return css`
1974
- padding: 4px 4px 4px 12px;
1975
- `;
1976
- case "S":
1977
- return css`
1978
- padding: 4px 4px 4px 8px;
1979
- gap: 4px;
1980
- `;
1981
- default:
1982
- return css`
1983
- padding: 4px 4px 4px 12px;
1984
- `;
1904
+ var Container2 = styled6.div`
1905
+ display: flex;
1906
+ align-items: center;
1907
+ justify-content: center;
1908
+ width: 24px;
1909
+ height: 24px;
1910
+ padding: 4px;
1911
+ `;
1912
+ var IconButton2 = styled6.button`
1913
+ display: flex;
1914
+ width: 16px;
1915
+ height: 16px;
1916
+ flex-direction: column;
1917
+ justify-content: center;
1918
+ align-items: center;
1919
+ border-radius: ${borderRadiusTokens.borderRadius04};
1920
+ border: none;
1921
+ background: ${({ color }) => colorTokens[color]};
1922
+ cursor: pointer;
1923
+ transition:
1924
+ transform 0.1s ease-out,
1925
+ background 0.1s ease;
1926
+
1927
+ &:hover {
1928
+ background: ${({ color }) => colorTokens[getNextColor(color, 1)]};
1985
1929
  }
1986
- };
1987
- var getDropdownIconSizeBySizeVar = (size2) => {
1988
- switch (size2) {
1989
- case "S":
1930
+ `;
1931
+ var MUNUS_BUTTON_SYMBOL_KEY = Symbol("SHOPLFLOW_MUNUS_BUTTON");
1932
+ var MinusButton = forwardRef((_a, ref) => {
1933
+ var _b = _a, { onClick, color = "neutral300" } = _b, rest = __objRest(_b, ["onClick", "color"]);
1934
+ return /* @__PURE__ */ jsx(Container2, { "data-shoplflow": "minusButton", children: /* @__PURE__ */ jsx(IconButton2, __spreadProps(__spreadValues({ color, onClick, ref }, rest), { children: /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
1935
+ /* @__PURE__ */ jsx(
1936
+ "path",
1937
+ {
1938
+ 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",
1939
+ fill: "none"
1940
+ }
1941
+ ),
1942
+ /* @__PURE__ */ jsx(
1943
+ "path",
1944
+ {
1945
+ fillRule: "evenodd",
1946
+ clipRule: "evenodd",
1947
+ 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",
1948
+ fill: "white"
1949
+ }
1950
+ )
1951
+ ] }) })) });
1952
+ });
1953
+ MinusButton[MUNUS_BUTTON_SYMBOL_KEY] = true;
1954
+ var MinusButton_default = MinusButton;
1955
+ var getStylesByStyleVariant = (styleVariant, isSelected, isHovered) => {
1956
+ switch (styleVariant) {
1957
+ case "PRIMARY":
1958
+ if (isSelected) {
1959
+ return css`
1960
+ background: ${colorTokens.primary300};
1961
+ border: 1.5px solid ${colorTokens.primary300};
1962
+ & > svg > path {
1963
+ fill: ${colorTokens.neutral0};
1964
+ }
1965
+ ${isHovered && css`
1966
+ border: 1.5px solid ${colorTokens.primary400};
1967
+ background: ${colorTokens.primary400};
1968
+ `}
1969
+ `;
1970
+ }
1990
1971
  return css`
1991
- height: 24px;
1992
- width: 24px;
1993
- min-width: 24px;
1994
- min-height: 24px;
1972
+ background: ${colorTokens.neutral200};
1973
+ border: 1.5px solid ${colorTokens.neutral200};
1974
+ border-radius: 4px;
1975
+ ${isHovered && css`
1976
+ border: 1.5px solid ${colorTokens.neutral300};
1977
+ background: ${colorTokens.neutral300};
1978
+ `}
1979
+
1980
+ & > svg > path {
1981
+ fill: ${colorTokens.neutral0};
1982
+ }
1995
1983
  `;
1996
- case "M":
1984
+ case "LINE":
1985
+ if (isSelected) {
1986
+ return css`
1987
+ border: 1.5px solid ${colorTokens.primary300};
1988
+ background: transparent;
1989
+ border-radius: 4px;
1990
+ & > svg > path {
1991
+ fill: ${colorTokens.primary300};
1992
+ }
1993
+ ${isHovered && css`
1994
+ border: 1.5px solid ${colorTokens.primary400};
1995
+ & > svg > path {
1996
+ fill: ${colorTokens.primary400};
1997
+ }
1998
+ `}
1999
+ `;
2000
+ }
1997
2001
  return css`
1998
- height: 32px;
1999
- width: 32px;
2000
- min-width: 32px;
2001
- min-height: 32px;
2002
+ background: transparent;
2003
+ border: 1.5px solid ${colorTokens.neutral200};
2004
+ border-radius: 4px;
2005
+ & > svg > path {
2006
+ fill: ${colorTokens.neutral200};
2007
+ }
2008
+ ${isHovered && css`
2009
+ border: 1.5px solid ${colorTokens.neutral300};
2010
+ & > svg > path {
2011
+ fill: ${colorTokens.neutral300};
2012
+ }
2013
+ `}
2002
2014
  `;
2003
2015
  default:
2004
- return css`
2005
- height: 32px;
2006
- width: 32px;
2007
- min-width: 32px;
2008
- min-height: 32px;
2009
- `;
2016
+ return "";
2010
2017
  }
2011
2018
  };
2012
- var StyledDropdown = styled6.div`
2013
- width: ${({ width }) => width};
2019
+ var StyledCheckHiddenInput = styled6.input`
2020
+ position: absolute;
2021
+ width: 0;
2022
+ height: 0;
2023
+ opacity: 0;
2024
+ visibility: hidden;
2014
2025
  `;
2015
- var StyledDropdownContent = styled6.div`
2026
+ var StyledCheckbox = styled6.label`
2016
2027
  display: flex;
2017
- flex-direction: column;
2018
- background: ${colorTokens.neutral0};
2019
- width: ${({ width }) => width != null ? width : "240px"};
2020
- padding: 4px;
2021
- border-radius: 6px;
2022
- box-shadow: ${boxShadowTokens.dropShadow};
2028
+ align-items: center;
2029
+ justify-content: center;
2030
+ min-width: 16px;
2031
+ min-height: 16px;
2032
+ width: 16px;
2033
+ height: 16px;
2034
+ background: ${colorTokens.neutral200};
2035
+ border-radius: 4px;
2036
+ box-sizing: border-box;
2037
+ cursor: pointer;
2038
+ ${({ styleVar, isSelected, isHovered }) => getStylesByStyleVariant(styleVar, isSelected, isHovered)};
2039
+ ${({ disabled }) => getDisabledStyle(disabled)}
2023
2040
  `;
2024
- var StyledDropdownButton = styled6.button`
2025
- display: flex;
2026
- flex-direction: row;
2027
- align-items: center;
2028
- justify-content: space-between;
2029
- width: 100%;
2030
- height: 100%;
2031
- gap: 8px;
2032
- cursor: pointer;
2033
- background-color: ${colorTokens.neutral0};
2034
- ${({ sizeVar }) => sizeVar && getDropdownStyleBySizeVar(sizeVar)};
2035
- ${({ disabled }) => disabled && css`
2036
- background-color: ${colorTokens.neutral100};
2037
- cursor: not-allowed;
2038
- `}
2039
- `;
2040
- var DropdownButtonIcon = styled6(motion.div)`
2041
+ var Container3 = styled6.button`
2041
2042
  display: flex;
2042
2043
  align-items: center;
2043
2044
  justify-content: center;
2044
-
2045
- ${({ sizeVar }) => sizeVar && getDropdownIconSizeBySizeVar(sizeVar)};
2046
- `;
2047
- var DropdownContext = createContext(null);
2048
- var useDropdown = () => {
2049
- const context = useContext(DropdownContext);
2050
- if (context === null) {
2051
- throw new Error("useDropdown must be used within a DropdownProvider");
2052
- }
2053
- return context;
2054
- };
2055
- var getBorderColorByStatus = ({ isFocused, isError, isHovered, disabled }) => {
2056
- if (!disabled) {
2057
- if (isError) {
2058
- return colorTokens.red300;
2059
- }
2060
- if (isFocused) {
2061
- return colorTokens.primary300;
2062
- }
2063
- if (isHovered) {
2064
- return colorTokens.neutral700;
2065
- }
2066
- }
2067
- return colorTokens.neutral300;
2068
- };
2069
- var getStyleByType = ({
2070
- type,
2071
- height,
2072
- minHeight,
2073
- maxHeight,
2074
- width,
2075
- minWidth,
2076
- maxWidth,
2077
- borderRadius,
2078
- customNumberInputHeight
2079
- }) => {
2080
- if (type === "number") {
2081
- return css`
2082
- width: ${width || "64px"};
2083
- height: ${customNumberInputHeight || "32px"};
2084
- border-radius: ${borderRadius ? borderRadiusTokens[borderRadius] : "6px"};
2085
- `;
2086
- }
2087
- return css`
2088
- width: ${width || "100%"};
2089
- min-width: ${minWidth || "initial"};
2090
- max-width: ${maxWidth || "initial"};
2091
- height: ${height || "initial"};
2092
- min-height: ${minHeight || "initial"};
2093
- max-height: ${maxHeight || "initial"};
2094
- border-radius: ${borderRadius ? borderRadiusTokens[borderRadius] : "6px"};
2095
- `;
2096
- };
2097
- var InputWrapper = styled6.label`
2098
- position: relative;
2099
- display: flex;
2100
- align-items: center;
2101
- border-radius: 6px;
2102
- flex-direction: ${({ direction }) => direction || "row"};
2103
- ${({ type, height, minHeight, maxHeight, width, maxWidth, minWidth, borderRadius, customNumberInputHeight }) => getStyleByType({
2104
- customNumberInputHeight,
2105
- type,
2106
- height,
2107
- minHeight,
2108
- maxHeight,
2109
- width,
2110
- maxWidth,
2111
- minWidth,
2112
- borderRadius
2113
- })};
2114
- justify-content: space-between;
2115
- gap: ${({ gap }) => gap || "8px"};
2116
- border: 1px solid ${(props) => getBorderColorByStatus(props)};
2117
- background-color: ${colorTokens.neutral0};
2118
- overflow: hidden;
2119
- ${({ disabled }) => disabled && css`
2120
- background-color: ${colorTokens.neutral100};
2121
- cursor: not-allowed;
2122
- `};
2123
- `;
2124
-
2125
- // src/components/Icon/Icon.types.ts
2126
- var IconSizeVariants = {
2127
- XS: "XS",
2128
- S: "S",
2129
- M: "M",
2130
- L: "L",
2131
- XL: "XL"
2132
- };
2133
-
2134
- // src/components/Icon/Icon.styled.ts
2135
- var getIconSize = (size2) => {
2136
- switch (size2) {
2137
- case IconSizeVariants.XS:
2138
- return "12px";
2139
- case IconSizeVariants.S:
2140
- return "20px";
2141
- case IconSizeVariants.M:
2142
- return "24px";
2143
- case IconSizeVariants.L:
2144
- return "30px";
2145
- case IconSizeVariants.XL:
2146
- return "36px";
2147
- default:
2148
- return "fit-content";
2149
- }
2150
- };
2151
- var StyledIcon = styled6.svg`
2152
- width: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2153
- min-width: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2154
- height: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2155
- min-height: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2156
- & > path {
2157
- fill: ${({ color }) => color && colorTokens[color]};
2158
- }
2045
+ padding: 4px;
2046
+ width: fit-content;
2047
+ height: fit-content;
2048
+ background-color: transparent;
2159
2049
  `;
2160
- var Icon = forwardRef((_a, ref) => {
2161
- var _b = _a, { iconSource } = _b, rest = __objRest(_b, ["iconSource"]);
2162
- return /* @__PURE__ */ jsx(StyledIcon, __spreadProps(__spreadValues({ as: iconSource, ref }, rest), { "data-shoplflow": "Icon" }));
2163
- });
2164
- var Icon_default = Icon;
2165
- var DropdownButton = forwardRef(
2050
+ var CHECKBOX_SYMBOL_KEY = Symbol("SHOPLFLOW_CHECKBOX");
2051
+ var Checkbox = forwardRef(
2166
2052
  (_a, ref) => {
2167
- 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"]);
2168
- const { isOpen, setIsOpen } = useDropdown();
2169
- const [isHovered, setIsHovered] = useState(false);
2170
- const handleOnClick = (e) => {
2171
- if (!disabled) {
2172
- onClick && onClick(e);
2173
- setIsOpen(!isOpen);
2174
- }
2175
- };
2176
- const handleOnMouseEnter = () => {
2177
- setIsHovered(true);
2053
+ var _b = _a, { defaultSelected, isSelected, disabled, onMouseEnter, onClick, onMouseLeave, styleVar = "PRIMARY", id } = _b, rest = __objRest(_b, ["defaultSelected", "isSelected", "disabled", "onMouseEnter", "onClick", "onMouseLeave", "styleVar", "id"]);
2054
+ const [selected, toggleSelected] = useOnToggle(isSelected, defaultSelected);
2055
+ const [isHovered, toggleHovered] = useState(false);
2056
+ const handleMouseLeave = (e) => {
2057
+ toggleHovered(false);
2058
+ onMouseLeave && onMouseLeave(e);
2178
2059
  };
2179
- const handleOnMouseLeave = () => {
2180
- setIsHovered(false);
2060
+ const handleMouseEnter = (e) => {
2061
+ toggleHovered(true);
2062
+ onMouseEnter && onMouseEnter(e);
2181
2063
  };
2182
- const getTextColor = ({ value: value2, disabled: disabled2 }) => {
2183
- if (disabled2) {
2184
- return "neutral350";
2185
- }
2186
- if (!value2) {
2187
- return "neutral400";
2064
+ const handleClick = (e) => {
2065
+ if (disabled) {
2066
+ return;
2188
2067
  }
2189
- return "neutral700";
2068
+ onClick && onClick(e);
2069
+ toggleSelected();
2190
2070
  };
2191
- return /* @__PURE__ */ jsx(
2192
- InputWrapper,
2071
+ return /* @__PURE__ */ jsxs(
2072
+ Container3,
2193
2073
  {
2194
- onMouseEnter: handleOnMouseEnter,
2195
- onMouseLeave: handleOnMouseLeave,
2196
- isFocused: isOpen,
2197
- isHovered,
2074
+ onClick: handleClick,
2075
+ onMouseLeave: handleMouseLeave,
2076
+ onMouseEnter: handleMouseEnter,
2198
2077
  disabled,
2199
- width,
2200
- isError,
2201
- height: getDropdownHeightBySizeVar(sizeVar),
2202
- children: /* @__PURE__ */ jsxs(StyledDropdownButton, __spreadProps(__spreadValues({ ref, onClick: handleOnClick, disabled }, rest), { sizeVar, children: [
2203
- leftSource && leftSource,
2204
- value || /* @__PURE__ */ jsx(
2205
- Text_default,
2206
- {
2207
- typography: getDropdownFontSizeBySizeVar(sizeVar),
2208
- color: getTextColor({ value, disabled }),
2209
- textOverflow: "ellipsis",
2210
- lineClamp: 1,
2211
- children: placeholder
2212
- }
2213
- ),
2078
+ type: "button",
2079
+ "data-shoplflow": "Checkbox",
2080
+ children: [
2081
+ /* @__PURE__ */ jsx(StyledCheckHiddenInput, __spreadProps(__spreadValues({ type: "checkbox", disabled, id }, rest), { ref })),
2214
2082
  /* @__PURE__ */ jsx(
2215
- DropdownButtonIcon,
2083
+ StyledCheckbox,
2216
2084
  {
2217
- sizeVar,
2218
- animate: {
2219
- rotate: isOpen ? 180 : 0
2220
- },
2221
- transition: {
2222
- duration: 0.2
2223
- },
2224
- children: /* @__PURE__ */ jsx(Icon_default, { iconSource: DownArrowSolidXsmallIcon, color: "neutral400", sizeVar: "XS" })
2085
+ styleVar,
2086
+ htmlFor: id,
2087
+ isHovered,
2088
+ isSelected: selected,
2089
+ disabled,
2090
+ children: /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "8", viewBox: "0 0 12 8", fill: "none", children: /* @__PURE__ */ jsx(
2091
+ "path",
2092
+ {
2093
+ fillRule: "evenodd",
2094
+ clipRule: "evenodd",
2095
+ 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",
2096
+ fill: "white"
2097
+ }
2098
+ ) })
2225
2099
  }
2226
2100
  )
2227
- ] }))
2101
+ ]
2228
2102
  }
2229
2103
  );
2230
2104
  }
2231
2105
  );
2232
- var DropdownContent = (_a) => {
2233
- var _b = _a, { children, width: initialWidth, type, onClick } = _b, rest = __objRest(_b, ["children", "width", "type", "onClick"]);
2234
- const { width, setIsOpen, option } = useDropdown();
2235
- const isFillType = type === "FILL";
2236
- const contentWidth = isFillType ? `${width}px` : initialWidth;
2237
- const returnCallbackByOption = () => {
2238
- if (option === "OUTSIDE_CLICK") {
2239
- return () => setIsOpen(false);
2240
- }
2241
- if (option === "CLICK") {
2242
- return () => setIsOpen(false);
2106
+ Checkbox[CHECKBOX_SYMBOL_KEY] = true;
2107
+ var Checkbox_default = Checkbox;
2108
+
2109
+ // src/components/ControlButtons/Checkbox/Checkbox.types.ts
2110
+ var CheckboxStyleVariants = {
2111
+ PRIMARY: "PRIMARY",
2112
+ LINE: "LINE"
2113
+ };
2114
+ var getSelectedStyle = (isHovered) => {
2115
+ return css`
2116
+ & > svg > circle {
2117
+ stroke: ${colorTokens.primary300};
2243
2118
  }
2244
- return noop;
2245
- };
2246
- const handleClick = (e) => {
2247
- onClick && onClick(e);
2248
- if (option === "CLICK") {
2249
- setIsOpen(false);
2250
- }
2251
- };
2252
- return /* @__PURE__ */ jsx(OutSideClick, { outsideClick: returnCallbackByOption(), children: /* @__PURE__ */ jsx(StyledDropdownContent, __spreadProps(__spreadValues({ width: contentWidth, onClick: handleClick }, rest), { children })) });
2253
- };
2254
- var Dropdown = ({
2255
- isOpen: initialIsOpen = false,
2256
- trigger,
2257
- popper,
2258
- option = "CLICK",
2259
- width = "100%"
2260
- }) => {
2261
- const [triggerRef, setTriggerRef] = useState(null);
2262
- const [size2, setSize] = useState({ width: 0, height: 0 });
2263
- const [isOpen, setIsOpen] = useState(false);
2264
- useEffect(() => {
2265
- if (triggerRef) {
2266
- setSize({
2267
- width: triggerRef.offsetWidth,
2268
- height: triggerRef.offsetHeight
2269
- });
2270
- }
2271
- }, [triggerRef]);
2272
- useEffect(() => {
2273
- if (initialIsOpen === void 0) {
2274
- return;
2275
- }
2276
- setIsOpen(initialIsOpen);
2277
- }, [initialIsOpen]);
2278
- return /* @__PURE__ */ jsx(StyledDropdown, { "data-shoplflow": "Dropdown", width, children: /* @__PURE__ */ jsx(DropdownContext.Provider, { value: __spreadProps(__spreadValues({}, size2), { isOpen, setIsOpen, option }), children: /* @__PURE__ */ jsxs(
2279
- Popper_default,
2280
- {
2281
- offset: 4,
2282
- autoPlacement: {
2283
- allowedPlacements: ["bottom-start", "top-start"]
2284
- },
2285
- children: [
2286
- /* @__PURE__ */ jsx(Popper_default.Trigger, { ref: setTriggerRef, isOpen, width, children: trigger }),
2287
- /* @__PURE__ */ jsx(Popper_default.Portal, { children: popper })
2288
- ]
2289
- }
2290
- ) }) });
2291
- };
2292
- Dropdown.Button = DropdownButton;
2293
- Dropdown.Content = DropdownContent;
2294
- var Dropdown_default = Dropdown;
2295
- var Container2 = styled6.div`
2296
- display: flex;
2297
- align-items: center;
2298
- justify-content: center;
2299
- width: 24px;
2300
- height: 24px;
2301
- padding: 4px;
2302
- `;
2303
- var IconButton2 = styled6.button`
2304
- display: flex;
2305
- width: 16px;
2306
- height: 16px;
2307
- flex-direction: column;
2308
- justify-content: center;
2309
- align-items: center;
2310
- border-radius: ${borderRadiusTokens.borderRadius04};
2311
- border: none;
2312
- background: ${({ color }) => colorTokens[color]};
2313
- cursor: pointer;
2314
- transition:
2315
- transform 0.1s ease-out,
2316
- background 0.1s ease;
2317
-
2318
- &:hover {
2319
- background: ${({ color }) => colorTokens[getNextColor(color, 1)]};
2320
- }
2321
- `;
2322
- var MUNUS_BUTTON_SYMBOL_KEY = Symbol("SHOPLFLOW_MUNUS_BUTTON");
2323
- var MinusButton = forwardRef((_a, ref) => {
2324
- var _b = _a, { onClick, color = "neutral300" } = _b, rest = __objRest(_b, ["onClick", "color"]);
2325
- return /* @__PURE__ */ jsx(Container2, { "data-shoplflow": "minusButton", children: /* @__PURE__ */ jsx(IconButton2, __spreadProps(__spreadValues({ color, onClick, ref }, rest), { children: /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
2326
- /* @__PURE__ */ jsx(
2327
- "path",
2328
- {
2329
- 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",
2330
- fill: "none"
2331
- }
2332
- ),
2333
- /* @__PURE__ */ jsx(
2334
- "path",
2335
- {
2336
- fillRule: "evenodd",
2337
- clipRule: "evenodd",
2338
- 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",
2339
- fill: "white"
2340
- }
2341
- )
2342
- ] }) })) });
2343
- });
2344
- MinusButton[MUNUS_BUTTON_SYMBOL_KEY] = true;
2345
- var MinusButton_default = MinusButton;
2346
- var getStylesByStyleVariant = (styleVariant, isSelected, isHovered) => {
2347
- switch (styleVariant) {
2348
- case "PRIMARY":
2349
- if (isSelected) {
2350
- return css`
2351
- background: ${colorTokens.primary300};
2352
- border: 1.5px solid ${colorTokens.primary300};
2353
- & > svg > path {
2354
- fill: ${colorTokens.neutral0};
2355
- }
2356
- ${isHovered && css`
2357
- border: 1.5px solid ${colorTokens.primary400};
2358
- background: ${colorTokens.primary400};
2359
- `}
2360
- `;
2361
- }
2362
- return css`
2363
- background: ${colorTokens.neutral200};
2364
- border: 1.5px solid ${colorTokens.neutral200};
2365
- border-radius: 4px;
2366
- ${isHovered && css`
2367
- border: 1.5px solid ${colorTokens.neutral300};
2368
- background: ${colorTokens.neutral300};
2369
- `}
2370
-
2371
- & > svg > path {
2372
- fill: ${colorTokens.neutral0};
2373
- }
2374
- `;
2375
- case "LINE":
2376
- if (isSelected) {
2377
- return css`
2378
- border: 1.5px solid ${colorTokens.primary300};
2379
- background: transparent;
2380
- border-radius: 4px;
2381
- & > svg > path {
2382
- fill: ${colorTokens.primary300};
2383
- }
2384
- ${isHovered && css`
2385
- border: 1.5px solid ${colorTokens.primary400};
2386
- & > svg > path {
2387
- fill: ${colorTokens.primary400};
2388
- }
2389
- `}
2390
- `;
2119
+ ${isHovered && css`
2120
+ & > svg > circle {
2121
+ stroke: ${colorTokens.primary400};
2391
2122
  }
2392
- return css`
2393
- background: transparent;
2394
- border: 1.5px solid ${colorTokens.neutral200};
2395
- border-radius: 4px;
2396
- & > svg > path {
2397
- fill: ${colorTokens.neutral200};
2398
- }
2399
- ${isHovered && css`
2400
- border: 1.5px solid ${colorTokens.neutral300};
2401
- & > svg > path {
2402
- fill: ${colorTokens.neutral300};
2403
- }
2404
- `}
2405
- `;
2406
- default:
2407
- return "";
2408
- }
2123
+ `}
2124
+ `;
2409
2125
  };
2410
- var StyledCheckHiddenInput = styled6.input`
2411
- position: absolute;
2412
- width: 0;
2413
- height: 0;
2414
- opacity: 0;
2415
- visibility: hidden;
2416
- `;
2417
- var StyledCheckbox = styled6.label`
2126
+ var StyledRadio = styled6.div`
2418
2127
  display: flex;
2419
2128
  align-items: center;
2420
2129
  justify-content: center;
@@ -2422,125 +2131,25 @@ var StyledCheckbox = styled6.label`
2422
2131
  min-height: 16px;
2423
2132
  width: 16px;
2424
2133
  height: 16px;
2425
- background: ${colorTokens.neutral200};
2426
- border-radius: 4px;
2427
- box-sizing: border-box;
2134
+ ${({ isHovered }) => css`
2135
+ & > svg > circle {
2136
+ stroke: ${colorTokens.neutral200};
2137
+ }
2138
+ ${isHovered && css`
2139
+ & > svg > circle {
2140
+ stroke: ${colorTokens.neutral300};
2141
+ }
2142
+ `}
2143
+ `}
2428
2144
  cursor: pointer;
2429
- ${({ styleVar, isSelected, isHovered }) => getStylesByStyleVariant(styleVar, isSelected, isHovered)};
2145
+ ${({ isSelected, isHovered }) => isSelected && getSelectedStyle(isHovered)}
2430
2146
  ${({ disabled }) => getDisabledStyle(disabled)}
2431
2147
  `;
2432
- var Container3 = styled6.button`
2148
+ var Container4 = styled6.button`
2433
2149
  display: flex;
2434
2150
  align-items: center;
2435
2151
  justify-content: center;
2436
- padding: 4px;
2437
- width: fit-content;
2438
- height: fit-content;
2439
- background-color: transparent;
2440
- `;
2441
- var CHECKBOX_SYMBOL_KEY = Symbol("SHOPLFLOW_CHECKBOX");
2442
- var Checkbox = forwardRef(
2443
- (_a, ref) => {
2444
- var _b = _a, { defaultSelected, isSelected, disabled, onMouseEnter, onClick, onMouseLeave, styleVar = "PRIMARY", id } = _b, rest = __objRest(_b, ["defaultSelected", "isSelected", "disabled", "onMouseEnter", "onClick", "onMouseLeave", "styleVar", "id"]);
2445
- const [selected, toggleSelected] = useOnToggle(isSelected, defaultSelected);
2446
- const [isHovered, toggleHovered] = useState(false);
2447
- const handleMouseLeave = (e) => {
2448
- toggleHovered(false);
2449
- onMouseLeave && onMouseLeave(e);
2450
- };
2451
- const handleMouseEnter = (e) => {
2452
- toggleHovered(true);
2453
- onMouseEnter && onMouseEnter(e);
2454
- };
2455
- const handleClick = (e) => {
2456
- if (disabled) {
2457
- return;
2458
- }
2459
- onClick && onClick(e);
2460
- toggleSelected();
2461
- };
2462
- return /* @__PURE__ */ jsxs(
2463
- Container3,
2464
- {
2465
- onClick: handleClick,
2466
- onMouseLeave: handleMouseLeave,
2467
- onMouseEnter: handleMouseEnter,
2468
- disabled,
2469
- type: "button",
2470
- "data-shoplflow": "Checkbox",
2471
- children: [
2472
- /* @__PURE__ */ jsx(StyledCheckHiddenInput, __spreadProps(__spreadValues({ type: "checkbox", disabled, id }, rest), { ref })),
2473
- /* @__PURE__ */ jsx(
2474
- StyledCheckbox,
2475
- {
2476
- styleVar,
2477
- htmlFor: id,
2478
- isHovered,
2479
- isSelected: selected,
2480
- disabled,
2481
- children: /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "8", viewBox: "0 0 12 8", fill: "none", children: /* @__PURE__ */ jsx(
2482
- "path",
2483
- {
2484
- fillRule: "evenodd",
2485
- clipRule: "evenodd",
2486
- 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",
2487
- fill: "white"
2488
- }
2489
- ) })
2490
- }
2491
- )
2492
- ]
2493
- }
2494
- );
2495
- }
2496
- );
2497
- Checkbox[CHECKBOX_SYMBOL_KEY] = true;
2498
- var Checkbox_default = Checkbox;
2499
-
2500
- // src/components/ControlButtons/Checkbox/Checkbox.types.ts
2501
- var CheckboxStyleVariants = {
2502
- PRIMARY: "PRIMARY",
2503
- LINE: "LINE"
2504
- };
2505
- var getSelectedStyle = (isHovered) => {
2506
- return css`
2507
- & > svg > circle {
2508
- stroke: ${colorTokens.primary300};
2509
- }
2510
- ${isHovered && css`
2511
- & > svg > circle {
2512
- stroke: ${colorTokens.primary400};
2513
- }
2514
- `}
2515
- `;
2516
- };
2517
- var StyledRadio = styled6.div`
2518
- display: flex;
2519
- align-items: center;
2520
- justify-content: center;
2521
- min-width: 16px;
2522
- min-height: 16px;
2523
- width: 16px;
2524
- height: 16px;
2525
- ${({ isHovered }) => css`
2526
- & > svg > circle {
2527
- stroke: ${colorTokens.neutral200};
2528
- }
2529
- ${isHovered && css`
2530
- & > svg > circle {
2531
- stroke: ${colorTokens.neutral300};
2532
- }
2533
- `}
2534
- `}
2535
- cursor: pointer;
2536
- ${({ isSelected, isHovered }) => isSelected && getSelectedStyle(isHovered)}
2537
- ${({ disabled }) => getDisabledStyle(disabled)}
2538
- `;
2539
- var Container4 = styled6.button`
2540
- display: flex;
2541
- align-items: center;
2542
- justify-content: center;
2543
- background: transparent;
2152
+ background: transparent;
2544
2153
  padding: 4px;
2545
2154
  width: fit-content;
2546
2155
  height: fit-content;
@@ -2688,6 +2297,524 @@ var MenuSizeVariants = {
2688
2297
  S: "S",
2689
2298
  M: "M"
2690
2299
  };
2300
+ var DropdownButtonContext = createContext(null);
2301
+ var useDropdownButtonContext = () => {
2302
+ const context = useContext(DropdownButtonContext);
2303
+ if (!context) {
2304
+ throw new Error("DropdownButtonContext must be used within a DropdownButton component");
2305
+ }
2306
+ return context;
2307
+ };
2308
+
2309
+ // src/components/Icon/Icon.types.ts
2310
+ var IconSizeVariants = {
2311
+ XS: "XS",
2312
+ S: "S",
2313
+ M: "M",
2314
+ L: "L",
2315
+ XL: "XL"
2316
+ };
2317
+
2318
+ // src/components/Icon/Icon.styled.ts
2319
+ var getIconSize = (size2) => {
2320
+ switch (size2) {
2321
+ case IconSizeVariants.XS:
2322
+ return "12px";
2323
+ case IconSizeVariants.S:
2324
+ return "20px";
2325
+ case IconSizeVariants.M:
2326
+ return "24px";
2327
+ case IconSizeVariants.L:
2328
+ return "30px";
2329
+ case IconSizeVariants.XL:
2330
+ return "36px";
2331
+ default:
2332
+ return "fit-content";
2333
+ }
2334
+ };
2335
+ var StyledIcon = styled6.svg`
2336
+ width: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2337
+ min-width: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2338
+ height: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2339
+ min-height: ${({ sizeVar }) => sizeVar && getIconSize(sizeVar)};
2340
+ & > path {
2341
+ fill: ${({ color }) => color && colorTokens[color]};
2342
+ }
2343
+ `;
2344
+ var Icon = forwardRef((_a, ref) => {
2345
+ var _b = _a, { iconSource } = _b, rest = __objRest(_b, ["iconSource"]);
2346
+ return /* @__PURE__ */ jsx(StyledIcon, __spreadProps(__spreadValues({ as: iconSource, ref }, rest), { "data-shoplflow": "Icon" }));
2347
+ });
2348
+ var Icon_default = Icon;
2349
+ var DropdownButtonMenu = (_a) => {
2350
+ var _b = _a, { onClick, children } = _b, rest = __objRest(_b, ["onClick", "children"]);
2351
+ const { setIsOpen } = useDropdownButtonContext();
2352
+ return /* @__PURE__ */ jsx(
2353
+ Menu_default,
2354
+ __spreadProps(__spreadValues({
2355
+ onClick: (event) => {
2356
+ event.stopPropagation();
2357
+ event.preventDefault();
2358
+ onClick == null ? void 0 : onClick(event);
2359
+ setIsOpen(false);
2360
+ }
2361
+ }, rest), {
2362
+ children
2363
+ })
2364
+ );
2365
+ };
2366
+ var DropdownButton = (_a) => {
2367
+ var _b = _a, {
2368
+ text,
2369
+ sizeVar,
2370
+ className,
2371
+ disabled,
2372
+ children,
2373
+ placement = "bottom-end",
2374
+ styleVar = "PRIMARY",
2375
+ floatingZIndex
2376
+ } = _b, rest = __objRest(_b, [
2377
+ "text",
2378
+ "sizeVar",
2379
+ "className",
2380
+ "disabled",
2381
+ "children",
2382
+ "placement",
2383
+ "styleVar",
2384
+ "floatingZIndex"
2385
+ ]);
2386
+ const selector = useRef(`shoplflow-${crypto.randomUUID()}-dropdown-button`).current;
2387
+ const [isOpen, setIsOpen] = useOutsideClick({
2388
+ selector: `.${selector}`,
2389
+ useOutsideScroll: true
2390
+ });
2391
+ let _className = `${selector}`;
2392
+ if (className) {
2393
+ _className += ` ${className}`;
2394
+ }
2395
+ let _styleVar = styleVar;
2396
+ let color = void 0;
2397
+ if (styleVar === "PRIMARY") {
2398
+ _styleVar = "SOLID";
2399
+ color = "coolgray50";
2400
+ }
2401
+ return /* @__PURE__ */ jsx(DropdownButtonContext.Provider, { value: { isOpen, setIsOpen }, children: /* @__PURE__ */ jsxs(Popper_default, { placement, offset: 4, children: [
2402
+ /* @__PURE__ */ jsx(Popper_default.Trigger, { isOpen, className: _className, children: /* @__PURE__ */ jsx(
2403
+ Button_default,
2404
+ __spreadProps(__spreadValues({
2405
+ "data-shoplflow": "DropdownButton",
2406
+ className: _className,
2407
+ sizeVar,
2408
+ styleVar: _styleVar,
2409
+ disabled,
2410
+ color,
2411
+ rightSource: /* @__PURE__ */ jsx(
2412
+ StyledArrowIcon,
2413
+ {
2414
+ animate: {
2415
+ rotate: isOpen ? 180 : 0
2416
+ },
2417
+ transition: {
2418
+ duration: 0.2
2419
+ },
2420
+ children: /* @__PURE__ */ jsx(
2421
+ Icon_default,
2422
+ {
2423
+ iconSource: DownArrowSolidXsmallIcon,
2424
+ color: styleVar === "PRIMARY" ? "coolgray300" : "neutral400",
2425
+ sizeVar: "XS"
2426
+ }
2427
+ )
2428
+ }
2429
+ ),
2430
+ onClick: () => {
2431
+ if (disabled) {
2432
+ return;
2433
+ }
2434
+ setIsOpen((prev) => !prev);
2435
+ }
2436
+ }, rest), {
2437
+ children: /* @__PURE__ */ jsx(Text_default, { typography: "body2_400", color: "neutral700", children: text })
2438
+ })
2439
+ ) }),
2440
+ /* @__PURE__ */ jsx(Popper_default.Portal, { zIndex: floatingZIndex, children: /* @__PURE__ */ jsx(StyledPopoverContentWrapper, { className: _className, children }) })
2441
+ ] }) });
2442
+ };
2443
+ DropdownButton.Menu = DropdownButtonMenu;
2444
+ var DropdownButton_default = DropdownButton;
2445
+
2446
+ // src/components/Buttons/DropdownButton/DropdownButton.types.ts
2447
+ var DropdownButtonSizeVariants = {
2448
+ S: "S",
2449
+ M: "M"
2450
+ };
2451
+ var DropdownButtonStyleVariants = {
2452
+ PRIMARY: "PRIMARY",
2453
+ SECONDARY: "SECONDARY"
2454
+ };
2455
+ var informationStyle = css`
2456
+ background: ${colorTokens.neutral100};
2457
+ & > span {
2458
+ color: ${colorTokens.neutral600};
2459
+ }
2460
+ & > svg > path {
2461
+ fill: ${colorTokens.neutral600};
2462
+ }
2463
+ `;
2464
+ var alertStyle = css`
2465
+ background: ${colorTokens.red100};
2466
+ & > span {
2467
+ align-self: center;
2468
+ color: ${colorTokens.red300};
2469
+ }
2470
+ & > svg > path {
2471
+ fill: ${colorTokens.red300};
2472
+ }
2473
+ `;
2474
+ var StyledCallout = styled6.div`
2475
+ display: flex;
2476
+ justify-content: flex-start;
2477
+ align-items: start;
2478
+ padding: 6px 8px;
2479
+ gap: 4px;
2480
+ border-radius: ${borderRadiusTokens.borderRadius08};
2481
+ ${({ styleVar }) => styleVar === "INFORMATION" && informationStyle}
2482
+ ${({ styleVar }) => styleVar === "ALERT" && alertStyle}
2483
+ `;
2484
+ var StyledCalloutIcon = styled6.svg`
2485
+ display: flex;
2486
+ height: 20px;
2487
+ min-height: 20px;
2488
+ width: 20px;
2489
+ min-width: 20px;
2490
+ `;
2491
+ styled6.div`
2492
+ padding: 2px 0;
2493
+ `;
2494
+ var Callout = (_a) => {
2495
+ var _b = _a, { children, styleVar = "INFORMATION" } = _b, rest = __objRest(_b, ["children", "styleVar"]);
2496
+ return /* @__PURE__ */ jsx(StyledCallout, __spreadProps(__spreadValues({}, rest), { styleVar, "data-shoplflow": "Callout", children }));
2497
+ };
2498
+ var CalloutText = (_a) => {
2499
+ var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
2500
+ return /* @__PURE__ */ jsx(Text_default, __spreadProps(__spreadValues({}, rest), { typography: "paragraph2", children }));
2501
+ };
2502
+ var CalloutIcon = ({ iconSource }) => {
2503
+ return /* @__PURE__ */ jsx(StyledCalloutIcon, { as: iconSource });
2504
+ };
2505
+ Callout.Text = CalloutText;
2506
+ Callout.Icon = CalloutIcon;
2507
+ var Callout_default = Callout;
2508
+
2509
+ // src/components/Callout/Callout.types.ts
2510
+ var CalloutTypes = {
2511
+ INFORMATION: "INFORMATION",
2512
+ ALERT: "ALERT"
2513
+ };
2514
+ var getDropdownHeightBySizeVar = (size2) => {
2515
+ switch (size2) {
2516
+ case "M":
2517
+ return "40px";
2518
+ case "S":
2519
+ return "32px";
2520
+ default:
2521
+ return "40px";
2522
+ }
2523
+ };
2524
+ var getDropdownFontSizeBySizeVar = (size2) => {
2525
+ switch (size2) {
2526
+ case "M":
2527
+ return "body1_400";
2528
+ case "S":
2529
+ return "body2_400";
2530
+ default:
2531
+ return "body1_400";
2532
+ }
2533
+ };
2534
+ var getDropdownStyleBySizeVar = (size2) => {
2535
+ switch (size2) {
2536
+ case "M":
2537
+ return css`
2538
+ padding: 4px 4px 4px 12px;
2539
+ `;
2540
+ case "S":
2541
+ return css`
2542
+ padding: 4px 4px 4px 8px;
2543
+ gap: 4px;
2544
+ `;
2545
+ default:
2546
+ return css`
2547
+ padding: 4px 4px 4px 12px;
2548
+ `;
2549
+ }
2550
+ };
2551
+ var getDropdownIconSizeBySizeVar = (size2) => {
2552
+ switch (size2) {
2553
+ case "S":
2554
+ return css`
2555
+ height: 24px;
2556
+ width: 24px;
2557
+ min-width: 24px;
2558
+ min-height: 24px;
2559
+ `;
2560
+ case "M":
2561
+ return css`
2562
+ height: 32px;
2563
+ width: 32px;
2564
+ min-width: 32px;
2565
+ min-height: 32px;
2566
+ `;
2567
+ default:
2568
+ return css`
2569
+ height: 32px;
2570
+ width: 32px;
2571
+ min-width: 32px;
2572
+ min-height: 32px;
2573
+ `;
2574
+ }
2575
+ };
2576
+ var StyledDropdown = styled6.div`
2577
+ width: ${({ width }) => width};
2578
+ `;
2579
+ var StyledDropdownContent = styled6.div`
2580
+ display: flex;
2581
+ flex-direction: column;
2582
+ background: ${colorTokens.neutral0};
2583
+ width: ${({ width }) => width != null ? width : "240px"};
2584
+ padding: 4px;
2585
+ border-radius: 6px;
2586
+ box-shadow: ${boxShadowTokens.dropShadow};
2587
+ `;
2588
+ var StyledDropdownButton = styled6.button`
2589
+ display: flex;
2590
+ flex-direction: row;
2591
+ align-items: center;
2592
+ justify-content: space-between;
2593
+ width: 100%;
2594
+ height: 100%;
2595
+ gap: 8px;
2596
+ cursor: pointer;
2597
+ background-color: ${colorTokens.neutral0};
2598
+ ${({ sizeVar }) => sizeVar && getDropdownStyleBySizeVar(sizeVar)};
2599
+ ${({ disabled }) => disabled && css`
2600
+ background-color: ${colorTokens.neutral100};
2601
+ cursor: not-allowed;
2602
+ `}
2603
+ `;
2604
+ var DropdownButtonIcon = styled6(motion.div)`
2605
+ display: flex;
2606
+ align-items: center;
2607
+ justify-content: center;
2608
+
2609
+ ${({ sizeVar }) => sizeVar && getDropdownIconSizeBySizeVar(sizeVar)};
2610
+ `;
2611
+ var DropdownContext = createContext(null);
2612
+ var useDropdown = () => {
2613
+ const context = useContext(DropdownContext);
2614
+ if (context === null) {
2615
+ throw new Error("useDropdown must be used within a DropdownProvider");
2616
+ }
2617
+ return context;
2618
+ };
2619
+ var getBorderColorByStatus = ({ isFocused, isError, isHovered, disabled }) => {
2620
+ if (!disabled) {
2621
+ if (isError) {
2622
+ return colorTokens.red300;
2623
+ }
2624
+ if (isFocused) {
2625
+ return colorTokens.primary300;
2626
+ }
2627
+ if (isHovered) {
2628
+ return colorTokens.neutral700;
2629
+ }
2630
+ }
2631
+ return colorTokens.neutral300;
2632
+ };
2633
+ var getStyleByType = ({
2634
+ type,
2635
+ height,
2636
+ minHeight,
2637
+ maxHeight,
2638
+ width,
2639
+ minWidth,
2640
+ maxWidth,
2641
+ borderRadius,
2642
+ customNumberInputHeight
2643
+ }) => {
2644
+ if (type === "number") {
2645
+ return css`
2646
+ width: ${width || "64px"};
2647
+ height: ${customNumberInputHeight || "32px"};
2648
+ border-radius: ${borderRadius ? borderRadiusTokens[borderRadius] : "6px"};
2649
+ `;
2650
+ }
2651
+ return css`
2652
+ width: ${width || "100%"};
2653
+ min-width: ${minWidth || "initial"};
2654
+ max-width: ${maxWidth || "initial"};
2655
+ height: ${height || "initial"};
2656
+ min-height: ${minHeight || "initial"};
2657
+ max-height: ${maxHeight || "initial"};
2658
+ border-radius: ${borderRadius ? borderRadiusTokens[borderRadius] : "6px"};
2659
+ `;
2660
+ };
2661
+ var InputWrapper = styled6.label`
2662
+ position: relative;
2663
+ display: flex;
2664
+ align-items: center;
2665
+ border-radius: 6px;
2666
+ flex-direction: ${({ direction }) => direction || "row"};
2667
+ ${({ type, height, minHeight, maxHeight, width, maxWidth, minWidth, borderRadius, customNumberInputHeight }) => getStyleByType({
2668
+ customNumberInputHeight,
2669
+ type,
2670
+ height,
2671
+ minHeight,
2672
+ maxHeight,
2673
+ width,
2674
+ maxWidth,
2675
+ minWidth,
2676
+ borderRadius
2677
+ })};
2678
+ justify-content: space-between;
2679
+ gap: ${({ gap }) => gap || "8px"};
2680
+ border: 1px solid ${(props) => getBorderColorByStatus(props)};
2681
+ background-color: ${colorTokens.neutral0};
2682
+ overflow: hidden;
2683
+ ${({ disabled }) => disabled && css`
2684
+ background-color: ${colorTokens.neutral100};
2685
+ cursor: not-allowed;
2686
+ `};
2687
+ `;
2688
+ var DropdownTriggerButton = forwardRef(
2689
+ (_a, ref) => {
2690
+ 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"]);
2691
+ const { isOpen, setIsOpen } = useDropdown();
2692
+ const [isHovered, setIsHovered] = useState(false);
2693
+ const handleOnClick = (e) => {
2694
+ if (!disabled) {
2695
+ onClick && onClick(e);
2696
+ setIsOpen(!isOpen);
2697
+ }
2698
+ };
2699
+ const handleOnMouseEnter = () => {
2700
+ setIsHovered(true);
2701
+ };
2702
+ const handleOnMouseLeave = () => {
2703
+ setIsHovered(false);
2704
+ };
2705
+ const getTextColor = ({ value: value2, disabled: disabled2 }) => {
2706
+ if (disabled2) {
2707
+ return "neutral350";
2708
+ }
2709
+ if (!value2) {
2710
+ return "neutral400";
2711
+ }
2712
+ return "neutral700";
2713
+ };
2714
+ return /* @__PURE__ */ jsx(
2715
+ InputWrapper,
2716
+ {
2717
+ onMouseEnter: handleOnMouseEnter,
2718
+ onMouseLeave: handleOnMouseLeave,
2719
+ isFocused: isOpen,
2720
+ isHovered,
2721
+ disabled,
2722
+ width,
2723
+ isError,
2724
+ height: getDropdownHeightBySizeVar(sizeVar),
2725
+ children: /* @__PURE__ */ jsxs(StyledDropdownButton, __spreadProps(__spreadValues({ ref, onClick: handleOnClick, disabled }, rest), { sizeVar, children: [
2726
+ leftSource && leftSource,
2727
+ value || /* @__PURE__ */ jsx(
2728
+ Text_default,
2729
+ {
2730
+ typography: getDropdownFontSizeBySizeVar(sizeVar),
2731
+ color: getTextColor({ value, disabled }),
2732
+ textOverflow: "ellipsis",
2733
+ lineClamp: 1,
2734
+ children: placeholder
2735
+ }
2736
+ ),
2737
+ /* @__PURE__ */ jsx(
2738
+ DropdownButtonIcon,
2739
+ {
2740
+ sizeVar,
2741
+ animate: {
2742
+ rotate: isOpen ? 180 : 0
2743
+ },
2744
+ transition: {
2745
+ duration: 0.2
2746
+ },
2747
+ children: /* @__PURE__ */ jsx(Icon_default, { iconSource: DownArrowSolidXsmallIcon, color: "neutral400", sizeVar: "XS" })
2748
+ }
2749
+ )
2750
+ ] }))
2751
+ }
2752
+ );
2753
+ }
2754
+ );
2755
+ var DropdownContent = (_a) => {
2756
+ var _b = _a, { children, width: initialWidth, type, onClick } = _b, rest = __objRest(_b, ["children", "width", "type", "onClick"]);
2757
+ const { width, setIsOpen, option } = useDropdown();
2758
+ const isFillType = type === "FILL";
2759
+ const contentWidth = isFillType ? `${width}px` : initialWidth;
2760
+ const returnCallbackByOption = () => {
2761
+ if (option === "OUTSIDE_CLICK") {
2762
+ return () => setIsOpen(false);
2763
+ }
2764
+ if (option === "CLICK") {
2765
+ return () => setIsOpen(false);
2766
+ }
2767
+ return noop;
2768
+ };
2769
+ const handleClick = (e) => {
2770
+ onClick && onClick(e);
2771
+ if (option === "CLICK") {
2772
+ setIsOpen(false);
2773
+ }
2774
+ };
2775
+ return /* @__PURE__ */ jsx(OutSideClick, { outsideClick: returnCallbackByOption(), children: /* @__PURE__ */ jsx(StyledDropdownContent, __spreadProps(__spreadValues({ width: contentWidth, onClick: handleClick }, rest), { children })) });
2776
+ };
2777
+ var Dropdown = ({
2778
+ isOpen: initialIsOpen = false,
2779
+ trigger,
2780
+ popper,
2781
+ option = "CLICK",
2782
+ width = "100%"
2783
+ }) => {
2784
+ const [triggerRef, setTriggerRef] = useState(null);
2785
+ const [size2, setSize] = useState({ width: 0, height: 0 });
2786
+ const [isOpen, setIsOpen] = useState(false);
2787
+ useEffect(() => {
2788
+ if (triggerRef) {
2789
+ setSize({
2790
+ width: triggerRef.offsetWidth,
2791
+ height: triggerRef.offsetHeight
2792
+ });
2793
+ }
2794
+ }, [triggerRef]);
2795
+ useEffect(() => {
2796
+ if (initialIsOpen === void 0) {
2797
+ return;
2798
+ }
2799
+ setIsOpen(initialIsOpen);
2800
+ }, [initialIsOpen]);
2801
+ return /* @__PURE__ */ jsx(StyledDropdown, { "data-shoplflow": "Dropdown", width, children: /* @__PURE__ */ jsx(DropdownContext.Provider, { value: __spreadProps(__spreadValues({}, size2), { isOpen, setIsOpen, option }), children: /* @__PURE__ */ jsxs(
2802
+ Popper_default,
2803
+ {
2804
+ offset: 4,
2805
+ autoPlacement: {
2806
+ allowedPlacements: ["bottom-start", "top-start"]
2807
+ },
2808
+ children: [
2809
+ /* @__PURE__ */ jsx(Popper_default.Trigger, { ref: setTriggerRef, isOpen, width, children: trigger }),
2810
+ /* @__PURE__ */ jsx(Popper_default.Portal, { children: popper })
2811
+ ]
2812
+ }
2813
+ ) }) });
2814
+ };
2815
+ Dropdown.Button = DropdownTriggerButton;
2816
+ Dropdown.Content = DropdownContent;
2817
+ var Dropdown_default = Dropdown;
2691
2818
  var StyledList = styled6.li`
2692
2819
  display: flex;
2693
2820
  flex-direction: row;
@@ -6014,6 +6141,6 @@ classnames/index.js:
6014
6141
  *)
6015
6142
  */
6016
6143
 
6017
- export { AnnualDatepicker_default as AnnualDatepicker, Avatar_default as Avatar, AvatarSizeVariants, Button_default as Button, ButtonSizeVariants, ButtonStyleVariants, CHECKBOX_SYMBOL_KEY, Callout_default as Callout, CalloutTypes, Checkbox_default as Checkbox, CheckboxStyleVariants, ChipButton_default as ChipButton, ChipButtonSizeVariants, ChipButtonStyleVariants, ChipToggle_default as ChipToggle, ChipToggleSizeVariants, ChipToggleStyleVariants, DayDatepicker_default as DayDatepicker, DayDatepickerSizeVariants, Dropdown_default as Dropdown, Icon_default as Icon, IconButton_default as IconButton, IconButtonSizeVariants, IconButtonStyleVariants, IconSizeVariants, Input_default as Input, InputButton_default as InputButton, InputSizeVariants, List_default as List, MODAL_FOOTER_KEY, MODAL_HEADER_KEY, Menu_default as Menu, MenuSizeVariants, MinusButton_default as MinusButton, Modal, ModalContext, ModalHandlerContext, ModalPortal_default as ModalProvider, ModalSize, MonthDatepicker_default as MonthDatepicker, MotionStack, MotionStackContainer, NumberCombobox_default as NumberCombobox, NumberComboboxSizeVariants, Pagination_default as Pagination, Popper_default as Popper, PopperPortal, PopperTrigger, RADIO_SYMBOL_KEY, Radio_default as Radio, ScrollArea_default as ScrollArea, SelectInputButton_default as SelectInputButton, ShoplflowProvider_default as ShoplflowProvider, Stack_default as Stack, StackContainer_default as StackContainer, StyledIcon, StyledStack, StyledStackContainer, Switch_default as Switch, TREE_SYMBOL_KEY, TabSizeVariants, TabStyleVariants, Tabs_default as Tabs, TabsContext, Tag_default as Tag, TagSizeVariants, TagStyleVariants, Text_default as Text, Text2Rows, TextArea_default as TextArea, ToggleButton_default as ToggleButton, ToggleButtonSizeVariants, Tooltip_default as Tooltip, Tree_default as Tree, TreeItem, WeekDatepicker_default as WeekDatepicker, borderRadiusTokens, boxShadowTokens, colorTokens, fontWeightTokens, getDomain, spacingTokens, typographyTokens, useDomain, useHandleModal, useModalValue, useTabs };
6144
+ export { AnnualDatepicker_default as AnnualDatepicker, Avatar_default as Avatar, AvatarSizeVariants, Button_default as Button, ButtonSizeVariants, ButtonStyleVariants, CHECKBOX_SYMBOL_KEY, Callout_default as Callout, CalloutTypes, Checkbox_default as Checkbox, CheckboxStyleVariants, ChipButton_default as ChipButton, ChipButtonSizeVariants, ChipButtonStyleVariants, ChipToggle_default as ChipToggle, ChipToggleSizeVariants, ChipToggleStyleVariants, DayDatepicker_default as DayDatepicker, DayDatepickerSizeVariants, Dropdown_default as Dropdown, DropdownButton_default as DropdownButton, DropdownButtonContext, DropdownButtonSizeVariants, DropdownButtonStyleVariants, Icon_default as Icon, IconButton_default as IconButton, IconButtonSizeVariants, IconButtonStyleVariants, IconSizeVariants, Input_default as Input, InputButton_default as InputButton, InputSizeVariants, List_default as List, MODAL_FOOTER_KEY, MODAL_HEADER_KEY, Menu_default as Menu, MenuSizeVariants, MinusButton_default as MinusButton, Modal, ModalContext, ModalHandlerContext, ModalPortal_default as ModalProvider, ModalSize, MonthDatepicker_default as MonthDatepicker, MotionStack, MotionStackContainer, NumberCombobox_default as NumberCombobox, NumberComboboxSizeVariants, Pagination_default as Pagination, Popper_default as Popper, PopperPortal, PopperTrigger, RADIO_SYMBOL_KEY, Radio_default as Radio, ScrollArea_default as ScrollArea, SelectInputButton_default as SelectInputButton, ShoplflowProvider_default as ShoplflowProvider, Stack_default as Stack, StackContainer_default as StackContainer, StyledIcon, StyledStack, StyledStackContainer, Switch_default as Switch, TREE_SYMBOL_KEY, TabSizeVariants, TabStyleVariants, Tabs_default as Tabs, TabsContext, Tag_default as Tag, TagSizeVariants, TagStyleVariants, Text_default as Text, Text2Rows, TextArea_default as TextArea, ToggleButton_default as ToggleButton, ToggleButtonSizeVariants, Tooltip_default as Tooltip, Tree_default as Tree, TreeItem, WeekDatepicker_default as WeekDatepicker, borderRadiusTokens, boxShadowTokens, colorTokens, fontWeightTokens, getDomain, spacingTokens, typographyTokens, useDomain, useDropdownButtonContext, useHandleModal, useModalValue, useTabs };
6018
6145
  //# sourceMappingURL=out.js.map
6019
6146
  //# sourceMappingURL=index.js.map