@workday/canvas-kit-docs 14.0.1 → 14.0.3
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/dist/mdx/tokens/TokenMigrationMappingColors.mdx +6 -6
- package/package.json +7 -7
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.3",
|
|
4
4
|
"description": "Documentation components of Canvas Kit components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"@emotion/styled": "^11.6.0",
|
|
46
46
|
"@stackblitz/sdk": "^1.11.0",
|
|
47
47
|
"@storybook/csf": "0.0.1",
|
|
48
|
-
"@workday/canvas-kit-labs-react": "^14.0.
|
|
49
|
-
"@workday/canvas-kit-preview-react": "^14.0.
|
|
50
|
-
"@workday/canvas-kit-react": "^14.0.
|
|
51
|
-
"@workday/canvas-kit-styling": "^14.0.
|
|
48
|
+
"@workday/canvas-kit-labs-react": "^14.0.3",
|
|
49
|
+
"@workday/canvas-kit-preview-react": "^14.0.3",
|
|
50
|
+
"@workday/canvas-kit-react": "^14.0.3",
|
|
51
|
+
"@workday/canvas-kit-styling": "^14.0.3",
|
|
52
52
|
"@workday/canvas-system-icons-web": "^3.0.36",
|
|
53
|
-
"@workday/canvas-tokens-web": "^3.
|
|
53
|
+
"@workday/canvas-tokens-web": "^3.1.1",
|
|
54
54
|
"markdown-to-jsx": "^7.2.0",
|
|
55
55
|
"react-syntax-highlighter": "^15.5.0",
|
|
56
56
|
"ts-node": "^10.9.1"
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"mkdirp": "^1.0.3",
|
|
62
62
|
"typescript": "5.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "241a81d0e3d2ef4db433277fcdb453df5700be4d"
|
|
65
65
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
## Accessibility Overview Coming Soon!
|
|
2
|
-
|
|
3
|
-
Canvas Kit is built with accessibility in mind. We continuously strive to provide a robust set of
|
|
4
|
-
accessible components that are easy to customize for your specific needs.
|
|
5
|
-
|
|
6
|
-
## What you can expect
|
|
7
|
-
|
|
8
|
-
- Introduction to the accessibility tree
|
|
9
|
-
- Introduction to the accessible name and description calculation
|
|
10
|
-
- Supporting Windows 11 high contrast desktop themes
|
|
11
|
-
- Responsiveness and reflow
|
|
12
|
-
- Introduction to ARIA live regions
|
|
13
|
-
|
|
14
|
-
### Bigger and better examples
|
|
15
|
-
|
|
16
|
-
- Page layouts with landmark regions and structured content headings
|
|
17
|
-
- Cards, clickable cards, and lists of cards
|
|
18
|
-
- Forms and error handling
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import React, {useState} from 'react';
|
|
2
|
-
|
|
3
|
-
import {AriaLiveRegion} from '@workday/canvas-kit-react/common';
|
|
4
|
-
import {BodyText, Heading} from '@workday/canvas-kit-react/text';
|
|
5
|
-
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
6
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
7
|
-
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
8
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
9
|
-
import {createStyles, px2rem} from '@workday/canvas-kit-styling';
|
|
10
|
-
|
|
11
|
-
const fruits = [
|
|
12
|
-
'Apples',
|
|
13
|
-
'Oranges',
|
|
14
|
-
'Bananas',
|
|
15
|
-
'Lemons',
|
|
16
|
-
'Limes',
|
|
17
|
-
'Strawberries',
|
|
18
|
-
'Raspberries',
|
|
19
|
-
'Blackberries',
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
const liveRegionStyle = createStyles({
|
|
23
|
-
border: `${px2rem(1)} solid ${system.color.bg.caution.stronger}`,
|
|
24
|
-
backgroundColor: system.color.bg.caution.default,
|
|
25
|
-
padding: system.space.x2,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const listStyles = createStyles({
|
|
29
|
-
paddingLeft: system.space.zero,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const listItemStyles = createStyles({
|
|
33
|
-
listStyle: 'none',
|
|
34
|
-
paddingLeft: system.space.zero,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const flexStyles = createStyles({
|
|
38
|
-
gap: system.space.x4,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
let filteredFruits = fruits;
|
|
42
|
-
|
|
43
|
-
export default () => {
|
|
44
|
-
const [filter, setFilter] = useState('');
|
|
45
|
-
function handleFilter(e) {
|
|
46
|
-
filteredFruits = fruits.filter(i => i.toUpperCase().indexOf(e.target.value.toUpperCase()) >= 0);
|
|
47
|
-
setFilter(e.target.value);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<>
|
|
52
|
-
<Flex cs={flexStyles}>
|
|
53
|
-
<Heading size="small">Fruits</Heading>
|
|
54
|
-
<AriaLiveRegion>
|
|
55
|
-
<BodyText size="small" cs={liveRegionStyle}>
|
|
56
|
-
{`Showing ${filteredFruits.length} of ${fruits.length}`}
|
|
57
|
-
</BodyText>
|
|
58
|
-
</AriaLiveRegion>
|
|
59
|
-
</Flex>
|
|
60
|
-
<FormField>
|
|
61
|
-
<FormField.Label>Filter Items:</FormField.Label>
|
|
62
|
-
<FormField.Input as={TextInput} value={filter} onChange={handleFilter} />
|
|
63
|
-
</FormField>
|
|
64
|
-
<ul className={listStyles}>
|
|
65
|
-
{filteredFruits.map(i => (
|
|
66
|
-
<BodyText size="small" as="li" cs={listItemStyles} key={i}>
|
|
67
|
-
{i}
|
|
68
|
-
</BodyText>
|
|
69
|
-
))}
|
|
70
|
-
</ul>
|
|
71
|
-
</>
|
|
72
|
-
);
|
|
73
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {AccessibleHide, AriaLiveRegion} 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
|
-
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
7
|
-
import {Text} from '@workday/canvas-kit-react/text';
|
|
8
|
-
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
9
|
-
import {createStyles} from '@workday/canvas-kit-styling';
|
|
10
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
11
|
-
|
|
12
|
-
let liveRegionStr = '';
|
|
13
|
-
|
|
14
|
-
const flexStyles = createStyles({
|
|
15
|
-
gap: system.space.x4,
|
|
16
|
-
alignItems: 'center',
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export default () => {
|
|
20
|
-
const [message, setMessage] = React.useState('');
|
|
21
|
-
|
|
22
|
-
function handleChange(e) {
|
|
23
|
-
setMessage(e.target.value);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function handleSendMessage(e) {
|
|
27
|
-
e.preventDefault();
|
|
28
|
-
liveRegionStr = message;
|
|
29
|
-
setMessage('');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<>
|
|
34
|
-
<Flex as="form" aria-label="Hidden Live Region" onSubmit={handleSendMessage} cs={flexStyles}>
|
|
35
|
-
<FormField>
|
|
36
|
-
<FormField.Label>Type your message:</FormField.Label>
|
|
37
|
-
<FormField.Input as={TextInput} onChange={handleChange} value={message} />
|
|
38
|
-
</FormField>
|
|
39
|
-
<PrimaryButton type="submit">Send Message</PrimaryButton>
|
|
40
|
-
</Flex>
|
|
41
|
-
<AriaLiveRegion>
|
|
42
|
-
<Text as={AccessibleHide}>{liveRegionStr}</Text>
|
|
43
|
-
</AriaLiveRegion>
|
|
44
|
-
</>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
@@ -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,31 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {AriaLiveRegion, changeFocus} from '@workday/canvas-kit-react/common';
|
|
3
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
4
|
-
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
5
|
-
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
6
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
7
|
-
import {createStyles} from '@workday/canvas-kit-styling';
|
|
8
|
-
|
|
9
|
-
const hintStyles = createStyles({
|
|
10
|
-
height: system.space.x6,
|
|
11
|
-
});
|
|
12
|
-
export default () => {
|
|
13
|
-
const errMsg = 'Error: First name is required.';
|
|
14
|
-
const [hasError, setHasError] = React.useState('no');
|
|
15
|
-
const inputRef = React.useRef(null);
|
|
16
|
-
const handleBlur = e => setHasError(e.target.value.trim().length === 0 ? 'error' : 'no');
|
|
17
|
-
const handleSubmit = () => hasError && changeFocus(inputRef.current);
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<>
|
|
21
|
-
<FormField error={hasError === 'error' ? 'error' : undefined} isRequired={true}>
|
|
22
|
-
<FormField.Label>First Name:</FormField.Label>
|
|
23
|
-
<FormField.Input as={TextInput} onBlur={handleBlur} ref={inputRef} />
|
|
24
|
-
<FormField.Hint cs={hintStyles}>
|
|
25
|
-
<AriaLiveRegion>{hasError === 'error' && errMsg}</AriaLiveRegion>
|
|
26
|
-
</FormField.Hint>
|
|
27
|
-
</FormField>
|
|
28
|
-
<PrimaryButton onClick={handleSubmit}>Continue</PrimaryButton>
|
|
29
|
-
</>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {AriaLiveRegion} 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
|
-
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
7
|
-
import {Text} from '@workday/canvas-kit-react/text';
|
|
8
|
-
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
9
|
-
import {system, base} from '@workday/canvas-tokens-web';
|
|
10
|
-
import {createStyles, px2rem, calc} from '@workday/canvas-kit-styling';
|
|
11
|
-
|
|
12
|
-
const liveRegionStyle = createStyles({
|
|
13
|
-
border: `${px2rem(1)} solid ${system.color.border.caution.default}`,
|
|
14
|
-
backgroundColor: system.color.bg.caution.default,
|
|
15
|
-
padding: system.space.x4,
|
|
16
|
-
display: 'block',
|
|
17
|
-
marginBlockStart: system.space.x4,
|
|
18
|
-
marginBlockEnd: system.space.x4,
|
|
19
|
-
width: calc.multiply(system.space.x16, 7),
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const flexGapStyles = createStyles({
|
|
23
|
-
gap: system.space.x4,
|
|
24
|
-
alignItems: 'center',
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
let liveRegionStr = 'This is an ARIA Live Region!';
|
|
28
|
-
|
|
29
|
-
export default () => {
|
|
30
|
-
const [message, setMessage] = React.useState('');
|
|
31
|
-
|
|
32
|
-
function handleChange(e) {
|
|
33
|
-
setMessage(e.target.value);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function handleSendMessage(e) {
|
|
37
|
-
e.preventDefault();
|
|
38
|
-
liveRegionStr = message;
|
|
39
|
-
setMessage('');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<>
|
|
44
|
-
<AriaLiveRegion>
|
|
45
|
-
<Text cs={liveRegionStyle}>{liveRegionStr}</Text>
|
|
46
|
-
</AriaLiveRegion>
|
|
47
|
-
<Flex
|
|
48
|
-
as="form"
|
|
49
|
-
aria-label="Visible Live Region"
|
|
50
|
-
onSubmit={handleSendMessage}
|
|
51
|
-
cs={flexGapStyles}
|
|
52
|
-
>
|
|
53
|
-
<FormField>
|
|
54
|
-
<FormField.Label>Type your message:</FormField.Label>
|
|
55
|
-
<FormField.Input as={TextInput} onChange={handleChange} value={message} />
|
|
56
|
-
</FormField>
|
|
57
|
-
<PrimaryButton type="submit">Send Message</PrimaryButton>
|
|
58
|
-
</Flex>
|
|
59
|
-
</>
|
|
60
|
-
);
|
|
61
|
-
};
|
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
AccessibleHide,
|
|
4
|
-
AriaLiveRegion,
|
|
5
|
-
composeHooks,
|
|
6
|
-
createComponent,
|
|
7
|
-
createElemPropsHook,
|
|
8
|
-
createSubcomponent,
|
|
9
|
-
ExtractProps,
|
|
10
|
-
useUniqueId,
|
|
11
|
-
} from '@workday/canvas-kit-react/common';
|
|
12
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
13
|
-
import {calc, createStyles, px2rem} from '@workday/canvas-kit-styling';
|
|
14
|
-
import {
|
|
15
|
-
notificationsIcon,
|
|
16
|
-
inboxIcon,
|
|
17
|
-
justifyIcon,
|
|
18
|
-
assistantIcon,
|
|
19
|
-
searchIcon,
|
|
20
|
-
} from '@workday/canvas-system-icons-web';
|
|
21
|
-
|
|
22
|
-
import {SecondaryButton, TertiaryButton} from '@workday/canvas-kit-react/button';
|
|
23
|
-
import {Avatar} from '@workday/canvas-kit-preview-react/avatar';
|
|
24
|
-
import {Flex, FlexProps} from '@workday/canvas-kit-react/layout';
|
|
25
|
-
import {LoadReturn} from '@workday/canvas-kit-react/collection';
|
|
26
|
-
import {Tooltip} from '@workday/canvas-kit-react/tooltip';
|
|
27
|
-
import {
|
|
28
|
-
Combobox,
|
|
29
|
-
useComboboxModel,
|
|
30
|
-
useComboboxInput,
|
|
31
|
-
useComboboxLoader,
|
|
32
|
-
} from '@workday/canvas-kit-react/combobox';
|
|
33
|
-
import {InputGroup, TextInput} from '@workday/canvas-kit-react/text-input';
|
|
34
|
-
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
|
|
35
|
-
import {SystemIcon} from '@workday/canvas-kit-react/icon';
|
|
36
|
-
import {CountBadge} from '@workday/canvas-kit-react/badge';
|
|
37
|
-
|
|
38
|
-
interface HeaderItemProps extends FlexProps {}
|
|
39
|
-
interface LiveCountBadgeProps extends FlexProps {
|
|
40
|
-
cnt: number;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const tasks = ['Request Time Off', 'Create Expense Report', 'Change Benefits'];
|
|
44
|
-
|
|
45
|
-
const styleOverrides = {
|
|
46
|
-
headerWrapper: createStyles({
|
|
47
|
-
display: 'flex',
|
|
48
|
-
alignItems: 'center',
|
|
49
|
-
justifyContent: 'space-between',
|
|
50
|
-
boxSizing: 'border-box',
|
|
51
|
-
...system.type.subtext.large,
|
|
52
|
-
WebkitFontSmoothing: 'antialiased',
|
|
53
|
-
MozOsxFontSmoothing: 'grayscale',
|
|
54
|
-
backgroundColor: system.color.bg.default,
|
|
55
|
-
padding: system.space.x1,
|
|
56
|
-
}),
|
|
57
|
-
inputGroupInner: createStyles({
|
|
58
|
-
marginLeft: '1rem',
|
|
59
|
-
width: px2rem(20),
|
|
60
|
-
transition: 'opacity 100ms ease',
|
|
61
|
-
}),
|
|
62
|
-
comboboxContainer: createStyles({
|
|
63
|
-
margin: 'auto',
|
|
64
|
-
width: '100%',
|
|
65
|
-
maxWidth: calc.multiply(system.space.x20, 6),
|
|
66
|
-
}),
|
|
67
|
-
comboboxInput: createStyles({
|
|
68
|
-
borderRadius: px2rem(1000),
|
|
69
|
-
width: '20rem',
|
|
70
|
-
}),
|
|
71
|
-
comboboxMenuList: createStyles({
|
|
72
|
-
maxHeight: px2rem(200),
|
|
73
|
-
}),
|
|
74
|
-
menuButtonStyles: createStyles({
|
|
75
|
-
textDecoration: 'none',
|
|
76
|
-
color: system.color.fg.strong,
|
|
77
|
-
}),
|
|
78
|
-
notificationContainerStyles: createStyles({
|
|
79
|
-
boxSizing: 'border-box',
|
|
80
|
-
position: 'relative',
|
|
81
|
-
}),
|
|
82
|
-
countBadgeStyles: createStyles({
|
|
83
|
-
boxSizing: 'border-box',
|
|
84
|
-
position: 'absolute',
|
|
85
|
-
top: calc.negate(system.space.x1),
|
|
86
|
-
insetInlineEnd: calc.negate(system.space.x1),
|
|
87
|
-
}),
|
|
88
|
-
actionButtonStyles: createStyles({
|
|
89
|
-
gap: system.space.x4,
|
|
90
|
-
margin: system.space.x4,
|
|
91
|
-
}),
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const useAutocompleteInput = composeHooks(
|
|
95
|
-
createElemPropsHook(useComboboxModel)(model => {
|
|
96
|
-
return {
|
|
97
|
-
onKeyPress(event: React.KeyboardEvent) {
|
|
98
|
-
model.events.show(event);
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
}),
|
|
102
|
-
useComboboxInput
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
const AutoCompleteInput = createSubcomponent(TextInput)({
|
|
106
|
-
modelHook: useComboboxModel,
|
|
107
|
-
elemPropsHook: useAutocompleteInput,
|
|
108
|
-
})<ExtractProps<typeof Combobox.Input, never>>((elemProps, Element) => {
|
|
109
|
-
return <Combobox.Input as={Element} {...elemProps} />;
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
export default () => {
|
|
113
|
-
const [notifications, setNotifications] = React.useState(0);
|
|
114
|
-
|
|
115
|
-
function handleAdd() {
|
|
116
|
-
setNotifications(prev => prev + 1);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function handleClear() {
|
|
120
|
-
setNotifications(0);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<>
|
|
125
|
-
<GlobalHeader>
|
|
126
|
-
<GlobalHeader.Item>
|
|
127
|
-
<Tooltip title="Global Navigation" type="describe">
|
|
128
|
-
<TertiaryButton icon={justifyIcon} cs={styleOverrides.menuButtonStyles}>
|
|
129
|
-
MENU
|
|
130
|
-
</TertiaryButton>
|
|
131
|
-
</Tooltip>
|
|
132
|
-
<Tooltip title="Workday Home">
|
|
133
|
-
<TertiaryButton>
|
|
134
|
-
<img src="https://design.workday.com/images/ck-dub-logo-blue.svg" alt="" />
|
|
135
|
-
</TertiaryButton>
|
|
136
|
-
</Tooltip>
|
|
137
|
-
</GlobalHeader.Item>
|
|
138
|
-
<GlobalHeader.Item cs={styleOverrides.comboboxContainer}>
|
|
139
|
-
<Autocomplete aria-label="Search Workday" />
|
|
140
|
-
</GlobalHeader.Item>
|
|
141
|
-
<GlobalHeader.Item>
|
|
142
|
-
<Tooltip title="Assistant">
|
|
143
|
-
<TertiaryButton icon={assistantIcon} />
|
|
144
|
-
</Tooltip>
|
|
145
|
-
|
|
146
|
-
<NotificationLiveBadge cnt={notifications} />
|
|
147
|
-
|
|
148
|
-
<Tooltip title="My Tasks">
|
|
149
|
-
<TertiaryButton icon={inboxIcon} />
|
|
150
|
-
</Tooltip>
|
|
151
|
-
<Tooltip title="Profile">
|
|
152
|
-
<Avatar name="Avatar" />
|
|
153
|
-
</Tooltip>
|
|
154
|
-
</GlobalHeader.Item>
|
|
155
|
-
</GlobalHeader>
|
|
156
|
-
<Flex cs={styleOverrides.actionButtonStyles}>
|
|
157
|
-
<SecondaryButton onClick={handleAdd}>Add notification</SecondaryButton>
|
|
158
|
-
<TertiaryButton onClick={handleClear}>Clear</TertiaryButton>
|
|
159
|
-
</Flex>
|
|
160
|
-
</>
|
|
161
|
-
);
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const GlobalHeaderItem = createComponent('div')({
|
|
165
|
-
displayName: 'GlobalHeader.Item',
|
|
166
|
-
Component: ({gap = 's', ...props}: HeaderItemProps, ref) => (
|
|
167
|
-
<Flex gap={gap} alignItems="center" marginX={system.space.x3} ref={ref} {...props} />
|
|
168
|
-
),
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
const GlobalHeader = createComponent('header')({
|
|
172
|
-
displayName: 'GlobalHeader',
|
|
173
|
-
Component: (props, ref) => (
|
|
174
|
-
<header className={styleOverrides.headerWrapper} ref={ref} {...props} />
|
|
175
|
-
),
|
|
176
|
-
subComponents: {Item: GlobalHeaderItem},
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
const Autocomplete = createComponent('div')({
|
|
180
|
-
displayName: 'Autocomplete',
|
|
181
|
-
Component: props => {
|
|
182
|
-
const [searchText, setSearchText] = React.useState('');
|
|
183
|
-
|
|
184
|
-
function handleChange(e) {
|
|
185
|
-
setSearchText(e.target.value);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const {model, loader} = useComboboxLoader(
|
|
189
|
-
{
|
|
190
|
-
// You can start with any number that makes sense.
|
|
191
|
-
total: 0,
|
|
192
|
-
|
|
193
|
-
// Pick whatever number makes sense for your API
|
|
194
|
-
pageSize: 20,
|
|
195
|
-
|
|
196
|
-
// A load function that will be called by the loader. You must return a promise that returns
|
|
197
|
-
// an object like `{items: [], total: 0}`. The `items` will be merged into the loader's cache
|
|
198
|
-
async load({pageNumber, pageSize, filter}) {
|
|
199
|
-
return new Promise<LoadReturn<string>>(resolve => {
|
|
200
|
-
// simulate a server response by resolving after a period of time
|
|
201
|
-
setTimeout(() => {
|
|
202
|
-
// simulate paging and filtering based on pre-computed items
|
|
203
|
-
const start = (pageNumber - 1) * pageSize;
|
|
204
|
-
const end = start + pageSize;
|
|
205
|
-
const filteredTasks = tasks.filter(i => {
|
|
206
|
-
if (searchText.trim() === '' || typeof searchText !== 'string') {
|
|
207
|
-
return true;
|
|
208
|
-
}
|
|
209
|
-
return i.toLowerCase().includes(searchText.trim().toLowerCase());
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
const total = filteredTasks.length;
|
|
213
|
-
const items = filteredTasks.slice(start, end);
|
|
214
|
-
|
|
215
|
-
resolve({
|
|
216
|
-
items,
|
|
217
|
-
total,
|
|
218
|
-
});
|
|
219
|
-
}, 300);
|
|
220
|
-
});
|
|
221
|
-
},
|
|
222
|
-
onShow() {
|
|
223
|
-
// The `shouldLoad` cancels while the combobox menu is hidden, so let's load when it is
|
|
224
|
-
// visible
|
|
225
|
-
loader.load();
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
useComboboxModel
|
|
229
|
-
);
|
|
230
|
-
|
|
231
|
-
return (
|
|
232
|
-
<Combobox model={model}>
|
|
233
|
-
<InputGroup>
|
|
234
|
-
<InputGroup.InnerStart cs={styleOverrides.inputGroupInner}>
|
|
235
|
-
<SystemIcon icon={searchIcon} />
|
|
236
|
-
</InputGroup.InnerStart>
|
|
237
|
-
<InputGroup.Input
|
|
238
|
-
as={AutoCompleteInput}
|
|
239
|
-
cs={styleOverrides.comboboxInput}
|
|
240
|
-
onChange={handleChange}
|
|
241
|
-
value={searchText}
|
|
242
|
-
{...props}
|
|
243
|
-
/>
|
|
244
|
-
</InputGroup>
|
|
245
|
-
<Combobox.Menu.Popper>
|
|
246
|
-
<Combobox.Menu.Card>
|
|
247
|
-
{model.state.items.length === 0 ? (
|
|
248
|
-
<StyledMenuItem as="span">No Results Found</StyledMenuItem>
|
|
249
|
-
) : (
|
|
250
|
-
model.state.items.length > 0 && (
|
|
251
|
-
<Combobox.Menu.List maxHeight={px2rem(200)}>
|
|
252
|
-
{item => <Combobox.Menu.Item>{item}</Combobox.Menu.Item>}
|
|
253
|
-
</Combobox.Menu.List>
|
|
254
|
-
)
|
|
255
|
-
)}
|
|
256
|
-
</Combobox.Menu.Card>
|
|
257
|
-
</Combobox.Menu.Popper>
|
|
258
|
-
</Combobox>
|
|
259
|
-
);
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
const NotificationLiveBadge = createComponent('span')({
|
|
264
|
-
displayName: 'NotificationLiveBadge',
|
|
265
|
-
Component: ({cnt = 0, ...props}: LiveCountBadgeProps) => {
|
|
266
|
-
const btnId = useUniqueId();
|
|
267
|
-
const badgeId = useUniqueId();
|
|
268
|
-
|
|
269
|
-
return (
|
|
270
|
-
<Flex cs={styleOverrides.notificationContainerStyles}>
|
|
271
|
-
<Tooltip title="Notifications">
|
|
272
|
-
<TertiaryButton
|
|
273
|
-
id={btnId}
|
|
274
|
-
icon={notificationsIcon}
|
|
275
|
-
aria-describedby={cnt > 0 ? badgeId : undefined}
|
|
276
|
-
{...props}
|
|
277
|
-
/>
|
|
278
|
-
</Tooltip>
|
|
279
|
-
<AriaLiveRegion aria-labelledby={btnId}>
|
|
280
|
-
{cnt > 0 && (
|
|
281
|
-
<>
|
|
282
|
-
<CountBadge
|
|
283
|
-
id={badgeId}
|
|
284
|
-
count={cnt}
|
|
285
|
-
limit={100}
|
|
286
|
-
cs={styleOverrides.countBadgeStyles}
|
|
287
|
-
/>
|
|
288
|
-
<AccessibleHide>New</AccessibleHide>
|
|
289
|
-
</>
|
|
290
|
-
)}
|
|
291
|
-
</AriaLiveRegion>
|
|
292
|
-
</Flex>
|
|
293
|
-
);
|
|
294
|
-
},
|
|
295
|
-
});
|