@stratakit/structures 0.1.0 → 0.2.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 +51 -0
- package/dist/AccordionItem.d.ts +202 -0
- package/dist/AccordionItem.js +140 -0
- package/dist/Banner.d.ts +81 -0
- package/dist/Banner.js +71 -0
- package/dist/Chip.d.ts +35 -0
- package/dist/Chip.js +41 -0
- package/dist/DEV/AccordionItem.js +148 -0
- package/dist/DEV/Banner.js +72 -0
- package/dist/DEV/Chip.js +42 -0
- package/dist/DEV/DropdownMenu.js +235 -0
- package/dist/DEV/ErrorRegion.js +170 -0
- package/dist/DEV/Table.js +151 -0
- package/dist/DEV/Tabs.js +66 -0
- package/dist/DEV/Toolbar.js +27 -0
- package/dist/DEV/Tree.js +26 -0
- package/dist/DEV/TreeItem.js +395 -0
- package/dist/DEV/index.js +21 -0
- package/dist/DEV/styles.css.js +1 -1
- package/dist/DEV/~utils.ListItem.js +49 -0
- package/dist/DEV/~utils.icons.js +61 -0
- package/dist/DropdownMenu.d.ts +113 -0
- package/dist/DropdownMenu.js +228 -0
- package/dist/ErrorRegion.d.ts +83 -0
- package/dist/ErrorRegion.js +168 -0
- package/dist/Table.d.ts +172 -0
- package/dist/Table.js +144 -0
- package/dist/Tabs.d.ts +81 -0
- package/dist/Tabs.js +62 -0
- package/dist/Toolbar.d.ts +36 -0
- package/dist/Toolbar.js +25 -0
- package/dist/Tree.d.ts +22 -0
- package/dist/Tree.js +25 -0
- package/dist/TreeItem.d.ts +183 -0
- package/dist/TreeItem.js +370 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +21 -0
- package/dist/styles.css.js +1 -1
- package/dist/~utils.ListItem.d.ts +14 -0
- package/dist/~utils.ListItem.js +46 -0
- package/dist/~utils.icons.d.ts +10 -0
- package/dist/~utils.icons.js +56 -0
- package/package.json +8 -8
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
Disclosure,
|
|
4
|
+
DisclosureContent,
|
|
5
|
+
DisclosureProvider
|
|
6
|
+
} from "@ariakit/react/disclosure";
|
|
7
|
+
import { Role } from "@ariakit/react/role";
|
|
8
|
+
import { Text } from "@stratakit/bricks";
|
|
9
|
+
import {
|
|
10
|
+
GhostAligner,
|
|
11
|
+
IconButtonPresentation
|
|
12
|
+
} from "@stratakit/bricks/secret-internals";
|
|
13
|
+
import {
|
|
14
|
+
forwardRef,
|
|
15
|
+
useControlledState
|
|
16
|
+
} from "@stratakit/foundations/secret-internals";
|
|
17
|
+
import cx from "classnames";
|
|
18
|
+
import { ChevronDown } from "./~utils.icons.js";
|
|
19
|
+
const AccordionItemRoot = forwardRef(
|
|
20
|
+
(props, forwardedRef) => {
|
|
21
|
+
const {
|
|
22
|
+
defaultOpen,
|
|
23
|
+
open: openProp,
|
|
24
|
+
setOpen: setOpenProp,
|
|
25
|
+
...rest
|
|
26
|
+
} = props;
|
|
27
|
+
const [open, setOpen] = useControlledState(
|
|
28
|
+
defaultOpen ?? false,
|
|
29
|
+
openProp,
|
|
30
|
+
setOpenProp
|
|
31
|
+
);
|
|
32
|
+
return /* @__PURE__ */ jsx(
|
|
33
|
+
DisclosureProvider,
|
|
34
|
+
{
|
|
35
|
+
defaultOpen,
|
|
36
|
+
open,
|
|
37
|
+
setOpen,
|
|
38
|
+
children: /* @__PURE__ */ jsx(
|
|
39
|
+
Role,
|
|
40
|
+
{
|
|
41
|
+
...rest,
|
|
42
|
+
className: cx("\u{1F95D}-accordion-item", props.className),
|
|
43
|
+
"data-kiwi-open": open,
|
|
44
|
+
ref: forwardedRef
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
DEV: AccordionItemRoot.displayName = "AccordionItem.Root";
|
|
52
|
+
const AccordionItemHeader = forwardRef(
|
|
53
|
+
(props, forwardedRef) => /* @__PURE__ */ jsx(GhostAligner, { align: "block", children: /* @__PURE__ */ jsx(
|
|
54
|
+
Role,
|
|
55
|
+
{
|
|
56
|
+
...props,
|
|
57
|
+
className: cx("\u{1F95D}-accordion-item-header", props.className),
|
|
58
|
+
ref: forwardedRef
|
|
59
|
+
}
|
|
60
|
+
) })
|
|
61
|
+
);
|
|
62
|
+
DEV: AccordionItemHeader.displayName = "AccordionItem.Header";
|
|
63
|
+
const AccordionItemButton = forwardRef(
|
|
64
|
+
(props, forwardedRef) => /* @__PURE__ */ jsx(
|
|
65
|
+
Disclosure,
|
|
66
|
+
{
|
|
67
|
+
...props,
|
|
68
|
+
className: cx("\u{1F95D}-accordion-item-button", props.className),
|
|
69
|
+
ref: forwardedRef
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
DEV: AccordionItemButton.displayName = "AccordionItem.Button";
|
|
74
|
+
const AccordionItemLabel = forwardRef(
|
|
75
|
+
(props, forwardedRef) => /* @__PURE__ */ jsx(
|
|
76
|
+
Text,
|
|
77
|
+
{
|
|
78
|
+
...props,
|
|
79
|
+
variant: "body-sm",
|
|
80
|
+
className: cx("\u{1F95D}-accordion-item-label", props.className),
|
|
81
|
+
ref: forwardedRef
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
DEV: AccordionItemLabel.displayName = "AccordionItem.Label";
|
|
86
|
+
const AccordionItemDecoration = forwardRef(
|
|
87
|
+
(props, forwardedRef) => /* @__PURE__ */ jsx(
|
|
88
|
+
Role,
|
|
89
|
+
{
|
|
90
|
+
...props,
|
|
91
|
+
className: cx("\u{1F95D}-accordion-item-decoration", props.className),
|
|
92
|
+
ref: forwardedRef
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
);
|
|
96
|
+
DEV: AccordionItemDecoration.displayName = "AccordionItem.Decoration";
|
|
97
|
+
const AccordionItemMarker = forwardRef(
|
|
98
|
+
(props, forwardedRef) => /* @__PURE__ */ jsx(
|
|
99
|
+
IconButtonPresentation,
|
|
100
|
+
{
|
|
101
|
+
...props,
|
|
102
|
+
variant: "ghost",
|
|
103
|
+
className: cx("\u{1F95D}-accordion-item-marker", props.className),
|
|
104
|
+
ref: forwardedRef,
|
|
105
|
+
children: props.children ?? /* @__PURE__ */ jsx(
|
|
106
|
+
ChevronDown,
|
|
107
|
+
{
|
|
108
|
+
"aria-hidden": "true",
|
|
109
|
+
className: "\u{1F95D}-accordion-item-marker-chevron"
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
);
|
|
115
|
+
DEV: AccordionItemMarker.displayName = "AccordionItem.Marker";
|
|
116
|
+
const AccordionItemContent = forwardRef(
|
|
117
|
+
(props, forwardedRef) => /* @__PURE__ */ jsx(
|
|
118
|
+
DisclosureContent,
|
|
119
|
+
{
|
|
120
|
+
...props,
|
|
121
|
+
className: cx("\u{1F95D}-accordion-item-content", props.className),
|
|
122
|
+
ref: forwardedRef
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
);
|
|
126
|
+
DEV: AccordionItemContent.displayName = "AccordionItem.Content";
|
|
127
|
+
const AccordionItemHeading = forwardRef(
|
|
128
|
+
(props, forwardedRef) => /* @__PURE__ */ jsx(
|
|
129
|
+
Text,
|
|
130
|
+
{
|
|
131
|
+
...props,
|
|
132
|
+
variant: "body-sm",
|
|
133
|
+
className: cx("\u{1F95D}-accordion-item-heading", props.className),
|
|
134
|
+
ref: forwardedRef
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
);
|
|
138
|
+
DEV: AccordionItemHeading.displayName = "AccordionItem.Heading";
|
|
139
|
+
export {
|
|
140
|
+
AccordionItemButton as Button,
|
|
141
|
+
AccordionItemContent as Content,
|
|
142
|
+
AccordionItemDecoration as Decoration,
|
|
143
|
+
AccordionItemHeader as Header,
|
|
144
|
+
AccordionItemHeading as Heading,
|
|
145
|
+
AccordionItemLabel as Label,
|
|
146
|
+
AccordionItemMarker as Marker,
|
|
147
|
+
AccordionItemRoot as Root
|
|
148
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Role } from "@ariakit/react/role";
|
|
3
|
+
import { IconButton, Text } from "@stratakit/bricks";
|
|
4
|
+
import { GhostAligner } from "@stratakit/bricks/secret-internals";
|
|
5
|
+
import { Icon } from "@stratakit/foundations";
|
|
6
|
+
import { forwardRef } from "@stratakit/foundations/secret-internals";
|
|
7
|
+
import cx from "classnames";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { Dismiss, StatusIcon } from "./~utils.icons.js";
|
|
10
|
+
const Banner = forwardRef((props, forwardedRef) => {
|
|
11
|
+
const {
|
|
12
|
+
message,
|
|
13
|
+
label,
|
|
14
|
+
actions,
|
|
15
|
+
onDismiss,
|
|
16
|
+
tone = "neutral",
|
|
17
|
+
icon = tone !== "neutral" ? /* @__PURE__ */ jsx(StatusIcon, { tone }) : void 0,
|
|
18
|
+
variant = "outline",
|
|
19
|
+
...rest
|
|
20
|
+
} = props;
|
|
21
|
+
const baseId = React.useId();
|
|
22
|
+
const labelId = `${baseId}-label`;
|
|
23
|
+
const dismissId = `${baseId}-dismiss`;
|
|
24
|
+
return /* @__PURE__ */ jsxs(
|
|
25
|
+
Role,
|
|
26
|
+
{
|
|
27
|
+
...rest,
|
|
28
|
+
"data-kiwi-tone": tone,
|
|
29
|
+
"data-kiwi-variant": variant,
|
|
30
|
+
className: cx("\u{1F95D}-banner", props.className),
|
|
31
|
+
ref: forwardedRef,
|
|
32
|
+
children: [
|
|
33
|
+
icon ? /* @__PURE__ */ jsx(
|
|
34
|
+
Icon,
|
|
35
|
+
{
|
|
36
|
+
className: "\u{1F95D}-banner-icon",
|
|
37
|
+
href: typeof icon === "string" ? icon : void 0,
|
|
38
|
+
render: React.isValidElement(icon) ? icon : void 0
|
|
39
|
+
}
|
|
40
|
+
) : null,
|
|
41
|
+
/* @__PURE__ */ jsx(
|
|
42
|
+
Text,
|
|
43
|
+
{
|
|
44
|
+
className: "\u{1F95D}-banner-label",
|
|
45
|
+
id: labelId,
|
|
46
|
+
variant: "body-sm",
|
|
47
|
+
render: React.isValidElement(label) ? label : /* @__PURE__ */ jsx("span", {}),
|
|
48
|
+
children: !React.isValidElement(label) ? label : void 0
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
/* @__PURE__ */ jsx(Text, { render: /* @__PURE__ */ jsx("div", {}), variant: "body-sm", className: "\u{1F95D}-banner-message", children: message }),
|
|
52
|
+
actions != null ? /* @__PURE__ */ jsx("div", { className: "\u{1F95D}-banner-actions", children: actions }) : null,
|
|
53
|
+
onDismiss ? /* @__PURE__ */ jsx(GhostAligner, { align: "block", children: /* @__PURE__ */ jsx(
|
|
54
|
+
IconButton,
|
|
55
|
+
{
|
|
56
|
+
id: dismissId,
|
|
57
|
+
className: "\u{1F95D}-banner-dismiss-button",
|
|
58
|
+
variant: "ghost",
|
|
59
|
+
label: "Dismiss",
|
|
60
|
+
"aria-labelledby": `${dismissId} ${labelId}`,
|
|
61
|
+
icon: /* @__PURE__ */ jsx(Dismiss, {}),
|
|
62
|
+
onClick: onDismiss
|
|
63
|
+
}
|
|
64
|
+
) }) : null
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
DEV: Banner.displayName = "Banner";
|
|
70
|
+
export {
|
|
71
|
+
Banner
|
|
72
|
+
};
|
package/dist/DEV/Chip.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Role } from "@ariakit/react/role";
|
|
3
|
+
import { IconButton } from "@stratakit/bricks";
|
|
4
|
+
import { forwardRef } from "@stratakit/foundations/secret-internals";
|
|
5
|
+
import cx from "classnames";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { Dismiss } from "./~utils.icons.js";
|
|
8
|
+
const Chip = forwardRef((props, forwardedRef) => {
|
|
9
|
+
const { variant = "solid", onDismiss, label, ...rest } = props;
|
|
10
|
+
const baseId = React.useId();
|
|
11
|
+
const labelId = `${baseId}-label`;
|
|
12
|
+
const dismissIconId = `${baseId}-dismiss`;
|
|
13
|
+
return /* @__PURE__ */ jsxs(
|
|
14
|
+
Role.div,
|
|
15
|
+
{
|
|
16
|
+
"data-kiwi-variant": variant,
|
|
17
|
+
...rest,
|
|
18
|
+
className: cx("\u{1F95D}-chip", props.className),
|
|
19
|
+
ref: forwardedRef,
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ jsx("span", { id: labelId, children: label }),
|
|
22
|
+
onDismiss && /* @__PURE__ */ jsx(
|
|
23
|
+
IconButton,
|
|
24
|
+
{
|
|
25
|
+
id: dismissIconId,
|
|
26
|
+
className: "\u{1F95D}-chip-dismiss-button",
|
|
27
|
+
variant: "ghost",
|
|
28
|
+
"aria-labelledby": `${dismissIconId} ${labelId}`,
|
|
29
|
+
label: "Dismiss",
|
|
30
|
+
labelVariant: "visually-hidden",
|
|
31
|
+
icon: /* @__PURE__ */ jsx(Dismiss, {}),
|
|
32
|
+
onClick: onDismiss
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
DEV: Chip.displayName = "Chip";
|
|
40
|
+
export {
|
|
41
|
+
Chip
|
|
42
|
+
};
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button as ButtonAk } from "@ariakit/react/button";
|
|
3
|
+
import {
|
|
4
|
+
Menu,
|
|
5
|
+
MenuButton,
|
|
6
|
+
MenuItem,
|
|
7
|
+
MenuItemCheckbox,
|
|
8
|
+
MenuProvider,
|
|
9
|
+
useMenuContext
|
|
10
|
+
} from "@ariakit/react/menu";
|
|
11
|
+
import { usePopoverContext } from "@ariakit/react/popover";
|
|
12
|
+
import { useStoreState } from "@ariakit/react/store";
|
|
13
|
+
import { Button, Kbd } from "@stratakit/bricks";
|
|
14
|
+
import {
|
|
15
|
+
DisclosureArrow,
|
|
16
|
+
Dot,
|
|
17
|
+
predefinedSymbols
|
|
18
|
+
} from "@stratakit/bricks/secret-internals";
|
|
19
|
+
import { Icon } from "@stratakit/foundations";
|
|
20
|
+
import {
|
|
21
|
+
forwardRef,
|
|
22
|
+
usePopoverApi
|
|
23
|
+
} from "@stratakit/foundations/secret-internals";
|
|
24
|
+
import cx from "classnames";
|
|
25
|
+
import * as React from "react";
|
|
26
|
+
import * as ListItem from "./~utils.ListItem.js";
|
|
27
|
+
import { Checkmark } from "./~utils.icons.js";
|
|
28
|
+
function DropdownMenuRoot(props) {
|
|
29
|
+
const {
|
|
30
|
+
children,
|
|
31
|
+
placement,
|
|
32
|
+
open: openProp,
|
|
33
|
+
setOpen: setOpenProp,
|
|
34
|
+
defaultOpen: defaultOpenProp
|
|
35
|
+
} = props;
|
|
36
|
+
return /* @__PURE__ */ jsx(
|
|
37
|
+
MenuProvider,
|
|
38
|
+
{
|
|
39
|
+
placement,
|
|
40
|
+
defaultOpen: defaultOpenProp,
|
|
41
|
+
open: openProp,
|
|
42
|
+
setOpen: setOpenProp,
|
|
43
|
+
popover: usePopoverContext(),
|
|
44
|
+
children
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
DEV: DropdownMenuRoot.displayName = "DropdownMenu.Root";
|
|
49
|
+
const DropdownMenuContent = forwardRef(
|
|
50
|
+
(props, forwardedRef) => {
|
|
51
|
+
const popover = usePopoverApi(useMenuContext());
|
|
52
|
+
return /* @__PURE__ */ jsx(
|
|
53
|
+
Menu,
|
|
54
|
+
{
|
|
55
|
+
portal: true,
|
|
56
|
+
unmountOnHide: true,
|
|
57
|
+
...props,
|
|
58
|
+
gutter: 4,
|
|
59
|
+
style: { ...popover.style, ...props.style },
|
|
60
|
+
wrapperProps: popover.wrapperProps,
|
|
61
|
+
className: cx("\u{1F95D}-dropdown-menu", props.className),
|
|
62
|
+
ref: forwardedRef
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
DEV: DropdownMenuContent.displayName = "DropdownMenu.Content";
|
|
68
|
+
const DropdownMenuButton = forwardRef(
|
|
69
|
+
(props, forwardedRef) => {
|
|
70
|
+
const { accessibleWhenDisabled = true, children, ...rest } = props;
|
|
71
|
+
const open = useStoreState(useMenuContext(), (state) => state?.open);
|
|
72
|
+
return /* @__PURE__ */ jsx(
|
|
73
|
+
MenuButton,
|
|
74
|
+
{
|
|
75
|
+
accessibleWhenDisabled: true,
|
|
76
|
+
render: /* @__PURE__ */ jsxs(Button, { accessibleWhenDisabled, children: [
|
|
77
|
+
children,
|
|
78
|
+
/* @__PURE__ */ jsx(DisclosureArrow, {})
|
|
79
|
+
] }),
|
|
80
|
+
...rest,
|
|
81
|
+
className: cx("\u{1F95D}-dropdown-menu-button", props.className),
|
|
82
|
+
"data-has-popover-open": open || void 0,
|
|
83
|
+
ref: forwardedRef
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
DEV: DropdownMenuButton.displayName = "DropdownMenu.Button";
|
|
89
|
+
const DropdownMenuItem = forwardRef(
|
|
90
|
+
(props, forwardedRef) => {
|
|
91
|
+
const { label, shortcuts, icon, unstable_dot, ...rest } = props;
|
|
92
|
+
const dotId = React.useId();
|
|
93
|
+
return /* @__PURE__ */ jsxs(
|
|
94
|
+
MenuItem,
|
|
95
|
+
{
|
|
96
|
+
accessibleWhenDisabled: true,
|
|
97
|
+
render: /* @__PURE__ */ jsx(
|
|
98
|
+
ListItem.Root,
|
|
99
|
+
{
|
|
100
|
+
render: /* @__PURE__ */ jsx(
|
|
101
|
+
ButtonAk,
|
|
102
|
+
{
|
|
103
|
+
accessibleWhenDisabled: true,
|
|
104
|
+
"aria-describedby": dotId,
|
|
105
|
+
...rest,
|
|
106
|
+
className: cx("\u{1F95D}-dropdown-menu-item", props.className),
|
|
107
|
+
ref: forwardedRef
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
children: [
|
|
113
|
+
icon ? /* @__PURE__ */ jsx(DropdownMenuIcon, { icon }) : null,
|
|
114
|
+
/* @__PURE__ */ jsx(ListItem.Content, { render: /* @__PURE__ */ jsx("span", {}), children: label }),
|
|
115
|
+
shortcuts ? /* @__PURE__ */ jsx(DropdownMenuItemShortcuts, { shortcuts }) : null,
|
|
116
|
+
unstable_dot ? /* @__PURE__ */ jsx(
|
|
117
|
+
ListItem.Decoration,
|
|
118
|
+
{
|
|
119
|
+
render: /* @__PURE__ */ jsx(Dot, { id: dotId, className: "\u{1F95D}-dropdown-menu-item-dot", children: unstable_dot })
|
|
120
|
+
}
|
|
121
|
+
) : null
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
DEV: DropdownMenuItem.displayName = "DropdownMenu.Item";
|
|
128
|
+
const DropdownMenuItemShortcuts = forwardRef((props, forwardedRef) => {
|
|
129
|
+
const { shortcuts, ...rest } = props;
|
|
130
|
+
const shortcutKeys = React.useMemo(() => {
|
|
131
|
+
return shortcuts.split("+").map((key) => ({
|
|
132
|
+
key: key.trim(),
|
|
133
|
+
isSymbol: key in predefinedSymbols
|
|
134
|
+
}));
|
|
135
|
+
}, [shortcuts]);
|
|
136
|
+
return /* @__PURE__ */ jsx(
|
|
137
|
+
ListItem.Decoration,
|
|
138
|
+
{
|
|
139
|
+
render: /* @__PURE__ */ jsx("span", {}),
|
|
140
|
+
...rest,
|
|
141
|
+
className: cx("\u{1F95D}-dropdown-menu-item-shortcuts", props.className),
|
|
142
|
+
ref: forwardedRef,
|
|
143
|
+
children: shortcutKeys.map(({ key, isSymbol }, index) => {
|
|
144
|
+
if (isSymbol) {
|
|
145
|
+
return /* @__PURE__ */ jsx(
|
|
146
|
+
Kbd,
|
|
147
|
+
{
|
|
148
|
+
variant: "ghost",
|
|
149
|
+
symbol: key
|
|
150
|
+
},
|
|
151
|
+
`${key + index}`
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
return /* @__PURE__ */ jsx(Kbd, { variant: "ghost", children: key }, `${key + index}`);
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
DEV: DropdownMenuItemShortcuts.displayName = "DropdownMenuItemShortcuts";
|
|
160
|
+
const DropdownMenuIcon = forwardRef(
|
|
161
|
+
(props, forwardedRef) => {
|
|
162
|
+
const { icon, ...rest } = props;
|
|
163
|
+
return /* @__PURE__ */ jsx(
|
|
164
|
+
ListItem.Decoration,
|
|
165
|
+
{
|
|
166
|
+
render: /* @__PURE__ */ jsx(
|
|
167
|
+
Icon,
|
|
168
|
+
{
|
|
169
|
+
href: typeof icon === "string" ? icon : void 0,
|
|
170
|
+
render: React.isValidElement(icon) ? icon : void 0,
|
|
171
|
+
...rest,
|
|
172
|
+
ref: forwardedRef
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
DEV: DropdownMenuIcon.displayName = "DropdownMenuIcon";
|
|
180
|
+
const DropdownMenuCheckboxItem = forwardRef((props, forwardedRef) => {
|
|
181
|
+
const {
|
|
182
|
+
label,
|
|
183
|
+
icon,
|
|
184
|
+
defaultChecked,
|
|
185
|
+
checked,
|
|
186
|
+
onChange,
|
|
187
|
+
name,
|
|
188
|
+
value = defaultChecked ? "on" : void 0,
|
|
189
|
+
// For defaultChecked to work
|
|
190
|
+
...rest
|
|
191
|
+
} = props;
|
|
192
|
+
return /* @__PURE__ */ jsxs(
|
|
193
|
+
MenuItemCheckbox,
|
|
194
|
+
{
|
|
195
|
+
accessibleWhenDisabled: true,
|
|
196
|
+
defaultChecked,
|
|
197
|
+
checked,
|
|
198
|
+
name,
|
|
199
|
+
value,
|
|
200
|
+
onChange,
|
|
201
|
+
render: /* @__PURE__ */ jsx(
|
|
202
|
+
ListItem.Root,
|
|
203
|
+
{
|
|
204
|
+
render: /* @__PURE__ */ jsx(
|
|
205
|
+
ButtonAk,
|
|
206
|
+
{
|
|
207
|
+
accessibleWhenDisabled: true,
|
|
208
|
+
...rest,
|
|
209
|
+
className: cx("\u{1F95D}-dropdown-menu-item", props.className),
|
|
210
|
+
ref: forwardedRef
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
),
|
|
215
|
+
children: [
|
|
216
|
+
icon ? /* @__PURE__ */ jsx(DropdownMenuIcon, { icon }) : null,
|
|
217
|
+
/* @__PURE__ */ jsx(ListItem.Content, { render: /* @__PURE__ */ jsx("span", {}), children: label }),
|
|
218
|
+
/* @__PURE__ */ jsx(
|
|
219
|
+
ListItem.Decoration,
|
|
220
|
+
{
|
|
221
|
+
render: /* @__PURE__ */ jsx(Checkmark, { className: "\u{1F95D}-dropdown-menu-checkmark" })
|
|
222
|
+
}
|
|
223
|
+
)
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
});
|
|
228
|
+
DEV: DropdownMenuCheckboxItem.displayName = "DropdownMenu.CheckboxItem";
|
|
229
|
+
export {
|
|
230
|
+
DropdownMenuButton as Button,
|
|
231
|
+
DropdownMenuCheckboxItem as CheckboxItem,
|
|
232
|
+
DropdownMenuContent as Content,
|
|
233
|
+
DropdownMenuItem as Item,
|
|
234
|
+
DropdownMenuRoot as Root
|
|
235
|
+
};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
Collection,
|
|
4
|
+
CollectionItem,
|
|
5
|
+
useCollectionStore
|
|
6
|
+
} from "@ariakit/react/collection";
|
|
7
|
+
import {
|
|
8
|
+
Dialog,
|
|
9
|
+
DialogDisclosure,
|
|
10
|
+
DialogProvider
|
|
11
|
+
} from "@ariakit/react/dialog";
|
|
12
|
+
import { Role } from "@ariakit/react/role";
|
|
13
|
+
import { useStoreState } from "@ariakit/react/store";
|
|
14
|
+
import { Button, Text, VisuallyHidden } from "@stratakit/bricks";
|
|
15
|
+
import { IconButtonPresentation } from "@stratakit/bricks/secret-internals";
|
|
16
|
+
import {
|
|
17
|
+
forwardRef,
|
|
18
|
+
useControlledState
|
|
19
|
+
} from "@stratakit/foundations/secret-internals";
|
|
20
|
+
import cx from "classnames";
|
|
21
|
+
import * as React from "react";
|
|
22
|
+
import { ChevronDown, StatusIcon } from "./~utils.icons.js";
|
|
23
|
+
const ErrorRegionRoot = forwardRef(
|
|
24
|
+
(props, forwardedRef) => {
|
|
25
|
+
const {
|
|
26
|
+
label,
|
|
27
|
+
items,
|
|
28
|
+
open: openProp,
|
|
29
|
+
setOpen: setOpenProp,
|
|
30
|
+
...rest
|
|
31
|
+
} = props;
|
|
32
|
+
const labelId = React.useId();
|
|
33
|
+
const sectionLabelledBy = props["aria-labelledby"] ?? (props["aria-label"] ? void 0 : labelId);
|
|
34
|
+
const [open, setOpen] = useControlledState(
|
|
35
|
+
false,
|
|
36
|
+
openProp,
|
|
37
|
+
setOpenProp
|
|
38
|
+
);
|
|
39
|
+
const containerRef = React.useRef(null);
|
|
40
|
+
const pulse = () => {
|
|
41
|
+
const el = containerRef.current;
|
|
42
|
+
if (!el) return;
|
|
43
|
+
const id = "--\u{1F95D}error-region-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(--ids-color-border-attention-base)",
|
|
50
|
+
opacity: 1
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
boxShadow: "0 0 15px 2px var(--ids-color-border-attention-base)",
|
|
54
|
+
opacity: 0.7,
|
|
55
|
+
offset: 0.5
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
boxShadow: "0 0 0 0 var(--ids-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
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const prevItems = useStoreState(store, "items");
|
|
82
|
+
const [liveLabel, setLiveLabel] = React.useState(label);
|
|
83
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
84
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "polite", "aria-atomic": true, children: liveLabel === label ? liveLabel : void 0 }),
|
|
85
|
+
/* @__PURE__ */ jsx(DialogProvider, { open, setOpen, children: /* @__PURE__ */ jsx(
|
|
86
|
+
Role.section,
|
|
87
|
+
{
|
|
88
|
+
...rest,
|
|
89
|
+
"aria-labelledby": sectionLabelledBy,
|
|
90
|
+
className: cx("\u{1F95D}-error-region", props.className),
|
|
91
|
+
"data-kiwi-visible": !!label,
|
|
92
|
+
"data-kiwi-expanded": open,
|
|
93
|
+
ref: forwardedRef,
|
|
94
|
+
children: /* @__PURE__ */ jsxs("div", { className: "\u{1F95D}-error-region-container", ref: containerRef, children: [
|
|
95
|
+
/* @__PURE__ */ jsxs(
|
|
96
|
+
DialogDisclosure,
|
|
97
|
+
{
|
|
98
|
+
className: "\u{1F95D}-error-region-header",
|
|
99
|
+
render: /* @__PURE__ */ jsx(Button, { variant: "ghost" }),
|
|
100
|
+
children: [
|
|
101
|
+
/* @__PURE__ */ jsx(StatusIcon, { tone: "attention", className: "\u{1F95D}-error-region-icon" }),
|
|
102
|
+
/* @__PURE__ */ jsx(
|
|
103
|
+
Text,
|
|
104
|
+
{
|
|
105
|
+
render: /* @__PURE__ */ jsx("span", {}),
|
|
106
|
+
id: labelId,
|
|
107
|
+
className: "\u{1F95D}-error-region-label",
|
|
108
|
+
variant: "body-sm",
|
|
109
|
+
children: label
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
/* @__PURE__ */ jsx(IconButtonPresentation, { inert: true, variant: "ghost", children: /* @__PURE__ */ jsx(ChevronDown, {}) })
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
),
|
|
116
|
+
/* @__PURE__ */ jsx(
|
|
117
|
+
Dialog,
|
|
118
|
+
{
|
|
119
|
+
className: "\u{1F95D}-error-region-dialog",
|
|
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}-error-region-items",
|
|
129
|
+
role: "list",
|
|
130
|
+
children: items
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
] })
|
|
136
|
+
}
|
|
137
|
+
) })
|
|
138
|
+
] });
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
DEV: ErrorRegionRoot.displayName = "ErrorRegion.Root";
|
|
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
|
+
{
|
|
154
|
+
...rest,
|
|
155
|
+
role: "listitem",
|
|
156
|
+
className: cx("\u{1F95D}-error-region-item", props.className),
|
|
157
|
+
ref: forwardedRef,
|
|
158
|
+
children: [
|
|
159
|
+
/* @__PURE__ */ jsx(Text, { id: messageId, variant: "body-sm", children: message }),
|
|
160
|
+
/* @__PURE__ */ jsx("div", { className: "\u{1F95D}-error-region-item-actions", children: actions })
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
DEV: ErrorRegionItem.displayName = "ErrorRegion.Item";
|
|
167
|
+
export {
|
|
168
|
+
ErrorRegionItem as Item,
|
|
169
|
+
ErrorRegionRoot as Root
|
|
170
|
+
};
|