@xyo-network/react-event 2.63.1 → 2.64.0-rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. package/dist/hooks/index.d.mts.map +1 -0
  2. package/dist/{esm/hooks/index.js → hooks/index.d.ts} +1 -1
  3. package/dist/hooks/index.d.ts.map +1 -0
  4. package/dist/hooks/useCustomEvent.d.mts.map +1 -0
  5. package/dist/hooks/useCustomEvent.d.ts +4 -0
  6. package/dist/hooks/useCustomEvent.d.ts.map +1 -0
  7. package/dist/hooks/useEvent.d.mts.map +1 -0
  8. package/dist/hooks/useEvent.d.ts +11 -0
  9. package/dist/hooks/useEvent.d.ts.map +1 -0
  10. package/dist/index.d.mts.map +1 -0
  11. package/dist/index.d.ts +2 -0
  12. package/dist/{types/index.d.ts.map → index.d.ts.map} +1 -1
  13. package/dist/index.js +83 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/index.mjs +55 -0
  16. package/dist/index.mjs.map +1 -0
  17. package/package.json +23 -14
  18. package/dist/cjs/hooks/index.js +0 -6
  19. package/dist/cjs/hooks/index.js.map +0 -1
  20. package/dist/cjs/hooks/useCustomEvent.js +0 -42
  21. package/dist/cjs/hooks/useCustomEvent.js.map +0 -1
  22. package/dist/cjs/hooks/useEvent.js +0 -17
  23. package/dist/cjs/hooks/useEvent.js.map +0 -1
  24. package/dist/cjs/index.js +0 -5
  25. package/dist/cjs/index.js.map +0 -1
  26. package/dist/docs.json +0 -982
  27. package/dist/esm/hooks/index.js.map +0 -1
  28. package/dist/esm/hooks/useCustomEvent.js +0 -37
  29. package/dist/esm/hooks/useCustomEvent.js.map +0 -1
  30. package/dist/esm/hooks/useEvent.js +0 -13
  31. package/dist/esm/hooks/useEvent.js.map +0 -1
  32. package/dist/esm/index.js +0 -2
  33. package/dist/esm/index.js.map +0 -1
  34. package/dist/types/hooks/index.d.ts.map +0 -1
  35. package/dist/types/hooks/useCustomEvent.d.ts.map +0 -1
  36. package/dist/types/hooks/useEvent.d.ts.map +0 -1
  37. /package/dist/{types/hooks/index.d.ts → hooks/index.d.mts} +0 -0
  38. /package/dist/{types/hooks/useCustomEvent.d.ts → hooks/useCustomEvent.d.mts} +0 -0
  39. /package/dist/{types/hooks/useEvent.d.ts → hooks/useEvent.d.mts} +0 -0
  40. /package/dist/{types/index.d.ts → index.d.mts} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA"}
@@ -1,37 +0,0 @@
1
- import { assertEx } from '@xylabs/assert';
2
- import { createRef, useEffect } from 'react';
3
- export const useCustomEvent = (type, listener, customRef) => {
4
- const ref = customRef ?? createRef();
5
- useEffect(() => {
6
- const element = ref?.current;
7
- const currentListener = listener;
8
- const handler = currentListener
9
- ? (event) => {
10
- const detail = assertEx(event.detail, 'Event missing detail');
11
- const stop = currentListener(detail);
12
- if (stop) {
13
- event.stopPropagation();
14
- }
15
- }
16
- : undefined;
17
- if (handler && element) {
18
- element?.addEventListener(type, handler);
19
- }
20
- return () => {
21
- if (handler && element) {
22
- element?.removeEventListener(type, handler);
23
- }
24
- };
25
- });
26
- const dispatch = (detail) => {
27
- const event = new CustomEvent(type, {
28
- bubbles: true,
29
- cancelable: true,
30
- composed: true,
31
- detail,
32
- });
33
- ref.current?.dispatchEvent(event);
34
- };
35
- return [ref, dispatch];
36
- };
37
- //# sourceMappingURL=useCustomEvent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCustomEvent.js","sourceRoot":"","sources":["../../../src/hooks/useCustomEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAa,SAAS,EAAE,MAAM,OAAO,CAAA;AAIvD,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAAY,EACZ,QAAuC,EACvC,SAA+B,EACsB,EAAE;IACvD,MAAM,GAAG,GAAG,SAAS,IAAI,SAAS,EAAY,CAAA;IAC9C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,OAAO,GAAG,GAAG,EAAE,OAAO,CAAA;QAC5B,MAAM,eAAe,GAAG,QAAQ,CAAA;QAChC,MAAM,OAAO,GAAG,eAAe;YAC7B,CAAC,CAAC,CAAC,KAAuC,EAAE,EAAE;gBAC1C,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAA;gBAC7D,MAAM,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,CAAA;gBACpC,IAAI,IAAI,EAAE;oBACR,KAAK,CAAC,eAAe,EAAE,CAAA;iBACxB;YACH,CAAC;YACH,CAAC,CAAC,SAAS,CAAA;QAEb,IAAI,OAAO,IAAI,OAAO,EAAE;YACtB,OAAO,EAAE,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;SACzC;QACD,OAAO,GAAG,EAAE;YACV,IAAI,OAAO,IAAI,OAAO,EAAE;gBACtB,OAAO,EAAE,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;aAC5C;QACH,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;IACF,MAAM,QAAQ,GAAiC,CAAC,MAAgB,EAAE,EAAE;QAClE,MAAM,KAAK,GAAG,IAAI,WAAW,CAAU,IAAI,EAAE;YAC3C,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,IAAI;YAChB,QAAQ,EAAE,IAAI;YACd,MAAM;SACP,CAAC,CAAA;QACF,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,CAAA;IACnC,CAAC,CAAA;IACD,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;AACxB,CAAC,CAAA"}
@@ -1,13 +0,0 @@
1
- import { useCustomEvent } from './useCustomEvent';
2
- export const useEvent = (listener, sharableRef) => {
3
- const [ref, customDispatch] = useCustomEvent('xyo', listener
4
- ? (detail) => {
5
- return listener(detail.noun, detail.verb, detail.data);
6
- }
7
- : undefined, sharableRef);
8
- const dispatch = (noun, verb, data) => {
9
- return customDispatch({ data, noun, verb });
10
- };
11
- return [ref, dispatch];
12
- };
13
- //# sourceMappingURL=useEvent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useEvent.js","sourceRoot":"","sources":["../../../src/hooks/useEvent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAajD,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,QAA6C,EAC7C,WAA0B,EAC0B,EAAE;IACtD,MAAM,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,cAAc,CAC1C,KAAK,EACL,QAAQ;QACN,CAAC,CAAC,CAAC,MAAkC,EAAE,EAAE;YACrC,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QACxD,CAAC;QACH,CAAC,CAAC,SAAS,EACb,WAAW,CACZ,CAAA;IAED,MAAM,QAAQ,GAAuC,CAAC,IAAW,EAAE,IAAW,EAAE,IAAY,EAAE,EAAE;QAC9F,OAAO,cAAc,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAC7C,CAAC,CAAA;IACD,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;AACxB,CAAC,CAAA"}
package/dist/esm/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './hooks';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCustomEvent.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCustomEvent.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,SAAS,EAAa,MAAM,OAAO,CAAA;AAEvD,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,CAAA;AAE5E,eAAO,MAAM,cAAc,0DACnB,MAAM,0JAqCb,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useEvent.d.ts","sourceRoot":"","sources":["../../../src/hooks/useEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAIjC,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,cAAc,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAA;AAChG,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,UAAU,CAAA;AAE5C,MAAM,WAAW,KAAK,CAAC,KAAK,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,EAAE,KAAK,GAAG,MAAM;IACzE,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,IAAI,EAAE,KAAK,CAAA;IACX,IAAI,EAAE,KAAK,CAAA;CACZ;AAED,MAAM,MAAM,aAAa,CAAC,KAAK,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,EAAE,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,KAAK,KAAK,OAAO,GAAG,IAAI,CAAA;AAE5I,eAAO,MAAM,QAAQ,wOAkBpB,CAAA"}
File without changes