@tamagui/tabs 1.125.34 → 1.126.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/dist/cjs/StyledContext.cjs +31 -0
- package/dist/cjs/StyledContext.js +23 -0
- package/dist/cjs/StyledContext.js.map +6 -0
- package/dist/cjs/StyledContext.native.js +28 -0
- package/dist/cjs/StyledContext.native.js.map +6 -0
- package/dist/cjs/Tabs.cjs +18 -242
- package/dist/cjs/Tabs.js +10 -210
- package/dist/cjs/Tabs.js.map +2 -2
- package/dist/cjs/Tabs.native.js +12 -193
- package/dist/cjs/Tabs.native.js.map +3 -3
- package/dist/cjs/createTabs.cjs +257 -0
- package/dist/cjs/createTabs.js +228 -0
- package/dist/cjs/createTabs.js.map +6 -0
- package/dist/cjs/createTabs.native.js +213 -0
- package/dist/cjs/createTabs.native.js.map +6 -0
- package/dist/cjs/index.cjs +19 -2
- package/dist/cjs/index.js +15 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +18 -3
- package/dist/cjs/index.native.js.map +3 -3
- package/dist/esm/StyledContext.js +7 -0
- package/dist/esm/StyledContext.js.map +6 -0
- package/dist/esm/StyledContext.mjs +7 -0
- package/dist/esm/StyledContext.mjs.map +1 -0
- package/dist/esm/StyledContext.native.js +7 -0
- package/dist/esm/StyledContext.native.js.map +1 -0
- package/dist/esm/Tabs.js +9 -210
- package/dist/esm/Tabs.js.map +2 -2
- package/dist/esm/Tabs.mjs +11 -225
- package/dist/esm/Tabs.mjs.map +1 -1
- package/dist/esm/Tabs.native.js +11 -241
- package/dist/esm/Tabs.native.js.map +1 -1
- package/dist/esm/createTabs.js +215 -0
- package/dist/esm/createTabs.js.map +6 -0
- package/dist/esm/createTabs.mjs +223 -0
- package/dist/esm/createTabs.mjs.map +1 -0
- package/dist/esm/createTabs.native.js +239 -0
- package/dist/esm/createTabs.native.js.map +1 -0
- package/dist/esm/index.js +12 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +10 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +10 -1
- package/dist/esm/index.native.js.map +1 -1
- package/dist/jsx/StyledContext.js +7 -0
- package/dist/jsx/StyledContext.js.map +6 -0
- package/dist/jsx/StyledContext.mjs +7 -0
- package/dist/jsx/StyledContext.mjs.map +1 -0
- package/dist/jsx/StyledContext.native.js +7 -0
- package/dist/jsx/StyledContext.native.js.map +6 -0
- package/dist/jsx/Tabs.js +9 -210
- package/dist/jsx/Tabs.js.map +2 -2
- package/dist/jsx/Tabs.mjs +11 -225
- package/dist/jsx/Tabs.mjs.map +1 -1
- package/dist/jsx/Tabs.native.js +9 -192
- package/dist/jsx/Tabs.native.js.map +3 -3
- package/dist/jsx/createTabs.js +215 -0
- package/dist/jsx/createTabs.js.map +6 -0
- package/dist/jsx/createTabs.mjs +223 -0
- package/dist/jsx/createTabs.mjs.map +1 -0
- package/dist/jsx/createTabs.native.js +195 -0
- package/dist/jsx/createTabs.native.js.map +6 -0
- package/dist/jsx/index.js +12 -1
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +10 -1
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/index.native.js +12 -1
- package/dist/jsx/index.native.js.map +3 -3
- package/package.json +13 -13
- package/src/StyledContext.tsx +19 -0
- package/src/Tabs.tsx +8 -444
- package/src/createTabs.tsx +437 -0
- package/src/index.ts +10 -1
- package/types/StyledContext.d.ts +19 -0
- package/types/StyledContext.d.ts.map +1 -0
- package/types/Tabs.d.ts +23 -784
- package/types/Tabs.d.ts.map +1 -1
- package/types/createTabs.d.ts +755 -0
- package/types/createTabs.d.ts.map +1 -0
- package/types/index.d.ts +724 -1
- package/types/index.d.ts.map +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
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) __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
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
var StyledContext_exports = {};
|
|
22
|
+
__export(StyledContext_exports, {
|
|
23
|
+
TabsProvider: () => TabsProvider,
|
|
24
|
+
useTabsContext: () => useTabsContext
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(StyledContext_exports);
|
|
27
|
+
var import_core = require("@tamagui/core");
|
|
28
|
+
const {
|
|
29
|
+
Provider: TabsProvider,
|
|
30
|
+
useStyledContext: useTabsContext
|
|
31
|
+
} = (0, import_core.createStyledContext)();
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var StyledContext_exports = {};
|
|
16
|
+
__export(StyledContext_exports, {
|
|
17
|
+
TabsProvider: () => TabsProvider,
|
|
18
|
+
useTabsContext: () => useTabsContext
|
|
19
|
+
});
|
|
20
|
+
module.exports = __toCommonJS(StyledContext_exports);
|
|
21
|
+
var import_core = require("@tamagui/core");
|
|
22
|
+
const { Provider: TabsProvider, useStyledContext: useTabsContext } = (0, import_core.createStyledContext)();
|
|
23
|
+
//# sourceMappingURL=StyledContext.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
+
var StyledContext_exports = {};
|
|
17
|
+
__export(StyledContext_exports, {
|
|
18
|
+
TabsProvider: () => TabsProvider,
|
|
19
|
+
useTabsContext: () => useTabsContext
|
|
20
|
+
});
|
|
21
|
+
module.exports = __toCommonJS(StyledContext_exports);
|
|
22
|
+
var import_core = require("@tamagui/core"), { Provider: TabsProvider, useStyledContext: useTabsContext } = (0, import_core.createStyledContext)();
|
|
23
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
24
|
+
0 && (module.exports = {
|
|
25
|
+
TabsProvider,
|
|
26
|
+
useTabsContext
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=StyledContext.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/StyledContext.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AACA;;;;;;kBAAoC,0BAgBvB,EAAEA,UAAUC,cAAcC,kBAAkBC,eAAc,QACrEC,iCAAAA;",
|
|
5
|
+
"names": ["Provider", "TabsProvider", "useStyledContext", "useTabsContext", "createStyledContext"]
|
|
6
|
+
}
|
package/dist/cjs/Tabs.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var
|
|
6
|
-
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all) __defProp(target, name, {
|
|
9
7
|
get: all[name],
|
|
@@ -17,66 +15,25 @@ var __export = (target, all) => {
|
|
|
17
15
|
});
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
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);
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
32
21
|
var Tabs_exports = {};
|
|
33
22
|
__export(Tabs_exports, {
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
DefaultTabsContentFrame: () => DefaultTabsContentFrame,
|
|
24
|
+
DefaultTabsFrame: () => DefaultTabsFrame,
|
|
25
|
+
DefaultTabsTabFrame: () => DefaultTabsTabFrame
|
|
36
26
|
});
|
|
37
27
|
module.exports = __toCommonJS(Tabs_exports);
|
|
38
|
-
var
|
|
39
|
-
import_constants = require("@tamagui/constants"),
|
|
40
|
-
import_get_button_sized = require("@tamagui/get-button-sized"),
|
|
41
|
-
import_group = require("@tamagui/group"),
|
|
42
|
-
import_helpers = require("@tamagui/helpers"),
|
|
43
|
-
import_roving_focus = require("@tamagui/roving-focus"),
|
|
28
|
+
var import_core = require("@tamagui/core"),
|
|
44
29
|
import_stacks = require("@tamagui/stacks"),
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
TabsList = React.forwardRef((props, forwardedRef) => {
|
|
53
|
-
const {
|
|
54
|
-
__scopeTabs,
|
|
55
|
-
loop = !0,
|
|
56
|
-
children,
|
|
57
|
-
...listProps
|
|
58
|
-
} = props,
|
|
59
|
-
context = useTabsContext(__scopeTabs);
|
|
60
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup, {
|
|
61
|
-
__scopeRovingFocusGroup: __scopeTabs || TABS_CONTEXT,
|
|
62
|
-
orientation: context.orientation,
|
|
63
|
-
dir: context.dir,
|
|
64
|
-
loop,
|
|
65
|
-
asChild: !0,
|
|
66
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_group.Group, {
|
|
67
|
-
role: "tablist",
|
|
68
|
-
componentName: TAB_LIST_NAME,
|
|
69
|
-
"aria-orientation": context.orientation,
|
|
70
|
-
ref: forwardedRef,
|
|
71
|
-
orientation: context.orientation,
|
|
72
|
-
...listProps,
|
|
73
|
-
children
|
|
74
|
-
})
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
TabsList.displayName = TAB_LIST_NAME;
|
|
78
|
-
const TRIGGER_NAME = "TabsTrigger",
|
|
79
|
-
TabsTriggerFrame = (0, import_web.styled)(import_stacks.ThemeableStack, {
|
|
30
|
+
import_get_button_sized = require("@tamagui/get-button-sized");
|
|
31
|
+
const TABS_NAME = "Tabs",
|
|
32
|
+
DefaultTabsFrame = (0, import_core.styled)(import_stacks.SizableStack, {
|
|
33
|
+
name: TABS_NAME
|
|
34
|
+
}),
|
|
35
|
+
TRIGGER_NAME = "TabsTrigger",
|
|
36
|
+
DefaultTabsTabFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
80
37
|
name: TRIGGER_NAME,
|
|
81
38
|
tag: "button",
|
|
82
39
|
variants: {
|
|
@@ -124,188 +81,7 @@ const TRIGGER_NAME = "TabsTrigger",
|
|
|
124
81
|
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
125
82
|
}
|
|
126
83
|
}),
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
__scopeTabs,
|
|
130
|
-
value,
|
|
131
|
-
disabled = !1,
|
|
132
|
-
onInteraction,
|
|
133
|
-
disableActiveTheme,
|
|
134
|
-
...triggerProps
|
|
135
|
-
} = props,
|
|
136
|
-
context = useTabsContext(__scopeTabs),
|
|
137
|
-
triggerId = makeTriggerId(context.baseId, value),
|
|
138
|
-
contentId = makeContentId(context.baseId, value),
|
|
139
|
-
isSelected = value === context.value,
|
|
140
|
-
[layout, setLayout] = React.useState(null),
|
|
141
|
-
triggerRef = React.useRef(null),
|
|
142
|
-
groupItemProps = (0, import_group.useGroupItem)({
|
|
143
|
-
disabled: !!disabled
|
|
144
|
-
});
|
|
145
|
-
return React.useEffect(() => (context.registerTrigger(), () => context.unregisterTrigger()), []), React.useEffect(() => {
|
|
146
|
-
if (!triggerRef.current || !import_constants.isWeb) return;
|
|
147
|
-
function getTriggerSize() {
|
|
148
|
-
triggerRef.current && setLayout({
|
|
149
|
-
width: triggerRef.current.offsetWidth,
|
|
150
|
-
height: triggerRef.current.offsetHeight,
|
|
151
|
-
x: triggerRef.current.offsetLeft,
|
|
152
|
-
y: triggerRef.current.offsetTop
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
getTriggerSize();
|
|
156
|
-
const observer = new ResizeObserver(getTriggerSize);
|
|
157
|
-
return observer.observe(triggerRef.current), () => {
|
|
158
|
-
triggerRef.current && observer.unobserve(triggerRef.current);
|
|
159
|
-
};
|
|
160
|
-
}, [context.triggersCount]), React.useEffect(() => {
|
|
161
|
-
isSelected && layout && onInteraction?.("select", layout);
|
|
162
|
-
}, [isSelected, value, layout]), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_web.Theme, {
|
|
163
|
-
name: isSelected && !disableActiveTheme ? "active" : null,
|
|
164
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup.Item, {
|
|
165
|
-
__scopeRovingFocusGroup: __scopeTabs || TABS_CONTEXT,
|
|
166
|
-
asChild: !0,
|
|
167
|
-
focusable: !disabled,
|
|
168
|
-
active: isSelected,
|
|
169
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(TabsTriggerFrame, {
|
|
170
|
-
onLayout: event => {
|
|
171
|
-
import_constants.isWeb || setLayout(event.nativeEvent.layout);
|
|
172
|
-
},
|
|
173
|
-
onHoverIn: (0, import_helpers.composeEventHandlers)(props.onHoverIn, () => {
|
|
174
|
-
layout && onInteraction?.("hover", layout);
|
|
175
|
-
}),
|
|
176
|
-
onHoverOut: (0, import_helpers.composeEventHandlers)(props.onHoverOut, () => {
|
|
177
|
-
onInteraction?.("hover", null);
|
|
178
|
-
}),
|
|
179
|
-
role: "tab",
|
|
180
|
-
"aria-selected": isSelected,
|
|
181
|
-
"aria-controls": contentId,
|
|
182
|
-
"data-state": isSelected ? "active" : "inactive",
|
|
183
|
-
"data-disabled": disabled ? "" : void 0,
|
|
184
|
-
disabled,
|
|
185
|
-
id: triggerId,
|
|
186
|
-
...(!props.unstyled && {
|
|
187
|
-
size: context.size
|
|
188
|
-
}),
|
|
189
|
-
...(isSelected && {
|
|
190
|
-
forceStyle: "focus"
|
|
191
|
-
}),
|
|
192
|
-
...groupItemProps,
|
|
193
|
-
...triggerProps,
|
|
194
|
-
ref: (0, import_compose_refs.composeRefs)(forwardedRef, triggerRef),
|
|
195
|
-
onPress: (0, import_helpers.composeEventHandlers)(props.onPress ?? void 0, event => {
|
|
196
|
-
const webChecks = !import_constants.isWeb || event.button === 0 && event.ctrlKey === !1;
|
|
197
|
-
!disabled && !isSelected && webChecks ? context.onChange(value) : event.preventDefault();
|
|
198
|
-
}),
|
|
199
|
-
...(import_constants.isWeb && {
|
|
200
|
-
type: "button",
|
|
201
|
-
onKeyDown: (0, import_helpers.composeEventHandlers)(props.onKeyDown, event => {
|
|
202
|
-
[" ", "Enter"].includes(event.key) && (context.onChange(value), event.preventDefault());
|
|
203
|
-
}),
|
|
204
|
-
onFocus: (0, import_helpers.composeEventHandlers)(props.onFocus, event => {
|
|
205
|
-
layout && onInteraction?.("focus", layout);
|
|
206
|
-
const isAutomaticActivation = context.activationMode !== "manual";
|
|
207
|
-
!isSelected && !disabled && isAutomaticActivation && context.onChange(value);
|
|
208
|
-
}),
|
|
209
|
-
onBlur: (0, import_helpers.composeEventHandlers)(props.onFocus, () => {
|
|
210
|
-
onInteraction?.("focus", null);
|
|
211
|
-
})
|
|
212
|
-
})
|
|
213
|
-
})
|
|
214
|
-
})
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
TabsTrigger.displayName = TRIGGER_NAME;
|
|
218
|
-
const CONTENT_NAME = "TabsContent",
|
|
219
|
-
TabsContentFrame = (0, import_web.styled)(import_stacks.ThemeableStack, {
|
|
84
|
+
CONTENT_NAME = "TabsContent",
|
|
85
|
+
DefaultTabsContentFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
220
86
|
name: CONTENT_NAME
|
|
221
|
-
})
|
|
222
|
-
TabsContent = TabsContentFrame.styleable(function (props, forwardedRef) {
|
|
223
|
-
const {
|
|
224
|
-
__scopeTabs,
|
|
225
|
-
value,
|
|
226
|
-
forceMount,
|
|
227
|
-
children,
|
|
228
|
-
...contentProps
|
|
229
|
-
} = props,
|
|
230
|
-
context = useTabsContext(__scopeTabs),
|
|
231
|
-
isSelected = value === context.value,
|
|
232
|
-
show = forceMount || isSelected,
|
|
233
|
-
triggerId = makeTriggerId(context.baseId, value),
|
|
234
|
-
contentId = makeContentId(context.baseId, value);
|
|
235
|
-
return show ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(TabsContentFrame, {
|
|
236
|
-
"data-state": isSelected ? "active" : "inactive",
|
|
237
|
-
"data-orientation": context.orientation,
|
|
238
|
-
role: "tabpanel",
|
|
239
|
-
"aria-labelledby": triggerId,
|
|
240
|
-
hidden: !show,
|
|
241
|
-
id: contentId,
|
|
242
|
-
tabIndex: 0,
|
|
243
|
-
...contentProps,
|
|
244
|
-
ref: forwardedRef,
|
|
245
|
-
children
|
|
246
|
-
}, value) : null;
|
|
247
|
-
}),
|
|
248
|
-
TABS_NAME = "Tabs",
|
|
249
|
-
{
|
|
250
|
-
Provider: TabsProvider,
|
|
251
|
-
useStyledContext: useTabsContext
|
|
252
|
-
} = (0, import_web.createStyledContext)(),
|
|
253
|
-
TabsFrame = (0, import_web.styled)(import_stacks.SizableStack, {
|
|
254
|
-
name: TABS_NAME
|
|
255
|
-
}),
|
|
256
|
-
TabsComponent = TabsFrame.styleable(function (props, forwardedRef) {
|
|
257
|
-
const {
|
|
258
|
-
__scopeTabs,
|
|
259
|
-
value: valueProp,
|
|
260
|
-
onValueChange,
|
|
261
|
-
defaultValue,
|
|
262
|
-
orientation = "horizontal",
|
|
263
|
-
dir,
|
|
264
|
-
activationMode = "automatic",
|
|
265
|
-
size = "$true",
|
|
266
|
-
...tabsProps
|
|
267
|
-
} = props,
|
|
268
|
-
direction = (0, import_use_direction.useDirection)(dir),
|
|
269
|
-
[value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
270
|
-
prop: valueProp,
|
|
271
|
-
onChange: onValueChange,
|
|
272
|
-
defaultProp: defaultValue ?? ""
|
|
273
|
-
}),
|
|
274
|
-
[triggersCount, setTriggersCount] = React.useState(0),
|
|
275
|
-
registerTrigger = (0, import_web.useEvent)(() => setTriggersCount(v => v + 1)),
|
|
276
|
-
unregisterTrigger = (0, import_web.useEvent)(() => setTriggersCount(v => v - 1));
|
|
277
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(TabsProvider, {
|
|
278
|
-
scope: __scopeTabs,
|
|
279
|
-
baseId: React.useId(),
|
|
280
|
-
value,
|
|
281
|
-
onChange: setValue,
|
|
282
|
-
orientation,
|
|
283
|
-
dir: direction,
|
|
284
|
-
activationMode,
|
|
285
|
-
size,
|
|
286
|
-
registerTrigger,
|
|
287
|
-
triggersCount,
|
|
288
|
-
unregisterTrigger,
|
|
289
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(TabsFrame, {
|
|
290
|
-
direction,
|
|
291
|
-
"data-orientation": orientation,
|
|
292
|
-
...tabsProps,
|
|
293
|
-
ref: forwardedRef
|
|
294
|
-
})
|
|
295
|
-
});
|
|
296
|
-
}),
|
|
297
|
-
Tabs2 = (0, import_helpers.withStaticProperties)(TabsComponent, {
|
|
298
|
-
List: TabsList,
|
|
299
|
-
/**
|
|
300
|
-
* @deprecated Use Tabs.Tab instead
|
|
301
|
-
*/
|
|
302
|
-
Trigger: TabsTrigger,
|
|
303
|
-
Tab: TabsTrigger,
|
|
304
|
-
Content: TabsContent
|
|
305
|
-
});
|
|
306
|
-
function makeTriggerId(baseId, value) {
|
|
307
|
-
return `${baseId}-trigger-${value}`;
|
|
308
|
-
}
|
|
309
|
-
function makeContentId(baseId, value) {
|
|
310
|
-
return `${baseId}-content-${value}`;
|
|
311
|
-
}
|
|
87
|
+
});
|
package/dist/cjs/Tabs.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
5
|
var __export = (target, all) => {
|
|
7
6
|
for (var name in all)
|
|
8
7
|
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
@@ -12,50 +11,18 @@ var __export = (target, all) => {
|
|
|
12
11
|
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
12
|
return to;
|
|
14
13
|
};
|
|
15
|
-
var
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
15
|
var Tabs_exports = {};
|
|
24
16
|
__export(Tabs_exports, {
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
DefaultTabsContentFrame: () => DefaultTabsContentFrame,
|
|
18
|
+
DefaultTabsFrame: () => DefaultTabsFrame,
|
|
19
|
+
DefaultTabsTabFrame: () => DefaultTabsTabFrame
|
|
27
20
|
});
|
|
28
21
|
module.exports = __toCommonJS(Tabs_exports);
|
|
29
|
-
var
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
34
|
-
import_roving_focus.RovingFocusGroup,
|
|
35
|
-
{
|
|
36
|
-
__scopeRovingFocusGroup: __scopeTabs || TABS_CONTEXT,
|
|
37
|
-
orientation: context.orientation,
|
|
38
|
-
dir: context.dir,
|
|
39
|
-
loop,
|
|
40
|
-
asChild: !0,
|
|
41
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
42
|
-
import_group.Group,
|
|
43
|
-
{
|
|
44
|
-
role: "tablist",
|
|
45
|
-
componentName: TAB_LIST_NAME,
|
|
46
|
-
"aria-orientation": context.orientation,
|
|
47
|
-
ref: forwardedRef,
|
|
48
|
-
orientation: context.orientation,
|
|
49
|
-
...listProps,
|
|
50
|
-
children
|
|
51
|
-
}
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
TabsList.displayName = TAB_LIST_NAME;
|
|
58
|
-
const TRIGGER_NAME = "TabsTrigger", TabsTriggerFrame = (0, import_web.styled)(import_stacks.ThemeableStack, {
|
|
22
|
+
var import_core = require("@tamagui/core"), import_stacks = require("@tamagui/stacks"), import_get_button_sized = require("@tamagui/get-button-sized");
|
|
23
|
+
const TABS_NAME = "Tabs", DefaultTabsFrame = (0, import_core.styled)(import_stacks.SizableStack, {
|
|
24
|
+
name: TABS_NAME
|
|
25
|
+
}), TRIGGER_NAME = "TabsTrigger", DefaultTabsTabFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
59
26
|
name: TRIGGER_NAME,
|
|
60
27
|
tag: "button",
|
|
61
28
|
variants: {
|
|
@@ -102,174 +69,7 @@ const TRIGGER_NAME = "TabsTrigger", TabsTriggerFrame = (0, import_web.styled)(im
|
|
|
102
69
|
defaultVariants: {
|
|
103
70
|
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
104
71
|
}
|
|
105
|
-
}),
|
|
106
|
-
(props, forwardedRef) => {
|
|
107
|
-
const {
|
|
108
|
-
__scopeTabs,
|
|
109
|
-
value,
|
|
110
|
-
disabled = !1,
|
|
111
|
-
onInteraction,
|
|
112
|
-
disableActiveTheme,
|
|
113
|
-
...triggerProps
|
|
114
|
-
} = props, context = useTabsContext(__scopeTabs), triggerId = makeTriggerId(context.baseId, value), contentId = makeContentId(context.baseId, value), isSelected = value === context.value, [layout, setLayout] = React.useState(null), triggerRef = React.useRef(null), groupItemProps = (0, import_group.useGroupItem)({ disabled: !!disabled });
|
|
115
|
-
return React.useEffect(() => (context.registerTrigger(), () => context.unregisterTrigger()), []), React.useEffect(() => {
|
|
116
|
-
if (!triggerRef.current || !import_constants.isWeb) return;
|
|
117
|
-
function getTriggerSize() {
|
|
118
|
-
triggerRef.current && setLayout({
|
|
119
|
-
width: triggerRef.current.offsetWidth,
|
|
120
|
-
height: triggerRef.current.offsetHeight,
|
|
121
|
-
x: triggerRef.current.offsetLeft,
|
|
122
|
-
y: triggerRef.current.offsetTop
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
getTriggerSize();
|
|
126
|
-
const observer = new ResizeObserver(getTriggerSize);
|
|
127
|
-
return observer.observe(triggerRef.current), () => {
|
|
128
|
-
triggerRef.current && observer.unobserve(triggerRef.current);
|
|
129
|
-
};
|
|
130
|
-
}, [context.triggersCount]), React.useEffect(() => {
|
|
131
|
-
isSelected && layout && onInteraction?.("select", layout);
|
|
132
|
-
}, [isSelected, value, layout]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.Theme, { name: isSelected && !disableActiveTheme ? "active" : null, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
133
|
-
import_roving_focus.RovingFocusGroup.Item,
|
|
134
|
-
{
|
|
135
|
-
__scopeRovingFocusGroup: __scopeTabs || TABS_CONTEXT,
|
|
136
|
-
asChild: !0,
|
|
137
|
-
focusable: !disabled,
|
|
138
|
-
active: isSelected,
|
|
139
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
140
|
-
TabsTriggerFrame,
|
|
141
|
-
{
|
|
142
|
-
onLayout: (event) => {
|
|
143
|
-
import_constants.isWeb || setLayout(event.nativeEvent.layout);
|
|
144
|
-
},
|
|
145
|
-
onHoverIn: (0, import_helpers.composeEventHandlers)(props.onHoverIn, () => {
|
|
146
|
-
layout && onInteraction?.("hover", layout);
|
|
147
|
-
}),
|
|
148
|
-
onHoverOut: (0, import_helpers.composeEventHandlers)(props.onHoverOut, () => {
|
|
149
|
-
onInteraction?.("hover", null);
|
|
150
|
-
}),
|
|
151
|
-
role: "tab",
|
|
152
|
-
"aria-selected": isSelected,
|
|
153
|
-
"aria-controls": contentId,
|
|
154
|
-
"data-state": isSelected ? "active" : "inactive",
|
|
155
|
-
"data-disabled": disabled ? "" : void 0,
|
|
156
|
-
disabled,
|
|
157
|
-
id: triggerId,
|
|
158
|
-
...!props.unstyled && {
|
|
159
|
-
size: context.size
|
|
160
|
-
},
|
|
161
|
-
...isSelected && {
|
|
162
|
-
forceStyle: "focus"
|
|
163
|
-
},
|
|
164
|
-
...groupItemProps,
|
|
165
|
-
...triggerProps,
|
|
166
|
-
ref: (0, import_compose_refs.composeRefs)(forwardedRef, triggerRef),
|
|
167
|
-
onPress: (0, import_helpers.composeEventHandlers)(props.onPress ?? void 0, (event) => {
|
|
168
|
-
const webChecks = !import_constants.isWeb || event.button === 0 && event.ctrlKey === !1;
|
|
169
|
-
!disabled && !isSelected && webChecks ? context.onChange(value) : event.preventDefault();
|
|
170
|
-
}),
|
|
171
|
-
...import_constants.isWeb && {
|
|
172
|
-
type: "button",
|
|
173
|
-
onKeyDown: (0, import_helpers.composeEventHandlers)(
|
|
174
|
-
props.onKeyDown,
|
|
175
|
-
(event) => {
|
|
176
|
-
[" ", "Enter"].includes(event.key) && (context.onChange(value), event.preventDefault());
|
|
177
|
-
}
|
|
178
|
-
),
|
|
179
|
-
onFocus: (0, import_helpers.composeEventHandlers)(props.onFocus, (event) => {
|
|
180
|
-
layout && onInteraction?.("focus", layout);
|
|
181
|
-
const isAutomaticActivation = context.activationMode !== "manual";
|
|
182
|
-
!isSelected && !disabled && isAutomaticActivation && context.onChange(value);
|
|
183
|
-
}),
|
|
184
|
-
onBlur: (0, import_helpers.composeEventHandlers)(props.onFocus, () => {
|
|
185
|
-
onInteraction?.("focus", null);
|
|
186
|
-
})
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
)
|
|
190
|
-
}
|
|
191
|
-
) });
|
|
192
|
-
}
|
|
193
|
-
);
|
|
194
|
-
TabsTrigger.displayName = TRIGGER_NAME;
|
|
195
|
-
const CONTENT_NAME = "TabsContent", TabsContentFrame = (0, import_web.styled)(import_stacks.ThemeableStack, {
|
|
72
|
+
}), CONTENT_NAME = "TabsContent", DefaultTabsContentFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
|
|
196
73
|
name: CONTENT_NAME
|
|
197
|
-
}), TabsContent = TabsContentFrame.styleable(
|
|
198
|
-
function(props, forwardedRef) {
|
|
199
|
-
const { __scopeTabs, value, forceMount, children, ...contentProps } = props, context = useTabsContext(__scopeTabs), isSelected = value === context.value, show = forceMount || isSelected, triggerId = makeTriggerId(context.baseId, value), contentId = makeContentId(context.baseId, value);
|
|
200
|
-
return show ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
201
|
-
TabsContentFrame,
|
|
202
|
-
{
|
|
203
|
-
"data-state": isSelected ? "active" : "inactive",
|
|
204
|
-
"data-orientation": context.orientation,
|
|
205
|
-
role: "tabpanel",
|
|
206
|
-
"aria-labelledby": triggerId,
|
|
207
|
-
hidden: !show,
|
|
208
|
-
id: contentId,
|
|
209
|
-
tabIndex: 0,
|
|
210
|
-
...contentProps,
|
|
211
|
-
ref: forwardedRef,
|
|
212
|
-
children
|
|
213
|
-
},
|
|
214
|
-
value
|
|
215
|
-
) : null;
|
|
216
|
-
}
|
|
217
|
-
), TABS_NAME = "Tabs", { Provider: TabsProvider, useStyledContext: useTabsContext } = (0, import_web.createStyledContext)(), TabsFrame = (0, import_web.styled)(import_stacks.SizableStack, {
|
|
218
|
-
name: TABS_NAME
|
|
219
|
-
}), TabsComponent = TabsFrame.styleable(function(props, forwardedRef) {
|
|
220
|
-
const {
|
|
221
|
-
__scopeTabs,
|
|
222
|
-
value: valueProp,
|
|
223
|
-
onValueChange,
|
|
224
|
-
defaultValue,
|
|
225
|
-
orientation = "horizontal",
|
|
226
|
-
dir,
|
|
227
|
-
activationMode = "automatic",
|
|
228
|
-
size = "$true",
|
|
229
|
-
...tabsProps
|
|
230
|
-
} = props, direction = (0, import_use_direction.useDirection)(dir), [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
231
|
-
prop: valueProp,
|
|
232
|
-
onChange: onValueChange,
|
|
233
|
-
defaultProp: defaultValue ?? ""
|
|
234
|
-
}), [triggersCount, setTriggersCount] = React.useState(0), registerTrigger = (0, import_web.useEvent)(() => setTriggersCount((v) => v + 1)), unregisterTrigger = (0, import_web.useEvent)(() => setTriggersCount((v) => v - 1));
|
|
235
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
236
|
-
TabsProvider,
|
|
237
|
-
{
|
|
238
|
-
scope: __scopeTabs,
|
|
239
|
-
baseId: React.useId(),
|
|
240
|
-
value,
|
|
241
|
-
onChange: setValue,
|
|
242
|
-
orientation,
|
|
243
|
-
dir: direction,
|
|
244
|
-
activationMode,
|
|
245
|
-
size,
|
|
246
|
-
registerTrigger,
|
|
247
|
-
triggersCount,
|
|
248
|
-
unregisterTrigger,
|
|
249
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
250
|
-
TabsFrame,
|
|
251
|
-
{
|
|
252
|
-
direction,
|
|
253
|
-
"data-orientation": orientation,
|
|
254
|
-
...tabsProps,
|
|
255
|
-
ref: forwardedRef
|
|
256
|
-
}
|
|
257
|
-
)
|
|
258
|
-
}
|
|
259
|
-
);
|
|
260
|
-
}), Tabs2 = (0, import_helpers.withStaticProperties)(TabsComponent, {
|
|
261
|
-
List: TabsList,
|
|
262
|
-
/**
|
|
263
|
-
* @deprecated Use Tabs.Tab instead
|
|
264
|
-
*/
|
|
265
|
-
Trigger: TabsTrigger,
|
|
266
|
-
Tab: TabsTrigger,
|
|
267
|
-
Content: TabsContent
|
|
268
74
|
});
|
|
269
|
-
function makeTriggerId(baseId, value) {
|
|
270
|
-
return `${baseId}-trigger-${value}`;
|
|
271
|
-
}
|
|
272
|
-
function makeContentId(baseId, value) {
|
|
273
|
-
return `${baseId}-content-${value}`;
|
|
274
|
-
}
|
|
275
75
|
//# sourceMappingURL=Tabs.js.map
|
package/dist/cjs/Tabs.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Tabs.tsx"],
|
|
4
|
-
"mappings": "
|
|
5
|
-
"names": [
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAuB,0BACvB,gBAA6C,4BAC7C,0BAA+B;AAE/B,MAAM,YAAY,QACL,uBAAmB,oBAAO,4BAAc;AAAA,EACnD,MAAM;AACR,CAAC,GAEK,eAAe,eAER,0BAAsB,oBAAO,8BAAgB;AAAA,EACxD,MAAM;AAAA,EACN,KAAK;AAAA,EAEL,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,WAAW;AAAA,IACb;AAAA,IAEA,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,IAEA,QAAQ;AAAA,MACN,MAAM;AAAA,QACJ,YAAY;AAAA,UACV,iBAAiB;AAAA,QACnB;AAAA,QAEA,YAAY;AAAA,UACV,iBAAiB;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAAA,IAEA,UAAU;AAAA,MACR,OAAO;AAAA,QACL,aAAa;AAAA,QACb,iBAAiB;AAAA,QACjB,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,eAAe;AAAA,QACf,QAAQ;AAAA,QAER,YAAY;AAAA,UACV,iBAAiB;AAAA,QACnB;AAAA,QAEA,YAAY;AAAA,UACV,iBAAiB;AAAA,QACnB;AAAA,QAEA,YAAY;AAAA,UACV,iBAAiB;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,iBAAiB;AAAA,IACf,UAAU,QAAQ,IAAI,qBAAqB;AAAA,EAC7C;AACF,CAAC,GAEK,eAAe,eAER,8BAA0B,oBAAO,8BAAgB;AAAA,EAC5D,MAAM;AACR,CAAC;",
|
|
5
|
+
"names": []
|
|
6
6
|
}
|