@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
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
3
|
-
import {SidePanel, useSidePanel} from '@workday/canvas-kit-preview-react/side-panel';
|
|
4
|
-
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
5
|
-
import {Heading, Subtext, Text} from '@workday/canvas-kit-react/text';
|
|
6
|
-
import {Expandable} from '@workday/canvas-kit-react/expandable';
|
|
7
|
-
import {SystemIcon} from '@workday/canvas-kit-react/icon';
|
|
8
|
-
import {Hyperlink, TertiaryButton} from '@workday/canvas-kit-react/button';
|
|
9
|
-
import {Menu} from '@workday/canvas-kit-react/menu';
|
|
10
|
-
import {birthdayIcon, checkIcon, ribbonIcon} from '@workday/canvas-system-icons-web';
|
|
11
|
-
import {createStyles, px2rem} from '@workday/canvas-kit-styling';
|
|
12
|
-
import {Tooltip} from '../../../../tooltip';
|
|
13
|
-
|
|
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
|
-
|
|
29
|
-
const stylesOverride = {
|
|
30
|
-
navContainer: createStyles({
|
|
31
|
-
height: px2rem(800),
|
|
32
|
-
positio: 'relative',
|
|
33
|
-
backgroundColor: system.color.bg.alt.default,
|
|
34
|
-
}),
|
|
35
|
-
accordionContainer: createStyles({
|
|
36
|
-
flexDirection: 'column',
|
|
37
|
-
rowGap: system.space.zero,
|
|
38
|
-
paddingInlineStart: system.space.zero,
|
|
39
|
-
}),
|
|
40
|
-
accordionIcon: createStyles({
|
|
41
|
-
verticalAlign: 'middle',
|
|
42
|
-
padding: system.space.x1,
|
|
43
|
-
}),
|
|
44
|
-
accordionSubText: createStyles({
|
|
45
|
-
margin: system.space.zero,
|
|
46
|
-
}),
|
|
47
|
-
listContainer: createStyles({
|
|
48
|
-
listStyle: 'none',
|
|
49
|
-
padding: system.space.x4,
|
|
50
|
-
paddingTop: system.space.x16,
|
|
51
|
-
flexDirection: 'column',
|
|
52
|
-
}),
|
|
53
|
-
links: createStyles({
|
|
54
|
-
textDecoration: 'none',
|
|
55
|
-
padding: system.space.x4,
|
|
56
|
-
}),
|
|
57
|
-
linkCheck: createStyles({
|
|
58
|
-
marginLeft: 'auto',
|
|
59
|
-
}),
|
|
60
|
-
flyOut: createStyles({
|
|
61
|
-
marginTop: '8rem',
|
|
62
|
-
}),
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const Accordion = ({config}) => {
|
|
66
|
-
const [currentPage, setCurrentPage] = React.useState('');
|
|
67
|
-
|
|
68
|
-
const handleClick = e => {
|
|
69
|
-
e.preventDefault();
|
|
70
|
-
setCurrentPage(e.target.textContent);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
return (
|
|
74
|
-
<Expandable>
|
|
75
|
-
<Expandable.Target>
|
|
76
|
-
<SystemIcon cs={stylesOverride.accordionIcon} icon={config.icon} />
|
|
77
|
-
<Expandable.Title>
|
|
78
|
-
{config.title}
|
|
79
|
-
<Subtext size="medium" cs={stylesOverride.accordionSubText}>
|
|
80
|
-
{config.subtitle}
|
|
81
|
-
</Subtext>
|
|
82
|
-
</Expandable.Title>
|
|
83
|
-
<Expandable.Icon iconPosition="end" />
|
|
84
|
-
</Expandable.Target>
|
|
85
|
-
<Expandable.Content as="ul" cs={stylesOverride.listContainer}>
|
|
86
|
-
{config.items.map(i => {
|
|
87
|
-
return (
|
|
88
|
-
<li key={i}>
|
|
89
|
-
<Flex
|
|
90
|
-
as="a"
|
|
91
|
-
href="#"
|
|
92
|
-
aria-current={i === currentPage ? 'true' : undefined}
|
|
93
|
-
className={stylesOverride.links}
|
|
94
|
-
onClick={handleClick}
|
|
95
|
-
>
|
|
96
|
-
{i}
|
|
97
|
-
{i === currentPage && <SystemIcon icon={checkIcon} cs={stylesOverride.linkCheck} />}
|
|
98
|
-
</Flex>
|
|
99
|
-
</li>
|
|
100
|
-
);
|
|
101
|
-
})}
|
|
102
|
-
</Expandable.Content>
|
|
103
|
-
</Expandable>
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const IconButtonMenu = ({config}) => {
|
|
108
|
-
return (
|
|
109
|
-
<Menu>
|
|
110
|
-
<Tooltip title={config.title} placement="right">
|
|
111
|
-
<Menu.Target as={TertiaryButton}>
|
|
112
|
-
<SystemIcon icon={config.icon} />
|
|
113
|
-
</Menu.Target>
|
|
114
|
-
</Tooltip>
|
|
115
|
-
<Menu.Popper placement="right">
|
|
116
|
-
<Menu.Card cs={stylesOverride.flyOut}>
|
|
117
|
-
<Menu.List>
|
|
118
|
-
{config.items.map(i => (
|
|
119
|
-
<Menu.Item>{i}</Menu.Item>
|
|
120
|
-
))}
|
|
121
|
-
</Menu.List>
|
|
122
|
-
</Menu.Card>
|
|
123
|
-
</Menu.Popper>
|
|
124
|
-
</Menu>
|
|
125
|
-
);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const CompactView = () => {
|
|
129
|
-
return (
|
|
130
|
-
<Flex as="ul" cs={stylesOverride.listContainer}>
|
|
131
|
-
<Flex.Item as="li">
|
|
132
|
-
<IconButtonMenu config={data.bestsellers} />
|
|
133
|
-
</Flex.Item>
|
|
134
|
-
<Flex.Item as="li">
|
|
135
|
-
<IconButtonMenu config={data.cakes} />
|
|
136
|
-
</Flex.Item>
|
|
137
|
-
</Flex>
|
|
138
|
-
);
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const ExpandedView = () => {
|
|
142
|
-
return (
|
|
143
|
-
<Flex as="ul" cs={stylesOverride.accordionContainer}>
|
|
144
|
-
<Flex.Item as="li">
|
|
145
|
-
<Accordion config={data.bestsellers} />
|
|
146
|
-
</Flex.Item>
|
|
147
|
-
<Flex.Item as="li">
|
|
148
|
-
<Accordion config={data.cakes} />
|
|
149
|
-
</Flex.Item>
|
|
150
|
-
</Flex>
|
|
151
|
-
);
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
export default () => {
|
|
155
|
-
const {expanded, panelProps, labelProps, controlProps} = useSidePanel();
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<Flex cs={stylesOverride.navContainer}>
|
|
159
|
-
<SidePanel as="nav" {...panelProps}>
|
|
160
|
-
<Heading size="small" {...labelProps} hidden={!expanded ? true : undefined}>
|
|
161
|
-
Cake or Death Bakery
|
|
162
|
-
</Heading>
|
|
163
|
-
<SidePanel.ToggleButton {...controlProps} />
|
|
164
|
-
{expanded ? <ExpandedView /> : <CompactView />}
|
|
165
|
-
</SidePanel>
|
|
166
|
-
</Flex>
|
|
167
|
-
);
|
|
168
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
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
|
-
|
|
8
|
-
const stylesOverride = {
|
|
9
|
-
panelContainer: createStyles({
|
|
10
|
-
height: px2rem(320),
|
|
11
|
-
backgroundColor: system.color.bg.alt.soft,
|
|
12
|
-
position: 'relative',
|
|
13
|
-
}),
|
|
14
|
-
panelContent: createStyles({
|
|
15
|
-
alignItems: 'center',
|
|
16
|
-
paddingY: system.space.x4,
|
|
17
|
-
paddingX: system.space.x4,
|
|
18
|
-
}),
|
|
19
|
-
panel: createStyles({
|
|
20
|
-
zIndex: 1,
|
|
21
|
-
}),
|
|
22
|
-
overlay: createStyles({
|
|
23
|
-
position: 'absolute',
|
|
24
|
-
background: system.color.bg.overlay,
|
|
25
|
-
height: '100%',
|
|
26
|
-
width: '100%',
|
|
27
|
-
}),
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export default () => {
|
|
31
|
-
const {expanded, panelProps, labelProps, controlProps} = useSidePanel();
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<Flex cs={stylesOverride.panelContainer}>
|
|
35
|
-
<SidePanel className={stylesOverride.panel} {...panelProps} variant="alternate">
|
|
36
|
-
<Flex cs={stylesOverride.panelContainer}>
|
|
37
|
-
<Heading size="small" {...labelProps} hidden={!expanded ? true : undefined}>
|
|
38
|
-
Alternate Panel
|
|
39
|
-
</Heading>
|
|
40
|
-
<SidePanel.ToggleButton {...controlProps} />
|
|
41
|
-
</Flex>
|
|
42
|
-
</SidePanel>
|
|
43
|
-
{expanded && <Box cs={stylesOverride.overlay} />}
|
|
44
|
-
</Flex>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
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 {
|
|
8
|
-
Popup,
|
|
9
|
-
usePopupModel,
|
|
10
|
-
useCloseOnOutsideClick,
|
|
11
|
-
useCloseOnEscape,
|
|
12
|
-
useInitialFocus,
|
|
13
|
-
useReturnFocus,
|
|
14
|
-
useFocusRedirect,
|
|
15
|
-
} from '@workday/canvas-kit-react/popup';
|
|
16
|
-
import {PrimaryButton, TertiaryButton} from '@workday/canvas-kit-react/button';
|
|
17
|
-
import {Table} from '@workday/canvas-kit-react/table';
|
|
18
|
-
import {Text} from '@workday/canvas-kit-react/text';
|
|
19
|
-
import {SystemIcon} from '@workday/canvas-kit-react/icon';
|
|
20
|
-
import {Tooltip} from '@workday/canvas-kit-react/tooltip';
|
|
21
|
-
import {createStyles} from '@workday/canvas-kit-styling';
|
|
22
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
23
|
-
import {filterIcon, searchIcon} from '@workday/canvas-system-icons-web';
|
|
24
|
-
|
|
25
|
-
interface CountryData {
|
|
26
|
-
country: string;
|
|
27
|
-
capital: string;
|
|
28
|
-
population: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const countryData: CountryData[] = [
|
|
32
|
-
{country: 'Australia', capital: 'Canberra', population: 25690000},
|
|
33
|
-
{country: 'Bahamas', capital: 'Nassau', population: 407906},
|
|
34
|
-
{country: 'Canada', capital: 'Ottawa', population: 38250000},
|
|
35
|
-
{country: 'Fiji', capital: 'Suva', population: 924610},
|
|
36
|
-
{country: 'Ghana', capital: 'Accra', population: 32830000},
|
|
37
|
-
{country: 'Hong Kong', capital: 'City of Victoria', population: 7413000},
|
|
38
|
-
{country: 'India', capital: 'New Delhi', population: 1408000000},
|
|
39
|
-
{country: 'Ireland', capital: 'Dublin', population: 5033000},
|
|
40
|
-
{country: 'Jamaica', capital: 'Kingston', population: 2828000},
|
|
41
|
-
{country: 'Kenya', capital: 'Nairobi', population: 53010000},
|
|
42
|
-
{country: 'Micronesia', capital: 'Palikir', population: 113131},
|
|
43
|
-
{country: 'New Zealand', capital: 'Wellington', population: 5123000},
|
|
44
|
-
{country: 'Philippines', capital: 'Manila', population: 113900000},
|
|
45
|
-
{country: 'Puerto Rico', capital: 'San Juan', population: 3264000},
|
|
46
|
-
{country: 'Samoa', capital: 'Apia', population: 218764},
|
|
47
|
-
{country: 'Singapore', capital: 'Singapore', population: 5454000},
|
|
48
|
-
{country: 'Tanzania', capital: 'Dodoma', population: 63590000},
|
|
49
|
-
{country: 'United Kingdom', capital: 'London', population: 67330000},
|
|
50
|
-
{country: 'United States', capital: 'Washington, D.C.', population: 331900000},
|
|
51
|
-
{country: 'Zimbabwe', capital: 'Harare', population: 15990000},
|
|
52
|
-
];
|
|
53
|
-
|
|
54
|
-
const textStyles = createStyles({
|
|
55
|
-
paddingInlineStart: system.space.x3,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
interface FilterableColumnHeaderProps {
|
|
59
|
-
label: string;
|
|
60
|
-
onFilter: (filterObject: {filterText: string; column: string}) => void;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const FilterableColumnHeader = createComponent('th')({
|
|
64
|
-
displayName: 'FilterableColumnHeader',
|
|
65
|
-
Component: ({label, onFilter}: FilterableColumnHeaderProps, ref) => {
|
|
66
|
-
const [inputVal, setInputVal] = React.useState('');
|
|
67
|
-
const targetId = useUniqueId();
|
|
68
|
-
const popupId = useUniqueId();
|
|
69
|
-
const initialFocusRef = React.useRef(null);
|
|
70
|
-
const filterPopupModel = usePopupModel({
|
|
71
|
-
initialFocusRef,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
useCloseOnOutsideClick(filterPopupModel);
|
|
75
|
-
useCloseOnEscape(filterPopupModel);
|
|
76
|
-
useInitialFocus(filterPopupModel);
|
|
77
|
-
useFocusRedirect(filterPopupModel);
|
|
78
|
-
useReturnFocus(filterPopupModel);
|
|
79
|
-
|
|
80
|
-
function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
|
|
81
|
-
const newVal = e.target.value;
|
|
82
|
-
setInputVal(newVal);
|
|
83
|
-
onFilter({filterText: newVal, column: label.toLowerCase()});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<Table.Header scope="col" aria-owns={targetId + ' ' + popupId}>
|
|
88
|
-
<Popup model={filterPopupModel}>
|
|
89
|
-
<Tooltip title={`Filter${inputVal !== '' ? `ed: "${inputVal}"` : ''}`} type="description">
|
|
90
|
-
<Popup.Target
|
|
91
|
-
as={TertiaryButton}
|
|
92
|
-
id={targetId}
|
|
93
|
-
icon={inputVal === '' ? searchIcon : filterIcon}
|
|
94
|
-
iconPosition="end"
|
|
95
|
-
>
|
|
96
|
-
{label}
|
|
97
|
-
</Popup.Target>
|
|
98
|
-
</Tooltip>
|
|
99
|
-
<Popup.Popper>
|
|
100
|
-
<Popup.Card id={popupId}>
|
|
101
|
-
<Popup.Heading>Filter</Popup.Heading>
|
|
102
|
-
<Popup.Body>
|
|
103
|
-
<FormField>
|
|
104
|
-
<FormField.Label>{label}</FormField.Label>
|
|
105
|
-
<FormField.Input as={InputGroup}>
|
|
106
|
-
<InputGroup.InnerStart>
|
|
107
|
-
<SystemIcon icon={searchIcon} />
|
|
108
|
-
</InputGroup.InnerStart>
|
|
109
|
-
<InputGroup.Input
|
|
110
|
-
as={TextInput}
|
|
111
|
-
type="search"
|
|
112
|
-
ref={initialFocusRef}
|
|
113
|
-
onChange={handleChange}
|
|
114
|
-
value={inputVal}
|
|
115
|
-
/>
|
|
116
|
-
</FormField.Input>
|
|
117
|
-
</FormField>
|
|
118
|
-
</Popup.Body>
|
|
119
|
-
<Flex>
|
|
120
|
-
<Popup.CloseButton as={PrimaryButton}>Done</Popup.CloseButton>
|
|
121
|
-
</Flex>
|
|
122
|
-
</Popup.Card>
|
|
123
|
-
</Popup.Popper>
|
|
124
|
-
</Popup>
|
|
125
|
-
</Table.Header>
|
|
126
|
-
);
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
function filterTableData(data: CountryData[], filters: CountryData) {
|
|
131
|
-
return data.filter(item => {
|
|
132
|
-
for (const key in filters) {
|
|
133
|
-
if (filters.hasOwnProperty(key) && filters[key]) {
|
|
134
|
-
const filterText = filters[key].toLowerCase();
|
|
135
|
-
const itemValue = String(item[key]).toLowerCase();
|
|
136
|
-
if (!itemValue.includes(filterText)) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return true;
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export default () => {
|
|
146
|
-
const [filteredData, setFilteredData] = React.useState(countryData);
|
|
147
|
-
const [colFilters, setColFilters] = React.useState<CountryData>({
|
|
148
|
-
country: '',
|
|
149
|
-
capital: '',
|
|
150
|
-
population: '',
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
React.useEffect(() => {
|
|
154
|
-
setFilteredData(filterTableData(countryData, colFilters));
|
|
155
|
-
}, [colFilters]);
|
|
156
|
-
|
|
157
|
-
let typingDelay: NodeJS.Timeout;
|
|
158
|
-
function handleColFilters({filterText, column}) {
|
|
159
|
-
clearTimeout(typingDelay);
|
|
160
|
-
typingDelay = setTimeout(() => {
|
|
161
|
-
setColFilters(prev => {
|
|
162
|
-
const newState = {...prev, [column]: filterText};
|
|
163
|
-
return newState;
|
|
164
|
-
});
|
|
165
|
-
}, 400);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return (
|
|
169
|
-
<Table maxHeight="40rem">
|
|
170
|
-
<Table.Caption>
|
|
171
|
-
Population Listed by Country (2021)
|
|
172
|
-
<AriaLiveRegion cs={textStyles}>
|
|
173
|
-
{filteredData.length} of {countryData.length} items
|
|
174
|
-
</AriaLiveRegion>
|
|
175
|
-
</Table.Caption>
|
|
176
|
-
<Table.Head>
|
|
177
|
-
<Table.Row>
|
|
178
|
-
<FilterableColumnHeader label="Country" onFilter={handleColFilters} />
|
|
179
|
-
<FilterableColumnHeader label="Capital" onFilter={handleColFilters} />
|
|
180
|
-
<FilterableColumnHeader label="Population" onFilter={handleColFilters} />
|
|
181
|
-
</Table.Row>
|
|
182
|
-
</Table.Head>
|
|
183
|
-
<Table.Body>
|
|
184
|
-
{filteredData.map(item => {
|
|
185
|
-
return (
|
|
186
|
-
<Table.Row key={item.country}>
|
|
187
|
-
<Table.Header scope="row">
|
|
188
|
-
<Text cs={textStyles}>{item.country}</Text>
|
|
189
|
-
</Table.Header>
|
|
190
|
-
<Table.Cell>
|
|
191
|
-
<Text cs={textStyles}>{item.capital}</Text>
|
|
192
|
-
</Table.Cell>
|
|
193
|
-
<Table.Cell>
|
|
194
|
-
<Text cs={textStyles}>{item.population.toLocaleString()}</Text>
|
|
195
|
-
</Table.Cell>
|
|
196
|
-
</Table.Row>
|
|
197
|
-
);
|
|
198
|
-
})}
|
|
199
|
-
</Table.Body>
|
|
200
|
-
</Table>
|
|
201
|
-
);
|
|
202
|
-
};
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
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
|
-
|
|
11
|
-
import {chevronDownSmallIcon, chevronRightSmallIcon} from '@workday/canvas-system-icons-web';
|
|
12
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
13
|
-
|
|
14
|
-
interface AutoData {
|
|
15
|
-
id: string;
|
|
16
|
-
brand: string;
|
|
17
|
-
model: string;
|
|
18
|
-
year: string;
|
|
19
|
-
price: string;
|
|
20
|
-
engine: string;
|
|
21
|
-
transmission: string;
|
|
22
|
-
horsepower: string;
|
|
23
|
-
torque: string;
|
|
24
|
-
curbWeight: string;
|
|
25
|
-
orderStatus: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const headingID = generateUniqueId();
|
|
29
|
-
const autoData: AutoData[] = [
|
|
30
|
-
{
|
|
31
|
-
id: generateUniqueId(),
|
|
32
|
-
brand: 'Porsche',
|
|
33
|
-
model: '992 911 GT3',
|
|
34
|
-
year: '2022',
|
|
35
|
-
price: 'Starts at $160,000',
|
|
36
|
-
engine: '4.0L Flat 6',
|
|
37
|
-
transmission: 'PDK or 7-Speed Manual',
|
|
38
|
-
horsepower: '502hp',
|
|
39
|
-
torque: '346 lb-ft',
|
|
40
|
-
curbWeight: '3,164 lbs',
|
|
41
|
-
orderStatus: 'Order Placed',
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
id: generateUniqueId(),
|
|
45
|
-
brand: 'BMW',
|
|
46
|
-
model: 'M5 Competition',
|
|
47
|
-
year: '2018',
|
|
48
|
-
price: 'Starts at $105,000',
|
|
49
|
-
engine: 'Twin-Turbo 4.4L V8',
|
|
50
|
-
transmission: 'Automatic',
|
|
51
|
-
horsepower: '627hp',
|
|
52
|
-
torque: '553 lb-ft',
|
|
53
|
-
curbWeight: '4,345 lbs',
|
|
54
|
-
orderStatus: 'Order Fulfilled',
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: generateUniqueId(),
|
|
58
|
-
brand: 'Audi',
|
|
59
|
-
model: 'R8',
|
|
60
|
-
year: '2022',
|
|
61
|
-
price: 'Starts at $148,000',
|
|
62
|
-
engine: '5.2L V10',
|
|
63
|
-
transmission: 'Automatic',
|
|
64
|
-
horsepower: '562hp',
|
|
65
|
-
torque: '408 lb-ft',
|
|
66
|
-
curbWeight: '3,594 lbs',
|
|
67
|
-
orderStatus: 'Order Fulfilled',
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
id: generateUniqueId(),
|
|
71
|
-
brand: 'Lotus',
|
|
72
|
-
model: 'Emira',
|
|
73
|
-
year: '2023',
|
|
74
|
-
price: 'Starts at $78,000',
|
|
75
|
-
engine: 'Supercharged 3.5L V6',
|
|
76
|
-
transmission: 'Automatic or 6-Speed Manual',
|
|
77
|
-
horsepower: '400hp',
|
|
78
|
-
torque: '317 lb-ft',
|
|
79
|
-
curbWeight: '3520 lbs',
|
|
80
|
-
orderStatus: 'Shipped: In Transit',
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
id: generateUniqueId(),
|
|
84
|
-
brand: 'Toyota',
|
|
85
|
-
model: 'Supra',
|
|
86
|
-
year: '1998',
|
|
87
|
-
price: '$40,000 - $80,000',
|
|
88
|
-
engine: '3.0L Inline 6',
|
|
89
|
-
transmission: 'Automatic or 6-Speed Manual',
|
|
90
|
-
horsepower: '320hp',
|
|
91
|
-
torque: '315 lb-ft',
|
|
92
|
-
curbWeight: '3,599 lbs',
|
|
93
|
-
orderStatus: 'Delivered',
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
id: generateUniqueId(),
|
|
97
|
-
brand: 'Nissan',
|
|
98
|
-
model: 'Skyline GT-R',
|
|
99
|
-
year: '1994',
|
|
100
|
-
price: '$45,000 - $90,000',
|
|
101
|
-
engine: '2.6L Twin-Turbo Inline 6',
|
|
102
|
-
transmission: '5-Speed Manual',
|
|
103
|
-
horsepower: '276hp',
|
|
104
|
-
torque: '260 lb-ft',
|
|
105
|
-
curbWeight: '3,153 lbs',
|
|
106
|
-
orderStatus: 'Delivered',
|
|
107
|
-
},
|
|
108
|
-
];
|
|
109
|
-
|
|
110
|
-
interface RowProps {
|
|
111
|
-
data: AutoData;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const expandableSectionStyles = createStyles({
|
|
115
|
-
alignItems: 'flex-start',
|
|
116
|
-
display: 'flex',
|
|
117
|
-
gap: system.space.x4,
|
|
118
|
-
padding: system.space.x8,
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
const expandableHeadingStyles = createStyles({
|
|
122
|
-
margin: 0,
|
|
123
|
-
fontWeight: system.fontWeight.bold,
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
const expandableListStyles = createStyles({
|
|
127
|
-
listStyle: 'none',
|
|
128
|
-
margin: 0,
|
|
129
|
-
padding: 0,
|
|
130
|
-
gap: system.space.x2,
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
function ExpandableRow({data}: RowProps) {
|
|
134
|
-
const [rowExpanded, setRowExpanded] = React.useState(false);
|
|
135
|
-
|
|
136
|
-
return (
|
|
137
|
-
<>
|
|
138
|
-
<Table.Row gridTemplateColumns="4rem repeat(4, 1fr)">
|
|
139
|
-
<Table.Cell>
|
|
140
|
-
<Tooltip title={`${data.brand} ${data.model}`}>
|
|
141
|
-
<TertiaryButton
|
|
142
|
-
size="small"
|
|
143
|
-
icon={rowExpanded ? chevronDownSmallIcon : chevronRightSmallIcon}
|
|
144
|
-
aria-expanded={rowExpanded}
|
|
145
|
-
onClick={() => setRowExpanded(!rowExpanded)}
|
|
146
|
-
/>
|
|
147
|
-
</Tooltip>
|
|
148
|
-
</Table.Cell>
|
|
149
|
-
<Table.Header scope="row">{data.brand}</Table.Header>
|
|
150
|
-
<Table.Cell>{data.model}</Table.Cell>
|
|
151
|
-
<Table.Cell>{data.year}</Table.Cell>
|
|
152
|
-
<Table.Cell>{data.price}</Table.Cell>
|
|
153
|
-
</Table.Row>
|
|
154
|
-
{rowExpanded && (
|
|
155
|
-
<Table.Row>
|
|
156
|
-
<Table.Cell colSpan={5} cs={expandableSectionStyles}>
|
|
157
|
-
<div>
|
|
158
|
-
<Subtext as="h4" size="large" cs={expandableHeadingStyles}>
|
|
159
|
-
Status
|
|
160
|
-
</Subtext>
|
|
161
|
-
<StatusIndicator variant="blue">{data.orderStatus}</StatusIndicator>
|
|
162
|
-
</div>
|
|
163
|
-
<div>
|
|
164
|
-
<Subtext as="h4" size="large" cs={expandableHeadingStyles}>
|
|
165
|
-
Specifications
|
|
166
|
-
</Subtext>
|
|
167
|
-
<ul className={expandableListStyles}>
|
|
168
|
-
<Subtext as="li" size="large">
|
|
169
|
-
Engine: {data.engine}
|
|
170
|
-
</Subtext>
|
|
171
|
-
<Subtext as="li" size="large">
|
|
172
|
-
Transmission: {data.transmission}
|
|
173
|
-
</Subtext>
|
|
174
|
-
<Subtext as="li" size="large">
|
|
175
|
-
Horsepower: {data.horsepower}
|
|
176
|
-
</Subtext>
|
|
177
|
-
<Subtext as="li" size="large">
|
|
178
|
-
Torque: {data.torque}
|
|
179
|
-
</Subtext>
|
|
180
|
-
<Subtext as="li" size="large">
|
|
181
|
-
Curb Weight: {data.curbWeight}
|
|
182
|
-
</Subtext>
|
|
183
|
-
</ul>
|
|
184
|
-
</div>
|
|
185
|
-
</Table.Cell>
|
|
186
|
-
</Table.Row>
|
|
187
|
-
)}
|
|
188
|
-
</>
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export default () => {
|
|
193
|
-
return (
|
|
194
|
-
<>
|
|
195
|
-
<Heading as="h3" id={headingID} size="small">
|
|
196
|
-
Showroom Inventory
|
|
197
|
-
</Heading>
|
|
198
|
-
<Table aria-labelledby={headingID}>
|
|
199
|
-
<Table.Head>
|
|
200
|
-
<Table.Row gridTemplateColumns="4rem repeat(4, 1fr)">
|
|
201
|
-
<Table.Cell></Table.Cell>
|
|
202
|
-
<Table.Header scope="col">Make</Table.Header>
|
|
203
|
-
<Table.Header scope="col">Model</Table.Header>
|
|
204
|
-
<Table.Header scope="col">Year</Table.Header>
|
|
205
|
-
<Table.Header scope="col">Price</Table.Header>
|
|
206
|
-
</Table.Row>
|
|
207
|
-
</Table.Head>
|
|
208
|
-
<Table.Body>
|
|
209
|
-
{autoData.map(item => (
|
|
210
|
-
<ExpandableRow key={item.id} data={item} />
|
|
211
|
-
))}
|
|
212
|
-
</Table.Body>
|
|
213
|
-
</Table>
|
|
214
|
-
</>
|
|
215
|
-
);
|
|
216
|
-
};
|