@stratakit/structures 0.4.5 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -0
- package/dist/AccordionItem.d.ts +1 -1
- package/dist/AccordionItem.js +69 -124
- package/dist/Banner.js +149 -120
- package/dist/Chip.js +86 -58
- package/dist/DEV/AccordionItem.js +2 -0
- package/dist/DEV/Banner.js +3 -0
- package/dist/DEV/Chip.js +3 -0
- package/dist/DEV/Dialog.js +2 -0
- package/dist/DEV/DropdownMenu.js +2 -0
- package/dist/DEV/ErrorRegion.js +5 -11
- package/dist/DEV/NavigationList.js +130 -0
- package/dist/DEV/NavigationRail.js +6 -4
- package/dist/DEV/Popover.js +90 -0
- package/dist/DEV/Table.js +3 -0
- package/dist/DEV/Tabs.js +3 -1
- package/dist/DEV/Toolbar.js +2 -0
- package/dist/DEV/Tree.js +2 -0
- package/dist/DEV/TreeItem.js +7 -2
- package/dist/DEV/index.js +4 -0
- package/dist/DEV/styles.css.js +1 -1
- package/dist/DEV/~utils.ListItem.js +3 -3
- package/dist/DEV/~utils.useInit.js +16 -0
- package/dist/Dialog.js +142 -132
- package/dist/DropdownMenu.js +217 -234
- package/dist/ErrorRegion.d.ts +18 -8
- package/dist/ErrorRegion.js +129 -154
- package/dist/NavigationList.d.ts +110 -0
- package/dist/NavigationList.js +130 -0
- package/dist/NavigationRail.js +211 -188
- package/dist/Popover.d.ts +36 -0
- package/dist/Popover.js +99 -0
- package/dist/Table.js +119 -108
- package/dist/Tabs.js +100 -63
- package/dist/Toolbar.js +25 -43
- package/dist/Tree.js +15 -12
- package/dist/TreeItem.js +398 -314
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -0
- package/dist/styles.css.js +1 -1
- package/dist/~utils.ListItem.d.ts +3 -3
- package/dist/~utils.ListItem.js +21 -34
- package/dist/~utils.icons.js +26 -46
- package/dist/~utils.useInit.d.ts +8 -0
- package/dist/~utils.useInit.js +13 -0
- package/package.json +25 -18
package/dist/Chip.js
CHANGED
|
@@ -1,92 +1,120 @@
|
|
|
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 { Role } from "@ariakit/react/role";
|
|
4
5
|
import { IconButton } from "@stratakit/bricks";
|
|
5
|
-
import {
|
|
6
|
-
forwardRef,
|
|
7
|
-
useSafeContext
|
|
8
|
-
} from "@stratakit/foundations/secret-internals";
|
|
6
|
+
import { forwardRef, useSafeContext } from "@stratakit/foundations/secret-internals";
|
|
9
7
|
import cx from "classnames";
|
|
10
8
|
import { createStore, useStore } from "zustand";
|
|
11
9
|
import { combine } from "zustand/middleware";
|
|
12
10
|
import { Dismiss } from "./~utils.icons.js";
|
|
11
|
+
import { useInit } from "./~utils.useInit.js";
|
|
13
12
|
function createChipStore(initialState) {
|
|
14
|
-
return createStore(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
);
|
|
13
|
+
return createStore(combine(initialState, (set, _, store) => ({
|
|
14
|
+
setLabelId: (labelId) => {
|
|
15
|
+
set({
|
|
16
|
+
labelId: labelId || store.getInitialState().labelId
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
})));
|
|
21
20
|
}
|
|
22
21
|
const ChipContext = React.createContext(void 0);
|
|
23
22
|
function ChipProvider(props) {
|
|
23
|
+
const $ = _c(5);
|
|
24
24
|
const defaultLabelId = React.useId();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
let t0;
|
|
26
|
+
if ($[0] !== defaultLabelId) {
|
|
27
|
+
t0 = () => createChipStore({
|
|
28
|
+
labelId: defaultLabelId
|
|
29
|
+
});
|
|
30
|
+
$[0] = defaultLabelId;
|
|
31
|
+
$[1] = t0;
|
|
32
|
+
} else {
|
|
33
|
+
t0 = $[1];
|
|
34
|
+
}
|
|
35
|
+
const [store] = React.useState(t0);
|
|
36
|
+
let t1;
|
|
37
|
+
if ($[2] !== props.children || $[3] !== store) {
|
|
38
|
+
t1 = jsx(ChipContext.Provider, {
|
|
39
|
+
value: store,
|
|
40
|
+
children: props.children
|
|
41
|
+
});
|
|
42
|
+
$[2] = props.children;
|
|
43
|
+
$[3] = store;
|
|
44
|
+
$[4] = t1;
|
|
45
|
+
} else {
|
|
46
|
+
t1 = $[4];
|
|
47
|
+
}
|
|
48
|
+
return t1;
|
|
29
49
|
}
|
|
30
50
|
function useChipState(selectorFn) {
|
|
31
51
|
const store = useSafeContext(ChipContext);
|
|
32
52
|
return useStore(store, selectorFn);
|
|
33
53
|
}
|
|
34
54
|
const ChipRoot = forwardRef((props, forwardedRef) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
55
|
+
useInit();
|
|
56
|
+
const {
|
|
57
|
+
variant = "solid",
|
|
58
|
+
...rest
|
|
59
|
+
} = props;
|
|
60
|
+
return /* @__PURE__ */ jsx(ChipProvider, {
|
|
61
|
+
children: /* @__PURE__ */ jsx(Role.div, {
|
|
39
62
|
"data-_sk-variant": variant,
|
|
40
63
|
...rest,
|
|
41
64
|
className: cx("\u{1F95D}Chip", props.className),
|
|
42
65
|
ref: forwardedRef
|
|
43
|
-
}
|
|
44
|
-
|
|
66
|
+
})
|
|
67
|
+
});
|
|
45
68
|
});
|
|
46
69
|
const ChipLabel = forwardRef((props, forwardedRef) => {
|
|
47
70
|
const labelId = useChipState((state) => state.labelId);
|
|
48
|
-
const setLabelId = useChipState((
|
|
71
|
+
const setLabelId = useChipState((state_0) => state_0.setLabelId);
|
|
49
72
|
React.useEffect(() => {
|
|
50
73
|
setLabelId(props.id);
|
|
51
74
|
}, [setLabelId, props.id]);
|
|
52
|
-
return /* @__PURE__ */ jsx(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
75
|
+
return /* @__PURE__ */ jsx(Role.span, {
|
|
76
|
+
id: labelId,
|
|
77
|
+
...props,
|
|
78
|
+
className: cx("\u{1F95D}ChipLabel", props.className),
|
|
79
|
+
ref: forwardedRef
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
const ChipDismissButton = forwardRef((props, forwardedRef) => {
|
|
83
|
+
const {
|
|
84
|
+
label = "Dismiss",
|
|
85
|
+
...rest
|
|
86
|
+
} = props;
|
|
87
|
+
const labelId = useChipState((state) => state.labelId);
|
|
88
|
+
const defaultId = React.useId();
|
|
89
|
+
const id = props.id ?? defaultId;
|
|
90
|
+
return /* @__PURE__ */ jsx(IconButton, {
|
|
91
|
+
id,
|
|
92
|
+
"aria-labelledby": `${id} ${labelId}`,
|
|
93
|
+
...rest,
|
|
94
|
+
label,
|
|
95
|
+
className: cx("\u{1F95D}ChipDismissButton", props.className),
|
|
96
|
+
variant: "ghost",
|
|
97
|
+
labelVariant: "visually-hidden",
|
|
98
|
+
icon: /* @__PURE__ */ jsx(Dismiss, {}),
|
|
99
|
+
ref: forwardedRef
|
|
100
|
+
});
|
|
61
101
|
});
|
|
62
|
-
const ChipDismissButton = forwardRef(
|
|
63
|
-
(props, forwardedRef) => {
|
|
64
|
-
const { label = "Dismiss", ...rest } = props;
|
|
65
|
-
const labelId = useChipState((state) => state.labelId);
|
|
66
|
-
const defaultId = React.useId();
|
|
67
|
-
const id = props.id ?? defaultId;
|
|
68
|
-
return /* @__PURE__ */ jsx(
|
|
69
|
-
IconButton,
|
|
70
|
-
{
|
|
71
|
-
id,
|
|
72
|
-
"aria-labelledby": `${id} ${labelId}`,
|
|
73
|
-
...rest,
|
|
74
|
-
label,
|
|
75
|
-
className: cx("\u{1F95D}ChipDismissButton", props.className),
|
|
76
|
-
variant: "ghost",
|
|
77
|
-
labelVariant: "visually-hidden",
|
|
78
|
-
icon: /* @__PURE__ */ jsx(Dismiss, {}),
|
|
79
|
-
ref: forwardedRef
|
|
80
|
-
}
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
102
|
const Chip = forwardRef((props, forwardedRef) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
103
|
+
useInit();
|
|
104
|
+
const {
|
|
105
|
+
onDismiss,
|
|
106
|
+
label,
|
|
107
|
+
...rest
|
|
108
|
+
} = props;
|
|
109
|
+
return /* @__PURE__ */ jsxs(ChipRoot, {
|
|
110
|
+
...rest,
|
|
111
|
+
ref: forwardedRef,
|
|
112
|
+
children: [/* @__PURE__ */ jsx(ChipLabel, {
|
|
113
|
+
children: label
|
|
114
|
+
}), onDismiss && /* @__PURE__ */ jsx(ChipDismissButton, {
|
|
115
|
+
onClick: onDismiss
|
|
116
|
+
})]
|
|
117
|
+
});
|
|
90
118
|
});
|
|
91
119
|
var Chip_default = Chip;
|
|
92
120
|
export {
|
|
@@ -16,8 +16,10 @@ import {
|
|
|
16
16
|
} from "@stratakit/foundations/secret-internals";
|
|
17
17
|
import cx from "classnames";
|
|
18
18
|
import { ChevronDown } from "./~utils.icons.js";
|
|
19
|
+
import { useInit } from "./~utils.useInit.js";
|
|
19
20
|
const AccordionItemRoot = forwardRef(
|
|
20
21
|
(props, forwardedRef) => {
|
|
22
|
+
useInit();
|
|
21
23
|
const {
|
|
22
24
|
defaultOpen,
|
|
23
25
|
open: openProp,
|
package/dist/DEV/Banner.js
CHANGED
|
@@ -12,6 +12,7 @@ import cx from "classnames";
|
|
|
12
12
|
import { createStore, useStore } from "zustand";
|
|
13
13
|
import { combine } from "zustand/middleware";
|
|
14
14
|
import { Dismiss, StatusIcon } from "./~utils.icons.js";
|
|
15
|
+
import { useInit } from "./~utils.useInit.js";
|
|
15
16
|
function createBannerStore(initialState) {
|
|
16
17
|
return createStore(
|
|
17
18
|
combine(initialState, (set, _, store) => ({
|
|
@@ -38,6 +39,7 @@ function useBannerState(selectorFn) {
|
|
|
38
39
|
return useStore(store, selectorFn);
|
|
39
40
|
}
|
|
40
41
|
const BannerRoot = forwardRef((props, forwardedRef) => {
|
|
42
|
+
useInit();
|
|
41
43
|
const { tone = "neutral", variant = "outline", ...rest } = props;
|
|
42
44
|
return /* @__PURE__ */ jsx(BannerProvider, { tone, children: /* @__PURE__ */ jsx(
|
|
43
45
|
Role,
|
|
@@ -143,6 +145,7 @@ const BannerDismissButton = forwardRef(
|
|
|
143
145
|
);
|
|
144
146
|
DEV: BannerDismissButton.displayName = "Banner.DismissButton";
|
|
145
147
|
const Banner = forwardRef((props, forwardedRef) => {
|
|
148
|
+
useInit();
|
|
146
149
|
const {
|
|
147
150
|
message,
|
|
148
151
|
label,
|
package/dist/DEV/Chip.js
CHANGED
|
@@ -10,6 +10,7 @@ import cx from "classnames";
|
|
|
10
10
|
import { createStore, useStore } from "zustand";
|
|
11
11
|
import { combine } from "zustand/middleware";
|
|
12
12
|
import { Dismiss } from "./~utils.icons.js";
|
|
13
|
+
import { useInit } from "./~utils.useInit.js";
|
|
13
14
|
function createChipStore(initialState) {
|
|
14
15
|
return createStore(
|
|
15
16
|
combine(initialState, (set, _, store) => ({
|
|
@@ -32,6 +33,7 @@ function useChipState(selectorFn) {
|
|
|
32
33
|
return useStore(store, selectorFn);
|
|
33
34
|
}
|
|
34
35
|
const ChipRoot = forwardRef((props, forwardedRef) => {
|
|
36
|
+
useInit();
|
|
35
37
|
const { variant = "solid", ...rest } = props;
|
|
36
38
|
return /* @__PURE__ */ jsx(ChipProvider, { children: /* @__PURE__ */ jsx(
|
|
37
39
|
Role.div,
|
|
@@ -85,6 +87,7 @@ const ChipDismissButton = forwardRef(
|
|
|
85
87
|
);
|
|
86
88
|
DEV: ChipDismissButton.displayName = "Chip.DismissButton";
|
|
87
89
|
const Chip = forwardRef((props, forwardedRef) => {
|
|
90
|
+
useInit();
|
|
88
91
|
const { onDismiss, label, ...rest } = props;
|
|
89
92
|
return /* @__PURE__ */ jsxs(ChipRoot, { ...rest, ref: forwardedRef, children: [
|
|
90
93
|
/* @__PURE__ */ jsx(ChipLabel, { children: label }),
|
package/dist/DEV/Dialog.js
CHANGED
|
@@ -12,7 +12,9 @@ import {
|
|
|
12
12
|
} from "@stratakit/foundations/secret-internals";
|
|
13
13
|
import cx from "classnames";
|
|
14
14
|
import { Dismiss } from "./~utils.icons.js";
|
|
15
|
+
import { useInit } from "./~utils.useInit.js";
|
|
15
16
|
const DialogRoot = forwardRef((props, forwardedRef) => {
|
|
17
|
+
useInit();
|
|
16
18
|
const { backdrop = true, unmountOnHide = true, ...rest } = props;
|
|
17
19
|
const store = AkDialog.useDialogStore();
|
|
18
20
|
const contentElement = useStoreState(store, "contentElement");
|
package/dist/DEV/DropdownMenu.js
CHANGED
|
@@ -26,7 +26,9 @@ import {
|
|
|
26
26
|
import cx from "classnames";
|
|
27
27
|
import { Checkmark, ChevronRight } from "./~utils.icons.js";
|
|
28
28
|
import * as ListItem from "./~utils.ListItem.js";
|
|
29
|
+
import { useInit } from "./~utils.useInit.js";
|
|
29
30
|
function DropdownMenuProvider(props) {
|
|
31
|
+
useInit();
|
|
30
32
|
const { children, placement, open, setOpen, defaultOpen } = props;
|
|
31
33
|
return /* @__PURE__ */ jsx(
|
|
32
34
|
MenuProvider,
|
package/dist/DEV/ErrorRegion.js
CHANGED
|
@@ -20,26 +20,20 @@ import {
|
|
|
20
20
|
} from "@stratakit/foundations/secret-internals";
|
|
21
21
|
import cx from "classnames";
|
|
22
22
|
import { ChevronDown, StatusIcon } from "./~utils.icons.js";
|
|
23
|
+
import { useInit } from "./~utils.useInit.js";
|
|
23
24
|
const ErrorRegionRoot = forwardRef(
|
|
24
25
|
(props, forwardedRef) => {
|
|
26
|
+
useInit();
|
|
25
27
|
const {
|
|
26
28
|
label,
|
|
27
|
-
items
|
|
29
|
+
items = [],
|
|
28
30
|
open: openProp,
|
|
29
31
|
setOpen: setOpenProp,
|
|
30
32
|
...rest
|
|
31
33
|
} = props;
|
|
32
34
|
const labelId = React.useId();
|
|
33
35
|
const sectionLabelledBy = props["aria-label"] ? void 0 : label ? labelId : void 0;
|
|
34
|
-
|
|
35
|
-
console.warn(
|
|
36
|
-
"`items` prop of `ErrorRegion.Root` expects an array of React nodes. `ReactNode` support is deprecated and will be removed in a future release."
|
|
37
|
-
);
|
|
38
|
-
DEV: if (!props["aria-label"] && !props["aria-labelledby"])
|
|
39
|
-
console.warn(
|
|
40
|
-
"`aria-label` or `aria-labelledby` prop is required for `ErrorRegion.Root` to set an accessible name of a region."
|
|
41
|
-
);
|
|
42
|
-
const visible = Array.isArray(itemsProp) ? itemsProp.length > 0 : !!label;
|
|
36
|
+
const visible = items.length > 0;
|
|
43
37
|
const [open, setOpen] = useControlledState(
|
|
44
38
|
false,
|
|
45
39
|
openProp,
|
|
@@ -136,7 +130,7 @@ const ErrorRegionRoot = forwardRef(
|
|
|
136
130
|
store,
|
|
137
131
|
className: "\u{1F95D}ErrorRegionItems",
|
|
138
132
|
role: "list",
|
|
139
|
-
children:
|
|
133
|
+
children: items
|
|
140
134
|
}
|
|
141
135
|
)
|
|
142
136
|
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Button as AriaButton } from "@ariakit/react/button";
|
|
4
|
+
import * as AriaDisclosure from "@ariakit/react/disclosure";
|
|
5
|
+
import { Focusable } from "@ariakit/react/focusable";
|
|
6
|
+
import { Role } from "@ariakit/react/role";
|
|
7
|
+
import { Text } from "@stratakit/bricks";
|
|
8
|
+
import { Icon } from "@stratakit/foundations";
|
|
9
|
+
import { forwardRef } from "@stratakit/foundations/secret-internals";
|
|
10
|
+
import cx from "classnames";
|
|
11
|
+
import { ChevronDown } from "./~utils.icons.js";
|
|
12
|
+
import { useInit } from "./~utils.useInit.js";
|
|
13
|
+
const NavigationListRoot = forwardRef(
|
|
14
|
+
(props, forwardedRef) => {
|
|
15
|
+
useInit();
|
|
16
|
+
const { items, role = "list", ...rest } = props;
|
|
17
|
+
const itemRole = role === "list" ? "listitem" : void 0;
|
|
18
|
+
const { indented } = React.useContext(NavigationListRootContext);
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
Role,
|
|
21
|
+
{
|
|
22
|
+
...rest,
|
|
23
|
+
role,
|
|
24
|
+
className: cx("\u{1F95D}NavigationListRoot", props.className),
|
|
25
|
+
"data-_sk-indented": indented ? "true" : void 0,
|
|
26
|
+
ref: forwardedRef,
|
|
27
|
+
children: React.Children.map(items, (item) => /* @__PURE__ */ jsx(
|
|
28
|
+
Role,
|
|
29
|
+
{
|
|
30
|
+
role: itemRole,
|
|
31
|
+
className: "\u{1F95D}NavigationListItem",
|
|
32
|
+
"data-_sk-indented": indented ? "true" : void 0,
|
|
33
|
+
children: item
|
|
34
|
+
}
|
|
35
|
+
))
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
DEV: NavigationListRoot.displayName = "NavigationList.Root";
|
|
41
|
+
const NavigationListRootContext = React.createContext({
|
|
42
|
+
indented: false
|
|
43
|
+
});
|
|
44
|
+
const NavigationListItemAction = forwardRef((props, forwardedRef) => {
|
|
45
|
+
return /* @__PURE__ */ jsx(
|
|
46
|
+
Focusable,
|
|
47
|
+
{
|
|
48
|
+
accessibleWhenDisabled: true,
|
|
49
|
+
...props,
|
|
50
|
+
className: cx("\u{1F95D}NavigationListItemAction", props.className),
|
|
51
|
+
ref: forwardedRef
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
DEV: NavigationListItemAction.displayName = "NavigationListItemAction";
|
|
56
|
+
const NavigationListAnchor = forwardRef(
|
|
57
|
+
(props, forwardedRef) => {
|
|
58
|
+
const { active, label, icon, ...rest } = props;
|
|
59
|
+
return /* @__PURE__ */ jsxs(
|
|
60
|
+
NavigationListItemAction,
|
|
61
|
+
{
|
|
62
|
+
...rest,
|
|
63
|
+
render: /* @__PURE__ */ jsx(
|
|
64
|
+
Role.a,
|
|
65
|
+
{
|
|
66
|
+
"aria-current": active ? "true" : void 0,
|
|
67
|
+
render: props.render
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
ref: forwardedRef,
|
|
71
|
+
children: [
|
|
72
|
+
typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon,
|
|
73
|
+
/* @__PURE__ */ jsx(Text, { variant: "body-sm", render: /* @__PURE__ */ jsx("span", {}), children: label })
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
DEV: NavigationListAnchor.displayName = "NavigationList.Anchor";
|
|
80
|
+
const NavigationListSubgroup = forwardRef(
|
|
81
|
+
(props, forwardedRef) => {
|
|
82
|
+
const { label, icon, items, defaultOpen, ...rest } = props;
|
|
83
|
+
return /* @__PURE__ */ jsx(
|
|
84
|
+
Role,
|
|
85
|
+
{
|
|
86
|
+
...rest,
|
|
87
|
+
className: cx("\u{1F95D}NavigationListSubgroup", props.className),
|
|
88
|
+
ref: forwardedRef,
|
|
89
|
+
children: /* @__PURE__ */ jsxs(AriaDisclosure.DisclosureProvider, { defaultOpen, children: [
|
|
90
|
+
/* @__PURE__ */ jsx(
|
|
91
|
+
AriaDisclosure.Disclosure,
|
|
92
|
+
{
|
|
93
|
+
render: /* @__PURE__ */ jsx(NavigationListSubgroupButton, { label, icon })
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
/* @__PURE__ */ jsx(NavigationListRootContext.Provider, { value: { indented: true }, children: /* @__PURE__ */ jsx(
|
|
97
|
+
AriaDisclosure.DisclosureContent,
|
|
98
|
+
{
|
|
99
|
+
render: /* @__PURE__ */ jsx(NavigationListRoot, { items })
|
|
100
|
+
}
|
|
101
|
+
) })
|
|
102
|
+
] })
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
DEV: NavigationListSubgroup.displayName = "NavigationList.Subgroup";
|
|
108
|
+
const NavigationListSubgroupButton = forwardRef((props, forwardedRef) => {
|
|
109
|
+
const { label, icon, ...rest } = props;
|
|
110
|
+
return /* @__PURE__ */ jsxs(
|
|
111
|
+
NavigationListItemAction,
|
|
112
|
+
{
|
|
113
|
+
render: /* @__PURE__ */ jsx(AriaButton, {}),
|
|
114
|
+
...rest,
|
|
115
|
+
className: cx("\u{1F95D}NavigationListSubgroupButton", props.className),
|
|
116
|
+
ref: forwardedRef,
|
|
117
|
+
children: [
|
|
118
|
+
typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon,
|
|
119
|
+
/* @__PURE__ */ jsx(Text, { variant: "body-sm", render: /* @__PURE__ */ jsx("span", {}), children: label }),
|
|
120
|
+
/* @__PURE__ */ jsx(ChevronDown, { className: "\u{1F95D}NavigationListSubgroupChevron" })
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
DEV: NavigationListSubgroupButton.displayName = "NavigationListSubgroupButton";
|
|
126
|
+
export {
|
|
127
|
+
NavigationListAnchor as Anchor,
|
|
128
|
+
NavigationListRoot as Root,
|
|
129
|
+
NavigationListSubgroup as Subgroup
|
|
130
|
+
};
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import cx from "classnames";
|
|
14
14
|
import { createStore, useStore } from "zustand";
|
|
15
15
|
import { combine } from "zustand/middleware";
|
|
16
|
+
import { useInit } from "./~utils.useInit.js";
|
|
16
17
|
function createNavigationRailStore(initialState) {
|
|
17
18
|
return createStore(
|
|
18
19
|
combine(initialState, (set) => ({
|
|
@@ -50,6 +51,7 @@ function useNavigationRailState(selectorFn) {
|
|
|
50
51
|
}
|
|
51
52
|
const NavigationRailRoot = forwardRef(
|
|
52
53
|
(props, forwardedRef) => {
|
|
54
|
+
useInit();
|
|
53
55
|
const { defaultExpanded = false, expanded, setExpanded, ...rest } = props;
|
|
54
56
|
return /* @__PURE__ */ jsx(
|
|
55
57
|
NavigationRailProvider,
|
|
@@ -77,7 +79,7 @@ const NavigationRailRootInner = forwardRef(
|
|
|
77
79
|
);
|
|
78
80
|
}
|
|
79
81
|
);
|
|
80
|
-
DEV: NavigationRailRootInner.displayName = "
|
|
82
|
+
DEV: NavigationRailRootInner.displayName = "NavigationRailRootInner";
|
|
81
83
|
const NavigationRailHeader = forwardRef(
|
|
82
84
|
(props, forwardedRef) => {
|
|
83
85
|
const expanded = useNavigationRailState((state) => state.expanded);
|
|
@@ -159,7 +161,7 @@ const NavigationRailListItem = forwardRef(
|
|
|
159
161
|
);
|
|
160
162
|
}
|
|
161
163
|
);
|
|
162
|
-
DEV: NavigationRailListItem.displayName = "NavigationRail.
|
|
164
|
+
DEV: NavigationRailListItem.displayName = "NavigationRail.ListItem";
|
|
163
165
|
const NavigationRailItemAction = forwardRef((props, forwardedRef) => {
|
|
164
166
|
const expanded = useNavigationRailState((state) => state.expanded);
|
|
165
167
|
const { label, icon, ...rest } = props;
|
|
@@ -188,7 +190,7 @@ const NavigationRailItemAction = forwardRef((props, forwardedRef) => {
|
|
|
188
190
|
}
|
|
189
191
|
return action;
|
|
190
192
|
});
|
|
191
|
-
DEV: NavigationRailItemAction.displayName = "
|
|
193
|
+
DEV: NavigationRailItemAction.displayName = "NavigationRailItemAction";
|
|
192
194
|
const NavigationRailAnchor = forwardRef(
|
|
193
195
|
(props, forwardedRef) => {
|
|
194
196
|
const { label, icon, active, ...rest } = props;
|
|
@@ -197,7 +199,7 @@ const NavigationRailAnchor = forwardRef(
|
|
|
197
199
|
{
|
|
198
200
|
label,
|
|
199
201
|
icon,
|
|
200
|
-
"aria-current": active ? "
|
|
202
|
+
"aria-current": active ? "true" : void 0,
|
|
201
203
|
render: /* @__PURE__ */ jsx(Role.a, { ...rest, ref: forwardedRef })
|
|
202
204
|
}
|
|
203
205
|
);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import * as AkPopover from "@ariakit/react/popover";
|
|
4
|
+
import { PortalContext } from "@ariakit/react/portal";
|
|
5
|
+
import { useStoreState } from "@ariakit/react/store";
|
|
6
|
+
import { Button } from "@stratakit/bricks";
|
|
7
|
+
import {
|
|
8
|
+
forwardRef,
|
|
9
|
+
usePopoverApi
|
|
10
|
+
} from "@stratakit/foundations/secret-internals";
|
|
11
|
+
import cx from "classnames";
|
|
12
|
+
import { useInit } from "./~utils.useInit.js";
|
|
13
|
+
function PopoverProvider(props) {
|
|
14
|
+
const { children, open, setOpen, placement = "bottom-start" } = props;
|
|
15
|
+
return /* @__PURE__ */ jsx(
|
|
16
|
+
AkPopover.PopoverProvider,
|
|
17
|
+
{
|
|
18
|
+
open,
|
|
19
|
+
setOpen,
|
|
20
|
+
placement,
|
|
21
|
+
children
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
DEV: PopoverProvider.displayName = "PopoverProvider";
|
|
26
|
+
const PopoverDisclosure = forwardRef(
|
|
27
|
+
(props, forwardedRef) => {
|
|
28
|
+
const store = AkPopover.usePopoverContext();
|
|
29
|
+
const open = useStoreState(store, "open");
|
|
30
|
+
const defaultId = React.useId();
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
AkPopover.PopoverDisclosure,
|
|
33
|
+
{
|
|
34
|
+
id: defaultId,
|
|
35
|
+
render: /* @__PURE__ */ jsx(Button, {}),
|
|
36
|
+
...props,
|
|
37
|
+
"data-has-popover-open": open || void 0,
|
|
38
|
+
ref: forwardedRef
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
DEV: PopoverDisclosure.displayName = "PopoverDisclosure";
|
|
44
|
+
const PopoverRoot = forwardRef(
|
|
45
|
+
(props, forwardedRef) => {
|
|
46
|
+
const { children, unmountOnHide, ...rest } = props;
|
|
47
|
+
const store = AkPopover.usePopoverContext();
|
|
48
|
+
const popoverElement = useStoreState(store, "popoverElement");
|
|
49
|
+
const open = useStoreState(store, "open");
|
|
50
|
+
const popoverProps = usePopoverApi({
|
|
51
|
+
element: popoverElement,
|
|
52
|
+
open
|
|
53
|
+
});
|
|
54
|
+
const contentElement = useStoreState(store, "contentElement");
|
|
55
|
+
const triggerId = useStoreState(
|
|
56
|
+
store,
|
|
57
|
+
(state) => state?.disclosureElement?.id
|
|
58
|
+
);
|
|
59
|
+
const labelledBy = props["aria-label"] ? void 0 : triggerId;
|
|
60
|
+
return /* @__PURE__ */ jsx(
|
|
61
|
+
AkPopover.Popover,
|
|
62
|
+
{
|
|
63
|
+
"aria-labelledby": labelledBy,
|
|
64
|
+
portal: true,
|
|
65
|
+
unmountOnHide,
|
|
66
|
+
...rest,
|
|
67
|
+
gutter: 8,
|
|
68
|
+
style: { ...popoverProps.style, ...props.style },
|
|
69
|
+
wrapperProps: { popover: popoverProps.popover },
|
|
70
|
+
className: cx("\u{1F95D}Popover", props.className),
|
|
71
|
+
ref: forwardedRef,
|
|
72
|
+
children: /* @__PURE__ */ jsx(PortalContext.Provider, { value: contentElement ?? null, children })
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
DEV: PopoverRoot.displayName = "PopoverRoot";
|
|
78
|
+
const Popover = forwardRef((props, forwardedRef) => {
|
|
79
|
+
useInit();
|
|
80
|
+
const { children, content, open, setOpen, placement, ...rest } = props;
|
|
81
|
+
return /* @__PURE__ */ jsxs(PopoverProvider, { open, setOpen, placement, children: [
|
|
82
|
+
/* @__PURE__ */ jsx(PopoverDisclosure, { render: children }),
|
|
83
|
+
/* @__PURE__ */ jsx(PopoverRoot, { ...rest, ref: forwardedRef, children: content })
|
|
84
|
+
] });
|
|
85
|
+
});
|
|
86
|
+
DEV: Popover.displayName = "Popover";
|
|
87
|
+
var Popover_default = Popover;
|
|
88
|
+
export {
|
|
89
|
+
Popover_default as default
|
|
90
|
+
};
|
package/dist/DEV/Table.js
CHANGED
|
@@ -7,9 +7,11 @@ import {
|
|
|
7
7
|
useSafeContext
|
|
8
8
|
} from "@stratakit/foundations/secret-internals";
|
|
9
9
|
import cx from "classnames";
|
|
10
|
+
import { useInit } from "./~utils.useInit.js";
|
|
10
11
|
const TableContext = React.createContext(void 0);
|
|
11
12
|
const TableHeaderContext = React.createContext(false);
|
|
12
13
|
const HtmlTable = forwardRef((props, forwardedRef) => {
|
|
14
|
+
useInit();
|
|
13
15
|
const tableContextValue = React.useMemo(
|
|
14
16
|
() => ({ mode: "html" }),
|
|
15
17
|
[]
|
|
@@ -27,6 +29,7 @@ const HtmlTable = forwardRef((props, forwardedRef) => {
|
|
|
27
29
|
DEV: HtmlTable.displayName = "Table.HtmlTable";
|
|
28
30
|
const CustomTable = forwardRef(
|
|
29
31
|
(props, forwardedRef) => {
|
|
32
|
+
useInit();
|
|
30
33
|
const [captionId, setCaptionId] = React.useState();
|
|
31
34
|
const tableContextValue = React.useMemo(
|
|
32
35
|
() => ({ captionId, setCaptionId, mode: "aria" }),
|
package/dist/DEV/Tabs.js
CHANGED
|
@@ -7,9 +7,11 @@ import {
|
|
|
7
7
|
useUnreactiveCallback
|
|
8
8
|
} from "@stratakit/foundations/secret-internals";
|
|
9
9
|
import cx from "classnames";
|
|
10
|
-
|
|
10
|
+
import { useInit } from "./~utils.useInit.js";
|
|
11
|
+
const supportsAnchorPositioning = isBrowser && CSS?.supports?.("anchor-name: --foo");
|
|
11
12
|
const prefersReducedMotion = () => isBrowser && window.matchMedia("(prefers-reduced-motion)").matches;
|
|
12
13
|
function TabsProvider(props) {
|
|
14
|
+
useInit();
|
|
13
15
|
const {
|
|
14
16
|
defaultSelectedId,
|
|
15
17
|
selectedId,
|
package/dist/DEV/Toolbar.js
CHANGED
|
@@ -7,8 +7,10 @@ import {
|
|
|
7
7
|
} from "@stratakit/bricks/secret-internals";
|
|
8
8
|
import { forwardRef } from "@stratakit/foundations/secret-internals";
|
|
9
9
|
import cx from "classnames";
|
|
10
|
+
import { useInit } from "./~utils.useInit.js";
|
|
10
11
|
const ToolbarGroup = forwardRef(
|
|
11
12
|
(props, forwardedRef) => {
|
|
13
|
+
useInit();
|
|
12
14
|
return /* @__PURE__ */ jsx(
|
|
13
15
|
IconButtonContext.Provider,
|
|
14
16
|
{
|
package/dist/DEV/Tree.js
CHANGED
|
@@ -3,8 +3,10 @@ import { Composite, useCompositeStore } from "@ariakit/react/composite";
|
|
|
3
3
|
import { Role } from "@ariakit/react/role";
|
|
4
4
|
import { forwardRef } from "@stratakit/foundations/secret-internals";
|
|
5
5
|
import cx from "classnames";
|
|
6
|
+
import { useInit } from "./~utils.useInit.js";
|
|
6
7
|
import { Action as TreeItemAction, Root as TreeItemRoot } from "./TreeItem.js";
|
|
7
8
|
const Tree = forwardRef((props, forwardedRef) => {
|
|
9
|
+
useInit();
|
|
8
10
|
const composite = useCompositeStore({ orientation: "vertical" });
|
|
9
11
|
return /* @__PURE__ */ jsx(
|
|
10
12
|
Role.div,
|
package/dist/DEV/TreeItem.js
CHANGED
|
@@ -56,9 +56,14 @@ const TreeItem = React.memo(
|
|
|
56
56
|
onExpandedChange?.(!expanded);
|
|
57
57
|
});
|
|
58
58
|
const handleClick = (event) => {
|
|
59
|
-
if (selected
|
|
59
|
+
if (selected !== void 0) {
|
|
60
|
+
event.stopPropagation();
|
|
61
|
+
onSelectedChange?.(!selected);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (expanded === void 0) return;
|
|
60
65
|
event.stopPropagation();
|
|
61
|
-
|
|
66
|
+
onExpandedChange?.(!expanded);
|
|
62
67
|
};
|
|
63
68
|
const handleKeyDown = (event) => {
|
|
64
69
|
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {
|
package/dist/DEV/index.js
CHANGED
|
@@ -5,7 +5,9 @@ import { default as default3 } from "./Chip.js";
|
|
|
5
5
|
import * as unstable_Dialog from "./Dialog.js";
|
|
6
6
|
import * as DropdownMenu from "./DropdownMenu.js";
|
|
7
7
|
import * as unstable_ErrorRegion from "./ErrorRegion.js";
|
|
8
|
+
import * as unstable_NavigationList from "./NavigationList.js";
|
|
8
9
|
import * as unstable_NavigationRail from "./NavigationRail.js";
|
|
10
|
+
import { default as default4 } from "./Popover.js";
|
|
9
11
|
import * as Table from "./Table.js";
|
|
10
12
|
import * as Tabs from "./Tabs.js";
|
|
11
13
|
import * as unstable_Toolbar from "./Toolbar.js";
|
|
@@ -20,6 +22,8 @@ export {
|
|
|
20
22
|
default2 as unstable_Banner,
|
|
21
23
|
unstable_Dialog,
|
|
22
24
|
unstable_ErrorRegion,
|
|
25
|
+
unstable_NavigationList,
|
|
23
26
|
unstable_NavigationRail,
|
|
27
|
+
default4 as unstable_Popover,
|
|
24
28
|
unstable_Toolbar
|
|
25
29
|
};
|