@workday/canvas-kit-docs 5.2.7 → 5.3.0-next.9

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.
Files changed (27) hide show
  1. package/dist/commonjs/lib/specs.js +134 -0
  2. package/dist/es6/lib/specs.js +134 -0
  3. package/dist/mdx/6.0-MIGRATION-GUIDE.mdx +296 -0
  4. package/dist/mdx/labs-react/search-form/SearchForm.mdx +64 -0
  5. package/dist/mdx/labs-react/search-form/examples/Basic.tsx +61 -0
  6. package/dist/mdx/labs-react/search-form/examples/CustomTheme.tsx +72 -0
  7. package/dist/mdx/labs-react/search-form/examples/Grow.tsx +62 -0
  8. package/dist/mdx/labs-react/search-form/examples/PropTables.splitProps.tsx +4 -0
  9. package/dist/mdx/labs-react/search-form/examples/RTL.tsx +70 -0
  10. package/dist/mdx/labs-react/search-form/examples/Theming.tsx +64 -0
  11. package/dist/mdx/labs-react/text-input/TextInput.mdx +123 -0
  12. package/dist/mdx/labs-react/text-input/examples/Alert.tsx +46 -0
  13. package/dist/mdx/labs-react/text-input/examples/Basic.tsx +20 -0
  14. package/dist/mdx/labs-react/text-input/examples/Disabled.tsx +20 -0
  15. package/dist/mdx/labs-react/text-input/examples/Error.tsx +43 -0
  16. package/dist/mdx/labs-react/text-input/examples/Grow.tsx +20 -0
  17. package/dist/mdx/labs-react/text-input/examples/HiddenLabel.tsx +17 -0
  18. package/dist/mdx/labs-react/text-input/examples/LabelPosition.tsx +20 -0
  19. package/dist/mdx/labs-react/text-input/examples/LoginForm.tsx +100 -0
  20. package/dist/mdx/labs-react/text-input/examples/Password.tsx +20 -0
  21. package/dist/mdx/labs-react/text-input/examples/Placeholder.tsx +20 -0
  22. package/dist/mdx/labs-react/text-input/examples/RefForwarding.tsx +27 -0
  23. package/dist/mdx/labs-react/text-input/examples/Required.tsx +20 -0
  24. package/dist/mdx/labs-react/text-input/examples/ThemedAlert.tsx +51 -0
  25. package/dist/mdx/labs-react/text-input/examples/ThemedError.tsx +40 -0
  26. package/dist/mdx/react/text-area/TextArea.mdx +1 -1
  27. package/package.json +3 -3
@@ -0,0 +1,100 @@
1
+ import React from 'react';
2
+
3
+ import {useFormik} from 'formik';
4
+ import * as yup from 'yup';
5
+
6
+ import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
7
+ import {HStack, VStack} from '@workday/canvas-kit-labs-react/layout';
8
+ import {IconButton, PrimaryButton} from '@workday/canvas-kit-react/button';
9
+ import {visibleIcon, invisibleIcon} from '@workday/canvas-system-icons-web';
10
+ import {useUniqueId} from '@workday/canvas-kit-react/common';
11
+
12
+ export default () => {
13
+ const passwordMinimum = 8;
14
+ const passwordHint = `Password should be of minimum ${passwordMinimum} characters length`;
15
+ const emailRequired = 'Email is required';
16
+ const passwordRequired = 'Password is required';
17
+
18
+ const validationSchema = yup.object({
19
+ email: yup
20
+ .string()
21
+ .email('Enter a valid email')
22
+ .required(emailRequired),
23
+ password: yup
24
+ .string()
25
+ .min(passwordMinimum, passwordHint)
26
+ .required(passwordRequired),
27
+ });
28
+
29
+ const passwordRef = React.useRef<HTMLInputElement>(null);
30
+ const [showPassword, setShowPassword] = React.useState(false);
31
+ const passwordId = useUniqueId();
32
+
33
+ const formik = useFormik({
34
+ initialValues: {
35
+ email: 'example@baz.com',
36
+ password: 'foobarbaz',
37
+ },
38
+ validationSchema: validationSchema,
39
+ onSubmit: values => {
40
+ passwordRef.current.type = 'password';
41
+
42
+ // Send data to server
43
+ setTimeout(() => {
44
+ alert(JSON.stringify(values, null, 2));
45
+ }, 0);
46
+ },
47
+ });
48
+
49
+ return (
50
+ <form onSubmit={formik.handleSubmit} action=".">
51
+ <VStack spacing="xs" alignItems="flex-start">
52
+ <TextInput isRequired={true} hasError={formik.touched.email && !!formik.errors.email}>
53
+ <TextInput.Label>Email</TextInput.Label>
54
+ <TextInput.Field
55
+ name="email"
56
+ autoComplete="username"
57
+ placeholder="yourName@example.com"
58
+ onChange={formik.handleChange}
59
+ onBlur={formik.handleBlur}
60
+ value={formik.values.email}
61
+ />
62
+ <TextInput.Hint>{formik.touched.email && formik.errors.email}</TextInput.Hint>
63
+ </TextInput>
64
+ <TextInput
65
+ inputId={passwordId}
66
+ hasError={formik.touched.password && !!formik.errors.password}
67
+ isRequired={true}
68
+ >
69
+ <TextInput.Label>Password</TextInput.Label>
70
+ <HStack spacing="xxs">
71
+ <TextInput.Field
72
+ type={showPassword ? 'text' : 'password'}
73
+ name="password"
74
+ autoComplete="current-password"
75
+ ref={passwordRef}
76
+ onChange={formik.handleChange}
77
+ onBlur={formik.handleBlur}
78
+ value={formik.values.password}
79
+ />
80
+ <IconButton
81
+ type="button"
82
+ icon={showPassword ? invisibleIcon : visibleIcon}
83
+ aria-label={showPassword ? 'Hide Password' : 'Show Password'}
84
+ aria-controls={passwordId}
85
+ onClick={() => {
86
+ setShowPassword(state => !state);
87
+ passwordRef.current.focus();
88
+ }}
89
+ />
90
+ </HStack>
91
+ <TextInput.Hint>
92
+ {(formik.touched.password && formik.errors.password) || passwordHint}
93
+ </TextInput.Hint>
94
+ </TextInput>
95
+
96
+ <PrimaryButton type="submit">Submit</PrimaryButton>
97
+ </VStack>
98
+ </form>
99
+ );
100
+ };
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
3
+ import {VStack} from '@workday/canvas-kit-labs-react/layout';
4
+
5
+ export default () => {
6
+ const [value, setValue] = React.useState('SuperSecret1');
7
+
8
+ const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
9
+ setValue(event.target.value);
10
+ };
11
+
12
+ return (
13
+ <VStack spacing="xxxs" alignItems="flex-start">
14
+ <TextInput>
15
+ <TextInput.Label>Password</TextInput.Label>
16
+ <TextInput.Field onChange={handleChange} value={value} type="password" />
17
+ </TextInput>
18
+ </VStack>
19
+ );
20
+ };
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
3
+ import {VStack} from '@workday/canvas-kit-labs-react/layout';
4
+
5
+ export default () => {
6
+ const [value, setValue] = React.useState('');
7
+
8
+ const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
9
+ setValue(event.target.value);
10
+ };
11
+
12
+ return (
13
+ <VStack spacing="xxxs" alignItems="flex-start">
14
+ <TextInput>
15
+ <TextInput.Label>Email</TextInput.Label>
16
+ <TextInput.Field onChange={handleChange} value={value} placeholder="user@email.com" />
17
+ </TextInput>
18
+ </VStack>
19
+ );
20
+ };
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
3
+ import {VStack} from '@workday/canvas-kit-labs-react/layout';
4
+ import {PrimaryButton} from '@workday/canvas-kit-react/button';
5
+
6
+ export default () => {
7
+ const [value, setValue] = React.useState('');
8
+ const ref = React.useRef(null);
9
+
10
+ const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
11
+ setValue(event.target.value);
12
+ };
13
+
14
+ const handleClick = () => {
15
+ ref.current.focus();
16
+ };
17
+
18
+ return (
19
+ <VStack spacing="xxxs" alignItems="flex-start">
20
+ <TextInput>
21
+ <TextInput.Label>Email</TextInput.Label>
22
+ <TextInput.Field onChange={handleChange} value={value} ref={ref} />
23
+ </TextInput>
24
+ <PrimaryButton onClick={handleClick}>Focus Text Input</PrimaryButton>
25
+ </VStack>
26
+ );
27
+ };
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
3
+ import {VStack} from '@workday/canvas-kit-labs-react/layout';
4
+
5
+ export default () => {
6
+ const [value, setValue] = React.useState('');
7
+
8
+ const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
9
+ setValue(event.target.value);
10
+ };
11
+
12
+ return (
13
+ <VStack spacing="xxxs" alignItems="flex-start">
14
+ <TextInput isRequired={true}>
15
+ <TextInput.Label>Email</TextInput.Label>
16
+ <TextInput.Field onChange={handleChange} value={value} />
17
+ </TextInput>
18
+ </VStack>
19
+ );
20
+ };
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
3
+ import {useThemedRing} from '@workday/canvas-kit-labs-react/common';
4
+ import {VStack} from '@workday/canvas-kit-labs-react/layout';
5
+ import {CanvasProvider, PartialEmotionCanvasTheme, styled} from '@workday/canvas-kit-react/common';
6
+ import {colors, CSSProperties, space} from '@workday/canvas-kit-react/tokens';
7
+
8
+ export default () => {
9
+ const theme: PartialEmotionCanvasTheme = {
10
+ canvas: {
11
+ palette: {
12
+ common: {
13
+ focusOutline: colors.grapeSoda300,
14
+ },
15
+ alert: {
16
+ main: colors.kiwi500,
17
+ darkest: colors.kiwi600,
18
+ },
19
+ },
20
+ },
21
+ };
22
+ return (
23
+ <CanvasProvider theme={theme}>
24
+ <AlertInput />
25
+ </CanvasProvider>
26
+ );
27
+ };
28
+
29
+ const StyledField = styled(TextInput.Field)<{alertStyles?: CSSProperties}>(
30
+ ({alertStyles}) => alertStyles
31
+ );
32
+
33
+ const AlertInput = () => {
34
+ const [value, setValue] = React.useState('invalid@email');
35
+
36
+ const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
37
+ setValue(event.target.value);
38
+ };
39
+
40
+ const alertStyles = useThemedRing('alert');
41
+
42
+ return (
43
+ <VStack spacing="xxxs" alignItems="flex-start">
44
+ <TextInput>
45
+ <TextInput.Label>Email</TextInput.Label>
46
+ <StyledField alertStyles={alertStyles} onChange={handleChange} value={value} />
47
+ <TextInput.Hint paddingTop={space.xxs}>Please enter a valid email.</TextInput.Hint>
48
+ </TextInput>
49
+ </VStack>
50
+ );
51
+ };
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
3
+ import {VStack} from '@workday/canvas-kit-labs-react/layout';
4
+ import {CanvasProvider, PartialEmotionCanvasTheme} from '@workday/canvas-kit-react/common';
5
+ import {colors, space} from '@workday/canvas-kit-react/tokens';
6
+
7
+ export default () => {
8
+ const [value, setValue] = React.useState('');
9
+
10
+ const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
11
+ setValue(event.target.value);
12
+ };
13
+
14
+ const theme: PartialEmotionCanvasTheme = {
15
+ canvas: {
16
+ palette: {
17
+ common: {
18
+ focusOutline: colors.grapeSoda300,
19
+ },
20
+ error: {
21
+ main: colors.islandPunch400,
22
+ },
23
+ },
24
+ },
25
+ };
26
+
27
+ return (
28
+ <CanvasProvider theme={theme}>
29
+ <VStack spacing="xxxs" alignItems="flex-start">
30
+ <TextInput hasError={!value} isRequired={true}>
31
+ <TextInput.Label>Email</TextInput.Label>
32
+ <TextInput.Field onChange={handleChange} value={value} />
33
+ <TextInput.Hint paddingTop={space.xxs}>
34
+ {!value && 'Please enter an email.'}
35
+ </TextInput.Hint>
36
+ </TextInput>
37
+ </VStack>
38
+ </CanvasProvider>
39
+ );
40
+ };
@@ -23,7 +23,7 @@ Text Areas allow users to enter and edit multiple lines of text.
23
23
  ## Installation
24
24
 
25
25
  ```sh
26
- yarn add @workday/canvas-kit-react
26
+ yarn add @workday/canvas-kit-labs-react
27
27
  ```
28
28
 
29
29
  ## Usage
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "5.2.7",
3
+ "version": "5.3.0-next.9+47f4d0a9",
4
4
  "description": "Documentation components of Canvas Kit components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -49,7 +49,7 @@
49
49
  ],
50
50
  "dependencies": {
51
51
  "@storybook/csf": "0.0.1",
52
- "@workday/canvas-kit-react": "^5.2.7"
52
+ "@workday/canvas-kit-react": "^5.3.0-next.9+47f4d0a9"
53
53
  },
54
54
  "devDependencies": {
55
55
  "fs-extra": "^10.0.0",
@@ -57,5 +57,5 @@
57
57
  "mkdirp": "^1.0.3",
58
58
  "typescript": "^3.8.3"
59
59
  },
60
- "gitHead": "def0edbf49b84470fd7b57254dc09ef9dd23d99a"
60
+ "gitHead": "47f4d0a90fddfb15752be9e6449be2979f934636"
61
61
  }