@stratakit/structures 0.4.5 → 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 +30 -0
- package/dist/AccordionItem.d.ts +1 -1
- package/dist/AccordionItem.js +67 -124
- package/dist/Banner.js +146 -120
- package/dist/Chip.js +83 -58
- package/dist/DEV/ErrorRegion.js +3 -11
- 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 +18 -8
- package/dist/ErrorRegion.js +127 -154
- package/dist/NavigationRail.js +209 -188
- package/dist/Table.js +116 -108
- 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,218 +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";
|
|
3
4
|
import { Button } from "@ariakit/react/button";
|
|
4
5
|
import { Role } from "@ariakit/react/role";
|
|
5
6
|
import { Tooltip, VisuallyHidden } from "@stratakit/bricks";
|
|
6
7
|
import { Icon } from "@stratakit/foundations";
|
|
7
|
-
import {
|
|
8
|
-
forwardRef,
|
|
9
|
-
useEventHandlers,
|
|
10
|
-
useSafeContext,
|
|
11
|
-
useUnreactiveCallback
|
|
12
|
-
} from "@stratakit/foundations/secret-internals";
|
|
8
|
+
import { forwardRef, useEventHandlers, useSafeContext, useUnreactiveCallback } from "@stratakit/foundations/secret-internals";
|
|
13
9
|
import cx from "classnames";
|
|
14
10
|
import { createStore, useStore } from "zustand";
|
|
15
11
|
import { combine } from "zustand/middleware";
|
|
16
12
|
function createNavigationRailStore(initialState) {
|
|
17
|
-
return createStore(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
21
|
-
);
|
|
13
|
+
return createStore(combine(initialState, (set) => ({
|
|
14
|
+
setExpanded: (expanded) => set({
|
|
15
|
+
expanded
|
|
16
|
+
})
|
|
17
|
+
})));
|
|
22
18
|
}
|
|
23
19
|
const NavigationRailContext = React.createContext(void 0);
|
|
24
20
|
function NavigationRailProvider(props) {
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
[
|
|
37
|
-
|
|
38
|
-
|
|
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() {
|
|
39
78
|
}
|
|
40
79
|
function useNavigationRailState(selectorFn) {
|
|
41
80
|
const store = useSafeContext(NavigationRailContext);
|
|
42
81
|
return useStore(store, selectorFn);
|
|
43
82
|
}
|
|
44
|
-
const NavigationRailRoot = forwardRef(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
className: cx("\u{1F95D}NavigationRailHeader", props.className),
|
|
80
|
-
"data-_sk-expanded": expanded ? "true" : void 0,
|
|
81
|
-
ref: forwardedRef
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
);
|
|
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, {
|
|
95
|
+
...rest,
|
|
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
|
+
});
|
|
86
118
|
const NavigationRailToggleButton = forwardRef((props, forwardedRef) => {
|
|
87
|
-
const {
|
|
119
|
+
const {
|
|
120
|
+
label = "Expand navigation",
|
|
121
|
+
...rest
|
|
122
|
+
} = props;
|
|
88
123
|
const expanded = useNavigationRailState((state) => state.expanded);
|
|
89
|
-
const setExpanded = useNavigationRailState((
|
|
90
|
-
return /* @__PURE__ */ jsxs(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
+
});
|
|
110
167
|
});
|
|
111
|
-
const NavigationRailContent = forwardRef(
|
|
112
|
-
(props, forwardedRef) => {
|
|
113
|
-
return /* @__PURE__ */ jsx(
|
|
114
|
-
Role.div,
|
|
115
|
-
{
|
|
116
|
-
...props,
|
|
117
|
-
className: cx("\u{1F95D}NavigationRailContent", props.className),
|
|
118
|
-
ref: forwardedRef
|
|
119
|
-
}
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
);
|
|
123
|
-
const NavigationRailList = forwardRef(
|
|
124
|
-
(props, forwardedRef) => {
|
|
125
|
-
return /* @__PURE__ */ jsx(
|
|
126
|
-
Role,
|
|
127
|
-
{
|
|
128
|
-
role: "list",
|
|
129
|
-
...props,
|
|
130
|
-
className: cx("\u{1F95D}NavigationRailList", props.className),
|
|
131
|
-
ref: forwardedRef
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
);
|
|
136
|
-
const NavigationRailListItem = forwardRef(
|
|
137
|
-
(props, forwardedRef) => {
|
|
138
|
-
return /* @__PURE__ */ jsx(
|
|
139
|
-
Role.div,
|
|
140
|
-
{
|
|
141
|
-
role: "listitem",
|
|
142
|
-
...props,
|
|
143
|
-
className: cx("\u{1F95D}NavigationRailListItem", props.className),
|
|
144
|
-
ref: forwardedRef
|
|
145
|
-
}
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
);
|
|
149
168
|
const NavigationRailItemAction = forwardRef((props, forwardedRef) => {
|
|
150
169
|
const expanded = useNavigationRailState((state) => state.expanded);
|
|
151
|
-
const {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
]
|
|
169
|
-
}
|
|
170
|
-
);
|
|
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
|
+
});
|
|
171
187
|
if (!expanded) {
|
|
172
|
-
return /* @__PURE__ */ jsx(Tooltip, {
|
|
188
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
189
|
+
content: label,
|
|
190
|
+
placement: "right",
|
|
191
|
+
type: "none",
|
|
192
|
+
children: action
|
|
193
|
+
});
|
|
173
194
|
}
|
|
174
195
|
return action;
|
|
175
196
|
});
|
|
176
|
-
const NavigationRailAnchor = forwardRef(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
);
|
|
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
|
+
});
|
|
216
237
|
export {
|
|
217
238
|
NavigationRailAnchor as Anchor,
|
|
218
239
|
NavigationRailButton as Button,
|