@btndprojects/loam-ui-native 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/dist/accordion/index.js +3 -0
- package/dist/adaptive/index.js +2 -0
- package/dist/alert/index.js +3 -0
- package/dist/analyzer/index.js +6 -0
- package/dist/announcement/index.js +6 -0
- package/dist/audio-player/index.js +3 -0
- package/dist/avatar/index.js +3 -0
- package/dist/avatar-group/index.js +3 -0
- package/dist/badge/index.js +5 -0
- package/dist/banner/index.js +2 -0
- package/dist/board/index.js +7 -0
- package/dist/button/index.js +5 -0
- package/dist/camera-permission/index.js +13 -0
- package/dist/capture-result/index.js +18 -0
- package/dist/card/index.js +4 -0
- package/dist/card-form/index.js +10 -0
- package/dist/carousel/index.js +2 -0
- package/dist/chart/index.js +6 -0
- package/dist/charts/index.js +7 -0
- package/dist/checkbox/index.js +7 -0
- package/dist/checklist/index.js +10 -0
- package/dist/checkout/index.js +13 -0
- package/dist/chip/index.js +7 -0
- package/dist/chunk-223Q2T2Q.js +229 -0
- package/dist/chunk-2A5NIQAK.js +254 -0
- package/dist/chunk-2GK6PHGE.js +363 -0
- package/dist/chunk-2WUTXHMU.js +1 -0
- package/dist/chunk-2ZZ7TDJ4.js +324 -0
- package/dist/chunk-35OFI3JG.js +499 -0
- package/dist/chunk-3ARE4TES.js +195 -0
- package/dist/chunk-3ECPOSKO.js +1 -0
- package/dist/chunk-3ENTMPQY.js +229 -0
- package/dist/chunk-3HJH6FF4.js +98 -0
- package/dist/chunk-3NMD74ZU.js +4 -0
- package/dist/chunk-3WPW4KUN.js +182 -0
- package/dist/chunk-47FWHGUN.js +394 -0
- package/dist/chunk-4BXMXBJO.js +141 -0
- package/dist/chunk-4DS5ZWVC.js +83 -0
- package/dist/chunk-4GBOGOTV.js +295 -0
- package/dist/chunk-4SZYY6AN.js +99 -0
- package/dist/chunk-4YIP3CWS.js +237 -0
- package/dist/chunk-4YQOR7JM.js +204 -0
- package/dist/chunk-4ZAHCY44.js +177 -0
- package/dist/chunk-52X2VYTD.js +228 -0
- package/dist/chunk-5P26LBDL.js +1 -0
- package/dist/chunk-5XLRYDAX.js +1 -0
- package/dist/chunk-5YNTNN5A.js +177 -0
- package/dist/chunk-66SG2H23.js +129 -0
- package/dist/chunk-6HT2LP62.js +504 -0
- package/dist/chunk-6N33LFQA.js +35 -0
- package/dist/chunk-6X6PQ443.js +432 -0
- package/dist/chunk-7CFF4HXS.js +126 -0
- package/dist/chunk-7O2FMUPT.js +755 -0
- package/dist/chunk-AI4DWZCD.js +162 -0
- package/dist/chunk-AWJOCGFZ.js +213 -0
- package/dist/chunk-AZRX6SAC.js +285 -0
- package/dist/chunk-B54QE2FN.js +1 -0
- package/dist/chunk-BC475SJH.js +1 -0
- package/dist/chunk-BEDBFJND.js +202 -0
- package/dist/chunk-BTTFCMKG.js +166 -0
- package/dist/chunk-BV3B2HYZ.js +1635 -0
- package/dist/chunk-C2NTXVWM.js +98 -0
- package/dist/chunk-CDRZHT42.js +424 -0
- package/dist/chunk-CJ5EOYZE.js +62 -0
- package/dist/chunk-CUMUNPXY.js +128 -0
- package/dist/chunk-CUS3ZSCU.js +1 -0
- package/dist/chunk-CYRBHQQZ.js +411 -0
- package/dist/chunk-DHWADYZX.js +144 -0
- package/dist/chunk-DKCSPATL.js +1 -0
- package/dist/chunk-DM5QUKKO.js +326 -0
- package/dist/chunk-DSJBXLUG.js +845 -0
- package/dist/chunk-DYBH2I6W.js +1 -0
- package/dist/chunk-DZ255O2F.js +1 -0
- package/dist/chunk-E35BPSGW.js +1 -0
- package/dist/chunk-EJBDRVIH.js +166 -0
- package/dist/chunk-F43NP42L.js +1 -0
- package/dist/chunk-F5XNPWS7.js +1024 -0
- package/dist/chunk-FIF2M24N.js +1521 -0
- package/dist/chunk-FOKG57CR.js +993 -0
- package/dist/chunk-G3HOYSF7.js +1 -0
- package/dist/chunk-GDKZTW34.js +395 -0
- package/dist/chunk-GL7B2DOW.js +134 -0
- package/dist/chunk-GNNJ4GCC.js +471 -0
- package/dist/chunk-GNZ56EUI.js +1 -0
- package/dist/chunk-H6NIOQHK.js +346 -0
- package/dist/chunk-H6PC7RDA.js +1 -0
- package/dist/chunk-HPPW424V.js +334 -0
- package/dist/chunk-HQOQIBJI.js +1 -0
- package/dist/chunk-HU2EQNRZ.js +44 -0
- package/dist/chunk-IIQTAY3J.js +715 -0
- package/dist/chunk-ITTYJZWX.js +271 -0
- package/dist/chunk-IVNRBPGC.js +1018 -0
- package/dist/chunk-J4KLDGI4.js +1 -0
- package/dist/chunk-J7Q7VCVC.js +254 -0
- package/dist/chunk-JDEOITQ2.js +1 -0
- package/dist/chunk-JNH2TYIN.js +96 -0
- package/dist/chunk-JRLTGLN4.js +1 -0
- package/dist/chunk-JTRJJLKL.js +1 -0
- package/dist/chunk-JUAMLEHX.js +379 -0
- package/dist/chunk-JXJB2X6M.js +131 -0
- package/dist/chunk-KMI5ML5I.js +262 -0
- package/dist/chunk-KTAC4MGE.js +4 -0
- package/dist/chunk-LAECSR4H.js +178 -0
- package/dist/chunk-LK4BCSGX.js +1 -0
- package/dist/chunk-LOE5YNN3.js +470 -0
- package/dist/chunk-LRJNDEIA.js +302 -0
- package/dist/chunk-LSS54GLJ.js +116 -0
- package/dist/chunk-LZLHELAG.js +137 -0
- package/dist/chunk-M2LUXGKZ.js +1 -0
- package/dist/chunk-MOUJOP55.js +425 -0
- package/dist/chunk-N32RGOA5.js +159 -0
- package/dist/chunk-N5ZNE2YE.js +1 -0
- package/dist/chunk-NBNCBML6.js +1 -0
- package/dist/chunk-NKB7BZYK.js +167 -0
- package/dist/chunk-NQYBUO3K.js +1795 -0
- package/dist/chunk-NY2U3PBI.js +59 -0
- package/dist/chunk-O4AEHWII.js +464 -0
- package/dist/chunk-O7AE6DAF.js +146 -0
- package/dist/chunk-OETCUXQP.js +134 -0
- package/dist/chunk-OOPPQH27.js +179 -0
- package/dist/chunk-OPXFZ4Y5.js +204 -0
- package/dist/chunk-P23EQNRQ.js +338 -0
- package/dist/chunk-PJXUJYS6.js +248 -0
- package/dist/chunk-PNWUWOBF.js +1 -0
- package/dist/chunk-PUPM2YGF.js +376 -0
- package/dist/chunk-PZXZJBMP.js +620 -0
- package/dist/chunk-Q72LJOVE.js +169 -0
- package/dist/chunk-QCDXZBC5.js +247 -0
- package/dist/chunk-QDYDBCFP.js +197 -0
- package/dist/chunk-QJJ6MADV.js +274 -0
- package/dist/chunk-QKXCPTFS.js +349 -0
- package/dist/chunk-QWCMU5B2.js +860 -0
- package/dist/chunk-RGQWWKLA.js +634 -0
- package/dist/chunk-RIBDXGUG.js +108 -0
- package/dist/chunk-RJQOOHT2.js +214 -0
- package/dist/chunk-RNGLIHFA.js +191 -0
- package/dist/chunk-RQ3HASCC.js +6 -0
- package/dist/chunk-RSOJT5YW.js +124 -0
- package/dist/chunk-RTIKSY6A.js +1 -0
- package/dist/chunk-RUZHTGKB.js +237 -0
- package/dist/chunk-RW6ZL2FQ.js +284 -0
- package/dist/chunk-S7F6XLTK.js +540 -0
- package/dist/chunk-SBMNWWBV.js +155 -0
- package/dist/chunk-SDTQPRRB.js +1 -0
- package/dist/chunk-SYNOJOQO.js +377 -0
- package/dist/chunk-T753XT36.js +1 -0
- package/dist/chunk-TKQYWZ5V.js +196 -0
- package/dist/chunk-TKVFVF5D.js +95 -0
- package/dist/chunk-TOXAGRDQ.js +144 -0
- package/dist/chunk-TUTI5HOZ.js +112 -0
- package/dist/chunk-U7TFM2JA.js +140 -0
- package/dist/chunk-UC2WGUP3.js +627 -0
- package/dist/chunk-UWFLYMAR.js +1126 -0
- package/dist/chunk-UWSZB7BJ.js +1 -0
- package/dist/chunk-UYG5L34B.js +87 -0
- package/dist/chunk-VBOXAEPI.js +336 -0
- package/dist/chunk-VCDBXW5H.js +188 -0
- package/dist/chunk-VCXPHHDS.js +1 -0
- package/dist/chunk-VEAYTRPX.js +414 -0
- package/dist/chunk-VFCUIDRT.js +1 -0
- package/dist/chunk-VQHPQEUH.js +273 -0
- package/dist/chunk-VXDZFJGP.js +874 -0
- package/dist/chunk-WS56BL3D.js +1 -0
- package/dist/chunk-WSW6ZFAQ.js +98 -0
- package/dist/chunk-WVKKJA6U.js +870 -0
- package/dist/chunk-XNUVB5OL.js +375 -0
- package/dist/chunk-XOSCY2CW.js +242 -0
- package/dist/chunk-XXXEFXY5.js +99 -0
- package/dist/chunk-Y5CSSPV4.js +1 -0
- package/dist/chunk-Y6DU4J47.js +1 -0
- package/dist/chunk-YC6WORFL.js +535 -0
- package/dist/chunk-YDGVJETP.js +60 -0
- package/dist/chunk-YF4NSSMT.js +366 -0
- package/dist/chunk-YG3ZJHGU.js +223 -0
- package/dist/chunk-YIJ55TBC.js +1 -0
- package/dist/chunk-YKZ4RZZF.js +1 -0
- package/dist/chunk-YLLCXTMC.js +37 -0
- package/dist/chunk-YTA74UZR.js +1 -0
- package/dist/chunk-Z7H7VSFZ.js +323 -0
- package/dist/chunk-ZK2H4O5P.js +1 -0
- package/dist/chunk-ZVFE5QGU.js +524 -0
- package/dist/coachmark/index.js +4 -0
- package/dist/code-block/index.js +4 -0
- package/dist/color-field/index.js +7 -0
- package/dist/commerce/index.js +20 -0
- package/dist/connectivity/index.js +2 -0
- package/dist/context-menu/index.js +5 -0
- package/dist/copy-button/index.js +3 -0
- package/dist/data-grid/index.js +24 -0
- package/dist/date-range-picker/index.js +13 -0
- package/dist/description-list/index.js +2 -0
- package/dist/dialog/index.js +3 -0
- package/dist/empty-state/index.js +3 -0
- package/dist/error-summary/index.js +3 -0
- package/dist/fab/index.js +2 -0
- package/dist/file-upload/index.js +9 -0
- package/dist/filter-bar/index.js +8 -0
- package/dist/flow-run/index.js +14 -0
- package/dist/form/index.js +3 -0
- package/dist/gallery/index.js +2 -0
- package/dist/header/index.js +5 -0
- package/dist/hold-to-confirm/index.js +4 -0
- package/dist/index.d.ts +22883 -0
- package/dist/index.js +158 -0
- package/dist/infinite-list/index.js +2 -0
- package/dist/inline-edit/index.js +5 -0
- package/dist/input/index.js +5 -0
- package/dist/interactions/index.js +2 -0
- package/dist/invoice/index.js +10 -0
- package/dist/kbd/index.js +1 -0
- package/dist/keyboard/index.js +3 -0
- package/dist/list-row/index.js +7 -0
- package/dist/log-viewer/index.js +2 -0
- package/dist/map-view/index.js +3 -0
- package/dist/markdown/index.js +6 -0
- package/dist/metric/index.js +4 -0
- package/dist/money/index.js +3 -0
- package/dist/nav-drawer/index.js +2 -0
- package/dist/navigation/index.js +2 -0
- package/dist/notification-center/index.js +16 -0
- package/dist/number-roll/index.js +3 -0
- package/dist/one-handed/index.js +5 -0
- package/dist/os-surfaces/index.js +3 -0
- package/dist/otp/index.js +7 -0
- package/dist/page-header/index.js +1 -0
- package/dist/payment-method/index.js +12 -0
- package/dist/payment-status/index.js +16 -0
- package/dist/permission/index.js +2 -0
- package/dist/picker/index.js +7 -0
- package/dist/progress/index.js +5 -0
- package/dist/pull-to-refresh/index.js +4 -0
- package/dist/radio-group/index.js +6 -0
- package/dist/rating/index.js +2 -0
- package/dist/receivables/index.js +20 -0
- package/dist/refund/index.js +16 -0
- package/dist/save-status/index.js +3 -0
- package/dist/scroll-area/index.js +1 -0
- package/dist/search-bar/index.js +5 -0
- package/dist/segmented-control/index.js +5 -0
- package/dist/sheet/index.js +4 -0
- package/dist/skeleton/index.js +2 -0
- package/dist/slider/index.js +5 -0
- package/dist/spinner/index.js +2 -0
- package/dist/split-button/index.js +7 -0
- package/dist/spotlight/index.js +2 -0
- package/dist/stage-timeline/index.js +4 -0
- package/dist/status-dot/index.js +2 -0
- package/dist/stepper/index.js +6 -0
- package/dist/streaming-text/index.js +3 -0
- package/dist/survey/index.js +19 -0
- package/dist/switch/index.js +5 -0
- package/dist/system-state/index.js +4 -0
- package/dist/tab-bar/index.js +2 -0
- package/dist/tabs/index.js +2 -0
- package/dist/textarea/index.js +6 -0
- package/dist/thinking/index.js +2 -0
- package/dist/timeline/index.js +4 -0
- package/dist/toast/index.js +2 -0
- package/dist/toolbar/index.js +2 -0
- package/dist/tour/index.js +11 -0
- package/dist/truncation-notice/index.js +2 -0
- package/dist/update-notice/index.js +11 -0
- package/dist/video-player/index.js +2 -0
- package/dist/viewfinder/index.js +5 -0
- package/dist/widget/index.js +4 -0
- package/dist/wizard/index.js +6 -0
- package/package.json +76 -3
- package/README.md +0 -3
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { Icon } from './chunk-TKVFVF5D.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Animated, Easing, View, ScrollView, Pressable, Text } from 'react-native';
|
|
4
|
+
import { createStyleSheet, useLoamTheme, useStyles } from '@btndprojects/loam-theme-native';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var CLOSE_ACTIONS = [{ name: "close", label: "Close" }];
|
|
8
|
+
function tabsRevealOffset(triggerX, triggerWidth, stripWidth, viewportWidth) {
|
|
9
|
+
const max = stripWidth - viewportWidth;
|
|
10
|
+
if (max <= 0) return 0;
|
|
11
|
+
return Math.min(Math.max(triggerX + triggerWidth / 2 - viewportWidth / 2, 0), max);
|
|
12
|
+
}
|
|
13
|
+
function Tabs({
|
|
14
|
+
items,
|
|
15
|
+
value,
|
|
16
|
+
defaultValue,
|
|
17
|
+
onValueChange,
|
|
18
|
+
variant = "underline",
|
|
19
|
+
size = "md",
|
|
20
|
+
onClose,
|
|
21
|
+
onAdd,
|
|
22
|
+
addLabel = "Add tab",
|
|
23
|
+
motion = "full"
|
|
24
|
+
}) {
|
|
25
|
+
const isControlled = value !== void 0;
|
|
26
|
+
const [internal, setInternal] = React.useState(
|
|
27
|
+
defaultValue ?? items[0]?.value
|
|
28
|
+
);
|
|
29
|
+
const current = isControlled ? value : internal;
|
|
30
|
+
const activeIndex = Math.max(
|
|
31
|
+
0,
|
|
32
|
+
items.findIndex((item) => item.value === current)
|
|
33
|
+
);
|
|
34
|
+
const activeItem = items[activeIndex];
|
|
35
|
+
const theme = useLoamTheme();
|
|
36
|
+
const { styles } = useStyles(sheet, { variant, size });
|
|
37
|
+
const iconSize = size === "sm" ? 16 : 18;
|
|
38
|
+
const closeIconSize = size === "sm" ? 14 : 16;
|
|
39
|
+
const [layouts, setLayouts] = React.useState({});
|
|
40
|
+
const onTriggerLayout = (index) => (e) => {
|
|
41
|
+
const { x, y, width, height } = e.nativeEvent.layout;
|
|
42
|
+
setLayouts((prev) => {
|
|
43
|
+
const p = prev[index];
|
|
44
|
+
if (p && p.x === x && p.y === y && p.width === width && p.height === height) return prev;
|
|
45
|
+
return { ...prev, [index]: { x, y, width, height } };
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
const active = layouts[activeIndex];
|
|
49
|
+
const indicatorX = React.useRef(new Animated.Value(0)).current;
|
|
50
|
+
const indicatorWidth = React.useRef(new Animated.Value(0)).current;
|
|
51
|
+
const measured = React.useRef(false);
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
if (!active) return;
|
|
54
|
+
if (!measured.current) {
|
|
55
|
+
indicatorX.setValue(active.x);
|
|
56
|
+
indicatorWidth.setValue(active.width);
|
|
57
|
+
measured.current = true;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (motion !== "full") {
|
|
61
|
+
indicatorX.setValue(active.x);
|
|
62
|
+
indicatorWidth.setValue(active.width);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const { duration, easing } = theme.motion.indicator;
|
|
66
|
+
Animated.parallel([
|
|
67
|
+
Animated.timing(indicatorX, {
|
|
68
|
+
toValue: active.x,
|
|
69
|
+
duration,
|
|
70
|
+
easing: Easing.bezier(easing[0], easing[1], easing[2], easing[3]),
|
|
71
|
+
useNativeDriver: false
|
|
72
|
+
}),
|
|
73
|
+
Animated.timing(indicatorWidth, {
|
|
74
|
+
toValue: active.width,
|
|
75
|
+
duration,
|
|
76
|
+
easing: Easing.bezier(easing[0], easing[1], easing[2], easing[3]),
|
|
77
|
+
useNativeDriver: false
|
|
78
|
+
})
|
|
79
|
+
]).start();
|
|
80
|
+
}, [active, motion, indicatorX, indicatorWidth, theme.motion.indicator]);
|
|
81
|
+
const select = (next) => {
|
|
82
|
+
if (!isControlled) setInternal(next);
|
|
83
|
+
onValueChange?.(next);
|
|
84
|
+
};
|
|
85
|
+
const scrollRef = React.useRef(null);
|
|
86
|
+
const [viewportWidth, setViewportWidth] = React.useState(0);
|
|
87
|
+
const [stripWidth, setStripWidth] = React.useState(0);
|
|
88
|
+
const revealed = React.useRef(false);
|
|
89
|
+
React.useEffect(() => {
|
|
90
|
+
if (!active || stripWidth <= viewportWidth) return;
|
|
91
|
+
scrollRef.current?.scrollTo({
|
|
92
|
+
x: tabsRevealOffset(active.x, active.width, stripWidth, viewportWidth),
|
|
93
|
+
animated: revealed.current
|
|
94
|
+
});
|
|
95
|
+
revealed.current = true;
|
|
96
|
+
}, [active, stripWidth, viewportWidth]);
|
|
97
|
+
const indicatorStyle = variant === "underline" ? [
|
|
98
|
+
styles.underline,
|
|
99
|
+
// The bar's weight is a ramp step per size — it was 2 and 3, which
|
|
100
|
+
// read as the same decision but came from nowhere.
|
|
101
|
+
{ left: indicatorX, width: indicatorWidth, height: theme.space[size === "sm" ? 2 : 3] }
|
|
102
|
+
] : [
|
|
103
|
+
styles.pill,
|
|
104
|
+
active ? { left: indicatorX, width: indicatorWidth, top: active.y, height: active.height } : { left: indicatorX, width: indicatorWidth }
|
|
105
|
+
];
|
|
106
|
+
return /* @__PURE__ */ jsxs(View, { children: [
|
|
107
|
+
/* @__PURE__ */ jsxs(View, { style: styles.bar, children: [
|
|
108
|
+
/* @__PURE__ */ jsx(View, { style: styles.list, children: /* @__PURE__ */ jsx(
|
|
109
|
+
ScrollView,
|
|
110
|
+
{
|
|
111
|
+
ref: scrollRef,
|
|
112
|
+
horizontal: true,
|
|
113
|
+
showsHorizontalScrollIndicator: false,
|
|
114
|
+
onLayout: (e) => setViewportWidth(e.nativeEvent.layout.width),
|
|
115
|
+
style: styles.scroll,
|
|
116
|
+
children: /* @__PURE__ */ jsxs(
|
|
117
|
+
View,
|
|
118
|
+
{
|
|
119
|
+
accessibilityRole: "tablist",
|
|
120
|
+
style: styles.row,
|
|
121
|
+
onLayout: (e) => setStripWidth(e.nativeEvent.layout.width),
|
|
122
|
+
children: [
|
|
123
|
+
active ? /* @__PURE__ */ jsx(Animated.View, { pointerEvents: "none", style: indicatorStyle }) : null,
|
|
124
|
+
items.map((item, index) => {
|
|
125
|
+
const selected = item.value === current;
|
|
126
|
+
const fg = selected ? theme.color.onSurface : theme.color.text2;
|
|
127
|
+
const triggerNode = /* @__PURE__ */ jsxs(
|
|
128
|
+
Pressable,
|
|
129
|
+
{
|
|
130
|
+
accessibilityRole: "tab",
|
|
131
|
+
accessibilityState: { selected },
|
|
132
|
+
"aria-selected": selected,
|
|
133
|
+
accessibilityActions: item.closable ? CLOSE_ACTIONS : void 0,
|
|
134
|
+
onAccessibilityAction: item.closable && onClose ? (e) => {
|
|
135
|
+
if (e.nativeEvent.actionName === "close") onClose(item.value);
|
|
136
|
+
} : void 0,
|
|
137
|
+
onPress: () => select(item.value),
|
|
138
|
+
onLayout: onTriggerLayout(index),
|
|
139
|
+
style: styles.trigger,
|
|
140
|
+
children: [
|
|
141
|
+
item.icon ? /* @__PURE__ */ jsx(Icon, { name: item.icon, size: iconSize, color: fg }) : null,
|
|
142
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.label, { color: fg }], children: item.label })
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
if (!item.closable) {
|
|
147
|
+
return /* @__PURE__ */ jsx(React.Fragment, { children: triggerNode }, item.value);
|
|
148
|
+
}
|
|
149
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
150
|
+
triggerNode,
|
|
151
|
+
/* @__PURE__ */ jsx(
|
|
152
|
+
Pressable,
|
|
153
|
+
{
|
|
154
|
+
"aria-hidden": true,
|
|
155
|
+
accessibilityElementsHidden: true,
|
|
156
|
+
importantForAccessibility: "no-hide-descendants",
|
|
157
|
+
focusable: false,
|
|
158
|
+
tabIndex: -1,
|
|
159
|
+
testID: `tabs-close-${item.value}`,
|
|
160
|
+
onPress: onClose ? () => onClose(item.value) : void 0,
|
|
161
|
+
style: styles.close,
|
|
162
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "x", size: closeIconSize, color: fg })
|
|
163
|
+
}
|
|
164
|
+
)
|
|
165
|
+
] }, item.value);
|
|
166
|
+
})
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
) }),
|
|
172
|
+
onAdd ? /* @__PURE__ */ jsx(
|
|
173
|
+
Pressable,
|
|
174
|
+
{
|
|
175
|
+
accessibilityRole: "button",
|
|
176
|
+
accessibilityLabel: addLabel,
|
|
177
|
+
onPress: onAdd,
|
|
178
|
+
style: styles.add,
|
|
179
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "plus", size: iconSize, color: theme.color.text2 })
|
|
180
|
+
}
|
|
181
|
+
) : null
|
|
182
|
+
] }),
|
|
183
|
+
activeItem?.content !== void 0 ? /* @__PURE__ */ jsx(View, { style: styles.panel, children: activeItem.content }) : null
|
|
184
|
+
] });
|
|
185
|
+
}
|
|
186
|
+
var sheet = createStyleSheet((theme) => ({
|
|
187
|
+
// The bar row: the scrolling chrome plus the pinned add button. It sizes to
|
|
188
|
+
// its content (`alignSelf: 'flex-start'`) and caps at the parent's edge
|
|
189
|
+
// (`maxWidth`), taking over the sizing role the chrome held before an add
|
|
190
|
+
// button could sit beside it.
|
|
191
|
+
bar: {
|
|
192
|
+
flexDirection: "row",
|
|
193
|
+
alignItems: "center",
|
|
194
|
+
alignSelf: "flex-start",
|
|
195
|
+
maxWidth: "100%"
|
|
196
|
+
},
|
|
197
|
+
// The chrome: the underline's rule, or the pill variant's tray. `flexShrink`
|
|
198
|
+
// lets it yield width to the add button so the triggers scroll underneath the
|
|
199
|
+
// chrome rather than pushing the add button off the edge; with no add button
|
|
200
|
+
// it is the only child of the bar and still sizes to its triggers.
|
|
201
|
+
list: {
|
|
202
|
+
flexShrink: 1,
|
|
203
|
+
variants: {
|
|
204
|
+
variant: {
|
|
205
|
+
underline: {
|
|
206
|
+
borderBottomWidth: theme.borderWidth.thin,
|
|
207
|
+
borderBottomColor: theme.color.border
|
|
208
|
+
},
|
|
209
|
+
pill: {
|
|
210
|
+
backgroundColor: theme.color.surface2,
|
|
211
|
+
borderRadius: theme.radius.full,
|
|
212
|
+
padding: theme.space.s1
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
size: { sm: {}, md: {} }
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
// A scroller clips at its padding box, and the underline indicator hangs 1px
|
|
219
|
+
// past the triggers so it lands *on* the rule (`bottom: -1` below). A hairline
|
|
220
|
+
// of padding keeps that overhang inside the clip box; the negative margin hands
|
|
221
|
+
// the same hairline back, so the bar's height and the rule's position are the
|
|
222
|
+
// ones it had before the strip could scroll.
|
|
223
|
+
scroll: {
|
|
224
|
+
variants: {
|
|
225
|
+
variant: {
|
|
226
|
+
underline: { paddingBottom: theme.space[1], marginBottom: -theme.space[1] },
|
|
227
|
+
pill: {}
|
|
228
|
+
},
|
|
229
|
+
size: { sm: {}, md: {} }
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
// The triggers and the indicator, in one padding-free coordinate space.
|
|
233
|
+
row: {
|
|
234
|
+
position: "relative",
|
|
235
|
+
flexDirection: "row",
|
|
236
|
+
variants: {
|
|
237
|
+
variant: {
|
|
238
|
+
underline: { gap: theme.space.s4 },
|
|
239
|
+
pill: { gap: theme.space.s1 }
|
|
240
|
+
},
|
|
241
|
+
size: { sm: {}, md: {} }
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
underline: {
|
|
245
|
+
position: "absolute",
|
|
246
|
+
bottom: -theme.space[1],
|
|
247
|
+
backgroundColor: theme.color.accent,
|
|
248
|
+
borderRadius: theme.radius.full,
|
|
249
|
+
variants: {
|
|
250
|
+
variant: { underline: {}, pill: {} },
|
|
251
|
+
size: { sm: {}, md: {} }
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
pill: {
|
|
255
|
+
position: "absolute",
|
|
256
|
+
backgroundColor: theme.color.accentSoft,
|
|
257
|
+
// The tint collapses to the plain surface under `contrast: 'more'`, where
|
|
258
|
+
// `edge.accent` stops being transparent and carries the selection instead.
|
|
259
|
+
borderWidth: theme.borderWidth.base,
|
|
260
|
+
borderColor: theme.edge.accent,
|
|
261
|
+
borderRadius: theme.radius.full,
|
|
262
|
+
variants: {
|
|
263
|
+
variant: { underline: {}, pill: {} },
|
|
264
|
+
size: { sm: {}, md: {} }
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
trigger: {
|
|
268
|
+
flexDirection: "row",
|
|
269
|
+
alignItems: "center",
|
|
270
|
+
justifyContent: "center",
|
|
271
|
+
gap: theme.space.s2,
|
|
272
|
+
variants: {
|
|
273
|
+
variant: {
|
|
274
|
+
underline: {},
|
|
275
|
+
pill: { borderRadius: theme.radius.full }
|
|
276
|
+
},
|
|
277
|
+
size: {
|
|
278
|
+
sm: { paddingVertical: theme.space.s2, paddingHorizontal: theme.space.s3 },
|
|
279
|
+
md: { paddingVertical: theme.space.s3, paddingHorizontal: theme.space.s4 }
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
label: {
|
|
284
|
+
fontFamily: theme.font.sans,
|
|
285
|
+
fontWeight: theme.fontWeight.semibold,
|
|
286
|
+
variants: {
|
|
287
|
+
variant: { underline: {}, pill: {} },
|
|
288
|
+
size: {
|
|
289
|
+
sm: { fontSize: theme.fontSize[14] },
|
|
290
|
+
md: { fontSize: theme.fontSize[16] }
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
// The close affordance beside a `closable` tab. `alignSelf: 'stretch'` gives it
|
|
295
|
+
// the trigger's full height as vertical hit area; the horizontal padding widens
|
|
296
|
+
// the target past the glyph. The `x` glyph inherits the label's ink (`text2`
|
|
297
|
+
// when inactive, `onSurface` when active) — both clear the 3:1 non-text floor.
|
|
298
|
+
close: {
|
|
299
|
+
alignSelf: "stretch",
|
|
300
|
+
alignItems: "center",
|
|
301
|
+
justifyContent: "center",
|
|
302
|
+
paddingHorizontal: theme.space.s2,
|
|
303
|
+
borderRadius: theme.radius.full
|
|
304
|
+
},
|
|
305
|
+
// The add button, pinned outside the tablist at the trailing edge. A full
|
|
306
|
+
// 44pt touch target; the `plus` glyph inks `text2` on the surface (3:1+).
|
|
307
|
+
add: {
|
|
308
|
+
minWidth: theme.tapMin,
|
|
309
|
+
minHeight: theme.tapMin,
|
|
310
|
+
alignItems: "center",
|
|
311
|
+
justifyContent: "center",
|
|
312
|
+
marginStart: theme.space.s1
|
|
313
|
+
},
|
|
314
|
+
panel: {
|
|
315
|
+
paddingTop: theme.space.s4,
|
|
316
|
+
variants: {
|
|
317
|
+
variant: { underline: {}, pill: {} },
|
|
318
|
+
size: { sm: {}, md: {} }
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}));
|
|
322
|
+
|
|
323
|
+
export { Tabs };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|