@workday/canvas-kit-docs 5.3.0-next.3 → 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.
- package/LICENSE +1 -1
- package/dist/commonjs/lib/specs.js +30 -14
- package/dist/es6/lib/specs.js +30 -14
- package/dist/mdx/CONTRIBUTING.mdx +90 -63
- package/dist/mdx/preview-react/breadcrumbs/Breadcrumbs.mdx +1 -1
- package/dist/mdx/preview-react/menu/Menu.mdx +17 -9
- package/dist/mdx/preview-react/menu/examples/Basic.tsx +65 -10
- package/dist/mdx/preview-react/menu/examples/ContextMenu.tsx +45 -29
- package/dist/mdx/preview-react/menu/examples/CustomMenuItem.tsx +2 -2
- package/dist/mdx/preview-react/menu/examples/Icons.tsx +1 -1
- package/dist/mdx/preview-react/menu/examples/ManyItems.tsx +2 -2
- package/dist/mdx/react/action-bar/ActionBar.mdx +1 -1
- package/dist/mdx/react/button/button/Button.mdx +7 -7
- package/dist/mdx/react/button/icon-button/IconButton.mdx +1 -1
- package/dist/mdx/react/pagination/PropTables.splitprops.tsx +47 -0
- package/dist/mdx/react/pagination/examples/{StepControls.tsx → Basic.tsx} +1 -1
- package/dist/mdx/react/pagination/examples/GoToForm.tsx +1 -1
- package/dist/mdx/react/pagination/examples/HoistedModel.tsx +36 -22
- package/dist/mdx/react/pagination/examples/RTL.tsx +1 -1
- package/dist/mdx/react/pagination/pagination.mdx +225 -474
- package/dist/mdx/react/popup/Popup.mdx +34 -36
- package/dist/mdx/react/radio/examples/Alert.tsx +3 -3
- package/dist/mdx/react/radio/examples/Basic.tsx +3 -3
- package/dist/mdx/react/radio/examples/Disabled.tsx +3 -3
- package/dist/mdx/react/radio/examples/Error.tsx +3 -3
- package/dist/mdx/react/radio/examples/LabelPosition.tsx +3 -3
- package/dist/mdx/react/radio/examples/NoValue.tsx +3 -3
- package/dist/mdx/react/radio/examples/RefForwarding.tsx +3 -3
- package/dist/mdx/react/radio/examples/Required.tsx +3 -3
- package/dist/mdx/react/segmented-control/SegmentedControl.mdx +1 -1
- package/dist/mdx/react/tabs/Tabs.mdx +37 -32
- package/dist/mdx/react/tabs/examples/HoistedModel.tsx +1 -1
- package/dist/mdx/react/toast/toast.mdx +1 -17
- package/dist/mdx/react/tooltip/Tooltip.mdx +1 -1
- package/dist/mdx/react/tooltip/examples/Ellipsis.tsx +6 -0
- package/package.json +3 -3
- package/dist/mdx/CODE_OF_CONDUCT.md +0 -68
- package/dist/mdx/preview-react/menu/examples/ContextMenuTarget.tsx +0 -33
- package/dist/mdx/preview-react/menu/examples/ControlButton.tsx +0 -84
- package/dist/mdx/react/pagination/examples/ShowAdditionalDetails.tsx +0 -52
|
@@ -1,49 +1,65 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {createComponent, useForkRef} from '@workday/canvas-kit-react/common';
|
|
4
4
|
import {Menu, MenuItem} from '@workday/canvas-kit-preview-react/menu';
|
|
5
5
|
import {
|
|
6
6
|
Popup,
|
|
7
|
+
PopupModelContext,
|
|
7
8
|
usePopupModel,
|
|
8
9
|
useAlwaysCloseOnOutsideClick,
|
|
9
10
|
useCloseOnEscape,
|
|
10
11
|
} from '@workday/canvas-kit-react/popup';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
const ContextMenuTarget = createComponent('div')({
|
|
14
|
+
displayName: 'Popup.ContextMenuTarget',
|
|
15
|
+
Component: ({children, ...elemProps}, ref, Element) => {
|
|
16
|
+
const model = React.useContext(PopupModelContext);
|
|
17
|
+
const elementRef = useForkRef(ref, model.state.targetRef as any);
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
const onContextMenu = (event: React.MouseEvent) => {
|
|
20
|
+
if (model.state.visibility === 'visible') {
|
|
21
|
+
model.events.hide({event});
|
|
22
|
+
} else if (model.state.visibility === 'hidden') {
|
|
23
|
+
model.events.show({event});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Prevent the default context menu from showing to avoid double menus
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
};
|
|
20
29
|
|
|
30
|
+
return (
|
|
31
|
+
<Element ref={elementRef} onContextMenu={onContextMenu} {...elemProps}>
|
|
32
|
+
{children}
|
|
33
|
+
</Element>
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export default () => {
|
|
21
39
|
const model = usePopupModel();
|
|
22
40
|
|
|
23
41
|
useAlwaysCloseOnOutsideClick(model);
|
|
24
42
|
useCloseOnEscape(model);
|
|
25
43
|
|
|
26
44
|
return (
|
|
27
|
-
<
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</Popup>
|
|
47
|
-
</CanvasProvider>
|
|
45
|
+
<Popup model={model}>
|
|
46
|
+
<ContextMenuTarget style={{display: 'inline'}} tabIndex={0}>
|
|
47
|
+
Right click on this text (Context menu target)
|
|
48
|
+
</ContextMenuTarget>
|
|
49
|
+
<Popup.Popper>
|
|
50
|
+
<Menu onClose={model.events.hide}>
|
|
51
|
+
<MenuItem>Back</MenuItem>
|
|
52
|
+
<MenuItem>Forward</MenuItem>
|
|
53
|
+
<MenuItem>Reload</MenuItem>
|
|
54
|
+
<MenuItem hasDivider>Bookmark Page</MenuItem>
|
|
55
|
+
<MenuItem>Save Page As...</MenuItem>
|
|
56
|
+
<MenuItem>Select All</MenuItem>
|
|
57
|
+
<MenuItem hasDivider>Take Screenshot</MenuItem>
|
|
58
|
+
<MenuItem hasDivider>View Page Source</MenuItem>
|
|
59
|
+
<MenuItem>Inspect Accessibility Properties</MenuItem>
|
|
60
|
+
<MenuItem>Inspect</MenuItem>
|
|
61
|
+
</Menu>
|
|
62
|
+
</Popup.Popper>
|
|
63
|
+
</Popup>
|
|
48
64
|
);
|
|
49
65
|
};
|
|
@@ -4,10 +4,10 @@ import {Menu, MenuItem} from '@workday/canvas-kit-preview-react/menu';
|
|
|
4
4
|
|
|
5
5
|
export default () => {
|
|
6
6
|
return (
|
|
7
|
-
<Menu
|
|
7
|
+
<Menu>
|
|
8
8
|
<MenuItem>First Item</MenuItem>
|
|
9
9
|
<MenuItem>Second Item</MenuItem>
|
|
10
|
-
<li role="
|
|
10
|
+
<li role="menuitem" tabIndex={-1} style={{listStyle: 'none'}}>
|
|
11
11
|
Third Item (custom)
|
|
12
12
|
</li>
|
|
13
13
|
</Menu>
|
|
@@ -10,7 +10,7 @@ import {Menu, MenuItem} from '@workday/canvas-kit-preview-react/menu';
|
|
|
10
10
|
|
|
11
11
|
export default () => {
|
|
12
12
|
return (
|
|
13
|
-
<Menu
|
|
13
|
+
<Menu>
|
|
14
14
|
<MenuItem icon={uploadCloudIcon}>First Item</MenuItem>
|
|
15
15
|
<MenuItem icon={setupIcon}>Second Item (with a really really really long label)</MenuItem>
|
|
16
16
|
<MenuItem isDisabled icon={uploadCloudIcon} secondaryIcon={taskContactIcon}>
|
|
@@ -4,11 +4,11 @@ import {Menu, MenuItem} from '@workday/canvas-kit-preview-react/menu';
|
|
|
4
4
|
|
|
5
5
|
export default () => {
|
|
6
6
|
return (
|
|
7
|
-
<Menu
|
|
7
|
+
<Menu>
|
|
8
8
|
{'One Two Three Four Five Six Seven Eight Nine Ten Eleven Twelve Thirteen Fourteen Fifteen'
|
|
9
9
|
.split(' ')
|
|
10
10
|
.map(item => {
|
|
11
|
-
return <MenuItem>Item {item}</MenuItem>;
|
|
11
|
+
return <MenuItem key={item}>Item {item}</MenuItem>;
|
|
12
12
|
})}
|
|
13
13
|
</Menu>
|
|
14
14
|
);
|
|
@@ -39,7 +39,7 @@ should take. Not all screens require a Primary Button.
|
|
|
39
39
|
|
|
40
40
|
#### Props
|
|
41
41
|
|
|
42
|
-
Undocumented props are spread to the underlying
|
|
42
|
+
Undocumented props are spread to the underlying `<button>` element.
|
|
43
43
|
|
|
44
44
|
<ArgsTable of={PrimaryButton} />
|
|
45
45
|
|
|
@@ -55,7 +55,7 @@ Use the `inverse` variants on dark or colorful backgrounds.
|
|
|
55
55
|
|
|
56
56
|
#### Props
|
|
57
57
|
|
|
58
|
-
Undocumented props are spread to the underlying
|
|
58
|
+
Undocumented props are spread to the underlying `<button>` element.
|
|
59
59
|
|
|
60
60
|
<ArgsTable of={SecondaryButton} />
|
|
61
61
|
|
|
@@ -72,7 +72,7 @@ Use the `inverse` variants on dark or colorful backgrounds.
|
|
|
72
72
|
|
|
73
73
|
#### Props
|
|
74
74
|
|
|
75
|
-
Undocumented props are spread to the underlying
|
|
75
|
+
Undocumented props are spread to the underlying `<button>` element.
|
|
76
76
|
|
|
77
77
|
<ArgsTable of={TertiaryButton} />
|
|
78
78
|
|
|
@@ -86,16 +86,16 @@ before deleting.
|
|
|
86
86
|
|
|
87
87
|
#### Props
|
|
88
88
|
|
|
89
|
-
Undocumented props are spread to the underlying
|
|
89
|
+
Undocumented props are spread to the underlying `<button>` element.
|
|
90
90
|
|
|
91
91
|
<ArgsTable of={DeleteButton} />
|
|
92
92
|
|
|
93
93
|
### Accessible Use of the `as` Prop
|
|
94
94
|
|
|
95
95
|
Like many of our components, Buttons accept an `as` prop, which lets you change the underlying
|
|
96
|
-
semantic element - usually an
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
semantic element - usually an `<a>`, or a `<button>`. This should be done with caution to ensure the
|
|
97
|
+
best accessibility. Generally, `<button>` elements should be used for actions, and `<a>` elements
|
|
98
|
+
should be used for navigation.
|
|
99
99
|
|
|
100
100
|
## Specifications
|
|
101
101
|
|
|
@@ -98,6 +98,6 @@ The `toggle` prop can be used to make icon buttons toggleable.
|
|
|
98
98
|
|
|
99
99
|
## Props
|
|
100
100
|
|
|
101
|
-
Undocumented props are spread to the underlying
|
|
101
|
+
Undocumented props are spread to the underlying `<button>` element.
|
|
102
102
|
|
|
103
103
|
<ArgsTable of={IconButton} />
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PaginationModel,
|
|
3
|
+
PaginationState,
|
|
4
|
+
PaginationEvents,
|
|
5
|
+
UsePaginationModelConfig,
|
|
6
|
+
} from '@workday/canvas-kit-react/pagination';
|
|
7
|
+
|
|
8
|
+
// <ArgsTable of={Pagination} /> generates a very large props table given that
|
|
9
|
+
// PaginationProps includes FlexProps. Use this dummy component instead to
|
|
10
|
+
// limit the props shown.
|
|
11
|
+
export const PaginationHoistedComponent = (_: {model: PaginationModel}) => <div />;
|
|
12
|
+
|
|
13
|
+
// <ArgsTable of={Pagination.PageButton} /> generates a props table with
|
|
14
|
+
// IconButton props. Use this dummy component instead to limit the props shown.
|
|
15
|
+
export const PageButtonComponent = (_: {pageNumber: number}) => <div />;
|
|
16
|
+
|
|
17
|
+
// <ArgsTable of={Pagination.PageListComponent} /> generates a very large props
|
|
18
|
+
// table given that PageListProps includes FlexProps. Use this dummy component
|
|
19
|
+
// instead to limit the props shown.
|
|
20
|
+
export const PageListComponent = (_: {
|
|
21
|
+
/**
|
|
22
|
+
* Accepts child elements or a render prop.
|
|
23
|
+
*/
|
|
24
|
+
children: (model: PaginationModel) => React.ReactNode | React.ReactNode;
|
|
25
|
+
}) => <div />;
|
|
26
|
+
|
|
27
|
+
// <ArgsTable of={Pagination.AdditionalDetails} /> generates a very large props
|
|
28
|
+
// table given that AdditionalDetailsProps includes FlexProps. Use this dummy
|
|
29
|
+
// component instead to limit the props shown.
|
|
30
|
+
export const AdditionalDetailsComponent = (_: {
|
|
31
|
+
/**
|
|
32
|
+
* Accepts child elements or a render prop.
|
|
33
|
+
*/
|
|
34
|
+
children: (model: PaginationModel) => React.ReactNode | React.ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
shouldAnnounceToScreenReader?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
shouldHideDetails?: boolean;
|
|
43
|
+
}) => <div />;
|
|
44
|
+
|
|
45
|
+
export const PaginationModelConfigComponent = (_: UsePaginationModelConfig) => <div />;
|
|
46
|
+
export const PaginationStateComponent = (_: PaginationState) => <div />;
|
|
47
|
+
export const PaginationEventsComponent = (_: PaginationEvents) => <div />;
|
|
@@ -30,7 +30,7 @@ export default () => {
|
|
|
30
30
|
</Pagination.PageList>
|
|
31
31
|
<Pagination.StepToNextButton aria-label="Next" />
|
|
32
32
|
</Pagination.Controls>
|
|
33
|
-
<Pagination.AdditionalDetails
|
|
33
|
+
<Pagination.AdditionalDetails>
|
|
34
34
|
{({state}) =>
|
|
35
35
|
`${getVisibleResultsMin(state.currentPage, resultCount)}-${getVisibleResultsMax(
|
|
36
36
|
state.currentPage,
|
|
@@ -33,7 +33,7 @@ export default () => {
|
|
|
33
33
|
<Pagination.JumpToLastButton aria-label="Last" />
|
|
34
34
|
<Pagination.GoToForm>
|
|
35
35
|
<Pagination.GoToTextInput aria-label="Go to page number" />
|
|
36
|
-
<Pagination.GoToLabel>{({state}) => `of ${
|
|
36
|
+
<Pagination.GoToLabel>{({state}) => `of ${state.lastPage} pages`}</Pagination.GoToLabel>
|
|
37
37
|
</Pagination.GoToForm>
|
|
38
38
|
</Pagination.Controls>
|
|
39
39
|
<Pagination.AdditionalDetails shouldHideDetails>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
2
3
|
import {
|
|
3
4
|
Pagination,
|
|
4
5
|
getLastPage,
|
|
@@ -16,30 +17,43 @@ export default () => {
|
|
|
16
17
|
lastPage,
|
|
17
18
|
onPageChange: number => console.log(number),
|
|
18
19
|
});
|
|
20
|
+
|
|
19
21
|
return (
|
|
20
|
-
|
|
21
|
-
<Pagination
|
|
22
|
-
<Pagination.
|
|
23
|
-
|
|
22
|
+
<>
|
|
23
|
+
<Pagination aria-label="Pagination" model={model}>
|
|
24
|
+
<Pagination.Controls>
|
|
25
|
+
<Pagination.StepToPreviousButton aria-label="Previous" />
|
|
26
|
+
<Pagination.PageList>
|
|
27
|
+
{({state}) =>
|
|
28
|
+
state.range.map(pageNumber => (
|
|
29
|
+
<Pagination.PageListItem key={pageNumber}>
|
|
30
|
+
<Pagination.PageButton
|
|
31
|
+
aria-label={`Page ${pageNumber}`}
|
|
32
|
+
pageNumber={pageNumber}
|
|
33
|
+
/>
|
|
34
|
+
</Pagination.PageListItem>
|
|
35
|
+
))
|
|
36
|
+
}
|
|
37
|
+
</Pagination.PageList>
|
|
38
|
+
<Pagination.StepToNextButton aria-label="Next" />
|
|
39
|
+
</Pagination.Controls>
|
|
40
|
+
<Pagination.AdditionalDetails shouldHideDetails>
|
|
24
41
|
{({state}) =>
|
|
25
|
-
state.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
)
|
|
42
|
+
`${getVisibleResultsMin(state.currentPage, resultCount)}-${getVisibleResultsMax(
|
|
43
|
+
state.currentPage,
|
|
44
|
+
resultCount,
|
|
45
|
+
totalCount
|
|
46
|
+
)} of ${totalCount} results`
|
|
30
47
|
}
|
|
31
|
-
</Pagination.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
</Pagination.AdditionalDetails>
|
|
43
|
-
</Pagination>
|
|
48
|
+
</Pagination.AdditionalDetails>
|
|
49
|
+
</Pagination>
|
|
50
|
+
<SecondaryButton
|
|
51
|
+
onClick={() => {
|
|
52
|
+
model.events.goTo(7);
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
Go to Page 7
|
|
56
|
+
</SecondaryButton>
|
|
57
|
+
</>
|
|
44
58
|
);
|
|
45
59
|
};
|
|
@@ -36,7 +36,7 @@ export default () => {
|
|
|
36
36
|
<Pagination.JumpToLastButton aria-label="Last" />
|
|
37
37
|
<Pagination.GoToForm>
|
|
38
38
|
<Pagination.GoToTextInput aria-label="Go to page number" />
|
|
39
|
-
<Pagination.GoToLabel>{() =>
|
|
39
|
+
<Pagination.GoToLabel>{({state}) => `از ${state.lastPage} صفحه`}</Pagination.GoToLabel>
|
|
40
40
|
</Pagination.GoToForm>
|
|
41
41
|
</Pagination.Controls>
|
|
42
42
|
<Pagination.AdditionalDetails shouldHideDetails>
|