@zag-js/live-region 0.1.1 → 0.1.3
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.js +3 -30
- package/package.json +5 -5
- package/dist/index.mjs +0 -54
package/dist/index.js
CHANGED
|
@@ -1,30 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
createLiveRegion: () => createLiveRegion
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(src_exports);
|
|
26
|
-
|
|
27
|
-
// ../dom/dist/index.mjs
|
|
1
|
+
// ../dom/dist/index.js
|
|
28
2
|
var visuallyHiddenStyle = {
|
|
29
3
|
border: "0",
|
|
30
4
|
clip: "rect(0 0 0 0)",
|
|
@@ -75,7 +49,6 @@ function createLiveRegion(opts = {}) {
|
|
|
75
49
|
}
|
|
76
50
|
};
|
|
77
51
|
}
|
|
78
|
-
|
|
79
|
-
0 && (module.exports = {
|
|
52
|
+
export {
|
|
80
53
|
createLiveRegion
|
|
81
|
-
}
|
|
54
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"type": "module",
|
|
2
3
|
"name": "@zag-js/live-region",
|
|
3
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3",
|
|
4
5
|
"description": "Implementing live region for screen readers",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"js",
|
|
@@ -11,7 +12,6 @@
|
|
|
11
12
|
"homepage": "https://github.com/chakra-ui/zag#readme",
|
|
12
13
|
"license": "MIT",
|
|
13
14
|
"main": "dist/index.js",
|
|
14
|
-
"module": "dist/index.mjs",
|
|
15
15
|
"types": "dist/index.d.ts",
|
|
16
16
|
"repository": "https://github.com/chakra-ui/zag/tree/main/packages/utilities/live-region",
|
|
17
17
|
"sideEffects": false,
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dist/**/*"
|
|
20
20
|
],
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@zag-js/dom-utils": "0.1.
|
|
22
|
+
"@zag-js/dom-utils": "0.1.12"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
|
-
"build-fast": "tsup src/index.ts --format=esm
|
|
31
|
+
"build-fast": "tsup src/index.ts --format=esm",
|
|
32
32
|
"start": "pnpm build --watch",
|
|
33
|
-
"build": "tsup src/index.ts --format=esm
|
|
33
|
+
"build": "tsup src/index.ts --format=esm --dts",
|
|
34
34
|
"test": "jest --config ../../../jest.config.js --rootDir tests",
|
|
35
35
|
"lint": "eslint src --ext .ts,.tsx",
|
|
36
36
|
"test-ci": "pnpm test --ci --runInBand -u",
|
package/dist/index.mjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// ../dom/dist/index.mjs
|
|
2
|
-
var visuallyHiddenStyle = {
|
|
3
|
-
border: "0",
|
|
4
|
-
clip: "rect(0 0 0 0)",
|
|
5
|
-
height: "1px",
|
|
6
|
-
margin: "-1px",
|
|
7
|
-
overflow: "hidden",
|
|
8
|
-
padding: "0",
|
|
9
|
-
position: "absolute",
|
|
10
|
-
width: "1px",
|
|
11
|
-
whiteSpace: "nowrap",
|
|
12
|
-
wordWrap: "normal"
|
|
13
|
-
};
|
|
14
|
-
function setVisuallyHidden(el) {
|
|
15
|
-
Object.assign(el.style, visuallyHiddenStyle);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// src/index.ts
|
|
19
|
-
var ID = "__live-region__";
|
|
20
|
-
function createLiveRegion(opts = {}) {
|
|
21
|
-
const { level = "polite", document: doc = document, root, delay: _delay = 0 } = opts;
|
|
22
|
-
const win = doc.defaultView ?? window;
|
|
23
|
-
const parent = root ?? doc.body;
|
|
24
|
-
function announce(message, delay) {
|
|
25
|
-
const oldRegion = doc.getElementById(ID);
|
|
26
|
-
oldRegion == null ? void 0 : oldRegion.remove();
|
|
27
|
-
delay = delay ?? _delay;
|
|
28
|
-
const region = doc.createElement("span");
|
|
29
|
-
region.id = ID;
|
|
30
|
-
region.dataset.liveAnnouncer = "true";
|
|
31
|
-
const role = level !== "assertive" ? "status" : "alert";
|
|
32
|
-
region.setAttribute("aria-live", level);
|
|
33
|
-
region.setAttribute("role", role);
|
|
34
|
-
setVisuallyHidden(region);
|
|
35
|
-
parent.appendChild(region);
|
|
36
|
-
win.setTimeout(() => {
|
|
37
|
-
region.textContent = message;
|
|
38
|
-
}, delay);
|
|
39
|
-
}
|
|
40
|
-
function destroy() {
|
|
41
|
-
const oldRegion = doc.getElementById(ID);
|
|
42
|
-
oldRegion == null ? void 0 : oldRegion.remove();
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
announce,
|
|
46
|
-
destroy,
|
|
47
|
-
toJSON() {
|
|
48
|
-
return ID;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
export {
|
|
53
|
-
createLiveRegion
|
|
54
|
-
};
|