@workday/canvas-kit-docs 5.3.0 → 5.3.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.
Files changed (43) hide show
  1. package/dist/commonjs/lib/specs.js +18 -232
  2. package/dist/es6/lib/specs.js +18 -232
  3. package/dist/mdx/COMPOUND_COMPONENTS.mdx +30 -31
  4. package/dist/mdx/react/button/button/Button.mdx +2 -27
  5. package/dist/mdx/react/button/button/examples/Primary.tsx +1 -10
  6. package/dist/mdx/react/button/button/examples/Secondary.tsx +1 -10
  7. package/dist/mdx/react/button/button/examples/Tertiary.tsx +1 -10
  8. package/dist/mdx/react/tabs/Tabs.mdx +5 -31
  9. package/dist/mdx/react/tabs/examples/DisabledTab.tsx +1 -1
  10. package/dist/mdx/react/tabs/examples/DynamicTabs.tsx +13 -41
  11. package/dist/mdx/react/tabs/examples/HoistedModel.tsx +4 -4
  12. package/dist/mdx/react/tabs/examples/{NamedTabs.tsx → NamedKeys.tsx} +0 -0
  13. package/dist/mdx/react/tabs/examples/SinglePanel.tsx +1 -1
  14. package/dist/mdx/react/text-area/TextArea.mdx +1 -1
  15. package/package.json +3 -3
  16. package/dist/mdx/6.0-MIGRATION-GUIDE.mdx +0 -554
  17. package/dist/mdx/labs-react/search-form/SearchForm.mdx +0 -64
  18. package/dist/mdx/labs-react/search-form/examples/Basic.tsx +0 -61
  19. package/dist/mdx/labs-react/search-form/examples/CustomTheme.tsx +0 -72
  20. package/dist/mdx/labs-react/search-form/examples/Grow.tsx +0 -62
  21. package/dist/mdx/labs-react/search-form/examples/PropTables.splitProps.tsx +0 -4
  22. package/dist/mdx/labs-react/search-form/examples/RTL.tsx +0 -70
  23. package/dist/mdx/labs-react/search-form/examples/Theming.tsx +0 -64
  24. package/dist/mdx/labs-react/text-input/TextInput.mdx +0 -123
  25. package/dist/mdx/labs-react/text-input/examples/Alert.tsx +0 -46
  26. package/dist/mdx/labs-react/text-input/examples/Basic.tsx +0 -20
  27. package/dist/mdx/labs-react/text-input/examples/Disabled.tsx +0 -20
  28. package/dist/mdx/labs-react/text-input/examples/Error.tsx +0 -43
  29. package/dist/mdx/labs-react/text-input/examples/Grow.tsx +0 -20
  30. package/dist/mdx/labs-react/text-input/examples/HiddenLabel.tsx +0 -17
  31. package/dist/mdx/labs-react/text-input/examples/LabelPosition.tsx +0 -20
  32. package/dist/mdx/labs-react/text-input/examples/LoginForm.tsx +0 -100
  33. package/dist/mdx/labs-react/text-input/examples/Password.tsx +0 -20
  34. package/dist/mdx/labs-react/text-input/examples/Placeholder.tsx +0 -20
  35. package/dist/mdx/labs-react/text-input/examples/RefForwarding.tsx +0 -27
  36. package/dist/mdx/labs-react/text-input/examples/Required.tsx +0 -20
  37. package/dist/mdx/labs-react/text-input/examples/ThemedAlert.tsx +0 -51
  38. package/dist/mdx/labs-react/text-input/examples/ThemedError.tsx +0 -40
  39. package/dist/mdx/react/button/button/examples/PrimaryInverse.tsx +0 -14
  40. package/dist/mdx/react/button/button/examples/SecondaryInverse.tsx +0 -14
  41. package/dist/mdx/react/button/button/examples/TertiaryInverse.tsx +0 -14
  42. package/dist/mdx/react/tabs/examples/Icons.tsx +0 -36
  43. package/dist/mdx/react/tabs/examples/OverflowTabs.tsx +0 -58
@@ -2,11 +2,9 @@ import {Tabs} from '@workday/canvas-kit-react/tabs';
2
2
  import {Specifications} from '@workday/canvas-kit-docs';
3
3
 
4
4
  import Basic from './examples/Basic';
5
- import NamedTabs from './examples/NamedTabs';
5
+ import NamedKeys from './examples/NamedKeys';
6
6
  import RightToLeft from './examples/RightToLeft';
7
- import OverflowTabs from './examples/OverflowTabs';
8
7
  import DisabledTab from './examples/DisabledTab';
9
- import Icons from './examples/Icons';
10
8
  import SinglePanel from './examples/SinglePanel';
11
9
  import AlternativeTabStop from './examples/AlternativeTabStop';
12
10
  import HoistedModel from './examples/HoistedModel';
@@ -40,26 +38,10 @@ yarn add @workday/canvas-kit-react
40
38
  in a variety of ways: `Tabs.List`, `Tabs.Item` and `Tabs.Panel`. It follows the
41
39
  [W3 Tabs specification](https://www.w3.org/TR/wai-aria-practices/#tabpanel).
42
40
 
43
- In this example, we set up a basic `Tabs` component with five tabs. This example uses a static API
44
- that does not support overflow.
41
+ In this example, we set up a basic `Tabs` component with five tabs.
45
42
 
46
43
  <ExampleCodeBlock code={Basic} />
47
44
 
48
- ### Overflow Tabs
49
-
50
- Tabs is a responsive component based on the width of its container. If the rendered tabs exceed the
51
- width of the `Tabs.List`, an overflow menu will be rendered. This only works against the dynamic API
52
- where you give the `TabsModel` an array of items to be rendered. The dynamic API handles the React
53
- `key` for you based on the item's identifier. The dynamic API requires either an `id` on each item
54
- object or a `getId` function that returns an identifier based on the item. The below example uses an
55
- `id` property on each item.
56
-
57
- The dynamic API takes in any object, but since nothing is known about your object, a
58
- [render prop](https://reactjs.org/docs/render-props.html) is necessary to instruct a list how it
59
- should render.
60
-
61
- <ExampleCodeBlock code={OverflowTabs} />
62
-
63
45
  ### Hoisted Model
64
46
 
65
47
  By default, `Tabs` will create and use its own [model](#model) internally. Alternatively, you may
@@ -73,13 +55,13 @@ trigger an event to change the active tab.
73
55
 
74
56
  <ExampleCodeBlock code={HoistedModel} />
75
57
 
76
- ### Named Tabs
58
+ ### Named Keys
77
59
 
78
60
  `Tabs.Item` and `Tabs.Panel` both take an optional `name` attribute that is used for the
79
- `onActivate` callback. This example is identical to the Basic Example, but with named tabs for the
61
+ `onActivate` callback. This example is identical to the Basic Example, but with named keys for the
80
62
  `Tabs.Item` and `Tabs.Panel` subcomponents.
81
63
 
82
- <ExampleCodeBlock code={NamedTabs} />
64
+ <ExampleCodeBlock code={NamedKeys} />
83
65
 
84
66
  ### Right-to-Left (RTL)
85
67
 
@@ -93,14 +75,6 @@ Set the `disabled` prop of a `Tabs.Item` to `true` to disable it.
93
75
 
94
76
  <ExampleCodeBlock code={DisabledTab} />
95
77
 
96
- ### Tab Icons
97
-
98
- Tabs can have icons. You must set `hasIcon` on the `Tabs.Item` and use the `Icon` and `Text`
99
- subcomponent. The `hasIcon` changes the `Tabs.Item` to change where overflow detection is from the
100
- `Tabs.Item` element to the `Tabs.Item.Text` element.
101
-
102
- <ExampleCodeBlock code={Icons} />
103
-
104
78
  ### Alternative Tab Stop
105
79
 
106
80
  By default, tab panels are focusable for accessibility. If the contents of a tab panel have a
@@ -8,7 +8,7 @@ export default () => {
8
8
  <Tabs>
9
9
  <Tabs.List>
10
10
  <Tabs.Item>First Tab</Tabs.Item>
11
- <Tabs.Item aria-disabled>Disabled Tab</Tabs.Item>
11
+ <Tabs.Item disabled>Disabled Tab</Tabs.Item>
12
12
  <Tabs.Item>Third Tab</Tabs.Item>
13
13
  </Tabs.List>
14
14
  <div style={{marginTop: space.m}}>
@@ -1,50 +1,22 @@
1
1
  import React from 'react';
2
2
  import {space} from '@workday/canvas-kit-react/tokens';
3
3
 
4
- import {Tabs, useTabsModel, TabsModel} from '@workday/canvas-kit-react/tabs';
5
- import {SelectionModel} from '../../lib/selection';
4
+ import {Tabs, useTabsModel} from '@workday/canvas-kit-react/tabs';
6
5
 
7
6
  export default () => {
8
7
  const [tabs, setTabs] = React.useState([
9
- {tab: 'Tab 1', id: 'tab-1'},
10
- {tab: 'Tab 2', id: 'tab-2'},
11
- {tab: 'Tab 3', id: 'tab-3'},
8
+ {tab: 'Tab 1', name: 'tab-1'},
9
+ {tab: 'Tab 2', name: 'tab-2'},
10
+ {tab: 'Tab 3', name: 'tab-3'},
12
11
  ]);
13
12
  const addedRef = React.useRef(tabs.length);
14
13
  const model = useTabsModel({
15
- shouldSelect: ({data}) => data.id !== 'last',
14
+ shouldActivate: ({data}) => data.tab !== 'last',
16
15
  });
17
16
 
18
- /**
19
- * Helper function that should be called when an item is programmatically removed. The following
20
- * side effects depend on state of the model:
21
- * * **Item is focused**: Focus will be moved to next item in the list
22
- * * **Item is selected**: Selection will be moved to the next item in the list
23
- * @param id The id of the item that will be removed
24
- */
25
- const removeItem = (id: string, model: SelectionModel) => {
26
- const index = model.state.items.findIndex(item => model.getId(item) === model.state.cursorId);
27
- const nextIndex = index === model.state.items.length - 1 ? index - 1 : index + 1;
28
- const nextId = model.getId(model.state.items[nextIndex]);
29
- if (model.state.selectedIds[0] === id) {
30
- // We're removing the currently selected item. Select next item
31
- model.events.select({id: nextId});
32
- }
33
- if (model.state.cursorId === id) {
34
- // We're removing the currently focused item. Focus next item
35
- model.events.goTo({id: nextId});
36
-
37
- // wait for stabilization of state
38
- requestAnimationFrame(() => {
39
- document.querySelector<HTMLElement>(`#${model.state.id}-${nextId}`)?.focus();
40
- });
41
- }
42
- };
43
-
44
- const onKeyDown = (e: React.KeyboardEvent<HTMLElement>, id: string) => {
45
- if (e.key === 'Delete') {
46
- setTabs(tabs.filter(item => item.id !== id));
47
- removeItem(id, model);
17
+ const onKeyDown = (e: React.KeyboardEvent<HTMLElement>, name: string) => {
18
+ if (e.key === 'Backspace') {
19
+ setTabs(tabs.filter(item => item.name !== name));
48
20
  }
49
21
  };
50
22
 
@@ -53,10 +25,10 @@ export default () => {
53
25
  <Tabs.List>
54
26
  {tabs.map((item, index) => (
55
27
  <Tabs.Item
56
- key={item.id}
57
- name={item.id}
28
+ key={item.name}
29
+ name={item.name}
58
30
  index={index}
59
- onKeyDown={e => onKeyDown(e, item.id)}
31
+ onKeyDown={e => onKeyDown(e, item.name)}
60
32
  >
61
33
  {item.tab}
62
34
  </Tabs.Item>
@@ -68,7 +40,7 @@ export default () => {
68
40
  onClick={() => {
69
41
  addedRef.current += 1;
70
42
  setTabs(tabs =>
71
- tabs.concat({tab: `Tab ${addedRef.current}`, id: `tab-${addedRef.current}`})
43
+ tabs.concat({tab: `Tab ${addedRef.current}`, name: `tab-${addedRef.current}`})
72
44
  );
73
45
  model.events.goTo({id: 'last'});
74
46
  }}
@@ -78,7 +50,7 @@ export default () => {
78
50
  </Tabs.List>
79
51
  <div style={{marginTop: space.m}}>
80
52
  {tabs.map((item, index) => (
81
- <Tabs.Panel key={item.id} name={item.id}>
53
+ <Tabs.Panel key={item.name} name={item.name}>
82
54
  Contents of {item.tab}
83
55
  </Tabs.Panel>
84
56
  ))}
@@ -6,8 +6,8 @@ import {Tabs, useTabsModel} from '@workday/canvas-kit-react/tabs';
6
6
 
7
7
  export default () => {
8
8
  const model = useTabsModel({
9
- onSelect({data, prevState}) {
10
- console.log('Selected Tab', data, prevState);
9
+ onActivate({data, prevState}) {
10
+ console.log('Activated Tab', data, prevState);
11
11
  },
12
12
  });
13
13
 
@@ -27,10 +27,10 @@ export default () => {
27
27
  </Tabs>
28
28
  <SecondaryButton
29
29
  onClick={() => {
30
- model.events.select({id: 'third'});
30
+ model.events.activate({tab: 'third'});
31
31
  }}
32
32
  >
33
- Select Third Tab
33
+ Activate Third Tab
34
34
  </SecondaryButton>
35
35
  </>
36
36
  );
@@ -34,7 +34,7 @@ export default () => {
34
34
  </Tabs.Item>
35
35
  </Tabs.List>
36
36
  <Tabs.Panel style={{marginTop: space.m}} hidden={undefined} id="mytab-panel">
37
- {contents[model.state.selectedIds[0]]}
37
+ {contents[model.state.activeTab]}
38
38
  </Tabs.Panel>
39
39
  </Tabs>
40
40
  );
@@ -23,7 +23,7 @@ Text Areas allow users to enter and edit multiple lines of text.
23
23
  ## Installation
24
24
 
25
25
  ```sh
26
- yarn add @workday/canvas-kit-labs-react
26
+ yarn add @workday/canvas-kit-react
27
27
  ```
28
28
 
29
29
  ## Usage
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "5.3.0",
3
+ "version": "5.3.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",
@@ -49,7 +49,7 @@
49
49
  ],
50
50
  "dependencies": {
51
51
  "@storybook/csf": "0.0.1",
52
- "@workday/canvas-kit-react": "^5.3.0"
52
+ "@workday/canvas-kit-react": "^5.3.1"
53
53
  },
54
54
  "devDependencies": {
55
55
  "fs-extra": "^10.0.0",
@@ -57,5 +57,5 @@
57
57
  "mkdirp": "^1.0.3",
58
58
  "typescript": "^3.8.3"
59
59
  },
60
- "gitHead": "0cf3030eb73935b5679f8c9bb79fb6178a721a4a"
60
+ "gitHead": "b60f3e21f949f6f514e63f3b5550e270220a22ae"
61
61
  }