@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.
Files changed (76) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/DEV/bricks/Anchor.js +20 -22
  3. package/dist/DEV/bricks/Button.js +17 -15
  4. package/dist/DEV/bricks/Checkbox.js +16 -14
  5. package/dist/DEV/bricks/Divider.js +14 -16
  6. package/dist/DEV/bricks/DropdownMenu.js +60 -44
  7. package/dist/DEV/bricks/Field.js +14 -15
  8. package/dist/DEV/bricks/Icon.js +45 -44
  9. package/dist/DEV/bricks/IconButton.js +21 -19
  10. package/dist/DEV/bricks/Kbd.js +14 -16
  11. package/dist/DEV/bricks/Label.js +2 -2
  12. package/dist/DEV/bricks/ListItem.js +16 -16
  13. package/dist/DEV/bricks/Radio.js +2 -2
  14. package/dist/DEV/bricks/Root.js +45 -43
  15. package/dist/DEV/bricks/Select.js +55 -0
  16. package/dist/DEV/bricks/Switch.js +17 -15
  17. package/dist/DEV/bricks/Tabs.js +14 -15
  18. package/dist/DEV/bricks/Text.js +20 -0
  19. package/dist/DEV/bricks/TextBox.js +52 -45
  20. package/dist/DEV/bricks/Textarea.js +22 -20
  21. package/dist/DEV/bricks/Tooltip.js +65 -57
  22. package/dist/DEV/bricks/Tree.js +70 -64
  23. package/dist/DEV/bricks/VisuallyHidden.js +6 -4
  24. package/dist/DEV/bricks/index.js +4 -0
  25. package/dist/DEV/bricks/styles.css.js +1 -1
  26. package/dist/DEV/bricks/~utils.js +3 -0
  27. package/dist/bricks/Anchor.d.ts +12 -3
  28. package/dist/bricks/Anchor.js +20 -22
  29. package/dist/bricks/Button.d.ts +27 -4
  30. package/dist/bricks/Button.js +17 -15
  31. package/dist/bricks/Checkbox.d.ts +17 -3
  32. package/dist/bricks/Checkbox.js +16 -14
  33. package/dist/bricks/Divider.d.ts +3 -4
  34. package/dist/bricks/Divider.js +14 -16
  35. package/dist/bricks/DropdownMenu.d.ts +60 -10
  36. package/dist/bricks/DropdownMenu.js +60 -44
  37. package/dist/bricks/Field.d.ts +22 -2
  38. package/dist/bricks/Field.js +14 -15
  39. package/dist/bricks/Icon.d.ts +4 -4
  40. package/dist/bricks/Icon.js +44 -43
  41. package/dist/bricks/IconButton.d.ts +4 -4
  42. package/dist/bricks/IconButton.js +21 -19
  43. package/dist/bricks/Kbd.d.ts +2 -3
  44. package/dist/bricks/Kbd.js +14 -16
  45. package/dist/bricks/Label.d.ts +22 -3
  46. package/dist/bricks/Label.js +2 -2
  47. package/dist/bricks/ListItem.d.ts +2 -3
  48. package/dist/bricks/ListItem.js +15 -15
  49. package/dist/bricks/Radio.d.ts +17 -3
  50. package/dist/bricks/Radio.js +2 -2
  51. package/dist/bricks/Root.d.ts +11 -2
  52. package/dist/bricks/Root.js +45 -43
  53. package/dist/bricks/Select.d.ts +45 -0
  54. package/dist/bricks/Select.js +55 -0
  55. package/dist/bricks/Switch.d.ts +17 -3
  56. package/dist/bricks/Switch.js +17 -15
  57. package/dist/bricks/Tabs.d.ts +65 -4
  58. package/dist/bricks/Tabs.js +14 -15
  59. package/dist/bricks/Text.d.ts +22 -0
  60. package/dist/bricks/Text.js +19 -0
  61. package/dist/bricks/TextBox.d.ts +39 -9
  62. package/dist/bricks/TextBox.js +52 -45
  63. package/dist/bricks/Textarea.d.ts +14 -4
  64. package/dist/bricks/Textarea.js +22 -20
  65. package/dist/bricks/Tooltip.d.ts +11 -4
  66. package/dist/bricks/Tooltip.js +65 -57
  67. package/dist/bricks/Tree.d.ts +5 -5
  68. package/dist/bricks/Tree.js +67 -61
  69. package/dist/bricks/VisuallyHidden.d.ts +15 -3
  70. package/dist/bricks/VisuallyHidden.js +6 -4
  71. package/dist/bricks/index.d.ts +2 -0
  72. package/dist/bricks/index.js +4 -0
  73. package/dist/bricks/styles.css.js +1 -1
  74. package/dist/bricks/~utils.d.ts +20 -0
  75. package/dist/bricks/~utils.js +3 -0
  76. package/package.json +1 -1
@@ -4,19 +4,24 @@ import { type FocusableProps } from "./~utils.js";
4
4
  interface DropdownMenuProps extends Pick<Ariakit.MenuProviderProps, "children" | "placement" | "open" | "setOpen" | "defaultOpen"> {
5
5
  }
6
6
  /**
7
- * Dropdown menu component displays a list of actions or commands.
7
+ * A dropdown menu displays a list of actions or commands when the menu button is clicked.
8
8
  *
9
+ * `DropdownMenu` is a compound component with subcomponents exposed for different parts.
10
+ *
11
+ * Example:
9
12
  * ```tsx
10
13
  * <DropdownMenu.Root>
11
- * <DropdownMenu.Button>Actions</DropdownMenu.Button>
14
+ * <DropdownMenu.Button>Actions</DropdownMenu.Button>
12
15
  *
13
- * <DropdownMenu.Content>
14
- * <DropdownMenu.Item>Add</DropdownMenu.Item>
15
- * <DropdownMenu.Item>Edit</DropdownMenu.Item>
16
- * <DropdownMenu.Item>Delete</DropdownMenu.Item>
17
- * </DropdownMenu.Content>
16
+ * <DropdownMenu.Content>
17
+ * <DropdownMenu.Item>Add</DropdownMenu.Item>
18
+ * <DropdownMenu.Item>Edit</DropdownMenu.Item>
19
+ * <DropdownMenu.Item>Delete</DropdownMenu.Item>
20
+ * </DropdownMenu.Content>
18
21
  * </DropdownMenu.Root>
19
22
  * ```
23
+ *
24
+ * **Note**: `DropdownMenu` should not be used for navigation; it is only intended for actions.
20
25
  */
21
26
  declare function DropdownMenu(props: DropdownMenuProps): import("react/jsx-runtime").JSX.Element;
22
27
  declare namespace DropdownMenu {
@@ -24,11 +29,56 @@ declare namespace DropdownMenu {
24
29
  }
25
30
  interface DropdownMenuContentProps extends FocusableProps {
26
31
  }
27
- declare const DropdownMenuContent: React.ForwardRefExoticComponent<DropdownMenuContentProps & React.RefAttributes<HTMLDivElement>>;
32
+ /**
33
+ * The actual "menu" portion containing the items shown within the dropdown.
34
+ *
35
+ * Should be used as a child of `DropdownMenu.Root`.
36
+ */
37
+ declare const DropdownMenuContent: React.ForwardRefExoticComponent<DropdownMenuContentProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
28
38
  interface DropdownMenuButtonProps extends FocusableProps<"button"> {
29
39
  }
30
- declare const DropdownMenuButton: React.ForwardRefExoticComponent<DropdownMenuButtonProps & React.RefAttributes<HTMLButtonElement | HTMLDivElement>>;
40
+ /**
41
+ * The button that triggers the dropdown menu to open. Should be used as a child of `DropdownMenu.Root`.
42
+ *
43
+ * Example:
44
+ * ```tsx
45
+ * <DropdownMenu.Button>Actions</DropdownMenu.Button>
46
+ * ```
47
+ *
48
+ * By default it will render a solid `Button` with a disclosure arrow. This can be
49
+ * customized by passing a `render` prop.
50
+ *
51
+ * ```tsx
52
+ * <DropdownMenu.Button
53
+ * render={<IconButton variant="ghost" label="More" icon={<Icon href={…} />} />}
54
+ * />
55
+ * ```
56
+ */
57
+ declare const DropdownMenuButton: React.ForwardRefExoticComponent<DropdownMenuButtonProps & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
31
58
  interface DropdownMenuItemProps extends FocusableProps {
59
+ /**
60
+ * A string defining the keyboard shortcut(s) associated with the menu item.
61
+ *
62
+ * ```tsx
63
+ * shortcuts="S" // A single key shortcut
64
+ * ```
65
+ *
66
+ * Multiple keys should be separated by the '+' character.
67
+ *
68
+ * ```tsx
69
+ * shortcuts="Ctrl+Shift+S" // A multi-key combination
70
+ * ```
71
+ */
72
+ shortcuts?: string;
32
73
  }
33
- declare const DropdownMenuItem: React.ForwardRefExoticComponent<DropdownMenuItemProps & React.RefAttributes<HTMLDivElement>>;
74
+ /**
75
+ * A single menu item within the dropdown menu. Should be used as a child of `DropdownMenu.Content`.
76
+ *
77
+ * Example:
78
+ * ```tsx
79
+ * <DropdownMenu.Item>Add</DropdownMenu.Item>
80
+ * <DropdownMenu.Item>Edit</DropdownMenu.Item>
81
+ * ```
82
+ */
83
+ declare const DropdownMenuItem: React.ForwardRefExoticComponent<DropdownMenuItemProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
34
84
  export { DropdownMenu as Root, DropdownMenuButton as Button, DropdownMenuContent as Content, DropdownMenuItem as Item, };
@@ -4,8 +4,9 @@ import cx from "classnames";
4
4
  import * as Ariakit from "@ariakit/react";
5
5
  import * as ListItem from "./ListItem.js";
6
6
  import { Button } from "./Button.js";
7
+ import { Kbd } from "./Kbd.js";
7
8
  import { DisclosureArrow } from "./Icon.js";
8
- import { supportsPopover } from "./~utils.js";
9
+ import { forwardRef, supportsPopover } from "./~utils.js";
9
10
  function DropdownMenu(props) {
10
11
  const {
11
12
  children,
@@ -15,8 +16,8 @@ function DropdownMenu(props) {
15
16
  defaultOpen: defaultOpenProp
16
17
  } = props;
17
18
  const store = Ariakit.useMenuStore();
18
- const open = Ariakit.useStoreState(store, (store2) => store2.open);
19
- const popover = Ariakit.useStoreState(store, (store2) => store2.popoverElement);
19
+ const open = Ariakit.useStoreState(store, (state) => state.open);
20
+ const popover = Ariakit.useStoreState(store, (state) => state.popoverElement);
20
21
  React.useEffect(
21
22
  function syncPopoverWithOpenState() {
22
23
  if (popover?.isConnected) {
@@ -37,47 +38,62 @@ function DropdownMenu(props) {
37
38
  }
38
39
  );
39
40
  }
40
- const DropdownMenuContent = React.forwardRef((props, forwardedRef) => {
41
- return /* @__PURE__ */ jsx(
42
- Ariakit.Menu,
43
- {
44
- portal: !supportsPopover,
45
- unmountOnHide: true,
46
- ...props,
47
- style: { zIndex: supportsPopover ? void 0 : 9999, ...props.style },
48
- wrapperProps: { popover: "manual" },
49
- className: cx("\u{1F95D}-dropdown-menu", props.className),
50
- ref: forwardedRef
51
- }
52
- );
53
- });
54
- const DropdownMenuButton = React.forwardRef((props, forwardedRef) => {
55
- const { accessibleWhenDisabled = true, children, ...rest } = props;
56
- return /* @__PURE__ */ jsx(
57
- Ariakit.MenuButton,
58
- {
59
- accessibleWhenDisabled: true,
60
- render: /* @__PURE__ */ jsxs(Button, { accessibleWhenDisabled, children: [
61
- children,
62
- /* @__PURE__ */ jsx(DisclosureArrow, {})
63
- ] }),
64
- ...rest,
65
- className: cx("\u{1F95D}-dropdown-menu-button", props.className),
66
- ref: forwardedRef
67
- }
68
- );
69
- });
70
- const DropdownMenuItem = React.forwardRef((props, forwardedRef) => {
71
- return /* @__PURE__ */ jsx(
72
- Ariakit.MenuItem,
73
- {
74
- accessibleWhenDisabled: true,
75
- ...props,
76
- render: /* @__PURE__ */ jsx(ListItem.Root, { render: props.render }),
77
- ref: forwardedRef
78
- }
79
- );
80
- });
41
+ const DropdownMenuContent = forwardRef(
42
+ (props, forwardedRef) => {
43
+ return /* @__PURE__ */ jsx(
44
+ Ariakit.Menu,
45
+ {
46
+ portal: !supportsPopover,
47
+ unmountOnHide: true,
48
+ ...props,
49
+ style: { zIndex: supportsPopover ? void 0 : 9999, ...props.style },
50
+ wrapperProps: { popover: "manual" },
51
+ className: cx("\u{1F95D}-dropdown-menu", props.className),
52
+ ref: forwardedRef
53
+ }
54
+ );
55
+ }
56
+ );
57
+ const DropdownMenuButton = forwardRef(
58
+ (props, forwardedRef) => {
59
+ const { accessibleWhenDisabled = true, children, ...rest } = props;
60
+ return /* @__PURE__ */ jsx(
61
+ Ariakit.MenuButton,
62
+ {
63
+ accessibleWhenDisabled: true,
64
+ render: /* @__PURE__ */ jsxs(Button, { accessibleWhenDisabled, children: [
65
+ children,
66
+ /* @__PURE__ */ jsx(DisclosureArrow, {})
67
+ ] }),
68
+ ...rest,
69
+ className: cx("\u{1F95D}-dropdown-menu-button", props.className),
70
+ ref: forwardedRef
71
+ }
72
+ );
73
+ }
74
+ );
75
+ const DropdownMenuItem = forwardRef(
76
+ (props, forwardedRef) => {
77
+ const { shortcuts, ...rest } = props;
78
+ const shortcutKeys = React.useMemo(() => {
79
+ return typeof shortcuts === "string" ? shortcuts.split("+").map((key) => key.trim()) : [];
80
+ }, [shortcuts]);
81
+ const hasShortcuts = shortcutKeys.length > 0;
82
+ return /* @__PURE__ */ jsxs(
83
+ Ariakit.MenuItem,
84
+ {
85
+ accessibleWhenDisabled: true,
86
+ ...rest,
87
+ render: /* @__PURE__ */ jsx(ListItem.Root, { render: props.render }),
88
+ ref: forwardedRef,
89
+ children: [
90
+ /* @__PURE__ */ jsx(ListItem.Content, { children: props.children }),
91
+ hasShortcuts && /* @__PURE__ */ jsx("span", { className: "\u{1F95D}-dropdown-menu-item-shortcuts", children: shortcutKeys.map((key, index) => /* @__PURE__ */ jsx(Kbd, { variant: "ghost", children: key }, `${key + index}`)) })
92
+ ]
93
+ }
94
+ );
95
+ }
96
+ );
81
97
  export {
82
98
  DropdownMenuButton as Button,
83
99
  DropdownMenuContent as Content,
@@ -1,11 +1,31 @@
1
1
  import * as React from "react";
2
- import type { BaseProps } from "./~utils.js";
2
+ import { type BaseProps } from "./~utils.js";
3
3
  interface FieldProps extends BaseProps {
4
4
  /**
5
5
  * Allows overriding the default block layout for text controls.
6
6
  */
7
7
  layout?: "inline";
8
8
  }
9
- export declare const Field: React.ForwardRefExoticComponent<FieldProps & React.RefAttributes<HTMLDivElement>>;
9
+ /**
10
+ * A container for form controls. It manages ID associations provides a consistent layout and spacing.
11
+ *
12
+ * Example:
13
+ * ```tsx
14
+ * <Field>
15
+ * <Label>Label</Label>
16
+ * <TextBox.Input />
17
+ * </Field>
18
+ * ```
19
+ *
20
+ * Supports a `layout` prop, which can be set to `inline` to align the label and control horizontally.
21
+ *
22
+ * Should contain a `Label` component paired with a form control. Supported form controls include:
23
+ * - `TextBox.Input`
24
+ * - `TextBox.Textarea`
25
+ * - `Checkbox`
26
+ * - `Radio`
27
+ * - `Switch`
28
+ */
29
+ export declare const Field: React.ForwardRefExoticComponent<FieldProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
10
30
  export declare function useFieldId(): string | undefined;
11
31
  export {};
@@ -2,21 +2,20 @@ import { jsx } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import * as Ariakit from "@ariakit/react";
4
4
  import cx from "classnames";
5
- const Field = React.forwardRef(
6
- (props, forwardedRef) => {
7
- const fieldId = React.useId();
8
- const { className, layout, ...rest } = props;
9
- return /* @__PURE__ */ jsx(FieldIdContext.Provider, { value: fieldId, children: /* @__PURE__ */ jsx(
10
- Ariakit.Role,
11
- {
12
- ...rest,
13
- className: cx("\u{1F95D}-field", className),
14
- "data-kiwi-layout": layout,
15
- ref: forwardedRef
16
- }
17
- ) });
18
- }
19
- );
5
+ import { forwardRef } from "./~utils.js";
6
+ const Field = forwardRef((props, forwardedRef) => {
7
+ const fieldId = React.useId();
8
+ const { className, layout, ...rest } = props;
9
+ return /* @__PURE__ */ jsx(FieldIdContext.Provider, { value: fieldId, children: /* @__PURE__ */ jsx(
10
+ Ariakit.Role,
11
+ {
12
+ ...rest,
13
+ className: cx("\u{1F95D}-field", className),
14
+ "data-kiwi-layout": layout,
15
+ ref: forwardedRef
16
+ }
17
+ ) });
18
+ });
20
19
  const FieldIdContext = React.createContext(void 0);
21
20
  function useFieldId() {
22
21
  return React.useContext(FieldIdContext);
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import type { BaseProps } from "./~utils.js";
2
+ import { type BaseProps } from "./~utils.js";
3
3
  interface IconProps extends Omit<BaseProps<"svg">, "children"> {
4
4
  /** URL of the symbol sprite. */
5
5
  href?: string;
@@ -11,7 +11,7 @@ interface IconProps extends Omit<BaseProps<"svg">, "children"> {
11
11
  * It uses an external symbol sprite to render the icon based on the specified `size`.
12
12
  *
13
13
  * ```tsx
14
- * const arrowIcon = new URL("@itwin/itwinui-icons/icons/arrow.svg", import.meta.url).href;
14
+ * const arrowIcon = new URL("@itwin/itwinui-icons/arrow.svg", import.meta.url).href;
15
15
  * <Icon href={arrowIcon} />
16
16
  * ```
17
17
  *
@@ -23,7 +23,7 @@ interface IconProps extends Omit<BaseProps<"svg">, "children"> {
23
23
  *
24
24
  * **Note**: This component is meant to be used with decorative icons, so it adds `aria-hidden` by default.
25
25
  */
26
- export declare const Icon: React.ForwardRefExoticComponent<IconProps & React.RefAttributes<SVGSVGElement>>;
26
+ export declare const Icon: React.ForwardRefExoticComponent<IconProps & React.RefAttributes<HTMLElement | SVGSVGElement>>;
27
27
  interface DisclosureArrowProps extends Omit<BaseProps<"svg">, "children"> {
28
28
  /**
29
29
  * Which direction should the arrow point towards?
@@ -31,5 +31,5 @@ interface DisclosureArrowProps extends Omit<BaseProps<"svg">, "children"> {
31
31
  */
32
32
  direction?: "down" | "right";
33
33
  }
34
- export declare const DisclosureArrow: React.ForwardRefExoticComponent<DisclosureArrowProps & React.RefAttributes<SVGSVGElement>>;
34
+ export declare const DisclosureArrow: React.ForwardRefExoticComponent<DisclosureArrowProps & React.RefAttributes<HTMLElement | SVGSVGElement>>;
35
35
  export {};
@@ -2,57 +2,58 @@ import { jsx } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import cx from "classnames";
4
4
  import * as Ariakit from "@ariakit/react";
5
- const Icon = React.forwardRef(
5
+ import { forwardRef } from "./~utils.js";
6
+ const Icon = forwardRef((props, forwardedRef) => {
7
+ const { href, size = "regular", ...rest } = props;
8
+ const iconId = toIconId(size);
9
+ return /* @__PURE__ */ jsx(
10
+ Ariakit.Role.svg,
11
+ {
12
+ "data-kiwi-size": size,
13
+ "aria-hidden": true,
14
+ ...rest,
15
+ className: cx("\u{1F95D}-icon", props.className),
16
+ ref: forwardedRef,
17
+ children: /* @__PURE__ */ jsx("use", { href: `${props.href}#${iconId}` })
18
+ }
19
+ );
20
+ });
21
+ function toIconId(size) {
22
+ if (size === "large") return "icon-large";
23
+ return "icon";
24
+ }
25
+ const DisclosureArrow = forwardRef(
6
26
  (props, forwardedRef) => {
7
- const { href, size = "regular", ...rest } = props;
8
- const iconId = toIconId(size);
27
+ const { direction = "down", ...rest } = props;
28
+ const path = React.useMemo(() => {
29
+ switch (direction) {
30
+ case "down":
31
+ return /* @__PURE__ */ jsx("path", { d: "M8 10 5 7h6l-3 3Z" });
32
+ case "right":
33
+ return /* @__PURE__ */ jsx("path", { d: "M7 11V5l3 3-3 3Z" });
34
+ }
35
+ }, [direction]);
9
36
  return /* @__PURE__ */ jsx(
10
- Ariakit.Role.svg,
37
+ Icon,
11
38
  {
12
- "data-kiwi-size": size,
13
- "aria-hidden": true,
14
39
  ...rest,
15
- className: cx("\u{1F95D}-icon", props.className),
16
- ref: forwardedRef,
17
- children: /* @__PURE__ */ jsx("use", { href: `${props.href}#${iconId}` })
40
+ render: /* @__PURE__ */ jsx(
41
+ Ariakit.Role.svg,
42
+ {
43
+ width: "16",
44
+ height: "16",
45
+ fill: "currentColor",
46
+ viewBox: "0 0 16 16",
47
+ render: props.render,
48
+ children: path
49
+ }
50
+ ),
51
+ className: cx("\u{1F95D}-disclosure-arrow", props.className),
52
+ ref: forwardedRef
18
53
  }
19
54
  );
20
55
  }
21
56
  );
22
- function toIconId(size) {
23
- if (size === "large") return "icon-large";
24
- return "icon";
25
- }
26
- const DisclosureArrow = React.forwardRef((props, forwardedRef) => {
27
- const { direction = "down", ...rest } = props;
28
- const path = React.useMemo(() => {
29
- switch (direction) {
30
- case "down":
31
- return /* @__PURE__ */ jsx("path", { d: "M8 10 5 7h6l-3 3Z" });
32
- case "right":
33
- return /* @__PURE__ */ jsx("path", { d: "M7 11V5l3 3-3 3Z" });
34
- }
35
- }, [direction]);
36
- return /* @__PURE__ */ jsx(
37
- Icon,
38
- {
39
- ...rest,
40
- render: /* @__PURE__ */ jsx(
41
- Ariakit.Role.svg,
42
- {
43
- width: "16",
44
- height: "16",
45
- fill: "currentColor",
46
- viewBox: "0 0 16 16",
47
- render: props.render,
48
- children: path
49
- }
50
- ),
51
- className: cx("\u{1F95D}-disclosure-arrow", props.className),
52
- ref: forwardedRef
53
- }
54
- );
55
- });
56
57
  export {
57
58
  DisclosureArrow,
58
59
  Icon
@@ -1,4 +1,3 @@
1
- import * as React from "react";
2
1
  import { Button } from "./Button.js";
3
2
  interface IconButtonBaseProps extends Omit<React.ComponentProps<typeof Button>, "children" | "tone"> {
4
3
  /**
@@ -32,7 +31,7 @@ interface IconButtonBaseProps extends Omit<React.ComponentProps<typeof Button>,
32
31
  * ```tsx
33
32
  * <IconButton
34
33
  * label="Reveal full content"
35
- * icon={new URL("@itwin/itwinui-icons/icons/arrow.svg", import.meta.url).href}
34
+ * icon={new URL("@itwin/itwinui-icons/arrow.svg", import.meta.url).href}
36
35
  * />
37
36
  * ```
38
37
  *
@@ -55,8 +54,9 @@ interface IconButtonBaseProps extends Omit<React.ComponentProps<typeof Button>,
55
54
  * isActive={isActive}
56
55
  * onClick={() => setIsActive(!isActive)}
57
56
  * />
57
+ * ```
58
58
  */
59
- export declare const IconButton: React.ForwardRefExoticComponent<(Omit<IconButtonBaseProps & {
59
+ export declare const IconButton: import("react").ForwardRefExoticComponent<(Omit<IconButtonBaseProps & {
60
60
  variant: "ghost";
61
61
  /**
62
62
  * Whether the button is in a toggled state and currently "active" (toggled on).
@@ -75,5 +75,5 @@ export declare const IconButton: React.ForwardRefExoticComponent<(Omit<IconButto
75
75
  }, "ref"> | Omit<IconButtonBaseProps & {
76
76
  variant?: Omit<React.ComponentProps<typeof Button>["variant"], "ghost">;
77
77
  isActive?: never;
78
- }, "ref">) & React.RefAttributes<HTMLButtonElement>>;
78
+ }, "ref">) & import("react").RefAttributes<HTMLElement | HTMLButtonElement>>;
79
79
  export {};
@@ -1,30 +1,32 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import * as React from "react";
3
2
  import cx from "classnames";
4
3
  import { Button } from "./Button.js";
5
4
  import { VisuallyHidden } from "./VisuallyHidden.js";
6
5
  import { Icon } from "./Icon.js";
7
6
  import { Tooltip } from "./Tooltip.js";
8
- const IconButton = React.forwardRef((props, forwardedRef) => {
9
- const { label, icon, isActive, labelVariant, ...rest } = props;
10
- const button = /* @__PURE__ */ jsxs(
11
- Button,
12
- {
13
- "aria-pressed": isActive,
14
- ...rest,
15
- className: cx("\u{1F95D}-icon-button", props.className),
16
- ref: forwardedRef,
17
- children: [
18
- /* @__PURE__ */ jsx(VisuallyHidden, { children: label }),
19
- typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon
20
- ]
7
+ import { forwardRef } from "./~utils.js";
8
+ const IconButton = forwardRef(
9
+ (props, forwardedRef) => {
10
+ const { label, icon, isActive, labelVariant, ...rest } = props;
11
+ const button = /* @__PURE__ */ jsxs(
12
+ Button,
13
+ {
14
+ "aria-pressed": isActive,
15
+ ...rest,
16
+ className: cx("\u{1F95D}-icon-button", props.className),
17
+ ref: forwardedRef,
18
+ children: [
19
+ /* @__PURE__ */ jsx(VisuallyHidden, { children: label }),
20
+ typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { href: icon }) : icon
21
+ ]
22
+ }
23
+ );
24
+ if (labelVariant === "visually-hidden") {
25
+ return button;
21
26
  }
22
- );
23
- if (labelVariant === "visually-hidden") {
24
- return button;
27
+ return /* @__PURE__ */ jsx(Tooltip, { content: label, type: "none", children: button });
25
28
  }
26
- return /* @__PURE__ */ jsx(Tooltip, { content: label, type: "none", children: button });
27
- });
29
+ );
28
30
  export {
29
31
  IconButton
30
32
  };
@@ -1,5 +1,4 @@
1
- import * as React from "react";
2
- import type { BaseProps } from "./~utils.js";
1
+ import { type BaseProps } from "./~utils.js";
3
2
  interface KbdProps extends BaseProps<"kbd"> {
4
3
  /** @default "solid" */
5
4
  variant?: "solid" | "muted" | "ghost";
@@ -12,5 +11,5 @@ interface KbdProps extends BaseProps<"kbd"> {
12
11
  * <Kbd>Ctrl</Kbd> <Kbd>S</Kbd>
13
12
  * ```
14
13
  */
15
- export declare const Kbd: React.ForwardRefExoticComponent<KbdProps & React.RefAttributes<HTMLElement>>;
14
+ export declare const Kbd: import("react").ForwardRefExoticComponent<KbdProps & import("react").RefAttributes<HTMLElement>>;
16
15
  export {};
@@ -1,22 +1,20 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
2
  import cx from "classnames";
4
3
  import * as Ariakit from "@ariakit/react";
5
- const Kbd = React.forwardRef(
6
- (props, forwardedRef) => {
7
- const { variant = "solid", ...rest } = props;
8
- return /* @__PURE__ */ jsx(
9
- Ariakit.Role,
10
- {
11
- "data-kiwi-variant": variant,
12
- ...rest,
13
- className: cx("\u{1F95D}-kbd", props.className),
14
- render: props.render || /* @__PURE__ */ jsx("kbd", {}),
15
- ref: forwardedRef
16
- }
17
- );
18
- }
19
- );
4
+ import { forwardRef } from "./~utils.js";
5
+ const Kbd = forwardRef((props, forwardedRef) => {
6
+ const { variant = "solid", ...rest } = props;
7
+ return /* @__PURE__ */ jsx(
8
+ Ariakit.Role,
9
+ {
10
+ "data-kiwi-variant": variant,
11
+ ...rest,
12
+ className: cx("\u{1F95D}-kbd", props.className),
13
+ render: props.render || /* @__PURE__ */ jsx("kbd", {}),
14
+ ref: forwardedRef
15
+ }
16
+ );
17
+ });
20
18
  export {
21
19
  Kbd
22
20
  };
@@ -1,6 +1,25 @@
1
- import * as React from "react";
2
- import type { BaseProps } from "./~utils.js";
1
+ import { type BaseProps } from "./~utils.js";
3
2
  interface LabelProps extends BaseProps<"label"> {
4
3
  }
5
- export declare const Label: React.ForwardRefExoticComponent<LabelProps & React.RefAttributes<HTMLLabelElement>>;
4
+ /**
5
+ * A styled wrapper over the HTML `<label>` element, used for labelling form controls.
6
+ *
7
+ * Can be used standalone:
8
+
9
+ * ```tsx
10
+ * <Label htmlFor="my-input">Label</Label>
11
+ * <TextBox.Input id="my-input" />
12
+ * ```
13
+ *
14
+ * Or within a `Field` component to automatically manage ID associations:
15
+ *
16
+ * ```tsx
17
+ * <Field>
18
+ * <Label>Label</Label>
19
+ * <TextBox.Input />
20
+ * </Field>
21
+ * ```
22
+ *
23
+ */
24
+ export declare const Label: import("react").ForwardRefExoticComponent<LabelProps & import("react").RefAttributes<HTMLElement | HTMLLabelElement>>;
6
25
  export {};
@@ -1,9 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
2
  import cx from "classnames";
4
3
  import * as Ariakit from "@ariakit/react";
5
4
  import { useFieldId } from "./Field.js";
6
- const Label = React.forwardRef((props, forwardedRef) => {
5
+ import { forwardRef } from "./~utils.js";
6
+ const Label = forwardRef((props, forwardedRef) => {
7
7
  const fieldId = useFieldId();
8
8
  return /* @__PURE__ */ jsx(
9
9
  Ariakit.Role.label,
@@ -1,11 +1,10 @@
1
- import * as React from "react";
2
1
  import * as Ariakit from "@ariakit/react";
3
2
  interface ListItemProps extends Ariakit.RoleProps<"div"> {
4
3
  }
5
4
  /** @internal */
6
- declare const ListItem: React.ForwardRefExoticComponent<Omit<ListItemProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
5
+ declare const ListItem: import("react").ForwardRefExoticComponent<Omit<ListItemProps, "ref"> & import("react").RefAttributes<HTMLElement | HTMLDivElement>>;
7
6
  interface ListItemContentProps extends Ariakit.RoleProps<"span"> {
8
7
  }
9
8
  /** @internal */
10
- declare const ListItemContent: React.ForwardRefExoticComponent<Omit<ListItemContentProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
9
+ declare const ListItemContent: import("react").ForwardRefExoticComponent<Omit<ListItemContentProps, "ref"> & import("react").RefAttributes<HTMLElement | HTMLSpanElement>>;
11
10
  export { ListItem as Root, ListItemContent as Content };