@shoplflow/base 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +367 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +57 -1
- package/dist/index.d.ts +57 -1
- package/dist/index.js +368 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -858,10 +858,10 @@ var useOnToggle = (selected, defaultSelected) => {
|
|
|
858
858
|
}
|
|
859
859
|
}, [isControlled, selected]);
|
|
860
860
|
React3.useEffect(() => {
|
|
861
|
-
if (defaultSelected) {
|
|
861
|
+
if (defaultSelected !== void 0) {
|
|
862
862
|
setIsToggle(defaultSelected);
|
|
863
863
|
}
|
|
864
|
-
}, [defaultSelected
|
|
864
|
+
}, [defaultSelected]);
|
|
865
865
|
return [isToggle, handleToggle];
|
|
866
866
|
};
|
|
867
867
|
var Switch = (_a) => {
|
|
@@ -1834,6 +1834,101 @@ var Dropdown = ({
|
|
|
1834
1834
|
Dropdown.Button = DropdownButton;
|
|
1835
1835
|
Dropdown.Content = DropdownContent;
|
|
1836
1836
|
exports.Dropdown = Dropdown;
|
|
1837
|
+
exports.StyledMenu = styled5__default.default.li`
|
|
1838
|
+
display: flex;
|
|
1839
|
+
flex-direction: row;
|
|
1840
|
+
padding: 6px;
|
|
1841
|
+
width: 100%;
|
|
1842
|
+
align-items: center;
|
|
1843
|
+
gap: 4px;
|
|
1844
|
+
cursor: pointer;
|
|
1845
|
+
border-radius: 4px;
|
|
1846
|
+
background: ${exports.colorTokens.neutral0};
|
|
1847
|
+
&:hover {
|
|
1848
|
+
background: ${exports.colorTokens.neutral100};
|
|
1849
|
+
}
|
|
1850
|
+
${({ disabled }) => disabled && getDisabledStyle(disabled)}
|
|
1851
|
+
${({ isSelected, leftSource }) => isSelected && !leftSource && react$1.css`
|
|
1852
|
+
background: ${exports.colorTokens.neutral200};
|
|
1853
|
+
&:hover {
|
|
1854
|
+
background: ${exports.colorTokens.neutral200};
|
|
1855
|
+
}
|
|
1856
|
+
`}
|
|
1857
|
+
`;
|
|
1858
|
+
var Menu = (_a) => {
|
|
1859
|
+
var _b = _a, {
|
|
1860
|
+
leftSource,
|
|
1861
|
+
rightSource,
|
|
1862
|
+
children,
|
|
1863
|
+
isSelected,
|
|
1864
|
+
defaultSelected = false,
|
|
1865
|
+
onClick,
|
|
1866
|
+
disabled = false
|
|
1867
|
+
} = _b, rest = __objRest(_b, [
|
|
1868
|
+
"leftSource",
|
|
1869
|
+
"rightSource",
|
|
1870
|
+
"children",
|
|
1871
|
+
"isSelected",
|
|
1872
|
+
"defaultSelected",
|
|
1873
|
+
"onClick",
|
|
1874
|
+
"disabled"
|
|
1875
|
+
]);
|
|
1876
|
+
const [selected, handleToggle] = useOnToggle(isSelected, defaultSelected);
|
|
1877
|
+
const LeftSourceClone = leftSource ? React3__namespace.default.cloneElement(leftSource, __spreadProps(__spreadValues({}, rest), {
|
|
1878
|
+
isSelected
|
|
1879
|
+
})) : leftSource;
|
|
1880
|
+
const handleOnClick = (e) => {
|
|
1881
|
+
!disabled && handleToggle();
|
|
1882
|
+
!disabled && onClick && onClick(e);
|
|
1883
|
+
};
|
|
1884
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(exports.StyledMenu, __spreadProps(__spreadValues({ isSelected: selected, leftSource, onClick: handleOnClick }, rest), { "data-shoplflow": "Menu", children: [
|
|
1885
|
+
leftSource && LeftSourceClone,
|
|
1886
|
+
/* @__PURE__ */ jsxRuntime.jsx(exports.Stack.Horizontal, { width: "100%", align: "center", className: "body1_400", children }),
|
|
1887
|
+
rightSource && rightSource
|
|
1888
|
+
] }));
|
|
1889
|
+
};
|
|
1890
|
+
exports.Menu = Menu;
|
|
1891
|
+
exports.StyledList = styled5__default.default.div`
|
|
1892
|
+
display: flex;
|
|
1893
|
+
flex-direction: row;
|
|
1894
|
+
width: 100%;
|
|
1895
|
+
align-items: center;
|
|
1896
|
+
padding: 6px 8px;
|
|
1897
|
+
gap: 4px;
|
|
1898
|
+
border-radius: 8px;
|
|
1899
|
+
background: ${exports.colorTokens.neutral0};
|
|
1900
|
+
cursor: pointer;
|
|
1901
|
+
${({ disabled }) => disabled && getDisabledStyle(disabled)}
|
|
1902
|
+
&:hover {
|
|
1903
|
+
background: ${exports.colorTokens.neutral100};
|
|
1904
|
+
}
|
|
1905
|
+
`;
|
|
1906
|
+
exports.StyledText2Rows = styled5__default.default.div`
|
|
1907
|
+
display: flex;
|
|
1908
|
+
flex-direction: column;
|
|
1909
|
+
justify-content: center;
|
|
1910
|
+
gap: 2px;
|
|
1911
|
+
`;
|
|
1912
|
+
var List = (_a) => {
|
|
1913
|
+
var _b = _a, { children, leftSource, rightSource } = _b, rest = __objRest(_b, ["children", "leftSource", "rightSource"]);
|
|
1914
|
+
const LeftSourceClone = leftSource ? React3__namespace.default.cloneElement(leftSource, __spreadValues({}, rest)) : leftSource;
|
|
1915
|
+
if (!children && rightSource) {
|
|
1916
|
+
throw new Error("RightSource\uB294 children\uC774 \uD544\uC218\uB85C \uD3EC\uD568\uB418\uC5B4\uC57C\uD569\uB2C8\uB2E4.");
|
|
1917
|
+
}
|
|
1918
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(exports.StyledList, __spreadProps(__spreadValues({ "data-shoplflow": "List" }, rest), { children: [
|
|
1919
|
+
LeftSourceClone && LeftSourceClone,
|
|
1920
|
+
/* @__PURE__ */ jsxRuntime.jsx(exports.Stack.Horizontal, { height: "36px", width: "100%", spacing: "spacing08", align: "center", children }),
|
|
1921
|
+
rightSource && rightSource
|
|
1922
|
+
] }));
|
|
1923
|
+
};
|
|
1924
|
+
var Text2Rows = ({ title, subTitle }) => {
|
|
1925
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(exports.StyledText2Rows, { children: [
|
|
1926
|
+
/* @__PURE__ */ jsxRuntime.jsx(exports.Text, { typography: "body1_500", color: "neutral700", children: title }),
|
|
1927
|
+
subTitle && /* @__PURE__ */ jsxRuntime.jsx(exports.Text, { typography: "body2_400", color: "neutral400", children: subTitle })
|
|
1928
|
+
] });
|
|
1929
|
+
};
|
|
1930
|
+
List.Text2Rows = Text2Rows;
|
|
1931
|
+
exports.List = List;
|
|
1837
1932
|
var StyledInput = styled5__default.default.input`
|
|
1838
1933
|
padding: 4px 0 4px 12px;
|
|
1839
1934
|
background-color: transparent;
|
|
@@ -1843,6 +1938,17 @@ var StyledInput = styled5__default.default.input`
|
|
|
1843
1938
|
&::placeholder {
|
|
1844
1939
|
color: ${exports.colorTokens.neutral350};
|
|
1845
1940
|
}
|
|
1941
|
+
&::-webkit-outer-spin-button,
|
|
1942
|
+
&::-webkit-inner-spin-button {
|
|
1943
|
+
-webkit-appearance: none;
|
|
1944
|
+
margin: 0;
|
|
1945
|
+
}
|
|
1946
|
+
/* Firefox */
|
|
1947
|
+
&[type='number'] {
|
|
1948
|
+
padding: 4px 8px;
|
|
1949
|
+
text-align: center;
|
|
1950
|
+
-moz-appearance: textfield;
|
|
1951
|
+
}
|
|
1846
1952
|
`;
|
|
1847
1953
|
var RightElementWrapper = styled5__default.default.div`
|
|
1848
1954
|
display: flex;
|
|
@@ -1891,6 +1997,8 @@ var Input = React3.forwardRef(
|
|
|
1891
1997
|
disabled,
|
|
1892
1998
|
type: initialType,
|
|
1893
1999
|
maxLength,
|
|
2000
|
+
min,
|
|
2001
|
+
max,
|
|
1894
2002
|
className,
|
|
1895
2003
|
width
|
|
1896
2004
|
} = _b, rest = __objRest(_b, [
|
|
@@ -1904,6 +2012,8 @@ var Input = React3.forwardRef(
|
|
|
1904
2012
|
"disabled",
|
|
1905
2013
|
"type",
|
|
1906
2014
|
"maxLength",
|
|
2015
|
+
"min",
|
|
2016
|
+
"max",
|
|
1907
2017
|
"className",
|
|
1908
2018
|
"width"
|
|
1909
2019
|
]);
|
|
@@ -1929,6 +2039,18 @@ var Input = React3.forwardRef(
|
|
|
1929
2039
|
},
|
|
1930
2040
|
[maxLength]
|
|
1931
2041
|
);
|
|
2042
|
+
const limitRange = React3.useCallback(
|
|
2043
|
+
(value2) => {
|
|
2044
|
+
if (min && Number(value2) < min) {
|
|
2045
|
+
return String(min);
|
|
2046
|
+
}
|
|
2047
|
+
if (max && Number(value2) > max) {
|
|
2048
|
+
return String(max);
|
|
2049
|
+
}
|
|
2050
|
+
return value2;
|
|
2051
|
+
},
|
|
2052
|
+
[max, min]
|
|
2053
|
+
);
|
|
1932
2054
|
const handleOnMouseEnter = () => {
|
|
1933
2055
|
setIsHovered(true);
|
|
1934
2056
|
};
|
|
@@ -1946,8 +2068,20 @@ var Input = React3.forwardRef(
|
|
|
1946
2068
|
const handleOnChange = (event) => {
|
|
1947
2069
|
onChange && onChange(event);
|
|
1948
2070
|
const slicedText = sliceText(event.target.value);
|
|
2071
|
+
if (type === "number") {
|
|
2072
|
+
const limitedText = limitRange(slicedText);
|
|
2073
|
+
setText(limitedText);
|
|
2074
|
+
return;
|
|
2075
|
+
}
|
|
1949
2076
|
setText(slicedText);
|
|
1950
2077
|
};
|
|
2078
|
+
const getWidth = () => {
|
|
2079
|
+
if (type === "number") {
|
|
2080
|
+
return "64px";
|
|
2081
|
+
} else {
|
|
2082
|
+
return width;
|
|
2083
|
+
}
|
|
2084
|
+
};
|
|
1951
2085
|
const handleOnClear = () => {
|
|
1952
2086
|
onClear && onClear();
|
|
1953
2087
|
if (inputRef.current) {
|
|
@@ -1963,16 +2097,18 @@ var Input = React3.forwardRef(
|
|
|
1963
2097
|
}
|
|
1964
2098
|
};
|
|
1965
2099
|
React3.useEffect(() => {
|
|
1966
|
-
if (defaultValue) {
|
|
2100
|
+
if (defaultValue !== void 0) {
|
|
1967
2101
|
const convertString = convertToString(defaultValue);
|
|
1968
2102
|
const slicedText = sliceText(convertString);
|
|
1969
2103
|
setText(slicedText);
|
|
1970
2104
|
}
|
|
1971
2105
|
}, [convertToString, defaultValue, maxLength, sliceText]);
|
|
1972
2106
|
React3.useEffect(() => {
|
|
1973
|
-
|
|
2107
|
+
var _a2;
|
|
2108
|
+
if (value !== void 0) {
|
|
1974
2109
|
const convertString = convertToString(value);
|
|
1975
2110
|
const slicedText = sliceText(convertString);
|
|
2111
|
+
((_a2 = inputRef.current) == null ? void 0 : _a2.value) && (inputRef.current.value = slicedText);
|
|
1976
2112
|
setText(slicedText);
|
|
1977
2113
|
}
|
|
1978
2114
|
}, [convertToString, maxLength, sliceText, value]);
|
|
@@ -1989,7 +2125,7 @@ var Input = React3.forwardRef(
|
|
|
1989
2125
|
isHovered,
|
|
1990
2126
|
onMouseEnter: handleOnMouseEnter,
|
|
1991
2127
|
onMouseLeave: handleOnMouseLeave,
|
|
1992
|
-
width,
|
|
2128
|
+
width: getWidth(),
|
|
1993
2129
|
"data-shoplflow": "input",
|
|
1994
2130
|
children: [
|
|
1995
2131
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2007,7 +2143,7 @@ var Input = React3.forwardRef(
|
|
|
2007
2143
|
className: "body1_400" + (className ? ` ${className}` : "")
|
|
2008
2144
|
}, rest)
|
|
2009
2145
|
),
|
|
2010
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RightElementWrapper, { children: [
|
|
2146
|
+
!(type === "number") && /* @__PURE__ */ jsxRuntime.jsxs(RightElementWrapper, { children: [
|
|
2011
2147
|
maxLength && isFocused && /* @__PURE__ */ jsxRuntime.jsx(TextCounter_default, { currentLength: String(text).length, maxLength }),
|
|
2012
2148
|
isFocused && Boolean(String(text).length > 0) && /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { sizeVar: "S", onClick: handleOnClear, styleVar: "GHOST", children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: assetFunction("DeleteIcon"), color: "neutral600" }) }),
|
|
2013
2149
|
initialType === "password" && /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { sizeVar: "S", onClick: handleTogglePasswordType, styleVar: "GHOST", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2297,6 +2433,231 @@ var MinusButton = React3.forwardRef((_a, ref) => {
|
|
|
2297
2433
|
] }) })) });
|
|
2298
2434
|
});
|
|
2299
2435
|
exports.MinusButton = MinusButton;
|
|
2436
|
+
var getStylesByStyleVariant = (styleVariant, isSelected, isHovered) => {
|
|
2437
|
+
switch (styleVariant) {
|
|
2438
|
+
case "PRIMARY":
|
|
2439
|
+
if (isSelected) {
|
|
2440
|
+
return react$1.css`
|
|
2441
|
+
background: ${exports.colorTokens.primary300};
|
|
2442
|
+
border: 1.5px solid ${exports.colorTokens.primary300};
|
|
2443
|
+
& > svg > path {
|
|
2444
|
+
fill: ${exports.colorTokens.neutral0};
|
|
2445
|
+
}
|
|
2446
|
+
${isHovered && react$1.css`
|
|
2447
|
+
border: 1.5px solid ${exports.colorTokens.primary400};
|
|
2448
|
+
background: ${exports.colorTokens.primary400};
|
|
2449
|
+
`}
|
|
2450
|
+
`;
|
|
2451
|
+
}
|
|
2452
|
+
return react$1.css`
|
|
2453
|
+
background: ${exports.colorTokens.neutral200};
|
|
2454
|
+
border: 1.5px solid ${exports.colorTokens.neutral200};
|
|
2455
|
+
border-radius: 4px;
|
|
2456
|
+
${isHovered && react$1.css`
|
|
2457
|
+
border: 1.5px solid ${exports.colorTokens.neutral300};
|
|
2458
|
+
background: ${exports.colorTokens.neutral300};
|
|
2459
|
+
`}
|
|
2460
|
+
|
|
2461
|
+
& > svg > path {
|
|
2462
|
+
fill: ${exports.colorTokens.neutral0};
|
|
2463
|
+
}
|
|
2464
|
+
`;
|
|
2465
|
+
case "LINE":
|
|
2466
|
+
if (isSelected) {
|
|
2467
|
+
return react$1.css`
|
|
2468
|
+
border: 1.5px solid ${exports.colorTokens.primary300};
|
|
2469
|
+
background: transparent;
|
|
2470
|
+
border-radius: 4px;
|
|
2471
|
+
& > svg > path {
|
|
2472
|
+
fill: ${exports.colorTokens.primary300};
|
|
2473
|
+
}
|
|
2474
|
+
${isHovered && react$1.css`
|
|
2475
|
+
border: 1.5px solid ${exports.colorTokens.primary400};
|
|
2476
|
+
& > svg > path {
|
|
2477
|
+
fill: ${exports.colorTokens.primary400};
|
|
2478
|
+
}
|
|
2479
|
+
`}
|
|
2480
|
+
`;
|
|
2481
|
+
}
|
|
2482
|
+
return react$1.css`
|
|
2483
|
+
background: transparent;
|
|
2484
|
+
border: 1.5px solid ${exports.colorTokens.neutral200};
|
|
2485
|
+
border-radius: 4px;
|
|
2486
|
+
& > svg > path {
|
|
2487
|
+
fill: ${exports.colorTokens.neutral200};
|
|
2488
|
+
}
|
|
2489
|
+
${isHovered && react$1.css`
|
|
2490
|
+
border: 1.5px solid ${exports.colorTokens.neutral300};
|
|
2491
|
+
& > svg > path {
|
|
2492
|
+
fill: ${exports.colorTokens.neutral300};
|
|
2493
|
+
}
|
|
2494
|
+
`}
|
|
2495
|
+
`;
|
|
2496
|
+
default:
|
|
2497
|
+
return "";
|
|
2498
|
+
}
|
|
2499
|
+
};
|
|
2500
|
+
var StyledCheckbox = styled5__default.default.button`
|
|
2501
|
+
display: flex;
|
|
2502
|
+
align-items: center;
|
|
2503
|
+
justify-content: center;
|
|
2504
|
+
min-width: 16px;
|
|
2505
|
+
min-height: 16px;
|
|
2506
|
+
width: 16px;
|
|
2507
|
+
height: 16px;
|
|
2508
|
+
background: ${exports.colorTokens.neutral200};
|
|
2509
|
+
border-radius: 4px;
|
|
2510
|
+
box-sizing: border-box;
|
|
2511
|
+
cursor: pointer;
|
|
2512
|
+
${({ styleVar, isSelected, isHovered }) => getStylesByStyleVariant(styleVar, isSelected, isHovered)};
|
|
2513
|
+
${({ disabled }) => getDisabledStyle(disabled)}
|
|
2514
|
+
`;
|
|
2515
|
+
var Container3 = styled5__default.default.button`
|
|
2516
|
+
display: flex;
|
|
2517
|
+
align-items: center;
|
|
2518
|
+
justify-content: center;
|
|
2519
|
+
padding: 4px;
|
|
2520
|
+
width: fit-content;
|
|
2521
|
+
height: fit-content;
|
|
2522
|
+
`;
|
|
2523
|
+
var Checkbox = (_a) => {
|
|
2524
|
+
var _b = _a, {
|
|
2525
|
+
defaultSelected,
|
|
2526
|
+
isSelected,
|
|
2527
|
+
disabled,
|
|
2528
|
+
onClick,
|
|
2529
|
+
onMouseEnter,
|
|
2530
|
+
onMouseLeave,
|
|
2531
|
+
styleVar = "PRIMARY"
|
|
2532
|
+
} = _b, rest = __objRest(_b, [
|
|
2533
|
+
"defaultSelected",
|
|
2534
|
+
"isSelected",
|
|
2535
|
+
"disabled",
|
|
2536
|
+
"onClick",
|
|
2537
|
+
"onMouseEnter",
|
|
2538
|
+
"onMouseLeave",
|
|
2539
|
+
"styleVar"
|
|
2540
|
+
]);
|
|
2541
|
+
const [selected, toggleSelected] = useOnToggle(isSelected, defaultSelected);
|
|
2542
|
+
const [isHovered, toggleHovered] = React3.useState(false);
|
|
2543
|
+
const handleMouseLeave = (e) => {
|
|
2544
|
+
toggleHovered(false);
|
|
2545
|
+
onMouseLeave && onMouseLeave(e);
|
|
2546
|
+
};
|
|
2547
|
+
const handleMouseEnter = (e) => {
|
|
2548
|
+
toggleHovered(true);
|
|
2549
|
+
onMouseEnter && onMouseEnter(e);
|
|
2550
|
+
};
|
|
2551
|
+
const handleClick = (e) => {
|
|
2552
|
+
if (disabled) {
|
|
2553
|
+
return;
|
|
2554
|
+
}
|
|
2555
|
+
onClick && onClick(e);
|
|
2556
|
+
toggleSelected();
|
|
2557
|
+
};
|
|
2558
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2559
|
+
Container3,
|
|
2560
|
+
__spreadProps(__spreadValues({
|
|
2561
|
+
onClick: handleClick,
|
|
2562
|
+
onMouseLeave: handleMouseLeave,
|
|
2563
|
+
onMouseEnter: handleMouseEnter,
|
|
2564
|
+
disabled
|
|
2565
|
+
}, rest), {
|
|
2566
|
+
"data-shoplflow": "Checkbox",
|
|
2567
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(StyledCheckbox, { styleVar, isHovered, isSelected: selected, disabled, 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(
|
|
2568
|
+
"path",
|
|
2569
|
+
{
|
|
2570
|
+
fillRule: "evenodd",
|
|
2571
|
+
clipRule: "evenodd",
|
|
2572
|
+
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",
|
|
2573
|
+
fill: "white"
|
|
2574
|
+
}
|
|
2575
|
+
) }) })
|
|
2576
|
+
})
|
|
2577
|
+
);
|
|
2578
|
+
};
|
|
2579
|
+
exports.Checkbox = Checkbox;
|
|
2580
|
+
|
|
2581
|
+
// src/components/ControlButtons/Checkbox/Checkbox.types.ts
|
|
2582
|
+
exports.CheckboxStyleVariants = {
|
|
2583
|
+
PRIMARY: "PRIMARY",
|
|
2584
|
+
LINE: "LINE"
|
|
2585
|
+
};
|
|
2586
|
+
var getSelectedStyle = (isHovered) => {
|
|
2587
|
+
return react$1.css`
|
|
2588
|
+
& > svg > circle {
|
|
2589
|
+
stroke: ${exports.colorTokens.primary300};
|
|
2590
|
+
}
|
|
2591
|
+
${isHovered && react$1.css`
|
|
2592
|
+
& > svg > circle {
|
|
2593
|
+
stroke: ${exports.colorTokens.primary400};
|
|
2594
|
+
}
|
|
2595
|
+
`}
|
|
2596
|
+
`;
|
|
2597
|
+
};
|
|
2598
|
+
var StyledRadio = styled5__default.default.div`
|
|
2599
|
+
display: flex;
|
|
2600
|
+
align-items: center;
|
|
2601
|
+
justify-content: center;
|
|
2602
|
+
min-width: 16px;
|
|
2603
|
+
min-height: 16px;
|
|
2604
|
+
width: 16px;
|
|
2605
|
+
height: 16px;
|
|
2606
|
+
${({ isHovered }) => react$1.css`
|
|
2607
|
+
& > svg > circle {
|
|
2608
|
+
stroke: ${exports.colorTokens.neutral200};
|
|
2609
|
+
}
|
|
2610
|
+
${isHovered && react$1.css`
|
|
2611
|
+
& > svg > circle {
|
|
2612
|
+
stroke: ${exports.colorTokens.neutral300};
|
|
2613
|
+
}
|
|
2614
|
+
`}
|
|
2615
|
+
`}
|
|
2616
|
+
cursor: pointer;
|
|
2617
|
+
${({ isSelected, isHovered }) => isSelected && getSelectedStyle(isHovered)}
|
|
2618
|
+
${({ disabled }) => getDisabledStyle(disabled)}
|
|
2619
|
+
`;
|
|
2620
|
+
var Container4 = styled5__default.default.button`
|
|
2621
|
+
display: flex;
|
|
2622
|
+
align-items: center;
|
|
2623
|
+
justify-content: center;
|
|
2624
|
+
background: transparent;
|
|
2625
|
+
padding: 4px;
|
|
2626
|
+
width: fit-content;
|
|
2627
|
+
height: fit-content;
|
|
2628
|
+
`;
|
|
2629
|
+
var Radio = (_a) => {
|
|
2630
|
+
var _b = _a, { isSelected, defaultSelected, disabled, onClick, onMouseEnter, onMouseLeave } = _b, rest = __objRest(_b, ["isSelected", "defaultSelected", "disabled", "onClick", "onMouseEnter", "onMouseLeave"]);
|
|
2631
|
+
const [selected, toggleSelected] = useOnToggle(isSelected, defaultSelected);
|
|
2632
|
+
const [isHovered, toggleHovered] = React3.useState(false);
|
|
2633
|
+
const handleMouseLeave = (e) => {
|
|
2634
|
+
toggleHovered(false);
|
|
2635
|
+
onMouseLeave && onMouseLeave(e);
|
|
2636
|
+
};
|
|
2637
|
+
const handleMouseEnter = (e) => {
|
|
2638
|
+
toggleHovered(true);
|
|
2639
|
+
onMouseEnter && onMouseEnter(e);
|
|
2640
|
+
};
|
|
2641
|
+
const handleClick = (e) => {
|
|
2642
|
+
if (disabled) {
|
|
2643
|
+
return;
|
|
2644
|
+
}
|
|
2645
|
+
onClick && onClick(e);
|
|
2646
|
+
toggleSelected();
|
|
2647
|
+
};
|
|
2648
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2649
|
+
Container4,
|
|
2650
|
+
__spreadProps(__spreadValues({
|
|
2651
|
+
onClick: handleClick,
|
|
2652
|
+
onMouseEnter: handleMouseEnter,
|
|
2653
|
+
onMouseLeave: handleMouseLeave
|
|
2654
|
+
}, rest), {
|
|
2655
|
+
"data-shoplflow": "Radio",
|
|
2656
|
+
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" }) }) })
|
|
2657
|
+
})
|
|
2658
|
+
);
|
|
2659
|
+
};
|
|
2660
|
+
exports.Radio = Radio;
|
|
2300
2661
|
|
|
2301
2662
|
Object.defineProperty(exports, 'arrow', {
|
|
2302
2663
|
enumerable: true,
|