@sepveneto/free-dom 0.4.2 → 0.4.3
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 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +21 -35
- package/dist/index.mjs +24 -40
- package/package.json +1 -1
package/dist/index.css
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -3,19 +3,19 @@ import * as vue_demi from 'vue-demi';
|
|
|
3
3
|
declare const freeDom: vue_demi.DefineComponent<{
|
|
4
4
|
x: {
|
|
5
5
|
type: NumberConstructor;
|
|
6
|
-
default:
|
|
6
|
+
default: number;
|
|
7
7
|
};
|
|
8
8
|
y: {
|
|
9
9
|
type: NumberConstructor;
|
|
10
|
-
default:
|
|
10
|
+
default: number;
|
|
11
11
|
};
|
|
12
12
|
width: {
|
|
13
13
|
type: NumberConstructor;
|
|
14
|
-
default:
|
|
14
|
+
default: number;
|
|
15
15
|
};
|
|
16
16
|
height: {
|
|
17
17
|
type: NumberConstructor;
|
|
18
|
-
default:
|
|
18
|
+
default: number;
|
|
19
19
|
};
|
|
20
20
|
absolute: {
|
|
21
21
|
type: BooleanConstructor;
|
|
@@ -73,19 +73,19 @@ declare const freeDom: vue_demi.DefineComponent<{
|
|
|
73
73
|
}, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, ("update:x" | "update:y" | "update:width" | "update:height" | "select")[], "update:x" | "update:y" | "update:width" | "update:height" | "select", vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
|
|
74
74
|
x: {
|
|
75
75
|
type: NumberConstructor;
|
|
76
|
-
default:
|
|
76
|
+
default: number;
|
|
77
77
|
};
|
|
78
78
|
y: {
|
|
79
79
|
type: NumberConstructor;
|
|
80
|
-
default:
|
|
80
|
+
default: number;
|
|
81
81
|
};
|
|
82
82
|
width: {
|
|
83
83
|
type: NumberConstructor;
|
|
84
|
-
default:
|
|
84
|
+
default: number;
|
|
85
85
|
};
|
|
86
86
|
height: {
|
|
87
87
|
type: NumberConstructor;
|
|
88
|
-
default:
|
|
88
|
+
default: number;
|
|
89
89
|
};
|
|
90
90
|
absolute: {
|
|
91
91
|
type: BooleanConstructor;
|
package/dist/index.js
CHANGED
|
@@ -146,19 +146,19 @@ var FreeDom = (0, import_vue_demi2.defineComponent)({
|
|
|
146
146
|
props: {
|
|
147
147
|
x: {
|
|
148
148
|
type: Number,
|
|
149
|
-
default:
|
|
149
|
+
default: 0
|
|
150
150
|
},
|
|
151
151
|
y: {
|
|
152
152
|
type: Number,
|
|
153
|
-
default:
|
|
153
|
+
default: 0
|
|
154
154
|
},
|
|
155
155
|
width: {
|
|
156
156
|
type: Number,
|
|
157
|
-
default:
|
|
157
|
+
default: 0
|
|
158
158
|
},
|
|
159
159
|
height: {
|
|
160
160
|
type: Number,
|
|
161
|
-
default:
|
|
161
|
+
default: 0
|
|
162
162
|
},
|
|
163
163
|
absolute: {
|
|
164
164
|
type: Boolean,
|
|
@@ -202,7 +202,7 @@ var FreeDom = (0, import_vue_demi2.defineComponent)({
|
|
|
202
202
|
emits: ["update:x", "update:y", "update:width", "update:height", "select"],
|
|
203
203
|
setup(props, { emit }) {
|
|
204
204
|
const active = (0, import_vue_demi2.ref)(false);
|
|
205
|
-
const SceneContext = (0, import_vue_demi2.inject)(SceneToken);
|
|
205
|
+
const SceneContext = (0, import_vue_demi2.inject)(SceneToken, void 0);
|
|
206
206
|
const _preview = (0, import_vue_demi2.computed)(() => SceneContext?.preview || props.preview);
|
|
207
207
|
const canScale = (0, import_vue_demi2.computed)(() => !_preview.value && (SceneContext?.scale || props.scale));
|
|
208
208
|
const canMove = (0, import_vue_demi2.computed)(() => !_preview.value && (SceneContext?.move || props.move));
|
|
@@ -222,7 +222,6 @@ var FreeDom = (0, import_vue_demi2.defineComponent)({
|
|
|
222
222
|
width: 0,
|
|
223
223
|
height: 0
|
|
224
224
|
});
|
|
225
|
-
const triggerThrottle = (0, import_core.useThrottleFn)(trigger);
|
|
226
225
|
const context = {
|
|
227
226
|
_rect,
|
|
228
227
|
trigger
|
|
@@ -233,40 +232,27 @@ var FreeDom = (0, import_vue_demi2.defineComponent)({
|
|
|
233
232
|
function parseNum(val) {
|
|
234
233
|
return typeof val === "number" ? val : parseFloat(val);
|
|
235
234
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
const unwatchWidth = (0, import_vue_demi2.watch)(rectBound.width, (width) => {
|
|
253
|
-
if (width) {
|
|
254
|
-
_rect.width = width;
|
|
255
|
-
unwatchWidth();
|
|
256
|
-
}
|
|
257
|
-
});
|
|
235
|
+
(0, import_vue_demi2.watch)(
|
|
236
|
+
[
|
|
237
|
+
() => props.width,
|
|
238
|
+
() => props.height,
|
|
239
|
+
() => props.x,
|
|
240
|
+
() => props.y
|
|
241
|
+
],
|
|
242
|
+
() => {
|
|
243
|
+
_rect.width = props.width;
|
|
244
|
+
_rect.height = props.height;
|
|
245
|
+
_rect.x = props.x;
|
|
246
|
+
_rect.y = props.y;
|
|
247
|
+
trigger();
|
|
248
|
+
},
|
|
249
|
+
{ immediate: true }
|
|
250
|
+
);
|
|
258
251
|
(0, import_vue_demi2.onMounted)(async () => {
|
|
259
252
|
SceneContext?.register(uuid, context);
|
|
260
|
-
await (0, import_vue_demi2.nextTick)();
|
|
261
253
|
const rect = widgetRef.value.getBoundingClientRect();
|
|
262
254
|
_rect.width = _rect.width || rect.width;
|
|
263
|
-
if (_rect.width) {
|
|
264
|
-
unwatchWidth();
|
|
265
|
-
}
|
|
266
255
|
_rect.height = _rect.height || rect.height;
|
|
267
|
-
if (_rect.height) {
|
|
268
|
-
unwatchHeight();
|
|
269
|
-
}
|
|
270
256
|
_rect.x = _rect.x || 0;
|
|
271
257
|
_rect.y = _rect.y || 0;
|
|
272
258
|
trigger();
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,6 @@ var __publicField = (obj, key, value) => {
|
|
|
7
7
|
|
|
8
8
|
// src/components/freeDom.ts
|
|
9
9
|
import {
|
|
10
|
-
nextTick,
|
|
11
10
|
onMounted,
|
|
12
11
|
defineComponent,
|
|
13
12
|
h,
|
|
@@ -17,7 +16,6 @@ import {
|
|
|
17
16
|
reactive,
|
|
18
17
|
isVue2,
|
|
19
18
|
shallowRef,
|
|
20
|
-
watchEffect,
|
|
21
19
|
watch as watch2
|
|
22
20
|
} from "vue-demi";
|
|
23
21
|
|
|
@@ -126,7 +124,7 @@ function useResize(startX, startY, rect, dot, diagonal, snapGrid, callbacks) {
|
|
|
126
124
|
}
|
|
127
125
|
|
|
128
126
|
// src/components/freeDom.ts
|
|
129
|
-
import { onClickOutside
|
|
127
|
+
import { onClickOutside } from "@vueuse/core";
|
|
130
128
|
import { v4 as uuidv4 } from "uuid";
|
|
131
129
|
var Dots = ["t", "r", "l", "b", "lt", "lb", "rt", "rb"];
|
|
132
130
|
var FreeDom = defineComponent({
|
|
@@ -134,19 +132,19 @@ var FreeDom = defineComponent({
|
|
|
134
132
|
props: {
|
|
135
133
|
x: {
|
|
136
134
|
type: Number,
|
|
137
|
-
default:
|
|
135
|
+
default: 0
|
|
138
136
|
},
|
|
139
137
|
y: {
|
|
140
138
|
type: Number,
|
|
141
|
-
default:
|
|
139
|
+
default: 0
|
|
142
140
|
},
|
|
143
141
|
width: {
|
|
144
142
|
type: Number,
|
|
145
|
-
default:
|
|
143
|
+
default: 0
|
|
146
144
|
},
|
|
147
145
|
height: {
|
|
148
146
|
type: Number,
|
|
149
|
-
default:
|
|
147
|
+
default: 0
|
|
150
148
|
},
|
|
151
149
|
absolute: {
|
|
152
150
|
type: Boolean,
|
|
@@ -190,7 +188,7 @@ var FreeDom = defineComponent({
|
|
|
190
188
|
emits: ["update:x", "update:y", "update:width", "update:height", "select"],
|
|
191
189
|
setup(props, { emit }) {
|
|
192
190
|
const active = ref2(false);
|
|
193
|
-
const SceneContext = inject(SceneToken);
|
|
191
|
+
const SceneContext = inject(SceneToken, void 0);
|
|
194
192
|
const _preview = computed(() => SceneContext?.preview || props.preview);
|
|
195
193
|
const canScale = computed(() => !_preview.value && (SceneContext?.scale || props.scale));
|
|
196
194
|
const canMove = computed(() => !_preview.value && (SceneContext?.move || props.move));
|
|
@@ -210,7 +208,6 @@ var FreeDom = defineComponent({
|
|
|
210
208
|
width: 0,
|
|
211
209
|
height: 0
|
|
212
210
|
});
|
|
213
|
-
const triggerThrottle = useThrottleFn(trigger);
|
|
214
211
|
const context = {
|
|
215
212
|
_rect,
|
|
216
213
|
trigger
|
|
@@ -221,40 +218,27 @@ var FreeDom = defineComponent({
|
|
|
221
218
|
function parseNum(val) {
|
|
222
219
|
return typeof val === "number" ? val : parseFloat(val);
|
|
223
220
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const unwatchWidth = watch2(rectBound.width, (width) => {
|
|
241
|
-
if (width) {
|
|
242
|
-
_rect.width = width;
|
|
243
|
-
unwatchWidth();
|
|
244
|
-
}
|
|
245
|
-
});
|
|
221
|
+
watch2(
|
|
222
|
+
[
|
|
223
|
+
() => props.width,
|
|
224
|
+
() => props.height,
|
|
225
|
+
() => props.x,
|
|
226
|
+
() => props.y
|
|
227
|
+
],
|
|
228
|
+
() => {
|
|
229
|
+
_rect.width = props.width;
|
|
230
|
+
_rect.height = props.height;
|
|
231
|
+
_rect.x = props.x;
|
|
232
|
+
_rect.y = props.y;
|
|
233
|
+
trigger();
|
|
234
|
+
},
|
|
235
|
+
{ immediate: true }
|
|
236
|
+
);
|
|
246
237
|
onMounted(async () => {
|
|
247
238
|
SceneContext?.register(uuid, context);
|
|
248
|
-
await nextTick();
|
|
249
239
|
const rect = widgetRef.value.getBoundingClientRect();
|
|
250
240
|
_rect.width = _rect.width || rect.width;
|
|
251
|
-
if (_rect.width) {
|
|
252
|
-
unwatchWidth();
|
|
253
|
-
}
|
|
254
241
|
_rect.height = _rect.height || rect.height;
|
|
255
|
-
if (_rect.height) {
|
|
256
|
-
unwatchHeight();
|
|
257
|
-
}
|
|
258
242
|
_rect.x = _rect.x || 0;
|
|
259
243
|
_rect.y = _rect.y || 0;
|
|
260
244
|
trigger();
|
|
@@ -481,7 +465,7 @@ var FreeDom = defineComponent({
|
|
|
481
465
|
|
|
482
466
|
// src/components/freeDomWrap.ts
|
|
483
467
|
import { defineComponent as defineComponent3, shallowRef as shallowRef3, h as h3, provide, reactive as reactive3, ref as ref4, toRefs } from "vue-demi";
|
|
484
|
-
import { useElementBounding
|
|
468
|
+
import { useElementBounding } from "@vueuse/core";
|
|
485
469
|
|
|
486
470
|
// src/components/markLine.ts
|
|
487
471
|
import { h as h2, defineComponent as defineComponent2, shallowRef as shallowRef2, ref as ref3, reactive as reactive2, inject as inject2, onBeforeUnmount } from "vue-demi";
|
|
@@ -675,7 +659,7 @@ var FreeDomWrap = defineComponent3({
|
|
|
675
659
|
props: freeDomWrapProps,
|
|
676
660
|
setup(props) {
|
|
677
661
|
const rectRef = shallowRef3(null);
|
|
678
|
-
const rect =
|
|
662
|
+
const rect = useElementBounding(rectRef);
|
|
679
663
|
const nodes = ref4([]);
|
|
680
664
|
function register(uuid, node) {
|
|
681
665
|
nodes.value.push({ uuid, node });
|