@workday/canvas-kit-docs 11.0.15 → 11.0.17
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/mdx/react/_examples/AriaLiveRegions.mdx +10 -6
- package/dist/mdx/react/_examples/examples/{common → AriaLiveRegions}/FilterListWithLiveStatus.tsx +18 -10
- package/dist/mdx/react/_examples/examples/AriaLiveRegions/HiddenLiveRegion.tsx +46 -0
- package/dist/mdx/react/_examples/examples/AriaLiveRegions/TextInputWithLiveError.tsx +31 -0
- package/dist/mdx/react/_examples/examples/AriaLiveRegions/VisibleLiveRegion.tsx +61 -0
- package/package.json +7 -7
- package/dist/mdx/react/_examples/examples/common/HiddenLiveRegion.tsx +0 -30
- package/dist/mdx/react/_examples/examples/common/TextInputWithLiveError.tsx +0 -25
- package/dist/mdx/react/_examples/examples/common/VisibleLiveRegion.tsx +0 -40
- /package/dist/mdx/react/_examples/examples/{common → AriaLiveRegions}/IconButtonsWithLiveBadges.tsx +0 -0
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {AriaLiveRegion} from '@workday/canvas-kit-react/common';
|
|
2
|
-
import FilterListWithLiveStatus from './examples/
|
|
3
|
-
import VisibleLiveRegion from './examples/
|
|
4
|
-
import HiddenLiveRegion from './examples/
|
|
5
|
-
import TextInputWithLiveError from './examples/
|
|
6
|
-
import IconButtonsWithLiveBadges from './examples/common/IconButtonsWithLiveBadges';
|
|
2
|
+
import FilterListWithLiveStatus from './examples/AriaLiveRegions/FilterListWithLiveStatus';
|
|
3
|
+
import VisibleLiveRegion from './examples/AriaLiveRegions/VisibleLiveRegion';
|
|
4
|
+
import HiddenLiveRegion from './examples/AriaLiveRegions/HiddenLiveRegion';
|
|
5
|
+
import TextInputWithLiveError from './examples/AriaLiveRegions/TextInputWithLiveError';
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
# ARIA Live Regions
|
|
@@ -56,7 +55,7 @@ experience when moving the keyboard focus to a new element on screen isn't feasi
|
|
|
56
55
|
|
|
57
56
|
In this example, a live region is applied to a short UI text describing the number of items shown in
|
|
58
57
|
the list. As you type characters into the input, listen for the screen reader to automatically
|
|
59
|
-
describe how many items in the list
|
|
58
|
+
describe how many items in the list are shown.
|
|
60
59
|
|
|
61
60
|
<ExampleCodeBlock code={FilterListWithLiveStatus} />
|
|
62
61
|
|
|
@@ -72,4 +71,9 @@ of error conditions. As forms increase in complexity, live regions on each error
|
|
|
72
71
|
increasingly distracting and disruptive to the experience, especially if users are trying to first
|
|
73
72
|
understand the information that is required of them to complete the task.
|
|
74
73
|
|
|
74
|
+
**Note:** The `<AriaLiveRegion>` component is used inside of the `Hint` to ensure the live
|
|
75
|
+
region remains in the browser DOM at all times. The `Hint` is only rendered in the DOM when it
|
|
76
|
+
contains content, so it will not work reliably as a live region for screen readers using the
|
|
77
|
+
`as={AriaLiveRegion}` prop.
|
|
78
|
+
|
|
75
79
|
<ExampleCodeBlock code={TextInputWithLiveError} />
|
package/dist/mdx/react/_examples/examples/{common → AriaLiveRegions}/FilterListWithLiveStatus.tsx
RENAMED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React, {useState} from 'react';
|
|
2
|
-
|
|
3
|
-
import {BodyText, Heading} from '@workday/canvas-kit-react/text';
|
|
2
|
+
|
|
4
3
|
import {AriaLiveRegion} from '@workday/canvas-kit-react/common';
|
|
4
|
+
import {BodyText, Heading} from '@workday/canvas-kit-react/text';
|
|
5
5
|
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
6
|
+
import {FormField} from '@workday/canvas-kit-preview-react/form-field';
|
|
7
|
+
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
6
8
|
import {system, base} from '@workday/canvas-tokens-web';
|
|
7
|
-
import {createStyles, px2rem} from '@workday/canvas-kit-styling';
|
|
9
|
+
import {createStyles, cssVar, px2rem} from '@workday/canvas-kit-styling';
|
|
8
10
|
|
|
9
11
|
const fruits = [
|
|
10
12
|
'Apples',
|
|
@@ -23,13 +25,19 @@ const liveRegionStyle = createStyles({
|
|
|
23
25
|
padding: system.space.x2,
|
|
24
26
|
});
|
|
25
27
|
|
|
26
|
-
const listStyles = {
|
|
28
|
+
const listStyles = createStyles({
|
|
29
|
+
paddingLeft: system.space.zero,
|
|
30
|
+
});
|
|
27
31
|
|
|
28
32
|
const listItemStyles = createStyles({
|
|
29
33
|
listStyle: 'none',
|
|
30
34
|
paddingLeft: system.space.zero,
|
|
31
35
|
});
|
|
32
36
|
|
|
37
|
+
const flexStyles = createStyles({
|
|
38
|
+
gap: system.space.x4,
|
|
39
|
+
});
|
|
40
|
+
|
|
33
41
|
let filteredFruits = fruits;
|
|
34
42
|
|
|
35
43
|
export default () => {
|
|
@@ -41,7 +49,7 @@ export default () => {
|
|
|
41
49
|
|
|
42
50
|
return (
|
|
43
51
|
<>
|
|
44
|
-
<Flex
|
|
52
|
+
<Flex cs={flexStyles}>
|
|
45
53
|
<Heading size="small">Fruits</Heading>
|
|
46
54
|
<AriaLiveRegion>
|
|
47
55
|
<BodyText size="small" cs={liveRegionStyle}>
|
|
@@ -49,11 +57,11 @@ export default () => {
|
|
|
49
57
|
</BodyText>
|
|
50
58
|
</AriaLiveRegion>
|
|
51
59
|
</Flex>
|
|
52
|
-
<
|
|
53
|
-
<
|
|
54
|
-
<
|
|
55
|
-
</
|
|
56
|
-
<ul
|
|
60
|
+
<FormField>
|
|
61
|
+
<FormField.Label>Filter Items:</FormField.Label>
|
|
62
|
+
<FormField.Input as={TextInput} value={filter} onChange={handleFilter} />
|
|
63
|
+
</FormField>
|
|
64
|
+
<ul className={listStyles}>
|
|
57
65
|
{filteredFruits.map(i => (
|
|
58
66
|
<BodyText size="small" as="li" cs={listItemStyles} key={i}>
|
|
59
67
|
{i}
|
|
@@ -0,0 +1,46 @@
|
|
|
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-preview-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
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {AriaLiveRegion, changeFocus} from '@workday/canvas-kit-react/common';
|
|
3
|
+
import {FormField} from '@workday/canvas-kit-preview-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
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
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-preview-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
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.17",
|
|
4
4
|
"description": "Documentation components of Canvas Kit components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@emotion/styled": "^11.6.0",
|
|
46
46
|
"@storybook/csf": "0.0.1",
|
|
47
|
-
"@workday/canvas-kit-labs-react": "^11.0.
|
|
48
|
-
"@workday/canvas-kit-preview-react": "^11.0.
|
|
49
|
-
"@workday/canvas-kit-react": "^11.0.
|
|
50
|
-
"@workday/canvas-kit-styling": "^11.0.
|
|
47
|
+
"@workday/canvas-kit-labs-react": "^11.0.17",
|
|
48
|
+
"@workday/canvas-kit-preview-react": "^11.0.17",
|
|
49
|
+
"@workday/canvas-kit-react": "^11.0.17",
|
|
50
|
+
"@workday/canvas-kit-styling": "^11.0.17",
|
|
51
51
|
"@workday/canvas-system-icons-web": "^3.0.0",
|
|
52
52
|
"@workday/canvas-tokens-web": "^2.0.0",
|
|
53
|
-
"markdown-to-jsx": "^
|
|
53
|
+
"markdown-to-jsx": "^7.2.0",
|
|
54
54
|
"ts-node": "^10.9.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"mkdirp": "^1.0.3",
|
|
60
60
|
"typescript": "4.2"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "bea3e7c2462c53db72574e524d8dee0a72fb0b95"
|
|
63
63
|
}
|
|
@@ -1,30 +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-preview-react/text-input';
|
|
5
|
-
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
6
|
-
import {system} from '@workday/canvas-tokens-web';
|
|
7
|
-
|
|
8
|
-
export default () => {
|
|
9
|
-
const [message, setMessage] = useState('This is an ARIA Live Region!');
|
|
10
|
-
const inputRef = useRef();
|
|
11
|
-
function handleSendMessage() {
|
|
12
|
-
setMessage(inputRef.current.value);
|
|
13
|
-
inputRef.current.value = '';
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<>
|
|
18
|
-
<Flex gap={`var(${system.space.x4})`} alignItems="flex-end">
|
|
19
|
-
<TextInput orientation="vertical">
|
|
20
|
-
<TextInput.Label>Type your message:</TextInput.Label>
|
|
21
|
-
<TextInput.Field ref={inputRef} />
|
|
22
|
-
</TextInput>
|
|
23
|
-
<PrimaryButton onClick={handleSendMessage}>Send Message</PrimaryButton>
|
|
24
|
-
</Flex>
|
|
25
|
-
<AriaLiveRegion>
|
|
26
|
-
<AccessibleHide>{message}</AccessibleHide>
|
|
27
|
-
</AriaLiveRegion>
|
|
28
|
-
</>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React, {useState, useRef} from 'react';
|
|
2
|
-
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
3
|
-
import {AriaLiveRegion, changeFocus} from '@workday/canvas-kit-react/common';
|
|
4
|
-
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
5
|
-
|
|
6
|
-
export default () => {
|
|
7
|
-
const errMsg = 'Error: First name is required.';
|
|
8
|
-
const [hasError, setHasError] = useState(false);
|
|
9
|
-
const inputRef = useRef();
|
|
10
|
-
const handleBlur = e => setHasError(e.target.value.trim().length === 0);
|
|
11
|
-
const handleSubmit = () => hasError && changeFocus(inputRef.current);
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<>
|
|
15
|
-
<TextInput orientation="vertical" hasError={hasError} isRequired={true}>
|
|
16
|
-
<TextInput.Label>First Name:</TextInput.Label>
|
|
17
|
-
<TextInput.Field onBlur={handleBlur} ref={inputRef} />
|
|
18
|
-
<TextInput.Hint height={'16px'}>
|
|
19
|
-
<AriaLiveRegion>{hasError && errMsg}</AriaLiveRegion>
|
|
20
|
-
</TextInput.Hint>
|
|
21
|
-
</TextInput>
|
|
22
|
-
<PrimaryButton onClick={handleSubmit}>Continue</PrimaryButton>
|
|
23
|
-
</>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
@@ -1,40 +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 {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
5
|
-
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
6
|
-
import {Text} from '@workday/canvas-kit-react/text';
|
|
7
|
-
import {system, base} from '@workday/canvas-tokens-web';
|
|
8
|
-
import {createStyles, px2rem} from '@workday/canvas-kit-styling';
|
|
9
|
-
|
|
10
|
-
const liveRegionStyle = createStyles({
|
|
11
|
-
border: `${px2rem(1)} solid ${base.cantaloupe400}`,
|
|
12
|
-
backgroundColor: base.cantaloupe100,
|
|
13
|
-
padding: system.space.x4,
|
|
14
|
-
display: 'block',
|
|
15
|
-
margin: system.space.x4 + ' 0',
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export default () => {
|
|
19
|
-
const [message, setMessage] = useState('This is an ARIA Live Region!');
|
|
20
|
-
const inputRef = useRef();
|
|
21
|
-
function handleSendMessage() {
|
|
22
|
-
setMessage(inputRef.current.value);
|
|
23
|
-
inputRef.current.value = '';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<>
|
|
28
|
-
<AriaLiveRegion>
|
|
29
|
-
<Text cs={liveRegionStyle}>{message}</Text>
|
|
30
|
-
</AriaLiveRegion>
|
|
31
|
-
<Flex gap={`var(${system.space.x4})`} alignItems="flex-end">
|
|
32
|
-
<TextInput orientation="vertical">
|
|
33
|
-
<TextInput.Label>Type your message:</TextInput.Label>
|
|
34
|
-
<TextInput.Field ref={inputRef} />
|
|
35
|
-
</TextInput>
|
|
36
|
-
<PrimaryButton onClick={handleSendMessage}>Send Message</PrimaryButton>
|
|
37
|
-
</Flex>
|
|
38
|
-
</>
|
|
39
|
-
);
|
|
40
|
-
};
|
/package/dist/mdx/react/_examples/examples/{common → AriaLiveRegions}/IconButtonsWithLiveBadges.tsx
RENAMED
|
File without changes
|