@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/ErrorRegion.js
CHANGED
|
@@ -1,168 +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
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const el = containerRef.current;
|
|
43
|
-
if (!el) return;
|
|
44
|
-
const id = "--\u{1F95D}ErrorRegion-pulse";
|
|
45
|
-
const animations = el.getAnimations({ subtree: true });
|
|
46
|
-
if (animations.find((animation) => animation.id === id)) return;
|
|
47
|
-
el.animate(
|
|
48
|
-
[
|
|
49
|
-
{
|
|
50
|
-
boxShadow: "0 0 0 0 var(--stratakit-color-border-attention-base)",
|
|
51
|
-
opacity: 1
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
boxShadow: "0 0 15px 2px var(--stratakit-color-border-attention-base)",
|
|
55
|
-
opacity: 0.7,
|
|
56
|
-
offset: 0.5
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
boxShadow: "0 0 0 0 var(--stratakit-color-border-attention-base)",
|
|
60
|
-
opacity: 1
|
|
61
|
-
}
|
|
62
|
-
],
|
|
63
|
-
{
|
|
64
|
-
id,
|
|
65
|
-
duration: 600,
|
|
66
|
-
easing: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
67
|
-
pseudoElement: "::before"
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
};
|
|
71
|
-
const store = useCollectionStore({
|
|
72
|
-
setItems: (newItems) => {
|
|
73
|
-
const prevItemsSet = new Set(prevItems.map((item) => item.id));
|
|
74
|
-
const addedItems = newItems.filter(
|
|
75
|
-
(item) => !prevItemsSet.has(item.id)
|
|
76
|
-
);
|
|
77
|
-
if (addedItems.length === 0) return;
|
|
78
|
-
pulse();
|
|
79
|
-
setLiveLabel(label);
|
|
80
|
-
}
|
|
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
|
|
81
31
|
});
|
|
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
|
-
|
|
121
|
-
portal: false,
|
|
122
|
-
modal: false,
|
|
123
|
-
autoFocusOnShow: false,
|
|
124
|
-
"aria-labelledby": labelId,
|
|
125
|
-
children: /* @__PURE__ */ jsx(
|
|
126
|
-
Collection,
|
|
127
|
-
{
|
|
128
|
-
store,
|
|
129
|
-
className: "\u{1F95D}ErrorRegionItems",
|
|
130
|
-
role: "list",
|
|
131
|
-
children: itemsProp
|
|
132
|
-
}
|
|
133
|
-
)
|
|
134
|
-
}
|
|
135
|
-
)
|
|
136
|
-
] })
|
|
137
|
-
}
|
|
138
|
-
) })
|
|
139
|
-
] });
|
|
140
|
-
}
|
|
141
|
-
);
|
|
142
|
-
const ErrorRegionItem = forwardRef(
|
|
143
|
-
(props, forwardedRef) => {
|
|
144
|
-
const generatedId = React.useId();
|
|
145
|
-
const {
|
|
146
|
-
message,
|
|
147
|
-
messageId = `${generatedId}-message`,
|
|
148
|
-
actions,
|
|
149
|
-
...rest
|
|
150
|
-
} = props;
|
|
151
|
-
return /* @__PURE__ */ jsxs(
|
|
152
|
-
CollectionItem,
|
|
153
|
-
{
|
|
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,
|
|
154
71
|
...rest,
|
|
155
|
-
|
|
156
|
-
|
|
72
|
+
className: cx("\u{1F95D}ErrorRegion", props.className),
|
|
73
|
+
"data-_sk-visible": visible,
|
|
74
|
+
"data-_sk-expanded": open,
|
|
157
75
|
ref: forwardedRef,
|
|
158
|
-
children:
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
)
|
|
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
|
+
});
|
|
166
139
|
export {
|
|
167
140
|
ErrorRegionItem as Item,
|
|
168
141
|
ErrorRegionRoot as Root
|