@workday/canvas-kit-docs 13.0.0-alpha.1107-next.0 → 13.0.0-alpha.1111-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.
@@ -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": "12.6.7",
22
- "@workday/canvas-kit-preview-react": "12.6.7",
23
- "@workday/canvas-kit-react": "12.6.7",
24
- "@workday/canvas-kit-react-fonts": "^12.6.7",
25
- "@workday/canvas-kit-styling": "12.6.7",
21
+ "@workday/canvas-kit-labs-react": "12.6.8",
22
+ "@workday/canvas-kit-preview-react": "12.6.8",
23
+ "@workday/canvas-kit-react": "12.6.8",
24
+ "@workday/canvas-kit-react-fonts": "^12.6.8",
25
+ "@workday/canvas-kit-styling": "12.6.8",
26
26
  "@workday/canvas-system-icons-web": "3.0.22",
27
27
  "@workday/canvas-tokens-web": "2.0.0"
28
28
  },
@@ -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": "12.6.7",
22
- "@workday/canvas-kit-preview-react": "12.6.7",
23
- "@workday/canvas-kit-react": "12.6.7",
24
- "@workday/canvas-kit-react-fonts": "^12.6.7",
25
- "@workday/canvas-kit-styling": "12.6.7",
21
+ "@workday/canvas-kit-labs-react": "12.6.8",
22
+ "@workday/canvas-kit-preview-react": "12.6.8",
23
+ "@workday/canvas-kit-react": "12.6.8",
24
+ "@workday/canvas-kit-react-fonts": "^12.6.8",
25
+ "@workday/canvas-kit-styling": "12.6.8",
26
26
  "@workday/canvas-system-icons-web": "3.0.22",
27
27
  "@workday/canvas-tokens-web": "2.0.0"
28
28
  },
@@ -17,17 +17,18 @@ any questions.
17
17
  - [Codemod](#codemod)
18
18
  - [Instructions](#instructions)
19
19
  - [Component Updates](#component-updates)
20
- - [Styling API and CSS Tokens](#styling-api-and-css-tokens)
21
- - [Avatar](#avatar)
22
- - [Expandable](#expandable)
23
- - [External Hyperlink](#external-hyperlink)
20
+ - [Styling API and CSS Tokens](#styling-api-and-css-tokens)
21
+ - [Avatar](#avatar)
22
+ - [Expandable](#expandable)
23
+ - [External Hyperlink](#external-hyperlink)
24
24
  - [Form Field and Form Field Group](#form-field-and-form-field-group)
25
- - [Pill](#pill)
26
- - [Tabs](#tabs)
25
+ - [Pill (Preview)](#pill-preview)
26
+ - [SidePanel (Preview)](#sidepanel-preview)
27
+ - [Tabs](#tabs)
27
28
  - [Brand Refresh](#brand-refresh)
28
29
  - [Logo Updates](#logo-updates)
29
30
  - [Infrastructure](#infrastructure)
30
- - [Supporting react-jsx](#supoorting-react-jsx)
31
+ - [Supporting react-jsx](#supporting-react-jsx)
31
32
  - [Troubleshooting](#troubleshooting)
32
33
  - [Glossary](#glossary)
33
34
  - [Main](#main)
@@ -197,14 +198,14 @@ The `orientation` prop on `FormField` component has been updated to remove the d
197
198
  ```
198
199
 
199
200
 
200
- ### Pill
201
+ ### Pill (Preview)
201
202
 
202
203
  **PR:** [#3104](https://github.com/Workday/canvas-kit/pull/3104)
203
204
 
204
205
  A few changes have been made to `Pill` to ensure proper accessibility and styles.
205
206
 
206
207
  - The border color on hover has been updated from `licorice400` to `licorice500` to match our design specs.
207
- - We've removed extra elements and leverage [flex box}(https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/CSS_layout/Flexbox) to ensure only the label receives overflow styles. When `maxWidth` is set, it is set on the parent `<Pill/>` element and the child elements will be styled accordingly. Before v13, `maxWidth` wasn't calculating the width of all its elements and wasn't a true pixel value.
208
+ - We've removed extra elements and leverage [flex box](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/CSS_layout/Flexbox) to ensure only the label receives overflow styles. When `maxWidth` is set, it is set on the parent `<Pill/>` element and the child elements will be styled accordingly. Before v13, `maxWidth` wasn't calculating the width of all its elements and wasn't a true pixel value.
208
209
 
209
210
  ##### Breaking Changes
210
211
 
@@ -213,6 +214,13 @@ A few changes have been made to `Pill` to ensure proper accessibility and styles
213
214
  - `<Pill.IconButton/>` no longer has a default `aria-label="remove"`. You *must* provide an `aria-label` for `<Pill.IconButton/>` to ensure proper accessibility. Our examples have been updated to reflect this change.
214
215
  - `<Pill.Label/>` is a *required* element when using other sub-components like `<Pill.Icon/>` to ensure that the label truncates correctly.
215
216
 
217
+ ### SidePanel (Preview)
218
+
219
+ **PR:** [3258](https://github.com/Workday/canvas-kit/pull/3258)
220
+
221
+ When we supported IE 11 we needed to use [CSS Animation](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animations/Using_CSS_animations) to support animation events. Since we dropped support for IE11, we can now use [CSS Transitions](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_transitions/Using_CSS_transitions) to animate the `width` of the `SidePanel` when it's expanding or collapsing.
222
+ As part of this change, we also removed the `onAnimationStart` prop. Since moving to transitions, React doesn't support `onTransitionStart`, therefore the prop is no longer needed.
223
+
216
224
  ### Tabs
217
225
 
218
226
  **PR:** [#3119](https://github.com/Workday/canvas-kit/pull/3119)
@@ -279,7 +287,6 @@ If you're using `react@16.x.x`, you'll need to upgrade to `react@17.x.x` to use
279
287
 
280
288
  >**Note:** You'll need to update the way `jsx` transpiles. The automatic runtime feature, enabled through the `@babel/preset-react` preset with the `runtime: "automatic"` option, handles the importing of functions that JSX transpiles to.
281
289
 
282
- ```sh
283
290
 
284
291
  ## Troubleshooting
285
292
 
@@ -8,6 +8,7 @@ import {
8
8
  useListModel,
9
9
  ListItemProps,
10
10
  ListBox,
11
+ getCursor,
11
12
  } from '@workday/canvas-kit-react/collection';
12
13
  import {composeHooks, createSubcomponent} from '@workday/canvas-kit-react/common';
13
14
 
@@ -47,7 +48,7 @@ export default () => {
47
48
  <Item data-id="third">Third</Item>
48
49
  </ListBox>
49
50
 
50
- <p>Cursor ID: {model.state.cursorId}</p>
51
+ <p>Cursor ID: {getCursor(model.state)}</p>
51
52
  <p>
52
53
  Selected IDs: {(model.state.selectedIds !== 'all' ? model.state.selectedIds : []).join(',')}
53
54
  </p>
@@ -7,6 +7,7 @@ import {
7
7
  useListModel,
8
8
  ListItemProps,
9
9
  ListBox,
10
+ getCursor,
10
11
  } from '@workday/canvas-kit-react/collection';
11
12
  import {
12
13
  composeHooks,
@@ -51,7 +52,7 @@ export default () => {
51
52
  <SelectableItem data-id="third">Third</SelectableItem>
52
53
  </ListBox>
53
54
 
54
- <p>Cursor ID: {model.state.cursorId}</p>
55
+ <p>Cursor ID: {getCursor(model.state)}</p>
55
56
  <p>Selected ID: {model.state.selectedIds[0]}</p>
56
57
  </>
57
58
  );
@@ -4,6 +4,8 @@ import ContextMenu from './examples/ContextMenu';
4
4
  import Icons from './examples/Icons';
5
5
  import SelectableMenu from './examples/SelectableMenu';
6
6
  import Grouping from './examples/Grouping';
7
+ import Nested from './examples/Nested';
8
+ import NestedDynamic from './examples/Nested';
7
9
 
8
10
  # Canvas Kit Menu
9
11
 
@@ -81,6 +83,26 @@ and are not selectable with the keyboard or mouse.
81
83
 
82
84
  <ExampleCodeBlock code={Grouping} />
83
85
 
86
+ ### Nested
87
+
88
+ Menus support nesting. If you only have a few items and not very many nesting levels, the menu can
89
+ be defined statically using JSX. A submenu is defined using the `<Menu.Submenu>` component. The
90
+ `Submenu` is implemented as a special `Menu` subcomponent. The API of the submenu is the same as the
91
+ `Menu` except the submenu's target is also a menu item. The component is named `TargetItem` to
92
+ indicate this dual role.
93
+
94
+ <ExampleCodeBlock code={Nested} />
95
+
96
+ ### Nested Dynamic Items
97
+
98
+ Menu nesting is simpler with the dynamic API. In this example, a `renderItem` function is defined to
99
+ allow recursive nesting of items using a data structure you define. A submenu will inherit the
100
+ `getId` and `getTextValue` functions of the parent menu. While you can pass a specialize `getId` or
101
+ `getTextValue` function to each submenu, it may be simpler to use the same one for the menu and
102
+ submenus.
103
+
104
+ <ExampleCodeBlock code={NestedDynamic} />
105
+
84
106
  ## Component API
85
107
 
86
108
  <SymbolDoc name="Menu" fileName="/react/" />
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import {chevronRightSmallIcon} from '@workday/canvas-system-icons-web';
3
+
4
+ import {Menu} from '@workday/canvas-kit-react/menu';
5
+ import {BodyText} from '@workday/canvas-kit-react/text';
6
+
7
+ export default () => {
8
+ const [selected, setSelected] = React.useState('');
9
+ return (
10
+ <Menu
11
+ id="first-menu"
12
+ onSelect={data => {
13
+ setSelected(data.id);
14
+ }}
15
+ >
16
+ <Menu.Target>Open Menu</Menu.Target>
17
+ <Menu.Popper>
18
+ <Menu.Card>
19
+ <Menu.List>
20
+ <Menu.Item data-id="first-item">First Item</Menu.Item>
21
+ <Menu.Submenu id="second-menu">
22
+ <Menu.Submenu.TargetItem data-id="second-item">Second Item</Menu.Submenu.TargetItem>
23
+ <Menu.Submenu.Popper>
24
+ <Menu.Submenu.Card>
25
+ <Menu.Submenu.List>
26
+ <Menu.Submenu.Item data-id="first-sub-item">First Sub Item</Menu.Submenu.Item>
27
+ <Menu.Submenu.Item data-id="second-sub-item">First Sub Item</Menu.Submenu.Item>
28
+ <Menu.Submenu.Item data-id="third-sub-item">Third Sub Item</Menu.Submenu.Item>
29
+ <Menu.Submenu.Item data-id="fourth-sub-item">Fourth Sub Item</Menu.Submenu.Item>
30
+ </Menu.Submenu.List>
31
+ </Menu.Submenu.Card>
32
+ </Menu.Submenu.Popper>
33
+ </Menu.Submenu>
34
+ <Menu.Divider />
35
+ <Menu.Item data-id="third-item">
36
+ Third Item (with a really, really, really long label)
37
+ </Menu.Item>
38
+ <Menu.Item aria-disabled data-id="fourth-item">
39
+ Fourth Item
40
+ </Menu.Item>
41
+ </Menu.List>
42
+ </Menu.Card>
43
+ </Menu.Popper>
44
+ <BodyText size="small" marginTop="s">
45
+ Selected: <span data-testid="output">{selected}</span>
46
+ </BodyText>
47
+ </Menu>
48
+ );
49
+ };
@@ -0,0 +1,105 @@
1
+ import React from 'react';
2
+
3
+ import {Menu} from '@workday/canvas-kit-react/menu';
4
+ import {BodyText} from '@workday/canvas-kit-react/text';
5
+ import {system} from '@workday/canvas-tokens-web';
6
+
7
+ type Item = {
8
+ type?: 'item';
9
+ id: string;
10
+ label: string;
11
+ };
12
+ type SubmenuItem = {
13
+ id: string;
14
+ label: string;
15
+ type: 'submenu';
16
+ children: (Item | SubmenuItem)[];
17
+ };
18
+
19
+ // This is a user-defined object. The structure uses `id` for the item identifier which is the
20
+ // default key used by the collection system and therefore doesn't require a `getId` function to be
21
+ // passed to the model. The `label` isn't the standard text value used by the collection system, so
22
+ // a `getTextValue` function is required. The `type` and `children` aren't important at all to the
23
+ // menu and are used in the template by the user-defined `renderItem` function.
24
+ const items: (SubmenuItem | Item)[] = [
25
+ {id: 'first-item', label: 'First Item'},
26
+ {
27
+ id: 'second-item',
28
+ label: 'Second Item',
29
+ type: 'submenu',
30
+ children: [
31
+ {id: 'first-sub-item', label: 'First Sub Item'},
32
+ {
33
+ id: 'second-sub-item',
34
+ label: 'Second Sub Item',
35
+ type: 'submenu',
36
+ children: [
37
+ {id: 'first-sub-sub-item', label: 'First Sub Sub Item'},
38
+ {
39
+ id: 'second-sub-sub-item',
40
+ type: 'submenu',
41
+ label: 'Second Sub Sub Item',
42
+ children: [
43
+ {id: 'first-sub-sub-sub-item', label: 'First Sub Sub Sub Item'},
44
+ {
45
+ id: 'second-sub-sub-sub-item',
46
+ label: 'Second Sub Sub Sub Item',
47
+ },
48
+ {id: 'third-sub-sub-sub-item', label: 'Third Sub Sub Sub Item'},
49
+ {id: 'fourth-sub-sub-sub-item', label: 'Fourth Sub Sub Sub Item'},
50
+ ],
51
+ },
52
+ {id: 'third-sub-sub-item', label: 'Third Sub Sub Item'},
53
+ {id: 'fourth-sub-sub-item', label: 'Fourth Sub Sub Item'},
54
+ ],
55
+ },
56
+ {id: 'third-sub-item', label: 'Third Sub Item'},
57
+ {id: 'fourth-sub-item', label: 'Fourth Sub Item'},
58
+ ],
59
+ },
60
+ {id: 'third-item', label: 'Third Item'},
61
+ {id: 'fourth-item', label: 'Fourth Item'},
62
+ ];
63
+
64
+ export default () => {
65
+ const [selected, setSelected] = React.useState('');
66
+
67
+ // defining this inline function allows use to recurse any nesting level defined by the `items`
68
+ // array.
69
+ function renderItem(item: SubmenuItem | Item) {
70
+ if (item.type === 'submenu') {
71
+ return (
72
+ <Menu.Submenu id={item.id} items={item.children}>
73
+ <Menu.Submenu.TargetItem>{item.label}</Menu.Submenu.TargetItem>
74
+ <Menu.Submenu.Popper>
75
+ <Menu.Submenu.Card>
76
+ <Menu.Submenu.List>{renderItem}</Menu.Submenu.List>
77
+ </Menu.Submenu.Card>
78
+ </Menu.Submenu.Popper>
79
+ </Menu.Submenu>
80
+ );
81
+ }
82
+ return <Menu.Item>{item.label}</Menu.Item>;
83
+ }
84
+
85
+ return (
86
+ <Menu
87
+ items={items}
88
+ id="first-menu"
89
+ getTextValue={item => item.label}
90
+ onSelect={data => {
91
+ setSelected(data.id);
92
+ }}
93
+ >
94
+ <Menu.Target>Open Menu</Menu.Target>
95
+ <Menu.Popper>
96
+ <Menu.Card>
97
+ <Menu.List>{renderItem}</Menu.List>
98
+ </Menu.Card>
99
+ </Menu.Popper>
100
+ <BodyText size="small" cs={{marginBlockStart: system.space.x4}}>
101
+ Selected: <span data-testid="output">{selected}</span>
102
+ </BodyText>
103
+ </Menu>
104
+ );
105
+ };
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
+ import {isCursor} from '@workday/canvas-kit-react/collection';
3
4
  import {Tabs, useTabsModel} from '@workday/canvas-kit-react/tabs';
4
5
 
5
6
  type Tab = {
@@ -32,14 +33,14 @@ export default () => {
32
33
  * @param id The id of the item that will be removed
33
34
  */
34
35
  const removeItem = <T extends unknown>(id: string, model: ReturnType<typeof useTabsModel>) => {
35
- const index = model.state.items.findIndex(item => item.id === model.state.cursorId);
36
+ const index = model.state.items.findIndex(item => isCursor(model.state, item.id));
36
37
  const nextIndex = index === model.state.items.length - 1 ? index - 1 : index + 1;
37
38
  const nextId = model.state.items[nextIndex].id;
38
39
  if (model.state.selectedIds[0] === id) {
39
40
  // We're removing the currently selected item. Select next item
40
41
  model.events.select({id: nextId});
41
42
  }
42
- if (model.state.cursorId === id) {
43
+ if (isCursor(model.state, id)) {
43
44
  // We're removing the currently focused item. Focus next item
44
45
  model.events.goTo({id: nextId});
45
46
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "13.0.0-alpha.1107-next.0",
3
+ "version": "13.0.0-alpha.1111-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": "^13.0.0-alpha.1107-next.0",
49
- "@workday/canvas-kit-preview-react": "^13.0.0-alpha.1107-next.0",
50
- "@workday/canvas-kit-react": "^13.0.0-alpha.1107-next.0",
51
- "@workday/canvas-kit-styling": "^13.0.0-alpha.1107-next.0",
48
+ "@workday/canvas-kit-labs-react": "^13.0.0-alpha.1111-next.0",
49
+ "@workday/canvas-kit-preview-react": "^13.0.0-alpha.1111-next.0",
50
+ "@workday/canvas-kit-react": "^13.0.0-alpha.1111-next.0",
51
+ "@workday/canvas-kit-styling": "^13.0.0-alpha.1111-next.0",
52
52
  "@workday/canvas-system-icons-web": "^3.0.0",
53
53
  "@workday/canvas-tokens-web": "^2.1.1",
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": "68413fa0564895825344e09a927b4848ebfe4824"
64
+ "gitHead": "b0529fc270482d902e8da5ba424763cfb0b6b994"
65
65
  }