@tamagui/tabs 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Radix
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,340 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], 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", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var Tabs_exports = {};
30
+ __export(Tabs_exports, {
31
+ Tabs: () => Tabs
32
+ });
33
+ module.exports = __toCommonJS(Tabs_exports);
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ var import_create_context = require("@tamagui/create-context");
36
+ var import_get_button_sized = require("@tamagui/get-button-sized");
37
+ var import_group = require("@tamagui/group");
38
+ var import_roving_focus = require("@tamagui/roving-focus");
39
+ var import_stacks = require("@tamagui/stacks");
40
+ var import_use_controllable_state = require("@tamagui/use-controllable-state");
41
+ var import_use_direction = require("@tamagui/use-direction");
42
+ var import_web = require("@tamagui/web");
43
+ var React = __toESM(require("react"));
44
+ const TAB_LIST_NAME = "TabsList";
45
+ const TabsListFrame = (0, import_web.styled)(import_group.Group, {
46
+ name: TAB_LIST_NAME,
47
+ focusable: true
48
+ // defaultVariants: {
49
+ // flexGrow: 0,
50
+ // },
51
+ });
52
+ const TabsList = React.forwardRef(
53
+ (props, forwardedRef) => {
54
+ const { __scopeTabs, loop = true, children, ...listProps } = props;
55
+ const context = useTabsContext(TAB_LIST_NAME, __scopeTabs);
56
+ const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);
57
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
58
+ import_roving_focus.RovingFocusGroup,
59
+ {
60
+ asChild: true,
61
+ orientation: context.orientation,
62
+ dir: context.dir,
63
+ loop,
64
+ ...rovingFocusGroupScope,
65
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
66
+ TabsListFrame,
67
+ {
68
+ role: "tablist",
69
+ "aria-orientation": context.orientation,
70
+ ref: forwardedRef,
71
+ axis: context.orientation,
72
+ ...listProps,
73
+ children
74
+ }
75
+ )
76
+ }
77
+ );
78
+ }
79
+ );
80
+ TabsList.displayName = TAB_LIST_NAME;
81
+ const TRIGGER_NAME = "TabsTrigger";
82
+ const TabsTriggerFrame = (0, import_web.styled)(import_stacks.ThemeableStack, {
83
+ name: TRIGGER_NAME,
84
+ justifyContent: "center",
85
+ alignItems: "center",
86
+ flexWrap: "nowrap",
87
+ flexDirection: "row",
88
+ cursor: "pointer",
89
+ variants: {
90
+ size: {
91
+ "...size": import_get_button_sized.getButtonSized
92
+ },
93
+ disabled: {
94
+ true: {
95
+ pointerEvents: "none"
96
+ }
97
+ },
98
+ theme: {
99
+ Button: {
100
+ focusable: true,
101
+ hoverTheme: true,
102
+ pressTheme: true,
103
+ backgrounded: true,
104
+ borderWidth: 1,
105
+ borderColor: "transparent",
106
+ pressStyle: {
107
+ borderColor: "transparent"
108
+ },
109
+ hoverStyle: {
110
+ borderColor: "transparent"
111
+ },
112
+ focusStyle: {
113
+ borderColor: "$borderColorFocus"
114
+ }
115
+ }
116
+ }
117
+ }
118
+ });
119
+ const TabsTrigger = TabsTriggerFrame.extractable(
120
+ React.forwardRef(
121
+ (props, forwardedRef) => {
122
+ const {
123
+ __scopeTabs,
124
+ value,
125
+ disabled = false,
126
+ onInteraction,
127
+ ...triggerProps
128
+ } = props;
129
+ const context = useTabsContext(TRIGGER_NAME, __scopeTabs);
130
+ const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);
131
+ const triggerId = makeTriggerId(context.baseId, value);
132
+ const contentId = makeContentId(context.baseId, value);
133
+ const isSelected = value === context.value;
134
+ const [layout, setLayout] = React.useState(null);
135
+ const triggerRef = React.useRef(null);
136
+ const groupItemProps = (0, import_group.useGroupItem)({ disabled });
137
+ React.useEffect(() => {
138
+ if (!triggerRef.current || !import_web.isWeb)
139
+ return;
140
+ function getTriggerSize() {
141
+ if (!triggerRef.current)
142
+ return;
143
+ setLayout({
144
+ width: triggerRef.current.offsetWidth,
145
+ height: triggerRef.current.offsetHeight,
146
+ x: triggerRef.current.offsetLeft,
147
+ y: triggerRef.current.offsetTop
148
+ });
149
+ }
150
+ getTriggerSize();
151
+ const observer = new ResizeObserver(getTriggerSize);
152
+ observer.observe(triggerRef.current);
153
+ return () => {
154
+ if (!triggerRef.current)
155
+ return;
156
+ observer.unobserve(triggerRef.current);
157
+ };
158
+ }, []);
159
+ React.useEffect(() => {
160
+ if (isSelected && layout) {
161
+ onInteraction == null ? void 0 : onInteraction("select", layout);
162
+ }
163
+ }, [isSelected, value, layout]);
164
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_web.Theme, { forceClassName: true, name: isSelected ? "active" : null, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
165
+ import_roving_focus.RovingFocusGroup.Item,
166
+ {
167
+ asChild: true,
168
+ ...rovingFocusGroupScope,
169
+ focusable: !disabled,
170
+ active: isSelected,
171
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
172
+ TabsTriggerFrame,
173
+ {
174
+ onLayout: (event) => {
175
+ if (!import_web.isWeb) {
176
+ setLayout(event.nativeEvent.layout);
177
+ }
178
+ },
179
+ onHoverIn: (0, import_web.composeEventHandlers)(props.onHoverIn, () => {
180
+ if (layout) {
181
+ onInteraction == null ? void 0 : onInteraction("hover", layout);
182
+ }
183
+ }),
184
+ onHoverOut: (0, import_web.composeEventHandlers)(props.onHoverOut, () => {
185
+ onInteraction == null ? void 0 : onInteraction("hover", null);
186
+ }),
187
+ role: "tab",
188
+ "aria-selected": isSelected,
189
+ "aria-controls": contentId,
190
+ "data-state": isSelected ? "active" : "inactive",
191
+ "data-disabled": disabled ? "" : void 0,
192
+ disabled,
193
+ id: triggerId,
194
+ size: context.size,
195
+ ...triggerProps,
196
+ ref: (0, import_web.composeRefs)(forwardedRef, triggerRef),
197
+ onPress: (0, import_web.composeEventHandlers)(props.onPress ?? void 0, (event) => {
198
+ const webChecks = !import_web.isWeb || event.button === 0 && event.ctrlKey === false;
199
+ if (!disabled && !isSelected && webChecks) {
200
+ context.onChange(value);
201
+ } else {
202
+ event.preventDefault();
203
+ }
204
+ }),
205
+ ...import_web.isWeb && {
206
+ type: "button",
207
+ onKeyDown: (0, import_web.composeEventHandlers)(
208
+ props.onKeyDown,
209
+ (event) => {
210
+ if ([" ", "Enter"].includes(event.key)) {
211
+ context.onChange(value);
212
+ }
213
+ }
214
+ ),
215
+ onFocus: (0, import_web.composeEventHandlers)(props.onFocus, (event) => {
216
+ if (layout) {
217
+ onInteraction == null ? void 0 : onInteraction("focus", layout);
218
+ }
219
+ const isAutomaticActivation = context.activationMode !== "manual";
220
+ if (!isSelected && !disabled && isAutomaticActivation) {
221
+ context.onChange(value);
222
+ }
223
+ }),
224
+ onBlur: (0, import_web.composeEventHandlers)(props.onFocus, () => {
225
+ onInteraction == null ? void 0 : onInteraction("focus", null);
226
+ })
227
+ },
228
+ ...groupItemProps
229
+ }
230
+ )
231
+ }
232
+ ) });
233
+ }
234
+ )
235
+ );
236
+ TabsTrigger.displayName = TRIGGER_NAME;
237
+ const CONTENT_NAME = "TabsContent";
238
+ const TabsContentFrame = (0, import_web.styled)(import_stacks.ThemeableStack, {
239
+ name: CONTENT_NAME
240
+ });
241
+ const TabsContent = React.forwardRef(
242
+ (props, forwardedRef) => {
243
+ const { __scopeTabs, value, forceMount, children, ...contentProps } = props;
244
+ const context = useTabsContext(CONTENT_NAME, __scopeTabs);
245
+ const isSelected = value === context.value;
246
+ const show = forceMount || isSelected;
247
+ const triggerId = makeTriggerId(context.baseId, value);
248
+ const contentId = makeContentId(context.baseId, value);
249
+ if (!show)
250
+ return null;
251
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
252
+ TabsContentFrame,
253
+ {
254
+ "data-state": isSelected ? "active" : "inactive",
255
+ "data-orientation": context.orientation,
256
+ role: "tabpanel",
257
+ "aria-labelledby": triggerId,
258
+ hidden: !show,
259
+ id: contentId,
260
+ tabIndex: 0,
261
+ ...contentProps,
262
+ ref: forwardedRef,
263
+ children
264
+ },
265
+ value
266
+ );
267
+ }
268
+ );
269
+ TabsContent.displayName = CONTENT_NAME;
270
+ const TABS_NAME = "Tabs";
271
+ const [createTabsContext, createTabsScope] = (0, import_create_context.createContextScope)(TABS_NAME, [
272
+ import_roving_focus.createRovingFocusGroupScope
273
+ ]);
274
+ const useRovingFocusGroupScope = (0, import_roving_focus.createRovingFocusGroupScope)();
275
+ const [TabsProvider, useTabsContext] = createTabsContext(TABS_NAME);
276
+ const TabsFrame = (0, import_web.styled)(import_stacks.SizableStack, {
277
+ name: TABS_NAME
278
+ });
279
+ const Tabs = (0, import_web.withStaticProperties)(
280
+ React.forwardRef(
281
+ (props, forwardedRef) => {
282
+ const {
283
+ __scopeTabs,
284
+ value: valueProp,
285
+ onValueChange,
286
+ defaultValue,
287
+ orientation = "horizontal",
288
+ dir,
289
+ activationMode = "automatic",
290
+ size = "$true",
291
+ ...tabsProps
292
+ } = props;
293
+ const direction = (0, import_use_direction.useDirection)(dir);
294
+ const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
295
+ prop: valueProp,
296
+ onChange: onValueChange,
297
+ defaultProp: defaultValue ?? ""
298
+ });
299
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
300
+ TabsProvider,
301
+ {
302
+ scope: __scopeTabs,
303
+ baseId: (0, import_web.useId)(),
304
+ value,
305
+ onChange: setValue,
306
+ orientation,
307
+ dir: direction,
308
+ activationMode,
309
+ size,
310
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
311
+ TabsFrame,
312
+ {
313
+ direction,
314
+ "data-orientation": orientation,
315
+ ...tabsProps,
316
+ ref: forwardedRef
317
+ }
318
+ )
319
+ }
320
+ );
321
+ }
322
+ ),
323
+ {
324
+ List: TabsList,
325
+ Trigger: TabsTrigger,
326
+ Content: TabsContent
327
+ }
328
+ );
329
+ Tabs.displayName = TABS_NAME;
330
+ function makeTriggerId(baseId, value) {
331
+ return `${baseId}-trigger-${value}`;
332
+ }
333
+ function makeContentId(baseId, value) {
334
+ return `${baseId}-content-${value}`;
335
+ }
336
+ // Annotate the CommonJS export names for ESM import in node:
337
+ 0 && (module.exports = {
338
+ Tabs
339
+ });
340
+ //# sourceMappingURL=Tabs.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Tabs.tsx"],
4
+ "sourcesContent": ["import type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { Group, GroupProps, useGroupItem } from '@tamagui/group'\nimport { RovingFocusGroup, createRovingFocusGroupScope } from '@tamagui/roving-focus'\nimport { SizableStack, ThemeableStack, ThemeableStackProps } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport { useDirection } from '@tamagui/use-direction'\nimport {\n GetProps,\n SizeTokens,\n Theme,\n composeEventHandlers,\n composeRefs,\n isWeb,\n styled,\n useId,\n withStaticProperties,\n} from '@tamagui/web'\nimport * as React from 'react'\nimport type { LayoutRectangle } from 'react-native'\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList'\n\nconst TabsListFrame = styled(Group, {\n name: TAB_LIST_NAME,\n focusable: true,\n // defaultVariants: {\n // flexGrow: 0,\n // },\n})\n\ntype TabsListFrameProps = GroupProps\n\ntype TabsListProps = TabsListFrameProps & {\n /**\n * Whether to loop over after reaching the end or start of the items\n * @default true\n */\n loop?: boolean\n}\n\nconst TabsList = React.forwardRef<HTMLDivElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, children, ...listProps } = props\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n\n return (\n <RovingFocusGroup\n asChild\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n {...rovingFocusGroupScope}\n >\n <TabsListFrame\n role=\"tablist\"\n aria-orientation={context.orientation}\n ref={forwardedRef}\n axis={context.orientation}\n {...listProps}\n >\n {children}\n </TabsListFrame>\n </RovingFocusGroup>\n )\n }\n)\n\nTabsList.displayName = TAB_LIST_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger'\n\nconst TabsTriggerFrame = styled(ThemeableStack, {\n name: TRIGGER_NAME,\n justifyContent: 'center',\n alignItems: 'center',\n flexWrap: 'nowrap',\n flexDirection: 'row',\n cursor: 'pointer',\n\n variants: {\n size: {\n '...size': getButtonSized,\n },\n disabled: {\n true: {\n pointerEvents: 'none',\n },\n },\n theme: {\n Button: {\n focusable: true,\n hoverTheme: true,\n pressTheme: true,\n backgrounded: true,\n borderWidth: 1,\n borderColor: 'transparent',\n\n pressStyle: {\n borderColor: 'transparent',\n },\n\n hoverStyle: {\n borderColor: 'transparent',\n },\n\n focusStyle: {\n borderColor: '$borderColorFocus',\n },\n },\n },\n },\n})\n\ntype TabTriggerLayout = LayoutRectangle\ntype InteractionType = 'select' | 'focus' | 'hover'\n\ntype TabsTriggerFrameProps = ThemeableStackProps\ntype TabsTriggerProps = TabsTriggerFrameProps & {\n /** The value for the tabs state to be changed to after activation of the trigger */\n value: string\n\n /** Used for making custom indicators when trigger interacted with */\n onInteraction?: (type: InteractionType, layout: TabTriggerLayout | null) => void\n}\n\nconst TabsTrigger = TabsTriggerFrame.extractable(\n React.forwardRef<HTMLButtonElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value,\n disabled = false,\n onInteraction,\n ...triggerProps\n } = props\n const context = useTabsContext(TRIGGER_NAME, __scopeTabs)\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs)\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n const isSelected = value === context.value\n const [layout, setLayout] = React.useState<TabTriggerLayout | null>(null)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const groupItemProps = useGroupItem({ disabled })\n React.useEffect(() => {\n if (!triggerRef.current || !isWeb) return\n\n function getTriggerSize() {\n if (!triggerRef.current) return\n setLayout({\n width: triggerRef.current.offsetWidth,\n height: triggerRef.current.offsetHeight,\n x: triggerRef.current.offsetLeft,\n y: triggerRef.current.offsetTop,\n })\n }\n getTriggerSize()\n\n const observer = new ResizeObserver(getTriggerSize)\n observer.observe(triggerRef.current)\n\n return () => {\n if (!triggerRef.current) return\n observer.unobserve(triggerRef.current)\n }\n }, [])\n\n React.useEffect(() => {\n if (isSelected && layout) {\n onInteraction?.('select', layout)\n }\n }, [isSelected, value, layout])\n\n return (\n <Theme forceClassName name={isSelected ? 'active' : null}>\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <TabsTriggerFrame\n onLayout={(event) => {\n if (!isWeb) {\n setLayout(event.nativeEvent.layout)\n }\n }}\n onHoverIn={composeEventHandlers(props.onHoverIn, () => {\n if (layout) {\n onInteraction?.('hover', layout)\n }\n })}\n onHoverOut={composeEventHandlers(props.onHoverOut, () => {\n onInteraction?.('hover', null)\n })}\n role=\"tab\"\n aria-selected={isSelected}\n aria-controls={contentId}\n data-state={isSelected ? 'active' : 'inactive'}\n data-disabled={disabled ? '' : undefined}\n disabled={disabled}\n id={triggerId}\n // @ts-ignore\n size={context.size}\n {...triggerProps}\n ref={composeRefs(forwardedRef, triggerRef)}\n onPress={composeEventHandlers(props.onPress ?? undefined, (event) => {\n // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)\n // but not when the control key is pressed (avoiding MacOS right click)\n\n const webChecks =\n !isWeb ||\n ((event as unknown as React.MouseEvent).button === 0 &&\n (event as unknown as React.MouseEvent).ctrlKey === false)\n if (!disabled && !isSelected && webChecks) {\n context.onChange(value)\n } else {\n // prevent focus to avoid accidental activation\n event.preventDefault()\n }\n })}\n {...(isWeb && {\n type: 'button',\n onKeyDown: composeEventHandlers(\n (props as React.HTMLProps<HTMLButtonElement>).onKeyDown,\n (event) => {\n if ([' ', 'Enter'].includes(event.key)) {\n context.onChange(value)\n }\n }\n ),\n onFocus: composeEventHandlers(props.onFocus, (event) => {\n if (layout) {\n onInteraction?.('focus', layout)\n }\n // handle \"automatic\" activation if necessary\n // ie. activate tab following focus\n const isAutomaticActivation = context.activationMode !== 'manual'\n if (!isSelected && !disabled && isAutomaticActivation) {\n context.onChange(value)\n }\n }),\n onBlur: composeEventHandlers(props.onFocus, () => {\n onInteraction?.('focus', null)\n }),\n })}\n {...groupItemProps}\n />\n </RovingFocusGroup.Item>\n </Theme>\n )\n }\n )\n)\n\nTabsTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent'\n\nconst TabsContentFrame = styled(ThemeableStack, {\n name: CONTENT_NAME,\n})\ntype TabsContentFrameProps = GetProps<typeof TabsContentFrame>\ntype TabsContentProps = TabsContentFrameProps & {\n /** Will show the content when the value matches the state of Tabs root */\n value: string\n\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with Tamagui animations.\n */\n forceMount?: true\n}\n\nconst TabsContent = React.forwardRef<HTMLDivElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, forceMount, children, ...contentProps } = props\n const context = useTabsContext(CONTENT_NAME, __scopeTabs)\n const isSelected = value === context.value\n const show = forceMount || isSelected\n\n const triggerId = makeTriggerId(context.baseId, value)\n const contentId = makeContentId(context.baseId, value)\n\n if (!show) return null\n return (\n <TabsContentFrame\n key={value}\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n // @ts-ignore\n hidden={!show}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n >\n {children}\n </TabsContentFrame>\n )\n }\n)\n\nTabsContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * Tabs\n * -----------------------------------------------------------------------------------------------*/\n\nconst TABS_NAME = 'Tabs'\n\ntype ScopedProps<P> = P & { __scopeTabs?: Scope }\nconst [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [\n createRovingFocusGroupScope,\n])\nconst useRovingFocusGroupScope = createRovingFocusGroupScope()\n\ntype TabsContextValue = {\n baseId: string\n value?: string\n onChange: (value: string) => void\n orientation?: TabsProps['orientation']\n dir?: TabsProps['dir']\n activationMode?: TabsProps['activationMode']\n size: SizeTokens\n}\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME)\n\nconst TabsFrame = styled(SizableStack, {\n name: TABS_NAME,\n})\ntype RovingFocusGroupProps = React.ComponentPropsWithoutRef<typeof RovingFocusGroup>\ntype TabsFrameProps = GetProps<typeof TabsFrame>\ntype TabsProps = TabsFrameProps & {\n /** The value for the selected tab, if controlled */\n value?: string\n /** The value of the tab to select by default, if uncontrolled */\n defaultValue?: string\n /** A function called when a new tab is selected */\n onValueChange?: (value: string) => void\n /**\n * The orientation the tabs are layed out.\n * Mainly so arrow navigation is done accordingly (left & right vs. up & down)\n * @defaultValue horizontal\n */\n orientation?: RovingFocusGroupProps['orientation']\n /**\n * The direction of navigation between toolbar items.\n */\n dir?: RovingFocusGroupProps['dir']\n /**\n * Whether a tab is activated automatically or manually. Only supported in web.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual'\n}\n\nexport const Tabs = withStaticProperties(\n React.forwardRef<HTMLDivElement, TabsProps>(\n (props: ScopedProps<TabsProps>, forwardedRef) => {\n const {\n __scopeTabs,\n value: valueProp,\n onValueChange,\n defaultValue,\n orientation = 'horizontal',\n dir,\n activationMode = 'automatic',\n size = '$true',\n ...tabsProps\n } = props\n const direction = useDirection(dir)\n const [value, setValue] = useControllableState({\n prop: valueProp,\n onChange: onValueChange,\n defaultProp: defaultValue ?? '',\n })\n\n return (\n <TabsProvider\n scope={__scopeTabs}\n baseId={useId()}\n value={value}\n onChange={setValue}\n orientation={orientation}\n dir={direction}\n activationMode={activationMode}\n size={size}\n >\n <TabsFrame\n direction={direction}\n // dir={direction}\n data-orientation={orientation}\n {...tabsProps}\n ref={forwardedRef}\n />\n </TabsProvider>\n )\n }\n ),\n {\n List: TabsList,\n Trigger: TabsTrigger,\n Content: TabsContent,\n }\n)\n\nTabs.displayName = TABS_NAME\n\n/* ---------------------------------------------------------------------------------------------- */\n\nfunction makeTriggerId(baseId: string, value: string) {\n return `${baseId}-trigger-${value}`\n}\n\nfunction makeContentId(baseId: string, value: string) {\n return `${baseId}-content-${value}`\n}\n\nexport type {\n TabsProps,\n TabsListProps,\n TabsTriggerProps,\n TabsContentProps,\n TabTriggerLayout,\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4DQ;AA3DR,4BAAmC;AACnC,8BAA+B;AAC/B,mBAAgD;AAChD,0BAA8D;AAC9D,oBAAkE;AAClE,oCAAqC;AACrC,2BAA6B;AAC7B,iBAUO;AACP,YAAuB;AAOvB,MAAM,gBAAgB;AAEtB,MAAM,oBAAgB,mBAAO,oBAAO;AAAA,EAClC,MAAM;AAAA,EACN,WAAW;AAAA;AAAA;AAAA;AAIb,CAAC;AAYD,MAAM,WAAW,MAAM;AAAA,EACrB,CAAC,OAAmC,iBAAiB;AACnD,UAAM,EAAE,aAAa,OAAO,MAAM,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P;AAAA,QACA;AAAA,QACA,cAAc;AAAA,QACd;AAAA,QACA,iBAAiB;AAAA,QACjB,OAAO;AAAA,QACP,GAAG;AAAA,MACL,IAAI;AACJ,YAAM,gBAAY,mCAAa,GAAG;AAClC,YAAM,CAAC,OAAO,QAAQ,QAAI,oDAAqB;AAAA,QAC7C,MAAM;AAAA,QACN,UAAU;AAAA,QACV,aAAa,gBAAgB;AAAA,MAC/B,CAAC;AAED,aACE;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,UACP,YAAQ,kBAAM;AAAA,UACd;AAAA,UACA,UAAU;AAAA,UACV;AAAA,UACA,KAAK;AAAA,UACL;AAAA,UACA;AAAA,UAEA;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cAEA,oBAAkB;AAAA,cACjB,GAAG;AAAA,cACJ,KAAK;AAAA;AAAA,UACP;AAAA;AAAA,MACF;AAAA,IAEJ;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,EACX;AACF;AAEA,KAAK,cAAc;AAInB,SAAS,cAAc,QAAgB,OAAe;AACpD,SAAO,GAAG,kBAAkB;AAC9B;AAEA,SAAS,cAAc,QAAgB,OAAe;AACpD,SAAO,GAAG,kBAAkB;AAC9B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,19 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./Tabs"), module.exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './Tabs'\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,mBAAd;",
6
+ "names": []
7
+ }