@prosekit/web 0.1.9 → 0.2.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.
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  defineCustomElement
3
- } from "./chunk-LCDA7GFP.js";
3
+ } from "./chunk-Y2CJYXR5.js";
4
4
 
5
5
  // src/components/resizable/resizable-handle/element.gen.ts
6
- import { ElementMixin } from "@aria-ui/core";
6
+ import { ElementBuilder } from "@aria-ui/core";
7
7
 
8
8
  // src/components/resizable/resizable-handle/props.ts
9
9
  var defaultResizableHandleProps = {
@@ -12,9 +12,7 @@ var defaultResizableHandleProps = {
12
12
 
13
13
  // src/components/resizable/resizable-handle/state.ts
14
14
  import {
15
- assignProps,
16
15
  createSignal,
17
- mapSignals,
18
16
  useEffect
19
17
  } from "@aria-ui/core";
20
18
  import { getWindow } from "@zag-js/dom-query";
@@ -24,26 +22,22 @@ import { createContext } from "@aria-ui/core";
24
22
  var onResizeContext = createContext(
25
23
  "prosekit/resizable/onResize",
26
24
  null
27
- );
28
- var onResizeStartContext = createContext(
25
+ ), onResizeStartContext = createContext(
29
26
  "prosekit/resizable/onResizeStart",
30
27
  null
31
- );
32
- var onResizeEndContext = createContext(
28
+ ), onResizeEndContext = createContext(
33
29
  "prosekit/resizable/onResizeEnd",
34
30
  null
35
31
  );
36
32
 
37
33
  // src/utils/is-finite-positive-number.ts
38
34
  function isFinitePositiveNumber(value) {
39
- return typeof value === "number" && Number.isFinite(value) && value > 0;
35
+ return typeof value == "number" && Number.isFinite(value) && value > 0;
40
36
  }
41
37
 
42
38
  // src/components/resizable/resizable-handle/calc-resize.ts
43
39
  function calcResize(position, w, h, dx, dy, aspectRatio) {
44
- aspectRatio = aspectRatio ? aspectRatio : w / h;
45
- aspectRatio = isFinitePositiveNumber(aspectRatio) ? aspectRatio : 1;
46
- switch (position) {
40
+ switch (aspectRatio = aspectRatio || w / h, aspectRatio = isFinitePositiveNumber(aspectRatio) ? aspectRatio : 1, position) {
47
41
  case "bottom-right":
48
42
  return calcBottomRightResize(w, h, dx, dy, aspectRatio);
49
43
  case "bottom-left":
@@ -65,92 +59,38 @@ function calcResize(position, w, h, dx, dy, aspectRatio) {
65
59
  }
66
60
  }
67
61
  var calcBottomRightResize = (w, h, dx, dy, r) => {
68
- w += dx;
69
- h += dy;
70
- const sum = w + h;
71
- h = sum / (r + 1);
72
- w = sum - h;
73
- return [w, h];
74
- };
75
- var calcBottomLeftResize = (w, h, dx, dy, r) => {
76
- w -= dx;
77
- h += dy;
78
- const sum = w + h;
79
- h = sum / (r + 1);
80
- w = sum - h;
81
- return [w, h];
82
- };
83
- var calcTopRightResize = (w, h, dx, dy, r) => {
84
- w += dx;
85
- h -= dy;
86
- const sum = w + h;
87
- h = sum / (r + 1);
88
- w = sum - h;
89
- return [w, h];
90
- };
91
- var calcTopLeftResize = (w, h, dx, dy, r) => {
92
- w -= dx;
93
- h -= dy;
94
- const sum = w + h;
95
- h = sum / (r + 1);
96
- w = sum - h;
97
- return [w, h];
98
- };
99
- var calcTopResize = (w, h, dx, dy, r) => {
100
- h -= dy;
101
- w = h * r;
102
- return [w, h];
103
- };
104
- var calcRightResize = (w, h, dx, dy, r) => {
105
- w += dx;
106
- h = w / r;
107
- return [w, h];
108
- };
109
- var calcBottomResize = (w, h, dx, dy, r) => {
110
- h += dy;
111
- w = h * r;
112
- return [w, h];
113
- };
114
- var calcLeftResize = (w, h, dx, dy, r) => {
115
- w -= dx;
116
- h = w / r;
117
- return [w, h];
118
- };
62
+ w += dx, h += dy;
63
+ let sum = w + h;
64
+ return h = sum / (r + 1), w = sum - h, [w, h];
65
+ }, calcBottomLeftResize = (w, h, dx, dy, r) => {
66
+ w -= dx, h += dy;
67
+ let sum = w + h;
68
+ return h = sum / (r + 1), w = sum - h, [w, h];
69
+ }, calcTopRightResize = (w, h, dx, dy, r) => {
70
+ w += dx, h -= dy;
71
+ let sum = w + h;
72
+ return h = sum / (r + 1), w = sum - h, [w, h];
73
+ }, calcTopLeftResize = (w, h, dx, dy, r) => {
74
+ w -= dx, h -= dy;
75
+ let sum = w + h;
76
+ return h = sum / (r + 1), w = sum - h, [w, h];
77
+ }, calcTopResize = (w, h, dx, dy, r) => (h -= dy, w = h * r, [w, h]), calcRightResize = (w, h, dx, dy, r) => (w += dx, h = w / r, [w, h]), calcBottomResize = (w, h, dx, dy, r) => (h += dy, w = h * r, [w, h]), calcLeftResize = (w, h, dx, dy, r) => (w -= dx, h = w / r, [w, h]);
119
78
 
120
79
  // src/components/resizable/resizable-handle/state.ts
121
- function useResizableHandle(host, props) {
122
- const state = mapSignals(assignProps(defaultResizableHandleProps, props));
123
- const onResize = onResizeContext.consume(host);
124
- const onResizeStart = onResizeStartContext.consume(host);
125
- const onResizeEnd = onResizeEndContext.consume(host);
80
+ function useResizableHandle(host, state) {
81
+ let onResize = onResizeContext.consume(host), onResizeStart = onResizeStartContext.consume(host), onResizeEnd = onResizeEndContext.consume(host);
126
82
  useResizableHandleState(host, state, { onResize, onResizeStart, onResizeEnd });
127
- return state;
128
83
  }
129
84
  function useResizableHandleState(host, state, context) {
130
- let startX = 0;
131
- let startY = 0;
132
- let width = 0;
133
- let height = 0;
134
- let aspectRatio = 1;
135
- const pointerPressing = createSignal(false);
136
- const handlePointerDown = (event) => {
137
- var _a, _b;
138
- event.preventDefault();
139
- pointerPressing.value = true;
140
- startX = event.x;
141
- startY = event.y;
142
- const size = (_b = (_a = context.onResizeStart).value) == null ? void 0 : _b.call(_a);
143
- if (size) {
144
- ;
145
- [width, height, aspectRatio] = size;
146
- }
147
- };
148
- const handlePointerMove = (event) => {
149
- var _a, _b;
85
+ let startX = 0, startY = 0, width = 0, height = 0, aspectRatio = 1, pointerPressing = createSignal(!1), handlePointerDown = (event) => {
86
+ var _a;
87
+ event.preventDefault(), pointerPressing.set(!0), startX = event.x, startY = event.y;
88
+ let size = (_a = context.onResizeStart.get()) == null ? void 0 : _a();
89
+ size && ([width, height, aspectRatio] = size);
90
+ }, handlePointerMove = (event) => {
91
+ var _a;
150
92
  event.preventDefault();
151
- const dx = event.x - startX;
152
- const dy = event.y - startY;
153
- const [w, h] = calcResize(
93
+ let dx = event.x - startX, dy = event.y - startY, [w, h] = calcResize(
154
94
  state.position.peek(),
155
95
  width,
156
96
  height,
@@ -158,41 +98,30 @@ function useResizableHandleState(host, state, context) {
158
98
  dy,
159
99
  aspectRatio
160
100
  );
161
- (_b = (_a = context.onResize).value) == null ? void 0 : _b.call(_a, w, h);
162
- };
163
- const handlePointerUp = (event) => {
164
- var _a, _b;
165
- event.preventDefault();
166
- pointerPressing.value = false;
167
- (_b = (_a = context.onResizeEnd).value) == null ? void 0 : _b.call(_a);
101
+ (_a = context.onResize.get()) == null || _a(w, h);
102
+ }, handlePointerUp = (event) => {
103
+ var _a;
104
+ event.preventDefault(), pointerPressing.set(!1), (_a = context.onResizeEnd.get()) == null || _a();
168
105
  };
169
- useEffect(host, () => {
170
- host.addEventListener("pointerdown", handlePointerDown);
171
- return () => {
172
- host.removeEventListener("pointerdown", handlePointerDown);
173
- };
174
- });
175
- useEffect(host, () => {
176
- if (!pointerPressing.value) {
106
+ useEffect(host, () => (host.addEventListener("pointerdown", handlePointerDown), () => {
107
+ host.removeEventListener("pointerdown", handlePointerDown);
108
+ })), useEffect(host, () => {
109
+ if (!pointerPressing.get())
177
110
  return;
178
- }
179
- const win = getWindow(host);
180
- win.addEventListener("pointermove", handlePointerMove);
181
- win.addEventListener("pointerup", handlePointerUp);
182
- return () => {
183
- win.removeEventListener("pointermove", handlePointerMove);
184
- win.removeEventListener("pointerup", handlePointerUp);
111
+ let win = getWindow(host);
112
+ return win.addEventListener("pointermove", handlePointerMove), win.addEventListener("pointerup", handlePointerUp), () => {
113
+ win.removeEventListener("pointermove", handlePointerMove), win.removeEventListener("pointerup", handlePointerUp);
185
114
  };
186
115
  });
187
116
  }
188
117
 
189
118
  // src/components/resizable/resizable-handle/element.gen.ts
190
- var ResizableHandleElement = class extends ElementMixin(useResizableHandle, defaultResizableHandleProps) {
119
+ var ResizableHandleElement = class extends ElementBuilder(useResizableHandle, defaultResizableHandleProps) {
191
120
  };
192
121
  defineCustomElement("prosekit-resizable-handle", ResizableHandleElement);
193
122
 
194
123
  // src/components/resizable/resizable-root/element.gen.ts
195
- import { ElementMixin as ElementMixin2 } from "@aria-ui/core";
124
+ import { ElementBuilder as ElementBuilder2 } from "@aria-ui/core";
196
125
 
197
126
  // src/components/resizable/resizable-root/props.ts
198
127
  var defaultResizableRootProps = {
@@ -206,65 +135,37 @@ var defaultResizableRootProps = {
206
135
 
207
136
  // src/components/resizable/resizable-root/state.ts
208
137
  import {
209
- assignProps as assignProps2,
210
138
  createSignal as createSignal2,
211
- mapSignals as mapSignals2,
212
139
  useEffect as useEffect2
213
140
  } from "@aria-ui/core";
214
- function useResizableRoot(host, props) {
215
- const state = mapSignals2(assignProps2(defaultResizableRootProps, props));
216
- useResizableRootState(host, state);
217
- return state;
218
- }
219
- function useResizableRootState(host, state) {
220
- const onResizeStart = () => {
141
+ function useResizableRoot(host, state) {
142
+ let onResizeStart = () => {
221
143
  var _a, _b;
222
- const { width, height } = host.getBoundingClientRect();
223
- let aspectRatio = (_a = state.aspectRatio.peek()) != null ? _a : width / height;
224
- if (!isFinitePositiveNumber(aspectRatio)) {
225
- aspectRatio = 0;
226
- }
227
- (_b = state.onSizeChangeStart.peek()) == null ? void 0 : _b({ width, height });
228
- return [width, height, aspectRatio];
229
- };
230
- const onResize = (width, height) => {
144
+ let { width, height } = host.getBoundingClientRect(), aspectRatio = (_a = state.aspectRatio.peek()) != null ? _a : width / height;
145
+ return isFinitePositiveNumber(aspectRatio) || (aspectRatio = 0), (_b = state.onSizeChangeStart.peek()) == null || _b({ width, height }), [width, height, aspectRatio];
146
+ }, onResize = (width, height) => {
231
147
  var _a;
232
- (_a = state.onSizeChange.peek()) == null ? void 0 : _a({ width, height });
233
- state.width.value = width;
234
- state.height.value = height;
235
- };
236
- const onResizeEnd = () => {
148
+ (_a = state.onSizeChange.peek()) == null || _a({ width, height }), state.width.set(width), state.height.set(height);
149
+ }, onResizeEnd = () => {
237
150
  var _a;
238
- const { width, height } = host.getBoundingClientRect();
239
- (_a = state.onSizeChangeEnd.peek()) == null ? void 0 : _a({ width, height });
151
+ let { width, height } = host.getBoundingClientRect();
152
+ (_a = state.onSizeChangeEnd.peek()) == null || _a({ width, height });
240
153
  };
241
- onResizeStartContext.provide(host, createSignal2(onResizeStart));
242
- onResizeContext.provide(host, createSignal2(onResize));
243
- onResizeEndContext.provide(host, createSignal2(onResizeEnd));
244
- useEffect2(host, () => {
154
+ onResizeStartContext.provide(host, createSignal2(onResizeStart)), onResizeContext.provide(host, createSignal2(onResize)), onResizeEndContext.provide(host, createSignal2(onResizeEnd)), useEffect2(host, () => {
245
155
  updateResizableRootStyles(
246
156
  host,
247
- state.width.value,
248
- state.height.value,
249
- state.aspectRatio.value
157
+ state.width.get(),
158
+ state.height.get(),
159
+ state.aspectRatio.get()
250
160
  );
251
161
  });
252
162
  }
253
163
  function updateResizableRootStyles(host, width, height, aspectRatio) {
254
- host.style.width = isFinitePositiveNumber(width) ? `${width}px` : "";
255
- host.style.height = isFinitePositiveNumber(height) ? `${height}px` : "";
256
- if (isFinitePositiveNumber(aspectRatio)) {
257
- host.style.aspectRatio = `${aspectRatio}`;
258
- if (width && width > 0 && aspectRatio >= 1) {
259
- host.style.height = "auto";
260
- } else if (height && height > 0 && aspectRatio <= 1) {
261
- host.style.width = "auto";
262
- }
263
- }
164
+ host.style.width = isFinitePositiveNumber(width) ? `${width}px` : "", host.style.height = isFinitePositiveNumber(height) ? `${height}px` : "", isFinitePositiveNumber(aspectRatio) && (host.style.aspectRatio = `${aspectRatio}`, width && width > 0 && aspectRatio >= 1 ? host.style.height = "auto" : height && height > 0 && aspectRatio <= 1 && (host.style.width = "auto"));
264
165
  }
265
166
 
266
167
  // src/components/resizable/resizable-root/element.gen.ts
267
- var ResizableRootElement = class extends ElementMixin2(useResizableRoot, defaultResizableRootProps) {
168
+ var ResizableRootElement = class extends ElementBuilder2(useResizableRoot, defaultResizableRootProps) {
268
169
  };
269
170
  defineCustomElement("prosekit-resizable-root", ResizableRootElement);
270
171
  export {
@@ -1,37 +1,33 @@
1
1
  import {
2
2
  defineCustomElement
3
- } from "./chunk-LCDA7GFP.js";
3
+ } from "./chunk-Y2CJYXR5.js";
4
4
 
5
5
  // src/components/tooltip/tooltip-content/element.gen.ts
6
- import { ElementMixin } from "@aria-ui/core";
6
+ import { ElementBuilder } from "@aria-ui/core";
7
7
 
8
8
  // src/components/tooltip/tooltip-content/props.ts
9
9
  import { defaultTooltipContentProps as defaultProps } from "@aria-ui/tooltip";
10
10
  var defaultTooltipContentProps = {
11
11
  ...defaultProps,
12
- shift: true,
13
- flip: true,
12
+ shift: !0,
13
+ flip: !0,
14
14
  offset: 6,
15
15
  overflowPadding: 4,
16
16
  // Don't need boundary when hoist is true.
17
- hoist: true,
17
+ hoist: !0,
18
18
  boundary: []
19
19
  };
20
20
 
21
21
  // src/components/tooltip/tooltip-content/state.ts
22
- import { assignProps } from "@aria-ui/core";
23
- import { useTooltipContent as useElement } from "@aria-ui/tooltip";
24
- function useTooltipContent(element, props) {
25
- return useElement(element, assignProps(defaultTooltipContentProps, props));
26
- }
22
+ import { useTooltipContent } from "@aria-ui/tooltip";
27
23
 
28
24
  // src/components/tooltip/tooltip-content/element.gen.ts
29
- var TooltipContentElement = class extends ElementMixin(useTooltipContent, defaultTooltipContentProps) {
25
+ var TooltipContentElement = class extends ElementBuilder(useTooltipContent, defaultTooltipContentProps) {
30
26
  };
31
27
  defineCustomElement("prosekit-tooltip-content", TooltipContentElement);
32
28
 
33
29
  // src/components/tooltip/tooltip-root/element.gen.ts
34
- import { ElementMixin as ElementMixin2 } from "@aria-ui/core";
30
+ import { ElementBuilder as ElementBuilder2 } from "@aria-ui/core";
35
31
 
36
32
  // src/components/tooltip/tooltip-root/props.ts
37
33
  import { defaultTooltipRootProps } from "@aria-ui/tooltip";
@@ -40,12 +36,12 @@ import { defaultTooltipRootProps } from "@aria-ui/tooltip";
40
36
  import { useTooltipRoot } from "@aria-ui/tooltip";
41
37
 
42
38
  // src/components/tooltip/tooltip-root/element.gen.ts
43
- var TooltipRootElement = class extends ElementMixin2(useTooltipRoot, defaultTooltipRootProps) {
39
+ var TooltipRootElement = class extends ElementBuilder2(useTooltipRoot, defaultTooltipRootProps) {
44
40
  };
45
41
  defineCustomElement("prosekit-tooltip-root", TooltipRootElement);
46
42
 
47
43
  // src/components/tooltip/tooltip-trigger/element.gen.ts
48
- import { ElementMixin as ElementMixin3 } from "@aria-ui/core";
44
+ import { ElementBuilder as ElementBuilder3 } from "@aria-ui/core";
49
45
 
50
46
  // src/components/tooltip/tooltip-trigger/props.ts
51
47
  import { defaultTooltipTriggerProps } from "@aria-ui/tooltip";
@@ -54,7 +50,7 @@ import { defaultTooltipTriggerProps } from "@aria-ui/tooltip";
54
50
  import { useTooltipTrigger } from "@aria-ui/tooltip";
55
51
 
56
52
  // src/components/tooltip/tooltip-trigger/element.gen.ts
57
- var TooltipTriggerElement = class extends ElementMixin3(useTooltipTrigger, defaultTooltipTriggerProps) {
53
+ var TooltipTriggerElement = class extends ElementBuilder3(useTooltipTrigger, defaultTooltipTriggerProps) {
58
54
  };
59
55
  defineCustomElement("prosekit-tooltip-trigger", TooltipTriggerElement);
60
56
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/web",
3
3
  "type": "module",
4
- "version": "0.1.9",
4
+ "version": "0.2.0",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -66,21 +66,21 @@
66
66
  ],
67
67
  "dependencies": {
68
68
  "@aria-ui/collection": "^0.0.3",
69
- "@aria-ui/core": "^0.0.14",
70
- "@aria-ui/listbox": "^0.0.13",
71
- "@aria-ui/overlay": "^0.0.15",
72
- "@aria-ui/popover": "^0.0.14",
73
- "@aria-ui/presence": "^0.0.9",
74
- "@aria-ui/tooltip": "^0.0.16",
69
+ "@aria-ui/core": "^0.0.16",
70
+ "@aria-ui/listbox": "^0.0.15",
71
+ "@aria-ui/overlay": "^0.0.17",
72
+ "@aria-ui/popover": "^0.0.17",
73
+ "@aria-ui/presence": "^0.0.11",
74
+ "@aria-ui/tooltip": "^0.0.19",
75
75
  "@floating-ui/dom": "^1.6.5",
76
- "@prosekit/core": "^0.5.4",
77
- "@prosekit/extensions": "^0.5.2",
78
- "@prosekit/pm": "^0.1.4",
79
- "@zag-js/dom-query": "^0.51.2"
76
+ "@zag-js/dom-query": "^0.58.2",
77
+ "@prosekit/core": "^0.6.0",
78
+ "@prosekit/pm": "^0.1.5",
79
+ "@prosekit/extensions": "^0.6.0"
80
80
  },
81
81
  "devDependencies": {
82
- "tsup": "^8.0.2",
83
- "typescript": "^5.4.5",
82
+ "tsup": "^8.1.0",
83
+ "typescript": "^5.5.2",
84
84
  "vitest": "^1.6.0",
85
85
  "@prosekit/dev": "0.0.0"
86
86
  },