@zag-js/live-region 0.2.1 → 0.2.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 CHANGED
@@ -23,42 +23,23 @@ __export(src_exports, {
23
23
  createLiveRegion: () => createLiveRegion
24
24
  });
25
25
  module.exports = __toCommonJS(src_exports);
26
-
27
- // ../dom/src/visually-hidden.ts
28
- var visuallyHiddenStyle = {
29
- border: "0",
30
- clip: "rect(0 0 0 0)",
31
- height: "1px",
32
- margin: "-1px",
33
- overflow: "hidden",
34
- padding: "0",
35
- position: "absolute",
36
- width: "1px",
37
- whiteSpace: "nowrap",
38
- wordWrap: "normal"
39
- };
40
- function setVisuallyHidden(el) {
41
- Object.assign(el.style, visuallyHiddenStyle);
42
- }
43
-
44
- // src/index.ts
26
+ var import_visually_hidden = require("@zag-js/visually-hidden");
45
27
  var ID = "__live-region__";
46
28
  function createLiveRegion(opts = {}) {
47
- var _a;
48
29
  const { level = "polite", document: doc = document, root, delay: _delay = 0 } = opts;
49
- const win = (_a = doc.defaultView) != null ? _a : window;
50
- const parent = root != null ? root : doc.body;
30
+ const win = doc.defaultView ?? window;
31
+ const parent = root ?? doc.body;
51
32
  function announce(message, delay) {
52
33
  const oldRegion = doc.getElementById(ID);
53
- oldRegion == null ? void 0 : oldRegion.remove();
54
- delay = delay != null ? delay : _delay;
34
+ oldRegion?.remove();
35
+ delay = delay ?? _delay;
55
36
  const region = doc.createElement("span");
56
37
  region.id = ID;
57
38
  region.dataset.liveAnnouncer = "true";
58
39
  const role = level !== "assertive" ? "status" : "alert";
59
40
  region.setAttribute("aria-live", level);
60
41
  region.setAttribute("role", role);
61
- setVisuallyHidden(region);
42
+ (0, import_visually_hidden.setVisuallyHidden)(region);
62
43
  parent.appendChild(region);
63
44
  win.setTimeout(() => {
64
45
  region.textContent = message;
@@ -66,7 +47,7 @@ function createLiveRegion(opts = {}) {
66
47
  }
67
48
  function destroy() {
68
49
  const oldRegion = doc.getElementById(ID);
69
- oldRegion == null ? void 0 : oldRegion.remove();
50
+ oldRegion?.remove();
70
51
  }
71
52
  return {
72
53
  announce,
package/dist/index.mjs CHANGED
@@ -1,31 +1,14 @@
1
- // ../dom/src/visually-hidden.ts
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
1
  // src/index.ts
2
+ import { setVisuallyHidden } from "@zag-js/visually-hidden";
19
3
  var ID = "__live-region__";
20
4
  function createLiveRegion(opts = {}) {
21
- var _a;
22
5
  const { level = "polite", document: doc = document, root, delay: _delay = 0 } = opts;
23
- const win = (_a = doc.defaultView) != null ? _a : window;
24
- const parent = root != null ? root : doc.body;
6
+ const win = doc.defaultView ?? window;
7
+ const parent = root ?? doc.body;
25
8
  function announce(message, delay) {
26
9
  const oldRegion = doc.getElementById(ID);
27
- oldRegion == null ? void 0 : oldRegion.remove();
28
- delay = delay != null ? delay : _delay;
10
+ oldRegion?.remove();
11
+ delay = delay ?? _delay;
29
12
  const region = doc.createElement("span");
30
13
  region.id = ID;
31
14
  region.dataset.liveAnnouncer = "true";
@@ -40,7 +23,7 @@ function createLiveRegion(opts = {}) {
40
23
  }
41
24
  function destroy() {
42
25
  const oldRegion = doc.getElementById(ID);
43
- oldRegion == null ? void 0 : oldRegion.remove();
26
+ oldRegion?.remove();
44
27
  }
45
28
  return {
46
29
  announce,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/live-region",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Implementing live region for screen readers",
5
5
  "keywords": [
6
6
  "js",
@@ -15,9 +15,11 @@
15
15
  "files": [
16
16
  "dist/**/*"
17
17
  ],
18
+ "dependencies": {
19
+ "@zag-js/visually-hidden": "0.0.1"
20
+ },
18
21
  "devDependencies": {
19
- "clean-package": "2.2.0",
20
- "@zag-js/dom-utils": "0.2.2"
22
+ "clean-package": "2.2.0"
21
23
  },
22
24
  "publishConfig": {
23
25
  "access": "public"