@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
package/CHANGELOG.md
CHANGED
|
@@ -1 +1,52 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Breaking changes
|
|
6
|
+
|
|
7
|
+
- [#720](https://github.com/iTwin/design-system/pull/720): Renamed `onExpandedChange` prop for `unstable_ErrorRegion.Root` to `setOpen`.
|
|
8
|
+
Renamed `expanded` prop for `unstable_ErrorRegion.Root` to `open`.
|
|
9
|
+
- [#709](https://github.com/iTwin/design-system/pull/709): `unstable_AccordionItem` breaking changes:
|
|
10
|
+
|
|
11
|
+
- `AccordionItem.Trigger` renamed to `AccordionItem.Header` and no longer represents the underlying `<button>` element (see `AccordionItem.Label`).
|
|
12
|
+
- `AccordionItem.Label` must be wrapped with the new `AccordionItem.Button`.
|
|
13
|
+
|
|
14
|
+
```diff
|
|
15
|
+
<AccordionItem.Root>
|
|
16
|
+
+ <AccordionItem.Header>
|
|
17
|
+
- <AccordionItem.Trigger>
|
|
18
|
+
+ <AccordionItem.Button>
|
|
19
|
+
+ <AccordionItem.Label>Label</AccordionItem.Label>
|
|
20
|
+
+ </AccordionItem.Button>
|
|
21
|
+
- <AccordionItem.Label>Label</AccordionItem.Label>
|
|
22
|
+
+ </AccordionItem.Header>
|
|
23
|
+
- </AccordionItem.Trigger>
|
|
24
|
+
<AccordionItem.Content>Body</AccordionItem.Content>
|
|
25
|
+
</AccordionItem.Root>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- [#720](https://github.com/iTwin/design-system/pull/720): Renamed `onOpenChange` prop for `unstable_AccordionItem.Root` to `setOpen`.
|
|
29
|
+
|
|
30
|
+
### Non-breaking changes
|
|
31
|
+
|
|
32
|
+
- [#709](https://github.com/iTwin/design-system/pull/709): Introduce `unstable_AccordionItem.Heading` component for wrapping `unstable_AccordionItem.Button` and `unstable_AccordionItem.Button` which represents the underlying `<button>` element.
|
|
33
|
+
- Updated dependencies:
|
|
34
|
+
- @stratakit/foundations@0.1.4
|
|
35
|
+
|
|
36
|
+
## 0.1.1
|
|
37
|
+
|
|
38
|
+
- [#704](https://github.com/iTwin/design-system/pull/704): The following components have been moved from `@stratakit/bricks` into `@stratakit/structures`.
|
|
39
|
+
|
|
40
|
+
- `unstable_AccordionItem`
|
|
41
|
+
- `unstable_Banner`
|
|
42
|
+
- `Chip`
|
|
43
|
+
- `DropdownMenu`
|
|
44
|
+
- `unstable_ErrorRegion`
|
|
45
|
+
- `Table`
|
|
46
|
+
- `Tabs`
|
|
47
|
+
- `unstable_Toolbar`
|
|
48
|
+
- `Tree`
|
|
49
|
+
|
|
50
|
+
- Updated dependencies:
|
|
51
|
+
- @stratakit/bricks@0.2.0
|
|
52
|
+
- @stratakit/foundations@0.1.3
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import type { BaseProps } from "@stratakit/foundations/secret-internals";
|
|
2
|
+
interface AccordionItemProps extends BaseProps {
|
|
3
|
+
/**
|
|
4
|
+
* The accordion item’s initial open state.
|
|
5
|
+
*
|
|
6
|
+
* @default false
|
|
7
|
+
*/
|
|
8
|
+
defaultOpen?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The accordion item’s controlled open state.
|
|
11
|
+
*
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
open?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Callback fired when the accordion item is opened.
|
|
17
|
+
*
|
|
18
|
+
* Should be used with the `open` prop.
|
|
19
|
+
*/
|
|
20
|
+
setOpen?: (open: boolean) => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* An item within an accordion. Disclosed content with a label.
|
|
24
|
+
*
|
|
25
|
+
* Bare minimum example:
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <AccordionItem.Root>
|
|
28
|
+
* <AccordionItem.Header>
|
|
29
|
+
* <AccordionItem.Button>
|
|
30
|
+
* <AccordionItem.Label>Label</AccordionItem.Label>
|
|
31
|
+
* </AccordionItem.Button>
|
|
32
|
+
* <AccordionItem.Marker />
|
|
33
|
+
* </AccordionItem.Header>
|
|
34
|
+
* <AccordionItem.Content>Body</AccordionItem.Content>
|
|
35
|
+
* </AccordionItem.Root>
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* If the accordion item discloses a significant section of the page, it may be
|
|
39
|
+
* desirable to markup its label as a heading for accessibility purposes (e.g.
|
|
40
|
+
* screen reader users often navigate by heading). For those cases, you can wrap
|
|
41
|
+
* the `AccordionItem.Button` component with an `AccordionItem.Heading`
|
|
42
|
+
* component and use its `render` prop for rendering an HTML heading element.
|
|
43
|
+
* ```tsx
|
|
44
|
+
* <AccordionItem.Root>
|
|
45
|
+
* <AccordionItem.Header>
|
|
46
|
+
* <AccordionItem.Heading render={<h2 />}>
|
|
47
|
+
* <AccordionItem.Button>
|
|
48
|
+
* <AccordionItem.Label>Label</AccordionItem.Label>
|
|
49
|
+
* </AccordionItem.Button>
|
|
50
|
+
* </AccordionItem.Heading>
|
|
51
|
+
* <AccordionItem.Marker />
|
|
52
|
+
* </AccordionItem.Header>
|
|
53
|
+
* <AccordionItem.Content>Body</AccordionItem.Content>
|
|
54
|
+
* </AccordionItem.Root>
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* Example with a decoration:
|
|
58
|
+
* ```tsx
|
|
59
|
+
* <AccordionItem.Root>
|
|
60
|
+
* <AccordionItem.Header>
|
|
61
|
+
* <AccordionItem.Decoration render={<Icon href={placeholder} />} />
|
|
62
|
+
* <AccordionItem.Button>
|
|
63
|
+
* <AccordionItem.Label>Label</AccordionItem.Label>
|
|
64
|
+
* </AccordionItem.Button>
|
|
65
|
+
* <AccordionItem.Marker />
|
|
66
|
+
* </AccordionItem.Header>
|
|
67
|
+
* <AccordionItem.Content>Body</AccordionItem.Content>
|
|
68
|
+
* </AccordionItem.Root>
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare const AccordionItemRoot: import("react").ForwardRefExoticComponent<AccordionItemProps & import("react").RefAttributes<HTMLDivElement | HTMLElement>>;
|
|
72
|
+
/**
|
|
73
|
+
* The always visible header of an accordion item.
|
|
74
|
+
*
|
|
75
|
+
* Must include an `AccordionItem.Button` and `AccordionItem.Marker` as a direct
|
|
76
|
+
* descendants.
|
|
77
|
+
*
|
|
78
|
+
* Example:
|
|
79
|
+
* ```tsx
|
|
80
|
+
* <AccordionItem.Root>
|
|
81
|
+
* <AccordionItem.Header>
|
|
82
|
+
* <AccordionItem.Button>
|
|
83
|
+
* <AccordionItem.Label>Label</AccordionItem.Label>
|
|
84
|
+
* </AccordionItem.Button>
|
|
85
|
+
* <AccordionItem.Marker />
|
|
86
|
+
* </AccordionItem.Header>
|
|
87
|
+
* <AccordionItem.Content>Body</AccordionItem.Content>
|
|
88
|
+
* </AccordionItem.Root>
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
declare const AccordionItemHeader: 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>>;
|
|
92
|
+
/**
|
|
93
|
+
* The accordion item button.
|
|
94
|
+
*
|
|
95
|
+
* Must be a direct descendant of `AccordionItem.Header`.
|
|
96
|
+
*
|
|
97
|
+
* Example:
|
|
98
|
+
* ```tsx
|
|
99
|
+
* <AccordionItem.Header>
|
|
100
|
+
* <AccordionItem.Button>
|
|
101
|
+
* <AccordionItem.Label>Label</AccordionItem.Label>
|
|
102
|
+
* </AccordionItem.Button>
|
|
103
|
+
* <AccordionItem.Marker />
|
|
104
|
+
* </AccordionItem.Header>
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
declare const AccordionItemButton: import("react").ForwardRefExoticComponent<Pick<import("@ariakit/react/role").RoleProps, "render"> & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "render"> & import("react").RefAttributes<HTMLElement | HTMLButtonElement>>;
|
|
108
|
+
/**
|
|
109
|
+
* An accordion item’s label.
|
|
110
|
+
*
|
|
111
|
+
* Must be a descendant of `AccordionItem.Button`.
|
|
112
|
+
*
|
|
113
|
+
* Example:
|
|
114
|
+
* ```tsx
|
|
115
|
+
* <AccordionItem.Button>
|
|
116
|
+
* <AccordionItem.Label>Label</AccordionItem.Label>
|
|
117
|
+
* </AccordionItem.Button>
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
declare const AccordionItemLabel: 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>>;
|
|
121
|
+
/**
|
|
122
|
+
* The always-visible, optional decoration of an accordion item’s button.
|
|
123
|
+
*
|
|
124
|
+
* Use as a direct descendant of `AccordionItem.Header`. This will be visually
|
|
125
|
+
* presented before the button’s label.
|
|
126
|
+
*
|
|
127
|
+
* Example:
|
|
128
|
+
* ```tsx
|
|
129
|
+
* <AccordionItem.Header>
|
|
130
|
+
* <AccordionItem.Decoration render={<Icon href={placeholder} />} />
|
|
131
|
+
* <AccordionItem.Button>
|
|
132
|
+
* <AccordionItem.Label>Label</AccordionItem.Label>
|
|
133
|
+
* </AccordionItem.Button>
|
|
134
|
+
* <AccordionItem.Marker />
|
|
135
|
+
* </AccordionItem.Header>
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
declare const AccordionItemDecoration: 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>>;
|
|
139
|
+
/**
|
|
140
|
+
* The visual marker of an accordion item’s button.
|
|
141
|
+
*
|
|
142
|
+
* Example:
|
|
143
|
+
* ```tsx
|
|
144
|
+
* <AccordionItem.Header>
|
|
145
|
+
* <AccordionItem.Button>
|
|
146
|
+
* <AccordionItem.Label>Label</AccordionItem.Label>
|
|
147
|
+
* </AccordionItem.Button>
|
|
148
|
+
* <AccordionItem.Marker />
|
|
149
|
+
* </AccordionItem.Header>
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* Pass an icon as a child to override the default chevron icon:
|
|
153
|
+
* ```tsx
|
|
154
|
+
* <AccordionItem.Header>
|
|
155
|
+
* <AccordionItem.Button>
|
|
156
|
+
* <AccordionItem.Label>Label</AccordionItem.Label>
|
|
157
|
+
* </AccordionItem.Button>
|
|
158
|
+
* <AccordionItem.Marker>
|
|
159
|
+
* <Icon href={placeholder} />
|
|
160
|
+
* </AccordionItem.Marker>
|
|
161
|
+
* </AccordionItem.Header>
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
declare const AccordionItemMarker: 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>>;
|
|
165
|
+
/**
|
|
166
|
+
* The disclosed content of the accordion item.
|
|
167
|
+
*
|
|
168
|
+
* Example:
|
|
169
|
+
* ```tsx
|
|
170
|
+
* <AccordionItem.Root>
|
|
171
|
+
* <AccordionItem.Header>
|
|
172
|
+
* <AccordionItem.Button>
|
|
173
|
+
* <AccordionItem.Label>Label</AccordionItem.Label>
|
|
174
|
+
* </AccordionItem.Button>
|
|
175
|
+
* <AccordionItem.Marker />
|
|
176
|
+
* </AccordionItem.Header>
|
|
177
|
+
* <AccordionItem.Content>Body</AccordionItem.Content>
|
|
178
|
+
* </AccordionItem.Root>
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
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>>;
|
|
182
|
+
interface AccordionItemHeadingProps extends BaseProps {
|
|
183
|
+
render: NonNullable<BaseProps["render"]>;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* A heading for wrapping `AccordionItem.Button`.
|
|
187
|
+
*
|
|
188
|
+
* The `render` prop is required.
|
|
189
|
+
*
|
|
190
|
+
* Example:
|
|
191
|
+
* ```tsx
|
|
192
|
+
* <AccordionItem.Header>
|
|
193
|
+
* <AccordionItem.Heading render={<h2 />}>
|
|
194
|
+
* <AccordionItem.Button>
|
|
195
|
+
* <AccordionItem.Label>Label</AccordionItem.Label>
|
|
196
|
+
* </AccordionItem.Button>
|
|
197
|
+
* </AccordionItem.Heading>
|
|
198
|
+
* <AccordionItem.Marker />
|
|
199
|
+
* </AccordionItem.Header>
|
|
200
|
+
*/
|
|
201
|
+
declare const AccordionItemHeading: import("react").ForwardRefExoticComponent<AccordionItemHeadingProps & import("react").RefAttributes<HTMLDivElement | HTMLElement>>;
|
|
202
|
+
export { AccordionItemRoot as Root, AccordionItemContent as Content, AccordionItemHeader as Header, AccordionItemButton as Button, AccordionItemLabel as Label, AccordionItemDecoration as Decoration, AccordionItemMarker as Marker, AccordionItemHeading as Heading, };
|
|
@@ -0,0 +1,140 @@
|
|
|
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
|
+
const AccordionItemHeader = forwardRef(
|
|
52
|
+
(props, forwardedRef) => /* @__PURE__ */ jsx(GhostAligner, { align: "block", children: /* @__PURE__ */ jsx(
|
|
53
|
+
Role,
|
|
54
|
+
{
|
|
55
|
+
...props,
|
|
56
|
+
className: cx("\u{1F95D}-accordion-item-header", props.className),
|
|
57
|
+
ref: forwardedRef
|
|
58
|
+
}
|
|
59
|
+
) })
|
|
60
|
+
);
|
|
61
|
+
const AccordionItemButton = forwardRef(
|
|
62
|
+
(props, forwardedRef) => /* @__PURE__ */ jsx(
|
|
63
|
+
Disclosure,
|
|
64
|
+
{
|
|
65
|
+
...props,
|
|
66
|
+
className: cx("\u{1F95D}-accordion-item-button", props.className),
|
|
67
|
+
ref: forwardedRef
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
);
|
|
71
|
+
const AccordionItemLabel = forwardRef(
|
|
72
|
+
(props, forwardedRef) => /* @__PURE__ */ jsx(
|
|
73
|
+
Text,
|
|
74
|
+
{
|
|
75
|
+
...props,
|
|
76
|
+
variant: "body-sm",
|
|
77
|
+
className: cx("\u{1F95D}-accordion-item-label", props.className),
|
|
78
|
+
ref: forwardedRef
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
const AccordionItemDecoration = forwardRef(
|
|
83
|
+
(props, forwardedRef) => /* @__PURE__ */ jsx(
|
|
84
|
+
Role,
|
|
85
|
+
{
|
|
86
|
+
...props,
|
|
87
|
+
className: cx("\u{1F95D}-accordion-item-decoration", props.className),
|
|
88
|
+
ref: forwardedRef
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
);
|
|
92
|
+
const AccordionItemMarker = forwardRef(
|
|
93
|
+
(props, forwardedRef) => /* @__PURE__ */ jsx(
|
|
94
|
+
IconButtonPresentation,
|
|
95
|
+
{
|
|
96
|
+
...props,
|
|
97
|
+
variant: "ghost",
|
|
98
|
+
className: cx("\u{1F95D}-accordion-item-marker", props.className),
|
|
99
|
+
ref: forwardedRef,
|
|
100
|
+
children: props.children ?? /* @__PURE__ */ jsx(
|
|
101
|
+
ChevronDown,
|
|
102
|
+
{
|
|
103
|
+
"aria-hidden": "true",
|
|
104
|
+
className: "\u{1F95D}-accordion-item-marker-chevron"
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
);
|
|
110
|
+
const AccordionItemContent = forwardRef(
|
|
111
|
+
(props, forwardedRef) => /* @__PURE__ */ jsx(
|
|
112
|
+
DisclosureContent,
|
|
113
|
+
{
|
|
114
|
+
...props,
|
|
115
|
+
className: cx("\u{1F95D}-accordion-item-content", 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}-accordion-item-heading", props.className),
|
|
127
|
+
ref: forwardedRef
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
);
|
|
131
|
+
export {
|
|
132
|
+
AccordionItemButton as Button,
|
|
133
|
+
AccordionItemContent as Content,
|
|
134
|
+
AccordionItemDecoration as Decoration,
|
|
135
|
+
AccordionItemHeader as Header,
|
|
136
|
+
AccordionItemHeading as Heading,
|
|
137
|
+
AccordionItemLabel as Label,
|
|
138
|
+
AccordionItemMarker as Marker,
|
|
139
|
+
AccordionItemRoot as Root
|
|
140
|
+
};
|
package/dist/Banner.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { BaseProps } from "@stratakit/foundations/secret-internals";
|
|
3
|
+
/**
|
|
4
|
+
* A banner to highlight information and also optionally provide actions.
|
|
5
|
+
* The information could be very important (like a call to action) or reasonably import (like a status message).
|
|
6
|
+
*
|
|
7
|
+
* Example:
|
|
8
|
+
* ```tsx
|
|
9
|
+
* <Banner label="Title" message="Message" icon={placeholderIcon} onDismiss={() => {}} />
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare const Banner: React.ForwardRefExoticComponent<Omit<BaseProps, "children"> & {
|
|
13
|
+
/**
|
|
14
|
+
* Icon to be displayed inside the banner.
|
|
15
|
+
*
|
|
16
|
+
* Can be a URL of an SVG from the `@stratakit/icons` package,
|
|
17
|
+
* or a custom JSX icon.
|
|
18
|
+
*
|
|
19
|
+
* - If `icon=undefined` and `tone="neutral"`, no icon is shown.
|
|
20
|
+
* - If `icon=undefined` and `tone!="neutral"`, the status icon will be shown.
|
|
21
|
+
*/
|
|
22
|
+
icon?: string | React.JSX.Element;
|
|
23
|
+
/**
|
|
24
|
+
* The label displayed inside the banner.
|
|
25
|
+
*
|
|
26
|
+
* Either pass a string or a `<VisuallyHidden>` component if you don't want the label to be visible.
|
|
27
|
+
*/
|
|
28
|
+
label: string | React.JSX.Element;
|
|
29
|
+
/**
|
|
30
|
+
* The content of the banner.
|
|
31
|
+
*/
|
|
32
|
+
message: React.ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* Callback invoked when the dismiss ("❌") button is clicked.
|
|
35
|
+
*
|
|
36
|
+
* If `undefined`, the dismiss button will not be rendered.
|
|
37
|
+
*
|
|
38
|
+
* @default undefined
|
|
39
|
+
*/
|
|
40
|
+
onDismiss?: () => void;
|
|
41
|
+
/**
|
|
42
|
+
* The actions available for the banner.
|
|
43
|
+
*
|
|
44
|
+
* Example with one action:
|
|
45
|
+
* ```tsx
|
|
46
|
+
* actions={<Button key={…} onClick={}>Action</Button>}
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* Example with two `Button`s:
|
|
50
|
+
* ```tsx
|
|
51
|
+
* actions={
|
|
52
|
+
* <>
|
|
53
|
+
* <Button key={…} onClick={…}>Action 1</Button>,
|
|
54
|
+
* <Button key={…} onClick={…}>Action 2</Button>,
|
|
55
|
+
* </>
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* Example with two `Anchor`s as `Button`:
|
|
60
|
+
* ```tsx
|
|
61
|
+
* actions={
|
|
62
|
+
* <>
|
|
63
|
+
* <Anchor key={…} render={<button />} onClick={…}>Action 1</Anchor>,
|
|
64
|
+
* <Anchor key={…} render={<button />} onClick={…}>Action 2</Anchor>,
|
|
65
|
+
* </>
|
|
66
|
+
* }
|
|
67
|
+
*/
|
|
68
|
+
actions?: React.ReactNode;
|
|
69
|
+
/**
|
|
70
|
+
* The tone of the banner.
|
|
71
|
+
*
|
|
72
|
+
* @default "neutral"
|
|
73
|
+
*/
|
|
74
|
+
tone?: "neutral" | "info" | "positive" | "attention" | "critical";
|
|
75
|
+
/**
|
|
76
|
+
* The variant of the banner.
|
|
77
|
+
*
|
|
78
|
+
* @default "outline"
|
|
79
|
+
*/
|
|
80
|
+
variant?: "outline";
|
|
81
|
+
} & React.RefAttributes<HTMLDivElement | HTMLElement>>;
|
package/dist/Banner.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
export {
|
|
70
|
+
Banner
|
|
71
|
+
};
|
package/dist/Chip.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { BaseProps } from "@stratakit/foundations/secret-internals";
|
|
3
|
+
interface ChipProps extends Omit<BaseProps<"div">, "children"> {
|
|
4
|
+
/**
|
|
5
|
+
* The label displayed inside the chip.
|
|
6
|
+
*/
|
|
7
|
+
label: string;
|
|
8
|
+
/**
|
|
9
|
+
* The variant style of the Chip.
|
|
10
|
+
* Use "solid" for primary states and "outline" for less prominent states.
|
|
11
|
+
*
|
|
12
|
+
* @default "solid"
|
|
13
|
+
*/
|
|
14
|
+
variant?: "solid" | "outline";
|
|
15
|
+
/**
|
|
16
|
+
* Callback invoked when the dismiss ("❌") button is clicked.
|
|
17
|
+
*
|
|
18
|
+
* If `undefined`, the dismiss button will not be rendered.
|
|
19
|
+
*
|
|
20
|
+
* @default undefined
|
|
21
|
+
*/
|
|
22
|
+
onDismiss?: () => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Chip is a UI component used to represent an item, attribute, or action in a compact visual style.
|
|
26
|
+
* It supports two visual variants: `solid` for primary emphasis and `outline` for less prominent states.
|
|
27
|
+
*
|
|
28
|
+
* Example:
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <Chip label="Value" />
|
|
31
|
+
* <Chip label="Value" variant="outline" />
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare const Chip: React.ForwardRefExoticComponent<ChipProps & React.RefAttributes<HTMLDivElement | HTMLElement>>;
|
|
35
|
+
export {};
|
package/dist/Chip.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
export {
|
|
40
|
+
Chip
|
|
41
|
+
};
|