@workday/canvas-kit-docs 11.1.0-833-next.0 → 11.1.0-864-next.0

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.
@@ -285,6 +285,10 @@ module.exports = {specifications: [
285
285
  "type": "it",
286
286
  "name": "should not have activedescendant set"
287
287
  },
288
+ {
289
+ "type": "it",
290
+ "name": "should not have visual focus on any element"
291
+ },
288
292
  {
289
293
  "type": "it",
290
294
  "name": "should not have aria-selected=true on any elements"
@@ -297,6 +301,10 @@ module.exports = {specifications: [
297
301
  "type": "it",
298
302
  "name": "should clear activedescendant"
299
303
  },
304
+ {
305
+ "type": "it",
306
+ "name": "should not have visual focus on the first item"
307
+ },
300
308
  {
301
309
  "type": "it",
302
310
  "name": "should not set aria-selected to the first option"
@@ -305,7 +313,7 @@ module.exports = {specifications: [
305
313
  },
306
314
  {
307
315
  "type": "describe",
308
- "name": "when a value is entered",
316
+ "name": "when \"Red\" is typed",
309
317
  "children": [
310
318
  {
311
319
  "type": "it",
@@ -353,7 +361,7 @@ module.exports = {specifications: [
353
361
  },
354
362
  {
355
363
  "type": "it",
356
- "name": "should set aria-selected to the first option"
364
+ "name": "should set visual focus to the first option"
357
365
  },
358
366
  {
359
367
  "type": "describe",
@@ -369,7 +377,7 @@ module.exports = {specifications: [
369
377
  },
370
378
  {
371
379
  "type": "describe",
372
- "name": "when the use hits the \"2\" key",
380
+ "name": "when the user hits the \"2\" key",
373
381
  "children": [
374
382
  {
375
383
  "type": "it",
@@ -378,6 +386,10 @@ module.exports = {specifications: [
378
386
  {
379
387
  "type": "it",
380
388
  "name": "should change the combobox value to reflect the key entered"
389
+ },
390
+ {
391
+ "type": "it",
392
+ "name": "should set aria-selected to the first option"
381
393
  }
382
394
  ]
383
395
  }
@@ -437,7 +449,11 @@ module.exports = {specifications: [
437
449
  },
438
450
  {
439
451
  "type": "it",
440
- "name": "should set aria-selected to the second option"
452
+ "name": "should set visual focus on the second option"
453
+ },
454
+ {
455
+ "type": "it",
456
+ "name": "should not have aria-selected=true on any elements"
441
457
  }
442
458
  ]
443
459
  },
@@ -455,7 +471,11 @@ module.exports = {specifications: [
455
471
  },
456
472
  {
457
473
  "type": "it",
458
- "name": "should set aria-selected to the first option"
474
+ "name": "should set visual focus on the first option"
475
+ },
476
+ {
477
+ "type": "it",
478
+ "name": "should not have aria-selected=true on any elements"
459
479
  }
460
480
  ]
461
481
  },
@@ -469,7 +489,11 @@ module.exports = {specifications: [
469
489
  },
470
490
  {
471
491
  "type": "it",
472
- "name": "should set aria-selected to the last option"
492
+ "name": "should set visual focus on the last option"
493
+ },
494
+ {
495
+ "type": "it",
496
+ "name": "should not have aria-selected=true on any elements"
473
497
  }
474
498
  ]
475
499
  },
@@ -483,7 +507,11 @@ module.exports = {specifications: [
483
507
  },
484
508
  {
485
509
  "type": "it",
486
- "name": "should set aria-selected to the third option"
510
+ "name": "should set visual focus on the third option"
511
+ },
512
+ {
513
+ "type": "it",
514
+ "name": "should not have aria-selected=true on any elements"
487
515
  }
488
516
  ]
489
517
  },
@@ -497,7 +525,11 @@ module.exports = {specifications: [
497
525
  },
498
526
  {
499
527
  "type": "it",
500
- "name": "should set aria-selected to the first option"
528
+ "name": "should set visual focus on the first option"
529
+ },
530
+ {
531
+ "type": "it",
532
+ "name": "should not have aria-selected=true on any elements"
501
533
  }
502
534
  ]
503
535
  }
@@ -2351,7 +2383,7 @@ module.exports = {specifications: [
2351
2383
  },
2352
2384
  {
2353
2385
  "type": "it",
2354
- "name": "should have an aria-modal=true"
2386
+ "name": "should have an aria-modal=false"
2355
2387
  },
2356
2388
  {
2357
2389
  "type": "it",
@@ -2621,7 +2653,7 @@ module.exports = {specifications: [
2621
2653
  },
2622
2654
  {
2623
2655
  "type": "it",
2624
- "name": "should have an aria-modal=true"
2656
+ "name": "should have an aria-modal=false"
2625
2657
  },
2626
2658
  {
2627
2659
  "type": "it",
@@ -2701,7 +2733,7 @@ module.exports = {specifications: [
2701
2733
  },
2702
2734
  {
2703
2735
  "type": "it",
2704
- "name": "should have an aria-modal=true"
2736
+ "name": "should have an aria-modal=false"
2705
2737
  },
2706
2738
  {
2707
2739
  "type": "it",
@@ -4504,6 +4536,10 @@ module.exports = {specifications: [
4504
4536
  {
4505
4537
  "type": "it",
4506
4538
  "name": "should scroll so that the \"San Francisco (United States)\" option is fully visible"
4539
+ },
4540
+ {
4541
+ "type": "it",
4542
+ "name": "should not have any item selected"
4507
4543
  }
4508
4544
  ]
4509
4545
  }
@@ -4520,6 +4556,10 @@ module.exports = {specifications: [
4520
4556
  {
4521
4557
  "type": "it",
4522
4558
  "name": "should scroll so that the \"San Mateo (United States)\" option is fully visible"
4559
+ },
4560
+ {
4561
+ "type": "it",
4562
+ "name": "should not have any item selected"
4523
4563
  }
4524
4564
  ]
4525
4565
  }
@@ -4536,6 +4576,10 @@ module.exports = {specifications: [
4536
4576
  {
4537
4577
  "type": "it",
4538
4578
  "name": "should scroll so that the \"Dallas (United States)\" option is fully visible"
4579
+ },
4580
+ {
4581
+ "type": "it",
4582
+ "name": "should not have any item selected"
4539
4583
  }
4540
4584
  ]
4541
4585
  }
@@ -4558,6 +4602,10 @@ module.exports = {specifications: [
4558
4602
  {
4559
4603
  "type": "it",
4560
4604
  "name": "should set assistive focus to the \"San Francisco (United States)\" option"
4605
+ },
4606
+ {
4607
+ "type": "it",
4608
+ "name": "should not have any item selected"
4561
4609
  }
4562
4610
  ]
4563
4611
  }
@@ -4574,6 +4622,10 @@ module.exports = {specifications: [
4574
4622
  {
4575
4623
  "type": "it",
4576
4624
  "name": "should set assistive focus to the \"San Francisco (United States)\" option"
4625
+ },
4626
+ {
4627
+ "type": "it",
4628
+ "name": "should not have any item selected"
4577
4629
  }
4578
4630
  ]
4579
4631
  }
@@ -4590,6 +4642,10 @@ module.exports = {specifications: [
4590
4642
  {
4591
4643
  "type": "it",
4592
4644
  "name": "should set assistive focus to the \"San Mateo (United States)\" option"
4645
+ },
4646
+ {
4647
+ "type": "it",
4648
+ "name": "should not have any item selected"
4593
4649
  }
4594
4650
  ]
4595
4651
  }
@@ -4614,6 +4670,10 @@ module.exports = {specifications: [
4614
4670
  {
4615
4671
  "type": "it",
4616
4672
  "name": "should scroll so that the \"Dallas (United States)\" option is centered in view"
4673
+ },
4674
+ {
4675
+ "type": "it",
4676
+ "name": "should set assistive focus to the \"Dallas (United States)\" option"
4617
4677
  }
4618
4678
  ]
4619
4679
  }
@@ -4656,6 +4716,10 @@ module.exports = {specifications: [
4656
4716
  {
4657
4717
  "type": "it",
4658
4718
  "name": "should set assistive focus to the first option (\"E-mail\")"
4719
+ },
4720
+ {
4721
+ "type": "it",
4722
+ "name": "should not have any item selected"
4659
4723
  }
4660
4724
  ]
4661
4725
  },
@@ -4670,6 +4734,10 @@ module.exports = {specifications: [
4670
4734
  {
4671
4735
  "type": "it",
4672
4736
  "name": "should set assistive focus to the second option (\"Phone\")"
4737
+ },
4738
+ {
4739
+ "type": "it",
4740
+ "name": "should not have any item selected"
4673
4741
  }
4674
4742
  ]
4675
4743
  },
@@ -4681,6 +4749,10 @@ module.exports = {specifications: [
4681
4749
  "type": "it",
4682
4750
  "name": "should not have an aria-activedescendant attribute"
4683
4751
  },
4752
+ {
4753
+ "type": "it",
4754
+ "name": "should not have any item selected"
4755
+ },
4684
4756
  {
4685
4757
  "type": "describe",
4686
4758
  "name": "when the menu is re-opened AFTER it has fully closed",
@@ -4692,6 +4764,10 @@ module.exports = {specifications: [
4692
4764
  {
4693
4765
  "type": "it",
4694
4766
  "name": "should set assistive focus to the second option (\"Phone\") that is where the cursor was"
4767
+ },
4768
+ {
4769
+ "type": "it",
4770
+ "name": "should not have any item selected"
4695
4771
  }
4696
4772
  ]
4697
4773
  }
@@ -4734,6 +4810,10 @@ module.exports = {specifications: [
4734
4810
  {
4735
4811
  "type": "it",
4736
4812
  "name": "should set assistive focus to second enabled option (\"Phone\")"
4813
+ },
4814
+ {
4815
+ "type": "it",
4816
+ "name": "should not have any item selected"
4737
4817
  }
4738
4818
  ]
4739
4819
  },
@@ -4748,6 +4828,10 @@ module.exports = {specifications: [
4748
4828
  {
4749
4829
  "type": "it",
4750
4830
  "name": "should set assistive focus to the fourth option down (\"Mail\") since focus will have skipped one disabled option (\"Fax\")"
4831
+ },
4832
+ {
4833
+ "type": "it",
4834
+ "name": "should not have any item selected"
4751
4835
  }
4752
4836
  ]
4753
4837
  }
@@ -4810,6 +4894,10 @@ module.exports = {specifications: [
4810
4894
  {
4811
4895
  "type": "it",
4812
4896
  "name": "should show Boulder (United States)"
4897
+ },
4898
+ {
4899
+ "type": "it",
4900
+ "name": "should not have any item selected"
4813
4901
  }
4814
4902
  ]
4815
4903
  }
@@ -4867,7 +4955,11 @@ module.exports = {specifications: [
4867
4955
  "children": [
4868
4956
  {
4869
4957
  "type": "it",
4870
- "name": "should have an aria-selected attribute set to \"true\""
4958
+ "name": "should set accessible focus on the \"E-Mail\" option"
4959
+ },
4960
+ {
4961
+ "type": "it",
4962
+ "name": "should not have any item selected"
4871
4963
  }
4872
4964
  ]
4873
4965
  },
@@ -4910,6 +5002,10 @@ module.exports = {specifications: [
4910
5002
  {
4911
5003
  "type": "it",
4912
5004
  "name": "should set assistive focus to the \"Phone\" option"
5005
+ },
5006
+ {
5007
+ "type": "it",
5008
+ "name": "should set assistive selection on the \"Phone\" option"
4913
5009
  }
4914
5010
  ]
4915
5011
  }
@@ -4968,6 +5064,10 @@ module.exports = {specifications: [
4968
5064
  {
4969
5065
  "type": "it",
4970
5066
  "name": "should set assistive focus to the \"Mail\" option and skip disabled fax"
5067
+ },
5068
+ {
5069
+ "type": "it",
5070
+ "name": "should not have any item selected"
4971
5071
  }
4972
5072
  ]
4973
5073
  }
@@ -4979,7 +5079,7 @@ module.exports = {specifications: [
4979
5079
  },
4980
5080
  {
4981
5081
  "type": "describe",
4982
- "name": "when the enter key is pressed",
5082
+ "name": "when the down arrow key is pressed",
4983
5083
  "children": [
4984
5084
  {
4985
5085
  "type": "describe",
@@ -4991,7 +5091,7 @@ module.exports = {specifications: [
4991
5091
  },
4992
5092
  {
4993
5093
  "type": "it",
4994
- "name": "should have E-Mail selected"
5094
+ "name": "should set accessible focus on the \"E-Mail\" option"
4995
5095
  }
4996
5096
  ]
4997
5097
  },
@@ -0,0 +1,36 @@
1
+ import {SymbolDoc, Specifications} from '@workday/canvas-kit-docs';
2
+
3
+ import {Divider} from '@workday/canvas-kit-preview-react/divider';
4
+ import Basic from './examples/Basic';
5
+ import CustomSpace from './examples/CustomSpace';
6
+
7
+
8
+ # Divider
9
+
10
+ A `Divider` segments and visually organizes content.
11
+
12
+ ## Installation
13
+
14
+ ```sh
15
+ yarn add @workday/canvas-kit-preview-react
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ Use a `Divider` to separate content and create visual hierarchy. Typically they are used between paragraph sections to indicate a break or shift in content. However, they can also be used as decorative elements to provide greater emphasis and visual hierarchy.
21
+
22
+ ### Basic Example
23
+
24
+ By default, `Divider` renders a `<hr>` (horizontal rule) element with `0.5rem` of margin on top and bottom. The `space` prop allows you to adjust the vertical margin evenly. In the example below, the `Divider`s provide a subtle deliniation between each profile card without being as visually prominent as a `Card`. The `space` is adjusted to `0.25rem` which applied `0.125rem` to the top and bottom margin.
25
+
26
+ <ExampleCodeBlock code={Basic} />
27
+
28
+ ### Custom Space
29
+
30
+ You might also want to apply custom space to `Divider` where the top and bottom margin are not equal. The best way to achieve this is with `createStyles` and the `cs` property. In the example below, the `Divider` is applied as a decorative element to add emphasis to the section heading. Custom styles are defined in the `createStyles` function outside the component and are passed to `Divider`'s `cs` prop. These styles remove the top margin and set the bottom margin to `1rem`.
31
+
32
+ <ExampleCodeBlock code={CustomSpace} />
33
+
34
+ ## Component API
35
+
36
+ <SymbolDoc name="Divider" hideDescription />
@@ -0,0 +1,105 @@
1
+ import React from 'react';
2
+ import {Divider} from '@workday/canvas-kit-preview-react/divider';
3
+ import {createStyles} from '@workday/canvas-kit-styling';
4
+ import {system} from '@workday/canvas-tokens-web';
5
+ import {Avatar} from '@workday/canvas-kit-react/avatar';
6
+
7
+ const sectionStyles = createStyles({
8
+ display: 'flex',
9
+ flexDirection: 'column',
10
+ gap: system.space.x4,
11
+ maxWidth: '40rem',
12
+ });
13
+
14
+ export default () => {
15
+ const lastIndex = maintainerList.length - 1;
16
+ return (
17
+ <section className={sectionStyles}>
18
+ {maintainerList.map((maintainerData, index) => (
19
+ <>
20
+ <ProfileCard {...maintainerData} />
21
+ {index !== lastIndex && <Divider space={system.space.x1} />}
22
+ </>
23
+ ))}
24
+ </section>
25
+ );
26
+ };
27
+
28
+ const maintainerList = [
29
+ {
30
+ id: '44883293',
31
+ name: 'Josh Bagwell',
32
+ bio: 'Software Development Engineer',
33
+ },
34
+ {
35
+ id: '338257',
36
+ name: 'Nicholas Boll',
37
+ bio: 'Principal Software Development Engineer',
38
+ },
39
+ {
40
+ id: '7966550',
41
+ name: 'Manuel Carrera',
42
+ bio: 'Sr. Software Development Engineer',
43
+ },
44
+ {
45
+ id: '146020',
46
+ name: 'James Fan',
47
+ bio: 'Sr. Software Development Engineer',
48
+ },
49
+ {
50
+ id: '48605821',
51
+ name: 'Raisa Primerova',
52
+ bio: 'Software Development Engineer',
53
+ },
54
+ {
55
+ id: '4818182',
56
+ name: 'Alan Smith',
57
+ bio: 'Principal Software Development Engineer',
58
+ },
59
+ ];
60
+
61
+ const profileCardStyles = createStyles({
62
+ display: 'grid',
63
+ gridGap: '0.5rem',
64
+ gridTemplateColumns: '5rem 1fr',
65
+ gridTemplateRows: '1fr 1fr',
66
+ });
67
+
68
+ const profileCardAvatarStyles = createStyles({
69
+ gridColumn: '1',
70
+ gridRow: '1 / 3',
71
+ });
72
+
73
+ const profileCardHeadingStyles = createStyles({
74
+ ...system.type.body.large,
75
+ fontWeight: system.fontWeight.bold,
76
+ gridColumn: '2/3',
77
+ gridRow: '1',
78
+ margin: 0,
79
+ });
80
+
81
+ const profileCardBodyStyles = createStyles({
82
+ ...system.type.body.small,
83
+ gridColumn: '2',
84
+ gridRow: '2',
85
+ margin: 0,
86
+ });
87
+
88
+ interface ProfileCardProps {
89
+ id: string;
90
+ name: string;
91
+ bio: string;
92
+ }
93
+
94
+ const ProfileCard = ({id, name, bio}: ProfileCardProps) => (
95
+ <div className={profileCardStyles}>
96
+ <Avatar
97
+ size={Avatar.Size.xl}
98
+ url={`https://avatars.githubusercontent.com/u/${id}?v=4`}
99
+ altText={`${name}'s avatar`}
100
+ className={profileCardAvatarStyles}
101
+ />
102
+ <h3 className={profileCardHeadingStyles}>{name}</h3>
103
+ <p className={profileCardBodyStyles}>{bio}</p>
104
+ </div>
105
+ );
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import {Divider} from '@workday/canvas-kit-preview-react/divider';
3
+ import {createStyles} from '@workday/canvas-kit-styling';
4
+ import {system} from '@workday/canvas-tokens-web';
5
+
6
+ const headingStyles = createStyles({
7
+ ...system.type.body.large,
8
+ fontWeight: system.fontWeight.bold,
9
+ margin: 0,
10
+ });
11
+
12
+ const bodyStyles = createStyles({
13
+ ...system.type.body.small,
14
+ margin: 0,
15
+ });
16
+
17
+ const customDividerSpace = createStyles({
18
+ margin: `0 0 ${system.space.x4}`,
19
+ });
20
+
21
+ export default () => {
22
+ return (
23
+ <section>
24
+ <h3 className={headingStyles}>Quote of the Day</h3>
25
+ <Divider cs={customDividerSpace} />
26
+ <p className={bodyStyles}>
27
+ "It is not our differences that divide us. It is our inability to recognize, accept, and
28
+ celebrate those differences." – Audre Lorde
29
+ </p>
30
+ </section>
31
+ );
32
+ };
@@ -1,9 +1,8 @@
1
1
  import {AriaLiveRegion} from '@workday/canvas-kit-react/common';
2
- import FilterListWithLiveStatus from './examples/common/FilterListWithLiveStatus';
3
- import VisibleLiveRegion from './examples/common/VisibleLiveRegion';
4
- import HiddenLiveRegion from './examples/common/HiddenLiveRegion';
5
- import TextInputWithLiveError from './examples/common/TextInputWithLiveError';
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 or shown.
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} />
@@ -1,10 +1,12 @@
1
1
  import React, {useState} from 'react';
2
- import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
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 = {paddingLeft: '0px'};
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 gap="1rem">
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
- <TextInput orientation="vertical">
53
- <TextInput.Label>Filter Items:</TextInput.Label>
54
- <TextInput.Field value={filter} onChange={handleFilter} />
55
- </TextInput>
56
- <ul style={listStyles}>
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
+ };