@workday/canvas-kit-docs 14.0.0 → 14.0.2
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/stackblitzFiles/packageJSONFile.js +5 -5
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.ts +5 -5
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/FilterListWithLiveStatus.d.ts +2 -0
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/FilterListWithLiveStatus.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/FilterListWithLiveStatus.js +43 -0
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/HiddenLiveRegion.d.ts +2 -0
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/HiddenLiveRegion.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/HiddenLiveRegion.js +27 -0
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/IconButtonsWithLiveBadges.d.ts +2 -0
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/IconButtonsWithLiveBadges.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/IconButtonsWithLiveBadges.js +51 -0
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/TextInputWithLiveError.d.ts +2 -0
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/TextInputWithLiveError.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/TextInputWithLiveError.js +19 -0
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/VisibleLiveRegion.d.ts +2 -0
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/VisibleLiveRegion.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/VisibleLiveRegion.js +36 -0
- package/dist/es6/mdx/accessibility/examples/GlobalHeader.d.ts +8 -0
- package/dist/es6/mdx/accessibility/examples/GlobalHeader.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/GlobalHeader.js +149 -0
- package/dist/es6/mdx/accessibility/examples/PageStructure/BreadcrumbNavRegion.d.ts +2 -0
- package/dist/es6/mdx/accessibility/examples/PageStructure/BreadcrumbNavRegion.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/PageStructure/BreadcrumbNavRegion.js +12 -0
- package/dist/es6/mdx/accessibility/examples/PageStructure/FullPageDemo.d.ts +2 -0
- package/dist/es6/mdx/accessibility/examples/PageStructure/FullPageDemo.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/PageStructure/FullPageDemo.js +40 -0
- package/dist/es6/mdx/accessibility/examples/PageStructure/LandmarkRegions.d.ts +2 -0
- package/dist/es6/mdx/accessibility/examples/PageStructure/LandmarkRegions.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/PageStructure/LandmarkRegions.js +22 -0
- package/dist/es6/mdx/accessibility/examples/SidePanelWithNavigation.d.ts +3 -0
- package/dist/es6/mdx/accessibility/examples/SidePanelWithNavigation.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/SidePanelWithNavigation.js +100 -0
- package/dist/es6/mdx/accessibility/examples/SidePanelWithOverlay.d.ts +2 -0
- package/dist/es6/mdx/accessibility/examples/SidePanelWithOverlay.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/SidePanelWithOverlay.js +31 -0
- package/dist/es6/mdx/accessibility/examples/Table/WithColumnHeaderFilters.d.ts +2 -0
- package/dist/es6/mdx/accessibility/examples/Table/WithColumnHeaderFilters.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/Table/WithColumnHeaderFilters.js +101 -0
- package/dist/es6/mdx/accessibility/examples/Table/WithExpandableRows.d.ts +2 -0
- package/dist/es6/mdx/accessibility/examples/Table/WithExpandableRows.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/Table/WithExpandableRows.js +115 -0
- package/dist/es6/mdx/accessibility/examples/Table/WithFormFields.d.ts +2 -0
- package/dist/es6/mdx/accessibility/examples/Table/WithFormFields.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/Table/WithFormFields.js +79 -0
- package/dist/es6/mdx/accessibility/examples/Table/WithSelectableRows.d.ts +2 -0
- package/dist/es6/mdx/accessibility/examples/Table/WithSelectableRows.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/Table/WithSelectableRows.js +89 -0
- package/dist/es6/mdx/accessibility/examples/Table/WithSortableColumnHeaders.d.ts +2 -0
- package/dist/es6/mdx/accessibility/examples/Table/WithSortableColumnHeaders.d.ts.map +1 -0
- package/dist/es6/mdx/accessibility/examples/Table/WithSortableColumnHeaders.js +114 -0
- package/dist/mdx/accessibility/AccessibilityOverview.mdx +167 -0
- package/dist/mdx/accessibility/AccessibilityTesting.mdx +10 -0
- package/dist/mdx/{react/_examples/mdx → accessibility}/Headers.mdx +0 -1
- package/dist/mdx/accessibility/PageStructure.mdx +58 -0
- package/dist/mdx/{react/_examples/mdx → accessibility}/SidePanel.mdx +1 -6
- package/dist/mdx/{react/_examples/mdx → accessibility}/TablesAdvanced.mdx +11 -0
- package/dist/mdx/accessibility/WindowsHighContrastThemes.mdx +97 -0
- package/dist/mdx/react/layout/examples/Grid/Basic.tsx +41 -60
- package/package.json +6 -6
- package/dist/mdx/react/_examples/mdx/AccessibilityOverview.mdx +0 -18
- package/dist/mdx/react/_examples/mdx/examples/AriaLiveRegions/FilterListWithLiveStatus.tsx +0 -73
- package/dist/mdx/react/_examples/mdx/examples/AriaLiveRegions/HiddenLiveRegion.tsx +0 -46
- package/dist/mdx/react/_examples/mdx/examples/AriaLiveRegions/IconButtonsWithLiveBadges.tsx +0 -98
- package/dist/mdx/react/_examples/mdx/examples/AriaLiveRegions/TextInputWithLiveError.tsx +0 -31
- package/dist/mdx/react/_examples/mdx/examples/AriaLiveRegions/VisibleLiveRegion.tsx +0 -61
- package/dist/mdx/react/_examples/mdx/examples/GlobalHeader.tsx +0 -295
- package/dist/mdx/react/_examples/mdx/examples/SidePanelWithNavigation.tsx +0 -168
- package/dist/mdx/react/_examples/mdx/examples/SidePanelWithOverlay.tsx +0 -46
- package/dist/mdx/react/_examples/mdx/examples/Table/WithColumnHeaderFilters.tsx +0 -202
- package/dist/mdx/react/_examples/mdx/examples/Table/WithExpandableRows.tsx +0 -216
- package/dist/mdx/react/_examples/mdx/examples/Table/WithSelectableRows.tsx +0 -156
- package/dist/mdx/react/_examples/mdx/examples/Table/WithSortableColumnHeaders.tsx +0 -213
- package/dist/mdx/react/_examples/mdx/examples/common/FilterListWithLiveStatus.tsx +0 -68
- package/dist/mdx/react/_examples/mdx/examples/common/HiddenLiveRegion.tsx +0 -33
- package/dist/mdx/react/_examples/mdx/examples/common/IconButtonsWithLiveBadges.tsx +0 -98
- package/dist/mdx/react/_examples/mdx/examples/common/TextInputWithLiveError.tsx +0 -28
- package/dist/mdx/react/_examples/mdx/examples/common/VisibleLiveRegion.tsx +0 -44
- /package/dist/mdx/{react/_examples/mdx → accessibility}/AriaLiveRegions.mdx +0 -0
- /package/dist/mdx/react/_examples/{examples/Tooltips → mdx/examples}/ListOfUploadedFiles.tsx +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { system } from '@workday/canvas-tokens-web';
|
|
4
|
+
import { SidePanel, useSidePanel } from '@workday/canvas-kit-preview-react/side-panel';
|
|
5
|
+
import { Flex } from '@workday/canvas-kit-react/layout';
|
|
6
|
+
import { Heading, Subtext } from '@workday/canvas-kit-react/text';
|
|
7
|
+
import { Expandable } from '@workday/canvas-kit-react/expandable';
|
|
8
|
+
import { SystemIcon } from '@workday/canvas-kit-react/icon';
|
|
9
|
+
import { TertiaryButton } from '@workday/canvas-kit-react/button';
|
|
10
|
+
import { Menu } from '@workday/canvas-kit-react/menu';
|
|
11
|
+
import { birthdayIcon, checkIcon, ribbonIcon } from '@workday/canvas-system-icons-web';
|
|
12
|
+
import { createStyles, px2rem } from '@workday/canvas-kit-styling';
|
|
13
|
+
import { Tooltip } from '@workday/canvas-kit-react/tooltip';
|
|
14
|
+
const data = {
|
|
15
|
+
bestsellers: {
|
|
16
|
+
icon: ribbonIcon,
|
|
17
|
+
title: 'Best Sellers',
|
|
18
|
+
subtitle: 'Award winning sweet treats',
|
|
19
|
+
items: ['Mango Coco Sago', 'Matcha Creme Pie', 'Key Lime Cheesecake', 'Tiramisu'],
|
|
20
|
+
},
|
|
21
|
+
cakes: {
|
|
22
|
+
icon: birthdayIcon,
|
|
23
|
+
title: 'Custom Cakes',
|
|
24
|
+
subtitle: 'To celebrate your life milestones',
|
|
25
|
+
items: ['Anniversary', 'Birthday', 'Graduation', 'Wedding'],
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
const stylesOverride = {
|
|
29
|
+
navContainer: createStyles({
|
|
30
|
+
height: px2rem(800),
|
|
31
|
+
positio: 'relative',
|
|
32
|
+
backgroundColor: system.color.bg.alt.default,
|
|
33
|
+
}),
|
|
34
|
+
heading: createStyles({
|
|
35
|
+
margin: system.space.zero,
|
|
36
|
+
}),
|
|
37
|
+
toggleBtn: createStyles({
|
|
38
|
+
top: system.space.zero,
|
|
39
|
+
}),
|
|
40
|
+
accordionContainer: createStyles({
|
|
41
|
+
listStyle: 'none',
|
|
42
|
+
flexDirection: 'column',
|
|
43
|
+
rowGap: system.space.zero,
|
|
44
|
+
paddingInlineStart: system.space.zero,
|
|
45
|
+
}),
|
|
46
|
+
accordionIcon: createStyles({
|
|
47
|
+
verticalAlign: 'middle',
|
|
48
|
+
padding: system.space.x1,
|
|
49
|
+
}),
|
|
50
|
+
accordionSubText: createStyles({
|
|
51
|
+
margin: system.space.zero,
|
|
52
|
+
}),
|
|
53
|
+
listContainer: createStyles({
|
|
54
|
+
listStyle: 'none',
|
|
55
|
+
padding: system.space.x4,
|
|
56
|
+
}),
|
|
57
|
+
compactListContainer: createStyles({
|
|
58
|
+
listStyle: 'none',
|
|
59
|
+
padding: system.space.x4,
|
|
60
|
+
flexDirection: 'column',
|
|
61
|
+
marginTop: system.space.x8,
|
|
62
|
+
}),
|
|
63
|
+
links: createStyles({
|
|
64
|
+
textDecoration: 'none',
|
|
65
|
+
padding: system.space.x4,
|
|
66
|
+
}),
|
|
67
|
+
linkCheck: createStyles({
|
|
68
|
+
marginLeft: 'auto',
|
|
69
|
+
}),
|
|
70
|
+
flyOut: createStyles({
|
|
71
|
+
marginTop: '8rem',
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
74
|
+
const Accordion = ({ config }) => {
|
|
75
|
+
const [currentPage, setCurrentPage] = React.useState('');
|
|
76
|
+
const handleClick = (e) => {
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
const target = e.target;
|
|
79
|
+
setCurrentPage(target.textContent || '');
|
|
80
|
+
};
|
|
81
|
+
return (_jsxs(Expandable, { children: [_jsxs(Expandable.Target, { children: [_jsx(SystemIcon, { cs: stylesOverride.accordionIcon, icon: config.icon }), _jsxs(Expandable.Title, { children: [config.title, _jsx(Subtext, { size: "medium", cs: stylesOverride.accordionSubText, children: config.subtitle })] }), _jsx(Expandable.Icon, { iconPosition: "end" })] }), _jsx(Expandable.Content, { as: "ul", cs: stylesOverride.listContainer, children: config.items.map((i) => {
|
|
82
|
+
return (_jsx("li", { children: _jsxs(Flex, { as: "a", href: "#", "aria-current": i === currentPage ? 'true' : undefined, className: stylesOverride.links, onClick: handleClick, children: [i, i === currentPage && _jsx(SystemIcon, { icon: checkIcon, cs: stylesOverride.linkCheck })] }) }, i));
|
|
83
|
+
}) })] }));
|
|
84
|
+
};
|
|
85
|
+
const IconButtonMenu = ({ config }) => {
|
|
86
|
+
return (_jsxs(Menu, { children: [_jsx(Tooltip, { title: config.title, placement: "right", children: _jsx(Menu.Target, { as: TertiaryButton, children: _jsx(SystemIcon, { icon: config.icon }) }) }), _jsx(Menu.Popper, { placement: "right", children: _jsx(Menu.Card, { cs: stylesOverride.flyOut, children: _jsx(Menu.List, { children: config.items.map((i) => (_jsx(Menu.Item, { children: i }, i))) }) }) })] }));
|
|
87
|
+
};
|
|
88
|
+
const CompactView = () => {
|
|
89
|
+
return (_jsxs(Flex, { as: "ul", cs: stylesOverride.compactListContainer, children: [_jsx(Flex.Item, { as: "li", children: _jsx(IconButtonMenu, { config: data.bestsellers }) }), _jsx(Flex.Item, { as: "li", children: _jsx(IconButtonMenu, { config: data.cakes }) })] }));
|
|
90
|
+
};
|
|
91
|
+
const ExpandedView = () => {
|
|
92
|
+
return (_jsxs(Flex, { as: "ul", cs: stylesOverride.accordionContainer, children: [_jsx(Flex.Item, { as: "li", children: _jsx(Accordion, { config: data.bestsellers }) }), _jsx(Flex.Item, { as: "li", children: _jsx(Accordion, { config: data.cakes }) })] }));
|
|
93
|
+
};
|
|
94
|
+
export const SideBarContent = () => {
|
|
95
|
+
const { expanded, panelProps, labelProps, controlProps } = useSidePanel();
|
|
96
|
+
return (_jsxs(SidePanel, { as: "div", touched: panelProps.touched, expanded: panelProps.expanded, children: [_jsx(Heading, { size: "small", cs: stylesOverride.heading, ...labelProps, hidden: !expanded ? true : undefined, children: "Cake or Death Bakery" }), _jsx(SidePanel.ToggleButton, { cs: stylesOverride.toggleBtn, ...controlProps }), expanded ? _jsx(ExpandedView, {}) : _jsx(CompactView, {})] }));
|
|
97
|
+
};
|
|
98
|
+
export const WithNavigation = () => {
|
|
99
|
+
return (_jsx(Flex, { as: "nav", cs: stylesOverride.navContainer, children: _jsx(SideBarContent, {}) }));
|
|
100
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidePanelWithOverlay.d.ts","sourceRoot":"","sources":["../../../../../mdx/accessibility/examples/SidePanelWithOverlay.tsx"],"names":[],"mappings":"AA4BA,eAAO,MAAM,WAAW,+CAgBvB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SidePanel, useSidePanel } from '@workday/canvas-kit-preview-react/side-panel';
|
|
3
|
+
import { Flex, Box } from '@workday/canvas-kit-react/layout';
|
|
4
|
+
import { Heading } from '@workday/canvas-kit-react/text';
|
|
5
|
+
import { createStyles, px2rem } from '@workday/canvas-kit-styling';
|
|
6
|
+
import { system } from '@workday/canvas-tokens-web';
|
|
7
|
+
const stylesOverride = {
|
|
8
|
+
panelContainer: createStyles({
|
|
9
|
+
height: px2rem(320),
|
|
10
|
+
backgroundColor: system.color.bg.alt.soft,
|
|
11
|
+
position: 'relative',
|
|
12
|
+
}),
|
|
13
|
+
panelContent: createStyles({
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
paddingY: system.space.x4,
|
|
16
|
+
paddingX: system.space.x4,
|
|
17
|
+
}),
|
|
18
|
+
panel: createStyles({
|
|
19
|
+
zIndex: 1,
|
|
20
|
+
}),
|
|
21
|
+
overlay: createStyles({
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
background: system.color.bg.overlay,
|
|
24
|
+
height: '100%',
|
|
25
|
+
width: '100%',
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
export const WithOverlay = () => {
|
|
29
|
+
const { expanded, panelProps, labelProps, controlProps } = useSidePanel();
|
|
30
|
+
return (_jsxs(Flex, { cs: stylesOverride.panelContainer, children: [_jsx(SidePanel, { className: stylesOverride.panel, ...panelProps, variant: "alternate", children: _jsxs(Flex, { cs: stylesOverride.panelContainer, children: [_jsx(Heading, { size: "small", ...labelProps, hidden: !expanded ? true : undefined, children: "Alternate Panel" }), _jsx(SidePanel.ToggleButton, { ...controlProps })] }) }), expanded && _jsx(Box, { cs: stylesOverride.overlay })] }));
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithColumnHeaderFilters.d.ts","sourceRoot":"","sources":["../../../../../../mdx/accessibility/examples/Table/WithColumnHeaderFilters.tsx"],"names":[],"mappings":"AAsJA,eAAO,MAAM,uBAAuB,+CAyDnC,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { AriaLiveRegion, createComponent, useUniqueId } from '@workday/canvas-kit-react/common';
|
|
4
|
+
import { Flex } from '@workday/canvas-kit-react/layout';
|
|
5
|
+
import { FormField } from '@workday/canvas-kit-react/form-field';
|
|
6
|
+
import { InputGroup, TextInput } from '@workday/canvas-kit-react/text-input';
|
|
7
|
+
import { Popup, usePopupModel, useCloseOnOutsideClick, useCloseOnEscape, useInitialFocus, useReturnFocus, useFocusRedirect, } from '@workday/canvas-kit-react/popup';
|
|
8
|
+
import { PrimaryButton, TertiaryButton } from '@workday/canvas-kit-react/button';
|
|
9
|
+
import { Table } from '@workday/canvas-kit-react/table';
|
|
10
|
+
import { Text } from '@workday/canvas-kit-react/text';
|
|
11
|
+
import { SystemIcon } from '@workday/canvas-kit-react/icon';
|
|
12
|
+
import { Tooltip } from '@workday/canvas-kit-react/tooltip';
|
|
13
|
+
import { createStyles } from '@workday/canvas-kit-styling';
|
|
14
|
+
import { system } from '@workday/canvas-tokens-web';
|
|
15
|
+
import { filterIcon, searchIcon } from '@workday/canvas-system-icons-web';
|
|
16
|
+
const countryData = [
|
|
17
|
+
{ country: 'Australia', capital: 'Canberra', population: 25690000 },
|
|
18
|
+
{ country: 'Bahamas', capital: 'Nassau', population: 407906 },
|
|
19
|
+
{ country: 'Canada', capital: 'Ottawa', population: 38250000 },
|
|
20
|
+
{ country: 'Fiji', capital: 'Suva', population: 924610 },
|
|
21
|
+
{ country: 'Ghana', capital: 'Accra', population: 32830000 },
|
|
22
|
+
{ country: 'Hong Kong', capital: 'City of Victoria', population: 7413000 },
|
|
23
|
+
{ country: 'India', capital: 'New Delhi', population: 1408000000 },
|
|
24
|
+
{ country: 'Ireland', capital: 'Dublin', population: 5033000 },
|
|
25
|
+
{ country: 'Jamaica', capital: 'Kingston', population: 2828000 },
|
|
26
|
+
{ country: 'Kenya', capital: 'Nairobi', population: 53010000 },
|
|
27
|
+
{ country: 'Micronesia', capital: 'Palikir', population: 113131 },
|
|
28
|
+
{ country: 'New Zealand', capital: 'Wellington', population: 5123000 },
|
|
29
|
+
{ country: 'Philippines', capital: 'Manila', population: 113900000 },
|
|
30
|
+
{ country: 'Puerto Rico', capital: 'San Juan', population: 3264000 },
|
|
31
|
+
{ country: 'Samoa', capital: 'Apia', population: 218764 },
|
|
32
|
+
{ country: 'Singapore', capital: 'Singapore', population: 5454000 },
|
|
33
|
+
{ country: 'Tanzania', capital: 'Dodoma', population: 63590000 },
|
|
34
|
+
{ country: 'United Kingdom', capital: 'London', population: 67330000 },
|
|
35
|
+
{ country: 'United States', capital: 'Washington, D.C.', population: 331900000 },
|
|
36
|
+
{ country: 'Zimbabwe', capital: 'Harare', population: 15990000 },
|
|
37
|
+
];
|
|
38
|
+
const textStyles = createStyles({
|
|
39
|
+
paddingInlineStart: system.space.x3,
|
|
40
|
+
});
|
|
41
|
+
const FilterableColumnHeader = createComponent('th')({
|
|
42
|
+
displayName: 'FilterableColumnHeader',
|
|
43
|
+
Component: ({ label, onFilter }, ref) => {
|
|
44
|
+
const [inputVal, setInputVal] = React.useState('');
|
|
45
|
+
const targetId = useUniqueId();
|
|
46
|
+
const popupId = useUniqueId();
|
|
47
|
+
const initialFocusRef = React.useRef(null);
|
|
48
|
+
const filterPopupModel = usePopupModel({
|
|
49
|
+
initialFocusRef,
|
|
50
|
+
});
|
|
51
|
+
useCloseOnOutsideClick(filterPopupModel);
|
|
52
|
+
useCloseOnEscape(filterPopupModel);
|
|
53
|
+
useInitialFocus(filterPopupModel);
|
|
54
|
+
useFocusRedirect(filterPopupModel);
|
|
55
|
+
useReturnFocus(filterPopupModel);
|
|
56
|
+
function handleChange(e) {
|
|
57
|
+
const newVal = e.target.value;
|
|
58
|
+
setInputVal(newVal);
|
|
59
|
+
onFilter({ filterText: newVal, column: label.toLowerCase() });
|
|
60
|
+
}
|
|
61
|
+
return (_jsx(Table.Header, { scope: "col", "aria-owns": targetId + ' ' + popupId, children: _jsxs(Popup, { model: filterPopupModel, children: [_jsx(Tooltip, { title: `Filter${inputVal !== '' ? `ed: "${inputVal}"` : ''}`, type: "description", children: _jsx(Popup.Target, { as: TertiaryButton, id: targetId, icon: inputVal === '' ? searchIcon : filterIcon, iconPosition: "end", children: label }) }), _jsx(Popup.Popper, { children: _jsxs(Popup.Card, { id: popupId, children: [_jsx(Popup.Heading, { children: "Filter" }), _jsx(Popup.Body, { children: _jsxs(FormField, { children: [_jsx(FormField.Label, { children: label }), _jsxs(FormField.Input, { as: InputGroup, children: [_jsx(InputGroup.InnerStart, { children: _jsx(SystemIcon, { icon: searchIcon }) }), _jsx(InputGroup.Input, { as: TextInput, type: "search", ref: initialFocusRef, onChange: handleChange, value: inputVal })] })] }) }), _jsx(Flex, { children: _jsx(Popup.CloseButton, { as: PrimaryButton, children: "Done" }) })] }) })] }) }));
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
function filterTableData(data, filters) {
|
|
65
|
+
return data.filter(item => {
|
|
66
|
+
for (const key in filters) {
|
|
67
|
+
if (filters.hasOwnProperty(key) && filters[key]) {
|
|
68
|
+
const filterText = filters[key].toLowerCase();
|
|
69
|
+
const itemValue = String(item[key]).toLowerCase();
|
|
70
|
+
if (!itemValue.includes(filterText)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
export const FilterableColumnHeaders = () => {
|
|
79
|
+
const [filteredData, setFilteredData] = React.useState(countryData);
|
|
80
|
+
const [colFilters, setColFilters] = React.useState({
|
|
81
|
+
country: '',
|
|
82
|
+
capital: '',
|
|
83
|
+
population: '',
|
|
84
|
+
});
|
|
85
|
+
React.useEffect(() => {
|
|
86
|
+
setFilteredData(filterTableData(countryData, colFilters));
|
|
87
|
+
}, [colFilters]);
|
|
88
|
+
let typingDelay;
|
|
89
|
+
function handleColFilters({ filterText, column }) {
|
|
90
|
+
clearTimeout(typingDelay);
|
|
91
|
+
typingDelay = setTimeout(() => {
|
|
92
|
+
setColFilters(prev => {
|
|
93
|
+
const newState = { ...prev, [column]: filterText };
|
|
94
|
+
return newState;
|
|
95
|
+
});
|
|
96
|
+
}, 400);
|
|
97
|
+
}
|
|
98
|
+
return (_jsxs(Table, { maxHeight: "40rem", children: [_jsxs(Table.Caption, { children: ["Population Listed by Country (2021)", _jsxs(AriaLiveRegion, { cs: textStyles, children: [filteredData.length, " of ", countryData.length, " items"] })] }), _jsx(Table.Head, { children: _jsxs(Table.Row, { children: [_jsx(FilterableColumnHeader, { label: "Country", onFilter: handleColFilters }), _jsx(FilterableColumnHeader, { label: "Capital", onFilter: handleColFilters }), _jsx(FilterableColumnHeader, { label: "Population", onFilter: handleColFilters })] }) }), _jsx(Table.Body, { children: filteredData.map(item => {
|
|
99
|
+
return (_jsxs(Table.Row, { children: [_jsx(Table.Header, { scope: "row", children: _jsx(Text, { cs: textStyles, children: item.country }) }), _jsx(Table.Cell, { children: _jsx(Text, { cs: textStyles, children: item.capital }) }), _jsx(Table.Cell, { children: _jsx(Text, { cs: textStyles, children: item.population.toLocaleString() }) })] }, item.country));
|
|
100
|
+
}) })] }));
|
|
101
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithExpandableRows.d.ts","sourceRoot":"","sources":["../../../../../../mdx/accessibility/examples/Table/WithExpandableRows.tsx"],"names":[],"mappings":"AA+LA,eAAO,MAAM,cAAc,+CAwB1B,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { StatusIndicator } from '@workday/canvas-kit-preview-react/status-indicator';
|
|
4
|
+
import { Table } from '@workday/canvas-kit-react/table';
|
|
5
|
+
import { TertiaryButton } from '@workday/canvas-kit-react/button';
|
|
6
|
+
import { generateUniqueId } from '@workday/canvas-kit-react/common';
|
|
7
|
+
import { Heading, Subtext } from '@workday/canvas-kit-react/text';
|
|
8
|
+
import { Tooltip } from '@workday/canvas-kit-react/tooltip';
|
|
9
|
+
import { createStyles } from '@workday/canvas-kit-styling';
|
|
10
|
+
import { chevronDownSmallIcon, chevronRightSmallIcon } from '@workday/canvas-system-icons-web';
|
|
11
|
+
import { system } from '@workday/canvas-tokens-web';
|
|
12
|
+
const headingID = generateUniqueId();
|
|
13
|
+
const autoData = [
|
|
14
|
+
{
|
|
15
|
+
id: generateUniqueId(),
|
|
16
|
+
brand: 'Porsche',
|
|
17
|
+
model: '992 911 GT3',
|
|
18
|
+
year: '2022',
|
|
19
|
+
price: 'Starts at $160,000',
|
|
20
|
+
engine: '4.0L Flat 6',
|
|
21
|
+
transmission: 'PDK or 7-Speed Manual',
|
|
22
|
+
horsepower: '502hp',
|
|
23
|
+
torque: '346 lb-ft',
|
|
24
|
+
curbWeight: '3,164 lbs',
|
|
25
|
+
orderStatus: 'Order Placed',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: generateUniqueId(),
|
|
29
|
+
brand: 'BMW',
|
|
30
|
+
model: 'M5 Competition',
|
|
31
|
+
year: '2018',
|
|
32
|
+
price: 'Starts at $105,000',
|
|
33
|
+
engine: 'Twin-Turbo 4.4L V8',
|
|
34
|
+
transmission: 'Automatic',
|
|
35
|
+
horsepower: '627hp',
|
|
36
|
+
torque: '553 lb-ft',
|
|
37
|
+
curbWeight: '4,345 lbs',
|
|
38
|
+
orderStatus: 'Order Fulfilled',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: generateUniqueId(),
|
|
42
|
+
brand: 'Audi',
|
|
43
|
+
model: 'R8',
|
|
44
|
+
year: '2022',
|
|
45
|
+
price: 'Starts at $148,000',
|
|
46
|
+
engine: '5.2L V10',
|
|
47
|
+
transmission: 'Automatic',
|
|
48
|
+
horsepower: '562hp',
|
|
49
|
+
torque: '408 lb-ft',
|
|
50
|
+
curbWeight: '3,594 lbs',
|
|
51
|
+
orderStatus: 'Order Fulfilled',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: generateUniqueId(),
|
|
55
|
+
brand: 'Lotus',
|
|
56
|
+
model: 'Emira',
|
|
57
|
+
year: '2023',
|
|
58
|
+
price: 'Starts at $78,000',
|
|
59
|
+
engine: 'Supercharged 3.5L V6',
|
|
60
|
+
transmission: 'Automatic or 6-Speed Manual',
|
|
61
|
+
horsepower: '400hp',
|
|
62
|
+
torque: '317 lb-ft',
|
|
63
|
+
curbWeight: '3520 lbs',
|
|
64
|
+
orderStatus: 'Shipped: In Transit',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: generateUniqueId(),
|
|
68
|
+
brand: 'Toyota',
|
|
69
|
+
model: 'Supra',
|
|
70
|
+
year: '1998',
|
|
71
|
+
price: '$40,000 - $80,000',
|
|
72
|
+
engine: '3.0L Inline 6',
|
|
73
|
+
transmission: 'Automatic or 6-Speed Manual',
|
|
74
|
+
horsepower: '320hp',
|
|
75
|
+
torque: '315 lb-ft',
|
|
76
|
+
curbWeight: '3,599 lbs',
|
|
77
|
+
orderStatus: 'Delivered',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: generateUniqueId(),
|
|
81
|
+
brand: 'Nissan',
|
|
82
|
+
model: 'Skyline GT-R',
|
|
83
|
+
year: '1994',
|
|
84
|
+
price: '$45,000 - $90,000',
|
|
85
|
+
engine: '2.6L Twin-Turbo Inline 6',
|
|
86
|
+
transmission: '5-Speed Manual',
|
|
87
|
+
horsepower: '276hp',
|
|
88
|
+
torque: '260 lb-ft',
|
|
89
|
+
curbWeight: '3,153 lbs',
|
|
90
|
+
orderStatus: 'Delivered',
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
const expandableSectionStyles = createStyles({
|
|
94
|
+
alignItems: 'flex-start',
|
|
95
|
+
display: 'flex',
|
|
96
|
+
gap: system.space.x4,
|
|
97
|
+
padding: system.space.x8,
|
|
98
|
+
});
|
|
99
|
+
const expandableHeadingStyles = createStyles({
|
|
100
|
+
margin: 0,
|
|
101
|
+
fontWeight: system.fontWeight.bold,
|
|
102
|
+
});
|
|
103
|
+
const expandableListStyles = createStyles({
|
|
104
|
+
listStyle: 'none',
|
|
105
|
+
margin: 0,
|
|
106
|
+
padding: 0,
|
|
107
|
+
gap: system.space.x2,
|
|
108
|
+
});
|
|
109
|
+
function ExpandableRow({ data }) {
|
|
110
|
+
const [rowExpanded, setRowExpanded] = React.useState(false);
|
|
111
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Table.Row, { gridTemplateColumns: "4rem repeat(4, 1fr)", children: [_jsx(Table.Cell, { children: _jsx(Tooltip, { title: `${data.brand} ${data.model}`, children: _jsx(TertiaryButton, { size: "small", icon: rowExpanded ? chevronDownSmallIcon : chevronRightSmallIcon, "aria-expanded": rowExpanded, onClick: () => setRowExpanded(!rowExpanded) }) }) }), _jsx(Table.Header, { scope: "row", children: data.brand }), _jsx(Table.Cell, { children: data.model }), _jsx(Table.Cell, { children: data.year }), _jsx(Table.Cell, { children: data.price })] }), rowExpanded && (_jsx(Table.Row, { children: _jsxs(Table.Cell, { colSpan: 5, cs: expandableSectionStyles, children: [_jsxs("div", { children: [_jsx(Subtext, { as: "h4", size: "large", cs: expandableHeadingStyles, children: "Status" }), _jsx(StatusIndicator, { variant: "blue", children: data.orderStatus })] }), _jsxs("div", { children: [_jsx(Subtext, { as: "h4", size: "large", cs: expandableHeadingStyles, children: "Specifications" }), _jsxs("ul", { className: expandableListStyles, children: [_jsxs(Subtext, { as: "li", size: "large", children: ["Engine: ", data.engine] }), _jsxs(Subtext, { as: "li", size: "large", children: ["Transmission: ", data.transmission] }), _jsxs(Subtext, { as: "li", size: "large", children: ["Horsepower: ", data.horsepower] }), _jsxs(Subtext, { as: "li", size: "large", children: ["Torque: ", data.torque] }), _jsxs(Subtext, { as: "li", size: "large", children: ["Curb Weight: ", data.curbWeight] })] })] })] }) }))] }));
|
|
112
|
+
}
|
|
113
|
+
export const ExpandableRows = () => {
|
|
114
|
+
return (_jsxs(_Fragment, { children: [_jsx(Heading, { as: "h3", id: headingID, size: "small", children: "Showroom Inventory" }), _jsxs(Table, { "aria-labelledby": headingID, children: [_jsx(Table.Head, { children: _jsxs(Table.Row, { gridTemplateColumns: "4rem repeat(4, 1fr)", children: [_jsx(Table.Cell, {}), _jsx(Table.Header, { scope: "col", children: "Make" }), _jsx(Table.Header, { scope: "col", children: "Model" }), _jsx(Table.Header, { scope: "col", children: "Year" }), _jsx(Table.Header, { scope: "col", children: "Price" })] }) }), _jsx(Table.Body, { children: autoData.map(item => (_jsx(ExpandableRow, { data: item }, item.id))) })] })] }));
|
|
115
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithFormFields.d.ts","sourceRoot":"","sources":["../../../../../../mdx/accessibility/examples/Table/WithFormFields.tsx"],"names":[],"mappings":"AAwHA,eAAO,MAAM,cAAc,+CAiC1B,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useUniqueId } from '@workday/canvas-kit-react/common';
|
|
4
|
+
import { createStyles } from '@workday/canvas-kit-styling';
|
|
5
|
+
import { system } from '@workday/canvas-tokens-web';
|
|
6
|
+
import { trashIcon } from '@workday/canvas-system-icons-web';
|
|
7
|
+
import { TextInput } from '@workday/canvas-kit-react/text-input';
|
|
8
|
+
import { Table } from '@workday/canvas-kit-react/table';
|
|
9
|
+
import { Checkbox } from '@workday/canvas-kit-react/checkbox';
|
|
10
|
+
import { TertiaryButton } from '@workday/canvas-kit-react/button';
|
|
11
|
+
import { Tooltip } from '@workday/canvas-kit-react/tooltip';
|
|
12
|
+
const rowStyles = createStyles({
|
|
13
|
+
gridTemplateColumns: '24rem 12rem 7rem 7rem',
|
|
14
|
+
});
|
|
15
|
+
const centerStyles = createStyles({
|
|
16
|
+
display: 'flex',
|
|
17
|
+
justifyContent: 'center',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
});
|
|
20
|
+
const currencyInputContainer = createStyles({
|
|
21
|
+
position: 'relative',
|
|
22
|
+
display: 'inline-block',
|
|
23
|
+
});
|
|
24
|
+
const dollarPrefix = createStyles({
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
left: system.space.x2,
|
|
27
|
+
top: '50%',
|
|
28
|
+
transform: 'translateY(-50%)',
|
|
29
|
+
color: system.color.text.default,
|
|
30
|
+
pointerEvents: 'none',
|
|
31
|
+
zIndex: 1,
|
|
32
|
+
...system.type.subtext.large,
|
|
33
|
+
});
|
|
34
|
+
const currencyInput = createStyles({
|
|
35
|
+
paddingLeft: system.space.x4, // Make room for dollar sign
|
|
36
|
+
});
|
|
37
|
+
const expensesData = [
|
|
38
|
+
'Rent',
|
|
39
|
+
'Groceries',
|
|
40
|
+
'Electricity bill',
|
|
41
|
+
'Internet service',
|
|
42
|
+
'Gasoline',
|
|
43
|
+
'Cell phone bill',
|
|
44
|
+
'Health insurance',
|
|
45
|
+
'Car payment',
|
|
46
|
+
'Student loan payment',
|
|
47
|
+
'Dining out',
|
|
48
|
+
];
|
|
49
|
+
const LineItem = ({ itemName, labelIds }) => {
|
|
50
|
+
const [name, setName] = React.useState(itemName);
|
|
51
|
+
const [amount, setAmount] = React.useState('');
|
|
52
|
+
function handleNameChange(e) {
|
|
53
|
+
setName(e.target.value);
|
|
54
|
+
}
|
|
55
|
+
function handleAmountChange(e) {
|
|
56
|
+
const value = e.target.value;
|
|
57
|
+
// For type="number", the browser handles most validation
|
|
58
|
+
// We just need to limit decimal places to 2 for currency
|
|
59
|
+
if (value.includes('.')) {
|
|
60
|
+
const parts = value.split('.');
|
|
61
|
+
if (parts[1] && parts[1].length > 2) {
|
|
62
|
+
// Limit to 2 decimal places
|
|
63
|
+
const limitedValue = parts[0] + '.' + parts[1].substring(0, 2);
|
|
64
|
+
setAmount(limitedValue);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
setAmount(value);
|
|
69
|
+
}
|
|
70
|
+
return (_jsxs(Table.Row, { cs: rowStyles, children: [_jsx(Table.Header, { scope: "row", children: _jsx(TextInput, { onChange: handleNameChange, value: name, "aria-labelledby": labelIds.name }) }), _jsx(Table.Cell, { children: _jsxs("div", { className: currencyInputContainer, children: [_jsx("span", { className: dollarPrefix, "aria-hidden": "true", children: "$" }), _jsx(TextInput, { type: "number", value: amount, onChange: handleAmountChange, placeholder: "0.00", min: "0", step: "0.01", width: "10.5rem", "aria-labelledby": labelIds.amount, cs: currencyInput })] }) }), _jsx(Table.Cell, { cs: centerStyles, children: _jsx(Checkbox, { "aria-labelledby": labelIds.recon }) }), _jsx(Table.Cell, { cs: centerStyles, children: _jsx(Tooltip, { title: "Delete", children: _jsx(TertiaryButton, { icon: trashIcon }) }) })] }));
|
|
71
|
+
};
|
|
72
|
+
export const WithFormFields = () => {
|
|
73
|
+
const colHeadIds = {
|
|
74
|
+
name: useUniqueId(),
|
|
75
|
+
amount: useUniqueId(),
|
|
76
|
+
recon: useUniqueId(),
|
|
77
|
+
};
|
|
78
|
+
return (_jsxs(Table, { children: [_jsx(Table.Caption, { children: "Budget Planning Tool" }), _jsx(Table.Head, { children: _jsxs(Table.Row, { cs: rowStyles, children: [_jsxs(Table.Header, { scope: "col", id: colHeadIds.name, children: ["Expense Name", ' '] }), _jsxs(Table.Header, { scope: "col", id: colHeadIds.amount, children: ["Budgeted Amount (USD)", ' '] }), _jsx(Table.Header, { scope: "col", id: colHeadIds.recon, cs: centerStyles, children: "Reconciled" }), _jsxs(Table.Header, { scope: "col", cs: centerStyles, children: ["Actions", ' '] })] }) }), _jsx(Table.Body, { children: expensesData.map(i => (_jsx(LineItem, { itemName: i, labelIds: colHeadIds }))) })] }));
|
|
79
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithSelectableRows.d.ts","sourceRoot":"","sources":["../../../../../../mdx/accessibility/examples/Table/WithSelectableRows.tsx"],"names":[],"mappings":"AA0EA,eAAO,MAAM,cAAc,+CAiF1B,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Table } from '@workday/canvas-kit-react/table';
|
|
4
|
+
import { Heading } from '@workday/canvas-kit-react/text';
|
|
5
|
+
import { Checkbox } from '@workday/canvas-kit-react/checkbox';
|
|
6
|
+
import { createComponent, generateUniqueId } from '@workday/canvas-kit-react/common';
|
|
7
|
+
import { Tooltip } from '@workday/canvas-kit-react/tooltip';
|
|
8
|
+
import { createStencil, createStyles } from '@workday/canvas-kit-styling';
|
|
9
|
+
import { system } from '@workday/canvas-tokens-web';
|
|
10
|
+
const selectableRowStencil = createStencil({
|
|
11
|
+
base: {
|
|
12
|
+
gridTemplateColumns: '3.5rem repeat(2, 1fr)',
|
|
13
|
+
transition: 'background-color 200ms',
|
|
14
|
+
},
|
|
15
|
+
modifiers: {
|
|
16
|
+
isSelected: {
|
|
17
|
+
true: {
|
|
18
|
+
backgroundColor: system.color.bg.primary.soft,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
const tableHeaderStyles = createStyles({
|
|
24
|
+
backgroundColor: system.color.bg.alt.soft,
|
|
25
|
+
});
|
|
26
|
+
const tableCellStyles = createStyles({
|
|
27
|
+
backgroundColor: 'transparent',
|
|
28
|
+
});
|
|
29
|
+
const SelectableRow = createComponent('tr')({
|
|
30
|
+
displayName: 'SelectableRow',
|
|
31
|
+
Component: ({ onSelect, rowData }) => {
|
|
32
|
+
return (_jsxs(Table.Row, { cs: selectableRowStencil({ isSelected: rowData.checked }), children: [_jsx(Table.Cell, { cs: tableCellStyles, children: _jsx(Tooltip, { title: rowData.name, children: _jsx(Checkbox, { checked: rowData.checked, onChange: onSelect }) }) }), _jsx(Table.Header, { cs: tableCellStyles, scope: "row", children: rowData.name }), _jsx(Table.Cell, { cs: tableCellStyles, children: rowData.amount })] }));
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const pizzaToppingData = [
|
|
36
|
+
{ name: 'Pepperoni', amount: '2.5 oz.', checked: false },
|
|
37
|
+
{ name: 'Mozzarella', amount: '5 oz.', checked: false },
|
|
38
|
+
{ name: 'Basil', amount: '10 Leaves', checked: false },
|
|
39
|
+
{ name: 'Roasted Red Peppers', amount: '3 oz.', checked: false },
|
|
40
|
+
{ name: 'Mushrooms', amount: '2 oz.', checked: false },
|
|
41
|
+
];
|
|
42
|
+
const headingID = generateUniqueId();
|
|
43
|
+
export const SelectableRows = () => {
|
|
44
|
+
const [selectAllState, setSelectAllState] = React.useState('unchecked');
|
|
45
|
+
const [toppings, setToppings] = React.useState(pizzaToppingData);
|
|
46
|
+
const handleToppingChange = (name) => {
|
|
47
|
+
// Toggle the selected item's checked state and update state
|
|
48
|
+
const updatedToppings = toppings.map(topping => {
|
|
49
|
+
if (topping.name === name) {
|
|
50
|
+
return { ...topping, checked: !topping.checked };
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return topping;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
setToppings(updatedToppings);
|
|
57
|
+
// Update the Select All checkbox state
|
|
58
|
+
const selectedToppings = updatedToppings.filter(topping => topping.checked === true);
|
|
59
|
+
// If no toppings are selected, set the Select All checkbox to 'unchecked'
|
|
60
|
+
if (selectedToppings.length === 0) {
|
|
61
|
+
setSelectAllState('unchecked');
|
|
62
|
+
// If all toppings are selected, set the Select All checkbox to 'checked'
|
|
63
|
+
}
|
|
64
|
+
else if (selectedToppings.length === updatedToppings.length) {
|
|
65
|
+
setSelectAllState('checked');
|
|
66
|
+
// Otherwise, set the Select All checkbox to 'indeterminate'
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
setSelectAllState('indeterminate');
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const handleSelectAll = () => {
|
|
73
|
+
// If the Select All checkbox is in a checked or indeterminate state,
|
|
74
|
+
// update it to 'unchecked', and uncheck all topping checkboxes
|
|
75
|
+
if (selectAllState === 'checked' || selectAllState === 'indeterminate') {
|
|
76
|
+
setSelectAllState('unchecked');
|
|
77
|
+
const updatedToppingData = toppings.map(topping => ({ ...topping, checked: false }));
|
|
78
|
+
setToppings(updatedToppingData);
|
|
79
|
+
}
|
|
80
|
+
// If the Select All checkbox is in an unchecked state,
|
|
81
|
+
// update it to 'checked', and check all topping checkboxes
|
|
82
|
+
if (selectAllState === 'unchecked') {
|
|
83
|
+
setSelectAllState('checked');
|
|
84
|
+
const updatedToppingData = toppings.map(topping => ({ ...topping, checked: true }));
|
|
85
|
+
setToppings(updatedToppingData);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
return (_jsxs(_Fragment, { children: [_jsx(Heading, { as: "h3", id: headingID, size: "small", children: "Select your pizza toppings" }), _jsxs(Table, { "aria-labelledby": headingID, children: [_jsxs(Table.Row, { gridTemplateColumns: "3.5rem repeat(2, 1fr)", children: [_jsx(Table.Cell, { cs: tableHeaderStyles, children: _jsx(Tooltip, { title: "Select All", children: _jsx(Checkbox, { checked: selectAllState === 'checked', indeterminate: selectAllState === 'indeterminate', onChange: handleSelectAll }) }) }), _jsx(Table.Header, { scope: "col", cs: tableHeaderStyles, children: "Toppings" }), _jsx(Table.Header, { scope: "col", cs: tableHeaderStyles, children: "Amount" })] }), _jsx(Table.Body, { children: toppings.map(rowData => (_jsx(SelectableRow, { rowData: rowData, onSelect: () => handleToppingChange(rowData.name) }, rowData.name))) })] })] }));
|
|
89
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithSortableColumnHeaders.d.ts","sourceRoot":"","sources":["../../../../../../mdx/accessibility/examples/Table/WithSortableColumnHeaders.tsx"],"names":[],"mappings":"AAwJA,eAAO,MAAM,qBAAqB,+CA4DjC,CAAC"}
|