@dxos/react-ui-tabs 0.8.4-main.b97322e → 0.8.4-main.bcb3aa67d6
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/lib/browser/index.mjs +149 -164
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +149 -164
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/Tabs.d.ts +13 -7
- package/dist/types/src/Tabs.d.ts.map +1 -1
- package/dist/types/src/Tabs.stories.d.ts +21 -6
- package/dist/types/src/Tabs.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -19
- package/src/Tabs.stories.tsx +53 -41
- package/src/Tabs.tsx +155 -118
|
@@ -1,194 +1,179 @@
|
|
|
1
1
|
// src/Tabs.tsx
|
|
2
|
-
import {
|
|
3
|
-
import { useFocusFinders, useArrowNavigationGroup, useFocusableGroup } from "@fluentui/react-tabster";
|
|
2
|
+
import { useArrowNavigationGroup, useFocusFinders, useFocusableGroup } from "@fluentui/react-tabster";
|
|
4
3
|
import { createContext } from "@radix-ui/react-context";
|
|
5
4
|
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
6
5
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
7
|
-
import React, { useCallback, useLayoutEffect
|
|
8
|
-
import { Button } from "@dxos/react-ui";
|
|
6
|
+
import React, { Activity, forwardRef, useCallback, useLayoutEffect } from "react";
|
|
7
|
+
import { Button, IconButton, useForwardedRef } from "@dxos/react-ui";
|
|
9
8
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
10
|
-
import {
|
|
9
|
+
import { mx } from "@dxos/ui-theme";
|
|
11
10
|
var TABS_NAME = "Tabs";
|
|
12
11
|
var [TabsContextProvider, useTabsContext] = createContext(TABS_NAME, {
|
|
12
|
+
orientation: "vertical",
|
|
13
13
|
activePart: "list",
|
|
14
14
|
setActivePart: () => {
|
|
15
|
-
},
|
|
16
|
-
orientation: "vertical"
|
|
17
|
-
});
|
|
18
|
-
var TabsRoot = ({ children, classNames, activePart: propsActivePart, onActivePartChange, defaultActivePart, value: propsValue, onValueChange, defaultValue, orientation = "vertical", activationMode = "manual", verticalVariant = "stateful", attendableId, ...props }) => {
|
|
19
|
-
var _effect = _useSignals();
|
|
20
|
-
try {
|
|
21
|
-
const _1 = useArrowNavigationGroup();
|
|
22
|
-
const _2 = useFocusableGroup();
|
|
23
|
-
const [activePart = "list", setActivePart] = useControllableState({
|
|
24
|
-
prop: propsActivePart,
|
|
25
|
-
onChange: onActivePartChange,
|
|
26
|
-
defaultProp: defaultActivePart
|
|
27
|
-
});
|
|
28
|
-
const [value, setValue] = useControllableState({
|
|
29
|
-
prop: propsValue,
|
|
30
|
-
onChange: onValueChange,
|
|
31
|
-
defaultProp: defaultValue
|
|
32
|
-
});
|
|
33
|
-
const handleValueChange = useCallback((nextValue) => {
|
|
34
|
-
setActivePart("panel");
|
|
35
|
-
setValue(nextValue);
|
|
36
|
-
}, [
|
|
37
|
-
value
|
|
38
|
-
]);
|
|
39
|
-
const { findFirstFocusable } = useFocusFinders();
|
|
40
|
-
const tabsRoot = useRef(null);
|
|
41
|
-
useLayoutEffect(() => {
|
|
42
|
-
if (tabsRoot.current) {
|
|
43
|
-
findFirstFocusable(tabsRoot.current)?.focus();
|
|
44
|
-
}
|
|
45
|
-
}, [
|
|
46
|
-
activePart
|
|
47
|
-
]);
|
|
48
|
-
return /* @__PURE__ */ React.createElement(TabsContextProvider, {
|
|
49
|
-
orientation,
|
|
50
|
-
activePart,
|
|
51
|
-
setActivePart,
|
|
52
|
-
value,
|
|
53
|
-
attendableId,
|
|
54
|
-
verticalVariant
|
|
55
|
-
}, /* @__PURE__ */ React.createElement(TabsPrimitive.Root, {
|
|
56
|
-
activationMode,
|
|
57
|
-
"data-active": activePart,
|
|
58
|
-
orientation,
|
|
59
|
-
...props,
|
|
60
|
-
value,
|
|
61
|
-
onValueChange: handleValueChange,
|
|
62
|
-
className: mx("overflow-hidden", orientation === "vertical" && verticalVariant === "stateful" && "[&[data-active=list]_[role=tabpanel]]:invisible @md:[&[data-active=list]_[role=tabpanel]]:visible", classNames),
|
|
63
|
-
ref: tabsRoot
|
|
64
|
-
}, children));
|
|
65
|
-
} finally {
|
|
66
|
-
_effect.f();
|
|
67
15
|
}
|
|
68
|
-
};
|
|
16
|
+
});
|
|
17
|
+
var TabsRoot = /* @__PURE__ */ forwardRef(({ children, classNames, activePart: propsActivePart, onActivePartChange, defaultActivePart, value: propsValue, onValueChange, defaultValue, orientation = "vertical", activationMode = "manual", attendableId, ...props }, forwardedRef) => {
|
|
18
|
+
const tabsRoot = useForwardedRef(forwardedRef);
|
|
19
|
+
const _1 = useArrowNavigationGroup();
|
|
20
|
+
const _2 = useFocusableGroup();
|
|
21
|
+
const [activePart = "list", setActivePart] = useControllableState({
|
|
22
|
+
prop: propsActivePart,
|
|
23
|
+
onChange: onActivePartChange,
|
|
24
|
+
defaultProp: defaultActivePart
|
|
25
|
+
});
|
|
26
|
+
const [value, setValue] = useControllableState({
|
|
27
|
+
prop: propsValue,
|
|
28
|
+
onChange: onValueChange,
|
|
29
|
+
defaultProp: defaultValue
|
|
30
|
+
});
|
|
31
|
+
const handleValueChange = useCallback((nextValue) => {
|
|
32
|
+
setActivePart("panel");
|
|
33
|
+
setValue(nextValue);
|
|
34
|
+
}, [
|
|
35
|
+
value
|
|
36
|
+
]);
|
|
37
|
+
const { findFirstFocusable } = useFocusFinders();
|
|
38
|
+
useLayoutEffect(() => {
|
|
39
|
+
if (tabsRoot.current) {
|
|
40
|
+
findFirstFocusable(tabsRoot.current)?.focus();
|
|
41
|
+
}
|
|
42
|
+
}, [
|
|
43
|
+
activePart
|
|
44
|
+
]);
|
|
45
|
+
return /* @__PURE__ */ React.createElement(TabsContextProvider, {
|
|
46
|
+
orientation,
|
|
47
|
+
activePart,
|
|
48
|
+
setActivePart,
|
|
49
|
+
value,
|
|
50
|
+
attendableId
|
|
51
|
+
}, /* @__PURE__ */ React.createElement(TabsPrimitive.Root, {
|
|
52
|
+
...props,
|
|
53
|
+
className: mx("overflow-hidden", classNames),
|
|
54
|
+
orientation,
|
|
55
|
+
activationMode,
|
|
56
|
+
"data-active": activePart,
|
|
57
|
+
value,
|
|
58
|
+
onValueChange: handleValueChange,
|
|
59
|
+
ref: tabsRoot
|
|
60
|
+
}, children));
|
|
61
|
+
});
|
|
69
62
|
var TabsViewport = ({ classNames, children, ...props }) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
className: mx(orientation === "vertical" && verticalVariant === "stateful" && [
|
|
78
|
-
"grid is-[200%] grid-cols-2 data-[active=panel]:mis-[-100%]",
|
|
79
|
-
"@md:is-auto @md:data-[active=panel]:mis-0 @md:grid-cols-[minmax(min-content,1fr)_3fr] @md:gap-1"
|
|
80
|
-
], classNames)
|
|
81
|
-
}, children);
|
|
82
|
-
} finally {
|
|
83
|
-
_effect.f();
|
|
84
|
-
}
|
|
63
|
+
const { activePart } = useTabsContext("TabsViewport");
|
|
64
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
65
|
+
role: "none",
|
|
66
|
+
...props,
|
|
67
|
+
"data-active": activePart,
|
|
68
|
+
className: mx(classNames)
|
|
69
|
+
}, children);
|
|
85
70
|
};
|
|
86
71
|
var TabsTablist = ({ children, classNames, ...props }) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
)
|
|
99
|
-
}, children);
|
|
100
|
-
} finally {
|
|
101
|
-
_effect.f();
|
|
102
|
-
}
|
|
72
|
+
const { orientation } = useTabsContext("TabsTablist");
|
|
73
|
+
return /* @__PURE__ */ React.createElement(TabsPrimitive.List, {
|
|
74
|
+
...props,
|
|
75
|
+
"data-arrow-keys": orientation === "vertical" ? "up down" : "left right",
|
|
76
|
+
className: mx(
|
|
77
|
+
"max-h-full w-full",
|
|
78
|
+
// TODO(burdon): Should be embeddable inside Toolbar (if horizontal).
|
|
79
|
+
orientation === "vertical" ? "overflow-y-auto" : "flex p-1 gap-1 items-stretch justify-start overflow-x-auto",
|
|
80
|
+
classNames
|
|
81
|
+
)
|
|
82
|
+
}, children);
|
|
103
83
|
};
|
|
104
84
|
var TabsBackButton = ({ onClick, classNames, ...props }) => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
classNames
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
onClick: handleClick
|
|
122
|
-
});
|
|
123
|
-
} finally {
|
|
124
|
-
_effect.f();
|
|
125
|
-
}
|
|
85
|
+
const { setActivePart } = useTabsContext("TabsBackButton");
|
|
86
|
+
const handleClick = useCallback((event) => {
|
|
87
|
+
setActivePart("list");
|
|
88
|
+
return onClick?.(event);
|
|
89
|
+
}, [
|
|
90
|
+
setActivePart,
|
|
91
|
+
onClick
|
|
92
|
+
]);
|
|
93
|
+
return /* @__PURE__ */ React.createElement(Button, {
|
|
94
|
+
...props,
|
|
95
|
+
classNames: [
|
|
96
|
+
"@md:hidden text-start",
|
|
97
|
+
classNames
|
|
98
|
+
],
|
|
99
|
+
onClick: handleClick
|
|
100
|
+
});
|
|
126
101
|
};
|
|
127
102
|
var TabsTabGroupHeading = ({ children, classNames, ...props }) => {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
className: mx("mlb-1 pli-2 text-sm text-unAccent", classNames)
|
|
133
|
-
}, children);
|
|
134
|
-
} finally {
|
|
135
|
-
_effect.f();
|
|
136
|
-
}
|
|
103
|
+
return /* @__PURE__ */ React.createElement("h2", {
|
|
104
|
+
...props,
|
|
105
|
+
className: mx("my-1 px-2 text-sm text-un-accent", classNames)
|
|
106
|
+
}, children);
|
|
137
107
|
};
|
|
138
108
|
var TabsTab = ({ value, classNames, children, onClick, ...props }) => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
(event)
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
orientation === "vertical" && ghostSelectedContainerMd,
|
|
166
|
-
ghostHover,
|
|
167
|
-
classNames
|
|
168
|
-
]
|
|
169
|
-
}, children));
|
|
170
|
-
} finally {
|
|
171
|
-
_effect.f();
|
|
172
|
-
}
|
|
109
|
+
const { setActivePart, orientation, value: contextValue, attendableId } = useTabsContext("TabsTab");
|
|
110
|
+
const { hasAttention } = useAttention(attendableId);
|
|
111
|
+
const handleClick = useCallback(
|
|
112
|
+
// NOTE: This handler is only called if the tab is *already active*.
|
|
113
|
+
(event) => {
|
|
114
|
+
setActivePart("panel");
|
|
115
|
+
onClick?.(event);
|
|
116
|
+
},
|
|
117
|
+
[
|
|
118
|
+
setActivePart,
|
|
119
|
+
onClick
|
|
120
|
+
]
|
|
121
|
+
);
|
|
122
|
+
return /* @__PURE__ */ React.createElement(TabsPrimitive.Trigger, {
|
|
123
|
+
value,
|
|
124
|
+
asChild: true
|
|
125
|
+
}, /* @__PURE__ */ React.createElement(Button, {
|
|
126
|
+
...props,
|
|
127
|
+
variant: orientation === "horizontal" && contextValue === value ? hasAttention ? "primary" : "default" : "ghost",
|
|
128
|
+
classNames: [
|
|
129
|
+
orientation === "vertical" && "block justify-start text-start w-full",
|
|
130
|
+
orientation === "vertical" && "dx-selected",
|
|
131
|
+
classNames
|
|
132
|
+
],
|
|
133
|
+
onClick: handleClick
|
|
134
|
+
}, children));
|
|
173
135
|
};
|
|
174
|
-
var
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
136
|
+
var TabsIconTab = ({ value, classNames, onClick, ...props }) => {
|
|
137
|
+
const { setActivePart, orientation, value: contextValue, attendableId } = useTabsContext("TabsTab");
|
|
138
|
+
const { hasAttention } = useAttention(attendableId);
|
|
139
|
+
const handleClick = useCallback((event) => {
|
|
140
|
+
setActivePart("panel");
|
|
141
|
+
onClick?.(event);
|
|
142
|
+
}, [
|
|
143
|
+
setActivePart,
|
|
144
|
+
onClick
|
|
145
|
+
]);
|
|
146
|
+
return /* @__PURE__ */ React.createElement(TabsPrimitive.Trigger, {
|
|
147
|
+
value,
|
|
148
|
+
asChild: true
|
|
149
|
+
}, /* @__PURE__ */ React.createElement(IconButton, {
|
|
150
|
+
...props,
|
|
151
|
+
variant: orientation === "horizontal" && contextValue === value ? hasAttention ? "primary" : "default" : "ghost",
|
|
152
|
+
classNames: [
|
|
153
|
+
orientation === "vertical" && "justify-start text-start w-full",
|
|
154
|
+
orientation === "vertical" && "dx-selected",
|
|
155
|
+
classNames
|
|
156
|
+
],
|
|
157
|
+
onClick: handleClick
|
|
158
|
+
}));
|
|
159
|
+
};
|
|
160
|
+
var TabsPanel = ({ classNames, children, ...props }) => {
|
|
161
|
+
const { value: contextValue } = useTabsContext("TabsTab");
|
|
162
|
+
return /* @__PURE__ */ React.createElement(Activity, {
|
|
163
|
+
mode: contextValue === props.value ? "visible" : "hidden"
|
|
164
|
+
}, /* @__PURE__ */ React.createElement(TabsPrimitive.Content, {
|
|
165
|
+
...props,
|
|
166
|
+
className: mx("dx-focus-ring-inset-over-all", classNames)
|
|
167
|
+
}, children));
|
|
184
168
|
};
|
|
185
169
|
var Tabs = {
|
|
186
170
|
Root: TabsRoot,
|
|
187
171
|
Tablist: TabsTablist,
|
|
188
172
|
Tab: TabsTab,
|
|
173
|
+
IconTab: TabsIconTab,
|
|
189
174
|
TabPrimitive: TabsPrimitive.Trigger,
|
|
190
175
|
TabGroupHeading: TabsTabGroupHeading,
|
|
191
|
-
|
|
176
|
+
Panel: TabsPanel,
|
|
192
177
|
BackButton: TabsBackButton,
|
|
193
178
|
Viewport: TabsViewport
|
|
194
179
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Tabs.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport {
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { useArrowNavigationGroup, useFocusFinders, useFocusableGroup } from '@fluentui/react-tabster';\nimport { createContext } from '@radix-ui/react-context';\nimport * as TabsPrimitive from '@radix-ui/react-tabs';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport React, {\n Activity,\n type ComponentPropsWithoutRef,\n type MouseEvent,\n forwardRef,\n useCallback,\n useLayoutEffect,\n} from 'react';\n\nimport {\n Button,\n type ButtonProps,\n IconButton,\n type IconButtonProps,\n type ThemedClassName,\n useForwardedRef,\n} from '@dxos/react-ui';\nimport { useAttention } from '@dxos/react-ui-attention';\nimport { mx } from '@dxos/ui-theme';\n\ntype TabsActivePart = 'list' | 'panel';\n\nconst TABS_NAME = 'Tabs';\n\ntype TabsContextValue = {\n activePart: TabsActivePart;\n setActivePart: (nextActivePart: TabsActivePart) => void;\n attendableId?: string;\n} & Pick<TabsPrimitive.TabsProps, 'orientation' | 'value'>;\n\nconst [TabsContextProvider, useTabsContext] = createContext<TabsContextValue>(TABS_NAME, {\n orientation: 'vertical',\n activePart: 'list',\n setActivePart: () => {},\n});\n\ntype TabsRootProps = ThemedClassName<TabsPrimitive.TabsProps> &\n Partial<\n Pick<TabsContextValue, 'activePart' | 'attendableId'> & {\n onActivePartChange: (nextActivePart: TabsActivePart) => void;\n defaultActivePart: TabsActivePart;\n }\n >;\n\nconst TabsRoot = forwardRef<HTMLDivElement, TabsRootProps>(\n (\n {\n children,\n classNames,\n activePart: propsActivePart,\n onActivePartChange,\n defaultActivePart,\n value: propsValue,\n onValueChange,\n defaultValue,\n orientation = 'vertical',\n activationMode = 'manual',\n attendableId,\n ...props\n },\n forwardedRef,\n ) => {\n // const tabsRoot = useRef<HTMLDivElement | null>(null);\n const tabsRoot = useForwardedRef(forwardedRef);\n\n // TODO(thure): Without these, we get Groupper/Mover `API used before initialization`, but why?\n const _1 = useArrowNavigationGroup();\n const _2 = useFocusableGroup();\n const [activePart = 'list', setActivePart] = useControllableState({\n prop: propsActivePart,\n onChange: onActivePartChange,\n defaultProp: defaultActivePart,\n });\n\n const [value, setValue] = useControllableState({\n prop: propsValue,\n onChange: onValueChange,\n defaultProp: defaultValue,\n });\n\n const handleValueChange = useCallback(\n (nextValue: string) => {\n setActivePart('panel');\n setValue(nextValue);\n },\n [value],\n );\n\n const { findFirstFocusable } = useFocusFinders();\n\n useLayoutEffect(() => {\n if (tabsRoot.current) {\n findFirstFocusable(tabsRoot.current)?.focus();\n }\n }, [activePart]);\n\n return (\n <TabsContextProvider\n orientation={orientation}\n activePart={activePart}\n setActivePart={setActivePart}\n value={value}\n attendableId={attendableId}\n >\n <TabsPrimitive.Root\n {...props}\n className={mx('overflow-hidden', classNames)}\n orientation={orientation}\n activationMode={activationMode}\n data-active={activePart}\n value={value}\n onValueChange={handleValueChange}\n ref={tabsRoot}\n >\n {children}\n </TabsPrimitive.Root>\n </TabsContextProvider>\n );\n },\n);\n\ntype TabsViewportProps = ThemedClassName<ComponentPropsWithoutRef<'div'>>;\n\nconst TabsViewport = ({ classNames, children, ...props }: TabsViewportProps) => {\n const { activePart } = useTabsContext('TabsViewport');\n return (\n <div role='none' {...props} data-active={activePart} className={mx(classNames)}>\n {children}\n </div>\n );\n};\n\ntype TabsTablistProps = ThemedClassName<TabsPrimitive.TabsListProps>;\n\nconst TabsTablist = ({ children, classNames, ...props }: TabsTablistProps) => {\n const { orientation } = useTabsContext('TabsTablist');\n return (\n <TabsPrimitive.List\n {...props}\n data-arrow-keys={orientation === 'vertical' ? 'up down' : 'left right'}\n className={mx(\n 'max-h-full w-full',\n // TODO(burdon): Should be embeddable inside Toolbar (if horizontal).\n orientation === 'vertical' ? 'overflow-y-auto' : 'flex p-1 gap-1 items-stretch justify-start overflow-x-auto',\n classNames,\n )}\n >\n {children}\n </TabsPrimitive.List>\n );\n};\n\nconst TabsBackButton = ({ onClick, classNames, ...props }: ButtonProps) => {\n const { setActivePart } = useTabsContext('TabsBackButton');\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n setActivePart('list');\n return onClick?.(event);\n },\n [setActivePart, onClick],\n );\n\n return <Button {...props} classNames={['@md:hidden text-start', classNames]} onClick={handleClick} />;\n};\n\ntype TabsTabGroupHeadingProps = ThemedClassName<ComponentPropsWithoutRef<'h2'>>;\n\nconst TabsTabGroupHeading = ({ children, classNames, ...props }: ThemedClassName<TabsTabGroupHeadingProps>) => {\n return (\n <h2 {...props} className={mx('my-1 px-2 text-sm text-un-accent', classNames)}>\n {children}\n </h2>\n );\n};\n\ntype TabsTabProps = ButtonProps & Pick<TabsPrimitive.TabsTriggerProps, 'value'>;\n\nconst TabsTab = ({ value, classNames, children, onClick, ...props }: TabsTabProps) => {\n const { setActivePart, orientation, value: contextValue, attendableId } = useTabsContext('TabsTab');\n const { hasAttention } = useAttention(attendableId);\n\n const handleClick = useCallback(\n // NOTE: This handler is only called if the tab is *already active*.\n (event: MouseEvent<HTMLButtonElement>) => {\n setActivePart('panel');\n onClick?.(event);\n },\n [setActivePart, onClick],\n );\n\n return (\n <TabsPrimitive.Trigger value={value} asChild>\n <Button\n {...props}\n variant={\n orientation === 'horizontal' && contextValue === value ? (hasAttention ? 'primary' : 'default') : 'ghost'\n }\n classNames={[\n orientation === 'vertical' && 'block justify-start text-start w-full',\n orientation === 'vertical' && 'dx-selected',\n classNames,\n ]}\n onClick={handleClick}\n >\n {children}\n </Button>\n </TabsPrimitive.Trigger>\n );\n};\n\ntype TabsIconTabProps = IconButtonProps & Pick<TabsPrimitive.TabsTriggerProps, 'value'>;\n\nconst TabsIconTab = ({ value, classNames, onClick, ...props }: TabsIconTabProps) => {\n const { setActivePart, orientation, value: contextValue, attendableId } = useTabsContext('TabsTab');\n const { hasAttention } = useAttention(attendableId);\n\n // NOTE: This handler is only called if the tab is *already active*.\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n setActivePart('panel');\n onClick?.(event);\n },\n [setActivePart, onClick],\n );\n\n return (\n <TabsPrimitive.Trigger value={value} asChild>\n <IconButton\n {...props}\n variant={\n orientation === 'horizontal' && contextValue === value ? (hasAttention ? 'primary' : 'default') : 'ghost'\n }\n classNames={[\n orientation === 'vertical' && 'justify-start text-start w-full',\n orientation === 'vertical' && 'dx-selected',\n classNames,\n ]}\n onClick={handleClick}\n />\n </TabsPrimitive.Trigger>\n );\n};\n\ntype TabsPanelProps = ThemedClassName<TabsPrimitive.TabsContentProps>;\n\n// TODO(burdon): Make slottable.\nconst TabsPanel = ({ classNames, children, ...props }: TabsPanelProps) => {\n const { value: contextValue } = useTabsContext('TabsTab');\n return (\n <Activity mode={contextValue === props.value ? 'visible' : 'hidden'}>\n <TabsPrimitive.Content {...props} className={mx('dx-focus-ring-inset-over-all', classNames)}>\n {children}\n </TabsPrimitive.Content>\n </Activity>\n );\n};\n\ntype TabsTabPrimitiveProps = TabsPrimitive.TabsTriggerProps;\n\nexport const Tabs = {\n Root: TabsRoot,\n Tablist: TabsTablist,\n Tab: TabsTab,\n IconTab: TabsIconTab,\n TabPrimitive: TabsPrimitive.Trigger,\n TabGroupHeading: TabsTabGroupHeading,\n Panel: TabsPanel,\n BackButton: TabsBackButton,\n Viewport: TabsViewport,\n};\n\nexport type {\n TabsActivePart,\n TabsRootProps,\n TabsTablistProps,\n TabsTabProps,\n TabsTabPrimitiveProps,\n TabsTabGroupHeadingProps,\n TabsPanelProps,\n TabsViewportProps,\n};\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,yBAAyBC,iBAAiBC,yBAAyB;AAC5E,SAASC,qBAAqB;AAC9B,YAAYC,mBAAmB;AAC/B,SAASC,4BAA4B;AACrC,OAAOC,SACLC,UAGAC,YACAC,aACAC,uBACK;AAEP,SACEC,QAEAC,YAGAC,uBACK;AACP,SAASC,oBAAoB;AAC7B,SAASC,UAAU;AAInB,IAAMC,YAAY;AAQlB,IAAM,CAACC,qBAAqBC,cAAAA,IAAkBC,cAAgCH,WAAW;EACvFI,aAAa;EACbC,YAAY;EACZC,eAAe,MAAA;EAAO;AACxB,CAAA;AAUA,IAAMC,WAAWC,2BACf,CACE,EACEC,UACAC,YACAL,YAAYM,iBACZC,oBACAC,mBACAC,OAAOC,YACPC,eACAC,cACAb,cAAc,YACdc,iBAAiB,UACjBC,cACA,GAAGC,MAAAA,GAELC,iBAAAA;AAGA,QAAMC,WAAWC,gBAAgBF,YAAAA;AAGjC,QAAMG,KAAKC,wBAAAA;AACX,QAAMC,KAAKC,kBAAAA;AACX,QAAM,CAACtB,aAAa,QAAQC,aAAAA,IAAiBsB,qBAAqB;IAChEC,MAAMlB;IACNmB,UAAUlB;IACVmB,aAAalB;EACf,CAAA;AAEA,QAAM,CAACC,OAAOkB,QAAAA,IAAYJ,qBAAqB;IAC7CC,MAAMd;IACNe,UAAUd;IACVe,aAAad;EACf,CAAA;AAEA,QAAMgB,oBAAoBC,YACxB,CAACC,cAAAA;AACC7B,kBAAc,OAAA;AACd0B,aAASG,SAAAA;EACX,GACA;IAACrB;GAAM;AAGT,QAAM,EAAEsB,mBAAkB,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ACE,GAAG/C;IACJ6C,SACE7D,gBAAgB,gBAAgBwD,iBAAiB9C,QAAS+C,eAAe,YAAY,YAAa;IAEpGnD,YAAY;MACVN,gBAAgB,cAAc;MAC9BA,gBAAgB,cAAc;MAC9BM;;IAEF2C,SAASC;;AAIjB;AAKA,IAAMc,YAAY,CAAC,EAAE1D,YAAYD,UAAU,GAAGW,MAAAA,MAAuB;AACnE,QAAM,EAAEN,OAAO8C,aAAY,IAAK1D,eAAe,SAAA;AAC/C,SACE,sBAAA,cAACmE,UAAAA;IAASC,MAAMV,iBAAiBxC,MAAMN,QAAQ,YAAY;KACzD,sBAAA,cAAeyD,uBAAO;IAAE,GAAGnD;IAAOsB,WAAWC,GAAG,gCAAgCjC,UAAAA;KAC7ED,QAAAA,CAAAA;AAIT;AAIO,IAAM+D,OAAO;EAClB/B,MAAMlC;EACNkE,SAASxB;EACTyB,KAAKf;EACLgB,SAAST;EACTU,cAA4Bb;EAC5Bc,iBAAiBpB;EACjBqB,OAAOV;EACPW,YAAY3B;EACZ4B,UAAUlC;AACZ;",
|
|
6
|
+
"names": ["useArrowNavigationGroup", "useFocusFinders", "useFocusableGroup", "createContext", "TabsPrimitive", "useControllableState", "React", "Activity", "forwardRef", "useCallback", "useLayoutEffect", "Button", "IconButton", "useForwardedRef", "useAttention", "mx", "TABS_NAME", "TabsContextProvider", "useTabsContext", "createContext", "orientation", "activePart", "setActivePart", "TabsRoot", "forwardRef", "children", "classNames", "propsActivePart", "onActivePartChange", "defaultActivePart", "value", "propsValue", "onValueChange", "defaultValue", "activationMode", "attendableId", "props", "forwardedRef", "tabsRoot", "useForwardedRef", "_1", "useArrowNavigationGroup", "_2", "useFocusableGroup", "useControllableState", "prop", "onChange", "defaultProp", "setValue", "handleValueChange", "useCallback", "nextValue", "findFirstFocusable", "useFocusFinders", "useLayoutEffect", "current", "focus", "Root", "className", "mx", "data-active", "ref", "TabsViewport", "div", "role", "TabsTablist", "List", "data-arrow-keys", "TabsBackButton", "onClick", "handleClick", "event", "Button", "TabsTabGroupHeading", "h2", "TabsTab", "contextValue", "hasAttention", "useAttention", "Trigger", "asChild", "variant", "TabsIconTab", "IconButton", "TabsPanel", "Activity", "mode", "Content", "Tabs", "Tablist", "Tab", "IconTab", "TabPrimitive", "TabGroupHeading", "Panel", "BackButton", "Viewport"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/Tabs.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"src/Tabs.tsx":{"bytes":25237,"imports":[{"path":"@fluentui/react-tabster","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-tabs","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-attention","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":444,"imports":[{"path":"src/Tabs.tsx","kind":"import-statement","original":"./Tabs"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":13752},"dist/lib/browser/index.mjs":{"imports":[{"path":"@fluentui/react-tabster","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-tabs","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-attention","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true}],"exports":["Tabs"],"entryPoint":"src/index.ts","inputs":{"src/Tabs.tsx":{"bytesInOutput":6165},"src/index.ts":{"bytesInOutput":0}},"bytes":6235}}}
|