@workday/canvas-kit-docs 6.0.0-alpha.0-next.33 → 6.0.0-alpha.0-next.39

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 (67) hide show
  1. package/dist/commonjs/lib/specs.js +224 -2
  2. package/dist/es6/lib/specs.js +224 -2
  3. package/dist/mdx/5.0-MIGRATION-GUIDE.mdx +81 -7
  4. package/dist/mdx/6.0-MIGRATION-GUIDE.mdx +18 -12
  5. package/dist/mdx/7.0-MIGRATION-GUIDE.mdx +33 -0
  6. package/dist/mdx/preview-react/form-field/FormField.mdx +27 -0
  7. package/dist/mdx/preview-react/form-field/examples/Custom.tsx +57 -0
  8. package/dist/mdx/preview-react/text-area/TextArea.mdx +122 -0
  9. package/dist/mdx/preview-react/text-area/examples/Alert.tsx +31 -0
  10. package/dist/mdx/preview-react/text-area/examples/Basic.tsx +17 -0
  11. package/dist/mdx/preview-react/text-area/examples/Disabled.tsx +17 -0
  12. package/dist/mdx/preview-react/text-area/examples/Error.tsx +40 -0
  13. package/dist/mdx/preview-react/text-area/examples/Grow.tsx +17 -0
  14. package/dist/mdx/preview-react/text-area/examples/HiddenLabel.tsx +20 -0
  15. package/dist/mdx/preview-react/text-area/examples/LabelPositionHorizontal.tsx +17 -0
  16. package/dist/mdx/preview-react/text-area/examples/LabelPositionVertical.tsx +17 -0
  17. package/dist/mdx/preview-react/text-area/examples/Placeholder.tsx +21 -0
  18. package/dist/mdx/preview-react/text-area/examples/RefForwarding.tsx +28 -0
  19. package/dist/mdx/preview-react/text-area/examples/Required.tsx +17 -0
  20. package/dist/mdx/preview-react/text-area/examples/ResizeConstraints.tsx +22 -0
  21. package/dist/mdx/{labs-react → preview-react}/text-input/TextInput.mdx +40 -18
  22. package/dist/mdx/preview-react/text-input/examples/Alert.tsx +40 -0
  23. package/dist/mdx/{labs-react/text-input/examples/HiddenLabel.tsx → preview-react/text-input/examples/Basic.tsx} +3 -3
  24. package/dist/mdx/preview-react/text-input/examples/Disabled.tsx +17 -0
  25. package/dist/mdx/{labs-react → preview-react}/text-input/examples/Error.tsx +6 -9
  26. package/dist/mdx/preview-react/text-input/examples/Grow.tsx +17 -0
  27. package/dist/mdx/preview-react/text-input/examples/HiddenLabel.tsx +20 -0
  28. package/dist/mdx/preview-react/text-input/examples/LabelPositionHorizontal.tsx +17 -0
  29. package/dist/mdx/preview-react/text-input/examples/LabelPositionVertical.tsx +17 -0
  30. package/dist/mdx/{labs-react → preview-react}/text-input/examples/LoginForm.tsx +10 -5
  31. package/dist/mdx/preview-react/text-input/examples/Password.tsx +17 -0
  32. package/dist/mdx/preview-react/text-input/examples/Placeholder.tsx +17 -0
  33. package/dist/mdx/{labs-react → preview-react}/text-input/examples/RefForwarding.tsx +7 -6
  34. package/dist/mdx/preview-react/text-input/examples/Required.tsx +17 -0
  35. package/dist/mdx/preview-react/text-input/examples/ThemedAlert.tsx +46 -0
  36. package/dist/mdx/{labs-react → preview-react}/text-input/examples/ThemedError.tsx +8 -11
  37. package/dist/mdx/react/_examples/GlobalHeader.mdx +9 -0
  38. package/dist/mdx/react/_examples/PageHeader.mdx +8 -0
  39. package/dist/mdx/react/_examples/examples/GlobalHeader.tsx +66 -0
  40. package/dist/mdx/react/_examples/examples/PageHeader.tsx +63 -0
  41. package/dist/mdx/react/banner/Banner.mdx +203 -19
  42. package/dist/mdx/react/banner/PropTables.splitprops.tsx +39 -0
  43. package/dist/mdx/react/banner/examples/ActionText.tsx +8 -1
  44. package/dist/mdx/react/banner/examples/Basic.tsx +8 -1
  45. package/dist/mdx/react/banner/examples/Error.tsx +8 -1
  46. package/dist/mdx/react/banner/examples/RefForwarding.tsx +25 -0
  47. package/dist/mdx/react/banner/examples/Sticky.tsx +15 -7
  48. package/dist/mdx/react/banner/examples/StickyAnimation.tsx +62 -0
  49. package/dist/mdx/react/banner/examples/StickyRTL.tsx +38 -0
  50. package/dist/mdx/react/banner/examples/ThemedAlert.tsx +28 -0
  51. package/dist/mdx/react/banner/examples/ThemedError.tsx +29 -0
  52. package/dist/mdx/react/button/button/examples/Primary.tsx +4 -3
  53. package/dist/mdx/react/loading-animation/LoadingAnimation.mdx +5 -0
  54. package/dist/mdx/react/loading-animation/examples/RTL.tsx +16 -0
  55. package/dist/mdx/react/tabs/examples/DynamicTabs.tsx +50 -34
  56. package/dist/mdx/react/tooltip/Tooltip.mdx +8 -0
  57. package/dist/mdx/react/tooltip/examples/DelayedTooltip.tsx +16 -0
  58. package/package.json +5 -4
  59. package/dist/mdx/labs-react/text-input/examples/Alert.tsx +0 -46
  60. package/dist/mdx/labs-react/text-input/examples/Basic.tsx +0 -20
  61. package/dist/mdx/labs-react/text-input/examples/Disabled.tsx +0 -20
  62. package/dist/mdx/labs-react/text-input/examples/Grow.tsx +0 -20
  63. package/dist/mdx/labs-react/text-input/examples/LabelPosition.tsx +0 -20
  64. package/dist/mdx/labs-react/text-input/examples/Password.tsx +0 -20
  65. package/dist/mdx/labs-react/text-input/examples/Placeholder.tsx +0 -20
  66. package/dist/mdx/labs-react/text-input/examples/Required.tsx +0 -20
  67. package/dist/mdx/labs-react/text-input/examples/ThemedAlert.tsx +0 -51
@@ -4,17 +4,28 @@ import {space} from '@workday/canvas-kit-react/tokens';
4
4
  import {Tabs, useTabsModel, TabsModel} from '@workday/canvas-kit-react/tabs';
5
5
  import {SelectionModel} from '../../lib/selection';
6
6
 
7
+ type Tab = {
8
+ tab: string;
9
+ id: string;
10
+ };
11
+
7
12
  export default () => {
8
- const [tabs, setTabs] = React.useState([
13
+ const [tabs, setTabs] = React.useState<Tab[]>([
9
14
  {tab: 'Tab 1', id: 'tab-1'},
10
15
  {tab: 'Tab 2', id: 'tab-2'},
11
16
  {tab: 'Tab 3', id: 'tab-3'},
17
+ {tab: 'Add Tab', id: 'add'},
12
18
  ]);
13
- const addedRef = React.useRef(tabs.length);
19
+ const addedRef = React.useRef(tabs.length - 1);
14
20
  const model = useTabsModel({
15
- shouldSelect: ({data}) => data.id !== 'last',
21
+ items: tabs,
22
+ shouldSelect: ({data}) => data.id !== 'add',
16
23
  });
17
24
 
25
+ // A ref of the model for the render functions to work around the caching done to lists
26
+ const modelRef = React.useRef(model);
27
+ modelRef.current = model;
28
+
18
29
  /**
19
30
  * Helper function that should be called when an item is programmatically removed. The following
20
31
  * side effects depend on state of the model:
@@ -22,8 +33,9 @@ export default () => {
22
33
  * * **Item is selected**: Selection will be moved to the next item in the list
23
34
  * @param id The id of the item that will be removed
24
35
  */
25
- const removeItem = (id: string, model: SelectionModel) => {
36
+ const removeItem = <T extends unknown>(id: string, model: SelectionModel<T>) => {
26
37
  const index = model.state.items.findIndex(item => model.getId(item) === model.state.cursorId);
38
+ console.log('index', index, id, model.state.cursorId, model.state.items);
27
39
  const nextIndex = index === model.state.items.length - 1 ? index - 1 : index + 1;
28
40
  const nextId = model.getId(model.state.items[nextIndex]);
29
41
  if (model.state.selectedIds[0] === id) {
@@ -41,48 +53,52 @@ export default () => {
41
53
  }
42
54
  };
43
55
 
44
- const onKeyDown = (e: React.KeyboardEvent<HTMLElement>, id: string) => {
45
- if (e.key === 'Delete') {
56
+ const onKeyDown = (id: string) => (e: React.KeyboardEvent<HTMLElement>) => {
57
+ if (e.key === 'Delete' && id !== 'add') {
46
58
  setTabs(tabs.filter(item => item.id !== id));
59
+ const model = modelRef.current;
47
60
  removeItem(id, model);
48
61
  }
49
62
  };
50
63
 
64
+ const onClick = (id: string) => (e: React.MouseEvent) => {
65
+ if (id === 'add') {
66
+ addedRef.current += 1;
67
+ setTabs(tabs => {
68
+ const newTabs = tabs.slice(0, tabs.length - 1);
69
+ const addTab = tabs.slice(-1);
70
+ return newTabs.concat(
71
+ {tab: `Tab ${addedRef.current}`, id: `tab-${addedRef.current}`},
72
+ addTab
73
+ );
74
+ });
75
+ model.events.goTo({id: 'add'});
76
+ }
77
+ };
78
+
51
79
  return (
52
80
  <Tabs model={model}>
53
- <Tabs.List>
54
- {tabs.map((item, index) => (
55
- <Tabs.Item
56
- key={item.id}
57
- name={item.id}
58
- index={index}
59
- onKeyDown={e => onKeyDown(e, item.id)}
60
- >
81
+ <Tabs.List overflowButton={<Tabs.OverflowButton>More</Tabs.OverflowButton>}>
82
+ {(item: Tab) => (
83
+ <Tabs.Item name={item.id} onKeyDown={onKeyDown(item.id)} onClick={onClick(item.id)}>
61
84
  {item.tab}
62
85
  </Tabs.Item>
63
- ))}
64
- <Tabs.Item
65
- key={'last'}
66
- index={tabs.length}
67
- name={'last'}
68
- onClick={() => {
69
- addedRef.current += 1;
70
- setTabs(tabs =>
71
- tabs.concat({tab: `Tab ${addedRef.current}`, id: `tab-${addedRef.current}`})
72
- );
73
- model.events.goTo({id: 'last'});
74
- }}
75
- >
76
- Add Tab
77
- </Tabs.Item>
86
+ )}
78
87
  </Tabs.List>
79
- <div style={{marginTop: space.m}}>
80
- {tabs.map((item, index) => (
81
- <Tabs.Panel key={item.id} name={item.id}>
88
+ <Tabs.Menu.Popper>
89
+ <Tabs.Menu.Card maxWidth={300} maxHeight={200}>
90
+ <Tabs.Menu.List>
91
+ {(item: Tab) => <Tabs.Menu.Item name={item.id}>{item.tab}</Tabs.Menu.Item>}
92
+ </Tabs.Menu.List>
93
+ </Tabs.Menu.Card>
94
+ </Tabs.Menu.Popper>
95
+ <Tabs.Panels>
96
+ {(item: Tab) => (
97
+ <Tabs.Panel marginTop="m" name={item.id}>
82
98
  Contents of {item.tab}
83
99
  </Tabs.Panel>
84
- ))}
85
- </div>
100
+ )}
101
+ </Tabs.Panels>
86
102
  </Tabs>
87
103
  );
88
104
  };
@@ -3,6 +3,7 @@ import {Specifications} from '@workday/canvas-kit-docs';
3
3
 
4
4
  import Default from './examples/Default';
5
5
  import CustomContent from './examples/CustomContent';
6
+ import DelayedTooltip from './examples/DelayedTooltip';
6
7
  import DescribeType from './examples/DescribeType';
7
8
  import Muted from './examples/Muted';
8
9
  import Placements from './examples/Placements';
@@ -87,6 +88,13 @@ a dialog instead.
87
88
 
88
89
  <ExampleCodeBlock code={CustomContent} />
89
90
 
91
+ ### Delayed Tooltip
92
+
93
+ The default delay for showing and hiding a tooltip are 300ms and 100ms, respectively. You can
94
+ control the length of the delay by providing custom `showDelay` and `hideDelay` in ms.
95
+
96
+ <ExampleCodeBlock code={DelayedTooltip} />
97
+
90
98
  ### Placements
91
99
 
92
100
  The tooltip allows for a `placement` configuration. The tooltip uses
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+
3
+ import {SecondaryButton} from '@workday/canvas-kit-react/button';
4
+ import {Tooltip} from '@workday/canvas-kit-react/tooltip';
5
+
6
+ export default () => {
7
+ return (
8
+ <React.Fragment>
9
+ <Tooltip type="describe" title="Tooltip Text" showDelay={2000} hideDelay={1000}>
10
+ <SecondaryButton>
11
+ Tooltip appears after 2 seconds and disappears after 1 second
12
+ </SecondaryButton>
13
+ </Tooltip>
14
+ </React.Fragment>
15
+ );
16
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "6.0.0-alpha.0-next.33+6766b20c",
3
+ "version": "6.0.0-alpha.0-next.39+ac7c09b9",
4
4
  "description": "Documentation components of Canvas Kit components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -35,7 +35,8 @@
35
35
  "build:specs": "node ./utils/build-specifications.js",
36
36
  "build:downlevel-dts": "yarn run downlevel-dts dist ts3.5/dist",
37
37
  "build": "npm-run-all --parallel build:cjs build:es6 build:mdx --sequential build:specs build:downlevel-dts",
38
- "depcheck": "node ../../utils/check-dependencies-exist.js"
38
+ "depcheck": "node ../../utils/check-dependencies-exist.js",
39
+ "typecheck:src": "tsc -p . --noEmit --incremental false"
39
40
  },
40
41
  "publishConfig": {
41
42
  "access": "public"
@@ -49,7 +50,7 @@
49
50
  ],
50
51
  "dependencies": {
51
52
  "@storybook/csf": "0.0.1",
52
- "@workday/canvas-kit-react": "^6.0.0-alpha.0-next.33+6766b20c"
53
+ "@workday/canvas-kit-react": "^6.0.0-alpha.0-next.39+ac7c09b9"
53
54
  },
54
55
  "devDependencies": {
55
56
  "fs-extra": "^10.0.0",
@@ -57,5 +58,5 @@
57
58
  "mkdirp": "^1.0.3",
58
59
  "typescript": "^3.8.3"
59
60
  },
60
- "gitHead": "6766b20c35f85b44e1c32b95e88ab376bf09eb84"
61
+ "gitHead": "ac7c09b97add635f256ffc4103478fab55da55c2"
61
62
  }
@@ -1,46 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
3
- import {VStack} from '@workday/canvas-kit-labs-react/layout';
4
- import {styled} from '@workday/canvas-kit-react/common';
5
- import {useThemedRing} from '@workday/canvas-kit-labs-react/common';
6
- import {CSSProperties, space} from '@workday/canvas-kit-react/tokens';
7
-
8
- const StyledField = styled(TextInput.Field)<{alertStyles?: CSSProperties}>(
9
- ({alertStyles}) => alertStyles
10
- );
11
-
12
- export default () => {
13
- const [value, setValue] = React.useState('foo');
14
-
15
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
16
- setValue(event.target.value);
17
- };
18
-
19
- const alertStyles = useThemedRing(
20
- value.length < 3 ? 'error' : value.length < 5 ? 'alert' : 'success'
21
- );
22
-
23
- return (
24
- <VStack spacing="xxxs" alignItems="flex-start">
25
- <TextInput>
26
- <TextInput.Label>Password</TextInput.Label>
27
- <StyledField
28
- alertStyles={alertStyles}
29
- onChange={handleChange}
30
- value={value}
31
- type="password"
32
- />
33
- <TextInput.Hint paddingTop={space.xxs}>
34
- <strong>Password Strength: </strong>
35
- {value.length < 3 ? (
36
- <span>Weak</span>
37
- ) : value.length < 5 ? (
38
- <span>Average</span>
39
- ) : (
40
- <span>Strong</span>
41
- )}
42
- </TextInput.Hint>
43
- </TextInput>
44
- </VStack>
45
- );
46
- };
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
3
- import {VStack} from '@workday/canvas-kit-labs-react/layout';
4
-
5
- export default () => {
6
- const [value, setValue] = React.useState('');
7
-
8
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
9
- setValue(event.target.value);
10
- };
11
-
12
- return (
13
- <VStack spacing="xxxs" alignItems="flex-start">
14
- <TextInput>
15
- <TextInput.Label>Email</TextInput.Label>
16
- <TextInput.Field onChange={handleChange} value={value} />
17
- </TextInput>
18
- </VStack>
19
- );
20
- };
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
3
- import {VStack} from '@workday/canvas-kit-labs-react/layout';
4
-
5
- export default () => {
6
- const [value, setValue] = React.useState('');
7
-
8
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
9
- setValue(event.target.value);
10
- };
11
-
12
- return (
13
- <VStack spacing="xxxs" alignItems="flex-start">
14
- <TextInput>
15
- <TextInput.Label>Email</TextInput.Label>
16
- <TextInput.Field onChange={handleChange} value={value} disabled />
17
- </TextInput>
18
- </VStack>
19
- );
20
- };
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
3
- import {VStack} from '@workday/canvas-kit-labs-react/layout';
4
-
5
- export default () => {
6
- const [value, setValue] = React.useState('');
7
-
8
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
9
- setValue(event.target.value);
10
- };
11
-
12
- return (
13
- <VStack spacing="xxxs">
14
- <TextInput>
15
- <TextInput.Label>Street Address</TextInput.Label>
16
- <TextInput.Field onChange={handleChange} value={value} />
17
- </TextInput>
18
- </VStack>
19
- );
20
- };
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
3
- import {HStack} from '@workday/canvas-kit-labs-react/layout';
4
-
5
- export default () => {
6
- const [value, setValue] = React.useState('');
7
-
8
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
9
- setValue(event.target.value);
10
- };
11
-
12
- return (
13
- <HStack spacing="l" alignItems="center">
14
- <TextInput>
15
- <TextInput.Label>Email</TextInput.Label>
16
- <TextInput.Field onChange={handleChange} value={value} />
17
- </TextInput>
18
- </HStack>
19
- );
20
- };
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
3
- import {VStack} from '@workday/canvas-kit-labs-react/layout';
4
-
5
- export default () => {
6
- const [value, setValue] = React.useState('SuperSecret1');
7
-
8
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
9
- setValue(event.target.value);
10
- };
11
-
12
- return (
13
- <VStack spacing="xxxs" alignItems="flex-start">
14
- <TextInput>
15
- <TextInput.Label>Password</TextInput.Label>
16
- <TextInput.Field onChange={handleChange} value={value} type="password" />
17
- </TextInput>
18
- </VStack>
19
- );
20
- };
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
3
- import {VStack} from '@workday/canvas-kit-labs-react/layout';
4
-
5
- export default () => {
6
- const [value, setValue] = React.useState('');
7
-
8
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
9
- setValue(event.target.value);
10
- };
11
-
12
- return (
13
- <VStack spacing="xxxs" alignItems="flex-start">
14
- <TextInput>
15
- <TextInput.Label>Email</TextInput.Label>
16
- <TextInput.Field onChange={handleChange} value={value} placeholder="user@email.com" />
17
- </TextInput>
18
- </VStack>
19
- );
20
- };
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
3
- import {VStack} from '@workday/canvas-kit-labs-react/layout';
4
-
5
- export default () => {
6
- const [value, setValue] = React.useState('');
7
-
8
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
9
- setValue(event.target.value);
10
- };
11
-
12
- return (
13
- <VStack spacing="xxxs" alignItems="flex-start">
14
- <TextInput isRequired={true}>
15
- <TextInput.Label>Email</TextInput.Label>
16
- <TextInput.Field onChange={handleChange} value={value} />
17
- </TextInput>
18
- </VStack>
19
- );
20
- };
@@ -1,51 +0,0 @@
1
- import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
3
- import {useThemedRing} from '@workday/canvas-kit-labs-react/common';
4
- import {VStack} from '@workday/canvas-kit-labs-react/layout';
5
- import {CanvasProvider, PartialEmotionCanvasTheme, styled} from '@workday/canvas-kit-react/common';
6
- import {colors, CSSProperties, space} from '@workday/canvas-kit-react/tokens';
7
-
8
- export default () => {
9
- const theme: PartialEmotionCanvasTheme = {
10
- canvas: {
11
- palette: {
12
- common: {
13
- focusOutline: colors.grapeSoda300,
14
- },
15
- alert: {
16
- main: colors.kiwi500,
17
- darkest: colors.kiwi600,
18
- },
19
- },
20
- },
21
- };
22
- return (
23
- <CanvasProvider theme={theme}>
24
- <AlertInput />
25
- </CanvasProvider>
26
- );
27
- };
28
-
29
- const StyledField = styled(TextInput.Field)<{alertStyles?: CSSProperties}>(
30
- ({alertStyles}) => alertStyles
31
- );
32
-
33
- const AlertInput = () => {
34
- const [value, setValue] = React.useState('invalid@email');
35
-
36
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
37
- setValue(event.target.value);
38
- };
39
-
40
- const alertStyles = useThemedRing('alert');
41
-
42
- return (
43
- <VStack spacing="xxxs" alignItems="flex-start">
44
- <TextInput>
45
- <TextInput.Label>Email</TextInput.Label>
46
- <StyledField alertStyles={alertStyles} onChange={handleChange} value={value} />
47
- <TextInput.Hint paddingTop={space.xxs}>Please enter a valid email.</TextInput.Hint>
48
- </TextInput>
49
- </VStack>
50
- );
51
- };