@itwin/itwinui-react 5.0.0-alpha.0 → 5.0.0-alpha.2
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 +24 -0
- package/dist/DEV/bricks/Anchor.js +20 -22
- package/dist/DEV/bricks/Button.js +17 -15
- package/dist/DEV/bricks/Checkbox.js +19 -15
- package/dist/DEV/bricks/Chip.js +21 -0
- package/dist/DEV/bricks/Description.js +27 -0
- package/dist/DEV/bricks/Divider.js +14 -16
- package/dist/DEV/bricks/DropdownMenu.js +60 -44
- package/dist/DEV/bricks/Field.js +66 -16
- package/dist/DEV/bricks/Icon.js +45 -44
- package/dist/DEV/bricks/IconButton.js +24 -19
- package/dist/DEV/bricks/Kbd.js +46 -16
- package/dist/DEV/bricks/Label.js +2 -2
- package/dist/DEV/bricks/ListItem.js +16 -16
- package/dist/DEV/bricks/Radio.js +5 -3
- package/dist/DEV/bricks/Root.js +45 -43
- package/dist/DEV/bricks/Select.js +57 -0
- package/dist/DEV/bricks/Spinner.js +40 -0
- package/dist/DEV/bricks/Switch.js +20 -16
- package/dist/DEV/bricks/Tabs.js +15 -16
- package/dist/DEV/bricks/Text.js +20 -0
- package/dist/DEV/bricks/TextBox.js +55 -46
- package/dist/DEV/bricks/Textarea.js +25 -21
- package/dist/DEV/bricks/Tooltip.js +65 -57
- package/dist/DEV/bricks/Tree.js +133 -66
- package/dist/DEV/bricks/VisuallyHidden.js +6 -4
- package/dist/DEV/bricks/index.js +12 -0
- package/dist/DEV/bricks/styles.css.js +1 -1
- package/dist/DEV/bricks/~hooks.js +13 -0
- package/dist/DEV/bricks/~utils.js +3 -0
- package/dist/DEV/foundations/styles.css.js +1 -1
- package/dist/bricks/Anchor.d.ts +12 -3
- package/dist/bricks/Anchor.js +20 -22
- package/dist/bricks/Button.d.ts +27 -4
- package/dist/bricks/Button.js +17 -15
- package/dist/bricks/Checkbox.d.ts +17 -3
- package/dist/bricks/Checkbox.js +19 -15
- package/dist/bricks/Chip.d.ts +22 -0
- package/dist/bricks/Chip.js +20 -0
- package/dist/bricks/Description.d.ts +20 -0
- package/dist/bricks/Description.js +27 -0
- package/dist/bricks/Divider.d.ts +3 -4
- package/dist/bricks/Divider.js +14 -16
- package/dist/bricks/DropdownMenu.d.ts +60 -10
- package/dist/bricks/DropdownMenu.js +60 -44
- package/dist/bricks/Field.d.ts +30 -2
- package/dist/bricks/Field.js +66 -16
- package/dist/bricks/Icon.d.ts +4 -4
- package/dist/bricks/Icon.js +44 -43
- package/dist/bricks/IconButton.d.ts +4 -4
- package/dist/bricks/IconButton.js +24 -19
- package/dist/bricks/Kbd.d.ts +32 -3
- package/dist/bricks/Kbd.js +39 -16
- package/dist/bricks/Label.d.ts +22 -3
- package/dist/bricks/Label.js +2 -2
- package/dist/bricks/ListItem.d.ts +2 -3
- package/dist/bricks/ListItem.js +15 -15
- package/dist/bricks/Radio.d.ts +17 -3
- package/dist/bricks/Radio.js +5 -3
- package/dist/bricks/Root.d.ts +11 -2
- package/dist/bricks/Root.js +45 -43
- package/dist/bricks/Select.d.ts +45 -0
- package/dist/bricks/Select.js +57 -0
- package/dist/bricks/Spinner.d.ts +31 -0
- package/dist/bricks/Spinner.js +39 -0
- package/dist/bricks/Switch.d.ts +17 -3
- package/dist/bricks/Switch.js +20 -16
- package/dist/bricks/Tabs.d.ts +66 -5
- package/dist/bricks/Tabs.js +15 -16
- package/dist/bricks/Text.d.ts +22 -0
- package/dist/bricks/Text.js +19 -0
- package/dist/bricks/TextBox.d.ts +39 -9
- package/dist/bricks/TextBox.js +55 -46
- package/dist/bricks/Textarea.d.ts +14 -4
- package/dist/bricks/Textarea.js +25 -21
- package/dist/bricks/Tooltip.d.ts +11 -4
- package/dist/bricks/Tooltip.js +65 -57
- package/dist/bricks/Tree.d.ts +79 -16
- package/dist/bricks/Tree.js +128 -62
- package/dist/bricks/VisuallyHidden.d.ts +15 -3
- package/dist/bricks/VisuallyHidden.js +6 -4
- package/dist/bricks/index.d.ts +6 -0
- package/dist/bricks/index.js +12 -0
- package/dist/bricks/styles.css.js +1 -1
- package/dist/bricks/~hooks.d.ts +15 -0
- package/dist/bricks/~hooks.js +13 -0
- package/dist/bricks/~utils.d.ts +20 -0
- package/dist/bricks/~utils.js +3 -0
- package/dist/foundations/styles.css.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 5.0.0-alpha.2
|
|
4
|
+
|
|
5
|
+
- Added initial `Tree` component, exposed as `<Tree.Root>` and `<Tree.Item>` subcomponents.
|
|
6
|
+
- Added initial `<Spinner>` component for indicating quick, indeterminate progress.
|
|
7
|
+
- Added `<Description>` component to be used within a `<Field>`.
|
|
8
|
+
- Added initial `<Chip>` component.
|
|
9
|
+
- Added `symbol` prop to `<Kbd>` for displaying predefined symbols.
|
|
10
|
+
- Added `focusable` prop to `<Tabs.TabPanel>` component.
|
|
11
|
+
- Fixed a visual issue where light color-scheme was using dark shadows.
|
|
12
|
+
|
|
13
|
+
## 5.0.0-alpha.1
|
|
14
|
+
|
|
15
|
+
- Added `<Text>` component with a `variant` prop to support all text styles from Figma.
|
|
16
|
+
- Added `Select` component built on top of the HTML `<select>` element. Exposed as `<Select.Root>` and `<Select.HtmlSelect>`.
|
|
17
|
+
- Added `shortcuts` prop to `<DropdownMenu.Item>`.
|
|
18
|
+
- Added JSDoc comments to all components for inline IDE hints.
|
|
19
|
+
- Fixed `<Kbd>` component using the wrong font.
|
|
20
|
+
- Fixed some visual issues.
|
|
21
|
+
|
|
22
|
+
## 5.0.0-alpha.0
|
|
23
|
+
|
|
24
|
+
Initial release 🥳
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
2
|
import cx from "classnames";
|
|
4
3
|
import * as Ariakit from "@ariakit/react";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
);
|
|
4
|
+
import { forwardRef } from "./~utils.js";
|
|
5
|
+
const Anchor = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const { tone = "neutral", ...rest } = props;
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
Ariakit.Role.a,
|
|
9
|
+
{
|
|
10
|
+
...rest,
|
|
11
|
+
"data-kiwi-tone": tone,
|
|
12
|
+
className: cx("\u{1F95D}-anchor", props.className),
|
|
13
|
+
render: /* @__PURE__ */ jsx(
|
|
14
|
+
Ariakit.Focusable,
|
|
15
|
+
{
|
|
16
|
+
accessibleWhenDisabled: true,
|
|
17
|
+
render: props.render || /* @__PURE__ */ jsx("a", {})
|
|
18
|
+
}
|
|
19
|
+
),
|
|
20
|
+
ref: forwardedRef
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
});
|
|
26
24
|
DEV: Anchor.displayName = "Anchor";
|
|
27
25
|
export {
|
|
28
26
|
Anchor
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
2
|
import cx from "classnames";
|
|
4
3
|
import * as Ariakit from "@ariakit/react";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
4
|
+
import { forwardRef } from "./~utils.js";
|
|
5
|
+
const Button = forwardRef(
|
|
6
|
+
(props, forwardedRef) => {
|
|
7
|
+
const { variant = "solid", tone = "neutral", ...rest } = props;
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
|
+
Ariakit.Button,
|
|
10
|
+
{
|
|
11
|
+
accessibleWhenDisabled: true,
|
|
12
|
+
...rest,
|
|
13
|
+
"data-kiwi-variant": variant,
|
|
14
|
+
"data-kiwi-tone": tone,
|
|
15
|
+
className: cx("\u{1F95D}-button", props.className),
|
|
16
|
+
ref: forwardedRef
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
);
|
|
19
21
|
DEV: Button.displayName = "Button";
|
|
20
22
|
export {
|
|
21
23
|
Button
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
2
|
import cx from "classnames";
|
|
4
3
|
import * as Ariakit from "@ariakit/react";
|
|
5
|
-
import { useFieldId } from "./Field.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
import { useFieldDescribedBy, useFieldId } from "./Field.js";
|
|
5
|
+
import { forwardRef } from "./~utils.js";
|
|
6
|
+
const Checkbox = forwardRef(
|
|
7
|
+
(props, forwardedRef) => {
|
|
8
|
+
const fieldId = useFieldId();
|
|
9
|
+
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
Ariakit.Checkbox,
|
|
12
|
+
{
|
|
13
|
+
accessibleWhenDisabled: true,
|
|
14
|
+
id: fieldId,
|
|
15
|
+
...props,
|
|
16
|
+
className: cx("\u{1F95D}-checkbox", props.className),
|
|
17
|
+
"aria-describedby": describedBy,
|
|
18
|
+
ref: forwardedRef
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
);
|
|
19
23
|
DEV: Checkbox.displayName = "Checkbox";
|
|
20
24
|
export {
|
|
21
25
|
Checkbox
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import cx from "classnames";
|
|
3
|
+
import * as Ariakit from "@ariakit/react";
|
|
4
|
+
import { forwardRef } from "./~utils.js";
|
|
5
|
+
const Chip = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const { variant = "solid", children, ...rest } = props;
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
Ariakit.Role.div,
|
|
9
|
+
{
|
|
10
|
+
"data-kiwi-variant": variant,
|
|
11
|
+
...rest,
|
|
12
|
+
className: cx("\u{1F95D}-chip", props.className),
|
|
13
|
+
ref: forwardedRef,
|
|
14
|
+
children
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
DEV: Chip.displayName = "Chip";
|
|
19
|
+
export {
|
|
20
|
+
Chip
|
|
21
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { forwardRef } from "./~utils.js";
|
|
4
|
+
import cx from "classnames";
|
|
5
|
+
import { Text } from "./Text.js";
|
|
6
|
+
import { useFieldRegisterDescribedBy } from "./Field.js";
|
|
7
|
+
const Description = forwardRef(
|
|
8
|
+
(props, forwardedRef) => {
|
|
9
|
+
const generatedId = React.useId();
|
|
10
|
+
const { id = generatedId, tone, ...rest } = props;
|
|
11
|
+
useFieldRegisterDescribedBy(id);
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
Text,
|
|
14
|
+
{
|
|
15
|
+
...rest,
|
|
16
|
+
id,
|
|
17
|
+
variant: "caption-md",
|
|
18
|
+
"data-kiwi-tone": tone ?? "neutral",
|
|
19
|
+
className: cx("\u{1F95D}-description", props.className),
|
|
20
|
+
ref: forwardedRef
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
export {
|
|
26
|
+
Description
|
|
27
|
+
};
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
2
|
import cx from "classnames";
|
|
4
3
|
import * as Ariakit from "@ariakit/react";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
);
|
|
4
|
+
import { forwardRef } from "./~utils.js";
|
|
5
|
+
const Divider = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const { presentational, ...rest } = props;
|
|
7
|
+
const Comp = presentational ? Ariakit.Role : Ariakit.Separator;
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
|
+
Comp,
|
|
10
|
+
{
|
|
11
|
+
...rest,
|
|
12
|
+
className: cx("\u{1F95D}-divider", props.className),
|
|
13
|
+
"data-kiwi-orientation": props.orientation,
|
|
14
|
+
ref: forwardedRef
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
});
|
|
20
18
|
DEV: Divider.displayName = "Divider";
|
|
21
19
|
export {
|
|
22
20
|
Divider
|
|
@@ -4,8 +4,9 @@ import cx from "classnames";
|
|
|
4
4
|
import * as Ariakit from "@ariakit/react";
|
|
5
5
|
import * as ListItem from "./ListItem.js";
|
|
6
6
|
import { Button } from "./Button.js";
|
|
7
|
+
import { Kbd } from "./Kbd.js";
|
|
7
8
|
import { DisclosureArrow } from "./Icon.js";
|
|
8
|
-
import { supportsPopover } from "./~utils.js";
|
|
9
|
+
import { forwardRef, supportsPopover } from "./~utils.js";
|
|
9
10
|
function DropdownMenu(props) {
|
|
10
11
|
const {
|
|
11
12
|
children,
|
|
@@ -15,8 +16,8 @@ function DropdownMenu(props) {
|
|
|
15
16
|
defaultOpen: defaultOpenProp
|
|
16
17
|
} = props;
|
|
17
18
|
const store = Ariakit.useMenuStore();
|
|
18
|
-
const open = Ariakit.useStoreState(store, (
|
|
19
|
-
const popover = Ariakit.useStoreState(store, (
|
|
19
|
+
const open = Ariakit.useStoreState(store, (state) => state.open);
|
|
20
|
+
const popover = Ariakit.useStoreState(store, (state) => state.popoverElement);
|
|
20
21
|
React.useEffect(
|
|
21
22
|
function syncPopoverWithOpenState() {
|
|
22
23
|
if (popover?.isConnected) {
|
|
@@ -38,49 +39,64 @@ function DropdownMenu(props) {
|
|
|
38
39
|
);
|
|
39
40
|
}
|
|
40
41
|
DEV: DropdownMenu.displayName = "DropdownMenu.Root";
|
|
41
|
-
const DropdownMenuContent =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
const DropdownMenuContent = forwardRef(
|
|
43
|
+
(props, forwardedRef) => {
|
|
44
|
+
return /* @__PURE__ */ jsx(
|
|
45
|
+
Ariakit.Menu,
|
|
46
|
+
{
|
|
47
|
+
portal: !supportsPopover,
|
|
48
|
+
unmountOnHide: true,
|
|
49
|
+
...props,
|
|
50
|
+
style: { zIndex: supportsPopover ? void 0 : 9999, ...props.style },
|
|
51
|
+
wrapperProps: { popover: "manual" },
|
|
52
|
+
className: cx("\u{1F95D}-dropdown-menu", props.className),
|
|
53
|
+
ref: forwardedRef
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
);
|
|
55
58
|
DEV: DropdownMenuContent.displayName = "DropdownMenu.Content";
|
|
56
|
-
const DropdownMenuButton =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
children
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
59
|
+
const DropdownMenuButton = forwardRef(
|
|
60
|
+
(props, forwardedRef) => {
|
|
61
|
+
const { accessibleWhenDisabled = true, children, ...rest } = props;
|
|
62
|
+
return /* @__PURE__ */ jsx(
|
|
63
|
+
Ariakit.MenuButton,
|
|
64
|
+
{
|
|
65
|
+
accessibleWhenDisabled: true,
|
|
66
|
+
render: /* @__PURE__ */ jsxs(Button, { accessibleWhenDisabled, children: [
|
|
67
|
+
children,
|
|
68
|
+
/* @__PURE__ */ jsx(DisclosureArrow, {})
|
|
69
|
+
] }),
|
|
70
|
+
...rest,
|
|
71
|
+
className: cx("\u{1F95D}-dropdown-menu-button", props.className),
|
|
72
|
+
ref: forwardedRef
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
);
|
|
72
77
|
DEV: DropdownMenuButton.displayName = "DropdownMenu.Button";
|
|
73
|
-
const DropdownMenuItem =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
const DropdownMenuItem = forwardRef(
|
|
79
|
+
(props, forwardedRef) => {
|
|
80
|
+
const { shortcuts, ...rest } = props;
|
|
81
|
+
const shortcutKeys = React.useMemo(() => {
|
|
82
|
+
return typeof shortcuts === "string" ? shortcuts.split("+").map((key) => key.trim()) : [];
|
|
83
|
+
}, [shortcuts]);
|
|
84
|
+
const hasShortcuts = shortcutKeys.length > 0;
|
|
85
|
+
return /* @__PURE__ */ jsxs(
|
|
86
|
+
Ariakit.MenuItem,
|
|
87
|
+
{
|
|
88
|
+
accessibleWhenDisabled: true,
|
|
89
|
+
...rest,
|
|
90
|
+
render: /* @__PURE__ */ jsx(ListItem.Root, { render: props.render }),
|
|
91
|
+
ref: forwardedRef,
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ jsx(ListItem.Content, { children: props.children }),
|
|
94
|
+
hasShortcuts && /* @__PURE__ */ jsx("span", { className: "\u{1F95D}-dropdown-menu-item-shortcuts", children: shortcutKeys.map((key, index) => /* @__PURE__ */ jsx(Kbd, { variant: "ghost", children: key }, `${key + index}`)) })
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
);
|
|
84
100
|
DEV: DropdownMenuItem.displayName = "DropdownMenu.Item";
|
|
85
101
|
export {
|
|
86
102
|
DropdownMenuButton as Button,
|
package/dist/DEV/bricks/Field.js
CHANGED
|
@@ -2,27 +2,77 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import * as Ariakit from "@ariakit/react";
|
|
4
4
|
import cx from "classnames";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
);
|
|
5
|
+
import { forwardRef } from "./~utils.js";
|
|
6
|
+
const Field = forwardRef((props, forwardedRef) => {
|
|
7
|
+
const fieldId = React.useId();
|
|
8
|
+
const { layout, ...rest } = props;
|
|
9
|
+
return /* @__PURE__ */ jsx(FieldIdContext.Provider, { value: fieldId, children: /* @__PURE__ */ jsx(FieldDescribedByProvider, { children: /* @__PURE__ */ jsx(
|
|
10
|
+
Ariakit.Role,
|
|
11
|
+
{
|
|
12
|
+
...rest,
|
|
13
|
+
className: cx("\u{1F95D}-field", props.className),
|
|
14
|
+
"data-kiwi-layout": layout,
|
|
15
|
+
ref: forwardedRef
|
|
16
|
+
}
|
|
17
|
+
) }) });
|
|
18
|
+
});
|
|
20
19
|
DEV: Field.displayName = "Field";
|
|
20
|
+
const FieldDescribedByContext = React.createContext(void 0);
|
|
21
|
+
function FieldDescribedByProvider(props) {
|
|
22
|
+
const [describedBy, setDescribedBy] = React.useState(/* @__PURE__ */ new Set());
|
|
23
|
+
const register = React.useCallback((id) => {
|
|
24
|
+
setDescribedBy((describedBy2) => {
|
|
25
|
+
const updated = new Set(describedBy2);
|
|
26
|
+
updated.add(id);
|
|
27
|
+
return updated;
|
|
28
|
+
});
|
|
29
|
+
}, []);
|
|
30
|
+
const unregister = React.useCallback((id) => {
|
|
31
|
+
setDescribedBy((describedBy2) => {
|
|
32
|
+
const updated = new Set(describedBy2);
|
|
33
|
+
updated.delete(id);
|
|
34
|
+
return updated;
|
|
35
|
+
});
|
|
36
|
+
}, []);
|
|
37
|
+
return /* @__PURE__ */ jsx(
|
|
38
|
+
FieldDescribedByContext.Provider,
|
|
39
|
+
{
|
|
40
|
+
value: React.useMemo(
|
|
41
|
+
() => ({
|
|
42
|
+
describedBy,
|
|
43
|
+
register,
|
|
44
|
+
unregister
|
|
45
|
+
}),
|
|
46
|
+
[describedBy, register, unregister]
|
|
47
|
+
),
|
|
48
|
+
children: props.children
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
function useFieldDescribedBy(ariaDescribedByProp) {
|
|
53
|
+
const describedBySet = React.useContext(FieldDescribedByContext)?.describedBy;
|
|
54
|
+
return React.useMemo(
|
|
55
|
+
() => !describedBySet || describedBySet.size === 0 ? ariaDescribedByProp : [...describedBySet, ariaDescribedByProp].filter(Boolean).join(" "),
|
|
56
|
+
[describedBySet, ariaDescribedByProp]
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
function useFieldRegisterDescribedBy(id) {
|
|
60
|
+
const context = React.useContext(FieldDescribedByContext);
|
|
61
|
+
const register = context?.register;
|
|
62
|
+
const unregister = context?.unregister;
|
|
63
|
+
React.useEffect(() => {
|
|
64
|
+
if (!register || !unregister) return;
|
|
65
|
+
register(id);
|
|
66
|
+
return () => unregister(id);
|
|
67
|
+
}, [id, register, unregister]);
|
|
68
|
+
}
|
|
21
69
|
const FieldIdContext = React.createContext(void 0);
|
|
22
70
|
function useFieldId() {
|
|
23
71
|
return React.useContext(FieldIdContext);
|
|
24
72
|
}
|
|
25
73
|
export {
|
|
26
74
|
Field,
|
|
27
|
-
|
|
75
|
+
useFieldDescribedBy,
|
|
76
|
+
useFieldId,
|
|
77
|
+
useFieldRegisterDescribedBy
|
|
28
78
|
};
|
package/dist/DEV/bricks/Icon.js
CHANGED
|
@@ -2,58 +2,59 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import cx from "classnames";
|
|
4
4
|
import * as Ariakit from "@ariakit/react";
|
|
5
|
-
|
|
5
|
+
import { forwardRef } from "./~utils.js";
|
|
6
|
+
const Icon = forwardRef((props, forwardedRef) => {
|
|
7
|
+
const { href, size = "regular", ...rest } = props;
|
|
8
|
+
const iconId = toIconId(size);
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
Ariakit.Role.svg,
|
|
11
|
+
{
|
|
12
|
+
"aria-hidden": true,
|
|
13
|
+
...rest,
|
|
14
|
+
"data-kiwi-size": size,
|
|
15
|
+
className: cx("\u{1F95D}-icon", props.className),
|
|
16
|
+
ref: forwardedRef,
|
|
17
|
+
children: /* @__PURE__ */ jsx("use", { href: `${props.href}#${iconId}` })
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
DEV: Icon.displayName = "Icon";
|
|
22
|
+
function toIconId(size) {
|
|
23
|
+
if (size === "large") return "icon-large";
|
|
24
|
+
return "icon";
|
|
25
|
+
}
|
|
26
|
+
const DisclosureArrow = forwardRef(
|
|
6
27
|
(props, forwardedRef) => {
|
|
7
|
-
const {
|
|
8
|
-
const
|
|
28
|
+
const { direction = "down", ...rest } = props;
|
|
29
|
+
const path = React.useMemo(() => {
|
|
30
|
+
switch (direction) {
|
|
31
|
+
case "down":
|
|
32
|
+
return /* @__PURE__ */ jsx("path", { d: "M8 10 5 7h6l-3 3Z" });
|
|
33
|
+
case "right":
|
|
34
|
+
return /* @__PURE__ */ jsx("path", { d: "M7 11V5l3 3-3 3Z" });
|
|
35
|
+
}
|
|
36
|
+
}, [direction]);
|
|
9
37
|
return /* @__PURE__ */ jsx(
|
|
10
|
-
|
|
38
|
+
Icon,
|
|
11
39
|
{
|
|
12
|
-
"data-kiwi-size": size,
|
|
13
|
-
"aria-hidden": true,
|
|
14
40
|
...rest,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
41
|
+
render: /* @__PURE__ */ jsx(
|
|
42
|
+
Ariakit.Role.svg,
|
|
43
|
+
{
|
|
44
|
+
width: "16",
|
|
45
|
+
height: "16",
|
|
46
|
+
fill: "currentColor",
|
|
47
|
+
viewBox: "0 0 16 16",
|
|
48
|
+
render: props.render,
|
|
49
|
+
children: path
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
className: cx("\u{1F95D}-disclosure-arrow", props.className),
|
|
53
|
+
ref: forwardedRef
|
|
18
54
|
}
|
|
19
55
|
);
|
|
20
56
|
}
|
|
21
57
|
);
|
|
22
|
-
DEV: Icon.displayName = "Icon";
|
|
23
|
-
function toIconId(size) {
|
|
24
|
-
if (size === "large") return "icon-large";
|
|
25
|
-
return "icon";
|
|
26
|
-
}
|
|
27
|
-
const DisclosureArrow = React.forwardRef((props, forwardedRef) => {
|
|
28
|
-
const { direction = "down", ...rest } = props;
|
|
29
|
-
const path = React.useMemo(() => {
|
|
30
|
-
switch (direction) {
|
|
31
|
-
case "down":
|
|
32
|
-
return /* @__PURE__ */ jsx("path", { d: "M8 10 5 7h6l-3 3Z" });
|
|
33
|
-
case "right":
|
|
34
|
-
return /* @__PURE__ */ jsx("path", { d: "M7 11V5l3 3-3 3Z" });
|
|
35
|
-
}
|
|
36
|
-
}, [direction]);
|
|
37
|
-
return /* @__PURE__ */ jsx(
|
|
38
|
-
Icon,
|
|
39
|
-
{
|
|
40
|
-
...rest,
|
|
41
|
-
render: /* @__PURE__ */ jsx(
|
|
42
|
-
Ariakit.Role.svg,
|
|
43
|
-
{
|
|
44
|
-
width: "16",
|
|
45
|
-
height: "16",
|
|
46
|
-
fill: "currentColor",
|
|
47
|
-
viewBox: "0 0 16 16",
|
|
48
|
-
render: props.render,
|
|
49
|
-
children: path
|
|
50
|
-
}
|
|
51
|
-
),
|
|
52
|
-
className: cx("\u{1F95D}-disclosure-arrow", props.className),
|
|
53
|
-
ref: forwardedRef
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
});
|
|
57
58
|
DEV: DisclosureArrow.displayName = "DisclosureArrow";
|
|
58
59
|
export {
|
|
59
60
|
DisclosureArrow,
|
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
2
|
import cx from "classnames";
|
|
3
|
+
import * as Ariakit from "@ariakit/react";
|
|
4
4
|
import { Button } from "./Button.js";
|
|
5
5
|
import { VisuallyHidden } from "./VisuallyHidden.js";
|
|
6
6
|
import { Icon } from "./Icon.js";
|
|
7
7
|
import { Tooltip } from "./Tooltip.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/* @__PURE__ */ jsx(
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
import { forwardRef } from "./~utils.js";
|
|
9
|
+
const IconButton = forwardRef(
|
|
10
|
+
(props, forwardedRef) => {
|
|
11
|
+
const { label, icon, isActive, labelVariant, ...rest } = props;
|
|
12
|
+
const toolbar = Ariakit.useToolbarContext();
|
|
13
|
+
const button = /* @__PURE__ */ jsxs(
|
|
14
|
+
Button,
|
|
15
|
+
{
|
|
16
|
+
"aria-pressed": isActive,
|
|
17
|
+
...rest,
|
|
18
|
+
render: toolbar ? /* @__PURE__ */ jsx(Ariakit.ToolbarItem, { render: props.render }) : props.render,
|
|
19
|
+
className: cx("\u{1F95D}-icon-button", props.className),
|
|
20
|
+
ref: forwardedRef,
|
|
21
|
+
children: [
|
|
22
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: label }),
|
|
23
|
+
typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
if (labelVariant === "visually-hidden") {
|
|
28
|
+
return button;
|
|
21
29
|
}
|
|
22
|
-
|
|
23
|
-
if (labelVariant === "visually-hidden") {
|
|
24
|
-
return button;
|
|
30
|
+
return /* @__PURE__ */ jsx(Tooltip, { content: label, type: "none", children: button });
|
|
25
31
|
}
|
|
26
|
-
|
|
27
|
-
});
|
|
32
|
+
);
|
|
28
33
|
DEV: IconButton.displayName = "IconButton";
|
|
29
34
|
export {
|
|
30
35
|
IconButton
|