@workday/canvas-kit-docs 11.0.0-alpha.682-next.0 → 11.0.0-alpha.696-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/docs.js +203 -12
- package/dist/es6/lib/specs.js +24 -0
- package/dist/es6/mdx/versionsTable.d.ts +2 -0
- package/dist/es6/mdx/versionsTable.d.ts.map +1 -0
- package/dist/es6/mdx/versionsTable.js +76 -0
- package/dist/mdx/11.0-UPGRADE-GUIDE.mdx +12 -0
- package/dist/mdx/Versions.mdx +8 -0
- package/dist/mdx/preview-react/_examples/TablesAdvanced.mdx +84 -0
- package/dist/mdx/preview-react/_examples/examples/Table/WithExpandableRows.tsx +219 -0
- package/dist/mdx/preview-react/_examples/examples/Table/WithSelectableRows.tsx +156 -0
- package/dist/mdx/preview-react/_examples/examples/Table/WithSortableColumnHeaders.tsx +213 -0
- package/dist/mdx/preview-react/table/Table.mdx +16 -1
- package/dist/mdx/preview-react/table/examples/FixedColumn.tsx +17 -17
- package/dist/mdx/preview-react/table/examples/RightToLeft.tsx +38 -0
- package/dist/mdx/react/select/Select.mdx +82 -7
- package/dist/mdx/react/select/examples/Basic.tsx +1 -1
- package/dist/mdx/react/select/examples/Complex.tsx +11 -16
- package/dist/mdx/react/select/examples/FetchingDynamicItems.tsx +103 -0
- package/dist/mdx/react/select/examples/Grow.tsx +1 -5
- package/dist/mdx/react/select/examples/HoistedModel.tsx +8 -15
- package/dist/mdx/react/select/examples/InitialSelectedItem.tsx +60 -0
- package/dist/mdx/react/select/examples/LabelPosition.tsx +1 -3
- package/dist/mdx/react/select/examples/Placeholder.tsx +41 -0
- package/dist/mdx/react/select/examples/RefForwarding.tsx +1 -0
- package/package.json +6 -6
|
@@ -9,7 +9,7 @@ export default () => {
|
|
|
9
9
|
const headingID = useUniqueId();
|
|
10
10
|
const exampleData = [
|
|
11
11
|
{
|
|
12
|
-
|
|
12
|
+
make: 'Porsche',
|
|
13
13
|
model: '992 911 GT3',
|
|
14
14
|
year: '2022',
|
|
15
15
|
price: 'Starts at $160,000',
|
|
@@ -20,7 +20,7 @@ export default () => {
|
|
|
20
20
|
curbWeight: '3,164 lbs',
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
|
-
|
|
23
|
+
make: 'BMW',
|
|
24
24
|
model: 'M5 Competition',
|
|
25
25
|
year: '2018',
|
|
26
26
|
price: 'Starts at $105,000',
|
|
@@ -31,18 +31,18 @@ export default () => {
|
|
|
31
31
|
curbWeight: '4,345 lbs',
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
|
-
|
|
35
|
-
model: '
|
|
36
|
-
year: '
|
|
37
|
-
price: '
|
|
38
|
-
engine: '
|
|
39
|
-
transmission: '
|
|
40
|
-
horsepower: '
|
|
41
|
-
torque: '
|
|
42
|
-
curbWeight: '
|
|
34
|
+
make: 'Alfa Romeo',
|
|
35
|
+
model: '1750 GTV',
|
|
36
|
+
year: '1970',
|
|
37
|
+
price: '$30,000 - $55,000',
|
|
38
|
+
engine: '1.75L Inline 4',
|
|
39
|
+
transmission: 'Manual',
|
|
40
|
+
horsepower: '122hp',
|
|
41
|
+
torque: '137 lb-ft',
|
|
42
|
+
curbWeight: '2,140 lbs',
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
|
-
|
|
45
|
+
make: 'Lotus',
|
|
46
46
|
model: 'Emira',
|
|
47
47
|
year: '2023',
|
|
48
48
|
price: 'Starts at $78,000',
|
|
@@ -53,7 +53,7 @@ export default () => {
|
|
|
53
53
|
curbWeight: '3520 lbs',
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
|
-
|
|
56
|
+
make: 'Toyota',
|
|
57
57
|
model: 'Supra',
|
|
58
58
|
year: '1998',
|
|
59
59
|
price: '$40,000 - $80,000',
|
|
@@ -64,7 +64,7 @@ export default () => {
|
|
|
64
64
|
curbWeight: '3,599 lbs',
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
|
-
|
|
67
|
+
make: 'Nissan',
|
|
68
68
|
model: 'Skyline GT-R',
|
|
69
69
|
year: '1994',
|
|
70
70
|
price: '$45,000 - $90,000',
|
|
@@ -90,7 +90,7 @@ export default () => {
|
|
|
90
90
|
backgroundColor="soap100"
|
|
91
91
|
borderRight={`2px solid ${colors.soap400}`}
|
|
92
92
|
>
|
|
93
|
-
|
|
93
|
+
Make
|
|
94
94
|
</Table.Header>
|
|
95
95
|
<Table.Header scope="col">Model</Table.Header>
|
|
96
96
|
<Table.Header scope="col">Year</Table.Header>
|
|
@@ -99,7 +99,7 @@ export default () => {
|
|
|
99
99
|
<Table.Header scope="col">Transmission</Table.Header>
|
|
100
100
|
<Table.Header scope="col">Horsepower</Table.Header>
|
|
101
101
|
<Table.Header scope="col">Torque</Table.Header>
|
|
102
|
-
<Table.Header scope="col">
|
|
102
|
+
<Table.Header scope="col">Curb Weight</Table.Header>
|
|
103
103
|
</Table.Row>
|
|
104
104
|
</Table.Head>
|
|
105
105
|
<Table.Body>
|
|
@@ -113,7 +113,7 @@ export default () => {
|
|
|
113
113
|
backgroundColor="soap100"
|
|
114
114
|
borderRight={`2px solid ${colors.soap400}`}
|
|
115
115
|
>
|
|
116
|
-
{item.
|
|
116
|
+
{item.make}
|
|
117
117
|
</Table.Header>
|
|
118
118
|
<Table.Cell>{item.model}</Table.Cell>
|
|
119
119
|
<Table.Cell>{item.year}</Table.Cell>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
4
|
+
import {CanvasProvider, ContentDirection} from '@workday/canvas-kit-react/common';
|
|
5
|
+
|
|
6
|
+
export default () => {
|
|
7
|
+
return (
|
|
8
|
+
<CanvasProvider theme={{canvas: {direction: ContentDirection.RTL}}}>
|
|
9
|
+
<Table>
|
|
10
|
+
<Table.Caption>משקאות קפה וגדלים</Table.Caption>
|
|
11
|
+
<Table.Head>
|
|
12
|
+
<Table.Row>
|
|
13
|
+
<Table.Header scope="col" backgroundColor="soap100">
|
|
14
|
+
מַשׁקֶה
|
|
15
|
+
</Table.Header>
|
|
16
|
+
<Table.Header scope="col" backgroundColor="soap100">
|
|
17
|
+
גודל
|
|
18
|
+
</Table.Header>
|
|
19
|
+
</Table.Row>
|
|
20
|
+
</Table.Head>
|
|
21
|
+
<Table.Body>
|
|
22
|
+
<Table.Row>
|
|
23
|
+
<Table.Cell>אספרסו</Table.Cell>
|
|
24
|
+
<Table.Cell>1 גר</Table.Cell>
|
|
25
|
+
</Table.Row>
|
|
26
|
+
<Table.Row>
|
|
27
|
+
<Table.Cell>מקיאטו</Table.Cell>
|
|
28
|
+
<Table.Cell>2 גרם אספרסו</Table.Cell>
|
|
29
|
+
</Table.Row>
|
|
30
|
+
<Table.Row>
|
|
31
|
+
<Table.Cell>גזירה</Table.Cell>
|
|
32
|
+
<Table.Cell>2 גרם אספרסו, 1 גרם חלב מוקצף</Table.Cell>
|
|
33
|
+
</Table.Row>
|
|
34
|
+
</Table.Body>
|
|
35
|
+
</Table>
|
|
36
|
+
</CanvasProvider>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -15,6 +15,9 @@ import Required from './examples/Required';
|
|
|
15
15
|
import MenuHeight from './examples/MenuHeight';
|
|
16
16
|
import HoistedModel from './examples/HoistedModel';
|
|
17
17
|
import RefForwarding from './examples/RefForwarding';
|
|
18
|
+
import FetchingDynamicItems from './examples/FetchingDynamicItems';
|
|
19
|
+
import Placeholder from './examples/Placeholder';
|
|
20
|
+
import InitialSelectedItem from './examples/InitialSelectedItem';
|
|
18
21
|
|
|
19
22
|
|
|
20
23
|
# Canvas Kit Select
|
|
@@ -86,6 +89,10 @@ and provides direct access to its `state` and `events` outside of the `Select` c
|
|
|
86
89
|
In this example, we set up external observation of the model state and create an external button to
|
|
87
90
|
trigger an event to change the selected item.
|
|
88
91
|
|
|
92
|
+
**Note: If your array of objects uses an `id` property and a `text` property there is no need to use
|
|
93
|
+
the helper functions of `getId` or `getTextValue`. The collection system and the `Select` use these
|
|
94
|
+
properties by default for keyboard navigation and selected the `id` based on the item clicked.**
|
|
95
|
+
|
|
89
96
|
<ExampleCodeBlock code={HoistedModel} />
|
|
90
97
|
|
|
91
98
|
### Label Position Horizontal
|
|
@@ -199,18 +206,43 @@ Use the error state when the selection is no longer valid.
|
|
|
199
206
|
|
|
200
207
|
<ExampleCodeBlock code={Error} />
|
|
201
208
|
|
|
209
|
+
### Initial Selected Item
|
|
210
|
+
|
|
211
|
+
You can set `initialSelectedIds` to the value that you want initially selected.
|
|
212
|
+
|
|
213
|
+
<ExampleCodeBlock code={InitialSelectedItem} />
|
|
214
|
+
|
|
215
|
+
### Placeholder
|
|
216
|
+
|
|
217
|
+
You can change the placeholder text by passing in a string value to the `placeholder` attribute on
|
|
218
|
+
the `Select.Input`.
|
|
219
|
+
|
|
220
|
+
<ExampleCodeBlock code={Placeholder} />
|
|
221
|
+
|
|
222
|
+
### Fetching Dynamic Items
|
|
223
|
+
|
|
224
|
+
It's common to load items from a server call. Hoisting the `model` and setting your items on state
|
|
225
|
+
allows you to pass those items to your `model`. You can leverage React state to set your items on
|
|
226
|
+
load as well as displaying a placeholder indicating when items are loaded.
|
|
227
|
+
|
|
228
|
+
**Note: In this case we need to use `getId` and `getTextValue` because our data doesn't have the
|
|
229
|
+
properties of `id` or `text`. Using these helper functions sets the `serverId` to be `id` and
|
|
230
|
+
`label` to be `text`.**
|
|
231
|
+
|
|
232
|
+
<ExampleCodeBlock code={FetchingDynamicItems} />
|
|
233
|
+
|
|
202
234
|
### Complex
|
|
203
235
|
|
|
204
|
-
When registering items in an array of objects, it's common to have
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
236
|
+
When registering items in an array of objects, it's common to have the text that is displayed to the user be
|
|
237
|
+
different than an id. In this example, `serverId` and `label` properties need to be remapped to
|
|
238
|
+
`id` and `text` hence the usage of `getId` and `getTextValue`. If your object has the properties
|
|
239
|
+
`text` and `id`, there would be no need for this.
|
|
208
240
|
|
|
209
241
|
<ExampleCodeBlock code={Complex} />
|
|
210
242
|
|
|
211
|
-
By default, the identifier and text value are `id` and `text` properties respectively. If
|
|
212
|
-
object for each item is different, provide a `getId` or `getTextValue` function to the
|
|
213
|
-
For example
|
|
243
|
+
**Note: By default, the identifier and text value are `id` and `text` properties respectively. If
|
|
244
|
+
your data object for each item is different, provide a `getId` or `getTextValue` function to the
|
|
245
|
+
model config. For example:**
|
|
214
246
|
|
|
215
247
|
```jsx
|
|
216
248
|
const items = [
|
|
@@ -225,6 +257,49 @@ const items = [
|
|
|
225
257
|
</Select>;
|
|
226
258
|
```
|
|
227
259
|
|
|
260
|
+
### When to use `getId`, or `getTextValue`
|
|
261
|
+
|
|
262
|
+
- `getId`: This is an optional function to return the id of an item. If not provided, the default
|
|
263
|
+
function will return the `id` property from the object of each item. If you did not provide
|
|
264
|
+
`items`, do not override this function. Instead provide static
|
|
265
|
+
items via JSX. the list will create an internal array of items where `id` is the only property and
|
|
266
|
+
the default `getId` will return the desired result. **Note: If your array of objects has a
|
|
267
|
+
different property for `id`, like `serverId`, use this function to set the id.**
|
|
268
|
+
|
|
269
|
+
```tsx
|
|
270
|
+
const options = [{text: 'Pizza', serverId: 'pizza-1'}, {text: 'Cheeseburger', serverId: 'cheeseburger'}]
|
|
271
|
+
<Select items={options} getId={(item) => item.serverId}>
|
|
272
|
+
<FormField label="Your Label">
|
|
273
|
+
<Select.Input onChange={e => handleChange(e)} id="contact-select" />
|
|
274
|
+
<Select.Popper>
|
|
275
|
+
<Select.Card>
|
|
276
|
+
<Select.List>{item => <Select.Item>{item.text}</Select.Item>}</Select.List>
|
|
277
|
+
</Select.Card>
|
|
278
|
+
</Select.Popper>
|
|
279
|
+
</FormField>
|
|
280
|
+
</Select>
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
- `getTextValue`: Optional function to return the text representation of an item. If not provided,
|
|
284
|
+
the default function will return the `text` property of the object of each item or an empty string
|
|
285
|
+
if there is no `text` property. If you did not provide `items`, do not override this function.
|
|
286
|
+
**Note: If your array of objects has a different property for `text`, like `label`, use this
|
|
287
|
+
function to set the text.**
|
|
288
|
+
|
|
289
|
+
```tsx
|
|
290
|
+
const options = [{label: 'Pizza', id: 'pizza-1'}, {label: 'Cheeseburger', id: 'cheeseburger'}]
|
|
291
|
+
<Select items={options} getTextValue={(item) => item.label}>
|
|
292
|
+
<FormField label="Your Label">
|
|
293
|
+
<Select.Input onChange={e => handleChange(e)} id="contact-select" />
|
|
294
|
+
<Select.Popper>
|
|
295
|
+
<Select.Card>
|
|
296
|
+
<Select.List>{item => <Select.Item>{item.label}</Select.Item>}</Select.List>
|
|
297
|
+
</Select.Card>
|
|
298
|
+
</Select.Popper>
|
|
299
|
+
</FormField>
|
|
300
|
+
</Select>
|
|
301
|
+
```
|
|
302
|
+
|
|
228
303
|
## Component API
|
|
229
304
|
|
|
230
305
|
<SymbolDoc name="Select" fileName="/react/" />
|
|
@@ -24,7 +24,7 @@ export default () => {
|
|
|
24
24
|
<Select items={options}>
|
|
25
25
|
<FormField>
|
|
26
26
|
<FormField.Label>Contact</FormField.Label>
|
|
27
|
-
<FormField.Input as={Select.Input} onChange={
|
|
27
|
+
<FormField.Input as={Select.Input} onChange={handleChange} />
|
|
28
28
|
<Select.Popper>
|
|
29
29
|
<Select.Card>
|
|
30
30
|
<Select.List>
|
|
@@ -4,14 +4,14 @@ import {Select} from '@workday/canvas-kit-react/select';
|
|
|
4
4
|
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
5
5
|
|
|
6
6
|
const options = [
|
|
7
|
-
{
|
|
8
|
-
{
|
|
9
|
-
{
|
|
10
|
-
{
|
|
11
|
-
{
|
|
7
|
+
{serverId: 'email', label: 'E-mail'},
|
|
8
|
+
{serverId: 'phone', label: 'Phone'},
|
|
9
|
+
{serverId: 'fax', label: 'Fax'},
|
|
10
|
+
{serverId: 'mail', label: 'Mail'},
|
|
11
|
+
{serverId: 'mobile', label: 'Mobile Phone'},
|
|
12
12
|
{
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
serverId: 'oasis',
|
|
14
|
+
label: 'The Ontologically Anthropocentric Sensory Immersive Simulation',
|
|
15
15
|
},
|
|
16
16
|
];
|
|
17
17
|
|
|
@@ -20,24 +20,19 @@ export default () => {
|
|
|
20
20
|
const [id, setId] = React.useState('');
|
|
21
21
|
|
|
22
22
|
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const handleSelect = ({id}: {id: string}) => {
|
|
27
|
-
setId(id);
|
|
23
|
+
setId(event.target.value);
|
|
24
|
+
setValue(options.find(item => item.serverId === event.target.value)!.label);
|
|
28
25
|
};
|
|
29
26
|
|
|
30
27
|
return (
|
|
31
28
|
<Flex flexDirection="column">
|
|
32
|
-
<Select items={options}
|
|
29
|
+
<Select items={options} getId={item => item.serverId} getTextValue={item => item.label}>
|
|
33
30
|
<FormField>
|
|
34
31
|
<FormField.Label>Contact</FormField.Label>
|
|
35
32
|
<FormField.Input as={Select.Input} onChange={e => handleChange(e)} />
|
|
36
33
|
<Select.Popper>
|
|
37
34
|
<Select.Card>
|
|
38
|
-
<Select.List>
|
|
39
|
-
{item => <Select.Item data-id={item.id}>{item.text}</Select.Item>}
|
|
40
|
-
</Select.List>
|
|
35
|
+
<Select.List>{item => <Select.Item>{item.label}</Select.Item>}</Select.List>
|
|
41
36
|
</Select.Card>
|
|
42
37
|
</Select.Popper>
|
|
43
38
|
</FormField>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
3
|
+
import {Select, useSelectModel} from '@workday/canvas-kit-react/select';
|
|
4
|
+
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
5
|
+
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
6
|
+
import {useMount} from '@workday/canvas-kit-react/common';
|
|
7
|
+
|
|
8
|
+
const movieListItems = [
|
|
9
|
+
{
|
|
10
|
+
label: 'The Lion King',
|
|
11
|
+
serverId: '123',
|
|
12
|
+
Year: '2019',
|
|
13
|
+
Runtime: '118 min',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
label: 'Mowgli: Legend of the Jungle',
|
|
17
|
+
serverId: '234',
|
|
18
|
+
Year: '2018',
|
|
19
|
+
Runtime: '104 min',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: 'Doctor Strange',
|
|
23
|
+
serverId: '345',
|
|
24
|
+
Year: '2016',
|
|
25
|
+
Runtime: '115 min',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: 'John Wick',
|
|
29
|
+
Year: '2014',
|
|
30
|
+
serverId: '456',
|
|
31
|
+
Runtime: '101 min',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: 'The Notebook',
|
|
35
|
+
serverId: '567',
|
|
36
|
+
Year: '2004',
|
|
37
|
+
Runtime: '123 min',
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
export default () => {
|
|
42
|
+
const [id, setId] = React.useState('456');
|
|
43
|
+
const [value, setValue] = React.useState('');
|
|
44
|
+
const [moviesLists, setMoviesList] = React.useState([]);
|
|
45
|
+
const [loadingStatus, setLoadingStatus] = React.useState<'idle' | 'loading' | 'success'>('idle');
|
|
46
|
+
const loadingRef = React.useRef<ReturnType<typeof setTimeout>>();
|
|
47
|
+
|
|
48
|
+
const model = useSelectModel({
|
|
49
|
+
items: moviesLists,
|
|
50
|
+
getTextValue: item => item.label,
|
|
51
|
+
getId: item => item.serverId,
|
|
52
|
+
initialSelectedIds: [id],
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
function loadItems() {
|
|
56
|
+
setLoadingStatus('loading');
|
|
57
|
+
loadingRef.current = setTimeout(() => {
|
|
58
|
+
setLoadingStatus('success');
|
|
59
|
+
setMoviesList(movieListItems);
|
|
60
|
+
}, 1500);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
useMount(() => {
|
|
64
|
+
return () => {
|
|
65
|
+
clearTimeout(loadingRef.current);
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<Flex flexDirection="column" maxWidth={300}>
|
|
71
|
+
<div id="foo">Foo Bar</div>
|
|
72
|
+
<Select model={model}>
|
|
73
|
+
<FormField label="Choose a Film">
|
|
74
|
+
<Select.Input
|
|
75
|
+
onChange={e => {
|
|
76
|
+
setId(e.target.value);
|
|
77
|
+
setValue(model.navigation.getItem(e.target.value, model).textValue);
|
|
78
|
+
}}
|
|
79
|
+
placeholder={loadingStatus}
|
|
80
|
+
/>
|
|
81
|
+
<Select.Popper>
|
|
82
|
+
<Select.Card>
|
|
83
|
+
<Select.List>
|
|
84
|
+
{item => {
|
|
85
|
+
return <Select.Item>{item.label}</Select.Item>;
|
|
86
|
+
}}
|
|
87
|
+
</Select.List>
|
|
88
|
+
</Select.Card>
|
|
89
|
+
</Select.Popper>
|
|
90
|
+
</FormField>
|
|
91
|
+
</Select>
|
|
92
|
+
<div data-testid="selected-id">Selected Id: {id}</div>
|
|
93
|
+
<div data-testid="selected-value">Selected value: {value}</div>
|
|
94
|
+
<PrimaryButton
|
|
95
|
+
onClick={() => {
|
|
96
|
+
loadItems();
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
Get Items
|
|
100
|
+
</PrimaryButton>
|
|
101
|
+
</Flex>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
@@ -25,11 +25,7 @@ export default () => {
|
|
|
25
25
|
<FormField.Input grow as={Select.Input} />
|
|
26
26
|
<Select.Popper>
|
|
27
27
|
<Select.Card>
|
|
28
|
-
{
|
|
29
|
-
<Select.List scrollMargin="10px">
|
|
30
|
-
{item => <Select.Item>{item}</Select.Item>}
|
|
31
|
-
</Select.List>
|
|
32
|
-
)}
|
|
28
|
+
<Select.List>{item => <Select.Item>{item}</Select.Item>}</Select.List>
|
|
33
29
|
</Select.Card>
|
|
34
30
|
</Select.Popper>
|
|
35
31
|
</FormField>
|
|
@@ -5,18 +5,17 @@ import {Select, useSelectModel} from '@workday/canvas-kit-react/select';
|
|
|
5
5
|
import {BodyText} from '@workday/canvas-kit-react/text';
|
|
6
6
|
|
|
7
7
|
const options = [
|
|
8
|
-
'E-mail',
|
|
9
|
-
'Phone',
|
|
10
|
-
'Fax
|
|
11
|
-
'Mail',
|
|
12
|
-
'Mobile Phone',
|
|
13
|
-
'The Ontologically Anthropocentric Sensory Immersive Simulation',
|
|
8
|
+
{text: 'E-mail', id: 'email-1'},
|
|
9
|
+
{text: 'Phone', id: 'phone-2'},
|
|
10
|
+
{text: 'Fax', id: 'fax-3'},
|
|
11
|
+
{text: 'Mail', id: 'mail-4'},
|
|
12
|
+
{text: 'Mobile Phone', id: 'mobile-phone-5'},
|
|
14
13
|
];
|
|
15
14
|
|
|
16
15
|
export default () => {
|
|
17
16
|
const model = useSelectModel({
|
|
18
17
|
items: options,
|
|
19
|
-
|
|
18
|
+
initialSelectedIds: ['fax-3'],
|
|
20
19
|
});
|
|
21
20
|
|
|
22
21
|
return (
|
|
@@ -27,13 +26,7 @@ export default () => {
|
|
|
27
26
|
<FormField.Input as={Select.Input} />
|
|
28
27
|
<Select.Popper>
|
|
29
28
|
<Select.Card>
|
|
30
|
-
<Select.List>
|
|
31
|
-
{item => (
|
|
32
|
-
<Select.Item aria-disabled={item === 'Fax (disabled)' ? true : undefined}>
|
|
33
|
-
{item}
|
|
34
|
-
</Select.Item>
|
|
35
|
-
)}
|
|
36
|
-
</Select.List>
|
|
29
|
+
<Select.List>{item => <Select.Item>{item.text}</Select.Item>}</Select.List>
|
|
37
30
|
</Select.Card>
|
|
38
31
|
</Select.Popper>
|
|
39
32
|
</FormField>
|
|
@@ -41,7 +34,7 @@ export default () => {
|
|
|
41
34
|
<BodyText size="small">Selected Value: {model.state.selectedIds[0]}</BodyText>
|
|
42
35
|
<SecondaryButton
|
|
43
36
|
onClick={() => {
|
|
44
|
-
model.events.select({id: '
|
|
37
|
+
model.events.select({id: 'phone-2'});
|
|
45
38
|
}}
|
|
46
39
|
>
|
|
47
40
|
Select Phone Item
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
3
|
+
import {Select} from '@workday/canvas-kit-react/select';
|
|
4
|
+
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
5
|
+
|
|
6
|
+
const options = [
|
|
7
|
+
{
|
|
8
|
+
id: 'b310c757b2d341f99d40d76f4d563c5b',
|
|
9
|
+
descriptor: 'Arabic',
|
|
10
|
+
languageCode: 'ar',
|
|
11
|
+
label: 'Arabic',
|
|
12
|
+
nativeLanguageName: 'العربية',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: 'a675a6b6e22d100017d7fe2a784d1255',
|
|
16
|
+
descriptor: 'Bulgarian (Bulgaria)',
|
|
17
|
+
languageCode: 'bg_BG',
|
|
18
|
+
label: 'Bulgarian (Bulgaria)',
|
|
19
|
+
nativeLanguageName: 'български (Република България)',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'da594226446c11de98360015c5e6daf6',
|
|
23
|
+
descriptor: 'English (United States)',
|
|
24
|
+
languageCode: 'en_US',
|
|
25
|
+
label: 'English (United States)',
|
|
26
|
+
nativeLanguageName: 'English',
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
export default () => {
|
|
31
|
+
const [value, setValue] = React.useState('English (United States)');
|
|
32
|
+
const [id, setId] = React.useState('da594226446c11de98360015c5e6daf6');
|
|
33
|
+
|
|
34
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
35
|
+
setId(event.target.value);
|
|
36
|
+
setValue(options.find(item => item.id === event.target.value).label);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Flex flexDirection="column">
|
|
41
|
+
<Select
|
|
42
|
+
items={options}
|
|
43
|
+
initialSelectedIds={['da594226446c11de98360015c5e6daf6']}
|
|
44
|
+
getId={item => item.id}
|
|
45
|
+
getTextValue={item => item.label}
|
|
46
|
+
>
|
|
47
|
+
<FormField label="Contact">
|
|
48
|
+
<Select.Input onChange={e => handleChange(e)} />
|
|
49
|
+
<Select.Popper>
|
|
50
|
+
<Select.Card>
|
|
51
|
+
<Select.List>{item => <Select.Item>{item.label}</Select.Item>}</Select.List>
|
|
52
|
+
</Select.Card>
|
|
53
|
+
</Select.Popper>
|
|
54
|
+
</FormField>
|
|
55
|
+
</Select>
|
|
56
|
+
<p>Id: {id}</p>
|
|
57
|
+
<p>Value: {value}</p>
|
|
58
|
+
</Flex>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
@@ -25,9 +25,7 @@ export default () => {
|
|
|
25
25
|
<FormField.Input as={Select.Input} />
|
|
26
26
|
<Select.Popper>
|
|
27
27
|
<Select.Card>
|
|
28
|
-
{
|
|
29
|
-
<Select.List>{item => <Select.Item>{item}</Select.Item>}</Select.List>
|
|
30
|
-
)}
|
|
28
|
+
<Select.List>{item => <Select.Item>{item}</Select.Item>}</Select.List>
|
|
31
29
|
</Select.Card>
|
|
32
30
|
</Select.Popper>
|
|
33
31
|
</FormField>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
3
|
+
import {Select} from '@workday/canvas-kit-react/select';
|
|
4
|
+
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
5
|
+
|
|
6
|
+
const options = [
|
|
7
|
+
'E-mail',
|
|
8
|
+
'Phone',
|
|
9
|
+
'Fax',
|
|
10
|
+
'Mail',
|
|
11
|
+
'Mobile Phone',
|
|
12
|
+
'The Ontologically Anthropocentric Sensory Immersive Simulation',
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
export default () => {
|
|
16
|
+
const [value, setValue] = React.useState('');
|
|
17
|
+
|
|
18
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
19
|
+
setValue(event.target.value);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Flex flexDirection="column">
|
|
24
|
+
<Select items={options}>
|
|
25
|
+
<FormField label="Contact">
|
|
26
|
+
<Select.Input placeholder="Make a Selection" onChange={e => handleChange(e)} />
|
|
27
|
+
<Select.Popper>
|
|
28
|
+
<Select.Card>
|
|
29
|
+
<Select.List>
|
|
30
|
+
{item => {
|
|
31
|
+
return <Select.Item>{item}</Select.Item>;
|
|
32
|
+
}}
|
|
33
|
+
</Select.List>
|
|
34
|
+
</Select.Card>
|
|
35
|
+
</Select.Popper>
|
|
36
|
+
</FormField>
|
|
37
|
+
</Select>
|
|
38
|
+
Selected Value: {value}
|
|
39
|
+
</Flex>
|
|
40
|
+
);
|
|
41
|
+
};
|
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.696-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.696-next.0",
|
|
48
|
+
"@workday/canvas-kit-preview-react": "^11.0.0-alpha.696-next.0",
|
|
49
|
+
"@workday/canvas-kit-react": "^11.0.0-alpha.696-next.0",
|
|
50
|
+
"@workday/canvas-kit-styling": "^11.0.0-alpha.696-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": "2b897235cbf8b889cd1e7f750e8c905b56944368"
|
|
63
63
|
}
|