@workday/canvas-kit-docs 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/es6/lib/Specifications.d.ts.map +1 -1
- package/dist/es6/lib/Specifications.js +12 -12
- package/dist/es6/lib/docs.js +772 -1077
- package/dist/es6/mdx/versionsTable.d.ts.map +1 -1
- package/dist/es6/mdx/versionsTable.js +2 -1
- package/dist/mdx/11.0-UPGRADE-GUIDE.mdx +110 -2
- package/dist/mdx/{preview-react → react}/_examples/TablesAdvanced.mdx +1 -1
- package/dist/mdx/{preview-react → react}/_examples/examples/Table/WithExpandableRows.tsx +1 -1
- package/dist/mdx/{preview-react → react}/_examples/examples/Table/WithSelectableRows.tsx +1 -1
- package/dist/mdx/{preview-react → react}/_examples/examples/Table/WithSortableColumnHeaders.tsx +1 -1
- package/dist/mdx/react/table/Table.mdx +34 -73
- package/dist/mdx/react/table/examples/Basic.tsx +31 -26
- package/dist/mdx/{preview-react → react}/table/examples/BasicWithHeading.tsx +8 -4
- package/dist/mdx/{preview-react → react}/table/examples/FixedColumn.tsx +1 -1
- package/dist/mdx/{preview-react → react}/table/examples/RightToLeft.tsx +1 -1
- package/lib/Specifications.tsx +31 -29
- package/package.json +6 -6
- package/dist/mdx/preview-react/table/Table.mdx +0 -66
- package/dist/mdx/preview-react/table/examples/Basic.tsx +0 -36
- package/dist/mdx/react/table/examples/RowHeader.tsx +0 -25
- package/dist/mdx/react/table/examples/RowStates.tsx +0 -54
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versionsTable.d.ts","sourceRoot":"","sources":["../../../mdx/versionsTable.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"versionsTable.d.ts","sourceRoot":"","sources":["../../../mdx/versionsTable.tsx"],"names":[],"mappings":"AA8DA,eAAO,MAAM,YAAY,mBAgCxB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Table
|
|
2
|
+
import { Table } from '@workday/canvas-kit-react';
|
|
3
|
+
import { StatusIndicator } from '@workday/canvas-kit-preview-react';
|
|
3
4
|
// @ts-ignore: Cannot find module error
|
|
4
5
|
import { version } from '../../../lerna.json';
|
|
5
6
|
// When we release a new version, add the support version before the first item.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Table} from '@workday/canvas-kit-
|
|
1
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
2
2
|
import {base, brand} from '@workday/canvas-tokens-web';
|
|
3
3
|
import {cssVar} from '@workday/canvas-kit-styling';
|
|
4
4
|
|
|
@@ -10,6 +10,8 @@ This guide contains an overview of the changes in Canvas Kit v11. Please
|
|
|
10
10
|
any questions.
|
|
11
11
|
|
|
12
12
|
- [Codemod](#codemod)
|
|
13
|
+
- [Component Promotions](#component-promotions)
|
|
14
|
+
- [Table](#table)
|
|
13
15
|
- [Deprecations](#deprecations)
|
|
14
16
|
- [Form Field (Main)](#form-field-main)
|
|
15
17
|
- [Label Text](#label-text)
|
|
@@ -25,6 +27,11 @@ any questions.
|
|
|
25
27
|
- [Switch](#switch)
|
|
26
28
|
- [Table (Preview)](#table-preview)
|
|
27
29
|
- [Text](#text)
|
|
30
|
+
- [Glossary](#glossary)
|
|
31
|
+
- [Main](#main)
|
|
32
|
+
- [Preview](#preview)
|
|
33
|
+
- [Labs](#labs)
|
|
34
|
+
|
|
28
35
|
|
|
29
36
|
## Codemod
|
|
30
37
|
|
|
@@ -87,6 +94,65 @@ finished.
|
|
|
87
94
|
> the codemod, as its resulting formatting (spacing, quotes, etc.) may not match your project
|
|
88
95
|
> conventions.
|
|
89
96
|
|
|
97
|
+
## Component Promotions
|
|
98
|
+
|
|
99
|
+
### Table
|
|
100
|
+
|
|
101
|
+
**PR:** [#2600](https://github.com/Workday/canvas-kit/pull/2600)
|
|
102
|
+
|
|
103
|
+
We've promoted the `Table` compound component in [Preview](#preview) to [Main](#main). This replaces the existing `Table` component with a compound component
|
|
104
|
+
and will consist of a new compound component API.
|
|
105
|
+
|
|
106
|
+
> `rowState` prop is no longer a part of the `Table` component.
|
|
107
|
+
|
|
108
|
+
In v10, the `Table` component in [Main](#main) only exposed a `Table` and `TableRow` component to build tables.
|
|
109
|
+
|
|
110
|
+
In v11, `Table` now exposes every subcomponent of a semantic HTML
|
|
111
|
+
[Table](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table). While more verbose, it provides more flexibility for customization.
|
|
112
|
+
|
|
113
|
+
See below for examples of the differences between the v10 `Table` and the v11 `Table` compound component.
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
v10:
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
<Table>
|
|
120
|
+
<thead>
|
|
121
|
+
<TableRow header={true}>
|
|
122
|
+
<th>Header Text</th>
|
|
123
|
+
</TableRow>
|
|
124
|
+
</thead>
|
|
125
|
+
<tbody>
|
|
126
|
+
<TableRow>
|
|
127
|
+
<td>Cell Text</td>
|
|
128
|
+
</TableRow>
|
|
129
|
+
</tbody>
|
|
130
|
+
</Table>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
v11:
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
<Table>
|
|
137
|
+
<Table.Head>
|
|
138
|
+
<Table.Row>
|
|
139
|
+
<Table.Header>Header Text</Table.Header>
|
|
140
|
+
</Table.Row>
|
|
141
|
+
</Table.Head>
|
|
142
|
+
<Table.Body>
|
|
143
|
+
<Table.Row>
|
|
144
|
+
<Table.Cell>Cell Text</Table.Cell>
|
|
145
|
+
</Table.Row>
|
|
146
|
+
</Table.Body>
|
|
147
|
+
</Table>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
Please refer to the [Table examples](https://workday.github.io/canvas-kit/?path=/story/components-containers-table--basic) for how
|
|
152
|
+
to implement new tables.
|
|
153
|
+
|
|
154
|
+
> **NOTE:** If you were using the [Preview](#preview) `Table` compound component, then you will need to update your import from `"@workday/canvas-kit-preview-react/table"` to `"@workday/canvas-kit-react/table"`.
|
|
155
|
+
|
|
90
156
|
## Deprecations
|
|
91
157
|
|
|
92
158
|
We add the [@deprecated](https://jsdoc.app/tags-deprecated.html) JSDoc tag to code we plan to remove
|
|
@@ -456,4 +522,46 @@ identically as it did in previous versions.
|
|
|
456
522
|
and [tokens](https://workday.github.io/canvas-tokens/?path=/docs/docs-getting-started--docs). It no
|
|
457
523
|
longer extends the `Box` component, however, it still supports Emotion `styled` and style props.
|
|
458
524
|
Type level components: `Title`, `Heading`, `BodyText` and `Subtext`, have not been changed since
|
|
459
|
-
they extend the `Text` component. These changes do not affect the components API.
|
|
525
|
+
they extend the `Text` component. These changes do not affect the components API.
|
|
526
|
+
|
|
527
|
+
## Glossary
|
|
528
|
+
|
|
529
|
+
### Main
|
|
530
|
+
|
|
531
|
+
Our Main package of Canvas Kit tokens, components, and utilities at `@workday/canvas-kit-react` has
|
|
532
|
+
undergone a full design and a11y review and is approved for use in product.
|
|
533
|
+
|
|
534
|
+
Breaking changes to code in Main will only occur during major version updates and will always be
|
|
535
|
+
communicated in advance and accompanied by migration strategies.
|
|
536
|
+
|
|
537
|
+
---
|
|
538
|
+
|
|
539
|
+
### Preview
|
|
540
|
+
|
|
541
|
+
Our Preview package of Canvas Kit tokens, components, and utilities at
|
|
542
|
+
`@workday/canvas-kit-preview-react` has undergone a full design and a11y review and is approved for
|
|
543
|
+
use in product, but may not be up to the high code standards upheld in the [Main](#main) package.
|
|
544
|
+
Preview is analagous to code in beta.
|
|
545
|
+
|
|
546
|
+
Breaking changes are unlikely, but possible, and can be deployed to Preview at any time without
|
|
547
|
+
triggering a major version update, though such changes will be communicated in advance and
|
|
548
|
+
accompanied by migration strategies.
|
|
549
|
+
|
|
550
|
+
Generally speaking, our goal is to eventually promote code from Preview to [Main](#main).
|
|
551
|
+
Occasionally, a component with the same name will exist in both [Main](#main) and Preview (for
|
|
552
|
+
example, see Segmented Control in [Preview](/components/buttons/segmented-control/) and
|
|
553
|
+
[Main](https://d2krrudi3mmzzw.cloudfront.net/v8/?path=/docs/components-buttons-segmented-control--basic)).
|
|
554
|
+
In these cases, Preview serves as a staging ground for an improved version of the component with a
|
|
555
|
+
different API. The component in [Main](#main) will eventually be replaced with the one in Preview.
|
|
556
|
+
|
|
557
|
+
---
|
|
558
|
+
|
|
559
|
+
### Labs
|
|
560
|
+
|
|
561
|
+
Our Labs package of Canvas Kit tokens, components, and utilities at `@workday/canvas-kit-labs-react`
|
|
562
|
+
has **not** undergone a full design and a11y review. Labs serves as an incubator space for new and
|
|
563
|
+
experimental code and is analagous to code in alpha.
|
|
564
|
+
|
|
565
|
+
Breaking changes can be deployed to Labs at any time without triggering a major version update and
|
|
566
|
+
may not be subject to the same rigor in communcation and migration strategies reserved for breaking
|
|
567
|
+
changes in [Preview](#preview) and [Main](#main).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import {StatusIndicator} from '@workday/canvas-kit-preview-react/status-indicator';
|
|
4
|
-
import {Table} from '@workday/canvas-kit-
|
|
4
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
5
5
|
import {TertiaryButton} from '@workday/canvas-kit-react/button';
|
|
6
6
|
import {createComponent, generateUniqueId} from '@workday/canvas-kit-react/common';
|
|
7
7
|
import {Heading, Subtext} from '@workday/canvas-kit-react/text';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import {Table} from '@workday/canvas-kit-
|
|
3
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
4
4
|
import {Heading} from '@workday/canvas-kit-react/text';
|
|
5
5
|
import {Checkbox} from '@workday/canvas-kit-react/checkbox';
|
|
6
6
|
import {createComponent, generateUniqueId} from '@workday/canvas-kit-react/common';
|
package/dist/mdx/{preview-react → react}/_examples/examples/Table/WithSortableColumnHeaders.tsx
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import {createComponent} from '@workday/canvas-kit-react/common';
|
|
4
|
-
import {Table} from '@workday/canvas-kit-
|
|
4
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
5
5
|
import {Tooltip} from '@workday/canvas-kit-react/tooltip';
|
|
6
6
|
import {TertiaryButton} from '@workday/canvas-kit-react/button';
|
|
7
7
|
import {Text} from '@workday/canvas-kit-react/text';
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
import {SymbolDoc} from '@workday/canvas-kit-docs';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {StatusIndicator} from '@workday/canvas-kit-preview-react/status-indicator';
|
|
5
|
-
|
|
2
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
3
|
+
// Examples
|
|
6
4
|
import Basic from './examples/Basic';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
5
|
+
import BasicWithHeading from './examples/BasicWithHeading';
|
|
6
|
+
import FixedColumn from './examples/FixedColumn';
|
|
7
|
+
import RightToLeft from './examples/RightToLeft';
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
# Canvas Kit Table
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
`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.
|
|
18
|
-
|
|
19
|
-
Tables are an efficient way of displaying sets of repeating data with the same structure.
|
|
20
|
-
|
|
21
|
-
[> Workday Design Reference](https://design.workday.com/components/containers/tables)
|
|
12
|
+
`Table` is a simple styled compound component that renders a
|
|
13
|
+
[table](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table) element. It is used to
|
|
14
|
+
present information in a two-dimensional table comprised of rows and columns of cells containing
|
|
15
|
+
data.
|
|
22
16
|
|
|
23
17
|
## Installation
|
|
24
18
|
|
|
@@ -30,76 +24,43 @@ yarn add @workday/canvas-kit-react
|
|
|
30
24
|
|
|
31
25
|
### Basic Example
|
|
32
26
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
Users may not want to use a `caption` so they can import [Heading](/components/text/heading/) or
|
|
28
|
+
[Text](/components/text/text/) instead. This will give the user more flexibility around the
|
|
29
|
+
customization of the title/heading of their table.
|
|
36
30
|
|
|
37
|
-
|
|
38
|
-
create your Table.
|
|
31
|
+
<ExampleCodeBlock code={BasicWithHeading} />
|
|
39
32
|
|
|
40
|
-
|
|
33
|
+
### Right to Left
|
|
41
34
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
### Table
|
|
45
|
-
|
|
46
|
-
`Table` is a simple wrapper of the `<table>` element with Canvas styles. Use it as you would a
|
|
47
|
-
standard `<table>` element.
|
|
48
|
-
|
|
49
|
-
```tsx
|
|
50
|
-
<Table>
|
|
51
|
-
<thead>
|
|
52
|
-
<TableRow header={true}>
|
|
53
|
-
<th>ID</th>
|
|
54
|
-
<th>Name</th>
|
|
55
|
-
...
|
|
56
|
-
</TableRow>
|
|
57
|
-
</thead>
|
|
58
|
-
<tbody>
|
|
59
|
-
<TableRow>
|
|
60
|
-
<td>1</td>
|
|
61
|
-
<td>Aidan Brown</td>
|
|
62
|
-
...
|
|
63
|
-
</TableRow>
|
|
64
|
-
...
|
|
65
|
-
</tbody>
|
|
66
|
-
</Table>
|
|
67
|
-
```
|
|
35
|
+
Table supports right-to-left languages when specified in the CanvasProvider theme.
|
|
68
36
|
|
|
69
|
-
|
|
37
|
+
<ExampleCodeBlock code={RightToLeft} />
|
|
70
38
|
|
|
71
|
-
|
|
72
|
-
`<table>` element.
|
|
39
|
+
### Example with Caption
|
|
73
40
|
|
|
74
|
-
|
|
41
|
+
Users are free to use a `caption` instead of a heading. A `caption` is not required but it is good
|
|
42
|
+
for
|
|
43
|
+
[accessibility](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table#accessibility_concerns)
|
|
44
|
+
purposes.
|
|
75
45
|
|
|
76
|
-
|
|
77
|
-
you would a standard `<tr>` element.
|
|
46
|
+
<ExampleCodeBlock code={Basic} />
|
|
78
47
|
|
|
79
|
-
|
|
48
|
+
### Fixed Column
|
|
80
49
|
|
|
81
|
-
|
|
50
|
+
Users may add styles to the `Table.Header` to render a fixed column. The example below assigns a
|
|
51
|
+
`width` to the `Table` to guarantee the fixed column is triggered, but you are free to omit the
|
|
52
|
+
`width` if you would only like the fixed column to be triggered if necessary.
|
|
82
53
|
|
|
83
|
-
|
|
84
|
-
`state` accepts the following values:
|
|
54
|
+
<ExampleCodeBlock code={FixedColumn} />
|
|
85
55
|
|
|
86
|
-
|
|
87
|
-
- `TableRow.State.Alert`
|
|
88
|
-
- `TableRow.State.InputAlert`
|
|
89
|
-
- `TableRow.State.Error`
|
|
90
|
-
- `TableRow.State.InputError`
|
|
56
|
+
### Advanced
|
|
91
57
|
|
|
92
|
-
|
|
93
|
-
| --------------------------- | ---------------------------------------------------------------------- |
|
|
94
|
-
| `TableRow.State.Alert` | When there is an issue with the entire row as a whole. |
|
|
95
|
-
| `TableRow.State.InputAlert` | When there are issues with one or more (but not all) cells in the row. |
|
|
96
|
-
| `TableRow.State.Error` | When there is an error with the entire row as a whole. |
|
|
97
|
-
| `TableRow.State.InputError` | When there are errors with one or more (but not all) cells in the row. |
|
|
98
|
-
| `TableRow.State.Selected` | Indicates the selected row to the user. |
|
|
58
|
+
You can also find several advanced Table examples in our Storybook Examples section.
|
|
99
59
|
|
|
100
|
-
|
|
60
|
+
- [Expandable Rows](/docs/examples-tables-advanced--expandable-rows)
|
|
61
|
+
- [Selectable Rows ](/docs/examples-tables-advanced--selectable-rows)
|
|
62
|
+
- [Sortable Column Headers](/docs/examples-tables-advanced--sortable-column-headers)
|
|
101
63
|
|
|
102
|
-
|
|
103
|
-
they lack a darkened border around the row.
|
|
64
|
+
## Component API
|
|
104
65
|
|
|
105
|
-
<SymbolDoc name="
|
|
66
|
+
<SymbolDoc name="Table" fileName="/react/" />
|
|
@@ -1,35 +1,40 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {Table, TableRow} from '@workday/canvas-kit-react/table';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const rows = [
|
|
7
|
-
[1, 'Aidan Brown', 'Product Manager', 'San Francisco, CA'],
|
|
8
|
-
[2, 'Betty Chen', 'Product Designer', 'San Francisco, CA'],
|
|
9
|
-
[3, 'Helen Gonzalez', 'Application Developer', 'Portland, OR'],
|
|
10
|
-
[4, 'Timothy May', 'VP, Product Development', 'San Francisco, CA'],
|
|
11
|
-
[5, 'John Hours', 'Product Manager', 'New York, New York'],
|
|
12
|
-
];
|
|
3
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
13
4
|
|
|
14
5
|
export default () => {
|
|
15
6
|
return (
|
|
16
7
|
<Table>
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
</
|
|
31
|
-
|
|
32
|
-
|
|
8
|
+
<Table.Caption>Coffee Drinks and Sizes</Table.Caption>
|
|
9
|
+
<Table.Head>
|
|
10
|
+
<Table.Row>
|
|
11
|
+
<Table.Header scope="col" backgroundColor="soap100">
|
|
12
|
+
Drink
|
|
13
|
+
</Table.Header>
|
|
14
|
+
<Table.Header scope="col" backgroundColor="soap100">
|
|
15
|
+
Size
|
|
16
|
+
</Table.Header>
|
|
17
|
+
</Table.Row>
|
|
18
|
+
</Table.Head>
|
|
19
|
+
<Table.Body>
|
|
20
|
+
<Table.Row>
|
|
21
|
+
<Table.Cell>Espresso</Table.Cell>
|
|
22
|
+
<Table.Cell>1 oz</Table.Cell>
|
|
23
|
+
</Table.Row>
|
|
24
|
+
<Table.Row>
|
|
25
|
+
<Table.Cell>Macchiato</Table.Cell>
|
|
26
|
+
<Table.Cell>2 oz Espresso</Table.Cell>
|
|
27
|
+
</Table.Row>
|
|
28
|
+
<Table.Row>
|
|
29
|
+
<Table.Cell>Cortado</Table.Cell>
|
|
30
|
+
<Table.Cell>2 oz Espresso, 1 oz Foamed Milk</Table.Cell>
|
|
31
|
+
</Table.Row>
|
|
32
|
+
<Table.Row></Table.Row>
|
|
33
|
+
<Table.Row>
|
|
34
|
+
<Table.Cell>Cappuccino</Table.Cell>
|
|
35
|
+
<Table.Cell>2 oz Espresso, 2 oz Foamed Milk, 2 oz Steamed Milk</Table.Cell>
|
|
36
|
+
</Table.Row>
|
|
37
|
+
</Table.Body>
|
|
33
38
|
</Table>
|
|
34
39
|
);
|
|
35
40
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import {Table} from '@workday/canvas-kit-
|
|
3
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
4
4
|
import {Heading} from '@workday/canvas-kit-react/text';
|
|
5
5
|
import {useUniqueId} from '@workday/canvas-kit-react/common';
|
|
6
6
|
|
|
7
7
|
export default () => {
|
|
8
8
|
const headingID = useUniqueId();
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
return (
|
|
11
11
|
<>
|
|
12
12
|
<Heading as="h3" id={headingID} size="small" marginBottom="s">
|
|
@@ -15,8 +15,12 @@ export default () => {
|
|
|
15
15
|
<Table aria-labelledby={headingID}>
|
|
16
16
|
<Table.Head>
|
|
17
17
|
<Table.Row>
|
|
18
|
-
<Table.Header scope="col" backgroundColor="soap100">
|
|
19
|
-
|
|
18
|
+
<Table.Header scope="col" backgroundColor="soap100">
|
|
19
|
+
Toppings
|
|
20
|
+
</Table.Header>
|
|
21
|
+
<Table.Header scope="col" backgroundColor="soap100">
|
|
22
|
+
Amount
|
|
23
|
+
</Table.Header>
|
|
20
24
|
</Table.Row>
|
|
21
25
|
</Table.Head>
|
|
22
26
|
<Table.Body>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import {Table} from '@workday/canvas-kit-
|
|
3
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
4
4
|
import {Heading} from '@workday/canvas-kit-react/text';
|
|
5
5
|
import {colors} from '@workday/canvas-kit-react/tokens';
|
|
6
6
|
import {useUniqueId} from '@workday/canvas-kit-react/common';
|
package/lib/Specifications.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import {toId} from '@storybook/csf';
|
|
4
|
-
import {Table
|
|
4
|
+
import {Table} from '@workday/canvas-kit-react/table';
|
|
5
5
|
import {Hyperlink} from '@workday/canvas-kit-react/button';
|
|
6
6
|
|
|
7
7
|
import {specifications, SpecDescribe, SpecIt} from './specs';
|
|
@@ -85,35 +85,37 @@ export const Specifications = ({file, name}: SpecificationsProps) => {
|
|
|
85
85
|
|
|
86
86
|
const [, first, kind, name, last] = matches;
|
|
87
87
|
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
88
|
+
return (
|
|
89
|
+
<>
|
|
90
|
+
{first.replace(/given /i, '')}
|
|
91
|
+
<Hyperlink
|
|
92
|
+
href={`${storybookBaseUrl}?path=/story/${toId(
|
|
93
|
+
kind,
|
|
94
|
+
name.replace('DefaultStory', 'Default Story')
|
|
95
|
+
)}`}
|
|
96
|
+
>
|
|
97
|
+
{name.replace('DefaultStory', 'Default')}
|
|
98
|
+
</Hyperlink>
|
|
99
|
+
{last}
|
|
100
|
+
</>
|
|
101
|
+
);
|
|
100
102
|
};
|
|
101
103
|
|
|
102
104
|
return block.type === 'describe' ? (
|
|
103
105
|
<>
|
|
104
106
|
<Table>
|
|
105
|
-
<
|
|
106
|
-
<
|
|
107
|
-
<
|
|
108
|
-
<
|
|
109
|
-
<
|
|
110
|
-
</
|
|
111
|
-
</
|
|
112
|
-
<
|
|
107
|
+
<Table.Head>
|
|
108
|
+
<Table.Row>
|
|
109
|
+
<Table.Header>Given</Table.Header>
|
|
110
|
+
<Table.Header>When</Table.Header>
|
|
111
|
+
<Table.Header>Then</Table.Header>
|
|
112
|
+
</Table.Row>
|
|
113
|
+
</Table.Head>
|
|
114
|
+
<Table.Body>
|
|
113
115
|
{block.children.reduce(createTableRows, []).map((row, index) => (
|
|
114
|
-
<
|
|
115
|
-
<
|
|
116
|
-
<
|
|
116
|
+
<Table.Row key={index}>
|
|
117
|
+
<Table.Cell>{renderGiven(row.given[0])}</Table.Cell>
|
|
118
|
+
<Table.Cell>
|
|
117
119
|
<ul>
|
|
118
120
|
{row.when.map((item, index) => (
|
|
119
121
|
<li key={index}>
|
|
@@ -121,17 +123,17 @@ export const Specifications = ({file, name}: SpecificationsProps) => {
|
|
|
121
123
|
</li>
|
|
122
124
|
))}
|
|
123
125
|
</ul>
|
|
124
|
-
</
|
|
125
|
-
<
|
|
126
|
+
</Table.Cell>
|
|
127
|
+
<Table.Cell>
|
|
126
128
|
<ul>
|
|
127
129
|
{row.then.map((item, index) => (
|
|
128
130
|
<li key={index}>{(item.indexOf('should') === 0 ? 'it ' : '') + item}</li>
|
|
129
131
|
))}
|
|
130
132
|
</ul>
|
|
131
|
-
</
|
|
132
|
-
</
|
|
133
|
+
</Table.Cell>
|
|
134
|
+
</Table.Row>
|
|
133
135
|
))}
|
|
134
|
-
</
|
|
136
|
+
</Table.Body>
|
|
135
137
|
</Table>
|
|
136
138
|
Source:{' '}
|
|
137
139
|
<Hyperlink href={`${githubUrl}blob/${githubBranch}/cypress/integration/${file}`}>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "11.0.0-alpha.
|
|
3
|
+
"version": "11.0.0-alpha.708-next.0",
|
|
4
4
|
"description": "Documentation components of Canvas Kit components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@emotion/styled": "^11.6.0",
|
|
46
46
|
"@storybook/csf": "0.0.1",
|
|
47
|
-
"@workday/canvas-kit-labs-react": "^11.0.0-alpha.
|
|
48
|
-
"@workday/canvas-kit-preview-react": "^11.0.0-alpha.
|
|
49
|
-
"@workday/canvas-kit-react": "^11.0.0-alpha.
|
|
50
|
-
"@workday/canvas-kit-styling": "^11.0.0-alpha.
|
|
47
|
+
"@workday/canvas-kit-labs-react": "^11.0.0-alpha.708-next.0",
|
|
48
|
+
"@workday/canvas-kit-preview-react": "^11.0.0-alpha.708-next.0",
|
|
49
|
+
"@workday/canvas-kit-react": "^11.0.0-alpha.708-next.0",
|
|
50
|
+
"@workday/canvas-kit-styling": "^11.0.0-alpha.708-next.0",
|
|
51
51
|
"@workday/canvas-system-icons-web": "^3.0.0",
|
|
52
52
|
"@workday/canvas-tokens-web": "^1.0.2",
|
|
53
53
|
"markdown-to-jsx": "^6.10.3",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"mkdirp": "^1.0.3",
|
|
60
60
|
"typescript": "4.2"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "c88b748b4f8ad105e0cc48bd7b67716841abe30d"
|
|
63
63
|
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {SymbolDoc} from '@workday/canvas-kit-docs';
|
|
2
|
-
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
3
|
-
// Examples
|
|
4
|
-
import Basic from './examples/Basic';
|
|
5
|
-
import BasicWithHeading from './examples/BasicWithHeading';
|
|
6
|
-
import FixedColumn from './examples/FixedColumn';
|
|
7
|
-
import RightToLeft from './examples/RightToLeft';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# Canvas Kit Table
|
|
11
|
-
|
|
12
|
-
`Table` is a simple styled compound component that renders a
|
|
13
|
-
[table](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table) element. It is used to
|
|
14
|
-
present information in a two-dimensional table comprised of rows and columns of cells containing
|
|
15
|
-
data.
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
```sh
|
|
20
|
-
yarn add @workday/canvas-kit-preview-react
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Usage
|
|
24
|
-
|
|
25
|
-
### Basic Example
|
|
26
|
-
|
|
27
|
-
Users may not want to use a `caption` so they can import [Heading](/components/text/heading/) or
|
|
28
|
-
[Text](/components/text/text/) instead. This will give the user more flexibility around the
|
|
29
|
-
customization of the title/heading of their table.
|
|
30
|
-
|
|
31
|
-
<ExampleCodeBlock code={BasicWithHeading} />
|
|
32
|
-
|
|
33
|
-
### Right to Left
|
|
34
|
-
|
|
35
|
-
Table supports right-to-left languages when specified in the CanvasProvider theme.
|
|
36
|
-
|
|
37
|
-
<ExampleCodeBlock code={RightToLeft} />
|
|
38
|
-
|
|
39
|
-
### Example with Caption
|
|
40
|
-
|
|
41
|
-
Users are free to use a `caption` instead of a heading. A `caption` is not required but it is good
|
|
42
|
-
for
|
|
43
|
-
[accessibility](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table#accessibility_concerns)
|
|
44
|
-
purposes.
|
|
45
|
-
|
|
46
|
-
<ExampleCodeBlock code={Basic} />
|
|
47
|
-
|
|
48
|
-
### Fixed Column
|
|
49
|
-
|
|
50
|
-
Users may add styles to the `Table.Header` to render a fixed column. The example below assigns a
|
|
51
|
-
`width` to the `Table` to guarantee the fixed column is triggered, but you are free to omit the
|
|
52
|
-
`width` if you would only like the fixed column to be triggered if necessary.
|
|
53
|
-
|
|
54
|
-
<ExampleCodeBlock code={FixedColumn} />
|
|
55
|
-
|
|
56
|
-
### Advanced
|
|
57
|
-
|
|
58
|
-
You can also find several advanced Table examples in our Storybook Examples section.
|
|
59
|
-
|
|
60
|
-
- [Expandable Rows](/docs/examples-tables-advanced--expandable-rows)
|
|
61
|
-
- [Selectable Rows ](/docs/examples-tables-advanced--selectable-rows)
|
|
62
|
-
- [Sortable Column Headers](/docs/examples-tables-advanced--sortable-column-headers)
|
|
63
|
-
|
|
64
|
-
## Component API
|
|
65
|
-
|
|
66
|
-
<SymbolDoc name="Table" fileName="/preview-react/" />
|