@prosekit/web 0.3.19 → 0.4.1

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,16 +1,7 @@
1
- import {
2
- defineCustomElement
3
- } from "./chunk-LCDA7GFP.js";
4
-
5
1
  // src/components/resizable/resizable-handle/element.gen.ts
6
- import { ElementBuilder } from "@aria-ui/core";
7
-
8
- // src/components/resizable/resizable-handle/props.ts
9
- var defaultResizableHandleProps = {
10
- position: "bottom-right"
11
- };
2
+ import { defineCustomElement, registerCustomElement } from "@aria-ui/core";
12
3
 
13
- // src/components/resizable/resizable-handle/state.ts
4
+ // src/components/resizable/resizable-handle/setup.ts
14
5
  import {
15
6
  createSignal,
16
7
  useEffect
@@ -115,8 +106,8 @@ var calcLeftResize = (w, h, dx, dy, r) => {
115
106
  return [w, h];
116
107
  };
117
108
 
118
- // src/components/resizable/resizable-handle/state.ts
119
- function useResizableHandle(host, state) {
109
+ // src/components/resizable/resizable-handle/setup.ts
110
+ function useResizableHandle(host, { state }) {
120
111
  const onResize = onResizeContext.consume(host);
121
112
  const onResizeStart = onResizeStartContext.consume(host);
122
113
  const onResizeEnd = onResizeEndContext.consume(host);
@@ -182,50 +173,51 @@ function useResizableHandleState(host, state, context) {
182
173
  });
183
174
  }
184
175
 
176
+ // src/components/resizable/resizable-handle/types.ts
177
+ var resizableHandleProps = {
178
+ position: { default: "bottom-right" }
179
+ };
180
+ var resizableHandleEvents = {};
181
+
185
182
  // src/components/resizable/resizable-handle/element.gen.ts
186
- var ResizableHandleElement = class extends ElementBuilder(useResizableHandle, defaultResizableHandleProps) {
183
+ var ResizableHandleElement = class extends defineCustomElement({
184
+ props: resizableHandleProps,
185
+ events: resizableHandleEvents,
186
+ setup: useResizableHandle
187
+ }) {
187
188
  };
188
- defineCustomElement("prosekit-resizable-handle", ResizableHandleElement);
189
+ registerCustomElement("prosekit-resizable-handle", ResizableHandleElement);
189
190
 
190
191
  // src/components/resizable/resizable-root/element.gen.ts
191
- import { ElementBuilder as ElementBuilder2 } from "@aria-ui/core";
192
-
193
- // src/components/resizable/resizable-root/props.ts
194
- var defaultResizableRootProps = {
195
- width: null,
196
- height: null,
197
- aspectRatio: null,
198
- onSizeChangeStart: null,
199
- onSizeChange: null,
200
- onSizeChangeEnd: null
201
- };
192
+ import { defineCustomElement as defineCustomElement2, registerCustomElement as registerCustomElement2 } from "@aria-ui/core";
202
193
 
203
- // src/components/resizable/resizable-root/state.ts
194
+ // src/components/resizable/resizable-root/setup.ts
204
195
  import {
205
196
  createSignal as createSignal2,
197
+ useAttribute,
206
198
  useEffect as useEffect2
207
199
  } from "@aria-ui/core";
208
- function useResizableRoot(host, state) {
200
+ function useResizableRoot(host, { state, emit }) {
201
+ const resizing = createSignal2(false);
209
202
  const onResizeStart = () => {
210
- var _a, _b;
203
+ var _a;
211
204
  const { width, height } = host.getBoundingClientRect();
212
205
  let aspectRatio = (_a = state.aspectRatio.peek()) != null ? _a : width / height;
213
206
  if (!isFinitePositiveNumber(aspectRatio)) {
214
207
  aspectRatio = 0;
215
208
  }
216
- (_b = state.onSizeChangeStart.peek()) == null ? void 0 : _b({ width, height });
209
+ emit("resizeStart", { width, height });
210
+ resizing.set(true);
217
211
  return [width, height, aspectRatio];
218
212
  };
219
213
  const onResize = (width, height) => {
220
- var _a;
221
- (_a = state.onSizeChange.peek()) == null ? void 0 : _a({ width, height });
222
214
  state.width.set(width);
223
215
  state.height.set(height);
224
216
  };
225
217
  const onResizeEnd = () => {
226
- var _a;
227
218
  const { width, height } = host.getBoundingClientRect();
228
- (_a = state.onSizeChangeEnd.peek()) == null ? void 0 : _a({ width, height });
219
+ emit("resizeEnd", { width, height });
220
+ resizing.set(false);
229
221
  };
230
222
  onResizeStartContext.provide(host, createSignal2(onResizeStart));
231
223
  onResizeContext.provide(host, createSignal2(onResize));
@@ -233,11 +225,12 @@ function useResizableRoot(host, state) {
233
225
  useEffect2(host, () => {
234
226
  updateResizableRootStyles(
235
227
  host,
236
- state.width.get(),
237
- state.height.get(),
228
+ Math.max(state.width.get() || 0, 1),
229
+ Math.max(state.height.get() || 0, 1),
238
230
  state.aspectRatio.get()
239
231
  );
240
232
  });
233
+ useAttribute(host, "data-resizing", () => resizing.get() ? "" : void 0);
241
234
  }
242
235
  function updateResizableRootStyles(host, width, height, aspectRatio) {
243
236
  host.style.width = isFinitePositiveNumber(width) ? `${width}px` : "";
@@ -247,18 +240,35 @@ function updateResizableRootStyles(host, width, height, aspectRatio) {
247
240
  if (width && width > 0 && aspectRatio >= 1) {
248
241
  host.style.height = "auto";
249
242
  } else if (height && height > 0 && aspectRatio <= 1) {
250
- host.style.width = "auto";
243
+ host.style.width = "min-content";
251
244
  }
252
245
  }
253
246
  }
254
247
 
248
+ // src/components/resizable/resizable-root/types.ts
249
+ var resizableRootProps = {
250
+ width: { default: null },
251
+ height: { default: null },
252
+ aspectRatio: { default: null }
253
+ };
254
+ var resizableRootEvents = {
255
+ resizeStart: {},
256
+ resizeEnd: {}
257
+ };
258
+
255
259
  // src/components/resizable/resizable-root/element.gen.ts
256
- var ResizableRootElement = class extends ElementBuilder2(useResizableRoot, defaultResizableRootProps) {
260
+ var ResizableRootElement = class extends defineCustomElement2({
261
+ props: resizableRootProps,
262
+ events: resizableRootEvents,
263
+ setup: useResizableRoot
264
+ }) {
257
265
  };
258
- defineCustomElement("prosekit-resizable-root", ResizableRootElement);
266
+ registerCustomElement2("prosekit-resizable-root", ResizableRootElement);
259
267
  export {
260
268
  ResizableHandleElement,
261
269
  ResizableRootElement,
262
- defaultResizableHandleProps,
263
- defaultResizableRootProps
270
+ resizableHandleEvents,
271
+ resizableHandleProps,
272
+ resizableRootEvents,
273
+ resizableRootProps
264
274
  };
@@ -1,21 +1,35 @@
1
1
  export { TableHandleColumnRootElement } from './_tsup-dts-rollup';
2
- export { defaultTableHandleColumnRootProps } from './_tsup-dts-rollup';
2
+ export { tableHandleColumnRootEvents } from './_tsup-dts-rollup';
3
+ export { tableHandleColumnRootProps } from './_tsup-dts-rollup';
4
+ export { TableHandleColumnRootEvents } from './_tsup-dts-rollup';
3
5
  export { TableHandleColumnRootProps } from './_tsup-dts-rollup';
4
6
  export { TableHandleColumnTriggerElement } from './_tsup-dts-rollup';
5
- export { defaultTableHandleColumnTriggerProps } from './_tsup-dts-rollup';
7
+ export { tableHandleColumnTriggerEvents } from './_tsup-dts-rollup';
8
+ export { tableHandleColumnTriggerProps } from './_tsup-dts-rollup';
9
+ export { TableHandleColumnTriggerEvents } from './_tsup-dts-rollup';
6
10
  export { TableHandleColumnTriggerProps } from './_tsup-dts-rollup';
7
11
  export { TableHandlePopoverContentElement } from './_tsup-dts-rollup';
8
- export { defaultTableHandlePopoverContentProps } from './_tsup-dts-rollup';
12
+ export { tableHandlePopoverContentEvents } from './_tsup-dts-rollup';
13
+ export { tableHandlePopoverContentProps } from './_tsup-dts-rollup';
14
+ export { TableHandlePopoverContentEvents } from './_tsup-dts-rollup';
9
15
  export { TableHandlePopoverContentProps } from './_tsup-dts-rollup';
10
16
  export { TableHandlePopoverItemElement } from './_tsup-dts-rollup';
11
- export { defaultTableHandlePopoverItemProps } from './_tsup-dts-rollup';
17
+ export { tableHandlePopoverItemEvents } from './_tsup-dts-rollup';
18
+ export { tableHandlePopoverItemProps } from './_tsup-dts-rollup';
19
+ export { TableHandlePopoverItemEvents } from './_tsup-dts-rollup';
12
20
  export { TableHandlePopoverItemProps } from './_tsup-dts-rollup';
13
21
  export { TableHandleRootElement } from './_tsup-dts-rollup';
14
- export { defaultTableHandleRootProps } from './_tsup-dts-rollup';
22
+ export { tableHandleRootEvents } from './_tsup-dts-rollup';
23
+ export { tableHandleRootProps } from './_tsup-dts-rollup';
24
+ export { TableHandleRootEvents } from './_tsup-dts-rollup';
15
25
  export { TableHandleRootProps } from './_tsup-dts-rollup';
16
26
  export { TableHandleRowRootElement } from './_tsup-dts-rollup';
17
- export { defaultTableHandleRowRootProps } from './_tsup-dts-rollup';
27
+ export { tableHandleRowRootEvents } from './_tsup-dts-rollup';
28
+ export { tableHandleRowRootProps } from './_tsup-dts-rollup';
29
+ export { TableHandleRowRootEvents } from './_tsup-dts-rollup';
18
30
  export { TableHandleRowRootProps } from './_tsup-dts-rollup';
19
31
  export { TableHandleRowTriggerElement } from './_tsup-dts-rollup';
20
- export { defaultTableHandleRowTriggerProps } from './_tsup-dts-rollup';
32
+ export { tableHandleRowTriggerEvents } from './_tsup-dts-rollup';
33
+ export { tableHandleRowTriggerProps } from './_tsup-dts-rollup';
34
+ export { TableHandleRowTriggerEvents } from './_tsup-dts-rollup';
21
35
  export { TableHandleRowTriggerProps } from './_tsup-dts-rollup';