@moda/om 21.6.3 → 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.3",
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>
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useMemo } from 'react';
1
+ import React, { useCallback, useEffect, useMemo } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import ChevronDownIcon from '@moda/icons/chevron-down-12';
4
4
  import ChevronUpIcon from '@moda/icons/chevron-up-12';
@@ -115,6 +115,12 @@ export const Select: React.FC<SelectProps> = ({
115
115
  [options, state.focused]
116
116
  );
117
117
 
118
+ useEffect(() => {
119
+ if (disabled && state.mode === Mode.Open) {
120
+ dispatch({ type: 'CLOSE' });
121
+ }
122
+ }, [disabled, state.mode, Mode, dispatch]);
123
+
118
124
  return (
119
125
  <>
120
126
  <div