@zag-js/pin-input 0.0.0-dev-20221015064943 → 0.0.0-dev-20221015100745

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
@@ -55,17 +55,13 @@ function defineDomHelpers(helpers) {
55
55
  getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
56
56
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
57
57
  getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
58
- createEmitter: (ctx, ns, target) => {
58
+ createEmitter: (ctx, target) => {
59
59
  const win = dom2.getWin(ctx);
60
- if (!target) {
61
- throw new Error("[dom/create-emit] Expected an element but got undefined");
62
- }
63
- return (evt, detail, options) => {
64
- const event = new win.CustomEvent(`zag:${ns}:${evt}`, {
65
- detail,
66
- bubbles: (options == null ? void 0 : options.bubbles) || true,
67
- cancelable: options == null ? void 0 : options.cancelable
68
- });
60
+ return function emit(evt, detail, options) {
61
+ const { bubbles = true, cancelable, composed = true } = options ?? {};
62
+ const eventName = `zag:${evt}`;
63
+ const init = { bubbles, cancelable, composed, detail };
64
+ const event = new win.CustomEvent(eventName, init);
69
65
  target.dispatchEvent(event);
70
66
  };
71
67
  }
package/dist/index.mjs CHANGED
@@ -28,17 +28,13 @@ function defineDomHelpers(helpers) {
28
28
  getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
29
29
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
30
30
  getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
31
- createEmitter: (ctx, ns, target) => {
31
+ createEmitter: (ctx, target) => {
32
32
  const win = dom2.getWin(ctx);
33
- if (!target) {
34
- throw new Error("[dom/create-emit] Expected an element but got undefined");
35
- }
36
- return (evt, detail, options) => {
37
- const event = new win.CustomEvent(`zag:${ns}:${evt}`, {
38
- detail,
39
- bubbles: (options == null ? void 0 : options.bubbles) || true,
40
- cancelable: options == null ? void 0 : options.cancelable
41
- });
33
+ return function emit(evt, detail, options) {
34
+ const { bubbles = true, cancelable, composed = true } = options ?? {};
35
+ const eventName = `zag:${evt}`;
36
+ const init = { bubbles, cancelable, composed, detail };
37
+ const event = new win.CustomEvent(eventName, init);
42
38
  target.dispatchEvent(event);
43
39
  };
44
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/pin-input",
3
- "version": "0.0.0-dev-20221015064943",
3
+ "version": "0.0.0-dev-20221015100745",
4
4
  "description": "Core logic for the pin-input widget implemented as a state machine",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -33,7 +33,7 @@
33
33
  "@zag-js/types": "0.2.7"
34
34
  },
35
35
  "devDependencies": {
36
- "@zag-js/dom-utils": "0.0.0-dev-20221015064943",
36
+ "@zag-js/dom-utils": "0.0.0-dev-20221015100745",
37
37
  "@zag-js/form-utils": "0.1.3",
38
38
  "@zag-js/utils": "0.1.6"
39
39
  },