@itwin/itwinui-react 5.0.0-alpha.11 → 5.0.0-alpha.13
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 +28 -0
- package/README.md +13 -2
- package/dist/DEV/bricks/Checkbox.js +7 -14
- package/dist/DEV/bricks/Description.js +7 -14
- package/dist/DEV/bricks/DropdownMenu.js +68 -21
- package/dist/DEV/bricks/ErrorRegion.js +137 -0
- package/dist/DEV/bricks/Field.internal.js +47 -0
- package/dist/DEV/bricks/Field.js +120 -85
- package/dist/DEV/bricks/Icon.js +57 -0
- package/dist/DEV/bricks/IconButton.js +2 -5
- package/dist/DEV/bricks/Label.js +4 -10
- package/dist/DEV/bricks/Radio.js +7 -14
- package/dist/DEV/bricks/Select.js +9 -15
- package/dist/DEV/bricks/Switch.js +8 -15
- package/dist/DEV/bricks/Table.js +71 -37
- package/dist/DEV/bricks/Tabs.js +4 -29
- package/dist/DEV/bricks/TextBox.js +23 -37
- package/dist/DEV/bricks/Toolbar.js +25 -0
- package/dist/DEV/bricks/TreeItem.js +114 -42
- package/dist/DEV/bricks/index.js +9 -3
- package/dist/DEV/bricks/styles.css.js +1 -1
- package/dist/DEV/bricks/~utils.Dot.js +22 -0
- package/dist/DEV/foundations/styles.css.js +1 -1
- package/dist/bricks/Checkbox.d.ts +13 -5
- package/dist/bricks/Checkbox.js +7 -14
- package/dist/bricks/Description.d.ts +2 -6
- package/dist/bricks/Description.js +7 -14
- package/dist/bricks/DropdownMenu.d.ts +11 -9
- package/dist/bricks/DropdownMenu.js +67 -20
- package/dist/bricks/ErrorRegion.d.ts +88 -0
- package/dist/bricks/ErrorRegion.js +135 -0
- package/dist/bricks/Field.d.ts +69 -27
- package/dist/bricks/Field.internal.d.ts +33 -0
- package/dist/bricks/Field.internal.js +47 -0
- package/dist/bricks/Field.js +115 -84
- package/dist/bricks/Icon.d.ts +6 -0
- package/dist/bricks/Icon.js +55 -0
- package/dist/bricks/IconButton.js +2 -5
- package/dist/bricks/Label.d.ts +5 -12
- package/dist/bricks/Label.js +4 -10
- package/dist/bricks/ProgressBar.d.ts +7 -1
- package/dist/bricks/Radio.d.ts +14 -5
- package/dist/bricks/Radio.js +7 -14
- package/dist/bricks/Select.d.ts +29 -12
- package/dist/bricks/Select.js +9 -15
- package/dist/bricks/Switch.d.ts +12 -5
- package/dist/bricks/Switch.js +8 -15
- package/dist/bricks/Table.d.ts +94 -37
- package/dist/bricks/Table.js +69 -36
- package/dist/bricks/Tabs.d.ts +3 -4
- package/dist/bricks/Tabs.js +4 -29
- package/dist/bricks/TextBox.d.ts +42 -19
- package/dist/bricks/TextBox.js +23 -37
- package/dist/bricks/Toolbar.d.ts +35 -0
- package/dist/bricks/Toolbar.js +23 -0
- package/dist/bricks/TreeItem.d.ts +63 -9
- package/dist/bricks/TreeItem.js +103 -41
- package/dist/bricks/index.d.ts +5 -2
- package/dist/bricks/index.js +9 -3
- package/dist/bricks/styles.css.js +1 -1
- package/dist/bricks/~hooks.d.ts +1 -1
- package/dist/bricks/~utils.Dot.d.ts +11 -0
- package/dist/bricks/~utils.Dot.js +21 -0
- package/dist/foundations/styles.css.js +1 -1
- package/package.json +1 -1
package/dist/bricks/Table.d.ts
CHANGED
|
@@ -1,44 +1,89 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type BaseProps } from "./~utils.js";
|
|
3
|
-
interface
|
|
3
|
+
interface HtmlTableProps extends BaseProps {
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
6
|
* A table is a grid of rows and columns that displays data in a structured format.
|
|
7
7
|
*
|
|
8
|
-
* `Table.
|
|
9
|
-
*
|
|
8
|
+
* `Table.HtmlTable` uses native HTML table elements for the table root *and its descendants*.
|
|
9
|
+
*
|
|
10
|
+
* E.g. `<table>`, `<thead>`, `<tbody>`, `<tr>`, `<th>`, and `<td>`.
|
|
11
|
+
*
|
|
12
|
+
* Related: `Table.CustomTable`
|
|
10
13
|
*
|
|
11
14
|
* Example:
|
|
12
15
|
* ```tsx
|
|
13
|
-
* <Table.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
16
|
+
* <Table.HtmlTable> // <table>
|
|
17
|
+
* <Table.Caption>Table Caption</Table.Caption> // <caption>
|
|
18
|
+
*
|
|
19
|
+
* <Table.Header> // <thead>
|
|
20
|
+
* <Table.Row> // <tr>
|
|
21
|
+
* <Table.Cell>Header 1</Table.Cell> // <th>
|
|
22
|
+
* <Table.Cell>Header 2</Table.Cell> // <th>
|
|
23
|
+
* </Table.Row>
|
|
24
|
+
* </Table.Header>
|
|
25
|
+
*
|
|
26
|
+
* <Table.Body> // <tbody>
|
|
27
|
+
* <Table.Row> // <tr>
|
|
28
|
+
* <Table.Cell>Cell 1.1</Table.Cell> // <td>
|
|
29
|
+
* <Table.Cell>Cell 1.2</Table.Cell> // <td>
|
|
30
|
+
* </Table.Row>
|
|
31
|
+
* <Table.Row> // <tr>
|
|
32
|
+
* <Table.Cell>Cell 2.1</Table.Cell> // <td>
|
|
33
|
+
* <Table.Cell>Cell 2.2</Table.Cell> // <td>
|
|
34
|
+
* </Table.Row>
|
|
35
|
+
* </Table.Body>
|
|
36
|
+
* </Table.HtmlTable>
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare const HtmlTable: React.ForwardRefExoticComponent<HtmlTableProps & React.RefAttributes<HTMLElement | HTMLTableElement>>;
|
|
40
|
+
interface CustomTableProps extends BaseProps {
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A table is a grid of rows and columns that displays data in a structured format.
|
|
44
|
+
*
|
|
45
|
+
* `Table.CustomTable` implements the [WAI-ARIA table pattern](https://www.w3.org/WAI/ARIA/apg/patterns/table/) using
|
|
46
|
+
* divs + appropriate roles for the table root *and its descendants*.
|
|
47
|
+
*
|
|
48
|
+
* E.g. `<div role="table">`, `<div role="row">`, `<div role="columnheader">`, and `<div role="cell">`.
|
|
49
|
+
*
|
|
50
|
+
* Related: `Table.HtmlTable`
|
|
51
|
+
*
|
|
52
|
+
* Example:
|
|
53
|
+
* ```tsx
|
|
54
|
+
* <Table.CustomTable> // <div role="table">
|
|
55
|
+
* <Table.Caption>Table Caption</Table.Caption> // <div role="caption">
|
|
56
|
+
*
|
|
57
|
+
* <Table.Header> // <div role="rowgroup">
|
|
58
|
+
* <Table.Row> // <div role="row">
|
|
59
|
+
* <Table.Cell>Header 1</Table.Cell> // <div role="columnheader">
|
|
60
|
+
* <Table.Cell>Header 2</Table.Cell> // <div role="columnheader">
|
|
61
|
+
* </Table.Row>
|
|
62
|
+
* </Table.Header>
|
|
63
|
+
*
|
|
64
|
+
* <Table.Body>
|
|
65
|
+
* <Table.Row> // <div role="row">
|
|
66
|
+
* <Table.Cell>Cell 1.1</Table.Cell> // <div role="cell">
|
|
67
|
+
* <Table.Cell>Cell 1.2</Table.Cell> // <div role="cell">
|
|
68
|
+
* </Table.Row>
|
|
69
|
+
* <Table.Row> // <div role="row">
|
|
70
|
+
* <Table.Cell>Cell 2.1</Table.Cell> // <div role="cell">
|
|
71
|
+
* <Table.Cell>Cell 2.2</Table.Cell> // <div role="cell">
|
|
72
|
+
* </Table.Row>
|
|
73
|
+
* </Table.Body>
|
|
74
|
+
* </Table.CustomTable>
|
|
33
75
|
* ```
|
|
34
76
|
*/
|
|
35
|
-
declare const
|
|
36
|
-
interface TableHeaderProps extends BaseProps {
|
|
77
|
+
declare const CustomTable: React.ForwardRefExoticComponent<CustomTableProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
78
|
+
interface TableHeaderProps extends BaseProps<"div"> {
|
|
37
79
|
}
|
|
38
80
|
/**
|
|
39
81
|
* `Table.Header` is a column component of cells that labels the columns of a table.
|
|
40
82
|
* `Table.Row` and `Table.Cell` can be nested inside a `Table.Header` to create a header row.
|
|
41
83
|
*
|
|
84
|
+
* If within a `Table.HtmlTable`: it will render a `<thead>` element.
|
|
85
|
+
* If within a `Table.CustomTable`: it will render a `<div role="rowgroup">` element.
|
|
86
|
+
*
|
|
42
87
|
* Example:
|
|
43
88
|
* ```tsx
|
|
44
89
|
* <Table.Header>
|
|
@@ -50,13 +95,14 @@ interface TableHeaderProps extends BaseProps {
|
|
|
50
95
|
* ```
|
|
51
96
|
*/
|
|
52
97
|
declare const TableHeader: React.ForwardRefExoticComponent<TableHeaderProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
53
|
-
interface TableBodyProps extends BaseProps {
|
|
98
|
+
interface TableBodyProps extends BaseProps<"div"> {
|
|
54
99
|
}
|
|
55
100
|
/**
|
|
56
101
|
* `Table.Body` is a component that contains the rows of table data.
|
|
57
102
|
* Multiple `Table.Row`s and `Table.Cell`s can be nested inside a `Table.Body` to create a table body.
|
|
58
103
|
*
|
|
59
|
-
*
|
|
104
|
+
* If within a `Table.HtmlTable`: it will render a `<tbody>` element.
|
|
105
|
+
* If within a `Table.CustomTable`: it will render a `<div>` element.
|
|
60
106
|
*
|
|
61
107
|
* Example:
|
|
62
108
|
* ```tsx
|
|
@@ -73,11 +119,14 @@ interface TableBodyProps extends BaseProps {
|
|
|
73
119
|
* ```
|
|
74
120
|
*/
|
|
75
121
|
declare const TableBody: React.ForwardRefExoticComponent<TableBodyProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
76
|
-
interface TableRowProps extends BaseProps {
|
|
122
|
+
interface TableRowProps extends BaseProps<"div"> {
|
|
77
123
|
}
|
|
78
124
|
/**
|
|
79
125
|
* `Table.Row` is a component that contains the cells of a table row.
|
|
80
126
|
*
|
|
127
|
+
* If within a `Table.HtmlTable`: it will render a `<tr>` element.
|
|
128
|
+
* If within a `Table.CustomTable`: it will render a `<div role="row">` element.
|
|
129
|
+
*
|
|
81
130
|
* Example:
|
|
82
131
|
* ```tsx
|
|
83
132
|
* <Table.Row>
|
|
@@ -87,29 +136,37 @@ interface TableRowProps extends BaseProps {
|
|
|
87
136
|
* ```
|
|
88
137
|
*/
|
|
89
138
|
declare const TableRow: React.ForwardRefExoticComponent<TableRowProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
90
|
-
interface TableCaptionProps extends BaseProps<"
|
|
139
|
+
interface TableCaptionProps extends BaseProps<"div"> {
|
|
91
140
|
}
|
|
92
141
|
/**
|
|
93
142
|
* `Table.Caption` is a component that contains the caption of a table.
|
|
94
143
|
*
|
|
144
|
+
* If within a `Table.HtmlTable`: it will render a `<caption>` element.
|
|
145
|
+
* If within a `Table.CustomTable`: it will render a `<div role="caption">` element.
|
|
146
|
+
*
|
|
95
147
|
* Example:
|
|
96
148
|
* ```tsx
|
|
97
|
-
* <Table.
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* </Table.
|
|
149
|
+
* <Table.CustomTable> // Or <Table.HtmlTable>
|
|
150
|
+
* <Table.Caption>Table Caption</Table.Caption>
|
|
151
|
+
* …
|
|
152
|
+
* </Table.CustomTable> // Or </Table.HtmlTable>
|
|
101
153
|
* ```
|
|
102
154
|
*/
|
|
103
|
-
declare const TableCaption: React.ForwardRefExoticComponent<TableCaptionProps & React.RefAttributes<HTMLElement>>;
|
|
104
|
-
interface TableCellProps extends BaseProps<"
|
|
155
|
+
declare const TableCaption: React.ForwardRefExoticComponent<TableCaptionProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
156
|
+
interface TableCellProps extends BaseProps<"div"> {
|
|
105
157
|
}
|
|
106
158
|
/**
|
|
107
159
|
* `Table.Cell` is a component that contains the data of a table cell.
|
|
108
160
|
*
|
|
161
|
+
* - If within a `Table.HtmlTable`: it will render a `<th>` element if also within a `Table.Header`, or a `<td>` element
|
|
162
|
+
* if also within a `Table.Body`.
|
|
163
|
+
* - If within a `Table.CustomTable`: it will render a `<div role="columnheader">` element if also within a
|
|
164
|
+
* `Table.Header`, or a `<div role="cell">` element if also within a `Table.Body`.
|
|
165
|
+
*
|
|
109
166
|
* Example:
|
|
110
167
|
* ```tsx
|
|
111
168
|
* <Table.Cell>Cell 1.1</Table.Cell>
|
|
112
169
|
* ```
|
|
113
170
|
*/
|
|
114
|
-
declare const TableCell: React.ForwardRefExoticComponent<TableCellProps & React.RefAttributes<HTMLElement |
|
|
115
|
-
export {
|
|
171
|
+
declare const TableCell: React.ForwardRefExoticComponent<TableCellProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
172
|
+
export { HtmlTable, CustomTable, TableHeader as Header, TableBody as Body, TableRow as Row, TableCaption as Caption, TableCell as Cell, };
|
package/dist/bricks/Table.js
CHANGED
|
@@ -3,98 +3,130 @@ import { Role } from "@ariakit/react/role";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import cx from "classnames";
|
|
5
5
|
import { forwardRef } from "./~utils.js";
|
|
6
|
-
import { useMergedRefs } from "./~hooks.js";
|
|
7
|
-
const TableContext = React.createContext(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return /* @__PURE__ */ jsx(TableContext.Provider, { value:
|
|
6
|
+
import { useMergedRefs, useSafeContext } from "./~hooks.js";
|
|
7
|
+
const TableContext = React.createContext(void 0);
|
|
8
|
+
const TableHeaderContext = React.createContext(false);
|
|
9
|
+
const HtmlTable = forwardRef((props, forwardedRef) => {
|
|
10
|
+
const tableContextValue = React.useMemo(
|
|
11
|
+
() => ({ mode: "html" }),
|
|
12
|
+
[]
|
|
13
|
+
);
|
|
14
|
+
return /* @__PURE__ */ jsx(TableContext.Provider, { value: tableContextValue, children: /* @__PURE__ */ jsx(
|
|
15
15
|
Role,
|
|
16
16
|
{
|
|
17
|
+
render: /* @__PURE__ */ jsx("table", {}),
|
|
17
18
|
...props,
|
|
18
|
-
className: cx("\u{1F95D}-table", props.className),
|
|
19
19
|
ref: forwardedRef,
|
|
20
|
-
|
|
21
|
-
"aria-labelledby": captionId,
|
|
22
|
-
children: props.children
|
|
20
|
+
className: cx("\u{1F95D}-table", props.className)
|
|
23
21
|
}
|
|
24
22
|
) });
|
|
25
23
|
});
|
|
26
|
-
const
|
|
24
|
+
const CustomTable = forwardRef(
|
|
25
|
+
(props, forwardedRef) => {
|
|
26
|
+
const [captionId, setCaptionId] = React.useState();
|
|
27
|
+
const tableContextValue = React.useMemo(
|
|
28
|
+
() => ({ captionId, setCaptionId, mode: "aria" }),
|
|
29
|
+
[captionId]
|
|
30
|
+
);
|
|
31
|
+
return /* @__PURE__ */ jsx(TableContext.Provider, { value: tableContextValue, children: /* @__PURE__ */ jsx(
|
|
32
|
+
Role.div,
|
|
33
|
+
{
|
|
34
|
+
role: "table",
|
|
35
|
+
"aria-labelledby": captionId,
|
|
36
|
+
...props,
|
|
37
|
+
ref: forwardedRef,
|
|
38
|
+
className: cx("\u{1F95D}-table", props.className)
|
|
39
|
+
}
|
|
40
|
+
) });
|
|
41
|
+
}
|
|
42
|
+
);
|
|
27
43
|
const TableHeader = forwardRef(
|
|
28
44
|
(props, forwardedRef) => {
|
|
45
|
+
const { mode } = useSafeContext(TableContext);
|
|
46
|
+
const render = mode === "html" ? /* @__PURE__ */ jsx("thead", {}) : void 0;
|
|
47
|
+
const role = mode === "aria" ? "rowgroup" : void 0;
|
|
29
48
|
return /* @__PURE__ */ jsx(TableHeaderContext.Provider, { value: true, children: /* @__PURE__ */ jsx(
|
|
30
49
|
Role.div,
|
|
31
50
|
{
|
|
51
|
+
render,
|
|
52
|
+
role,
|
|
32
53
|
...props,
|
|
33
|
-
className: cx("\u{1F95D}-table-header", props.className),
|
|
34
54
|
ref: forwardedRef,
|
|
35
|
-
|
|
36
|
-
children: props.children
|
|
55
|
+
className: cx("\u{1F95D}-table-header", props.className)
|
|
37
56
|
}
|
|
38
57
|
) });
|
|
39
58
|
}
|
|
40
59
|
);
|
|
41
60
|
const TableBody = forwardRef((props, forwardedRef) => {
|
|
61
|
+
const { mode } = useSafeContext(TableContext);
|
|
62
|
+
const render = mode === "html" ? /* @__PURE__ */ jsx("tbody", {}) : void 0;
|
|
42
63
|
return /* @__PURE__ */ jsx(
|
|
43
64
|
Role.div,
|
|
44
65
|
{
|
|
66
|
+
render,
|
|
67
|
+
role: void 0,
|
|
45
68
|
...props,
|
|
46
|
-
className: cx("\u{1F95D}-table-body", props.className),
|
|
47
69
|
ref: forwardedRef,
|
|
48
|
-
|
|
70
|
+
className: cx("\u{1F95D}-table-body", props.className)
|
|
49
71
|
}
|
|
50
72
|
);
|
|
51
73
|
});
|
|
52
74
|
const TableRow = forwardRef((props, forwardedRef) => {
|
|
53
|
-
const {
|
|
75
|
+
const { mode } = useSafeContext(TableContext);
|
|
76
|
+
const render = mode === "html" ? /* @__PURE__ */ jsx("tr", {}) : void 0;
|
|
77
|
+
const role = mode === "aria" ? "row" : void 0;
|
|
54
78
|
return /* @__PURE__ */ jsx(
|
|
55
79
|
Role.div,
|
|
56
80
|
{
|
|
57
|
-
|
|
58
|
-
|
|
81
|
+
render,
|
|
82
|
+
role,
|
|
83
|
+
...props,
|
|
59
84
|
ref: forwardedRef,
|
|
60
|
-
|
|
61
|
-
children
|
|
85
|
+
className: cx("\u{1F95D}-table-row", props.className)
|
|
62
86
|
}
|
|
63
87
|
);
|
|
64
88
|
});
|
|
65
89
|
const TableCaption = forwardRef(
|
|
66
90
|
(props, forwardedRef) => {
|
|
67
91
|
const fallbackId = React.useId();
|
|
68
|
-
const { id = fallbackId,
|
|
69
|
-
const { setCaptionId } =
|
|
92
|
+
const { id = fallbackId, ...rest } = props;
|
|
93
|
+
const { mode, setCaptionId } = useSafeContext(TableContext);
|
|
94
|
+
const render = mode === "html" ? /* @__PURE__ */ jsx("caption", {}) : void 0;
|
|
70
95
|
const captionIdRef = React.useCallback(
|
|
71
96
|
(element) => {
|
|
72
|
-
setCaptionId(element ? id : void 0);
|
|
97
|
+
setCaptionId?.(element ? id : void 0);
|
|
73
98
|
},
|
|
74
99
|
[id, setCaptionId]
|
|
75
100
|
);
|
|
76
101
|
return /* @__PURE__ */ jsx(
|
|
77
|
-
Role,
|
|
102
|
+
Role.div,
|
|
78
103
|
{
|
|
104
|
+
render,
|
|
79
105
|
...rest,
|
|
80
106
|
id,
|
|
81
|
-
className: cx("\u{1F95D}-table-caption", props.className),
|
|
82
107
|
ref: useMergedRefs(forwardedRef, captionIdRef),
|
|
83
|
-
|
|
108
|
+
className: cx("\u{1F95D}-table-caption", props.className)
|
|
84
109
|
}
|
|
85
110
|
);
|
|
86
111
|
}
|
|
87
112
|
);
|
|
88
113
|
const TableCell = forwardRef((props, forwardedRef) => {
|
|
89
|
-
const isWithinTableHeader =
|
|
114
|
+
const isWithinTableHeader = useSafeContext(TableHeaderContext);
|
|
115
|
+
const { mode } = useSafeContext(TableContext);
|
|
116
|
+
const { render, role } = React.useMemo(() => {
|
|
117
|
+
if (mode === "aria") {
|
|
118
|
+
return { role: isWithinTableHeader ? "columnheader" : "cell" };
|
|
119
|
+
}
|
|
120
|
+
return { render: isWithinTableHeader ? /* @__PURE__ */ jsx("th", {}) : /* @__PURE__ */ jsx("td", {}) };
|
|
121
|
+
}, [isWithinTableHeader, mode]);
|
|
90
122
|
return /* @__PURE__ */ jsx(
|
|
91
|
-
Role.
|
|
123
|
+
Role.div,
|
|
92
124
|
{
|
|
125
|
+
render,
|
|
126
|
+
role,
|
|
93
127
|
...props,
|
|
94
|
-
className: cx("\u{1F95D}-table-cell", props.className),
|
|
95
128
|
ref: forwardedRef,
|
|
96
|
-
|
|
97
|
-
children: props.children
|
|
129
|
+
className: cx("\u{1F95D}-table-cell", props.className)
|
|
98
130
|
}
|
|
99
131
|
);
|
|
100
132
|
});
|
|
@@ -102,7 +134,8 @@ export {
|
|
|
102
134
|
TableBody as Body,
|
|
103
135
|
TableCaption as Caption,
|
|
104
136
|
TableCell as Cell,
|
|
137
|
+
CustomTable,
|
|
105
138
|
TableHeader as Header,
|
|
106
|
-
|
|
139
|
+
HtmlTable,
|
|
107
140
|
TableRow as Row
|
|
108
141
|
};
|
package/dist/bricks/Tabs.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import * as AkTab from "@ariakit/react/tab";
|
|
3
2
|
import { type FocusableProps, type BaseProps } from "./~utils.js";
|
|
4
3
|
interface TabsProps extends Pick<AkTab.TabProviderProps, "defaultSelectedId" | "selectedId" | "setSelectedId" | "selectOnMove" | "children"> {
|
|
@@ -52,7 +51,7 @@ interface TabListProps extends BaseProps {
|
|
|
52
51
|
* </Tabs.TabList>
|
|
53
52
|
* ```
|
|
54
53
|
*/
|
|
55
|
-
declare const TabList:
|
|
54
|
+
declare const TabList: import("react").ForwardRefExoticComponent<TabListProps & import("react").RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
56
55
|
interface TabProps extends FocusableProps<"button">, Pick<AkTab.TabProps, "id"> {
|
|
57
56
|
}
|
|
58
57
|
/**
|
|
@@ -66,7 +65,7 @@ interface TabProps extends FocusableProps<"button">, Pick<AkTab.TabProps, "id">
|
|
|
66
65
|
* <Tabs.Tab id="tab-1">Tab 1</Tabs.Tab>
|
|
67
66
|
* ```
|
|
68
67
|
*/
|
|
69
|
-
declare const Tab:
|
|
68
|
+
declare const Tab: import("react").ForwardRefExoticComponent<TabProps & import("react").RefAttributes<HTMLElement | HTMLButtonElement>>;
|
|
70
69
|
interface TabPanelProps extends FocusableProps<"div">, Pick<AkTab.TabPanelProps, "tabId" | "unmountOnHide" | "focusable"> {
|
|
71
70
|
}
|
|
72
71
|
/**
|
|
@@ -78,5 +77,5 @@ interface TabPanelProps extends FocusableProps<"div">, Pick<AkTab.TabPanelProps,
|
|
|
78
77
|
* <Tabs.TabPanel tabId="tab-1">Tab 1 content</Tabs.TabPanel>
|
|
79
78
|
* ```
|
|
80
79
|
*/
|
|
81
|
-
declare const TabPanel:
|
|
80
|
+
declare const TabPanel: import("react").ForwardRefExoticComponent<TabPanelProps & import("react").RefAttributes<HTMLElement | HTMLDivElement>>;
|
|
82
81
|
export { Tabs as Root, TabList, Tab, TabPanel };
|
package/dist/bricks/Tabs.js
CHANGED
|
@@ -1,41 +1,21 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import * as ReactDOM from "react-dom";
|
|
4
2
|
import cx from "classnames";
|
|
5
3
|
import * as AkTab from "@ariakit/react/tab";
|
|
6
|
-
import { useControlledState } from "./~hooks.js";
|
|
7
4
|
import { forwardRef } from "./~utils.js";
|
|
8
5
|
function Tabs(props) {
|
|
9
6
|
const {
|
|
10
7
|
defaultSelectedId,
|
|
11
|
-
selectedId
|
|
12
|
-
setSelectedId
|
|
8
|
+
selectedId,
|
|
9
|
+
setSelectedId,
|
|
13
10
|
selectOnMove,
|
|
14
11
|
children
|
|
15
12
|
} = props;
|
|
16
|
-
const [selectedId, setSelectedId] = useControlledState(
|
|
17
|
-
defaultSelectedId,
|
|
18
|
-
selectedIdProp,
|
|
19
|
-
setSelectedIdProp
|
|
20
|
-
);
|
|
21
13
|
return /* @__PURE__ */ jsx(
|
|
22
14
|
AkTab.TabProvider,
|
|
23
15
|
{
|
|
16
|
+
defaultSelectedId,
|
|
24
17
|
selectedId,
|
|
25
|
-
setSelectedId
|
|
26
|
-
(id) => {
|
|
27
|
-
if (document.startViewTransition) {
|
|
28
|
-
document.startViewTransition(() => {
|
|
29
|
-
ReactDOM.flushSync(() => {
|
|
30
|
-
setSelectedId(id);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
} else {
|
|
34
|
-
setSelectedId(id);
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
[setSelectedId]
|
|
38
|
-
),
|
|
18
|
+
setSelectedId,
|
|
39
19
|
selectOnMove,
|
|
40
20
|
children
|
|
41
21
|
}
|
|
@@ -43,17 +23,12 @@ function Tabs(props) {
|
|
|
43
23
|
}
|
|
44
24
|
const TabList = forwardRef((props, forwardedRef) => {
|
|
45
25
|
const { tone = "neutral", ...rest } = props;
|
|
46
|
-
const viewTransitionName = `\u{1F95D}active-stripe-${React.useId().replaceAll(":", "_")}`;
|
|
47
26
|
return /* @__PURE__ */ jsx(
|
|
48
27
|
AkTab.TabList,
|
|
49
28
|
{
|
|
50
29
|
...rest,
|
|
51
30
|
"data-kiwi-tone": tone,
|
|
52
31
|
className: cx("\u{1F95D}-tab-list", props.className),
|
|
53
|
-
style: {
|
|
54
|
-
"--\u{1F95D}tab-active-stripe-view-transition-name": viewTransitionName,
|
|
55
|
-
...props.style
|
|
56
|
-
},
|
|
57
32
|
ref: forwardedRef
|
|
58
33
|
}
|
|
59
34
|
);
|
package/dist/bricks/TextBox.d.ts
CHANGED
|
@@ -19,17 +19,26 @@ interface TextBoxInputProps extends Omit<BaseInputProps, "children" | "type"> {
|
|
|
19
19
|
*
|
|
20
20
|
* Example usage:
|
|
21
21
|
* ```tsx
|
|
22
|
-
* <TextBox.Input defaultValue="Hello" />
|
|
22
|
+
* <TextBox.Input name="greeting" defaultValue="Hello" />
|
|
23
23
|
* ```
|
|
24
24
|
*
|
|
25
25
|
* To add additional decorations, see `TextBox.Root` component.
|
|
26
26
|
*
|
|
27
|
-
*
|
|
27
|
+
* Use with the `Field` components to automatically handle ID associations for
|
|
28
|
+
* labels and descriptions:
|
|
28
29
|
* ```tsx
|
|
29
|
-
* <Field>
|
|
30
|
-
* <Label>
|
|
31
|
-
* <TextBox.Input />
|
|
32
|
-
* </Field>
|
|
30
|
+
* <Field.Root>
|
|
31
|
+
* <Field.Label>First name</Field.Label>
|
|
32
|
+
* <Field.Control render={<TextBox.Input name="firstName" />} />
|
|
33
|
+
* </Field.Root>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Without the `Field` components you will need to manually associate labels,
|
|
37
|
+
* descriptions, etc.:
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <Label htmlFor="fruit">Fruit</Label>
|
|
40
|
+
* <TextBox.Input id="fruit" aria-describedby="fruit-description" />
|
|
41
|
+
* <Description id="fruit-description">Something to include in a fruit salad.</Description>
|
|
33
42
|
* ```
|
|
34
43
|
*
|
|
35
44
|
* Underneath, it's an HTML input, i.e. `<input>`, so it supports the same props, including
|
|
@@ -48,12 +57,21 @@ interface TextareaProps extends FocusableProps<"textarea"> {
|
|
|
48
57
|
* <TextBox.Textarea defaultValue="Hello" />
|
|
49
58
|
* ```
|
|
50
59
|
*
|
|
51
|
-
*
|
|
60
|
+
* Use with the `Field` components to automatically handle ID associations for
|
|
61
|
+
* labels and descriptions:
|
|
62
|
+
* ```tsx
|
|
63
|
+
* <Field.Root>
|
|
64
|
+
* <Field.Label>Leave a comment, be kind</Field.Label>
|
|
65
|
+
* <Field.Control render={<TextBox.Textarea name="comment" />} />
|
|
66
|
+
* </Field.Root>
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* Without the `Field` components you will need to manually associate labels,
|
|
70
|
+
* descriptions, etc.:
|
|
52
71
|
* ```tsx
|
|
53
|
-
* <
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* </Field>
|
|
72
|
+
* <Label htmlFor="fruit">Fruit</Label>
|
|
73
|
+
* <TextBox.Input id="fruit" aria-describedby="fruit-description" />
|
|
74
|
+
* <Description id="fruit-description">Something to include in a fruit salad.</Description>
|
|
57
75
|
* ```
|
|
58
76
|
*
|
|
59
77
|
* Underneath, it's an HTML textarea, i.e. `<textarea>`, so it supports the same props, including
|
|
@@ -73,15 +91,20 @@ interface TextBoxRootProps extends BaseProps {
|
|
|
73
91
|
* </TextBox.Root>
|
|
74
92
|
* ```
|
|
75
93
|
*
|
|
76
|
-
*
|
|
94
|
+
* Use with the `Field` components to automatically handle ID associations for
|
|
95
|
+
* labels and descriptions:
|
|
77
96
|
* ```tsx
|
|
78
|
-
* <Field>
|
|
79
|
-
* <Label>
|
|
80
|
-
* <
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
97
|
+
* <Field.Root>
|
|
98
|
+
* <Field.Label>First name</Field.Label>
|
|
99
|
+
* <Field.Control
|
|
100
|
+
* render={(controlProps) => (
|
|
101
|
+
* <TextBox.Root>
|
|
102
|
+
* <TextBox.Input name="firstName" {...controlProps} />
|
|
103
|
+
* <TextBox.Icon href={…} />
|
|
104
|
+
* </TextBox.Root>
|
|
105
|
+
* )}
|
|
106
|
+
* />
|
|
107
|
+
* </Field.Root>
|
|
85
108
|
* ```
|
|
86
109
|
*/
|
|
87
110
|
declare const TextBoxRoot: React.ForwardRefExoticComponent<TextBoxRootProps & React.RefAttributes<HTMLElement | HTMLDivElement>>;
|
package/dist/bricks/TextBox.js
CHANGED
|
@@ -3,69 +3,55 @@ import * as React from "react";
|
|
|
3
3
|
import { Role } from "@ariakit/react/role";
|
|
4
4
|
import { Focusable } from "@ariakit/react/focusable";
|
|
5
5
|
import cx from "classnames";
|
|
6
|
-
import { FieldControl } from "./Field.js";
|
|
7
6
|
import { Icon } from "./Icon.js";
|
|
8
7
|
import { useMergedRefs } from "./~hooks.js";
|
|
9
8
|
import { forwardRef } from "./~utils.js";
|
|
9
|
+
import { useFieldControlType } from "./Field.internal.js";
|
|
10
10
|
const TextBoxInput = forwardRef(
|
|
11
11
|
(props, forwardedRef) => {
|
|
12
|
-
|
|
12
|
+
useFieldControlType("textlike");
|
|
13
13
|
const rootContext = React.useContext(TextBoxRootContext);
|
|
14
14
|
const setDisabled = rootContext?.setDisabled;
|
|
15
15
|
React.useEffect(() => {
|
|
16
16
|
setDisabled?.(props.disabled);
|
|
17
17
|
}, [setDisabled, props.disabled]);
|
|
18
18
|
return /* @__PURE__ */ jsx(
|
|
19
|
-
|
|
19
|
+
Role.input,
|
|
20
20
|
{
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
readOnly: props.disabled,
|
|
22
|
+
...props,
|
|
23
|
+
className: cx({ "\u{1F95D}-text-box": !rootContext }, props.className),
|
|
24
|
+
placeholder: props.placeholder ?? " ",
|
|
23
25
|
render: /* @__PURE__ */ jsx(
|
|
24
|
-
|
|
26
|
+
Focusable,
|
|
25
27
|
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
className: cx({ "\u{1F95D}-text-box": !rootContext }, props.className),
|
|
29
|
-
placeholder: props.placeholder ?? " ",
|
|
30
|
-
render: /* @__PURE__ */ jsx(
|
|
31
|
-
Focusable,
|
|
32
|
-
{
|
|
33
|
-
accessibleWhenDisabled: true,
|
|
34
|
-
render: props.render || /* @__PURE__ */ jsx("input", {})
|
|
35
|
-
}
|
|
36
|
-
),
|
|
37
|
-
ref: useMergedRefs(rootContext?.inputRef, forwardedRef)
|
|
28
|
+
accessibleWhenDisabled: true,
|
|
29
|
+
render: props.render || /* @__PURE__ */ jsx("input", {})
|
|
38
30
|
}
|
|
39
|
-
)
|
|
31
|
+
),
|
|
32
|
+
ref: useMergedRefs(rootContext?.inputRef, forwardedRef)
|
|
40
33
|
}
|
|
41
34
|
);
|
|
42
35
|
}
|
|
43
36
|
);
|
|
44
37
|
const TextBoxTextarea = forwardRef(
|
|
45
38
|
(props, forwardedRef) => {
|
|
46
|
-
|
|
39
|
+
useFieldControlType("textlike");
|
|
47
40
|
return /* @__PURE__ */ jsx(
|
|
48
|
-
|
|
41
|
+
Role.textarea,
|
|
49
42
|
{
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
readOnly: props.disabled,
|
|
44
|
+
...props,
|
|
45
|
+
className: cx("\u{1F95D}-text-box", props.className),
|
|
46
|
+
placeholder: props.placeholder ?? " ",
|
|
52
47
|
render: /* @__PURE__ */ jsx(
|
|
53
|
-
|
|
48
|
+
Focusable,
|
|
54
49
|
{
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
className: cx("\u{1F95D}-text-box", props.className),
|
|
58
|
-
placeholder: props.placeholder ?? " ",
|
|
59
|
-
render: /* @__PURE__ */ jsx(
|
|
60
|
-
Focusable,
|
|
61
|
-
{
|
|
62
|
-
accessibleWhenDisabled: true,
|
|
63
|
-
render: props.render || /* @__PURE__ */ jsx("textarea", {})
|
|
64
|
-
}
|
|
65
|
-
),
|
|
66
|
-
ref: forwardedRef
|
|
50
|
+
accessibleWhenDisabled: true,
|
|
51
|
+
render: props.render || /* @__PURE__ */ jsx("textarea", {})
|
|
67
52
|
}
|
|
68
|
-
)
|
|
53
|
+
),
|
|
54
|
+
ref: forwardedRef
|
|
69
55
|
}
|
|
70
56
|
);
|
|
71
57
|
}
|