@workday/canvas-kit-react 11.0.0-alpha.707-next.0 → 11.0.0-alpha.708-next.0
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 +0 -1
- package/dist/commonjs/table/index.d.ts.map +1 -1
- package/dist/commonjs/table/index.js +0 -1
- package/dist/commonjs/table/lib/Table.d.ts +204 -8
- package/dist/commonjs/table/lib/Table.d.ts.map +1 -1
- package/dist/commonjs/table/lib/Table.js +226 -43
- 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 +19 -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 +20 -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 +20 -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 +19 -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 +20 -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 +20 -0
- package/dist/commonjs/table/lib/TableRow.d.ts +1 -33
- package/dist/commonjs/table/lib/TableRow.d.ts.map +1 -1
- package/dist/commonjs/table/lib/TableRow.js +20 -197
- package/dist/es6/table/index.d.ts +0 -1
- package/dist/es6/table/index.d.ts.map +1 -1
- package/dist/es6/table/index.js +0 -1
- package/dist/es6/table/lib/Table.d.ts +204 -8
- package/dist/es6/table/lib/Table.d.ts.map +1 -1
- package/dist/es6/table/lib/Table.js +225 -22
- 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 +13 -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 +14 -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 +14 -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 +13 -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 +14 -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 +14 -0
- package/dist/es6/table/lib/TableRow.d.ts +1 -33
- package/dist/es6/table/lib/TableRow.d.ts.map +1 -1
- package/dist/es6/table/lib/TableRow.js +19 -177
- package/package.json +4 -5
- package/table/LICENSE +51 -0
- package/table/index.ts +0 -1
- package/table/lib/Table.tsx +235 -22
- package/table/lib/TableBody.tsx +42 -0
- package/table/lib/TableCaption.tsx +25 -0
- package/table/lib/TableCell.tsx +31 -0
- package/table/lib/TableFooter.tsx +22 -0
- package/table/lib/TableHead.tsx +33 -0
- package/table/lib/TableHeader.tsx +31 -0
- package/table/lib/TableRow.tsx +33 -212
|
@@ -1,24 +1,227 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mergeStyles } from '@workday/canvas-kit-react/layout';
|
|
3
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
4
|
+
import { TableHead } from './TableHead';
|
|
5
|
+
import { TableBody } from './TableBody';
|
|
6
|
+
import { TableRow } from './TableRow';
|
|
7
|
+
import { TableHeader } from './TableHeader';
|
|
8
|
+
import { TableCell } from './TableCell';
|
|
9
|
+
import { TableFooter } from './TableFooter';
|
|
10
|
+
import { TableCaption } from './TableCaption';
|
|
11
|
+
import { createStencil, px2rem } from '@workday/canvas-kit-styling';
|
|
12
|
+
import { base, system } from '@workday/canvas-tokens-web';
|
|
13
|
+
const tableStencil = createStencil({
|
|
14
|
+
base: { name: "1jt00fi", styles: "font-family:var(--cnvs-base-font-family-50, \"Roboto\");font-weight:var(--cnvs-base-font-weight-400, 400);line-height:var(--cnvs-base-line-height-100, 1.25rem);font-size:var(--cnvs-base-font-size-75, 0.875rem);letter-spacing:var(--cnvs-base-letter-spacing-150, 0.015rem);display:grid;border:0.0625rem solid var(--cnvs-base-palette-soap-500, rgba(206,211,217,1));border-radius:var(--cnvs-sys-shape-x2, calc(0.25rem * 2));overflow:auto;color:var(--cnvs-base-palette-black-pepper-300, rgba(73,73,73,1));box-sizing:border-box;" }
|
|
15
|
+
}, "table");
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
* `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.
|
|
18
|
+
*
|
|
19
|
+
*
|
|
20
|
+
* ```tsx
|
|
21
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
22
|
+
|
|
23
|
+
export default function App() {
|
|
24
|
+
return (
|
|
25
|
+
<Table>
|
|
26
|
+
<Table.Caption>Table Caption</Table.Caption>
|
|
27
|
+
<Table.Head>
|
|
28
|
+
<Table.Row>
|
|
29
|
+
<Table.Header>Table Header</Table.Header>
|
|
30
|
+
<Table.Header>Table Header</Table.Header>
|
|
31
|
+
</Table.Row>
|
|
32
|
+
</Table.Head>
|
|
33
|
+
<Table.Body>
|
|
34
|
+
<Table.Row>
|
|
35
|
+
<Table.Header>Table Header</Table.Header>
|
|
36
|
+
<Table.Header>Table Header</Table.Header>
|
|
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.Row>
|
|
43
|
+
<Table.Header>Table Header</Table.Header>
|
|
44
|
+
<Table.Cell>Table Data Cell</Table.Cell>
|
|
45
|
+
</Table.Row>
|
|
46
|
+
</Table.Body>
|
|
47
|
+
<Table.Footer>
|
|
48
|
+
<Table.Row>
|
|
49
|
+
<Table.Header>Table Header</Table.Header>
|
|
50
|
+
<Table.Cell>Table Data Cell</Table.Cell>
|
|
51
|
+
</Table.Row>
|
|
52
|
+
</Table.Footer>
|
|
53
|
+
</Table>
|
|
54
|
+
);
|
|
24
55
|
}
|
|
56
|
+
```
|
|
57
|
+
*/
|
|
58
|
+
export const Table = createComponent('table')({
|
|
59
|
+
displayName: 'Table',
|
|
60
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
61
|
+
return (React.createElement(Element, Object.assign({ ref: ref }, mergeStyles(elemProps, tableStencil())), children));
|
|
62
|
+
},
|
|
63
|
+
subComponents: {
|
|
64
|
+
/**
|
|
65
|
+
* `Table.Caption` renders a [caption](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/caption) element.
|
|
66
|
+
*
|
|
67
|
+
*
|
|
68
|
+
* ```tsx
|
|
69
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
70
|
+
|
|
71
|
+
export default function App() {
|
|
72
|
+
return (
|
|
73
|
+
<Table>
|
|
74
|
+
<Table.Caption>Table Caption</Table.Caption>
|
|
75
|
+
<Table.Body>
|
|
76
|
+
<Table.Row>
|
|
77
|
+
<Table.Header>Table Header</Table.Header>
|
|
78
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
79
|
+
</Table.Row>
|
|
80
|
+
</Table.Body>
|
|
81
|
+
</Table>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
*/
|
|
86
|
+
Caption: TableCaption,
|
|
87
|
+
/**
|
|
88
|
+
* `Table.Head` renders a [thead](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/thead) element.
|
|
89
|
+
*
|
|
90
|
+
*
|
|
91
|
+
* ```tsx
|
|
92
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
93
|
+
|
|
94
|
+
export default function App() {
|
|
95
|
+
return (
|
|
96
|
+
<Table>
|
|
97
|
+
<Table.Head>
|
|
98
|
+
<Table.Row>
|
|
99
|
+
<Table.Header>Table Header</Table.Header>
|
|
100
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
101
|
+
</Table.Row>
|
|
102
|
+
</Table.Head>
|
|
103
|
+
</Table>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
*/
|
|
108
|
+
Head: TableHead,
|
|
109
|
+
/**
|
|
110
|
+
* `Table.Body` renders a [tbody](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tbody) element.
|
|
111
|
+
*
|
|
112
|
+
*
|
|
113
|
+
* ```tsx
|
|
114
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
115
|
+
|
|
116
|
+
export default function App() {
|
|
117
|
+
return (
|
|
118
|
+
<Table>
|
|
119
|
+
<Table.Body>
|
|
120
|
+
<Table.Row>
|
|
121
|
+
<Table.Header>Table Header</Table.Header>
|
|
122
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
123
|
+
</Table.Row>
|
|
124
|
+
</Table.Body>
|
|
125
|
+
</Table>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
*/
|
|
130
|
+
Body: TableBody,
|
|
131
|
+
/**
|
|
132
|
+
* `Table.Row` renders a [tr](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tr) element.
|
|
133
|
+
*
|
|
134
|
+
* **Note**: `Table.Row` is built on [Grid](/docs/components-layout-grid--basic). It will look for
|
|
135
|
+
* how many children are there and if those children are valid React Elements. This will adjust the
|
|
136
|
+
* amount of columns automatically using the `gridTemplateColumns` style prop and the width of the
|
|
137
|
+
* columns is also set using a `minmax` function in the `gridTemplateColumns` style prop. If a user
|
|
138
|
+
* would like to adjust this, it can be overwritten on `Table.Row`. See the example below for how to
|
|
139
|
+
* overwrite `gridTemplateColumns`.
|
|
140
|
+
*
|
|
141
|
+
*
|
|
142
|
+
* ```tsx
|
|
143
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
144
|
+
|
|
145
|
+
export default function App() {
|
|
146
|
+
return (
|
|
147
|
+
<Table>
|
|
148
|
+
<Table.Head>
|
|
149
|
+
<Table.Row gridTemplateColumns="repeat(4, minmax(100px, 1fr))">
|
|
150
|
+
<Table.Header>Table Header</Table.Header>
|
|
151
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
152
|
+
</Table.Row>
|
|
153
|
+
</Table.Head>
|
|
154
|
+
</Table>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
*/
|
|
159
|
+
Row: TableRow,
|
|
160
|
+
/**
|
|
161
|
+
* `Table.Header` renders a [th](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th) element.
|
|
162
|
+
*
|
|
163
|
+
*
|
|
164
|
+
* ```tsx
|
|
165
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
166
|
+
|
|
167
|
+
export default function App() {
|
|
168
|
+
return (
|
|
169
|
+
<Table>
|
|
170
|
+
<Table.Head>
|
|
171
|
+
<Table.Row>
|
|
172
|
+
<Table.Header>Table Header</Table.Header>
|
|
173
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
174
|
+
</Table.Row>
|
|
175
|
+
</Table.Head>
|
|
176
|
+
</Table>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
*/
|
|
181
|
+
Header: TableHeader,
|
|
182
|
+
/**
|
|
183
|
+
* `Table.Cell` renders a [td](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td) element.
|
|
184
|
+
*
|
|
185
|
+
*
|
|
186
|
+
* ```tsx
|
|
187
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
188
|
+
|
|
189
|
+
export default function App() {
|
|
190
|
+
return (
|
|
191
|
+
<Table>
|
|
192
|
+
<Table.Body>
|
|
193
|
+
<Table.Row>
|
|
194
|
+
<Table.Header>Table Header</Table.Header>
|
|
195
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
196
|
+
</Table.Row>
|
|
197
|
+
</Table.Body>
|
|
198
|
+
</Table>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
*/
|
|
203
|
+
Cell: TableCell,
|
|
204
|
+
/**
|
|
205
|
+
* `Table.Footer` renders a [tfoot](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tfoot) element.
|
|
206
|
+
*
|
|
207
|
+
*
|
|
208
|
+
* ```tsx
|
|
209
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
210
|
+
|
|
211
|
+
export default function App() {
|
|
212
|
+
return (
|
|
213
|
+
<Table>
|
|
214
|
+
<Table.Footer>
|
|
215
|
+
<Table.Row>
|
|
216
|
+
<Table.Header>Table Header</Table.Header>
|
|
217
|
+
<Table.Cell>Table Cell</Table.Cell>
|
|
218
|
+
</Table.Row>
|
|
219
|
+
</Table.Footer>
|
|
220
|
+
</Table>
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
*/
|
|
225
|
+
Footer: TableFooter,
|
|
226
|
+
},
|
|
227
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableBody.d.ts","sourceRoot":"","sources":["../../../../table/lib/TableBody.tsx"],"names":[],"mappings":"AAgCA,eAAO,MAAM,SAAS,wMASpB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mergeStyles } from '@workday/canvas-kit-react/layout';
|
|
3
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
4
|
+
import { createStencil } from '@workday/canvas-kit-styling';
|
|
5
|
+
const tableBodyStencil = createStencil({
|
|
6
|
+
base: { name: "1aq46he", styles: "display:grid;box-sizing:border-box;tr {&:last-of-type{td, th{border-bottom:none;}}&:first-of-type{td, th{border-top:none;}}}td {&:last-of-type{border-inline-end:none;}&:first-of-type{border-inline-start:none;}}" }
|
|
7
|
+
}, "table-body");
|
|
8
|
+
export const TableBody = createComponent('tbody')({
|
|
9
|
+
displayName: 'Table.Body',
|
|
10
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
11
|
+
return (React.createElement(Element, Object.assign({ ref: ref }, mergeStyles(elemProps, tableBodyStencil())), children));
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -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":"AAeA,eAAO,MAAM,YAAY,0MASvB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mergeStyles } from '@workday/canvas-kit-react/layout';
|
|
3
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
4
|
+
import { createStencil, px2rem } from '@workday/canvas-kit-styling';
|
|
5
|
+
import { base, system } from '@workday/canvas-tokens-web';
|
|
6
|
+
const tableCaptionStencil = createStencil({
|
|
7
|
+
base: { name: "mnuok4", styles: "display:flex;border-bottom:0.0625rem solid var(--cnvs-base-palette-soap-500, rgba(206,211,217,1));padding:var(--cnvs-sys-space-x2, calc(0.25rem * 2)) var(--cnvs-sys-space-x4, calc(0.25rem * 4));box-sizing:border-box;" }
|
|
8
|
+
}, "table-caption");
|
|
9
|
+
export const TableCaption = createComponent('caption')({
|
|
10
|
+
displayName: 'Table.Caption',
|
|
11
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
12
|
+
return (React.createElement(Element, Object.assign({ ref: ref }, mergeStyles(elemProps, tableCaptionStencil())), children));
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableCell.d.ts","sourceRoot":"","sources":["../../../../table/lib/TableCell.tsx"],"names":[],"mappings":"AAqBA,eAAO,MAAM,SAAS,qMASpB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mergeStyles } from '@workday/canvas-kit-react/layout';
|
|
3
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
4
|
+
import { createStencil, px2rem } from '@workday/canvas-kit-styling';
|
|
5
|
+
import { base, system } from '@workday/canvas-tokens-web';
|
|
6
|
+
const tableCellStencil = createStencil({
|
|
7
|
+
base: { name: "iww62y", styles: "display:grid;align-items:center;background-color:var(--cnvs-base-palette-french-vanilla-100, rgba(255,255,255,1));border-bottom:0.0625rem solid var(--cnvs-base-palette-soap-400, rgba(223,226,230,1));grid-template-columns:1fr;justify-content:start;min-height:3.5rem;padding:var(--cnvs-sys-space-x2, calc(0.25rem * 2)) var(--cnvs-sys-space-x4, calc(0.25rem * 4));word-break:break-word;box-sizing:border-box;" }
|
|
8
|
+
}, "table-cell");
|
|
9
|
+
export const TableCell = createComponent('td')({
|
|
10
|
+
displayName: 'Table.Cell',
|
|
11
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
12
|
+
return (React.createElement(Element, Object.assign({ ref: ref }, mergeStyles(elemProps, tableCellStencil())), children));
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableFooter.d.ts","sourceRoot":"","sources":["../../../../table/lib/TableFooter.tsx"],"names":[],"mappings":"AAYA,eAAO,MAAM,WAAW,wMAStB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mergeStyles } from '@workday/canvas-kit-react/layout';
|
|
3
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
4
|
+
import { createStencil } from '@workday/canvas-kit-styling';
|
|
5
|
+
const tableFooterStencil = createStencil({
|
|
6
|
+
base: { name: "197vc7s", styles: "display:grid;box-sizing:border-box;" }
|
|
7
|
+
}, "table-footer");
|
|
8
|
+
export const TableFooter = createComponent('tfoot')({
|
|
9
|
+
displayName: 'Table.Footer',
|
|
10
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
11
|
+
return (React.createElement(Element, Object.assign({ ref: ref }, mergeStyles(elemProps, tableFooterStencil())), children));
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableHead.d.ts","sourceRoot":"","sources":["../../../../table/lib/TableHead.tsx"],"names":[],"mappings":"AAuBA,eAAO,MAAM,SAAS,wMASpB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mergeStyles } from '@workday/canvas-kit-react/layout';
|
|
3
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
4
|
+
import { createStencil } from '@workday/canvas-kit-styling';
|
|
5
|
+
import { base } from '@workday/canvas-tokens-web';
|
|
6
|
+
const tableHeadStencil = createStencil({
|
|
7
|
+
base: { name: "sv3y8l", styles: "display:grid;background-color:var(--cnvs-base-palette-soap-100, rgba(246,247,248,1));min-height:3rem;box-sizing:border-box;th {&:first-of-type{border-inline-start:none;}&:last-of-type{border-inline-end:none;}}" }
|
|
8
|
+
}, "table-head");
|
|
9
|
+
export const TableHead = createComponent('thead')({
|
|
10
|
+
displayName: 'Table.Head',
|
|
11
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
12
|
+
return (React.createElement(Element, Object.assign({ ref: ref }, mergeStyles(elemProps, tableHeadStencil())), children));
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableHeader.d.ts","sourceRoot":"","sources":["../../../../table/lib/TableHeader.tsx"],"names":[],"mappings":"AAqBA,eAAO,MAAM,WAAW,qMAStB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mergeStyles } from '@workday/canvas-kit-react/layout';
|
|
3
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
4
|
+
import { createStencil, px2rem } from '@workday/canvas-kit-styling';
|
|
5
|
+
import { base, system } from '@workday/canvas-tokens-web';
|
|
6
|
+
const tableHeaderStencil = createStencil({
|
|
7
|
+
base: { name: "mt03mc", styles: "display:grid;align-items:center;background-color:var(--cnvs-base-palette-french-vanilla-100, rgba(255,255,255,1));border-bottom:0.0625rem solid var(--cnvs-base-palette-soap-400, rgba(223,226,230,1));justify-content:start;min-height:3.5rem;padding:var(--cnvs-sys-space-x2, calc(0.25rem * 2)) var(--cnvs-sys-space-x4, calc(0.25rem * 4));word-break:break-word;font-weight:var(--cnvs-sys-font-weight-medium, 500);box-sizing:border-box;" }
|
|
8
|
+
}, "table-header");
|
|
9
|
+
export const TableHeader = createComponent('th')({
|
|
10
|
+
displayName: 'Table.Header',
|
|
11
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
12
|
+
return (React.createElement(Element, Object.assign({ ref: ref }, mergeStyles(elemProps, tableHeaderStencil())), children));
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -1,34 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { StyledType } from '@workday/canvas-kit-react/common';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated ⚠️ `Table` has been deprecated and will be removed in a future major version. Please use [`Table`](https://workday.github.io/canvas-kit/?path=/docs/preview-table--basic) in Preview instead.
|
|
5
|
-
*/
|
|
6
|
-
export declare enum TableRowState {
|
|
7
|
-
Error = 0,
|
|
8
|
-
Alert = 1,
|
|
9
|
-
InputError = 2,
|
|
10
|
-
InputAlert = 3,
|
|
11
|
-
Hover = 4,
|
|
12
|
-
Selected = 5
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated ⚠️ `Table` has been deprecated and will be removed in a future major version. Please use [`Table`](https://workday.github.io/canvas-kit/?path=/docs/preview-table--basic) in Preview instead.
|
|
16
|
-
*/
|
|
17
|
-
export interface TableRowProps extends React.HTMLAttributes<HTMLTableRowElement> {
|
|
18
|
-
/**
|
|
19
|
-
* The state of the TableRow. Accepts `Error`, `Alert`, `InputError`, `InputAlert`, `Hover`, or `Selected`.
|
|
20
|
-
*/
|
|
21
|
-
state?: TableRowState;
|
|
22
|
-
/**
|
|
23
|
-
* If true, render the TableRow with header elements.
|
|
24
|
-
* @default false
|
|
25
|
-
*/
|
|
26
|
-
header?: boolean;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated ⚠️ `Table` has been deprecated and will be removed in a future major version. Please use [`Table`](https://workday.github.io/canvas-kit/?path=/docs/preview-table--basic) in Preview instead.
|
|
30
|
-
*/
|
|
31
|
-
export declare const TableRow: import("@workday/canvas-kit-react/common").ElementComponent<"tr", TableRowProps & StyledType> & {
|
|
32
|
-
State: typeof TableRowState;
|
|
33
|
-
};
|
|
1
|
+
export declare const TableRow: import("@workday/canvas-kit-react/common").ElementComponent<"tr", Omit<import("@workday/canvas-kit-react/layout").BoxProps, "display"> & import("@workday/canvas-kit-react/layout").GridStyleProps>;
|
|
34
2
|
//# sourceMappingURL=TableRow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableRow.d.ts","sourceRoot":"","sources":["../../../../table/lib/TableRow.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TableRow.d.ts","sourceRoot":"","sources":["../../../../table/lib/TableRow.tsx"],"names":[],"mappings":"AAiBA,eAAO,MAAM,QAAQ,qMAuBnB,CAAC"}
|
|
@@ -1,181 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { rgba } from 'polished';
|
|
4
|
-
import { colors, space, statusColors } from '@workday/canvas-kit-react/tokens';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mergeStyles } from '@workday/canvas-kit-react/layout';
|
|
5
3
|
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
TableRowState[TableRowState["Error"] = 0] = "Error";
|
|
13
|
-
TableRowState[TableRowState["Alert"] = 1] = "Alert";
|
|
14
|
-
TableRowState[TableRowState["InputError"] = 2] = "InputError";
|
|
15
|
-
TableRowState[TableRowState["InputAlert"] = 3] = "InputAlert";
|
|
16
|
-
TableRowState[TableRowState["Hover"] = 4] = "Hover";
|
|
17
|
-
TableRowState[TableRowState["Selected"] = 5] = "Selected";
|
|
18
|
-
})(TableRowState || (TableRowState = {}));
|
|
19
|
-
const errorColor = statusColors.error;
|
|
20
|
-
const errorColorLight = colors.cinnamon200;
|
|
21
|
-
const alertColor = statusColors.warning;
|
|
22
|
-
const alertColorLight = colors.cantaloupe200;
|
|
23
|
-
function makeColoredRow(_bgColor, _borderColor) {
|
|
24
|
-
return {
|
|
25
|
-
backgroundColor: _bgColor,
|
|
26
|
-
position: 'relative',
|
|
27
|
-
// Bottom border
|
|
28
|
-
'&:before, &:after': {
|
|
29
|
-
position: 'absolute',
|
|
30
|
-
left: 0,
|
|
31
|
-
top: -borderWidth,
|
|
32
|
-
content: '""',
|
|
33
|
-
width: `calc(100% + ${borderWidth}px)`,
|
|
34
|
-
height: borderWidth,
|
|
35
|
-
backgroundColor: _borderColor,
|
|
36
|
-
},
|
|
37
|
-
'&:after': {
|
|
38
|
-
top: 'auto',
|
|
39
|
-
bottom: -borderWidth,
|
|
40
|
-
},
|
|
41
|
-
'&:first-of-type': {
|
|
42
|
-
boxShadow: `inset ${borderWidth}px 0 0 ${_borderColor}`,
|
|
43
|
-
},
|
|
44
|
-
'&:last-child': {
|
|
45
|
-
boxShadow: `inset -${borderWidth}px 0 0 ${_borderColor}`,
|
|
46
|
-
'&:before, &:after': {
|
|
47
|
-
width: '100%',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function makeColoredRowStyle(_bgColor, _borderColor) {
|
|
53
|
-
const lightenedBg = rgba(_bgColor, 0.2);
|
|
54
|
-
return {
|
|
55
|
-
'th, td': [
|
|
56
|
-
makeColoredRow(lightenedBg, _bgColor),
|
|
57
|
-
{
|
|
58
|
-
borderLeftColor: _borderColor,
|
|
59
|
-
borderRightColor: _borderColor,
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
'&:hover': {
|
|
63
|
-
'th, td': {
|
|
64
|
-
backgroundColor: lightenedBg,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
function makeBorderlessStyle(_bgColor) {
|
|
70
|
-
return {
|
|
71
|
-
'th, td': {
|
|
72
|
-
backgroundColor: rgba(_bgColor, 0.2),
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
const StyledTableRow = styled('tr')({
|
|
77
|
-
'th, td': {
|
|
78
|
-
backgroundColor: colors.frenchVanilla100,
|
|
79
|
-
padding: `${space.xs} ${space.xxs}`,
|
|
80
|
-
fontSize: 13,
|
|
81
|
-
borderRight: cellBorder,
|
|
82
|
-
borderBottom: cellBorder,
|
|
83
|
-
height: `calc(${space.xl} + ${space.xxs})`,
|
|
84
|
-
boxSizing: 'border-box',
|
|
85
|
-
transition: 'background-color 0.2s',
|
|
86
|
-
},
|
|
87
|
-
td: {
|
|
88
|
-
'&:last-child': {
|
|
89
|
-
borderRight: 'none',
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
th: {
|
|
93
|
-
height: space.xxl,
|
|
94
|
-
'&:last-child': {
|
|
95
|
-
borderRight: 'none',
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
'&:last-child': {
|
|
99
|
-
'th, td': {
|
|
100
|
-
borderBottom: 'none',
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
}, ({ header }) => header && {
|
|
104
|
-
'&:last-child': {
|
|
105
|
-
'th, td': {
|
|
106
|
-
borderBottom: '1px solid transparent',
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
'th, td': {
|
|
110
|
-
position: 'relative',
|
|
111
|
-
backgroundColor: colors.frenchVanilla100,
|
|
112
|
-
verticalAlign: 'middle',
|
|
113
|
-
'&:after': {
|
|
114
|
-
position: 'absolute',
|
|
115
|
-
left: 0,
|
|
116
|
-
bottom: -borderWidth,
|
|
117
|
-
content: '""',
|
|
118
|
-
width: `calc(100% + ${borderWidth}px)`,
|
|
119
|
-
height: borderWidth,
|
|
120
|
-
backgroundColor: borderColor,
|
|
121
|
-
},
|
|
122
|
-
'&:last-child': {
|
|
123
|
-
'&:after': {
|
|
124
|
-
width: '100%',
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
}, ({ state }) => {
|
|
129
|
-
switch (state) {
|
|
130
|
-
case TableRowState.InputError:
|
|
131
|
-
return makeBorderlessStyle(errorColor);
|
|
132
|
-
case TableRowState.Error:
|
|
133
|
-
return makeColoredRowStyle(errorColor, errorColorLight);
|
|
134
|
-
case TableRowState.InputAlert:
|
|
135
|
-
return makeBorderlessStyle(alertColor);
|
|
136
|
-
case TableRowState.Alert:
|
|
137
|
-
return makeColoredRowStyle(alertColor, alertColorLight);
|
|
138
|
-
case TableRowState.Selected:
|
|
139
|
-
return {
|
|
140
|
-
'th, td': [
|
|
141
|
-
makeColoredRow(colors.blueberry100, colors.blueberry500),
|
|
142
|
-
{
|
|
143
|
-
'&:after': {
|
|
144
|
-
zIndex: 2,
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
};
|
|
149
|
-
default:
|
|
150
|
-
return {
|
|
151
|
-
'&:hover': {
|
|
152
|
-
'th, td': {
|
|
153
|
-
backgroundColor: colors.soap300,
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
'&:focus': {
|
|
157
|
-
outline: 'none',
|
|
158
|
-
'th, td': [
|
|
159
|
-
makeColoredRow(colors.blueberry100, colors.blueberry500),
|
|
160
|
-
{
|
|
161
|
-
'&:after': {
|
|
162
|
-
zIndex: 2,
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
],
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
/**
|
|
171
|
-
* @deprecated ⚠️ `Table` has been deprecated and will be removed in a future major version. Please use [`Table`](https://workday.github.io/canvas-kit/?path=/docs/preview-table--basic) in Preview instead.
|
|
172
|
-
*/
|
|
4
|
+
import { createStencil, createVars } from '@workday/canvas-kit-styling';
|
|
5
|
+
const childrenVars = createVars({ id: "cnvs-children", args: ["cellNumber"] });
|
|
6
|
+
// Styles for rows including dynamic sizing for amount of cells within a row
|
|
7
|
+
const tableRowStencil = createStencil({
|
|
8
|
+
base: { name: "s9e95c", styles: "display:grid;grid-auto-flow:column;grid-template-columns:repeat(var(--cnvs-children-cellNumber), minmax(10rem, 1fr));box-sizing:border-box;" }
|
|
9
|
+
}, "table-row");
|
|
173
10
|
export const TableRow = createComponent('tr')({
|
|
174
|
-
displayName: '
|
|
175
|
-
Component: ({
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
11
|
+
displayName: 'Table.Row',
|
|
12
|
+
Component: ({ children, ...elemProps }, ref, Element) => {
|
|
13
|
+
// This calculates the amount of valid React children cells within the row and will update the gridTemplateColumns style property with that amount of cells within the row
|
|
14
|
+
const validChildren = (children) => {
|
|
15
|
+
return React.Children.toArray(children).filter(child => React.isValidElement(child));
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* This is the calculated amount of valid React children
|
|
19
|
+
*/
|
|
20
|
+
const childrenArray = validChildren(children).length;
|
|
21
|
+
return (React.createElement(Element, Object.assign({ ref: ref }, mergeStyles(elemProps, [tableRowStencil(), { [childrenVars.cellNumber]: childrenArray }])), children));
|
|
180
22
|
},
|
|
181
23
|
});
|