@radix-ui/react-tabs 1.0.5-rc.9 → 1.1.0-rc.1

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/index.d.mts CHANGED
@@ -1,11 +1,23 @@
1
- import * as React from "react";
2
- import * as Radix from "@radix-ui/react-primitive";
3
- import { Primitive } from "@radix-ui/react-primitive";
4
- import * as RovingFocusGroup from "@radix-ui/react-roving-focus";
5
- export const createTabsScope: import("@radix-ui/react-context").CreateScope;
6
- type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;
7
- type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
8
- export interface TabsProps extends PrimitiveDivProps {
1
+ import * as React from 'react';
2
+ import * as Radix from '@radix-ui/react-primitive';
3
+ import { Primitive } from '@radix-ui/react-primitive';
4
+ import * as RovingFocusGroup from '@radix-ui/react-roving-focus';
5
+
6
+ declare type Scope<C = any> = {
7
+ [scopeName: string]: React.Context<C>[];
8
+ } | undefined;
9
+ declare type ScopeHook = (scope: Scope) => {
10
+ [__scopeProp: string]: Scope;
11
+ };
12
+ interface CreateScope {
13
+ scopeName: string;
14
+ (): ScopeHook;
15
+ }
16
+
17
+ declare const createTabsScope: CreateScope;
18
+ declare type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;
19
+ declare type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
20
+ interface TabsProps extends PrimitiveDivProps {
9
21
  /** The value for the selected tab, if controlled */
10
22
  value?: string;
11
23
  /** The value of the tab to select by default, if uncontrolled */
@@ -28,17 +40,17 @@ export interface TabsProps extends PrimitiveDivProps {
28
40
  * */
29
41
  activationMode?: 'automatic' | 'manual';
30
42
  }
31
- export const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
32
- export interface TabsListProps extends PrimitiveDivProps {
43
+ declare const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
44
+ interface TabsListProps extends PrimitiveDivProps {
33
45
  loop?: RovingFocusGroupProps['loop'];
34
46
  }
35
- export const TabsList: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>;
36
- type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
37
- export interface TabsTriggerProps extends PrimitiveButtonProps {
47
+ declare const TabsList: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>;
48
+ declare type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
49
+ interface TabsTriggerProps extends PrimitiveButtonProps {
38
50
  value: string;
39
51
  }
40
- export const TabsTrigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>;
41
- export interface TabsContentProps extends PrimitiveDivProps {
52
+ declare const TabsTrigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>;
53
+ interface TabsContentProps extends PrimitiveDivProps {
42
54
  value: string;
43
55
  /**
44
56
  * Used to force mounting when more control is needed. Useful when
@@ -46,10 +58,10 @@ export interface TabsContentProps extends PrimitiveDivProps {
46
58
  */
47
59
  forceMount?: true;
48
60
  }
49
- export const TabsContent: React.ForwardRefExoticComponent<TabsContentProps & React.RefAttributes<HTMLDivElement>>;
50
- export const Root: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
51
- export const List: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>;
52
- export const Trigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>;
53
- export const Content: React.ForwardRefExoticComponent<TabsContentProps & React.RefAttributes<HTMLDivElement>>;
61
+ declare const TabsContent: React.ForwardRefExoticComponent<TabsContentProps & React.RefAttributes<HTMLDivElement>>;
62
+ declare const Root: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
63
+ declare const List: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>;
64
+ declare const Trigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>;
65
+ declare const Content: React.ForwardRefExoticComponent<TabsContentProps & React.RefAttributes<HTMLDivElement>>;
54
66
 
55
- //# sourceMappingURL=index.d.ts.map
67
+ export { Content, List, Root, Tabs, TabsContent, type TabsContentProps, TabsList, type TabsListProps, type TabsProps, TabsTrigger, type TabsTriggerProps, Trigger, createTabsScope };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,23 @@
1
- import * as React from "react";
2
- import * as Radix from "@radix-ui/react-primitive";
3
- import { Primitive } from "@radix-ui/react-primitive";
4
- import * as RovingFocusGroup from "@radix-ui/react-roving-focus";
5
- export const createTabsScope: import("@radix-ui/react-context").CreateScope;
6
- type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;
7
- type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
8
- export interface TabsProps extends PrimitiveDivProps {
1
+ import * as React from 'react';
2
+ import * as Radix from '@radix-ui/react-primitive';
3
+ import { Primitive } from '@radix-ui/react-primitive';
4
+ import * as RovingFocusGroup from '@radix-ui/react-roving-focus';
5
+
6
+ declare type Scope<C = any> = {
7
+ [scopeName: string]: React.Context<C>[];
8
+ } | undefined;
9
+ declare type ScopeHook = (scope: Scope) => {
10
+ [__scopeProp: string]: Scope;
11
+ };
12
+ interface CreateScope {
13
+ scopeName: string;
14
+ (): ScopeHook;
15
+ }
16
+
17
+ declare const createTabsScope: CreateScope;
18
+ declare type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;
19
+ declare type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
20
+ interface TabsProps extends PrimitiveDivProps {
9
21
  /** The value for the selected tab, if controlled */
10
22
  value?: string;
11
23
  /** The value of the tab to select by default, if uncontrolled */
@@ -28,17 +40,17 @@ export interface TabsProps extends PrimitiveDivProps {
28
40
  * */
29
41
  activationMode?: 'automatic' | 'manual';
30
42
  }
31
- export const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
32
- export interface TabsListProps extends PrimitiveDivProps {
43
+ declare const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
44
+ interface TabsListProps extends PrimitiveDivProps {
33
45
  loop?: RovingFocusGroupProps['loop'];
34
46
  }
35
- export const TabsList: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>;
36
- type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
37
- export interface TabsTriggerProps extends PrimitiveButtonProps {
47
+ declare const TabsList: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>;
48
+ declare type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
49
+ interface TabsTriggerProps extends PrimitiveButtonProps {
38
50
  value: string;
39
51
  }
40
- export const TabsTrigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>;
41
- export interface TabsContentProps extends PrimitiveDivProps {
52
+ declare const TabsTrigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>;
53
+ interface TabsContentProps extends PrimitiveDivProps {
42
54
  value: string;
43
55
  /**
44
56
  * Used to force mounting when more control is needed. Useful when
@@ -46,10 +58,10 @@ export interface TabsContentProps extends PrimitiveDivProps {
46
58
  */
47
59
  forceMount?: true;
48
60
  }
49
- export const TabsContent: React.ForwardRefExoticComponent<TabsContentProps & React.RefAttributes<HTMLDivElement>>;
50
- export const Root: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
51
- export const List: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>;
52
- export const Trigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>;
53
- export const Content: React.ForwardRefExoticComponent<TabsContentProps & React.RefAttributes<HTMLDivElement>>;
61
+ declare const TabsContent: React.ForwardRefExoticComponent<TabsContentProps & React.RefAttributes<HTMLDivElement>>;
62
+ declare const Root: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
63
+ declare const List: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>;
64
+ declare const Trigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>;
65
+ declare const Content: React.ForwardRefExoticComponent<TabsContentProps & React.RefAttributes<HTMLDivElement>>;
54
66
 
55
- //# sourceMappingURL=index.d.ts.map
67
+ export { Content, List, Root, Tabs, TabsContent, type TabsContentProps, TabsList, type TabsListProps, type TabsProps, TabsTrigger, type TabsTriggerProps, Trigger, createTabsScope };
package/dist/index.js CHANGED
@@ -1,198 +1,218 @@
1
- var $8oLOM$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
2
- var $8oLOM$react = require("react");
3
- var $8oLOM$radixuiprimitive = require("@radix-ui/primitive");
4
- var $8oLOM$radixuireactcontext = require("@radix-ui/react-context");
5
- var $8oLOM$radixuireactrovingfocus = require("@radix-ui/react-roving-focus");
6
- var $8oLOM$radixuireactpresence = require("@radix-ui/react-presence");
7
- var $8oLOM$radixuireactprimitive = require("@radix-ui/react-primitive");
8
- var $8oLOM$radixuireactdirection = require("@radix-ui/react-direction");
9
- var $8oLOM$radixuireactusecontrollablestate = require("@radix-ui/react-use-controllable-state");
10
- var $8oLOM$radixuireactid = require("@radix-ui/react-id");
11
-
12
- function $parcel$export(e, n, v, s) {
13
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
14
- }
15
- function $parcel$interopDefault(a) {
16
- return a && a.__esModule ? a.default : a;
17
- }
18
-
19
- $parcel$export(module.exports, "createTabsScope", () => $2bbff03427f8eaee$export$355f5bd209d7b13a);
20
- $parcel$export(module.exports, "Tabs", () => $2bbff03427f8eaee$export$b2539bed5023c21c);
21
- $parcel$export(module.exports, "TabsList", () => $2bbff03427f8eaee$export$9712d22edc0d78c1);
22
- $parcel$export(module.exports, "TabsTrigger", () => $2bbff03427f8eaee$export$8114b9fdfdf9f3ba);
23
- $parcel$export(module.exports, "TabsContent", () => $2bbff03427f8eaee$export$bd905d70e8fd2ebb);
24
- $parcel$export(module.exports, "Root", () => $2bbff03427f8eaee$export$be92b6f5f03c0fe9);
25
- $parcel$export(module.exports, "List", () => $2bbff03427f8eaee$export$54c2e3dc7acea9f5);
26
- $parcel$export(module.exports, "Trigger", () => $2bbff03427f8eaee$export$41fb9f06171c75f4);
27
- $parcel$export(module.exports, "Content", () => $2bbff03427f8eaee$export$7c6e2c02157bb7d2);
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
- /* -------------------------------------------------------------------------------------------------
40
- * Tabs
41
- * -----------------------------------------------------------------------------------------------*/ const $2bbff03427f8eaee$var$TABS_NAME = 'Tabs';
42
- const [$2bbff03427f8eaee$var$createTabsContext, $2bbff03427f8eaee$export$355f5bd209d7b13a] = $8oLOM$radixuireactcontext.createContextScope($2bbff03427f8eaee$var$TABS_NAME, [
43
- $8oLOM$radixuireactrovingfocus.createRovingFocusGroupScope
44
- ]);
45
- const $2bbff03427f8eaee$var$useRovingFocusGroupScope = $8oLOM$radixuireactrovingfocus.createRovingFocusGroupScope();
46
- const [$2bbff03427f8eaee$var$TabsProvider, $2bbff03427f8eaee$var$useTabsContext] = $2bbff03427f8eaee$var$createTabsContext($2bbff03427f8eaee$var$TABS_NAME);
47
- const $2bbff03427f8eaee$export$b2539bed5023c21c = /*#__PURE__*/ $8oLOM$react.forwardRef((props, forwardedRef)=>{
48
- const { __scopeTabs: __scopeTabs , value: valueProp , onValueChange: onValueChange , defaultValue: defaultValue , orientation: orientation = 'horizontal' , dir: dir , activationMode: activationMode = 'automatic' , ...tabsProps } = props;
49
- const direction = $8oLOM$radixuireactdirection.useDirection(dir);
50
- const [value, setValue] = $8oLOM$radixuireactusecontrollablestate.useControllableState({
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
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
11
+ }) : x)(function(x) {
12
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
14
+ });
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+
32
+ // packages/react/tabs/src/Tabs.tsx
33
+ var React = __toESM(__require("react"));
34
+ var import_primitive = __require("@radix-ui/primitive");
35
+ var import_react_context = __require("@radix-ui/react-context");
36
+ var import_react_roving_focus = __require("@radix-ui/react-roving-focus");
37
+ var import_react_presence = __require("@radix-ui/react-presence");
38
+ var import_react_primitive = __require("@radix-ui/react-primitive");
39
+ var RovingFocusGroup = __toESM(__require("@radix-ui/react-roving-focus"));
40
+ var import_react_direction = __require("@radix-ui/react-direction");
41
+ var import_react_use_controllable_state = __require("@radix-ui/react-use-controllable-state");
42
+ var import_react_id = __require("@radix-ui/react-id");
43
+ var import_jsx_runtime = __require("react/jsx-runtime");
44
+ var TABS_NAME = "Tabs";
45
+ var [createTabsContext, createTabsScope] = (0, import_react_context.createContextScope)(TABS_NAME, [
46
+ import_react_roving_focus.createRovingFocusGroupScope
47
+ ]);
48
+ var useRovingFocusGroupScope = (0, import_react_roving_focus.createRovingFocusGroupScope)();
49
+ var [TabsProvider, useTabsContext] = createTabsContext(TABS_NAME);
50
+ var Tabs = React.forwardRef(
51
+ (props, forwardedRef) => {
52
+ const {
53
+ __scopeTabs,
54
+ value: valueProp,
55
+ onValueChange,
56
+ defaultValue,
57
+ orientation = "horizontal",
58
+ dir,
59
+ activationMode = "automatic",
60
+ ...tabsProps
61
+ } = props;
62
+ const direction = (0, import_react_direction.useDirection)(dir);
63
+ const [value, setValue] = (0, import_react_use_controllable_state.useControllableState)({
51
64
  prop: valueProp,
52
65
  onChange: onValueChange,
53
66
  defaultProp: defaultValue
54
- });
55
- return /*#__PURE__*/ $8oLOM$react.createElement($2bbff03427f8eaee$var$TabsProvider, {
56
- scope: __scopeTabs,
57
- baseId: $8oLOM$radixuireactid.useId(),
58
- value: value,
59
- onValueChange: setValue,
60
- orientation: orientation,
61
- dir: direction,
62
- activationMode: activationMode
63
- }, /*#__PURE__*/ $8oLOM$react.createElement($8oLOM$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($8oLOM$babelruntimehelpersextends))({
64
- dir: direction,
65
- "data-orientation": orientation
66
- }, tabsProps, {
67
- ref: forwardedRef
68
- })));
69
- });
70
- /*#__PURE__*/ Object.assign($2bbff03427f8eaee$export$b2539bed5023c21c, {
71
- displayName: $2bbff03427f8eaee$var$TABS_NAME
72
- });
73
- /* -------------------------------------------------------------------------------------------------
74
- * TabsList
75
- * -----------------------------------------------------------------------------------------------*/ const $2bbff03427f8eaee$var$TAB_LIST_NAME = 'TabsList';
76
- const $2bbff03427f8eaee$export$9712d22edc0d78c1 = /*#__PURE__*/ $8oLOM$react.forwardRef((props, forwardedRef)=>{
77
- const { __scopeTabs: __scopeTabs , loop: loop = true , ...listProps } = props;
78
- const context = $2bbff03427f8eaee$var$useTabsContext($2bbff03427f8eaee$var$TAB_LIST_NAME, __scopeTabs);
79
- const rovingFocusGroupScope = $2bbff03427f8eaee$var$useRovingFocusGroupScope(__scopeTabs);
80
- return /*#__PURE__*/ $8oLOM$react.createElement($8oLOM$radixuireactrovingfocus.Root, ($parcel$interopDefault($8oLOM$babelruntimehelpersextends))({
81
- asChild: true
82
- }, rovingFocusGroupScope, {
83
- orientation: context.orientation,
84
- dir: context.dir,
85
- loop: loop
86
- }), /*#__PURE__*/ $8oLOM$react.createElement($8oLOM$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($8oLOM$babelruntimehelpersextends))({
87
- role: "tablist",
88
- "aria-orientation": context.orientation
89
- }, listProps, {
90
- ref: forwardedRef
91
- })));
92
- });
93
- /*#__PURE__*/ Object.assign($2bbff03427f8eaee$export$9712d22edc0d78c1, {
94
- displayName: $2bbff03427f8eaee$var$TAB_LIST_NAME
95
- });
96
- /* -------------------------------------------------------------------------------------------------
97
- * TabsTrigger
98
- * -----------------------------------------------------------------------------------------------*/ const $2bbff03427f8eaee$var$TRIGGER_NAME = 'TabsTrigger';
99
- const $2bbff03427f8eaee$export$8114b9fdfdf9f3ba = /*#__PURE__*/ $8oLOM$react.forwardRef((props, forwardedRef)=>{
100
- const { __scopeTabs: __scopeTabs , value: value , disabled: disabled = false , ...triggerProps } = props;
101
- const context = $2bbff03427f8eaee$var$useTabsContext($2bbff03427f8eaee$var$TRIGGER_NAME, __scopeTabs);
102
- const rovingFocusGroupScope = $2bbff03427f8eaee$var$useRovingFocusGroupScope(__scopeTabs);
103
- const triggerId = $2bbff03427f8eaee$var$makeTriggerId(context.baseId, value);
104
- const contentId = $2bbff03427f8eaee$var$makeContentId(context.baseId, value);
105
- const isSelected = value === context.value;
106
- return /*#__PURE__*/ $8oLOM$react.createElement($8oLOM$radixuireactrovingfocus.Item, ($parcel$interopDefault($8oLOM$babelruntimehelpersextends))({
107
- asChild: true
108
- }, rovingFocusGroupScope, {
109
- focusable: !disabled,
110
- active: isSelected
111
- }), /*#__PURE__*/ $8oLOM$react.createElement($8oLOM$radixuireactprimitive.Primitive.button, ($parcel$interopDefault($8oLOM$babelruntimehelpersextends))({
112
- type: "button",
113
- role: "tab",
114
- "aria-selected": isSelected,
115
- "aria-controls": contentId,
116
- "data-state": isSelected ? 'active' : 'inactive',
117
- "data-disabled": disabled ? '' : undefined,
118
- disabled: disabled,
119
- id: triggerId
120
- }, triggerProps, {
121
- ref: forwardedRef,
122
- onMouseDown: $8oLOM$radixuiprimitive.composeEventHandlers(props.onMouseDown, (event)=>{
123
- // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)
124
- // but not when the control key is pressed (avoiding MacOS right click)
125
- if (!disabled && event.button === 0 && event.ctrlKey === false) context.onValueChange(value);
126
- else // prevent focus to avoid accidental activation
127
- event.preventDefault();
128
- }),
129
- onKeyDown: $8oLOM$radixuiprimitive.composeEventHandlers(props.onKeyDown, (event)=>{
130
- if ([
131
- ' ',
132
- 'Enter'
133
- ].includes(event.key)) context.onValueChange(value);
134
- }),
135
- onFocus: $8oLOM$radixuiprimitive.composeEventHandlers(props.onFocus, ()=>{
136
- // handle "automatic" activation if necessary
137
- // ie. activate tab following focus
138
- const isAutomaticActivation = context.activationMode !== 'manual';
139
- if (!isSelected && !disabled && isAutomaticActivation) context.onValueChange(value);
140
- })
141
- })));
142
- });
143
- /*#__PURE__*/ Object.assign($2bbff03427f8eaee$export$8114b9fdfdf9f3ba, {
144
- displayName: $2bbff03427f8eaee$var$TRIGGER_NAME
145
- });
146
- /* -------------------------------------------------------------------------------------------------
147
- * TabsContent
148
- * -----------------------------------------------------------------------------------------------*/ const $2bbff03427f8eaee$var$CONTENT_NAME = 'TabsContent';
149
- const $2bbff03427f8eaee$export$bd905d70e8fd2ebb = /*#__PURE__*/ $8oLOM$react.forwardRef((props, forwardedRef)=>{
150
- const { __scopeTabs: __scopeTabs , value: value , forceMount: forceMount , children: children , ...contentProps } = props;
151
- const context = $2bbff03427f8eaee$var$useTabsContext($2bbff03427f8eaee$var$CONTENT_NAME, __scopeTabs);
152
- const triggerId = $2bbff03427f8eaee$var$makeTriggerId(context.baseId, value);
153
- const contentId = $2bbff03427f8eaee$var$makeContentId(context.baseId, value);
154
- const isSelected = value === context.value;
155
- const isMountAnimationPreventedRef = $8oLOM$react.useRef(isSelected);
156
- $8oLOM$react.useEffect(()=>{
157
- const rAF = requestAnimationFrame(()=>isMountAnimationPreventedRef.current = false
158
- );
159
- return ()=>cancelAnimationFrame(rAF)
160
- ;
161
- }, []);
162
- return /*#__PURE__*/ $8oLOM$react.createElement($8oLOM$radixuireactpresence.Presence, {
163
- present: forceMount || isSelected
164
- }, ({ present: present })=>/*#__PURE__*/ $8oLOM$react.createElement($8oLOM$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($8oLOM$babelruntimehelpersextends))({
165
- "data-state": isSelected ? 'active' : 'inactive',
166
- "data-orientation": context.orientation,
167
- role: "tabpanel",
168
- "aria-labelledby": triggerId,
169
- hidden: !present,
170
- id: contentId,
171
- tabIndex: 0
172
- }, contentProps, {
173
- ref: forwardedRef,
174
- style: {
175
- ...props.style,
176
- animationDuration: isMountAnimationPreventedRef.current ? '0s' : undefined
67
+ });
68
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
+ TabsProvider,
70
+ {
71
+ scope: __scopeTabs,
72
+ baseId: (0, import_react_id.useId)(),
73
+ value,
74
+ onValueChange: setValue,
75
+ orientation,
76
+ dir: direction,
77
+ activationMode,
78
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
79
+ import_react_primitive.Primitive.div,
80
+ {
81
+ dir: direction,
82
+ "data-orientation": orientation,
83
+ ...tabsProps,
84
+ ref: forwardedRef
85
+ }
86
+ )
87
+ }
88
+ );
89
+ }
90
+ );
91
+ Tabs.displayName = TABS_NAME;
92
+ var TAB_LIST_NAME = "TabsList";
93
+ var TabsList = React.forwardRef(
94
+ (props, forwardedRef) => {
95
+ const { __scopeTabs, loop = true, ...listProps } = props;
96
+ const context = useTabsContext(TAB_LIST_NAME, __scopeTabs);
97
+ const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);
98
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
99
+ RovingFocusGroup.Root,
100
+ {
101
+ asChild: true,
102
+ ...rovingFocusGroupScope,
103
+ orientation: context.orientation,
104
+ dir: context.dir,
105
+ loop,
106
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
107
+ import_react_primitive.Primitive.div,
108
+ {
109
+ role: "tablist",
110
+ "aria-orientation": context.orientation,
111
+ ...listProps,
112
+ ref: forwardedRef
113
+ }
114
+ )
115
+ }
116
+ );
117
+ }
118
+ );
119
+ TabsList.displayName = TAB_LIST_NAME;
120
+ var TRIGGER_NAME = "TabsTrigger";
121
+ var TabsTrigger = React.forwardRef(
122
+ (props, forwardedRef) => {
123
+ const { __scopeTabs, value, disabled = false, ...triggerProps } = props;
124
+ const context = useTabsContext(TRIGGER_NAME, __scopeTabs);
125
+ const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);
126
+ const triggerId = makeTriggerId(context.baseId, value);
127
+ const contentId = makeContentId(context.baseId, value);
128
+ const isSelected = value === context.value;
129
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
130
+ RovingFocusGroup.Item,
131
+ {
132
+ asChild: true,
133
+ ...rovingFocusGroupScope,
134
+ focusable: !disabled,
135
+ active: isSelected,
136
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
137
+ import_react_primitive.Primitive.button,
138
+ {
139
+ type: "button",
140
+ role: "tab",
141
+ "aria-selected": isSelected,
142
+ "aria-controls": contentId,
143
+ "data-state": isSelected ? "active" : "inactive",
144
+ "data-disabled": disabled ? "" : void 0,
145
+ disabled,
146
+ id: triggerId,
147
+ ...triggerProps,
148
+ ref: forwardedRef,
149
+ onMouseDown: (0, import_primitive.composeEventHandlers)(props.onMouseDown, (event) => {
150
+ if (!disabled && event.button === 0 && event.ctrlKey === false) {
151
+ context.onValueChange(value);
152
+ } else {
153
+ event.preventDefault();
154
+ }
155
+ }),
156
+ onKeyDown: (0, import_primitive.composeEventHandlers)(props.onKeyDown, (event) => {
157
+ if ([" ", "Enter"].includes(event.key)) context.onValueChange(value);
158
+ }),
159
+ onFocus: (0, import_primitive.composeEventHandlers)(props.onFocus, () => {
160
+ const isAutomaticActivation = context.activationMode !== "manual";
161
+ if (!isSelected && !disabled && isAutomaticActivation) {
162
+ context.onValueChange(value);
163
+ }
164
+ })
177
165
  }
178
- }), present && children)
179
- );
180
- });
181
- /*#__PURE__*/ Object.assign($2bbff03427f8eaee$export$bd905d70e8fd2ebb, {
182
- displayName: $2bbff03427f8eaee$var$CONTENT_NAME
183
- });
184
- /* ---------------------------------------------------------------------------------------------- */ function $2bbff03427f8eaee$var$makeTriggerId(baseId, value) {
166
+ )
167
+ }
168
+ );
169
+ }
170
+ );
171
+ TabsTrigger.displayName = TRIGGER_NAME;
172
+ var CONTENT_NAME = "TabsContent";
173
+ var TabsContent = React.forwardRef(
174
+ (props, forwardedRef) => {
175
+ const { __scopeTabs, value, forceMount, children, ...contentProps } = props;
176
+ const context = useTabsContext(CONTENT_NAME, __scopeTabs);
177
+ const triggerId = makeTriggerId(context.baseId, value);
178
+ const contentId = makeContentId(context.baseId, value);
179
+ const isSelected = value === context.value;
180
+ const isMountAnimationPreventedRef = React.useRef(isSelected);
181
+ React.useEffect(() => {
182
+ const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
183
+ return () => cancelAnimationFrame(rAF);
184
+ }, []);
185
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_presence.Presence, { present: forceMount || isSelected, children: ({ present }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
186
+ import_react_primitive.Primitive.div,
187
+ {
188
+ "data-state": isSelected ? "active" : "inactive",
189
+ "data-orientation": context.orientation,
190
+ role: "tabpanel",
191
+ "aria-labelledby": triggerId,
192
+ hidden: !present,
193
+ id: contentId,
194
+ tabIndex: 0,
195
+ ...contentProps,
196
+ ref: forwardedRef,
197
+ style: {
198
+ ...props.style,
199
+ animationDuration: isMountAnimationPreventedRef.current ? "0s" : void 0
200
+ },
201
+ children: present && children
202
+ }
203
+ ) });
204
+ }
205
+ );
206
+ TabsContent.displayName = CONTENT_NAME;
207
+ function makeTriggerId(baseId, value) {
185
208
  return `${baseId}-trigger-${value}`;
186
- }
187
- function $2bbff03427f8eaee$var$makeContentId(baseId, value) {
209
+ }
210
+ function makeContentId(baseId, value) {
188
211
  return `${baseId}-content-${value}`;
189
- }
190
- const $2bbff03427f8eaee$export$be92b6f5f03c0fe9 = $2bbff03427f8eaee$export$b2539bed5023c21c;
191
- const $2bbff03427f8eaee$export$54c2e3dc7acea9f5 = $2bbff03427f8eaee$export$9712d22edc0d78c1;
192
- const $2bbff03427f8eaee$export$41fb9f06171c75f4 = $2bbff03427f8eaee$export$8114b9fdfdf9f3ba;
193
- const $2bbff03427f8eaee$export$7c6e2c02157bb7d2 = $2bbff03427f8eaee$export$bd905d70e8fd2ebb;
194
-
195
-
196
-
197
-
212
+ }
213
+ var Root2 = Tabs;
214
+ var List = TabsList;
215
+ var Trigger = TabsTrigger;
216
+ var Content = TabsContent;
217
+ })();
198
218
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1,7 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;A;;;;;;;;;;;ACcA;;oGAEA,CAEA,MAAMmB,+BAAS,GAAG,MAAlB,AAAA;AAGA,MAAM,CAACC,uCAAD,EAAoBpB,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AAA,EAAA;IAAA,WAAA,EAAA,kCAAA;CAAA,CAAA,CAAA;AAEA,oGAAA,CAEA,SAASlB,mCAAT,CAAuBC,MAAvB,EAAuCvB,KAAvC,EAAsD;IACpD,OAAQ,CAAA,EAAEuB,MAAO,CAAA,SAAA,EAAWvB,KAAM,CAAA,CAAlC,CAAA;CACD;AAED,SAASyB,mCAAT,CAAuBF,MAAvB,EAAuCvB,KAAvC,EAAsD;IACpD,OAAQ,CAAA,EAAEuB,MAAO,CAAA,SAAA,EAAWvB,KAAM,CAAA,CAAlC,CAAA;CACD;AAED,MAAMvB,yCAAI,GAAGJ,yCAAb,AAAA;AACA,MAAMK,yCAAI,GAAGJ,yCAAb,AAAA;AACA,MAAMK,yCAAO,GAAGJ,yCAAhB,AAAA;AACA,MAAMK,yCAAO,GAAGJ,yCAAhB,AAAA;;AD1RA","sources":["packages/react/tabs/src/index.ts","packages/react/tabs/src/Tabs.tsx"],"sourcesContent":["export {\n createTabsScope,\n //\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n //\n Root,\n List,\n Trigger,\n Content,\n} from './Tabs';\nexport type { TabsProps, TabsListProps, TabsTriggerProps, TabsContentProps } from './Tabs';\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { useDirection } from '@radix-ui/react-direction';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useId } from '@radix-ui/react-id';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\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 onValueChange: (value: string) => void;\n orientation?: TabsProps['orientation'];\n dir?: TabsProps['dir'];\n activationMode?: TabsProps['activationMode'];\n};\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME);\n\ntype TabsElement = React.ElementRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface TabsProps extends PrimitiveDivProps {\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.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual';\n}\n\nconst Tabs = React.forwardRef<TabsElement, 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 ...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 onValueChange={setValue}\n orientation={orientation}\n dir={direction}\n activationMode={activationMode}\n >\n <Primitive.div\n dir={direction}\n data-orientation={orientation}\n {...tabsProps}\n ref={forwardedRef}\n />\n </TabsProvider>\n );\n }\n);\n\nTabs.displayName = TABS_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList';\n\ntype TabsListElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsListProps extends PrimitiveDivProps {\n loop?: RovingFocusGroupProps['loop'];\n}\n\nconst TabsList = React.forwardRef<TabsListElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, ...listProps } = props;\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs);\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);\n return (\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n >\n <Primitive.div\n role=\"tablist\"\n aria-orientation={context.orientation}\n {...listProps}\n ref={forwardedRef}\n />\n </RovingFocusGroup.Root>\n );\n }\n);\n\nTabsList.displayName = TAB_LIST_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger';\n\ntype TabsTriggerElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface TabsTriggerProps extends PrimitiveButtonProps {\n value: string;\n}\n\nconst TabsTrigger = React.forwardRef<TabsTriggerElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const { __scopeTabs, value, disabled = false, ...triggerProps } = 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 return (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <Primitive.button\n type=\"button\"\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 {...triggerProps}\n ref={forwardedRef}\n onMouseDown={composeEventHandlers(props.onMouseDown, (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 if (!disabled && event.button === 0 && event.ctrlKey === false) {\n context.onValueChange(value);\n } else {\n // prevent focus to avoid accidental activation\n event.preventDefault();\n }\n })}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if ([' ', 'Enter'].includes(event.key)) context.onValueChange(value);\n })}\n onFocus={composeEventHandlers(props.onFocus, () => {\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.onValueChange(value);\n }\n })}\n />\n </RovingFocusGroup.Item>\n );\n }\n);\n\nTabsTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent';\n\ntype TabsContentElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsContentProps extends PrimitiveDivProps {\n value: string;\n\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst TabsContent = React.forwardRef<TabsContentElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, forceMount, children, ...contentProps } = props;\n const context = useTabsContext(CONTENT_NAME, __scopeTabs);\n const triggerId = makeTriggerId(context.baseId, value);\n const contentId = makeContentId(context.baseId, value);\n const isSelected = value === context.value;\n const isMountAnimationPreventedRef = React.useRef(isSelected);\n\n React.useEffect(() => {\n const rAF = requestAnimationFrame(() => (isMountAnimationPreventedRef.current = false));\n return () => cancelAnimationFrame(rAF);\n }, []);\n\n return (\n <Presence present={forceMount || isSelected}>\n {({ present }) => (\n <Primitive.div\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n hidden={!present}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n style={{\n ...props.style,\n animationDuration: isMountAnimationPreventedRef.current ? '0s' : undefined,\n }}\n >\n {present && children}\n </Primitive.div>\n )}\n </Presence>\n );\n }\n);\n\nTabsContent.displayName = CONTENT_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\nconst Root = Tabs;\nconst List = TabsList;\nconst Trigger = TabsTrigger;\nconst Content = TabsContent;\n\nexport {\n createTabsScope,\n //\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n //\n Root,\n List,\n Trigger,\n Content,\n};\nexport type { TabsProps, TabsListProps, TabsTriggerProps, TabsContentProps };\n"],"names":["createTabsScope","Tabs","TabsList","TabsTrigger","TabsContent","Root","List","Trigger","Content","React","composeEventHandlers","createContextScope","createRovingFocusGroupScope","Presence","Primitive","RovingFocusGroup","useDirection","useControllableState","useId","TABS_NAME","createTabsContext","useRovingFocusGroupScope","TabsProvider","useTabsContext","forwardRef","props","forwardedRef","__scopeTabs","value","valueProp","onValueChange","defaultValue","orientation","dir","activationMode","tabsProps","direction","setValue","prop","onChange","defaultProp","TAB_LIST_NAME","loop","listProps","context","rovingFocusGroupScope","TRIGGER_NAME","disabled","triggerProps","triggerId","makeTriggerId","baseId","contentId","makeContentId","isSelected","undefined","onMouseDown","event","button","ctrlKey","preventDefault","onKeyDown","includes","key","onFocus","isAutomaticActivation","CONTENT_NAME","forceMount","children","contentProps","isMountAnimationPreventedRef","useRef","useEffect","rAF","requestAnimationFrame","current","cancelAnimationFrame","present","style","animationDuration"],"version":3,"file":"index.js.map"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/Tabs.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { useDirection } from '@radix-ui/react-direction';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useId } from '@radix-ui/react-id';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\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 onValueChange: (value: string) => void;\n orientation?: TabsProps['orientation'];\n dir?: TabsProps['dir'];\n activationMode?: TabsProps['activationMode'];\n};\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME);\n\ntype TabsElement = React.ElementRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface TabsProps extends PrimitiveDivProps {\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.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual';\n}\n\nconst Tabs = React.forwardRef<TabsElement, 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 ...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 onValueChange={setValue}\n orientation={orientation}\n dir={direction}\n activationMode={activationMode}\n >\n <Primitive.div\n dir={direction}\n data-orientation={orientation}\n {...tabsProps}\n ref={forwardedRef}\n />\n </TabsProvider>\n );\n }\n);\n\nTabs.displayName = TABS_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList';\n\ntype TabsListElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsListProps extends PrimitiveDivProps {\n loop?: RovingFocusGroupProps['loop'];\n}\n\nconst TabsList = React.forwardRef<TabsListElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, ...listProps } = props;\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs);\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);\n return (\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n >\n <Primitive.div\n role=\"tablist\"\n aria-orientation={context.orientation}\n {...listProps}\n ref={forwardedRef}\n />\n </RovingFocusGroup.Root>\n );\n }\n);\n\nTabsList.displayName = TAB_LIST_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger';\n\ntype TabsTriggerElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface TabsTriggerProps extends PrimitiveButtonProps {\n value: string;\n}\n\nconst TabsTrigger = React.forwardRef<TabsTriggerElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const { __scopeTabs, value, disabled = false, ...triggerProps } = 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 return (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <Primitive.button\n type=\"button\"\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 {...triggerProps}\n ref={forwardedRef}\n onMouseDown={composeEventHandlers(props.onMouseDown, (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 if (!disabled && event.button === 0 && event.ctrlKey === false) {\n context.onValueChange(value);\n } else {\n // prevent focus to avoid accidental activation\n event.preventDefault();\n }\n })}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if ([' ', 'Enter'].includes(event.key)) context.onValueChange(value);\n })}\n onFocus={composeEventHandlers(props.onFocus, () => {\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.onValueChange(value);\n }\n })}\n />\n </RovingFocusGroup.Item>\n );\n }\n);\n\nTabsTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent';\n\ntype TabsContentElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsContentProps extends PrimitiveDivProps {\n value: string;\n\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst TabsContent = React.forwardRef<TabsContentElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, forceMount, children, ...contentProps } = props;\n const context = useTabsContext(CONTENT_NAME, __scopeTabs);\n const triggerId = makeTriggerId(context.baseId, value);\n const contentId = makeContentId(context.baseId, value);\n const isSelected = value === context.value;\n const isMountAnimationPreventedRef = React.useRef(isSelected);\n\n React.useEffect(() => {\n const rAF = requestAnimationFrame(() => (isMountAnimationPreventedRef.current = false));\n return () => cancelAnimationFrame(rAF);\n }, []);\n\n return (\n <Presence present={forceMount || isSelected}>\n {({ present }) => (\n <Primitive.div\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n hidden={!present}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n style={{\n ...props.style,\n animationDuration: isMountAnimationPreventedRef.current ? '0s' : undefined,\n }}\n >\n {present && children}\n </Primitive.div>\n )}\n </Presence>\n );\n }\n);\n\nTabsContent.displayName = CONTENT_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\nconst Root = Tabs;\nconst List = TabsList;\nconst Trigger = TabsTrigger;\nconst Content = TabsContent;\n\nexport {\n createTabsScope,\n //\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n //\n Root,\n List,\n Trigger,\n Content,\n};\nexport type { TabsProps, TabsListProps, TabsTriggerProps, TabsContentProps };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAuB;AACvB,yBAAqC;AACrC,6BAAmC;AACnC,kCAA4C;AAC5C,8BAAyB;AACzB,+BAA0B;AAC1B,yBAAkC;AAClC,+BAA6B;AAC7B,4CAAqC;AACrC,wBAAsB;AAoFd;AA3ER,MAAM,YAAY;AAGlB,MAAM,CAAC,mBAAmB,eAAe,QAAI,yCAAmB,WAAW;AAAA,IACzE;AAAA,EACF,CAAC;AACD,MAAM,+BAA2B,uDAA4B;AAW7D,MAAM,CAAC,cAAc,cAAc,IAAI,kBAAoC,SAAS;AA6BpF,MAAM,OAAa;AAAA,IACjB,CAAC,OAA+B,iBAAiB;AAC/C,YAAM;AAAA,QACJ;AAAA,QACA,OAAO;AAAA,QACP;AAAA,QACA;AAAA,QACA,cAAc;AAAA,QACd;AAAA,QACA,iBAAiB;AAAA,QACjB,GAAG;AAAA,MACL,IAAI;AACJ,YAAM,gBAAY,qCAAa,GAAG;AAClC,YAAM,CAAC,OAAO,QAAQ,QAAI,0DAAqB;AAAA,QAC7C,MAAM;AAAA,QACN,UAAU;AAAA,QACV,aAAa;AAAA,MACf,CAAC;AAED,aACE;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,UACP,YAAQ,uBAAM;AAAA,UACd;AAAA,UACA,eAAe;AAAA,UACf;AAAA,UACA,KAAK;AAAA,UACL;AAAA,UAEA;AAAA,YAAC,iCAAU;AAAA,YAAV;AAAA,cACC,KAAK;AAAA,cACL,oBAAkB;AAAA,cACjB,GAAG;AAAA,cACJ,KAAK;AAAA;AAAA,UACP;AAAA;AAAA,MACF;AAAA,IAEJ;AAAA,EACF;AAEA,OAAK,cAAc;AAMnB,MAAM,gBAAgB;AAOtB,MAAM,WAAiB;AAAA,IACrB,CAA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,IAAI;AAAA,UACJ,UAAU;AAAA,UACT,GAAG;AAAA,UACJ,KAAK;AAAA,UACL,OAAO;AAAA,YACL,GAAG,MAAM;AAAA,YACT,mBAAmB,6BAA6B,UAAU,OAAO;AAAA,UACnE;AAAA,UAEC,qBAAW;AAAA;AAAA,MACd,GAEJ;AAAA,IAEJ;AAAA,EACF;AAEA,cAAY,cAAc;AAI1B,WAAS,cAAc,QAAgB,OAAe;AACpD,WAAO,GAAG,MAAM,YAAY,KAAK;AAAA,EACnC;AAEA,WAAS,cAAc,QAAgB,OAAe;AACpD,WAAO,GAAG,MAAM,YAAY,KAAK;AAAA,EACnC;AAEA,MAAMA,QAAO;AACb,MAAM,OAAO;AACb,MAAM,UAAU;AAChB,MAAM,UAAU;",
6
+ "names": ["Root"]
7
+ }
package/dist/index.mjs CHANGED
@@ -1,183 +1,197 @@
1
- import $1IHzk$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
2
- import {forwardRef as $1IHzk$forwardRef, createElement as $1IHzk$createElement, useRef as $1IHzk$useRef, useEffect as $1IHzk$useEffect} from "react";
3
- import {composeEventHandlers as $1IHzk$composeEventHandlers} from "@radix-ui/primitive";
4
- import {createContextScope as $1IHzk$createContextScope} from "@radix-ui/react-context";
5
- import {createRovingFocusGroupScope as $1IHzk$createRovingFocusGroupScope, Root as $1IHzk$Root, Item as $1IHzk$Item} from "@radix-ui/react-roving-focus";
6
- import {Presence as $1IHzk$Presence} from "@radix-ui/react-presence";
7
- import {Primitive as $1IHzk$Primitive} from "@radix-ui/react-primitive";
8
- import {useDirection as $1IHzk$useDirection} from "@radix-ui/react-direction";
9
- import {useControllableState as $1IHzk$useControllableState} from "@radix-ui/react-use-controllable-state";
10
- import {useId as $1IHzk$useId} from "@radix-ui/react-id";
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
- /* -------------------------------------------------------------------------------------------------
24
- * Tabs
25
- * -----------------------------------------------------------------------------------------------*/ const $69cb30bb0017df05$var$TABS_NAME = 'Tabs';
26
- const [$69cb30bb0017df05$var$createTabsContext, $69cb30bb0017df05$export$355f5bd209d7b13a] = $1IHzk$createContextScope($69cb30bb0017df05$var$TABS_NAME, [
27
- $1IHzk$createRovingFocusGroupScope
1
+ // packages/react/tabs/src/Tabs.tsx
2
+ import * as React from "react";
3
+ import { composeEventHandlers } from "@radix-ui/primitive";
4
+ import { createContextScope } from "@radix-ui/react-context";
5
+ import { createRovingFocusGroupScope } from "@radix-ui/react-roving-focus";
6
+ import { Presence } from "@radix-ui/react-presence";
7
+ import { Primitive } from "@radix-ui/react-primitive";
8
+ import * as RovingFocusGroup from "@radix-ui/react-roving-focus";
9
+ import { useDirection } from "@radix-ui/react-direction";
10
+ import { useControllableState } from "@radix-ui/react-use-controllable-state";
11
+ import { useId } from "@radix-ui/react-id";
12
+ import { jsx } from "react/jsx-runtime";
13
+ var TABS_NAME = "Tabs";
14
+ var [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [
15
+ createRovingFocusGroupScope
28
16
  ]);
29
- const $69cb30bb0017df05$var$useRovingFocusGroupScope = $1IHzk$createRovingFocusGroupScope();
30
- const [$69cb30bb0017df05$var$TabsProvider, $69cb30bb0017df05$var$useTabsContext] = $69cb30bb0017df05$var$createTabsContext($69cb30bb0017df05$var$TABS_NAME);
31
- const $69cb30bb0017df05$export$b2539bed5023c21c = /*#__PURE__*/ $1IHzk$forwardRef((props, forwardedRef)=>{
32
- const { __scopeTabs: __scopeTabs , value: valueProp , onValueChange: onValueChange , defaultValue: defaultValue , orientation: orientation = 'horizontal' , dir: dir , activationMode: activationMode = 'automatic' , ...tabsProps } = props;
33
- const direction = $1IHzk$useDirection(dir);
34
- const [value, setValue] = $1IHzk$useControllableState({
35
- prop: valueProp,
36
- onChange: onValueChange,
37
- defaultProp: defaultValue
17
+ var useRovingFocusGroupScope = createRovingFocusGroupScope();
18
+ var [TabsProvider, useTabsContext] = createTabsContext(TABS_NAME);
19
+ var Tabs = React.forwardRef(
20
+ (props, forwardedRef) => {
21
+ const {
22
+ __scopeTabs,
23
+ value: valueProp,
24
+ onValueChange,
25
+ defaultValue,
26
+ orientation = "horizontal",
27
+ dir,
28
+ activationMode = "automatic",
29
+ ...tabsProps
30
+ } = props;
31
+ const direction = useDirection(dir);
32
+ const [value, setValue] = useControllableState({
33
+ prop: valueProp,
34
+ onChange: onValueChange,
35
+ defaultProp: defaultValue
38
36
  });
39
- return /*#__PURE__*/ $1IHzk$createElement($69cb30bb0017df05$var$TabsProvider, {
37
+ return /* @__PURE__ */ jsx(
38
+ TabsProvider,
39
+ {
40
40
  scope: __scopeTabs,
41
- baseId: $1IHzk$useId(),
42
- value: value,
41
+ baseId: useId(),
42
+ value,
43
43
  onValueChange: setValue,
44
- orientation: orientation,
44
+ orientation,
45
45
  dir: direction,
46
- activationMode: activationMode
47
- }, /*#__PURE__*/ $1IHzk$createElement($1IHzk$Primitive.div, $1IHzk$babelruntimehelpersesmextends({
48
- dir: direction,
49
- "data-orientation": orientation
50
- }, tabsProps, {
51
- ref: forwardedRef
52
- })));
53
- });
54
- /*#__PURE__*/ Object.assign($69cb30bb0017df05$export$b2539bed5023c21c, {
55
- displayName: $69cb30bb0017df05$var$TABS_NAME
56
- });
57
- /* -------------------------------------------------------------------------------------------------
58
- * TabsList
59
- * -----------------------------------------------------------------------------------------------*/ const $69cb30bb0017df05$var$TAB_LIST_NAME = 'TabsList';
60
- const $69cb30bb0017df05$export$9712d22edc0d78c1 = /*#__PURE__*/ $1IHzk$forwardRef((props, forwardedRef)=>{
61
- const { __scopeTabs: __scopeTabs , loop: loop = true , ...listProps } = props;
62
- const context = $69cb30bb0017df05$var$useTabsContext($69cb30bb0017df05$var$TAB_LIST_NAME, __scopeTabs);
63
- const rovingFocusGroupScope = $69cb30bb0017df05$var$useRovingFocusGroupScope(__scopeTabs);
64
- return /*#__PURE__*/ $1IHzk$createElement($1IHzk$Root, $1IHzk$babelruntimehelpersesmextends({
65
- asChild: true
66
- }, rovingFocusGroupScope, {
46
+ activationMode,
47
+ children: /* @__PURE__ */ jsx(
48
+ Primitive.div,
49
+ {
50
+ dir: direction,
51
+ "data-orientation": orientation,
52
+ ...tabsProps,
53
+ ref: forwardedRef
54
+ }
55
+ )
56
+ }
57
+ );
58
+ }
59
+ );
60
+ Tabs.displayName = TABS_NAME;
61
+ var TAB_LIST_NAME = "TabsList";
62
+ var TabsList = React.forwardRef(
63
+ (props, forwardedRef) => {
64
+ const { __scopeTabs, loop = true, ...listProps } = props;
65
+ const context = useTabsContext(TAB_LIST_NAME, __scopeTabs);
66
+ const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);
67
+ return /* @__PURE__ */ jsx(
68
+ RovingFocusGroup.Root,
69
+ {
70
+ asChild: true,
71
+ ...rovingFocusGroupScope,
67
72
  orientation: context.orientation,
68
73
  dir: context.dir,
69
- loop: loop
70
- }), /*#__PURE__*/ $1IHzk$createElement($1IHzk$Primitive.div, $1IHzk$babelruntimehelpersesmextends({
71
- role: "tablist",
72
- "aria-orientation": context.orientation
73
- }, listProps, {
74
- ref: forwardedRef
75
- })));
76
- });
77
- /*#__PURE__*/ Object.assign($69cb30bb0017df05$export$9712d22edc0d78c1, {
78
- displayName: $69cb30bb0017df05$var$TAB_LIST_NAME
79
- });
80
- /* -------------------------------------------------------------------------------------------------
81
- * TabsTrigger
82
- * -----------------------------------------------------------------------------------------------*/ const $69cb30bb0017df05$var$TRIGGER_NAME = 'TabsTrigger';
83
- const $69cb30bb0017df05$export$8114b9fdfdf9f3ba = /*#__PURE__*/ $1IHzk$forwardRef((props, forwardedRef)=>{
84
- const { __scopeTabs: __scopeTabs , value: value , disabled: disabled = false , ...triggerProps } = props;
85
- const context = $69cb30bb0017df05$var$useTabsContext($69cb30bb0017df05$var$TRIGGER_NAME, __scopeTabs);
86
- const rovingFocusGroupScope = $69cb30bb0017df05$var$useRovingFocusGroupScope(__scopeTabs);
87
- const triggerId = $69cb30bb0017df05$var$makeTriggerId(context.baseId, value);
88
- const contentId = $69cb30bb0017df05$var$makeContentId(context.baseId, value);
74
+ loop,
75
+ children: /* @__PURE__ */ jsx(
76
+ Primitive.div,
77
+ {
78
+ role: "tablist",
79
+ "aria-orientation": context.orientation,
80
+ ...listProps,
81
+ ref: forwardedRef
82
+ }
83
+ )
84
+ }
85
+ );
86
+ }
87
+ );
88
+ TabsList.displayName = TAB_LIST_NAME;
89
+ var TRIGGER_NAME = "TabsTrigger";
90
+ var TabsTrigger = React.forwardRef(
91
+ (props, forwardedRef) => {
92
+ const { __scopeTabs, value, disabled = false, ...triggerProps } = props;
93
+ const context = useTabsContext(TRIGGER_NAME, __scopeTabs);
94
+ const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);
95
+ const triggerId = makeTriggerId(context.baseId, value);
96
+ const contentId = makeContentId(context.baseId, value);
89
97
  const isSelected = value === context.value;
90
- return /*#__PURE__*/ $1IHzk$createElement($1IHzk$Item, $1IHzk$babelruntimehelpersesmextends({
91
- asChild: true
92
- }, rovingFocusGroupScope, {
98
+ return /* @__PURE__ */ jsx(
99
+ RovingFocusGroup.Item,
100
+ {
101
+ asChild: true,
102
+ ...rovingFocusGroupScope,
93
103
  focusable: !disabled,
94
- active: isSelected
95
- }), /*#__PURE__*/ $1IHzk$createElement($1IHzk$Primitive.button, $1IHzk$babelruntimehelpersesmextends({
96
- type: "button",
97
- role: "tab",
98
- "aria-selected": isSelected,
99
- "aria-controls": contentId,
100
- "data-state": isSelected ? 'active' : 'inactive',
101
- "data-disabled": disabled ? '' : undefined,
102
- disabled: disabled,
103
- id: triggerId
104
- }, triggerProps, {
105
- ref: forwardedRef,
106
- onMouseDown: $1IHzk$composeEventHandlers(props.onMouseDown, (event)=>{
107
- // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)
108
- // but not when the control key is pressed (avoiding MacOS right click)
109
- if (!disabled && event.button === 0 && event.ctrlKey === false) context.onValueChange(value);
110
- else // prevent focus to avoid accidental activation
111
- event.preventDefault();
112
- }),
113
- onKeyDown: $1IHzk$composeEventHandlers(props.onKeyDown, (event)=>{
114
- if ([
115
- ' ',
116
- 'Enter'
117
- ].includes(event.key)) context.onValueChange(value);
118
- }),
119
- onFocus: $1IHzk$composeEventHandlers(props.onFocus, ()=>{
120
- // handle "automatic" activation if necessary
121
- // ie. activate tab following focus
122
- const isAutomaticActivation = context.activationMode !== 'manual';
123
- if (!isSelected && !disabled && isAutomaticActivation) context.onValueChange(value);
124
- })
125
- })));
126
- });
127
- /*#__PURE__*/ Object.assign($69cb30bb0017df05$export$8114b9fdfdf9f3ba, {
128
- displayName: $69cb30bb0017df05$var$TRIGGER_NAME
129
- });
130
- /* -------------------------------------------------------------------------------------------------
131
- * TabsContent
132
- * -----------------------------------------------------------------------------------------------*/ const $69cb30bb0017df05$var$CONTENT_NAME = 'TabsContent';
133
- const $69cb30bb0017df05$export$bd905d70e8fd2ebb = /*#__PURE__*/ $1IHzk$forwardRef((props, forwardedRef)=>{
134
- const { __scopeTabs: __scopeTabs , value: value , forceMount: forceMount , children: children , ...contentProps } = props;
135
- const context = $69cb30bb0017df05$var$useTabsContext($69cb30bb0017df05$var$CONTENT_NAME, __scopeTabs);
136
- const triggerId = $69cb30bb0017df05$var$makeTriggerId(context.baseId, value);
137
- const contentId = $69cb30bb0017df05$var$makeContentId(context.baseId, value);
138
- const isSelected = value === context.value;
139
- const isMountAnimationPreventedRef = $1IHzk$useRef(isSelected);
140
- $1IHzk$useEffect(()=>{
141
- const rAF = requestAnimationFrame(()=>isMountAnimationPreventedRef.current = false
142
- );
143
- return ()=>cancelAnimationFrame(rAF)
144
- ;
145
- }, []);
146
- return /*#__PURE__*/ $1IHzk$createElement($1IHzk$Presence, {
147
- present: forceMount || isSelected
148
- }, ({ present: present })=>/*#__PURE__*/ $1IHzk$createElement($1IHzk$Primitive.div, $1IHzk$babelruntimehelpersesmextends({
149
- "data-state": isSelected ? 'active' : 'inactive',
150
- "data-orientation": context.orientation,
151
- role: "tabpanel",
152
- "aria-labelledby": triggerId,
153
- hidden: !present,
154
- id: contentId,
155
- tabIndex: 0
156
- }, contentProps, {
104
+ active: isSelected,
105
+ children: /* @__PURE__ */ jsx(
106
+ Primitive.button,
107
+ {
108
+ type: "button",
109
+ role: "tab",
110
+ "aria-selected": isSelected,
111
+ "aria-controls": contentId,
112
+ "data-state": isSelected ? "active" : "inactive",
113
+ "data-disabled": disabled ? "" : void 0,
114
+ disabled,
115
+ id: triggerId,
116
+ ...triggerProps,
157
117
  ref: forwardedRef,
158
- style: {
159
- ...props.style,
160
- animationDuration: isMountAnimationPreventedRef.current ? '0s' : undefined
161
- }
162
- }), present && children)
118
+ onMouseDown: composeEventHandlers(props.onMouseDown, (event) => {
119
+ if (!disabled && event.button === 0 && event.ctrlKey === false) {
120
+ context.onValueChange(value);
121
+ } else {
122
+ event.preventDefault();
123
+ }
124
+ }),
125
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
126
+ if ([" ", "Enter"].includes(event.key)) context.onValueChange(value);
127
+ }),
128
+ onFocus: composeEventHandlers(props.onFocus, () => {
129
+ const isAutomaticActivation = context.activationMode !== "manual";
130
+ if (!isSelected && !disabled && isAutomaticActivation) {
131
+ context.onValueChange(value);
132
+ }
133
+ })
134
+ }
135
+ )
136
+ }
163
137
  );
164
- });
165
- /*#__PURE__*/ Object.assign($69cb30bb0017df05$export$bd905d70e8fd2ebb, {
166
- displayName: $69cb30bb0017df05$var$CONTENT_NAME
167
- });
168
- /* ---------------------------------------------------------------------------------------------- */ function $69cb30bb0017df05$var$makeTriggerId(baseId, value) {
169
- return `${baseId}-trigger-${value}`;
138
+ }
139
+ );
140
+ TabsTrigger.displayName = TRIGGER_NAME;
141
+ var CONTENT_NAME = "TabsContent";
142
+ var TabsContent = React.forwardRef(
143
+ (props, forwardedRef) => {
144
+ const { __scopeTabs, value, forceMount, children, ...contentProps } = props;
145
+ const context = useTabsContext(CONTENT_NAME, __scopeTabs);
146
+ const triggerId = makeTriggerId(context.baseId, value);
147
+ const contentId = makeContentId(context.baseId, value);
148
+ const isSelected = value === context.value;
149
+ const isMountAnimationPreventedRef = React.useRef(isSelected);
150
+ React.useEffect(() => {
151
+ const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
152
+ return () => cancelAnimationFrame(rAF);
153
+ }, []);
154
+ return /* @__PURE__ */ jsx(Presence, { present: forceMount || isSelected, children: ({ present }) => /* @__PURE__ */ jsx(
155
+ Primitive.div,
156
+ {
157
+ "data-state": isSelected ? "active" : "inactive",
158
+ "data-orientation": context.orientation,
159
+ role: "tabpanel",
160
+ "aria-labelledby": triggerId,
161
+ hidden: !present,
162
+ id: contentId,
163
+ tabIndex: 0,
164
+ ...contentProps,
165
+ ref: forwardedRef,
166
+ style: {
167
+ ...props.style,
168
+ animationDuration: isMountAnimationPreventedRef.current ? "0s" : void 0
169
+ },
170
+ children: present && children
171
+ }
172
+ ) });
173
+ }
174
+ );
175
+ TabsContent.displayName = CONTENT_NAME;
176
+ function makeTriggerId(baseId, value) {
177
+ return `${baseId}-trigger-${value}`;
170
178
  }
171
- function $69cb30bb0017df05$var$makeContentId(baseId, value) {
172
- return `${baseId}-content-${value}`;
179
+ function makeContentId(baseId, value) {
180
+ return `${baseId}-content-${value}`;
173
181
  }
174
- const $69cb30bb0017df05$export$be92b6f5f03c0fe9 = $69cb30bb0017df05$export$b2539bed5023c21c;
175
- const $69cb30bb0017df05$export$54c2e3dc7acea9f5 = $69cb30bb0017df05$export$9712d22edc0d78c1;
176
- const $69cb30bb0017df05$export$41fb9f06171c75f4 = $69cb30bb0017df05$export$8114b9fdfdf9f3ba;
177
- const $69cb30bb0017df05$export$7c6e2c02157bb7d2 = $69cb30bb0017df05$export$bd905d70e8fd2ebb;
178
-
179
-
180
-
181
-
182
- export {$69cb30bb0017df05$export$355f5bd209d7b13a as createTabsScope, $69cb30bb0017df05$export$b2539bed5023c21c as Tabs, $69cb30bb0017df05$export$9712d22edc0d78c1 as TabsList, $69cb30bb0017df05$export$8114b9fdfdf9f3ba as TabsTrigger, $69cb30bb0017df05$export$bd905d70e8fd2ebb as TabsContent, $69cb30bb0017df05$export$be92b6f5f03c0fe9 as Root, $69cb30bb0017df05$export$54c2e3dc7acea9f5 as List, $69cb30bb0017df05$export$41fb9f06171c75f4 as Trigger, $69cb30bb0017df05$export$7c6e2c02157bb7d2 as Content};
182
+ var Root2 = Tabs;
183
+ var List = TabsList;
184
+ var Trigger = TabsTrigger;
185
+ var Content = TabsContent;
186
+ export {
187
+ Content,
188
+ List,
189
+ Root2 as Root,
190
+ Tabs,
191
+ TabsContent,
192
+ TabsList,
193
+ TabsTrigger,
194
+ Trigger,
195
+ createTabsScope
196
+ };
183
197
  //# sourceMappingURL=index.mjs.map
@@ -1 +1,7 @@
1
- {"mappings":";;;;;;;;;;;A;;;;;;;;;;;ACcA;;oGAEA,CAEA,MAAMmB,+BAAS,GAAG,MAAlB,AAAA;AAGA,MAAM,CAACC,uCAAD,EAAoBpB,yCAApB,CAAA,GAAuCW,yBAAkB,CAACQ,+BAAD,EAAY;IACzEP,kCADyE;CAAZ,CAA/D,AAAA;AAGA,MAAMS,8CAAwB,GAAGT,kCAA2B,EAA5D,AAAA;AAWA,MAAM,CAACU,kCAAD,EAAeC,oCAAf,CAAA,GAAiCH,uCAAiB,CAAmBD,+BAAnB,CAAxD,AAAA;AA6BA,MAAMlB,yCAAI,GAAA,aAAGQ,CAAAA,iBAAA,CACX,CAACgB,KAAD,EAAgCC,YAAhC,GAAiD;IAC/C,MAAM,E,aACJC,WADI,CAAA,EAEJC,KAAK,EAAEC,SAFH,CAAA,E,eAGJC,aAHI,CAAA,E,cAIJC,YAJI,CAAA,eAKJC,WAAW,GAAG,YALV,G,KAMJC,GANI,CAAA,kBAOJC,cAAc,GAAG,WAPb,GAQJ,GAAGC,SAAH,EARI,GASFV,KATJ,AAAM;IAUN,MAAMW,SAAS,GAAGpB,mBAAY,CAACiB,GAAD,CAA9B,AAAA;IACA,MAAM,CAACL,KAAD,EAAQS,QAAR,CAAA,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AC,gBAAD,CAAW,GAAX,EADA,oCAAA,CAAA;YAEE,YAAA,EAAYvB,UAAU,GAAG,QAAH,GAAc,UADtC;YAEE,kBAAA,EAAkBV,OAAO,CAACZ,WAF5B;YAGE,IAAI,EAAC,UAHP;YAIE,iBAAA,EAAiBiB,SAJnB;YAKE,MAAM,EAAE,CAAC4B,OALX;YAME,EAAE,EAAEzB,SANN;YAOE,QAAQ,EAAE,CAAV;SAPF,EAQMiB,YARN,EAAA;YASE,GAAG,EAAE3C,YATP;YAUE,KAAK,EAAE;gBACL,GAAGD,KAAK,CAACqD,KADJ;gBAELC,iBAAiB,EAAET,4BAA4B,CAACK,OAA7B,GAAuC,IAAvC,GAA8CpB,SAAjEwB;aAFK;SAVT,CAAA,EAeGF,OAAO,IAAIT,QAfd,CAFJ;IAAA,CADF,CAGM;CAjBU,CAApB,AAqCG;AAGH,aAAA,CAAA,MAAA,CAAA,MAAA,CAAA,yCAAA,EAAA;IAAA,WAAA,EAAA,kCAAA;CAAA,CAAA,CAAA;AAEA,oGAAA,CAEA,SAASlB,mCAAT,CAAuBC,MAAvB,EAAuCvB,KAAvC,EAAsD;IACpD,OAAQ,CAAA,EAAEuB,MAAO,CAAA,SAAA,EAAWvB,KAAM,CAAA,CAAlC,CAAA;CACD;AAED,SAASyB,mCAAT,CAAuBF,MAAvB,EAAuCvB,KAAvC,EAAsD;IACpD,OAAQ,CAAA,EAAEuB,MAAO,CAAA,SAAA,EAAWvB,KAAM,CAAA,CAAlC,CAAA;CACD;AAED,MAAMvB,yCAAI,GAAGJ,yCAAb,AAAA;AACA,MAAMK,yCAAI,GAAGJ,yCAAb,AAAA;AACA,MAAMK,yCAAO,GAAGJ,yCAAhB,AAAA;AACA,MAAMK,yCAAO,GAAGJ,yCAAhB,AAAA;;AD1RA","sources":["packages/react/tabs/src/index.ts","packages/react/tabs/src/Tabs.tsx"],"sourcesContent":["export {\n createTabsScope,\n //\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n //\n Root,\n List,\n Trigger,\n Content,\n} from './Tabs';\nexport type { TabsProps, TabsListProps, TabsTriggerProps, TabsContentProps } from './Tabs';\n","import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { useDirection } from '@radix-ui/react-direction';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useId } from '@radix-ui/react-id';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\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 onValueChange: (value: string) => void;\n orientation?: TabsProps['orientation'];\n dir?: TabsProps['dir'];\n activationMode?: TabsProps['activationMode'];\n};\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME);\n\ntype TabsElement = React.ElementRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface TabsProps extends PrimitiveDivProps {\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.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual';\n}\n\nconst Tabs = React.forwardRef<TabsElement, 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 ...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 onValueChange={setValue}\n orientation={orientation}\n dir={direction}\n activationMode={activationMode}\n >\n <Primitive.div\n dir={direction}\n data-orientation={orientation}\n {...tabsProps}\n ref={forwardedRef}\n />\n </TabsProvider>\n );\n }\n);\n\nTabs.displayName = TABS_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList';\n\ntype TabsListElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsListProps extends PrimitiveDivProps {\n loop?: RovingFocusGroupProps['loop'];\n}\n\nconst TabsList = React.forwardRef<TabsListElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, ...listProps } = props;\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs);\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);\n return (\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n >\n <Primitive.div\n role=\"tablist\"\n aria-orientation={context.orientation}\n {...listProps}\n ref={forwardedRef}\n />\n </RovingFocusGroup.Root>\n );\n }\n);\n\nTabsList.displayName = TAB_LIST_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger';\n\ntype TabsTriggerElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface TabsTriggerProps extends PrimitiveButtonProps {\n value: string;\n}\n\nconst TabsTrigger = React.forwardRef<TabsTriggerElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const { __scopeTabs, value, disabled = false, ...triggerProps } = 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 return (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <Primitive.button\n type=\"button\"\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 {...triggerProps}\n ref={forwardedRef}\n onMouseDown={composeEventHandlers(props.onMouseDown, (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 if (!disabled && event.button === 0 && event.ctrlKey === false) {\n context.onValueChange(value);\n } else {\n // prevent focus to avoid accidental activation\n event.preventDefault();\n }\n })}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if ([' ', 'Enter'].includes(event.key)) context.onValueChange(value);\n })}\n onFocus={composeEventHandlers(props.onFocus, () => {\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.onValueChange(value);\n }\n })}\n />\n </RovingFocusGroup.Item>\n );\n }\n);\n\nTabsTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent';\n\ntype TabsContentElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsContentProps extends PrimitiveDivProps {\n value: string;\n\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst TabsContent = React.forwardRef<TabsContentElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, forceMount, children, ...contentProps } = props;\n const context = useTabsContext(CONTENT_NAME, __scopeTabs);\n const triggerId = makeTriggerId(context.baseId, value);\n const contentId = makeContentId(context.baseId, value);\n const isSelected = value === context.value;\n const isMountAnimationPreventedRef = React.useRef(isSelected);\n\n React.useEffect(() => {\n const rAF = requestAnimationFrame(() => (isMountAnimationPreventedRef.current = false));\n return () => cancelAnimationFrame(rAF);\n }, []);\n\n return (\n <Presence present={forceMount || isSelected}>\n {({ present }) => (\n <Primitive.div\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n hidden={!present}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n style={{\n ...props.style,\n animationDuration: isMountAnimationPreventedRef.current ? '0s' : undefined,\n }}\n >\n {present && children}\n </Primitive.div>\n )}\n </Presence>\n );\n }\n);\n\nTabsContent.displayName = CONTENT_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\nconst Root = Tabs;\nconst List = TabsList;\nconst Trigger = TabsTrigger;\nconst Content = TabsContent;\n\nexport {\n createTabsScope,\n //\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n //\n Root,\n List,\n Trigger,\n Content,\n};\nexport type { TabsProps, TabsListProps, TabsTriggerProps, TabsContentProps };\n"],"names":["createTabsScope","Tabs","TabsList","TabsTrigger","TabsContent","Root","List","Trigger","Content","React","composeEventHandlers","createContextScope","createRovingFocusGroupScope","Presence","Primitive","RovingFocusGroup","useDirection","useControllableState","useId","TABS_NAME","createTabsContext","useRovingFocusGroupScope","TabsProvider","useTabsContext","forwardRef","props","forwardedRef","__scopeTabs","value","valueProp","onValueChange","defaultValue","orientation","dir","activationMode","tabsProps","direction","setValue","prop","onChange","defaultProp","TAB_LIST_NAME","loop","listProps","context","rovingFocusGroupScope","TRIGGER_NAME","disabled","triggerProps","triggerId","makeTriggerId","baseId","contentId","makeContentId","isSelected","undefined","onMouseDown","event","button","ctrlKey","preventDefault","onKeyDown","includes","key","onFocus","isAutomaticActivation","CONTENT_NAME","forceMount","children","contentProps","isMountAnimationPreventedRef","useRef","useEffect","rAF","requestAnimationFrame","current","cancelAnimationFrame","present","style","animationDuration"],"version":3,"file":"index.mjs.map"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/Tabs.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { createRovingFocusGroupScope } from '@radix-ui/react-roving-focus';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as RovingFocusGroup from '@radix-ui/react-roving-focus';\nimport { useDirection } from '@radix-ui/react-direction';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useId } from '@radix-ui/react-id';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\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 onValueChange: (value: string) => void;\n orientation?: TabsProps['orientation'];\n dir?: TabsProps['dir'];\n activationMode?: TabsProps['activationMode'];\n};\n\nconst [TabsProvider, useTabsContext] = createTabsContext<TabsContextValue>(TABS_NAME);\n\ntype TabsElement = React.ElementRef<typeof Primitive.div>;\ntype RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface TabsProps extends PrimitiveDivProps {\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.\n * @defaultValue automatic\n * */\n activationMode?: 'automatic' | 'manual';\n}\n\nconst Tabs = React.forwardRef<TabsElement, 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 ...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 onValueChange={setValue}\n orientation={orientation}\n dir={direction}\n activationMode={activationMode}\n >\n <Primitive.div\n dir={direction}\n data-orientation={orientation}\n {...tabsProps}\n ref={forwardedRef}\n />\n </TabsProvider>\n );\n }\n);\n\nTabs.displayName = TABS_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsList\n * -----------------------------------------------------------------------------------------------*/\n\nconst TAB_LIST_NAME = 'TabsList';\n\ntype TabsListElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsListProps extends PrimitiveDivProps {\n loop?: RovingFocusGroupProps['loop'];\n}\n\nconst TabsList = React.forwardRef<TabsListElement, TabsListProps>(\n (props: ScopedProps<TabsListProps>, forwardedRef) => {\n const { __scopeTabs, loop = true, ...listProps } = props;\n const context = useTabsContext(TAB_LIST_NAME, __scopeTabs);\n const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);\n return (\n <RovingFocusGroup.Root\n asChild\n {...rovingFocusGroupScope}\n orientation={context.orientation}\n dir={context.dir}\n loop={loop}\n >\n <Primitive.div\n role=\"tablist\"\n aria-orientation={context.orientation}\n {...listProps}\n ref={forwardedRef}\n />\n </RovingFocusGroup.Root>\n );\n }\n);\n\nTabsList.displayName = TAB_LIST_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TabsTrigger';\n\ntype TabsTriggerElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface TabsTriggerProps extends PrimitiveButtonProps {\n value: string;\n}\n\nconst TabsTrigger = React.forwardRef<TabsTriggerElement, TabsTriggerProps>(\n (props: ScopedProps<TabsTriggerProps>, forwardedRef) => {\n const { __scopeTabs, value, disabled = false, ...triggerProps } = 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 return (\n <RovingFocusGroup.Item\n asChild\n {...rovingFocusGroupScope}\n focusable={!disabled}\n active={isSelected}\n >\n <Primitive.button\n type=\"button\"\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 {...triggerProps}\n ref={forwardedRef}\n onMouseDown={composeEventHandlers(props.onMouseDown, (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 if (!disabled && event.button === 0 && event.ctrlKey === false) {\n context.onValueChange(value);\n } else {\n // prevent focus to avoid accidental activation\n event.preventDefault();\n }\n })}\n onKeyDown={composeEventHandlers(props.onKeyDown, (event) => {\n if ([' ', 'Enter'].includes(event.key)) context.onValueChange(value);\n })}\n onFocus={composeEventHandlers(props.onFocus, () => {\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.onValueChange(value);\n }\n })}\n />\n </RovingFocusGroup.Item>\n );\n }\n);\n\nTabsTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TabsContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TabsContent';\n\ntype TabsContentElement = React.ElementRef<typeof Primitive.div>;\ninterface TabsContentProps extends PrimitiveDivProps {\n value: string;\n\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst TabsContent = React.forwardRef<TabsContentElement, TabsContentProps>(\n (props: ScopedProps<TabsContentProps>, forwardedRef) => {\n const { __scopeTabs, value, forceMount, children, ...contentProps } = props;\n const context = useTabsContext(CONTENT_NAME, __scopeTabs);\n const triggerId = makeTriggerId(context.baseId, value);\n const contentId = makeContentId(context.baseId, value);\n const isSelected = value === context.value;\n const isMountAnimationPreventedRef = React.useRef(isSelected);\n\n React.useEffect(() => {\n const rAF = requestAnimationFrame(() => (isMountAnimationPreventedRef.current = false));\n return () => cancelAnimationFrame(rAF);\n }, []);\n\n return (\n <Presence present={forceMount || isSelected}>\n {({ present }) => (\n <Primitive.div\n data-state={isSelected ? 'active' : 'inactive'}\n data-orientation={context.orientation}\n role=\"tabpanel\"\n aria-labelledby={triggerId}\n hidden={!present}\n id={contentId}\n tabIndex={0}\n {...contentProps}\n ref={forwardedRef}\n style={{\n ...props.style,\n animationDuration: isMountAnimationPreventedRef.current ? '0s' : undefined,\n }}\n >\n {present && children}\n </Primitive.div>\n )}\n </Presence>\n );\n }\n);\n\nTabsContent.displayName = CONTENT_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\nconst Root = Tabs;\nconst List = TabsList;\nconst Trigger = TabsTrigger;\nconst Content = TabsContent;\n\nexport {\n createTabsScope,\n //\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n //\n Root,\n List,\n Trigger,\n Content,\n};\nexport type { TabsProps, TabsListProps, TabsTriggerProps, TabsContentProps };\n"],
5
+ "mappings": ";AAAA,YAAY,WAAW;AACvB,SAAS,4BAA4B;AACrC,SAAS,0BAA0B;AACnC,SAAS,mCAAmC;AAC5C,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,YAAY,sBAAsB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,4BAA4B;AACrC,SAAS,aAAa;AAoFd;AA3ER,IAAM,YAAY;AAGlB,IAAM,CAAC,mBAAmB,eAAe,IAAI,mBAAmB,WAAW;AAAA,EACzE;AACF,CAAC;AACD,IAAM,2BAA2B,4BAA4B;AAW7D,IAAM,CAAC,cAAc,cAAc,IAAI,kBAAoC,SAAS;AA6BpF,IAAM,OAAa;AAAA,EACjB,CAAC,OAA+B,iBAAiB;AAC/C,UAAM;AAAA,MACJ;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA,cAAc;AAA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AI;AACtE,UAAM,UAAU,eAAe,cAAc,WAAW;AACxD,UAAM,YAAY,cAAc,QAAQ,QAAQ,KAAK;AACrD,UAAM,YAAY,cAAc,QAAQ,QAAQ,KAAK;AACrD,UAAM,aAAa,UAAU,QAAQ;AACrC,UAAM,+BAAqC,aAAO,UAAU;AAE5D,IAAM,gBAAU,MAAM;AACpB,YAAM,MAAM,sBAAsB,MAAO,6BAA6B,UAAU,KAAM;AACtF,aAAO,MAAM,qBAAqB,GAAG;AAAA,IACvC,GAAG,CAAC,CAAC;AAEL,WACE,oBAAC,YAAS,SAAS,cAAc,YAC9B,WAAC,EAAE,QAAQ,MACV;AAAA,MAAC,UAAU;AAAA,MAAV;AAAA,QACC,cAAY,aAAa,WAAW;AAAA,QACpC,oBAAkB,QAAQ;AAAA,QAC1B,MAAK;AAAA,QACL,mBAAiB;AAAA,QACjB,QAAQ,CAAC;AAAA,QACT,IAAI;AAAA,QACJ,UAAU;AAAA,QACT,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,OAAO;AAAA,UACL,GAAG,MAAM;AAAA,UACT,mBAAmB,6BAA6B,UAAU,OAAO;AAAA,QACnE;AAAA,QAEC,qBAAW;AAAA;AAAA,IACd,GAEJ;AAAA,EAEJ;AACF;AAEA,YAAY,cAAc;AAI1B,SAAS,cAAc,QAAgB,OAAe;AACpD,SAAO,GAAG,MAAM,YAAY,KAAK;AACnC;AAEA,SAAS,cAAc,QAAgB,OAAe;AACpD,SAAO,GAAG,MAAM,YAAY,KAAK;AACnC;AAEA,IAAMA,QAAO;AACb,IAAM,OAAO;AACb,IAAM,UAAU;AAChB,IAAM,UAAU;",
6
+ "names": ["Root"]
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-tabs",
3
- "version": "1.0.5-rc.9",
3
+ "version": "1.1.0-rc.1",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": {
@@ -28,15 +28,14 @@
28
28
  "version": "yarn version"
29
29
  },
30
30
  "dependencies": {
31
- "@babel/runtime": "^7.13.10",
32
- "@radix-ui/primitive": "1.0.1",
33
- "@radix-ui/react-context": "1.0.1",
34
- "@radix-ui/react-direction": "1.0.1",
35
- "@radix-ui/react-id": "1.0.1",
36
- "@radix-ui/react-presence": "1.0.1",
37
- "@radix-ui/react-primitive": "1.0.3",
38
- "@radix-ui/react-roving-focus": "1.0.5-rc.9",
39
- "@radix-ui/react-use-controllable-state": "1.0.1"
31
+ "@radix-ui/primitive": "1.1.0-rc.1",
32
+ "@radix-ui/react-context": "1.1.0-rc.1",
33
+ "@radix-ui/react-direction": "1.1.0-rc.1",
34
+ "@radix-ui/react-id": "1.1.0-rc.1",
35
+ "@radix-ui/react-presence": "1.1.0-rc.1",
36
+ "@radix-ui/react-primitive": "1.1.0-rc.1",
37
+ "@radix-ui/react-roving-focus": "1.1.0-rc.1",
38
+ "@radix-ui/react-use-controllable-state": "1.1.0-rc.1"
40
39
  },
41
40
  "peerDependencies": {
42
41
  "@types/react": "*",
@@ -1 +0,0 @@
1
- {"mappings":";;;;AAqBA,OAAA,sFAEE,CAAC;AAeH,6BAA6B,MAAM,wBAAwB,CAAC,OAAO,iBAAiB,IAAI,CAAC,CAAC;AAC1F,yBAAyB,MAAM,wBAAwB,CAAC,OAAO,UAAU,GAAG,CAAC,CAAC;AAC9E,0BAAoB,SAAQ,iBAAiB;IAC3C,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC;;;;OAIG;IACH,WAAW,CAAC,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAC;IACnD;;OAEG;IACH,GAAG,CAAC,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACnC;;;SAGK;IACL,cAAc,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC;CACzC;AAED,OAAA,MAAM,sFAsCL,CAAC;AAWF,8BAAwB,SAAQ,iBAAiB;IAC/C,IAAI,CAAC,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAC;CACtC;AAED,OAAA,MAAM,8FAsBL,CAAC;AAWF,4BAA4B,MAAM,wBAAwB,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC;AACpF,iCAA2B,SAAQ,oBAAoB;IACrD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,OAAA,MAAM,uGAmDL,CAAC;AAWF,iCAA2B,SAAQ,iBAAiB;IAClD,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC;CACnB;AAED,OAAA,MAAM,oGAsCL,CAAC;AAcF,OAAA,MAAM,sFAAW,CAAC;AAClB,OAAA,MAAM,0FAAe,CAAC;AACtB,OAAA,MAAM,mGAAqB,CAAC;AAC5B,OAAA,MAAM,gGAAqB,CAAC","sources":["packages/react/tabs/src/packages/react/tabs/src/Tabs.tsx","packages/react/tabs/src/packages/react/tabs/src/index.ts","packages/react/tabs/src/index.ts"],"sourcesContent":[null,null,"export {\n createTabsScope,\n //\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n //\n Root,\n List,\n Trigger,\n Content,\n} from './Tabs';\nexport type { TabsProps, TabsListProps, TabsTriggerProps, TabsContentProps } from './Tabs';\n"],"names":[],"version":3,"file":"index.d.ts.map"}