@itwin/itwinui-react 5.0.0-alpha.0 → 5.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/DEV/bricks/Anchor.js +20 -22
- package/dist/DEV/bricks/Button.js +17 -15
- package/dist/DEV/bricks/Checkbox.js +16 -14
- package/dist/DEV/bricks/Divider.js +14 -16
- package/dist/DEV/bricks/DropdownMenu.js +60 -44
- package/dist/DEV/bricks/Field.js +14 -15
- package/dist/DEV/bricks/Icon.js +45 -44
- package/dist/DEV/bricks/IconButton.js +21 -19
- package/dist/DEV/bricks/Kbd.js +14 -16
- package/dist/DEV/bricks/Label.js +2 -2
- package/dist/DEV/bricks/ListItem.js +16 -16
- package/dist/DEV/bricks/Radio.js +2 -2
- package/dist/DEV/bricks/Root.js +45 -43
- package/dist/DEV/bricks/Select.js +55 -0
- package/dist/DEV/bricks/Switch.js +17 -15
- package/dist/DEV/bricks/Tabs.js +14 -15
- package/dist/DEV/bricks/Text.js +20 -0
- package/dist/DEV/bricks/TextBox.js +52 -45
- package/dist/DEV/bricks/Textarea.js +22 -20
- package/dist/DEV/bricks/Tooltip.js +65 -57
- package/dist/DEV/bricks/Tree.js +70 -64
- package/dist/DEV/bricks/VisuallyHidden.js +6 -4
- package/dist/DEV/bricks/index.js +4 -0
- package/dist/DEV/bricks/styles.css.js +1 -1
- package/dist/DEV/bricks/~utils.js +3 -0
- 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 +16 -14
- 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 +22 -2
- package/dist/bricks/Field.js +14 -15
- 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 +21 -19
- package/dist/bricks/Kbd.d.ts +2 -3
- package/dist/bricks/Kbd.js +14 -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 +2 -2
- 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 +55 -0
- package/dist/bricks/Switch.d.ts +17 -3
- package/dist/bricks/Switch.js +17 -15
- package/dist/bricks/Tabs.d.ts +65 -4
- package/dist/bricks/Tabs.js +14 -15
- 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 +52 -45
- package/dist/bricks/Textarea.d.ts +14 -4
- package/dist/bricks/Textarea.js +22 -20
- package/dist/bricks/Tooltip.d.ts +11 -4
- package/dist/bricks/Tooltip.js +65 -57
- package/dist/bricks/Tree.d.ts +5 -5
- package/dist/bricks/Tree.js +67 -61
- package/dist/bricks/VisuallyHidden.d.ts +15 -3
- package/dist/bricks/VisuallyHidden.js +6 -4
- package/dist/bricks/index.d.ts +2 -0
- package/dist/bricks/index.js +4 -0
- package/dist/bricks/styles.css.js +1 -1
- package/dist/bricks/~utils.d.ts +20 -0
- package/dist/bricks/~utils.js +3 -0
- package/package.json +1 -1
package/dist/bricks/TextBox.js
CHANGED
|
@@ -6,31 +6,34 @@ import { useFieldId } from "./Field.js";
|
|
|
6
6
|
import { Icon } from "./Icon.js";
|
|
7
7
|
import { Textarea } from "./Textarea.js";
|
|
8
8
|
import { useMergedRefs } from "./~hooks.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
setDisabled?.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
9
|
+
import { forwardRef } from "./~utils.js";
|
|
10
|
+
const TextBoxInput = forwardRef(
|
|
11
|
+
(props, forwardedRef) => {
|
|
12
|
+
const fieldId = useFieldId();
|
|
13
|
+
const rootContext = React.useContext(TextBoxRootContext);
|
|
14
|
+
const setDisabled = rootContext?.setDisabled;
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
setDisabled?.(props.disabled);
|
|
17
|
+
}, [setDisabled, props.disabled]);
|
|
18
|
+
return /* @__PURE__ */ jsx(
|
|
19
|
+
Ariakit.Role.input,
|
|
20
|
+
{
|
|
21
|
+
id: fieldId,
|
|
22
|
+
...props,
|
|
23
|
+
className: cx({ "\u{1F95D}-text-box": !rootContext }, props.className),
|
|
24
|
+
render: /* @__PURE__ */ jsx(
|
|
25
|
+
Ariakit.Focusable,
|
|
26
|
+
{
|
|
27
|
+
accessibleWhenDisabled: true,
|
|
28
|
+
render: props.render || /* @__PURE__ */ jsx("input", {})
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
ref: useMergedRefs(rootContext?.inputRef, forwardedRef)
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
const TextBoxRoot = forwardRef(
|
|
34
37
|
(props, forwardedRef) => {
|
|
35
38
|
const inputRef = React.useRef(null);
|
|
36
39
|
const [disabled, setDisabled] = React.useState();
|
|
@@ -59,26 +62,30 @@ const TextBoxRoot = React.forwardRef(
|
|
|
59
62
|
);
|
|
60
63
|
}
|
|
61
64
|
);
|
|
62
|
-
const TextBoxIcon =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
65
|
+
const TextBoxIcon = forwardRef(
|
|
66
|
+
(props, forwardedRef) => {
|
|
67
|
+
return /* @__PURE__ */ jsx(
|
|
68
|
+
Icon,
|
|
69
|
+
{
|
|
70
|
+
...props,
|
|
71
|
+
className: cx("\u{1F95D}-text-box-decoration", props.className),
|
|
72
|
+
ref: forwardedRef
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
const TextBoxText = forwardRef(
|
|
78
|
+
(props, forwardedRef) => {
|
|
79
|
+
return /* @__PURE__ */ jsx(
|
|
80
|
+
Ariakit.Role.span,
|
|
81
|
+
{
|
|
82
|
+
...props,
|
|
83
|
+
className: cx("\u{1F95D}-text-box-decoration", props.className),
|
|
84
|
+
ref: forwardedRef
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
);
|
|
82
89
|
const TextBoxRootContext = React.createContext(void 0);
|
|
83
90
|
export {
|
|
84
91
|
TextBoxIcon as Icon,
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { FocusableProps } from "./~utils.js";
|
|
1
|
+
import { type FocusableProps } from "./~utils.js";
|
|
3
2
|
interface TextareaProps extends FocusableProps<"textarea"> {
|
|
4
3
|
}
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
5
|
+
* A styled textarea element that allows users to enter multiline text values.
|
|
7
6
|
*
|
|
8
7
|
* Example usage:
|
|
9
8
|
* ```tsx
|
|
10
9
|
* <TextBox.Textarea defaultValue="Hello" />
|
|
11
10
|
* ```
|
|
11
|
+
*
|
|
12
|
+
* Works well with the `Field` and `Label` components.
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <Field>
|
|
15
|
+
* <Label>Leave a comment, be kind</Label>
|
|
16
|
+
* <TextBox.Textarea />
|
|
17
|
+
* </Field>
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Underneath, it's an HTML textarea, i.e. `<textarea>`, so it supports the same props, including
|
|
21
|
+
* `value`, `defaultValue`, `onChange`, and `disabled`.
|
|
12
22
|
*/
|
|
13
|
-
export declare const Textarea:
|
|
23
|
+
export declare const Textarea: import("react").ForwardRefExoticComponent<TextareaProps & import("react").RefAttributes<HTMLElement | HTMLTextAreaElement>>;
|
|
14
24
|
export {};
|
package/dist/bricks/Textarea.js
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
2
|
import * as Ariakit from "@ariakit/react";
|
|
4
3
|
import cx from "classnames";
|
|
5
4
|
import { useFieldId } from "./Field.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
5
|
+
import { forwardRef } from "./~utils.js";
|
|
6
|
+
const Textarea = forwardRef(
|
|
7
|
+
(props, forwardedRef) => {
|
|
8
|
+
const fieldId = useFieldId();
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
Ariakit.Role.textarea,
|
|
11
|
+
{
|
|
12
|
+
id: fieldId,
|
|
13
|
+
...props,
|
|
14
|
+
className: cx("\u{1F95D}-text-box", props.className),
|
|
15
|
+
render: /* @__PURE__ */ jsx(
|
|
16
|
+
Ariakit.Focusable,
|
|
17
|
+
{
|
|
18
|
+
accessibleWhenDisabled: true,
|
|
19
|
+
render: props.render || /* @__PURE__ */ jsx("textarea", {})
|
|
20
|
+
}
|
|
21
|
+
),
|
|
22
|
+
ref: forwardedRef
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
);
|
|
25
27
|
export {
|
|
26
28
|
Textarea
|
|
27
29
|
};
|
package/dist/bricks/Tooltip.d.ts
CHANGED
|
@@ -3,12 +3,16 @@ import * as Ariakit from "@ariakit/react";
|
|
|
3
3
|
import { type FocusableProps } from "./~utils.js";
|
|
4
4
|
interface TooltipProps extends Omit<FocusableProps<"div">, "content">, Pick<Ariakit.TooltipProps, "open" | "unmountOnHide">, Pick<Ariakit.TooltipProviderProps, "defaultOpen" | "setOpen"> {
|
|
5
5
|
/**
|
|
6
|
-
* The content to be displayed inside the tooltip.
|
|
6
|
+
* The content to be displayed inside the tooltip when the trigger element is hovered or focused.
|
|
7
7
|
*/
|
|
8
8
|
content: React.ReactNode;
|
|
9
9
|
/**
|
|
10
10
|
* The element that will trigger the tooltip when hovered or focused.
|
|
11
11
|
* Common examples include buttons, links, or form controls.
|
|
12
|
+
*
|
|
13
|
+
* **Note**: The trigger must be a single interactive element. Do not add a
|
|
14
|
+
* tooltip to a non-interactive static element (such as a `<div>` or `<svg>`). Also,
|
|
15
|
+
* the trigger element must forward its ref and spread its props.
|
|
12
16
|
*/
|
|
13
17
|
children: React.ReactElement;
|
|
14
18
|
/**
|
|
@@ -23,7 +27,7 @@ interface TooltipProps extends Omit<FocusableProps<"div">, "content">, Pick<Aria
|
|
|
23
27
|
type?: "description" | "label" | "none";
|
|
24
28
|
}
|
|
25
29
|
/**
|
|
26
|
-
*
|
|
30
|
+
* A tooltip component that provides additional information or context for an interactive trigger element.
|
|
27
31
|
*
|
|
28
32
|
* Example usage:
|
|
29
33
|
*
|
|
@@ -33,7 +37,10 @@ interface TooltipProps extends Omit<FocusableProps<"div">, "content">, Pick<Aria
|
|
|
33
37
|
* </Tooltip>
|
|
34
38
|
* ```
|
|
35
39
|
*
|
|
36
|
-
* **Note**:
|
|
40
|
+
* **Note**: The trigger element must be a single interactive element, such as a button or link. Do not add a
|
|
41
|
+
* tooltip to a non-interactive static element (such as a `<div>` or `<svg>`).
|
|
42
|
+
*
|
|
43
|
+
* **Note**: If `type` is set to `"none"`, the tooltip will not use ARIA attributes.
|
|
37
44
|
*/
|
|
38
|
-
export declare const Tooltip: React.ForwardRefExoticComponent<TooltipProps & React.RefAttributes<HTMLDivElement>>;
|
|
45
|
+
export declare const Tooltip: React.ForwardRefExoticComponent<TooltipProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
39
46
|
export {};
|
package/dist/bricks/Tooltip.js
CHANGED
|
@@ -2,66 +2,74 @@ import { Fragment, jsx, jsxs } 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
|
-
import { supportsPopover } from "./~utils.js";
|
|
6
|
-
const Tooltip =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
open: openProp,
|
|
15
|
-
setOpen: setOpenProp,
|
|
16
|
-
unmountOnHide = type === "none",
|
|
17
|
-
...rest
|
|
18
|
-
} = props;
|
|
19
|
-
const store = Ariakit.useTooltipStore();
|
|
20
|
-
const open = Ariakit.useStoreState(store, (state) => state.open);
|
|
21
|
-
const popover = Ariakit.useStoreState(store, (state) => state.popoverElement);
|
|
22
|
-
React.useEffect(
|
|
23
|
-
function syncPopoverWithOpenState() {
|
|
24
|
-
if (popover?.isConnected) {
|
|
25
|
-
popover?.togglePopover?.(open);
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
[open, popover]
|
|
29
|
-
);
|
|
30
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
31
|
-
Ariakit.TooltipProvider,
|
|
32
|
-
{
|
|
33
|
-
store,
|
|
5
|
+
import { forwardRef, supportsPopover } from "./~utils.js";
|
|
6
|
+
const Tooltip = forwardRef(
|
|
7
|
+
(props, forwardedRef) => {
|
|
8
|
+
const {
|
|
9
|
+
content,
|
|
10
|
+
children,
|
|
11
|
+
className,
|
|
12
|
+
type = "description",
|
|
13
|
+
id = React.useId(),
|
|
34
14
|
defaultOpen: defaultOpenProp,
|
|
35
15
|
open: openProp,
|
|
36
16
|
setOpen: setOpenProp,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
17
|
+
unmountOnHide = type === "none",
|
|
18
|
+
...rest
|
|
19
|
+
} = props;
|
|
20
|
+
const store = Ariakit.useTooltipStore();
|
|
21
|
+
const open = Ariakit.useStoreState(store, (state) => state.open);
|
|
22
|
+
const popover = Ariakit.useStoreState(
|
|
23
|
+
store,
|
|
24
|
+
(state) => state.popoverElement
|
|
25
|
+
);
|
|
26
|
+
React.useEffect(
|
|
27
|
+
function syncPopoverWithOpenState() {
|
|
28
|
+
if (popover?.isConnected) {
|
|
29
|
+
popover?.togglePopover?.(open);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
[open, popover]
|
|
33
|
+
);
|
|
34
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
35
|
+
Ariakit.TooltipProvider,
|
|
36
|
+
{
|
|
37
|
+
store,
|
|
38
|
+
defaultOpen: defaultOpenProp,
|
|
39
|
+
open: openProp,
|
|
40
|
+
setOpen: setOpenProp,
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
Ariakit.TooltipAnchor,
|
|
44
|
+
{
|
|
45
|
+
render: children,
|
|
46
|
+
...type === "description" && { "aria-describedby": id },
|
|
47
|
+
...type === "label" && { "aria-labelledby": id }
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
/* @__PURE__ */ jsx(
|
|
51
|
+
Ariakit.Tooltip,
|
|
52
|
+
{
|
|
53
|
+
"aria-hidden": "true",
|
|
54
|
+
...rest,
|
|
55
|
+
unmountOnHide,
|
|
56
|
+
className: cx("\u{1F95D}-tooltip", className),
|
|
57
|
+
ref: forwardedRef,
|
|
58
|
+
id,
|
|
59
|
+
style: {
|
|
60
|
+
zIndex: supportsPopover ? void 0 : 9999,
|
|
61
|
+
...props.style
|
|
62
|
+
},
|
|
63
|
+
wrapperProps: { popover: "manual" },
|
|
64
|
+
portal: !supportsPopover,
|
|
65
|
+
children: content
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
) });
|
|
71
|
+
}
|
|
72
|
+
);
|
|
65
73
|
export {
|
|
66
74
|
Tooltip
|
|
67
75
|
};
|
package/dist/bricks/Tree.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { IconButton } from "./IconButton.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type BaseProps } from "./~utils.js";
|
|
4
4
|
interface TreeProps extends BaseProps {
|
|
5
5
|
}
|
|
6
|
-
declare const Tree: React.ForwardRefExoticComponent<TreeProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
declare const Tree: React.ForwardRefExoticComponent<TreeProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
7
7
|
interface TreeItemProps extends Omit<BaseProps, "content"> {
|
|
8
8
|
content?: React.ReactNode;
|
|
9
9
|
selected?: boolean;
|
|
10
10
|
/** Specifies if the tree item is expanded. Used to determine if a tree item is a parent node. Defaults to `undefined`. */
|
|
11
11
|
expanded?: boolean;
|
|
12
12
|
}
|
|
13
|
-
declare const TreeItem: React.ForwardRefExoticComponent<TreeItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
declare const TreeItem: React.ForwardRefExoticComponent<TreeItemProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
14
14
|
interface TreeItemContentProps extends BaseProps<"span"> {
|
|
15
15
|
}
|
|
16
|
-
declare const TreeItemContent: React.ForwardRefExoticComponent<TreeItemContentProps & React.RefAttributes<HTMLSpanElement>>;
|
|
16
|
+
declare const TreeItemContent: React.ForwardRefExoticComponent<TreeItemContentProps & React.RefAttributes<HTMLElement | HTMLSpanElement>>;
|
|
17
17
|
type IconButtonProps = React.ComponentProps<typeof IconButton>;
|
|
18
18
|
interface TreeItemExpanderProps extends Omit<IconButtonProps, "variant" | "label" | "icon"> {
|
|
19
19
|
label?: IconButtonProps["label"];
|
|
20
20
|
icon?: IconButtonProps["icon"];
|
|
21
21
|
}
|
|
22
|
-
declare const TreeItemExpander: React.ForwardRefExoticComponent<Omit<TreeItemExpanderProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
22
|
+
declare const TreeItemExpander: React.ForwardRefExoticComponent<Omit<TreeItemExpanderProps, "ref"> & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
|
|
23
23
|
export { Tree as Root, TreeItem as Item, TreeItemExpander as Expander, TreeItemContent as Content, };
|
package/dist/bricks/Tree.js
CHANGED
|
@@ -5,77 +5,83 @@ import * as Ariakit from "@ariakit/react";
|
|
|
5
5
|
import * as ListItem from "./ListItem.js";
|
|
6
6
|
import { IconButton } from "./IconButton.js";
|
|
7
7
|
import { Icon } from "./Icon.js";
|
|
8
|
-
|
|
8
|
+
import { forwardRef } from "./~utils.js";
|
|
9
|
+
const Tree = forwardRef((props, forwardedRef) => {
|
|
10
|
+
return /* @__PURE__ */ jsx(Ariakit.Role.div, { ...props, role: "list", ref: forwardedRef, children: props.children });
|
|
11
|
+
});
|
|
12
|
+
const TreeItem = forwardRef((props, forwardedRef) => {
|
|
13
|
+
const { selected, content, children, className, expanded, style, ...rest } = props;
|
|
14
|
+
const parentContext = React.useContext(TreeItemContext);
|
|
15
|
+
const level = parentContext ? parentContext.level + 1 : 1;
|
|
16
|
+
const firstSelected = !!selected && !parentContext?.selected;
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
TreeItemContext.Provider,
|
|
19
|
+
{
|
|
20
|
+
value: React.useMemo(
|
|
21
|
+
() => ({
|
|
22
|
+
level,
|
|
23
|
+
expanded,
|
|
24
|
+
selected
|
|
25
|
+
}),
|
|
26
|
+
[level, expanded, selected]
|
|
27
|
+
),
|
|
28
|
+
children: /* @__PURE__ */ jsxs("div", { role: "listitem", "aria-current": firstSelected ? true : void 0, children: [
|
|
29
|
+
/* @__PURE__ */ jsx(
|
|
30
|
+
ListItem.Root,
|
|
31
|
+
{
|
|
32
|
+
...rest,
|
|
33
|
+
"data-kiwi-expanded": expanded,
|
|
34
|
+
"data-kiwi-selected": selected,
|
|
35
|
+
"data-kiwi-parent-selected": parentContext?.selected,
|
|
36
|
+
className: cx("\u{1F95D}-tree-item", className),
|
|
37
|
+
style: {
|
|
38
|
+
...style,
|
|
39
|
+
"--\u{1F95D}tree-item-level": level
|
|
40
|
+
},
|
|
41
|
+
ref: forwardedRef,
|
|
42
|
+
role: void 0,
|
|
43
|
+
children: content
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
children && /* @__PURE__ */ jsx("div", { role: "list", children })
|
|
47
|
+
] })
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
const TreeItemContent = forwardRef(
|
|
9
52
|
(props, forwardedRef) => {
|
|
10
|
-
|
|
53
|
+
const { children, ...rest } = props;
|
|
54
|
+
return /* @__PURE__ */ jsx(
|
|
55
|
+
ListItem.Content,
|
|
56
|
+
{
|
|
57
|
+
...rest,
|
|
58
|
+
className: cx("\u{1F95D}-tree-item-content", props.className),
|
|
59
|
+
ref: forwardedRef,
|
|
60
|
+
children: /* @__PURE__ */ jsx("button", { type: "button", children })
|
|
61
|
+
}
|
|
62
|
+
);
|
|
11
63
|
}
|
|
12
64
|
);
|
|
13
|
-
const
|
|
65
|
+
const TreeItemExpander = forwardRef(
|
|
14
66
|
(props, forwardedRef) => {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const level = parentContext ? parentContext.level + 1 : 1;
|
|
67
|
+
const context = React.useContext(TreeItemContext);
|
|
68
|
+
const expanded = context?.expanded;
|
|
18
69
|
return /* @__PURE__ */ jsx(
|
|
19
|
-
|
|
70
|
+
IconButton,
|
|
20
71
|
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/* @__PURE__ */ jsx(
|
|
30
|
-
ListItem.Root,
|
|
31
|
-
{
|
|
32
|
-
...rest,
|
|
33
|
-
"data-kiwi-expanded": expanded,
|
|
34
|
-
"data-kiwi-selected": selected,
|
|
35
|
-
className: cx("\u{1F95D}-tree-item", className),
|
|
36
|
-
style: {
|
|
37
|
-
...style,
|
|
38
|
-
"--\u{1F95D}tree-item-level": level
|
|
39
|
-
},
|
|
40
|
-
ref: forwardedRef,
|
|
41
|
-
role: void 0,
|
|
42
|
-
children: content
|
|
43
|
-
}
|
|
44
|
-
),
|
|
45
|
-
children && /* @__PURE__ */ jsx("div", { role: "list", children })
|
|
46
|
-
] })
|
|
72
|
+
icon: /* @__PURE__ */ jsx(TreeChevron, {}),
|
|
73
|
+
label: "Toggle",
|
|
74
|
+
"aria-expanded": expanded === void 0 ? void 0 : expanded,
|
|
75
|
+
...props,
|
|
76
|
+
className: cx("\u{1F95D}-tree-item-expander", props.className),
|
|
77
|
+
variant: "ghost",
|
|
78
|
+
labelVariant: "visually-hidden",
|
|
79
|
+
ref: forwardedRef
|
|
47
80
|
}
|
|
48
81
|
);
|
|
49
82
|
}
|
|
50
83
|
);
|
|
51
|
-
const
|
|
52
|
-
return /* @__PURE__ */ jsx(
|
|
53
|
-
ListItem.Content,
|
|
54
|
-
{
|
|
55
|
-
...props,
|
|
56
|
-
className: cx("\u{1F95D}-tree-item-content", props.className),
|
|
57
|
-
ref: forwardedRef
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
});
|
|
61
|
-
const TreeItemExpander = React.forwardRef((props, forwardedRef) => {
|
|
62
|
-
const context = React.useContext(TreeItemContext);
|
|
63
|
-
const expanded = context?.expanded;
|
|
64
|
-
return /* @__PURE__ */ jsx(
|
|
65
|
-
IconButton,
|
|
66
|
-
{
|
|
67
|
-
icon: /* @__PURE__ */ jsx(TreeChevron, {}),
|
|
68
|
-
label: "Toggle",
|
|
69
|
-
"aria-expanded": expanded === void 0 ? void 0 : expanded,
|
|
70
|
-
...props,
|
|
71
|
-
className: cx("\u{1F95D}-tree-item-expander", props.className),
|
|
72
|
-
variant: "ghost",
|
|
73
|
-
labelVariant: "visually-hidden",
|
|
74
|
-
ref: forwardedRef
|
|
75
|
-
}
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
const TreeChevron = React.forwardRef(
|
|
84
|
+
const TreeChevron = forwardRef(
|
|
79
85
|
(props, forwardedRef) => {
|
|
80
86
|
return /* @__PURE__ */ jsx(
|
|
81
87
|
Icon,
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { BaseProps } from "./~utils.js";
|
|
1
|
+
import { type BaseProps } from "./~utils.js";
|
|
3
2
|
interface VisuallyHiddenProps extends BaseProps<"span"> {
|
|
4
3
|
}
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* A visually hidden element that is still accessible to screen readers and other assistive technology.
|
|
6
|
+
*
|
|
7
|
+
* This is useful when you want to provide a text alternative to a visual element (e.g. an icon or symbol).
|
|
8
|
+
*
|
|
9
|
+
* Example:
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <span aria-hidden="true">⭐</span>
|
|
12
|
+
* <VisuallyHidden>Favorite</VisuallyHidden>
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* **Note**: The `IconButton` component utilizes `VisuallyHidden` internally when the `label` prop is set.
|
|
16
|
+
*/
|
|
17
|
+
export declare const VisuallyHidden: import("react").ForwardRefExoticComponent<VisuallyHiddenProps & import("react").RefAttributes<HTMLElement | HTMLSpanElement>>;
|
|
6
18
|
export {};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from "react";
|
|
3
2
|
import * as Ariakit from "@ariakit/react";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { forwardRef } from "./~utils.js";
|
|
4
|
+
const VisuallyHidden = forwardRef(
|
|
5
|
+
(props, forwardedRef) => {
|
|
6
|
+
return /* @__PURE__ */ jsx(Ariakit.VisuallyHidden, { ...props, ref: forwardedRef });
|
|
7
|
+
}
|
|
8
|
+
);
|
|
7
9
|
export {
|
|
8
10
|
VisuallyHidden
|
|
9
11
|
};
|
package/dist/bricks/index.d.ts
CHANGED
|
@@ -10,8 +10,10 @@ export { Field } from "./Field.js";
|
|
|
10
10
|
export { Kbd } from "./Kbd.js";
|
|
11
11
|
export { Label } from "./Label.js";
|
|
12
12
|
export { Radio } from "./Radio.js";
|
|
13
|
+
export * as Select from "./Select.js";
|
|
13
14
|
export { Switch } from "./Switch.js";
|
|
14
15
|
export * as Tabs from "./Tabs.js";
|
|
16
|
+
export { Text } from "./Text.js";
|
|
15
17
|
export * as TextBox from "./TextBox.js";
|
|
16
18
|
export { Tooltip } from "./Tooltip.js";
|
|
17
19
|
export { VisuallyHidden } from "./VisuallyHidden.js";
|
package/dist/bricks/index.js
CHANGED
|
@@ -11,8 +11,10 @@ import { Field } from "./Field.js";
|
|
|
11
11
|
import { Kbd } from "./Kbd.js";
|
|
12
12
|
import { Label } from "./Label.js";
|
|
13
13
|
import { Radio } from "./Radio.js";
|
|
14
|
+
import * as Select from "./Select.js";
|
|
14
15
|
import { Switch } from "./Switch.js";
|
|
15
16
|
import * as Tabs from "./Tabs.js";
|
|
17
|
+
import { Text } from "./Text.js";
|
|
16
18
|
import * as TextBox from "./TextBox.js";
|
|
17
19
|
import { Tooltip } from "./Tooltip.js";
|
|
18
20
|
import { VisuallyHidden } from "./VisuallyHidden.js";
|
|
@@ -29,8 +31,10 @@ export {
|
|
|
29
31
|
Label,
|
|
30
32
|
Radio,
|
|
31
33
|
Root,
|
|
34
|
+
Select,
|
|
32
35
|
Switch,
|
|
33
36
|
Tabs,
|
|
37
|
+
Text,
|
|
34
38
|
TextBox,
|
|
35
39
|
Tooltip,
|
|
36
40
|
VisuallyHidden
|