@workday/canvas-kit-docs 16.1.0-0586-next.0 → 16.1.0-0590-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/stackblitzFiles/packageJSONFile.js +5 -5
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.ts +5 -5
- package/dist/mdx/react/checkbox/Checkbox.mdx +142 -15
- package/dist/mdx/react/checkbox/examples/Basic.tsx +1 -14
- package/dist/mdx/react/checkbox/examples/Caution.tsx +9 -8
- package/dist/mdx/react/checkbox/examples/Disabled.tsx +1 -13
- package/dist/mdx/react/checkbox/examples/Error.tsx +9 -8
- package/dist/mdx/react/checkbox/examples/Indeterminate.tsx +34 -20
- package/dist/mdx/react/checkbox/examples/LabelPosition.tsx +7 -7
- package/dist/mdx/react/checkbox/examples/RefForwarding.tsx +12 -24
- package/dist/mdx/react/checkbox/examples/Required.tsx +7 -7
- package/package.json +6 -6
|
@@ -18,11 +18,11 @@ export const packageJSONFile = `{
|
|
|
18
18
|
"@emotion/react": "11.11.4",
|
|
19
19
|
"@types/react": "18.2.60",
|
|
20
20
|
"@types/react-dom": "18.2.19",
|
|
21
|
-
"@workday/canvas-kit-labs-react": "16.0.
|
|
22
|
-
"@workday/canvas-kit-preview-react": "16.0.
|
|
23
|
-
"@workday/canvas-kit-react": "16.0.
|
|
24
|
-
"@workday/canvas-kit-react-fonts": "^16.0.
|
|
25
|
-
"@workday/canvas-kit-styling": "16.0.
|
|
21
|
+
"@workday/canvas-kit-labs-react": "16.0.16",
|
|
22
|
+
"@workday/canvas-kit-preview-react": "16.0.16",
|
|
23
|
+
"@workday/canvas-kit-react": "16.0.16",
|
|
24
|
+
"@workday/canvas-kit-react-fonts": "^16.0.16",
|
|
25
|
+
"@workday/canvas-kit-styling": "16.0.16",
|
|
26
26
|
"@workday/canvas-system-icons-web": "^5.0.3",
|
|
27
27
|
"@workday/canvas-expressive-icons-web": "1.0.1",
|
|
28
28
|
"@workday/canvas-tokens-web": "4.4.0-beta.11"
|
|
@@ -19,11 +19,11 @@ export const packageJSONFile = `{
|
|
|
19
19
|
"@emotion/react": "11.11.4",
|
|
20
20
|
"@types/react": "18.2.60",
|
|
21
21
|
"@types/react-dom": "18.2.19",
|
|
22
|
-
"@workday/canvas-kit-labs-react": "16.0.
|
|
23
|
-
"@workday/canvas-kit-preview-react": "16.0.
|
|
24
|
-
"@workday/canvas-kit-react": "16.0.
|
|
25
|
-
"@workday/canvas-kit-react-fonts": "^16.0.
|
|
26
|
-
"@workday/canvas-kit-styling": "16.0.
|
|
22
|
+
"@workday/canvas-kit-labs-react": "16.0.16",
|
|
23
|
+
"@workday/canvas-kit-preview-react": "16.0.16",
|
|
24
|
+
"@workday/canvas-kit-react": "16.0.16",
|
|
25
|
+
"@workday/canvas-kit-react-fonts": "^16.0.16",
|
|
26
|
+
"@workday/canvas-kit-styling": "16.0.16",
|
|
27
27
|
"@workday/canvas-system-icons-web": "^5.0.3",
|
|
28
28
|
"@workday/canvas-expressive-icons-web": "1.0.1",
|
|
29
29
|
"@workday/canvas-tokens-web": "4.4.0-beta.11"
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ExampleCodeBlock,
|
|
3
|
-
Specifications,
|
|
4
|
-
SymbolDoc,
|
|
5
|
-
} from '@workday/canvas-kit-docs';
|
|
1
|
+
import {ExampleCodeBlock, Specifications, SymbolDoc} from '@workday/canvas-kit-docs';
|
|
6
2
|
|
|
7
3
|
import Basic from './examples/Basic';
|
|
8
4
|
import Caution from './examples/Caution';
|
|
@@ -34,7 +30,9 @@ yarn add @workday/canvas-kit-react
|
|
|
34
30
|
|
|
35
31
|
Checkbox may be used on its own without [Form Field](/components/inputs/form-field/) since it
|
|
36
32
|
includes a `<label>` with a `for` attribute referencing the underlying `<input type="checkbox">`
|
|
37
|
-
element.
|
|
33
|
+
element. For checkboxes grouped with **`FormFieldGroup`**, see
|
|
34
|
+
[FormField accessibility](/components/inputs/form-field/#accessibility) for hint, error, caution,
|
|
35
|
+
and required state wiring.
|
|
38
36
|
|
|
39
37
|
<ExampleCodeBlock code={Basic} />
|
|
40
38
|
|
|
@@ -61,6 +59,9 @@ not all) of its children are checked.
|
|
|
61
59
|
|
|
62
60
|
<ExampleCodeBlock code={Indeterminate} />
|
|
63
61
|
|
|
62
|
+
> **Accessibility Note**: Use semantic unordered list markup so that screen readers can communicate
|
|
63
|
+
> the nested hierarchy of the components to users.
|
|
64
|
+
|
|
64
65
|
### Ref Forwarding
|
|
65
66
|
|
|
66
67
|
Checkbox supports [ref forwarding](https://reactjs.org/docs/forwarding-refs.html). It will forward
|
|
@@ -70,27 +71,32 @@ Checkbox supports [ref forwarding](https://reactjs.org/docs/forwarding-refs.html
|
|
|
70
71
|
|
|
71
72
|
### Label Position Horizontal
|
|
72
73
|
|
|
73
|
-
Set the `orientation` prop of the
|
|
74
|
-
|
|
74
|
+
Set the `orientation` prop of the wrapping FormFieldGroup to designate the position of the group
|
|
75
|
+
label relative to the checkboxes. By default, the orientation will be set to `vertical`.
|
|
75
76
|
|
|
76
77
|
<ExampleCodeBlock code={LabelPosition} />
|
|
77
78
|
|
|
78
79
|
### Required
|
|
79
80
|
|
|
80
|
-
Set the `
|
|
81
|
-
Labels for required fields are suffixed by a red asterisk.
|
|
81
|
+
Set the `isRequired` prop of a wrapping FormFieldGroup to `true` to indicate that the field is
|
|
82
|
+
required. Labels for required fields are suffixed by a red asterisk.
|
|
83
|
+
|
|
84
|
+
A standalone checkbox does not need **`FormFieldGroup`**. This example wraps a single checkbox so
|
|
85
|
+
`isRequired` can show the required asterisk on **`FormFieldGroup.Label`**. Use that wrapper only
|
|
86
|
+
when the spec includes a required state (or a group name, hint, error, or caution). See
|
|
87
|
+
[Accessibility](#accessibility).
|
|
82
88
|
|
|
83
89
|
<ExampleCodeBlock code={Required} />
|
|
84
90
|
|
|
85
91
|
### Error States
|
|
86
92
|
|
|
87
|
-
Set the `error` prop of the wrapping
|
|
88
|
-
the Alert or Error state, respectively.
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
Set the `error` prop of the wrapping FormFieldGroup to `"caution"` or `"error"` to set the Checkbox
|
|
94
|
+
to the Alert or Error state, respectively. Render `FormFieldGroup.Hint` with the message text so
|
|
95
|
+
assistive technology can associate the hint with the group. Keep the Checkbox `label` so each
|
|
96
|
+
control retains its own accessible name; `FormFieldGroup.Label` only provides the group name.
|
|
91
97
|
|
|
92
98
|
The `error` prop may be applied directly to the Checkbox with a value of `"caution"` or `"error"` if
|
|
93
|
-
|
|
99
|
+
FormFieldGroup is not being used.
|
|
94
100
|
|
|
95
101
|
#### Caution
|
|
96
102
|
|
|
@@ -105,6 +111,127 @@ Form Field is not being used.
|
|
|
105
111
|
Checkbox supports custom styling via the `cs` prop. For more information, check our
|
|
106
112
|
["How To Customize Styles"](https://workday.github.io/canvas-kit/?path=/docs/styling-guides-customizing-styles--docs).
|
|
107
113
|
|
|
114
|
+
## Accessibility
|
|
115
|
+
|
|
116
|
+
The primary accessibility goal is a visible, programmatically determinable name and a checked,
|
|
117
|
+
unchecked, or mixed state that assistive technology can expose. Use **Checkbox** when the user can
|
|
118
|
+
select zero, one, or many independent options. For mutually exclusive choices, use
|
|
119
|
+
[**Radio**](https://workday.github.io/canvas-kit/?path=/docs/preview-inputs-radio--docs) instead.
|
|
120
|
+
When checkboxes answer the same question, or need hint, error, caution, or required association, see
|
|
121
|
+
[FormField's accessibility documentation](/components/inputs/form-field/#accessibility).
|
|
122
|
+
|
|
123
|
+
### Minimum Accessible Structure
|
|
124
|
+
|
|
125
|
+
The following matches the [Basic Example](#basic-example): a **`Checkbox`** with a non-empty
|
|
126
|
+
**`label`**. **`FormFieldGroup`** is not required for a single standalone checkbox with no hint,
|
|
127
|
+
error, caution, or required state.
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
import {Checkbox} from '@workday/canvas-kit-react/checkbox';
|
|
131
|
+
|
|
132
|
+
<Checkbox label="I agree to the terms" />;
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Built-in Behaviors
|
|
136
|
+
|
|
137
|
+
Canvas Kit applies these automatically on **`Checkbox`**. When checkboxes that answer the same
|
|
138
|
+
question are composed with **`FormFieldGroup`** subcomponents, that grouping wiring is also applied
|
|
139
|
+
automatically. **Do not duplicate them** in consuming code.
|
|
140
|
+
|
|
141
|
+
**ARIA and DOM** (_applied by Checkbox_):
|
|
142
|
+
|
|
143
|
+
- **`Checkbox`**: Renders a native `<input type="checkbox">`. Canvas Kit assigns an `id` with
|
|
144
|
+
`useUniqueId` unless you pass **`id`**.
|
|
145
|
+
- **`label`**: Renders a visible `<label htmlFor={id}>` so the control has an accessible name and
|
|
146
|
+
clicking the text activates the input.
|
|
147
|
+
- **`indeterminate`**: Sets `aria-checked="mixed"` and the input's native `indeterminate` property.
|
|
148
|
+
Otherwise `aria-checked` follows the **`checked`** prop.
|
|
149
|
+
- **`disabled`**: Maps to the native `disabled` attribute.
|
|
150
|
+
- **`ref`**: Forwards to the underlying `<input type="checkbox">`.
|
|
151
|
+
|
|
152
|
+
**Keyboard** (_native checkbox behavior_):
|
|
153
|
+
|
|
154
|
+
**`Checkbox`** uses native `<input type="checkbox">` keyboard behavior (tab order, Space to toggle,
|
|
155
|
+
and label activation). Do not intercept <kbd>Space</kbd> or otherwise prevent the native toggle.
|
|
156
|
+
|
|
157
|
+
**Screen reader expectations** (_when built-in behaviors are used as intended_):
|
|
158
|
+
|
|
159
|
+
- On focus, assistive technology announces the Checkbox **`label`** and checked, unchecked, or mixed
|
|
160
|
+
state
|
|
161
|
+
- Disabled checkboxes are announced as unavailable
|
|
162
|
+
|
|
163
|
+
For group, hint, error, and required association, see
|
|
164
|
+
[FormField's Built-in Behaviors](/components/inputs/form-field/#built-in-behaviors).
|
|
165
|
+
|
|
166
|
+
### Accessibility Requirements
|
|
167
|
+
|
|
168
|
+
Required in application code for an accessible Checkbox. Rows marked _(conditional)_ apply only when
|
|
169
|
+
the situation matches—otherwise omit.
|
|
170
|
+
|
|
171
|
+
**If no design spec is provided:** use a visible, non-empty Checkbox **`label`**. Omit
|
|
172
|
+
**`FormFieldGroup`** unless the spec includes a group name, more than one independent option for the
|
|
173
|
+
same question, or hint, error, caution, or required state. Omit **`FormFieldGroup.Hint`**,
|
|
174
|
+
**`isRequired`**, **`error`**, **`indeterminate`**, **`disabled`**, a custom **`id`**, and a
|
|
175
|
+
**`ref`** unless the spec requires them.
|
|
176
|
+
|
|
177
|
+
**Choose a composition:**
|
|
178
|
+
|
|
179
|
+
- Standalone **`Checkbox`** with **`label`** — one control with no hint, error, caution, or required
|
|
180
|
+
state
|
|
181
|
+
- **`FormFieldGroup`** — one question with two or more independent options, or any checkbox that
|
|
182
|
+
needs a group name, hint, error, caution, or required state
|
|
183
|
+
- Nested `<ul>` / `<li>` — parent checkbox with nested children and **`indeterminate`**. Do not use
|
|
184
|
+
**`FormFieldGroup`** for that hierarchy. Checkboxes that answer different questions stay in
|
|
185
|
+
separate compositions.
|
|
186
|
+
|
|
187
|
+
**Programmatic focus** _(conditional — omit by default)_:
|
|
188
|
+
|
|
189
|
+
Attach a `ref` only when the product must move focus to the checkbox after an action (for example,
|
|
190
|
+
**Submit** in [Ref Forwarding](#ref-forwarding)). Do not attach a `ref` or call `focus()` unless the
|
|
191
|
+
design or developer asks for it.
|
|
192
|
+
|
|
193
|
+
| Requirement | How to satisfy |
|
|
194
|
+
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
195
|
+
| Accessible name | Non-empty **`label`** on every **`Checkbox`**. **`FormFieldGroup.Label`** names the group only (`div` with an `id`); it is not a `<label>` and does not replace **`label`**. |
|
|
196
|
+
| Group wiring _(conditional)_ | When the spec is one question with two or more independent options, or includes a group name, hint, error, caution, or required state: **`FormFieldGroup`** + **`FormFieldGroup.Label`** + **`FormFieldGroup.Input as={Checkbox}`**. Put hint, error, caution, and required on the group — see [FormField accessibility](/components/inputs/form-field/#accessibility). See [Required](#required) and [Error States](#error-states). |
|
|
197
|
+
| Visual error or caution _(conditional)_ | When **`FormFieldGroup`** has `error="error"` or `error="caution"`, also set **`error`** on **`Checkbox`** to the same state so the visual ring appears. See [Caution](#caution) and [Error](#error). |
|
|
198
|
+
| Indeterminate parent _(conditional)_ | When a parent checkbox's value depends on nested children and some (but not all) children are checked: set **`indeterminate`** on the parent **`Checkbox`**; keep a non-empty **`label`** on the parent and on each child; nest the children in a `<ul>` inside the parent's `<li>`. See [Indeterminate](#indeterminate). |
|
|
199
|
+
| Disabled _(conditional)_ | `disabled` on **`Checkbox`** when the spec marks the option unavailable. See [Disabled](#disabled). |
|
|
200
|
+
| Programmatic focus _(conditional)_ | `ref` on **`Checkbox`** (or **`FormFieldGroup.Input`**) and move focus when the product requires it — omit by default (see **Programmatic focus** above and [Ref Forwarding](#ref-forwarding)). |
|
|
201
|
+
|
|
202
|
+
**Summary for code generation:**
|
|
203
|
+
|
|
204
|
+
- **REQUIRED:** non-empty **`label`**
|
|
205
|
+
- **CONDITIONAL:** **`FormFieldGroup`** for one question with two or more independent options, or
|
|
206
|
+
for hint, error, caution, or required; **`error`** on **`Checkbox`** when the group is in caution
|
|
207
|
+
or error; nested list + **`indeterminate`** for a parent/child tree; disabled; programmatic focus
|
|
208
|
+
via `ref`. See [FormField accessibility](/components/inputs/form-field/#accessibility) for group
|
|
209
|
+
hint, error, caution, and required.
|
|
210
|
+
|
|
211
|
+
### Anti-Patterns
|
|
212
|
+
|
|
213
|
+
Do **not** generate code that does the following (see **Accessibility Requirements** above for what
|
|
214
|
+
to supply instead):
|
|
215
|
+
|
|
216
|
+
- Manually set `aria-checked` or `htmlFor` on **`Checkbox`**, or pass an **`id`** when the spec does
|
|
217
|
+
not require a known id — Canvas Kit wires `aria-checked` and `htmlFor`, and assigns an `id` with
|
|
218
|
+
`useUniqueId` unless you pass one (see **If no design spec is provided**)
|
|
219
|
+
- Ignore **Choose a composition** — do not wrap a standalone checkbox with no group name, hint,
|
|
220
|
+
error, caution, or required state in **`FormFieldGroup`**; do not put different questions in one
|
|
221
|
+
group; do not use **`FormFieldGroup`** for a parent/child indeterminate tree
|
|
222
|
+
- Wrap **`Checkbox`** with **`FormField.Input`** — **`Checkbox`** already renders its own `<label>`.
|
|
223
|
+
When a group is required, use **`FormFieldGroup.Input as={Checkbox}`** (see **Group wiring**)
|
|
224
|
+
- Omit **`label`** because **`FormFieldGroup.Label`** is present — the group label does not name the
|
|
225
|
+
individual control
|
|
226
|
+
- Set `aria-checked="mixed"` without **`indeterminate`**
|
|
227
|
+
- Use **`aria-disabled`** instead of **`disabled`** — **`Checkbox`** maps unavailability to the
|
|
228
|
+
native **`disabled`** prop
|
|
229
|
+
- Use **`disabled`** when the spec says users must still focus the control to hear why it is
|
|
230
|
+
unavailable. Only in that case keep the checkbox enabled and put the explanation in
|
|
231
|
+
**`FormFieldGroup.Hint`** or on an adjacent focusable control
|
|
232
|
+
- Use **Checkbox** for mutually exclusive choices — use
|
|
233
|
+
[**Radio**](https://workday.github.io/canvas-kit/?path=/docs/preview-inputs-radio--docs) instead
|
|
234
|
+
|
|
108
235
|
## Component API
|
|
109
236
|
|
|
110
237
|
<SymbolDoc name="Checkbox" fileName="/react/" />
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import {Checkbox} from '@workday/canvas-kit-react/checkbox';
|
|
4
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
5
4
|
|
|
6
5
|
export default () => {
|
|
7
6
|
const [checked, setChecked] = React.useState(false);
|
|
@@ -10,17 +9,5 @@ export default () => {
|
|
|
10
9
|
setChecked(event.target.checked);
|
|
11
10
|
};
|
|
12
11
|
|
|
13
|
-
return
|
|
14
|
-
<FormField>
|
|
15
|
-
<FormField.Label>Confirm</FormField.Label>
|
|
16
|
-
<FormField.Field>
|
|
17
|
-
<FormField.Input
|
|
18
|
-
as={Checkbox}
|
|
19
|
-
checked={checked}
|
|
20
|
-
label="I agree to the terms"
|
|
21
|
-
onChange={handleChange}
|
|
22
|
-
/>
|
|
23
|
-
</FormField.Field>
|
|
24
|
-
</FormField>
|
|
25
|
-
);
|
|
12
|
+
return <Checkbox checked={checked} label="I agree to the terms" onChange={handleChange} />;
|
|
26
13
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import {Checkbox} from '@workday/canvas-kit-react/checkbox';
|
|
4
|
-
import {
|
|
4
|
+
import {FormFieldGroup} from '@workday/canvas-kit-react/form-field';
|
|
5
5
|
|
|
6
6
|
export default () => {
|
|
7
7
|
const [checked, setChecked] = React.useState(false);
|
|
@@ -11,17 +11,18 @@ export default () => {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
<
|
|
17
|
-
<
|
|
14
|
+
<FormFieldGroup error="caution">
|
|
15
|
+
<FormFieldGroup.Label>Confirm</FormFieldGroup.Label>
|
|
16
|
+
<FormFieldGroup.Field>
|
|
17
|
+
<FormFieldGroup.Input
|
|
18
18
|
as={Checkbox}
|
|
19
19
|
checked={checked}
|
|
20
|
+
error={Checkbox.ErrorType.Caution}
|
|
20
21
|
label="I agree to the terms"
|
|
21
22
|
onChange={handleChange}
|
|
22
23
|
/>
|
|
23
|
-
<
|
|
24
|
-
</
|
|
25
|
-
</
|
|
24
|
+
<FormFieldGroup.Hint>You must agree to the terms before proceeding</FormFieldGroup.Hint>
|
|
25
|
+
</FormFieldGroup.Field>
|
|
26
|
+
</FormFieldGroup>
|
|
26
27
|
);
|
|
27
28
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import {Checkbox} from '@workday/canvas-kit-react/checkbox';
|
|
4
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
5
4
|
|
|
6
5
|
export default () => {
|
|
7
6
|
const [checked, setChecked] = React.useState(false);
|
|
@@ -11,17 +10,6 @@ export default () => {
|
|
|
11
10
|
};
|
|
12
11
|
|
|
13
12
|
return (
|
|
14
|
-
<
|
|
15
|
-
<FormField.Label>Confirm</FormField.Label>
|
|
16
|
-
<FormField.Field>
|
|
17
|
-
<FormField.Input
|
|
18
|
-
as={Checkbox}
|
|
19
|
-
checked={checked}
|
|
20
|
-
disabled={true}
|
|
21
|
-
label="I agree to the terms"
|
|
22
|
-
onChange={handleChange}
|
|
23
|
-
/>
|
|
24
|
-
</FormField.Field>
|
|
25
|
-
</FormField>
|
|
13
|
+
<Checkbox checked={checked} disabled label="I agree to the terms" onChange={handleChange} />
|
|
26
14
|
);
|
|
27
15
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import {Checkbox} from '@workday/canvas-kit-react/checkbox';
|
|
4
|
-
import {
|
|
4
|
+
import {FormFieldGroup} from '@workday/canvas-kit-react/form-field';
|
|
5
5
|
|
|
6
6
|
export default () => {
|
|
7
7
|
const [checked, setChecked] = React.useState(false);
|
|
@@ -11,17 +11,18 @@ export default () => {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
<
|
|
17
|
-
<
|
|
14
|
+
<FormFieldGroup error="error">
|
|
15
|
+
<FormFieldGroup.Label>Confirm</FormFieldGroup.Label>
|
|
16
|
+
<FormFieldGroup.Field>
|
|
17
|
+
<FormFieldGroup.Input
|
|
18
18
|
as={Checkbox}
|
|
19
19
|
checked={checked}
|
|
20
|
+
error={Checkbox.ErrorType.Error}
|
|
20
21
|
label="I agree to the terms"
|
|
21
22
|
onChange={handleChange}
|
|
22
23
|
/>
|
|
23
|
-
<
|
|
24
|
-
</
|
|
25
|
-
</
|
|
24
|
+
<FormFieldGroup.Hint>You must agree to the terms before proceeding</FormFieldGroup.Hint>
|
|
25
|
+
</FormFieldGroup.Field>
|
|
26
|
+
</FormFieldGroup>
|
|
26
27
|
);
|
|
27
28
|
};
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import {Checkbox} from '@workday/canvas-kit-react/checkbox';
|
|
4
|
-
import {Box} from '@workday/canvas-kit-react/layout';
|
|
5
4
|
import {createStyles} from '@workday/canvas-kit-styling';
|
|
6
5
|
import {system} from '@workday/canvas-tokens-web';
|
|
7
6
|
|
|
8
|
-
const
|
|
7
|
+
const listStyles = createStyles({
|
|
8
|
+
listStyle: 'none',
|
|
9
|
+
margin: 0,
|
|
10
|
+
padding: 0,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const nestedListStyles = createStyles({
|
|
14
|
+
listStyle: 'none',
|
|
15
|
+
margin: 0,
|
|
9
16
|
marginInlineStart: system.gap.xl,
|
|
10
17
|
marginBlockStart: system.gap.sm,
|
|
18
|
+
padding: 0,
|
|
19
|
+
display: 'flex',
|
|
20
|
+
flexDirection: 'column',
|
|
21
|
+
gap: system.gap.sm,
|
|
11
22
|
});
|
|
12
23
|
|
|
13
24
|
export default () => {
|
|
@@ -59,23 +70,26 @@ export default () => {
|
|
|
59
70
|
};
|
|
60
71
|
|
|
61
72
|
return (
|
|
62
|
-
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
<ul className={listStyles}>
|
|
74
|
+
<li>
|
|
75
|
+
<Checkbox
|
|
76
|
+
checked={pizzaChecked}
|
|
77
|
+
indeterminate={pizzaIndeterminate}
|
|
78
|
+
label="Supreme Pizza Toppings"
|
|
79
|
+
onChange={handlePizzaChange}
|
|
80
|
+
/>
|
|
81
|
+
<ul className={nestedListStyles}>
|
|
82
|
+
{toppings.map((topping, index) => (
|
|
83
|
+
<li key={topping.name}>
|
|
84
|
+
<Checkbox
|
|
85
|
+
checked={topping.checked}
|
|
86
|
+
label={topping.name}
|
|
87
|
+
onChange={event => handleToppingChange(event, index)}
|
|
88
|
+
/>
|
|
89
|
+
</li>
|
|
90
|
+
))}
|
|
91
|
+
</ul>
|
|
92
|
+
</li>
|
|
93
|
+
</ul>
|
|
80
94
|
);
|
|
81
95
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import {Checkbox} from '@workday/canvas-kit-react/checkbox';
|
|
4
|
-
import {
|
|
4
|
+
import {FormFieldGroup} from '@workday/canvas-kit-react/form-field';
|
|
5
5
|
|
|
6
6
|
export default () => {
|
|
7
7
|
const [checked, setChecked] = React.useState(false);
|
|
@@ -11,16 +11,16 @@ export default () => {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
<
|
|
17
|
-
<
|
|
14
|
+
<FormFieldGroup orientation="horizontalStart">
|
|
15
|
+
<FormFieldGroup.Label>Confirm</FormFieldGroup.Label>
|
|
16
|
+
<FormFieldGroup.Field>
|
|
17
|
+
<FormFieldGroup.Input
|
|
18
18
|
as={Checkbox}
|
|
19
19
|
checked={checked}
|
|
20
20
|
label="I agree to the terms"
|
|
21
21
|
onChange={handleChange}
|
|
22
22
|
/>
|
|
23
|
-
</
|
|
24
|
-
</
|
|
23
|
+
</FormFieldGroup.Field>
|
|
24
|
+
</FormFieldGroup>
|
|
25
25
|
);
|
|
26
26
|
};
|
|
@@ -2,45 +2,33 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
4
4
|
import {Checkbox} from '@workday/canvas-kit-react/checkbox';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {createStyles
|
|
5
|
+
import {changeFocus} from '@workday/canvas-kit-react/common';
|
|
6
|
+
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
7
|
+
import {createStyles} from '@workday/canvas-kit-styling';
|
|
8
8
|
import {system} from '@workday/canvas-tokens-web';
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const containerStyles = createStyles({
|
|
11
|
+
gap: system.gap.md,
|
|
12
|
+
alignItems: 'flex-start',
|
|
12
13
|
flexDirection: 'column',
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
export default () => {
|
|
16
17
|
const [checked, setChecked] = React.useState(false);
|
|
17
|
-
const ref = React.useRef(null);
|
|
18
|
+
const ref = React.useRef<HTMLInputElement>(null);
|
|
18
19
|
|
|
19
20
|
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
20
21
|
setChecked(event.target.checked);
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
const handleClick = () => {
|
|
24
|
-
ref.current
|
|
25
|
+
changeFocus(ref.current);
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
return (
|
|
28
|
-
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<FormField.Field>
|
|
33
|
-
<FormField.Input
|
|
34
|
-
as={Checkbox}
|
|
35
|
-
checked={checked}
|
|
36
|
-
label="I agree to the terms"
|
|
37
|
-
onChange={handleChange}
|
|
38
|
-
ref={ref}
|
|
39
|
-
/>
|
|
40
|
-
</FormField.Field>
|
|
41
|
-
</FormField>
|
|
42
|
-
</Box>
|
|
43
|
-
<PrimaryButton onClick={handleClick}>Check Agreement to Terms</PrimaryButton>
|
|
44
|
-
</>
|
|
29
|
+
<Flex cs={containerStyles}>
|
|
30
|
+
<Checkbox checked={checked} label="I agree to the terms" onChange={handleChange} ref={ref} />
|
|
31
|
+
<PrimaryButton onClick={handleClick}>Focus Checkbox</PrimaryButton>
|
|
32
|
+
</Flex>
|
|
45
33
|
);
|
|
46
34
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import {Checkbox} from '@workday/canvas-kit-react/checkbox';
|
|
4
|
-
import {
|
|
4
|
+
import {FormFieldGroup} from '@workday/canvas-kit-react/form-field';
|
|
5
5
|
|
|
6
6
|
export default () => {
|
|
7
7
|
const [checked, setChecked] = React.useState(false);
|
|
@@ -11,16 +11,16 @@ export default () => {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
<
|
|
17
|
-
<
|
|
14
|
+
<FormFieldGroup isRequired={true}>
|
|
15
|
+
<FormFieldGroup.Label>Confirm</FormFieldGroup.Label>
|
|
16
|
+
<FormFieldGroup.Field>
|
|
17
|
+
<FormFieldGroup.Input
|
|
18
18
|
as={Checkbox}
|
|
19
19
|
checked={checked}
|
|
20
20
|
label="I agree to the terms"
|
|
21
21
|
onChange={handleChange}
|
|
22
22
|
/>
|
|
23
|
-
</
|
|
24
|
-
</
|
|
23
|
+
</FormFieldGroup.Field>
|
|
24
|
+
</FormFieldGroup>
|
|
25
25
|
);
|
|
26
26
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "16.1.0-
|
|
3
|
+
"version": "16.1.0-0590-next.0",
|
|
4
4
|
"description": "Documentation components of Canvas Kit components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"@stackblitz/sdk": "^1.11.0",
|
|
48
48
|
"@storybook/csf": "0.0.1",
|
|
49
49
|
"@workday/canvas-expressive-icons-web": "1.0.2",
|
|
50
|
-
"@workday/canvas-kit-labs-react": "^16.1.0-
|
|
51
|
-
"@workday/canvas-kit-preview-react": "^16.1.0-
|
|
52
|
-
"@workday/canvas-kit-react": "^16.1.0-
|
|
53
|
-
"@workday/canvas-kit-styling": "^16.1.0-
|
|
50
|
+
"@workday/canvas-kit-labs-react": "^16.1.0-0590-next.0",
|
|
51
|
+
"@workday/canvas-kit-preview-react": "^16.1.0-0590-next.0",
|
|
52
|
+
"@workday/canvas-kit-react": "^16.1.0-0590-next.0",
|
|
53
|
+
"@workday/canvas-kit-styling": "^16.1.0-0590-next.0",
|
|
54
54
|
"@workday/canvas-system-icons-web": "^5.0.3",
|
|
55
55
|
"@workday/canvas-tokens-web": "^4.4.0",
|
|
56
56
|
"markdown-to-jsx": "^7.2.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"mkdirp": "^1.0.3",
|
|
64
64
|
"typescript": "5.0"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "e5d6d9f4290f82891450b2fa5acf88d9d3990d58"
|
|
67
67
|
}
|