@workday/canvas-kit-docs 14.0.1 → 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,156 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
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
|
-
|
|
11
|
-
const selectableRowStencil = createStencil({
|
|
12
|
-
base: {
|
|
13
|
-
gridTemplateColumns: '3.5rem repeat(2, 1fr)',
|
|
14
|
-
transition: 'background-color 200ms',
|
|
15
|
-
},
|
|
16
|
-
modifiers: {
|
|
17
|
-
isSelected: {
|
|
18
|
-
true: {
|
|
19
|
-
backgroundColor: system.color.bg.primary.soft,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const tableHeaderStyles = createStyles({
|
|
26
|
-
backgroundColor: system.color.bg.alt.soft,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const tableCellStyles = createStyles({
|
|
30
|
-
backgroundColor: 'transparent',
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
interface SelectableRowProps {
|
|
34
|
-
onSelect?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
35
|
-
rowData: PizzaTopping;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const SelectableRow = createComponent('tr')({
|
|
39
|
-
displayName: 'SelectableRow',
|
|
40
|
-
Component: ({onSelect, rowData}: SelectableRowProps) => {
|
|
41
|
-
return (
|
|
42
|
-
<Table.Row cs={selectableRowStencil({isSelected: rowData.checked})}>
|
|
43
|
-
<Table.Cell cs={tableCellStyles}>
|
|
44
|
-
<Tooltip title={rowData.name}>
|
|
45
|
-
<Checkbox checked={rowData.checked} onChange={onSelect} />
|
|
46
|
-
</Tooltip>
|
|
47
|
-
</Table.Cell>
|
|
48
|
-
<Table.Header cs={tableCellStyles} scope="row">
|
|
49
|
-
{rowData.name}
|
|
50
|
-
</Table.Header>
|
|
51
|
-
<Table.Cell cs={tableCellStyles}>{rowData.amount}</Table.Cell>
|
|
52
|
-
</Table.Row>
|
|
53
|
-
);
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
interface PizzaTopping {
|
|
58
|
-
name: string;
|
|
59
|
-
amount: string;
|
|
60
|
-
checked: boolean;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const pizzaToppingData: PizzaTopping[] = [
|
|
64
|
-
{name: 'Pepperoni', amount: '2.5 oz.', checked: false},
|
|
65
|
-
{name: 'Mozzarella', amount: '5 oz.', checked: false},
|
|
66
|
-
{name: 'Basil', amount: '10 Leaves', checked: false},
|
|
67
|
-
{name: 'Roasted Red Peppers', amount: '3 oz.', checked: false},
|
|
68
|
-
{name: 'Mushrooms', amount: '2 oz.', checked: false},
|
|
69
|
-
];
|
|
70
|
-
|
|
71
|
-
const headingID = generateUniqueId();
|
|
72
|
-
|
|
73
|
-
type SelectAll = 'checked' | 'indeterminate' | 'unchecked';
|
|
74
|
-
|
|
75
|
-
export default () => {
|
|
76
|
-
const [selectAllState, setSelectAllState] = React.useState<SelectAll>('unchecked');
|
|
77
|
-
const [toppings, setToppings] = React.useState(pizzaToppingData);
|
|
78
|
-
|
|
79
|
-
const handleToppingChange = (name: string) => {
|
|
80
|
-
// Toggle the selected item's checked state and update state
|
|
81
|
-
const updatedToppings = toppings.map(topping => {
|
|
82
|
-
if (topping.name === name) {
|
|
83
|
-
return {...topping, checked: !topping.checked};
|
|
84
|
-
} else {
|
|
85
|
-
return topping;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
setToppings(updatedToppings);
|
|
89
|
-
|
|
90
|
-
// Update the Select All checkbox state
|
|
91
|
-
const selectedToppings = updatedToppings.filter(topping => topping.checked === true);
|
|
92
|
-
// If no toppings are selected, set the Select All checkbox to 'unchecked'
|
|
93
|
-
if (selectedToppings.length === 0) {
|
|
94
|
-
setSelectAllState('unchecked');
|
|
95
|
-
// If all toppings are selected, set the Select All checkbox to 'checked'
|
|
96
|
-
} else if (selectedToppings.length === updatedToppings.length) {
|
|
97
|
-
setSelectAllState('checked');
|
|
98
|
-
// Otherwise, set the Select All checkbox to 'indeterminate'
|
|
99
|
-
} else {
|
|
100
|
-
setSelectAllState('indeterminate');
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
const handleSelectAll = () => {
|
|
105
|
-
// If the Select All checkbox is in a checked or indeterminate state,
|
|
106
|
-
// update it to 'unchecked', and uncheck all topping checkboxes
|
|
107
|
-
if (selectAllState === 'checked' || selectAllState === 'indeterminate') {
|
|
108
|
-
setSelectAllState('unchecked');
|
|
109
|
-
const updatedToppingData = toppings.map(topping => ({...topping, checked: false}));
|
|
110
|
-
setToppings(updatedToppingData);
|
|
111
|
-
}
|
|
112
|
-
// If the Select All checkbox is in an unchecked state,
|
|
113
|
-
// update it to 'checked', and check all topping checkboxes
|
|
114
|
-
if (selectAllState === 'unchecked') {
|
|
115
|
-
setSelectAllState('checked');
|
|
116
|
-
const updatedToppingData = toppings.map(topping => ({...topping, checked: true}));
|
|
117
|
-
setToppings(updatedToppingData);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
return (
|
|
122
|
-
<>
|
|
123
|
-
<Heading as="h3" id={headingID} size="small">
|
|
124
|
-
Select your pizza toppings
|
|
125
|
-
</Heading>
|
|
126
|
-
<Table aria-labelledby={headingID}>
|
|
127
|
-
<Table.Row gridTemplateColumns="3.5rem repeat(2, 1fr)">
|
|
128
|
-
<Table.Cell cs={tableHeaderStyles}>
|
|
129
|
-
<Tooltip title="Select All">
|
|
130
|
-
<Checkbox
|
|
131
|
-
checked={selectAllState === 'checked'}
|
|
132
|
-
indeterminate={selectAllState === 'indeterminate'}
|
|
133
|
-
onChange={handleSelectAll}
|
|
134
|
-
/>
|
|
135
|
-
</Tooltip>
|
|
136
|
-
</Table.Cell>
|
|
137
|
-
<Table.Header scope="col" cs={tableHeaderStyles}>
|
|
138
|
-
Toppings
|
|
139
|
-
</Table.Header>
|
|
140
|
-
<Table.Header scope="col" cs={tableHeaderStyles}>
|
|
141
|
-
Amount
|
|
142
|
-
</Table.Header>
|
|
143
|
-
</Table.Row>
|
|
144
|
-
<Table.Body>
|
|
145
|
-
{toppings.map(rowData => (
|
|
146
|
-
<SelectableRow
|
|
147
|
-
key={rowData.name}
|
|
148
|
-
rowData={rowData}
|
|
149
|
-
onSelect={() => handleToppingChange(rowData.name)}
|
|
150
|
-
/>
|
|
151
|
-
))}
|
|
152
|
-
</Table.Body>
|
|
153
|
-
</Table>
|
|
154
|
-
</>
|
|
155
|
-
);
|
|
156
|
-
};
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {createComponent} from '@workday/canvas-kit-react/common';
|
|
4
|
-
import {Table} from '@workday/canvas-kit-react/table';
|
|
5
|
-
import {Tooltip} from '@workday/canvas-kit-react/tooltip';
|
|
6
|
-
import {TertiaryButton} from '@workday/canvas-kit-react/button';
|
|
7
|
-
import {Text} from '@workday/canvas-kit-react/text';
|
|
8
|
-
import {sortDownIcon, sortUpIcon} from '@workday/canvas-system-icons-web';
|
|
9
|
-
import {createStyles} from '@workday/canvas-kit-styling';
|
|
10
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
11
|
-
|
|
12
|
-
interface CountryData {
|
|
13
|
-
country: string;
|
|
14
|
-
capital: string;
|
|
15
|
-
population: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const countryData: CountryData[] = [
|
|
19
|
-
{country: 'Australia', capital: 'Canberra', population: 25690000},
|
|
20
|
-
{country: 'Bahamas', capital: 'Nassau', population: 407906},
|
|
21
|
-
{country: 'Canada', capital: 'Ottawa', population: 38250000},
|
|
22
|
-
{country: 'Fiji', capital: 'Suva', population: 924610},
|
|
23
|
-
{country: 'Ghana', capital: 'Accra', population: 32830000},
|
|
24
|
-
{country: 'Hong Kong', capital: 'City of Victoria', population: 7413000},
|
|
25
|
-
{country: 'India', capital: 'New Delhi', population: 1408000000},
|
|
26
|
-
{country: 'Ireland', capital: 'Dublin', population: 5033000},
|
|
27
|
-
{country: 'Jamaica', capital: 'Kingston', population: 2828000},
|
|
28
|
-
{country: 'Kenya', capital: 'Nairobi', population: 53010000},
|
|
29
|
-
{country: 'Micronesia', capital: 'Palikir', population: 113131},
|
|
30
|
-
{country: 'New Zealand', capital: 'Wellington', population: 5123000},
|
|
31
|
-
{country: 'Philippines', capital: 'Manila', population: 113900000},
|
|
32
|
-
{country: 'Puerto Rico', capital: 'San Juan', population: 3264000},
|
|
33
|
-
{country: 'Samoa', capital: 'Apia', population: 218764},
|
|
34
|
-
{country: 'Singapore', capital: 'Singapore', population: 5454000},
|
|
35
|
-
{country: 'Tanzania', capital: 'Dodoma', population: 63590000},
|
|
36
|
-
{country: 'United Kingdom', capital: 'London', population: 67330000},
|
|
37
|
-
{country: 'United States', capital: 'Washington, D.C.', population: 331900000},
|
|
38
|
-
{country: 'Zimbabwe', capital: 'Harare', population: 15990000},
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
type SortOrder = 'ascending' | 'descending' | 'none';
|
|
42
|
-
|
|
43
|
-
interface HeaderRowState {
|
|
44
|
-
column1SortDirection: SortOrder;
|
|
45
|
-
column2SortDirection: SortOrder;
|
|
46
|
-
column3SortDirection: SortOrder;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
interface HeaderRowAction {
|
|
50
|
-
column: 'Country' | 'Capital' | 'Population';
|
|
51
|
-
payload: CountryData[];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const initialHeaderRowState: HeaderRowState = {
|
|
55
|
-
column1SortDirection: 'none',
|
|
56
|
-
column2SortDirection: 'none',
|
|
57
|
-
column3SortDirection: 'none',
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Given the current sort order, return the next sort order
|
|
62
|
-
*/
|
|
63
|
-
function getNextSortOrder(sortOrder: SortOrder) {
|
|
64
|
-
return sortOrder === 'ascending' ? 'descending' : 'ascending';
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function headerRowReducer(state: HeaderRowState, action: HeaderRowAction): HeaderRowState {
|
|
68
|
-
switch (action.column) {
|
|
69
|
-
case 'Country':
|
|
70
|
-
if (state.column1SortDirection === 'ascending') {
|
|
71
|
-
action.payload.sort((a, b) => b.country.localeCompare(a.country));
|
|
72
|
-
} else {
|
|
73
|
-
action.payload.sort((a, b) => a.country.localeCompare(b.country));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
...initialHeaderRowState,
|
|
78
|
-
column1SortDirection: getNextSortOrder(state.column1SortDirection),
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
case 'Capital':
|
|
82
|
-
if (state.column2SortDirection === 'ascending') {
|
|
83
|
-
action.payload.sort((a, b) => b.capital.localeCompare(a.capital));
|
|
84
|
-
} else {
|
|
85
|
-
action.payload.sort((a, b) => a.capital.localeCompare(b.capital));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
...initialHeaderRowState,
|
|
90
|
-
column2SortDirection: getNextSortOrder(state.column2SortDirection),
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
case 'Population':
|
|
94
|
-
if (state.column3SortDirection === 'ascending') {
|
|
95
|
-
action.payload.sort((a, b) => b.population - a.population);
|
|
96
|
-
} else {
|
|
97
|
-
action.payload.sort();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
...initialHeaderRowState,
|
|
102
|
-
column3SortDirection: getNextSortOrder(state.column3SortDirection),
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
default:
|
|
106
|
-
return initialHeaderRowState;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
interface SortableColumnHeaderProps {
|
|
111
|
-
label: string;
|
|
112
|
-
onSortAction: (label: string) => void;
|
|
113
|
-
children?: React.ReactNode;
|
|
114
|
-
sortOrder: SortOrder;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const getSortIcon = (sortOrder?: SortOrder) => {
|
|
118
|
-
if (sortOrder === 'ascending') {
|
|
119
|
-
return sortUpIcon;
|
|
120
|
-
} else if (sortOrder === 'descending') {
|
|
121
|
-
return sortDownIcon;
|
|
122
|
-
} else {
|
|
123
|
-
return undefined;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const SortableColumnHeader = createComponent('th')({
|
|
128
|
-
displayName: 'SortableColumnHeader',
|
|
129
|
-
Component: (
|
|
130
|
-
{label, sortOrder, onSortAction, children, ...elemProps}: SortableColumnHeaderProps,
|
|
131
|
-
ref
|
|
132
|
-
) => {
|
|
133
|
-
return (
|
|
134
|
-
<Table.Header ref={ref} scope="col" aria-sort={sortOrder} {...elemProps}>
|
|
135
|
-
<Tooltip type="description" title={`Sort ${getNextSortOrder(sortOrder)}`}>
|
|
136
|
-
<TertiaryButton
|
|
137
|
-
icon={getSortIcon(sortOrder)}
|
|
138
|
-
iconPosition="end"
|
|
139
|
-
onClick={() => onSortAction(label)}
|
|
140
|
-
>
|
|
141
|
-
{children}
|
|
142
|
-
</TertiaryButton>
|
|
143
|
-
</Tooltip>
|
|
144
|
-
</Table.Header>
|
|
145
|
-
);
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
const textStyles = createStyles({
|
|
150
|
-
paddingInlineStart: system.space.x3,
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
export default () => {
|
|
154
|
-
const [headerRowState, headerRowDispatch] = React.useReducer(
|
|
155
|
-
headerRowReducer,
|
|
156
|
-
initialHeaderRowState
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
function sortColumnHandler(columnName) {
|
|
160
|
-
headerRowDispatch({
|
|
161
|
-
column: columnName,
|
|
162
|
-
payload: countryData,
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return (
|
|
167
|
-
<Table maxHeight="40rem">
|
|
168
|
-
<Table.Caption>Population Listed by Country (2021)</Table.Caption>
|
|
169
|
-
<Table.Head>
|
|
170
|
-
<Table.Row>
|
|
171
|
-
<SortableColumnHeader
|
|
172
|
-
label="Country"
|
|
173
|
-
sortOrder={headerRowState.column1SortDirection as SortOrder}
|
|
174
|
-
onSortAction={sortColumnHandler}
|
|
175
|
-
>
|
|
176
|
-
Country
|
|
177
|
-
</SortableColumnHeader>
|
|
178
|
-
<SortableColumnHeader
|
|
179
|
-
label="Capital"
|
|
180
|
-
sortOrder={headerRowState.column2SortDirection as SortOrder}
|
|
181
|
-
onSortAction={sortColumnHandler}
|
|
182
|
-
>
|
|
183
|
-
Capital
|
|
184
|
-
</SortableColumnHeader>
|
|
185
|
-
<SortableColumnHeader
|
|
186
|
-
label="Population"
|
|
187
|
-
sortOrder={headerRowState.column3SortDirection as SortOrder}
|
|
188
|
-
onSortAction={sortColumnHandler}
|
|
189
|
-
>
|
|
190
|
-
Population
|
|
191
|
-
</SortableColumnHeader>
|
|
192
|
-
</Table.Row>
|
|
193
|
-
</Table.Head>
|
|
194
|
-
<Table.Body>
|
|
195
|
-
{countryData.map(item => {
|
|
196
|
-
return (
|
|
197
|
-
<Table.Row key={item.country}>
|
|
198
|
-
<Table.Header scope="row">
|
|
199
|
-
<Text cs={textStyles}>{item.country}</Text>
|
|
200
|
-
</Table.Header>
|
|
201
|
-
<Table.Cell>
|
|
202
|
-
<Text cs={textStyles}>{item.capital}</Text>
|
|
203
|
-
</Table.Cell>
|
|
204
|
-
<Table.Cell>
|
|
205
|
-
<Text cs={textStyles}>{item.population.toLocaleString()}</Text>
|
|
206
|
-
</Table.Cell>
|
|
207
|
-
</Table.Row>
|
|
208
|
-
);
|
|
209
|
-
})}
|
|
210
|
-
</Table.Body>
|
|
211
|
-
</Table>
|
|
212
|
-
);
|
|
213
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import React, {useState} from 'react';
|
|
2
|
-
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
3
|
-
import {BodyText, Heading} from '@workday/canvas-kit-react/text';
|
|
4
|
-
import {AriaLiveRegion} from '@workday/canvas-kit-react/common';
|
|
5
|
-
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
6
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
7
|
-
import {createStyles, px2rem} from '@workday/canvas-kit-styling';
|
|
8
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
9
|
-
|
|
10
|
-
const fruits = [
|
|
11
|
-
'Apples',
|
|
12
|
-
'Oranges',
|
|
13
|
-
'Bananas',
|
|
14
|
-
'Lemons',
|
|
15
|
-
'Limes',
|
|
16
|
-
'Strawberries',
|
|
17
|
-
'Raspberries',
|
|
18
|
-
'Blackberries',
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
const liveRegionStyle = createStyles({
|
|
22
|
-
border: `${px2rem(1)} solid ${system.color.border.caution.strong}`,
|
|
23
|
-
backgroundColor: system.color.bg.caution.default,
|
|
24
|
-
padding: system.space.x2,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const listStyles = {paddingLeft: '0px'};
|
|
28
|
-
|
|
29
|
-
const listItemStyles = createStyles({
|
|
30
|
-
listStyle: 'none',
|
|
31
|
-
paddingLeft: system.space.zero,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
let filteredFruits = fruits;
|
|
35
|
-
|
|
36
|
-
export default () => {
|
|
37
|
-
const [filter, setFilter] = useState('');
|
|
38
|
-
function handleFilter(e) {
|
|
39
|
-
filteredFruits = fruits.filter(i => i.toUpperCase().indexOf(e.target.value.toUpperCase()) >= 0);
|
|
40
|
-
setFilter(e.target.value);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<>
|
|
45
|
-
<Flex gap="1rem">
|
|
46
|
-
<Heading size="small">Fruits</Heading>
|
|
47
|
-
<AriaLiveRegion>
|
|
48
|
-
<BodyText size="small" cs={liveRegionStyle}>
|
|
49
|
-
{`Showing ${filteredFruits.length} of ${fruits.length}`}
|
|
50
|
-
</BodyText>
|
|
51
|
-
</AriaLiveRegion>
|
|
52
|
-
</Flex>
|
|
53
|
-
<FormField>
|
|
54
|
-
<FormField.Label>Filter Items:</FormField.Label>
|
|
55
|
-
<FormField.Field>
|
|
56
|
-
<FormField.Input as={TextInput} value={filter} onChange={handleFilter} />
|
|
57
|
-
</FormField.Field>
|
|
58
|
-
</FormField>
|
|
59
|
-
<ul style={listStyles}>
|
|
60
|
-
{filteredFruits.map(i => (
|
|
61
|
-
<BodyText size="small" as="li" cs={listItemStyles} key={i}>
|
|
62
|
-
{i}
|
|
63
|
-
</BodyText>
|
|
64
|
-
))}
|
|
65
|
-
</ul>
|
|
66
|
-
</>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React, {useState, useRef} from 'react';
|
|
2
|
-
import {AriaLiveRegion, AccessibleHide} from '@workday/canvas-kit-react/common';
|
|
3
|
-
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
-
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
5
|
-
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
6
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
7
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
8
|
-
|
|
9
|
-
export default () => {
|
|
10
|
-
const [message, setMessage] = useState('This is an ARIA Live Region!');
|
|
11
|
-
const inputRef = useRef();
|
|
12
|
-
function handleSendMessage() {
|
|
13
|
-
setMessage(inputRef.current.value);
|
|
14
|
-
inputRef.current.value = '';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<>
|
|
19
|
-
<Flex gap={`var(${system.space.x4})`} alignItems="flex-end">
|
|
20
|
-
<FormField>
|
|
21
|
-
<FormField.Label>Type your message:</FormField.Label>
|
|
22
|
-
<FormField.Field>
|
|
23
|
-
<FormField.Input as={TextInput} ref={inputRef} />
|
|
24
|
-
</FormField.Field>
|
|
25
|
-
</FormField>
|
|
26
|
-
<PrimaryButton onClick={handleSendMessage}>Send Message</PrimaryButton>
|
|
27
|
-
</Flex>
|
|
28
|
-
<AriaLiveRegion>
|
|
29
|
-
<AccessibleHide>{message}</AccessibleHide>
|
|
30
|
-
</AriaLiveRegion>
|
|
31
|
-
</>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import React, {useState} from 'react';
|
|
2
|
-
import {AccessibleHide, AriaLiveRegion, useUniqueId} from '@workday/canvas-kit-react/common';
|
|
3
|
-
import {notificationsIcon, inboxIcon, assistantIcon} from '@workday/canvas-system-icons-web';
|
|
4
|
-
import {space} from '@workday/canvas-kit-react/tokens';
|
|
5
|
-
import {SecondaryButton, TertiaryButton} from '@workday/canvas-kit-react/button';
|
|
6
|
-
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
7
|
-
import {Tooltip} from '@workday/canvas-kit-react/tooltip';
|
|
8
|
-
import {CountBadge} from '@workday/canvas-kit-react/badge';
|
|
9
|
-
|
|
10
|
-
const MyTasksLiveBadge = ({cnt}) => {
|
|
11
|
-
// use tooltip to assign name,
|
|
12
|
-
// use AriaLiveRegion inside button,
|
|
13
|
-
// assign name to live region referencing the button,
|
|
14
|
-
// use BadgeCount inside live region,
|
|
15
|
-
// use AccessibleHide to create invisible word "new" after badge
|
|
16
|
-
// use aria-describedby on button, referencing live region container to set description
|
|
17
|
-
// Safari + VO => not working at all
|
|
18
|
-
// JAWS 2024 + Chrome / Edge => works as expected :)
|
|
19
|
-
// NVDA + Chrome / Edge => works as expected :)
|
|
20
|
-
// Firefox => isn't announcing description on focus, only announces "X New" live (missing button name)
|
|
21
|
-
const badgeID = useUniqueId();
|
|
22
|
-
const myTasksID = useUniqueId();
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<Tooltip title="My Tasks">
|
|
26
|
-
<TertiaryButton icon={inboxIcon} id={myTasksID} aria-describedby={badgeID}>
|
|
27
|
-
<AriaLiveRegion id={badgeID} aria-labelledby={myTasksID}>
|
|
28
|
-
<CountBadge count={cnt} />
|
|
29
|
-
<AccessibleHide>New</AccessibleHide>
|
|
30
|
-
</AriaLiveRegion>
|
|
31
|
-
</TertiaryButton>
|
|
32
|
-
</Tooltip>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// use AriaLiveRegion around the button,
|
|
37
|
-
// use Tooltip to assign the name of the button,
|
|
38
|
-
// make sure Tooltip title string includes count value
|
|
39
|
-
// Chrome + VO => Announces name "notifications X new" and innerText 'X'
|
|
40
|
-
// Safari + VO => Works as expected :)
|
|
41
|
-
// JAWS 2024 => Announces full button name twice (previous state, then new state)
|
|
42
|
-
// JAWS 2024 + Firefox => Works as expected :)
|
|
43
|
-
// NVDA (All Browsers) => Atomic property isn't working, only announcing number change, announces twice
|
|
44
|
-
const NotificationsLiveBadge = ({cnt}) => (
|
|
45
|
-
<AriaLiveRegion>
|
|
46
|
-
<Tooltip title={`Notifications ${cnt} new`}>
|
|
47
|
-
<TertiaryButton icon={notificationsIcon}>
|
|
48
|
-
<CountBadge count={cnt} />
|
|
49
|
-
</TertiaryButton>
|
|
50
|
-
</Tooltip>
|
|
51
|
-
</AriaLiveRegion>
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const AssistantLiveBadge = ({cnt}) => {
|
|
55
|
-
// use AriaLiveRegion around the button
|
|
56
|
-
// use muted type Tooltip (avoid using aria-label to name button)
|
|
57
|
-
// use AccessibleHide inside of button to compose name
|
|
58
|
-
// Chrome + VO => announces twice
|
|
59
|
-
// Safari + VO => works as expected :)
|
|
60
|
-
const lbl = 'Workday Assistant';
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<AriaLiveRegion>
|
|
64
|
-
<Tooltip title={lbl} type="muted">
|
|
65
|
-
<TertiaryButton icon={assistantIcon}>
|
|
66
|
-
<AccessibleHide>{lbl}</AccessibleHide>
|
|
67
|
-
<CountBadge count={cnt} />
|
|
68
|
-
<AccessibleHide>New</AccessibleHide>
|
|
69
|
-
</TertiaryButton>
|
|
70
|
-
</Tooltip>
|
|
71
|
-
</AriaLiveRegion>
|
|
72
|
-
);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export default () => {
|
|
76
|
-
const [counter, setCounter] = useState(0);
|
|
77
|
-
const [notifications, setNotifications] = useState(0);
|
|
78
|
-
const [assistant, setAssistant] = useState(0);
|
|
79
|
-
|
|
80
|
-
const handleAddTask = () => setCounter(prev => prev + 1);
|
|
81
|
-
const handleAddNotification = () => setNotifications(prev => prev + 1);
|
|
82
|
-
const handleAssistant = () => setAssistant(prev => prev + 1);
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<>
|
|
86
|
-
<Flex padding={space.s} gap={space.s} as="header">
|
|
87
|
-
<AssistantLiveBadge cnt={assistant} />
|
|
88
|
-
<NotificationsLiveBadge cnt={notifications} />
|
|
89
|
-
<MyTasksLiveBadge cnt={counter} />
|
|
90
|
-
</Flex>
|
|
91
|
-
<Flex padding={space.s} gap={space.s} as="main">
|
|
92
|
-
<SecondaryButton onClick={handleAssistant}>Add a Message</SecondaryButton>
|
|
93
|
-
<SecondaryButton onClick={handleAddNotification}>Add a Notification</SecondaryButton>
|
|
94
|
-
<SecondaryButton onClick={handleAddTask}>Add an item to My Tasks</SecondaryButton>
|
|
95
|
-
</Flex>
|
|
96
|
-
</>
|
|
97
|
-
);
|
|
98
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React, {useState, useRef} from 'react';
|
|
2
|
-
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
3
|
-
import {AriaLiveRegion, changeFocus} from '@workday/canvas-kit-react/common';
|
|
4
|
-
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
5
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
6
|
-
|
|
7
|
-
export default () => {
|
|
8
|
-
const errMsg = 'Error: First name is required.';
|
|
9
|
-
const [hasError, setHasError] = useState(false);
|
|
10
|
-
const inputRef = useRef();
|
|
11
|
-
const handleBlur = e => setHasError(e.target.value.trim().length === 0);
|
|
12
|
-
const handleSubmit = () => hasError && changeFocus(inputRef.current);
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<>
|
|
16
|
-
<FormField error={hasError ? 'error' : undefined} isRequired={true}>
|
|
17
|
-
<FormField.Label>First Name:</FormField.Label>
|
|
18
|
-
<FormField.Field>
|
|
19
|
-
<FormField.Input onBlur={handleBlur} as={TextInput} ref={inputRef} />
|
|
20
|
-
<FormField.Hint>
|
|
21
|
-
<AriaLiveRegion>{hasError && errMsg}</AriaLiveRegion>
|
|
22
|
-
</FormField.Hint>
|
|
23
|
-
</FormField.Field>
|
|
24
|
-
</FormField>
|
|
25
|
-
<PrimaryButton onClick={handleSubmit}>Continue</PrimaryButton>
|
|
26
|
-
</>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import React, {useState, useRef} from 'react';
|
|
2
|
-
import {AriaLiveRegion} from '@workday/canvas-kit-react/common';
|
|
3
|
-
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
5
|
-
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
6
|
-
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
7
|
-
import {Text} from '@workday/canvas-kit-react/text';
|
|
8
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
9
|
-
import {createStyles, px2rem} from '@workday/canvas-kit-styling';
|
|
10
|
-
|
|
11
|
-
const liveRegionStyle = createStyles({
|
|
12
|
-
border: `${px2rem(1)} solid ${system.color.bg.caution.stronger}`,
|
|
13
|
-
backgroundColor: system.color.bg.caution.default,
|
|
14
|
-
padding: system.space.x4,
|
|
15
|
-
display: 'block',
|
|
16
|
-
margin: system.space.x4 + ' 0',
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export default () => {
|
|
20
|
-
const [message, setMessage] = useState('This is an ARIA Live Region!');
|
|
21
|
-
const inputRef = useRef();
|
|
22
|
-
|
|
23
|
-
function handleSendMessage() {
|
|
24
|
-
setMessage(inputRef.current.value);
|
|
25
|
-
inputRef.current.value = '';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<>
|
|
30
|
-
<AriaLiveRegion>
|
|
31
|
-
<Text cs={liveRegionStyle}>{message}</Text>
|
|
32
|
-
</AriaLiveRegion>
|
|
33
|
-
<Flex gap={`var(${system.space.x4})`} alignItems="flex-end">
|
|
34
|
-
<FormField>
|
|
35
|
-
<FormField.Label>Type your message:</FormField.Label>
|
|
36
|
-
<FormField.Field>
|
|
37
|
-
<FormField.Input as={TextInput} ref={inputRef} />
|
|
38
|
-
</FormField.Field>
|
|
39
|
-
</FormField>
|
|
40
|
-
<PrimaryButton onClick={handleSendMessage}>Send Message</PrimaryButton>
|
|
41
|
-
</Flex>
|
|
42
|
-
</>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
File without changes
|
/package/dist/mdx/react/_examples/{examples/Tooltips → mdx/examples}/ListOfUploadedFiles.tsx
RENAMED
|
File without changes
|