@prosekit/preact 0.4.3 → 0.4.4

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.
@@ -24,9 +24,7 @@ function createComponent(tagName, displayName, propNames, eventNames) {
24
24
  const [el, setEl] = useState(null);
25
25
  const properties = {};
26
26
  const attributes = {};
27
- const eventHandlersRef = useRef(
28
- Object.fromEntries(eventNames.map((eventName) => [eventName, []]))
29
- );
27
+ const eventHandlersRef = useRef({});
30
28
  const eventHandlers = {};
31
29
  for (const [name, value] of Object.entries(props)) {
32
30
  if (value === void 0) {
@@ -67,33 +65,24 @@ function createComponent(tagName, displayName, propNames, eventNames) {
67
65
  }
68
66
  }, [el, ...propNames.map((name) => properties[name])]);
69
67
  useIsomorphicLayoutEffect(() => {
70
- for (const [eventName, handerArray] of Object.entries(
71
- eventHandlersRef.current
72
- )) {
73
- const handler = eventHandlers[eventName];
74
- handerArray.length = 0;
75
- if (handler) {
76
- handerArray.push(handler);
77
- }
78
- }
68
+ eventHandlersRef.current = eventHandlers;
79
69
  });
80
70
  useIsomorphicLayoutEffect(() => {
81
71
  if (!el) {
82
72
  return;
83
73
  }
84
- const handlers = {};
74
+ const fixedEventHandlers = {};
85
75
  for (const eventName of eventNames) {
86
- handlers[eventName] = (event) => {
87
- for (const handler of eventHandlersRef.current[eventName]) {
88
- handler(event);
89
- }
76
+ fixedEventHandlers[eventName] = (event) => {
77
+ var _a, _b;
78
+ (_b = (_a = eventHandlersRef.current)[eventName]) == null ? void 0 : _b.call(_a, event);
90
79
  };
91
80
  }
92
- for (const [name, handler] of Object.entries(handlers)) {
81
+ for (const [name, handler] of Object.entries(fixedEventHandlers)) {
93
82
  el.addEventListener(name, handler);
94
83
  }
95
84
  return () => {
96
- for (const [name, handler] of Object.entries(handlers)) {
85
+ for (const [name, handler] of Object.entries(fixedEventHandlers)) {
97
86
  el.removeEventListener(name, handler);
98
87
  }
99
88
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-YDJM74CW.js";
3
+ } from "./chunk-FEWLACYV.js";
4
4
  import "./chunk-V253IGNY.js";
5
5
 
6
6
  // src/components/autocomplete/autocomplete-empty.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-YDJM74CW.js";
3
+ } from "./chunk-FEWLACYV.js";
4
4
  import "./chunk-V253IGNY.js";
5
5
 
6
6
  // src/components/block-handle/block-handle-add.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-YDJM74CW.js";
3
+ } from "./chunk-FEWLACYV.js";
4
4
  import "./chunk-V253IGNY.js";
5
5
 
6
6
  // src/components/inline-popover/inline-popover.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-YDJM74CW.js";
3
+ } from "./chunk-FEWLACYV.js";
4
4
  import "./chunk-V253IGNY.js";
5
5
 
6
6
  // src/components/popover/popover-content.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-YDJM74CW.js";
3
+ } from "./chunk-FEWLACYV.js";
4
4
  import "./chunk-V253IGNY.js";
5
5
 
6
6
  // src/components/resizable/resizable-handle.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-YDJM74CW.js";
3
+ } from "./chunk-FEWLACYV.js";
4
4
  import "./chunk-V253IGNY.js";
5
5
 
6
6
  // src/components/table-handle/table-handle-column-root.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-YDJM74CW.js";
3
+ } from "./chunk-FEWLACYV.js";
4
4
  import "./chunk-V253IGNY.js";
5
5
 
6
6
  // src/components/tooltip/tooltip-content.gen.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/preact",
3
3
  "type": "module",
4
- "version": "0.4.3",
4
+ "version": "0.4.4",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -73,7 +73,7 @@
73
73
  "react-merge-refs": "^2.1.1",
74
74
  "@prosekit/core": "^0.7.12",
75
75
  "@prosekit/pm": "^0.1.8",
76
- "@prosekit/web": "^0.4.3"
76
+ "@prosekit/web": "^0.5.0"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "preact": ">= 10.11.0"