@hanzogui/tabs-headless 2.0.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.
@@ -0,0 +1,18 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ },
12
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
+ value: !0
15
+ }), mod);
16
+ var index_exports = {};
17
+ module.exports = __toCommonJS(index_exports);
18
+ __reExport(index_exports, require("./useTabs.cjs"), module.exports);
@@ -0,0 +1,21 @@
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 __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
9
+ get: () => from[key],
10
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
+ });
12
+ return to;
13
+ },
14
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
16
+ value: !0
17
+ }), mod);
18
+ var index_exports = {};
19
+ module.exports = __toCommonJS(index_exports);
20
+ __reExport(index_exports, require("./useTabs.native.js"), module.exports);
21
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA","ignoreList":[]}
@@ -0,0 +1,258 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var useTabs_exports = {};
33
+ __export(useTabs_exports, {
34
+ TabsProvider: () => TabsProvider,
35
+ useTab: () => useTab,
36
+ useTabContent: () => useTabContent,
37
+ useTabs: () => useTabs,
38
+ useTabsContext: () => useTabsContext
39
+ });
40
+ module.exports = __toCommonJS(useTabs_exports);
41
+ var import_gui_helpers = require("@hanzo/gui-helpers"),
42
+ import_gui_use_controllable_state = require("@hanzo/gui-use-controllable-state"),
43
+ import_gui_use_direction = require("@hanzo/gui-use-direction"),
44
+ React = __toESM(require("react"), 1),
45
+ import_react = require("react");
46
+ function useTabs(props = {}) {
47
+ const {
48
+ value: valueProp,
49
+ onValueChange,
50
+ defaultValue = "",
51
+ orientation = "horizontal",
52
+ dir,
53
+ activationMode = "automatic",
54
+ loop = !0
55
+ } = props,
56
+ direction = (0, import_gui_use_direction.useDirection)(dir),
57
+ baseId = (0, import_react.useId)(),
58
+ [value, setValue] = (0, import_gui_use_controllable_state.useControllableState)({
59
+ prop: valueProp,
60
+ onChange: onValueChange,
61
+ defaultProp: defaultValue
62
+ }),
63
+ tabRefs = (0, import_react.useRef)(/* @__PURE__ */new Map()),
64
+ [tabValues, setTabValues] = (0, import_react.useState)([]),
65
+ registerTab = (0, import_react.useCallback)((tabValue, element) => {
66
+ element ? (tabRefs.current.set(tabValue, element), setTabValues(prev => prev.includes(tabValue) ? prev : [...prev, tabValue])) : (tabRefs.current.delete(tabValue), setTabValues(prev => prev.filter(v => v !== tabValue)));
67
+ }, []),
68
+ focusTab = (0, import_react.useCallback)(tabValue => {
69
+ tabRefs.current.get(tabValue)?.focus();
70
+ }, []),
71
+ getNextTab = (0, import_react.useCallback)((currentValue, direction2) => {
72
+ const currentIndex = tabValues.indexOf(currentValue);
73
+ if (currentIndex === -1) return null;
74
+ let nextIndex = currentIndex + direction2;
75
+ if (loop) nextIndex = (nextIndex + tabValues.length) % tabValues.length;else if (nextIndex < 0 || nextIndex >= tabValues.length) return null;
76
+ return tabValues[nextIndex] ?? null;
77
+ }, [tabValues, loop]),
78
+ handleKeyDown = (0, import_react.useCallback)(tabValue => event => {
79
+ const isHorizontal = orientation === "horizontal",
80
+ isRtl = direction === "rtl";
81
+ let nextTab = null;
82
+ switch (event.key) {
83
+ case "ArrowRight":
84
+ isHorizontal && (nextTab = getNextTab(tabValue, isRtl ? -1 : 1));
85
+ break;
86
+ case "ArrowLeft":
87
+ isHorizontal && (nextTab = getNextTab(tabValue, isRtl ? 1 : -1));
88
+ break;
89
+ case "ArrowDown":
90
+ isHorizontal || (nextTab = getNextTab(tabValue, 1));
91
+ break;
92
+ case "ArrowUp":
93
+ isHorizontal || (nextTab = getNextTab(tabValue, -1));
94
+ break;
95
+ case "Home":
96
+ nextTab = tabValues[0] ?? null;
97
+ break;
98
+ case "End":
99
+ nextTab = tabValues[tabValues.length - 1] ?? null;
100
+ break;
101
+ case " ":
102
+ case "Enter":
103
+ activationMode === "manual" && (setValue(tabValue), event.preventDefault());
104
+ return;
105
+ }
106
+ nextTab && (event.preventDefault(), focusTab(nextTab), activationMode === "automatic" && setValue(nextTab));
107
+ }, [orientation, direction, getNextTab, tabValues, activationMode, setValue, focusTab]),
108
+ getTabProps = (0, import_react.useCallback)((tabValue, disabled) => {
109
+ const isSelected = value === tabValue,
110
+ triggerId = makeTriggerId(baseId, tabValue),
111
+ contentId = makeContentId(baseId, tabValue);
112
+ return {
113
+ role: "tab",
114
+ id: triggerId,
115
+ "aria-selected": isSelected,
116
+ "aria-controls": contentId,
117
+ "data-state": isSelected ? "active" : "inactive",
118
+ ...(disabled && {
119
+ "data-disabled": ""
120
+ }),
121
+ disabled,
122
+ tabIndex: isSelected ? 0 : -1,
123
+ onKeyDown: disabled ? () => {} : handleKeyDown(tabValue),
124
+ onClick: event => {
125
+ !disabled && !isSelected && setValue(tabValue);
126
+ },
127
+ onFocus: event => {
128
+ registerTab(tabValue, event.currentTarget), !disabled && !isSelected && activationMode === "automatic" && setValue(tabValue);
129
+ }
130
+ };
131
+ }, [value, baseId, handleKeyDown, setValue, activationMode, registerTab]),
132
+ getContentProps = (0, import_react.useCallback)(tabValue => {
133
+ const isSelected = value === tabValue,
134
+ triggerId = makeTriggerId(baseId, tabValue);
135
+ return {
136
+ role: "tabpanel",
137
+ id: makeContentId(baseId, tabValue),
138
+ "aria-labelledby": triggerId,
139
+ "data-state": isSelected ? "active" : "inactive",
140
+ "data-orientation": orientation,
141
+ hidden: !isSelected,
142
+ tabIndex: 0
143
+ };
144
+ }, [value, baseId, orientation]);
145
+ return {
146
+ value,
147
+ setValue,
148
+ direction,
149
+ tabsProps: {
150
+ "data-orientation": orientation,
151
+ dir: direction
152
+ },
153
+ listProps: {
154
+ role: "tablist",
155
+ "aria-orientation": orientation
156
+ },
157
+ getTabProps,
158
+ getContentProps,
159
+ contextValue: {
160
+ baseId,
161
+ value,
162
+ setValue,
163
+ orientation,
164
+ direction,
165
+ activationMode,
166
+ loop
167
+ }
168
+ };
169
+ }
170
+ const TabsContext = React.createContext(null),
171
+ TabsProvider = TabsContext.Provider;
172
+ function useTabsContext() {
173
+ const context = React.useContext(TabsContext);
174
+ if (!context) throw new Error("useTabsContext must be used within a TabsProvider");
175
+ return context;
176
+ }
177
+ function useTab(props) {
178
+ const {
179
+ value: tabValue,
180
+ disabled,
181
+ onPress,
182
+ onKeyDown,
183
+ onFocus
184
+ } = props,
185
+ context = useTabsContext(),
186
+ {
187
+ value,
188
+ setValue,
189
+ baseId,
190
+ activationMode,
191
+ orientation,
192
+ direction,
193
+ loop
194
+ } = context,
195
+ isSelected = value === tabValue,
196
+ triggerId = makeTriggerId(baseId, tabValue),
197
+ contentId = makeContentId(baseId, tabValue),
198
+ ref = (0, import_react.useRef)(null);
199
+ return {
200
+ isSelected,
201
+ tabProps: {
202
+ ref,
203
+ role: "tab",
204
+ id: triggerId,
205
+ "aria-selected": isSelected,
206
+ "aria-controls": contentId,
207
+ "data-state": isSelected ? "active" : "inactive",
208
+ ...(disabled && {
209
+ "data-disabled": ""
210
+ }),
211
+ disabled,
212
+ tabIndex: isSelected ? 0 : -1,
213
+ onKeyDown: (0, import_gui_helpers.composeEventHandlers)(onKeyDown, event => {
214
+ disabled || [" ", "Enter"].includes(event.key) && (setValue(tabValue), event.preventDefault());
215
+ }),
216
+ onPress: (0, import_gui_helpers.composeEventHandlers)(onPress, () => {
217
+ !disabled && !isSelected && setValue(tabValue);
218
+ }),
219
+ onFocus: (0, import_gui_helpers.composeEventHandlers)(onFocus, () => {
220
+ !disabled && !isSelected && activationMode === "automatic" && setValue(tabValue);
221
+ })
222
+ }
223
+ };
224
+ }
225
+ function useTabContent(props) {
226
+ const {
227
+ value: tabValue,
228
+ forceMount
229
+ } = props,
230
+ context = useTabsContext(),
231
+ {
232
+ value,
233
+ baseId,
234
+ orientation
235
+ } = context,
236
+ isSelected = value === tabValue,
237
+ triggerId = makeTriggerId(baseId, tabValue),
238
+ contentId = makeContentId(baseId, tabValue);
239
+ return {
240
+ isSelected,
241
+ shouldMount: forceMount || isSelected,
242
+ contentProps: {
243
+ role: "tabpanel",
244
+ id: contentId,
245
+ "aria-labelledby": triggerId,
246
+ "data-state": isSelected ? "active" : "inactive",
247
+ "data-orientation": orientation,
248
+ hidden: !isSelected,
249
+ tabIndex: 0
250
+ }
251
+ };
252
+ }
253
+ function makeTriggerId(baseId, value) {
254
+ return `${baseId}-trigger-${value}`;
255
+ }
256
+ function makeContentId(baseId, value) {
257
+ return `${baseId}-content-${value}`;
258
+ }
@@ -0,0 +1,276 @@
1
+ "use strict";
2
+
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf,
8
+ __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: !0
13
+ });
14
+ },
15
+ __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: !0
30
+ }) : target, mod)),
31
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: !0
33
+ }), mod);
34
+ var useTabs_exports = {};
35
+ __export(useTabs_exports, {
36
+ TabsProvider: () => TabsProvider,
37
+ useTab: () => useTab,
38
+ useTabContent: () => useTabContent,
39
+ useTabs: () => useTabs,
40
+ useTabsContext: () => useTabsContext
41
+ });
42
+ module.exports = __toCommonJS(useTabs_exports);
43
+ var import_gui_helpers = require("@hanzo/gui-helpers"),
44
+ import_gui_use_controllable_state = require("@hanzo/gui-use-controllable-state"),
45
+ import_gui_use_direction = require("@hanzo/gui-use-direction"),
46
+ React = __toESM(require("react"), 1),
47
+ import_react = require("react");
48
+ function useTabs() {
49
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {},
50
+ {
51
+ value: valueProp,
52
+ onValueChange,
53
+ defaultValue = "",
54
+ orientation = "horizontal",
55
+ dir,
56
+ activationMode = "automatic",
57
+ loop = !0
58
+ } = props,
59
+ direction = (0, import_gui_use_direction.useDirection)(dir),
60
+ baseId = (0, import_react.useId)(),
61
+ [value, setValue] = (0, import_gui_use_controllable_state.useControllableState)({
62
+ prop: valueProp,
63
+ onChange: onValueChange,
64
+ defaultProp: defaultValue
65
+ }),
66
+ tabRefs = (0, import_react.useRef)(/* @__PURE__ */new Map()),
67
+ [tabValues, setTabValues] = (0, import_react.useState)([]),
68
+ registerTab = (0, import_react.useCallback)(function (tabValue, element) {
69
+ element ? (tabRefs.current.set(tabValue, element), setTabValues(function (prev) {
70
+ return prev.includes(tabValue) ? prev : [...prev, tabValue];
71
+ })) : (tabRefs.current.delete(tabValue), setTabValues(function (prev) {
72
+ return prev.filter(function (v) {
73
+ return v !== tabValue;
74
+ });
75
+ }));
76
+ }, []),
77
+ focusTab = (0, import_react.useCallback)(function (tabValue) {
78
+ var element = tabRefs.current.get(tabValue);
79
+ element?.focus();
80
+ }, []),
81
+ getNextTab = (0, import_react.useCallback)(function (currentValue, direction2) {
82
+ var currentIndex = tabValues.indexOf(currentValue);
83
+ if (currentIndex === -1) return null;
84
+ var nextIndex = currentIndex + direction2;
85
+ if (loop) nextIndex = (nextIndex + tabValues.length) % tabValues.length;else if (nextIndex < 0 || nextIndex >= tabValues.length) return null;
86
+ var _tabValues_nextIndex;
87
+ return (_tabValues_nextIndex = tabValues[nextIndex]) !== null && _tabValues_nextIndex !== void 0 ? _tabValues_nextIndex : null;
88
+ }, [tabValues, loop]),
89
+ handleKeyDown = (0, import_react.useCallback)(function (tabValue) {
90
+ return function (event) {
91
+ var isHorizontal = orientation === "horizontal",
92
+ isRtl = direction === "rtl",
93
+ nextTab = null;
94
+ switch (event.key) {
95
+ case "ArrowRight":
96
+ isHorizontal && (nextTab = getNextTab(tabValue, isRtl ? -1 : 1));
97
+ break;
98
+ case "ArrowLeft":
99
+ isHorizontal && (nextTab = getNextTab(tabValue, isRtl ? 1 : -1));
100
+ break;
101
+ case "ArrowDown":
102
+ isHorizontal || (nextTab = getNextTab(tabValue, 1));
103
+ break;
104
+ case "ArrowUp":
105
+ isHorizontal || (nextTab = getNextTab(tabValue, -1));
106
+ break;
107
+ case "Home":
108
+ var _tabValues_;
109
+ nextTab = (_tabValues_ = tabValues[0]) !== null && _tabValues_ !== void 0 ? _tabValues_ : null;
110
+ break;
111
+ case "End":
112
+ var _tabValues_1;
113
+ nextTab = (_tabValues_1 = tabValues[tabValues.length - 1]) !== null && _tabValues_1 !== void 0 ? _tabValues_1 : null;
114
+ break;
115
+ case " ":
116
+ case "Enter":
117
+ activationMode === "manual" && (setValue(tabValue), event.preventDefault());
118
+ return;
119
+ }
120
+ nextTab && (event.preventDefault(), focusTab(nextTab), activationMode === "automatic" && setValue(nextTab));
121
+ };
122
+ }, [orientation, direction, getNextTab, tabValues, activationMode, setValue, focusTab]),
123
+ getTabProps = (0, import_react.useCallback)(function (tabValue, disabled) {
124
+ var isSelected = value === tabValue,
125
+ triggerId = makeTriggerId(baseId, tabValue),
126
+ contentId = makeContentId(baseId, tabValue);
127
+ return {
128
+ role: "tab",
129
+ id: triggerId,
130
+ "aria-selected": isSelected,
131
+ "aria-controls": contentId,
132
+ "data-state": isSelected ? "active" : "inactive",
133
+ ...(disabled && {
134
+ "data-disabled": ""
135
+ }),
136
+ disabled,
137
+ tabIndex: isSelected ? 0 : -1,
138
+ onKeyDown: disabled ? function () {} : handleKeyDown(tabValue),
139
+ onClick: function (event) {
140
+ !disabled && !isSelected && setValue(tabValue);
141
+ },
142
+ onFocus: function (event) {
143
+ registerTab(tabValue, event.currentTarget), !disabled && !isSelected && activationMode === "automatic" && setValue(tabValue);
144
+ }
145
+ };
146
+ }, [value, baseId, handleKeyDown, setValue, activationMode, registerTab]),
147
+ getContentProps = (0, import_react.useCallback)(function (tabValue) {
148
+ var isSelected = value === tabValue,
149
+ triggerId = makeTriggerId(baseId, tabValue),
150
+ contentId = makeContentId(baseId, tabValue);
151
+ return {
152
+ role: "tabpanel",
153
+ id: contentId,
154
+ "aria-labelledby": triggerId,
155
+ "data-state": isSelected ? "active" : "inactive",
156
+ "data-orientation": orientation,
157
+ hidden: !isSelected,
158
+ tabIndex: 0
159
+ };
160
+ }, [value, baseId, orientation]),
161
+ contextValue = {
162
+ baseId,
163
+ value,
164
+ setValue,
165
+ orientation,
166
+ direction,
167
+ activationMode,
168
+ loop
169
+ };
170
+ return {
171
+ value,
172
+ setValue,
173
+ direction,
174
+ tabsProps: {
175
+ "data-orientation": orientation,
176
+ dir: direction
177
+ },
178
+ listProps: {
179
+ role: "tablist",
180
+ "aria-orientation": orientation
181
+ },
182
+ getTabProps,
183
+ getContentProps,
184
+ contextValue
185
+ };
186
+ }
187
+ var TabsContext = /* @__PURE__ */React.createContext(null),
188
+ TabsProvider = TabsContext.Provider;
189
+ function useTabsContext() {
190
+ var context = React.useContext(TabsContext);
191
+ if (!context) throw new Error("useTabsContext must be used within a TabsProvider");
192
+ return context;
193
+ }
194
+ function useTab(props) {
195
+ var {
196
+ value: tabValue,
197
+ disabled,
198
+ onPress,
199
+ onKeyDown,
200
+ onFocus
201
+ } = props,
202
+ context = useTabsContext(),
203
+ {
204
+ value,
205
+ setValue,
206
+ baseId,
207
+ activationMode,
208
+ orientation,
209
+ direction,
210
+ loop
211
+ } = context,
212
+ isSelected = value === tabValue,
213
+ triggerId = makeTriggerId(baseId, tabValue),
214
+ contentId = makeContentId(baseId, tabValue),
215
+ ref = (0, import_react.useRef)(null);
216
+ return {
217
+ isSelected,
218
+ tabProps: {
219
+ ref,
220
+ role: "tab",
221
+ id: triggerId,
222
+ "aria-selected": isSelected,
223
+ "aria-controls": contentId,
224
+ "data-state": isSelected ? "active" : "inactive",
225
+ ...(disabled && {
226
+ "data-disabled": ""
227
+ }),
228
+ disabled,
229
+ tabIndex: isSelected ? 0 : -1,
230
+ onKeyDown: (0, import_gui_helpers.composeEventHandlers)(onKeyDown, function (event) {
231
+ disabled || [" ", "Enter"].includes(event.key) && (setValue(tabValue), event.preventDefault());
232
+ }),
233
+ onPress: (0, import_gui_helpers.composeEventHandlers)(onPress, function () {
234
+ !disabled && !isSelected && setValue(tabValue);
235
+ }),
236
+ onFocus: (0, import_gui_helpers.composeEventHandlers)(onFocus, function () {
237
+ !disabled && !isSelected && activationMode === "automatic" && setValue(tabValue);
238
+ })
239
+ }
240
+ };
241
+ }
242
+ function useTabContent(props) {
243
+ var {
244
+ value: tabValue,
245
+ forceMount
246
+ } = props,
247
+ context = useTabsContext(),
248
+ {
249
+ value,
250
+ baseId,
251
+ orientation
252
+ } = context,
253
+ isSelected = value === tabValue,
254
+ triggerId = makeTriggerId(baseId, tabValue),
255
+ contentId = makeContentId(baseId, tabValue);
256
+ return {
257
+ isSelected,
258
+ shouldMount: forceMount || isSelected,
259
+ contentProps: {
260
+ role: "tabpanel",
261
+ id: contentId,
262
+ "aria-labelledby": triggerId,
263
+ "data-state": isSelected ? "active" : "inactive",
264
+ "data-orientation": orientation,
265
+ hidden: !isSelected,
266
+ tabIndex: 0
267
+ }
268
+ };
269
+ }
270
+ function makeTriggerId(baseId, value) {
271
+ return `${baseId}-trigger-${value}`;
272
+ }
273
+ function makeContentId(baseId, value) {
274
+ return `${baseId}-content-${value}`;
275
+ }
276
+ //# sourceMappingURL=useTabs.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","useTabs_exports","__export","TabsProvider","useTab","useTabContent","useTabs","useTabsContext","module","exports","import_gui_helpers","require","import_gui_use_controllable_state","import_gui_use_direction","React","__toESM","import_react","props","arguments","length","valueProp","onValueChange","defaultValue","orientation","dir","activationMode","loop","direction","useDirection","baseId","useId","setValue","useControllableState","prop","onChange","defaultProp","tabRefs","useRef","Map","tabValues","setTabValues","useState","registerTab","useCallback","tabValue","element","current","set","prev","includes","delete","filter","v","focusTab","get","focus","getNextTab","currentValue","direction2","currentIndex","indexOf","nextIndex","_tabValues_nextIndex","handleKeyDown","event","isHorizontal","isRtl","nextTab","key","_tabValues_","_tabValues_1","preventDefault","getTabProps","disabled","isSelected","triggerId","makeTriggerId","contentId","makeContentId","role","id","tabIndex","onKeyDown","onClick","onFocus","currentTarget","getContentProps","hidden","contextValue","tabsProps","listProps","TabsContext","createContext","Provider","context","useContext","Error","onPress","ref","tabPro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A,YAAAlB,KAAA;QACtCS,QAAA,KACA,KACA,OAAU,CACZ,CAAAxB,QAAA,CAAAe,KAAA,CAAAI,GAAA,MAAArC,QAAA,CAAAa,QAAA,GAAAoB,KAAA,CAAAO,cAAA;MACF;MACF0B,OAAA,MAAAvF,kBAAA,CAAA0F,oBAAA,EAAAH,OAAA;QAMA,CAASxB,QAAA,KAAAC,UAA8B,IAAA3C,QAAe,CAAAa,QAAA;MACpD;MACFwC,OAAA,MAAA1E,kBAAA,CAAA0F,oBAAA,EAAAhB,OAAA;QAEA,CAASX,QAAA,KAAAC,UAA8B,IAAAjD,cAAe,oBAAAM,QAAA,CAAAa,QAAA;MACpD;IACF","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./useTabs.mjs";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./useTabs.mjs";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./useTabs.native.js";
2
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}