@itwin/itwinui-react 5.0.0-alpha.0 → 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.
Files changed (118) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +6 -6
  3. package/dist/DEV/bricks/Anchor.js +16 -23
  4. package/dist/DEV/bricks/Avatar.js +24 -0
  5. package/dist/DEV/bricks/Badge.js +22 -0
  6. package/dist/DEV/bricks/Button.js +25 -16
  7. package/dist/DEV/bricks/Checkbox.js +26 -16
  8. package/dist/DEV/bricks/Chip.js +42 -0
  9. package/dist/DEV/bricks/Description.js +29 -0
  10. package/dist/DEV/bricks/Divider.js +16 -17
  11. package/dist/DEV/bricks/DropdownMenu.js +143 -48
  12. package/dist/DEV/bricks/Field.js +120 -20
  13. package/dist/DEV/bricks/Icon.js +108 -45
  14. package/dist/DEV/bricks/IconButton.js +31 -18
  15. package/dist/DEV/bricks/Kbd.internal.js +19 -0
  16. package/dist/DEV/bricks/Kbd.js +32 -17
  17. package/dist/DEV/bricks/Label.js +13 -10
  18. package/dist/DEV/bricks/ProgressBar.js +25 -0
  19. package/dist/DEV/bricks/Radio.js +19 -11
  20. package/dist/DEV/bricks/Root.js +78 -45
  21. package/dist/DEV/bricks/Select.js +61 -0
  22. package/dist/DEV/bricks/Skeleton.js +24 -0
  23. package/dist/DEV/bricks/Spinner.js +40 -0
  24. package/dist/DEV/bricks/Switch.js +27 -17
  25. package/dist/DEV/bricks/Table.js +114 -0
  26. package/dist/DEV/bricks/Tabs.js +19 -20
  27. package/dist/DEV/bricks/Text.js +20 -0
  28. package/dist/DEV/bricks/TextBox.js +95 -50
  29. package/dist/DEV/bricks/Tooltip.js +58 -58
  30. package/dist/DEV/bricks/Tree.js +16 -102
  31. package/dist/DEV/bricks/TreeItem.js +224 -0
  32. package/dist/DEV/bricks/VisuallyHidden.js +7 -5
  33. package/dist/DEV/bricks/index.js +20 -0
  34. package/dist/DEV/bricks/styles.css.js +2 -2
  35. package/dist/DEV/bricks/~hooks.js +55 -3
  36. package/dist/DEV/bricks/~utils.GhostAligner.js +13 -0
  37. package/dist/DEV/bricks/~utils.ListItem.js +49 -0
  38. package/dist/DEV/bricks/~utils.js +3 -0
  39. package/dist/DEV/foundations/styles.css.js +2 -2
  40. package/dist/bricks/Anchor.d.ts +12 -3
  41. package/dist/bricks/Anchor.js +16 -23
  42. package/dist/bricks/Avatar.d.ts +47 -0
  43. package/dist/bricks/Avatar.js +23 -0
  44. package/dist/bricks/Badge.d.ts +28 -0
  45. package/dist/bricks/Badge.js +21 -0
  46. package/dist/bricks/Button.d.ts +27 -4
  47. package/dist/bricks/Button.js +25 -16
  48. package/dist/bricks/Checkbox.d.ts +19 -5
  49. package/dist/bricks/Checkbox.js +26 -16
  50. package/dist/bricks/Chip.d.ts +31 -0
  51. package/dist/bricks/Chip.js +41 -0
  52. package/dist/bricks/Description.d.ts +19 -0
  53. package/dist/bricks/Description.js +29 -0
  54. package/dist/bricks/Divider.d.ts +5 -6
  55. package/dist/bricks/Divider.js +16 -17
  56. package/dist/bricks/DropdownMenu.d.ts +92 -15
  57. package/dist/bricks/DropdownMenu.js +138 -46
  58. package/dist/bricks/Field.d.ts +45 -3
  59. package/dist/bricks/Field.js +120 -20
  60. package/dist/bricks/Icon.d.ts +38 -7
  61. package/dist/bricks/Icon.js +105 -44
  62. package/dist/bricks/IconButton.d.ts +20 -4
  63. package/dist/bricks/IconButton.js +31 -18
  64. package/dist/bricks/Kbd.d.ts +17 -3
  65. package/dist/bricks/Kbd.internal.d.ts +17 -0
  66. package/dist/bricks/Kbd.internal.js +19 -0
  67. package/dist/bricks/Kbd.js +25 -17
  68. package/dist/bricks/Label.d.ts +22 -3
  69. package/dist/bricks/Label.js +13 -10
  70. package/dist/bricks/ProgressBar.d.ts +31 -0
  71. package/dist/bricks/ProgressBar.js +24 -0
  72. package/dist/bricks/Radio.d.ts +19 -5
  73. package/dist/bricks/Radio.js +19 -11
  74. package/dist/bricks/Root.d.ts +11 -2
  75. package/dist/bricks/Root.js +78 -45
  76. package/dist/bricks/Select.d.ts +51 -0
  77. package/dist/bricks/Select.js +61 -0
  78. package/dist/bricks/Skeleton.d.ts +25 -0
  79. package/dist/bricks/Skeleton.js +23 -0
  80. package/dist/bricks/Spinner.d.ts +31 -0
  81. package/dist/bricks/Spinner.js +39 -0
  82. package/dist/bricks/Switch.d.ts +19 -5
  83. package/dist/bricks/Switch.js +27 -17
  84. package/dist/bricks/Table.d.ts +115 -0
  85. package/dist/bricks/Table.js +108 -0
  86. package/dist/bricks/Tabs.d.ts +69 -8
  87. package/dist/bricks/Tabs.js +19 -20
  88. package/dist/bricks/Text.d.ts +22 -0
  89. package/dist/bricks/Text.js +19 -0
  90. package/dist/bricks/TextBox.d.ts +62 -11
  91. package/dist/bricks/TextBox.js +94 -50
  92. package/dist/bricks/Tooltip.d.ts +13 -6
  93. package/dist/bricks/Tooltip.js +58 -58
  94. package/dist/bricks/Tree.d.ts +20 -21
  95. package/dist/bricks/Tree.js +15 -97
  96. package/dist/bricks/TreeItem.d.ts +123 -0
  97. package/dist/bricks/TreeItem.js +219 -0
  98. package/dist/bricks/VisuallyHidden.d.ts +15 -3
  99. package/dist/bricks/VisuallyHidden.js +7 -5
  100. package/dist/bricks/index.d.ts +10 -0
  101. package/dist/bricks/index.js +20 -0
  102. package/dist/bricks/styles.css.js +2 -2
  103. package/dist/bricks/~hooks.d.ts +55 -0
  104. package/dist/bricks/~hooks.js +55 -3
  105. package/dist/bricks/~utils.GhostAligner.d.ts +22 -0
  106. package/dist/bricks/~utils.GhostAligner.js +13 -0
  107. package/dist/bricks/~utils.ListItem.d.ts +14 -0
  108. package/dist/bricks/~utils.ListItem.js +46 -0
  109. package/dist/bricks/~utils.d.ts +26 -3
  110. package/dist/bricks/~utils.js +3 -0
  111. package/dist/foundations/styles.css.js +2 -2
  112. package/package.json +14 -13
  113. package/dist/DEV/bricks/ListItem.js +0 -33
  114. package/dist/DEV/bricks/Textarea.js +0 -28
  115. package/dist/bricks/ListItem.d.ts +0 -11
  116. package/dist/bricks/ListItem.js +0 -31
  117. package/dist/bricks/Textarea.d.ts +0 -14
  118. package/dist/bricks/Textarea.js +0 -27
@@ -1,28 +1,21 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
2
  import cx from "classnames";
4
- import * as Ariakit from "@ariakit/react";
5
- const Anchor = React.forwardRef(
6
- (props, forwardedRef) => {
7
- const { tone = "neutral", ...rest } = props;
8
- return /* @__PURE__ */ jsx(
9
- Ariakit.Role.a,
10
- {
11
- "data-kiwi-tone": tone,
12
- ...rest,
13
- className: cx("\u{1F95D}-anchor", props.className),
14
- render: /* @__PURE__ */ jsx(
15
- Ariakit.Focusable,
16
- {
17
- accessibleWhenDisabled: true,
18
- render: props.render || /* @__PURE__ */ jsx("a", {})
19
- }
20
- ),
21
- ref: forwardedRef
22
- }
23
- );
24
- }
25
- );
3
+ import { Role } from "@ariakit/react/role";
4
+ import { Focusable } from "@ariakit/react/focusable";
5
+ import { forwardRef } from "./~utils.js";
6
+ const Anchor = forwardRef((props, forwardedRef) => {
7
+ const { tone = "neutral", ...rest } = props;
8
+ return /* @__PURE__ */ jsx(
9
+ Role.a,
10
+ {
11
+ ...rest,
12
+ "data-kiwi-tone": tone,
13
+ className: cx("\u{1F95D}-anchor", props.className),
14
+ render: /* @__PURE__ */ jsx(Focusable, { accessibleWhenDisabled: true, render: props.render || /* @__PURE__ */ jsx("a", {}) }),
15
+ ref: forwardedRef
16
+ }
17
+ );
18
+ });
26
19
  export {
27
20
  Anchor
28
21
  };
@@ -0,0 +1,47 @@
1
+ import { type BaseProps } from "./~utils.js";
2
+ interface AvatarProps extends BaseProps<"span"> {
3
+ /**
4
+ * The size of the avatar.
5
+ * @default "medium"
6
+ */
7
+ size?: "small" | "medium" | "large" | "xlarge";
8
+ /**
9
+ * Initials that gets displayed in the absence of an image.
10
+ */
11
+ initials?: string;
12
+ /**
13
+ * Alternative text describing the avatar, typically the user's or organization's full name.
14
+ *
15
+ * When this prop is passed, the avatar gets rendered as `role="img"` and labelled
16
+ * using the provided text.
17
+ *
18
+ * This prop is not required if the avatar is purely decorative. By default, the avatar
19
+ * will be hidden from the accessibility tree.
20
+ */
21
+ alt?: string;
22
+ /**
23
+ * Image to be displayed. Can be `<img>` or `<svg>` or anything else.
24
+ */
25
+ image?: React.JSX.Element;
26
+ }
27
+ /**
28
+ * An avatar to represent a user or organization.
29
+ *
30
+ * By default, this component assumes that the avatar is decorative, so it adds `aria-hidden` by default.
31
+ * ```tsx
32
+ * <Avatar initials="JD" />
33
+ * ```
34
+ *
35
+ * If the avatar is semantically meaningful, the `alt` prop can be used to provide alternative text.
36
+ * ```tsx
37
+ * <Avatar initials="JD" alt="John Doe" />
38
+ * ```
39
+ *
40
+ * Image & size examples:
41
+ * ```tsx
42
+ * <Avatar initials="JD" alt="John Doe" size="xlarge" image={<img src="…" alt="">} />
43
+ * <Avatar initials="JD" alt="John Doe" size="small" image={<Icon href="…">} />
44
+ * ```
45
+ */
46
+ export declare const Avatar: import("react").ForwardRefExoticComponent<AvatarProps & import("react").RefAttributes<HTMLElement | HTMLSpanElement>>;
47
+ export {};
@@ -0,0 +1,23 @@
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
+ export {
22
+ Avatar
23
+ };
@@ -0,0 +1,28 @@
1
+ import { type BaseProps } from "./~utils.js";
2
+ interface BadgeProps extends Omit<BaseProps<"span">, "children"> {
3
+ /**
4
+ * The label displayed inside the badge.
5
+ */
6
+ label: string;
7
+ /**
8
+ * The tone of the badge.
9
+ * @default "neutral"
10
+ */
11
+ tone?: "neutral" | "info" | "positive" | "attention" | "critical";
12
+ /**
13
+ * The variant style of the badge.
14
+ * @default "solid"
15
+ */
16
+ variant?: "solid" | "muted" | "outline";
17
+ }
18
+ /**
19
+ * A badge component, typically used to designate the status of an item.
20
+ *
21
+ * Example:
22
+ * ```tsx
23
+ * <Badge label="Value" />
24
+ * <Badge label="Value" tone="info" variant="outline" />
25
+ * ```
26
+ */
27
+ export declare const Badge: import("react").ForwardRefExoticComponent<BadgeProps & import("react").RefAttributes<HTMLElement | HTMLSpanElement>>;
28
+ export {};
@@ -0,0 +1,21 @@
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
+ export {
20
+ Badge
21
+ };
@@ -1,7 +1,10 @@
1
- import * as React from "react";
2
- import type { FocusableProps } from "./~utils.js";
1
+ import { type FocusableProps } from "./~utils.js";
3
2
  type ButtonProps = FocusableProps<"button"> & ({
4
- /** @default "solid" */
3
+ /**
4
+ * The variant of the button, i.e. solid, outline, or ghost.
5
+ *
6
+ * @default "solid"
7
+ */
5
8
  variant?: "solid";
6
9
  /**
7
10
  * The tone of the button. Most buttons should be neutral.
@@ -16,5 +19,25 @@ type ButtonProps = FocusableProps<"button"> & ({
16
19
  variant: "outline" | "ghost";
17
20
  tone?: never;
18
21
  });
19
- export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
22
+ /**
23
+ * A styled button element which allows the user to perform an action when clicked.
24
+ *
25
+ * Example:
26
+ * ```tsx
27
+ * <Button onClick={() => doSomething()}>Click me</Button>
28
+ * ```
29
+ *
30
+ * Start and end icons can be added by passing `Icon` as children.
31
+ *
32
+ * ```tsx
33
+ * <Button>
34
+ * <Icon href={…} />
35
+ * Click me
36
+ * <Icon href={…} />
37
+ * </Button>
38
+ * ```
39
+ *
40
+ * The button's appearance can be customized using the `variant` and `tone` props.
41
+ */
42
+ export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLElement | HTMLButtonElement>>;
20
43
  export {};
@@ -1,21 +1,30 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
2
  import cx from "classnames";
4
- import * as Ariakit from "@ariakit/react";
5
- const Button = React.forwardRef((props, forwardedRef) => {
6
- const { variant = "solid", tone = "neutral", ...rest } = props;
7
- return /* @__PURE__ */ jsx(
8
- Ariakit.Button,
9
- {
10
- accessibleWhenDisabled: true,
11
- "data-kiwi-variant": variant,
12
- "data-kiwi-tone": tone,
13
- ...rest,
14
- className: cx("\u{1F95D}-button", props.className),
15
- ref: forwardedRef
16
- }
17
- );
18
- });
3
+ import { Button as AkButton } from "@ariakit/react/button";
4
+ import { forwardRef } from "./~utils.js";
5
+ import { useGhostAlignment } from "./~utils.GhostAligner.js";
6
+ const Button = forwardRef(
7
+ (props, forwardedRef) => {
8
+ const { variant = "solid", tone = "neutral", ...rest } = props;
9
+ const ghostAlignment = useGhostAlignment();
10
+ return /* @__PURE__ */ jsx(
11
+ AkButton,
12
+ {
13
+ accessibleWhenDisabled: true,
14
+ ...rest,
15
+ "data-kiwi-variant": variant,
16
+ "data-kiwi-tone": tone,
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
+ ),
23
+ ref: forwardedRef
24
+ }
25
+ );
26
+ }
27
+ );
19
28
  export {
20
29
  Button
21
30
  };
@@ -1,9 +1,23 @@
1
- import * as React from "react";
2
- import * as Ariakit from "@ariakit/react";
3
- import type { FocusableProps } from "./~utils.js";
1
+ import { type CheckboxProps as AkCheckboxProps } from "@ariakit/react/checkbox";
2
+ import { type FocusableProps } from "./~utils.js";
4
3
  type InputBaseProps = Omit<FocusableProps<"input">, "defaultValue" | "checked" | "defaultChecked">;
5
- type CheckboxOwnProps = Pick<Ariakit.CheckboxProps, "value" | "defaultChecked" | "checked" | "onChange">;
4
+ type CheckboxOwnProps = Pick<AkCheckboxProps, "value" | "defaultChecked" | "checked" | "onChange">;
6
5
  interface CheckboxProps extends InputBaseProps, CheckboxOwnProps {
7
6
  }
8
- export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
7
+ /**
8
+ * A styled checkbox element, typically used for selecting one or more options from a list.
9
+ *
10
+ * Works well the `Field` and `Label` components.
11
+ *
12
+ * ```tsx
13
+ * <Field>
14
+ * <Label>Check me</Label>
15
+ * <Checkbox />
16
+ * </Field>
17
+ * ```
18
+ *
19
+ * Underneath, it's an HTML checkbox, i.e. `<input type="checkbox">`, so it supports the same props,
20
+ * including `value`, `defaultChecked`, `checked`, and `onChange`.
21
+ */
22
+ export declare const Checkbox: import("react").ForwardRefExoticComponent<CheckboxProps & import("react").RefAttributes<HTMLElement | HTMLInputElement>>;
9
23
  export {};
@@ -1,21 +1,31 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
2
  import cx from "classnames";
4
- import * as Ariakit from "@ariakit/react";
5
- import { useFieldId } from "./Field.js";
6
- const Checkbox = React.forwardRef((props, forwardedRef) => {
7
- const fieldId = useFieldId();
8
- return /* @__PURE__ */ jsx(
9
- Ariakit.Checkbox,
10
- {
11
- accessibleWhenDisabled: true,
12
- id: fieldId,
13
- ...props,
14
- className: cx("\u{1F95D}-checkbox", props.className),
15
- ref: forwardedRef
16
- }
17
- );
18
- });
3
+ import {
4
+ Checkbox as AkCheckbox
5
+ } from "@ariakit/react/checkbox";
6
+ import { FieldControl } from "./Field.js";
7
+ import { forwardRef } from "./~utils.js";
8
+ const Checkbox = forwardRef(
9
+ (props, forwardedRef) => {
10
+ const { id, ...rest } = props;
11
+ return /* @__PURE__ */ jsx(
12
+ FieldControl,
13
+ {
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
+ )
25
+ }
26
+ );
27
+ }
28
+ );
19
29
  export {
20
30
  Checkbox
21
31
  };
@@ -0,0 +1,31 @@
1
+ import * as React from "react";
2
+ import { type BaseProps } from "./~utils.js";
3
+ interface ChipProps extends Omit<BaseProps<"div">, "children"> {
4
+ /**
5
+ * The label displayed inside the chip.
6
+ */
7
+ label: string;
8
+ /**
9
+ * The variant style of the Chip.
10
+ * Use "solid" for primary states and "outline" for less prominent states.
11
+ *
12
+ * @default "solid"
13
+ */
14
+ variant?: "solid" | "outline";
15
+ /**
16
+ * Callback invoked when the dismiss ("❌") button is clicked.
17
+ */
18
+ onDismiss?: () => void;
19
+ }
20
+ /**
21
+ * Chip is a UI component used to represent an item, attribute, or action in a compact visual style.
22
+ * It supports two visual variants: `solid` for primary emphasis and `outline` for less prominent states.
23
+ *
24
+ * Example:
25
+ * ```tsx
26
+ * <Chip label="Value" />
27
+ * <Chip label="Value" variant="outline" />
28
+ * ```
29
+ */
30
+ export declare const Chip: React.ForwardRefExoticComponent<ChipProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
31
+ export {};
@@ -0,0 +1,41 @@
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
+ export {
40
+ Chip
41
+ };
@@ -0,0 +1,19 @@
1
+ import { type BaseProps } from "./~utils.js";
2
+ interface DescriptionProps extends BaseProps {
3
+ /**
4
+ * The tone of the description.
5
+ * @default "neutral"
6
+ */
7
+ tone?: "neutral" | "critical";
8
+ }
9
+ /**
10
+ * An additional description for a form control.
11
+ *
12
+ * Should not include content without an adequate text alternative.
13
+ *
14
+ * Either give this component an `id` and manually associate with a form control
15
+ * using `aria-describedby` on said control or use the `<Field>` component
16
+ * (WIP).
17
+ */
18
+ export declare const Description: import("react").ForwardRefExoticComponent<DescriptionProps & import("react").RefAttributes<HTMLElement | HTMLDivElement>>;
19
+ export {};
@@ -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,7 +1,6 @@
1
- import * as React from "react";
2
- import * as Ariakit from "@ariakit/react";
3
- import type { BaseProps } from "./~utils.js";
4
- interface DividerProps extends BaseProps<"hr">, Pick<Ariakit.SeparatorProps, "orientation"> {
1
+ import { type SeparatorProps } from "@ariakit/react/separator";
2
+ import { type BaseProps } from "./~utils.js";
3
+ interface DividerProps extends BaseProps<"hr">, Pick<SeparatorProps, "orientation"> {
5
4
  /**
6
5
  * If true, the divider will be purely presentational and will not have any associated semantics.
7
6
  *
@@ -10,10 +9,10 @@ interface DividerProps extends BaseProps<"hr">, Pick<Ariakit.SeparatorProps, "or
10
9
  presentational?: boolean;
11
10
  }
12
11
  /**
13
- * The `Divider` component can be used for grouping and dividing content within a layout.
12
+ * A styled "separator" element (e.g. `<hr>`), useful for grouping and dividing content within a layout.
14
13
  *
15
14
  * A `Divider` can be oriented horizontally or vertically (using the `orientation` prop),
16
15
  * and can be a semantic divider or a purely presentational one (using the `presentational` prop).
17
16
  */
18
- export declare const Divider: React.ForwardRefExoticComponent<DividerProps & React.RefAttributes<HTMLDivElement>>;
17
+ export declare const Divider: import("react").ForwardRefExoticComponent<DividerProps & import("react").RefAttributes<HTMLElement | HTMLHRElement>>;
19
18
  export {};
@@ -1,22 +1,21 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
2
  import cx from "classnames";
4
- import * as Ariakit from "@ariakit/react";
5
- const Divider = React.forwardRef(
6
- (props, forwardedRef) => {
7
- const { presentational, ...rest } = props;
8
- const Comp = presentational ? Ariakit.Role : Ariakit.Separator;
9
- return /* @__PURE__ */ jsx(
10
- Comp,
11
- {
12
- ...rest,
13
- className: cx("\u{1F95D}-divider", props.className),
14
- "data-kiwi-orientation": props.orientation,
15
- ref: forwardedRef
16
- }
17
- );
18
- }
19
- );
3
+ import { Role } from "@ariakit/react/role";
4
+ import { Separator } from "@ariakit/react/separator";
5
+ import { forwardRef } from "./~utils.js";
6
+ const Divider = forwardRef((props, forwardedRef) => {
7
+ const { presentational, ...rest } = props;
8
+ const Comp = presentational ? Role : Separator;
9
+ return /* @__PURE__ */ jsx(
10
+ Comp,
11
+ {
12
+ ...rest,
13
+ className: cx("\u{1F95D}-divider", props.className),
14
+ "data-kiwi-orientation": props.orientation,
15
+ ref: forwardedRef
16
+ }
17
+ );
18
+ });
20
19
  export {
21
20
  Divider
22
21
  };
@@ -1,22 +1,28 @@
1
1
  import * as React from "react";
2
- import * as Ariakit from "@ariakit/react";
3
- import { type FocusableProps } from "./~utils.js";
4
- interface DropdownMenuProps extends Pick<Ariakit.MenuProviderProps, "children" | "placement" | "open" | "setOpen" | "defaultOpen"> {
2
+ import { type AnyString, type BaseProps, type FocusableProps } from "./~utils.js";
3
+ import { type MenuItemCheckboxProps, type MenuProviderProps } from "@ariakit/react/menu";
4
+ import { type PredefinedSymbol } from "./Kbd.internal.js";
5
+ interface DropdownMenuProps extends Pick<MenuProviderProps, "children" | "placement" | "open" | "setOpen" | "defaultOpen"> {
5
6
  }
6
7
  /**
7
- * Dropdown menu component displays a list of actions or commands.
8
+ * A dropdown menu displays a list of actions or commands when the menu button is clicked.
8
9
  *
10
+ * `DropdownMenu` is a compound component with subcomponents exposed for different parts.
11
+ *
12
+ * Example:
9
13
  * ```tsx
10
14
  * <DropdownMenu.Root>
11
- * <DropdownMenu.Button>Actions</DropdownMenu.Button>
15
+ * <DropdownMenu.Button>Actions</DropdownMenu.Button>
12
16
  *
13
- * <DropdownMenu.Content>
14
- * <DropdownMenu.Item>Add</DropdownMenu.Item>
15
- * <DropdownMenu.Item>Edit</DropdownMenu.Item>
16
- * <DropdownMenu.Item>Delete</DropdownMenu.Item>
17
- * </DropdownMenu.Content>
17
+ * <DropdownMenu.Content>
18
+ * <DropdownMenu.Item label="Add" />
19
+ * <DropdownMenu.Item label="Edit" />
20
+ * <DropdownMenu.Item label="Delete" />
21
+ * </DropdownMenu.Content>
18
22
  * </DropdownMenu.Root>
19
23
  * ```
24
+ *
25
+ * **Note**: `DropdownMenu` should not be used for navigation; it is only intended for actions.
20
26
  */
21
27
  declare function DropdownMenu(props: DropdownMenuProps): import("react/jsx-runtime").JSX.Element;
22
28
  declare namespace DropdownMenu {
@@ -24,11 +30,82 @@ declare namespace DropdownMenu {
24
30
  }
25
31
  interface DropdownMenuContentProps extends FocusableProps {
26
32
  }
27
- declare const DropdownMenuContent: React.ForwardRefExoticComponent<DropdownMenuContentProps & React.RefAttributes<HTMLDivElement>>;
33
+ /**
34
+ * The actual "menu" portion containing the items shown within the dropdown.
35
+ *
36
+ * Should be used as a child of `DropdownMenu.Root`.
37
+ */
38
+ declare const DropdownMenuContent: React.ForwardRefExoticComponent<DropdownMenuContentProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
28
39
  interface DropdownMenuButtonProps extends FocusableProps<"button"> {
29
40
  }
30
- declare const DropdownMenuButton: React.ForwardRefExoticComponent<DropdownMenuButtonProps & React.RefAttributes<HTMLButtonElement | HTMLDivElement>>;
31
- interface DropdownMenuItemProps extends FocusableProps {
41
+ /**
42
+ * The button that triggers the dropdown menu to open. Should be used as a child of `DropdownMenu.Root`.
43
+ *
44
+ * Example:
45
+ * ```tsx
46
+ * <DropdownMenu.Button>Actions</DropdownMenu.Button>
47
+ * ```
48
+ *
49
+ * By default it will render a solid `Button` with a disclosure arrow. This can be
50
+ * customized by passing a `render` prop.
51
+ *
52
+ * ```tsx
53
+ * <DropdownMenu.Button
54
+ * render={<IconButton variant="ghost" label="More" icon={<Icon href={…} />} />}
55
+ * />
56
+ * ```
57
+ */
58
+ declare const DropdownMenuButton: React.ForwardRefExoticComponent<DropdownMenuButtonProps & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
59
+ interface DropdownMenuItemProps extends Omit<FocusableProps, "children">, Partial<Pick<DropdownMenuItemShortcutsProps, "shortcuts"> & Pick<DropdownMenuIconProps, "icon">> {
60
+ /** The primary text label for the menu-item. */
61
+ label: React.ReactNode;
32
62
  }
33
- declare const DropdownMenuItem: React.ForwardRefExoticComponent<DropdownMenuItemProps & React.RefAttributes<HTMLDivElement>>;
34
- export { DropdownMenu as Root, DropdownMenuButton as Button, DropdownMenuContent as Content, DropdownMenuItem as Item, };
63
+ /**
64
+ * A single menu item within the dropdown menu. Should be used as a child of `DropdownMenu.Content`.
65
+ *
66
+ * Example:
67
+ * ```tsx
68
+ * <DropdownMenu.Item label="Add" />
69
+ * <DropdownMenu.Item label="Edit" />
70
+ * ```
71
+ */
72
+ declare const DropdownMenuItem: React.ForwardRefExoticComponent<DropdownMenuItemProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
73
+ interface DropdownMenuItemShortcutsProps extends BaseProps {
74
+ /**
75
+ * A string defining the keyboard shortcut(s) associated with the menu item.
76
+ *
77
+ * ```tsx
78
+ * shortcuts="S" // A single key shortcut
79
+ * ```
80
+ *
81
+ * Multiple keys should be separated by the `+` character. If one of the keys is
82
+ * recognized as a symbol name or a modifier key, it will be displayed as a symbol.
83
+ *
84
+ * ```tsx
85
+ * shortcuts="Control+Enter" // A multi-key shortcut, displayed as "Ctrl ⏎"
86
+ * ```
87
+ */
88
+ shortcuts: AnyString | `${PredefinedSymbol}+${AnyString}`;
89
+ }
90
+ interface DropdownMenuIconProps extends BaseProps {
91
+ /**
92
+ * An optional icon displayed before the menu-item label.
93
+ *
94
+ * Can be a URL of an SVG from the `@itwin/itwinui-icons` package,
95
+ * or a custom JSX icon.
96
+ */
97
+ icon?: string | React.JSX.Element;
98
+ }
99
+ interface DropdownMenuCheckboxItemProps extends Omit<FocusableProps, "onChange" | "children">, Pick<MenuItemCheckboxProps, "checked" | "onChange" | "name" | "value">, Pick<DropdownMenuItemProps, "label" | "icon"> {
100
+ }
101
+ /**
102
+ * A single menu item within the dropdown menu. Should be used as a child of `DropdownMenu.Content`.
103
+ *
104
+ * Example:
105
+ * ```tsx
106
+ * <DropdownMenu.CheckboxItem name="add" label="Add" />
107
+ * <DropdownMenu.CheckboxItem name="edit" label="Edit" />
108
+ * ```
109
+ */
110
+ declare const DropdownMenuCheckboxItem: React.ForwardRefExoticComponent<DropdownMenuCheckboxItemProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
111
+ export { DropdownMenu as Root, DropdownMenuButton as Button, DropdownMenuContent as Content, DropdownMenuItem as Item, DropdownMenuCheckboxItem as CheckboxItem, };