@zag-js/live-region 0.52.0 → 0.54.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/index.js +73 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,74 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
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
|
+
var ID = "__live-region__";
|
|
27
|
+
function createLiveRegion(opts = {}) {
|
|
28
|
+
const { level = "polite", document: doc = document, root, delay: _delay = 0 } = opts;
|
|
29
|
+
const win = doc.defaultView ?? window;
|
|
30
|
+
const parent = root ?? doc.body;
|
|
31
|
+
function announce(message, delay) {
|
|
32
|
+
const oldRegion = doc.getElementById(ID);
|
|
33
|
+
oldRegion?.remove();
|
|
34
|
+
delay = delay ?? _delay;
|
|
35
|
+
const region = doc.createElement("span");
|
|
36
|
+
region.id = ID;
|
|
37
|
+
region.dataset.liveAnnouncer = "true";
|
|
38
|
+
const role = level !== "assertive" ? "status" : "alert";
|
|
39
|
+
region.setAttribute("aria-live", level);
|
|
40
|
+
region.setAttribute("role", role);
|
|
41
|
+
Object.assign(region.style, {
|
|
42
|
+
border: "0",
|
|
43
|
+
clip: "rect(0 0 0 0)",
|
|
44
|
+
height: "1px",
|
|
45
|
+
margin: "-1px",
|
|
46
|
+
overflow: "hidden",
|
|
47
|
+
padding: "0",
|
|
48
|
+
position: "absolute",
|
|
49
|
+
width: "1px",
|
|
50
|
+
whiteSpace: "nowrap",
|
|
51
|
+
wordWrap: "normal"
|
|
52
|
+
});
|
|
53
|
+
parent.appendChild(region);
|
|
54
|
+
win.setTimeout(() => {
|
|
55
|
+
region.textContent = message;
|
|
56
|
+
}, delay);
|
|
57
|
+
}
|
|
58
|
+
function destroy() {
|
|
59
|
+
const oldRegion = doc.getElementById(ID);
|
|
60
|
+
oldRegion?.remove();
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
announce,
|
|
64
|
+
destroy,
|
|
65
|
+
toJSON() {
|
|
66
|
+
return ID;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
createLiveRegion
|
|
73
|
+
});
|
|
2
74
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export interface LiveRegionOptions {\n level: \"polite\" | \"assertive\"\n document?: Document\n root?: HTMLElement | null\n delay?: number\n}\n\nexport type LiveRegion = ReturnType<typeof createLiveRegion>\n\nconst ID = \"__live-region__\"\n\nexport function createLiveRegion(opts: Partial<LiveRegionOptions> = {}) {\n const { level = \"polite\", document: doc = document, root, delay: _delay = 0 } = opts\n\n const win = doc.defaultView ?? window\n const parent = root ?? doc.body\n\n function announce(message: string, delay?: number) {\n const oldRegion = doc.getElementById(ID)\n\n // remove old region\n oldRegion?.remove()\n\n // Did an override level get set?\n delay = delay ?? _delay\n\n // create fresh region\n const region = doc.createElement(\"span\")\n region.id = ID\n region.dataset.liveAnnouncer = \"true\"\n\n // Determine redundant role\n const role = level !== \"assertive\" ? \"status\" : \"alert\"\n\n // add role and attributes\n region.setAttribute(\"aria-live\", level)\n region.setAttribute(\"role\", role)\n\n // hide live region\n Object.assign(region.style, {\n border: \"0\",\n clip: \"rect(0 0 0 0)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0\",\n position: \"absolute\",\n width: \"1px\",\n whiteSpace: \"nowrap\",\n wordWrap: \"normal\",\n })\n\n parent.appendChild(region)\n\n // populate region to trigger it\n win.setTimeout(() => {\n region.textContent = message\n }, delay)\n }\n\n function destroy() {\n const oldRegion = doc.getElementById(ID)\n oldRegion?.remove()\n }\n\n return {\n announce,\n destroy,\n toJSON() {\n return ID\n },\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export interface LiveRegionOptions {\n level: \"polite\" | \"assertive\"\n document?: Document\n root?: HTMLElement | null\n delay?: number\n}\n\nexport type LiveRegion = ReturnType<typeof createLiveRegion>\n\nconst ID = \"__live-region__\"\n\nexport function createLiveRegion(opts: Partial<LiveRegionOptions> = {}) {\n const { level = \"polite\", document: doc = document, root, delay: _delay = 0 } = opts\n\n const win = doc.defaultView ?? window\n const parent = root ?? doc.body\n\n function announce(message: string, delay?: number) {\n const oldRegion = doc.getElementById(ID)\n\n // remove old region\n oldRegion?.remove()\n\n // Did an override level get set?\n delay = delay ?? _delay\n\n // create fresh region\n const region = doc.createElement(\"span\")\n region.id = ID\n region.dataset.liveAnnouncer = \"true\"\n\n // Determine redundant role\n const role = level !== \"assertive\" ? \"status\" : \"alert\"\n\n // add role and attributes\n region.setAttribute(\"aria-live\", level)\n region.setAttribute(\"role\", role)\n\n // hide live region\n Object.assign(region.style, {\n border: \"0\",\n clip: \"rect(0 0 0 0)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0\",\n position: \"absolute\",\n width: \"1px\",\n whiteSpace: \"nowrap\",\n wordWrap: \"normal\",\n })\n\n parent.appendChild(region)\n\n // populate region to trigger it\n win.setTimeout(() => {\n region.textContent = message\n }, delay)\n }\n\n function destroy() {\n const oldRegion = doc.getElementById(ID)\n oldRegion?.remove()\n }\n\n return {\n announce,\n destroy,\n toJSON() {\n return ID\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAM,KAAK;AAEJ,SAAS,iBAAiB,OAAmC,CAAC,GAAG;AACtE,QAAM,EAAE,QAAQ,UAAU,UAAU,MAAM,UAAU,MAAM,OAAO,SAAS,EAAE,IAAI;AAEhF,QAAM,MAAM,IAAI,eAAe;AAC/B,QAAM,SAAS,QAAQ,IAAI;AAE3B,WAAS,SAAS,SAAiB,OAAgB;AACjD,UAAM,YAAY,IAAI,eAAe,EAAE;AAGvC,eAAW,OAAO;AAGlB,YAAQ,SAAS;AAGjB,UAAM,SAAS,IAAI,cAAc,MAAM;AACvC,WAAO,KAAK;AACZ,WAAO,QAAQ,gBAAgB;AAG/B,UAAM,OAAO,UAAU,cAAc,WAAW;AAGhD,WAAO,aAAa,aAAa,KAAK;AACtC,WAAO,aAAa,QAAQ,IAAI;AAGhC,WAAO,OAAO,OAAO,OAAO;AAAA,MAC1B,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,MACT,UAAU;AAAA,MACV,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ,CAAC;AAED,WAAO,YAAY,MAAM;AAGzB,QAAI,WAAW,MAAM;AACnB,aAAO,cAAc;AAAA,IACvB,GAAG,KAAK;AAAA,EACV;AAEA,WAAS,UAAU;AACjB,UAAM,YAAY,IAAI,eAAe,EAAE;AACvC,eAAW,OAAO;AAAA,EACpB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,SAAS;AACP,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var ID = "__live-region__";
|
|
3
|
+
function createLiveRegion(opts = {}) {
|
|
4
|
+
const { level = "polite", document: doc = document, root, delay: _delay = 0 } = opts;
|
|
5
|
+
const win = doc.defaultView ?? window;
|
|
6
|
+
const parent = root ?? doc.body;
|
|
7
|
+
function announce(message, delay) {
|
|
8
|
+
const oldRegion = doc.getElementById(ID);
|
|
9
|
+
oldRegion?.remove();
|
|
10
|
+
delay = delay ?? _delay;
|
|
11
|
+
const region = doc.createElement("span");
|
|
12
|
+
region.id = ID;
|
|
13
|
+
region.dataset.liveAnnouncer = "true";
|
|
14
|
+
const role = level !== "assertive" ? "status" : "alert";
|
|
15
|
+
region.setAttribute("aria-live", level);
|
|
16
|
+
region.setAttribute("role", role);
|
|
17
|
+
Object.assign(region.style, {
|
|
18
|
+
border: "0",
|
|
19
|
+
clip: "rect(0 0 0 0)",
|
|
20
|
+
height: "1px",
|
|
21
|
+
margin: "-1px",
|
|
22
|
+
overflow: "hidden",
|
|
23
|
+
padding: "0",
|
|
24
|
+
position: "absolute",
|
|
25
|
+
width: "1px",
|
|
26
|
+
whiteSpace: "nowrap",
|
|
27
|
+
wordWrap: "normal"
|
|
28
|
+
});
|
|
29
|
+
parent.appendChild(region);
|
|
30
|
+
win.setTimeout(() => {
|
|
31
|
+
region.textContent = message;
|
|
32
|
+
}, delay);
|
|
33
|
+
}
|
|
34
|
+
function destroy() {
|
|
35
|
+
const oldRegion = doc.getElementById(ID);
|
|
36
|
+
oldRegion?.remove();
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
announce,
|
|
40
|
+
destroy,
|
|
41
|
+
toJSON() {
|
|
42
|
+
return ID;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
createLiveRegion
|
|
48
|
+
};
|
|
2
49
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export interface LiveRegionOptions {\n level: \"polite\" | \"assertive\"\n document?: Document\n root?: HTMLElement | null\n delay?: number\n}\n\nexport type LiveRegion = ReturnType<typeof createLiveRegion>\n\nconst ID = \"__live-region__\"\n\nexport function createLiveRegion(opts: Partial<LiveRegionOptions> = {}) {\n const { level = \"polite\", document: doc = document, root, delay: _delay = 0 } = opts\n\n const win = doc.defaultView ?? window\n const parent = root ?? doc.body\n\n function announce(message: string, delay?: number) {\n const oldRegion = doc.getElementById(ID)\n\n // remove old region\n oldRegion?.remove()\n\n // Did an override level get set?\n delay = delay ?? _delay\n\n // create fresh region\n const region = doc.createElement(\"span\")\n region.id = ID\n region.dataset.liveAnnouncer = \"true\"\n\n // Determine redundant role\n const role = level !== \"assertive\" ? \"status\" : \"alert\"\n\n // add role and attributes\n region.setAttribute(\"aria-live\", level)\n region.setAttribute(\"role\", role)\n\n // hide live region\n Object.assign(region.style, {\n border: \"0\",\n clip: \"rect(0 0 0 0)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0\",\n position: \"absolute\",\n width: \"1px\",\n whiteSpace: \"nowrap\",\n wordWrap: \"normal\",\n })\n\n parent.appendChild(region)\n\n // populate region to trigger it\n win.setTimeout(() => {\n region.textContent = message\n }, delay)\n }\n\n function destroy() {\n const oldRegion = doc.getElementById(ID)\n oldRegion?.remove()\n }\n\n return {\n announce,\n destroy,\n toJSON() {\n return ID\n },\n }\n}\n"],"mappings":"AASA,IAAM,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export interface LiveRegionOptions {\n level: \"polite\" | \"assertive\"\n document?: Document\n root?: HTMLElement | null\n delay?: number\n}\n\nexport type LiveRegion = ReturnType<typeof createLiveRegion>\n\nconst ID = \"__live-region__\"\n\nexport function createLiveRegion(opts: Partial<LiveRegionOptions> = {}) {\n const { level = \"polite\", document: doc = document, root, delay: _delay = 0 } = opts\n\n const win = doc.defaultView ?? window\n const parent = root ?? doc.body\n\n function announce(message: string, delay?: number) {\n const oldRegion = doc.getElementById(ID)\n\n // remove old region\n oldRegion?.remove()\n\n // Did an override level get set?\n delay = delay ?? _delay\n\n // create fresh region\n const region = doc.createElement(\"span\")\n region.id = ID\n region.dataset.liveAnnouncer = \"true\"\n\n // Determine redundant role\n const role = level !== \"assertive\" ? \"status\" : \"alert\"\n\n // add role and attributes\n region.setAttribute(\"aria-live\", level)\n region.setAttribute(\"role\", role)\n\n // hide live region\n Object.assign(region.style, {\n border: \"0\",\n clip: \"rect(0 0 0 0)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0\",\n position: \"absolute\",\n width: \"1px\",\n whiteSpace: \"nowrap\",\n wordWrap: \"normal\",\n })\n\n parent.appendChild(region)\n\n // populate region to trigger it\n win.setTimeout(() => {\n region.textContent = message\n }, delay)\n }\n\n function destroy() {\n const oldRegion = doc.getElementById(ID)\n oldRegion?.remove()\n }\n\n return {\n announce,\n destroy,\n toJSON() {\n return ID\n },\n }\n}\n"],"mappings":";AASA,IAAM,KAAK;AAEJ,SAAS,iBAAiB,OAAmC,CAAC,GAAG;AACtE,QAAM,EAAE,QAAQ,UAAU,UAAU,MAAM,UAAU,MAAM,OAAO,SAAS,EAAE,IAAI;AAEhF,QAAM,MAAM,IAAI,eAAe;AAC/B,QAAM,SAAS,QAAQ,IAAI;AAE3B,WAAS,SAAS,SAAiB,OAAgB;AACjD,UAAM,YAAY,IAAI,eAAe,EAAE;AAGvC,eAAW,OAAO;AAGlB,YAAQ,SAAS;AAGjB,UAAM,SAAS,IAAI,cAAc,MAAM;AACvC,WAAO,KAAK;AACZ,WAAO,QAAQ,gBAAgB;AAG/B,UAAM,OAAO,UAAU,cAAc,WAAW;AAGhD,WAAO,aAAa,aAAa,KAAK;AACtC,WAAO,aAAa,QAAQ,IAAI;AAGhC,WAAO,OAAO,OAAO,OAAO;AAAA,MAC1B,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,SAAS;AAAA,MACT,UAAU;AAAA,MACV,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ,CAAC;AAED,WAAO,YAAY,MAAM;AAGzB,QAAI,WAAW,MAAM;AACnB,aAAO,cAAc;AAAA,IACvB,GAAG,KAAK;AAAA,EACV;AAEA,WAAS,UAAU;AACjB,UAAM,YAAY,IAAI,eAAe,EAAE;AACvC,eAAW,OAAO;AAAA,EACpB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,SAAS;AACP,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|