@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/ErrorRegion.js
CHANGED
|
@@ -1,167 +1,141 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
CollectionItem,
|
|
6
|
-
useCollectionStore
|
|
7
|
-
} from "@ariakit/react/collection";
|
|
8
|
-
import {
|
|
9
|
-
Dialog,
|
|
10
|
-
DialogDisclosure,
|
|
11
|
-
DialogProvider
|
|
12
|
-
} from "@ariakit/react/dialog";
|
|
3
|
+
import { Collection, CollectionItem, useCollectionStore } from "@ariakit/react/collection";
|
|
4
|
+
import { Dialog, DialogDisclosure, DialogProvider } from "@ariakit/react/dialog";
|
|
13
5
|
import { Role } from "@ariakit/react/role";
|
|
14
6
|
import { useStoreState } from "@ariakit/react/store";
|
|
15
7
|
import { Button, Text, VisuallyHidden } from "@stratakit/bricks";
|
|
16
8
|
import { IconButtonPresentation } from "@stratakit/bricks/secret-internals";
|
|
17
|
-
import {
|
|
18
|
-
forwardRef,
|
|
19
|
-
useControlledState
|
|
20
|
-
} from "@stratakit/foundations/secret-internals";
|
|
9
|
+
import { forwardRef, useControlledState } from "@stratakit/foundations/secret-internals";
|
|
21
10
|
import cx from "classnames";
|
|
22
11
|
import { ChevronDown, StatusIcon } from "./~utils.icons.js";
|
|
23
|
-
const ErrorRegionRoot = forwardRef(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
);
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
if (!el) return;
|
|
43
|
-
const id = "--\u{1F95D}ErrorRegion-pulse";
|
|
44
|
-
const animations = el.getAnimations({ subtree: true });
|
|
45
|
-
if (animations.find((animation) => animation.id === id)) return;
|
|
46
|
-
el.animate(
|
|
47
|
-
[
|
|
48
|
-
{
|
|
49
|
-
boxShadow: "0 0 0 0 var(--stratakit-color-border-attention-base)",
|
|
50
|
-
opacity: 1
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
boxShadow: "0 0 15px 2px var(--stratakit-color-border-attention-base)",
|
|
54
|
-
opacity: 0.7,
|
|
55
|
-
offset: 0.5
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
boxShadow: "0 0 0 0 var(--stratakit-color-border-attention-base)",
|
|
59
|
-
opacity: 1
|
|
60
|
-
}
|
|
61
|
-
],
|
|
62
|
-
{
|
|
63
|
-
id,
|
|
64
|
-
duration: 600,
|
|
65
|
-
easing: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
66
|
-
pseudoElement: "::before"
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
const store = useCollectionStore({
|
|
71
|
-
setItems: (newItems) => {
|
|
72
|
-
const prevItemsSet = new Set(prevItems.map((item) => item.id));
|
|
73
|
-
const addedItems = newItems.filter(
|
|
74
|
-
(item) => !prevItemsSet.has(item.id)
|
|
75
|
-
);
|
|
76
|
-
if (addedItems.length === 0) return;
|
|
77
|
-
pulse();
|
|
78
|
-
setLiveLabel(label);
|
|
79
|
-
}
|
|
12
|
+
const ErrorRegionRoot = forwardRef((props, forwardedRef) => {
|
|
13
|
+
const {
|
|
14
|
+
label,
|
|
15
|
+
items = [],
|
|
16
|
+
open: openProp,
|
|
17
|
+
setOpen: setOpenProp,
|
|
18
|
+
...rest
|
|
19
|
+
} = props;
|
|
20
|
+
const labelId = React.useId();
|
|
21
|
+
const sectionLabelledBy = props["aria-label"] ? void 0 : label ? labelId : void 0;
|
|
22
|
+
const visible = items.length > 0;
|
|
23
|
+
const [open, setOpen] = useControlledState(false, openProp, setOpenProp);
|
|
24
|
+
const containerRef = React.useRef(null);
|
|
25
|
+
const pulse = () => {
|
|
26
|
+
const el = containerRef.current;
|
|
27
|
+
if (!el) return;
|
|
28
|
+
const id = "--\u{1F95D}ErrorRegion-pulse";
|
|
29
|
+
const animations = el.getAnimations({
|
|
30
|
+
subtree: true
|
|
80
31
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
portal: false,
|
|
121
|
-
modal: false,
|
|
122
|
-
autoFocusOnShow: false,
|
|
123
|
-
"aria-labelledby": labelId,
|
|
124
|
-
children: /* @__PURE__ */ jsx(
|
|
125
|
-
Collection,
|
|
126
|
-
{
|
|
127
|
-
store,
|
|
128
|
-
className: "\u{1F95D}ErrorRegionItems",
|
|
129
|
-
role: "list",
|
|
130
|
-
children: items
|
|
131
|
-
}
|
|
132
|
-
)
|
|
133
|
-
}
|
|
134
|
-
)
|
|
135
|
-
] })
|
|
136
|
-
}
|
|
137
|
-
) })
|
|
138
|
-
] });
|
|
139
|
-
}
|
|
140
|
-
);
|
|
141
|
-
const ErrorRegionItem = forwardRef(
|
|
142
|
-
(props, forwardedRef) => {
|
|
143
|
-
const generatedId = React.useId();
|
|
144
|
-
const {
|
|
145
|
-
message,
|
|
146
|
-
messageId = `${generatedId}-message`,
|
|
147
|
-
actions,
|
|
148
|
-
...rest
|
|
149
|
-
} = props;
|
|
150
|
-
return /* @__PURE__ */ jsxs(
|
|
151
|
-
CollectionItem,
|
|
152
|
-
{
|
|
32
|
+
if (animations.find((animation) => animation.id === id)) return;
|
|
33
|
+
el.animate([{
|
|
34
|
+
boxShadow: "0 0 0 0 var(--stratakit-color-border-attention-base)",
|
|
35
|
+
opacity: 1
|
|
36
|
+
}, {
|
|
37
|
+
boxShadow: "0 0 15px 2px var(--stratakit-color-border-attention-base)",
|
|
38
|
+
opacity: 0.7,
|
|
39
|
+
offset: 0.5
|
|
40
|
+
}, {
|
|
41
|
+
boxShadow: "0 0 0 0 var(--stratakit-color-border-attention-base)",
|
|
42
|
+
opacity: 1
|
|
43
|
+
}], {
|
|
44
|
+
id,
|
|
45
|
+
duration: 600,
|
|
46
|
+
easing: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
47
|
+
pseudoElement: "::before"
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
const store = useCollectionStore({
|
|
51
|
+
setItems: (newItems) => {
|
|
52
|
+
const prevItemsSet = new Set(prevItems.map((item) => item.id));
|
|
53
|
+
const addedItems = newItems.filter((item_0) => !prevItemsSet.has(item_0.id));
|
|
54
|
+
if (addedItems.length === 0) return;
|
|
55
|
+
pulse();
|
|
56
|
+
setLiveLabel(label);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const prevItems = useStoreState(store, "items");
|
|
60
|
+
const [liveLabel, setLiveLabel] = React.useState(label);
|
|
61
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
62
|
+
children: [/* @__PURE__ */ jsx(VisuallyHidden, {
|
|
63
|
+
"aria-live": "polite",
|
|
64
|
+
"aria-atomic": true,
|
|
65
|
+
children: liveLabel === label ? liveLabel : void 0
|
|
66
|
+
}), /* @__PURE__ */ jsx(DialogProvider, {
|
|
67
|
+
open,
|
|
68
|
+
setOpen,
|
|
69
|
+
children: /* @__PURE__ */ jsx(Role.section, {
|
|
70
|
+
"aria-labelledby": sectionLabelledBy,
|
|
153
71
|
...rest,
|
|
154
|
-
|
|
155
|
-
|
|
72
|
+
className: cx("\u{1F95D}ErrorRegion", props.className),
|
|
73
|
+
"data-_sk-visible": visible,
|
|
74
|
+
"data-_sk-expanded": open,
|
|
156
75
|
ref: forwardedRef,
|
|
157
|
-
children:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
)
|
|
76
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
77
|
+
className: "\u{1F95D}ErrorRegionContainer",
|
|
78
|
+
ref: containerRef,
|
|
79
|
+
children: [/* @__PURE__ */ jsxs(DialogDisclosure, {
|
|
80
|
+
className: "\u{1F95D}ErrorRegionHeader",
|
|
81
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
82
|
+
variant: "ghost"
|
|
83
|
+
}),
|
|
84
|
+
children: [/* @__PURE__ */ jsx(StatusIcon, {
|
|
85
|
+
tone: "attention",
|
|
86
|
+
className: "\u{1F95D}ErrorRegionIcon"
|
|
87
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
88
|
+
render: /* @__PURE__ */ jsx("span", {}),
|
|
89
|
+
id: labelId,
|
|
90
|
+
className: "\u{1F95D}ErrorRegionLabel",
|
|
91
|
+
variant: "body-sm",
|
|
92
|
+
children: label
|
|
93
|
+
}), /* @__PURE__ */ jsx(IconButtonPresentation, {
|
|
94
|
+
inert: true,
|
|
95
|
+
variant: "ghost",
|
|
96
|
+
children: /* @__PURE__ */ jsx(ChevronDown, {})
|
|
97
|
+
})]
|
|
98
|
+
}), /* @__PURE__ */ jsx(Dialog, {
|
|
99
|
+
className: "\u{1F95D}ErrorRegionDialog",
|
|
100
|
+
portal: false,
|
|
101
|
+
modal: false,
|
|
102
|
+
autoFocusOnShow: false,
|
|
103
|
+
"aria-labelledby": labelId,
|
|
104
|
+
children: /* @__PURE__ */ jsx(Collection, {
|
|
105
|
+
store,
|
|
106
|
+
className: "\u{1F95D}ErrorRegionItems",
|
|
107
|
+
role: "list",
|
|
108
|
+
children: items
|
|
109
|
+
})
|
|
110
|
+
})]
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
})]
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
const ErrorRegionItem = forwardRef((props, forwardedRef) => {
|
|
117
|
+
const generatedId = React.useId();
|
|
118
|
+
const {
|
|
119
|
+
message,
|
|
120
|
+
messageId = `${generatedId}-message`,
|
|
121
|
+
actions,
|
|
122
|
+
...rest
|
|
123
|
+
} = props;
|
|
124
|
+
return /* @__PURE__ */ jsxs(CollectionItem, {
|
|
125
|
+
...rest,
|
|
126
|
+
role: "listitem",
|
|
127
|
+
className: cx("\u{1F95D}ErrorRegionItem", props.className),
|
|
128
|
+
ref: forwardedRef,
|
|
129
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
130
|
+
id: messageId,
|
|
131
|
+
variant: "body-sm",
|
|
132
|
+
children: message
|
|
133
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
134
|
+
className: "\u{1F95D}ErrorRegionItemActions",
|
|
135
|
+
children: actions
|
|
136
|
+
})]
|
|
137
|
+
});
|
|
138
|
+
});
|
|
165
139
|
export {
|
|
166
140
|
ErrorRegionItem as Item,
|
|
167
141
|
ErrorRegionRoot as Root
|
package/dist/NavigationRail.d.ts
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { BaseProps, FocusableProps } from "@stratakit/foundations/secret-internals";
|
|
3
|
-
interface
|
|
3
|
+
interface NavigationRailRootInnerProps extends BaseProps<"nav"> {
|
|
4
|
+
}
|
|
5
|
+
interface NavigationRailRootProps extends NavigationRailRootInnerProps {
|
|
6
|
+
/**
|
|
7
|
+
* The initial expanded state of the `NavigationRail` when it is first rendered.
|
|
8
|
+
*
|
|
9
|
+
* This prop is recommended over `expanded` when you don't need to fully control the expanded
|
|
10
|
+
* state from the outside.
|
|
11
|
+
*
|
|
12
|
+
* This prop will be ignored if the `expanded` prop is provided.
|
|
13
|
+
*
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
defaultExpanded?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Control whether the `NavigationRail` is expanded or collapsed.
|
|
19
|
+
*
|
|
20
|
+
* When `true`, the `NavigationRail` shows both icons and labels for its items.
|
|
21
|
+
* When `false`, it shows only icons, with labels available as tooltips.
|
|
22
|
+
*
|
|
23
|
+
* This prop is optional; if not provided, the `NavigationRail` will manage its own state internally.
|
|
24
|
+
*
|
|
25
|
+
* This should be used in conjunction with the `setExpanded` prop to reflect internal state changes.
|
|
26
|
+
*/
|
|
27
|
+
expanded?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Callback that is called when the expanded state of the `NavigationRail` changes.
|
|
30
|
+
*
|
|
31
|
+
* This is useful for syncing the internal state of the `NavigationRail` with external state.
|
|
32
|
+
*/
|
|
33
|
+
setExpanded?: (expanded: boolean) => void;
|
|
4
34
|
}
|
|
5
35
|
/**
|
|
6
36
|
* The `NavigationRail` presents top-level navigation items in a vertical orientation.
|
|
@@ -43,7 +73,7 @@ interface NavigationRailProps extends BaseProps<"nav"> {
|
|
|
43
73
|
* </NavigationRail.Root>
|
|
44
74
|
* ```
|
|
45
75
|
*/
|
|
46
|
-
declare const NavigationRailRoot: React.ForwardRefExoticComponent<
|
|
76
|
+
declare const NavigationRailRoot: React.ForwardRefExoticComponent<NavigationRailRootProps & React.RefAttributes<HTMLElement>>;
|
|
47
77
|
interface NavigationRailHeaderProps extends BaseProps<"header"> {
|
|
48
78
|
}
|
|
49
79
|
/**
|
|
@@ -64,8 +94,11 @@ interface NavigationRailToggleButtonProps extends Omit<FocusableProps<"button">,
|
|
|
64
94
|
label?: string;
|
|
65
95
|
}
|
|
66
96
|
/**
|
|
67
|
-
* `NavigationRail.ToggleButton` toggles the collapsed state of the `NavigationRail`.
|
|
97
|
+
* `NavigationRail.ToggleButton` toggles the expanded/collapsed state of the `NavigationRail`.
|
|
68
98
|
* It is typically placed inside `NavigationRail.Header`, next to the logo.
|
|
99
|
+
*
|
|
100
|
+
* When this button is clicked, it toggles the internal expanded state of the `NavigationRail`,
|
|
101
|
+
* and also calls the `setExpanded` callback prop if provided, to allow syncing with external state.
|
|
69
102
|
*/
|
|
70
103
|
declare const NavigationRailToggleButton: React.ForwardRefExoticComponent<NavigationRailToggleButtonProps & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
|
|
71
104
|
interface NavigationRailContentProps extends BaseProps {
|