@stratakit/structures 0.4.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/dist/AccordionItem.d.ts +1 -1
- package/dist/AccordionItem.js +67 -124
- package/dist/Banner.js +146 -117
- package/dist/Chip.js +83 -58
- package/dist/DEV/Banner.js +7 -4
- package/dist/DEV/ErrorRegion.js +5 -4
- package/dist/DEV/NavigationRail.js +52 -20
- package/dist/DEV/Tabs.js +1 -1
- package/dist/DEV/styles.css.js +1 -1
- package/dist/Dialog.js +140 -132
- package/dist/DropdownMenu.js +206 -239
- package/dist/ErrorRegion.d.ts +31 -13
- package/dist/ErrorRegion.js +127 -153
- package/dist/NavigationRail.d.ts +36 -3
- package/dist/NavigationRail.js +215 -169
- package/dist/Table.js +116 -108
- package/dist/Tabs.d.ts +2 -0
- package/dist/Tabs.js +97 -62
- package/dist/Toolbar.js +23 -43
- package/dist/Tree.js +13 -12
- package/dist/TreeItem.js +394 -315
- package/dist/styles.css.js +1 -1
- package/dist/~utils.ListItem.js +21 -34
- package/dist/~utils.icons.js +26 -46
- package/package.json +13 -18
package/dist/NavigationRail.js
CHANGED
|
@@ -1,193 +1,239 @@
|
|
|
1
|
+
import { c as _c } from "react-compiler-runtime";
|
|
1
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
3
|
import * as React from "react";
|
|
4
|
+
import { Button } from "@ariakit/react/button";
|
|
3
5
|
import { Role } from "@ariakit/react/role";
|
|
4
6
|
import { Tooltip, VisuallyHidden } from "@stratakit/bricks";
|
|
5
7
|
import { Icon } from "@stratakit/foundations";
|
|
6
|
-
import {
|
|
7
|
-
forwardRef,
|
|
8
|
-
useEventHandlers,
|
|
9
|
-
useSafeContext
|
|
10
|
-
} from "@stratakit/foundations/secret-internals";
|
|
8
|
+
import { forwardRef, useEventHandlers, useSafeContext, useUnreactiveCallback } from "@stratakit/foundations/secret-internals";
|
|
11
9
|
import cx from "classnames";
|
|
12
10
|
import { createStore, useStore } from "zustand";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
import { combine } from "zustand/middleware";
|
|
12
|
+
function createNavigationRailStore(initialState) {
|
|
13
|
+
return createStore(combine(initialState, (set) => ({
|
|
14
|
+
setExpanded: (expanded) => set({
|
|
15
|
+
expanded
|
|
16
|
+
})
|
|
17
|
+
})));
|
|
18
18
|
}
|
|
19
19
|
const NavigationRailContext = React.createContext(void 0);
|
|
20
20
|
function NavigationRailProvider(props) {
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const $ = _c(11);
|
|
22
|
+
const {
|
|
23
|
+
defaultExpanded,
|
|
24
|
+
expanded,
|
|
25
|
+
setExpanded: setExpandedProp
|
|
26
|
+
} = props;
|
|
27
|
+
let t0;
|
|
28
|
+
if ($[0] !== defaultExpanded || $[1] !== expanded) {
|
|
29
|
+
t0 = () => createNavigationRailStore({
|
|
30
|
+
expanded: expanded ?? defaultExpanded
|
|
31
|
+
});
|
|
32
|
+
$[0] = defaultExpanded;
|
|
33
|
+
$[1] = expanded;
|
|
34
|
+
$[2] = t0;
|
|
35
|
+
} else {
|
|
36
|
+
t0 = $[2];
|
|
37
|
+
}
|
|
38
|
+
const [store] = React.useState(t0);
|
|
39
|
+
const setExpanded = useUnreactiveCallback(setExpandedProp ?? _temp);
|
|
40
|
+
let t1;
|
|
41
|
+
let t2;
|
|
42
|
+
if ($[3] !== expanded || $[4] !== setExpanded || $[5] !== store) {
|
|
43
|
+
t1 = function synchronizeWithProps() {
|
|
44
|
+
if (expanded === void 0) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
store.setState({
|
|
48
|
+
expanded,
|
|
49
|
+
setExpanded
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
t2 = [store, expanded, setExpanded];
|
|
53
|
+
$[3] = expanded;
|
|
54
|
+
$[4] = setExpanded;
|
|
55
|
+
$[5] = store;
|
|
56
|
+
$[6] = t1;
|
|
57
|
+
$[7] = t2;
|
|
58
|
+
} else {
|
|
59
|
+
t1 = $[6];
|
|
60
|
+
t2 = $[7];
|
|
61
|
+
}
|
|
62
|
+
React.useEffect(t1, t2);
|
|
63
|
+
let t3;
|
|
64
|
+
if ($[8] !== props.children || $[9] !== store) {
|
|
65
|
+
t3 = jsx(NavigationRailContext.Provider, {
|
|
66
|
+
value: store,
|
|
67
|
+
children: props.children
|
|
68
|
+
});
|
|
69
|
+
$[8] = props.children;
|
|
70
|
+
$[9] = store;
|
|
71
|
+
$[10] = t3;
|
|
72
|
+
} else {
|
|
73
|
+
t3 = $[10];
|
|
74
|
+
}
|
|
75
|
+
return t3;
|
|
76
|
+
}
|
|
77
|
+
function _temp() {
|
|
23
78
|
}
|
|
24
79
|
function useNavigationRailState(selectorFn) {
|
|
25
80
|
const store = useSafeContext(NavigationRailContext);
|
|
26
81
|
return useStore(store, selectorFn);
|
|
27
82
|
}
|
|
28
|
-
const NavigationRailRoot = forwardRef(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
className: cx("\u{1F95D}NavigationRail", props.className),
|
|
41
|
-
"data-_sk-expanded": collapsed ? "false" : "true",
|
|
42
|
-
ref: forwardedRef
|
|
43
|
-
}
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
const NavigationRailHeader = forwardRef(
|
|
48
|
-
(props, forwardedRef) => {
|
|
49
|
-
const collapsed = useNavigationRailState((state) => state.collapsed);
|
|
50
|
-
return /* @__PURE__ */ jsx(
|
|
51
|
-
Role.header,
|
|
52
|
-
{
|
|
53
|
-
...props,
|
|
54
|
-
className: cx("\u{1F95D}NavigationRailHeader", props.className),
|
|
55
|
-
"data-_sk-collapsed": collapsed ? "true" : void 0,
|
|
56
|
-
ref: forwardedRef
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
const NavigationRailToggleButton = forwardRef((props, forwardedRef) => {
|
|
62
|
-
const { label = "Expand navigation", ...rest } = props;
|
|
63
|
-
const collapsed = useNavigationRailState((state) => state.collapsed);
|
|
64
|
-
const setCollapsed = useNavigationRailState((state) => state.setCollapsed);
|
|
65
|
-
return /* @__PURE__ */ jsxs(
|
|
66
|
-
Role.button,
|
|
67
|
-
{
|
|
68
|
-
"aria-expanded": collapsed ? "false" : "true",
|
|
83
|
+
const NavigationRailRoot = forwardRef((props, forwardedRef) => {
|
|
84
|
+
const {
|
|
85
|
+
defaultExpanded = false,
|
|
86
|
+
expanded,
|
|
87
|
+
setExpanded,
|
|
88
|
+
...rest
|
|
89
|
+
} = props;
|
|
90
|
+
return /* @__PURE__ */ jsx(NavigationRailProvider, {
|
|
91
|
+
defaultExpanded,
|
|
92
|
+
expanded,
|
|
93
|
+
setExpanded,
|
|
94
|
+
children: /* @__PURE__ */ jsx(NavigationRailRootInner, {
|
|
69
95
|
...rest,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
);
|
|
96
|
+
ref: forwardedRef
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
const NavigationRailRootInner = forwardRef((props, forwardedRef) => {
|
|
101
|
+
const expanded = useNavigationRailState((state) => state.expanded);
|
|
102
|
+
return /* @__PURE__ */ jsx(Role.nav, {
|
|
103
|
+
...props,
|
|
104
|
+
className: cx("\u{1F95D}NavigationRail", props.className),
|
|
105
|
+
"data-_sk-expanded": expanded ? "true" : void 0,
|
|
106
|
+
ref: forwardedRef
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
const NavigationRailHeader = forwardRef((props, forwardedRef) => {
|
|
110
|
+
const expanded = useNavigationRailState((state) => state.expanded);
|
|
111
|
+
return /* @__PURE__ */ jsx(Role.header, {
|
|
112
|
+
...props,
|
|
113
|
+
className: cx("\u{1F95D}NavigationRailHeader", props.className),
|
|
114
|
+
"data-_sk-expanded": expanded ? "true" : void 0,
|
|
115
|
+
ref: forwardedRef
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
const NavigationRailToggleButton = forwardRef((props, forwardedRef) => {
|
|
119
|
+
const {
|
|
120
|
+
label = "Expand navigation",
|
|
121
|
+
...rest
|
|
122
|
+
} = props;
|
|
123
|
+
const expanded = useNavigationRailState((state) => state.expanded);
|
|
124
|
+
const setExpanded = useNavigationRailState((state_0) => state_0.setExpanded);
|
|
125
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
126
|
+
"aria-expanded": expanded ? "true" : "false",
|
|
127
|
+
...rest,
|
|
128
|
+
className: cx("\u{1F95D}NavigationRailToggleButton", props.className),
|
|
129
|
+
ref: forwardedRef,
|
|
130
|
+
onClick: useEventHandlers(props.onClick, () => setExpanded(!expanded)),
|
|
131
|
+
children: [/* @__PURE__ */ jsx("svg", {
|
|
132
|
+
width: "12",
|
|
133
|
+
height: "12",
|
|
134
|
+
fill: "none",
|
|
135
|
+
"aria-hidden": "true",
|
|
136
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
137
|
+
fill: "currentColor",
|
|
138
|
+
d: "M5.405 2.845a.75.75 0 1 0-1.06 1.06L6.439 6 4.345 8.095a.75.75 0 0 0 1.06 1.06L8.03 6.53a.75.75 0 0 0 0-1.06L5.405 2.845Z"
|
|
139
|
+
})
|
|
140
|
+
}), /* @__PURE__ */ jsx(VisuallyHidden, {
|
|
141
|
+
children: label
|
|
142
|
+
})]
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
const NavigationRailContent = forwardRef((props, forwardedRef) => {
|
|
146
|
+
return /* @__PURE__ */ jsx(Role.div, {
|
|
147
|
+
...props,
|
|
148
|
+
className: cx("\u{1F95D}NavigationRailContent", props.className),
|
|
149
|
+
ref: forwardedRef
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
const NavigationRailList = forwardRef((props, forwardedRef) => {
|
|
153
|
+
return /* @__PURE__ */ jsx(Role, {
|
|
154
|
+
role: "list",
|
|
155
|
+
...props,
|
|
156
|
+
className: cx("\u{1F95D}NavigationRailList", props.className),
|
|
157
|
+
ref: forwardedRef
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
const NavigationRailListItem = forwardRef((props, forwardedRef) => {
|
|
161
|
+
return /* @__PURE__ */ jsx(Role.div, {
|
|
162
|
+
role: "listitem",
|
|
163
|
+
...props,
|
|
164
|
+
className: cx("\u{1F95D}NavigationRailListItem", props.className),
|
|
165
|
+
ref: forwardedRef
|
|
166
|
+
});
|
|
85
167
|
});
|
|
86
|
-
const NavigationRailContent = forwardRef(
|
|
87
|
-
(props, forwardedRef) => {
|
|
88
|
-
return /* @__PURE__ */ jsx(
|
|
89
|
-
Role.div,
|
|
90
|
-
{
|
|
91
|
-
...props,
|
|
92
|
-
className: cx("\u{1F95D}NavigationRailContent", props.className),
|
|
93
|
-
ref: forwardedRef
|
|
94
|
-
}
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
const NavigationRailList = forwardRef(
|
|
99
|
-
(props, forwardedRef) => {
|
|
100
|
-
return /* @__PURE__ */ jsx(
|
|
101
|
-
Role,
|
|
102
|
-
{
|
|
103
|
-
role: "list",
|
|
104
|
-
...props,
|
|
105
|
-
className: cx("\u{1F95D}NavigationRailList", props.className),
|
|
106
|
-
ref: forwardedRef
|
|
107
|
-
}
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
);
|
|
111
|
-
const NavigationRailListItem = forwardRef(
|
|
112
|
-
(props, forwardedRef) => {
|
|
113
|
-
return /* @__PURE__ */ jsx(
|
|
114
|
-
Role.div,
|
|
115
|
-
{
|
|
116
|
-
role: "listitem",
|
|
117
|
-
...props,
|
|
118
|
-
className: cx("\u{1F95D}NavigationRailListItem", props.className),
|
|
119
|
-
ref: forwardedRef
|
|
120
|
-
}
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
);
|
|
124
168
|
const NavigationRailItemAction = forwardRef((props, forwardedRef) => {
|
|
125
|
-
const
|
|
126
|
-
const {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
169
|
+
const expanded = useNavigationRailState((state) => state.expanded);
|
|
170
|
+
const {
|
|
171
|
+
label,
|
|
172
|
+
icon,
|
|
173
|
+
...rest
|
|
174
|
+
} = props;
|
|
175
|
+
const action = /* @__PURE__ */ jsxs(Role, {
|
|
176
|
+
...rest,
|
|
177
|
+
className: cx("\u{1F95D}NavigationRailItemAction", props.className),
|
|
178
|
+
ref: forwardedRef,
|
|
179
|
+
children: [typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, {
|
|
180
|
+
href: icon
|
|
181
|
+
}) : icon, /* @__PURE__ */ jsx(Role.span, {
|
|
182
|
+
className: "\u{1F95D}NavigationRailItemActionLabel",
|
|
183
|
+
render: !expanded ? /* @__PURE__ */ jsx(VisuallyHidden, {}) : void 0,
|
|
184
|
+
children: label
|
|
185
|
+
})]
|
|
186
|
+
});
|
|
187
|
+
if (!expanded) {
|
|
188
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
189
|
+
content: label,
|
|
190
|
+
placement: "right",
|
|
191
|
+
type: "none",
|
|
192
|
+
children: action
|
|
193
|
+
});
|
|
148
194
|
}
|
|
149
195
|
return action;
|
|
150
196
|
});
|
|
151
|
-
const NavigationRailAnchor = forwardRef(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
);
|
|
197
|
+
const NavigationRailAnchor = forwardRef((props, forwardedRef) => {
|
|
198
|
+
const {
|
|
199
|
+
label,
|
|
200
|
+
icon,
|
|
201
|
+
active,
|
|
202
|
+
...rest
|
|
203
|
+
} = props;
|
|
204
|
+
return /* @__PURE__ */ jsx(NavigationRailItemAction, {
|
|
205
|
+
label,
|
|
206
|
+
icon,
|
|
207
|
+
"aria-current": active ? "page" : void 0,
|
|
208
|
+
render: /* @__PURE__ */ jsx(Role.a, {
|
|
209
|
+
...rest,
|
|
210
|
+
ref: forwardedRef
|
|
211
|
+
})
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
const NavigationRailButton = forwardRef((props, forwardedRef) => {
|
|
215
|
+
const {
|
|
216
|
+
label,
|
|
217
|
+
icon,
|
|
218
|
+
...rest
|
|
219
|
+
} = props;
|
|
220
|
+
return /* @__PURE__ */ jsx(NavigationRailItemAction, {
|
|
221
|
+
label,
|
|
222
|
+
icon,
|
|
223
|
+
render: /* @__PURE__ */ jsx(Role.button, {
|
|
224
|
+
...rest,
|
|
225
|
+
ref: forwardedRef
|
|
226
|
+
})
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
const NavigationRailFooter = forwardRef((props, forwardedRef) => {
|
|
230
|
+
return /* @__PURE__ */ jsx(Role, {
|
|
231
|
+
render: /* @__PURE__ */ jsx("footer", {}),
|
|
232
|
+
...props,
|
|
233
|
+
className: cx("\u{1F95D}NavigationRailFooter", props.className),
|
|
234
|
+
ref: forwardedRef
|
|
235
|
+
});
|
|
236
|
+
});
|
|
191
237
|
export {
|
|
192
238
|
NavigationRailAnchor as Anchor,
|
|
193
239
|
NavigationRailButton as Button,
|
package/dist/Table.js
CHANGED
|
@@ -1,137 +1,145 @@
|
|
|
1
|
+
import { c as _c } from "react-compiler-runtime";
|
|
1
2
|
import { jsx } from "react/jsx-runtime";
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
import { Role } from "@ariakit/react/role";
|
|
4
|
-
import {
|
|
5
|
-
forwardRef,
|
|
6
|
-
useMergedRefs,
|
|
7
|
-
useSafeContext
|
|
8
|
-
} from "@stratakit/foundations/secret-internals";
|
|
5
|
+
import { forwardRef, useMergedRefs, useSafeContext } from "@stratakit/foundations/secret-internals";
|
|
9
6
|
import cx from "classnames";
|
|
10
7
|
const TableContext = React.createContext(void 0);
|
|
11
8
|
const TableHeaderContext = React.createContext(false);
|
|
12
9
|
const HtmlTable = forwardRef((props, forwardedRef) => {
|
|
13
|
-
const tableContextValue = React.useMemo(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Role,
|
|
19
|
-
{
|
|
10
|
+
const tableContextValue = React.useMemo(() => ({
|
|
11
|
+
mode: "html"
|
|
12
|
+
}), []);
|
|
13
|
+
return /* @__PURE__ */ jsx(TableContext.Provider, {
|
|
14
|
+
value: tableContextValue,
|
|
15
|
+
children: /* @__PURE__ */ jsx(Role, {
|
|
20
16
|
render: /* @__PURE__ */ jsx("table", {}),
|
|
21
17
|
...props,
|
|
22
18
|
ref: forwardedRef,
|
|
23
19
|
className: cx("\u{1F95D}Table", props.className)
|
|
24
|
-
}
|
|
25
|
-
|
|
20
|
+
})
|
|
21
|
+
});
|
|
26
22
|
});
|
|
27
|
-
const CustomTable = forwardRef(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
...props,
|
|
40
|
-
ref: forwardedRef,
|
|
41
|
-
className: cx("\u{1F95D}Table", props.className)
|
|
42
|
-
}
|
|
43
|
-
) });
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
const TableHeader = forwardRef(
|
|
47
|
-
(props, forwardedRef) => {
|
|
48
|
-
const { mode } = useSafeContext(TableContext);
|
|
49
|
-
const render = mode === "html" ? /* @__PURE__ */ jsx("thead", {}) : void 0;
|
|
50
|
-
const role = mode === "aria" ? "rowgroup" : void 0;
|
|
51
|
-
return /* @__PURE__ */ jsx(TableHeaderContext.Provider, { value: true, children: /* @__PURE__ */ jsx(
|
|
52
|
-
Role.div,
|
|
53
|
-
{
|
|
54
|
-
render,
|
|
55
|
-
role,
|
|
56
|
-
...props,
|
|
57
|
-
ref: forwardedRef,
|
|
58
|
-
className: cx("\u{1F95D}TableHeader", props.className)
|
|
59
|
-
}
|
|
60
|
-
) });
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
const TableBody = forwardRef((props, forwardedRef) => {
|
|
64
|
-
const { mode } = useSafeContext(TableContext);
|
|
65
|
-
const render = mode === "html" ? /* @__PURE__ */ jsx("tbody", {}) : void 0;
|
|
66
|
-
return /* @__PURE__ */ jsx(
|
|
67
|
-
Role.div,
|
|
68
|
-
{
|
|
69
|
-
render,
|
|
70
|
-
role: void 0,
|
|
23
|
+
const CustomTable = forwardRef((props, forwardedRef) => {
|
|
24
|
+
const [captionId, setCaptionId] = React.useState();
|
|
25
|
+
const tableContextValue = React.useMemo(() => ({
|
|
26
|
+
captionId,
|
|
27
|
+
setCaptionId,
|
|
28
|
+
mode: "aria"
|
|
29
|
+
}), [captionId]);
|
|
30
|
+
return /* @__PURE__ */ jsx(TableContext.Provider, {
|
|
31
|
+
value: tableContextValue,
|
|
32
|
+
children: /* @__PURE__ */ jsx(Role.div, {
|
|
33
|
+
role: "table",
|
|
34
|
+
"aria-labelledby": captionId,
|
|
71
35
|
...props,
|
|
72
36
|
ref: forwardedRef,
|
|
73
|
-
className: cx("\u{1F95D}
|
|
74
|
-
}
|
|
75
|
-
);
|
|
37
|
+
className: cx("\u{1F95D}Table", props.className)
|
|
38
|
+
})
|
|
39
|
+
});
|
|
76
40
|
});
|
|
77
|
-
const
|
|
78
|
-
const {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
41
|
+
const TableHeader = forwardRef((props, forwardedRef) => {
|
|
42
|
+
const {
|
|
43
|
+
mode
|
|
44
|
+
} = useSafeContext(TableContext);
|
|
45
|
+
const render = mode === "html" ? /* @__PURE__ */ jsx("thead", {}) : void 0;
|
|
46
|
+
const role = mode === "aria" ? "rowgroup" : void 0;
|
|
47
|
+
return /* @__PURE__ */ jsx(TableHeaderContext.Provider, {
|
|
48
|
+
value: true,
|
|
49
|
+
children: /* @__PURE__ */ jsx(Role.div, {
|
|
84
50
|
render,
|
|
85
51
|
role,
|
|
86
52
|
...props,
|
|
87
53
|
ref: forwardedRef,
|
|
88
|
-
className: cx("\u{1F95D}
|
|
89
|
-
}
|
|
90
|
-
);
|
|
54
|
+
className: cx("\u{1F95D}TableHeader", props.className)
|
|
55
|
+
})
|
|
56
|
+
});
|
|
91
57
|
});
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
58
|
+
const TableBody = forwardRef((props, forwardedRef) => {
|
|
59
|
+
const {
|
|
60
|
+
mode
|
|
61
|
+
} = useSafeContext(TableContext);
|
|
62
|
+
const render = mode === "html" ? /* @__PURE__ */ jsx("tbody", {}) : void 0;
|
|
63
|
+
return /* @__PURE__ */ jsx(Role.div, {
|
|
64
|
+
render,
|
|
65
|
+
role: void 0,
|
|
66
|
+
...props,
|
|
67
|
+
ref: forwardedRef,
|
|
68
|
+
className: cx("\u{1F95D}TableBody", props.className)
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
const TableRow = forwardRef((props, forwardedRef) => {
|
|
72
|
+
const {
|
|
73
|
+
mode
|
|
74
|
+
} = useSafeContext(TableContext);
|
|
75
|
+
const render = mode === "html" ? /* @__PURE__ */ jsx("tr", {}) : void 0;
|
|
76
|
+
const role = mode === "aria" ? "row" : void 0;
|
|
77
|
+
return /* @__PURE__ */ jsx(Role.div, {
|
|
78
|
+
render,
|
|
79
|
+
role,
|
|
80
|
+
...props,
|
|
81
|
+
ref: forwardedRef,
|
|
82
|
+
className: cx("\u{1F95D}TableRow", props.className)
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
const TableCaption = forwardRef((props, forwardedRef) => {
|
|
86
|
+
const $ = _c(3);
|
|
87
|
+
const fallbackId = React.useId();
|
|
88
|
+
const {
|
|
89
|
+
id: t0,
|
|
90
|
+
...rest
|
|
91
|
+
} = props;
|
|
92
|
+
const id = t0 === void 0 ? fallbackId : t0;
|
|
93
|
+
const {
|
|
94
|
+
mode,
|
|
95
|
+
setCaptionId
|
|
96
|
+
} = useSafeContext(TableContext);
|
|
97
|
+
const render = mode === "html" ? jsx("caption", {}) : void 0;
|
|
98
|
+
let t1;
|
|
99
|
+
if ($[0] !== id || $[1] !== setCaptionId) {
|
|
100
|
+
t1 = (element) => {
|
|
101
|
+
setCaptionId?.(element ? id : void 0);
|
|
102
|
+
};
|
|
103
|
+
$[0] = id;
|
|
104
|
+
$[1] = setCaptionId;
|
|
105
|
+
$[2] = t1;
|
|
106
|
+
} else {
|
|
107
|
+
t1 = $[2];
|
|
114
108
|
}
|
|
115
|
-
|
|
109
|
+
const captionIdRef = t1;
|
|
110
|
+
return jsx(Role.div, {
|
|
111
|
+
render,
|
|
112
|
+
...rest,
|
|
113
|
+
id,
|
|
114
|
+
ref: useMergedRefs(forwardedRef, captionIdRef),
|
|
115
|
+
className: cx("\u{1F95D}TableCaption", props.className)
|
|
116
|
+
});
|
|
117
|
+
});
|
|
116
118
|
const TableCell = forwardRef((props, forwardedRef) => {
|
|
117
119
|
const isWithinTableHeader = useSafeContext(TableHeaderContext);
|
|
118
|
-
const {
|
|
119
|
-
|
|
120
|
+
const {
|
|
121
|
+
mode
|
|
122
|
+
} = useSafeContext(TableContext);
|
|
123
|
+
const {
|
|
124
|
+
render,
|
|
125
|
+
role
|
|
126
|
+
} = React.useMemo(() => {
|
|
120
127
|
if (mode === "aria") {
|
|
121
|
-
return {
|
|
128
|
+
return {
|
|
129
|
+
role: isWithinTableHeader ? "columnheader" : "cell"
|
|
130
|
+
};
|
|
122
131
|
}
|
|
123
|
-
return {
|
|
132
|
+
return {
|
|
133
|
+
render: isWithinTableHeader ? /* @__PURE__ */ jsx("th", {}) : /* @__PURE__ */ jsx("td", {})
|
|
134
|
+
};
|
|
124
135
|
}, [isWithinTableHeader, mode]);
|
|
125
|
-
return /* @__PURE__ */ jsx(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
className: cx("\u{1F95D}TableCell", props.className)
|
|
133
|
-
}
|
|
134
|
-
);
|
|
136
|
+
return /* @__PURE__ */ jsx(Role.div, {
|
|
137
|
+
render,
|
|
138
|
+
role,
|
|
139
|
+
...props,
|
|
140
|
+
ref: forwardedRef,
|
|
141
|
+
className: cx("\u{1F95D}TableCell", props.className)
|
|
142
|
+
});
|
|
135
143
|
});
|
|
136
144
|
export {
|
|
137
145
|
TableBody as Body,
|
package/dist/Tabs.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as AkTab from "@ariakit/react/tab";
|
|
2
2
|
import type { BaseProps, FocusableProps } from "@stratakit/foundations/secret-internals";
|
|
3
3
|
interface TabsProviderProps extends Pick<AkTab.TabProviderProps, "defaultSelectedId" | "selectedId" | "setSelectedId" | "selectOnMove" | "children"> {
|
|
4
|
+
/** @default false */
|
|
5
|
+
selectOnMove?: AkTab.TabProviderProps["selectOnMove"];
|
|
4
6
|
}
|
|
5
7
|
/**
|
|
6
8
|
* A set of tabs that can be used to switch between different views.
|