@workday/canvas-kit-docs 14.0.0-alpha.1230-next.0 → 14.0.0-alpha.1233-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.
Files changed (43) hide show
  1. package/dist/es6/lib/docs.js +25 -911
  2. package/dist/mdx/14.0-UPGRADE-GUIDE.mdx +78 -32
  3. package/dist/mdx/labs-react/combobox/Combobox.mdx +1 -1
  4. package/dist/mdx/labs-react/search-form/SearchForm.mdx +14 -2
  5. package/dist/mdx/preview-react/_examples/mdx/examples/TextInputWithFormik.tsx +35 -28
  6. package/dist/mdx/preview-react/_examples/mdx/examples/TextInputWithReactHookForm.tsx +27 -21
  7. package/dist/mdx/react/_examples/mdx/examples/common/FilterListWithLiveStatus.tsx +8 -5
  8. package/dist/mdx/react/_examples/mdx/examples/common/HiddenLiveRegion.tsx +8 -5
  9. package/dist/mdx/react/_examples/mdx/examples/common/TextInputWithLiveError.tsx +11 -8
  10. package/dist/mdx/react/_examples/mdx/examples/common/VisibleLiveRegion.tsx +9 -5
  11. package/package.json +6 -6
  12. package/dist/mdx/preview-react/text-area/TextArea.mdx +0 -136
  13. package/dist/mdx/preview-react/text-area/examples/Alert.tsx +0 -35
  14. package/dist/mdx/preview-react/text-area/examples/Basic.tsx +0 -17
  15. package/dist/mdx/preview-react/text-area/examples/Disabled.tsx +0 -17
  16. package/dist/mdx/preview-react/text-area/examples/Error.tsx +0 -40
  17. package/dist/mdx/preview-react/text-area/examples/Grow.tsx +0 -17
  18. package/dist/mdx/preview-react/text-area/examples/HiddenLabel.tsx +0 -22
  19. package/dist/mdx/preview-react/text-area/examples/LabelPositionHorizontal.tsx +0 -17
  20. package/dist/mdx/preview-react/text-area/examples/LabelPositionVertical.tsx +0 -17
  21. package/dist/mdx/preview-react/text-area/examples/Placeholder.tsx +0 -17
  22. package/dist/mdx/preview-react/text-area/examples/RefForwarding.tsx +0 -28
  23. package/dist/mdx/preview-react/text-area/examples/Required.tsx +0 -17
  24. package/dist/mdx/preview-react/text-area/examples/ResizeConstraints.tsx +0 -22
  25. package/dist/mdx/preview-react/text-input/TextInput.mdx +0 -170
  26. package/dist/mdx/preview-react/text-input/examples/Alert.tsx +0 -33
  27. package/dist/mdx/preview-react/text-input/examples/Basic.tsx +0 -17
  28. package/dist/mdx/preview-react/text-input/examples/Disabled.tsx +0 -17
  29. package/dist/mdx/preview-react/text-input/examples/Error.tsx +0 -40
  30. package/dist/mdx/preview-react/text-input/examples/Grow.tsx +0 -17
  31. package/dist/mdx/preview-react/text-input/examples/Hidden.tsx +0 -11
  32. package/dist/mdx/preview-react/text-input/examples/HiddenLabel.tsx +0 -22
  33. package/dist/mdx/preview-react/text-input/examples/LabelPositionHorizontal.tsx +0 -17
  34. package/dist/mdx/preview-react/text-input/examples/LabelPositionVertical.tsx +0 -17
  35. package/dist/mdx/preview-react/text-input/examples/Password.tsx +0 -17
  36. package/dist/mdx/preview-react/text-input/examples/Placeholder.tsx +0 -17
  37. package/dist/mdx/preview-react/text-input/examples/ReadOnly.tsx +0 -17
  38. package/dist/mdx/preview-react/text-input/examples/RefForwarding.tsx +0 -28
  39. package/dist/mdx/preview-react/text-input/examples/Required.tsx +0 -17
  40. package/dist/mdx/preview-react/text-input/examples/ThemedAlert.tsx +0 -51
  41. package/dist/mdx/preview-react/text-input/examples/ThemedError.tsx +0 -40
  42. package/dist/mdx/react/_examples/mdx/SearchForm.mdx +0 -19
  43. package/dist/mdx/react/_examples/mdx/examples/SearchFormBasic.tsx +0 -35
@@ -1,136 +0,0 @@
1
- import {
2
- ExampleCodeBlock,
3
- StorybookStatusIndicator,
4
- SymbolDoc,
5
- Specifications,
6
- } from '@workday/canvas-kit-docs';
7
- import {InformationHighlight} from '@workday/canvas-kit-preview-react/information-highlight';
8
-
9
- import Alert from './examples/Alert';
10
- import Basic from './examples/Basic';
11
- import Disabled from './examples/Disabled';
12
- import Error from './examples/Error';
13
- import Grow from './examples/Grow';
14
- import LabelPositionVertical from './examples/LabelPositionVertical';
15
- import LabelPositionHorizontal from './examples/LabelPositionHorizontal';
16
- import HiddenLabel from './examples/HiddenLabel';
17
- import Placeholder from './examples/Placeholder';
18
- import RefForwarding from './examples/RefForwarding';
19
- import Required from './examples/Required';
20
- import ResizeConstraints from './examples/ResizeConstraints';
21
- import {StatusIndicator} from '@workday/canvas-kit-preview-react/status-indicator';
22
-
23
-
24
- # Canvas Kit Text Area <StorybookStatusIndicator type="deprecated" />
25
-
26
- <InformationHighlight className="sb-unstyled" variant="caution" cs={{p: {marginBlock: 0}}}>
27
- <InformationHighlight.Icon />
28
- <InformationHighlight.Body>
29
- `TextArea` in Preview has been deprecated and will be removed in a future major version. Please
30
- use `TextArea` in Main instead.
31
- </InformationHighlight.Body>
32
- <InformationHighlight.Link href="https://workday.github.io/canvas-kit/?path=/docs/components-inputs-textarea--docs">
33
- Text Area Docs
34
- </InformationHighlight.Link>
35
- </InformationHighlight>
36
-
37
- TextArea's allow users to enter and edit multiple lines of text.
38
-
39
- [> Workday Design Reference](https://design.workday.com/components/inputs/text-area)
40
-
41
- ## Installation
42
-
43
- ```sh
44
- yarn add @workday/canvas-kit-preview-react
45
- ```
46
-
47
- ## Usage
48
-
49
- ### Basic Example
50
-
51
- <ExampleCodeBlock code={Basic} />
52
-
53
- ### Disabled
54
-
55
- Use `TextArea.Field`'s `disabled` prop to prevent users from interacting with the field.
56
-
57
- <ExampleCodeBlock code={Disabled} />
58
-
59
- ### Placeholder
60
-
61
- Use `TextArea.Field`'s `placeholder` prop to display a sample of its expected format or value before
62
- a value has been provided.
63
-
64
- <ExampleCodeBlock code={Placeholder} />
65
-
66
- ### Required
67
-
68
- Use `TextArea.Field`'s `isRequired` prop (or use with the `useTextAreaModel` hook) to indicate that
69
- the field is required. This will also add a red asterisk to `TextArea.Label`.
70
-
71
- <ExampleCodeBlock code={Required} />
72
-
73
- ### Ref Forwarding
74
-
75
- `TextArea` supports [ref forwarding](https://reactjs.org/docs/forwarding-refs.html). It will forward
76
- `ref` to its underlying `<textarea>` element.
77
-
78
- <ExampleCodeBlock code={RefForwarding} />
79
-
80
- ### Resize Constraints
81
-
82
- Use the `resize` css attribute to restrict resizing of it to certain dimensions.
83
-
84
- <ExampleCodeBlock code={ResizeConstraints} />
85
-
86
- ### Grow
87
-
88
- There are lots of ways to accomplish this. The `TextArea.Field` extends from Box so it is easy to
89
- extend full width, e.g. setting width prop to 100%, or you can set the `alignItems` prop to
90
- `stretch` on `TextArea`, etc.
91
-
92
- <ExampleCodeBlock code={Grow} />
93
-
94
- ### Label Position
95
-
96
- Use the `orientation` property to set `TextArea.Label`'s position. You can override the default
97
- spacing using the `gap` prop. Below are examples of both positions:
98
-
99
- #### Horizontal
100
-
101
- <ExampleCodeBlock code={LabelPositionHorizontal} />
102
-
103
- #### Vertical
104
-
105
- <ExampleCodeBlock code={LabelPositionVertical} />
106
-
107
- ### Visually Hiding The Label
108
-
109
- If your label is just for screen reader users you can use the `accessibleHide` utility class from
110
- `@workday/canvas-kit-react/common`. You will likely want to set the `gap` prop on `TextArea` to
111
- `zero`.
112
-
113
- <ExampleCodeBlock code={HiddenLabel} />
114
-
115
- ### Error States
116
-
117
- Use the `hasError` property from `useTextAreaModel` to set the `TextArea` to the Error state. If you
118
- have an accompanying hint you can use the `TextArea.Hint` subcomponent.
119
-
120
- <ExampleCodeBlock code={Error} />
121
-
122
- ### Other Visual States
123
-
124
- Use the `useThemedRing` hook to change the visual state of the `<textarea>` element.
125
-
126
- #### Alert
127
-
128
- <ExampleCodeBlock code={Alert} />
129
-
130
- ## Component API
131
-
132
- <SymbolDoc name="TextArea" fileName="/preview-react/" />
133
-
134
- ## Specifications
135
-
136
- <Specifications file="TextAreaPreview.spec.ts" name="Text Area" />
@@ -1,35 +0,0 @@
1
- import React from 'react';
2
- import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
3
- import {useThemedRing} from '@workday/canvas-kit-react/common';
4
- import {space, colors} from '@workday/canvas-kit-react/tokens';
5
- import {Text} from '@workday/canvas-kit-react/text';
6
-
7
- export default () => {
8
- const [value, setValue] = React.useState('Hello');
9
-
10
- const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
11
- setValue(event.target.value.slice(0, 10));
12
- };
13
-
14
- const alertStyles = useThemedRing(
15
- value.length < 3 ? 'success' : value.length < 7 ? 'alert' : 'error'
16
- );
17
-
18
- const hintColor =
19
- value.length < 3
20
- ? colors.greenApple600
21
- : value.length < 7
22
- ? colors.blackPepper300
23
- : colors.cinnamon500;
24
-
25
- return (
26
- <TextArea orientation="vertical">
27
- <TextArea.Label>Add a comment</TextArea.Label>
28
- <TextArea.Field cs={alertStyles} onChange={handleChange} value={value} />
29
- <TextArea.Hint paddingTop={space.xxs}>
30
- <strong>Character Limit: </strong>
31
- <Text color={hintColor}>{10 - value.length} Left</Text>
32
- </TextArea.Hint>
33
- </TextArea>
34
- );
35
- };
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
3
-
4
- export default () => {
5
- const [value, setValue] = React.useState('');
6
-
7
- const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
8
- setValue(event.target.value);
9
- };
10
-
11
- return (
12
- <TextArea orientation="vertical">
13
- <TextArea.Label>Leave a review</TextArea.Label>
14
- <TextArea.Field onChange={handleChange} value={value} />
15
- </TextArea>
16
- );
17
- };
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
3
-
4
- export default () => {
5
- const [value, setValue] = React.useState('');
6
-
7
- const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
8
- setValue(event.target.value);
9
- };
10
-
11
- return (
12
- <TextArea orientation="vertical">
13
- <TextArea.Label>Leave a review</TextArea.Label>
14
- <TextArea.Field disabled onChange={handleChange} value={value} />
15
- </TextArea>
16
- );
17
- };
@@ -1,40 +0,0 @@
1
- import React from 'react';
2
- import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
3
- import {space} from '@workday/canvas-kit-react/tokens';
4
-
5
- export default () => {
6
- const [value, setValue] = React.useState('four');
7
- const [hint, setHint] = React.useState('');
8
- const [hasError, setHasError] = React.useState(false);
9
-
10
- const validateInput = (value: string) => {
11
- const stringLength = value.length;
12
- if (stringLength !== 3) {
13
- setHasError(true);
14
- const hintStart = 'Word length must be';
15
- setHint(stringLength < 3 ? `${hintStart} greater than 2` : `${hintStart} less than 4`);
16
- } else {
17
- setHasError(false);
18
- setHint('');
19
- }
20
- };
21
-
22
- React.useEffect(() => {
23
- validateInput(value);
24
- // Only run on load
25
- // eslint-disable-next-line react-hooks/exhaustive-deps
26
- }, []);
27
-
28
- const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
29
- validateInput(event.target.value);
30
- setValue(event.target.value);
31
- };
32
-
33
- return (
34
- <TextArea error={hasError ? 'error' : undefined} orientation="vertical">
35
- <TextArea.Label>A three letter word</TextArea.Label>
36
- <TextArea.Field onChange={handleChange} value={value} />
37
- <TextArea.Hint paddingTop={space.xxs}>{hint}</TextArea.Hint>
38
- </TextArea>
39
- );
40
- };
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
3
-
4
- export default () => {
5
- const [value, setValue] = React.useState('');
6
-
7
- const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
8
- setValue(event.target.value);
9
- };
10
-
11
- return (
12
- <TextArea orientation="vertical" alignItems="stretch">
13
- <TextArea.Label>Leave a review</TextArea.Label>
14
- <TextArea.Field onChange={handleChange} value={value} />
15
- </TextArea>
16
- );
17
- };
@@ -1,22 +0,0 @@
1
- import React from 'react';
2
- import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
3
- import {accessibleHide, styled} from '@workday/canvas-kit-react/common';
4
-
5
- const StyledTextAreaLabel = styled(TextArea.Label)({
6
- ...accessibleHide,
7
- });
8
-
9
- export default () => {
10
- const [value, setValue] = React.useState('');
11
-
12
- const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
13
- setValue(event.target.value);
14
- };
15
-
16
- return (
17
- <TextArea orientation="vertical" gap="zero">
18
- <StyledTextAreaLabel>Email</StyledTextAreaLabel>
19
- <TextArea.Field onChange={handleChange} value={value} />
20
- </TextArea>
21
- );
22
- };
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
3
-
4
- export default () => {
5
- const [value, setValue] = React.useState('');
6
-
7
- const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
8
- setValue(event.target.value);
9
- };
10
-
11
- return (
12
- <TextArea orientation="horizontalStart">
13
- <TextArea.Label>Leave a review</TextArea.Label>
14
- <TextArea.Field onChange={handleChange} value={value} />
15
- </TextArea>
16
- );
17
- };
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
3
-
4
- export default () => {
5
- const [value, setValue] = React.useState('');
6
-
7
- const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
8
- setValue(event.target.value);
9
- };
10
-
11
- return (
12
- <TextArea orientation="vertical" gap="xxxs">
13
- <TextArea.Label>Leave a review</TextArea.Label>
14
- <TextArea.Field onChange={handleChange} value={value} />
15
- </TextArea>
16
- );
17
- };
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
3
-
4
- export default () => {
5
- const [value, setValue] = React.useState('');
6
-
7
- const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
8
- setValue(event.target.value);
9
- };
10
-
11
- return (
12
- <TextArea orientation="vertical">
13
- <TextArea.Label>Leave a review</TextArea.Label>
14
- <TextArea.Field placeholder="Let us know how we did!" onChange={handleChange} value={value} />
15
- </TextArea>
16
- );
17
- };
@@ -1,28 +0,0 @@
1
- import React from 'react';
2
- import {changeFocus} from '@workday/canvas-kit-react/common';
3
- import {Flex} from '@workday/canvas-kit-react/layout';
4
- import {SecondaryButton} from '@workday/canvas-kit-react/button';
5
- import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
6
-
7
- export default () => {
8
- const [value, setValue] = React.useState('');
9
- const ref = React.useRef(null);
10
-
11
- const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
12
- setValue(event.target.value);
13
- };
14
-
15
- const handleClick = () => {
16
- changeFocus(ref.current);
17
- };
18
-
19
- return (
20
- <Flex gap="xxxs" alignItems="flex-start" flexDirection="column">
21
- <TextArea orientation="vertical">
22
- <TextArea.Label>Leave a review</TextArea.Label>
23
- <TextArea.Field onChange={handleChange} value={value} ref={ref} />
24
- </TextArea>
25
- <SecondaryButton onClick={handleClick}>Focus Text Area</SecondaryButton>
26
- </Flex>
27
- );
28
- };
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
3
-
4
- export default () => {
5
- const [value, setValue] = React.useState('');
6
-
7
- const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
8
- setValue(event.target.value);
9
- };
10
-
11
- return (
12
- <TextArea isRequired={true} orientation="vertical">
13
- <TextArea.Label>Leave a review</TextArea.Label>
14
- <TextArea.Field onChange={handleChange} value={value} />
15
- </TextArea>
16
- );
17
- };
@@ -1,22 +0,0 @@
1
- import React from 'react';
2
- import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
3
- import {styled} from '@workday/canvas-kit-react/common';
4
-
5
- const StyledField = styled(TextArea.Field)({
6
- resize: 'vertical',
7
- });
8
-
9
- export default () => {
10
- const [value, setValue] = React.useState('');
11
-
12
- const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
13
- setValue(event.target.value);
14
- };
15
-
16
- return (
17
- <TextArea orientation="vertical">
18
- <TextArea.Label>Leave a review</TextArea.Label>
19
- <StyledField onChange={handleChange} value={value} />
20
- </TextArea>
21
- );
22
- };
@@ -1,170 +0,0 @@
1
- import {StatusIndicator} from '@workday/canvas-kit-preview-react/status-indicator';
2
- import {
3
- ExampleCodeBlock,
4
- StorybookStatusIndicator,
5
- SymbolDoc,
6
- Specifications,
7
- } from '@workday/canvas-kit-docs';
8
- import {InformationHighlight} from '@workday/canvas-kit-preview-react/information-highlight';
9
-
10
- import Basic from './examples/Basic';
11
- import Disabled from './examples/Disabled';
12
- import Grow from './examples/Grow';
13
- import LabelPositionHorizontal from './examples/LabelPositionHorizontal';
14
- import LabelPositionVertical from './examples/LabelPositionVertical';
15
- import Placeholder from './examples/Placeholder';
16
- import RefForwarding from './examples/RefForwarding';
17
- import Required from './examples/Required';
18
- import Hidden from './examples/Hidden';
19
- import ReadOnly from './examples/ReadOnly';
20
- import Password from './examples/Password';
21
- import HiddenLabel from './examples/HiddenLabel';
22
- import ThemedAlert from './examples/ThemedAlert';
23
- import ThemedError from './examples/ThemedError';
24
- import Error from './examples/Error';
25
- import Alert from './examples/Alert';
26
-
27
-
28
- # Canvas Kit Text Input <StorybookStatusIndicator type="deprecated" />
29
-
30
- <InformationHighlight className="sb-unstyled" variant="caution" cs={{p: {marginBlock: 0}}}>
31
- <InformationHighlight.Icon />
32
- <InformationHighlight.Body>
33
- `TextInput` in Preview has been deprecated and will be removed in a future major version. Please
34
- use `TextInput` in Main instead.
35
- </InformationHighlight.Body>
36
- <InformationHighlight.Link href="https://workday.github.io/canvas-kit/?path=/docs/components-inputs-text-input--docs">
37
- Text Input Docs
38
- </InformationHighlight.Link>
39
- </InformationHighlight>
40
-
41
- Text Inputs allow users to enter words or characters without styling.
42
-
43
- [> Workday Design Reference](https://design.workday.com/components/inputs/text-input)
44
-
45
- ## Installation
46
-
47
- ```sh
48
- yarn add @workday/canvas-kit-preview-react
49
- ```
50
-
51
- ## Usage
52
-
53
- ### Basic Example
54
-
55
- <ExampleCodeBlock code={Basic} />
56
-
57
- ### Disabled
58
-
59
- Use `TextInput.Field`s `disabled` prop to prevent users from interacting with it.
60
-
61
- <ExampleCodeBlock code={Disabled} />
62
-
63
- ### Placeholder
64
-
65
- Use `TextInput.Field`s `placeholder` prop to display a sample of its expected format or value before
66
- a value has been provided.
67
-
68
- <ExampleCodeBlock code={Placeholder} />
69
-
70
- ### Required
71
-
72
- Use `TextInput.Field`'s `isRequired` prop (or use with the `useTextInputModel` hook) to indicate
73
- that the field is required. This will also add a red asterisk to `TextInput.Label`.
74
-
75
- <ExampleCodeBlock code={Required} />
76
-
77
- ### Read Only
78
-
79
- Use `TextInput.Field`'s `readOnly` prop to indicate that the field can not be changed. We reccommend
80
- setting the background and border color to tranparent and the cursor to default to help inform users
81
- of the immutiblity.
82
-
83
- <ExampleCodeBlock code={ReadOnly} />
84
-
85
- ### Hidden Input
86
-
87
- Set `TextInput.Field`'s `type` prop to `hidden` to completly hide a field while still submitting its
88
- value, often used for things like security tokens. Note: You will likely need to manually
89
- set`aria-describedby={undefined}`and`id={undefined}`
90
-
91
- <ExampleCodeBlock code={Hidden} />
92
-
93
- ### Ref Forwarding
94
-
95
- All the TextInput subcomponents support
96
- [ref forwarding](https://reactjs.org/docs/forwarding-refs.html). e.g. TextInput.Field will forward
97
- `ref` to its underlying `<input type="text">` element.
98
-
99
- <ExampleCodeBlock code={RefForwarding} />
100
-
101
- ### Grow
102
-
103
- There are lots of ways to accomplish this. The TextInput.Field extends from Box so it is easy to
104
- extend full width, e.g. setting width prop to 100%, or you can set the `alignItems` prop to
105
- `stretch` on `TextInput`, etc.
106
-
107
- <ExampleCodeBlock code={Grow} />
108
-
109
- ### Label Position
110
-
111
- Use the `orientation` property to set `TextInput.Label`'s position. You can override the default
112
- spacing using the `gap` prop. Below are examples of both positions:
113
-
114
- #### Horizontal
115
-
116
- <ExampleCodeBlock code={LabelPositionHorizontal} />
117
-
118
- #### Vertical
119
-
120
- <ExampleCodeBlock code={LabelPositionVertical} />
121
-
122
- ### Visually Hiding The Label
123
-
124
- If your label is just for screen reader users you can use the `accessibleHide` utility class from
125
- `@workday/canvas-kit-react/common`. You will likely want to set the `gap` prop on `TextInput` to
126
- `zero`.
127
-
128
- <ExampleCodeBlock code={HiddenLabel} />
129
-
130
- ### Type
131
-
132
- Use `TextInput.Field`'s `type` prop to customize the input type, e.g. `password`, `email`, etc.
133
-
134
- <ExampleCodeBlock code={Password} />
135
-
136
- ### Error States
137
-
138
- Use the `hasError` property from `useTextInputModel` to set the `TextInput` to the Error state. If
139
- you have an accompanying hint you can use the TextInput.Hint subcomponent.
140
-
141
- #### Errors
142
-
143
- <ExampleCodeBlock code={Error} />
144
-
145
- #### Themed Errors
146
-
147
- <ExampleCodeBlock code={ThemedError} />
148
-
149
- ### Other Visual States
150
-
151
- Use the `useThemedRing` hook to change the visual state of the input field.
152
-
153
- #### Alerts
154
-
155
- <ExampleCodeBlock code={Alert} />
156
-
157
- #### Themed Alerts
158
-
159
- If the your theme's `main` color doesn't meet accessibility contrast, the `darkest` color will be
160
- used in an outer ring.
161
-
162
- <ExampleCodeBlock code={ThemedAlert} />
163
-
164
- ## Component API
165
-
166
- <SymbolDoc name="TextInput" fileName="/preview-react/" />
167
-
168
- ## Specifications
169
-
170
- <Specifications file="TextInputPreview.spec.ts" name="Text Input" />
@@ -1,33 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
3
- import {useThemedRing} from '@workday/canvas-kit-react/common';
4
- import {space} from '@workday/canvas-kit-react/tokens';
5
-
6
- export default () => {
7
- const [value, setValue] = React.useState('foo');
8
-
9
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
10
- setValue(event.target.value);
11
- };
12
-
13
- const alertStyles = useThemedRing(
14
- value.length < 3 ? 'error' : value.length < 5 ? 'alert' : 'success'
15
- );
16
-
17
- return (
18
- <TextInput orientation="vertical">
19
- <TextInput.Label>Password</TextInput.Label>
20
- <TextInput.Field cs={alertStyles} onChange={handleChange} value={value} type="password" />
21
- <TextInput.Hint paddingTop={space.xxs}>
22
- <strong>Password Strength: </strong>
23
- {value.length < 3 ? (
24
- <span>Weak</span>
25
- ) : value.length < 5 ? (
26
- <span>Average</span>
27
- ) : (
28
- <span>Strong</span>
29
- )}
30
- </TextInput.Hint>
31
- </TextInput>
32
- );
33
- };
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
3
-
4
- export default () => {
5
- const [value, setValue] = React.useState('');
6
-
7
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
8
- setValue(event.target.value);
9
- };
10
-
11
- return (
12
- <TextInput orientation="vertical">
13
- <TextInput.Label>Email</TextInput.Label>
14
- <TextInput.Field onChange={handleChange} value={value} />
15
- </TextInput>
16
- );
17
- };
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
3
-
4
- export default () => {
5
- const [value, setValue] = React.useState('');
6
-
7
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
8
- setValue(event.target.value);
9
- };
10
-
11
- return (
12
- <TextInput orientation="vertical">
13
- <TextInput.Label>Email</TextInput.Label>
14
- <TextInput.Field onChange={handleChange} value={value} disabled />
15
- </TextInput>
16
- );
17
- };