@workday/canvas-kit-docs 7.2.0-next.1 → 7.2.1
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/commonjs/lib/specs.js +0 -4
- package/dist/es6/lib/specs.js +0 -4
- package/dist/mdx/7.0-UPGRADE-GUIDE.mdx +11 -2
- package/dist/mdx/react/button/button/Button.mdx +2 -2
- package/dist/mdx/react/collection/Collection.mdx +271 -49
- package/dist/mdx/react/collection/Collection.splitprops.tsx +19 -0
- package/dist/mdx/react/collection/examples/BasicGrid.tsx +46 -0
- package/dist/mdx/react/collection/examples/WrappingGrid.tsx +48 -0
- package/dist/mdx/react/radio/examples/Basic.tsx +11 -2
- package/dist/mdx/react/skeleton/examples/Simulation.tsx +23 -23
- package/dist/mdx/react/tabs/TabsModel.splitprops.tsx +7 -3
- package/package.json +3 -3
|
@@ -2258,10 +2258,6 @@ module.exports = {specifications: [
|
|
|
2258
2258
|
"type": "it",
|
|
2259
2259
|
"name": "should set aria-atomic to true"
|
|
2260
2260
|
},
|
|
2261
|
-
{
|
|
2262
|
-
"type": "it",
|
|
2263
|
-
"name": "should set aria-relevant to true"
|
|
2264
|
-
},
|
|
2265
2261
|
{
|
|
2266
2262
|
"type": "it",
|
|
2267
2263
|
"name": "should describe the current page range and the total page count"
|
package/dist/es6/lib/specs.js
CHANGED
|
@@ -2258,10 +2258,6 @@ module.exports = {specifications: [
|
|
|
2258
2258
|
"type": "it",
|
|
2259
2259
|
"name": "should set aria-atomic to true"
|
|
2260
2260
|
},
|
|
2261
|
-
{
|
|
2262
|
-
"type": "it",
|
|
2263
|
-
"name": "should set aria-relevant to true"
|
|
2264
|
-
},
|
|
2265
2261
|
{
|
|
2266
2262
|
"type": "it",
|
|
2267
2263
|
"name": "should describe the current page range and the total page count"
|
|
@@ -431,7 +431,9 @@ The APIs for these promoted components remain unchanged.
|
|
|
431
431
|
|
|
432
432
|
### Action Bar
|
|
433
433
|
|
|
434
|
-
|
|
434
|
+
#### Model
|
|
435
|
+
|
|
436
|
+
The `ActionBar` API changed to model API to support more generic behaviors to allow for other
|
|
435
437
|
components to support responsive layouts using the same models and behaviors. It also allows to
|
|
436
438
|
implement a responsive layout based on a container width
|
|
437
439
|
([#1585](https://github.com/Workday/canvas-kit/pull/1585)).
|
|
@@ -449,7 +451,9 @@ const model = useActionBarModel({
|
|
|
449
451
|
<ActionBar model={model} />;
|
|
450
452
|
```
|
|
451
453
|
|
|
452
|
-
|
|
454
|
+
#### Responsive Container Support
|
|
455
|
+
|
|
456
|
+
The `ActionBar` component can now handle responsive containers, but the support is not automatic. You
|
|
453
457
|
must use the dynamic API and provide an overflow menu subcomponent. The dynamic API doesn't know the
|
|
454
458
|
shape of your object, so render props must be used to instruct React how to render each item.
|
|
455
459
|
|
|
@@ -497,6 +501,11 @@ const model = useActionBarModel({items});
|
|
|
497
501
|
</ActionBar>;
|
|
498
502
|
```
|
|
499
503
|
|
|
504
|
+
#### Fixed Position Prop
|
|
505
|
+
|
|
506
|
+
`ActionBar`'s boolean `fixed` prop has been removed. It has been replaced by a new `position` style
|
|
507
|
+
prop in the `ActionBar.List` component and is set to `fixed` by default.
|
|
508
|
+
|
|
500
509
|
🤖 The codemod will remove uses of the `fixed` prop from `ActionBar` and restructure component by
|
|
501
510
|
creating `ActionBar.List` subcomponent and replacing all `ActionBar` children to it.
|
|
502
511
|
|
|
@@ -84,8 +84,8 @@ the user may not often be looking to do. Tertiary Buttons have lower prominence
|
|
|
84
84
|
not visible until it is interacted with. Use Tertiary Buttons for supplemental actions such as “View
|
|
85
85
|
More”, “Read More” or “Select a File”. Tertiary Buttons are frequently used on Cards.
|
|
86
86
|
|
|
87
|
-
Tertiary Buttons have three sizes: `extraSmall`, `small`, and `
|
|
88
|
-
every size and can be positioned at the `start` or `end` with the `iconPosition` prop.
|
|
87
|
+
Tertiary Buttons have three sizes: `extraSmall`, `small`, `medium` and `large`. Icons are supported
|
|
88
|
+
for every size and can be positioned at the `start` or `end` with the `iconPosition` prop.
|
|
89
89
|
|
|
90
90
|
<ExampleCodeBlock code={Tertiary} />
|
|
91
91
|
|
|
@@ -7,6 +7,17 @@ import IdentifiedItems from './examples/IdentifiedItems';
|
|
|
7
7
|
import RovingFocus from './examples/RovingFocus';
|
|
8
8
|
import Selection from './examples/Selection';
|
|
9
9
|
import MultiSelection from './examples/MultiSelection';
|
|
10
|
+
import BasicGrid from './examples/BasicGrid';
|
|
11
|
+
import WrappingGrid from './examples/WrappingGrid';
|
|
12
|
+
import {
|
|
13
|
+
ListModelConfigComponent,
|
|
14
|
+
ListStateComponent,
|
|
15
|
+
ListEventsComponent,
|
|
16
|
+
GridModelConfigComponent,
|
|
17
|
+
GridStateComponent,
|
|
18
|
+
GridEventsComponent,
|
|
19
|
+
NavigationManager,
|
|
20
|
+
} from './Collection.splitprops';
|
|
10
21
|
|
|
11
22
|
|
|
12
23
|
# Canvas Kit Collection API
|
|
@@ -24,21 +35,7 @@ yarn add @workday/canvas-kit-react
|
|
|
24
35
|
|
|
25
36
|
## Usage
|
|
26
37
|
|
|
27
|
-
###
|
|
28
|
-
|
|
29
|
-
The `ListBox` is a basic component that offers vertical rendering of a collection in the form of a
|
|
30
|
-
2-dimension list. It understands virtualization, rendering only visible items in the DOM while also
|
|
31
|
-
providing aria attributes to allow screen readers to still navigate virtual lists. The `ListBox`
|
|
32
|
-
contains a basic `ListBox.Item` that renders list items that render correctly with virtualization
|
|
33
|
-
and adds `aria-setsize` and `aria-posinset` for screen readers.
|
|
34
|
-
|
|
35
|
-
The `ListBox` is very basic and only adds enough functionality to render correctly. No additional
|
|
36
|
-
behaviors are added to navigate or select. React Hooks are provided to add this functionality and
|
|
37
|
-
are used by higher level components like `Menu` and `Menu.Item` which utilize `ListBox`.
|
|
38
|
-
|
|
39
|
-
<ArgsTable of={ListBox} />
|
|
40
|
-
|
|
41
|
-
#### Basic Example
|
|
38
|
+
### Basic Example
|
|
42
39
|
|
|
43
40
|
The `ListBox` on its own isn't very useful. It registers each item with the model. The
|
|
44
41
|
`ListBox.Item` only uses the `useListItemRegister` hook which handles registration of static items
|
|
@@ -47,7 +44,7 @@ as [Dynamic List](#dynamic-list) example).
|
|
|
47
44
|
|
|
48
45
|
<ExampleCodeBlock code={Basic} />
|
|
49
46
|
|
|
50
|
-
|
|
47
|
+
### Identifying Items
|
|
51
48
|
|
|
52
49
|
A list item takes an optional `data-id` property that will be used to identify an item. Without a
|
|
53
50
|
`data-id`, the identifier will be the item's index when first registered. The basic example has a
|
|
@@ -57,7 +54,7 @@ item for selection, maintaining a cursor, or anything else.
|
|
|
57
54
|
|
|
58
55
|
<ExampleCodeBlock code={IdentifiedItems} />
|
|
59
56
|
|
|
60
|
-
|
|
57
|
+
### Dynamic Items
|
|
61
58
|
|
|
62
59
|
The `ListBox` also handles a dynamic collection of items. Instead of providing each `ListBox.Item`
|
|
63
60
|
statically, provide a render function instead. The function is called with an `items` value that is
|
|
@@ -68,35 +65,6 @@ item, which could cause problems for popup menus. If your item count is low, pas
|
|
|
68
65
|
|
|
69
66
|
<ExampleCodeBlock code={DynamicItems} />
|
|
70
67
|
|
|
71
|
-
### List Model
|
|
72
|
-
|
|
73
|
-
The List model contains the the state and events necessary to track items, selection, and a cursor.
|
|
74
|
-
Various hooks can be used for a List model to create common behaviors associated with lists, such as
|
|
75
|
-
navigating a list with a keyboard, selection (single and multiple), and virtualization.
|
|
76
|
-
|
|
77
|
-
A list also has a "cursor". A cursor is often represented by focus, but it is not always a 1:1
|
|
78
|
-
mapping. Think of the cursor as the focus item within the list. If the list has browser focus, the
|
|
79
|
-
cursor will map to browser focus. Behaviors such as `useListRovingFocus` will map the cursor to the
|
|
80
|
-
active tab stop of the list. For more information, see
|
|
81
|
-
[Roving Tabindex](https://w3c.github.io/aria-practices/#kbd_roving_tabindex). `useListRovingFocus`
|
|
82
|
-
adds keyboard events that map to navigation events. A [Navigation Manager](#navigation-manager) is
|
|
83
|
-
used to map new cursor ids to these events. The `ListModel` takes an optional `navigation`
|
|
84
|
-
configuration to change the default navigation behavior. The default navigation manager is a
|
|
85
|
-
[wrappingNavigationManager](#wrappingnavigationmanager) meaning the cursor will wrap around the
|
|
86
|
-
beginning and the ends. The cursor also provides a [navigationManager](#navigationmanager) that does
|
|
87
|
-
not wrap. This is the default navigation for grids.
|
|
88
|
-
|
|
89
|
-
The cursor also adds the concept of `orientation` which defaults to `'vertical'`. A Tab list is an
|
|
90
|
-
example of a `'horizontal'` list.
|
|
91
|
-
|
|
92
|
-
### Grid
|
|
93
|
-
|
|
94
|
-
A Cursor List can become a grid if a `columnCount` is provided. The array of items is still flat,
|
|
95
|
-
but navigational controls are now in two dimensions instead of one. A one dimension list is
|
|
96
|
-
bidirectionally aware, but a grid will always
|
|
97
|
-
|
|
98
|
-
#### Navigation Manager
|
|
99
|
-
|
|
100
68
|
#### Roving Tabindex
|
|
101
69
|
|
|
102
70
|
The list system also includes a cursor that extends the list. A cursor is mostly used for focusing
|
|
@@ -128,9 +96,263 @@ uses `ListBox` and creates a custom `SelectableItem` elemProps hook and componen
|
|
|
128
96
|
|
|
129
97
|
#### Multiple Selection
|
|
130
98
|
|
|
131
|
-
|
|
132
|
-
|
|
99
|
+
The `selection` manager can be passed directly to the model configuration to handle different
|
|
100
|
+
selection types. This example passes the `multiSelectionManager` to handle selecting multiple items.
|
|
133
101
|
|
|
134
102
|
<ExampleCodeBlock code={MultiSelection} />
|
|
135
103
|
|
|
136
|
-
###
|
|
104
|
+
### Basic Grid
|
|
105
|
+
|
|
106
|
+
A grid is a two dimensional list. A `columnCount` config is added to inform how to break up an array
|
|
107
|
+
of items. A grid is very similar to a list - it receives items as a single dimension list and uses
|
|
108
|
+
the `columnCount` to determine keyboard navigation. Grids only support a single orientation.
|
|
109
|
+
|
|
110
|
+
<ExampleCodeBlock code={BasicGrid} />
|
|
111
|
+
|
|
112
|
+
#### Wrapping Grid
|
|
113
|
+
|
|
114
|
+
By default, navigating a grid does not wrap around when the user reaches the end of a row or column.
|
|
115
|
+
The grid model supports passing in a navigation manager. The collection system supports two types of
|
|
116
|
+
navigation managers, a non-wrapping `navigationManager` and the `wrappingNavigationManager`. The
|
|
117
|
+
following example passes the `wrappingNavigationManager` manager to the model. Observe how the
|
|
118
|
+
cursor wraps around columns and rows when an edge of a column or row is encountered.
|
|
119
|
+
|
|
120
|
+
<ExampleCodeBlock code={WrappingGrid} />
|
|
121
|
+
|
|
122
|
+
## Components
|
|
123
|
+
|
|
124
|
+
### ListBox
|
|
125
|
+
|
|
126
|
+
#### Usage
|
|
127
|
+
|
|
128
|
+
The `ListBox` is a basic component that offers vertical rendering of a collection in the form of a
|
|
129
|
+
2-dimension list. It understands virtualization, rendering only visible items in the DOM while also
|
|
130
|
+
providing aria attributes to allow screen readers to still navigate virtual lists. The `ListBox`
|
|
131
|
+
contains a basic `ListBox.Item` that renders list items that render correctly with virtualization
|
|
132
|
+
and adds `aria-setsize` and `aria-posinset` for screen readers.
|
|
133
|
+
|
|
134
|
+
The `ListBox` is very basic and only adds enough functionality to render correctly. No additional
|
|
135
|
+
behaviors are added to navigate or select. React Hooks are provided to add this functionality and
|
|
136
|
+
are used by higher level components like `Menu` and `Menu.Item` which utilize `ListBox`.
|
|
137
|
+
|
|
138
|
+
#### Props
|
|
139
|
+
|
|
140
|
+
<ArgsTable of={ListBox} />
|
|
141
|
+
|
|
142
|
+
### ListBox.Item
|
|
143
|
+
|
|
144
|
+
#### Usage
|
|
145
|
+
|
|
146
|
+
The `ListBox.Item` is a simple placeholder for listbox items. The functionality of a collection item
|
|
147
|
+
varies between components. For example, a `Tabs.Item` and a `Menu.Item` have shared functionality,
|
|
148
|
+
but have different behavior. All collection-based components should implement a custom `Item`
|
|
149
|
+
subcomponent using the collection-based behavior hooks. The [Roving Tabindex](#roving-tabindex)
|
|
150
|
+
example uses the `elemPropsHook` to provide additional functionality. `elemPropsHook` is provided on
|
|
151
|
+
all compound components and is useful in the example to add additional functionality without making
|
|
152
|
+
a new component.
|
|
153
|
+
|
|
154
|
+
#### Props
|
|
155
|
+
|
|
156
|
+
<ArgsTable of={ListBox.Item} />
|
|
157
|
+
|
|
158
|
+
## Models
|
|
159
|
+
|
|
160
|
+
There are two supported models based on the collection system.
|
|
161
|
+
|
|
162
|
+
### `useListModel`
|
|
163
|
+
|
|
164
|
+
The List model contains the the state and events necessary to track items, selection, and a cursor.
|
|
165
|
+
Various hooks can be used for a List model to create common behaviors associated with lists, such as
|
|
166
|
+
navigating a list with a keyboard, selection (single and multiple), and virtualization.
|
|
167
|
+
|
|
168
|
+
A list also has a "cursor". A cursor is often represented by focus, but it is not always a 1:1
|
|
169
|
+
mapping. Think of the cursor as the focus item within the list. If the list has browser focus, the
|
|
170
|
+
cursor will map to browser focus. Behaviors such as `useListRovingFocus` will map the cursor to the
|
|
171
|
+
active tab stop of the list. For more information, see
|
|
172
|
+
[Roving Tabindex](https://w3c.github.io/aria-practices/#kbd_roving_tabindex). `useListRovingFocus`
|
|
173
|
+
adds keyboard events that map to navigation events. A [Navigation Manager](#navigation-manager) is
|
|
174
|
+
used to map new cursor ids to these events. The `ListModel` takes an optional `navigation`
|
|
175
|
+
configuration to change the default navigation behavior. The default navigation manager is a
|
|
176
|
+
[wrappingNavigationManager](#wrappingnavigationmanager) meaning the cursor will wrap around the
|
|
177
|
+
beginning and the ends. The cursor also provides a [navigationManager](#navigationmanager) that does
|
|
178
|
+
not wrap. This is the default navigation for grids.
|
|
179
|
+
|
|
180
|
+
The cursor also adds the concept of `orientation` which defaults to `'vertical'`. A Tab list is an
|
|
181
|
+
example of a `'horizontal'` list.
|
|
182
|
+
|
|
183
|
+
#### Config
|
|
184
|
+
|
|
185
|
+
<ArgsTable of={ListModelConfigComponent} />
|
|
186
|
+
|
|
187
|
+
#### State
|
|
188
|
+
|
|
189
|
+
<ArgsTable of={ListStateComponent} />
|
|
190
|
+
|
|
191
|
+
#### Events
|
|
192
|
+
|
|
193
|
+
<ArgsTable of={ListEventsComponent} />
|
|
194
|
+
|
|
195
|
+
### `useGridModel`
|
|
196
|
+
|
|
197
|
+
The Grid model extends the List model and changes some config. For example, the `columnCount` is
|
|
198
|
+
required on the grid model's configuration and `orientation` is removed.
|
|
199
|
+
|
|
200
|
+
#### Config
|
|
201
|
+
|
|
202
|
+
<ArgsTable of={GridModelConfigComponent} />
|
|
203
|
+
|
|
204
|
+
#### State
|
|
205
|
+
|
|
206
|
+
<ArgsTable of={GridStateComponent} />
|
|
207
|
+
|
|
208
|
+
#### Events
|
|
209
|
+
|
|
210
|
+
<ArgsTable of={GridEventsComponent} />
|
|
211
|
+
|
|
212
|
+
### Navigation Manager
|
|
213
|
+
|
|
214
|
+
The list and grid models accept a `navigation` config. If one is not provided, a default will be
|
|
215
|
+
chosen. It is possible to create a custom navigation manager to hand to the model if the default
|
|
216
|
+
doesn't work.
|
|
217
|
+
|
|
218
|
+
<ArgsTable of={NavigationManager} />
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
type NavigationRequestor = <T>(id: string, model: Model) => Item<T>;
|
|
222
|
+
|
|
223
|
+
interface Item<T> {
|
|
224
|
+
index: number;
|
|
225
|
+
id: string;
|
|
226
|
+
value: T;
|
|
227
|
+
/**
|
|
228
|
+
* Used by components that allow jumping to an item based on typing
|
|
229
|
+
*/
|
|
230
|
+
textValue?: string;
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
#### `navigationManager`
|
|
235
|
+
|
|
236
|
+
The `navigationManager` implements the [Navigation Manager](#navigation-manager) interface for lists
|
|
237
|
+
and grids, but does not wrap when the user hits a boundary of the collection. This is the default
|
|
238
|
+
navigation manager for grids.
|
|
239
|
+
|
|
240
|
+
#### `wrappingNavigationManager`
|
|
241
|
+
|
|
242
|
+
The `wrappingNavigationManager` implements the [Navigation Manager](#navigation-manager) interface
|
|
243
|
+
for lists and grids, and wraps when the user hits a boundary of the collection. Grids will wrap
|
|
244
|
+
columns, but not rows. This is the default navigation manager for lists.
|
|
245
|
+
|
|
246
|
+
### Selection Manager
|
|
247
|
+
|
|
248
|
+
The list and grid models accept a `selection` config. If one is not provided, `singleSelectManager`
|
|
249
|
+
is used. You can provide a custom select manager to suite your needs. A selection manager is an
|
|
250
|
+
object with a single `select` method that takes an id and previously selected ids and returns a new
|
|
251
|
+
set of selected ids.
|
|
252
|
+
|
|
253
|
+
The collection system provides two selection managers: `singleSelectManager` and
|
|
254
|
+
`multiSelectionManager`.
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
interface Selection {
|
|
258
|
+
selectedIds: 'all' | string[];
|
|
259
|
+
unselectedIds: string[];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
interface SelectionManager {
|
|
263
|
+
select(id: string, prevState: Selection): Selection;
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Hooks
|
|
268
|
+
|
|
269
|
+
### `useListItemRegister`
|
|
270
|
+
|
|
271
|
+
This elemProps hook is the base of all item component hooks. It registers an item with a collection
|
|
272
|
+
and sets the `data-id` that is used by other hooks. It should always be the last defined hook when
|
|
273
|
+
using `composeHooks` (`composeHooks` executes hooks right to left and merges props left to right).
|
|
274
|
+
It is used by `ListBox.Item` and all `*.Item` subcomponents.
|
|
275
|
+
|
|
276
|
+
```ts
|
|
277
|
+
const useMyItem = composeHooks(
|
|
278
|
+
useListItemSelect, // additional hooks go here
|
|
279
|
+
useListItemRegister // always last
|
|
280
|
+
);
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### `useListItemRovingFocus`
|
|
284
|
+
|
|
285
|
+
This elemProps hook is used for cursor navigation by using
|
|
286
|
+
[Roving Tabindex](https://w3c.github.io/aria-practices/#kbd_roving_tabindex). Only a single item in
|
|
287
|
+
the collection has a tab stop. Pressing an arrow key moves the tab stop to a different item in the
|
|
288
|
+
corresponding direction. See the [Roving Tabindex](#roving-tabindex) example. This elemProps hook
|
|
289
|
+
should be applied to an `*.Item` component.
|
|
290
|
+
|
|
291
|
+
```ts
|
|
292
|
+
const useMyItem = composeHooks(
|
|
293
|
+
useListItemRovingFocus, // adds the roving tabindex support
|
|
294
|
+
useListItemRegister
|
|
295
|
+
);
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### `useListItemSelect`
|
|
299
|
+
|
|
300
|
+
This elemProps hook adds selection support to a `*.Item` subcomponent of a collection. It adds a
|
|
301
|
+
click handler that toggles selection status according to the [Selection Manager](#selection-manager)
|
|
302
|
+
used.
|
|
303
|
+
|
|
304
|
+
```ts
|
|
305
|
+
const useMyItem = composeHooks(
|
|
306
|
+
useListItemSelect, // adds selection support to an item
|
|
307
|
+
useListItemRegister
|
|
308
|
+
);
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### `useListRenderItem`
|
|
312
|
+
|
|
313
|
+
```ts
|
|
314
|
+
declare function useListRenderItem<T>(
|
|
315
|
+
model: Model,
|
|
316
|
+
children: React.ReactNode | ((item: T, index: number) => React.ReactNode)
|
|
317
|
+
): React.ReactNode;
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
This hook is meant to be used inside the render function of `List` style components. It is used by
|
|
321
|
+
`ListBox`. This hook gives list-based components their static and dynamic APIs to handle list items.
|
|
322
|
+
This hook should only be used if you want to implement your own List. For example, `Tabs.List` uses
|
|
323
|
+
this hook, but `Menu.List` uses `ListBox` which uses this hook.
|
|
324
|
+
|
|
325
|
+
```tsx
|
|
326
|
+
const MyList = createContainer('ul')({
|
|
327
|
+
modelHook: useListModel,
|
|
328
|
+
})((elemProps, Element, model) => {
|
|
329
|
+
return <Element {...elemProps}>{useListRenderItems(model, elemProps.children)}</Element>;
|
|
330
|
+
});
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### `useListResetCursorOnBlur`
|
|
334
|
+
|
|
335
|
+
This elemProps hook resets the cursor when the list looses focus. By default,
|
|
336
|
+
[useListItemRovingFocus](#use-list-item-roving-focus) will leave the last focused item as the
|
|
337
|
+
focusable item in the list. Sometimes it is desireable to reset the cursor to the last selected
|
|
338
|
+
item. For example, `Tabs.Item` uses this hook to reset the tab stop to the currently selected tab.
|
|
339
|
+
|
|
340
|
+
```ts
|
|
341
|
+
const useMyItem = composeHooks(
|
|
342
|
+
useListResetCursorOnBlur, // adds the cursor reset to selected for roving tabindex
|
|
343
|
+
useListItemRovingFocus,
|
|
344
|
+
useListItemRegister
|
|
345
|
+
);
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### `useOverflowListItemMeasure`
|
|
349
|
+
|
|
350
|
+
Coming Soon
|
|
351
|
+
|
|
352
|
+
### `useOverflowListMeasure`
|
|
353
|
+
|
|
354
|
+
Coming Soon
|
|
355
|
+
|
|
356
|
+
### `useOverflowListTarget`
|
|
357
|
+
|
|
358
|
+
Coming Soon
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {useListModel, useGridModel} from '@workday/canvas-kit-react/collection';
|
|
2
|
+
|
|
3
|
+
type ListModelConfig = Partial<typeof useListModel.defaultConfig> &
|
|
4
|
+
typeof useListModel.requiredConfig;
|
|
5
|
+
type ListModel = ReturnType<typeof useListModel>;
|
|
6
|
+
|
|
7
|
+
type GridModelConfig = Partial<typeof useGridModel.defaultConfig> &
|
|
8
|
+
typeof useGridModel.requiredConfig;
|
|
9
|
+
type GridModel = ReturnType<typeof useGridModel>;
|
|
10
|
+
|
|
11
|
+
export const ListModelConfigComponent = (_: ListModelConfig) => <div />;
|
|
12
|
+
export const ListStateComponent = (_: ListModel['state']) => <div />;
|
|
13
|
+
export const ListEventsComponent = (_: ListModel['events']) => <div />;
|
|
14
|
+
|
|
15
|
+
export const GridModelConfigComponent = (_: GridModelConfig) => <div />;
|
|
16
|
+
export const GridStateComponent = (_: GridModel['state']) => <div />;
|
|
17
|
+
export const GridEventsComponent = (_: GridModel['events']) => <div />;
|
|
18
|
+
|
|
19
|
+
export const NavigationManager = (_: GridModelConfig['navigation']) => <div />;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Flex, Box} from '@workday/canvas-kit-react/layout';
|
|
4
|
+
import {
|
|
5
|
+
ListBox,
|
|
6
|
+
useGridModel,
|
|
7
|
+
useListItemSelect,
|
|
8
|
+
useListItemRovingFocus,
|
|
9
|
+
useListItemRegister,
|
|
10
|
+
} from '@workday/canvas-kit-react/collection';
|
|
11
|
+
import {composeHooks, createSubcomponent} from '@workday/canvas-kit-react/common';
|
|
12
|
+
|
|
13
|
+
const useItem = composeHooks(useListItemSelect, useListItemRovingFocus, useListItemRegister);
|
|
14
|
+
|
|
15
|
+
const Item = createSubcomponent('button')({
|
|
16
|
+
modelHook: useGridModel,
|
|
17
|
+
elemPropsHook: useItem,
|
|
18
|
+
})((elemProps, Element, model) => {
|
|
19
|
+
return (
|
|
20
|
+
<Box
|
|
21
|
+
as={Element}
|
|
22
|
+
{...elemProps}
|
|
23
|
+
width={40}
|
|
24
|
+
border="solid 1px black"
|
|
25
|
+
style={{
|
|
26
|
+
background: model.state.selectedIds.includes(elemProps['data-id']) ? 'gray' : 'white',
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export default () => {
|
|
33
|
+
const model = useGridModel({
|
|
34
|
+
columnCount: 5,
|
|
35
|
+
// @ts-ignore Create an array of [{id: 1}, ...{id: n}]
|
|
36
|
+
items: [...Array(25).keys()].map(i => ({id: i + 1})),
|
|
37
|
+
// we don't need virtualization here
|
|
38
|
+
shouldVirtualize: false,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<ListBox model={model} as={Flex} flexDirection="row" flexWrap="wrap" width={200}>
|
|
43
|
+
{item => <Item>{item.id}</Item>}
|
|
44
|
+
</ListBox>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Flex, Box} from '@workday/canvas-kit-react/layout';
|
|
4
|
+
import {
|
|
5
|
+
ListBox,
|
|
6
|
+
useGridModel,
|
|
7
|
+
useListItemSelect,
|
|
8
|
+
useListItemRovingFocus,
|
|
9
|
+
useListItemRegister,
|
|
10
|
+
wrappingNavigationManager,
|
|
11
|
+
} from '@workday/canvas-kit-react/collection';
|
|
12
|
+
import {composeHooks, createSubcomponent} from '@workday/canvas-kit-react/common';
|
|
13
|
+
|
|
14
|
+
const useItem = composeHooks(useListItemSelect, useListItemRovingFocus, useListItemRegister);
|
|
15
|
+
|
|
16
|
+
const Item = createSubcomponent('button')({
|
|
17
|
+
modelHook: useGridModel,
|
|
18
|
+
elemPropsHook: useItem,
|
|
19
|
+
})((elemProps, Element, model) => {
|
|
20
|
+
return (
|
|
21
|
+
<Box
|
|
22
|
+
as={Element}
|
|
23
|
+
{...elemProps}
|
|
24
|
+
width={40}
|
|
25
|
+
border="solid 1px black"
|
|
26
|
+
style={{
|
|
27
|
+
background: model.state.selectedIds.includes(elemProps['data-id']) ? 'gray' : 'white',
|
|
28
|
+
}}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export default () => {
|
|
34
|
+
const model = useGridModel({
|
|
35
|
+
columnCount: 5,
|
|
36
|
+
// @ts-ignore Create an array of [{id: 1}, ...{id: n}]
|
|
37
|
+
items: [...Array(25).keys()].map(i => ({id: i + 1})),
|
|
38
|
+
// we don't need virtualization here
|
|
39
|
+
shouldVirtualize: false,
|
|
40
|
+
navigation: wrappingNavigationManager,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<ListBox model={model} as={Flex} flexDirection="row" flexWrap="wrap" width={200}>
|
|
45
|
+
{item => <Item>{item.id}</Item>}
|
|
46
|
+
</ListBox>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
3
3
|
import {Radio, RadioGroup} from '@workday/canvas-kit-react/radio';
|
|
4
|
+
import styled from '@emotion/styled';
|
|
4
5
|
|
|
5
6
|
export default () => {
|
|
6
7
|
const [value, setValue] = React.useState<string | number>('deep-dish');
|
|
@@ -9,14 +10,22 @@ export default () => {
|
|
|
9
10
|
setValue(value);
|
|
10
11
|
};
|
|
11
12
|
|
|
13
|
+
const StyledFormField = styled(FormField)({
|
|
14
|
+
width: '161px',
|
|
15
|
+
});
|
|
16
|
+
|
|
12
17
|
return (
|
|
13
|
-
<
|
|
18
|
+
<StyledFormField label="Choose Your Pizza Crust" useFieldset={true}>
|
|
14
19
|
<RadioGroup name="crust" onChange={handleChange} value={value}>
|
|
15
20
|
<Radio label="Deep dish" value="deep-dish" />
|
|
16
21
|
<Radio label="Thin" value="thin" />
|
|
17
22
|
<Radio label="Gluten free" value="gluten-free" />
|
|
18
23
|
<Radio label="Cauliflower" value="cauliflower" />
|
|
24
|
+
<Radio
|
|
25
|
+
label="My favorite pizza crust flavor is butter because it's the best thing to put on bread"
|
|
26
|
+
value="cauliflower"
|
|
27
|
+
/>
|
|
19
28
|
</RadioGroup>
|
|
20
|
-
</
|
|
29
|
+
</StyledFormField>
|
|
21
30
|
);
|
|
22
31
|
};
|
|
@@ -79,7 +79,29 @@ export default () => {
|
|
|
79
79
|
<Card>
|
|
80
80
|
<Card.Body>
|
|
81
81
|
<Box minHeight={180} position="relative">
|
|
82
|
-
{
|
|
82
|
+
{loading ? (
|
|
83
|
+
<StyledSimulation
|
|
84
|
+
position="absolute"
|
|
85
|
+
top={0}
|
|
86
|
+
left={0}
|
|
87
|
+
width="100%"
|
|
88
|
+
animation={!loading ? `${fadeOut} 150ms ease-out forwards` : undefined}
|
|
89
|
+
>
|
|
90
|
+
<Skeleton>
|
|
91
|
+
<Flex alignItems="center">
|
|
92
|
+
<Skeleton.Shape
|
|
93
|
+
width={space.xl}
|
|
94
|
+
height={space.xl}
|
|
95
|
+
borderRadius={borderRadius.circle}
|
|
96
|
+
/>
|
|
97
|
+
<Box flex={1} marginLeft="xs">
|
|
98
|
+
<Skeleton.Header />
|
|
99
|
+
</Box>
|
|
100
|
+
</Flex>
|
|
101
|
+
<Skeleton.Text lineCount={3} />
|
|
102
|
+
</Skeleton>
|
|
103
|
+
</StyledSimulation>
|
|
104
|
+
) : (
|
|
83
105
|
<Box>
|
|
84
106
|
<Flex alignItems="center" display="inline-flex" marginBottom="s">
|
|
85
107
|
<SystemIconCircle icon={patternIcon} />
|
|
@@ -100,28 +122,6 @@ export default () => {
|
|
|
100
122
|
</p>
|
|
101
123
|
</Box>
|
|
102
124
|
)}
|
|
103
|
-
|
|
104
|
-
<StyledSimulation
|
|
105
|
-
position="absolute"
|
|
106
|
-
top={0}
|
|
107
|
-
left={0}
|
|
108
|
-
width="100%"
|
|
109
|
-
animation={!loading ? `${fadeOut} 150ms ease-out forwards` : undefined}
|
|
110
|
-
>
|
|
111
|
-
<Skeleton>
|
|
112
|
-
<Flex alignItems="center">
|
|
113
|
-
<Skeleton.Shape
|
|
114
|
-
width={space.xl}
|
|
115
|
-
height={space.xl}
|
|
116
|
-
borderRadius={borderRadius.circle}
|
|
117
|
-
/>
|
|
118
|
-
<Box flex={1} marginLeft="xs">
|
|
119
|
-
<Skeleton.Header />
|
|
120
|
-
</Box>
|
|
121
|
-
</Flex>
|
|
122
|
-
<Skeleton.Text lineCount={3} />
|
|
123
|
-
</Skeleton>
|
|
124
|
-
</StyledSimulation>
|
|
125
125
|
</Box>
|
|
126
126
|
</Card.Body>
|
|
127
127
|
</Card>
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {useTabsModel} from '@workday/canvas-kit-react/tabs';
|
|
2
|
+
|
|
3
|
+
type TabsModelConfig = Partial<typeof useTabsModel.defaultConfig> &
|
|
4
|
+
typeof useTabsModel.requiredConfig;
|
|
5
|
+
type Model = ReturnType<typeof useTabsModel>;
|
|
2
6
|
|
|
3
7
|
export const TabsModelConfigComponent = (_: TabsModelConfig) => <div />;
|
|
4
|
-
export const TabsStateComponent = (_:
|
|
5
|
-
export const TabsEventsComponent = (_:
|
|
8
|
+
export const TabsStateComponent = (_: Model['state']) => <div />;
|
|
9
|
+
export const TabsEventsComponent = (_: Model['events']) => <div />;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.1",
|
|
4
4
|
"description": "Documentation components of Canvas Kit components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@storybook/csf": "0.0.1",
|
|
45
|
-
"@workday/canvas-kit-react": "^7.2.
|
|
45
|
+
"@workday/canvas-kit-react": "^7.2.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"fs-extra": "^10.0.0",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"mkdirp": "^1.0.3",
|
|
51
51
|
"typescript": "4.1"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "ed7a5b8c4072cc64cbf34f87de2605b40ec9e68c"
|
|
54
54
|
}
|