@shoplflow/base 0.26.7 → 0.26.8

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
@@ -2794,6 +2794,12 @@ exports.TagSizeVariants = {
2794
2794
  S: "S",
2795
2795
  M: "M"
2796
2796
  };
2797
+ var StyledTree = styled6__default.default.div``;
2798
+ var Tree = (_a) => {
2799
+ var rest = __objRest(_a, []);
2800
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledTree, __spreadProps(__spreadValues({}, rest), { "data-shoplflow": "Tree", children: "Tree" }));
2801
+ };
2802
+ exports.Tree = Tree;
2797
2803
  var StyledInput = styled6__default.default.input`
2798
2804
  padding: 4px 0 4px 12px;
2799
2805
  background-color: transparent;
@@ -3436,6 +3442,263 @@ var Tooltip = (_a) => {
3436
3442
  };
3437
3443
  Tooltip.Content = TooltipContent;
3438
3444
  exports.Tooltip = Tooltip;
3445
+ exports.TabsContext = React3.createContext(null);
3446
+ exports.useTabs = () => {
3447
+ const context = React3.useContext(exports.TabsContext);
3448
+ if (context === null) {
3449
+ throw new Error("useTabs should be used in Tabs");
3450
+ }
3451
+ return context;
3452
+ };
3453
+ var getHoverTabStyleByStyleVar = (styleVar) => {
3454
+ switch (styleVar) {
3455
+ case "INFO": {
3456
+ return react$1.css`
3457
+ ::after {
3458
+ content: '';
3459
+ position: absolute;
3460
+ left: 0;
3461
+ right: 0;
3462
+ bottom: -2px;
3463
+ height: 2px;
3464
+ background: ${exports.colorTokens.neutral500};
3465
+ }
3466
+ `;
3467
+ }
3468
+ default: {
3469
+ return null;
3470
+ }
3471
+ }
3472
+ };
3473
+ var getWrapperStyleByStyleVar = (styleVar) => {
3474
+ switch (styleVar) {
3475
+ case "INFO": {
3476
+ return react$1.css`
3477
+ padding-inline: 16px;
3478
+ `;
3479
+ }
3480
+ default: {
3481
+ return null;
3482
+ }
3483
+ }
3484
+ };
3485
+ var getActiveTriggerStyleByStyleVar = (styleVar) => {
3486
+ switch (styleVar) {
3487
+ case "INFO": {
3488
+ return react$1.css`
3489
+ ::after {
3490
+ content: '';
3491
+ position: absolute;
3492
+ left: 0;
3493
+ right: 0;
3494
+ bottom: -2px;
3495
+ height: 2px;
3496
+ background: #000;
3497
+ }
3498
+ `;
3499
+ }
3500
+ default: {
3501
+ return null;
3502
+ }
3503
+ }
3504
+ };
3505
+ var StyledTab = styled6__default.default.div`
3506
+ display: flex;
3507
+ flex-direction: row;
3508
+ align-items: center;
3509
+ padding: 12px 16px;
3510
+ width: fit-content;
3511
+ cursor: pointer;
3512
+ position: relative;
3513
+ user-select: none;
3514
+
3515
+ ${({ styleVar }) => styleVar && getWrapperStyleByStyleVar(styleVar)};
3516
+
3517
+ /* hover style */
3518
+ ${({ isActive, isHover, styleVar }) => !isActive && isHover && styleVar && getHoverTabStyleByStyleVar(styleVar)}
3519
+
3520
+ /* active style */
3521
+ ${({ isActive, styleVar }) => isActive && styleVar && getActiveTriggerStyleByStyleVar(styleVar)}
3522
+ `;
3523
+ var getTextStyleByStyleVar = (styleVar) => {
3524
+ switch (styleVar) {
3525
+ case "NORMAL": {
3526
+ return react$1.css`
3527
+ color: ${exports.colorTokens.neutral400};
3528
+ `;
3529
+ }
3530
+ case "INFO": {
3531
+ return react$1.css`
3532
+ color: ${exports.colorTokens.neutral500};
3533
+ `;
3534
+ }
3535
+ }
3536
+ };
3537
+ var getHoverTextStyleByStyleVar = (styleVar) => {
3538
+ switch (styleVar) {
3539
+ case "NORMAL": {
3540
+ return react$1.css`
3541
+ color: ${exports.colorTokens.neutral500};
3542
+ `;
3543
+ }
3544
+ case "INFO": {
3545
+ return react$1.css`
3546
+ color: ${exports.colorTokens.neutral700};
3547
+ `;
3548
+ }
3549
+ default: {
3550
+ return null;
3551
+ }
3552
+ }
3553
+ };
3554
+ var getActiveTextStyleByStyleVar = (styleVar, activeColor) => {
3555
+ switch (styleVar) {
3556
+ case "NORMAL": {
3557
+ return react$1.css`
3558
+ color: ${activeColor ? exports.colorTokens[activeColor] : exports.colorTokens.neutral700};
3559
+ `;
3560
+ }
3561
+ case "INFO": {
3562
+ return react$1.css`
3563
+ color: ${exports.colorTokens.neutral700};
3564
+ `;
3565
+ }
3566
+ default: {
3567
+ return react$1.css`
3568
+ color: ${exports.colorTokens.primary300};
3569
+ `;
3570
+ }
3571
+ }
3572
+ };
3573
+ var StyledTabText = styled6__default.default(exports.Text)`
3574
+ cursor: pointer;
3575
+
3576
+ ${({ styleVar }) => styleVar && getTextStyleByStyleVar(styleVar)};
3577
+
3578
+ /* hover style */
3579
+ ${({ isHover, styleVar, isActive }) => !isActive && isHover && styleVar && getHoverTextStyleByStyleVar(styleVar)}
3580
+
3581
+ /* active style */
3582
+ ${({ isActive, styleVar, activeColor }) => isActive && styleVar && getActiveTextStyleByStyleVar(styleVar, activeColor)}
3583
+ `;
3584
+ var StyledIndicator = styled6__default.default(framerMotion.motion.div)`
3585
+ position: absolute;
3586
+ bottom: -2px;
3587
+ left: 0px;
3588
+ right: 0px;
3589
+ height: 2px;
3590
+ background-color: black;
3591
+ width: 100%;
3592
+ `;
3593
+ var Indicator = ({ layoutId }) => {
3594
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledIndicator, { layoutId, transition: { duration: 0.2 } });
3595
+ };
3596
+ var Tab = (_a) => {
3597
+ var _b = _a, {
3598
+ value,
3599
+ label,
3600
+ leftSource,
3601
+ rightSource,
3602
+ as,
3603
+ styleVar = "NORMAL",
3604
+ sizeVar = "L",
3605
+ onClick,
3606
+ activeColor
3607
+ } = _b, args = __objRest(_b, [
3608
+ "value",
3609
+ "label",
3610
+ "leftSource",
3611
+ "rightSource",
3612
+ "as",
3613
+ "styleVar",
3614
+ "sizeVar",
3615
+ "onClick",
3616
+ "activeColor"
3617
+ ]);
3618
+ const { activeTab, setActiveTab } = exports.useTabs();
3619
+ const [isHover, setIsHover] = React3.useState(false);
3620
+ const isActive = value === activeTab;
3621
+ const hoverHandler = React3.useCallback(() => {
3622
+ setIsHover(true);
3623
+ }, []);
3624
+ const unhoverHandler = React3.useCallback(() => {
3625
+ setIsHover(false);
3626
+ }, []);
3627
+ const clickHandler = (event) => {
3628
+ onClick == null ? void 0 : onClick(event);
3629
+ setActiveTab(value);
3630
+ };
3631
+ let typography = "title1_700";
3632
+ if (styleVar === "INFO") {
3633
+ typography = "body1_700";
3634
+ }
3635
+ if (styleVar === "NORMAL" && sizeVar === "M") {
3636
+ typography = "title2_700";
3637
+ }
3638
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3639
+ StyledTab,
3640
+ __spreadProps(__spreadValues({
3641
+ isActive,
3642
+ as,
3643
+ onClick: clickHandler,
3644
+ onMouseOver: hoverHandler,
3645
+ onMouseLeave: unhoverHandler,
3646
+ onFocus: hoverHandler,
3647
+ onBlur: unhoverHandler,
3648
+ isHover,
3649
+ styleVar
3650
+ }, args), {
3651
+ children: [
3652
+ leftSource,
3653
+ /* @__PURE__ */ jsxRuntime.jsx(
3654
+ StyledTabText,
3655
+ {
3656
+ isHover,
3657
+ lineClamp: 2,
3658
+ typography: `${typography}`,
3659
+ isActive,
3660
+ activeColor,
3661
+ styleVar,
3662
+ children: label
3663
+ }
3664
+ ),
3665
+ rightSource,
3666
+ styleVar === "INFO" && isActive && /* @__PURE__ */ jsxRuntime.jsx(Indicator, { layoutId: "underline" })
3667
+ ]
3668
+ })
3669
+ );
3670
+ };
3671
+ var Tabs = ({ children, initialTab, onChange }) => {
3672
+ const [activeTab, setActiveTab] = React3.useState(initialTab);
3673
+ React3.useEffect(() => {
3674
+ if (!onChange || !activeTab) {
3675
+ return;
3676
+ }
3677
+ onChange(activeTab);
3678
+ }, [activeTab]);
3679
+ return /* @__PURE__ */ jsxRuntime.jsx(
3680
+ exports.TabsContext.Provider,
3681
+ {
3682
+ value: {
3683
+ activeTab,
3684
+ setActiveTab
3685
+ },
3686
+ children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.LayoutGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children }) })
3687
+ }
3688
+ );
3689
+ };
3690
+ Tabs.Tab = Tab;
3691
+ exports.Tabs = Tabs;
3692
+
3693
+ // src/components/Tabs/Tabs.types.ts
3694
+ exports.TabStyleVariants = {
3695
+ NORMAL: "NORMAL",
3696
+ INFO: "INFO"
3697
+ };
3698
+ exports.TabSizeVariants = {
3699
+ M: "M",
3700
+ L: "L"
3701
+ };
3439
3702
  var PaginationWrapper = styled6__default.default.div`
3440
3703
  display: flex;
3441
3704
  align-items: center;