@itwin/itwinui-react 5.0.0-alpha.1 → 5.0.0-alpha.10
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/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 +70 -8
- 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.js +35 -4
- package/dist/DEV/bricks/Select.js +17 -11
- package/dist/DEV/bricks/Skeleton.js +24 -0
- package/dist/DEV/bricks/Spinner.js +40 -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 +224 -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 +55 -3
- package/dist/DEV/bricks/~utils.GhostAligner.js +13 -0
- package/dist/DEV/bricks/{ListItem.js → ~utils.ListItem.js} +19 -3
- 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 +34 -3
- package/dist/bricks/Icon.js +68 -8
- 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.js +35 -4
- 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 +39 -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 +123 -0
- package/dist/bricks/TreeItem.js +219 -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 +55 -0
- package/dist/bricks/~hooks.js +55 -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 +6 -3
- package/dist/foundations/styles.css.js +2 -2
- package/package.json +14 -13
- package/CHANGELOG.md +0 -14
- 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/dist/bricks/Field.js
CHANGED
|
@@ -1,26 +1,127 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import * as Ariakit from "@ariakit/react";
|
|
4
3
|
import cx from "classnames";
|
|
4
|
+
import { Role } from "@ariakit/react/role";
|
|
5
|
+
import {
|
|
6
|
+
useCollectionStore,
|
|
7
|
+
Collection,
|
|
8
|
+
useCollectionContext,
|
|
9
|
+
CollectionItem
|
|
10
|
+
} from "@ariakit/react/collection";
|
|
11
|
+
import { useStoreState } from "@ariakit/react/store";
|
|
5
12
|
import { forwardRef } from "./~utils.js";
|
|
6
13
|
const Field = forwardRef((props, forwardedRef) => {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Ariakit.Role,
|
|
14
|
+
const { layout, ...rest } = props;
|
|
15
|
+
return /* @__PURE__ */ jsx(
|
|
16
|
+
FieldCollection,
|
|
11
17
|
{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
render: /* @__PURE__ */ jsx(
|
|
19
|
+
Role.div,
|
|
20
|
+
{
|
|
21
|
+
...rest,
|
|
22
|
+
className: cx("\u{1F95D}-field", props.className),
|
|
23
|
+
"data-kiwi-layout": layout,
|
|
24
|
+
ref: forwardedRef
|
|
25
|
+
}
|
|
26
|
+
)
|
|
16
27
|
}
|
|
17
|
-
)
|
|
28
|
+
);
|
|
18
29
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
30
|
+
function FieldCollection(props) {
|
|
31
|
+
const fieldElementCollection = useCollectionStore({
|
|
32
|
+
defaultItems: []
|
|
33
|
+
});
|
|
34
|
+
const renderedItems = useStoreState(fieldElementCollection, "renderedItems");
|
|
35
|
+
const [controlType, controlIndex] = React.useMemo(() => {
|
|
36
|
+
const controlIndex2 = renderedItems.findIndex(
|
|
37
|
+
(item) => item.elementType === "control"
|
|
38
|
+
);
|
|
39
|
+
return [renderedItems[controlIndex2]?.controlType, controlIndex2];
|
|
40
|
+
}, [renderedItems]);
|
|
41
|
+
const labelPlacement = React.useMemo(() => {
|
|
42
|
+
const labelIndex = renderedItems.findIndex(
|
|
43
|
+
(item) => item.elementType === "label"
|
|
44
|
+
);
|
|
45
|
+
if (controlIndex === -1 || labelIndex === -1) return;
|
|
46
|
+
return labelIndex < controlIndex ? "before" : "after";
|
|
47
|
+
}, [renderedItems, controlIndex]);
|
|
48
|
+
return /* @__PURE__ */ jsx(
|
|
49
|
+
Collection,
|
|
50
|
+
{
|
|
51
|
+
...props,
|
|
52
|
+
store: fieldElementCollection,
|
|
53
|
+
"data-kiwi-label-placement": labelPlacement,
|
|
54
|
+
"data-kiwi-control-type": controlType
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
function FieldControl(props) {
|
|
59
|
+
const store = useCollectionContext();
|
|
60
|
+
const generatedId = React.useId();
|
|
61
|
+
const { id = store ? generatedId : void 0, type, ...rest } = props;
|
|
62
|
+
const renderedItems = useStoreState(store, "renderedItems");
|
|
63
|
+
const describedBy = React.useMemo(() => {
|
|
64
|
+
const idRefList = renderedItems?.filter(
|
|
65
|
+
(item) => item.elementType === "description"
|
|
66
|
+
)?.map((item) => item.id).join(" ");
|
|
67
|
+
return idRefList || void 0;
|
|
68
|
+
}, [renderedItems]);
|
|
69
|
+
const getData = React.useCallback(
|
|
70
|
+
(data) => ({
|
|
71
|
+
...data,
|
|
72
|
+
elementType: "control",
|
|
73
|
+
controlType: type
|
|
74
|
+
}),
|
|
75
|
+
[type]
|
|
76
|
+
);
|
|
77
|
+
return /* @__PURE__ */ jsx(
|
|
78
|
+
CollectionItem,
|
|
79
|
+
{
|
|
80
|
+
id,
|
|
81
|
+
getItem: getData,
|
|
82
|
+
render: /* @__PURE__ */ jsx(Role, { ...rest, "aria-describedby": describedBy })
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
function FieldLabel(props) {
|
|
87
|
+
const store = useCollectionContext();
|
|
88
|
+
const renderedItems = useStoreState(store, "renderedItems");
|
|
89
|
+
const fieldId = React.useMemo(
|
|
90
|
+
() => renderedItems?.find(
|
|
91
|
+
(item) => item.elementType === "control"
|
|
92
|
+
)?.id,
|
|
93
|
+
[renderedItems]
|
|
94
|
+
);
|
|
95
|
+
const getData = React.useCallback(
|
|
96
|
+
(data) => ({
|
|
97
|
+
...data,
|
|
98
|
+
elementType: "label"
|
|
99
|
+
}),
|
|
100
|
+
[]
|
|
101
|
+
);
|
|
102
|
+
return /* @__PURE__ */ jsx(
|
|
103
|
+
CollectionItem,
|
|
104
|
+
{
|
|
105
|
+
getItem: getData,
|
|
106
|
+
render: /* @__PURE__ */ jsx(Role.label, { ...props, htmlFor: fieldId })
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
function FieldDescription(props) {
|
|
111
|
+
const generatedId = React.useId();
|
|
112
|
+
const { id = generatedId, ...rest } = props;
|
|
113
|
+
const getData = React.useCallback(
|
|
114
|
+
(data) => ({
|
|
115
|
+
...data,
|
|
116
|
+
elementType: "description"
|
|
117
|
+
}),
|
|
118
|
+
[]
|
|
119
|
+
);
|
|
120
|
+
return /* @__PURE__ */ jsx(CollectionItem, { ...rest, id, getItem: getData });
|
|
22
121
|
}
|
|
23
122
|
export {
|
|
24
123
|
Field,
|
|
25
|
-
|
|
124
|
+
FieldControl,
|
|
125
|
+
FieldDescription,
|
|
126
|
+
FieldLabel
|
|
26
127
|
};
|
package/dist/bricks/Icon.d.ts
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type BaseProps } from "./~utils.js";
|
|
3
3
|
interface IconProps extends Omit<BaseProps<"svg">, "children"> {
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* URL of the symbol sprite.
|
|
6
|
+
*
|
|
7
|
+
* Should be a URL to an `.svg` file from `@itwin/itwinui-icons`.
|
|
8
|
+
*/
|
|
5
9
|
href?: string;
|
|
6
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Size of the icon. This affects the icon's physical dimensions, as well as the
|
|
12
|
+
* actual SVG contents (different sizes might have different fidelity).
|
|
13
|
+
*
|
|
14
|
+
* Defaults to `"regular"` (16px) and can be optionally set to `"large"` (24px).
|
|
15
|
+
*/
|
|
7
16
|
size?: "regular" | "large";
|
|
17
|
+
/**
|
|
18
|
+
* Alternative text describing the icon.
|
|
19
|
+
*
|
|
20
|
+
* When this prop is passed, the SVG gets rendered as `role="img"` and labelled
|
|
21
|
+
* using the provided text.
|
|
22
|
+
*
|
|
23
|
+
* This prop is not required if the icon is purely decorative. By default, the icon
|
|
24
|
+
* will be hidden from the accessibility tree.
|
|
25
|
+
*/
|
|
26
|
+
alt?: string;
|
|
8
27
|
}
|
|
9
28
|
/**
|
|
10
29
|
* Icon component that provides fill and sizing to the SVGs from `@itwin/itwinui-icons`.
|
|
@@ -21,7 +40,13 @@ interface IconProps extends Omit<BaseProps<"svg">, "children"> {
|
|
|
21
40
|
* <Icon render={<svg><path d="…" fill="currentColor" /></svg>} />
|
|
22
41
|
* ```
|
|
23
42
|
*
|
|
24
|
-
*
|
|
43
|
+
* By default, this component assumes that the icon is decorative, so it adds `aria-hidden` by default.
|
|
44
|
+
*
|
|
45
|
+
* If the icon is semantically meaningful, the `alt` prop can be used to provide alternative text.
|
|
46
|
+
*
|
|
47
|
+
* ```tsx
|
|
48
|
+
* <Icon href={…} alt="Help" />
|
|
49
|
+
* ```
|
|
25
50
|
*/
|
|
26
51
|
export declare const Icon: React.ForwardRefExoticComponent<IconProps & React.RefAttributes<HTMLElement | SVGSVGElement>>;
|
|
27
52
|
interface DisclosureArrowProps extends Omit<BaseProps<"svg">, "children"> {
|
|
@@ -32,4 +57,10 @@ interface DisclosureArrowProps extends Omit<BaseProps<"svg">, "children"> {
|
|
|
32
57
|
direction?: "down" | "right";
|
|
33
58
|
}
|
|
34
59
|
export declare const DisclosureArrow: React.ForwardRefExoticComponent<DisclosureArrowProps & React.RefAttributes<HTMLElement | SVGSVGElement>>;
|
|
60
|
+
interface CheckmarkProps extends Omit<BaseProps<"svg">, "children"> {
|
|
61
|
+
}
|
|
62
|
+
export declare const Checkmark: React.ForwardRefExoticComponent<CheckmarkProps & React.RefAttributes<HTMLElement | SVGSVGElement>>;
|
|
63
|
+
interface DismissProps extends Omit<BaseProps<"svg">, "children"> {
|
|
64
|
+
}
|
|
65
|
+
export declare const Dismiss: React.ForwardRefExoticComponent<DismissProps & React.RefAttributes<HTMLElement | SVGSVGElement>>;
|
|
35
66
|
export {};
|
package/dist/bricks/Icon.js
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import cx from "classnames";
|
|
4
|
-
import
|
|
4
|
+
import { Role } from "@ariakit/react/role";
|
|
5
5
|
import { forwardRef } from "./~utils.js";
|
|
6
6
|
const Icon = forwardRef((props, forwardedRef) => {
|
|
7
|
-
const { href, size
|
|
8
|
-
const
|
|
7
|
+
const { href, size, alt, ...rest } = props;
|
|
8
|
+
const isDecorative = !alt;
|
|
9
9
|
return /* @__PURE__ */ jsx(
|
|
10
|
-
|
|
10
|
+
Role.svg,
|
|
11
11
|
{
|
|
12
|
-
"
|
|
13
|
-
"
|
|
12
|
+
"aria-hidden": isDecorative ? "true" : void 0,
|
|
13
|
+
role: isDecorative ? void 0 : "img",
|
|
14
|
+
"aria-label": isDecorative ? void 0 : alt,
|
|
14
15
|
...rest,
|
|
16
|
+
"data-kiwi-size": size,
|
|
15
17
|
className: cx("\u{1F95D}-icon", props.className),
|
|
16
18
|
ref: forwardedRef,
|
|
17
|
-
children: /* @__PURE__ */ jsx("use", { href:
|
|
19
|
+
children: href ? /* @__PURE__ */ jsx("use", { href: toIconHref(href, size) }) : null
|
|
18
20
|
}
|
|
19
21
|
);
|
|
20
22
|
});
|
|
23
|
+
function toIconHref(href, size) {
|
|
24
|
+
const separator = href.includes("#") ? "--" : "#";
|
|
25
|
+
const suffix = toIconId(size);
|
|
26
|
+
return `${href}${separator}${suffix}`;
|
|
27
|
+
}
|
|
21
28
|
function toIconId(size) {
|
|
22
29
|
if (size === "large") return "icon-large";
|
|
23
30
|
return "icon";
|
|
@@ -38,7 +45,7 @@ const DisclosureArrow = forwardRef(
|
|
|
38
45
|
{
|
|
39
46
|
...rest,
|
|
40
47
|
render: /* @__PURE__ */ jsx(
|
|
41
|
-
|
|
48
|
+
Role.svg,
|
|
42
49
|
{
|
|
43
50
|
width: "16",
|
|
44
51
|
height: "16",
|
|
@@ -54,7 +61,60 @@ const DisclosureArrow = forwardRef(
|
|
|
54
61
|
);
|
|
55
62
|
}
|
|
56
63
|
);
|
|
64
|
+
const Checkmark = forwardRef(
|
|
65
|
+
(props, forwardedRef) => {
|
|
66
|
+
return /* @__PURE__ */ jsx(
|
|
67
|
+
Icon,
|
|
68
|
+
{
|
|
69
|
+
...props,
|
|
70
|
+
render: /* @__PURE__ */ jsx(
|
|
71
|
+
Role.svg,
|
|
72
|
+
{
|
|
73
|
+
width: "16",
|
|
74
|
+
height: "16",
|
|
75
|
+
fill: "currentColor",
|
|
76
|
+
viewBox: "0 0 16 16",
|
|
77
|
+
render: props.render,
|
|
78
|
+
children: /* @__PURE__ */ jsx(
|
|
79
|
+
"path",
|
|
80
|
+
{
|
|
81
|
+
fillRule: "evenodd",
|
|
82
|
+
d: "M13.854 4.146a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3-3a.5.5 0 1 1 .708-.708L6.5 10.793l6.646-6.647a.5.5 0 0 1 .708 0Z",
|
|
83
|
+
clipRule: "evenodd"
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
ref: forwardedRef
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
const Dismiss = forwardRef(
|
|
94
|
+
(props, forwardedRef) => {
|
|
95
|
+
return /* @__PURE__ */ jsx(
|
|
96
|
+
Icon,
|
|
97
|
+
{
|
|
98
|
+
...props,
|
|
99
|
+
render: /* @__PURE__ */ jsx(
|
|
100
|
+
Role.svg,
|
|
101
|
+
{
|
|
102
|
+
width: "16",
|
|
103
|
+
height: "16",
|
|
104
|
+
viewBox: "0 0 16 16",
|
|
105
|
+
fill: "currentColor",
|
|
106
|
+
render: props.render,
|
|
107
|
+
children: /* @__PURE__ */ jsx("path", { d: "M4.853 4.146a.5.5 0 1 0-.707.708L7.293 8l-3.147 3.146a.5.5 0 0 0 .707.708L8 8.707l3.146 3.147a.5.5 0 0 0 .707-.708L8.707 8l3.146-3.146a.5.5 0 1 0-.707-.708L8 7.293 4.853 4.146Z" })
|
|
108
|
+
}
|
|
109
|
+
),
|
|
110
|
+
ref: forwardedRef
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
);
|
|
57
115
|
export {
|
|
116
|
+
Checkmark,
|
|
58
117
|
DisclosureArrow,
|
|
118
|
+
Dismiss,
|
|
59
119
|
Icon
|
|
60
120
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import { Button } from "./Button.js";
|
|
2
3
|
interface IconButtonBaseProps extends Omit<React.ComponentProps<typeof Button>, "children" | "tone"> {
|
|
3
4
|
/**
|
|
@@ -10,7 +11,7 @@ interface IconButtonBaseProps extends Omit<React.ComponentProps<typeof Button>,
|
|
|
10
11
|
/**
|
|
11
12
|
* Icon to be displayed inside the button.
|
|
12
13
|
*
|
|
13
|
-
* Can be a URL of an SVG from the
|
|
14
|
+
* Can be a URL of an SVG from the `@itwin/itwinui-icons` package,
|
|
14
15
|
* or a custom JSX icon.
|
|
15
16
|
*/
|
|
16
17
|
icon: string | React.JSX.Element;
|
|
@@ -23,11 +24,26 @@ interface IconButtonBaseProps extends Omit<React.ComponentProps<typeof Button>,
|
|
|
23
24
|
* @default "tooltip"
|
|
24
25
|
*/
|
|
25
26
|
labelVariant?: "tooltip" | "visually-hidden";
|
|
27
|
+
/**
|
|
28
|
+
* A small dot displayed in the corner of the icon.
|
|
29
|
+
*
|
|
30
|
+
* The value of this prop gets used as the button's "accessible description".
|
|
31
|
+
*
|
|
32
|
+
* Example:
|
|
33
|
+
* ```tsx
|
|
34
|
+
* <IconButton
|
|
35
|
+
* label="Messages"
|
|
36
|
+
* dot="You have unread messages"
|
|
37
|
+
* icon={…}
|
|
38
|
+
* />
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
dot?: string;
|
|
26
42
|
}
|
|
27
43
|
/**
|
|
28
44
|
* An icon-only button, with a required accessible name.
|
|
29
45
|
*
|
|
30
|
-
* The icon can be a URL from the
|
|
46
|
+
* The icon can be a URL from the `@itwin/itwinui-icons` package:
|
|
31
47
|
* ```tsx
|
|
32
48
|
* <IconButton
|
|
33
49
|
* label="Reveal full content"
|
|
@@ -56,7 +72,7 @@ interface IconButtonBaseProps extends Omit<React.ComponentProps<typeof Button>,
|
|
|
56
72
|
* />
|
|
57
73
|
* ```
|
|
58
74
|
*/
|
|
59
|
-
export declare const IconButton:
|
|
75
|
+
export declare const IconButton: React.ForwardRefExoticComponent<(Omit<IconButtonBaseProps & {
|
|
60
76
|
variant: "ghost";
|
|
61
77
|
/**
|
|
62
78
|
* Whether the button is in a toggled state and currently "active" (toggled on).
|
|
@@ -75,5 +91,5 @@ export declare const IconButton: import("react").ForwardRefExoticComponent<(Omit
|
|
|
75
91
|
}, "ref"> | Omit<IconButtonBaseProps & {
|
|
76
92
|
variant?: Omit<React.ComponentProps<typeof Button>["variant"], "ghost">;
|
|
77
93
|
isActive?: never;
|
|
78
|
-
}, "ref">) &
|
|
94
|
+
}, "ref">) & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
|
|
79
95
|
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
2
3
|
import cx from "classnames";
|
|
4
|
+
import { useToolbarContext, ToolbarItem } from "@ariakit/react/toolbar";
|
|
3
5
|
import { Button } from "./Button.js";
|
|
4
6
|
import { VisuallyHidden } from "./VisuallyHidden.js";
|
|
5
7
|
import { Icon } from "./Icon.js";
|
|
@@ -7,17 +9,26 @@ import { Tooltip } from "./Tooltip.js";
|
|
|
7
9
|
import { forwardRef } from "./~utils.js";
|
|
8
10
|
const IconButton = forwardRef(
|
|
9
11
|
(props, forwardedRef) => {
|
|
10
|
-
const { label, icon, isActive, labelVariant, ...rest } = props;
|
|
12
|
+
const { label, icon, isActive, labelVariant, dot, ...rest } = props;
|
|
13
|
+
const baseId = React.useId();
|
|
14
|
+
const labelId = `${baseId}-label`;
|
|
15
|
+
const dotId = `${baseId}-dot`;
|
|
16
|
+
const toolbar = useToolbarContext();
|
|
11
17
|
const button = /* @__PURE__ */ jsxs(
|
|
12
18
|
Button,
|
|
13
19
|
{
|
|
14
20
|
"aria-pressed": isActive,
|
|
21
|
+
"aria-labelledby": labelId,
|
|
22
|
+
"aria-describedby": dot ? dotId : void 0,
|
|
15
23
|
...rest,
|
|
24
|
+
"data-kiwi-dot": dot ? "true" : void 0,
|
|
25
|
+
render: toolbar ? /* @__PURE__ */ jsx(ToolbarItem, { render: props.render }) : props.render,
|
|
16
26
|
className: cx("\u{1F95D}-icon-button", props.className),
|
|
17
27
|
ref: forwardedRef,
|
|
18
28
|
children: [
|
|
19
|
-
/* @__PURE__ */ jsx(VisuallyHidden, { children: label }),
|
|
20
|
-
typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon
|
|
29
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { id: labelId, children: label }),
|
|
30
|
+
typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon,
|
|
31
|
+
dot ? /* @__PURE__ */ jsx(VisuallyHidden, { id: dotId, "aria-hidden": "true", children: dot }) : null
|
|
21
32
|
]
|
|
22
33
|
}
|
|
23
34
|
);
|
package/dist/bricks/Kbd.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { type BaseProps } from "./~utils.js";
|
|
2
|
+
import { type PredefinedSymbol } from "./Kbd.internal.js";
|
|
2
3
|
interface KbdProps extends BaseProps<"kbd"> {
|
|
3
4
|
/** @default "solid" */
|
|
4
5
|
variant?: "solid" | "muted" | "ghost";
|
|
6
|
+
/**
|
|
7
|
+
* Display a specific key symbol from a predefined list. This is useful for
|
|
8
|
+
* displaying modifier keys or special keys, such as `Control`, `Shift`, `Enter`, etc.
|
|
9
|
+
*
|
|
10
|
+
* Example:
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Kbd symbol="Control" />
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
symbol?: PredefinedSymbol;
|
|
5
16
|
}
|
|
6
17
|
/**
|
|
7
18
|
* A styled wrapper over the HTML `<kbd>` element. This is typically
|
|
@@ -10,6 +21,10 @@ interface KbdProps extends BaseProps<"kbd"> {
|
|
|
10
21
|
* ```tsx
|
|
11
22
|
* <Kbd>Ctrl</Kbd> <Kbd>S</Kbd>
|
|
12
23
|
* ```
|
|
24
|
+
*
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <Kbd symbol="Control" />
|
|
27
|
+
* ```
|
|
13
28
|
*/
|
|
14
29
|
export declare const Kbd: import("react").ForwardRefExoticComponent<KbdProps & import("react").RefAttributes<HTMLElement>>;
|
|
15
30
|
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type PredefinedSymbol = keyof typeof predefinedSymbols;
|
|
2
|
+
export declare const predefinedSymbols: {
|
|
3
|
+
readonly Backspace: "⌫";
|
|
4
|
+
readonly Command: "⌘";
|
|
5
|
+
readonly Control: "Ctrl";
|
|
6
|
+
readonly Down: "↓";
|
|
7
|
+
readonly Eject: "⏏";
|
|
8
|
+
readonly Enter: "↵";
|
|
9
|
+
readonly Escape: "Esc";
|
|
10
|
+
readonly Left: "←";
|
|
11
|
+
readonly Option: "⌥";
|
|
12
|
+
readonly Right: "→";
|
|
13
|
+
readonly Shift: "⇧";
|
|
14
|
+
readonly Space: "␣";
|
|
15
|
+
readonly Tab: "Tab";
|
|
16
|
+
readonly Up: "↑";
|
|
17
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const predefinedSymbols = {
|
|
2
|
+
Backspace: "\u232B",
|
|
3
|
+
Command: "\u2318",
|
|
4
|
+
Control: "Ctrl",
|
|
5
|
+
Down: "\u2193",
|
|
6
|
+
Eject: "\u23CF",
|
|
7
|
+
Enter: "\u21B5",
|
|
8
|
+
Escape: "Esc",
|
|
9
|
+
Left: "\u2190",
|
|
10
|
+
Option: "\u2325",
|
|
11
|
+
Right: "\u2192",
|
|
12
|
+
Shift: "\u21E7",
|
|
13
|
+
Space: "\u2423",
|
|
14
|
+
Tab: "Tab",
|
|
15
|
+
Up: "\u2191"
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
predefinedSymbols
|
|
19
|
+
};
|
package/dist/bricks/Kbd.js
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import cx from "classnames";
|
|
3
|
-
import
|
|
3
|
+
import { Role } from "@ariakit/react/role";
|
|
4
4
|
import { forwardRef } from "./~utils.js";
|
|
5
|
+
import { VisuallyHidden } from "./VisuallyHidden.js";
|
|
6
|
+
import { predefinedSymbols } from "./Kbd.internal.js";
|
|
5
7
|
const Kbd = forwardRef((props, forwardedRef) => {
|
|
6
|
-
const { variant = "solid", ...rest } = props;
|
|
8
|
+
const { variant = "solid", symbol, children, ...rest } = props;
|
|
9
|
+
let content = children;
|
|
10
|
+
if (symbol) {
|
|
11
|
+
content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
12
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: predefinedSymbols[symbol] }),
|
|
13
|
+
children || /* @__PURE__ */ jsx(VisuallyHidden, { children: symbol })
|
|
14
|
+
] });
|
|
15
|
+
}
|
|
7
16
|
return /* @__PURE__ */ jsx(
|
|
8
|
-
|
|
17
|
+
Role,
|
|
9
18
|
{
|
|
10
|
-
"data-kiwi-variant": variant,
|
|
11
19
|
...rest,
|
|
20
|
+
"data-kiwi-variant": variant,
|
|
12
21
|
className: cx("\u{1F95D}-kbd", props.className),
|
|
13
22
|
render: props.render || /* @__PURE__ */ jsx("kbd", {}),
|
|
14
|
-
ref: forwardedRef
|
|
23
|
+
ref: forwardedRef,
|
|
24
|
+
children: content
|
|
15
25
|
}
|
|
16
26
|
);
|
|
17
27
|
});
|
package/dist/bricks/Label.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import cx from "classnames";
|
|
3
|
-
import
|
|
4
|
-
import { useFieldId } from "./Field.js";
|
|
3
|
+
import { Role } from "@ariakit/react/role";
|
|
5
4
|
import { forwardRef } from "./~utils.js";
|
|
5
|
+
import { FieldLabel } from "./Field.js";
|
|
6
6
|
const Label = forwardRef((props, forwardedRef) => {
|
|
7
|
-
const fieldId = useFieldId();
|
|
8
7
|
return /* @__PURE__ */ jsx(
|
|
9
|
-
|
|
8
|
+
FieldLabel,
|
|
10
9
|
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
render: /* @__PURE__ */ jsx(
|
|
11
|
+
Role.label,
|
|
12
|
+
{
|
|
13
|
+
...props,
|
|
14
|
+
className: cx("\u{1F95D}-label", props.className),
|
|
15
|
+
ref: forwardedRef
|
|
16
|
+
}
|
|
17
|
+
)
|
|
15
18
|
}
|
|
16
19
|
);
|
|
17
20
|
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type BaseProps } from "./~utils.js";
|
|
2
|
+
interface ProgressBarProps extends Omit<BaseProps, "aria-labelledby">, Required<Pick<BaseProps, "aria-labelledby">> {
|
|
3
|
+
/**
|
|
4
|
+
* The size of the progress bar.
|
|
5
|
+
* @default "medium"
|
|
6
|
+
*/
|
|
7
|
+
size?: "small" | "medium" | "large";
|
|
8
|
+
/**
|
|
9
|
+
* The tone of the progress bar.
|
|
10
|
+
* @default "neutral"
|
|
11
|
+
*/
|
|
12
|
+
tone?: "neutral" | "accent";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A linear progress bar for indicating progress of an operation (or loading of data).
|
|
16
|
+
* This component maps to the [ARIA `progressbar` role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/progressbar_role)
|
|
17
|
+
* and must be labelled using `aria-labelledby`.
|
|
18
|
+
*
|
|
19
|
+
* Example:
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <ProgressBar aria-labelledby={…} />
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Supports a `tone` prop to change the tone (color) of the progress bar.
|
|
25
|
+
* Supports a `size` prop to change the size of the progress bar.
|
|
26
|
+
*
|
|
27
|
+
* Note: This component currently only supports indeterminate progress, and should
|
|
28
|
+
* only be used for indicating the progress of short operations (i.e. less than 5 seconds).
|
|
29
|
+
*/
|
|
30
|
+
export declare const ProgressBar: import("react").ForwardRefExoticComponent<ProgressBarProps & import("react").RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Role } from "@ariakit/react/role";
|
|
3
|
+
import cx from "classnames";
|
|
4
|
+
import { forwardRef } from "./~utils.js";
|
|
5
|
+
const ProgressBar = forwardRef(
|
|
6
|
+
(props, forwardedRef) => {
|
|
7
|
+
const { size = "medium", tone = "neutral", ...rest } = props;
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
|
+
Role,
|
|
10
|
+
{
|
|
11
|
+
role: "progressbar",
|
|
12
|
+
...rest,
|
|
13
|
+
"data-kiwi-size": size,
|
|
14
|
+
"data-kiwi-tone": tone,
|
|
15
|
+
"data-kiwi-variant": "indeterminate",
|
|
16
|
+
className: cx("\u{1F95D}-progress-bar", props.className),
|
|
17
|
+
ref: forwardedRef
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
export {
|
|
23
|
+
ProgressBar
|
|
24
|
+
};
|
package/dist/bricks/Radio.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type RadioProps as AkRadioProps } from "@ariakit/react/radio";
|
|
2
2
|
import { type FocusableProps } from "./~utils.js";
|
|
3
3
|
type InputBaseProps = Omit<FocusableProps<"input">, "defaultValue" | "value">;
|
|
4
|
-
type RadioOwnProps = Pick<
|
|
4
|
+
type RadioOwnProps = Pick<AkRadioProps, "value" | "checked" | "onChange">;
|
|
5
5
|
interface RadioProps extends InputBaseProps, RadioOwnProps {
|
|
6
6
|
}
|
|
7
7
|
/**
|
package/dist/bricks/Radio.js
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import cx from "classnames";
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
Radio as AkRadio
|
|
5
|
+
} from "@ariakit/react/radio";
|
|
6
|
+
import { FieldControl } from "./Field.js";
|
|
5
7
|
import { forwardRef } from "./~utils.js";
|
|
6
8
|
const Radio = forwardRef((props, forwardedRef) => {
|
|
7
|
-
const
|
|
9
|
+
const { id, ...rest } = props;
|
|
8
10
|
return /* @__PURE__ */ jsx(
|
|
9
|
-
|
|
11
|
+
FieldControl,
|
|
10
12
|
{
|
|
11
|
-
|
|
12
|
-
id
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
type: "checkable",
|
|
14
|
+
id,
|
|
15
|
+
render: /* @__PURE__ */ jsx(
|
|
16
|
+
AkRadio,
|
|
17
|
+
{
|
|
18
|
+
accessibleWhenDisabled: true,
|
|
19
|
+
...rest,
|
|
20
|
+
className: cx("\u{1F95D}-checkbox", "\u{1F95D}-radio", props.className),
|
|
21
|
+
ref: forwardedRef
|
|
22
|
+
}
|
|
23
|
+
)
|
|
16
24
|
}
|
|
17
25
|
);
|
|
18
26
|
});
|