@tamagui/tabs 1.114.3 → 1.115.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/Tabs.cjs +308 -0
- package/dist/cjs/index.cjs +18 -0
- package/package.json +15 -14
- package/dist/cjs/Tabs.js +0 -274
- package/dist/cjs/index.js +0 -15
- /package/dist/cjs/{Tabs.js.map → Tabs.cjs.map} +0 -0
- /package/dist/cjs/{index.js.map → index.cjs.map} +0 -0
|
@@ -0,0 +1,308 @@
|
|
|
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 Tabs_exports = {};
|
|
33
|
+
__export(Tabs_exports, {
|
|
34
|
+
Tabs: () => Tabs,
|
|
35
|
+
useTabsContext: () => useTabsContext
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(Tabs_exports);
|
|
38
|
+
var import_compose_refs = require("@tamagui/compose-refs"),
|
|
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"),
|
|
44
|
+
import_stacks = require("@tamagui/stacks"),
|
|
45
|
+
import_use_controllable_state = require("@tamagui/use-controllable-state"),
|
|
46
|
+
import_use_direction = require("@tamagui/use-direction"),
|
|
47
|
+
import_web = require("@tamagui/web"),
|
|
48
|
+
React = __toESM(require("react")),
|
|
49
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
50
|
+
const TABS_CONTEXT = "TabsContext",
|
|
51
|
+
TAB_LIST_NAME = "TabsList",
|
|
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, {
|
|
80
|
+
name: TRIGGER_NAME,
|
|
81
|
+
tag: "button",
|
|
82
|
+
justifyContent: "center",
|
|
83
|
+
alignItems: "center",
|
|
84
|
+
flexWrap: "nowrap",
|
|
85
|
+
flexDirection: "row",
|
|
86
|
+
cursor: "pointer",
|
|
87
|
+
userSelect: "none",
|
|
88
|
+
variants: {
|
|
89
|
+
size: {
|
|
90
|
+
"...size": import_get_button_sized.getButtonSized
|
|
91
|
+
},
|
|
92
|
+
disabled: {
|
|
93
|
+
true: {
|
|
94
|
+
pointerEvents: "none"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
active: {
|
|
98
|
+
true: {
|
|
99
|
+
hoverStyle: {
|
|
100
|
+
backgroundColor: "$background"
|
|
101
|
+
},
|
|
102
|
+
focusStyle: {
|
|
103
|
+
backgroundColor: "$background"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
unstyled: {
|
|
108
|
+
false: {
|
|
109
|
+
backgroundColor: "$background",
|
|
110
|
+
pressStyle: {
|
|
111
|
+
backgroundColor: "$backgroundPress"
|
|
112
|
+
},
|
|
113
|
+
hoverStyle: {
|
|
114
|
+
backgroundColor: "$backgroundHover"
|
|
115
|
+
},
|
|
116
|
+
focusStyle: {
|
|
117
|
+
backgroundColor: "$backgroundFocus"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
defaultVariants: {
|
|
123
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
124
|
+
}
|
|
125
|
+
}),
|
|
126
|
+
TabsTrigger = TabsTriggerFrame.styleable((props, forwardedRef) => {
|
|
127
|
+
const {
|
|
128
|
+
__scopeTabs,
|
|
129
|
+
value,
|
|
130
|
+
disabled = !1,
|
|
131
|
+
onInteraction,
|
|
132
|
+
disableActiveTheme,
|
|
133
|
+
...triggerProps
|
|
134
|
+
} = props,
|
|
135
|
+
context = useTabsContext(__scopeTabs),
|
|
136
|
+
triggerId = makeTriggerId(context.baseId, value),
|
|
137
|
+
contentId = makeContentId(context.baseId, value),
|
|
138
|
+
isSelected = value === context.value,
|
|
139
|
+
[layout, setLayout] = React.useState(null),
|
|
140
|
+
triggerRef = React.useRef(null),
|
|
141
|
+
groupItemProps = (0, import_group.useGroupItem)({
|
|
142
|
+
disabled: !!disabled
|
|
143
|
+
});
|
|
144
|
+
return React.useEffect(() => (context.registerTrigger(), () => context.unregisterTrigger()), []), React.useEffect(() => {
|
|
145
|
+
if (!triggerRef.current || !import_constants.isWeb) return;
|
|
146
|
+
function getTriggerSize() {
|
|
147
|
+
triggerRef.current && setLayout({
|
|
148
|
+
width: triggerRef.current.offsetWidth,
|
|
149
|
+
height: triggerRef.current.offsetHeight,
|
|
150
|
+
x: triggerRef.current.offsetLeft,
|
|
151
|
+
y: triggerRef.current.offsetTop
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
getTriggerSize();
|
|
155
|
+
const observer = new ResizeObserver(getTriggerSize);
|
|
156
|
+
return observer.observe(triggerRef.current), () => {
|
|
157
|
+
triggerRef.current && observer.unobserve(triggerRef.current);
|
|
158
|
+
};
|
|
159
|
+
}, [context.triggersCount]), React.useEffect(() => {
|
|
160
|
+
isSelected && layout && onInteraction?.("select", layout);
|
|
161
|
+
}, [isSelected, value, layout]), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_web.Theme, {
|
|
162
|
+
name: isSelected && !disableActiveTheme ? "active" : null,
|
|
163
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_roving_focus.RovingFocusGroup.Item, {
|
|
164
|
+
__scopeRovingFocusGroup: __scopeTabs || TABS_CONTEXT,
|
|
165
|
+
asChild: !0,
|
|
166
|
+
focusable: !disabled,
|
|
167
|
+
active: isSelected,
|
|
168
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(TabsTriggerFrame, {
|
|
169
|
+
onLayout: event => {
|
|
170
|
+
import_constants.isWeb || setLayout(event.nativeEvent.layout);
|
|
171
|
+
},
|
|
172
|
+
onHoverIn: (0, import_helpers.composeEventHandlers)(props.onHoverIn, () => {
|
|
173
|
+
layout && onInteraction?.("hover", layout);
|
|
174
|
+
}),
|
|
175
|
+
onHoverOut: (0, import_helpers.composeEventHandlers)(props.onHoverOut, () => {
|
|
176
|
+
onInteraction?.("hover", null);
|
|
177
|
+
}),
|
|
178
|
+
role: "tab",
|
|
179
|
+
"aria-selected": isSelected,
|
|
180
|
+
"aria-controls": contentId,
|
|
181
|
+
"data-state": isSelected ? "active" : "inactive",
|
|
182
|
+
"data-disabled": disabled ? "" : void 0,
|
|
183
|
+
disabled,
|
|
184
|
+
id: triggerId,
|
|
185
|
+
...(!props.unstyled && {
|
|
186
|
+
size: context.size
|
|
187
|
+
}),
|
|
188
|
+
...groupItemProps,
|
|
189
|
+
...triggerProps,
|
|
190
|
+
ref: (0, import_compose_refs.composeRefs)(forwardedRef, triggerRef),
|
|
191
|
+
onPress: (0, import_helpers.composeEventHandlers)(props.onPress ?? void 0, event => {
|
|
192
|
+
const webChecks = !import_constants.isWeb || event.button === 0 && event.ctrlKey === !1;
|
|
193
|
+
!disabled && !isSelected && webChecks ? context.onChange(value) : event.preventDefault();
|
|
194
|
+
}),
|
|
195
|
+
...(import_constants.isWeb && {
|
|
196
|
+
type: "button",
|
|
197
|
+
onKeyDown: (0, import_helpers.composeEventHandlers)(props.onKeyDown, event => {
|
|
198
|
+
[" ", "Enter"].includes(event.key) && (context.onChange(value), event.preventDefault());
|
|
199
|
+
}),
|
|
200
|
+
onFocus: (0, import_helpers.composeEventHandlers)(props.onFocus, event => {
|
|
201
|
+
layout && onInteraction?.("focus", layout);
|
|
202
|
+
const isAutomaticActivation = context.activationMode !== "manual";
|
|
203
|
+
!isSelected && !disabled && isAutomaticActivation && context.onChange(value);
|
|
204
|
+
}),
|
|
205
|
+
onBlur: (0, import_helpers.composeEventHandlers)(props.onFocus, () => {
|
|
206
|
+
onInteraction?.("focus", null);
|
|
207
|
+
})
|
|
208
|
+
})
|
|
209
|
+
})
|
|
210
|
+
})
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
TabsTrigger.displayName = TRIGGER_NAME;
|
|
214
|
+
const CONTENT_NAME = "TabsContent",
|
|
215
|
+
TabsContentFrame = (0, import_web.styled)(import_stacks.ThemeableStack, {
|
|
216
|
+
name: CONTENT_NAME
|
|
217
|
+
}),
|
|
218
|
+
TabsContent = TabsContentFrame.styleable(function (props, forwardedRef) {
|
|
219
|
+
const {
|
|
220
|
+
__scopeTabs,
|
|
221
|
+
value,
|
|
222
|
+
forceMount,
|
|
223
|
+
children,
|
|
224
|
+
...contentProps
|
|
225
|
+
} = props,
|
|
226
|
+
context = useTabsContext(__scopeTabs),
|
|
227
|
+
isSelected = value === context.value,
|
|
228
|
+
show = forceMount || isSelected,
|
|
229
|
+
triggerId = makeTriggerId(context.baseId, value),
|
|
230
|
+
contentId = makeContentId(context.baseId, value);
|
|
231
|
+
return show ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(TabsContentFrame, {
|
|
232
|
+
"data-state": isSelected ? "active" : "inactive",
|
|
233
|
+
"data-orientation": context.orientation,
|
|
234
|
+
role: "tabpanel",
|
|
235
|
+
"aria-labelledby": triggerId,
|
|
236
|
+
hidden: !show,
|
|
237
|
+
id: contentId,
|
|
238
|
+
tabIndex: 0,
|
|
239
|
+
...contentProps,
|
|
240
|
+
ref: forwardedRef,
|
|
241
|
+
children
|
|
242
|
+
}, value) : null;
|
|
243
|
+
}),
|
|
244
|
+
TABS_NAME = "Tabs",
|
|
245
|
+
{
|
|
246
|
+
Provider: TabsProvider,
|
|
247
|
+
useStyledContext: useTabsContext
|
|
248
|
+
} = (0, import_web.createStyledContext)(),
|
|
249
|
+
TabsFrame = (0, import_web.styled)(import_stacks.SizableStack, {
|
|
250
|
+
name: TABS_NAME
|
|
251
|
+
}),
|
|
252
|
+
TabsComponent = TabsFrame.styleable((props, forwardedRef) => {
|
|
253
|
+
const {
|
|
254
|
+
__scopeTabs,
|
|
255
|
+
value: valueProp,
|
|
256
|
+
onValueChange,
|
|
257
|
+
defaultValue,
|
|
258
|
+
orientation = "horizontal",
|
|
259
|
+
dir,
|
|
260
|
+
activationMode = "automatic",
|
|
261
|
+
size = "$true",
|
|
262
|
+
...tabsProps
|
|
263
|
+
} = props,
|
|
264
|
+
direction = (0, import_use_direction.useDirection)(dir),
|
|
265
|
+
[value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
266
|
+
prop: valueProp,
|
|
267
|
+
onChange: onValueChange,
|
|
268
|
+
defaultProp: defaultValue ?? ""
|
|
269
|
+
}),
|
|
270
|
+
[triggersCount, setTriggersCount] = React.useState(0),
|
|
271
|
+
registerTrigger = (0, import_web.useEvent)(() => setTriggersCount(v => v + 1)),
|
|
272
|
+
unregisterTrigger = (0, import_web.useEvent)(() => setTriggersCount(v => v - 1));
|
|
273
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(TabsProvider, {
|
|
274
|
+
scope: __scopeTabs,
|
|
275
|
+
baseId: React.useId(),
|
|
276
|
+
value,
|
|
277
|
+
onChange: setValue,
|
|
278
|
+
orientation,
|
|
279
|
+
dir: direction,
|
|
280
|
+
activationMode,
|
|
281
|
+
size,
|
|
282
|
+
registerTrigger,
|
|
283
|
+
triggersCount,
|
|
284
|
+
unregisterTrigger,
|
|
285
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(TabsFrame, {
|
|
286
|
+
direction,
|
|
287
|
+
"data-orientation": orientation,
|
|
288
|
+
...tabsProps,
|
|
289
|
+
ref: forwardedRef
|
|
290
|
+
})
|
|
291
|
+
});
|
|
292
|
+
}),
|
|
293
|
+
Tabs = (0, import_helpers.withStaticProperties)(TabsComponent, {
|
|
294
|
+
List: TabsList,
|
|
295
|
+
/**
|
|
296
|
+
* @deprecated Use Tabs.Tab instead
|
|
297
|
+
*/
|
|
298
|
+
Trigger: TabsTrigger,
|
|
299
|
+
Tab: TabsTrigger,
|
|
300
|
+
Content: TabsContent
|
|
301
|
+
});
|
|
302
|
+
Tabs.displayName = TABS_NAME;
|
|
303
|
+
function makeTriggerId(baseId, value) {
|
|
304
|
+
return `${baseId}-trigger-${value}`;
|
|
305
|
+
}
|
|
306
|
+
function makeContentId(baseId, value) {
|
|
307
|
+
return `${baseId}-content-${value}`;
|
|
308
|
+
}
|
|
@@ -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 src_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(src_exports);
|
|
18
|
+
__reExport(src_exports, require("./Tabs.cjs"), module.exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/tabs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.115.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -27,27 +27,28 @@
|
|
|
27
27
|
"react-native": "./dist/cjs/index.native.js",
|
|
28
28
|
"types": "./types/index.d.ts",
|
|
29
29
|
"import": "./dist/esm/index.mjs",
|
|
30
|
-
"require": "./dist/cjs/index.
|
|
30
|
+
"require": "./dist/cjs/index.cjs",
|
|
31
|
+
"default": "./dist/cjs/index.native.js"
|
|
31
32
|
}
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@tamagui/compose-refs": "1.
|
|
35
|
-
"@tamagui/constants": "1.
|
|
36
|
-
"@tamagui/create-context": "1.
|
|
37
|
-
"@tamagui/get-button-sized": "1.
|
|
38
|
-
"@tamagui/group": "1.
|
|
39
|
-
"@tamagui/helpers": "1.
|
|
40
|
-
"@tamagui/roving-focus": "1.
|
|
41
|
-
"@tamagui/stacks": "1.
|
|
42
|
-
"@tamagui/use-controllable-state": "1.
|
|
43
|
-
"@tamagui/use-direction": "1.
|
|
44
|
-
"@tamagui/web": "1.
|
|
35
|
+
"@tamagui/compose-refs": "1.115.0",
|
|
36
|
+
"@tamagui/constants": "1.115.0",
|
|
37
|
+
"@tamagui/create-context": "1.115.0",
|
|
38
|
+
"@tamagui/get-button-sized": "1.115.0",
|
|
39
|
+
"@tamagui/group": "1.115.0",
|
|
40
|
+
"@tamagui/helpers": "1.115.0",
|
|
41
|
+
"@tamagui/roving-focus": "1.115.0",
|
|
42
|
+
"@tamagui/stacks": "1.115.0",
|
|
43
|
+
"@tamagui/use-controllable-state": "1.115.0",
|
|
44
|
+
"@tamagui/use-direction": "1.115.0",
|
|
45
|
+
"@tamagui/web": "1.115.0"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
48
|
"react": "*"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
|
-
"@tamagui/build": "1.
|
|
51
|
+
"@tamagui/build": "1.115.0",
|
|
51
52
|
"react": "^18.2.0 || ^19.0.0",
|
|
52
53
|
"react-dom": "^18.2.0 || ^19.0.0"
|
|
53
54
|
},
|
package/dist/cjs/Tabs.js
DELETED
|
@@ -1,274 +0,0 @@
|
|
|
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, __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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
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);
|
|
23
|
-
var Tabs_exports = {};
|
|
24
|
-
__export(Tabs_exports, {
|
|
25
|
-
Tabs: () => Tabs,
|
|
26
|
-
useTabsContext: () => useTabsContext
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(Tabs_exports);
|
|
29
|
-
var import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_get_button_sized = require("@tamagui/get-button-sized"), import_group = require("@tamagui/group"), import_helpers = require("@tamagui/helpers"), import_roving_focus = require("@tamagui/roving-focus"), import_stacks = require("@tamagui/stacks"), import_use_controllable_state = require("@tamagui/use-controllable-state"), import_use_direction = require("@tamagui/use-direction"), import_web = require("@tamagui/web"), React = __toESM(require("react")), import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
-
const TABS_CONTEXT = "TabsContext", TAB_LIST_NAME = "TabsList", TabsList = React.forwardRef(
|
|
31
|
-
(props, forwardedRef) => {
|
|
32
|
-
const { __scopeTabs, loop = !0, children, ...listProps } = props, context = useTabsContext(__scopeTabs);
|
|
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, {
|
|
59
|
-
name: TRIGGER_NAME,
|
|
60
|
-
tag: "button",
|
|
61
|
-
justifyContent: "center",
|
|
62
|
-
alignItems: "center",
|
|
63
|
-
flexWrap: "nowrap",
|
|
64
|
-
flexDirection: "row",
|
|
65
|
-
cursor: "pointer",
|
|
66
|
-
userSelect: "none",
|
|
67
|
-
variants: {
|
|
68
|
-
size: {
|
|
69
|
-
"...size": import_get_button_sized.getButtonSized
|
|
70
|
-
},
|
|
71
|
-
disabled: {
|
|
72
|
-
true: {
|
|
73
|
-
pointerEvents: "none"
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
active: {
|
|
77
|
-
true: {
|
|
78
|
-
hoverStyle: {
|
|
79
|
-
backgroundColor: "$background"
|
|
80
|
-
},
|
|
81
|
-
focusStyle: {
|
|
82
|
-
backgroundColor: "$background"
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
unstyled: {
|
|
87
|
-
false: {
|
|
88
|
-
backgroundColor: "$background",
|
|
89
|
-
pressStyle: {
|
|
90
|
-
backgroundColor: "$backgroundPress"
|
|
91
|
-
},
|
|
92
|
-
hoverStyle: {
|
|
93
|
-
backgroundColor: "$backgroundHover"
|
|
94
|
-
},
|
|
95
|
-
focusStyle: {
|
|
96
|
-
backgroundColor: "$backgroundFocus"
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
defaultVariants: {
|
|
102
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
103
|
-
}
|
|
104
|
-
}), TabsTrigger = TabsTriggerFrame.styleable(
|
|
105
|
-
(props, forwardedRef) => {
|
|
106
|
-
const {
|
|
107
|
-
__scopeTabs,
|
|
108
|
-
value,
|
|
109
|
-
disabled = !1,
|
|
110
|
-
onInteraction,
|
|
111
|
-
disableActiveTheme,
|
|
112
|
-
...triggerProps
|
|
113
|
-
} = 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 });
|
|
114
|
-
return React.useEffect(() => (context.registerTrigger(), () => context.unregisterTrigger()), []), React.useEffect(() => {
|
|
115
|
-
if (!triggerRef.current || !import_constants.isWeb) return;
|
|
116
|
-
function getTriggerSize() {
|
|
117
|
-
triggerRef.current && setLayout({
|
|
118
|
-
width: triggerRef.current.offsetWidth,
|
|
119
|
-
height: triggerRef.current.offsetHeight,
|
|
120
|
-
x: triggerRef.current.offsetLeft,
|
|
121
|
-
y: triggerRef.current.offsetTop
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
getTriggerSize();
|
|
125
|
-
const observer = new ResizeObserver(getTriggerSize);
|
|
126
|
-
return observer.observe(triggerRef.current), () => {
|
|
127
|
-
triggerRef.current && observer.unobserve(triggerRef.current);
|
|
128
|
-
};
|
|
129
|
-
}, [context.triggersCount]), React.useEffect(() => {
|
|
130
|
-
isSelected && layout && onInteraction?.("select", layout);
|
|
131
|
-
}, [isSelected, value, layout]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.Theme, { name: isSelected && !disableActiveTheme ? "active" : null, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
132
|
-
import_roving_focus.RovingFocusGroup.Item,
|
|
133
|
-
{
|
|
134
|
-
__scopeRovingFocusGroup: __scopeTabs || TABS_CONTEXT,
|
|
135
|
-
asChild: !0,
|
|
136
|
-
focusable: !disabled,
|
|
137
|
-
active: isSelected,
|
|
138
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
139
|
-
TabsTriggerFrame,
|
|
140
|
-
{
|
|
141
|
-
onLayout: (event) => {
|
|
142
|
-
import_constants.isWeb || setLayout(event.nativeEvent.layout);
|
|
143
|
-
},
|
|
144
|
-
onHoverIn: (0, import_helpers.composeEventHandlers)(props.onHoverIn, () => {
|
|
145
|
-
layout && onInteraction?.("hover", layout);
|
|
146
|
-
}),
|
|
147
|
-
onHoverOut: (0, import_helpers.composeEventHandlers)(props.onHoverOut, () => {
|
|
148
|
-
onInteraction?.("hover", null);
|
|
149
|
-
}),
|
|
150
|
-
role: "tab",
|
|
151
|
-
"aria-selected": isSelected,
|
|
152
|
-
"aria-controls": contentId,
|
|
153
|
-
"data-state": isSelected ? "active" : "inactive",
|
|
154
|
-
"data-disabled": disabled ? "" : void 0,
|
|
155
|
-
disabled,
|
|
156
|
-
id: triggerId,
|
|
157
|
-
...!props.unstyled && {
|
|
158
|
-
size: context.size
|
|
159
|
-
},
|
|
160
|
-
...groupItemProps,
|
|
161
|
-
...triggerProps,
|
|
162
|
-
ref: (0, import_compose_refs.composeRefs)(forwardedRef, triggerRef),
|
|
163
|
-
onPress: (0, import_helpers.composeEventHandlers)(props.onPress ?? void 0, (event) => {
|
|
164
|
-
const webChecks = !import_constants.isWeb || event.button === 0 && event.ctrlKey === !1;
|
|
165
|
-
!disabled && !isSelected && webChecks ? context.onChange(value) : event.preventDefault();
|
|
166
|
-
}),
|
|
167
|
-
...import_constants.isWeb && {
|
|
168
|
-
type: "button",
|
|
169
|
-
onKeyDown: (0, import_helpers.composeEventHandlers)(
|
|
170
|
-
props.onKeyDown,
|
|
171
|
-
(event) => {
|
|
172
|
-
[" ", "Enter"].includes(event.key) && (context.onChange(value), event.preventDefault());
|
|
173
|
-
}
|
|
174
|
-
),
|
|
175
|
-
onFocus: (0, import_helpers.composeEventHandlers)(props.onFocus, (event) => {
|
|
176
|
-
layout && onInteraction?.("focus", layout);
|
|
177
|
-
const isAutomaticActivation = context.activationMode !== "manual";
|
|
178
|
-
!isSelected && !disabled && isAutomaticActivation && context.onChange(value);
|
|
179
|
-
}),
|
|
180
|
-
onBlur: (0, import_helpers.composeEventHandlers)(props.onFocus, () => {
|
|
181
|
-
onInteraction?.("focus", null);
|
|
182
|
-
})
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
)
|
|
186
|
-
}
|
|
187
|
-
) });
|
|
188
|
-
}
|
|
189
|
-
);
|
|
190
|
-
TabsTrigger.displayName = TRIGGER_NAME;
|
|
191
|
-
const CONTENT_NAME = "TabsContent", TabsContentFrame = (0, import_web.styled)(import_stacks.ThemeableStack, {
|
|
192
|
-
name: CONTENT_NAME
|
|
193
|
-
}), TabsContent = TabsContentFrame.styleable(
|
|
194
|
-
function(props, forwardedRef) {
|
|
195
|
-
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);
|
|
196
|
-
return show ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
197
|
-
TabsContentFrame,
|
|
198
|
-
{
|
|
199
|
-
"data-state": isSelected ? "active" : "inactive",
|
|
200
|
-
"data-orientation": context.orientation,
|
|
201
|
-
role: "tabpanel",
|
|
202
|
-
"aria-labelledby": triggerId,
|
|
203
|
-
hidden: !show,
|
|
204
|
-
id: contentId,
|
|
205
|
-
tabIndex: 0,
|
|
206
|
-
...contentProps,
|
|
207
|
-
ref: forwardedRef,
|
|
208
|
-
children
|
|
209
|
-
},
|
|
210
|
-
value
|
|
211
|
-
) : null;
|
|
212
|
-
}
|
|
213
|
-
), TABS_NAME = "Tabs", { Provider: TabsProvider, useStyledContext: useTabsContext } = (0, import_web.createStyledContext)(), TabsFrame = (0, import_web.styled)(import_stacks.SizableStack, {
|
|
214
|
-
name: TABS_NAME
|
|
215
|
-
}), TabsComponent = TabsFrame.styleable(
|
|
216
|
-
(props, forwardedRef) => {
|
|
217
|
-
const {
|
|
218
|
-
__scopeTabs,
|
|
219
|
-
value: valueProp,
|
|
220
|
-
onValueChange,
|
|
221
|
-
defaultValue,
|
|
222
|
-
orientation = "horizontal",
|
|
223
|
-
dir,
|
|
224
|
-
activationMode = "automatic",
|
|
225
|
-
size = "$true",
|
|
226
|
-
...tabsProps
|
|
227
|
-
} = props, direction = (0, import_use_direction.useDirection)(dir), [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
228
|
-
prop: valueProp,
|
|
229
|
-
onChange: onValueChange,
|
|
230
|
-
defaultProp: defaultValue ?? ""
|
|
231
|
-
}), [triggersCount, setTriggersCount] = React.useState(0), registerTrigger = (0, import_web.useEvent)(() => setTriggersCount((v) => v + 1)), unregisterTrigger = (0, import_web.useEvent)(() => setTriggersCount((v) => v - 1));
|
|
232
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
233
|
-
TabsProvider,
|
|
234
|
-
{
|
|
235
|
-
scope: __scopeTabs,
|
|
236
|
-
baseId: React.useId(),
|
|
237
|
-
value,
|
|
238
|
-
onChange: setValue,
|
|
239
|
-
orientation,
|
|
240
|
-
dir: direction,
|
|
241
|
-
activationMode,
|
|
242
|
-
size,
|
|
243
|
-
registerTrigger,
|
|
244
|
-
triggersCount,
|
|
245
|
-
unregisterTrigger,
|
|
246
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
247
|
-
TabsFrame,
|
|
248
|
-
{
|
|
249
|
-
direction,
|
|
250
|
-
"data-orientation": orientation,
|
|
251
|
-
...tabsProps,
|
|
252
|
-
ref: forwardedRef
|
|
253
|
-
}
|
|
254
|
-
)
|
|
255
|
-
}
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
), Tabs = (0, import_helpers.withStaticProperties)(TabsComponent, {
|
|
259
|
-
List: TabsList,
|
|
260
|
-
/**
|
|
261
|
-
* @deprecated Use Tabs.Tab instead
|
|
262
|
-
*/
|
|
263
|
-
Trigger: TabsTrigger,
|
|
264
|
-
Tab: TabsTrigger,
|
|
265
|
-
Content: TabsContent
|
|
266
|
-
});
|
|
267
|
-
Tabs.displayName = TABS_NAME;
|
|
268
|
-
function makeTriggerId(baseId, value) {
|
|
269
|
-
return `${baseId}-trigger-${value}`;
|
|
270
|
-
}
|
|
271
|
-
function makeContentId(baseId, value) {
|
|
272
|
-
return `${baseId}-content-${value}`;
|
|
273
|
-
}
|
|
274
|
-
//# sourceMappingURL=Tabs.js.map
|
package/dist/cjs/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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")
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
-
return to;
|
|
10
|
-
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
11
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
-
var src_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(src_exports);
|
|
14
|
-
__reExport(src_exports, require("./Tabs"), module.exports);
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
|
File without changes
|
|
File without changes
|