@workday/canvas-kit-docs 14.0.0-alpha.1230-next.0 → 14.0.0-alpha.1234-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 (74) hide show
  1. package/dist/es6/lib/docs.js +138 -980
  2. package/dist/es6/mdx/installBlock.d.ts.map +1 -1
  3. package/dist/es6/mdx/installBlock.js +4 -1
  4. package/dist/es6/mdx/welcomePage.d.ts.map +1 -1
  5. package/dist/es6/mdx/welcomePage.js +1 -1
  6. package/dist/mdx/14.0-UPGRADE-GUIDE.mdx +84 -36
  7. package/dist/mdx/MAINTAINING.mdx +4 -4
  8. package/dist/mdx/PACKAGES.mdx +9 -10
  9. package/dist/mdx/labs-react/combobox/Combobox.mdx +1 -1
  10. package/dist/mdx/labs-react/search-form/SearchForm.mdx +21 -4
  11. package/dist/mdx/preview-react/_examples/mdx/examples/TextInputWithFormik.tsx +35 -28
  12. package/dist/mdx/preview-react/_examples/mdx/examples/TextInputWithReactHookForm.tsx +27 -21
  13. package/dist/mdx/preview-react/divider/Divider.mdx +15 -5
  14. package/dist/mdx/preview-react/pill/Pill.mdx +4 -4
  15. package/dist/mdx/preview-react/radio/Radio.mdx +2 -2
  16. package/dist/mdx/preview-react/select/Select.mdx +1 -1
  17. package/dist/mdx/preview-react/status-indicator/StatusIndicator.mdx +2 -2
  18. package/dist/mdx/react/_examples/mdx/Layouts.mdx +1 -1
  19. package/dist/mdx/react/_examples/mdx/examples/common/FilterListWithLiveStatus.tsx +8 -5
  20. package/dist/mdx/react/_examples/mdx/examples/common/HiddenLiveRegion.tsx +8 -5
  21. package/dist/mdx/react/_examples/mdx/examples/common/TextInputWithLiveError.tsx +11 -8
  22. package/dist/mdx/react/_examples/mdx/examples/common/VisibleLiveRegion.tsx +9 -5
  23. package/dist/mdx/react/avatar/avatar/Avatar.mdx +10 -4
  24. package/dist/mdx/react/button/button/Button.mdx +21 -16
  25. package/dist/mdx/react/card/card.mdx +1 -1
  26. package/dist/mdx/react/checkbox/Checkbox.mdx +5 -5
  27. package/dist/mdx/react/combobox/Combobox.mdx +2 -2
  28. package/dist/mdx/react/form-field/FormField.mdx +2 -2
  29. package/dist/mdx/react/select/Select.mdx +6 -6
  30. package/dist/mdx/react/status-indicator/StatusIndicator.mdx +1 -1
  31. package/dist/mdx/react/switch/Switch.mdx +5 -5
  32. package/dist/mdx/react/table/Table.mdx +26 -13
  33. package/dist/mdx/react/text/BodyText.mdx +2 -2
  34. package/dist/mdx/react/text/Heading.mdx +2 -2
  35. package/dist/mdx/react/text/Subtext.mdx +2 -2
  36. package/dist/mdx/react/text/Text.mdx +2 -2
  37. package/dist/mdx/react/text/Title.mdx +2 -2
  38. package/dist/mdx/style-props/STYLE_PROPS.mdx +1 -1
  39. package/dist/mdx/styling/mdx/CustomizingStyles.mdx +8 -8
  40. package/dist/mdx/styling/mdx/Overview.mdx +7 -3
  41. package/dist/mdx/tokens/TokenMigrationFinal.mdx +1 -1
  42. package/package.json +6 -6
  43. package/dist/mdx/preview-react/text-area/TextArea.mdx +0 -136
  44. package/dist/mdx/preview-react/text-area/examples/Alert.tsx +0 -35
  45. package/dist/mdx/preview-react/text-area/examples/Basic.tsx +0 -17
  46. package/dist/mdx/preview-react/text-area/examples/Disabled.tsx +0 -17
  47. package/dist/mdx/preview-react/text-area/examples/Error.tsx +0 -40
  48. package/dist/mdx/preview-react/text-area/examples/Grow.tsx +0 -17
  49. package/dist/mdx/preview-react/text-area/examples/HiddenLabel.tsx +0 -22
  50. package/dist/mdx/preview-react/text-area/examples/LabelPositionHorizontal.tsx +0 -17
  51. package/dist/mdx/preview-react/text-area/examples/LabelPositionVertical.tsx +0 -17
  52. package/dist/mdx/preview-react/text-area/examples/Placeholder.tsx +0 -17
  53. package/dist/mdx/preview-react/text-area/examples/RefForwarding.tsx +0 -28
  54. package/dist/mdx/preview-react/text-area/examples/Required.tsx +0 -17
  55. package/dist/mdx/preview-react/text-area/examples/ResizeConstraints.tsx +0 -22
  56. package/dist/mdx/preview-react/text-input/TextInput.mdx +0 -170
  57. package/dist/mdx/preview-react/text-input/examples/Alert.tsx +0 -33
  58. package/dist/mdx/preview-react/text-input/examples/Basic.tsx +0 -17
  59. package/dist/mdx/preview-react/text-input/examples/Disabled.tsx +0 -17
  60. package/dist/mdx/preview-react/text-input/examples/Error.tsx +0 -40
  61. package/dist/mdx/preview-react/text-input/examples/Grow.tsx +0 -17
  62. package/dist/mdx/preview-react/text-input/examples/Hidden.tsx +0 -11
  63. package/dist/mdx/preview-react/text-input/examples/HiddenLabel.tsx +0 -22
  64. package/dist/mdx/preview-react/text-input/examples/LabelPositionHorizontal.tsx +0 -17
  65. package/dist/mdx/preview-react/text-input/examples/LabelPositionVertical.tsx +0 -17
  66. package/dist/mdx/preview-react/text-input/examples/Password.tsx +0 -17
  67. package/dist/mdx/preview-react/text-input/examples/Placeholder.tsx +0 -17
  68. package/dist/mdx/preview-react/text-input/examples/ReadOnly.tsx +0 -17
  69. package/dist/mdx/preview-react/text-input/examples/RefForwarding.tsx +0 -28
  70. package/dist/mdx/preview-react/text-input/examples/Required.tsx +0 -17
  71. package/dist/mdx/preview-react/text-input/examples/ThemedAlert.tsx +0 -51
  72. package/dist/mdx/preview-react/text-input/examples/ThemedError.tsx +0 -40
  73. package/dist/mdx/react/_examples/mdx/SearchForm.mdx +0 -19
  74. package/dist/mdx/react/_examples/mdx/examples/SearchFormBasic.tsx +0 -35
@@ -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
- };
@@ -1,40 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
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<HTMLInputElement>) => {
29
- validateInput(event.target.value);
30
- setValue(event.target.value);
31
- };
32
-
33
- return (
34
- <TextInput error={hasError ? 'error' : undefined} orientation="vertical">
35
- <TextInput.Label>A three letter word</TextInput.Label>
36
- <TextInput.Field onChange={handleChange} value={value} />
37
- <TextInput.Hint paddingTop={space.xxs}>{hint}</TextInput.Hint>
38
- </TextInput>
39
- );
40
- };
@@ -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" alignItems="stretch">
13
- <TextInput.Label>Street Address</TextInput.Label>
14
- <TextInput.Field onChange={handleChange} value={value} />
15
- </TextInput>
16
- );
17
- };
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
3
-
4
- export default () => {
5
- return (
6
- <>
7
- <h2>Inspect Element to see the markup</h2>
8
- <TextInput.Field value={'Secret'} type="hidden" />
9
- </>
10
- );
11
- };
@@ -1,22 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
3
- import {accessibleHide, styled} from '@workday/canvas-kit-react/common';
4
-
5
- const StyledTextAreaLabel = styled(TextInput.Label)({
6
- ...accessibleHide,
7
- });
8
-
9
- export default () => {
10
- const [value, setValue] = React.useState('');
11
-
12
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
13
- setValue(event.target.value);
14
- };
15
-
16
- return (
17
- <TextInput orientation="vertical" gap="zero">
18
- <StyledTextAreaLabel>Email</StyledTextAreaLabel>
19
- <TextInput.Field onChange={handleChange} value={value} />
20
- </TextInput>
21
- );
22
- };
@@ -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="horizontalStart">
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" gap="xxxs">
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('SuperSecret1');
6
-
7
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
8
- setValue(event.target.value);
9
- };
10
-
11
- return (
12
- <TextInput orientation="vertical">
13
- <TextInput.Label>Password</TextInput.Label>
14
- <TextInput.Field onChange={handleChange} value={value} type="password" />
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} placeholder="user@email.com" />
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
- return (
6
- <TextInput orientation="vertical">
7
- <TextInput.Label>Unwavering Opinion</TextInput.Label>
8
- <TextInput.Field
9
- value={'CKR is great'}
10
- readOnly={true}
11
- borderColor="transparent"
12
- background="transparent"
13
- cursor="default"
14
- />
15
- </TextInput>
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 {TextInput} from '@workday/canvas-kit-preview-react/text-input';
6
-
7
- export default () => {
8
- const [value, setValue] = React.useState('');
9
- const ref = React.useRef(null);
10
-
11
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
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
- <TextInput orientation="vertical">
22
- <TextInput.Label>Email</TextInput.Label>
23
- <TextInput.Field onChange={handleChange} value={value} ref={ref} />
24
- </TextInput>
25
- <SecondaryButton onClick={handleClick}>Focus Text Input</SecondaryButton>
26
- </Flex>
27
- );
28
- };
@@ -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 isRequired={true} orientation="vertical">
13
- <TextInput.Label>Email</TextInput.Label>
14
- <TextInput.Field onChange={handleChange} value={value} />
15
- </TextInput>
16
- );
17
- };
@@ -1,51 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
3
- import {
4
- CanvasProvider,
5
- PartialEmotionCanvasTheme,
6
- useThemedRing,
7
- } from '@workday/canvas-kit-react/common';
8
- import {base, system} from '@workday/canvas-tokens-web';
9
- import {cssVar} from '@workday/canvas-kit-styling';
10
-
11
- export default () => {
12
- const theme: PartialEmotionCanvasTheme = {
13
- canvas: {
14
- palette: {
15
- alert: {
16
- lightest: cssVar(system.color.static.green.softer),
17
- },
18
- common: {
19
- focusOutline: cssVar(base.purple500),
20
- alertInner: cssVar(base.green400),
21
- alertOuter: cssVar(base.green500),
22
- },
23
- },
24
- },
25
- };
26
- return (
27
- <CanvasProvider theme={theme}>
28
- <AlertInput />
29
- </CanvasProvider>
30
- );
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
- <TextInput error="alert" orientation="vertical">
44
- <TextInput.Label>Email</TextInput.Label>
45
- <TextInput.Field cs={alertStyles} onChange={handleChange} value={value} />
46
- <TextInput.Hint cs={{paddingTop: cssVar(system.space.x2)}}>
47
- Please enter a valid email.
48
- </TextInput.Hint>
49
- </TextInput>
50
- );
51
- };
@@ -1,40 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
3
- import {CanvasProvider, PartialEmotionCanvasTheme} from '@workday/canvas-kit-react/common';
4
- import {system, base} from '@workday/canvas-tokens-web';
5
- import {cssVar} from '@workday/canvas-kit-styling';
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
- error: {
18
- lightest: cssVar(base.purple100),
19
- main: cssVar(base.purple600),
20
- },
21
- common: {
22
- focusOutline: cssVar(system.color.static.green.default),
23
- errorInner: cssVar(base.purple600),
24
- },
25
- },
26
- },
27
- };
28
-
29
- return (
30
- <CanvasProvider theme={theme}>
31
- <TextInput error={!value ? 'error' : undefined} isRequired={true} orientation="vertical">
32
- <TextInput.Label>Email</TextInput.Label>
33
- <TextInput.Field onChange={handleChange} value={value} />
34
- <TextInput.Hint cs={{paddingTop: cssVar(system.space.x2)}}>
35
- {!value && 'Please enter an email.'}
36
- </TextInput.Hint>
37
- </TextInput>
38
- </CanvasProvider>
39
- );
40
- };
@@ -1,19 +0,0 @@
1
- import {ExampleCodeBlock} from '@workday/canvas-kit-docs';
2
- import SearchFormBasic from './examples/SearchFormBasic';
3
-
4
-
5
- # Canvas Kit Examples
6
-
7
- ## Search Form Basic
8
-
9
- A search form has a couple unique attributes to work correctly across platforms.
10
-
11
- If you are a SPA and use an `onSubmit` attritbute be sure to also include a `action="."` attribute
12
- to get the correct keyboard on mobile devices.
13
-
14
- The form should always have a `role="search"` and the input should be `type="search"`
15
-
16
- If you want to use a CKR clear button you will need to hide the webkit default one using the
17
- `::-webkit-search-cancel-button` pseudo selector.
18
-
19
- <ExampleCodeBlock code={SearchFormBasic} />
@@ -1,35 +0,0 @@
1
- import React from 'react';
2
- import {TertiaryButton} from '@workday/canvas-kit-react/button';
3
- import {InputGroup} from '@workday/canvas-kit-react/text-input';
4
- import {searchIcon} from '@workday/canvas-system-icons-web';
5
- import {createStyles} from '@workday/canvas-kit-styling';
6
-
7
- const hideNativeClearStyles = createStyles({
8
- '&::-webkit-search-cancel-button': {
9
- display: 'none',
10
- },
11
- });
12
-
13
- export default () => {
14
- const handleSubmit = (e: React.FormEvent) => {
15
- e.preventDefault();
16
- console.log(e.target[1]);
17
- };
18
- return (
19
- <form role="search" action="." onSubmit={handleSubmit}>
20
- <InputGroup>
21
- <InputGroup.InnerStart>
22
- <TertiaryButton size="small" aria-label="Search" icon={searchIcon} type="submit" />
23
- </InputGroup.InnerStart>
24
- <InputGroup.Input
25
- type="search"
26
- placeholder="Search for your favorite wine"
27
- cs={hideNativeClearStyles}
28
- />
29
- <InputGroup.InnerEnd>
30
- <InputGroup.ClearButton />
31
- </InputGroup.InnerEnd>
32
- </InputGroup>
33
- </form>
34
- );
35
- };