@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
@@ -1,30 +1,30 @@
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 ListItem = React.forwardRef(
4
+ import { forwardRef } from "./~utils.js";
5
+ const ListItem = forwardRef((props, forwardedRef) => {
6
+ return /* @__PURE__ */ jsx(
7
+ Ariakit.Role.div,
8
+ {
9
+ role: "listitem",
10
+ ...props,
11
+ className: cx("\u{1F95D}-list-item", props.className),
12
+ ref: forwardedRef
13
+ }
14
+ );
15
+ });
16
+ const ListItemContent = forwardRef(
6
17
  (props, forwardedRef) => {
7
18
  return /* @__PURE__ */ jsx(
8
- Ariakit.Role.div,
19
+ Ariakit.Role.span,
9
20
  {
10
- role: "listitem",
11
21
  ...props,
12
- className: cx("\u{1F95D}-list-item", props.className),
22
+ className: cx("\u{1F95D}-list-item-content", props.className),
13
23
  ref: forwardedRef
14
24
  }
15
25
  );
16
26
  }
17
27
  );
18
- const ListItemContent = React.forwardRef((props, forwardedRef) => {
19
- return /* @__PURE__ */ jsx(
20
- Ariakit.Role.span,
21
- {
22
- ...props,
23
- className: cx("\u{1F95D}-list-item-content", props.className),
24
- ref: forwardedRef
25
- }
26
- );
27
- });
28
28
  export {
29
29
  ListItemContent as Content,
30
30
  ListItem as Root
@@ -1,9 +1,23 @@
1
- import * as React from "react";
2
1
  import * as Ariakit from "@ariakit/react";
3
- import type { FocusableProps } from "./~utils.js";
2
+ import { type FocusableProps } from "./~utils.js";
4
3
  type InputBaseProps = Omit<FocusableProps<"input">, "defaultValue" | "value">;
5
4
  type RadioOwnProps = Pick<Ariakit.RadioProps, "value" | "checked" | "onChange">;
6
5
  interface RadioProps extends InputBaseProps, RadioOwnProps {
7
6
  }
8
- export declare const Radio: React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLInputElement>>;
7
+ /**
8
+ * A styled radio input element, typically used for selecting a single option from a list.
9
+ *
10
+ * Works well with the `Field` and `Label` components.
11
+ *
12
+ * ```tsx
13
+ * <Field>
14
+ * <Label>Choose one</Label>
15
+ * <Radio />
16
+ * </Field>
17
+ * ```
18
+ *
19
+ * Underneath, it's an HTML radio input, i.e. `<input type="radio">`, so it supports the same props,
20
+ * including `value`, `defaultChecked`, `checked`, and `onChange`.
21
+ */
22
+ export declare const Radio: import("react").ForwardRefExoticComponent<RadioProps & import("react").RefAttributes<HTMLElement | HTMLInputElement>>;
9
23
  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 Radio = React.forwardRef((props, forwardedRef) => {
5
+ import { forwardRef } from "./~utils.js";
6
+ const Radio = forwardRef((props, forwardedRef) => {
7
7
  const fieldId = useFieldId();
8
8
  return /* @__PURE__ */ jsx(
9
9
  Ariakit.Radio,
@@ -19,8 +19,17 @@ interface RootProps extends BaseProps {
19
19
  density: "dense";
20
20
  }
21
21
  /**
22
- * Component to be used at the root of your application. It ensures that kiwi styles are loaded
22
+ * Component to be used at the root of your application. It ensures that kiwi styles and fonts are loaded
23
23
  * and automatically applied to the current page or the encompassing shadow-root.
24
+ *
25
+ * Make sure to specify the `colorScheme` and `density` props.
26
+ *
27
+ * Example:
28
+ * ```tsx
29
+ * <Root colorScheme="dark" density="dense">
30
+ * <App />
31
+ * </Root>
32
+ * ```
24
33
  */
25
- export declare const Root: React.ForwardRefExoticComponent<RootProps & React.RefAttributes<HTMLDivElement>>;
34
+ export declare const Root: React.ForwardRefExoticComponent<RootProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
26
35
  export {};
@@ -4,47 +4,45 @@ import * as Ariakit from "@ariakit/react";
4
4
  import cx from "classnames";
5
5
  import foundationsCss from "../foundations/styles.css.js";
6
6
  import bricksCss from "./styles.css.js";
7
- import { isBrowser } from "./~utils.js";
7
+ import { forwardRef, isBrowser } from "./~utils.js";
8
8
  import { useMergedRefs } from "./~hooks.js";
9
9
  const css = foundationsCss + bricksCss;
10
- const Root = React.forwardRef(
11
- (props, forwardedRef) => {
12
- const { children, synchronizeColorScheme = false, ...rest } = props;
13
- return /* @__PURE__ */ jsxs(RootInternal, { ...rest, ref: forwardedRef, children: [
14
- /* @__PURE__ */ jsx(Styles, {}),
15
- /* @__PURE__ */ jsx(Fonts, {}),
16
- synchronizeColorScheme ? /* @__PURE__ */ jsx(SynchronizeColorScheme, { colorScheme: props.colorScheme }) : null,
17
- children
18
- ] });
19
- }
20
- );
10
+ const Root = forwardRef((props, forwardedRef) => {
11
+ const { children, synchronizeColorScheme = false, ...rest } = props;
12
+ return /* @__PURE__ */ jsxs(RootInternal, { ...rest, ref: forwardedRef, children: [
13
+ /* @__PURE__ */ jsx(Styles, {}),
14
+ /* @__PURE__ */ jsx(Fonts, {}),
15
+ synchronizeColorScheme ? /* @__PURE__ */ jsx(SynchronizeColorScheme, { colorScheme: props.colorScheme }) : null,
16
+ children
17
+ ] });
18
+ });
21
19
  const RootNodeContext = React.createContext(null);
22
20
  function useRootNode() {
23
21
  return React.useContext(RootNodeContext);
24
22
  }
25
- const RootInternal = React.forwardRef((props, forwardedRef) => {
26
- const { children, colorScheme, density, ...rest } = props;
27
- const [rootNode, setRootNode] = React.useState(
28
- null
29
- );
30
- const findRootNodeFromRef = React.useCallback((element) => {
31
- if (!element) return;
32
- const rootNode2 = element.getRootNode();
33
- if (!isDocument(rootNode2) && !isShadow(rootNode2)) return;
34
- setRootNode(rootNode2);
35
- }, []);
36
- return /* @__PURE__ */ jsx(
37
- Ariakit.Role,
38
- {
39
- ...rest,
40
- className: cx("\u{1F95D}-root", props.className),
41
- "data-kiwi-theme": colorScheme,
42
- "data-kiwi-density": density,
43
- ref: useMergedRefs(forwardedRef, findRootNodeFromRef),
44
- children: /* @__PURE__ */ jsx(RootNodeContext.Provider, { value: rootNode, children })
45
- }
46
- );
47
- });
23
+ const RootInternal = forwardRef(
24
+ (props, forwardedRef) => {
25
+ const { children, colorScheme, density, ...rest } = props;
26
+ const [rootNode, setRootNode] = React.useState(null);
27
+ const findRootNodeFromRef = React.useCallback((element) => {
28
+ if (!element) return;
29
+ const rootNode2 = element.getRootNode();
30
+ if (!isDocument(rootNode2) && !isShadow(rootNode2)) return;
31
+ setRootNode(rootNode2);
32
+ }, []);
33
+ return /* @__PURE__ */ jsx(
34
+ Ariakit.Role,
35
+ {
36
+ ...rest,
37
+ className: cx("\u{1F95D}-root", props.className),
38
+ "data-kiwi-theme": colorScheme,
39
+ "data-kiwi-density": density,
40
+ ref: useMergedRefs(forwardedRef, findRootNodeFromRef),
41
+ children: /* @__PURE__ */ jsx(RootNodeContext.Provider, { value: rootNode, children })
42
+ }
43
+ );
44
+ }
45
+ );
48
46
  function SynchronizeColorScheme({
49
47
  colorScheme
50
48
  }) {
@@ -104,8 +102,8 @@ function Fonts() {
104
102
  return null;
105
103
  }
106
104
  function loadFonts(rootNode) {
107
- const ownerDocument = getOwnerDocument(rootNode);
108
- if (!ownerDocument || Array.from(ownerDocument.fonts).some(
105
+ const ownerWindow = getWindow(rootNode);
106
+ if (!ownerWindow || Array.from(ownerWindow.document.fonts).some(
109
107
  (font) => font.family === "InterVariable"
110
108
  )) {
111
109
  return;
@@ -115,12 +113,16 @@ function loadFonts(rootNode) {
115
113
  italic: "https://rsms.me/inter/font-files/InterVariable-Italic.woff2?v=4.1"
116
114
  };
117
115
  for (const [style, url] of Object.entries(interStyles)) {
118
- const font = new FontFace("InterVariable", `url(${url}) format("woff2")`, {
119
- display: "swap",
120
- weight: "100 900",
121
- style
122
- });
123
- ownerDocument.fonts.add(font);
116
+ const font = new ownerWindow.FontFace(
117
+ "InterVariable",
118
+ `url(${url}) format("woff2")`,
119
+ {
120
+ display: "swap",
121
+ weight: "100 900",
122
+ style
123
+ }
124
+ );
125
+ ownerWindow.document.fonts.add(font);
124
126
  }
125
127
  }
126
128
  const supportsAdoptedStylesheets = isBrowser && "adoptedStyleSheets" in Document.prototype;
@@ -0,0 +1,45 @@
1
+ import * as React from "react";
2
+ import * as Ariakit from "@ariakit/react";
3
+ import { type FocusableProps } from "./~utils.js";
4
+ /**
5
+ * Compound component for a select element, which allows the user to select a value from a list of options.
6
+ *
7
+ * Works well with the `Field` and `Label` components.
8
+ *
9
+ * Example usage:
10
+ * ```tsx
11
+ * <Field>
12
+ * <Label>Select an option</Label>
13
+ * <Select.Root>
14
+ * <Select.HtmlSelect>
15
+ * <option value="1">Option 1</option>
16
+ * <option value="2">Option 2</option>
17
+ * <option value="3">Option 3</option>
18
+ * </Select.HtmlSelect>
19
+ * </Select.Root>
20
+ * </Field>
21
+ * ```
22
+ */
23
+ declare const SelectRoot: React.ForwardRefExoticComponent<Pick<Ariakit.RoleProps, "render"> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "render"> & React.RefAttributes<HTMLElement | HTMLDivElement>>;
24
+ interface HtmlSelectProps extends Omit<FocusableProps<"select">, "multiple" | "size"> {
25
+ }
26
+ /**
27
+ * The actual select element to be used inside `Select.Root`. This is a wrapper around the
28
+ * HTML `<select>` element and should render HTML `<option>` elements as children.
29
+ *
30
+ * Example usage:
31
+ * ```tsx
32
+ * <Select.HtmlSelect>
33
+ * <option value="1">Option 1</option>
34
+ * <option value="2">Option 2</option>
35
+ * <option value="3">Option 3</option>
36
+ * </Select.HtmlSelect>
37
+ * ```
38
+ *
39
+ * The usage of this component largely mirrors how the `<select>` element would be used in React.
40
+ * You can use the same familiar props, including `name`, `defaultValue`, `value`, `onChange`, etc.
41
+ *
42
+ * @see https://react.dev/reference/react-dom/components/select
43
+ */
44
+ declare const HtmlSelect: React.ForwardRefExoticComponent<HtmlSelectProps & React.RefAttributes<HTMLElement | HTMLSelectElement>>;
45
+ export { SelectRoot as Root, HtmlSelect };
@@ -0,0 +1,55 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import cx from "classnames";
4
+ import * as Ariakit from "@ariakit/react";
5
+ import {
6
+ forwardRef,
7
+ isBrowser
8
+ } from "./~utils.js";
9
+ import { DisclosureArrow } from "./Icon.js";
10
+ import { useFieldId } from "./Field.js";
11
+ const supportsHas = isBrowser && CSS?.supports?.("selector(:has(+ *))");
12
+ const HtmlSelectContext = React.createContext(() => {
13
+ });
14
+ const SelectRoot = forwardRef((props, forwardedRef) => {
15
+ const [isHtmlSelect, setIsHtmlSelect] = React.useState(false);
16
+ return /* @__PURE__ */ jsx(HtmlSelectContext.Provider, { value: setIsHtmlSelect, children: /* @__PURE__ */ jsx(
17
+ Ariakit.Role.div,
18
+ {
19
+ ...props,
20
+ className: cx("\u{1F95D}-select-root", props.className),
21
+ "data-kiwi-has-select": !supportsHas && isHtmlSelect ? "true" : void 0,
22
+ ref: forwardedRef
23
+ }
24
+ ) });
25
+ });
26
+ const HtmlSelect = forwardRef(
27
+ (props, forwardedRef) => {
28
+ const setIsHtmlSelect = React.useContext(HtmlSelectContext);
29
+ const fieldId = useFieldId();
30
+ React.useEffect(
31
+ function updateContext() {
32
+ setIsHtmlSelect(true);
33
+ },
34
+ [setIsHtmlSelect]
35
+ );
36
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
37
+ /* @__PURE__ */ jsx(
38
+ Ariakit.Role.select,
39
+ {
40
+ id: fieldId,
41
+ ...props,
42
+ className: cx("\u{1F95D}-button", "\u{1F95D}-select", props.className),
43
+ "data-kiwi-tone": "neutral",
44
+ "data-kiwi-variant": "solid",
45
+ ref: forwardedRef
46
+ }
47
+ ),
48
+ /* @__PURE__ */ jsx(DisclosureArrow, { className: "\u{1F95D}-select-arrow" })
49
+ ] });
50
+ }
51
+ );
52
+ export {
53
+ HtmlSelect,
54
+ SelectRoot as Root
55
+ };
@@ -1,6 +1,5 @@
1
- import * as React from "react";
2
1
  import * as Ariakit from "@ariakit/react";
3
- import type { FocusableProps } from "./~utils.js";
2
+ import { type FocusableProps } from "./~utils.js";
4
3
  type InputBaseProps = Omit<FocusableProps<"input">, "defaultValue" | "value">;
5
4
  type CheckboxOwnProps = Pick<Ariakit.CheckboxProps, "value" | "defaultChecked" | "checked" | "onChange">;
6
5
  interface SwitchProps extends InputBaseProps, CheckboxOwnProps {
@@ -9,5 +8,20 @@ interface SwitchProps extends InputBaseProps, CheckboxOwnProps {
9
8
  /** The controlled checked state of the toggle switch. */
10
9
  checked?: boolean;
11
10
  }
12
- export declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLInputElement>>;
11
+ /**
12
+ * A toggle switch element, typically used for enabling or disabling a feature.
13
+ *
14
+ * Works well with the `Field` and `Label` components.
15
+ *
16
+ * ```tsx
17
+ * <Field>
18
+ * <Label>Enable feature</Label>
19
+ * <Switch />
20
+ * </Field>
21
+ * ```
22
+ *
23
+ * Underneath, it's an HTML checkbox, i.e. `<input type="checkbox">`, so it supports the same props,
24
+ * including `value`, `defaultChecked`, `checked`, and `onChange`.
25
+ */
26
+ export declare const Switch: import("react").ForwardRefExoticComponent<SwitchProps & import("react").RefAttributes<HTMLElement | HTMLInputElement>>;
13
27
  export {};
@@ -1,22 +1,24 @@
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 Switch = 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}-switch", props.className),
15
- role: "switch",
16
- ref: forwardedRef
17
- }
18
- );
19
- });
5
+ import { forwardRef } from "./~utils.js";
6
+ const Switch = forwardRef(
7
+ (props, forwardedRef) => {
8
+ const fieldId = useFieldId();
9
+ return /* @__PURE__ */ jsx(
10
+ Ariakit.Checkbox,
11
+ {
12
+ accessibleWhenDisabled: true,
13
+ id: fieldId,
14
+ ...props,
15
+ className: cx("\u{1F95D}-switch", props.className),
16
+ role: "switch",
17
+ ref: forwardedRef
18
+ }
19
+ );
20
+ }
21
+ );
20
22
  export {
21
23
  Switch
22
24
  };
@@ -1,8 +1,36 @@
1
1
  import * as React from "react";
2
2
  import * as Ariakit from "@ariakit/react";
3
- import type { FocusableProps, BaseProps } from "./~utils.js";
3
+ import { type FocusableProps, type BaseProps } from "./~utils.js";
4
4
  interface TabsProps extends Pick<Ariakit.TabProviderProps, "defaultSelectedId" | "selectedId" | "setSelectedId" | "selectOnMove" | "children"> {
5
5
  }
6
+ /**
7
+ * A set of tabs that can be used to switch between different views.
8
+ *
9
+ * `Tabs` is a compound component with subcomponents exposed for different parts.
10
+ *
11
+ * Example:
12
+ * ```tsx
13
+ * <Tabs.Root>
14
+ * <Tabs.TabList>
15
+ * <Tabs.Tab id="tab-1">Tab 1</Tabs.Tab>
16
+ * <Tabs.Tab id="tab-2">Tab 2</Tabs.Tab>
17
+ * <Tabs.Tab id="tab-3">Tab 3</Tabs.Tab>
18
+ * </Tabs.TabList>
19
+ *
20
+ * <Tabs.TabPanel tabId="tab-1">Tab 1 content</Tabs.TabPanel>
21
+ * <Tabs.TabPanel tabId="tab-2">Tab 2 content</Tabs.TabPanel>
22
+ * <Tabs.TabPanel tabId="tab-3">Tab 3 content</Tabs.TabPanel>
23
+ * </Tabs.Root>
24
+ * ```
25
+ *
26
+ * The tabs and their panels are connected by matching the `id` prop on the `Tabs.Tab` component with
27
+ * the `tabId` prop on the `Tabs.TabPanel` component.
28
+ *
29
+ * The `Tabs` component automatically manages the selected tab state. The initially selected tab can be set using `defaultSelectedId`.
30
+ * To take full control the selected tab state, use the `selectedId` and `setSelectedId` props together.
31
+ *
32
+ * **Note**: `Tabs` should _not_ be used for navigation; it is only intended for switching smaller views within an existing page.
33
+ */
6
34
  declare function Tabs(props: TabsProps): import("react/jsx-runtime").JSX.Element;
7
35
  declare namespace Tabs {
8
36
  var displayName: string;
@@ -11,11 +39,44 @@ interface TabListProps extends BaseProps {
11
39
  /** @default "neutral" */
12
40
  tone?: "neutral" | "accent";
13
41
  }
14
- declare const TabList: React.ForwardRefExoticComponent<TabListProps & React.RefAttributes<HTMLDivElement>>;
42
+ /**
43
+ * A simple container for the tab buttons.
44
+ * Should be used as a child of `Tabs.Root` and consist of the individual `Tabs.Tab` components.
45
+ *
46
+ * Example:
47
+ * ```tsx
48
+ * <Tabs.TabList>
49
+ * <Tabs.Tab id="tab-1">Tab 1</Tabs.Tab>
50
+ * <Tabs.Tab id="tab-2">Tab 2</Tabs.Tab>
51
+ * <Tabs.Tab id="tab-3">Tab 3</Tabs.Tab>
52
+ * </Tabs.TabList>
53
+ * ```
54
+ */
55
+ declare const TabList: React.ForwardRefExoticComponent<TabListProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
15
56
  interface TabProps extends FocusableProps<"button">, Pick<Ariakit.TabProps, "id"> {
16
57
  }
17
- declare const Tab: React.ForwardRefExoticComponent<TabProps & React.RefAttributes<HTMLButtonElement>>;
58
+ /**
59
+ * An individual tab button that switches the selected tab panel when clicked.
60
+ *
61
+ * Should be used as a child of `Tabs.TabList` and be paired with a `Tabs.TabPanel`,
62
+ * connected using an id.
63
+ *
64
+ * Example:
65
+ * ```tsx
66
+ * <Tabs.Tab id="tab-1">Tab 1</Tabs.Tab>
67
+ * ```
68
+ */
69
+ declare const Tab: React.ForwardRefExoticComponent<TabProps & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
18
70
  interface TabPanelProps extends BaseProps<"div">, Pick<Ariakit.TabPanelProps, "tabId" | "unmountOnHide"> {
19
71
  }
20
- declare const TabPanel: React.ForwardRefExoticComponent<TabPanelProps & React.RefAttributes<HTMLDivElement>>;
72
+ /**
73
+ * The actual content of a tab, shown when the tab is selected. Should be used as a child of `Tabs.Root`.
74
+ * The `tabId` prop should match the `id` prop of the corresponding `Tabs.Tab` component.
75
+ *
76
+ * Example:
77
+ * ```tsx
78
+ * <Tabs.TabPanel tabId="tab-1">Tab 1 content</Tabs.TabPanel>
79
+ * ```
80
+ */
81
+ declare const TabPanel: React.ForwardRefExoticComponent<TabPanelProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
21
82
  export { Tabs as Root, TabList, Tab, TabPanel };
@@ -4,6 +4,7 @@ import * as ReactDOM from "react-dom";
4
4
  import cx from "classnames";
5
5
  import * as Ariakit from "@ariakit/react";
6
6
  import { useControlledState } from "./~hooks.js";
7
+ import { forwardRef } from "./~utils.js";
7
8
  function Tabs(props) {
8
9
  const {
9
10
  defaultSelectedId,
@@ -40,7 +41,7 @@ function Tabs(props) {
40
41
  }
41
42
  );
42
43
  }
43
- const TabList = React.forwardRef((props, forwardedRef) => {
44
+ const TabList = forwardRef((props, forwardedRef) => {
44
45
  const { tone = "neutral", ...rest } = props;
45
46
  const viewTransitionName = `\u{1F95D}active-stripe-${React.useId().replaceAll(":", "_")}`;
46
47
  return /* @__PURE__ */ jsx(
@@ -57,20 +58,18 @@ const TabList = React.forwardRef((props, forwardedRef) => {
57
58
  }
58
59
  );
59
60
  });
60
- const Tab = React.forwardRef(
61
- (props, forwardedRef) => {
62
- return /* @__PURE__ */ jsx(
63
- Ariakit.Tab,
64
- {
65
- accessibleWhenDisabled: true,
66
- ...props,
67
- className: cx("\u{1F95D}-tab", props.className),
68
- ref: forwardedRef
69
- }
70
- );
71
- }
72
- );
73
- const TabPanel = React.forwardRef((props, forwardedRef) => {
61
+ const Tab = forwardRef((props, forwardedRef) => {
62
+ return /* @__PURE__ */ jsx(
63
+ Ariakit.Tab,
64
+ {
65
+ accessibleWhenDisabled: true,
66
+ ...props,
67
+ className: cx("\u{1F95D}-tab", props.className),
68
+ ref: forwardedRef
69
+ }
70
+ );
71
+ });
72
+ const TabPanel = forwardRef((props, forwardedRef) => {
74
73
  return /* @__PURE__ */ jsx(
75
74
  Ariakit.TabPanel,
76
75
  {
@@ -0,0 +1,22 @@
1
+ import { type BaseProps } from "./~utils.js";
2
+ interface TextProps extends BaseProps {
3
+ /**
4
+ * The typography variant to use.
5
+ */
6
+ variant?: "display-lg" | "display-md" | "display-sm" | "headline-lg" | "headline-md" | "headline-sm" | "body-lg" | "body-md" | "body-sm" | "caption-lg" | "caption-md" | "caption-sm" | "mono-sm";
7
+ }
8
+ /**
9
+ * An element with text styles applied. Useful for paragraphs, headings, and other text content.
10
+ *
11
+ * Example usage:
12
+ * ```tsx
13
+ * <Text variant="display-sm">Hello, World!</Text>
14
+ * ```
15
+ *
16
+ * Use the `render` prop to change the underlying element (defaults to a `<div>`):
17
+ * ```tsx
18
+ * <Text render={<h1 />} variant="headline-lg">Hello, World!</Text>
19
+ * ```
20
+ */
21
+ export declare const Text: import("react").ForwardRefExoticComponent<TextProps & import("react").RefAttributes<HTMLElement | HTMLDivElement>>;
22
+ export {};
@@ -0,0 +1,19 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import * as Ariakit from "@ariakit/react";
3
+ import cx from "classnames";
4
+ import { forwardRef } from "./~utils.js";
5
+ const Text = forwardRef((props, forwardedRef) => {
6
+ const { variant, ...rest } = props;
7
+ return /* @__PURE__ */ jsx(
8
+ Ariakit.Role,
9
+ {
10
+ ...rest,
11
+ className: cx("\u{1F95D}-text", props.className),
12
+ "data-kiwi-text-variant": variant,
13
+ ref: forwardedRef
14
+ }
15
+ );
16
+ });
17
+ export {
18
+ Text
19
+ };
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { Icon } from "./Icon.js";
3
3
  import { Textarea } from "./Textarea.js";
4
- import type { FocusableProps, BaseProps } from "./~utils.js";
4
+ import { type FocusableProps, type BaseProps } from "./~utils.js";
5
5
  interface BaseInputProps extends FocusableProps<"input"> {
6
6
  }
7
7
  interface TextBoxInputProps extends Omit<BaseInputProps, "children" | "type"> {
@@ -16,7 +16,7 @@ interface TextBoxInputProps extends Omit<BaseInputProps, "children" | "type"> {
16
16
  type?: Extract<BaseInputProps["type"], "text" | "email" | "password" | "search" | "tel" | "url" | "number" | "date">;
17
17
  }
18
18
  /**
19
- * Input component that allows users to enter text based values.
19
+ * An input component that allows users to enter text based values.
20
20
  *
21
21
  * Example usage:
22
22
  * ```tsx
@@ -24,26 +24,56 @@ interface TextBoxInputProps extends Omit<BaseInputProps, "children" | "type"> {
24
24
  * ```
25
25
  *
26
26
  * To add additional decorations, see `TextBox.Root` component.
27
+ *
28
+ * Works well with the `Field` and `Label` components.
29
+ * ```tsx
30
+ * <Field>
31
+ * <Label>Enter your name</Label>
32
+ * <TextBox.Input />
33
+ * </Field>
34
+ * ```
35
+ *
36
+ * Underneath, it's an HTML input, i.e. `<input>`, so it supports the same props, including
37
+ * `value`, `defaultValue`, `onChange`, and `disabled`.
38
+ *
39
+ * For a multiline text input, use the `TextBox.Textarea` component.
27
40
  */
28
- declare const TextBoxInput: React.ForwardRefExoticComponent<TextBoxInputProps & React.RefAttributes<HTMLInputElement>>;
41
+ declare const TextBoxInput: React.ForwardRefExoticComponent<TextBoxInputProps & React.RefAttributes<HTMLElement | HTMLInputElement>>;
29
42
  interface TextBoxRootProps extends BaseProps {
30
43
  }
31
44
  /**
32
- * Root component allows adding additional decorations to text based inputs.
45
+ * Compound component for a text input. Allows adding additional decorations.
33
46
  *
34
47
  * Example usage to add an end icon:
35
48
  * ```tsx
36
49
  * <TextBox.Root>
37
- * <TextBox.Input defaultValue="Hello" />
38
- * <TextBox.Icon href={...} />
50
+ * <TextBox.Input defaultValue="Hello" />
51
+ * <TextBox.Icon href={...} />
39
52
  * </TextBox.Root>
40
53
  * ```
54
+ *
55
+ * Works well with the `Field` and `Label` components.
56
+ * ```tsx
57
+ * <Field>
58
+ * <Label>Enter your name</Label>
59
+ * <TextBox.Root>
60
+ * <TextBox.Input />
61
+ * <TextBox.Icon href={…} />
62
+ * </TextBox.Root>
63
+ * </Field>
64
+ * ```
41
65
  */
42
- declare const TextBoxRoot: React.ForwardRefExoticComponent<TextBoxRootProps & React.RefAttributes<HTMLDivElement>>;
66
+ declare const TextBoxRoot: React.ForwardRefExoticComponent<TextBoxRootProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
43
67
  interface TextBoxIconProps extends React.ComponentProps<typeof Icon> {
44
68
  }
45
- declare const TextBoxIcon: React.ForwardRefExoticComponent<Omit<TextBoxIconProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
69
+ /**
70
+ * A static icon decoration for the `TextBox.Root` component. Can be added before or after the `TextBox.Input`.
71
+ */
72
+ declare const TextBoxIcon: React.ForwardRefExoticComponent<Omit<TextBoxIconProps, "ref"> & React.RefAttributes<HTMLElement | SVGSVGElement>>;
46
73
  interface TextBoxTextProps extends BaseProps<"span"> {
47
74
  }
48
- declare const TextBoxText: React.ForwardRefExoticComponent<TextBoxTextProps & React.RefAttributes<HTMLSpanElement>>;
75
+ /**
76
+ * A static text decoration for the `TextBox.Root` component. Can be added before or after the `TextBox.Input`.
77
+ */
78
+ declare const TextBoxText: React.ForwardRefExoticComponent<TextBoxTextProps & React.RefAttributes<HTMLElement | HTMLSpanElement>>;
49
79
  export { TextBoxRoot as Root, TextBoxInput as Input, Textarea, TextBoxIcon as Icon, TextBoxText as Text, };