@itwin/itwinui-react 5.0.0-alpha.1 → 5.0.0-alpha.11
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 +102 -0
- package/LICENSE.md +1 -1
- package/README.md +6 -6
- package/dist/DEV/bricks/Anchor.js +5 -10
- package/dist/DEV/bricks/Avatar.js +24 -0
- package/dist/DEV/bricks/Badge.js +22 -0
- package/dist/DEV/bricks/Button.js +11 -4
- package/dist/DEV/bricks/Checkbox.js +17 -9
- package/dist/DEV/bricks/Chip.js +42 -0
- package/dist/DEV/bricks/Description.js +29 -0
- package/dist/DEV/bricks/Divider.js +3 -2
- package/dist/DEV/bricks/DropdownMenu.js +109 -30
- package/dist/DEV/bricks/Field.js +115 -14
- package/dist/DEV/bricks/Icon.js +177 -10
- package/dist/DEV/bricks/IconButton.js +14 -3
- package/dist/DEV/bricks/Kbd.internal.js +19 -0
- package/dist/DEV/bricks/Kbd.js +23 -6
- package/dist/DEV/bricks/Label.js +11 -8
- package/dist/DEV/bricks/ProgressBar.js +25 -0
- package/dist/DEV/bricks/Radio.js +17 -9
- package/dist/DEV/bricks/Root.internal.js +17 -0
- package/dist/DEV/bricks/Root.js +103 -26
- package/dist/DEV/bricks/Select.js +17 -11
- package/dist/DEV/bricks/Skeleton.js +24 -0
- package/dist/DEV/bricks/Spinner.js +55 -0
- package/dist/DEV/bricks/Switch.js +18 -10
- package/dist/DEV/bricks/Table.js +114 -0
- package/dist/DEV/bricks/Tabs.js +6 -6
- package/dist/DEV/bricks/Text.js +2 -2
- package/dist/DEV/bricks/TextBox.js +54 -16
- package/dist/DEV/bricks/Tooltip.js +17 -25
- package/dist/DEV/bricks/Tree.js +15 -107
- package/dist/DEV/bricks/TreeItem.js +227 -0
- package/dist/DEV/bricks/VisuallyHidden.js +2 -2
- package/dist/DEV/bricks/index.js +16 -0
- package/dist/DEV/bricks/styles.css.js +2 -2
- package/dist/DEV/bricks/~hooks.js +57 -3
- package/dist/DEV/bricks/~utils.GhostAligner.js +13 -0
- package/dist/DEV/bricks/{ListItem.js → ~utils.ListItem.js} +19 -3
- package/dist/DEV/bricks/~utils.js +17 -0
- package/dist/DEV/foundations/styles.css.js +2 -2
- package/dist/bricks/Anchor.js +5 -10
- package/dist/bricks/Avatar.d.ts +47 -0
- package/dist/bricks/Avatar.js +23 -0
- package/dist/bricks/Badge.d.ts +28 -0
- package/dist/bricks/Badge.js +21 -0
- package/dist/bricks/Button.js +11 -4
- package/dist/bricks/Checkbox.d.ts +2 -2
- package/dist/bricks/Checkbox.js +17 -9
- package/dist/bricks/Chip.d.ts +31 -0
- package/dist/bricks/Chip.js +41 -0
- package/dist/bricks/Description.d.ts +19 -0
- package/dist/bricks/Description.js +29 -0
- package/dist/bricks/Divider.d.ts +2 -2
- package/dist/bricks/Divider.js +3 -2
- package/dist/bricks/DropdownMenu.d.ts +41 -14
- package/dist/bricks/DropdownMenu.js +106 -30
- package/dist/bricks/Field.d.ts +23 -1
- package/dist/bricks/Field.js +115 -14
- package/dist/bricks/Icon.d.ts +43 -4
- package/dist/bricks/Icon.js +174 -10
- package/dist/bricks/IconButton.d.ts +20 -4
- package/dist/bricks/IconButton.js +14 -3
- package/dist/bricks/Kbd.d.ts +15 -0
- package/dist/bricks/Kbd.internal.d.ts +17 -0
- package/dist/bricks/Kbd.internal.js +19 -0
- package/dist/bricks/Kbd.js +16 -6
- package/dist/bricks/Label.js +11 -8
- package/dist/bricks/ProgressBar.d.ts +31 -0
- package/dist/bricks/ProgressBar.js +24 -0
- package/dist/bricks/Radio.d.ts +2 -2
- package/dist/bricks/Radio.js +17 -9
- package/dist/bricks/Root.d.ts +12 -0
- package/dist/bricks/Root.internal.d.ts +6 -0
- package/dist/bricks/Root.internal.js +17 -0
- package/dist/bricks/Root.js +103 -26
- package/dist/bricks/Select.d.ts +9 -3
- package/dist/bricks/Select.js +17 -11
- package/dist/bricks/Skeleton.d.ts +25 -0
- package/dist/bricks/Skeleton.js +23 -0
- package/dist/bricks/Spinner.d.ts +31 -0
- package/dist/bricks/Spinner.js +54 -0
- package/dist/bricks/Switch.d.ts +2 -2
- package/dist/bricks/Switch.js +18 -10
- package/dist/bricks/Table.d.ts +115 -0
- package/dist/bricks/Table.js +108 -0
- package/dist/bricks/Tabs.d.ts +4 -4
- package/dist/bricks/Tabs.js +6 -6
- package/dist/bricks/Text.d.ts +1 -1
- package/dist/bricks/Text.js +2 -2
- package/dist/bricks/TextBox.d.ts +23 -2
- package/dist/bricks/TextBox.js +53 -16
- package/dist/bricks/Tooltip.d.ts +2 -2
- package/dist/bricks/Tooltip.js +17 -25
- package/dist/bricks/Tree.d.ts +19 -20
- package/dist/bricks/Tree.js +14 -102
- package/dist/bricks/TreeItem.d.ts +129 -0
- package/dist/bricks/TreeItem.js +222 -0
- package/dist/bricks/VisuallyHidden.js +2 -2
- package/dist/bricks/index.d.ts +8 -0
- package/dist/bricks/index.js +16 -0
- package/dist/bricks/styles.css.js +2 -2
- package/dist/bricks/~hooks.d.ts +63 -0
- package/dist/bricks/~hooks.js +57 -3
- package/dist/bricks/~utils.GhostAligner.d.ts +22 -0
- package/dist/bricks/~utils.GhostAligner.js +13 -0
- package/dist/bricks/~utils.ListItem.d.ts +14 -0
- package/dist/bricks/{ListItem.js → ~utils.ListItem.js} +18 -3
- package/dist/bricks/~utils.d.ts +14 -3
- package/dist/bricks/~utils.js +17 -0
- package/dist/foundations/styles.css.js +2 -2
- package/package.json +14 -13
- package/dist/DEV/bricks/Textarea.js +0 -30
- package/dist/bricks/ListItem.d.ts +0 -10
- package/dist/bricks/Textarea.d.ts +0 -24
- package/dist/bricks/Textarea.js +0 -29
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,107 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.0.0-alpha.11
|
|
4
|
+
|
|
5
|
+
- Added `error` prop to `<Tree.Item>`.
|
|
6
|
+
- Implemented fallback strategy for `<Icon>`, so that non-HTTP URLs are fetched at runtime.
|
|
7
|
+
- Added `unstable_htmlSanitizer` prop to `<Root>`.
|
|
8
|
+
- Added `tone="accent"` support to `<Badge>`.
|
|
9
|
+
- Adjusted `DropdownMenu` and `Tooltip` to be portaled by default.
|
|
10
|
+
- Styling changes:
|
|
11
|
+
- Added shimmer animation to `<Skeleton>`.
|
|
12
|
+
- Updated `<Spinner>` visuals and animation to match `<ProgressBar>`.
|
|
13
|
+
- Bug fixes:
|
|
14
|
+
- Fixed styles not unloading when `<Root>` is unmounted.
|
|
15
|
+
- Fixed `<Anchor>` underline not showing when rendered as a `<button>`.
|
|
16
|
+
- Fixed `<Tree.ItemAction visible>` affecting the visibility of all actions.
|
|
17
|
+
- Fixed vertical centering in `<Tab.TabList>`.
|
|
18
|
+
- Fixed `Tab` active stripe positioning and animation.
|
|
19
|
+
- Fixed `<Button variant="solid" tone="accent">` icon fill in pressed state.
|
|
20
|
+
|
|
21
|
+
## 5.0.0-alpha.10
|
|
22
|
+
|
|
23
|
+
- Added initial `<Skeleton>` component.
|
|
24
|
+
- Added initial `<ProgressBar>` component.
|
|
25
|
+
- Fixed various UX and accessibility issues related to `<Tree.Item>` actions visibility.
|
|
26
|
+
- Actions no longer get stuck.
|
|
27
|
+
- Tooltips can now be hovered.
|
|
28
|
+
- Focus correctly returns to actions after menu closes.
|
|
29
|
+
- Keyboard events no longer affect the main treeitem.
|
|
30
|
+
- Reduced `<Field>` spacing.
|
|
31
|
+
- Experimental changes in `<Icon>` component's `href` handling.
|
|
32
|
+
|
|
33
|
+
## 5.0.0-alpha.9
|
|
34
|
+
|
|
35
|
+
- Added `dot` prop to `<IconButton>` for showing a small "dot" next to the icon.
|
|
36
|
+
- Added `unstable_decorations` prop to `<Tree.Item>` for showing multiple decorations (e.g. icons).
|
|
37
|
+
- **breaking**: Replaced `<DropdownMenu.Item>` children with new `label` prop (see [#423](https://github.com/iTwin/design-system/pull/423)).
|
|
38
|
+
- Added `icon` prop to `<DropdownMenu.Item>` and `<DropdownMenu.CheckboxItem>`.
|
|
39
|
+
- Updated the `shortcuts` prop of `<DropdownMenu.Item>` to recognize predefined "symbols" (e.g. modifier keys).
|
|
40
|
+
- Updated `<Anchor>` and `<Badge>` visuals to match the latest design.
|
|
41
|
+
- Fixed forced-colors mode styling for `DropdownMenu`.
|
|
42
|
+
|
|
43
|
+
## 5.0.0-alpha.8
|
|
44
|
+
|
|
45
|
+
- Added `description` prop to `<Tree.Item>` component for showing "sublabels".
|
|
46
|
+
- **breaking**: Updated `<Text>` component to require `variant` prop.
|
|
47
|
+
- (soft breaking) Removed `children` from `<Tree.Item>` prop types.
|
|
48
|
+
- Updated `DropdownMenu` padding.
|
|
49
|
+
|
|
50
|
+
## 5.0.0-alpha.7
|
|
51
|
+
|
|
52
|
+
- Added new `<Avatar>` component.
|
|
53
|
+
- Added new `<Badge>` component.
|
|
54
|
+
- Added `alt` prop to `<Icon>` component.
|
|
55
|
+
- Fixed all color tokens to use the correct `oklch` values.
|
|
56
|
+
- Fixed an issue where `<Tree.Item>` was not respecting its `style` prop.
|
|
57
|
+
|
|
58
|
+
## 5.0.0-alpha.6
|
|
59
|
+
|
|
60
|
+
- **breaking**: All CSS variables have been renamed to use the `--ids` prefix. See [#369](https://github.com/iTwin/kiwi/pull/369).
|
|
61
|
+
- **breaking**: Some CSS variables were renamed further. See [#368](https://github.com/iTwin/kiwi/pull/368).
|
|
62
|
+
- Notably, the "surface" backgrounds have been split into two different "page" and "elevation" scales.
|
|
63
|
+
- Background colors have been updated to match the latest design.
|
|
64
|
+
- All styles are now loaded into `@layer itwinui`. The one exception is the CSS reset which remains in `@layer reset`.
|
|
65
|
+
- `<Field>` now respects the order of `<Description>`s when creating associations.
|
|
66
|
+
|
|
67
|
+
## 5.0.0-alpha.5
|
|
68
|
+
|
|
69
|
+
- **breaking**: `Tree` API has changed to require flat structure, with explicit ARIA props (see [#300](https://github.com/iTwin/kiwi/pull/300)). `<Tree.Item>` no longer allows passing `children`.
|
|
70
|
+
- **breaking**: `Tree.Item`s `action` prop now requires a list of `<Tree.ItemAction>` components (see [#355](https://github.com/iTwin/kiwi/pull/355) and [#362](https://github.com/iTwin/kiwi/pull/362)).
|
|
71
|
+
- **breaking**: Replaced `<Chip>` children with new `label` prop (see [#349](https://github.com/iTwin/kiwi/pull/349)).
|
|
72
|
+
- Added `<Tree.ItemAction>` component with `visible` prop for more granular control over action visibility.
|
|
73
|
+
- Updated the layout of `<Field>` so that `<Description>` is placed in the best spot according on the label position and control type.
|
|
74
|
+
- `<Field>` now considers the presence of explicit control `id`s when creating associations.
|
|
75
|
+
|
|
76
|
+
## 5.0.0-alpha.4
|
|
77
|
+
|
|
78
|
+
- Added `onDismiss` prop and dismiss button to `<Chip>`.
|
|
79
|
+
- Fixed a rare issue where `TextBox` was still editable when `disabled`.
|
|
80
|
+
- Fixed "forced colors" mode styling for `<Button>` and `<IconButton>`.
|
|
81
|
+
- Explicitly set typography styles on `<Root>` to improve compatibility with iTwinUI theme bridge.
|
|
82
|
+
- Updated `DropdownMenu` visuals.
|
|
83
|
+
|
|
84
|
+
## 5.0.0-alpha.3
|
|
85
|
+
|
|
86
|
+
- Added `<DropdownMenu.CheckboxItem>` component for rendering menu items with a checkable state.
|
|
87
|
+
- Added `variant` prop to `<Select.HtmlSelect>` component for displaying different visual variants of the component.
|
|
88
|
+
- Updated event handling of `Tree` components to avoid firing `onClick` event of the `<Tree.Item>` component when the expander or one of the actions is clicked.
|
|
89
|
+
- Updated `Tree` components to implement a tree view pattern instead of the previously used nested list approach.
|
|
90
|
+
- Updated size and spacing of `<Tree.Item>`, `<DropdownMenu.Item>` and `<Select>` components.
|
|
91
|
+
- Fixed `<Label>` component alignment with `TextBox` components.
|
|
92
|
+
- Fixed action rendering of `<Tree.Item>` component.
|
|
93
|
+
- Fixed `<Checkbox>` component styling, which caused the mixed checkbox to be displayed as unchecked in the light theme.
|
|
94
|
+
|
|
95
|
+
## 5.0.0-alpha.2
|
|
96
|
+
|
|
97
|
+
- Added initial `Tree` component, exposed as `<Tree.Root>` and `<Tree.Item>` subcomponents.
|
|
98
|
+
- Added initial `<Spinner>` component for indicating quick, indeterminate progress.
|
|
99
|
+
- Added `<Description>` component to be used within a `<Field>`.
|
|
100
|
+
- Added initial `<Chip>` component.
|
|
101
|
+
- Added `symbol` prop to `<Kbd>` for displaying predefined symbols.
|
|
102
|
+
- Added `focusable` prop to `<Tabs.TabPanel>` component.
|
|
103
|
+
- Fixed a visual issue where light color-scheme was using dark shadows.
|
|
104
|
+
|
|
3
105
|
## 5.0.0-alpha.1
|
|
4
106
|
|
|
5
107
|
- Added `<Text>` component with a `variant` prop to support all text styles from Figma.
|
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MIT License
|
|
2
2
|
|
|
3
|
-
Copyright ©
|
|
3
|
+
Copyright © 2025 Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @itwin/itwinui-react
|
|
2
2
|
|
|
3
|
-
A React component library for the
|
|
3
|
+
A React component library for the next evolution of the iTwinUI design system.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
|
-
To use components from the
|
|
7
|
+
To use components from the iTwinUI design system in your app, you’ll need to wrap your app’s UI with iTwinUI's `<Root>` component, and specify the required `colorScheme` and `density` props:
|
|
8
8
|
|
|
9
9
|
```jsx
|
|
10
10
|
import { Root } from "@itwin/itwinui-react/bricks";
|
|
@@ -12,18 +12,18 @@ import { Root } from "@itwin/itwinui-react/bricks";
|
|
|
12
12
|
export function App() {
|
|
13
13
|
return (
|
|
14
14
|
<Root colorScheme="dark" density="dense">
|
|
15
|
-
{/* Use
|
|
15
|
+
{/* Use design system components here */}
|
|
16
16
|
</Root>
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
This will ensure
|
|
21
|
+
This will ensure iTwinUI's styles are loaded to either the document or the encompassing shadow root.
|
|
22
22
|
|
|
23
23
|
Once that’s in place you can import and use components from `@itwin/itwinui-react/bricks`.
|
|
24
24
|
|
|
25
25
|
## Contributing
|
|
26
26
|
|
|
27
|
-
Are you interested in helping
|
|
27
|
+
Are you interested in helping iTwinUI grow and expand? You can submit feature requests or bugs by creating [issues](https://github.com/iTwin/design-system/issues).
|
|
28
28
|
|
|
29
|
-
If you're interested in contributing code, please read [`CONTRIBUTING.md`](https://github.com/iTwin/
|
|
29
|
+
If you're interested in contributing code, please read [`CONTRIBUTING.md`](https://github.com/iTwin/design-system/blob/main/CONTRIBUTING.md) for more information.
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import cx from "classnames";
|
|
3
|
-
import
|
|
3
|
+
import { Role } from "@ariakit/react/role";
|
|
4
|
+
import { Focusable } from "@ariakit/react/focusable";
|
|
4
5
|
import { forwardRef } from "./~utils.js";
|
|
5
6
|
const Anchor = forwardRef((props, forwardedRef) => {
|
|
6
7
|
const { tone = "neutral", ...rest } = props;
|
|
7
8
|
return /* @__PURE__ */ jsx(
|
|
8
|
-
|
|
9
|
+
Role.a,
|
|
9
10
|
{
|
|
10
|
-
"data-kiwi-tone": tone,
|
|
11
11
|
...rest,
|
|
12
|
+
"data-kiwi-tone": tone,
|
|
12
13
|
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
|
-
),
|
|
14
|
+
render: /* @__PURE__ */ jsx(Focusable, { accessibleWhenDisabled: true, render: props.render || /* @__PURE__ */ jsx("a", {}) }),
|
|
20
15
|
ref: forwardedRef
|
|
21
16
|
}
|
|
22
17
|
);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import cx from "classnames";
|
|
3
|
+
import { Role } from "@ariakit/react/role";
|
|
4
|
+
import { forwardRef } from "./~utils.js";
|
|
5
|
+
const Avatar = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const { size = "medium", initials, alt, image, children, ...rest } = props;
|
|
7
|
+
const isDecorative = !alt;
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
|
+
Role.span,
|
|
10
|
+
{
|
|
11
|
+
role: isDecorative ? void 0 : "img",
|
|
12
|
+
"aria-label": isDecorative ? void 0 : alt,
|
|
13
|
+
...rest,
|
|
14
|
+
"data-kiwi-size": size,
|
|
15
|
+
className: cx("\u{1F95D}-avatar", props.className),
|
|
16
|
+
ref: forwardedRef,
|
|
17
|
+
children: image ?? /* @__PURE__ */ jsx("abbr", { className: "\u{1F95D}-avatar-initials", "aria-hidden": "true", children: initials?.substring(0, 1) })
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
DEV: Avatar.displayName = "Avatar";
|
|
22
|
+
export {
|
|
23
|
+
Avatar
|
|
24
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import cx from "classnames";
|
|
3
|
+
import { Role } from "@ariakit/react/role";
|
|
4
|
+
import { forwardRef } from "./~utils.js";
|
|
5
|
+
const Badge = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const { tone = "neutral", variant = "solid", label, ...rest } = props;
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
Role.span,
|
|
9
|
+
{
|
|
10
|
+
...rest,
|
|
11
|
+
"data-kiwi-tone": tone,
|
|
12
|
+
"data-kiwi-variant": variant,
|
|
13
|
+
className: cx("\u{1F95D}-badge", props.className),
|
|
14
|
+
ref: forwardedRef,
|
|
15
|
+
children: label
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
DEV: Badge.displayName = "Badge";
|
|
20
|
+
export {
|
|
21
|
+
Badge
|
|
22
|
+
};
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import cx from "classnames";
|
|
3
|
-
import
|
|
3
|
+
import { Button as AkButton } from "@ariakit/react/button";
|
|
4
4
|
import { forwardRef } from "./~utils.js";
|
|
5
|
+
import { useGhostAlignment } from "./~utils.GhostAligner.js";
|
|
5
6
|
const Button = forwardRef(
|
|
6
7
|
(props, forwardedRef) => {
|
|
7
8
|
const { variant = "solid", tone = "neutral", ...rest } = props;
|
|
9
|
+
const ghostAlignment = useGhostAlignment();
|
|
8
10
|
return /* @__PURE__ */ jsx(
|
|
9
|
-
|
|
11
|
+
AkButton,
|
|
10
12
|
{
|
|
11
13
|
accessibleWhenDisabled: true,
|
|
14
|
+
...rest,
|
|
12
15
|
"data-kiwi-variant": variant,
|
|
13
16
|
"data-kiwi-tone": tone,
|
|
14
|
-
|
|
15
|
-
className: cx(
|
|
17
|
+
"data-kiwi-ghost-align": variant === "ghost" ? ghostAlignment : void 0,
|
|
18
|
+
className: cx(
|
|
19
|
+
"\u{1F95D}-button",
|
|
20
|
+
{ "\u{1F95D}-ghost-aligner": variant === "ghost" },
|
|
21
|
+
props.className
|
|
22
|
+
),
|
|
16
23
|
ref: forwardedRef
|
|
17
24
|
}
|
|
18
25
|
);
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import cx from "classnames";
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
Checkbox as AkCheckbox
|
|
5
|
+
} from "@ariakit/react/checkbox";
|
|
6
|
+
import { FieldControl } from "./Field.js";
|
|
5
7
|
import { forwardRef } from "./~utils.js";
|
|
6
8
|
const Checkbox = forwardRef(
|
|
7
9
|
(props, forwardedRef) => {
|
|
8
|
-
const
|
|
10
|
+
const { id, ...rest } = props;
|
|
9
11
|
return /* @__PURE__ */ jsx(
|
|
10
|
-
|
|
12
|
+
FieldControl,
|
|
11
13
|
{
|
|
12
|
-
|
|
13
|
-
id
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
type: "checkable",
|
|
15
|
+
id,
|
|
16
|
+
render: /* @__PURE__ */ jsx(
|
|
17
|
+
AkCheckbox,
|
|
18
|
+
{
|
|
19
|
+
accessibleWhenDisabled: true,
|
|
20
|
+
...rest,
|
|
21
|
+
className: cx("\u{1F95D}-checkbox", props.className),
|
|
22
|
+
ref: forwardedRef
|
|
23
|
+
}
|
|
24
|
+
)
|
|
17
25
|
}
|
|
18
26
|
);
|
|
19
27
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import cx from "classnames";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Role } from "@ariakit/react/role";
|
|
5
|
+
import { forwardRef } from "./~utils.js";
|
|
6
|
+
import { IconButton } from "./IconButton.js";
|
|
7
|
+
import { Dismiss } from "./Icon.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,29 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "./~utils.js";
|
|
3
|
+
import cx from "classnames";
|
|
4
|
+
import { Text } from "./Text.js";
|
|
5
|
+
import { FieldDescription } from "./Field.js";
|
|
6
|
+
const Description = forwardRef(
|
|
7
|
+
(props, forwardedRef) => {
|
|
8
|
+
const { id, tone, ...rest } = props;
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
FieldDescription,
|
|
11
|
+
{
|
|
12
|
+
id,
|
|
13
|
+
render: /* @__PURE__ */ jsx(
|
|
14
|
+
Text,
|
|
15
|
+
{
|
|
16
|
+
...rest,
|
|
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
|
+
}
|
|
26
|
+
);
|
|
27
|
+
export {
|
|
28
|
+
Description
|
|
29
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import cx from "classnames";
|
|
3
|
-
import
|
|
3
|
+
import { Role } from "@ariakit/react/role";
|
|
4
|
+
import { Separator } from "@ariakit/react/separator";
|
|
4
5
|
import { forwardRef } from "./~utils.js";
|
|
5
6
|
const Divider = forwardRef((props, forwardedRef) => {
|
|
6
7
|
const { presentational, ...rest } = props;
|
|
7
|
-
const Comp = presentational ?
|
|
8
|
+
const Comp = presentational ? Role : Separator;
|
|
8
9
|
return /* @__PURE__ */ jsx(
|
|
9
10
|
Comp,
|
|
10
11
|
{
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import cx from "classnames";
|
|
4
|
-
import * as
|
|
5
|
-
import * as ListItem from "./ListItem.js";
|
|
4
|
+
import * as ListItem from "./~utils.ListItem.js";
|
|
6
5
|
import { Button } from "./Button.js";
|
|
7
6
|
import { Kbd } from "./Kbd.js";
|
|
8
|
-
import { DisclosureArrow } from "./Icon.js";
|
|
9
|
-
import {
|
|
7
|
+
import { Checkmark, DisclosureArrow, Icon } from "./Icon.js";
|
|
8
|
+
import {
|
|
9
|
+
forwardRef
|
|
10
|
+
} from "./~utils.js";
|
|
11
|
+
import { usePopoverApi } from "./~hooks.js";
|
|
12
|
+
import {
|
|
13
|
+
MenuProvider,
|
|
14
|
+
useMenuContext,
|
|
15
|
+
Menu,
|
|
16
|
+
MenuButton,
|
|
17
|
+
MenuItem,
|
|
18
|
+
MenuItemCheckbox
|
|
19
|
+
} from "@ariakit/react/menu";
|
|
20
|
+
import { useStoreState } from "@ariakit/react/store";
|
|
21
|
+
import { predefinedSymbols } from "./Kbd.internal.js";
|
|
10
22
|
function DropdownMenu(props) {
|
|
11
23
|
const {
|
|
12
24
|
children,
|
|
@@ -15,21 +27,9 @@ function DropdownMenu(props) {
|
|
|
15
27
|
setOpen: setOpenProp,
|
|
16
28
|
defaultOpen: defaultOpenProp
|
|
17
29
|
} = props;
|
|
18
|
-
const store = Ariakit.useMenuStore();
|
|
19
|
-
const open = Ariakit.useStoreState(store, (state) => state.open);
|
|
20
|
-
const popover = Ariakit.useStoreState(store, (state) => state.popoverElement);
|
|
21
|
-
React.useEffect(
|
|
22
|
-
function syncPopoverWithOpenState() {
|
|
23
|
-
if (popover?.isConnected) {
|
|
24
|
-
popover?.togglePopover?.(open);
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
[open, popover]
|
|
28
|
-
);
|
|
29
30
|
return /* @__PURE__ */ jsx(
|
|
30
|
-
|
|
31
|
+
MenuProvider,
|
|
31
32
|
{
|
|
32
|
-
store,
|
|
33
33
|
placement,
|
|
34
34
|
defaultOpen: defaultOpenProp,
|
|
35
35
|
open: openProp,
|
|
@@ -41,14 +41,16 @@ function DropdownMenu(props) {
|
|
|
41
41
|
DEV: DropdownMenu.displayName = "DropdownMenu.Root";
|
|
42
42
|
const DropdownMenuContent = forwardRef(
|
|
43
43
|
(props, forwardedRef) => {
|
|
44
|
+
const popover = usePopoverApi(useMenuContext());
|
|
44
45
|
return /* @__PURE__ */ jsx(
|
|
45
|
-
|
|
46
|
+
Menu,
|
|
46
47
|
{
|
|
47
|
-
portal:
|
|
48
|
+
portal: true,
|
|
48
49
|
unmountOnHide: true,
|
|
49
50
|
...props,
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
gutter: 4,
|
|
52
|
+
style: { ...popover.style, ...props.style },
|
|
53
|
+
wrapperProps: popover.wrapperProps,
|
|
52
54
|
className: cx("\u{1F95D}-dropdown-menu", props.className),
|
|
53
55
|
ref: forwardedRef
|
|
54
56
|
}
|
|
@@ -59,8 +61,9 @@ DEV: DropdownMenuContent.displayName = "DropdownMenu.Content";
|
|
|
59
61
|
const DropdownMenuButton = forwardRef(
|
|
60
62
|
(props, forwardedRef) => {
|
|
61
63
|
const { accessibleWhenDisabled = true, children, ...rest } = props;
|
|
64
|
+
const open = useStoreState(useMenuContext(), (state) => state?.open);
|
|
62
65
|
return /* @__PURE__ */ jsx(
|
|
63
|
-
|
|
66
|
+
MenuButton,
|
|
64
67
|
{
|
|
65
68
|
accessibleWhenDisabled: true,
|
|
66
69
|
render: /* @__PURE__ */ jsxs(Button, { accessibleWhenDisabled, children: [
|
|
@@ -69,6 +72,7 @@ const DropdownMenuButton = forwardRef(
|
|
|
69
72
|
] }),
|
|
70
73
|
...rest,
|
|
71
74
|
className: cx("\u{1F95D}-dropdown-menu-button", props.className),
|
|
75
|
+
"data-has-popover-open": open || void 0,
|
|
72
76
|
ref: forwardedRef
|
|
73
77
|
}
|
|
74
78
|
);
|
|
@@ -77,29 +81,104 @@ const DropdownMenuButton = forwardRef(
|
|
|
77
81
|
DEV: DropdownMenuButton.displayName = "DropdownMenu.Button";
|
|
78
82
|
const DropdownMenuItem = forwardRef(
|
|
79
83
|
(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;
|
|
84
|
+
const { label, shortcuts, icon, ...rest } = props;
|
|
85
85
|
return /* @__PURE__ */ jsxs(
|
|
86
|
-
|
|
86
|
+
MenuItem,
|
|
87
87
|
{
|
|
88
88
|
accessibleWhenDisabled: true,
|
|
89
89
|
...rest,
|
|
90
90
|
render: /* @__PURE__ */ jsx(ListItem.Root, { render: props.render }),
|
|
91
|
+
className: cx("\u{1F95D}-dropdown-menu-item", props.className),
|
|
91
92
|
ref: forwardedRef,
|
|
92
93
|
children: [
|
|
93
|
-
/* @__PURE__ */ jsx(
|
|
94
|
-
|
|
94
|
+
icon ? /* @__PURE__ */ jsx(DropdownMenuIcon, { icon }) : null,
|
|
95
|
+
/* @__PURE__ */ jsx(ListItem.Content, { children: label }),
|
|
96
|
+
shortcuts ? /* @__PURE__ */ jsx(DropdownMenuItemShortcuts, { shortcuts }) : null
|
|
95
97
|
]
|
|
96
98
|
}
|
|
97
99
|
);
|
|
98
100
|
}
|
|
99
101
|
);
|
|
100
102
|
DEV: DropdownMenuItem.displayName = "DropdownMenu.Item";
|
|
103
|
+
const DropdownMenuItemShortcuts = forwardRef((props, forwardedRef) => {
|
|
104
|
+
const { shortcuts, ...rest } = props;
|
|
105
|
+
const shortcutKeys = React.useMemo(() => {
|
|
106
|
+
return shortcuts.split("+").map((key) => ({
|
|
107
|
+
key: key.trim(),
|
|
108
|
+
isSymbol: key in predefinedSymbols
|
|
109
|
+
}));
|
|
110
|
+
}, [shortcuts]);
|
|
111
|
+
return /* @__PURE__ */ jsx(
|
|
112
|
+
ListItem.Decoration,
|
|
113
|
+
{
|
|
114
|
+
...rest,
|
|
115
|
+
className: cx("\u{1F95D}-dropdown-menu-item-shortcuts", props.className),
|
|
116
|
+
ref: forwardedRef,
|
|
117
|
+
children: shortcutKeys.map(({ key, isSymbol }, index) => {
|
|
118
|
+
if (isSymbol) {
|
|
119
|
+
return /* @__PURE__ */ jsx(
|
|
120
|
+
Kbd,
|
|
121
|
+
{
|
|
122
|
+
variant: "ghost",
|
|
123
|
+
symbol: key
|
|
124
|
+
},
|
|
125
|
+
`${key + index}`
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
return /* @__PURE__ */ jsx(Kbd, { variant: "ghost", children: key }, `${key + index}`);
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
DEV: DropdownMenuItemShortcuts.displayName = "DropdownMenuItemShortcuts";
|
|
134
|
+
const DropdownMenuIcon = forwardRef(
|
|
135
|
+
(props, forwardedRef) => {
|
|
136
|
+
const { icon, ...rest } = props;
|
|
137
|
+
return /* @__PURE__ */ jsx(
|
|
138
|
+
ListItem.Decoration,
|
|
139
|
+
{
|
|
140
|
+
render: /* @__PURE__ */ jsx(
|
|
141
|
+
Icon,
|
|
142
|
+
{
|
|
143
|
+
href: typeof icon === "string" ? icon : void 0,
|
|
144
|
+
render: React.isValidElement(icon) ? icon : void 0
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
...rest,
|
|
148
|
+
ref: forwardedRef
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
DEV: DropdownMenuIcon.displayName = "DropdownMenuIcon";
|
|
154
|
+
const DropdownMenuCheckboxItem = forwardRef((props, forwardedRef) => {
|
|
155
|
+
const { label, icon, ...rest } = props;
|
|
156
|
+
return /* @__PURE__ */ jsxs(
|
|
157
|
+
MenuItemCheckbox,
|
|
158
|
+
{
|
|
159
|
+
accessibleWhenDisabled: true,
|
|
160
|
+
value: props.defaultChecked ? "on" : void 0,
|
|
161
|
+
...rest,
|
|
162
|
+
render: /* @__PURE__ */ jsx(ListItem.Root, { render: props.render }),
|
|
163
|
+
className: cx("\u{1F95D}-dropdown-menu-item", props.className),
|
|
164
|
+
ref: forwardedRef,
|
|
165
|
+
children: [
|
|
166
|
+
icon ? /* @__PURE__ */ jsx(DropdownMenuIcon, { icon }) : null,
|
|
167
|
+
/* @__PURE__ */ jsx(ListItem.Content, { children: label }),
|
|
168
|
+
/* @__PURE__ */ jsx(
|
|
169
|
+
ListItem.Decoration,
|
|
170
|
+
{
|
|
171
|
+
render: /* @__PURE__ */ jsx(Checkmark, { className: "\u{1F95D}-dropdown-menu-checkmark" })
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
});
|
|
178
|
+
DEV: DropdownMenuCheckboxItem.displayName = "DropdownMenu.CheckboxItem";
|
|
101
179
|
export {
|
|
102
180
|
DropdownMenuButton as Button,
|
|
181
|
+
DropdownMenuCheckboxItem as CheckboxItem,
|
|
103
182
|
DropdownMenuContent as Content,
|
|
104
183
|
DropdownMenuItem as Item,
|
|
105
184
|
DropdownMenu as Root
|