@workday/canvas-kit-docs 16.1.3 → 16.2.0-0604-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/docs.js +18348 -5198
- package/dist/es6/lib/specs.js +204 -20
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.js +5 -5
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.ts +5 -5
- package/dist/mdx/accessibility/AccessibilityOverview.mdx +1 -3
- package/dist/mdx/labs-react/selection-group/SelectionGroup.mdx +135 -0
- package/dist/mdx/labs-react/selection-group/examples/Basic.tsx +11 -0
- package/dist/mdx/labs-react/selection-group/examples/Caution.tsx +27 -0
- package/dist/mdx/labs-react/selection-group/examples/ColumnWidth.tsx +17 -0
- package/dist/mdx/labs-react/selection-group/examples/ContentWidth.tsx +11 -0
- package/dist/mdx/labs-react/selection-group/examples/Disabled.tsx +33 -0
- package/dist/mdx/labs-react/selection-group/examples/EqualWidth.tsx +11 -0
- package/dist/mdx/labs-react/selection-group/examples/Error.tsx +27 -0
- package/dist/mdx/labs-react/selection-group/examples/MultiSelect.tsx +41 -0
- package/dist/mdx/labs-react/selection-group/examples/RTL.tsx +13 -0
- package/dist/mdx/labs-react/selection-group/examples/SingleSelect.tsx +33 -0
- package/dist/mdx/preview-react/_examples/mdx/FormLibraryExample.mdx +1 -33
- package/dist/mdx/preview-react/_examples/mdx/examples/TextInputWithReactHookForm.tsx +65 -94
- package/dist/mdx/react/_examples/mdx/Density.mdx +3 -19
- package/dist/mdx/react/_examples/mdx/FormsWithFormik.mdx +9 -0
- package/dist/mdx/react/_examples/mdx/examples/Density.tsx +212 -139
- package/dist/mdx/react/_examples/mdx/examples/SelectWithFormik.tsx +84 -0
- package/dist/mdx/react/expandable/Expandable.mdx +55 -161
- package/package.json +6 -6
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {ExampleCodeBlock, SymbolDoc} from '@workday/canvas-kit-docs';
|
|
2
2
|
|
|
3
|
+
import StartIcon from './examples/StartIcon';
|
|
4
|
+
import EndIcon from './examples/EndIcon';
|
|
3
5
|
import Avatar from './examples/Avatar';
|
|
4
6
|
import Depth from './examples/Depth';
|
|
5
|
-
import EndIcon from './examples/EndIcon';
|
|
6
|
-
import HoistedModel from './examples/HoistedModel';
|
|
7
|
-
import LongTitle from './examples/LongTitle';
|
|
8
7
|
import RTL from './examples/RTL';
|
|
9
|
-
import
|
|
8
|
+
import LongTitle from './examples/LongTitle';
|
|
9
|
+
import HoistedModel from './examples/HoistedModel';
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
# Canvas Kit Expandable
|
|
@@ -23,8 +23,8 @@ yarn add @workday/canvas-kit-react
|
|
|
23
23
|
|
|
24
24
|
### Start Icon
|
|
25
25
|
|
|
26
|
-
For a basic expandable container with a chevron icon before the title, place
|
|
27
|
-
|
|
26
|
+
For a basic expandable container with a chevron icon before the title, place`Expandable.Icon` before
|
|
27
|
+
`Expandable.Title` as children of `Expandable.Target` and pass the `iconPosition` prop to
|
|
28
28
|
`Expandable.Icon` with a value of `start`. `Expandable.Icon` will use a right chevron icon when
|
|
29
29
|
collapsed and a down chevron icon when expanded.
|
|
30
30
|
|
|
@@ -46,12 +46,18 @@ To include an avatar image, `Expandable.Avatar` should be placed between `Expand
|
|
|
46
46
|
to `Expandable.Icon` depending on whether the `Expandable.Icon` is placed before or after
|
|
47
47
|
`Expandable.Title`.
|
|
48
48
|
|
|
49
|
-
**Note:** If using an avatar image, do not also include an Icon component in addition to the
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
**Note:** If using an avatar image, do not also include an Icon component in addition to the Expandable.Icon.
|
|
50
|
+
This component is meant to have either an avatar image or an icon in addition to the Expandable.Icon, or neither
|
|
51
|
+
an avatar image nor an extra icon.
|
|
52
|
+
|
|
52
53
|
|
|
53
54
|
<ExampleCodeBlock code={Avatar} />
|
|
54
55
|
|
|
56
|
+
> **Accessibility Note:** In this situation, the Avatar is decorative and should not be announced to
|
|
57
|
+
> screen readers. The `<Expandable.Avatar>` component has `isDecorative` set to `true` by default to
|
|
58
|
+
> hide it from screen readers, as avatars in expandable headers are typically decorative when paired
|
|
59
|
+
> with adjacent text.
|
|
60
|
+
|
|
55
61
|
### Right to Left (RTL)
|
|
56
62
|
|
|
57
63
|
Expandable container has bidirectional support and should function as expected with RTL languages as
|
|
@@ -72,6 +78,8 @@ Long titles will wrap to the next line and increase the height of the container.
|
|
|
72
78
|
|
|
73
79
|
<ExampleCodeBlock code={LongTitle} />
|
|
74
80
|
|
|
81
|
+
You can also have direct access to the model if
|
|
82
|
+
|
|
75
83
|
### Hoisted Model
|
|
76
84
|
|
|
77
85
|
If you need direct access to the model, you can hoist it with the `useExpandableModel` hook. In the
|
|
@@ -79,161 +87,47 @@ example below, we're hoisting the models to expand and collapse all three contai
|
|
|
79
87
|
|
|
80
88
|
<ExampleCodeBlock code={HoistedModel} />
|
|
81
89
|
|
|
82
|
-
|
|
83
|
-
|
|
90
|
+
> **Accessibility Note:** When using multiple Expandable Containers on a page, use the `as` prop to
|
|
91
|
+
> render the `<Expandable.Content>` sub-component as an HTML `<section>` element. Then, use
|
|
92
|
+
> `aria-labelledby` to reference the unique `id` of the `<Expandable.Title>` element. This practice
|
|
93
|
+
> can be useful to screen reader users when multiple Expandable Containers are opened at one time
|
|
94
|
+
> for uniquely describing the boundaries of the expandable content.
|
|
84
95
|
|
|
85
96
|
## Accessibility
|
|
86
97
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
subcomponents. **Do not duplicate them** in consuming code.
|
|
121
|
-
|
|
122
|
-
**ARIA and DOM** (_applied by hooks/subcomponents_):
|
|
123
|
-
|
|
124
|
-
- **`Expandable.Target`**: native `<button>` with `aria-expanded` (`true` when
|
|
125
|
-
`visibility !== 'hidden'`) and `aria-controls` set to the disclosure `id`. `onClick` toggles
|
|
126
|
-
`events.show()` / `events.hide()`.
|
|
127
|
-
- **`headingLevel`**: when set (`'h1'`–`'h6'`), wraps the button in **`Heading`** rendered as that
|
|
128
|
-
heading element. When omitted, the button is not wrapped in a heading.
|
|
129
|
-
- **`Expandable.Content`**: `id` set to the same disclosure `id`. Collapsed content stays in the DOM
|
|
130
|
-
with `display: none` (not unmounted). Default element is a `<div>`.
|
|
131
|
-
- **`Expandable.Title`**: styled `<div>` for the visible name. It does **not** receive an `id` from
|
|
132
|
-
the model.
|
|
133
|
-
- **`Expandable.Icon`**: decorative chevron that rotates from `visibility`. Expanded/collapsed state
|
|
134
|
-
for assistive technology comes from `aria-expanded`, not from the icon.
|
|
135
|
-
- **`Expandable.Avatar`**: `isDecorative={true}` by default so the image is hidden from assistive
|
|
136
|
-
technology when paired with **`Expandable.Title`**.
|
|
137
|
-
- Disclosure `id`: generated with `useUniqueId` unless you pass `id` to **`useExpandableModel`**.
|
|
138
|
-
Default `initialVisibility` is `'hidden'`.
|
|
139
|
-
|
|
140
|
-
**Keyboard** (_native button behavior_):
|
|
141
|
-
|
|
142
|
-
**`Expandable.Target`** uses native `<button>` keyboard behavior (tab order, <kbd>Enter</kbd> /
|
|
143
|
-
|
|
144
|
-
<kbd>Space</kbd> to toggle). Collapsed content is not in the tab order (`display: none`). Focus
|
|
145
|
-
stays on the button; Canvas Kit does not move focus into **`Expandable.Content`**.
|
|
146
|
-
|
|
147
|
-
**Screen reader expectations** (_when built-in behaviors are used as intended_):
|
|
148
|
-
|
|
149
|
-
- On focus, assistive technology announces the title text, the button role, and expanded/collapsed
|
|
150
|
-
state from `aria-expanded` (for example, "Title, button, collapsed")
|
|
151
|
-
- Activating the button announces the updated expanded/collapsed state from `aria-expanded`
|
|
152
|
-
- While collapsed, content is removed from the accessibility tree (`display: none`)
|
|
153
|
-
- While expanded, content follows the button in reading order
|
|
154
|
-
- When **`headingLevel`** is set, heading navigation includes the heading that wraps the button
|
|
155
|
-
- When **`Expandable.Content as="section"`** is used with `aria-labelledby` pointing at
|
|
156
|
-
**`Expandable.Title`**, region/landmark navigation can name each open section
|
|
157
|
-
|
|
158
|
-
### Accessibility Requirements
|
|
159
|
-
|
|
160
|
-
Required in application code for an accessible Expandable. Hoist **`useExpandableModel`** when you
|
|
161
|
-
need programmatic show/hide (for example, expand all) or a stable disclosure `id`. Rows marked
|
|
162
|
-
_(conditional)_ apply only when the situation matches—otherwise omit.
|
|
163
|
-
|
|
164
|
-
**If no design spec is provided:** use the **single disclosure** composition
|
|
165
|
-
([Basic Example](#basic-example)). If the spec is several related headers, use the **accordion**
|
|
166
|
-
composition. Omit **`Expandable.Avatar`**, **`initialVisibility`**, and a custom **`id`**.
|
|
167
|
-
|
|
168
|
-
**Choose a composition** (pick one; **`Expandable.Content as="section"`** and **`as="ul"`** are
|
|
169
|
-
mutually exclusive):
|
|
170
|
-
|
|
171
|
-
- **Single disclosure** — one show/hide section. [Basic Example](#basic-example) /
|
|
172
|
-
[Minimum Accessible Structure](#minimum-accessible-structure). Default Content is a `<div>`.
|
|
173
|
-
- **Accordion** — several related headers. [Hoisted Model](#hoisted-model): unique `id` on
|
|
174
|
-
**`Expandable.Title`**, **`Expandable.Content as="section"`** with `aria-labelledby`.
|
|
175
|
-
- **Navigation list** — disclosed links.
|
|
176
|
-
[Side Panel with Navigation](https://workday.github.io/canvas-kit/?path=/docs/guides-accessibility-examples-side-panel-navigation--docs):
|
|
177
|
-
**`as="ul"`**, omit **`headingLevel`**.
|
|
178
|
-
|
|
179
|
-
**Heading level:** Ask which heading (`h1`–`h6`) belongs in the document outline before setting
|
|
180
|
-
**`headingLevel`**. Omit **`headingLevel`** for navigation. Do not generate **`headingLevel`** by
|
|
181
|
-
default — the Basic Example code uses `h4` only as a sample.
|
|
182
|
-
|
|
183
|
-
| Requirement | How to satisfy |
|
|
184
|
-
| ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
185
|
-
| Accessible name | Non-empty **`Expandable.Title`** inside **`Expandable.Target`**. |
|
|
186
|
-
| Keyboard-operable toggle | **`Expandable.Target`** (native `<button>`). |
|
|
187
|
-
| Visual expanded/collapsed indicator | **`Expandable.Icon`** with `iconPosition` matching layout (`start` or `end`). |
|
|
188
|
-
| Heading in the document outline _(conditional)_ | **`headingLevel`** on **`Expandable.Target`** when the control titles body content (single disclosure or accordion). Omit **`headingLevel`** for the navigation-list composition. Ask which level. |
|
|
189
|
-
| Accordion named regions _(conditional)_ | Accordion composition: **`Expandable.Content as="section"`** plus `aria-labelledby` referencing a unique `id` on **`Expandable.Title`**. |
|
|
190
|
-
| List markup _(conditional)_ | Navigation-list composition: **`Expandable.Content as="ul"`** (and list items as children). |
|
|
191
|
-
| Decorative avatar _(conditional)_ | **`Expandable.Avatar`** when the design includes an avatar. Keep **`isDecorative`** at the default `true`. |
|
|
192
|
-
| Start expanded _(conditional)_ | `initialVisibility: 'visible'` on **`useExpandableModel`** (or the equivalent model config). |
|
|
193
|
-
| Programmatic expand/collapse _(conditional)_ | Hoist **`useExpandableModel`** and call `model.events.show()` / `model.events.hide()`. |
|
|
194
|
-
|
|
195
|
-
**Summary for code generation:**
|
|
196
|
-
|
|
197
|
-
- **REQUIRED:** **`Expandable.Target`**, non-empty **`Expandable.Title`**, **`Expandable.Content`**,
|
|
198
|
-
**`Expandable.Icon`**
|
|
199
|
-
- **CONDITIONAL:** composition (single disclosure vs accordion vs navigation list),
|
|
200
|
-
**`headingLevel`** (ask which; omit for navigation), accordion **`as="section"`** +
|
|
201
|
-
`aria-labelledby`, navigation **`as="ul"`**, **`Expandable.Avatar`**, hoisted
|
|
202
|
-
**`useExpandableModel`**, **`initialVisibility`**
|
|
203
|
-
|
|
204
|
-
### Anti-Patterns
|
|
205
|
-
|
|
206
|
-
Do **not** generate code that does the following (see **Accessibility Requirements** above for what
|
|
207
|
-
to supply instead):
|
|
208
|
-
|
|
209
|
-
- Manually set `aria-expanded`, `aria-controls`, or the disclosure `id` on **`Expandable.Target`**
|
|
210
|
-
or **`Expandable.Content`** — `useExpandableTarget` and `useExpandableContent` wire these
|
|
211
|
-
- Rely on **`Expandable.Icon`** or **`Expandable.Avatar`** for the accessible name — use
|
|
212
|
-
**`Expandable.Title`**
|
|
213
|
-
- Override **`Expandable.Target`** with a custom **`as`** — **`Expandable.Target`** already renders
|
|
214
|
-
a native `<button>`
|
|
215
|
-
- Set `id` on **`Expandable`** to identify the outer wrapper — `id` is model config **and** is
|
|
216
|
-
forwarded to the container element, while **`Expandable.Content`** also uses `state.id`, which can
|
|
217
|
-
produce duplicate IDs. For a stable content `id`, hoist **`useExpandableModel({id: '…'})`**.
|
|
218
|
-
**`Expandable.Title`** still needs its own `id` when you set `aria-labelledby` on
|
|
219
|
-
**`Expandable.Content`**
|
|
220
|
-
- Wrap **`Expandable.Target`** in your own heading — use **`headingLevel`** instead
|
|
221
|
-
- Default **`headingLevel`** to `h4` (or any level) without asking, or set **`headingLevel`** on
|
|
222
|
-
navigation disclosures
|
|
223
|
-
- Generate several Basic Example disclosures with default `div` Content when the spec is an
|
|
224
|
-
accordion — use the **accordion** composition (see **Choose a composition**)
|
|
225
|
-
- Set **`as="section"`** and **`as="ul"`** on the same **`Expandable.Content`** — pick one
|
|
226
|
-
composition
|
|
227
|
-
- Change **`Expandable.Title`** to encode state (for example "Collapsed" / "Expanded" or "Show" /
|
|
228
|
-
"Hide") — `aria-expanded` already exposes state
|
|
229
|
-
- Unmount **`Expandable.Content`** when collapsed, or add `aria-hidden` on it — the library uses
|
|
230
|
-
`display: none`
|
|
231
|
-
- Set **`isDecorative={false}`** on **`Expandable.Avatar`** by default, or pair an avatar with an
|
|
232
|
-
extra non-chevron icon
|
|
233
|
-
- Use **`open`**, **`expanded`**, or **`onToggle`** props on **`Expandable`** — visibility is
|
|
234
|
-
`initialVisibility` plus **`useExpandableModel`** events
|
|
235
|
-
- Assume default **`Expandable.Content`** is a landmark region — that is only true with
|
|
236
|
-
**`as="section"`**
|
|
98
|
+
Our Expandable component renders a semantic HTML `<button>` element to the DOM, with an optional
|
|
99
|
+
parent heading element as defined by the `headingLevel` prop. The `aria-expanded` property is
|
|
100
|
+
included on the button to indicate the state of the content to screen readers.
|
|
101
|
+
|
|
102
|
+
[Accordion Pattern | APG | WAI | W3C](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/)
|
|
103
|
+
|
|
104
|
+
- Use the `headingLevel` prop to assign an appropriate heading level based on the context of the
|
|
105
|
+
page content.
|
|
106
|
+
- When using Expandable Container for navigation elements, then we don't recommend using the
|
|
107
|
+
`headingLevel` prop. This will render only expandable buttons to the DOM, reserving headings for
|
|
108
|
+
organizing content in the main body of the page.
|
|
109
|
+
- The `as` prop may also be used on `<Expandable.Content>` to render an HTML `<ul>` element for
|
|
110
|
+
displaying a list of items. For example, check out
|
|
111
|
+
[Side Panel with Navigation](https://workday.github.io/canvas-kit/?path=/docs/guides-accessibility-examples-side-panel-navigation--docs).
|
|
112
|
+
|
|
113
|
+
### Navigation
|
|
114
|
+
|
|
115
|
+
- **Tab key**: Moves focus to the next expandable button or focusable element
|
|
116
|
+
- **Shift + Tab**: Moves focus to the previous focusable element
|
|
117
|
+
- **Enter or Space**: Toggles the expanded/collapsed state
|
|
118
|
+
|
|
119
|
+
### Screen Reader Experience
|
|
120
|
+
|
|
121
|
+
- The expandable button will be announced with its title text followed by the button role
|
|
122
|
+
- The current state will be announced as either "collapsed" or "expanded" (For example: "Usage
|
|
123
|
+
Guidance, button, collapsed" or "Usage Guidance, button, expanded")
|
|
124
|
+
- **State Changes:** When activating the button to expand content, screen readers will announce the
|
|
125
|
+
new "expanded" state and vice versa when collapsing content.
|
|
126
|
+
- **Content Regions:** Screen reader users can use landmark navigation to jump between sections and
|
|
127
|
+
each section will be announced with its associated title (For example: "Usage Guidance, landmark
|
|
128
|
+
region")
|
|
129
|
+
- **Heading Structure:** Using heading levels with expandable buttons allows screen reader users to
|
|
130
|
+
navigate by headings, making the document structure and hierarchy easier to understand.
|
|
237
131
|
|
|
238
132
|
## Component API
|
|
239
133
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.2.0-0604-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.
|
|
51
|
-
"@workday/canvas-kit-preview-react": "^16.
|
|
52
|
-
"@workday/canvas-kit-react": "^16.
|
|
53
|
-
"@workday/canvas-kit-styling": "^16.
|
|
50
|
+
"@workday/canvas-kit-labs-react": "^16.2.0-0604-next.0",
|
|
51
|
+
"@workday/canvas-kit-preview-react": "^16.2.0-0604-next.0",
|
|
52
|
+
"@workday/canvas-kit-react": "^16.2.0-0604-next.0",
|
|
53
|
+
"@workday/canvas-kit-styling": "^16.2.0-0604-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": "58ce933e857e255360611f2330a230b167cead8d"
|
|
67
67
|
}
|