@sepveneto/free-dom 0.4.0-beta.0 → 0.4.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.
- package/dist/index.css +1 -2
- package/dist/index.d.ts +18 -0
- package/dist/index.js +23 -20
- package/dist/index.mjs +24 -22
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ../../../../../../../tmp/tmp-
|
|
1
|
+
/* ../../../../../../../tmp/tmp-1800-oTeH5e7LtwVq/core/src/style/index.css */
|
|
2
2
|
:root {
|
|
3
3
|
--free-dom-theme: #4089ef;
|
|
4
4
|
--free-dom-line: var(--free-dom-theme);
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
}
|
|
24
24
|
.free-dom__widget-wrapper {
|
|
25
25
|
display: inline-block;
|
|
26
|
-
box-sizing: border-box;
|
|
27
26
|
border: 1px dashed transparent;
|
|
28
27
|
transition: border-color 0.3s;
|
|
29
28
|
box-sizing: content-box;
|
package/dist/index.d.ts
CHANGED
|
@@ -47,6 +47,14 @@ declare const freeDom: vue_demi.DefineComponent<{
|
|
|
47
47
|
type: vue_demi.PropType<[number, number]>;
|
|
48
48
|
default: undefined;
|
|
49
49
|
};
|
|
50
|
+
onDragStart: {
|
|
51
|
+
type: FunctionConstructor;
|
|
52
|
+
default: undefined;
|
|
53
|
+
};
|
|
54
|
+
onDragEnd: {
|
|
55
|
+
type: FunctionConstructor;
|
|
56
|
+
default: undefined;
|
|
57
|
+
};
|
|
50
58
|
}, {
|
|
51
59
|
widgetRef: vue_demi.ShallowRef<any>;
|
|
52
60
|
canMove: vue_demi.ComputedRef<boolean>;
|
|
@@ -109,6 +117,14 @@ declare const freeDom: vue_demi.DefineComponent<{
|
|
|
109
117
|
type: vue_demi.PropType<[number, number]>;
|
|
110
118
|
default: undefined;
|
|
111
119
|
};
|
|
120
|
+
onDragStart: {
|
|
121
|
+
type: FunctionConstructor;
|
|
122
|
+
default: undefined;
|
|
123
|
+
};
|
|
124
|
+
onDragEnd: {
|
|
125
|
+
type: FunctionConstructor;
|
|
126
|
+
default: undefined;
|
|
127
|
+
};
|
|
112
128
|
}>> & {
|
|
113
129
|
"onUpdate:x"?: ((...args: any[]) => any) | undefined;
|
|
114
130
|
"onUpdate:y"?: ((...args: any[]) => any) | undefined;
|
|
@@ -129,6 +145,8 @@ declare const freeDom: vue_demi.DefineComponent<{
|
|
|
129
145
|
handler: "dot" | "mark";
|
|
130
146
|
diagonal: boolean;
|
|
131
147
|
grid: [number, number];
|
|
148
|
+
onDragStart: Function;
|
|
149
|
+
onDragEnd: Function;
|
|
132
150
|
}>;
|
|
133
151
|
declare const freeScene: vue_demi.DefineComponent<{
|
|
134
152
|
absolute: {
|
package/dist/index.js
CHANGED
|
@@ -189,6 +189,14 @@ var FreeDom = (0, import_vue_demi2.defineComponent)({
|
|
|
189
189
|
grid: {
|
|
190
190
|
type: Object,
|
|
191
191
|
default: void 0
|
|
192
|
+
},
|
|
193
|
+
onDragStart: {
|
|
194
|
+
type: Function,
|
|
195
|
+
default: void 0
|
|
196
|
+
},
|
|
197
|
+
onDragEnd: {
|
|
198
|
+
type: Function,
|
|
199
|
+
default: void 0
|
|
192
200
|
}
|
|
193
201
|
},
|
|
194
202
|
emits: ["update:x", "update:y", "update:width", "update:height", "select"],
|
|
@@ -275,6 +283,9 @@ var FreeDom = (0, import_vue_demi2.defineComponent)({
|
|
|
275
283
|
return;
|
|
276
284
|
isScale.value = true;
|
|
277
285
|
active.value = true;
|
|
286
|
+
const shouldUpdate = props.onDragStart?.();
|
|
287
|
+
if (shouldUpdate === false)
|
|
288
|
+
return;
|
|
278
289
|
const { clientX, clientY } = evt;
|
|
279
290
|
useResize(clientX, clientY, _rect, dot, diagonal.value, snapGrid.value, {
|
|
280
291
|
onMove() {
|
|
@@ -284,6 +295,7 @@ var FreeDom = (0, import_vue_demi2.defineComponent)({
|
|
|
284
295
|
trigger();
|
|
285
296
|
},
|
|
286
297
|
onUp() {
|
|
298
|
+
props.onDragEnd?.();
|
|
287
299
|
isScale.value = false;
|
|
288
300
|
EventBus.emit("moveup", uuid);
|
|
289
301
|
emitPos();
|
|
@@ -328,6 +340,9 @@ var FreeDom = (0, import_vue_demi2.defineComponent)({
|
|
|
328
340
|
return;
|
|
329
341
|
isMove.value = true;
|
|
330
342
|
active.value = true;
|
|
343
|
+
const shouldUpdate = props.onDragStart?.();
|
|
344
|
+
if (shouldUpdate === false)
|
|
345
|
+
return;
|
|
331
346
|
const pos = getStyle(_style.value);
|
|
332
347
|
const move = (mouseEvt) => {
|
|
333
348
|
const { clientX, clientY } = mouseEvt;
|
|
@@ -343,6 +358,7 @@ var FreeDom = (0, import_vue_demi2.defineComponent)({
|
|
|
343
358
|
trigger();
|
|
344
359
|
};
|
|
345
360
|
const up = () => {
|
|
361
|
+
props.onDragEnd?.();
|
|
346
362
|
isMove.value = false;
|
|
347
363
|
EventBus.emit("moveup", uuid);
|
|
348
364
|
document.removeEventListener("mousemove", move);
|
|
@@ -416,25 +432,10 @@ var FreeDom = (0, import_vue_demi2.defineComponent)({
|
|
|
416
432
|
onMousedown: (evt) => this.onMousedownDot(evt, dot)
|
|
417
433
|
});
|
|
418
434
|
}) : null;
|
|
419
|
-
const
|
|
420
|
-
if (!defaultSlots) {
|
|
421
|
-
console.error("[free-dom] must have a default slot");
|
|
422
|
-
return null;
|
|
423
|
-
}
|
|
424
|
-
if (defaultSlots.length > 1) {
|
|
425
|
-
console.error("[free-dom] must have only one default slot");
|
|
426
|
-
return null;
|
|
427
|
-
}
|
|
428
|
-
const defaultSlot = defaultSlots[0];
|
|
429
|
-
const node = (0, import_vue_demi2.cloneVNode)(defaultSlot);
|
|
430
|
-
if (Array.isArray(node.children)) {
|
|
431
|
-
node.children = [...node.children, ...dots];
|
|
432
|
-
} else {
|
|
433
|
-
console.error("[free-dom] generate resiable handles failed");
|
|
434
|
-
}
|
|
435
|
+
const defaultSlot = typeof this.$slots.default === "function" ? this.$slots.default() : this.$slots.default;
|
|
435
436
|
if (import_vue_demi2.isVue2) {
|
|
436
437
|
return (0, import_vue_demi2.h)(
|
|
437
|
-
|
|
438
|
+
"section",
|
|
438
439
|
{
|
|
439
440
|
class: [
|
|
440
441
|
"free-dom__widget-wrapper",
|
|
@@ -448,11 +449,12 @@ var FreeDom = (0, import_vue_demi2.defineComponent)({
|
|
|
448
449
|
on: {
|
|
449
450
|
mousedown: this.onMousedown
|
|
450
451
|
}
|
|
451
|
-
}
|
|
452
|
+
},
|
|
453
|
+
[dots, defaultSlot]
|
|
452
454
|
);
|
|
453
455
|
}
|
|
454
456
|
return (0, import_vue_demi2.h)(
|
|
455
|
-
|
|
457
|
+
"section",
|
|
456
458
|
{
|
|
457
459
|
ref: "widgetRef",
|
|
458
460
|
class: [
|
|
@@ -464,7 +466,8 @@ var FreeDom = (0, import_vue_demi2.defineComponent)({
|
|
|
464
466
|
],
|
|
465
467
|
style: this.wrapStyle,
|
|
466
468
|
onMousedown: this.onMousedown
|
|
467
|
-
}
|
|
469
|
+
},
|
|
470
|
+
[defaultSlot, dots]
|
|
468
471
|
);
|
|
469
472
|
}
|
|
470
473
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -17,8 +17,7 @@ import {
|
|
|
17
17
|
reactive,
|
|
18
18
|
isVue2,
|
|
19
19
|
shallowRef,
|
|
20
|
-
watchEffect
|
|
21
|
-
cloneVNode
|
|
20
|
+
watchEffect
|
|
22
21
|
} from "vue-demi";
|
|
23
22
|
|
|
24
23
|
// src/hooks/use-normalize-style.ts
|
|
@@ -177,6 +176,14 @@ var FreeDom = defineComponent({
|
|
|
177
176
|
grid: {
|
|
178
177
|
type: Object,
|
|
179
178
|
default: void 0
|
|
179
|
+
},
|
|
180
|
+
onDragStart: {
|
|
181
|
+
type: Function,
|
|
182
|
+
default: void 0
|
|
183
|
+
},
|
|
184
|
+
onDragEnd: {
|
|
185
|
+
type: Function,
|
|
186
|
+
default: void 0
|
|
180
187
|
}
|
|
181
188
|
},
|
|
182
189
|
emits: ["update:x", "update:y", "update:width", "update:height", "select"],
|
|
@@ -263,6 +270,9 @@ var FreeDom = defineComponent({
|
|
|
263
270
|
return;
|
|
264
271
|
isScale.value = true;
|
|
265
272
|
active.value = true;
|
|
273
|
+
const shouldUpdate = props.onDragStart?.();
|
|
274
|
+
if (shouldUpdate === false)
|
|
275
|
+
return;
|
|
266
276
|
const { clientX, clientY } = evt;
|
|
267
277
|
useResize(clientX, clientY, _rect, dot, diagonal.value, snapGrid.value, {
|
|
268
278
|
onMove() {
|
|
@@ -272,6 +282,7 @@ var FreeDom = defineComponent({
|
|
|
272
282
|
trigger();
|
|
273
283
|
},
|
|
274
284
|
onUp() {
|
|
285
|
+
props.onDragEnd?.();
|
|
275
286
|
isScale.value = false;
|
|
276
287
|
EventBus.emit("moveup", uuid);
|
|
277
288
|
emitPos();
|
|
@@ -316,6 +327,9 @@ var FreeDom = defineComponent({
|
|
|
316
327
|
return;
|
|
317
328
|
isMove.value = true;
|
|
318
329
|
active.value = true;
|
|
330
|
+
const shouldUpdate = props.onDragStart?.();
|
|
331
|
+
if (shouldUpdate === false)
|
|
332
|
+
return;
|
|
319
333
|
const pos = getStyle(_style.value);
|
|
320
334
|
const move = (mouseEvt) => {
|
|
321
335
|
const { clientX, clientY } = mouseEvt;
|
|
@@ -331,6 +345,7 @@ var FreeDom = defineComponent({
|
|
|
331
345
|
trigger();
|
|
332
346
|
};
|
|
333
347
|
const up = () => {
|
|
348
|
+
props.onDragEnd?.();
|
|
334
349
|
isMove.value = false;
|
|
335
350
|
EventBus.emit("moveup", uuid);
|
|
336
351
|
document.removeEventListener("mousemove", move);
|
|
@@ -404,25 +419,10 @@ var FreeDom = defineComponent({
|
|
|
404
419
|
onMousedown: (evt) => this.onMousedownDot(evt, dot)
|
|
405
420
|
});
|
|
406
421
|
}) : null;
|
|
407
|
-
const
|
|
408
|
-
if (!defaultSlots) {
|
|
409
|
-
console.error("[free-dom] must have a default slot");
|
|
410
|
-
return null;
|
|
411
|
-
}
|
|
412
|
-
if (defaultSlots.length > 1) {
|
|
413
|
-
console.error("[free-dom] must have only one default slot");
|
|
414
|
-
return null;
|
|
415
|
-
}
|
|
416
|
-
const defaultSlot = defaultSlots[0];
|
|
417
|
-
const node = cloneVNode(defaultSlot);
|
|
418
|
-
if (Array.isArray(node.children)) {
|
|
419
|
-
node.children = [...node.children, ...dots];
|
|
420
|
-
} else {
|
|
421
|
-
console.error("[free-dom] generate resiable handles failed");
|
|
422
|
-
}
|
|
422
|
+
const defaultSlot = typeof this.$slots.default === "function" ? this.$slots.default() : this.$slots.default;
|
|
423
423
|
if (isVue2) {
|
|
424
424
|
return h(
|
|
425
|
-
|
|
425
|
+
"section",
|
|
426
426
|
{
|
|
427
427
|
class: [
|
|
428
428
|
"free-dom__widget-wrapper",
|
|
@@ -436,11 +436,12 @@ var FreeDom = defineComponent({
|
|
|
436
436
|
on: {
|
|
437
437
|
mousedown: this.onMousedown
|
|
438
438
|
}
|
|
439
|
-
}
|
|
439
|
+
},
|
|
440
|
+
[dots, defaultSlot]
|
|
440
441
|
);
|
|
441
442
|
}
|
|
442
443
|
return h(
|
|
443
|
-
|
|
444
|
+
"section",
|
|
444
445
|
{
|
|
445
446
|
ref: "widgetRef",
|
|
446
447
|
class: [
|
|
@@ -452,7 +453,8 @@ var FreeDom = defineComponent({
|
|
|
452
453
|
],
|
|
453
454
|
style: this.wrapStyle,
|
|
454
455
|
onMousedown: this.onMousedown
|
|
455
|
-
}
|
|
456
|
+
},
|
|
457
|
+
[defaultSlot, dots]
|
|
456
458
|
);
|
|
457
459
|
}
|
|
458
460
|
});
|