@zag-js/live-region 0.70.0 → 0.72.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 CHANGED
@@ -1,28 +1,6 @@
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);
1
+ 'use strict';
19
2
 
20
3
  // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- createLiveRegion: () => createLiveRegion
24
- });
25
- module.exports = __toCommonJS(src_exports);
26
4
  var ID = "__live-region__";
27
5
  function createLiveRegion(opts = {}) {
28
6
  const { level = "polite", document: doc = document, root, delay: _delay = 0 } = opts;
@@ -67,8 +45,5 @@ function createLiveRegion(opts = {}) {
67
45
  }
68
46
  };
69
47
  }
70
- // Annotate the CommonJS export names for ESM import in node:
71
- 0 && (module.exports = {
72
- createLiveRegion
73
- });
74
- //# sourceMappingURL=index.js.map
48
+
49
+ exports.createLiveRegion = createLiveRegion;
package/dist/index.mjs CHANGED
@@ -43,7 +43,5 @@ function createLiveRegion(opts = {}) {
43
43
  }
44
44
  };
45
45
  }
46
- export {
47
- createLiveRegion
48
- };
49
- //# sourceMappingURL=index.mjs.map
46
+
47
+ export { createLiveRegion };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/live-region",
3
- "version": "0.70.0",
3
+ "version": "0.72.0",
4
4
  "description": "Implementing live region for screen readers",
5
5
  "keywords": [
6
6
  "js",
@@ -13,8 +13,7 @@
13
13
  "repository": "https://github.com/chakra-ui/zag/tree/main/packages/utilities/live-region",
14
14
  "sideEffects": false,
15
15
  "files": [
16
- "dist",
17
- "src"
16
+ "dist"
18
17
  ],
19
18
  "devDependencies": {
20
19
  "clean-package": "2.2.0"
@@ -39,7 +38,7 @@
39
38
  },
40
39
  "scripts": {
41
40
  "build": "tsup",
42
- "test": "jest --config ../../../jest.config.js --rootDir tests",
41
+ "test": "vitest",
43
42
  "lint": "eslint src",
44
43
  "test-ci": "pnpm test --ci --runInBand -u",
45
44
  "test-watch": "pnpm test --watchAll"
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
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":[]}
@@ -1 +0,0 @@
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":[]}
package/src/index.ts DELETED
@@ -1,73 +0,0 @@
1
- export interface LiveRegionOptions {
2
- level: "polite" | "assertive"
3
- document?: Document
4
- root?: HTMLElement | null
5
- delay?: number
6
- }
7
-
8
- export type LiveRegion = ReturnType<typeof createLiveRegion>
9
-
10
- const ID = "__live-region__"
11
-
12
- export function createLiveRegion(opts: Partial<LiveRegionOptions> = {}) {
13
- const { level = "polite", document: doc = document, root, delay: _delay = 0 } = opts
14
-
15
- const win = doc.defaultView ?? window
16
- const parent = root ?? doc.body
17
-
18
- function announce(message: string, delay?: number) {
19
- const oldRegion = doc.getElementById(ID)
20
-
21
- // remove old region
22
- oldRegion?.remove()
23
-
24
- // Did an override level get set?
25
- delay = delay ?? _delay
26
-
27
- // create fresh region
28
- const region = doc.createElement("span")
29
- region.id = ID
30
- region.dataset.liveAnnouncer = "true"
31
-
32
- // Determine redundant role
33
- const role = level !== "assertive" ? "status" : "alert"
34
-
35
- // add role and attributes
36
- region.setAttribute("aria-live", level)
37
- region.setAttribute("role", role)
38
-
39
- // hide live region
40
- Object.assign(region.style, {
41
- border: "0",
42
- clip: "rect(0 0 0 0)",
43
- height: "1px",
44
- margin: "-1px",
45
- overflow: "hidden",
46
- padding: "0",
47
- position: "absolute",
48
- width: "1px",
49
- whiteSpace: "nowrap",
50
- wordWrap: "normal",
51
- })
52
-
53
- parent.appendChild(region)
54
-
55
- // populate region to trigger it
56
- win.setTimeout(() => {
57
- region.textContent = message
58
- }, delay)
59
- }
60
-
61
- function destroy() {
62
- const oldRegion = doc.getElementById(ID)
63
- oldRegion?.remove()
64
- }
65
-
66
- return {
67
- announce,
68
- destroy,
69
- toJSON() {
70
- return ID
71
- },
72
- }
73
- }