@workday/canvas-kit-docs 10.0.8 → 10.0.10
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/specs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import {useFormik} from 'formik';
|
|
3
|
-
import {Select} from '@workday/canvas-kit-
|
|
3
|
+
import {Select, useSelectModel} from '@workday/canvas-kit-react/select';
|
|
4
4
|
import {
|
|
5
5
|
FormField,
|
|
6
6
|
useFormFieldInput,
|
|
@@ -8,6 +8,31 @@ import {
|
|
|
8
8
|
} from '@workday/canvas-kit-preview-react/form-field';
|
|
9
9
|
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
10
10
|
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
11
|
+
import {
|
|
12
|
+
activityStreamIcon,
|
|
13
|
+
avatarIcon,
|
|
14
|
+
uploadCloudIcon,
|
|
15
|
+
userIcon,
|
|
16
|
+
} from '@workday/canvas-system-icons-web';
|
|
17
|
+
|
|
18
|
+
export default [
|
|
19
|
+
{
|
|
20
|
+
label: 'Dessert Person by Claire Saffitz',
|
|
21
|
+
serverId: 1,
|
|
22
|
+
icon: activityStreamIcon,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: 'Elements of Pizza by Ken Forkish',
|
|
26
|
+
serverId: 2,
|
|
27
|
+
icon: avatarIcon,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
label: 'Flour Water Salt Yeast by Ken Forkish',
|
|
31
|
+
serverId: 3,
|
|
32
|
+
icon: uploadCloudIcon,
|
|
33
|
+
},
|
|
34
|
+
{label: 'Mastering Pasta by Marc Verti', serverId: 4, icon: userIcon},
|
|
35
|
+
];
|
|
11
36
|
|
|
12
37
|
export default () => {
|
|
13
38
|
const formik = useFormik({
|
|
@@ -22,34 +47,45 @@ export default () => {
|
|
|
22
47
|
},
|
|
23
48
|
});
|
|
24
49
|
|
|
25
|
-
const
|
|
26
|
-
|
|
50
|
+
const selectModel = useSelectModel({
|
|
51
|
+
items: customOptionsMain,
|
|
52
|
+
getId: item => {
|
|
53
|
+
return item.serverId;
|
|
54
|
+
},
|
|
55
|
+
getTextValue: item => item.label,
|
|
56
|
+
});
|
|
27
57
|
|
|
28
58
|
return (
|
|
29
59
|
<form onSubmit={formik.handleSubmit} action=".">
|
|
30
60
|
<Flex gap="xs" flexDirection="column" alignItems="flex-start">
|
|
31
61
|
<FormField orientation="vertical" alignSelf="stretch" alignItems="normal">
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
62
|
+
<Select model={selectModel}>
|
|
63
|
+
<FormField.Label>Choose a book</FormField.Label>
|
|
64
|
+
<FormField.Input
|
|
65
|
+
as={Select.Input}
|
|
66
|
+
name="selectedBook"
|
|
67
|
+
onChange={event => formik.setFieldValue('selectedBook', event.currentTarget.value)}
|
|
68
|
+
value={formik.values.selectedBook}
|
|
69
|
+
grow
|
|
70
|
+
/>
|
|
71
|
+
<Select.Popper>
|
|
72
|
+
<Select.Card>
|
|
73
|
+
<Select.List maxHeight={200}>
|
|
74
|
+
{item => {
|
|
75
|
+
return (
|
|
76
|
+
<Select.Item data-id={item.serverId} data-text={item.label}>
|
|
77
|
+
<Select.Item.Icon icon={item.icon} />
|
|
78
|
+
{item.label}
|
|
79
|
+
</Select.Item>
|
|
80
|
+
);
|
|
81
|
+
}}
|
|
82
|
+
</Select.List>
|
|
83
|
+
</Select.Card>
|
|
84
|
+
</Select.Popper>
|
|
85
|
+
</Select>
|
|
41
86
|
</FormField>
|
|
42
87
|
<PrimaryButton type="submit">Submit</PrimaryButton>
|
|
43
88
|
</Flex>
|
|
44
89
|
</form>
|
|
45
90
|
);
|
|
46
91
|
};
|
|
47
|
-
|
|
48
|
-
const bookList = [
|
|
49
|
-
{label: 'Dessert Person by Claire Saffitz', value: 'dessert person'},
|
|
50
|
-
{label: 'Elements of Pizza by Ken Forkish', value: 'the elements of pizza'},
|
|
51
|
-
{label: 'Flour Water Salt Yeast by Ken Forkish', value: 'flour water salt yeast'},
|
|
52
|
-
{label: 'Mastering Pasta by Marc Verti', value: 'mastering pasta'},
|
|
53
|
-
{label: 'Patisserie by Christophe Felder', value: 'patisserie'},
|
|
54
|
-
{label: 'Tartine by Elisabeth Prueitt & Chad Robertson', value: 'tartine'},
|
|
55
|
-
];
|
|
@@ -6,6 +6,8 @@ import {object, SchemaOf, string} from 'yup';
|
|
|
6
6
|
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
7
7
|
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
8
8
|
import {TertiaryButton, PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
9
|
+
import {Select} from '@workday/canvas-kit-react/select';
|
|
10
|
+
import {FormField} from '@workday/canvas-kit-preview-react/form-field';
|
|
9
11
|
import {visibleIcon, invisibleIcon} from '@workday/canvas-system-icons-web';
|
|
10
12
|
import {useUniqueId} from '@workday/canvas-kit-react/common';
|
|
11
13
|
|
|
@@ -13,7 +15,7 @@ type YupValidationResolver = <T extends {}>(
|
|
|
13
15
|
validationSchema: SchemaOf<T>
|
|
14
16
|
) => (data: T) => Promise<{values: T; errors: {}} | {values: {}; errors: FieldErrorsImpl<T>}>;
|
|
15
17
|
|
|
16
|
-
const useYupValidationResolver:
|
|
18
|
+
const useYupValidationResolver: YupValidationResolver = validationSchema => {
|
|
17
19
|
return React.useCallback(
|
|
18
20
|
async data => {
|
|
19
21
|
try {
|
|
@@ -42,22 +44,23 @@ const useYupValidationResolver: any = validationSchema => {
|
|
|
42
44
|
interface LoginSchema {
|
|
43
45
|
email: string;
|
|
44
46
|
password: string;
|
|
47
|
+
role: string;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
const passwordMinimum = 8;
|
|
48
51
|
const passwordHint = `Password should be of minimum ${passwordMinimum} characters length`;
|
|
49
52
|
const emailRequired = 'Email is required';
|
|
50
53
|
const passwordRequired = 'Password is required';
|
|
54
|
+
const roleRequired = 'Role is required';
|
|
51
55
|
|
|
52
56
|
const validationSchema: SchemaOf<LoginSchema> = object({
|
|
53
|
-
email: string()
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
password: string()
|
|
57
|
-
.min(passwordMinimum, passwordHint)
|
|
58
|
-
.required(passwordRequired),
|
|
57
|
+
email: string().email('Enter a valid email').required(emailRequired),
|
|
58
|
+
password: string().min(passwordMinimum, passwordHint).required(passwordRequired),
|
|
59
|
+
role: string().required(roleRequired),
|
|
59
60
|
});
|
|
60
61
|
|
|
62
|
+
const options = ['Developer', 'Designer', 'Product Manager'];
|
|
63
|
+
|
|
61
64
|
export default () => {
|
|
62
65
|
const {
|
|
63
66
|
handleSubmit,
|
|
@@ -67,6 +70,7 @@ export default () => {
|
|
|
67
70
|
defaultValues: {
|
|
68
71
|
email: 'example@baz.com',
|
|
69
72
|
password: 'foobarbaz',
|
|
73
|
+
role: 'Designer',
|
|
70
74
|
},
|
|
71
75
|
resolver: useYupValidationResolver(validationSchema),
|
|
72
76
|
mode: 'onTouched',
|
|
@@ -92,6 +96,22 @@ export default () => {
|
|
|
92
96
|
return (
|
|
93
97
|
<form onSubmit={onSubmit} action=".">
|
|
94
98
|
<Flex gap="xs" flexDirection="column" alignItems="flex-start">
|
|
99
|
+
<FormField orientation="vertical" isRequired={true} hasError={!!errors.role}>
|
|
100
|
+
<Select items={options}>
|
|
101
|
+
<FormField.Label>What is your role?</FormField.Label>
|
|
102
|
+
<FormField.Input as={Select.Input} {...register('role')} width="280px" />
|
|
103
|
+
<Select.Popper>
|
|
104
|
+
<Select.Card>
|
|
105
|
+
<Select.List maxHeight={200}>
|
|
106
|
+
{item => {
|
|
107
|
+
return <Select.Item>{item}</Select.Item>;
|
|
108
|
+
}}
|
|
109
|
+
</Select.List>
|
|
110
|
+
</Select.Card>
|
|
111
|
+
</Select.Popper>
|
|
112
|
+
<FormField.Hint>{errors.role?.message}</FormField.Hint>
|
|
113
|
+
</Select>
|
|
114
|
+
</FormField>
|
|
95
115
|
<TextInput orientation="vertical" isRequired={true} hasError={!!errors.email}>
|
|
96
116
|
<TextInput.Label>Email</TextInput.Label>
|
|
97
117
|
<TextInput.Field
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.10",
|
|
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": "^10.0.
|
|
48
|
-
"@workday/canvas-kit-preview-react": "^10.0.
|
|
49
|
-
"@workday/canvas-kit-react": "^10.0.
|
|
50
|
-
"@workday/canvas-kit-styling": "^10.0.
|
|
47
|
+
"@workday/canvas-kit-labs-react": "^10.0.10",
|
|
48
|
+
"@workday/canvas-kit-preview-react": "^10.0.10",
|
|
49
|
+
"@workday/canvas-kit-react": "^10.0.10",
|
|
50
|
+
"@workday/canvas-kit-styling": "^10.0.10",
|
|
51
51
|
"@workday/canvas-system-icons-web": "^3.0.0",
|
|
52
52
|
"@workday/canvas-tokens-web": "^1.0.0",
|
|
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": "0151ebb7cf081ea1aae115fd90770765cd949714"
|
|
63
63
|
}
|