@dxos/react-ui-tabs 0.8.4-main.ef1bc66f44 → 0.8.4-main.effb148878
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/dist/lib/browser/index.mjs +52 -52
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +52 -52
- 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 +39 -12
- package/dist/types/src/Tabs.d.ts.map +1 -1
- package/dist/types/src/Tabs.stories.d.ts +8 -5
- package/dist/types/src/Tabs.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -14
- package/src/Tabs.stories.tsx +48 -41
- package/src/Tabs.tsx +62 -69
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2024 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
|
@@ -6,15 +6,15 @@ import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
|
6
6
|
import React, { Activity, forwardRef, useCallback, useLayoutEffect } from "react";
|
|
7
7
|
import { Button, IconButton, useForwardedRef } from "@dxos/react-ui";
|
|
8
8
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
9
|
-
import {
|
|
9
|
+
import { mx } from "@dxos/ui-theme";
|
|
10
10
|
var TABS_NAME = "Tabs";
|
|
11
11
|
var [TabsContextProvider, useTabsContext] = createContext(TABS_NAME, {
|
|
12
|
+
orientation: "vertical",
|
|
12
13
|
activePart: "list",
|
|
13
14
|
setActivePart: () => {
|
|
14
|
-
}
|
|
15
|
-
orientation: "vertical"
|
|
15
|
+
}
|
|
16
16
|
});
|
|
17
|
-
var TabsRoot = /* @__PURE__ */ forwardRef(({ children, classNames, activePart: propsActivePart, onActivePartChange, defaultActivePart, value: propsValue, onValueChange, defaultValue, orientation = "vertical", activationMode = "manual",
|
|
17
|
+
var TabsRoot = /* @__PURE__ */ forwardRef(({ children, classNames, activePart: propsActivePart, onActivePartChange, defaultActivePart, value: propsValue, onValueChange, defaultValue, orientation = "vertical", activationMode = "manual", attendableId, ...props }, forwardedRef) => {
|
|
18
18
|
const tabsRoot = useForwardedRef(forwardedRef);
|
|
19
19
|
const _1 = useArrowNavigationGroup();
|
|
20
20
|
const _2 = useFocusableGroup();
|
|
@@ -47,70 +47,69 @@ var TabsRoot = /* @__PURE__ */ forwardRef(({ children, classNames, activePart: p
|
|
|
47
47
|
activePart,
|
|
48
48
|
setActivePart,
|
|
49
49
|
value,
|
|
50
|
-
attendableId
|
|
51
|
-
verticalVariant
|
|
50
|
+
attendableId
|
|
52
51
|
}, /* @__PURE__ */ React.createElement(TabsPrimitive.Root, {
|
|
52
|
+
...props,
|
|
53
|
+
className: mx("overflow-hidden", classNames),
|
|
54
|
+
orientation,
|
|
53
55
|
activationMode,
|
|
54
56
|
"data-active": activePart,
|
|
55
|
-
orientation,
|
|
56
|
-
...props,
|
|
57
57
|
value,
|
|
58
58
|
onValueChange: handleValueChange,
|
|
59
|
-
className: mx("overflow-hidden", orientation === "vertical" && verticalVariant === "stateful" && "[&[data-active=list]_[role=tabpanel]]:invisible @md:[&[data-active=list]_[role=tabpanel]]:visible", classNames),
|
|
60
59
|
ref: tabsRoot
|
|
61
60
|
}, children));
|
|
62
61
|
});
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
TabsRoot.displayName = "Tabs.Root";
|
|
63
|
+
function TabsViewport({ classNames, children, ...props }) {
|
|
64
|
+
const { activePart } = useTabsContext("TabsViewport");
|
|
65
65
|
return /* @__PURE__ */ React.createElement("div", {
|
|
66
|
-
role: "none",
|
|
67
66
|
...props,
|
|
68
67
|
"data-active": activePart,
|
|
69
|
-
className: mx(
|
|
70
|
-
"grid is-[200%] grid-cols-2 data-[active=panel]:mis-[-100%]",
|
|
71
|
-
"@md:is-auto @md:data-[active=panel]:mis-0 @md:grid-cols-[minmax(min-content,1fr)_3fr] @md:gap-1"
|
|
72
|
-
], classNames)
|
|
68
|
+
className: mx(classNames)
|
|
73
69
|
}, children);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
}
|
|
71
|
+
TabsViewport.displayName = "Tabs.Viewport";
|
|
72
|
+
function TabsTablist({ children, classNames, ...props }) {
|
|
73
|
+
const { orientation } = useTabsContext("TabsTablist");
|
|
77
74
|
return /* @__PURE__ */ React.createElement(TabsPrimitive.List, {
|
|
78
75
|
...props,
|
|
79
76
|
"data-arrow-keys": orientation === "vertical" ? "up down" : "left right",
|
|
80
77
|
className: mx(
|
|
81
|
-
"max-
|
|
82
|
-
//
|
|
83
|
-
orientation === "vertical" ? "overflow-y-auto" : "flex items-stretch justify-start overflow-x-auto
|
|
84
|
-
orientation === "vertical" && verticalVariant === "stateful" && "place-self-start p-1",
|
|
78
|
+
"max-h-full w-full",
|
|
79
|
+
// TODO(burdon): Should be embeddable inside Toolbar (if horizontal).
|
|
80
|
+
orientation === "vertical" ? "overflow-y-auto" : "flex p-1 gap-1 items-stretch justify-start overflow-x-auto",
|
|
85
81
|
classNames
|
|
86
82
|
)
|
|
87
83
|
}, children);
|
|
88
|
-
}
|
|
89
|
-
|
|
84
|
+
}
|
|
85
|
+
TabsTablist.displayName = "Tabs.Tablist";
|
|
86
|
+
function TabsBackButton({ onClick, classNames, ...props }) {
|
|
90
87
|
const { setActivePart } = useTabsContext("TabsBackButton");
|
|
91
88
|
const handleClick = useCallback((event) => {
|
|
92
89
|
setActivePart("list");
|
|
93
90
|
return onClick?.(event);
|
|
94
91
|
}, [
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
setActivePart,
|
|
93
|
+
onClick
|
|
97
94
|
]);
|
|
98
95
|
return /* @__PURE__ */ React.createElement(Button, {
|
|
99
96
|
...props,
|
|
100
97
|
classNames: [
|
|
101
|
-
"
|
|
98
|
+
"@md:hidden text-start",
|
|
102
99
|
classNames
|
|
103
100
|
],
|
|
104
101
|
onClick: handleClick
|
|
105
102
|
});
|
|
106
|
-
}
|
|
107
|
-
|
|
103
|
+
}
|
|
104
|
+
TabsBackButton.displayName = "Tabs.BackButton";
|
|
105
|
+
function TabsTabGroupHeading({ children, classNames, ...props }) {
|
|
108
106
|
return /* @__PURE__ */ React.createElement("h2", {
|
|
109
107
|
...props,
|
|
110
|
-
className: mx("
|
|
108
|
+
className: mx("my-1 px-2 text-sm text-un-accent", classNames)
|
|
111
109
|
}, children);
|
|
112
|
-
}
|
|
113
|
-
|
|
110
|
+
}
|
|
111
|
+
TabsTabGroupHeading.displayName = "Tabs.TabGroupHeading";
|
|
112
|
+
function TabsTab({ value, classNames, children, onClick, ...props }) {
|
|
114
113
|
const { setActivePart, orientation, value: contextValue, attendableId } = useTabsContext("TabsTab");
|
|
115
114
|
const { hasAttention } = useAttention(attendableId);
|
|
116
115
|
const handleClick = useCallback(
|
|
@@ -128,18 +127,18 @@ var TabsTab = ({ value, classNames, children, onClick, ...props }) => {
|
|
|
128
127
|
value,
|
|
129
128
|
asChild: true
|
|
130
129
|
}, /* @__PURE__ */ React.createElement(Button, {
|
|
131
|
-
density: "fine",
|
|
132
|
-
variant: orientation === "horizontal" && contextValue === value ? hasAttention ? "primary" : "default" : "ghost",
|
|
133
130
|
...props,
|
|
134
|
-
|
|
131
|
+
variant: orientation === "horizontal" && contextValue === value ? hasAttention ? "primary" : "default" : "ghost",
|
|
135
132
|
classNames: [
|
|
136
|
-
orientation === "vertical" && "block justify-start text-start
|
|
137
|
-
orientation === "vertical" &&
|
|
133
|
+
orientation === "vertical" && "block justify-start text-start w-full",
|
|
134
|
+
orientation === "vertical" && "dx-selected",
|
|
138
135
|
classNames
|
|
139
|
-
]
|
|
136
|
+
],
|
|
137
|
+
onClick: handleClick
|
|
140
138
|
}, children));
|
|
141
|
-
}
|
|
142
|
-
|
|
139
|
+
}
|
|
140
|
+
TabsTab.displayName = "Tabs.Tab";
|
|
141
|
+
function TabsIconTab({ value, classNames, onClick, ...props }) {
|
|
143
142
|
const { setActivePart, orientation, value: contextValue, attendableId } = useTabsContext("TabsTab");
|
|
144
143
|
const { hasAttention } = useAttention(attendableId);
|
|
145
144
|
const handleClick = useCallback((event) => {
|
|
@@ -153,26 +152,27 @@ var TabsIconTab = ({ value, classNames, onClick, ...props }) => {
|
|
|
153
152
|
value,
|
|
154
153
|
asChild: true
|
|
155
154
|
}, /* @__PURE__ */ React.createElement(IconButton, {
|
|
156
|
-
density: "fine",
|
|
157
|
-
variant: orientation === "horizontal" && contextValue === value ? hasAttention ? "primary" : "default" : "ghost",
|
|
158
155
|
...props,
|
|
159
|
-
|
|
156
|
+
variant: orientation === "horizontal" && contextValue === value ? hasAttention ? "primary" : "default" : "ghost",
|
|
160
157
|
classNames: [
|
|
161
|
-
orientation === "vertical" && "justify-start text-start
|
|
162
|
-
orientation === "vertical" &&
|
|
158
|
+
orientation === "vertical" && "justify-start text-start w-full",
|
|
159
|
+
orientation === "vertical" && "dx-selected",
|
|
163
160
|
classNames
|
|
164
|
-
]
|
|
161
|
+
],
|
|
162
|
+
onClick: handleClick
|
|
165
163
|
}));
|
|
166
|
-
}
|
|
167
|
-
|
|
164
|
+
}
|
|
165
|
+
TabsIconTab.displayName = "Tabs.IconTab";
|
|
166
|
+
function TabsPanel({ classNames, children, ...props }) {
|
|
168
167
|
const { value: contextValue } = useTabsContext("TabsTab");
|
|
169
168
|
return /* @__PURE__ */ React.createElement(Activity, {
|
|
170
169
|
mode: contextValue === props.value ? "visible" : "hidden"
|
|
171
170
|
}, /* @__PURE__ */ React.createElement(TabsPrimitive.Content, {
|
|
172
171
|
...props,
|
|
173
|
-
className: mx("dx-focus-ring-inset-over-all", classNames)
|
|
172
|
+
className: mx("p-0! dx-focus-ring-inset-over-all", classNames)
|
|
174
173
|
}, children));
|
|
175
|
-
}
|
|
174
|
+
}
|
|
175
|
+
TabsPanel.displayName = "Tabs.Panel";
|
|
176
176
|
var Tabs = {
|
|
177
177
|
Root: TabsRoot,
|
|
178
178
|
Tablist: TabsTablist,
|
|
@@ -180,7 +180,7 @@ var Tabs = {
|
|
|
180
180
|
IconTab: TabsIconTab,
|
|
181
181
|
TabPrimitive: TabsPrimitive.Trigger,
|
|
182
182
|
TabGroupHeading: TabsTabGroupHeading,
|
|
183
|
-
|
|
183
|
+
Panel: TabsPanel,
|
|
184
184
|
BackButton: TabsBackButton,
|
|
185
185
|
Viewport: TabsViewport
|
|
186
186
|
};
|
|
@@ -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 { 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 {
|
|
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,
|
|
6
|
-
"names": ["useArrowNavigationGroup", "useFocusFinders", "useFocusableGroup", "createContext", "TabsPrimitive", "useControllableState", "React", "Activity", "forwardRef", "useCallback", "useLayoutEffect", "Button", "IconButton", "useForwardedRef", "useAttention", "
|
|
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\nTabsRoot.displayName = 'Tabs.Root';\n\ntype TabsViewportProps = ThemedClassName<ComponentPropsWithoutRef<'div'>>;\n\nfunction TabsViewport({ classNames, children, ...props }: TabsViewportProps) {\n const { activePart } = useTabsContext('TabsViewport');\n return (\n <div {...props} data-active={activePart} className={mx(classNames)}>\n {children}\n </div>\n );\n}\n\nTabsViewport.displayName = 'Tabs.Viewport';\n\ntype TabsTablistProps = ThemedClassName<TabsPrimitive.TabsListProps>;\n\nfunction 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\nTabsTablist.displayName = 'Tabs.Tablist';\n\nfunction 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\nTabsBackButton.displayName = 'Tabs.BackButton';\n\ntype TabsTabGroupHeadingProps = ThemedClassName<ComponentPropsWithoutRef<'h2'>>;\n\nfunction 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\nTabsTabGroupHeading.displayName = 'Tabs.TabGroupHeading';\n\ntype TabsTabProps = ButtonProps & Pick<TabsPrimitive.TabsTriggerProps, 'value'>;\n\nfunction 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\nTabsTab.displayName = 'Tabs.Tab';\n\ntype TabsIconTabProps = IconButtonProps & Pick<TabsPrimitive.TabsTriggerProps, 'value'>;\n\nfunction 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\nTabsIconTab.displayName = 'Tabs.IconTab';\n\ntype TabsPanelProps = ThemedClassName<TabsPrimitive.TabsContentProps>;\n\nfunction 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('p-0! dx-focus-ring-inset-over-all', classNames)}>\n {children}\n </TabsPrimitive.Content>\n </Activity>\n );\n}\n\nTabsPanel.displayName = 'Tabs.Panel';\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": "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",
|
|
6
|
+
"names": ["useArrowNavigationGroup", "useFocusFinders", "useFocusableGroup", "createContext", "TabsPrimitive", "useControllableState", "React", "Activity", "forwardRef", "useCallback", "useLayoutEffect", "Button", "IconButton", "useForwardedRef", "useAttention", "mx", "TABS_NAME", "TabsContextProvider", "useTabsContext", "orientation", "activePart", "setActivePart", "TabsRoot", "children", "classNames", "propsActivePart", "onActivePartChange", "defaultActivePart", "value", "propsValue", "onValueChange", "defaultValue", "activationMode", "attendableId", "props", "forwardedRef", "tabsRoot", "_1", "_2", "prop", "onChange", "defaultProp", "setValue", "handleValueChange", "nextValue", "findFirstFocusable", "current", "focus", "Root", "className", "data-active", "ref", "displayName", "TabsViewport", "div", "TabsTablist", "List", "data-arrow-keys", "TabsBackButton", "onClick", "handleClick", "event", "TabsTabGroupHeading", "h2", "TabsTab", "contextValue", "hasAttention", "Trigger", "asChild", "variant", "TabsIconTab", "TabsPanel", "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":26019,"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":368,"imports":[{"path":"src/Tabs.tsx","kind":"import-statement","original":"./Tabs"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":13922},"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":6480},"src/index.ts":{"bytesInOutput":0}},"bytes":6550}}}
|
|
@@ -8,15 +8,15 @@ import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
|
8
8
|
import React, { Activity, forwardRef, useCallback, useLayoutEffect } from "react";
|
|
9
9
|
import { Button, IconButton, useForwardedRef } from "@dxos/react-ui";
|
|
10
10
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
11
|
-
import {
|
|
11
|
+
import { mx } from "@dxos/ui-theme";
|
|
12
12
|
var TABS_NAME = "Tabs";
|
|
13
13
|
var [TabsContextProvider, useTabsContext] = createContext(TABS_NAME, {
|
|
14
|
+
orientation: "vertical",
|
|
14
15
|
activePart: "list",
|
|
15
16
|
setActivePart: () => {
|
|
16
|
-
}
|
|
17
|
-
orientation: "vertical"
|
|
17
|
+
}
|
|
18
18
|
});
|
|
19
|
-
var TabsRoot = /* @__PURE__ */ forwardRef(({ children, classNames, activePart: propsActivePart, onActivePartChange, defaultActivePart, value: propsValue, onValueChange, defaultValue, orientation = "vertical", activationMode = "manual",
|
|
19
|
+
var TabsRoot = /* @__PURE__ */ forwardRef(({ children, classNames, activePart: propsActivePart, onActivePartChange, defaultActivePart, value: propsValue, onValueChange, defaultValue, orientation = "vertical", activationMode = "manual", attendableId, ...props }, forwardedRef) => {
|
|
20
20
|
const tabsRoot = useForwardedRef(forwardedRef);
|
|
21
21
|
const _1 = useArrowNavigationGroup();
|
|
22
22
|
const _2 = useFocusableGroup();
|
|
@@ -49,70 +49,69 @@ var TabsRoot = /* @__PURE__ */ forwardRef(({ children, classNames, activePart: p
|
|
|
49
49
|
activePart,
|
|
50
50
|
setActivePart,
|
|
51
51
|
value,
|
|
52
|
-
attendableId
|
|
53
|
-
verticalVariant
|
|
52
|
+
attendableId
|
|
54
53
|
}, /* @__PURE__ */ React.createElement(TabsPrimitive.Root, {
|
|
54
|
+
...props,
|
|
55
|
+
className: mx("overflow-hidden", classNames),
|
|
56
|
+
orientation,
|
|
55
57
|
activationMode,
|
|
56
58
|
"data-active": activePart,
|
|
57
|
-
orientation,
|
|
58
|
-
...props,
|
|
59
59
|
value,
|
|
60
60
|
onValueChange: handleValueChange,
|
|
61
|
-
className: mx("overflow-hidden", orientation === "vertical" && verticalVariant === "stateful" && "[&[data-active=list]_[role=tabpanel]]:invisible @md:[&[data-active=list]_[role=tabpanel]]:visible", classNames),
|
|
62
61
|
ref: tabsRoot
|
|
63
62
|
}, children));
|
|
64
63
|
});
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
TabsRoot.displayName = "Tabs.Root";
|
|
65
|
+
function TabsViewport({ classNames, children, ...props }) {
|
|
66
|
+
const { activePart } = useTabsContext("TabsViewport");
|
|
67
67
|
return /* @__PURE__ */ React.createElement("div", {
|
|
68
|
-
role: "none",
|
|
69
68
|
...props,
|
|
70
69
|
"data-active": activePart,
|
|
71
|
-
className: mx(
|
|
72
|
-
"grid is-[200%] grid-cols-2 data-[active=panel]:mis-[-100%]",
|
|
73
|
-
"@md:is-auto @md:data-[active=panel]:mis-0 @md:grid-cols-[minmax(min-content,1fr)_3fr] @md:gap-1"
|
|
74
|
-
], classNames)
|
|
70
|
+
className: mx(classNames)
|
|
75
71
|
}, children);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
}
|
|
73
|
+
TabsViewport.displayName = "Tabs.Viewport";
|
|
74
|
+
function TabsTablist({ children, classNames, ...props }) {
|
|
75
|
+
const { orientation } = useTabsContext("TabsTablist");
|
|
79
76
|
return /* @__PURE__ */ React.createElement(TabsPrimitive.List, {
|
|
80
77
|
...props,
|
|
81
78
|
"data-arrow-keys": orientation === "vertical" ? "up down" : "left right",
|
|
82
79
|
className: mx(
|
|
83
|
-
"max-
|
|
84
|
-
//
|
|
85
|
-
orientation === "vertical" ? "overflow-y-auto" : "flex items-stretch justify-start overflow-x-auto
|
|
86
|
-
orientation === "vertical" && verticalVariant === "stateful" && "place-self-start p-1",
|
|
80
|
+
"max-h-full w-full",
|
|
81
|
+
// TODO(burdon): Should be embeddable inside Toolbar (if horizontal).
|
|
82
|
+
orientation === "vertical" ? "overflow-y-auto" : "flex p-1 gap-1 items-stretch justify-start overflow-x-auto",
|
|
87
83
|
classNames
|
|
88
84
|
)
|
|
89
85
|
}, children);
|
|
90
|
-
}
|
|
91
|
-
|
|
86
|
+
}
|
|
87
|
+
TabsTablist.displayName = "Tabs.Tablist";
|
|
88
|
+
function TabsBackButton({ onClick, classNames, ...props }) {
|
|
92
89
|
const { setActivePart } = useTabsContext("TabsBackButton");
|
|
93
90
|
const handleClick = useCallback((event) => {
|
|
94
91
|
setActivePart("list");
|
|
95
92
|
return onClick?.(event);
|
|
96
93
|
}, [
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
setActivePart,
|
|
95
|
+
onClick
|
|
99
96
|
]);
|
|
100
97
|
return /* @__PURE__ */ React.createElement(Button, {
|
|
101
98
|
...props,
|
|
102
99
|
classNames: [
|
|
103
|
-
"
|
|
100
|
+
"@md:hidden text-start",
|
|
104
101
|
classNames
|
|
105
102
|
],
|
|
106
103
|
onClick: handleClick
|
|
107
104
|
});
|
|
108
|
-
}
|
|
109
|
-
|
|
105
|
+
}
|
|
106
|
+
TabsBackButton.displayName = "Tabs.BackButton";
|
|
107
|
+
function TabsTabGroupHeading({ children, classNames, ...props }) {
|
|
110
108
|
return /* @__PURE__ */ React.createElement("h2", {
|
|
111
109
|
...props,
|
|
112
|
-
className: mx("
|
|
110
|
+
className: mx("my-1 px-2 text-sm text-un-accent", classNames)
|
|
113
111
|
}, children);
|
|
114
|
-
}
|
|
115
|
-
|
|
112
|
+
}
|
|
113
|
+
TabsTabGroupHeading.displayName = "Tabs.TabGroupHeading";
|
|
114
|
+
function TabsTab({ value, classNames, children, onClick, ...props }) {
|
|
116
115
|
const { setActivePart, orientation, value: contextValue, attendableId } = useTabsContext("TabsTab");
|
|
117
116
|
const { hasAttention } = useAttention(attendableId);
|
|
118
117
|
const handleClick = useCallback(
|
|
@@ -130,18 +129,18 @@ var TabsTab = ({ value, classNames, children, onClick, ...props }) => {
|
|
|
130
129
|
value,
|
|
131
130
|
asChild: true
|
|
132
131
|
}, /* @__PURE__ */ React.createElement(Button, {
|
|
133
|
-
density: "fine",
|
|
134
|
-
variant: orientation === "horizontal" && contextValue === value ? hasAttention ? "primary" : "default" : "ghost",
|
|
135
132
|
...props,
|
|
136
|
-
|
|
133
|
+
variant: orientation === "horizontal" && contextValue === value ? hasAttention ? "primary" : "default" : "ghost",
|
|
137
134
|
classNames: [
|
|
138
|
-
orientation === "vertical" && "block justify-start text-start
|
|
139
|
-
orientation === "vertical" &&
|
|
135
|
+
orientation === "vertical" && "block justify-start text-start w-full",
|
|
136
|
+
orientation === "vertical" && "dx-selected",
|
|
140
137
|
classNames
|
|
141
|
-
]
|
|
138
|
+
],
|
|
139
|
+
onClick: handleClick
|
|
142
140
|
}, children));
|
|
143
|
-
}
|
|
144
|
-
|
|
141
|
+
}
|
|
142
|
+
TabsTab.displayName = "Tabs.Tab";
|
|
143
|
+
function TabsIconTab({ value, classNames, onClick, ...props }) {
|
|
145
144
|
const { setActivePart, orientation, value: contextValue, attendableId } = useTabsContext("TabsTab");
|
|
146
145
|
const { hasAttention } = useAttention(attendableId);
|
|
147
146
|
const handleClick = useCallback((event) => {
|
|
@@ -155,26 +154,27 @@ var TabsIconTab = ({ value, classNames, onClick, ...props }) => {
|
|
|
155
154
|
value,
|
|
156
155
|
asChild: true
|
|
157
156
|
}, /* @__PURE__ */ React.createElement(IconButton, {
|
|
158
|
-
density: "fine",
|
|
159
|
-
variant: orientation === "horizontal" && contextValue === value ? hasAttention ? "primary" : "default" : "ghost",
|
|
160
157
|
...props,
|
|
161
|
-
|
|
158
|
+
variant: orientation === "horizontal" && contextValue === value ? hasAttention ? "primary" : "default" : "ghost",
|
|
162
159
|
classNames: [
|
|
163
|
-
orientation === "vertical" && "justify-start text-start
|
|
164
|
-
orientation === "vertical" &&
|
|
160
|
+
orientation === "vertical" && "justify-start text-start w-full",
|
|
161
|
+
orientation === "vertical" && "dx-selected",
|
|
165
162
|
classNames
|
|
166
|
-
]
|
|
163
|
+
],
|
|
164
|
+
onClick: handleClick
|
|
167
165
|
}));
|
|
168
|
-
}
|
|
169
|
-
|
|
166
|
+
}
|
|
167
|
+
TabsIconTab.displayName = "Tabs.IconTab";
|
|
168
|
+
function TabsPanel({ classNames, children, ...props }) {
|
|
170
169
|
const { value: contextValue } = useTabsContext("TabsTab");
|
|
171
170
|
return /* @__PURE__ */ React.createElement(Activity, {
|
|
172
171
|
mode: contextValue === props.value ? "visible" : "hidden"
|
|
173
172
|
}, /* @__PURE__ */ React.createElement(TabsPrimitive.Content, {
|
|
174
173
|
...props,
|
|
175
|
-
className: mx("dx-focus-ring-inset-over-all", classNames)
|
|
174
|
+
className: mx("p-0! dx-focus-ring-inset-over-all", classNames)
|
|
176
175
|
}, children));
|
|
177
|
-
}
|
|
176
|
+
}
|
|
177
|
+
TabsPanel.displayName = "Tabs.Panel";
|
|
178
178
|
var Tabs = {
|
|
179
179
|
Root: TabsRoot,
|
|
180
180
|
Tablist: TabsTablist,
|
|
@@ -182,7 +182,7 @@ var Tabs = {
|
|
|
182
182
|
IconTab: TabsIconTab,
|
|
183
183
|
TabPrimitive: TabsPrimitive.Trigger,
|
|
184
184
|
TabGroupHeading: TabsTabGroupHeading,
|
|
185
|
-
|
|
185
|
+
Panel: TabsPanel,
|
|
186
186
|
BackButton: TabsBackButton,
|
|
187
187
|
Viewport: TabsViewport
|
|
188
188
|
};
|