@workday/canvas-kit-preview-react 9.0.0-alpha.382-next.2 → 9.0.0-alpha.385-next.4
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/dist/commonjs/table/index.d.ts +2 -0
- package/dist/commonjs/table/index.d.ts.map +1 -0
- package/dist/commonjs/table/index.js +13 -0
- package/dist/commonjs/table/lib/Table.d.ts +207 -0
- package/dist/commonjs/table/lib/Table.d.ts.map +1 -0
- package/dist/commonjs/table/lib/Table.js +229 -0
- package/dist/commonjs/table/lib/TableBody.d.ts +2 -0
- package/dist/commonjs/table/lib/TableBody.d.ts.map +1 -0
- package/dist/commonjs/table/lib/TableBody.js +35 -0
- package/dist/commonjs/table/lib/TableCaption.d.ts +2 -0
- package/dist/commonjs/table/lib/TableCaption.d.ts.map +1 -0
- package/dist/commonjs/table/lib/TableCaption.js +16 -0
- package/dist/commonjs/table/lib/TableCell.d.ts +2 -0
- package/dist/commonjs/table/lib/TableCell.d.ts.map +1 -0
- package/dist/commonjs/table/lib/TableCell.js +16 -0
- package/dist/commonjs/table/lib/TableFooter.d.ts +2 -0
- package/dist/commonjs/table/lib/TableFooter.d.ts.map +1 -0
- package/dist/commonjs/table/lib/TableFooter.js +15 -0
- package/dist/commonjs/table/lib/TableHead.d.ts +2 -0
- package/dist/commonjs/table/lib/TableHead.d.ts.map +1 -0
- package/dist/commonjs/table/lib/TableHead.js +23 -0
- package/dist/commonjs/table/lib/TableHeader.d.ts +2 -0
- package/dist/commonjs/table/lib/TableHeader.d.ts.map +1 -0
- package/dist/commonjs/table/lib/TableHeader.js +16 -0
- package/dist/commonjs/table/lib/TableRow.d.ts +2 -0
- package/dist/commonjs/table/lib/TableRow.d.ts.map +1 -0
- package/dist/commonjs/table/lib/TableRow.js +19 -0
- package/dist/es6/table/index.d.ts +2 -0
- package/dist/es6/table/index.d.ts.map +1 -0
- package/dist/es6/table/index.js +1 -0
- package/dist/es6/table/lib/Table.d.ts +207 -0
- package/dist/es6/table/lib/Table.d.ts.map +1 -0
- package/dist/es6/table/lib/Table.js +223 -0
- package/dist/es6/table/lib/TableBody.d.ts +2 -0
- package/dist/es6/table/lib/TableBody.d.ts.map +1 -0
- package/dist/es6/table/lib/TableBody.js +29 -0
- package/dist/es6/table/lib/TableCaption.d.ts +2 -0
- package/dist/es6/table/lib/TableCaption.d.ts.map +1 -0
- package/dist/es6/table/lib/TableCaption.js +10 -0
- package/dist/es6/table/lib/TableCell.d.ts +2 -0
- package/dist/es6/table/lib/TableCell.d.ts.map +1 -0
- package/dist/es6/table/lib/TableCell.js +10 -0
- package/dist/es6/table/lib/TableFooter.d.ts +2 -0
- package/dist/es6/table/lib/TableFooter.d.ts.map +1 -0
- package/dist/es6/table/lib/TableFooter.js +9 -0
- package/dist/es6/table/lib/TableHead.d.ts +2 -0
- package/dist/es6/table/lib/TableHead.d.ts.map +1 -0
- package/dist/es6/table/lib/TableHead.js +17 -0
- package/dist/es6/table/lib/TableHeader.d.ts +2 -0
- package/dist/es6/table/lib/TableHeader.d.ts.map +1 -0
- package/dist/es6/table/lib/TableHeader.js +10 -0
- package/dist/es6/table/lib/TableRow.d.ts +2 -0
- package/dist/es6/table/lib/TableRow.d.ts.map +1 -0
- package/dist/es6/table/lib/TableRow.js +13 -0
- package/package.json +3 -3
- package/table/LICENSE +51 -0
- package/table/README.md +5 -0
- package/table/index.ts +1 -0
- package/table/lib/Table.tsx +236 -0
- package/table/lib/TableBody.tsx +35 -0
- package/table/lib/TableCaption.tsx +22 -0
- package/table/lib/TableCell.tsx +27 -0
- package/table/lib/TableFooter.tsx +14 -0
- package/table/lib/TableHead.tsx +23 -0
- package/table/lib/TableHeader.tsx +28 -0
- package/table/lib/TableRow.tsx +26 -0
- package/table/package.json +6 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TableRow = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const layout_1 = require("@workday/canvas-kit-react/layout");
|
|
9
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
10
|
+
exports.TableRow = common_1.createComponent('tr')({
|
|
11
|
+
displayName: 'Table.Row',
|
|
12
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
13
|
+
const validChildren = (children) => {
|
|
14
|
+
return react_1.default.Children.toArray(children).filter(child => react_1.default.isValidElement(child));
|
|
15
|
+
};
|
|
16
|
+
const childrenArray = validChildren(children).length;
|
|
17
|
+
return (react_1.default.createElement(layout_1.Grid, Object.assign({ as: Element, ref: ref, gridAutoFlow: "column", gridTemplateColumns: `repeat(${childrenArray}, minmax(10rem, 1fr))` }, elemProps), children));
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../table/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/Table';
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Table` is a simple styled compound component that renders a [table](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table) element. It is used to present information in a two-dimensional table comprised of rows and columns of cells containing data.
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* ```tsx
|
|
6
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
7
|
+
|
|
8
|
+
export default function App() {
|
|
9
|
+
return (
|
|
10
|
+
<Table>
|
|
11
|
+
<Table.Caption>Table Caption</Table.Caption>
|
|
12
|
+
<Table.Head>
|
|
13
|
+
<Table.Row>
|
|
14
|
+
<Table.Header>Table Header</Table.Header>
|
|
15
|
+
<Table.Header>Table Header</Table.Header>
|
|
16
|
+
</Table.Row>
|
|
17
|
+
</Table.Head>
|
|
18
|
+
<Table.Body>
|
|
19
|
+
<Table.Row>
|
|
20
|
+
<Table.Header>Table Header</Table.Header>
|
|
21
|
+
<Table.Header>Table Header</Table.Header>
|
|
22
|
+
</Table.Row>
|
|
23
|
+
<Table.Row>
|
|
24
|
+
<Table.Header>Table Header</Table.Header>
|
|
25
|
+
<Table.Cell>Table Data Cell</Table.Cell>
|
|
26
|
+
</Table.Row>
|
|
27
|
+
<Table.Row>
|
|
28
|
+
<Table.Header>Table Header</Table.Header>
|
|
29
|
+
<Table.Cell>Table Data Cell</Table.Cell>
|
|
30
|
+
</Table.Row>
|
|
31
|
+
</Table.Body>
|
|
32
|
+
<Table.Footer>
|
|
33
|
+
<Table.Row>
|
|
34
|
+
<Table.Header>Table Header</Table.Header>
|
|
35
|
+
<Table.Cell>Table Data Cell</Table.Cell>
|
|
36
|
+
</Table.Row>
|
|
37
|
+
</Table.Footer>
|
|
38
|
+
</Table>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
*/
|
|
43
|
+
export declare const Table: import("@workday/canvas-kit-react/common").ElementComponent<"table", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").GridStyleProps> & {
|
|
44
|
+
/**
|
|
45
|
+
* `Table.Caption` renders a [caption](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/caption) element.
|
|
46
|
+
*
|
|
47
|
+
*
|
|
48
|
+
* ```tsx
|
|
49
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
50
|
+
|
|
51
|
+
export default function App() {
|
|
52
|
+
return (
|
|
53
|
+
<Table>
|
|
54
|
+
<Table.Caption>Table Caption</Table.Caption>
|
|
55
|
+
<Table.Body>
|
|
56
|
+
<Table.Row>
|
|
57
|
+
<Table.Header>Table Header</Table.Header>
|
|
58
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
59
|
+
</Table.Row>
|
|
60
|
+
</Table.Body>
|
|
61
|
+
</Table>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
*/
|
|
66
|
+
Caption: import("@workday/canvas-kit-react/common").ElementComponent<"caption", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps>;
|
|
67
|
+
/**
|
|
68
|
+
* `Table.Head` renders a [thead](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/thead) element.
|
|
69
|
+
*
|
|
70
|
+
*
|
|
71
|
+
* ```tsx
|
|
72
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
73
|
+
|
|
74
|
+
export default function App() {
|
|
75
|
+
return (
|
|
76
|
+
<Table>
|
|
77
|
+
<Table.Head>
|
|
78
|
+
<Table.Row>
|
|
79
|
+
<Table.Header>Table Header</Table.Header>
|
|
80
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
81
|
+
</Table.Row>
|
|
82
|
+
</Table.Head>
|
|
83
|
+
</Table>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
*/
|
|
88
|
+
Head: import("@workday/canvas-kit-react/common").ElementComponent<"thead", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").GridStyleProps>;
|
|
89
|
+
/**
|
|
90
|
+
* `Table.Body` renders a [tbody](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tbody) element.
|
|
91
|
+
*
|
|
92
|
+
*
|
|
93
|
+
* ```tsx
|
|
94
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
95
|
+
|
|
96
|
+
export default function App() {
|
|
97
|
+
return (
|
|
98
|
+
<Table>
|
|
99
|
+
<Table.Body>
|
|
100
|
+
<Table.Row>
|
|
101
|
+
<Table.Header>Table Header</Table.Header>
|
|
102
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
103
|
+
</Table.Row>
|
|
104
|
+
</Table.Body>
|
|
105
|
+
</Table>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
*/
|
|
110
|
+
Body: import("@workday/canvas-kit-react/common").ElementComponent<"tbody", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").GridStyleProps>;
|
|
111
|
+
/**
|
|
112
|
+
* `Table.Row` renders a [tr](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tr) element.
|
|
113
|
+
*
|
|
114
|
+
* **Note**: `Table.Row` is built on [Grid](/docs/components-layout-grid--basic). It will look for
|
|
115
|
+
* how many children are there and if those children are valid React Elements. This will adjust the
|
|
116
|
+
* amount of columns automatically using the `gridTemplateColumns` style prop and the width of the
|
|
117
|
+
* columns is also set using a `minmax` function in the `gridTemplateColumns` style prop. If a user
|
|
118
|
+
* would like to adjust this, it can be overwritten on `Table.Row`. See the example below for how to
|
|
119
|
+
* overwrite `gridTemplateColumns`.
|
|
120
|
+
*
|
|
121
|
+
*
|
|
122
|
+
* ```tsx
|
|
123
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
124
|
+
|
|
125
|
+
export default function App() {
|
|
126
|
+
return (
|
|
127
|
+
<Table>
|
|
128
|
+
<Table.Head>
|
|
129
|
+
<Table.Row gridTemplateColumns="repeat(4, minmax(100px, 1fr))">
|
|
130
|
+
<Table.Header>Table Header</Table.Header>
|
|
131
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
132
|
+
</Table.Row>
|
|
133
|
+
</Table.Head>
|
|
134
|
+
</Table>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
*/
|
|
139
|
+
Row: import("@workday/canvas-kit-react/common").ElementComponent<"tr", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").GridStyleProps>;
|
|
140
|
+
/**
|
|
141
|
+
* `Table.Header` renders a [th](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th) element.
|
|
142
|
+
*
|
|
143
|
+
*
|
|
144
|
+
* ```tsx
|
|
145
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
146
|
+
|
|
147
|
+
export default function App() {
|
|
148
|
+
return (
|
|
149
|
+
<Table>
|
|
150
|
+
<Table.Head>
|
|
151
|
+
<Table.Row>
|
|
152
|
+
<Table.Header>Table Header</Table.Header>
|
|
153
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
154
|
+
</Table.Row>
|
|
155
|
+
</Table.Head>
|
|
156
|
+
</Table>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
*/
|
|
161
|
+
Header: import("@workday/canvas-kit-react/common").ElementComponent<"th", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").GridStyleProps>;
|
|
162
|
+
/**
|
|
163
|
+
* `Table.Cell` renders a [td](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td) element.
|
|
164
|
+
*
|
|
165
|
+
*
|
|
166
|
+
* ```tsx
|
|
167
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
168
|
+
|
|
169
|
+
export default function App() {
|
|
170
|
+
return (
|
|
171
|
+
<Table>
|
|
172
|
+
<Table.Body>
|
|
173
|
+
<Table.Row>
|
|
174
|
+
<Table.Header>Table Header</Table.Header>
|
|
175
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
176
|
+
</Table.Row>
|
|
177
|
+
</Table.Body>
|
|
178
|
+
</Table>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
*/
|
|
183
|
+
Cell: import("@workday/canvas-kit-react/common").ElementComponent<"td", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").GridStyleProps>;
|
|
184
|
+
/**
|
|
185
|
+
* `Table.Footer` renders a [tfoot](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tfoot) element.
|
|
186
|
+
*
|
|
187
|
+
*
|
|
188
|
+
* ```tsx
|
|
189
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
190
|
+
|
|
191
|
+
export default function App() {
|
|
192
|
+
return (
|
|
193
|
+
<Table>
|
|
194
|
+
<Table.Footer>
|
|
195
|
+
<Table.Row>
|
|
196
|
+
<Table.Header>Table Header</Table.Header>
|
|
197
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
198
|
+
</Table.Row>
|
|
199
|
+
</Table.Footer>
|
|
200
|
+
</Table>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
*/
|
|
205
|
+
Footer: import("@workday/canvas-kit-react/common").ElementComponent<"tfoot", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").GridStyleProps>;
|
|
206
|
+
};
|
|
207
|
+
//# sourceMappingURL=Table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../table/lib/Table.tsx"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,KAAK;IAkBd;;;;;;;;;;;;;;;;;;;;;MAqBE;;IAEF;;;;;;;;;;;;;;;;;;;;MAoBE;;IAEF;;;;;;;;;;;;;;;;;;;;MAoBE;;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2BE;;IAEF;;;;;;;;;;;;;;;;;;;;MAoBE;;IAEF;;;;;;;;;;;;;;;;;;;;MAoBE;;IAEF;;;;;;;;;;;;;;;;;;;;MAoBE;;CAGJ,CAAC"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Grid } from '@workday/canvas-kit-react/layout';
|
|
3
|
+
import { type, colors } from '@workday/canvas-kit-react/tokens';
|
|
4
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
5
|
+
import { TableHead } from './TableHead';
|
|
6
|
+
import { TableBody } from './TableBody';
|
|
7
|
+
import { TableRow } from './TableRow';
|
|
8
|
+
import { TableHeader } from './TableHeader';
|
|
9
|
+
import { TableCell } from './TableCell';
|
|
10
|
+
import { TableFooter } from './TableFooter';
|
|
11
|
+
import { TableCaption } from './TableCaption';
|
|
12
|
+
/**
|
|
13
|
+
* `Table` is a simple styled compound component that renders a [table](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table) element. It is used to present information in a two-dimensional table comprised of rows and columns of cells containing data.
|
|
14
|
+
*
|
|
15
|
+
*
|
|
16
|
+
* ```tsx
|
|
17
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
18
|
+
|
|
19
|
+
export default function App() {
|
|
20
|
+
return (
|
|
21
|
+
<Table>
|
|
22
|
+
<Table.Caption>Table Caption</Table.Caption>
|
|
23
|
+
<Table.Head>
|
|
24
|
+
<Table.Row>
|
|
25
|
+
<Table.Header>Table Header</Table.Header>
|
|
26
|
+
<Table.Header>Table Header</Table.Header>
|
|
27
|
+
</Table.Row>
|
|
28
|
+
</Table.Head>
|
|
29
|
+
<Table.Body>
|
|
30
|
+
<Table.Row>
|
|
31
|
+
<Table.Header>Table Header</Table.Header>
|
|
32
|
+
<Table.Header>Table Header</Table.Header>
|
|
33
|
+
</Table.Row>
|
|
34
|
+
<Table.Row>
|
|
35
|
+
<Table.Header>Table Header</Table.Header>
|
|
36
|
+
<Table.Cell>Table Data Cell</Table.Cell>
|
|
37
|
+
</Table.Row>
|
|
38
|
+
<Table.Row>
|
|
39
|
+
<Table.Header>Table Header</Table.Header>
|
|
40
|
+
<Table.Cell>Table Data Cell</Table.Cell>
|
|
41
|
+
</Table.Row>
|
|
42
|
+
</Table.Body>
|
|
43
|
+
<Table.Footer>
|
|
44
|
+
<Table.Row>
|
|
45
|
+
<Table.Header>Table Header</Table.Header>
|
|
46
|
+
<Table.Cell>Table Data Cell</Table.Cell>
|
|
47
|
+
</Table.Row>
|
|
48
|
+
</Table.Footer>
|
|
49
|
+
</Table>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
*/
|
|
54
|
+
export const Table = createComponent('table')({
|
|
55
|
+
displayName: 'Table',
|
|
56
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
57
|
+
return (React.createElement(Grid, Object.assign({ as: Element, ref: ref, border: `1px solid ${colors.soap500}`, borderRadius: "l", overflow: "scroll" }, type.levels.subtext.large, elemProps), children));
|
|
58
|
+
},
|
|
59
|
+
subComponents: {
|
|
60
|
+
/**
|
|
61
|
+
* `Table.Caption` renders a [caption](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/caption) element.
|
|
62
|
+
*
|
|
63
|
+
*
|
|
64
|
+
* ```tsx
|
|
65
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
66
|
+
|
|
67
|
+
export default function App() {
|
|
68
|
+
return (
|
|
69
|
+
<Table>
|
|
70
|
+
<Table.Caption>Table Caption</Table.Caption>
|
|
71
|
+
<Table.Body>
|
|
72
|
+
<Table.Row>
|
|
73
|
+
<Table.Header>Table Header</Table.Header>
|
|
74
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
75
|
+
</Table.Row>
|
|
76
|
+
</Table.Body>
|
|
77
|
+
</Table>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
*/
|
|
82
|
+
Caption: TableCaption,
|
|
83
|
+
/**
|
|
84
|
+
* `Table.Head` renders a [thead](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/thead) element.
|
|
85
|
+
*
|
|
86
|
+
*
|
|
87
|
+
* ```tsx
|
|
88
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
89
|
+
|
|
90
|
+
export default function App() {
|
|
91
|
+
return (
|
|
92
|
+
<Table>
|
|
93
|
+
<Table.Head>
|
|
94
|
+
<Table.Row>
|
|
95
|
+
<Table.Header>Table Header</Table.Header>
|
|
96
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
97
|
+
</Table.Row>
|
|
98
|
+
</Table.Head>
|
|
99
|
+
</Table>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
*/
|
|
104
|
+
Head: TableHead,
|
|
105
|
+
/**
|
|
106
|
+
* `Table.Body` renders a [tbody](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tbody) element.
|
|
107
|
+
*
|
|
108
|
+
*
|
|
109
|
+
* ```tsx
|
|
110
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
111
|
+
|
|
112
|
+
export default function App() {
|
|
113
|
+
return (
|
|
114
|
+
<Table>
|
|
115
|
+
<Table.Body>
|
|
116
|
+
<Table.Row>
|
|
117
|
+
<Table.Header>Table Header</Table.Header>
|
|
118
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
119
|
+
</Table.Row>
|
|
120
|
+
</Table.Body>
|
|
121
|
+
</Table>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
*/
|
|
126
|
+
Body: TableBody,
|
|
127
|
+
/**
|
|
128
|
+
* `Table.Row` renders a [tr](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tr) element.
|
|
129
|
+
*
|
|
130
|
+
* **Note**: `Table.Row` is built on [Grid](/docs/components-layout-grid--basic). It will look for
|
|
131
|
+
* how many children are there and if those children are valid React Elements. This will adjust the
|
|
132
|
+
* amount of columns automatically using the `gridTemplateColumns` style prop and the width of the
|
|
133
|
+
* columns is also set using a `minmax` function in the `gridTemplateColumns` style prop. If a user
|
|
134
|
+
* would like to adjust this, it can be overwritten on `Table.Row`. See the example below for how to
|
|
135
|
+
* overwrite `gridTemplateColumns`.
|
|
136
|
+
*
|
|
137
|
+
*
|
|
138
|
+
* ```tsx
|
|
139
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
140
|
+
|
|
141
|
+
export default function App() {
|
|
142
|
+
return (
|
|
143
|
+
<Table>
|
|
144
|
+
<Table.Head>
|
|
145
|
+
<Table.Row gridTemplateColumns="repeat(4, minmax(100px, 1fr))">
|
|
146
|
+
<Table.Header>Table Header</Table.Header>
|
|
147
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
148
|
+
</Table.Row>
|
|
149
|
+
</Table.Head>
|
|
150
|
+
</Table>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
*/
|
|
155
|
+
Row: TableRow,
|
|
156
|
+
/**
|
|
157
|
+
* `Table.Header` renders a [th](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th) element.
|
|
158
|
+
*
|
|
159
|
+
*
|
|
160
|
+
* ```tsx
|
|
161
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
162
|
+
|
|
163
|
+
export default function App() {
|
|
164
|
+
return (
|
|
165
|
+
<Table>
|
|
166
|
+
<Table.Head>
|
|
167
|
+
<Table.Row>
|
|
168
|
+
<Table.Header>Table Header</Table.Header>
|
|
169
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
170
|
+
</Table.Row>
|
|
171
|
+
</Table.Head>
|
|
172
|
+
</Table>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
*/
|
|
177
|
+
Header: TableHeader,
|
|
178
|
+
/**
|
|
179
|
+
* `Table.Cell` renders a [td](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td) element.
|
|
180
|
+
*
|
|
181
|
+
*
|
|
182
|
+
* ```tsx
|
|
183
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
184
|
+
|
|
185
|
+
export default function App() {
|
|
186
|
+
return (
|
|
187
|
+
<Table>
|
|
188
|
+
<Table.Body>
|
|
189
|
+
<Table.Row>
|
|
190
|
+
<Table.Header>Table Header</Table.Header>
|
|
191
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
192
|
+
</Table.Row>
|
|
193
|
+
</Table.Body>
|
|
194
|
+
</Table>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
*/
|
|
199
|
+
Cell: TableCell,
|
|
200
|
+
/**
|
|
201
|
+
* `Table.Footer` renders a [tfoot](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tfoot) element.
|
|
202
|
+
*
|
|
203
|
+
*
|
|
204
|
+
* ```tsx
|
|
205
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
206
|
+
|
|
207
|
+
export default function App() {
|
|
208
|
+
return (
|
|
209
|
+
<Table>
|
|
210
|
+
<Table.Footer>
|
|
211
|
+
<Table.Row>
|
|
212
|
+
<Table.Header>Table Header</Table.Header>
|
|
213
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
214
|
+
</Table.Row>
|
|
215
|
+
</Table.Footer>
|
|
216
|
+
</Table>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
*/
|
|
221
|
+
Footer: TableFooter,
|
|
222
|
+
},
|
|
223
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableBody.d.ts","sourceRoot":"","sources":["../../../../table/lib/TableBody.tsx"],"names":[],"mappings":"AAyBA,eAAO,MAAM,SAAS,wMASpB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Grid } from '@workday/canvas-kit-react/layout';
|
|
3
|
+
import { createComponent, styled } from '@workday/canvas-kit-react/common';
|
|
4
|
+
const StyledBody = styled(Grid.as('tbody'))({
|
|
5
|
+
'tr:last-of-type td': {
|
|
6
|
+
borderBottom: 'none',
|
|
7
|
+
},
|
|
8
|
+
'tr:last-of-type th': {
|
|
9
|
+
borderBottom: 'none',
|
|
10
|
+
},
|
|
11
|
+
'tr:first-of-type td': {
|
|
12
|
+
borderTop: 'none',
|
|
13
|
+
},
|
|
14
|
+
'tr:first-of-type th': {
|
|
15
|
+
borderTop: 'none',
|
|
16
|
+
},
|
|
17
|
+
'td:last-of-type': {
|
|
18
|
+
borderRight: 'none',
|
|
19
|
+
},
|
|
20
|
+
'td:first-of-type': {
|
|
21
|
+
borderLeft: 'none',
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
export const TableBody = createComponent('tbody')({
|
|
25
|
+
displayName: 'Table.Body',
|
|
26
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
27
|
+
return (React.createElement(StyledBody, Object.assign({ as: Element, ref: ref }, elemProps), children));
|
|
28
|
+
},
|
|
29
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const TableCaption: import("@workday/canvas-kit-react/common").ElementComponent<"caption", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").FlexStyleProps>;
|
|
2
|
+
//# sourceMappingURL=TableCaption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableCaption.d.ts","sourceRoot":"","sources":["../../../../table/lib/TableCaption.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY,0MAgBvB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { colors } from '@workday/canvas-kit-react/tokens';
|
|
3
|
+
import { Flex } from '@workday/canvas-kit-react/layout';
|
|
4
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
5
|
+
export const TableCaption = createComponent('caption')({
|
|
6
|
+
displayName: 'Table.Caption',
|
|
7
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
8
|
+
return (React.createElement(Flex, Object.assign({ as: Element, ref: ref, borderBottom: `1px solid ${colors.soap500}`, paddingY: "xxs", paddingX: "s" }, elemProps), children));
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableCell.d.ts","sourceRoot":"","sources":["../../../../table/lib/TableCell.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS,qMAqBpB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Grid } from '@workday/canvas-kit-react/layout';
|
|
3
|
+
import { colors } from '@workday/canvas-kit-react/tokens';
|
|
4
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
5
|
+
export const TableCell = createComponent('td')({
|
|
6
|
+
displayName: 'Table.Cell',
|
|
7
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
8
|
+
return (React.createElement(Grid, Object.assign({ as: Element, ref: ref, alignItems: "center", backgroundColor: "frenchVanilla100", borderBottom: `1px solid ${colors.soap400}`, justifyContent: "left", minHeight: "56px", paddingY: "xxs", paddingX: "s", wordBreak: "break-word" }, elemProps), children));
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableFooter.d.ts","sourceRoot":"","sources":["../../../../table/lib/TableFooter.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,wMAStB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Grid } from '@workday/canvas-kit-react/layout';
|
|
3
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
4
|
+
export const TableFooter = createComponent('tfoot')({
|
|
5
|
+
displayName: 'Table.Footer',
|
|
6
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
7
|
+
return (React.createElement(Grid, Object.assign({ as: Element, ref: ref }, elemProps), children));
|
|
8
|
+
},
|
|
9
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableHead.d.ts","sourceRoot":"","sources":["../../../../table/lib/TableHead.tsx"],"names":[],"mappings":"AAaA,eAAO,MAAM,SAAS,wMASpB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Grid } from '@workday/canvas-kit-react/layout';
|
|
3
|
+
import { createComponent, styled } from '@workday/canvas-kit-react/common';
|
|
4
|
+
const StyledHead = styled(Grid.as('thead'))({
|
|
5
|
+
'th:last-of-type': {
|
|
6
|
+
borderRight: 'none',
|
|
7
|
+
},
|
|
8
|
+
'th:first-of-type': {
|
|
9
|
+
borderLeft: 'none',
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
export const TableHead = createComponent('thead')({
|
|
13
|
+
displayName: 'Table.Head',
|
|
14
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
15
|
+
return (React.createElement(StyledHead, Object.assign({ as: Element, ref: ref, backgroundColor: "soap100", minHeight: "48px" }, elemProps), children));
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableHeader.d.ts","sourceRoot":"","sources":["../../../../table/lib/TableHeader.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW,qMAsBtB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Grid } from '@workday/canvas-kit-react/layout';
|
|
3
|
+
import { colors } from '@workday/canvas-kit-react/tokens';
|
|
4
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
5
|
+
export const TableHeader = createComponent('th')({
|
|
6
|
+
displayName: 'Table.Header',
|
|
7
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
8
|
+
return (React.createElement(Grid, Object.assign({ as: Element, ref: ref, alignItems: "center", backgroundColor: "frenchVanilla100", borderBottom: `1px solid ${colors.soap400}`, justifyContent: "left", minHeight: "56px", paddingY: "xxs", paddingX: "s", wordBreak: "break-word", fontWeight: "medium" }, elemProps), children));
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableRow.d.ts","sourceRoot":"","sources":["../../../../table/lib/TableRow.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ,qMAqBnB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Grid } from '@workday/canvas-kit-react/layout';
|
|
3
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
4
|
+
export const TableRow = createComponent('tr')({
|
|
5
|
+
displayName: 'Table.Row',
|
|
6
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
7
|
+
const validChildren = (children) => {
|
|
8
|
+
return React.Children.toArray(children).filter(child => React.isValidElement(child));
|
|
9
|
+
};
|
|
10
|
+
const childrenArray = validChildren(children).length;
|
|
11
|
+
return (React.createElement(Grid, Object.assign({ as: Element, ref: ref, gridAutoFlow: "column", gridTemplateColumns: `repeat(${childrenArray}, minmax(10rem, 1fr))` }, elemProps), children));
|
|
12
|
+
},
|
|
13
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-preview-react",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.385-next.4+399695e0",
|
|
4
4
|
"description": "Canvas Kit Preview is made up of components that have the full design and a11y review, are part of the DS ecosystem and are approved for use in product. The API's could be subject to change, but not without strong communication and migration strategies.",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@emotion/react": "^11.7.1",
|
|
48
48
|
"@emotion/styled": "^11.6.0",
|
|
49
|
-
"@workday/canvas-kit-react": "^9.0.0-alpha.
|
|
49
|
+
"@workday/canvas-kit-react": "^9.0.0-alpha.385-next.4+399695e0",
|
|
50
50
|
"@workday/canvas-system-icons-web": "^3.0.0",
|
|
51
51
|
"@workday/design-assets-types": "^0.2.8"
|
|
52
52
|
},
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"react-hook-form": "7.36.1",
|
|
57
57
|
"yup": "^0.32.11"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "399695e0108fa563e49cae17ecde059a7de58890"
|
|
60
60
|
}
|