one 1.2.6 → 1.2.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/cjs/ui/Slot.cjs +42 -0
- package/dist/cjs/ui/Slot.js +27 -0
- package/dist/cjs/ui/Slot.js.map +6 -0
- package/dist/cjs/ui/Slot.native.js +48 -0
- package/dist/cjs/ui/Slot.native.js.map +1 -0
- package/dist/cjs/ui/TabContext.cjs +44 -0
- package/dist/cjs/ui/TabContext.js +35 -0
- package/dist/cjs/ui/TabContext.js.map +6 -0
- package/dist/cjs/ui/TabContext.native.js +47 -0
- package/dist/cjs/ui/TabContext.native.js.map +1 -0
- package/dist/cjs/ui/TabList.cjs +52 -0
- package/dist/cjs/ui/TabList.js +38 -0
- package/dist/cjs/ui/TabList.js.map +6 -0
- package/dist/cjs/ui/TabList.native.js +57 -0
- package/dist/cjs/ui/TabList.native.js.map +1 -0
- package/dist/cjs/ui/TabRouter.cjs +47 -0
- package/dist/cjs/ui/TabRouter.js +41 -0
- package/dist/cjs/ui/TabRouter.js.map +6 -0
- package/dist/cjs/ui/TabRouter.native.js +57 -0
- package/dist/cjs/ui/TabRouter.native.js.map +1 -0
- package/dist/cjs/ui/TabSlot.cjs +115 -0
- package/dist/cjs/ui/TabSlot.js +91 -0
- package/dist/cjs/ui/TabSlot.js.map +6 -0
- package/dist/cjs/ui/TabSlot.native.js +120 -0
- package/dist/cjs/ui/TabSlot.native.js.map +1 -0
- package/dist/cjs/ui/TabTrigger.cjs +151 -0
- package/dist/cjs/ui/TabTrigger.js +120 -0
- package/dist/cjs/ui/TabTrigger.js.map +6 -0
- package/dist/cjs/ui/TabTrigger.native.js +153 -0
- package/dist/cjs/ui/TabTrigger.native.js.map +1 -0
- package/dist/cjs/ui/Tabs.cjs +175 -0
- package/dist/cjs/ui/Tabs.js +121 -0
- package/dist/cjs/ui/Tabs.js.map +6 -0
- package/dist/cjs/ui/Tabs.native.js +191 -0
- package/dist/cjs/ui/Tabs.native.js.map +1 -0
- package/dist/cjs/ui/common.cjs +160 -0
- package/dist/cjs/ui/common.js +146 -0
- package/dist/cjs/ui/common.js.map +6 -0
- package/dist/cjs/ui/common.native.js +223 -0
- package/dist/cjs/ui/common.native.js.map +1 -0
- package/dist/cjs/ui/index.cjs +18 -0
- package/dist/cjs/ui/index.js +15 -0
- package/dist/cjs/ui/index.js.map +6 -0
- package/dist/cjs/ui/index.native.js +21 -0
- package/dist/cjs/ui/index.native.js.map +1 -0
- package/dist/cjs/ui/useComponent.cjs +46 -0
- package/dist/cjs/ui/useComponent.js +37 -0
- package/dist/cjs/ui/useComponent.js.map +6 -0
- package/dist/cjs/ui/useComponent.native.js +53 -0
- package/dist/cjs/ui/useComponent.native.js.map +1 -0
- package/dist/esm/ui/Slot.js +17 -0
- package/dist/esm/ui/Slot.js.map +6 -0
- package/dist/esm/ui/Slot.mjs +19 -0
- package/dist/esm/ui/Slot.mjs.map +1 -0
- package/dist/esm/ui/Slot.native.js +22 -0
- package/dist/esm/ui/Slot.native.js.map +1 -0
- package/dist/esm/ui/TabContext.js +19 -0
- package/dist/esm/ui/TabContext.js.map +6 -0
- package/dist/esm/ui/TabContext.mjs +17 -0
- package/dist/esm/ui/TabContext.mjs.map +1 -0
- package/dist/esm/ui/TabContext.native.js +17 -0
- package/dist/esm/ui/TabContext.native.js.map +1 -0
- package/dist/esm/ui/TabList.js +24 -0
- package/dist/esm/ui/TabList.js.map +6 -0
- package/dist/esm/ui/TabList.mjs +28 -0
- package/dist/esm/ui/TabList.mjs.map +1 -0
- package/dist/esm/ui/TabList.native.js +30 -0
- package/dist/esm/ui/TabList.native.js.map +1 -0
- package/dist/esm/ui/TabRouter.js +27 -0
- package/dist/esm/ui/TabRouter.js.map +6 -0
- package/dist/esm/ui/TabRouter.mjs +24 -0
- package/dist/esm/ui/TabRouter.mjs.map +1 -0
- package/dist/esm/ui/TabRouter.native.js +31 -0
- package/dist/esm/ui/TabRouter.native.js.map +1 -0
- package/dist/esm/ui/TabSlot.js +80 -0
- package/dist/esm/ui/TabSlot.js.map +6 -0
- package/dist/esm/ui/TabSlot.mjs +89 -0
- package/dist/esm/ui/TabSlot.mjs.map +1 -0
- package/dist/esm/ui/TabSlot.native.js +91 -0
- package/dist/esm/ui/TabSlot.native.js.map +1 -0
- package/dist/esm/ui/TabTrigger.js +115 -0
- package/dist/esm/ui/TabTrigger.js.map +6 -0
- package/dist/esm/ui/TabTrigger.mjs +126 -0
- package/dist/esm/ui/TabTrigger.mjs.map +1 -0
- package/dist/esm/ui/TabTrigger.native.js +125 -0
- package/dist/esm/ui/TabTrigger.native.js.map +1 -0
- package/dist/esm/ui/Tabs.js +130 -0
- package/dist/esm/ui/Tabs.js.map +6 -0
- package/dist/esm/ui/Tabs.mjs +149 -0
- package/dist/esm/ui/Tabs.mjs.map +1 -0
- package/dist/esm/ui/Tabs.native.js +162 -0
- package/dist/esm/ui/Tabs.native.js.map +1 -0
- package/dist/esm/ui/common.js +133 -0
- package/dist/esm/ui/common.js.map +6 -0
- package/dist/esm/ui/common.mjs +135 -0
- package/dist/esm/ui/common.mjs.map +1 -0
- package/dist/esm/ui/common.native.js +195 -0
- package/dist/esm/ui/common.native.js.map +1 -0
- package/dist/esm/ui/index.js +2 -0
- package/dist/esm/ui/index.js.map +6 -0
- package/dist/esm/ui/index.mjs +2 -0
- package/dist/esm/ui/index.mjs.map +1 -0
- package/dist/esm/ui/index.native.js +2 -0
- package/dist/esm/ui/index.native.js.map +1 -0
- package/dist/esm/ui/useComponent.js +22 -0
- package/dist/esm/ui/useComponent.js.map +6 -0
- package/dist/esm/ui/useComponent.mjs +23 -0
- package/dist/esm/ui/useComponent.mjs.map +1 -0
- package/dist/esm/ui/useComponent.native.js +27 -0
- package/dist/esm/ui/useComponent.native.js.map +1 -0
- package/package.json +18 -9
- package/src/ui/README.md +121 -0
- package/src/ui/Slot.tsx +34 -0
- package/src/ui/TabContext.tsx +115 -0
- package/src/ui/TabList.tsx +47 -0
- package/src/ui/TabRouter.tsx +79 -0
- package/src/ui/TabSlot.tsx +170 -0
- package/src/ui/TabTrigger.tsx +282 -0
- package/src/ui/Tabs.tsx +313 -0
- package/src/ui/common.tsx +277 -0
- package/src/ui/index.ts +1 -0
- package/src/ui/useComponent.tsx +42 -0
- package/types/ui/Slot.d.ts +6 -0
- package/types/ui/Slot.d.ts.map +1 -0
- package/types/ui/TabContext.d.ts +190 -0
- package/types/ui/TabContext.d.ts.map +1 -0
- package/types/ui/TabList.d.ts +25 -0
- package/types/ui/TabList.d.ts.map +1 -0
- package/types/ui/TabRouter.d.ts +103 -0
- package/types/ui/TabRouter.d.ts.map +1 -0
- package/types/ui/TabSlot.d.ts +73 -0
- package/types/ui/TabSlot.d.ts.map +1 -0
- package/types/ui/TabTrigger.d.ts +88 -0
- package/types/ui/TabTrigger.d.ts.map +1 -0
- package/types/ui/Tabs.d.ts +255 -0
- package/types/ui/Tabs.d.ts.map +1 -0
- package/types/ui/common.d.ts +40 -0
- package/types/ui/common.d.ts.map +1 -0
- package/types/ui/index.d.ts +2 -0
- package/types/ui/index.d.ts.map +1 -0
- package/types/ui/useComponent.d.ts +10 -0
- package/types/ui/useComponent.d.ts.map +1 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: !0
|
|
22
|
+
}), mod);
|
|
23
|
+
var TabTrigger_exports = {};
|
|
24
|
+
__export(TabTrigger_exports, {
|
|
25
|
+
TabTrigger: () => TabTrigger,
|
|
26
|
+
isTabTrigger: () => isTabTrigger,
|
|
27
|
+
useTabTrigger: () => useTabTrigger
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(TabTrigger_exports);
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime"),
|
|
31
|
+
import_react_slot = require("@radix-ui/react-slot"),
|
|
32
|
+
import_react = require("react"),
|
|
33
|
+
import_react_native = require("react-native"),
|
|
34
|
+
import_TabContext = require("./TabContext.native.js"),
|
|
35
|
+
import_getPathFromState_mods = require("../fork/getPathFromState-mods.native.js"),
|
|
36
|
+
import_imperative_api = require("../router/imperative-api.native.js"),
|
|
37
|
+
import_matchers = require("../router/matchers.native.js"),
|
|
38
|
+
import_Navigator = require("../views/Navigator.native.js"),
|
|
39
|
+
TabTriggerSlot = import_react_slot.Slot;
|
|
40
|
+
function shouldHandleMouseEvent(e) {
|
|
41
|
+
return e && "button" in e ? !e.metaKey && !e.altKey && !e.ctrlKey && !e.shiftKey && (e.button == null || e.button === 0) && [void 0, null, "", "self"].includes(e.currentTarget.target) : !0;
|
|
42
|
+
}
|
|
43
|
+
function TabTrigger(param) {
|
|
44
|
+
var {
|
|
45
|
+
asChild,
|
|
46
|
+
name,
|
|
47
|
+
href,
|
|
48
|
+
resetOnFocus,
|
|
49
|
+
...props
|
|
50
|
+
} = param,
|
|
51
|
+
{
|
|
52
|
+
trigger,
|
|
53
|
+
triggerProps
|
|
54
|
+
} = useTabTrigger({
|
|
55
|
+
name,
|
|
56
|
+
resetOnFocus,
|
|
57
|
+
...props
|
|
58
|
+
});
|
|
59
|
+
if (asChild) return /* @__PURE__ */(0, import_jsx_runtime.jsx)(TabTriggerSlot, {
|
|
60
|
+
style: styles.tabTrigger,
|
|
61
|
+
...props,
|
|
62
|
+
...triggerProps,
|
|
63
|
+
href: trigger?.resolvedHref,
|
|
64
|
+
children: props.children
|
|
65
|
+
});
|
|
66
|
+
var reactNativeWebProps = {
|
|
67
|
+
href: trigger?.resolvedHref
|
|
68
|
+
};
|
|
69
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.Pressable, {
|
|
70
|
+
style: styles.tabTrigger,
|
|
71
|
+
...reactNativeWebProps,
|
|
72
|
+
...props,
|
|
73
|
+
...triggerProps,
|
|
74
|
+
children: props.children
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function isTabTrigger(child) {
|
|
78
|
+
return child.type === TabTrigger;
|
|
79
|
+
}
|
|
80
|
+
function useTabTrigger(options) {
|
|
81
|
+
var {
|
|
82
|
+
state,
|
|
83
|
+
navigation
|
|
84
|
+
} = (0, import_Navigator.useNavigatorContext)(),
|
|
85
|
+
{
|
|
86
|
+
name,
|
|
87
|
+
resetOnFocus,
|
|
88
|
+
onPress,
|
|
89
|
+
onLongPress
|
|
90
|
+
} = options,
|
|
91
|
+
triggerMap = (0, import_react.use)(import_TabContext.TabTriggerMapContext),
|
|
92
|
+
getTrigger = (0, import_react.useCallback)(function (name2) {
|
|
93
|
+
var config = triggerMap[name2];
|
|
94
|
+
if (config) return {
|
|
95
|
+
isFocused: state.index === config.index,
|
|
96
|
+
route: state.routes[config.index],
|
|
97
|
+
resolvedHref: (0, import_matchers.stripGroupSegmentsFromPath)((0, import_getPathFromState_mods.appendBaseUrl)(config.href)),
|
|
98
|
+
...config
|
|
99
|
+
};
|
|
100
|
+
}, [triggerMap, state]),
|
|
101
|
+
trigger = name !== void 0 ? getTrigger(name) : void 0,
|
|
102
|
+
switchTab = (0, import_react.useCallback)(function (name2, options2) {
|
|
103
|
+
var config = triggerMap[name2];
|
|
104
|
+
return config ? config.type === "external" ? import_imperative_api.router.navigate(config.href) : navigation?.dispatch({
|
|
105
|
+
...config.action,
|
|
106
|
+
type: "JUMP_TO",
|
|
107
|
+
payload: {
|
|
108
|
+
...config.action.payload,
|
|
109
|
+
...options2
|
|
110
|
+
}
|
|
111
|
+
}) : navigation?.dispatch({
|
|
112
|
+
type: "JUMP_TO",
|
|
113
|
+
payload: {
|
|
114
|
+
name: name2
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}, [navigation, triggerMap]),
|
|
118
|
+
handleOnPress = (0, import_react.useCallback)(function (event) {
|
|
119
|
+
onPress?.(event), trigger && (event?.isDefaultPrevented() || (navigation?.emit({
|
|
120
|
+
type: "tabPress",
|
|
121
|
+
target: trigger.type === "internal" ? trigger.route.key : trigger?.href,
|
|
122
|
+
canPreventDefault: !0
|
|
123
|
+
}), shouldHandleMouseEvent(event) && switchTab(name, {
|
|
124
|
+
resetOnFocus
|
|
125
|
+
})));
|
|
126
|
+
}, [onPress, name, resetOnFocus, trigger, navigation, switchTab]),
|
|
127
|
+
handleOnLongPress = (0, import_react.useCallback)(function (event) {
|
|
128
|
+
onLongPress?.(event), trigger && (event?.isDefaultPrevented() || (navigation?.emit({
|
|
129
|
+
type: "tabLongPress",
|
|
130
|
+
target: trigger.type === "internal" ? trigger.route.key : trigger?.href
|
|
131
|
+
}), shouldHandleMouseEvent(event) && switchTab(name, {
|
|
132
|
+
resetOnFocus
|
|
133
|
+
})));
|
|
134
|
+
}, [onLongPress, name, resetOnFocus, trigger, navigation, switchTab]),
|
|
135
|
+
triggerProps = {
|
|
136
|
+
isFocused: !!trigger?.isFocused,
|
|
137
|
+
onPress: handleOnPress,
|
|
138
|
+
onLongPress: handleOnLongPress
|
|
139
|
+
};
|
|
140
|
+
return {
|
|
141
|
+
switchTab,
|
|
142
|
+
getTrigger,
|
|
143
|
+
trigger,
|
|
144
|
+
triggerProps
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
var styles = import_react_native.StyleSheet.create({
|
|
148
|
+
tabTrigger: {
|
|
149
|
+
flexDirection: "row",
|
|
150
|
+
justifyContent: "space-between"
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
//# sourceMappingURL=TabTrigger.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","TabTrigger_exports","__export","TabTrigger","isTabTrigger","useTabTrigger","module","exports","import_jsx_runtime","require","import_react_slot","import_react","import_react_native","import_TabContext","import_getPathFromState_mods","import_imperative_api","import_matchers","import_Navigator","TabTriggerSlot","Slot","shouldHandleMouseEvent","e","metaKey","altKey","ctrlKey","shiftKey","button","includes","currentTarget","target","param","asChild","name","href","resetOnFocus","props","trigger","triggerProps","jsx","style","styles","tabTrigger","resolvedHref","children","reactNativeWebProps","Pressable","child","type","options","state","navigation","useNavigatorContext","onPress","onLongPress","triggerMap","use","TabTriggerMapContext","getTrigger","useCallback","name2","config","isFocused","index","route","routes","stripGroupSegmentsFromPath","appendBaseUrl","switchTab","options2","router","navigate","dispatch","action","payload","handleOnPress","event","isDefaultPrevented","emit","key","canPreventDefault","handleOnLongPress"],"sources":["../../../src/ui/TabTrigger.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,kBAAA;AAAAC,QAAA,CAAAD,kBAAA;EAAAE,UAAA,EAAAA,CAAA,KAAAA,UAAA;EAAAC,YAAA,EAAAA,CAAA,KAAAA,YAAA;EAAAC,aAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAX,YAAqB,CAAAK,kBAAA;AAsDrB,IAAAO,kBAAM,GAAiBC,OAAA;EAAAC,iBAAA,GAAAD,OAAA;EAAAE,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or;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
},
|
|
18
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
20
|
+
value: !0
|
|
21
|
+
}), mod);
|
|
22
|
+
var Tabs_exports = {};
|
|
23
|
+
__export(Tabs_exports, {
|
|
24
|
+
Tabs: () => Tabs,
|
|
25
|
+
useTabsWithChildren: () => useTabsWithChildren,
|
|
26
|
+
useTabsWithTriggers: () => useTabsWithTriggers
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(Tabs_exports);
|
|
29
|
+
var import_native = require("@react-navigation/native"),
|
|
30
|
+
import_react = require("react"),
|
|
31
|
+
import_react_native = require("react-native-web"),
|
|
32
|
+
import_TabContext = require("./TabContext.cjs"),
|
|
33
|
+
import_TabList = require("./TabList.cjs"),
|
|
34
|
+
import_TabRouter = require("./TabRouter.cjs"),
|
|
35
|
+
import_TabSlot = require("./TabSlot.cjs"),
|
|
36
|
+
import_TabTrigger = require("./TabTrigger.cjs"),
|
|
37
|
+
import_common = require("./common.cjs"),
|
|
38
|
+
import_useComponent = require("./useComponent.cjs"),
|
|
39
|
+
import_Route = require("../router/Route.cjs"),
|
|
40
|
+
import_hooks = require("../hooks.cjs"),
|
|
41
|
+
import_href = require("../link/href.cjs"),
|
|
42
|
+
import_url = require("../utils/url.cjs"),
|
|
43
|
+
import_Navigator = require("../views/Navigator.cjs");
|
|
44
|
+
__reExport(Tabs_exports, require("./TabContext.cjs"), module.exports);
|
|
45
|
+
__reExport(Tabs_exports, require("./TabList.cjs"), module.exports);
|
|
46
|
+
__reExport(Tabs_exports, require("./TabSlot.cjs"), module.exports);
|
|
47
|
+
__reExport(Tabs_exports, require("./TabTrigger.cjs"), module.exports);
|
|
48
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
49
|
+
function Tabs(props) {
|
|
50
|
+
const {
|
|
51
|
+
children,
|
|
52
|
+
asChild,
|
|
53
|
+
options,
|
|
54
|
+
...rest
|
|
55
|
+
} = props,
|
|
56
|
+
Comp = asChild ? import_common.ViewSlot : import_react_native.View,
|
|
57
|
+
{
|
|
58
|
+
NavigationContent
|
|
59
|
+
} = useTabsWithChildren({
|
|
60
|
+
// asChild adds an extra layer, so we need to process the child's children
|
|
61
|
+
children: asChild && (0, import_react.isValidElement)(children) && children.props && typeof children.props == "object" && "children" in children.props ? children.props.children : children,
|
|
62
|
+
...options
|
|
63
|
+
});
|
|
64
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Comp, {
|
|
65
|
+
style: styles.tabsRoot,
|
|
66
|
+
...rest,
|
|
67
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(NavigationContent, {
|
|
68
|
+
children
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function useTabsWithChildren(options) {
|
|
73
|
+
const {
|
|
74
|
+
children,
|
|
75
|
+
...rest
|
|
76
|
+
} = options;
|
|
77
|
+
return useTabsWithTriggers({
|
|
78
|
+
triggers: parseTriggersFromChildren(children),
|
|
79
|
+
...rest
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function useTabsWithTriggers(options) {
|
|
83
|
+
const {
|
|
84
|
+
triggers,
|
|
85
|
+
...rest
|
|
86
|
+
} = options,
|
|
87
|
+
parentTriggerMap = (0, import_react.use)(import_TabContext.TabTriggerMapContext),
|
|
88
|
+
routeNode = (0, import_Route.useRouteNode)(),
|
|
89
|
+
contextKey = (0, import_Route.useContextKey)(),
|
|
90
|
+
linking = (0, import_react.use)(import_native.LinkingContext).options,
|
|
91
|
+
routeInfo = (0, import_hooks.useRouteInfo)();
|
|
92
|
+
if (!routeNode || !linking) throw new Error("No RouteNode. This is likely a bug in one router.");
|
|
93
|
+
const initialRouteName = routeNode.initialRouteName,
|
|
94
|
+
{
|
|
95
|
+
children,
|
|
96
|
+
triggerMap
|
|
97
|
+
} = (0, import_common.triggersToScreens)(triggers, routeNode, linking, initialRouteName, parentTriggerMap, routeInfo, contextKey),
|
|
98
|
+
navigatorContext = (0, import_native.useNavigationBuilder)(import_TabRouter.ExpoTabRouter, {
|
|
99
|
+
children,
|
|
100
|
+
...rest,
|
|
101
|
+
triggerMap,
|
|
102
|
+
id: contextKey,
|
|
103
|
+
initialRouteName
|
|
104
|
+
}),
|
|
105
|
+
{
|
|
106
|
+
state,
|
|
107
|
+
descriptors,
|
|
108
|
+
navigation,
|
|
109
|
+
describe,
|
|
110
|
+
NavigationContent: RNNavigationContent
|
|
111
|
+
} = navigatorContext,
|
|
112
|
+
navigatorContextValue = (0, import_react.useMemo)(() => ({
|
|
113
|
+
...navigatorContext,
|
|
114
|
+
contextKey,
|
|
115
|
+
router: import_TabRouter.ExpoTabRouter
|
|
116
|
+
}), [navigatorContext, contextKey, import_TabRouter.ExpoTabRouter]),
|
|
117
|
+
NavigationContent = (0, import_useComponent.useComponent)(children2 => /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_TabContext.TabTriggerMapContext.Provider, {
|
|
118
|
+
value: triggerMap,
|
|
119
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Navigator.NavigatorContext.Provider, {
|
|
120
|
+
value: navigatorContextValue,
|
|
121
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(RNNavigationContent, {
|
|
122
|
+
children: children2
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
}));
|
|
126
|
+
return {
|
|
127
|
+
state,
|
|
128
|
+
descriptors,
|
|
129
|
+
navigation,
|
|
130
|
+
NavigationContent,
|
|
131
|
+
describe
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function parseTriggersFromChildren(children, screenTriggers = [], isInTabList = !1) {
|
|
135
|
+
return import_react.Children.forEach(children, child => {
|
|
136
|
+
if (!child || !(0, import_react.isValidElement)(child) || (0, import_TabSlot.isTabSlot)(child)) return;
|
|
137
|
+
if (isFragment(child) && typeof child.props.children != "function") return parseTriggersFromChildren(child.props.children, screenTriggers, isInTabList || (0, import_TabList.isTabList)(child));
|
|
138
|
+
if ((0, import_TabList.isTabList)(child) && typeof child.props.children != "function") {
|
|
139
|
+
let children2 = child.props.children;
|
|
140
|
+
return child.props.asChild && (0, import_react.isValidElement)(children2) && children2.props && typeof children2.props == "object" && "children" in children2.props && (children2 = children2.props.children), parseTriggersFromChildren(children2, screenTriggers, isInTabList || (0, import_TabList.isTabList)(child));
|
|
141
|
+
}
|
|
142
|
+
if (!isInTabList || !(0, import_TabTrigger.isTabTrigger)(child)) return;
|
|
143
|
+
const {
|
|
144
|
+
href,
|
|
145
|
+
name
|
|
146
|
+
} = child.props;
|
|
147
|
+
if (!href) {
|
|
148
|
+
process.env.NODE_ENV === "development" && console.warn(`<TabTrigger name={${name}}> does not have a 'href' prop. TabTriggers within a <TabList /> are required to have an href.`);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const resolvedHref = (0, import_href.resolveHref)(href);
|
|
152
|
+
if ((0, import_url.shouldLinkExternally)(resolvedHref)) return screenTriggers.push({
|
|
153
|
+
type: "external",
|
|
154
|
+
name,
|
|
155
|
+
href: resolvedHref
|
|
156
|
+
});
|
|
157
|
+
if (!name) {
|
|
158
|
+
process.env.NODE_ENV === "development" && console.warn("<TabTrigger> does not have a 'name' prop. TabTriggers within a <TabList /> are required to have a name.");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
return screenTriggers.push({
|
|
162
|
+
type: "internal",
|
|
163
|
+
href: resolvedHref,
|
|
164
|
+
name
|
|
165
|
+
});
|
|
166
|
+
}), screenTriggers;
|
|
167
|
+
}
|
|
168
|
+
function isFragment(child) {
|
|
169
|
+
return child.type === import_react.Fragment;
|
|
170
|
+
}
|
|
171
|
+
const styles = import_react_native.StyleSheet.create({
|
|
172
|
+
tabsRoot: {
|
|
173
|
+
flex: 1
|
|
174
|
+
}
|
|
175
|
+
});
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var Tabs_exports = {};
|
|
16
|
+
__export(Tabs_exports, {
|
|
17
|
+
Tabs: () => Tabs,
|
|
18
|
+
useTabsWithChildren: () => useTabsWithChildren,
|
|
19
|
+
useTabsWithTriggers: () => useTabsWithTriggers
|
|
20
|
+
});
|
|
21
|
+
module.exports = __toCommonJS(Tabs_exports);
|
|
22
|
+
var import_native = require("@react-navigation/native"), import_react = require("react"), import_react_native = require("react-native-web"), import_TabContext = require("./TabContext"), import_TabList = require("./TabList"), import_TabRouter = require("./TabRouter"), import_TabSlot = require("./TabSlot"), import_TabTrigger = require("./TabTrigger"), import_common = require("./common"), import_useComponent = require("./useComponent"), import_Route = require("../router/Route"), import_hooks = require("../hooks"), import_href = require("../link/href"), import_url = require("../utils/url"), import_Navigator = require("../views/Navigator");
|
|
23
|
+
__reExport(Tabs_exports, require("./TabContext"), module.exports);
|
|
24
|
+
__reExport(Tabs_exports, require("./TabList"), module.exports);
|
|
25
|
+
__reExport(Tabs_exports, require("./TabSlot"), module.exports);
|
|
26
|
+
__reExport(Tabs_exports, require("./TabTrigger"), module.exports);
|
|
27
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
function Tabs(props) {
|
|
29
|
+
const { children, asChild, options, ...rest } = props, Comp = asChild ? import_common.ViewSlot : import_react_native.View, { NavigationContent } = useTabsWithChildren({
|
|
30
|
+
// asChild adds an extra layer, so we need to process the child's children
|
|
31
|
+
children: asChild && (0, import_react.isValidElement)(children) && children.props && typeof children.props == "object" && "children" in children.props ? children.props.children : children,
|
|
32
|
+
...options
|
|
33
|
+
});
|
|
34
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Comp, { style: styles.tabsRoot, ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NavigationContent, { children }) });
|
|
35
|
+
}
|
|
36
|
+
function useTabsWithChildren(options) {
|
|
37
|
+
const { children, ...rest } = options;
|
|
38
|
+
return useTabsWithTriggers({ triggers: parseTriggersFromChildren(children), ...rest });
|
|
39
|
+
}
|
|
40
|
+
function useTabsWithTriggers(options) {
|
|
41
|
+
const { triggers, ...rest } = options, parentTriggerMap = (0, import_react.use)(import_TabContext.TabTriggerMapContext), routeNode = (0, import_Route.useRouteNode)(), contextKey = (0, import_Route.useContextKey)(), linking = (0, import_react.use)(import_native.LinkingContext).options, routeInfo = (0, import_hooks.useRouteInfo)();
|
|
42
|
+
if (!routeNode || !linking)
|
|
43
|
+
throw new Error("No RouteNode. This is likely a bug in one router.");
|
|
44
|
+
const initialRouteName = routeNode.initialRouteName, { children, triggerMap } = (0, import_common.triggersToScreens)(
|
|
45
|
+
triggers,
|
|
46
|
+
routeNode,
|
|
47
|
+
linking,
|
|
48
|
+
initialRouteName,
|
|
49
|
+
parentTriggerMap,
|
|
50
|
+
routeInfo,
|
|
51
|
+
contextKey
|
|
52
|
+
), navigatorContext = (0, import_native.useNavigationBuilder)(import_TabRouter.ExpoTabRouter, {
|
|
53
|
+
children,
|
|
54
|
+
...rest,
|
|
55
|
+
triggerMap,
|
|
56
|
+
id: contextKey,
|
|
57
|
+
initialRouteName
|
|
58
|
+
}), {
|
|
59
|
+
state,
|
|
60
|
+
descriptors,
|
|
61
|
+
navigation,
|
|
62
|
+
describe,
|
|
63
|
+
NavigationContent: RNNavigationContent
|
|
64
|
+
} = navigatorContext, navigatorContextValue = (0, import_react.useMemo)(
|
|
65
|
+
() => ({
|
|
66
|
+
...navigatorContext,
|
|
67
|
+
contextKey,
|
|
68
|
+
router: import_TabRouter.ExpoTabRouter
|
|
69
|
+
}),
|
|
70
|
+
[navigatorContext, contextKey, import_TabRouter.ExpoTabRouter]
|
|
71
|
+
), NavigationContent = (0, import_useComponent.useComponent)((children2) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TabContext.TabTriggerMapContext.Provider, { value: triggerMap, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Navigator.NavigatorContext.Provider, { value: navigatorContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RNNavigationContent, { children: children2 }) }) }));
|
|
72
|
+
return { state, descriptors, navigation, NavigationContent, describe };
|
|
73
|
+
}
|
|
74
|
+
function parseTriggersFromChildren(children, screenTriggers = [], isInTabList = !1) {
|
|
75
|
+
return import_react.Children.forEach(children, (child) => {
|
|
76
|
+
if (!child || !(0, import_react.isValidElement)(child) || (0, import_TabSlot.isTabSlot)(child))
|
|
77
|
+
return;
|
|
78
|
+
if (isFragment(child) && typeof child.props.children != "function")
|
|
79
|
+
return parseTriggersFromChildren(
|
|
80
|
+
child.props.children,
|
|
81
|
+
screenTriggers,
|
|
82
|
+
isInTabList || (0, import_TabList.isTabList)(child)
|
|
83
|
+
);
|
|
84
|
+
if ((0, import_TabList.isTabList)(child) && typeof child.props.children != "function") {
|
|
85
|
+
let children2 = child.props.children;
|
|
86
|
+
return child.props.asChild && (0, import_react.isValidElement)(children2) && children2.props && typeof children2.props == "object" && "children" in children2.props && (children2 = children2.props.children), parseTriggersFromChildren(children2, screenTriggers, isInTabList || (0, import_TabList.isTabList)(child));
|
|
87
|
+
}
|
|
88
|
+
if (!isInTabList || !(0, import_TabTrigger.isTabTrigger)(child))
|
|
89
|
+
return;
|
|
90
|
+
const { href, name } = child.props;
|
|
91
|
+
if (!href) {
|
|
92
|
+
process.env.NODE_ENV === "development" && console.warn(
|
|
93
|
+
`<TabTrigger name={${name}}> does not have a 'href' prop. TabTriggers within a <TabList /> are required to have an href.`
|
|
94
|
+
);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const resolvedHref = (0, import_href.resolveHref)(href);
|
|
98
|
+
if ((0, import_url.shouldLinkExternally)(resolvedHref))
|
|
99
|
+
return screenTriggers.push({
|
|
100
|
+
type: "external",
|
|
101
|
+
name,
|
|
102
|
+
href: resolvedHref
|
|
103
|
+
});
|
|
104
|
+
if (!name) {
|
|
105
|
+
process.env.NODE_ENV === "development" && console.warn(
|
|
106
|
+
"<TabTrigger> does not have a 'name' prop. TabTriggers within a <TabList /> are required to have a name."
|
|
107
|
+
);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
return screenTriggers.push({ type: "internal", href: resolvedHref, name });
|
|
111
|
+
}), screenTriggers;
|
|
112
|
+
}
|
|
113
|
+
function isFragment(child) {
|
|
114
|
+
return child.type === import_react.Fragment;
|
|
115
|
+
}
|
|
116
|
+
const styles = import_react_native.StyleSheet.create({
|
|
117
|
+
tabsRoot: {
|
|
118
|
+
flex: 1
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=Tabs.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/ui/Tabs.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAQO,qCACP,eAUO,kBACP,sBAAiD,yBAEjD,oBAKO,yBACP,iBAA0B,sBAC1B,mBAAyD,wBACzD,iBAA0B,sBAC1B,oBAA6B,yBAC7B,gBAAgE,qBAChE,sBAA6B,2BAC7B,eAA4C,4BAC5C,eAA6B,qBAC7B,cAA4B,yBAC5B,aAAqC,yBACrC,mBAAiC;AAWjC,yBAAc,yBAjDd;AAkDA,yBAAc,sBAlDd;AAmDA,yBAAc,sBAnDd;AAoDA,yBAAc,yBApDd;AA8GM;AAnBC,SAAS,KAAK,OAAkB;AACrC,QAAM,EAAE,UAAU,SAAS,SAAS,GAAG,KAAK,IAAI,OAC1C,OAAO,UAAU,yBAAW,0BAE5B,EAAE,kBAAkB,IAAI,oBAAoB;AAAA;AAAA,IAEhD,UACE,eACA,6BAAe,QAAQ,KACvB,SAAS,SACT,OAAO,SAAS,SAAU,YAC1B,cAAc,SAAS,QAClB,SAAS,MAAM,WAChB;AAAA,IACN,GAAG;AAAA,EACL,CAAC;AAED,SACE,4CAAC,QAAK,OAAO,OAAO,UAAW,GAAG,MAChC,sDAAC,qBAAmB,UAAS,GAC/B;AAEJ;AA2BO,SAAS,oBAAoB,SAAqC;AACvE,QAAM,EAAE,UAAU,GAAG,KAAK,IAAI;AAC9B,SAAO,oBAAoB,EAAE,UAAU,0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
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
},
|
|
20
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
22
|
+
value: !0
|
|
23
|
+
}), mod);
|
|
24
|
+
var Tabs_exports = {};
|
|
25
|
+
__export(Tabs_exports, {
|
|
26
|
+
Tabs: () => Tabs,
|
|
27
|
+
useTabsWithChildren: () => useTabsWithChildren,
|
|
28
|
+
useTabsWithTriggers: () => useTabsWithTriggers
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(Tabs_exports);
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime"),
|
|
32
|
+
import_native = require("@react-navigation/native"),
|
|
33
|
+
import_react = require("react"),
|
|
34
|
+
import_react_native = require("react-native"),
|
|
35
|
+
import_TabContext = require("./TabContext.native.js"),
|
|
36
|
+
import_TabList = require("./TabList.native.js"),
|
|
37
|
+
import_TabRouter = require("./TabRouter.native.js"),
|
|
38
|
+
import_TabSlot = require("./TabSlot.native.js"),
|
|
39
|
+
import_TabTrigger = require("./TabTrigger.native.js"),
|
|
40
|
+
import_common = require("./common.native.js"),
|
|
41
|
+
import_useComponent = require("./useComponent.native.js"),
|
|
42
|
+
import_Route = require("../router/Route.native.js"),
|
|
43
|
+
import_hooks = require("../hooks.native.js"),
|
|
44
|
+
import_href = require("../link/href.native.js"),
|
|
45
|
+
import_url = require("../utils/url.native.js"),
|
|
46
|
+
import_Navigator = require("../views/Navigator.native.js");
|
|
47
|
+
__reExport(Tabs_exports, require("./TabContext.native.js"), module.exports);
|
|
48
|
+
__reExport(Tabs_exports, require("./TabList.native.js"), module.exports);
|
|
49
|
+
__reExport(Tabs_exports, require("./TabSlot.native.js"), module.exports);
|
|
50
|
+
__reExport(Tabs_exports, require("./TabTrigger.native.js"), module.exports);
|
|
51
|
+
function _type_of(obj) {
|
|
52
|
+
"@swc/helpers - typeof";
|
|
53
|
+
|
|
54
|
+
return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
55
|
+
}
|
|
56
|
+
function Tabs(props) {
|
|
57
|
+
var {
|
|
58
|
+
children,
|
|
59
|
+
asChild,
|
|
60
|
+
options,
|
|
61
|
+
...rest
|
|
62
|
+
} = props,
|
|
63
|
+
Comp = asChild ? import_common.ViewSlot : import_react_native.View,
|
|
64
|
+
{
|
|
65
|
+
NavigationContent
|
|
66
|
+
} = useTabsWithChildren({
|
|
67
|
+
// asChild adds an extra layer, so we need to process the child's children
|
|
68
|
+
children: asChild && /* @__PURE__ */(0, import_react.isValidElement)(children) && children.props && _type_of(children.props) === "object" && "children" in children.props ? children.props.children : children,
|
|
69
|
+
...options
|
|
70
|
+
});
|
|
71
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Comp, {
|
|
72
|
+
style: styles.tabsRoot,
|
|
73
|
+
...rest,
|
|
74
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(NavigationContent, {
|
|
75
|
+
children
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function useTabsWithChildren(options) {
|
|
80
|
+
var {
|
|
81
|
+
children,
|
|
82
|
+
...rest
|
|
83
|
+
} = options;
|
|
84
|
+
return useTabsWithTriggers({
|
|
85
|
+
triggers: parseTriggersFromChildren(children),
|
|
86
|
+
...rest
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function useTabsWithTriggers(options) {
|
|
90
|
+
var {
|
|
91
|
+
triggers,
|
|
92
|
+
...rest
|
|
93
|
+
} = options,
|
|
94
|
+
parentTriggerMap = (0, import_react.use)(import_TabContext.TabTriggerMapContext),
|
|
95
|
+
routeNode = (0, import_Route.useRouteNode)(),
|
|
96
|
+
contextKey = (0, import_Route.useContextKey)(),
|
|
97
|
+
linking = (0, import_react.use)(import_native.LinkingContext).options,
|
|
98
|
+
routeInfo = (0, import_hooks.useRouteInfo)();
|
|
99
|
+
if (!routeNode || !linking) throw new Error("No RouteNode. This is likely a bug in one router.");
|
|
100
|
+
var initialRouteName = routeNode.initialRouteName,
|
|
101
|
+
{
|
|
102
|
+
children,
|
|
103
|
+
triggerMap
|
|
104
|
+
} = (0, import_common.triggersToScreens)(triggers, routeNode, linking, initialRouteName, parentTriggerMap, routeInfo, contextKey),
|
|
105
|
+
navigatorContext = (0, import_native.useNavigationBuilder)(import_TabRouter.ExpoTabRouter, {
|
|
106
|
+
children,
|
|
107
|
+
...rest,
|
|
108
|
+
triggerMap,
|
|
109
|
+
id: contextKey,
|
|
110
|
+
initialRouteName
|
|
111
|
+
}),
|
|
112
|
+
{
|
|
113
|
+
state,
|
|
114
|
+
descriptors,
|
|
115
|
+
navigation,
|
|
116
|
+
describe,
|
|
117
|
+
NavigationContent: RNNavigationContent
|
|
118
|
+
} = navigatorContext,
|
|
119
|
+
navigatorContextValue = (0, import_react.useMemo)(function () {
|
|
120
|
+
return {
|
|
121
|
+
...navigatorContext,
|
|
122
|
+
contextKey,
|
|
123
|
+
router: import_TabRouter.ExpoTabRouter
|
|
124
|
+
};
|
|
125
|
+
}, [navigatorContext, contextKey, import_TabRouter.ExpoTabRouter]),
|
|
126
|
+
NavigationContent = (0, import_useComponent.useComponent)(function (children2) {
|
|
127
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_TabContext.TabTriggerMapContext.Provider, {
|
|
128
|
+
value: triggerMap,
|
|
129
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Navigator.NavigatorContext.Provider, {
|
|
130
|
+
value: navigatorContextValue,
|
|
131
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(RNNavigationContent, {
|
|
132
|
+
children: children2
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
state,
|
|
139
|
+
descriptors,
|
|
140
|
+
navigation,
|
|
141
|
+
NavigationContent,
|
|
142
|
+
describe
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function parseTriggersFromChildren(children) {
|
|
146
|
+
var screenTriggers = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [],
|
|
147
|
+
isInTabList = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
|
|
148
|
+
return import_react.Children.forEach(children, function (child) {
|
|
149
|
+
if (!(!child || ! /* @__PURE__ */(0, import_react.isValidElement)(child) || (0, import_TabSlot.isTabSlot)(child))) {
|
|
150
|
+
if (isFragment(child) && typeof child.props.children != "function") return parseTriggersFromChildren(child.props.children, screenTriggers, isInTabList || (0, import_TabList.isTabList)(child));
|
|
151
|
+
if ((0, import_TabList.isTabList)(child) && typeof child.props.children != "function") {
|
|
152
|
+
var _$children = child.props.children;
|
|
153
|
+
return child.props.asChild && /* @__PURE__ */(0, import_react.isValidElement)(_$children) && _$children.props && _type_of(_$children.props) === "object" && "children" in _$children.props && (_$children = _$children.props.children), parseTriggersFromChildren(_$children, screenTriggers, isInTabList || (0, import_TabList.isTabList)(child));
|
|
154
|
+
}
|
|
155
|
+
if (!(!isInTabList || !(0, import_TabTrigger.isTabTrigger)(child))) {
|
|
156
|
+
var {
|
|
157
|
+
href,
|
|
158
|
+
name
|
|
159
|
+
} = child.props;
|
|
160
|
+
if (!href) {
|
|
161
|
+
process.env.NODE_ENV === "development" && console.warn(`<TabTrigger name={${name}}> does not have a 'href' prop. TabTriggers within a <TabList /> are required to have an href.`);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
var resolvedHref = (0, import_href.resolveHref)(href);
|
|
165
|
+
if ((0, import_url.shouldLinkExternally)(resolvedHref)) return screenTriggers.push({
|
|
166
|
+
type: "external",
|
|
167
|
+
name,
|
|
168
|
+
href: resolvedHref
|
|
169
|
+
});
|
|
170
|
+
if (!name) {
|
|
171
|
+
process.env.NODE_ENV === "development" && console.warn("<TabTrigger> does not have a 'name' prop. TabTriggers within a <TabList /> are required to have a name.");
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
return screenTriggers.push({
|
|
175
|
+
type: "internal",
|
|
176
|
+
href: resolvedHref,
|
|
177
|
+
name
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}), screenTriggers;
|
|
182
|
+
}
|
|
183
|
+
function isFragment(child) {
|
|
184
|
+
return child.type === import_react.Fragment;
|
|
185
|
+
}
|
|
186
|
+
var styles = import_react_native.StyleSheet.create({
|
|
187
|
+
tabsRoot: {
|
|
188
|
+
flex: 1
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
//# sourceMappingURL=Tabs.native.js.map
|