@zag-js/live-region 0.2.0 → 0.2.2
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/index.d.ts +2 -2
- package/dist/index.js +6 -7
- package/dist/index.mjs +6 -7
- package/package.json +17 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
type LiveRegionOptions = {
|
|
2
2
|
level: "polite" | "assertive";
|
|
3
3
|
document?: Document;
|
|
4
4
|
root?: HTMLElement | null;
|
|
5
5
|
delay?: number;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type LiveRegion = ReturnType<typeof createLiveRegion>;
|
|
8
8
|
declare function createLiveRegion(opts?: Partial<LiveRegionOptions>): {
|
|
9
9
|
announce: (message: string, delay?: number) => void;
|
|
10
10
|
destroy: () => void;
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ __export(src_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(src_exports);
|
|
26
26
|
|
|
27
|
-
// ../dom/
|
|
27
|
+
// ../dom/src/visually-hidden.ts
|
|
28
28
|
var visuallyHiddenStyle = {
|
|
29
29
|
border: "0",
|
|
30
30
|
clip: "rect(0 0 0 0)",
|
|
@@ -44,14 +44,13 @@ function setVisuallyHidden(el) {
|
|
|
44
44
|
// src/index.ts
|
|
45
45
|
var ID = "__live-region__";
|
|
46
46
|
function createLiveRegion(opts = {}) {
|
|
47
|
-
var _a;
|
|
48
47
|
const { level = "polite", document: doc = document, root, delay: _delay = 0 } = opts;
|
|
49
|
-
const win =
|
|
50
|
-
const parent = root
|
|
48
|
+
const win = doc.defaultView ?? window;
|
|
49
|
+
const parent = root ?? doc.body;
|
|
51
50
|
function announce(message, delay) {
|
|
52
51
|
const oldRegion = doc.getElementById(ID);
|
|
53
|
-
oldRegion
|
|
54
|
-
delay = delay
|
|
52
|
+
oldRegion?.remove();
|
|
53
|
+
delay = delay ?? _delay;
|
|
55
54
|
const region = doc.createElement("span");
|
|
56
55
|
region.id = ID;
|
|
57
56
|
region.dataset.liveAnnouncer = "true";
|
|
@@ -66,7 +65,7 @@ function createLiveRegion(opts = {}) {
|
|
|
66
65
|
}
|
|
67
66
|
function destroy() {
|
|
68
67
|
const oldRegion = doc.getElementById(ID);
|
|
69
|
-
oldRegion
|
|
68
|
+
oldRegion?.remove();
|
|
70
69
|
}
|
|
71
70
|
return {
|
|
72
71
|
announce,
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../dom/
|
|
1
|
+
// ../dom/src/visually-hidden.ts
|
|
2
2
|
var visuallyHiddenStyle = {
|
|
3
3
|
border: "0",
|
|
4
4
|
clip: "rect(0 0 0 0)",
|
|
@@ -18,14 +18,13 @@ function setVisuallyHidden(el) {
|
|
|
18
18
|
// src/index.ts
|
|
19
19
|
var ID = "__live-region__";
|
|
20
20
|
function createLiveRegion(opts = {}) {
|
|
21
|
-
var _a;
|
|
22
21
|
const { level = "polite", document: doc = document, root, delay: _delay = 0 } = opts;
|
|
23
|
-
const win =
|
|
24
|
-
const parent = root
|
|
22
|
+
const win = doc.defaultView ?? window;
|
|
23
|
+
const parent = root ?? doc.body;
|
|
25
24
|
function announce(message, delay) {
|
|
26
25
|
const oldRegion = doc.getElementById(ID);
|
|
27
|
-
oldRegion
|
|
28
|
-
delay = delay
|
|
26
|
+
oldRegion?.remove();
|
|
27
|
+
delay = delay ?? _delay;
|
|
29
28
|
const region = doc.createElement("span");
|
|
30
29
|
region.id = ID;
|
|
31
30
|
region.dataset.liveAnnouncer = "true";
|
|
@@ -40,7 +39,7 @@ function createLiveRegion(opts = {}) {
|
|
|
40
39
|
}
|
|
41
40
|
function destroy() {
|
|
42
41
|
const oldRegion = doc.getElementById(ID);
|
|
43
|
-
oldRegion
|
|
42
|
+
oldRegion?.remove();
|
|
44
43
|
}
|
|
45
44
|
return {
|
|
46
45
|
announce,
|
package/package.json
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/live-region",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Implementing live region for screen readers",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.mjs",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
5
|
"keywords": [
|
|
9
6
|
"js",
|
|
10
7
|
"utils",
|
|
@@ -19,7 +16,8 @@
|
|
|
19
16
|
"dist/**/*"
|
|
20
17
|
],
|
|
21
18
|
"devDependencies": {
|
|
22
|
-
"
|
|
19
|
+
"clean-package": "2.2.0",
|
|
20
|
+
"@zag-js/dom-utils": "0.2.4"
|
|
23
21
|
},
|
|
24
22
|
"publishConfig": {
|
|
25
23
|
"access": "public"
|
|
@@ -27,10 +25,22 @@
|
|
|
27
25
|
"bugs": {
|
|
28
26
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
29
27
|
},
|
|
28
|
+
"clean-package": "../../../clean-package.config.json",
|
|
29
|
+
"main": "dist/index.js",
|
|
30
|
+
"module": "dist/index.mjs",
|
|
31
|
+
"types": "dist/index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"import": "./dist/index.mjs",
|
|
36
|
+
"require": "./dist/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
30
40
|
"scripts": {
|
|
31
|
-
"build-fast": "tsup src
|
|
41
|
+
"build-fast": "tsup src",
|
|
32
42
|
"start": "pnpm build --watch",
|
|
33
|
-
"build": "tsup src
|
|
43
|
+
"build": "tsup src --dts",
|
|
34
44
|
"test": "jest --config ../../../jest.config.js --rootDir tests",
|
|
35
45
|
"lint": "eslint src --ext .ts,.tsx",
|
|
36
46
|
"test-ci": "pnpm test --ci --runInBand -u",
|