@itwin/itwinui-react 5.0.0-alpha.0 → 5.0.0-alpha.2
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 +24 -0
- package/dist/DEV/bricks/Anchor.js +20 -22
- package/dist/DEV/bricks/Button.js +17 -15
- package/dist/DEV/bricks/Checkbox.js +19 -15
- package/dist/DEV/bricks/Chip.js +21 -0
- package/dist/DEV/bricks/Description.js +27 -0
- package/dist/DEV/bricks/Divider.js +14 -16
- package/dist/DEV/bricks/DropdownMenu.js +60 -44
- package/dist/DEV/bricks/Field.js +66 -16
- package/dist/DEV/bricks/Icon.js +45 -44
- package/dist/DEV/bricks/IconButton.js +24 -19
- package/dist/DEV/bricks/Kbd.js +46 -16
- package/dist/DEV/bricks/Label.js +2 -2
- package/dist/DEV/bricks/ListItem.js +16 -16
- package/dist/DEV/bricks/Radio.js +5 -3
- package/dist/DEV/bricks/Root.js +45 -43
- package/dist/DEV/bricks/Select.js +57 -0
- package/dist/DEV/bricks/Spinner.js +40 -0
- package/dist/DEV/bricks/Switch.js +20 -16
- package/dist/DEV/bricks/Tabs.js +15 -16
- package/dist/DEV/bricks/Text.js +20 -0
- package/dist/DEV/bricks/TextBox.js +55 -46
- package/dist/DEV/bricks/Textarea.js +25 -21
- package/dist/DEV/bricks/Tooltip.js +65 -57
- package/dist/DEV/bricks/Tree.js +133 -66
- package/dist/DEV/bricks/VisuallyHidden.js +6 -4
- package/dist/DEV/bricks/index.js +12 -0
- package/dist/DEV/bricks/styles.css.js +1 -1
- package/dist/DEV/bricks/~hooks.js +13 -0
- package/dist/DEV/bricks/~utils.js +3 -0
- package/dist/DEV/foundations/styles.css.js +1 -1
- 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 +19 -15
- package/dist/bricks/Chip.d.ts +22 -0
- package/dist/bricks/Chip.js +20 -0
- package/dist/bricks/Description.d.ts +20 -0
- package/dist/bricks/Description.js +27 -0
- 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 +30 -2
- package/dist/bricks/Field.js +66 -16
- 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 +24 -19
- package/dist/bricks/Kbd.d.ts +32 -3
- package/dist/bricks/Kbd.js +39 -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 +5 -3
- 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 +57 -0
- package/dist/bricks/Spinner.d.ts +31 -0
- package/dist/bricks/Spinner.js +39 -0
- package/dist/bricks/Switch.d.ts +17 -3
- package/dist/bricks/Switch.js +20 -16
- package/dist/bricks/Tabs.d.ts +66 -5
- package/dist/bricks/Tabs.js +15 -16
- 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 +55 -46
- package/dist/bricks/Textarea.d.ts +14 -4
- package/dist/bricks/Textarea.js +25 -21
- package/dist/bricks/Tooltip.d.ts +11 -4
- package/dist/bricks/Tooltip.js +65 -57
- package/dist/bricks/Tree.d.ts +79 -16
- package/dist/bricks/Tree.js +128 -62
- package/dist/bricks/VisuallyHidden.d.ts +15 -3
- package/dist/bricks/VisuallyHidden.js +6 -4
- package/dist/bricks/index.d.ts +6 -0
- package/dist/bricks/index.js +12 -0
- package/dist/bricks/styles.css.js +1 -1
- package/dist/bricks/~hooks.d.ts +15 -0
- package/dist/bricks/~hooks.js +13 -0
- package/dist/bricks/~utils.d.ts +20 -0
- package/dist/bricks/~utils.js +3 -0
- package/dist/foundations/styles.css.js +1 -1
- package/package.json +2 -2
package/dist/bricks/ListItem.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
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
|
package/dist/bricks/Radio.d.ts
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import * as Ariakit from "@ariakit/react";
|
|
3
|
-
import type
|
|
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
|
-
|
|
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 {};
|
package/dist/bricks/Radio.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
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
|
-
import { useFieldId } from "./Field.js";
|
|
6
|
-
|
|
4
|
+
import { useFieldDescribedBy, useFieldId } from "./Field.js";
|
|
5
|
+
import { forwardRef } from "./~utils.js";
|
|
6
|
+
const Radio = forwardRef((props, forwardedRef) => {
|
|
7
7
|
const fieldId = useFieldId();
|
|
8
|
+
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
8
9
|
return /* @__PURE__ */ jsx(
|
|
9
10
|
Ariakit.Radio,
|
|
10
11
|
{
|
|
@@ -12,6 +13,7 @@ const Radio = React.forwardRef((props, forwardedRef) => {
|
|
|
12
13
|
id: fieldId,
|
|
13
14
|
...props,
|
|
14
15
|
className: cx("\u{1F95D}-checkbox", "\u{1F95D}-radio", props.className),
|
|
16
|
+
"aria-describedby": describedBy,
|
|
15
17
|
ref: forwardedRef
|
|
16
18
|
}
|
|
17
19
|
);
|
package/dist/bricks/Root.d.ts
CHANGED
|
@@ -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 {};
|
package/dist/bricks/Root.js
CHANGED
|
@@ -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 =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
null
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
|
108
|
-
if (!
|
|
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(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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,57 @@
|
|
|
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 { useFieldDescribedBy, 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
|
+
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
31
|
+
React.useEffect(
|
|
32
|
+
function updateContext() {
|
|
33
|
+
setIsHtmlSelect(true);
|
|
34
|
+
},
|
|
35
|
+
[setIsHtmlSelect]
|
|
36
|
+
);
|
|
37
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
38
|
+
/* @__PURE__ */ jsx(
|
|
39
|
+
Ariakit.Role.select,
|
|
40
|
+
{
|
|
41
|
+
id: fieldId,
|
|
42
|
+
...props,
|
|
43
|
+
className: cx("\u{1F95D}-button", "\u{1F95D}-select", props.className),
|
|
44
|
+
"aria-describedby": describedBy,
|
|
45
|
+
"data-kiwi-tone": "neutral",
|
|
46
|
+
"data-kiwi-variant": "solid",
|
|
47
|
+
ref: forwardedRef
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
/* @__PURE__ */ jsx(DisclosureArrow, { className: "\u{1F95D}-select-arrow" })
|
|
51
|
+
] });
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
export {
|
|
55
|
+
HtmlSelect,
|
|
56
|
+
SelectRoot as Root
|
|
57
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type BaseProps } from "./~utils.js";
|
|
2
|
+
interface SpinnerProps extends BaseProps {
|
|
3
|
+
/**
|
|
4
|
+
* A text alternative for the spinner.
|
|
5
|
+
* @default "Loading…"
|
|
6
|
+
*/
|
|
7
|
+
alt?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The size of the spinner.
|
|
10
|
+
* @default "medium"
|
|
11
|
+
*/
|
|
12
|
+
size?: "small" | "medium" | "large" | "xlarge";
|
|
13
|
+
/**
|
|
14
|
+
* The tone of the spinner.
|
|
15
|
+
* @default "neutral"
|
|
16
|
+
*/
|
|
17
|
+
tone?: "neutral" | "accent";
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A loading spinner.
|
|
21
|
+
*
|
|
22
|
+
* Example:
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <Spinner />
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* Supports a `tone` prop to change the tone (color) of the spinner.
|
|
28
|
+
* Supports a `size` prop to change the size of the spinner.
|
|
29
|
+
*/
|
|
30
|
+
export declare const Spinner: import("react").ForwardRefExoticComponent<SpinnerProps & import("react").RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as Ariakit from "@ariakit/react";
|
|
3
|
+
import cx from "classnames";
|
|
4
|
+
import { VisuallyHidden } from "./VisuallyHidden.js";
|
|
5
|
+
import { forwardRef } from "./~utils.js";
|
|
6
|
+
const Spinner = forwardRef(
|
|
7
|
+
(props, forwardedRef) => {
|
|
8
|
+
const {
|
|
9
|
+
alt = "Loading\u2026",
|
|
10
|
+
size = "medium",
|
|
11
|
+
tone = "neutral",
|
|
12
|
+
...rest
|
|
13
|
+
} = props;
|
|
14
|
+
return /* @__PURE__ */ jsxs(
|
|
15
|
+
Ariakit.Role,
|
|
16
|
+
{
|
|
17
|
+
...rest,
|
|
18
|
+
"data-kiwi-size": size,
|
|
19
|
+
"data-kiwi-tone": tone,
|
|
20
|
+
className: cx("\u{1F95D}-spinner", props.className),
|
|
21
|
+
ref: forwardedRef,
|
|
22
|
+
children: [
|
|
23
|
+
/* @__PURE__ */ jsx("svg", { "aria-hidden": "true", className: "\u{1F95D}-spinner-svg", viewBox: "0 0 16 16", children: /* @__PURE__ */ jsx(
|
|
24
|
+
"path",
|
|
25
|
+
{
|
|
26
|
+
stroke: "currentColor",
|
|
27
|
+
"stroke-linecap": "round",
|
|
28
|
+
d: "M9.5 1.674a6.503 6.503 0 0 1 0 12.652m-3-12.652a6.503 6.503 0 0 0 0 12.652"
|
|
29
|
+
}
|
|
30
|
+
) }),
|
|
31
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: alt })
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
export {
|
|
38
|
+
Spinner
|
|
39
|
+
};
|
package/dist/bricks/Switch.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import * as Ariakit from "@ariakit/react";
|
|
3
|
-
import type
|
|
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
|
-
|
|
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 {};
|
package/dist/bricks/Switch.js
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
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
|
-
import { useFieldId } from "./Field.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
import { useFieldDescribedBy, useFieldId } from "./Field.js";
|
|
5
|
+
import { forwardRef } from "./~utils.js";
|
|
6
|
+
const Switch = forwardRef(
|
|
7
|
+
(props, forwardedRef) => {
|
|
8
|
+
const fieldId = useFieldId();
|
|
9
|
+
const describedBy = useFieldDescribedBy(props["aria-describedby"]);
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
Ariakit.Checkbox,
|
|
12
|
+
{
|
|
13
|
+
accessibleWhenDisabled: true,
|
|
14
|
+
id: fieldId,
|
|
15
|
+
...props,
|
|
16
|
+
className: cx("\u{1F95D}-switch", props.className),
|
|
17
|
+
"aria-describedby": describedBy,
|
|
18
|
+
role: "switch",
|
|
19
|
+
ref: forwardedRef
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
);
|
|
20
24
|
export {
|
|
21
25
|
Switch
|
|
22
26
|
};
|
package/dist/bricks/Tabs.d.ts
CHANGED
|
@@ -1,8 +1,36 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as Ariakit from "@ariakit/react";
|
|
3
|
-
import type
|
|
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
|
-
|
|
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
|
-
|
|
18
|
-
|
|
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>>;
|
|
70
|
+
interface TabPanelProps extends FocusableProps<"div">, Pick<Ariakit.TabPanelProps, "tabId" | "unmountOnHide" | "focusable"> {
|
|
19
71
|
}
|
|
20
|
-
|
|
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 };
|
package/dist/bricks/Tabs.js
CHANGED
|
@@ -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,14 +41,14 @@ function Tabs(props) {
|
|
|
40
41
|
}
|
|
41
42
|
);
|
|
42
43
|
}
|
|
43
|
-
const TabList =
|
|
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(
|
|
47
48
|
Ariakit.TabList,
|
|
48
49
|
{
|
|
49
|
-
"data-kiwi-tone": tone,
|
|
50
50
|
...rest,
|
|
51
|
+
"data-kiwi-tone": tone,
|
|
51
52
|
className: cx("\u{1F95D}-tab-list", props.className),
|
|
52
53
|
style: {
|
|
53
54
|
"--\u{1F95D}tab-active-stripe-view-transition-name": viewTransitionName,
|
|
@@ -57,20 +58,18 @@ const TabList = React.forwardRef((props, forwardedRef) => {
|
|
|
57
58
|
}
|
|
58
59
|
);
|
|
59
60
|
});
|
|
60
|
-
const Tab =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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 {};
|