@momentum-design/components 0.46.0 → 0.47.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.
- package/dist/browser/index.js +156 -141
- package/dist/browser/index.js.map +4 -4
- package/dist/components/screenreaderannouncer/index.d.ts +7 -0
- package/dist/components/screenreaderannouncer/index.js +4 -0
- package/dist/components/screenreaderannouncer/screenreaderannouncer.component.d.ts +110 -0
- package/dist/components/screenreaderannouncer/screenreaderannouncer.component.js +212 -0
- package/dist/components/screenreaderannouncer/screenreaderannouncer.constants.d.ts +13 -0
- package/dist/components/screenreaderannouncer/screenreaderannouncer.constants.js +14 -0
- package/dist/components/screenreaderannouncer/screenreaderannouncer.styles.d.ts +2 -0
- package/dist/components/screenreaderannouncer/screenreaderannouncer.styles.js +8 -0
- package/dist/components/screenreaderannouncer/screenreaderannouncer.types.d.ts +3 -0
- package/dist/components/screenreaderannouncer/screenreaderannouncer.types.js +1 -0
- package/dist/custom-elements.json +179 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/dist/react/screenreaderannouncer/index.d.ts +34 -0
- package/dist/react/screenreaderannouncer/index.js +43 -0
- package/package.json +2 -1
@@ -0,0 +1,34 @@
|
|
1
|
+
import Component from '../../components/screenreaderannouncer';
|
2
|
+
/**
|
3
|
+
* `mdc-screenreaderannouncer` can be used to announce messages with the screen reader.
|
4
|
+
*
|
5
|
+
* To make an announcement set `announcement` attribute on the `mdc-screenreaderannouncer` element.
|
6
|
+
*
|
7
|
+
* **Internal logic**
|
8
|
+
*
|
9
|
+
* When the screenreader announcer is connected to the DOM, if the `identity` attribute is not
|
10
|
+
* provided, it is set to `mdc-screenreaderannouncer-identity` and a `<div>` element with this id is created
|
11
|
+
* in the DOM. If the `identity` attribute is provided, the identity element is used and no new element
|
12
|
+
* is created in the DOM.
|
13
|
+
*
|
14
|
+
* When the `announcement` attribute is set, the screenreader announcer will create a `<div>` element with
|
15
|
+
* `aria-live` attribute set to the value of `data-aria-live` attribute and append it to the `identity` element.
|
16
|
+
* After delay of `delay` milliseconds, a <p> element with the announcement text is appended to the `<div>` element.
|
17
|
+
*
|
18
|
+
* The announcement `<div>` element is removed from the DOM after `timeout` milliseconds.
|
19
|
+
*
|
20
|
+
* When the screen announcer component is disconnected from the DOM, all the timeouts are cleared and
|
21
|
+
* all the announcement elements added are removed from the DOM and timeouts cleared.
|
22
|
+
*
|
23
|
+
* **Note**
|
24
|
+
* 1. The default delay of 150 miliseconds is used as we dynamically generate the
|
25
|
+
* aria-live region in the DOM and add the announcement text to it.
|
26
|
+
* 3. If no `identity` is provided, all the screen reader components will create and use only one
|
27
|
+
* `<div>` element with id `mdc-screenreaderannouncer-identity` in the DOM.
|
28
|
+
*
|
29
|
+
* Reference: https://patrickhlauke.github.io/aria/tests/live-regions/
|
30
|
+
*
|
31
|
+
* @tagname mdc-screenreaderannouncer
|
32
|
+
*/
|
33
|
+
declare const reactWrapper: import("@lit/react").ReactWebComponent<Component, {}>;
|
34
|
+
export default reactWrapper;
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { createComponent } from '@lit/react';
|
3
|
+
import Component from '../../components/screenreaderannouncer';
|
4
|
+
import { TAG_NAME } from '../../components/screenreaderannouncer/screenreaderannouncer.constants';
|
5
|
+
/**
|
6
|
+
* `mdc-screenreaderannouncer` can be used to announce messages with the screen reader.
|
7
|
+
*
|
8
|
+
* To make an announcement set `announcement` attribute on the `mdc-screenreaderannouncer` element.
|
9
|
+
*
|
10
|
+
* **Internal logic**
|
11
|
+
*
|
12
|
+
* When the screenreader announcer is connected to the DOM, if the `identity` attribute is not
|
13
|
+
* provided, it is set to `mdc-screenreaderannouncer-identity` and a `<div>` element with this id is created
|
14
|
+
* in the DOM. If the `identity` attribute is provided, the identity element is used and no new element
|
15
|
+
* is created in the DOM.
|
16
|
+
*
|
17
|
+
* When the `announcement` attribute is set, the screenreader announcer will create a `<div>` element with
|
18
|
+
* `aria-live` attribute set to the value of `data-aria-live` attribute and append it to the `identity` element.
|
19
|
+
* After delay of `delay` milliseconds, a <p> element with the announcement text is appended to the `<div>` element.
|
20
|
+
*
|
21
|
+
* The announcement `<div>` element is removed from the DOM after `timeout` milliseconds.
|
22
|
+
*
|
23
|
+
* When the screen announcer component is disconnected from the DOM, all the timeouts are cleared and
|
24
|
+
* all the announcement elements added are removed from the DOM and timeouts cleared.
|
25
|
+
*
|
26
|
+
* **Note**
|
27
|
+
* 1. The default delay of 150 miliseconds is used as we dynamically generate the
|
28
|
+
* aria-live region in the DOM and add the announcement text to it.
|
29
|
+
* 3. If no `identity` is provided, all the screen reader components will create and use only one
|
30
|
+
* `<div>` element with id `mdc-screenreaderannouncer-identity` in the DOM.
|
31
|
+
*
|
32
|
+
* Reference: https://patrickhlauke.github.io/aria/tests/live-regions/
|
33
|
+
*
|
34
|
+
* @tagname mdc-screenreaderannouncer
|
35
|
+
*/
|
36
|
+
const reactWrapper = createComponent({
|
37
|
+
tagName: TAG_NAME,
|
38
|
+
elementClass: Component,
|
39
|
+
react: React,
|
40
|
+
events: {},
|
41
|
+
displayName: 'ScreenreaderAnnouncer',
|
42
|
+
});
|
43
|
+
export default reactWrapper;
|
package/package.json
CHANGED
@@ -31,6 +31,7 @@
|
|
31
31
|
"@floating-ui/dom": "^1.6.12",
|
32
32
|
"@lit/context": "^1.1.2",
|
33
33
|
"@lit/react": "^1.0.5",
|
34
|
+
"@momentum-design/brand-visuals": "*",
|
34
35
|
"@momentum-design/fonts": "*",
|
35
36
|
"@momentum-design/icons": "*",
|
36
37
|
"@momentum-design/tokens": "*",
|
@@ -38,5 +39,5 @@
|
|
38
39
|
"lit": "^3.2.0",
|
39
40
|
"uuid": "^11.0.5"
|
40
41
|
},
|
41
|
-
"version": "0.
|
42
|
+
"version": "0.47.0"
|
42
43
|
}
|