@workday/canvas-kit-docs 14.3.9 → 14.3.11
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/ExampleCodeBlock.d.ts.map +1 -1
- package/dist/es6/lib/ExampleCodeBlock.js +12 -3
- package/dist/es6/lib/docs.js +15500 -5241
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.js +5 -5
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.ts +5 -5
- package/dist/es6/mdx/accessibility/examples/Popups/InlinePopupNoPortal.d.ts +2 -0
- package/dist/es6/mdx/accessibility/examples/Popups/InlinePopupNoPortal.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/Popups/InlinePopupNoPortal.js +62 -0
- package/dist/es6/mdx/accessibility/examples/Popups/InlinePortalPopup.d.ts +7 -0
- package/dist/es6/mdx/accessibility/examples/Popups/InlinePortalPopup.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/Popups/InlinePortalPopup.js +63 -0
- package/dist/es6/mdx/accessibility/examples/Popups/PopupAriaOwns.d.ts +7 -0
- package/dist/es6/mdx/accessibility/examples/Popups/PopupAriaOwns.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/Popups/PopupAriaOwns.js +46 -0
- package/dist/mdx/accessibility/InlinePortals.mdx +20 -0
- package/dist/mdx/accessibility/Popups.mdx +71 -0
- package/dist/mdx/react/dialog/Dialog.mdx +51 -20
- package/dist/mdx/react/modal/Modal.mdx +87 -9
- package/dist/mdx/react/modal/examples/FormModal.tsx +26 -1
- package/dist/mdx/react/modal/examples/ReturnFocus.tsx +137 -39
- package/dist/mdx/react/popup/Popup.mdx +55 -28
- package/dist/mdx/react/popup/examples/Basic.tsx +20 -3
- package/dist/mdx/react/popup/examples/FocusRedirect.tsx +24 -9
- package/dist/mdx/react/popup/examples/InitialFocus.tsx +113 -9
- package/dist/mdx/react/popup/examples/InlinePopup.tsx +125 -0
- package/dist/mdx/react/popup/examples/MultiplePopups.tsx +34 -22
- package/lib/ExampleCodeBlock.tsx +12 -3
- package/package.json +6 -6
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {DeleteButton} from '@workday/canvas-kit-react/button';
|
|
3
|
+
import {
|
|
4
|
+
Popup,
|
|
5
|
+
usePopupModel,
|
|
6
|
+
useCloseOnEscape,
|
|
7
|
+
useCloseOnOutsideClick,
|
|
8
|
+
useInitialFocus,
|
|
9
|
+
useReturnFocus,
|
|
10
|
+
useFocusRedirect,
|
|
11
|
+
} from '@workday/canvas-kit-react/popup';
|
|
12
|
+
import {Box, Flex} from '@workday/canvas-kit-react/layout';
|
|
13
|
+
import {Heading} from '@workday/canvas-kit-react/text';
|
|
14
|
+
import {createStyles, px2rem} from '@workday/canvas-kit-styling';
|
|
15
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
16
|
+
|
|
17
|
+
const headingStyles = createStyles({
|
|
18
|
+
marginTop: system.space.zero,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const cardStyles = createStyles({
|
|
22
|
+
width: px2rem(320),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const flexStyles = createStyles({
|
|
26
|
+
gap: system.space.x4,
|
|
27
|
+
padding: system.space.x2,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const clipContainerStyles = createStyles({
|
|
31
|
+
padding: system.space.x4,
|
|
32
|
+
border: `${px2rem(2)} dashed ${system.color.border.info.default}`,
|
|
33
|
+
height: px2rem(200),
|
|
34
|
+
position: 'relative',
|
|
35
|
+
overflow: 'clip',
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const visibleContainerStyles = createStyles({
|
|
39
|
+
padding: system.space.x4,
|
|
40
|
+
border: `${px2rem(2)} dashed ${system.color.border.info.default}`,
|
|
41
|
+
height: px2rem(200),
|
|
42
|
+
position: 'relative',
|
|
43
|
+
overflow: 'visible',
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const scrollContainerStyles = createStyles({
|
|
47
|
+
padding: system.space.x4,
|
|
48
|
+
border: `${px2rem(2)} dashed ${system.color.border.info.default}`,
|
|
49
|
+
height: px2rem(200),
|
|
50
|
+
position: 'relative',
|
|
51
|
+
overflow: 'scroll',
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const comparisonLayoutStyles = createStyles({
|
|
55
|
+
display: 'grid',
|
|
56
|
+
gridTemplateColumns: 'repeat(3, minmax(0, 1fr))',
|
|
57
|
+
gap: system.space.x6,
|
|
58
|
+
marginBottom: system.space.x4,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
function SingleInlinePopup({
|
|
62
|
+
overflowLabel,
|
|
63
|
+
containerStyles,
|
|
64
|
+
}: {
|
|
65
|
+
overflowLabel: string;
|
|
66
|
+
containerStyles: string;
|
|
67
|
+
}) {
|
|
68
|
+
const initialFocusRef = React.useRef(null);
|
|
69
|
+
const model = usePopupModel({
|
|
70
|
+
initialFocusRef,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
useCloseOnOutsideClick(model);
|
|
74
|
+
useCloseOnEscape(model);
|
|
75
|
+
useInitialFocus(model);
|
|
76
|
+
useReturnFocus(model);
|
|
77
|
+
useFocusRedirect(model);
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<Box cs={containerStyles}>
|
|
81
|
+
<Heading size="small" as="h4" cs={headingStyles}>
|
|
82
|
+
{overflowLabel}
|
|
83
|
+
</Heading>
|
|
84
|
+
<Popup model={model}>
|
|
85
|
+
<Popup.Target as={DeleteButton}>Delete Item</Popup.Target>
|
|
86
|
+
<Popup.Popper placement="top" portal={false}>
|
|
87
|
+
<Popup.Card cs={cardStyles}>
|
|
88
|
+
<Popup.Heading>Delete Item</Popup.Heading>
|
|
89
|
+
<Popup.Body>
|
|
90
|
+
<Box as="p">Are you sure you'd like to delete the item titled 'My Item'?</Box>
|
|
91
|
+
</Popup.Body>
|
|
92
|
+
<Flex cs={flexStyles}>
|
|
93
|
+
<Popup.CloseButton ref={initialFocusRef}>Cancel</Popup.CloseButton>
|
|
94
|
+
<Popup.CloseButton as={DeleteButton}>Delete</Popup.CloseButton>
|
|
95
|
+
</Flex>
|
|
96
|
+
</Popup.Card>
|
|
97
|
+
</Popup.Popper>
|
|
98
|
+
</Popup>
|
|
99
|
+
</Box>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default () => {
|
|
104
|
+
return (
|
|
105
|
+
<>
|
|
106
|
+
<Flex cs={comparisonLayoutStyles}>
|
|
107
|
+
<SingleInlinePopup overflowLabel="overflow: clip" containerStyles={clipContainerStyles} />
|
|
108
|
+
<SingleInlinePopup
|
|
109
|
+
overflowLabel="overflow: scroll"
|
|
110
|
+
containerStyles={scrollContainerStyles}
|
|
111
|
+
/>
|
|
112
|
+
<SingleInlinePopup
|
|
113
|
+
overflowLabel="overflow: visible"
|
|
114
|
+
containerStyles={visibleContainerStyles}
|
|
115
|
+
/>
|
|
116
|
+
</Flex>
|
|
117
|
+
<p>
|
|
118
|
+
With <code>overflow: visible</code>, the popup can extend past the dashed border. With{' '}
|
|
119
|
+
<code>overflow: scroll</code> (or <code>hidden</code> / <code>clip</code>), the popup is
|
|
120
|
+
constrained and any overflow is clipped. The container uses <code>position: relative</code>{' '}
|
|
121
|
+
so it establishes a containing block for the positioned popup.
|
|
122
|
+
</p>
|
|
123
|
+
</>
|
|
124
|
+
);
|
|
125
|
+
};
|
|
@@ -1,42 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Popup,
|
|
3
|
-
useCloseOnOutsideClick,
|
|
4
|
-
useCloseOnEscape,
|
|
5
|
-
usePopupModel,
|
|
6
|
-
} from '@workday/canvas-kit-react/popup';
|
|
1
|
+
import {Popup} from '@workday/canvas-kit-react/popup';
|
|
7
2
|
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
3
|
+
import {useDialogModel} from '@workday/canvas-kit-react/dialog';
|
|
4
|
+
import {useModalModel} from '@workday/canvas-kit-react/modal';
|
|
5
|
+
import {createStyles, px2rem} from '@workday/canvas-kit-styling';
|
|
6
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const flexStyles = createStyles({
|
|
9
|
+
gap: system.space.x4,
|
|
10
|
+
});
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const popupStyles = createStyles({
|
|
13
|
+
width: px2rem(400),
|
|
14
|
+
});
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
export default () => {
|
|
17
|
+
const dialogModel = useDialogModel();
|
|
18
|
+
const modalModel = useModalModel();
|
|
18
19
|
|
|
19
20
|
return (
|
|
20
|
-
<Flex
|
|
21
|
-
<Popup model={
|
|
22
|
-
<Popup.Target>
|
|
21
|
+
<Flex cs={flexStyles}>
|
|
22
|
+
<Popup model={dialogModel}>
|
|
23
|
+
<Popup.Target>Focus Redirect Popup</Popup.Target>
|
|
23
24
|
<Popup.Popper>
|
|
24
|
-
<Popup.Card
|
|
25
|
+
<Popup.Card cs={popupStyles}>
|
|
25
26
|
<Popup.CloseIcon aria-label="Close" size="small" />
|
|
27
|
+
<Popup.Heading>Focus Redirect Popup</Popup.Heading>
|
|
26
28
|
<Popup.Body>
|
|
27
|
-
<p>
|
|
29
|
+
<p>
|
|
30
|
+
This popup uses the dialog model and will allow keyboard focus to escape when users
|
|
31
|
+
press Tab or Shift + Tab.
|
|
32
|
+
</p>
|
|
28
33
|
</Popup.Body>
|
|
29
34
|
</Popup.Card>
|
|
30
35
|
</Popup.Popper>
|
|
31
36
|
</Popup>
|
|
32
|
-
<Popup model={
|
|
33
|
-
<Popup.Target>
|
|
37
|
+
<Popup model={modalModel}>
|
|
38
|
+
<Popup.Target>Focus Trap Popup</Popup.Target>
|
|
34
39
|
<Popup.Popper>
|
|
35
|
-
<Popup.Card
|
|
40
|
+
<Popup.Card cs={popupStyles}>
|
|
36
41
|
<Popup.CloseIcon aria-label="Close" size="small" />
|
|
42
|
+
<Popup.Heading>Focus Trap Popup</Popup.Heading>
|
|
37
43
|
<Popup.Body>
|
|
38
|
-
<p>
|
|
44
|
+
<p>
|
|
45
|
+
This popup uses the modal model and will trap keyboard focus when users press Tab or
|
|
46
|
+
Shift + Tab.
|
|
47
|
+
</p>
|
|
39
48
|
</Popup.Body>
|
|
49
|
+
<Flex>
|
|
50
|
+
<Popup.CloseButton>OK</Popup.CloseButton>
|
|
51
|
+
</Flex>
|
|
40
52
|
</Popup.Card>
|
|
41
53
|
</Popup.Popper>
|
|
42
54
|
</Popup>
|
package/lib/ExampleCodeBlock.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import {Prism as SyntaxHighlighter} from 'react-syntax-highlighter';
|
|
|
3
3
|
|
|
4
4
|
import {TertiaryButton} from '@workday/canvas-kit-react/button';
|
|
5
5
|
import {Card} from '@workday/canvas-kit-react/card';
|
|
6
|
-
import {
|
|
6
|
+
import {createStencil, cssVar} from '@workday/canvas-kit-styling';
|
|
7
7
|
import {system} from '@workday/canvas-tokens-web';
|
|
8
8
|
import {vscDarkPlus} from 'react-syntax-highlighter/dist/cjs/styles/prism';
|
|
9
9
|
import {checkCircleIcon, copyIcon} from '@workday/canvas-system-icons-web';
|
|
@@ -22,14 +22,20 @@ import {CanvasProvider, defaultBranding} from '@workday/canvas-kit-react/common'
|
|
|
22
22
|
|
|
23
23
|
const cardStencil = createStencil({
|
|
24
24
|
base: {
|
|
25
|
+
// Lets the block shrink inside flex/grid doc layouts so content width does not force overflow.
|
|
26
|
+
minWidth: 0,
|
|
27
|
+
maxWidth: '100%',
|
|
25
28
|
'[data-part="example-block"]': {
|
|
26
29
|
boxShadow: system.depth[1],
|
|
27
30
|
borderRadius: system.shape.x1,
|
|
28
31
|
position: 'relative',
|
|
32
|
+
minWidth: 0,
|
|
29
33
|
overflow: 'auto', // This allows for the entire ExampleCodeBlock to scroll on smaller viewports
|
|
30
34
|
},
|
|
31
35
|
'[data-part="example-block-container"]': {
|
|
36
|
+
minWidth: 0,
|
|
32
37
|
overflow: 'auto',
|
|
38
|
+
padding: system.space.x1,
|
|
33
39
|
},
|
|
34
40
|
'[data-part="code-block"]': {
|
|
35
41
|
display: 'none',
|
|
@@ -38,8 +44,9 @@ const cardStencil = createStencil({
|
|
|
38
44
|
},
|
|
39
45
|
'[data-part="code-toggle-stackblitz-btn-container"]': {
|
|
40
46
|
position: 'absolute',
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
// Keep inside the padding box; negative inset was expanding scroll overflow by ~1px.
|
|
48
|
+
right: system.space.zero,
|
|
49
|
+
bottom: system.space.zero,
|
|
43
50
|
display: 'flex',
|
|
44
51
|
gap: system.space.x2,
|
|
45
52
|
},
|
|
@@ -161,6 +168,8 @@ export const ExampleCodeBlock = ({code}: any) => {
|
|
|
161
168
|
lineHeight: cssVar(system.lineHeight.subtext.large),
|
|
162
169
|
margin: '0',
|
|
163
170
|
padding: `${cssVar(system.space.x8)} ${cssVar(system.space.x10)}`,
|
|
171
|
+
boxSizing: 'border-box',
|
|
172
|
+
maxWidth: '100%',
|
|
164
173
|
}}
|
|
165
174
|
children={code.__RAW__}
|
|
166
175
|
/>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "14.3.
|
|
3
|
+
"version": "14.3.11",
|
|
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": "^14.3.
|
|
49
|
-
"@workday/canvas-kit-preview-react": "^14.3.
|
|
50
|
-
"@workday/canvas-kit-react": "^14.3.
|
|
51
|
-
"@workday/canvas-kit-styling": "^14.3.
|
|
48
|
+
"@workday/canvas-kit-labs-react": "^14.3.11",
|
|
49
|
+
"@workday/canvas-kit-preview-react": "^14.3.11",
|
|
50
|
+
"@workday/canvas-kit-react": "^14.3.11",
|
|
51
|
+
"@workday/canvas-kit-styling": "^14.3.11",
|
|
52
52
|
"@workday/canvas-system-icons-web": "^3.0.36",
|
|
53
53
|
"@workday/canvas-tokens-web": "^3.1.6",
|
|
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": "0a0ab9c73205f581f7a50d7a2e7b7ca2af6345c1"
|
|
65
65
|
}
|