@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.1
|
|
4
|
+
|
|
5
|
+
- [#1075](https://github.com/iTwin/design-system/pull/1075): Added a new `unstable_NavigationList` component that displays a vertical list of links for secondary navigation.
|
|
6
|
+
|
|
7
|
+
Includes the following subcomponents:
|
|
8
|
+
- `<NavigationList.Root>`
|
|
9
|
+
- `<NavigationList.Anchor>`
|
|
10
|
+
- `<NavigationList.Subgroup>`
|
|
11
|
+
|
|
12
|
+
Example:
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
<NavigationList.Root
|
|
16
|
+
items={[
|
|
17
|
+
<NavigationList.Anchor key={1} href="/page1" label="Page 1" />,
|
|
18
|
+
<NavigationList.Anchor key={2} href="/page2" label="Page 2" />,
|
|
19
|
+
<NavigationList.Subgroup
|
|
20
|
+
key={3}
|
|
21
|
+
label="Group of pages"
|
|
22
|
+
items={[
|
|
23
|
+
<NavigationList.Anchor key={1} href="/page3-1" label="Sub-page 1" active />,
|
|
24
|
+
<NavigationList.Anchor key={2} href="/page3-2" label="Sub-page 2" />,
|
|
25
|
+
]}
|
|
26
|
+
/>,
|
|
27
|
+
]}
|
|
28
|
+
/>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- [#1079](https://github.com/iTwin/design-system/pull/1079): Increased the click target area of non-selectable `Tree.Item`s.
|
|
32
|
+
- If `selected` is undefined, the `Tree.Item` will expand/collapse when clicked.
|
|
33
|
+
- If `selected` is defined, the `Tree.Item` will continue to toggle selection when clicked.
|
|
34
|
+
|
|
35
|
+
- [#1064](https://github.com/iTwin/design-system/pull/1064): Added new `unstable_Popover` component that displays custom content in a non-modal window overlay that is placed relative to a trigger element.
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
<Popover content={<>Popover content</>}>
|
|
39
|
+
<Button>Open popover</Button>
|
|
40
|
+
</Popover>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- Updated dependencies:
|
|
44
|
+
- @stratakit/bricks@0.5.1
|
|
45
|
+
- @stratakit/foundations@0.4.1
|
|
46
|
+
|
|
47
|
+
## 0.5.0
|
|
48
|
+
|
|
49
|
+
### Breaking changes
|
|
50
|
+
|
|
51
|
+
- [#1036](https://github.com/iTwin/design-system/pull/1036): Changed `items` prop type of `ErrorRegion.Root` component from `ReactNode` to `ReactNode[]`.
|
|
52
|
+
|
|
53
|
+
`items` prop is used to determine error region visibility.
|
|
54
|
+
|
|
55
|
+
- [#1038](https://github.com/iTwin/design-system/pull/1038): Removed unintentionally exposed `TreeItem` [subpath export](https://nodejs.org/api/packages.html#subpath-exports). Tree item components are available under the `Tree` subpath or the main entry point of the package.
|
|
56
|
+
|
|
57
|
+
```diff
|
|
58
|
+
- import * as TreeItem from "@stratakit/structures/TreeItem";
|
|
59
|
+
+ import * as Tree from "@stratakit/structures/Tree";
|
|
60
|
+
|
|
61
|
+
- <TreeItem.Root />
|
|
62
|
+
+ <Tree.Item />
|
|
63
|
+
|
|
64
|
+
- <TreeItem.Action />
|
|
65
|
+
+ <Tree.ItemAction />
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
- [#1037](https://github.com/iTwin/design-system/pull/1037): Require `aria-label` or `aria-labelledby` prop in `ErrorRegion.Root` component.
|
|
69
|
+
|
|
70
|
+
### Non-breaking changes
|
|
71
|
+
|
|
72
|
+
- [#1003](https://github.com/iTwin/design-system/pull/1003): Enabled React Compiler for production build. In React 18 apps, `react-compiler-runtime` dependency will be used.
|
|
73
|
+
- Updated dependencies:
|
|
74
|
+
- @stratakit/bricks@0.5.0
|
|
75
|
+
- @stratakit/foundations@0.4.0
|
|
76
|
+
|
|
3
77
|
## 0.4.5
|
|
4
78
|
|
|
5
79
|
- `unstable_NavigationRail` changes:
|
package/dist/AccordionItem.d.ts
CHANGED
|
@@ -228,7 +228,7 @@ declare const AccordionItemMarker: import("react").ForwardRefExoticComponent<Pic
|
|
|
228
228
|
* ```
|
|
229
229
|
*/
|
|
230
230
|
declare const AccordionItemContent: import("react").ForwardRefExoticComponent<Pick<import("@ariakit/react/role").RoleProps, "render"> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "render"> & import("react").RefAttributes<HTMLDivElement | HTMLElement>>;
|
|
231
|
-
interface AccordionItemHeadingProps extends BaseProps {
|
|
231
|
+
interface AccordionItemHeadingProps extends Omit<BaseProps, "render"> {
|
|
232
232
|
render: NonNullable<BaseProps["render"]>;
|
|
233
233
|
}
|
|
234
234
|
/**
|
package/dist/AccordionItem.js
CHANGED
|
@@ -1,133 +1,78 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
Disclosure,
|
|
4
|
-
DisclosureContent,
|
|
5
|
-
DisclosureProvider
|
|
6
|
-
} from "@ariakit/react/disclosure";
|
|
2
|
+
import { Disclosure, DisclosureContent, DisclosureProvider } from "@ariakit/react/disclosure";
|
|
7
3
|
import { Role } from "@ariakit/react/role";
|
|
8
4
|
import { Text } from "@stratakit/bricks";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
IconButtonPresentation
|
|
12
|
-
} from "@stratakit/bricks/secret-internals";
|
|
13
|
-
import {
|
|
14
|
-
forwardRef,
|
|
15
|
-
useControlledState
|
|
16
|
-
} from "@stratakit/foundations/secret-internals";
|
|
5
|
+
import { GhostAligner, IconButtonPresentation } from "@stratakit/bricks/secret-internals";
|
|
6
|
+
import { forwardRef, useControlledState } from "@stratakit/foundations/secret-internals";
|
|
17
7
|
import cx from "classnames";
|
|
18
8
|
import { ChevronDown } from "./~utils.icons.js";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
setOpen,
|
|
38
|
-
children: /* @__PURE__ */ jsx(
|
|
39
|
-
Role,
|
|
40
|
-
{
|
|
41
|
-
...rest,
|
|
42
|
-
className: cx("\u{1F95D}AccordionItem", props.className),
|
|
43
|
-
"data-_sk-open": open,
|
|
44
|
-
ref: forwardedRef
|
|
45
|
-
}
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
const AccordionItemHeader = forwardRef(
|
|
52
|
-
(props, forwardedRef) => /* @__PURE__ */ jsx(GhostAligner, { align: "block", children: /* @__PURE__ */ jsx(
|
|
53
|
-
Role,
|
|
54
|
-
{
|
|
55
|
-
...props,
|
|
56
|
-
className: cx("\u{1F95D}AccordionItemHeader", props.className),
|
|
9
|
+
import { useInit } from "./~utils.useInit.js";
|
|
10
|
+
const AccordionItemRoot = forwardRef((props, forwardedRef) => {
|
|
11
|
+
useInit();
|
|
12
|
+
const {
|
|
13
|
+
defaultOpen,
|
|
14
|
+
open: openProp,
|
|
15
|
+
setOpen: setOpenProp,
|
|
16
|
+
...rest
|
|
17
|
+
} = props;
|
|
18
|
+
const [open, setOpen] = useControlledState(defaultOpen ?? false, openProp, setOpenProp);
|
|
19
|
+
return /* @__PURE__ */ jsx(DisclosureProvider, {
|
|
20
|
+
defaultOpen,
|
|
21
|
+
open,
|
|
22
|
+
setOpen,
|
|
23
|
+
children: /* @__PURE__ */ jsx(Role, {
|
|
24
|
+
...rest,
|
|
25
|
+
className: cx("\u{1F95D}AccordionItem", props.className),
|
|
26
|
+
"data-_sk-open": open,
|
|
57
27
|
ref: forwardedRef
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
);
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
const AccordionItemContent = forwardRef(
|
|
111
|
-
(props, forwardedRef) => /* @__PURE__ */ jsx(
|
|
112
|
-
DisclosureContent,
|
|
113
|
-
{
|
|
114
|
-
...props,
|
|
115
|
-
className: cx("\u{1F95D}AccordionItemContent", props.className),
|
|
116
|
-
ref: forwardedRef
|
|
117
|
-
}
|
|
118
|
-
)
|
|
119
|
-
);
|
|
120
|
-
const AccordionItemHeading = forwardRef(
|
|
121
|
-
(props, forwardedRef) => /* @__PURE__ */ jsx(
|
|
122
|
-
Text,
|
|
123
|
-
{
|
|
124
|
-
...props,
|
|
125
|
-
variant: "body-sm",
|
|
126
|
-
className: cx("\u{1F95D}AccordionItemHeading", props.className),
|
|
127
|
-
ref: forwardedRef
|
|
128
|
-
}
|
|
129
|
-
)
|
|
130
|
-
);
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
const AccordionItemHeader = forwardRef((props, forwardedRef) => /* @__PURE__ */ jsx(GhostAligner, {
|
|
32
|
+
align: "block",
|
|
33
|
+
children: /* @__PURE__ */ jsx(Role, {
|
|
34
|
+
...props,
|
|
35
|
+
className: cx("\u{1F95D}AccordionItemHeader", props.className),
|
|
36
|
+
ref: forwardedRef
|
|
37
|
+
})
|
|
38
|
+
}));
|
|
39
|
+
const AccordionItemButton = forwardRef((props, forwardedRef) => /* @__PURE__ */ jsx(Disclosure, {
|
|
40
|
+
...props,
|
|
41
|
+
className: cx("\u{1F95D}AccordionItemButton", props.className),
|
|
42
|
+
ref: forwardedRef
|
|
43
|
+
}));
|
|
44
|
+
const AccordionItemLabel = forwardRef((props, forwardedRef) => /* @__PURE__ */ jsx(Text, {
|
|
45
|
+
...props,
|
|
46
|
+
variant: "body-sm",
|
|
47
|
+
className: cx("\u{1F95D}AccordionItemLabel", props.className),
|
|
48
|
+
ref: forwardedRef
|
|
49
|
+
}));
|
|
50
|
+
const AccordionItemDecoration = forwardRef((props, forwardedRef) => /* @__PURE__ */ jsx(Role, {
|
|
51
|
+
...props,
|
|
52
|
+
className: cx("\u{1F95D}AccordionItemDecoration", props.className),
|
|
53
|
+
ref: forwardedRef
|
|
54
|
+
}));
|
|
55
|
+
const AccordionItemMarker = forwardRef((props, forwardedRef) => /* @__PURE__ */ jsx(IconButtonPresentation, {
|
|
56
|
+
...props,
|
|
57
|
+
variant: "ghost",
|
|
58
|
+
className: cx("\u{1F95D}AccordionItemMarker", props.className),
|
|
59
|
+
ref: forwardedRef,
|
|
60
|
+
children: props.children ?? /* @__PURE__ */ jsx(ChevronDown, {
|
|
61
|
+
"aria-hidden": "true",
|
|
62
|
+
className: "\u{1F95D}AccordionItemMarkerChevron"
|
|
63
|
+
})
|
|
64
|
+
}));
|
|
65
|
+
const AccordionItemContent = forwardRef((props, forwardedRef) => /* @__PURE__ */ jsx(DisclosureContent, {
|
|
66
|
+
...props,
|
|
67
|
+
className: cx("\u{1F95D}AccordionItemContent", props.className),
|
|
68
|
+
ref: forwardedRef
|
|
69
|
+
}));
|
|
70
|
+
const AccordionItemHeading = forwardRef((props, forwardedRef) => /* @__PURE__ */ jsx(Text, {
|
|
71
|
+
...props,
|
|
72
|
+
variant: "body-sm",
|
|
73
|
+
className: cx("\u{1F95D}AccordionItemHeading", props.className),
|
|
74
|
+
ref: forwardedRef
|
|
75
|
+
}));
|
|
131
76
|
export {
|
|
132
77
|
AccordionItemButton as Button,
|
|
133
78
|
AccordionItemContent as Content,
|
package/dist/Banner.js
CHANGED
|
@@ -1,142 +1,169 @@
|
|
|
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, Text } from "@stratakit/bricks";
|
|
5
6
|
import { GhostAligner } from "@stratakit/bricks/secret-internals";
|
|
6
7
|
import { Icon } from "@stratakit/foundations";
|
|
7
|
-
import {
|
|
8
|
-
forwardRef,
|
|
9
|
-
useSafeContext
|
|
10
|
-
} from "@stratakit/foundations/secret-internals";
|
|
8
|
+
import { forwardRef, useSafeContext } from "@stratakit/foundations/secret-internals";
|
|
11
9
|
import cx from "classnames";
|
|
12
10
|
import { createStore, useStore } from "zustand";
|
|
13
11
|
import { combine } from "zustand/middleware";
|
|
14
12
|
import { Dismiss, StatusIcon } from "./~utils.icons.js";
|
|
13
|
+
import { useInit } from "./~utils.useInit.js";
|
|
15
14
|
function createBannerStore(initialState) {
|
|
16
|
-
return createStore(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
);
|
|
15
|
+
return createStore(combine(initialState, (set, _, store) => ({
|
|
16
|
+
setLabelId: (labelId) => {
|
|
17
|
+
set({
|
|
18
|
+
labelId: labelId || store.getInitialState().labelId
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
})));
|
|
23
22
|
}
|
|
24
23
|
const BannerContext = React.createContext(void 0);
|
|
25
24
|
function BannerProvider(props) {
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
const $ = _c(9);
|
|
26
|
+
const {
|
|
27
|
+
tone
|
|
28
|
+
} = props;
|
|
29
|
+
let t0;
|
|
30
|
+
if ($[0] !== tone) {
|
|
31
|
+
t0 = () => createBannerStore({
|
|
32
|
+
tone
|
|
33
|
+
});
|
|
34
|
+
$[0] = tone;
|
|
35
|
+
$[1] = t0;
|
|
36
|
+
} else {
|
|
37
|
+
t0 = $[1];
|
|
38
|
+
}
|
|
39
|
+
const [store] = React.useState(t0);
|
|
40
|
+
let t1;
|
|
41
|
+
let t2;
|
|
42
|
+
if ($[2] !== store || $[3] !== tone) {
|
|
43
|
+
t1 = function synchronizeWithProps() {
|
|
44
|
+
store.setState({
|
|
45
|
+
tone
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
t2 = [store, tone];
|
|
49
|
+
$[2] = store;
|
|
50
|
+
$[3] = tone;
|
|
51
|
+
$[4] = t1;
|
|
52
|
+
$[5] = t2;
|
|
53
|
+
} else {
|
|
54
|
+
t1 = $[4];
|
|
55
|
+
t2 = $[5];
|
|
56
|
+
}
|
|
57
|
+
React.useEffect(t1, t2);
|
|
58
|
+
let t3;
|
|
59
|
+
if ($[6] !== props.children || $[7] !== store) {
|
|
60
|
+
t3 = jsx(BannerContext.Provider, {
|
|
61
|
+
value: store,
|
|
62
|
+
children: props.children
|
|
63
|
+
});
|
|
64
|
+
$[6] = props.children;
|
|
65
|
+
$[7] = store;
|
|
66
|
+
$[8] = t3;
|
|
67
|
+
} else {
|
|
68
|
+
t3 = $[8];
|
|
69
|
+
}
|
|
70
|
+
return t3;
|
|
35
71
|
}
|
|
36
72
|
function useBannerState(selectorFn) {
|
|
37
73
|
const store = useSafeContext(BannerContext);
|
|
38
74
|
return useStore(store, selectorFn);
|
|
39
75
|
}
|
|
40
76
|
const BannerRoot = forwardRef((props, forwardedRef) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
77
|
+
useInit();
|
|
78
|
+
const {
|
|
79
|
+
tone = "neutral",
|
|
80
|
+
variant = "outline",
|
|
81
|
+
...rest
|
|
82
|
+
} = props;
|
|
83
|
+
return /* @__PURE__ */ jsx(BannerProvider, {
|
|
84
|
+
tone,
|
|
85
|
+
children: /* @__PURE__ */ jsx(Role, {
|
|
45
86
|
...rest,
|
|
46
87
|
"data-_sk-tone": tone,
|
|
47
88
|
"data-_sk-variant": variant,
|
|
48
89
|
className: cx("\u{1F95D}Banner", props.className),
|
|
49
90
|
ref: forwardedRef
|
|
50
|
-
}
|
|
51
|
-
|
|
91
|
+
})
|
|
92
|
+
});
|
|
52
93
|
});
|
|
53
94
|
const BannerIcon = forwardRef((props, forwardedRef) => {
|
|
54
95
|
const tone = useBannerState((state) => state.tone);
|
|
55
96
|
const hasDefaultIcon = props.href === void 0 && tone !== "neutral";
|
|
56
97
|
const {
|
|
57
|
-
render = hasDefaultIcon ? /* @__PURE__ */ jsx(StatusIcon, {
|
|
98
|
+
render = hasDefaultIcon ? /* @__PURE__ */ jsx(StatusIcon, {
|
|
99
|
+
tone
|
|
100
|
+
}) : void 0,
|
|
58
101
|
...rest
|
|
59
102
|
} = props;
|
|
60
|
-
return /* @__PURE__ */ jsx(
|
|
61
|
-
|
|
62
|
-
|
|
103
|
+
return /* @__PURE__ */ jsx(Icon, {
|
|
104
|
+
...rest,
|
|
105
|
+
render,
|
|
106
|
+
className: cx("\u{1F95D}BannerIcon", props.className),
|
|
107
|
+
ref: forwardedRef
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
const BannerLabel = forwardRef((props, forwardedRef) => {
|
|
111
|
+
const defaultLabelId = React.useId();
|
|
112
|
+
const labelId = useBannerState((state) => state.labelId);
|
|
113
|
+
const setLabelId = useBannerState((state_0) => state_0.setLabelId);
|
|
114
|
+
const id = props.id ?? defaultLabelId;
|
|
115
|
+
React.useEffect(() => {
|
|
116
|
+
setLabelId(id);
|
|
117
|
+
return () => setLabelId(void 0);
|
|
118
|
+
}, [setLabelId, id]);
|
|
119
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
120
|
+
id: labelId,
|
|
121
|
+
render: /* @__PURE__ */ jsx("span", {}),
|
|
122
|
+
...props,
|
|
123
|
+
className: cx("\u{1F95D}BannerLabel", props.className),
|
|
124
|
+
variant: "body-sm",
|
|
125
|
+
ref: forwardedRef
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
const BannerMessage = forwardRef((props, forwardedRef) => {
|
|
129
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
130
|
+
...props,
|
|
131
|
+
variant: "body-sm",
|
|
132
|
+
className: cx("\u{1F95D}BannerMessage", props.className),
|
|
133
|
+
ref: forwardedRef
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
const BannerActions = forwardRef((props, forwardedRef) => {
|
|
137
|
+
return /* @__PURE__ */ jsx(Role.div, {
|
|
138
|
+
...props,
|
|
139
|
+
className: cx("\u{1F95D}BannerActions", props.className),
|
|
140
|
+
ref: forwardedRef
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
const BannerDismissButton = forwardRef((props, forwardedRef) => {
|
|
144
|
+
const {
|
|
145
|
+
label = "Dismiss",
|
|
146
|
+
...rest
|
|
147
|
+
} = props;
|
|
148
|
+
const labelId = useBannerState((state) => state.labelId);
|
|
149
|
+
const defaultId = React.useId();
|
|
150
|
+
const id = props.id ?? defaultId;
|
|
151
|
+
return /* @__PURE__ */ jsx(GhostAligner, {
|
|
152
|
+
align: "block",
|
|
153
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
63
154
|
...rest,
|
|
64
|
-
|
|
65
|
-
className: cx("\u{1F95D}
|
|
155
|
+
id,
|
|
156
|
+
className: cx("\u{1F95D}BannerDismissButton", props.className),
|
|
157
|
+
variant: "ghost",
|
|
158
|
+
label,
|
|
159
|
+
"aria-labelledby": `${id} ${labelId || ""}`,
|
|
160
|
+
icon: /* @__PURE__ */ jsx(Dismiss, {}),
|
|
66
161
|
ref: forwardedRef
|
|
67
|
-
}
|
|
68
|
-
);
|
|
162
|
+
})
|
|
163
|
+
});
|
|
69
164
|
});
|
|
70
|
-
const BannerLabel = forwardRef(
|
|
71
|
-
(props, forwardedRef) => {
|
|
72
|
-
const defaultLabelId = React.useId();
|
|
73
|
-
const labelId = useBannerState((state) => state.labelId);
|
|
74
|
-
const setLabelId = useBannerState((state) => state.setLabelId);
|
|
75
|
-
const id = props.id ?? defaultLabelId;
|
|
76
|
-
React.useEffect(() => {
|
|
77
|
-
setLabelId(id);
|
|
78
|
-
return () => setLabelId(void 0);
|
|
79
|
-
}, [setLabelId, id]);
|
|
80
|
-
return /* @__PURE__ */ jsx(
|
|
81
|
-
Text,
|
|
82
|
-
{
|
|
83
|
-
id: labelId,
|
|
84
|
-
render: /* @__PURE__ */ jsx("span", {}),
|
|
85
|
-
...props,
|
|
86
|
-
className: cx("\u{1F95D}BannerLabel", props.className),
|
|
87
|
-
variant: "body-sm",
|
|
88
|
-
ref: forwardedRef
|
|
89
|
-
}
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
);
|
|
93
|
-
const BannerMessage = forwardRef(
|
|
94
|
-
(props, forwardedRef) => {
|
|
95
|
-
return /* @__PURE__ */ jsx(
|
|
96
|
-
Text,
|
|
97
|
-
{
|
|
98
|
-
...props,
|
|
99
|
-
variant: "body-sm",
|
|
100
|
-
className: cx("\u{1F95D}BannerMessage", props.className),
|
|
101
|
-
ref: forwardedRef
|
|
102
|
-
}
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
const BannerActions = forwardRef(
|
|
107
|
-
(props, forwardedRef) => {
|
|
108
|
-
return /* @__PURE__ */ jsx(
|
|
109
|
-
Role.div,
|
|
110
|
-
{
|
|
111
|
-
...props,
|
|
112
|
-
className: cx("\u{1F95D}BannerActions", props.className),
|
|
113
|
-
ref: forwardedRef
|
|
114
|
-
}
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
);
|
|
118
|
-
const BannerDismissButton = forwardRef(
|
|
119
|
-
(props, forwardedRef) => {
|
|
120
|
-
const { label = "Dismiss", ...rest } = props;
|
|
121
|
-
const labelId = useBannerState((state) => state.labelId);
|
|
122
|
-
const defaultId = React.useId();
|
|
123
|
-
const id = props.id ?? defaultId;
|
|
124
|
-
return /* @__PURE__ */ jsx(GhostAligner, { align: "block", children: /* @__PURE__ */ jsx(
|
|
125
|
-
IconButton,
|
|
126
|
-
{
|
|
127
|
-
...rest,
|
|
128
|
-
id,
|
|
129
|
-
className: cx("\u{1F95D}BannerDismissButton", props.className),
|
|
130
|
-
variant: "ghost",
|
|
131
|
-
label,
|
|
132
|
-
"aria-labelledby": `${id} ${labelId || ""}`,
|
|
133
|
-
icon: /* @__PURE__ */ jsx(Dismiss, {}),
|
|
134
|
-
ref: forwardedRef
|
|
135
|
-
}
|
|
136
|
-
) });
|
|
137
|
-
}
|
|
138
|
-
);
|
|
139
165
|
const Banner = forwardRef((props, forwardedRef) => {
|
|
166
|
+
useInit();
|
|
140
167
|
const {
|
|
141
168
|
message,
|
|
142
169
|
label,
|
|
@@ -146,23 +173,25 @@ const Banner = forwardRef((props, forwardedRef) => {
|
|
|
146
173
|
tone = "neutral",
|
|
147
174
|
...rest
|
|
148
175
|
} = props;
|
|
149
|
-
const shouldRenderIcon = React.useMemo(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
shouldRenderIcon ? /* @__PURE__ */ jsx(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
/* @__PURE__ */ jsx(
|
|
163
|
-
|
|
164
|
-
onDismiss ? /* @__PURE__ */ jsx(BannerDismissButton, {
|
|
165
|
-
|
|
176
|
+
const shouldRenderIcon = React.useMemo(() => icon !== void 0 || tone !== "neutral", [icon, tone]);
|
|
177
|
+
return /* @__PURE__ */ jsxs(BannerRoot, {
|
|
178
|
+
tone,
|
|
179
|
+
...rest,
|
|
180
|
+
ref: forwardedRef,
|
|
181
|
+
children: [shouldRenderIcon ? /* @__PURE__ */ jsx(BannerIcon, {
|
|
182
|
+
href: typeof icon === "string" ? icon : void 0,
|
|
183
|
+
render: React.isValidElement(icon) ? icon : void 0
|
|
184
|
+
}) : null, /* @__PURE__ */ jsx(BannerLabel, {
|
|
185
|
+
render: React.isValidElement(label) ? label : void 0,
|
|
186
|
+
children: label
|
|
187
|
+
}), /* @__PURE__ */ jsx(BannerMessage, {
|
|
188
|
+
children: message
|
|
189
|
+
}), actions != null ? /* @__PURE__ */ jsx(BannerActions, {
|
|
190
|
+
children: actions
|
|
191
|
+
}) : null, onDismiss ? /* @__PURE__ */ jsx(BannerDismissButton, {
|
|
192
|
+
onClick: onDismiss
|
|
193
|
+
}) : null]
|
|
194
|
+
});
|
|
166
195
|
});
|
|
167
196
|
var Banner_default = Banner;
|
|
168
197
|
export {
|