@nation-a/ui 0.10.7 → 0.11.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 CHANGED
@@ -3557,11 +3557,42 @@ const getPortalNode = (cb) => {
3557
3557
  };
3558
3558
  const subscribe = () => () => {
3559
3559
  };
3560
+ function useDebounce(value, delay2) {
3561
+ const [debouncedValue, setDebouncedValue] = React.useState(value);
3562
+ React.useEffect(() => {
3563
+ const timer = setTimeout(() => {
3564
+ setDebouncedValue(value);
3565
+ }, delay2);
3566
+ return () => {
3567
+ clearTimeout(timer);
3568
+ };
3569
+ }, [value, delay2]);
3570
+ return debouncedValue;
3571
+ }
3560
3572
  const [TabsProvider, useTabsContext] = createContext({
3561
3573
  name: "TabsContext",
3562
3574
  hookName: "useTabsContext",
3563
3575
  providerName: "<TabsProvider />"
3564
3576
  });
3577
+ const TabContent = React.forwardRef((props, ref) => {
3578
+ const [contentProps, localProps] = createSplitProps()(props, ["value"]);
3579
+ const tabs = useTabsContext();
3580
+ const renderStrategyProps = useRenderStrategyPropsContext();
3581
+ const presence = usePresence({
3582
+ ...renderStrategyProps,
3583
+ present: useDebounce(tabs.value === props.value, 0),
3584
+ immediate: true
3585
+ });
3586
+ const mergedProps = mergeProps(tabs.getContentProps(contentProps), presence.getPresenceProps(), localProps);
3587
+ return /* @__PURE__ */ jsxRuntime.jsx(PresenceProvider, { value: presence, children: presence.unmounted ? null : /* @__PURE__ */ jsxRuntime.jsx(ark.div, { ...mergedProps, ref: composeRefs(presence.ref, ref) }) });
3588
+ });
3589
+ TabContent.displayName = "TabContent";
3590
+ const TabIndicator = React.forwardRef((props, ref) => {
3591
+ const tabs = useTabsContext();
3592
+ const mergedProps = mergeProps(tabs.getIndicatorProps(), props);
3593
+ return /* @__PURE__ */ jsxRuntime.jsx(ark.div, { ...mergedProps, ref });
3594
+ });
3595
+ TabIndicator.displayName = "TabIndicator";
3565
3596
  const TabList = React.forwardRef((props, ref) => {
3566
3597
  const tabs = useTabsContext();
3567
3598
  const mergedProps = mergeProps(tabs.getListProps(), props);
@@ -5961,16 +5992,16 @@ const dialogRecipe = sva({
5961
5992
  }
5962
5993
  }
5963
5994
  });
5964
- const { withRootProvider: withRootProvider$1, withContext: withContext$2 } = createStyleContext(dialogRecipe);
5965
- const Root$2 = withRootProvider$1(DialogRoot);
5966
- const Backdrop$1 = withContext$2(DialogBackdrop, "backdrop");
5967
- const Trigger$1 = withContext$2(DialogTrigger, "trigger");
5968
- const Content$1 = withContext$2(DialogContent, "content");
5969
- const Title = withContext$2(DialogTitle, "title");
5970
- const Description$1 = withContext$2(DialogDescription, "description");
5971
- const Positioner = withContext$2(DialogPositioner, "positioner");
5972
- const Header = withContext$2(ark.header, "header");
5973
- const Footer = withContext$2(
5995
+ const { withRootProvider: withRootProvider$2, withContext: withContext$3 } = createStyleContext(dialogRecipe);
5996
+ const Root$3 = withRootProvider$2(DialogRoot);
5997
+ const Backdrop$1 = withContext$3(DialogBackdrop, "backdrop");
5998
+ const Trigger$2 = withContext$3(DialogTrigger, "trigger");
5999
+ const Content$2 = withContext$3(DialogContent, "content");
6000
+ const Title = withContext$3(DialogTitle, "title");
6001
+ const Description$1 = withContext$3(DialogDescription, "description");
6002
+ const Positioner = withContext$3(DialogPositioner, "positioner");
6003
+ const Header = withContext$3(ark.header, "header");
6004
+ const Footer = withContext$3(
5974
6005
  ({ orientation = "horizontal", className, ...props }) => {
5975
6006
  return /* @__PURE__ */ jsxRuntime.jsx(
5976
6007
  ark.footer,
@@ -5988,13 +6019,13 @@ const Footer = withContext$2(
5988
6019
  },
5989
6020
  "footer"
5990
6021
  );
5991
- const Body = withContext$2(ark.main, "body");
5992
- const CloseTrigger = withContext$2(DialogCloseTrigger, "closeTrigger");
6022
+ const Body = withContext$3(ark.main, "body");
6023
+ const CloseTrigger = withContext$3(DialogCloseTrigger, "closeTrigger");
5993
6024
  const Dialog = {
5994
- Root: Root$2,
6025
+ Root: Root$3,
5995
6026
  Backdrop: Backdrop$1,
5996
- Trigger: Trigger$1,
5997
- Content: Content$1,
6027
+ Trigger: Trigger$2,
6028
+ Content: Content$2,
5998
6029
  Title,
5999
6030
  Description: Description$1,
6000
6031
  Positioner,
@@ -9914,20 +9945,20 @@ const navigationRecipe = sva({
9914
9945
  }
9915
9946
  }
9916
9947
  });
9917
- const { withRootProvider, withContext: withContext$1 } = createStyleContext(navigationRecipe);
9918
- const Root$1 = withRootProvider(TabsRoot);
9919
- const Trigger = withContext$1(
9948
+ const { withRootProvider: withRootProvider$1, withContext: withContext$2 } = createStyleContext(navigationRecipe);
9949
+ const Root$2 = withRootProvider$1(TabsRoot);
9950
+ const Trigger$1 = withContext$2(
9920
9951
  ({ icon, label, ...props }) => /* @__PURE__ */ jsxRuntime.jsxs(TabTrigger, { ...props, children: [
9921
9952
  icon,
9922
9953
  label
9923
9954
  ] }),
9924
9955
  "trigger"
9925
9956
  );
9926
- const List = withContext$1(TabList, "list");
9957
+ const List$1 = withContext$2(TabList, "list");
9927
9958
  const Navigation = {
9928
- Root: Root$1,
9929
- Item: Trigger,
9930
- List
9959
+ Root: Root$2,
9960
+ Item: Trigger$1,
9961
+ List: List$1
9931
9962
  };
9932
9963
  const tagRecipe = cva({
9933
9964
  base: {
@@ -10079,6 +10110,12 @@ function P({ size: C = 24, color: n = "currentColor", ...o }) {
10079
10110
  }
10080
10111
  const Tag = React.forwardRef(({ imageSrc, text, onDeleteClick, ...rest }, ref) => {
10081
10112
  const StyledTag = styled(ark.div, tagRecipe);
10113
+ const handleClickDelete = (e) => {
10114
+ e.stopPropagation();
10115
+ if (onDeleteClick) {
10116
+ onDeleteClick();
10117
+ }
10118
+ };
10082
10119
  return /* @__PURE__ */ jsxRuntime.jsxs(StyledTag, { avatar: !!imageSrc, ref, ...rest, children: [
10083
10120
  imageSrc ? /* @__PURE__ */ jsxRuntime.jsx(
10084
10121
  styled.img,
@@ -10089,7 +10126,7 @@ const Tag = React.forwardRef(({ imageSrc, text, onDeleteClick, ...rest }, ref) =
10089
10126
  }
10090
10127
  ) : null,
10091
10128
  text,
10092
- onDeleteClick ? /* @__PURE__ */ jsxRuntime.jsx(P, { size: 12, onClick: onDeleteClick, cursor: "pointer" }) : null
10129
+ onDeleteClick ? /* @__PURE__ */ jsxRuntime.jsx(P, { size: 12, onClick: handleClickDelete, className: css$1({ cursor: "pointer" }) }) : null
10093
10130
  ] });
10094
10131
  });
10095
10132
  Tag.displayName = "Tag";
@@ -10442,6 +10479,169 @@ const Textarea = React.forwardRef(
10442
10479
  );
10443
10480
  Textarea.displayName = "Textarea";
10444
10481
  const index = React.memo(Textarea);
10482
+ const tabsRecipe = sva({
10483
+ className: "tabs",
10484
+ slots: anatomy$1.keys(),
10485
+ base: {
10486
+ root: {
10487
+ display: "flex",
10488
+ width: "full",
10489
+ flexDirection: "column"
10490
+ },
10491
+ list: {
10492
+ display: "flex",
10493
+ flexShrink: "0",
10494
+ flexDirection: "row",
10495
+ overflowX: "auto",
10496
+ position: "relative",
10497
+ scrollbarWidth: "none",
10498
+ "&::-webkit-scrollbar": {
10499
+ display: "none"
10500
+ }
10501
+ },
10502
+ trigger: {
10503
+ alignItems: "center",
10504
+ color: "content.neutral.subtlest",
10505
+ cursor: "pointer",
10506
+ display: "inline-flex",
10507
+ flexShrink: "0",
10508
+ gap: "2",
10509
+ justifyContent: "center",
10510
+ px: "4",
10511
+ py: "2",
10512
+ textStyle: "label.md",
10513
+ transition: "all",
10514
+ transitionDuration: "normal",
10515
+ transitionTimingFunction: "default",
10516
+ whiteSpace: "nowrap",
10517
+ _disabled: {
10518
+ color: "content.neutral.disabled",
10519
+ cursor: "not-allowed"
10520
+ },
10521
+ _hover: {
10522
+ color: "content.neutral.hovered"
10523
+ },
10524
+ _selected: {
10525
+ color: "content.neutral.bold"
10526
+ }
10527
+ },
10528
+ content: {
10529
+ pt: "4"
10530
+ },
10531
+ indicator: {
10532
+ width: "var(--width)",
10533
+ height: "2px",
10534
+ borderRadius: "xs",
10535
+ background: "content.neutral.bold",
10536
+ bottom: "0px"
10537
+ }
10538
+ },
10539
+ variants: {
10540
+ variant: {
10541
+ line: {
10542
+ list: {
10543
+ borderBottomWidth: "1px",
10544
+ borderColor: "background.neutral.selected"
10545
+ }
10546
+ },
10547
+ enclosed: {
10548
+ list: {
10549
+ p: "16px 0 0 16px",
10550
+ borderRadius: "md",
10551
+ gap: "16"
10552
+ },
10553
+ trigger: {
10554
+ borderRadius: "full",
10555
+ _selected: {
10556
+ background: "background.neutral.selected"
10557
+ }
10558
+ },
10559
+ indicator: {
10560
+ display: "none"
10561
+ }
10562
+ }
10563
+ },
10564
+ fitted: {
10565
+ true: {
10566
+ root: {
10567
+ width: "100%"
10568
+ },
10569
+ list: {
10570
+ width: "100%",
10571
+ p: 1,
10572
+ overflowX: "visible"
10573
+ },
10574
+ trigger: {
10575
+ flex: 1,
10576
+ justifyContent: "center",
10577
+ overflow: "hidden",
10578
+ textOverflow: "ellipsis",
10579
+ whiteSpace: "nowrap"
10580
+ }
10581
+ }
10582
+ },
10583
+ bottomLine: {
10584
+ true: {
10585
+ list: {
10586
+ borderBottomWidth: "1px",
10587
+ borderColor: "background.neutral.selected"
10588
+ }
10589
+ },
10590
+ false: {
10591
+ list: {
10592
+ borderBottomWidth: "0px"
10593
+ }
10594
+ }
10595
+ },
10596
+ shadow: {
10597
+ true: {
10598
+ list: {
10599
+ boxShadow: "0px 8px 12px 0px var(--colors-semantic-shadow-overlay, rgba(0, 0, 0, 0.08))"
10600
+ }
10601
+ }
10602
+ }
10603
+ },
10604
+ compoundVariants: [
10605
+ {
10606
+ variant: "enclosed",
10607
+ fitted: true,
10608
+ css: {
10609
+ list: {
10610
+ background: "background.neutral.default",
10611
+ borderRadius: "full"
10612
+ }
10613
+ }
10614
+ },
10615
+ {
10616
+ variant: "enclosed",
10617
+ bottomLine: true,
10618
+ css: {
10619
+ list: {
10620
+ borderBottomWidth: "0px"
10621
+ }
10622
+ }
10623
+ }
10624
+ ],
10625
+ defaultVariants: {
10626
+ variant: "line",
10627
+ fitted: false,
10628
+ bottomLine: true,
10629
+ shadow: false
10630
+ }
10631
+ });
10632
+ const { withRootProvider, withContext: withContext$1 } = createStyleContext(tabsRecipe);
10633
+ const Root$1 = withRootProvider(TabsRoot);
10634
+ const List = withContext$1(TabList, "list");
10635
+ const Trigger = withContext$1(TabTrigger, "trigger");
10636
+ const Content$1 = withContext$1(TabContent, "content");
10637
+ const Indicator = withContext$1(TabIndicator, "indicator");
10638
+ const Tabs = Object.assign(Root$1, {
10639
+ Root: Root$1,
10640
+ List,
10641
+ Trigger,
10642
+ Content: Content$1,
10643
+ Indicator
10644
+ });
10445
10645
  function definePreset(preset2) {
10446
10646
  return preset2;
10447
10647
  }
@@ -11021,6 +11221,7 @@ exports.Navigation = Navigation;
11021
11221
  exports.Portal = Portal;
11022
11222
  exports.Spinner = Spinner;
11023
11223
  exports.Stack = Stack2;
11224
+ exports.Tabs = Tabs;
11024
11225
  exports.Tag = index$2;
11025
11226
  exports.Text = Text;
11026
11227
  exports.TextArea = index;