@workday/canvas-kit-docs 15.0.0-alpha.0075-next.0 → 15.0.0-alpha.0077-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/StorybookStatusIndicator.d.ts +2 -2
- package/dist/es6/lib/StorybookStatusIndicator.d.ts.map +1 -1
- package/dist/es6/lib/StorybookStatusIndicator.js +6 -1
- package/dist/es6/lib/docs.js +10908 -14026
- package/dist/es6/mdx/accessibility/examples/GlobalHeader.js +1 -1
- package/dist/mdx/15.0-UPGRADE-GUIDE.mdx +250 -0
- package/dist/mdx/preview-react/divider/examples/Basic.tsx +1 -1
- package/dist/mdx/{preview-react → react}/avatar/Avatar.mdx +5 -7
- package/dist/mdx/react/avatar/examples/Basic.tsx +5 -0
- package/dist/mdx/{preview-react → react}/avatar/examples/Custom.tsx +1 -1
- package/dist/mdx/{preview-react → react}/avatar/examples/Decorative.tsx +1 -1
- package/dist/mdx/{preview-react → react}/avatar/examples/Image.tsx +1 -1
- package/dist/mdx/{preview-react → react}/avatar/examples/Size.tsx +1 -1
- package/dist/mdx/{preview-react → react}/avatar/examples/Variant.tsx +1 -1
- package/dist/mdx/react/select/Select.mdx +8 -1
- package/dist/mdx/react/select/examples/GroupedItems.tsx +59 -0
- package/lib/StorybookStatusIndicator.tsx +10 -1
- package/package.json +6 -6
- package/dist/mdx/preview-react/avatar/examples/Basic.tsx +0 -5
- package/dist/mdx/preview-react/select/Select.mdx +0 -107
- package/dist/mdx/preview-react/select/examples/Left Label/AlertLeft.tsx +0 -18
- package/dist/mdx/preview-react/select/examples/Left Label/DefaultLeft.tsx +0 -17
- package/dist/mdx/preview-react/select/examples/Left Label/DefaultWithCustomOptionsLeft.tsx +0 -25
- package/dist/mdx/preview-react/select/examples/Left Label/DefaultWithSimpleOptionsLeft.tsx +0 -17
- package/dist/mdx/preview-react/select/examples/Left Label/DisabledLeft.tsx +0 -19
- package/dist/mdx/preview-react/select/examples/Left Label/ErrorLeft.tsx +0 -18
- package/dist/mdx/preview-react/select/examples/Left Label/GrowLeft.tsx +0 -17
- package/dist/mdx/preview-react/select/examples/Left Label/ScrollableLeft.tsx +0 -17
- package/dist/mdx/preview-react/select/examples/Left Label/index.ts +0 -8
- package/dist/mdx/preview-react/select/examples/Top Label/Caution.tsx +0 -16
- package/dist/mdx/preview-react/select/examples/Top Label/Default.tsx +0 -15
- package/dist/mdx/preview-react/select/examples/Top Label/DefaultWithCustomOptions.tsx +0 -23
- package/dist/mdx/preview-react/select/examples/Top Label/DefaultWithSimpleOptions.tsx +0 -15
- package/dist/mdx/preview-react/select/examples/Top Label/Disabled.tsx +0 -17
- package/dist/mdx/preview-react/select/examples/Top Label/Error.tsx +0 -16
- package/dist/mdx/preview-react/select/examples/Top Label/Grow.tsx +0 -15
- package/dist/mdx/preview-react/select/examples/Top Label/Scrollable.tsx +0 -13
- package/dist/mdx/preview-react/select/examples/Top Label/index.ts +0 -8
- package/dist/mdx/preview-react/select/examples/storiesData.tsx +0 -92
- package/dist/mdx/react/avatar/avatar/Avatar.mdx +0 -109
- package/dist/mdx/react/avatar/avatar/examples/Basic.tsx +0 -17
- package/dist/mdx/react/avatar/avatar/examples/Button.tsx +0 -20
- package/dist/mdx/react/avatar/avatar/examples/CustomStyles.tsx +0 -34
- package/dist/mdx/react/avatar/avatar/examples/Image.tsx +0 -25
- package/dist/mdx/react/avatar/avatar/examples/LazyLoad.tsx +0 -20
- package/dist/mdx/react/avatar/avatar/examples/ObjectFit.tsx +0 -30
- package/dist/mdx/react/avatar/avatar/examples/Size.tsx +0 -27
- package/dist/mdx/react/avatar/avatar/examples/Variant.tsx +0 -10
- package/dist/mdx/react/avatar/avatar/examples/test-avatar.png +0 -0
- /package/dist/mdx/{preview-react → react}/avatar/examples/nicholas-avatar.jpg +0 -0
|
@@ -5,7 +5,7 @@ import { system } from '@workday/canvas-tokens-web';
|
|
|
5
5
|
import { calc, createStyles, px2rem } from '@workday/canvas-kit-styling';
|
|
6
6
|
import { notificationsIcon, inboxIcon, justifyIcon, assistantIcon, searchIcon, } from '@workday/canvas-system-icons-web';
|
|
7
7
|
import { SecondaryButton, TertiaryButton } from '@workday/canvas-kit-react/button';
|
|
8
|
-
import { Avatar } from '@workday/canvas-kit-
|
|
8
|
+
import { Avatar } from '@workday/canvas-kit-react/avatar';
|
|
9
9
|
import { Flex } from '@workday/canvas-kit-react/layout';
|
|
10
10
|
import { Tooltip } from '@workday/canvas-kit-react/tooltip';
|
|
11
11
|
import { Combobox, useComboboxModel, useComboboxInput, useComboboxLoader, } from '@workday/canvas-kit-react/combobox';
|
|
@@ -18,6 +18,7 @@ space tokens, the new tokens aim to add more semantic meaning to allow for bette
|
|
|
18
18
|
- [Codemod](#codemod)
|
|
19
19
|
- [Instructions](#instructions)
|
|
20
20
|
- [Component Promotions](#component-promotions)
|
|
21
|
+
- [Avatar](#avatar-)
|
|
21
22
|
- [Pill](#pill-)
|
|
22
23
|
- [Segmented Control](#segmented-control-)
|
|
23
24
|
- [Information Highlight](#information-highlight-)
|
|
@@ -31,7 +32,9 @@ space tokens, the new tokens aim to add more semantic meaning to allow for bette
|
|
|
31
32
|
- [Component Updates](#component-updates)
|
|
32
33
|
- [Buttons](#buttons)
|
|
33
34
|
- [Removals](#removals)
|
|
35
|
+
- [Avatar (Deprecated)](#avatar-deprecated)
|
|
34
36
|
- [Segmented Control (Deprecated)](#segmented-control-deprecated)
|
|
37
|
+
- [Select (Deprecated)](#select-deprecated)
|
|
35
38
|
- [Search Form (Labs)](#search-form-labs)
|
|
36
39
|
- [Combobox (Labs)](#combobox-labs)
|
|
37
40
|
- [Glossary](#glossary)
|
|
@@ -105,6 +108,121 @@ yarn remove @workday/canvas-kit-codemod
|
|
|
105
108
|
|
|
106
109
|
## Component Promotions
|
|
107
110
|
|
|
111
|
+
### Avatar ⚡️
|
|
112
|
+
|
|
113
|
+
**PR:** [](https://github.com/Workday/canvas-kit/issues/3659)
|
|
114
|
+
|
|
115
|
+
We've promoted `Avatar` from [Preview](#preview) to [Main](#main). This replaces the deprecated `Avatar` that was previously in Main.
|
|
116
|
+
|
|
117
|
+
**Before in v14**
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
import {Avatar} from '@workday/canvas-kit-preview-react/avatar';
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**After in v15**
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import {Avatar} from '@workday/canvas-kit-react/avatar';
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
> 🤖 The codemod will handle the change of imports as shown above.
|
|
130
|
+
|
|
131
|
+
#### API Differences
|
|
132
|
+
|
|
133
|
+
The new `Avatar` is a [compound component](/getting-started/for-developers/resources/compound-components/)
|
|
134
|
+
with a different API than the deprecated version.
|
|
135
|
+
|
|
136
|
+
##### Structure Changes
|
|
137
|
+
|
|
138
|
+
| Deprecated (Old Main) | New (Promoted from Preview) |
|
|
139
|
+
| --------------------- | ----------------------------------- |
|
|
140
|
+
| `Avatar` | `Avatar` |
|
|
141
|
+
| - | `BaseAvatar` |
|
|
142
|
+
| - | `BaseAvatar.Image` / `AvatarImage` |
|
|
143
|
+
| - | `BaseAvatar.Name` / `AvatarName` |
|
|
144
|
+
|
|
145
|
+
##### Prop Changes
|
|
146
|
+
|
|
147
|
+
| Feature | Deprecated (Old Main) | New (Promoted from Preview) |
|
|
148
|
+
| -------------------- | ------------------------------------------ | ------------------------------------------------ |
|
|
149
|
+
| Variant | `variant` (`light`, `dark`) | `variant` (`blue`, `amber`, `teal`, `purple`) |
|
|
150
|
+
| Size | `size` (extraSmall=16px to extraExtraLarge=120px) | `size` (extraExtraSmall=24px to extraExtraLarge=120px) |
|
|
151
|
+
| User identifier | `altText` prop | `name` prop |
|
|
152
|
+
| Custom initials | Not supported | `preferredInitials` prop |
|
|
153
|
+
| Decorative mode | Not supported | `isDecorative` prop |
|
|
154
|
+
| Image URL | `url` prop | `url` prop |
|
|
155
|
+
| Object fit | `objectFit` prop | `objectFit` prop |
|
|
156
|
+
| Initials display | Not supported (shows user icon) | Shows initials from `name` when no image |
|
|
157
|
+
|
|
158
|
+
##### Size Mapping
|
|
159
|
+
|
|
160
|
+
| Size Name | Deprecated (Old Main) | New (Promoted from Preview) |
|
|
161
|
+
| ---------------- | --------------------- | --------------------------- |
|
|
162
|
+
| extraExtraSmall | - | 24px |
|
|
163
|
+
| extraSmall | 16px | 32px |
|
|
164
|
+
| small | 24px | 40px |
|
|
165
|
+
| medium | 32px | 48px |
|
|
166
|
+
| large | 40px | 72px |
|
|
167
|
+
| extraLarge | 64px | 96px |
|
|
168
|
+
| extraExtraLarge | 120px | 120px |
|
|
169
|
+
|
|
170
|
+
##### Code Migration
|
|
171
|
+
|
|
172
|
+
**Deprecated API (Old Main)**
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
import {Avatar} from '@workday/canvas-kit-react/avatar';
|
|
176
|
+
|
|
177
|
+
<Avatar
|
|
178
|
+
size="medium"
|
|
179
|
+
variant="light"
|
|
180
|
+
url="https://example.com/photo.jpg"
|
|
181
|
+
altText="John Doe"
|
|
182
|
+
/>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**New API (v15)**
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
import {Avatar} from '@workday/canvas-kit-react/avatar';
|
|
189
|
+
|
|
190
|
+
<Avatar
|
|
191
|
+
size="medium"
|
|
192
|
+
variant="blue"
|
|
193
|
+
url="https://example.com/photo.jpg"
|
|
194
|
+
name="John Doe"
|
|
195
|
+
/>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
##### New Features
|
|
199
|
+
|
|
200
|
+
The promoted `Avatar` includes several new features:
|
|
201
|
+
|
|
202
|
+
- **Initials display**: Automatically shows initials from the `name` prop when no image URL is provided
|
|
203
|
+
- **Color variants**: Four color variants (`blue`, `amber`, `teal`, `purple`) instead of light/dark
|
|
204
|
+
- **Custom initials**: Use `preferredInitials` for full control over displayed initials
|
|
205
|
+
- **Decorative mode**: Use `isDecorative` when Avatar is purely decorative (rendered next to a name)
|
|
206
|
+
- **Compound components**: Build custom avatars using `BaseAvatar`, `BaseAvatar.Image`, and `BaseAvatar.Name`
|
|
207
|
+
- **Utility function**: Use `getInitialsFromName` to extract initials from a name string
|
|
208
|
+
|
|
209
|
+
```tsx
|
|
210
|
+
// With initials (no image)
|
|
211
|
+
<Avatar name="John Doe" variant="blue" />
|
|
212
|
+
|
|
213
|
+
// Custom initials
|
|
214
|
+
<Avatar name="John Doe" preferredInitials="JD" />
|
|
215
|
+
|
|
216
|
+
// Decorative (next to text name)
|
|
217
|
+
<Avatar name="John Doe" url="..." isDecorative />
|
|
218
|
+
|
|
219
|
+
// Using compound components for custom layouts
|
|
220
|
+
<BaseAvatar variant="teal" size="large">
|
|
221
|
+
<BaseAvatar.Image src="..." alt="John Doe" />
|
|
222
|
+
<BaseAvatar.Name name="John Doe" />
|
|
223
|
+
</BaseAvatar>
|
|
224
|
+
```
|
|
225
|
+
|
|
108
226
|
### Pill ⚡️
|
|
109
227
|
|
|
110
228
|
**PR** [#3634](https://github.com/Workday/canvas-kit/pull/3634)
|
|
@@ -129,6 +247,8 @@ import {Pill} from '@workday/canvas-kit-react/pill';
|
|
|
129
247
|
|
|
130
248
|
### Segmented Control ⚡️
|
|
131
249
|
|
|
250
|
+
**PR:** [#3633](https://github.com/Workday/canvas-kit/pull/3633)
|
|
251
|
+
|
|
132
252
|
We've promoted `SegmentedControl` from [Preview](#preview) to [Main](#main). This replaces the deprecated `SegmentedControl` that was previously in Main.
|
|
133
253
|
|
|
134
254
|
**Before in v14**
|
|
@@ -229,6 +349,8 @@ The promoted `SegmentedControl` includes several new features:
|
|
|
229
349
|
|
|
230
350
|
### Information Highlight ⚡️
|
|
231
351
|
|
|
352
|
+
**PR:** [#3633](https://github.com/Workday/canvas-kit/pull/3633)
|
|
353
|
+
|
|
232
354
|
We've promoted `InformationHighlight` from [Preview](#preview) to [Main](#main). There are no changes to the functionality or styling of the component. The only change required is updating the import statement.
|
|
233
355
|
|
|
234
356
|
**Before in v14**
|
|
@@ -259,6 +381,16 @@ tokens. These changes are **only visual**.
|
|
|
259
381
|
|
|
260
382
|
## Removals
|
|
261
383
|
|
|
384
|
+
### Avatar (Deprecated)
|
|
385
|
+
|
|
386
|
+
The deprecated `Avatar` that was previously in `@workday/canvas-kit-react/avatar`
|
|
387
|
+
has been removed. This was the older implementation that showed a user icon placeholder
|
|
388
|
+
and supported `light`/`dark` variants.
|
|
389
|
+
|
|
390
|
+
Please migrate to the new `Avatar` component (promoted from Preview) which uses initials
|
|
391
|
+
display, color variants (`blue`, `amber`, `teal`, `purple`), and supports compound components.
|
|
392
|
+
See the [API Differences](#api-differences) section above for migration guidance.
|
|
393
|
+
|
|
262
394
|
### Segmented Control (Deprecated)
|
|
263
395
|
|
|
264
396
|
The deprecated `SegmentedControl` that was previously in `@workday/canvas-kit-react/segmented-control`
|
|
@@ -268,6 +400,124 @@ Please migrate to the new `SegmentedControl` component (promoted from Preview) w
|
|
|
268
400
|
component pattern with `SegmentedControl.List` and `SegmentedControl.Item`. See the
|
|
269
401
|
[API Differences](#api-differences) section above for migration guidance.
|
|
270
402
|
|
|
403
|
+
### Select (Deprecated)
|
|
404
|
+
|
|
405
|
+
**PR:** [#3658](https://github.com/Workday/canvas-kit/pull/3658)
|
|
406
|
+
|
|
407
|
+
The `Select` component in `@workday/canvas-kit-preview-react/select` has been removed. Please use the
|
|
408
|
+
`Select` component from `@workday/canvas-kit-react/select` instead.
|
|
409
|
+
|
|
410
|
+
**Before in v14**
|
|
411
|
+
|
|
412
|
+
```tsx
|
|
413
|
+
import {Select} from '@workday/canvas-kit-preview-react/select';
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
**After in v15**
|
|
417
|
+
|
|
418
|
+
```tsx
|
|
419
|
+
import {Select} from '@workday/canvas-kit-react/select';
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
#### API Differences
|
|
423
|
+
|
|
424
|
+
The Main `Select` is a [compound component](/getting-started/for-developers/resources/compound-components/)
|
|
425
|
+
built on top of the Combobox component with a composition-based API, whereas the Preview Select was a
|
|
426
|
+
monolithic class-based component.
|
|
427
|
+
|
|
428
|
+
##### Structure Changes
|
|
429
|
+
|
|
430
|
+
| Preview (Removed) | Main |
|
|
431
|
+
| --------------------------- | ------------------------------------------------------------- |
|
|
432
|
+
| `Select` (single component) | `Select` + `Select.Input` + `Select.Popper` + `Select.Card` + `Select.List` + `Select.Item` |
|
|
433
|
+
|
|
434
|
+
##### Prop Changes
|
|
435
|
+
|
|
436
|
+
| Feature | Preview (Removed) | Main |
|
|
437
|
+
| ---------------- | ------------------------------------------ | ------------------------------------------------ |
|
|
438
|
+
| Options | `options` prop (array of Option objects) | `items` prop (array of any type) |
|
|
439
|
+
| Selected value | `value` prop | Managed via model (`useSelectModel`) |
|
|
440
|
+
| Change handler | `onChange={(e) => {}}` | `onChange` on `Select.Input` |
|
|
441
|
+
| Error state | `error={Select.ErrorType.Error}` | `error="error"` or `error="caution"` |
|
|
442
|
+
| Custom rendering | `renderOption` / `renderSelected` props | Composition via `Select.Item` children |
|
|
443
|
+
| Form integration | Manual | Built-in with `FormField` wrapper |
|
|
444
|
+
| Accessibility | Manual ARIA | Built-in via Combobox foundation |
|
|
445
|
+
|
|
446
|
+
##### Code Migration
|
|
447
|
+
|
|
448
|
+
**Preview API (Removed)**
|
|
449
|
+
|
|
450
|
+
```tsx
|
|
451
|
+
import {Select} from '@workday/canvas-kit-preview-react/select';
|
|
452
|
+
|
|
453
|
+
const options = [
|
|
454
|
+
{label: 'Small', value: 'small'},
|
|
455
|
+
{label: 'Medium', value: 'medium'},
|
|
456
|
+
{label: 'Large', value: 'large'},
|
|
457
|
+
];
|
|
458
|
+
|
|
459
|
+
const [value, setValue] = React.useState('medium');
|
|
460
|
+
|
|
461
|
+
<Select
|
|
462
|
+
options={options}
|
|
463
|
+
value={value}
|
|
464
|
+
onChange={e => setValue(e.target.value)}
|
|
465
|
+
/>
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
**Main API (v15)**
|
|
469
|
+
|
|
470
|
+
```tsx
|
|
471
|
+
import {Select} from '@workday/canvas-kit-react/select';
|
|
472
|
+
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
473
|
+
|
|
474
|
+
const items = ['Small', 'Medium', 'Large'];
|
|
475
|
+
|
|
476
|
+
<Select items={items}>
|
|
477
|
+
<FormField label="Size">
|
|
478
|
+
<Select.Input onChange={e => console.log('Selected:', e.target.value)} />
|
|
479
|
+
<Select.Popper>
|
|
480
|
+
<Select.Card>
|
|
481
|
+
<Select.List>
|
|
482
|
+
{item => <Select.Item>{item}</Select.Item>}
|
|
483
|
+
</Select.List>
|
|
484
|
+
</Select.Card>
|
|
485
|
+
</Select.Popper>
|
|
486
|
+
</FormField>
|
|
487
|
+
</Select>
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
##### Main Select Features
|
|
491
|
+
|
|
492
|
+
The Main `Select` includes features not available in the Preview version:
|
|
493
|
+
|
|
494
|
+
- **Composition-based API**: Full control over structure with subcomponents
|
|
495
|
+
- **FormField integration**: Built-in accessibility when wrapped with FormField
|
|
496
|
+
- **Model-based state**: Use `useSelectModel` for advanced state management
|
|
497
|
+
- **Virtualization support**: Enable for large lists via model config
|
|
498
|
+
- **Icons in input**: Use `inputStartIcon` prop on `Select.Input`
|
|
499
|
+
- **Icons in items**: Use `Select.Item.Icon` subcomponent
|
|
500
|
+
|
|
501
|
+
```tsx
|
|
502
|
+
// With icons
|
|
503
|
+
<Select.Input inputStartIcon={myIcon} />
|
|
504
|
+
|
|
505
|
+
// With item icons
|
|
506
|
+
<Select.Item>
|
|
507
|
+
<Select.Item.Icon icon={starIcon} />
|
|
508
|
+
Favorite
|
|
509
|
+
</Select.Item>
|
|
510
|
+
|
|
511
|
+
// With model for controlled state
|
|
512
|
+
const model = useSelectModel({
|
|
513
|
+
items: myItems,
|
|
514
|
+
onSelect: ({id}) => console.log('Selected:', id),
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
<Select model={model}>
|
|
518
|
+
...
|
|
519
|
+
</Select>
|
|
520
|
+
```
|
|
271
521
|
### Search Form (Labs)
|
|
272
522
|
|
|
273
523
|
The deprecated `SearchForm` component has been removed from `@workday/canvas-kit-labs-react`.
|
|
@@ -96,7 +96,7 @@ const ProfileCard = ({id, name, bio}: ProfileCardProps) => (
|
|
|
96
96
|
<Avatar
|
|
97
97
|
size="extraLarge"
|
|
98
98
|
url={`https://avatars.githubusercontent.com/u/${id}?v=4`}
|
|
99
|
-
|
|
99
|
+
name={`${name}'s avatar`}
|
|
100
100
|
className={profileCardAvatarStyles}
|
|
101
101
|
/>
|
|
102
102
|
<h3 className={profileCardHeadingStyles}>{name}</h3>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {SymbolDoc, Specifications, ExampleCodeBlock} from '@workday/canvas-kit-docs';
|
|
1
|
+
import {SymbolDoc, Specifications, ExampleCodeBlock, StorybookStatusIndicator} from '@workday/canvas-kit-docs';
|
|
2
2
|
|
|
3
|
-
import {Avatar} from '@workday/canvas-kit-
|
|
3
|
+
import {Avatar} from '@workday/canvas-kit-react/avatar';
|
|
4
4
|
import Basic from './examples/Basic';
|
|
5
5
|
import Image from './examples/Image';
|
|
6
6
|
import Size from './examples/Size';
|
|
@@ -9,14 +9,12 @@ import Custom from './examples/Custom';
|
|
|
9
9
|
import Decorative from './examples/Decorative';
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
# Avatar
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
# Avatar <StorybookStatusIndicator type="promoted" />
|
|
15
13
|
|
|
16
14
|
## Installation
|
|
17
15
|
|
|
18
16
|
```sh
|
|
19
|
-
yarn add @workday/canvas-kit-
|
|
17
|
+
yarn add @workday/canvas-kit-react
|
|
20
18
|
```
|
|
21
19
|
|
|
22
20
|
|
|
@@ -77,4 +75,4 @@ If the Avatar is purely decorative, you can set the `isDecorative` prop to `true
|
|
|
77
75
|
|
|
78
76
|
## Component API
|
|
79
77
|
|
|
80
|
-
<SymbolDoc name="Avatar" fileName="/
|
|
78
|
+
<SymbolDoc name="Avatar" fileName="/react/" hideDescription />
|
|
@@ -20,7 +20,8 @@ import HoistedModel from './examples/HoistedModel';
|
|
|
20
20
|
import RefForwarding from './examples/RefForwarding';
|
|
21
21
|
import FetchingDynamicItems from './examples/FetchingDynamicItems';
|
|
22
22
|
import Placeholder from './examples/Placeholder';
|
|
23
|
-
import InitialSelectedItem from './examples/InitialSelectedItem';
|
|
23
|
+
import InitialSelectedItem from './examples/InitialSelectedItem';
|
|
24
|
+
import GroupedItems from './examples/GroupedItems';import {Table} from '@workday/canvas-kit-react/table';
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
# Canvas Kit Select
|
|
@@ -301,6 +302,12 @@ prop as well as the `value` DOM property and will update the model accordingly.
|
|
|
301
302
|
</Select>
|
|
302
303
|
```
|
|
303
304
|
|
|
305
|
+
### Grouped Items
|
|
306
|
+
|
|
307
|
+
In order to group items, you have to use the static API in combination of the `Menu.Group` component.
|
|
308
|
+
|
|
309
|
+
<ExampleCodeBlock code={GroupedItems} />
|
|
310
|
+
|
|
304
311
|
### Custom Styles
|
|
305
312
|
|
|
306
313
|
Select and its subcomponents support custom styling via the `cs` prop. For more information, check
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Menu} from '@workday/canvas-kit-react/menu';
|
|
4
|
+
import {Select} from '@workday/canvas-kit-react/select';
|
|
5
|
+
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
6
|
+
|
|
7
|
+
const items = [
|
|
8
|
+
{
|
|
9
|
+
id: 'first',
|
|
10
|
+
text: 'First Item',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: 'second',
|
|
14
|
+
text: 'Second Item',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: 'third',
|
|
18
|
+
text: 'Third Item',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 'fourth',
|
|
22
|
+
text: 'Fourth Item',
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
export default () => {
|
|
27
|
+
const [selected, setSelected] = React.useState('');
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
<FormField>
|
|
32
|
+
<FormField.Label>Contact</FormField.Label>
|
|
33
|
+
<FormField.Field>
|
|
34
|
+
<Select items={items} getId={item => item.id} getTextValue={item => item.text}>
|
|
35
|
+
<FormField.Input as={Select.Input} />
|
|
36
|
+
<Select.Popper>
|
|
37
|
+
<Select.Card>
|
|
38
|
+
<Select.List>
|
|
39
|
+
<Menu.Group title="First Group">
|
|
40
|
+
<Select.Item data-id="first">First Item</Select.Item>
|
|
41
|
+
<Select.Item data-id="second">Second Item</Select.Item>
|
|
42
|
+
</Menu.Group>
|
|
43
|
+
<Menu.Group title="Second Group">
|
|
44
|
+
<Select.Item data-id="third">
|
|
45
|
+
Third Item (with a really, really, really long label)
|
|
46
|
+
</Select.Item>
|
|
47
|
+
<Select.Item aria-disabled data-id="fourth">
|
|
48
|
+
Fourth Item
|
|
49
|
+
</Select.Item>
|
|
50
|
+
</Menu.Group>
|
|
51
|
+
</Select.List>
|
|
52
|
+
</Select.Card>
|
|
53
|
+
</Select.Popper>
|
|
54
|
+
</Select>
|
|
55
|
+
</FormField.Field>
|
|
56
|
+
</FormField>
|
|
57
|
+
</>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
@@ -28,14 +28,23 @@ const content = {
|
|
|
28
28
|
icon: undefined,
|
|
29
29
|
label: 'New',
|
|
30
30
|
},
|
|
31
|
+
promoted: {
|
|
32
|
+
icon: undefined,
|
|
33
|
+
label: 'Promoted',
|
|
34
|
+
},
|
|
31
35
|
};
|
|
32
36
|
|
|
33
|
-
export const StorybookStatusIndicator = ({
|
|
37
|
+
export const StorybookStatusIndicator = ({
|
|
38
|
+
type,
|
|
39
|
+
}: {
|
|
40
|
+
type: 'ai' | 'deprecated' | 'new' | 'promoted';
|
|
41
|
+
}) => {
|
|
34
42
|
const {icon, label} = content[type];
|
|
35
43
|
const variantMapping = {
|
|
36
44
|
ai: 'ai',
|
|
37
45
|
deprecated: 'caution',
|
|
38
46
|
new: 'positive',
|
|
47
|
+
promoted: 'info',
|
|
39
48
|
};
|
|
40
49
|
console.log(variantMapping[type]);
|
|
41
50
|
return (
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "15.0.0-alpha.
|
|
3
|
+
"version": "15.0.0-alpha.0077-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",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"@emotion/styled": "^11.6.0",
|
|
46
46
|
"@stackblitz/sdk": "^1.11.0",
|
|
47
47
|
"@storybook/csf": "0.0.1",
|
|
48
|
-
"@workday/canvas-kit-labs-react": "^15.0.0-alpha.
|
|
49
|
-
"@workday/canvas-kit-preview-react": "^15.0.0-alpha.
|
|
50
|
-
"@workday/canvas-kit-react": "^15.0.0-alpha.
|
|
51
|
-
"@workday/canvas-kit-styling": "^15.0.0-alpha.
|
|
48
|
+
"@workday/canvas-kit-labs-react": "^15.0.0-alpha.0077-next.0",
|
|
49
|
+
"@workday/canvas-kit-preview-react": "^15.0.0-alpha.0077-next.0",
|
|
50
|
+
"@workday/canvas-kit-react": "^15.0.0-alpha.0077-next.0",
|
|
51
|
+
"@workday/canvas-kit-styling": "^15.0.0-alpha.0077-next.0",
|
|
52
52
|
"@workday/canvas-system-icons-web": "^3.0.36",
|
|
53
53
|
"@workday/canvas-tokens-web": "4.0.0-alpha.3",
|
|
54
54
|
"markdown-to-jsx": "^7.2.0",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"mkdirp": "^1.0.3",
|
|
62
62
|
"typescript": "5.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "6944d028b6f1250481ad8c4f8d5f817bea4e01a1"
|
|
65
65
|
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ExampleCodeBlock,
|
|
3
|
-
StorybookStatusIndicator,
|
|
4
|
-
SymbolDoc,
|
|
5
|
-
Specifications,
|
|
6
|
-
} from '@workday/canvas-kit-docs';
|
|
7
|
-
import {InformationHighlight} from '@workday/canvas-kit-react/information-highlight';
|
|
8
|
-
import Default from './examples/Top Label/Default';
|
|
9
|
-
import DefaultWithCustomOptions from './examples/Top Label/DefaultWithCustomOptions';
|
|
10
|
-
import DefaultWithSimpleOptions from './examples/Top Label/DefaultWithSimpleOptions';
|
|
11
|
-
import Scrollable from './examples/Top Label/Scrollable';
|
|
12
|
-
import Disabled from './examples/Top Label/Disabled';
|
|
13
|
-
import Caution from './examples/Top Label/Caution';
|
|
14
|
-
import Error from './examples/Top Label/Error';
|
|
15
|
-
import Grow from './examples/Top Label/Grow';
|
|
16
|
-
import DefaultLeft from './examples/Left Label/DefaultLeft';
|
|
17
|
-
import DefaultWithCustomOptionsLeft from './examples/Left Label/DefaultWithCustomOptionsLeft';
|
|
18
|
-
import DefaultWithSimpleOptionsLeft from './examples/Left Label/DefaultWithSimpleOptionsLeft';
|
|
19
|
-
import ScrollableLeft from './examples/Left Label/ScrollableLeft';
|
|
20
|
-
import DisabledLeft from './examples/Left Label/DisabledLeft';
|
|
21
|
-
import AlertLeft from './examples/Left Label/AlertLeft';
|
|
22
|
-
import ErrorLeft from './examples/Left Label/ErrorLeft';
|
|
23
|
-
import GrowLeft from './examples/Left Label/GrowLeft';
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
# Canvas Kit Select <StorybookStatusIndicator type="deprecated" />
|
|
27
|
-
|
|
28
|
-
<InformationHighlight className="sb-unstyled" variant="caution" cs={{p: {marginBlock: 0}}}>
|
|
29
|
-
<InformationHighlight.Icon />
|
|
30
|
-
<InformationHighlight.Body>
|
|
31
|
-
`Select` in Preview has been deprecated and will be removed in a future major version. Please
|
|
32
|
-
use `Select` in Main instead.
|
|
33
|
-
</InformationHighlight.Body>
|
|
34
|
-
<InformationHighlight.Link href="https://workday.github.io/canvas-kit/?path=/docs/components-inputs-select--docs">
|
|
35
|
-
Select (main) Docs
|
|
36
|
-
</InformationHighlight.Link>
|
|
37
|
-
</InformationHighlight>
|
|
38
|
-
|
|
39
|
-
<br />
|
|
40
|
-
|
|
41
|
-
## Top Label
|
|
42
|
-
|
|
43
|
-
### Default
|
|
44
|
-
|
|
45
|
-
<ExampleCodeBlock code={Default} />
|
|
46
|
-
|
|
47
|
-
### Default with Custom Options Data
|
|
48
|
-
|
|
49
|
-
<ExampleCodeBlock code={DefaultWithCustomOptions} />
|
|
50
|
-
|
|
51
|
-
### Default with Simple Options Data
|
|
52
|
-
|
|
53
|
-
<ExampleCodeBlock code={DefaultWithSimpleOptions} />
|
|
54
|
-
|
|
55
|
-
### Scrollable
|
|
56
|
-
|
|
57
|
-
<ExampleCodeBlock code={Scrollable} />
|
|
58
|
-
|
|
59
|
-
### Disabled
|
|
60
|
-
|
|
61
|
-
<ExampleCodeBlock code={Disabled} />
|
|
62
|
-
|
|
63
|
-
### Alert
|
|
64
|
-
|
|
65
|
-
<ExampleCodeBlock code={Caution} />
|
|
66
|
-
|
|
67
|
-
### Error
|
|
68
|
-
|
|
69
|
-
<ExampleCodeBlock code={Error} />
|
|
70
|
-
|
|
71
|
-
### Grow
|
|
72
|
-
|
|
73
|
-
<ExampleCodeBlock code={Grow} />
|
|
74
|
-
|
|
75
|
-
## Left Label
|
|
76
|
-
|
|
77
|
-
### Default
|
|
78
|
-
|
|
79
|
-
<ExampleCodeBlock code={DefaultLeft} />
|
|
80
|
-
|
|
81
|
-
### Default with Custom Options Data
|
|
82
|
-
|
|
83
|
-
<ExampleCodeBlock code={DefaultWithCustomOptionsLeft} />
|
|
84
|
-
|
|
85
|
-
### Default with Simple Options Data
|
|
86
|
-
|
|
87
|
-
<ExampleCodeBlock code={DefaultWithSimpleOptionsLeft} />
|
|
88
|
-
|
|
89
|
-
### Scrollable
|
|
90
|
-
|
|
91
|
-
<ExampleCodeBlock code={ScrollableLeft} />
|
|
92
|
-
|
|
93
|
-
### Disabled
|
|
94
|
-
|
|
95
|
-
<ExampleCodeBlock code={DisabledLeft} />
|
|
96
|
-
|
|
97
|
-
### Alert
|
|
98
|
-
|
|
99
|
-
<ExampleCodeBlock code={CautionLeft} />
|
|
100
|
-
|
|
101
|
-
### Error
|
|
102
|
-
|
|
103
|
-
<ExampleCodeBlock code={ErrorLeft} />
|
|
104
|
-
|
|
105
|
-
### Grow
|
|
106
|
-
|
|
107
|
-
<ExampleCodeBlock code={GrowLeft} />
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
4
|
-
import {Select} from '@workday/canvas-kit-preview-react/select';
|
|
5
|
-
import {hintText, options} from '../storiesData';
|
|
6
|
-
import {controlComponent} from '../../../../../../utils/storybook';
|
|
7
|
-
|
|
8
|
-
export default () => {
|
|
9
|
-
return (
|
|
10
|
-
<FormField orientation="horizontalStart" id="select-alert" error="caution">
|
|
11
|
-
<FormField.Label>Label</FormField.Label>
|
|
12
|
-
<FormField.Field>
|
|
13
|
-
{controlComponent(<FormField.Input as={Select} name="contact" options={options} />)}
|
|
14
|
-
<FormField.Hint>{hintText}</FormField.Hint>
|
|
15
|
-
</FormField.Field>
|
|
16
|
-
</FormField>
|
|
17
|
-
);
|
|
18
|
-
};
|