@shoplflow/base 0.16.0 → 0.18.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 +319 -2
- 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 +320 -3
- 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;
|
|
@@ -2297,6 +2392,228 @@ var MinusButton = React3.forwardRef((_a, ref) => {
|
|
|
2297
2392
|
] }) })) });
|
|
2298
2393
|
});
|
|
2299
2394
|
exports.MinusButton = MinusButton;
|
|
2395
|
+
var getStylesByStyleVariant = (styleVariant, isSelected, isHovered) => {
|
|
2396
|
+
switch (styleVariant) {
|
|
2397
|
+
case "PRIMARY":
|
|
2398
|
+
if (isSelected) {
|
|
2399
|
+
return react$1.css`
|
|
2400
|
+
background: ${exports.colorTokens.primary300};
|
|
2401
|
+
border: 1.5px solid ${exports.colorTokens.primary300};
|
|
2402
|
+
& > svg > path {
|
|
2403
|
+
fill: ${exports.colorTokens.neutral0};
|
|
2404
|
+
}
|
|
2405
|
+
${isHovered && react$1.css`
|
|
2406
|
+
background: ${exports.colorTokens.primary400};
|
|
2407
|
+
`}
|
|
2408
|
+
`;
|
|
2409
|
+
}
|
|
2410
|
+
return react$1.css`
|
|
2411
|
+
background: ${exports.colorTokens.neutral200};
|
|
2412
|
+
border: 1.5px solid ${exports.colorTokens.neutral200};
|
|
2413
|
+
border-radius: 4px;
|
|
2414
|
+
${isHovered && react$1.css`
|
|
2415
|
+
background: ${exports.colorTokens.neutral300};
|
|
2416
|
+
`}
|
|
2417
|
+
|
|
2418
|
+
& > svg > path {
|
|
2419
|
+
fill: ${exports.colorTokens.neutral0};
|
|
2420
|
+
}
|
|
2421
|
+
`;
|
|
2422
|
+
case "LINE":
|
|
2423
|
+
if (isSelected) {
|
|
2424
|
+
return react$1.css`
|
|
2425
|
+
border: 1.5px solid ${exports.colorTokens.primary300};
|
|
2426
|
+
background: transparent;
|
|
2427
|
+
border-radius: 4px;
|
|
2428
|
+
& > svg > path {
|
|
2429
|
+
fill: ${exports.colorTokens.primary300};
|
|
2430
|
+
}
|
|
2431
|
+
${isHovered && react$1.css`
|
|
2432
|
+
border: 1.5px solid ${exports.colorTokens.primary400};
|
|
2433
|
+
& > svg > path {
|
|
2434
|
+
fill: ${exports.colorTokens.primary400};
|
|
2435
|
+
}
|
|
2436
|
+
`}
|
|
2437
|
+
`;
|
|
2438
|
+
}
|
|
2439
|
+
return react$1.css`
|
|
2440
|
+
background: transparent;
|
|
2441
|
+
border: 1.5px solid ${exports.colorTokens.neutral200};
|
|
2442
|
+
border-radius: 4px;
|
|
2443
|
+
& > svg > path {
|
|
2444
|
+
fill: ${exports.colorTokens.neutral200};
|
|
2445
|
+
}
|
|
2446
|
+
${isHovered && react$1.css`
|
|
2447
|
+
border: 1.5px solid ${exports.colorTokens.neutral300};
|
|
2448
|
+
& > svg > path {
|
|
2449
|
+
fill: ${exports.colorTokens.neutral300};
|
|
2450
|
+
}
|
|
2451
|
+
`}
|
|
2452
|
+
`;
|
|
2453
|
+
default:
|
|
2454
|
+
return "";
|
|
2455
|
+
}
|
|
2456
|
+
};
|
|
2457
|
+
var StyledCheckbox = styled5__default.default.button`
|
|
2458
|
+
display: flex;
|
|
2459
|
+
align-items: center;
|
|
2460
|
+
justify-content: center;
|
|
2461
|
+
min-width: 16px;
|
|
2462
|
+
min-height: 16px;
|
|
2463
|
+
width: 16px;
|
|
2464
|
+
height: 16px;
|
|
2465
|
+
background: ${exports.colorTokens.neutral200};
|
|
2466
|
+
border-radius: 4px;
|
|
2467
|
+
box-sizing: border-box;
|
|
2468
|
+
cursor: pointer;
|
|
2469
|
+
${({ styleVar, isSelected, isHovered }) => getStylesByStyleVariant(styleVar, isSelected, isHovered)};
|
|
2470
|
+
${({ disabled }) => getDisabledStyle(disabled)}
|
|
2471
|
+
`;
|
|
2472
|
+
var Container3 = styled5__default.default.button`
|
|
2473
|
+
display: flex;
|
|
2474
|
+
align-items: center;
|
|
2475
|
+
justify-content: center;
|
|
2476
|
+
padding: 4px;
|
|
2477
|
+
width: fit-content;
|
|
2478
|
+
height: fit-content;
|
|
2479
|
+
`;
|
|
2480
|
+
var Checkbox = (_a) => {
|
|
2481
|
+
var _b = _a, {
|
|
2482
|
+
defaultSelected,
|
|
2483
|
+
isSelected,
|
|
2484
|
+
disabled,
|
|
2485
|
+
onClick,
|
|
2486
|
+
onMouseEnter,
|
|
2487
|
+
onMouseLeave,
|
|
2488
|
+
styleVar = "PRIMARY"
|
|
2489
|
+
} = _b, rest = __objRest(_b, [
|
|
2490
|
+
"defaultSelected",
|
|
2491
|
+
"isSelected",
|
|
2492
|
+
"disabled",
|
|
2493
|
+
"onClick",
|
|
2494
|
+
"onMouseEnter",
|
|
2495
|
+
"onMouseLeave",
|
|
2496
|
+
"styleVar"
|
|
2497
|
+
]);
|
|
2498
|
+
const [selected, toggleSelected] = useOnToggle(isSelected, defaultSelected);
|
|
2499
|
+
const [isHovered, toggleHovered] = React3.useState(false);
|
|
2500
|
+
const handleMouseLeave = (e) => {
|
|
2501
|
+
toggleHovered(false);
|
|
2502
|
+
onMouseLeave && onMouseLeave(e);
|
|
2503
|
+
};
|
|
2504
|
+
const handleMouseEnter = (e) => {
|
|
2505
|
+
toggleHovered(true);
|
|
2506
|
+
onMouseEnter && onMouseEnter(e);
|
|
2507
|
+
};
|
|
2508
|
+
const handleClick = (e) => {
|
|
2509
|
+
if (disabled) {
|
|
2510
|
+
return;
|
|
2511
|
+
}
|
|
2512
|
+
onClick && onClick(e);
|
|
2513
|
+
toggleSelected();
|
|
2514
|
+
};
|
|
2515
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2516
|
+
Container3,
|
|
2517
|
+
__spreadProps(__spreadValues({
|
|
2518
|
+
onClick: handleClick,
|
|
2519
|
+
onMouseLeave: handleMouseLeave,
|
|
2520
|
+
onMouseEnter: handleMouseEnter,
|
|
2521
|
+
disabled
|
|
2522
|
+
}, rest), {
|
|
2523
|
+
"data-shoplflow": "Checkbox",
|
|
2524
|
+
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(
|
|
2525
|
+
"path",
|
|
2526
|
+
{
|
|
2527
|
+
fillRule: "evenodd",
|
|
2528
|
+
clipRule: "evenodd",
|
|
2529
|
+
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",
|
|
2530
|
+
fill: "white"
|
|
2531
|
+
}
|
|
2532
|
+
) }) })
|
|
2533
|
+
})
|
|
2534
|
+
);
|
|
2535
|
+
};
|
|
2536
|
+
exports.Checkbox = Checkbox;
|
|
2537
|
+
|
|
2538
|
+
// src/components/ControlButtons/Checkbox/Checkbox.types.ts
|
|
2539
|
+
exports.CheckboxStyleVariants = {
|
|
2540
|
+
PRIMARY: "PRIMARY",
|
|
2541
|
+
LINE: "LINE"
|
|
2542
|
+
};
|
|
2543
|
+
var getSelectedStyle = (isHovered) => {
|
|
2544
|
+
return react$1.css`
|
|
2545
|
+
& > svg > circle {
|
|
2546
|
+
stroke: ${exports.colorTokens.primary300};
|
|
2547
|
+
}
|
|
2548
|
+
${isHovered && react$1.css`
|
|
2549
|
+
& > svg > circle {
|
|
2550
|
+
stroke: ${exports.colorTokens.primary400};
|
|
2551
|
+
}
|
|
2552
|
+
`}
|
|
2553
|
+
`;
|
|
2554
|
+
};
|
|
2555
|
+
var StyledRadio = styled5__default.default.div`
|
|
2556
|
+
display: flex;
|
|
2557
|
+
align-items: center;
|
|
2558
|
+
justify-content: center;
|
|
2559
|
+
min-width: 16px;
|
|
2560
|
+
min-height: 16px;
|
|
2561
|
+
width: 16px;
|
|
2562
|
+
height: 16px;
|
|
2563
|
+
${({ isHovered }) => react$1.css`
|
|
2564
|
+
& > svg > circle {
|
|
2565
|
+
stroke: ${exports.colorTokens.neutral200};
|
|
2566
|
+
}
|
|
2567
|
+
${isHovered && react$1.css`
|
|
2568
|
+
& > svg > circle {
|
|
2569
|
+
stroke: ${exports.colorTokens.neutral300};
|
|
2570
|
+
}
|
|
2571
|
+
`}
|
|
2572
|
+
`}
|
|
2573
|
+
cursor: pointer;
|
|
2574
|
+
${({ isSelected, isHovered }) => isSelected && getSelectedStyle(isHovered)}
|
|
2575
|
+
${({ disabled }) => getDisabledStyle(disabled)}
|
|
2576
|
+
`;
|
|
2577
|
+
var Container4 = styled5__default.default.button`
|
|
2578
|
+
display: flex;
|
|
2579
|
+
align-items: center;
|
|
2580
|
+
justify-content: center;
|
|
2581
|
+
padding: 4px;
|
|
2582
|
+
width: fit-content;
|
|
2583
|
+
height: fit-content;
|
|
2584
|
+
`;
|
|
2585
|
+
var Radio = (_a) => {
|
|
2586
|
+
var _b = _a, { isSelected, defaultSelected, disabled, onClick, onMouseEnter, onMouseLeave } = _b, rest = __objRest(_b, ["isSelected", "defaultSelected", "disabled", "onClick", "onMouseEnter", "onMouseLeave"]);
|
|
2587
|
+
const [selected, toggleSelected] = useOnToggle(isSelected, defaultSelected);
|
|
2588
|
+
const [isHovered, toggleHovered] = React3.useState(false);
|
|
2589
|
+
const handleMouseLeave = (e) => {
|
|
2590
|
+
toggleHovered(false);
|
|
2591
|
+
onMouseLeave && onMouseLeave(e);
|
|
2592
|
+
};
|
|
2593
|
+
const handleMouseEnter = (e) => {
|
|
2594
|
+
toggleHovered(true);
|
|
2595
|
+
onMouseEnter && onMouseEnter(e);
|
|
2596
|
+
};
|
|
2597
|
+
const handleClick = (e) => {
|
|
2598
|
+
if (disabled) {
|
|
2599
|
+
return;
|
|
2600
|
+
}
|
|
2601
|
+
onClick && onClick(e);
|
|
2602
|
+
toggleSelected();
|
|
2603
|
+
};
|
|
2604
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2605
|
+
Container4,
|
|
2606
|
+
__spreadProps(__spreadValues({
|
|
2607
|
+
onClick: handleClick,
|
|
2608
|
+
onMouseEnter: handleMouseEnter,
|
|
2609
|
+
onMouseLeave: handleMouseLeave
|
|
2610
|
+
}, rest), {
|
|
2611
|
+
"data-shoplflow": "Radio",
|
|
2612
|
+
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" }) }) })
|
|
2613
|
+
})
|
|
2614
|
+
);
|
|
2615
|
+
};
|
|
2616
|
+
exports.Radio = Radio;
|
|
2300
2617
|
|
|
2301
2618
|
Object.defineProperty(exports, 'arrow', {
|
|
2302
2619
|
enumerable: true,
|