@moda/om 21.6.4 → 21.6.5

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.
@@ -5,5 +5,7 @@ export type ModalProps = React.HTMLAttributes<HTMLDivElement> & {
5
5
  onClose(): void;
6
6
  shards?: ComponentProps<typeof FocusOn>['shards'];
7
7
  autoFocus?: boolean;
8
+ 'aria-label'?: string;
9
+ 'aria-labelledby'?: string;
8
10
  };
9
11
  export declare const Modal: React.FC<ModalProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moda/om",
3
- "version": "21.6.4",
3
+ "version": "21.6.5",
4
4
  "description": "Moda Operandi design system",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -1,4 +1,4 @@
1
- import React, { ReactNode } from 'react';
1
+ import React, { ReactNode, useId } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { ModalOverlay, ModalOverlayProps } from '../ModalOverlay';
4
4
  import { Stack } from '../Stack';
@@ -18,16 +18,28 @@ export const Dialog: React.FC<DialogProps> = ({
18
18
  actions,
19
19
  contentClassName,
20
20
  ...rest
21
- }) => (
22
- <ModalOverlay contentClassName={classNames('Dialog', contentClassName)} {...rest}>
23
- <Stack className='Dialog__content' space={6}>
24
- {title && <Text treatment='h5'>{title}</Text>}
25
- {message && <Text>{message}</Text>}
26
- {actions && (
27
- <Stack direction='horizontal' space={3} alignItems='center' justifyContent='center'>
28
- {actions}
29
- </Stack>
30
- )}
31
- </Stack>
32
- </ModalOverlay>
33
- );
21
+ }) => {
22
+ const titleId = useId();
23
+
24
+ return (
25
+ <ModalOverlay
26
+ contentClassName={classNames('Dialog', contentClassName)}
27
+ aria-labelledby={title ? titleId : undefined}
28
+ {...rest}
29
+ >
30
+ <Stack className='Dialog__content' space={6}>
31
+ {title && (
32
+ <Text id={titleId} treatment='h5'>
33
+ {title}
34
+ </Text>
35
+ )}
36
+ {message && <Text>{message}</Text>}
37
+ {actions && (
38
+ <Stack direction='horizontal' space={3} alignItems='center' justifyContent='center'>
39
+ {actions}
40
+ </Stack>
41
+ )}
42
+ </Stack>
43
+ </ModalOverlay>
44
+ );
45
+ };
@@ -19,7 +19,9 @@ export const Default = () => {
19
19
  <Button onClick={() => setMode(Mode.Open)}>Open Modal</Button>
20
20
  {mode === Mode.Open && (
21
21
  <Modal onClose={() => setMode(Mode.Resting)}>
22
- <Text>Click (or press &lt;esc&gt;) to close</Text>
22
+ <div tabIndex={-1}>
23
+ <Text>Click (or press &lt;esc&gt;) to close</Text>
24
+ </div>
23
25
  </Modal>
24
26
  )}
25
27
  </>
@@ -45,6 +47,7 @@ export const BackdropContent = () => {
45
47
  }}
46
48
  >
47
49
  <div
50
+ tabIndex={-1}
48
51
  style={{
49
52
  backgroundColor: 'white',
50
53
  padding: '1rem 1.5rem'
@@ -8,6 +8,8 @@ export type ModalProps = React.HTMLAttributes<HTMLDivElement> & {
8
8
  onClose(): void;
9
9
  shards?: ComponentProps<typeof FocusOn>['shards'];
10
10
  autoFocus?: boolean;
11
+ 'aria-label'?: string;
12
+ 'aria-labelledby'?: string;
11
13
  };
12
14
 
13
15
  export const Modal: React.FC<ModalProps> = ({
@@ -15,10 +17,10 @@ export const Modal: React.FC<ModalProps> = ({
15
17
  children,
16
18
  onClose,
17
19
  shards,
18
- autoFocus,
20
+ autoFocus = true,
19
21
  ...rest
20
22
  }) => (
21
- <div className={classNames('Modal', className)} {...rest}>
23
+ <div className={classNames('Modal', className)} role='dialog' aria-modal='true' {...rest}>
22
24
  <FocusOn autoFocus={autoFocus} shards={shards} onClickOutside={onClose} onEscapeKey={onClose}>
23
25
  {children}
24
26
  </FocusOn>