@vellira-ui/react-native 2.59.3 → 2.60.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.
Files changed (2) hide show
  1. package/dist/index.js +143 -85
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5297,7 +5297,7 @@ const createStyles$6 = (theme) => StyleSheet.create({
5297
5297
  //#region src/components/Tabs/List/TabsList.tsx
5298
5298
  const TabsList = ({ children, scrollable: scrollableProp, style }) => {
5299
5299
  const styles = useThemeStyles(createStyles$6);
5300
- const { orientation, variant } = useTabs();
5300
+ const { mode, orientation, variant } = useTabs();
5301
5301
  const scrollable = scrollableProp ?? false;
5302
5302
  const listStyle = [
5303
5303
  styles.list,
@@ -5309,13 +5309,13 @@ const TabsList = ({ children, scrollable: scrollableProp, style }) => {
5309
5309
  ];
5310
5310
  if (scrollable && orientation === "horizontal") return /* @__PURE__ */ jsx(ScrollView, {
5311
5311
  horizontal: true,
5312
- accessibilityRole: "tablist",
5312
+ accessibilityRole: mode === "tabs" ? "tablist" : void 0,
5313
5313
  showsHorizontalScrollIndicator: false,
5314
5314
  contentContainerStyle: listStyle,
5315
5315
  children
5316
5316
  });
5317
5317
  return /* @__PURE__ */ jsx(View, {
5318
- accessibilityRole: "tablist",
5318
+ accessibilityRole: mode === "tabs" ? "tablist" : void 0,
5319
5319
  style: listStyle,
5320
5320
  children
5321
5321
  });
@@ -5476,6 +5476,37 @@ const createStyles$5 = (theme) => StyleSheet.create({
5476
5476
  tabIconActive: { color: theme.components.tabs.primary.trigger.active.fg },
5477
5477
  tabIconPillsActive: { color: theme.components.tabs.primary.pills.active.fg }
5478
5478
  });
5479
+ const getTriggerStyle = ({ styles, isSm, isLg, isOnlyIcon, isVertical, isPills, isSegmented, isLine, isActive, isDisabled, borderColor, backgroundColor, segmentedActiveBorderColor, style }) => [
5480
+ styles.tab,
5481
+ isSm && styles.tabSm,
5482
+ isLg && styles.tabLg,
5483
+ isOnlyIcon && styles.tabIconOnly,
5484
+ isOnlyIcon && isSm && styles.tabIconOnlySm,
5485
+ isOnlyIcon && isLg && styles.tabIconOnlyLg,
5486
+ isVertical && styles.tabVertical,
5487
+ isPills && styles.tabPills,
5488
+ isPills && isOnlyIcon && styles.tabPillsIconOnly,
5489
+ isSegmented && styles.tabSegmented,
5490
+ isSegmented && isSm && styles.tabSegmentedSm,
5491
+ isSegmented && isLg && styles.tabSegmentedLg,
5492
+ isSegmented && isOnlyIcon && styles.tabSegmentedIconOnly,
5493
+ isSegmented && isOnlyIcon && isSm && styles.tabSegmentedIconOnlySm,
5494
+ isSegmented && isOnlyIcon && isLg && styles.tabSegmentedIconOnlyLg,
5495
+ {
5496
+ borderColor: isLine ? "transparent" : borderColor,
5497
+ backgroundColor
5498
+ },
5499
+ isSegmented && isActive && {
5500
+ borderColor: segmentedActiveBorderColor,
5501
+ backgroundColor: "transparent"
5502
+ },
5503
+ isPills && isActive && {
5504
+ borderColor: "transparent",
5505
+ backgroundColor: "transparent"
5506
+ },
5507
+ isDisabled && styles.tabDisabled,
5508
+ style
5509
+ ];
5479
5510
  //#endregion
5480
5511
  //#region src/components/Tabs/Trigger/TabsBadge.tsx
5481
5512
  const TabsBadge = ({ children, style }) => {
@@ -5508,19 +5539,21 @@ const TabsIcon = ({ children, style }) => {
5508
5539
  TabsIcon.displayName = "Tabs.Icon";
5509
5540
  //#endregion
5510
5541
  //#region src/components/Tabs/Trigger/TabsTrigger.tsx
5511
- const TabsTrigger = ({ value, children, icon, badge, description, disabled, style, textStyle }) => {
5542
+ const TabsTrigger = ({ value, children, asChild = false, icon, badge, description, disabled, style, textStyle }) => {
5512
5543
  const { theme } = useTheme();
5513
5544
  const styles = useThemeStyles(createStyles$5);
5514
- const { value: selectedValue, variant, color, size, orientation, disabled: rootDisabled, setValue, registerTrigger, registerTriggerLayout } = useTabs();
5515
- const isDisabled = rootDisabled || disabled;
5545
+ const { value: selectedValue, variant, color, size, mode, orientation, disabled: rootDisabled, setValue, registerTrigger, registerTriggerLayout } = useTabs();
5546
+ const isDisabled = rootDisabled || Boolean(disabled);
5516
5547
  const isActive = selectedValue === value;
5548
+ const child = asChild && isValidElement(children) ? children : void 0;
5549
+ const visibleChildren = child ? child.props.children : children;
5517
5550
  const isPills = variant === "pills";
5518
5551
  const isLine = variant === "line";
5519
5552
  const isSegmented = variant === "segmented";
5520
5553
  const isVertical = orientation === "vertical";
5521
5554
  const isSm = size === "sm";
5522
5555
  const isLg = size === "lg";
5523
- const isOnlyIcon = icon != null && children == null && badge == null;
5556
+ const isOnlyIcon = icon != null && visibleChildren == null && badge == null;
5524
5557
  const palette = theme.components.tabs[color];
5525
5558
  const state = isDisabled ? theme.components.tabs.disabled : isPills ? isActive ? palette.pills.active : palette.pills.default : isActive ? palette.trigger.active : palette.trigger.default;
5526
5559
  const pressedState = isDisabled ? state : isPills ? isActive ? palette.pills.active : palette.pills.hover : isActive ? palette.trigger.active : palette.trigger.hover;
@@ -5539,91 +5572,114 @@ const TabsTrigger = ({ value, children, icon, badge, description, disabled, styl
5539
5572
  const handleLayout = (event) => {
5540
5573
  registerTriggerLayout(value, event.nativeEvent.layout);
5541
5574
  };
5575
+ const handlePress = (_event) => {
5576
+ if (isDisabled || isActive) return;
5577
+ setValue(value);
5578
+ };
5542
5579
  const iconColor = isPills && isActive ? palette.pills.active.fg : isActive ? palette.trigger.active.fg : state.fg;
5543
5580
  const renderedIcon = isValidElement(icon) ? cloneElement(icon, { color: iconColor }) : icon;
5544
- return /* @__PURE__ */ jsx(Pressable, {
5545
- disabled: isDisabled,
5546
- accessibilityRole: "tab",
5547
- accessibilityState: {
5581
+ const content = /* @__PURE__ */ jsxs(Fragment, { children: [
5582
+ icon != null && /* @__PURE__ */ jsx(View, {
5583
+ style: styles.tabIcon,
5584
+ children: renderedIcon
5585
+ }),
5586
+ visibleChildren != null && /* @__PURE__ */ jsx(Text, {
5587
+ numberOfLines: 2,
5588
+ ellipsizeMode: "tail",
5589
+ style: [
5590
+ styles.tabText,
5591
+ isSm && styles.tabTextSm,
5592
+ isLg && styles.tabTextLg,
5593
+ { color: isSegmented && isActive ? palette.segmented.active.fg : state.fg },
5594
+ textStyle
5595
+ ],
5596
+ children: visibleChildren
5597
+ }),
5598
+ description != null && /* @__PURE__ */ jsx(Text, {
5599
+ numberOfLines: 2,
5600
+ ellipsizeMode: "tail",
5601
+ style: [
5602
+ styles.tabText,
5603
+ styles.tabDescription,
5604
+ isSm && styles.tabTextSm,
5605
+ isLg && styles.tabTextLg,
5606
+ { color: isDisabled ? theme.components.tabs.disabled.fg : state.fg }
5607
+ ],
5608
+ children: description
5609
+ }),
5610
+ badge != null && /* @__PURE__ */ jsx(View, {
5611
+ style: [
5612
+ styles.tabBadge,
5613
+ isLg && styles.tabBadgeLg,
5614
+ { backgroundColor: palette.pills.active.bg }
5615
+ ],
5616
+ children: /* @__PURE__ */ jsx(Text, {
5617
+ style: [styles.tabBadgeText, { color: palette.pills.active.fg }],
5618
+ children: badge
5619
+ })
5620
+ })
5621
+ ] });
5622
+ const baseStyle = getTriggerStyle({
5623
+ styles,
5624
+ isSm,
5625
+ isLg,
5626
+ isOnlyIcon,
5627
+ isVertical,
5628
+ isPills,
5629
+ isSegmented,
5630
+ isLine,
5631
+ isActive,
5632
+ isDisabled,
5633
+ borderColor: state.border,
5634
+ backgroundColor: state.bg,
5635
+ segmentedActiveBorderColor: palette.segmented.active.border,
5636
+ style
5637
+ });
5638
+ if (child) return cloneElement(child, {
5639
+ accessibilityRole: mode === "tabs" ? "tab" : void 0,
5640
+ accessibilityState: mode === "tabs" ? {
5548
5641
  selected: isActive,
5549
5642
  disabled: isDisabled
5643
+ } : { disabled: isDisabled },
5644
+ disabled: isDisabled,
5645
+ onLayout: (event) => {
5646
+ child.props.onLayout?.(event);
5647
+ handleLayout(event);
5550
5648
  },
5551
- onPress: () => {
5552
- if (!isDisabled && !isActive) setValue(value);
5649
+ onPress: (event) => {
5650
+ child.props.onPress?.(event);
5651
+ if (isDisabled) return;
5652
+ handlePress(event);
5553
5653
  },
5654
+ style: [baseStyle, child.props.style],
5655
+ children: content
5656
+ });
5657
+ return /* @__PURE__ */ jsx(Pressable, {
5658
+ disabled: isDisabled,
5659
+ accessibilityRole: mode === "tabs" ? "tab" : void 0,
5660
+ accessibilityState: mode === "tabs" ? {
5661
+ selected: isActive,
5662
+ disabled: isDisabled
5663
+ } : { disabled: isDisabled },
5664
+ onPress: handlePress,
5554
5665
  onLayout: handleLayout,
5555
- style: ({ pressed }) => [
5556
- styles.tab,
5557
- isSm && styles.tabSm,
5558
- isLg && styles.tabLg,
5559
- isOnlyIcon && styles.tabIconOnly,
5560
- isOnlyIcon && isSm && styles.tabIconOnlySm,
5561
- isOnlyIcon && isLg && styles.tabIconOnlyLg,
5562
- isVertical && styles.tabVertical,
5563
- isPills && styles.tabPills,
5564
- isPills && isOnlyIcon && styles.tabPillsIconOnly,
5565
- isSegmented && styles.tabSegmented,
5566
- isSegmented && isSm && styles.tabSegmentedSm,
5567
- isSegmented && isLg && styles.tabSegmentedLg,
5568
- isSegmented && isOnlyIcon && styles.tabSegmentedIconOnly,
5569
- isSegmented && isOnlyIcon && isSm && styles.tabSegmentedIconOnlySm,
5570
- isSegmented && isOnlyIcon && isLg && styles.tabSegmentedIconOnlyLg,
5571
- {
5572
- borderColor: isLine ? "transparent" : state.border,
5573
- backgroundColor: pressed ? pressedState.bg : state.bg
5574
- },
5575
- isSegmented && isActive && {
5576
- borderColor: palette.segmented.active.border,
5577
- backgroundColor: "transparent"
5578
- },
5579
- isPills && isActive && {
5580
- borderColor: "transparent",
5581
- backgroundColor: "transparent"
5582
- },
5583
- isDisabled && styles.tabDisabled,
5666
+ style: ({ pressed }) => getTriggerStyle({
5667
+ styles,
5668
+ isSm,
5669
+ isLg,
5670
+ isOnlyIcon,
5671
+ isVertical,
5672
+ isPills,
5673
+ isSegmented,
5674
+ isLine,
5675
+ isActive,
5676
+ isDisabled,
5677
+ borderColor: state.border,
5678
+ backgroundColor: pressed ? pressedState.bg : state.bg,
5679
+ segmentedActiveBorderColor: palette.segmented.active.border,
5584
5680
  style
5585
- ],
5586
- children: () => /* @__PURE__ */ jsxs(Fragment, { children: [
5587
- icon != null && /* @__PURE__ */ jsx(View, {
5588
- style: styles.tabIcon,
5589
- children: renderedIcon
5590
- }),
5591
- children != null && /* @__PURE__ */ jsx(Text, {
5592
- numberOfLines: 2,
5593
- ellipsizeMode: "tail",
5594
- style: [
5595
- styles.tabText,
5596
- isSm && styles.tabTextSm,
5597
- isLg && styles.tabTextLg,
5598
- { color: isSegmented && isActive ? palette.segmented.active.fg : state.fg },
5599
- textStyle
5600
- ],
5601
- children
5602
- }),
5603
- description != null && /* @__PURE__ */ jsx(Text, {
5604
- numberOfLines: 2,
5605
- ellipsizeMode: "tail",
5606
- style: [
5607
- styles.tabText,
5608
- styles.tabDescription,
5609
- isSm && styles.tabTextSm,
5610
- isLg && styles.tabTextLg,
5611
- { color: isDisabled ? theme.components.tabs.disabled.fg : state.fg }
5612
- ],
5613
- children: description
5614
- }),
5615
- badge != null && /* @__PURE__ */ jsx(View, {
5616
- style: [
5617
- styles.tabBadge,
5618
- isLg && styles.tabBadgeLg,
5619
- { backgroundColor: palette.pills.active.bg }
5620
- ],
5621
- children: /* @__PURE__ */ jsx(Text, {
5622
- style: [styles.tabBadgeText, { color: palette.pills.active.fg }],
5623
- children: badge
5624
- })
5625
- })
5626
- ] })
5681
+ }),
5682
+ children: content
5627
5683
  });
5628
5684
  };
5629
5685
  TabsTrigger.displayName = "Tabs.Trigger";
@@ -5644,7 +5700,7 @@ const createStyles$4 = (theme) => StyleSheet.create({
5644
5700
  });
5645
5701
  //#endregion
5646
5702
  //#region src/components/Tabs/Root/TabsRoot.tsx
5647
- const TabsRoot = ({ children, value: controlledValue, defaultValue, onValueChange, orientation = "horizontal", activationMode = "automatic", variant = "line", color = "primary", size = "md", keepMounted = false, lazyMount = false, disabled = false, style }) => {
5703
+ const TabsRoot = ({ children, value: controlledValue, defaultValue, onValueChange, orientation = "horizontal", activationMode = "automatic", mode = "tabs", variant = "line", color = "primary", size = "md", keepMounted = false, lazyMount = false, disabled = false, style }) => {
5648
5704
  const styles = useThemeStyles(createStyles$4);
5649
5705
  const isControlled = controlledValue !== void 0;
5650
5706
  const [version, setVersion] = useState(0);
@@ -5701,6 +5757,7 @@ const TabsRoot = ({ children, value: controlledValue, defaultValue, onValueChang
5701
5757
  const contextValue = useMemo(() => ({
5702
5758
  value,
5703
5759
  setValue,
5760
+ mode,
5704
5761
  orientation,
5705
5762
  activationMode,
5706
5763
  variant,
@@ -5719,6 +5776,7 @@ const TabsRoot = ({ children, value: controlledValue, defaultValue, onValueChang
5719
5776
  disabled,
5720
5777
  keepMounted,
5721
5778
  lazyMount,
5779
+ mode,
5722
5780
  orientation,
5723
5781
  getTriggerLayout,
5724
5782
  indicatorVersion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellira-ui/react-native",
3
- "version": "2.59.3",
3
+ "version": "2.60.0",
4
4
  "description": "React Native components for Vellira Design System",
5
5
  "keywords": [
6
6
  "vellira",