@workday/canvas-kit-docs 16.1.3 → 16.2.0-0604-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 +18348 -5198
- package/dist/es6/lib/specs.js +204 -20
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.js +5 -5
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.ts +5 -5
- package/dist/mdx/accessibility/AccessibilityOverview.mdx +1 -3
- package/dist/mdx/labs-react/selection-group/SelectionGroup.mdx +135 -0
- package/dist/mdx/labs-react/selection-group/examples/Basic.tsx +11 -0
- package/dist/mdx/labs-react/selection-group/examples/Caution.tsx +27 -0
- package/dist/mdx/labs-react/selection-group/examples/ColumnWidth.tsx +17 -0
- package/dist/mdx/labs-react/selection-group/examples/ContentWidth.tsx +11 -0
- package/dist/mdx/labs-react/selection-group/examples/Disabled.tsx +33 -0
- package/dist/mdx/labs-react/selection-group/examples/EqualWidth.tsx +11 -0
- package/dist/mdx/labs-react/selection-group/examples/Error.tsx +27 -0
- package/dist/mdx/labs-react/selection-group/examples/MultiSelect.tsx +41 -0
- package/dist/mdx/labs-react/selection-group/examples/RTL.tsx +13 -0
- package/dist/mdx/labs-react/selection-group/examples/SingleSelect.tsx +33 -0
- package/dist/mdx/preview-react/_examples/mdx/FormLibraryExample.mdx +1 -33
- package/dist/mdx/preview-react/_examples/mdx/examples/TextInputWithReactHookForm.tsx +65 -94
- package/dist/mdx/react/_examples/mdx/Density.mdx +3 -19
- package/dist/mdx/react/_examples/mdx/FormsWithFormik.mdx +9 -0
- package/dist/mdx/react/_examples/mdx/examples/Density.tsx +212 -139
- package/dist/mdx/react/_examples/mdx/examples/SelectWithFormik.tsx +84 -0
- package/dist/mdx/react/expandable/Expandable.mdx +55 -161
- package/package.json +6 -6
|
@@ -1,38 +1,30 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {useUniqueId} from '@workday/canvas-kit-react/common';
|
|
5
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
3
|
+
import {FormField, FormFieldGroup} from '@workday/canvas-kit-react/form-field';
|
|
6
4
|
import {SegmentedControl} from '@workday/canvas-kit-react/segmented-control';
|
|
7
5
|
import {Select} from '@workday/canvas-kit-react/select';
|
|
8
|
-
import {
|
|
6
|
+
import {Switch} from '@workday/canvas-kit-react/switch';
|
|
7
|
+
import {Heading, Text} from '@workday/canvas-kit-react/text';
|
|
9
8
|
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
10
9
|
import {calc, createStencil, createStyles, px2rem} from '@workday/canvas-kit-styling';
|
|
11
10
|
import {base, system} from '@workday/canvas-tokens-web';
|
|
12
11
|
|
|
13
|
-
type DensityLevel = 'high' | 'medium' | 'low';
|
|
14
|
-
type LabelOrientation = 'vertical' | 'horizontalStart' | 'horizontalEnd';
|
|
15
|
-
type ContainerAlignment = 'left' | 'center';
|
|
16
|
-
type DensityTypeLevel = 'subtext.medium' | 'subtext.large' | 'body.small';
|
|
17
|
-
|
|
18
|
-
const densitySummary: Record<
|
|
19
|
-
DensityLevel,
|
|
20
|
-
{inputHeight: string; stackGap: string; typeLevel: DensityTypeLevel}
|
|
21
|
-
> = {
|
|
22
|
-
high: {inputHeight: '32px', stackGap: '16px', typeLevel: 'subtext.medium'},
|
|
23
|
-
medium: {inputHeight: '40px', stackGap: '24px', typeLevel: 'subtext.large'},
|
|
24
|
-
low: {inputHeight: '48px', stackGap: '32px', typeLevel: 'body.small'},
|
|
25
|
-
};
|
|
26
|
-
|
|
27
12
|
const formStyles = createStyles({
|
|
28
13
|
margin: `${px2rem(12)} ${'0'}`,
|
|
29
14
|
maxWidth: px2rem(600),
|
|
30
15
|
minWidth: '0',
|
|
31
16
|
});
|
|
32
17
|
|
|
18
|
+
const formFieldGroupListStyles = createStyles({
|
|
19
|
+
display: 'inline-flex',
|
|
20
|
+
flexDirection: 'row',
|
|
21
|
+
flexWrap: 'wrap',
|
|
22
|
+
});
|
|
23
|
+
|
|
33
24
|
const sideBySideInputs = createStencil({
|
|
34
25
|
base: {
|
|
35
26
|
display: 'inline-flex',
|
|
27
|
+
gap: system.gap.sm,
|
|
36
28
|
justifyContent: 'space-between',
|
|
37
29
|
},
|
|
38
30
|
modifiers: {
|
|
@@ -47,21 +39,52 @@ const sideBySideInputs = createStencil({
|
|
|
47
39
|
},
|
|
48
40
|
vertical: {
|
|
49
41
|
display: 'inline-flex',
|
|
50
|
-
flexDirection: 'row',
|
|
51
42
|
},
|
|
52
43
|
},
|
|
53
44
|
density: {
|
|
54
|
-
high: {
|
|
45
|
+
high: {},
|
|
46
|
+
medium: {},
|
|
47
|
+
low: {},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
compound: [
|
|
51
|
+
{
|
|
52
|
+
modifiers: {labelOrientation: 'horizontalStart', density: 'high'},
|
|
53
|
+
styles: {
|
|
55
54
|
gap: system.gap.md,
|
|
56
55
|
},
|
|
57
|
-
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
modifiers: {labelOrientation: 'horizontalStart', density: 'medium'},
|
|
59
|
+
styles: {
|
|
58
60
|
gap: system.gap.lg,
|
|
59
61
|
},
|
|
60
|
-
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
modifiers: {labelOrientation: 'horizontalStart', density: 'low'},
|
|
65
|
+
styles: {
|
|
61
66
|
gap: system.gap.xl,
|
|
62
67
|
},
|
|
63
68
|
},
|
|
64
|
-
|
|
69
|
+
{
|
|
70
|
+
modifiers: {labelOrientation: 'horizontalEnd', density: 'high'},
|
|
71
|
+
styles: {
|
|
72
|
+
gap: system.gap.md,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
modifiers: {labelOrientation: 'horizontalEnd', density: 'medium'},
|
|
77
|
+
styles: {
|
|
78
|
+
gap: system.gap.lg,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
modifiers: {labelOrientation: 'horizontalEnd', density: 'low'},
|
|
83
|
+
styles: {
|
|
84
|
+
gap: system.gap.xl,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
],
|
|
65
88
|
});
|
|
66
89
|
|
|
67
90
|
const zipCodeInput = createStyles({
|
|
@@ -73,10 +96,7 @@ const zipCodeContainerStyles = createStyles({
|
|
|
73
96
|
});
|
|
74
97
|
|
|
75
98
|
const formFieldStencil = createStencil({
|
|
76
|
-
base: {
|
|
77
|
-
// FormField's built-in margin would double-space with the stack gap below.
|
|
78
|
-
margin: 0,
|
|
79
|
-
},
|
|
99
|
+
base: {},
|
|
80
100
|
modifiers: {
|
|
81
101
|
density: {
|
|
82
102
|
high: {
|
|
@@ -135,6 +155,32 @@ const formFieldStencil = createStencil({
|
|
|
135
155
|
],
|
|
136
156
|
});
|
|
137
157
|
|
|
158
|
+
const selectStencil = createStencil({
|
|
159
|
+
base: {},
|
|
160
|
+
modifiers: {
|
|
161
|
+
density: {
|
|
162
|
+
high: {
|
|
163
|
+
height: system.size.sm,
|
|
164
|
+
padding: `${system.padding.xxs} ${system.padding.xs}`,
|
|
165
|
+
'& + div': {
|
|
166
|
+
height: system.size.sm,
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
medium: {
|
|
170
|
+
height: system.size.md,
|
|
171
|
+
padding: `${system.padding.xs}`,
|
|
172
|
+
},
|
|
173
|
+
low: {
|
|
174
|
+
height: calc.add(system.size.md, base.size100),
|
|
175
|
+
padding: `${system.padding.sm} ${system.padding.xs}`,
|
|
176
|
+
'& + div': {
|
|
177
|
+
height: calc.add(system.size.md, base.size100),
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
|
|
138
184
|
const inputStencil = createStencil({
|
|
139
185
|
base: {
|
|
140
186
|
minWidth: px2rem(200),
|
|
@@ -144,25 +190,29 @@ const inputStencil = createStencil({
|
|
|
144
190
|
high: {
|
|
145
191
|
height: system.size.sm,
|
|
146
192
|
padding: `${system.padding.xxs} ${system.padding.xs}`,
|
|
147
|
-
fontSize: system.legacy.fontSize.subtext.md,
|
|
148
|
-
lineHeight: system.legacy.lineHeight.subtext.md,
|
|
149
193
|
},
|
|
150
194
|
medium: {
|
|
151
195
|
height: system.size.md,
|
|
152
196
|
padding: `${system.padding.xs}`,
|
|
153
|
-
fontSize: system.legacy.fontSize.subtext.lg,
|
|
154
|
-
lineHeight: system.legacy.lineHeight.subtext.lg,
|
|
155
197
|
},
|
|
198
|
+
|
|
156
199
|
low: {
|
|
157
200
|
height: calc.add(system.size.md, base.size100),
|
|
158
201
|
padding: `${system.padding.sm} ${system.padding.xs}`,
|
|
159
|
-
fontSize: system.legacy.fontSize.body.sm,
|
|
160
|
-
lineHeight: system.legacy.lineHeight.body.sm,
|
|
161
202
|
},
|
|
162
203
|
},
|
|
163
204
|
},
|
|
164
205
|
});
|
|
165
206
|
|
|
207
|
+
const creditCardInputStencil = createStencil({
|
|
208
|
+
extends: inputStencil,
|
|
209
|
+
base: {
|
|
210
|
+
width: calc.add(system.size.md, system.size.md),
|
|
211
|
+
minWidth: calc.add(system.size.md, system.size.md),
|
|
212
|
+
textAlign: 'center',
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
|
|
166
216
|
const flexContainerStencil = createStencil({
|
|
167
217
|
base: {
|
|
168
218
|
display: 'flex',
|
|
@@ -213,44 +263,37 @@ const optionItemStyles = createStyles({
|
|
|
213
263
|
maxWidth: 'fit-content',
|
|
214
264
|
});
|
|
215
265
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const [labelOrientation, setLabelOrientation] = React.useState<LabelOrientation>('vertical');
|
|
220
|
-
const [fastShipping, setFastShipping] = React.useState(false);
|
|
221
|
-
const densityLabelId = useUniqueId();
|
|
222
|
-
const containerAlignmentLabelId = useUniqueId();
|
|
223
|
-
const labelOrientationLabelId = useUniqueId();
|
|
266
|
+
// high = 32px height on inputs, space between inputs is 16px
|
|
267
|
+
// medium 40px height on inputs, space between inputs is 24px
|
|
268
|
+
// low = 48px height on inputs, space between inputs is 32px
|
|
224
269
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
270
|
+
export default () => {
|
|
271
|
+
const [density, setDensity] = React.useState<'high' | 'medium' | 'low'>('medium');
|
|
272
|
+
const [containerAlignment, setContainerAlignment] = React.useState<'left' | 'center'>('left');
|
|
273
|
+
const [labelOrientation, setLabelOrientation] = React.useState<
|
|
274
|
+
'vertical' | 'horizontalStart' | 'horizontalEnd'
|
|
275
|
+
>('vertical');
|
|
228
276
|
|
|
229
|
-
const
|
|
230
|
-
|
|
277
|
+
const handleDensity = data => {
|
|
278
|
+
setDensity(data.id);
|
|
231
279
|
};
|
|
232
280
|
|
|
233
|
-
const
|
|
234
|
-
|
|
281
|
+
const handleContainerAlignment = data => {
|
|
282
|
+
setContainerAlignment(data.id);
|
|
235
283
|
};
|
|
236
284
|
|
|
237
|
-
const
|
|
238
|
-
|
|
285
|
+
const handleLabelOrientation = data => {
|
|
286
|
+
setLabelOrientation(data.id);
|
|
239
287
|
};
|
|
240
288
|
|
|
241
|
-
const labelTypeLevel = densitySummary[density].typeLevel;
|
|
242
|
-
const fieldCs = formFieldStencil({density, labelOrientation});
|
|
243
|
-
const inputCs = inputStencil({density});
|
|
244
|
-
|
|
245
289
|
return (
|
|
246
|
-
|
|
290
|
+
<div>
|
|
291
|
+
<Heading size="small">Choose Your Density and Alignment</Heading>
|
|
247
292
|
<div className={optionStyles}>
|
|
248
293
|
<div className={optionItemStyles}>
|
|
249
|
-
<Text
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
<SegmentedControl initialValue={density} onSelect={handleDensity} size="small">
|
|
253
|
-
<SegmentedControl.List aria-label="Density" aria-labelledby={densityLabelId}>
|
|
294
|
+
<Text>Density</Text>
|
|
295
|
+
<SegmentedControl onSelect={data => handleDensity(data)} size="small">
|
|
296
|
+
<SegmentedControl.List aria-label="choose a density">
|
|
254
297
|
<SegmentedControl.Item data-id="high">High</SegmentedControl.Item>
|
|
255
298
|
<SegmentedControl.Item data-id="medium">Medium</SegmentedControl.Item>
|
|
256
299
|
<SegmentedControl.Item data-id="low">Low</SegmentedControl.Item>
|
|
@@ -258,18 +301,9 @@ export default () => {
|
|
|
258
301
|
</SegmentedControl>
|
|
259
302
|
</div>
|
|
260
303
|
<div className={optionItemStyles}>
|
|
261
|
-
<Text
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
<SegmentedControl
|
|
265
|
-
initialValue={labelOrientation}
|
|
266
|
-
onSelect={handleLabelOrientation}
|
|
267
|
-
size="small"
|
|
268
|
-
>
|
|
269
|
-
<SegmentedControl.List
|
|
270
|
-
aria-label="Label Orientation"
|
|
271
|
-
aria-labelledby={labelOrientationLabelId}
|
|
272
|
-
>
|
|
304
|
+
<Text>Label Orientation</Text>
|
|
305
|
+
<SegmentedControl onSelect={data => handleLabelOrientation(data)} size="small">
|
|
306
|
+
<SegmentedControl.List aria-label="choose a label orientation">
|
|
273
307
|
<SegmentedControl.Item data-id="vertical">Vertical</SegmentedControl.Item>
|
|
274
308
|
<SegmentedControl.Item data-id="horizontalStart">
|
|
275
309
|
Horizontal Start
|
|
@@ -279,92 +313,131 @@ export default () => {
|
|
|
279
313
|
</SegmentedControl>
|
|
280
314
|
</div>
|
|
281
315
|
<div className={optionItemStyles}>
|
|
282
|
-
<Text
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
<SegmentedControl
|
|
286
|
-
initialValue={containerAlignment}
|
|
287
|
-
onSelect={handleContainerAlignment}
|
|
288
|
-
size="small"
|
|
289
|
-
>
|
|
290
|
-
<SegmentedControl.List
|
|
291
|
-
aria-label="Container Alignment"
|
|
292
|
-
aria-labelledby={containerAlignmentLabelId}
|
|
293
|
-
>
|
|
316
|
+
<Text>Container Alignment</Text>
|
|
317
|
+
<SegmentedControl onSelect={data => handleContainerAlignment(data)} size="small">
|
|
318
|
+
<SegmentedControl.List aria-label="choose a density">
|
|
294
319
|
<SegmentedControl.Item data-id="left">Left</SegmentedControl.Item>
|
|
295
320
|
<SegmentedControl.Item data-id="center">Center</SegmentedControl.Item>
|
|
296
321
|
</SegmentedControl.List>
|
|
297
322
|
</SegmentedControl>
|
|
298
323
|
</div>
|
|
299
|
-
<Subtext size="large">
|
|
300
|
-
Input height: {densitySummary[density].inputHeight}. Field spacing:{' '}
|
|
301
|
-
{densitySummary[density].stackGap}. Type: {densitySummary[density].typeLevel}.
|
|
302
|
-
</Subtext>
|
|
303
324
|
</div>
|
|
304
325
|
|
|
305
326
|
<div {...containerAlignmentStencil({alignment: containerAlignment})}>
|
|
306
|
-
<form className={formStyles}
|
|
307
|
-
<Heading size="small">Shipping Address</Heading>
|
|
327
|
+
<form action="#" className={formStyles}>
|
|
308
328
|
<div {...flexContainerStencil({density})}>
|
|
309
|
-
<FormField
|
|
310
|
-
|
|
311
|
-
|
|
329
|
+
<FormField
|
|
330
|
+
orientation={labelOrientation}
|
|
331
|
+
grow
|
|
332
|
+
cs={formFieldStencil({density, labelOrientation})}
|
|
333
|
+
id="foo"
|
|
334
|
+
>
|
|
335
|
+
<FormField.Label>Choose Country</FormField.Label>
|
|
336
|
+
<Select items={['Dominican Republic', 'Spain', 'United States']}>
|
|
337
|
+
<FormField.Input
|
|
338
|
+
cs={selectStencil({density})}
|
|
339
|
+
placeholder="Choose a country"
|
|
340
|
+
as={Select.Input}
|
|
341
|
+
/>
|
|
342
|
+
<Select.Popper>
|
|
343
|
+
<Select.Card>
|
|
344
|
+
<Select.List>{item => <Select.Item>{item}</Select.Item>}</Select.List>
|
|
345
|
+
</Select.Card>
|
|
346
|
+
</Select.Popper>
|
|
347
|
+
</Select>
|
|
312
348
|
</FormField>
|
|
313
|
-
<
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
<FormField
|
|
319
|
-
|
|
320
|
-
<FormField.Input as={TextInput} autoComplete="email" cs={inputCs} />
|
|
321
|
-
</FormField>
|
|
322
|
-
</div>
|
|
323
|
-
<FormField grow orientation={labelOrientation} cs={fieldCs}>
|
|
324
|
-
<FormField.Label typeLevel={labelTypeLevel}>Street Address</FormField.Label>
|
|
325
|
-
<FormField.Input as={TextInput} autoComplete="street-address" cs={inputCs} />
|
|
349
|
+
<FormField
|
|
350
|
+
grow
|
|
351
|
+
orientation={labelOrientation}
|
|
352
|
+
cs={formFieldStencil({density, labelOrientation})}
|
|
353
|
+
>
|
|
354
|
+
<FormField.Label>Full Name</FormField.Label>
|
|
355
|
+
<FormField.Input as={TextInput} cs={inputStencil({density})} />
|
|
326
356
|
</FormField>
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
</FormField>
|
|
333
|
-
<FormField
|
|
334
|
-
|
|
335
|
-
|
|
357
|
+
<FormField
|
|
358
|
+
grow
|
|
359
|
+
orientation={labelOrientation}
|
|
360
|
+
cs={formFieldStencil({density, labelOrientation})}
|
|
361
|
+
>
|
|
362
|
+
<FormField.Label>Phone Number</FormField.Label>
|
|
363
|
+
<FormField.Input as={TextInput} cs={inputStencil({density})} />
|
|
364
|
+
</FormField>
|
|
365
|
+
<FormField
|
|
366
|
+
grow
|
|
367
|
+
orientation={labelOrientation}
|
|
368
|
+
cs={formFieldStencil({density, labelOrientation})}
|
|
369
|
+
>
|
|
370
|
+
<FormField.Label>Street Address</FormField.Label>
|
|
371
|
+
<FormField.Input as={TextInput} cs={inputStencil({density})} />
|
|
372
|
+
</FormField>
|
|
373
|
+
<FormField
|
|
374
|
+
grow
|
|
375
|
+
orientation={labelOrientation}
|
|
376
|
+
cs={formFieldStencil({density, labelOrientation})}
|
|
377
|
+
>
|
|
378
|
+
<FormField.Label>City</FormField.Label>
|
|
379
|
+
<FormField.Input as={TextInput} cs={inputStencil({density})} />
|
|
380
|
+
</FormField>
|
|
381
|
+
<div {...sideBySideInputs({labelOrientation: labelOrientation, density})}>
|
|
382
|
+
<FormField
|
|
383
|
+
grow
|
|
384
|
+
orientation={labelOrientation}
|
|
385
|
+
cs={formFieldStencil({density, labelOrientation})}
|
|
386
|
+
>
|
|
387
|
+
<FormField.Label>State</FormField.Label>
|
|
388
|
+
<FormField.Input as={TextInput} cs={inputStencil({density})} />
|
|
336
389
|
</FormField>
|
|
337
|
-
<FormField
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
/>
|
|
390
|
+
<FormField
|
|
391
|
+
grow
|
|
392
|
+
orientation={labelOrientation}
|
|
393
|
+
cs={[formFieldStencil({density, labelOrientation}), zipCodeContainerStyles]}
|
|
394
|
+
>
|
|
395
|
+
<FormField.Label>Zip Code</FormField.Label>
|
|
396
|
+
<FormField.Input cs={[inputStencil({density}), zipCodeInput]} as={TextInput} />
|
|
344
397
|
</FormField>
|
|
345
398
|
</div>
|
|
346
|
-
<FormField
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
<Select.Popper>
|
|
352
|
-
<Select.Card>
|
|
353
|
-
<Select.List>{item => <Select.Item>{item}</Select.Item>}</Select.List>
|
|
354
|
-
</Select.Card>
|
|
355
|
-
</Select.Popper>
|
|
356
|
-
</Select>
|
|
357
|
-
</FormField.Field>
|
|
358
|
-
</FormField>
|
|
359
|
-
<FormField orientation={labelOrientation} cs={fieldCs}>
|
|
360
|
-
<FormField.Label typeLevel={labelTypeLevel}>Enable Fast Shipping</FormField.Label>
|
|
399
|
+
<FormField
|
|
400
|
+
orientation={labelOrientation}
|
|
401
|
+
cs={formFieldStencil({density, labelOrientation})}
|
|
402
|
+
>
|
|
403
|
+
<FormField.Label>Enable Fast Shipping</FormField.Label>
|
|
361
404
|
<FormField.Field>
|
|
362
|
-
<FormField.Input as={Switch}
|
|
405
|
+
<FormField.Input as={Switch} />
|
|
363
406
|
</FormField.Field>
|
|
364
407
|
</FormField>
|
|
408
|
+
<FormFieldGroup
|
|
409
|
+
cs={formFieldStencil({density, labelOrientation})}
|
|
410
|
+
orientation={labelOrientation}
|
|
411
|
+
>
|
|
412
|
+
<FormFieldGroup.Label>Credit Card</FormFieldGroup.Label>
|
|
413
|
+
<FormFieldGroup.Field>
|
|
414
|
+
<FormFieldGroup.List cs={formFieldGroupListStyles}>
|
|
415
|
+
<FormFieldGroup.Input
|
|
416
|
+
as={TextInput}
|
|
417
|
+
placeholder="XXXX"
|
|
418
|
+
cs={creditCardInputStencil({density})}
|
|
419
|
+
/>
|
|
420
|
+
<FormFieldGroup.Input
|
|
421
|
+
as={TextInput}
|
|
422
|
+
placeholder="XXXX"
|
|
423
|
+
cs={creditCardInputStencil({density})}
|
|
424
|
+
/>
|
|
425
|
+
<FormFieldGroup.Input
|
|
426
|
+
as={TextInput}
|
|
427
|
+
placeholder="XXXX"
|
|
428
|
+
cs={creditCardInputStencil({density})}
|
|
429
|
+
/>
|
|
430
|
+
<FormFieldGroup.Input
|
|
431
|
+
cs={creditCardInputStencil({density})}
|
|
432
|
+
placeholder="XXXX"
|
|
433
|
+
as={TextInput}
|
|
434
|
+
/>
|
|
435
|
+
</FormFieldGroup.List>
|
|
436
|
+
</FormFieldGroup.Field>
|
|
437
|
+
</FormFieldGroup>
|
|
365
438
|
</div>
|
|
366
439
|
</form>
|
|
367
440
|
</div>
|
|
368
|
-
|
|
441
|
+
</div>
|
|
369
442
|
);
|
|
370
443
|
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {useFormik} from 'formik';
|
|
2
|
+
|
|
3
|
+
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
+
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
5
|
+
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
6
|
+
import {Select, useSelectModel} from '@workday/canvas-kit-react/select';
|
|
7
|
+
import {px2rem} from '@workday/canvas-kit-styling';
|
|
8
|
+
import {cloudArrowUpIcon, cloudIcon, commentIcon, userIcon} from '@workday/canvas-system-icons-web';
|
|
9
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
10
|
+
|
|
11
|
+
export default [
|
|
12
|
+
{
|
|
13
|
+
label: 'Dessert Person by Claire Saffitz',
|
|
14
|
+
serverId: 1,
|
|
15
|
+
icon: commentIcon,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
label: 'Elements of Pizza by Ken Forkish',
|
|
19
|
+
serverId: 2,
|
|
20
|
+
icon: cloudIcon,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
label: 'Flour Water Salt Yeast by Ken Forkish',
|
|
24
|
+
serverId: 3,
|
|
25
|
+
icon: cloudArrowUpIcon,
|
|
26
|
+
},
|
|
27
|
+
{label: 'Mastering Pasta by Marc Verti', serverId: 4, icon: userIcon},
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
export default () => {
|
|
31
|
+
const formik = useFormik({
|
|
32
|
+
initialValues: {
|
|
33
|
+
selectedBook: '',
|
|
34
|
+
},
|
|
35
|
+
onSubmit: values => {
|
|
36
|
+
// Send data to server
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
alert(JSON.stringify(values, null, 2));
|
|
39
|
+
}, 0);
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const selectModel = useSelectModel({
|
|
44
|
+
items: customOptionsMain,
|
|
45
|
+
getId: item => {
|
|
46
|
+
return item.serverId;
|
|
47
|
+
},
|
|
48
|
+
getTextValue: item => item.label,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<form onSubmit={formik.handleSubmit} action=".">
|
|
53
|
+
<Flex cs={{gap: system.gap.sm, flexDirection: 'column', alignItems: 'flex-start'}}>
|
|
54
|
+
<FormField orientation="vertical" cs={{alignSelf: 'stretch', alignItems: 'normal'}}>
|
|
55
|
+
<Select model={selectModel}>
|
|
56
|
+
<FormField.Label>Choose a book</FormField.Label>
|
|
57
|
+
<FormField.Input
|
|
58
|
+
as={Select.Input}
|
|
59
|
+
name="selectedBook"
|
|
60
|
+
onChange={event => formik.setFieldValue('selectedBook', event.currentTarget.value)}
|
|
61
|
+
value={formik.values.selectedBook}
|
|
62
|
+
grow
|
|
63
|
+
/>
|
|
64
|
+
<Select.Popper>
|
|
65
|
+
<Select.Card>
|
|
66
|
+
<Select.List cs={{maxHeight: px2rem(200)}}>
|
|
67
|
+
{item => {
|
|
68
|
+
return (
|
|
69
|
+
<Select.Item data-id={item.serverId} data-text={item.label}>
|
|
70
|
+
<Select.Item.Icon icon={item.icon} />
|
|
71
|
+
{item.label}
|
|
72
|
+
</Select.Item>
|
|
73
|
+
);
|
|
74
|
+
}}
|
|
75
|
+
</Select.List>
|
|
76
|
+
</Select.Card>
|
|
77
|
+
</Select.Popper>
|
|
78
|
+
</Select>
|
|
79
|
+
</FormField>
|
|
80
|
+
<PrimaryButton type="submit">Submit</PrimaryButton>
|
|
81
|
+
</Flex>
|
|
82
|
+
</form>
|
|
83
|
+
);
|
|
84
|
+
};
|