@avenue-ticketing/native 0.1.12 → 0.1.14
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/avatar.d.ts +1 -1
- package/dist/badge.d.ts +7 -7
- package/dist/button-group.d.ts +1 -1
- package/dist/checkbox.d.ts +1 -1
- package/dist/combobox.d.ts +1 -1
- package/dist/combobox.js +1 -1
- package/dist/dropdown.js +1 -1
- package/dist/input.d.ts +4 -5
- package/dist/input.js +2 -2
- package/dist/input.js.map +1 -1
- package/dist/multi-select.d.ts +1 -1
- package/dist/multi-select.js +1 -1
- package/dist/popover.d.ts +1 -1
- package/dist/radio.d.ts +1 -1
- package/dist/{select-native-C3ctbnUG.d.ts → select-native-D6wLBN5N.d.ts} +1 -1
- package/dist/select-native.d.ts +1 -1
- package/dist/select-native.js +1 -1
- package/dist/select.d.ts +1 -1
- package/dist/select.js +1 -1
- package/dist/tabs.d.ts +29 -2
- package/dist/tabs.js +201 -17
- package/dist/tabs.js.map +1 -1
- package/dist/tag-select.d.ts +1 -1
- package/dist/tag-select.js +1 -1
- package/dist/textarea.d.ts +1 -1
- package/dist/textarea.js +3 -2
- package/dist/textarea.js.map +1 -1
- package/dist/toast.d.ts +1 -1
- package/dist/toggle.d.ts +1 -1
- package/dist/tooltip.d.ts +1 -1
- package/package.json +1 -1
package/dist/multi-select.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SelectItemProps } from './select-item.js';
|
|
2
|
-
import {
|
|
2
|
+
import { FC, ReactNode } from 'react';
|
|
3
3
|
import { C as CommonProps, S as SelectItemType } from './select-shared-Ah_SqhzA.js';
|
|
4
4
|
import { S as SelectSelection, a as SelectSize } from './select-BJtrES5I.js';
|
|
5
5
|
|
package/dist/multi-select.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext, forwardRef,
|
|
1
|
+
import { createContext, forwardRef, useState, useContext, useMemo, isValidElement, useEffect } from 'react';
|
|
2
2
|
import { View, TextInput, Pressable, Text, ScrollView } from 'react-native-css/components';
|
|
3
3
|
import { useNativeVariable } from 'react-native-css';
|
|
4
4
|
import { CaretDownIcon } from 'phosphor-react-native/src/icons/CaretDown';
|
package/dist/popover.d.ts
CHANGED
package/dist/radio.d.ts
CHANGED
|
@@ -30,4 +30,4 @@ interface NativeSelectProps {
|
|
|
30
30
|
*/
|
|
31
31
|
declare const NativeSelect: FC<NativeSelectProps>;
|
|
32
32
|
|
|
33
|
-
export { type InputSize as I, NativeSelect as N, type InputType as a, type
|
|
33
|
+
export { type InputSize as I, NativeSelect as N, type InputType as a, type NativeSelectOption as b, type NativeSelectProps as c };
|
package/dist/select-native.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { N as NativeSelect,
|
|
1
|
+
export { N as NativeSelect, b as NativeSelectOption, c as NativeSelectProps } from './select-native-D6wLBN5N.js';
|
|
2
2
|
import 'react';
|
package/dist/select-native.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext, forwardRef,
|
|
1
|
+
import { createContext, forwardRef, useState, useContext, useCallback, useEffect } from 'react';
|
|
2
2
|
import { StyleSheet, Platform, useColorScheme, Modal, View as View$1, Pressable as Pressable$1 } from 'react-native';
|
|
3
3
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
4
4
|
import { View, TextInput, Pressable, Text } from 'react-native-css/components';
|
package/dist/select.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SelectItemProps } from './select-item.js';
|
|
2
2
|
import { ComboBoxProps } from './combobox.js';
|
|
3
|
-
import {
|
|
3
|
+
import { FC, ReactNode } from 'react';
|
|
4
4
|
import { C as CommonProps, S as SelectItemType } from './select-shared-Ah_SqhzA.js';
|
|
5
5
|
import 'react-native';
|
|
6
6
|
import './select-BJtrES5I.js';
|
package/dist/select.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext, forwardRef,
|
|
1
|
+
import { createContext, forwardRef, useState, useContext, useRef, useMemo, isValidElement, useEffect } from 'react';
|
|
2
2
|
import { View, TextInput, Pressable, Text, ScrollView } from 'react-native-css/components';
|
|
3
3
|
import { useNativeVariable } from 'react-native-css';
|
|
4
4
|
import { CaretDownIcon } from 'phosphor-react-native/src/icons/CaretDown';
|
package/dist/tabs.d.ts
CHANGED
|
@@ -4,12 +4,15 @@ declare const TAB_ORIENTATIONS: readonly ["horizontal", "vertical"];
|
|
|
4
4
|
type TabOrientation = (typeof TAB_ORIENTATIONS)[number];
|
|
5
5
|
declare const TAB_SIZES: readonly ["sm", "md"];
|
|
6
6
|
type TabSize = (typeof TAB_SIZES)[number];
|
|
7
|
-
declare const HORIZONTAL_TAB_TYPES: readonly ["button-brand", "button-gray", "button-border", "button-minimal", "underline"];
|
|
7
|
+
declare const HORIZONTAL_TAB_TYPES: readonly ["button-brand", "button-gray", "button-border", "button-minimal", "button-pill", "underline"];
|
|
8
8
|
/** `line` = vertical underline (icon + label in a row). `line-stacked` = same chrome, icon above label. */
|
|
9
9
|
declare const VERTICAL_TAB_TYPES: readonly ["button-brand", "button-gray", "button-border", "button-minimal", "line", "line-stacked"];
|
|
10
10
|
type HorizontalTabType = (typeof HORIZONTAL_TAB_TYPES)[number];
|
|
11
11
|
type VerticalTabType = (typeof VERTICAL_TAB_TYPES)[number];
|
|
12
12
|
type TabType = HorizontalTabType | VerticalTabType;
|
|
13
|
+
/** Fill color for `button-pill` only — maps to solid indicator + selected label. */
|
|
14
|
+
declare const PILL_TAB_COLORS: readonly ["brand", "primary"];
|
|
15
|
+
type PillTabColor = (typeof PILL_TAB_COLORS)[number];
|
|
13
16
|
|
|
14
17
|
declare const TabsRoot: FC<{
|
|
15
18
|
children?: ReactNode;
|
|
@@ -23,6 +26,18 @@ declare const TabList: FC<{
|
|
|
23
26
|
children?: ReactNode;
|
|
24
27
|
size?: TabSize;
|
|
25
28
|
type?: TabType;
|
|
29
|
+
/** `button-pill` only — indicator fill. Ignored for other types. */
|
|
30
|
+
color?: PillTabColor;
|
|
31
|
+
/**
|
|
32
|
+
* Traveling underline / line border for `underline`, `line`, and `line-stacked`.
|
|
33
|
+
* Defaults to `true`. Ignored for button types (`button-pill` always travels).
|
|
34
|
+
*/
|
|
35
|
+
travel?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* `button-pill` only — inactive tabs use the same border as Button `secondary`
|
|
38
|
+
* (`border-solid border-primary`). Ignored for every other type. Defaults to `false`.
|
|
39
|
+
*/
|
|
40
|
+
stroke?: boolean;
|
|
26
41
|
fullWidth?: boolean;
|
|
27
42
|
className?: string;
|
|
28
43
|
items?: TabItemProps[];
|
|
@@ -55,6 +70,18 @@ declare const Tabs: FC<{
|
|
|
55
70
|
children?: ReactNode;
|
|
56
71
|
size?: TabSize;
|
|
57
72
|
type?: TabType;
|
|
73
|
+
/** `button-pill` only — indicator fill. Ignored for other types. */
|
|
74
|
+
color?: PillTabColor;
|
|
75
|
+
/**
|
|
76
|
+
* Traveling underline / line border for `underline`, `line`, and `line-stacked`.
|
|
77
|
+
* Defaults to `true`. Ignored for button types (`button-pill` always travels).
|
|
78
|
+
*/
|
|
79
|
+
travel?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* `button-pill` only — inactive tabs use the same border as Button `secondary`
|
|
82
|
+
* (`border-solid border-primary`). Ignored for every other type. Defaults to `false`.
|
|
83
|
+
*/
|
|
84
|
+
stroke?: boolean;
|
|
58
85
|
fullWidth?: boolean;
|
|
59
86
|
className?: string;
|
|
60
87
|
items?: TabItemProps[];
|
|
@@ -67,4 +94,4 @@ declare const Tabs: FC<{
|
|
|
67
94
|
}>;
|
|
68
95
|
};
|
|
69
96
|
|
|
70
|
-
export { Tab, type TabItemProps, TabList, type TabOrientation, TabPanel, type TabSize, type TabType, Tabs, TabsRoot };
|
|
97
|
+
export { type PillTabColor, Tab, type TabItemProps, TabList, type TabOrientation, TabPanel, type TabSize, type TabType, Tabs, TabsRoot };
|
package/dist/tabs.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { createContext, useState, useMemo, useContext } from 'react';
|
|
2
|
-
import { ScrollView } from 'react-native';
|
|
1
|
+
import { createContext, useState, useMemo, useContext, useCallback, useRef, useEffect } from 'react';
|
|
2
|
+
import { StyleSheet, ScrollView } from 'react-native';
|
|
3
3
|
import { View, Pressable, Text } from 'react-native-css/components';
|
|
4
4
|
import { useNativeVariable } from 'react-native-css';
|
|
5
|
+
import Animated, { Easing, useSharedValue, withTiming, useAnimatedStyle } from 'react-native-reanimated';
|
|
5
6
|
import { extendTailwindMerge } from 'tailwind-merge';
|
|
6
7
|
import Svg from 'react-native-svg';
|
|
7
8
|
import 'phosphor-react-native/src/icons/X';
|
|
@@ -36,6 +37,23 @@ var isReactComponent = (component) => {
|
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
// ../core/src/tabs.ts
|
|
40
|
+
function isLineTabType(type) {
|
|
41
|
+
return type === "underline" || type === "line" || type === "line-stacked";
|
|
42
|
+
}
|
|
43
|
+
var pillTabColorStyles = {
|
|
44
|
+
brand: {
|
|
45
|
+
indicator: "bg-brand-solid",
|
|
46
|
+
selected: "text-primary_on-brand *:data-icon:text-primary_on-brand",
|
|
47
|
+
nativeSelected: "rounded-full bg-brand-solid",
|
|
48
|
+
nativeLabel: "text-primary_on-brand"
|
|
49
|
+
},
|
|
50
|
+
primary: {
|
|
51
|
+
indicator: "bg-primary-solid",
|
|
52
|
+
selected: "text-fg-white *:data-icon:text-fg-white",
|
|
53
|
+
nativeSelected: "rounded-full bg-primary-solid",
|
|
54
|
+
nativeLabel: "text-fg-white"
|
|
55
|
+
}
|
|
56
|
+
};
|
|
39
57
|
var tabSizes = {
|
|
40
58
|
sm: {
|
|
41
59
|
base: "text-sm font-semibold gap-1 *:data-icon:size-4",
|
|
@@ -43,6 +61,8 @@ var tabSizes = {
|
|
|
43
61
|
"button-gray": "py-2 px-2.5",
|
|
44
62
|
"button-border": "py-2 px-2.5",
|
|
45
63
|
"button-minimal": "py-2 px-2.5",
|
|
64
|
+
// Match legacy Avenue UI pill: h-9 + px-4.
|
|
65
|
+
"button-pill": "h-9 rounded-full px-4 py-0",
|
|
46
66
|
underline: "px-0.5 pb-2.5 pt-0",
|
|
47
67
|
line: "pl-2.5 pr-3 py-0.5",
|
|
48
68
|
// Vertical underline + stacked: pl-5 / pr-3, icon size-5.
|
|
@@ -55,6 +75,7 @@ var tabSizes = {
|
|
|
55
75
|
"button-gray": "py-2.5 px-2.5",
|
|
56
76
|
"button-border": "py-2.5 px-2.5",
|
|
57
77
|
"button-minimal": "py-2.5 px-2.5",
|
|
78
|
+
"button-pill": "h-10 rounded-full px-4 py-0",
|
|
58
79
|
underline: "px-0.5 pb-2.5 pt-0",
|
|
59
80
|
line: "pr-3.5 pl-3 py-1",
|
|
60
81
|
"line-stacked": "gap-1.5 py-2 pr-3 pl-5 text-sm font-medium *:data-icon:size-5",
|
|
@@ -67,6 +88,7 @@ function tabListStyles({ size, fullWidth }) {
|
|
|
67
88
|
"button-gray": "gap-1",
|
|
68
89
|
"button-border": cx("gap-1 rounded-[10px] bg-secondary_alt p-1 ring-1 ring-secondary ring-inset", size === "md" && "rounded-xl p-1.5"),
|
|
69
90
|
"button-minimal": "gap-0.5 rounded-lg bg-secondary_alt ring-1 ring-inset ring-secondary",
|
|
91
|
+
"button-pill": "relative items-center gap-1",
|
|
70
92
|
underline: cx("gap-3", fullWidth && "w-full gap-4"),
|
|
71
93
|
line: "gap-2",
|
|
72
94
|
"line-stacked": "gap-1"
|
|
@@ -87,11 +109,13 @@ var tabsStyles = {
|
|
|
87
109
|
labelRow: "flex-row items-center gap-1.5",
|
|
88
110
|
labelStacked: "w-full min-w-0",
|
|
89
111
|
iconStacked: "relative size-5 shrink-0 items-center justify-center overflow-visible",
|
|
90
|
-
badgeStacked: "absolute top-0 right-0 z-10 -translate-y-1/2 translate-x-1/2"
|
|
91
|
-
}
|
|
92
|
-
|
|
112
|
+
badgeStacked: "absolute top-0 right-0 z-10 -translate-y-1/2 translate-x-1/2"};
|
|
113
|
+
function tabNativeItemState(type, selected, options = {}) {
|
|
114
|
+
const travel = options.travel !== false;
|
|
115
|
+
const stroke = options.stroke === true;
|
|
93
116
|
if (!selected) {
|
|
94
117
|
if (type === "underline" || type === "line" || type === "line-stacked") return "border-transparent";
|
|
118
|
+
if (type === "button-pill" && stroke) return "rounded-full border border-solid border-primary";
|
|
95
119
|
return "";
|
|
96
120
|
}
|
|
97
121
|
switch (type) {
|
|
@@ -103,11 +127,13 @@ function tabNativeItemState(type, selected) {
|
|
|
103
127
|
return "bg-primary_alt";
|
|
104
128
|
case "button-minimal":
|
|
105
129
|
return "rounded-lg bg-primary_alt border border-primary";
|
|
130
|
+
case "button-pill":
|
|
131
|
+
return stroke ? "rounded-full border border-solid border-transparent" : "rounded-full";
|
|
106
132
|
case "underline":
|
|
107
|
-
return "rounded-none border-b-2 border-fg-brand-primary_alt";
|
|
133
|
+
return travel ? "rounded-none border-b-2 border-transparent" : "rounded-none border-b-2 border-fg-brand-primary_alt";
|
|
108
134
|
case "line":
|
|
109
135
|
case "line-stacked":
|
|
110
|
-
return "rounded-none border-l-2 border-fg-brand-primary_alt";
|
|
136
|
+
return travel ? "rounded-none border-l-2 border-transparent" : "rounded-none border-l-2 border-fg-brand-primary_alt";
|
|
111
137
|
default: {
|
|
112
138
|
const _exhaustive = type;
|
|
113
139
|
return _exhaustive;
|
|
@@ -116,12 +142,15 @@ function tabNativeItemState(type, selected) {
|
|
|
116
142
|
}
|
|
117
143
|
function tabNativeLabelState(type, selected) {
|
|
118
144
|
if (!selected) {
|
|
145
|
+
if (type === "button-pill") return "text-primary";
|
|
119
146
|
if (type === "button-brand") return "text-secondary";
|
|
120
147
|
return "text-quaternary";
|
|
121
148
|
}
|
|
122
149
|
switch (type) {
|
|
123
150
|
case "button-brand":
|
|
124
151
|
return "text-primary";
|
|
152
|
+
case "button-pill":
|
|
153
|
+
return pillTabColorStyles.brand.nativeLabel;
|
|
125
154
|
case "button-gray":
|
|
126
155
|
case "button-border":
|
|
127
156
|
case "button-minimal":
|
|
@@ -293,10 +322,15 @@ var Badge = ({
|
|
|
293
322
|
const colorRoot = colors.styles[color].root;
|
|
294
323
|
return /* @__PURE__ */ jsx(View, { className: cx(colors.common, resolveBadgeSizeClass(type, size), colorRoot, className), children: /* @__PURE__ */ jsx(BadgeLabel, { size, colorClass: colorRoot, children }) });
|
|
295
324
|
};
|
|
325
|
+
var PILL_EASE = Easing.bezier(0, 0.55, 0.45, 1);
|
|
326
|
+
var PILL_MS = 300;
|
|
296
327
|
var TabsContext = createContext(void 0);
|
|
297
328
|
var TabListContext = createContext({
|
|
298
329
|
size: "sm",
|
|
299
330
|
type: "button-brand",
|
|
331
|
+
color: "brand",
|
|
332
|
+
travel: true,
|
|
333
|
+
stroke: false,
|
|
300
334
|
orientation: "horizontal"
|
|
301
335
|
});
|
|
302
336
|
var TabsRoot = ({ children, selectedKey, defaultSelectedKey, onSelectionChange, orientation = "horizontal", className }) => {
|
|
@@ -312,9 +346,108 @@ var TabsRoot = ({ children, selectedKey, defaultSelectedKey, onSelectionChange,
|
|
|
312
346
|
);
|
|
313
347
|
return /* @__PURE__ */ jsx(TabsContext.Provider, { value, children: /* @__PURE__ */ jsx(View, { className: cx(orientation === "vertical" ? tabsStyles.rootVertical : tabsStyles.root, className), children }) });
|
|
314
348
|
};
|
|
315
|
-
var TabList = ({
|
|
349
|
+
var TabList = ({
|
|
350
|
+
children,
|
|
351
|
+
size = "sm",
|
|
352
|
+
type = "button-brand",
|
|
353
|
+
color = "brand",
|
|
354
|
+
travel = true,
|
|
355
|
+
stroke = false,
|
|
356
|
+
fullWidth,
|
|
357
|
+
className,
|
|
358
|
+
items
|
|
359
|
+
}) => {
|
|
316
360
|
const tabs = useContext(TabsContext);
|
|
317
361
|
const orientation = tabs?.orientation ?? "horizontal";
|
|
362
|
+
const isPill = type === "button-pill";
|
|
363
|
+
const isLine = isLineTabType(type);
|
|
364
|
+
const isVerticalLine = type === "line" || type === "line-stacked";
|
|
365
|
+
const useTravelIndicator = isPill || isLine && travel;
|
|
366
|
+
const selectedKey = tabs?.selectedKey;
|
|
367
|
+
const brandSolid = useNativeVariable("--color-bg-brand-solid") ?? "#7c3aed";
|
|
368
|
+
const primarySolid = useNativeVariable("--color-bg-primary-solid") ?? "#171717";
|
|
369
|
+
const brandLine = useNativeVariable("--color-fg-brand-primary_alt") ?? "#9e77ed";
|
|
370
|
+
const layoutsRef = useRef(/* @__PURE__ */ new Map());
|
|
371
|
+
const hasPlacedRef = useRef(false);
|
|
372
|
+
const indicatorX = useSharedValue(0);
|
|
373
|
+
const indicatorY = useSharedValue(0);
|
|
374
|
+
const indicatorW = useSharedValue(0);
|
|
375
|
+
const indicatorH = useSharedValue(0);
|
|
376
|
+
const indicatorOpacity = useSharedValue(0);
|
|
377
|
+
const moveIndicator = useCallback(
|
|
378
|
+
(key, animate) => {
|
|
379
|
+
if (!key) return;
|
|
380
|
+
const layout = layoutsRef.current.get(key);
|
|
381
|
+
if (!layout || layout.width <= 0 || layout.height <= 0) return;
|
|
382
|
+
const cfg = { duration: PILL_MS, easing: PILL_EASE };
|
|
383
|
+
let nextX = layout.x;
|
|
384
|
+
let nextY = layout.y;
|
|
385
|
+
let nextW = layout.width;
|
|
386
|
+
let nextH = layout.height;
|
|
387
|
+
if (isLine && !isPill) {
|
|
388
|
+
if (isVerticalLine) {
|
|
389
|
+
nextX = layout.x;
|
|
390
|
+
nextY = layout.y;
|
|
391
|
+
nextW = 2;
|
|
392
|
+
nextH = layout.height;
|
|
393
|
+
} else {
|
|
394
|
+
nextX = layout.x;
|
|
395
|
+
nextY = layout.y + Math.max(layout.height - 2, 0);
|
|
396
|
+
nextW = layout.width;
|
|
397
|
+
nextH = 2;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (animate && hasPlacedRef.current) {
|
|
401
|
+
indicatorX.value = withTiming(nextX, cfg);
|
|
402
|
+
indicatorY.value = withTiming(nextY, cfg);
|
|
403
|
+
indicatorW.value = withTiming(nextW, cfg);
|
|
404
|
+
indicatorH.value = withTiming(nextH, cfg);
|
|
405
|
+
} else {
|
|
406
|
+
indicatorX.value = nextX;
|
|
407
|
+
indicatorY.value = nextY;
|
|
408
|
+
indicatorW.value = nextW;
|
|
409
|
+
indicatorH.value = nextH;
|
|
410
|
+
hasPlacedRef.current = true;
|
|
411
|
+
}
|
|
412
|
+
indicatorOpacity.value = 1;
|
|
413
|
+
},
|
|
414
|
+
[indicatorH, indicatorOpacity, indicatorW, indicatorX, indicatorY, isLine, isPill, isVerticalLine]
|
|
415
|
+
);
|
|
416
|
+
const registerTravelLayout = useCallback(
|
|
417
|
+
(id, layout) => {
|
|
418
|
+
layoutsRef.current.set(id, layout);
|
|
419
|
+
if (id === selectedKey) {
|
|
420
|
+
moveIndicator(id, hasPlacedRef.current);
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
[moveIndicator, selectedKey]
|
|
424
|
+
);
|
|
425
|
+
useEffect(() => {
|
|
426
|
+
if (!useTravelIndicator) return;
|
|
427
|
+
moveIndicator(selectedKey, true);
|
|
428
|
+
}, [useTravelIndicator, selectedKey, moveIndicator]);
|
|
429
|
+
const indicatorStyle = useAnimatedStyle(() => ({
|
|
430
|
+
opacity: indicatorOpacity.value,
|
|
431
|
+
width: indicatorW.value,
|
|
432
|
+
height: indicatorH.value,
|
|
433
|
+
transform: [{ translateX: indicatorX.value }, { translateY: indicatorY.value }]
|
|
434
|
+
}));
|
|
435
|
+
const indicatorColor = isPill ? color === "primary" ? primarySolid : brandSolid : brandLine;
|
|
436
|
+
const travelIndicator = useTravelIndicator ? /* @__PURE__ */ jsx(
|
|
437
|
+
Animated.View,
|
|
438
|
+
{
|
|
439
|
+
pointerEvents: "none",
|
|
440
|
+
style: [
|
|
441
|
+
styles.indicatorBase,
|
|
442
|
+
{
|
|
443
|
+
backgroundColor: indicatorColor,
|
|
444
|
+
borderRadius: isPill ? 9999 : 0,
|
|
445
|
+
zIndex: isPill ? 0 : 1
|
|
446
|
+
},
|
|
447
|
+
indicatorStyle
|
|
448
|
+
]
|
|
449
|
+
}
|
|
450
|
+
) : null;
|
|
318
451
|
const list = /* @__PURE__ */ jsxs(
|
|
319
452
|
View,
|
|
320
453
|
{
|
|
@@ -322,42 +455,83 @@ var TabList = ({ children, size = "sm", type = "button-brand", fullWidth, classN
|
|
|
322
455
|
orientation === "vertical" ? tabsStyles.listVertical : tabsStyles.list,
|
|
323
456
|
type === "button-border" ? cx(tabsStyles.listButtonBorder, size === "md" && tabsStyles.listButtonBorderMd) : type === "button-minimal" ? tabsStyles.listButtonMinimal : tabListStyles({ size, fullWidth })[type],
|
|
324
457
|
orientation === "horizontal" && type === "underline" && "relative",
|
|
458
|
+
useTravelIndicator && "relative",
|
|
325
459
|
fullWidth && "w-full",
|
|
326
460
|
className
|
|
327
461
|
),
|
|
462
|
+
style: useTravelIndicator ? styles.listTravel : void 0,
|
|
328
463
|
children: [
|
|
329
464
|
orientation === "horizontal" && type === "underline" && /* @__PURE__ */ jsx(View, { className: "absolute right-0 bottom-0 left-0 h-px bg-border-secondary" }),
|
|
330
|
-
|
|
465
|
+
isPill && travelIndicator,
|
|
466
|
+
children ?? items?.map((item) => /* @__PURE__ */ jsx(Tab, { ...item }, item.id)),
|
|
467
|
+
!isPill && travelIndicator
|
|
331
468
|
]
|
|
332
469
|
}
|
|
333
470
|
);
|
|
334
|
-
return /* @__PURE__ */ jsx(
|
|
471
|
+
return /* @__PURE__ */ jsx(
|
|
472
|
+
TabListContext.Provider,
|
|
473
|
+
{
|
|
474
|
+
value: {
|
|
475
|
+
size,
|
|
476
|
+
type,
|
|
477
|
+
color,
|
|
478
|
+
travel,
|
|
479
|
+
stroke,
|
|
480
|
+
fullWidth,
|
|
481
|
+
orientation,
|
|
482
|
+
registerTravelLayout: useTravelIndicator ? registerTravelLayout : void 0
|
|
483
|
+
},
|
|
484
|
+
children: orientation === "horizontal" ? /* @__PURE__ */ jsx(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, contentContainerClassName: fullWidth ? "grow" : void 0, children: list }) : list
|
|
485
|
+
}
|
|
486
|
+
);
|
|
335
487
|
};
|
|
336
488
|
var Tab = ({ id, label, children, badge, icon: Icon }) => {
|
|
337
489
|
const tabs = useContext(TabsContext);
|
|
338
|
-
const { size, type, fullWidth, orientation } = useContext(TabListContext);
|
|
490
|
+
const { size, type, color, travel, stroke, fullWidth, orientation, registerTravelLayout } = useContext(TabListContext);
|
|
339
491
|
const selected = tabs?.selectedKey === id;
|
|
340
492
|
const isLineChrome = type === "line" || type === "line-stacked";
|
|
341
493
|
const isStacked = type === "line-stacked";
|
|
342
|
-
const
|
|
494
|
+
const isPill = type === "button-pill";
|
|
495
|
+
const showPill = type === "underline" || isLineChrome || type === "button-brand" || isPill;
|
|
343
496
|
const fg = useNativeVariable(selected ? "--color-fg-primary" : "--color-fg-quaternary") ?? "#717680";
|
|
344
497
|
const brand = useNativeVariable("--color-fg-brand-secondary") ?? "#6941c6";
|
|
498
|
+
const fgPrimary = useNativeVariable("--color-fg-primary") ?? "#181d27";
|
|
345
499
|
const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#717680";
|
|
346
|
-
const
|
|
500
|
+
const onBrand = useNativeVariable("--color-text-primary_on-brand") ?? "#ffffff";
|
|
501
|
+
const fgWhite = useNativeVariable("--color-fg-white") ?? "#ffffff";
|
|
502
|
+
const iconColor = isPill ? selected ? color === "primary" ? fgWhite : onBrand : fgPrimary : selected && (type === "underline" || isLineChrome) ? brand : selected ? fg : fgQuaternary;
|
|
503
|
+
const onLayout = useCallback(
|
|
504
|
+
(event) => {
|
|
505
|
+
if (!registerTravelLayout) return;
|
|
506
|
+
const { x, y, width, height } = event.nativeEvent.layout;
|
|
507
|
+
if (width <= 0 || height <= 0) return;
|
|
508
|
+
registerTravelLayout(id, { x, y, width, height });
|
|
509
|
+
},
|
|
510
|
+
[id, registerTravelLayout]
|
|
511
|
+
);
|
|
347
512
|
return /* @__PURE__ */ jsxs(
|
|
348
513
|
Pressable,
|
|
349
514
|
{
|
|
350
515
|
accessibilityRole: "tab",
|
|
351
516
|
accessibilityState: { selected },
|
|
352
517
|
onPress: () => tabs?.setSelectedKey(id),
|
|
353
|
-
|
|
518
|
+
onLayout,
|
|
519
|
+
style: ({ pressed }) => [
|
|
520
|
+
orientation === "horizontal" ? { flexShrink: 0, zIndex: 1 } : { zIndex: 1 },
|
|
521
|
+
isPill && {
|
|
522
|
+
transform: [{ scale: pressed ? 0.98 : 1 }]
|
|
523
|
+
}
|
|
524
|
+
],
|
|
354
525
|
className: cx(
|
|
355
526
|
tabsStyles.item,
|
|
356
527
|
orientation === "vertical" && tabsStyles.itemVertical,
|
|
357
528
|
isStacked && tabsStyles.itemStacked,
|
|
358
529
|
fullWidth && orientation === "vertical" && tabsStyles.itemFull,
|
|
359
530
|
tabSizes[size][type],
|
|
360
|
-
tabNativeItemState(type, selected
|
|
531
|
+
tabNativeItemState(type, selected, {
|
|
532
|
+
travel: isLineTabType(type) ? travel : void 0,
|
|
533
|
+
stroke: isPill ? stroke : void 0
|
|
534
|
+
})
|
|
361
535
|
),
|
|
362
536
|
children: [
|
|
363
537
|
isStacked && isReactComponent(Icon) && /* @__PURE__ */ jsxs(View, { className: tabsStyles.iconStacked, children: [
|
|
@@ -365,7 +539,7 @@ var Tab = ({ id, label, children, badge, icon: Icon }) => {
|
|
|
365
539
|
badge != null && /* @__PURE__ */ jsx(View, { className: tabsStyles.badgeStacked, children: /* @__PURE__ */ jsx(Badge, { size: "sm", type: showPill ? "pill-color" : "modern", color: showPill && selected ? "brand" : "gray", children: badge }) })
|
|
366
540
|
] }),
|
|
367
541
|
!isStacked && isReactComponent(Icon) && /* @__PURE__ */ jsx(Icon, { size: tabSizes[size].icon, color: iconColor }),
|
|
368
|
-
/* @__PURE__ */ jsxs(View, { className: cx(isStacked ? tabsStyles.labelStacked : tabsStyles.labelRow, !isLineChrome && "px-0.5"), children: [
|
|
542
|
+
/* @__PURE__ */ jsxs(View, { className: cx(isStacked ? tabsStyles.labelStacked : tabsStyles.labelRow, !isLineChrome && type !== "underline" && "px-0.5"), children: [
|
|
369
543
|
/* @__PURE__ */ jsx(
|
|
370
544
|
Text,
|
|
371
545
|
{
|
|
@@ -373,7 +547,7 @@ var Tab = ({ id, label, children, badge, icon: Icon }) => {
|
|
|
373
547
|
className: cx(
|
|
374
548
|
isStacked ? "text-sm font-medium" : size === "sm" ? "text-sm font-semibold" : "text-md font-semibold",
|
|
375
549
|
isStacked && "text-left",
|
|
376
|
-
tabNativeLabelState(type, selected)
|
|
550
|
+
isPill && selected ? pillTabColorStyles[color].nativeLabel : tabNativeLabelState(type, selected)
|
|
377
551
|
),
|
|
378
552
|
children: children || label
|
|
379
553
|
}
|
|
@@ -394,6 +568,16 @@ var Tabs = Object.assign(TabsRoot, {
|
|
|
394
568
|
Item: Tab,
|
|
395
569
|
Panel: TabPanel
|
|
396
570
|
});
|
|
571
|
+
var styles = StyleSheet.create({
|
|
572
|
+
listTravel: {
|
|
573
|
+
overflow: "visible"
|
|
574
|
+
},
|
|
575
|
+
indicatorBase: {
|
|
576
|
+
position: "absolute",
|
|
577
|
+
top: 0,
|
|
578
|
+
left: 0
|
|
579
|
+
}
|
|
580
|
+
});
|
|
397
581
|
|
|
398
582
|
export { Tab, TabList, TabPanel, Tabs, TabsRoot };
|
|
399
583
|
//# sourceMappingURL=tabs.js.map
|