@sepveneto/free-dom 0.7.0-alpha.2 → 0.7.2
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 +66 -46
- package/dist/index.js +280 -199
- package/dist/index.mjs +190 -109
- package/package.json +11 -4
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,40 @@
|
|
|
1
1
|
// src/components/freeDomWrap.ts
|
|
2
|
-
import { computed as computed7, defineComponent as defineComponent5,
|
|
2
|
+
import { computed as computed7, defineComponent as defineComponent5, onMounted as onMounted3, provide, reactive as reactive3, ref as ref10, shallowRef as shallowRef4, toRefs, watchEffect as watchEffect4 } from "vue-demi";
|
|
3
3
|
|
|
4
4
|
// src/util/tokens.ts
|
|
5
5
|
var SceneToken = Symbol("Scene");
|
|
6
6
|
|
|
7
|
+
// src/util/render.ts
|
|
8
|
+
import { merge } from "lodash";
|
|
9
|
+
import { h, isVue2 } from "vue-demi";
|
|
10
|
+
function createRender(comp, attrs = {}, props = {}, listeners = {}) {
|
|
11
|
+
if (!comp)
|
|
12
|
+
return () => null;
|
|
13
|
+
const options = isVue2 ? {
|
|
14
|
+
...attrs,
|
|
15
|
+
props,
|
|
16
|
+
on: listeners
|
|
17
|
+
} : {
|
|
18
|
+
...attrs,
|
|
19
|
+
...props
|
|
20
|
+
};
|
|
21
|
+
if (isVue2 && typeof comp === "object" && !("render" in comp)) {
|
|
22
|
+
merge(comp.data, options);
|
|
23
|
+
return comp;
|
|
24
|
+
}
|
|
25
|
+
return (slots) => {
|
|
26
|
+
if (isVue2) {
|
|
27
|
+
if (Object.prototype.toString.call(slots) === "[object Object]") {
|
|
28
|
+
return h(comp, { ...options, scopedSlots: slots });
|
|
29
|
+
} else {
|
|
30
|
+
return h(comp, options, Array.isArray(slots) ? slots : [slots]);
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
return h(comp, options, slots);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
7
38
|
// src/util/index.ts
|
|
8
39
|
var isProduction = process.env.NODE_ENV === "production";
|
|
9
40
|
function clamp(value, min, max = Infinity) {
|
|
@@ -16,7 +47,7 @@ function log(...args) {
|
|
|
16
47
|
}
|
|
17
48
|
|
|
18
49
|
// src/components/markLine.ts
|
|
19
|
-
import { defineComponent, h, inject, onBeforeUnmount, reactive, ref, shallowRef } from "vue-demi";
|
|
50
|
+
import { defineComponent, h as h2, inject, onBeforeUnmount, reactive, ref, shallowRef } from "vue-demi";
|
|
20
51
|
var lineType = ["xt", "xc", "xb", "yl", "yc", "yr"];
|
|
21
52
|
var markLine_default = defineComponent({
|
|
22
53
|
props: {
|
|
@@ -171,12 +202,12 @@ var markLine_default = defineComponent({
|
|
|
171
202
|
};
|
|
172
203
|
},
|
|
173
204
|
render() {
|
|
174
|
-
const _line = (line, info) =>
|
|
205
|
+
const _line = (line, info) => h2("div", {
|
|
175
206
|
style: { [line.includes("x") ? "top" : "left"]: info.pos + "px" },
|
|
176
207
|
class: [line.includes("x") ? "vv-free-dom--xline" : "vv-free-dom--yline", "vv-free-dom--line"]
|
|
177
208
|
});
|
|
178
209
|
const _lines = this.showLine ? this.lines.filter((line) => this.lineStatus[line].show).map((line) => _line(line, this.lineStatus[line])) : [];
|
|
179
|
-
return
|
|
210
|
+
return h2("div", {
|
|
180
211
|
class: "vv-free-dom--markline"
|
|
181
212
|
}, _lines);
|
|
182
213
|
}
|
|
@@ -186,13 +217,13 @@ var markLine_default = defineComponent({
|
|
|
186
217
|
import { ref as ref2, unref, watch } from "vue-demi";
|
|
187
218
|
|
|
188
219
|
// src/hooks/use-default-slot.ts
|
|
189
|
-
import {
|
|
220
|
+
import { computed, useSlots } from "vue-demi";
|
|
190
221
|
function useDefaultSlot() {
|
|
191
222
|
const slots = useSlots();
|
|
192
223
|
const slotList = computed(() => {
|
|
193
224
|
return typeof slots.default === "function" ? slots.default() : slots.default;
|
|
194
225
|
});
|
|
195
|
-
const only = computed(() => slotList.value?.
|
|
226
|
+
const only = computed(() => slotList.value?.[0]);
|
|
196
227
|
return {
|
|
197
228
|
slots: slotList,
|
|
198
229
|
only
|
|
@@ -374,9 +405,9 @@ function useResizableData(props, domRef) {
|
|
|
374
405
|
if (fixNonMonospaced) {
|
|
375
406
|
await document.fonts.ready;
|
|
376
407
|
}
|
|
377
|
-
const { width: w, height:
|
|
408
|
+
const { width: w, height: h5 } = window.getComputedStyle(domRef.value.$el);
|
|
378
409
|
width.value = Math.max(Math.ceil(parseFloat(w)), minWidth);
|
|
379
|
-
height.value = Math.max(Math.ceil(parseFloat(
|
|
410
|
+
height.value = Math.max(Math.ceil(parseFloat(h5)), minHeight);
|
|
380
411
|
}
|
|
381
412
|
return {
|
|
382
413
|
width,
|
|
@@ -498,10 +529,10 @@ function useLayout(props) {
|
|
|
498
529
|
layout.value = _normalize(_layout);
|
|
499
530
|
return layout.value;
|
|
500
531
|
}
|
|
501
|
-
function resizeTo(item, w,
|
|
532
|
+
function resizeTo(item, w, h5) {
|
|
502
533
|
let hasCollisions = false;
|
|
503
534
|
if (!props.collision) {
|
|
504
|
-
const collisions = layout.value.filter((l) => _collides(l, { ...item, w, h:
|
|
535
|
+
const collisions = layout.value.filter((l) => _collides(l, { ...item, w, h: h5 }));
|
|
505
536
|
hasCollisions = collisions.length > 0;
|
|
506
537
|
if (hasCollisions) {
|
|
507
538
|
let leastX = Infinity;
|
|
@@ -520,7 +551,7 @@ function useLayout(props) {
|
|
|
520
551
|
}
|
|
521
552
|
if (!hasCollisions) {
|
|
522
553
|
item.w = w;
|
|
523
|
-
item.h =
|
|
554
|
+
item.h = h5;
|
|
524
555
|
}
|
|
525
556
|
layout.value = _normalize([...layout.value]);
|
|
526
557
|
}
|
|
@@ -716,15 +747,15 @@ function useLayoutItem(props, layout) {
|
|
|
716
747
|
};
|
|
717
748
|
const onResize = (evt, coreData) => {
|
|
718
749
|
const { width: width2, height: height2 } = coreData;
|
|
719
|
-
const { w, h:
|
|
750
|
+
const { w, h: h5 } = _calcWH(width2, height2);
|
|
720
751
|
resizing.value = { width: width2, height: height2 };
|
|
721
|
-
props.resizeFn(evt, { w, h:
|
|
752
|
+
props.resizeFn(evt, { w, h: h5 });
|
|
722
753
|
};
|
|
723
754
|
const onResizeStop = (evt, coreData) => {
|
|
724
755
|
resizing.value = void 0;
|
|
725
756
|
const { width: width2, height: height2 } = coreData;
|
|
726
|
-
const { w, h:
|
|
727
|
-
props.resizeStopFn(evt, { w, h:
|
|
757
|
+
const { w, h: h5 } = _calcWH(width2, height2);
|
|
758
|
+
props.resizeStopFn(evt, { w, h: h5 });
|
|
728
759
|
};
|
|
729
760
|
function _calcXY(left, top) {
|
|
730
761
|
let x2 = Math.round((left - margin.value[0]) / (cellWidth.value + margin.value[0]));
|
|
@@ -735,10 +766,10 @@ function useLayoutItem(props, layout) {
|
|
|
735
766
|
}
|
|
736
767
|
function _calcWH(width2, height2) {
|
|
737
768
|
let w = Math.round((width2 + margin.value[0]) / (cellWidth.value + margin.value[0]));
|
|
738
|
-
let
|
|
769
|
+
let h5 = Math.round((height2 + margin.value[1]) / (rowHeight.value + margin.value[1]));
|
|
739
770
|
w = clamp(w, 0, cols.value - props.x);
|
|
740
|
-
|
|
741
|
-
return { w, h:
|
|
771
|
+
h5 = clamp(h5, 0, maxRows.value - props.y);
|
|
772
|
+
return { w, h: h5 };
|
|
742
773
|
}
|
|
743
774
|
return {
|
|
744
775
|
x,
|
|
@@ -760,10 +791,10 @@ function useLayoutItem(props, layout) {
|
|
|
760
791
|
}
|
|
761
792
|
|
|
762
793
|
// src/components/freeDom.ts
|
|
763
|
-
import { computed as computed6, defineComponent as defineComponent4,
|
|
794
|
+
import { computed as computed6, defineComponent as defineComponent4, onMounted as onMounted2, reactive as reactive2, ref as ref9 } from "vue-demi";
|
|
764
795
|
|
|
765
796
|
// src/components/freeDomCore.ts
|
|
766
|
-
import { computed as computed4, defineComponent as defineComponent2,
|
|
797
|
+
import { computed as computed4, defineComponent as defineComponent2, isVue2 as isVue22, onUnmounted, ref as ref8 } from "vue-demi";
|
|
767
798
|
function noop() {
|
|
768
799
|
}
|
|
769
800
|
var freeDomCoreProps = {
|
|
@@ -791,8 +822,8 @@ var freeDomCore = defineComponent2({
|
|
|
791
822
|
setup(props) {
|
|
792
823
|
const { only } = useDefaultSlot();
|
|
793
824
|
const dragging = ref8(false);
|
|
794
|
-
const
|
|
795
|
-
const node = computed4(() =>
|
|
825
|
+
const coreRef = ref8();
|
|
826
|
+
const node = computed4(() => coreRef.value?.$el || coreRef.value);
|
|
796
827
|
const ownerDoc = computed4(() => node.value?.ownerDocument);
|
|
797
828
|
const { lastX, lastY, create } = useCoreData(node);
|
|
798
829
|
let parentNode;
|
|
@@ -882,17 +913,42 @@ var freeDomCore = defineComponent2({
|
|
|
882
913
|
}
|
|
883
914
|
return {
|
|
884
915
|
only,
|
|
885
|
-
|
|
916
|
+
coreRef,
|
|
886
917
|
mousedownFn,
|
|
887
918
|
mouseupFn
|
|
888
919
|
};
|
|
889
920
|
},
|
|
890
921
|
render() {
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
922
|
+
const vue2Props = {
|
|
923
|
+
on: {
|
|
924
|
+
mousedown: (evt) => {
|
|
925
|
+
evt.stopPropagation();
|
|
926
|
+
this.mousedownFn(evt);
|
|
927
|
+
},
|
|
928
|
+
mouseup: this.mouseupFn
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
const vue3Props = {
|
|
932
|
+
onMousedown: (evt) => {
|
|
933
|
+
evt.stopPropagation();
|
|
934
|
+
this.mousedownFn(evt);
|
|
935
|
+
},
|
|
894
936
|
onMouseup: this.mouseupFn
|
|
895
|
-
}
|
|
937
|
+
};
|
|
938
|
+
const res = createRender(
|
|
939
|
+
// @ts-expect-error: maybe vue2
|
|
940
|
+
this.only,
|
|
941
|
+
{ ref: (el) => {
|
|
942
|
+
this.coreRef = el;
|
|
943
|
+
} },
|
|
944
|
+
isVue22 ? {} : vue3Props,
|
|
945
|
+
isVue22 ? vue2Props.on : {}
|
|
946
|
+
);
|
|
947
|
+
if (typeof res === "function") {
|
|
948
|
+
return res();
|
|
949
|
+
} else {
|
|
950
|
+
return res;
|
|
951
|
+
}
|
|
896
952
|
}
|
|
897
953
|
});
|
|
898
954
|
var freeDomCore_default = freeDomCore;
|
|
@@ -1016,20 +1072,25 @@ var resizeDomCore = defineComponent3({
|
|
|
1016
1072
|
};
|
|
1017
1073
|
},
|
|
1018
1074
|
render() {
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1075
|
+
const slots = [
|
|
1076
|
+
...this.children || [],
|
|
1077
|
+
this.dots.map((dot) => {
|
|
1078
|
+
return createRender(
|
|
1079
|
+
freeDomCore_default,
|
|
1080
|
+
{ class: [this.dragOpts.disabled && "vv-resize-dom--disabled"] },
|
|
1081
|
+
{
|
|
1082
|
+
...this.dragOpts,
|
|
1083
|
+
stopFn: this.handleResize("stop", dot),
|
|
1084
|
+
startFn: this.handleResize("start", dot),
|
|
1085
|
+
dragFn: this.handleResize("resize", dot)
|
|
1086
|
+
}
|
|
1087
|
+
)(this.renderResizehandler(dot));
|
|
1088
|
+
})
|
|
1089
|
+
];
|
|
1090
|
+
return createRender(
|
|
1091
|
+
"div",
|
|
1092
|
+
{ class: "vv-resize-dom--box" }
|
|
1093
|
+
)(slots);
|
|
1033
1094
|
}
|
|
1034
1095
|
});
|
|
1035
1096
|
var resizeDomCore_default = resizeDomCore;
|
|
@@ -1106,7 +1167,6 @@ var freeDom = defineComponent4({
|
|
|
1106
1167
|
],
|
|
1107
1168
|
setup(props, { emit, expose, slots }) {
|
|
1108
1169
|
const domRef = ref9();
|
|
1109
|
-
const { slots: children } = useDefaultSlot();
|
|
1110
1170
|
const {
|
|
1111
1171
|
x,
|
|
1112
1172
|
y,
|
|
@@ -1178,9 +1238,9 @@ var freeDom = defineComponent4({
|
|
|
1178
1238
|
emit("update:y", y.value);
|
|
1179
1239
|
emit("update:modelValue", { x: x.value, y: y.value, w: width.value, h: height.value });
|
|
1180
1240
|
};
|
|
1181
|
-
const onResize = (evt, { node, width: w, height:
|
|
1241
|
+
const onResize = (evt, { node, width: w, height: h5, handle: axis }) => {
|
|
1182
1242
|
const offsetW = -(w - width.value);
|
|
1183
|
-
const offsetH = -(
|
|
1243
|
+
const offsetH = -(h5 - height.value);
|
|
1184
1244
|
const axisH = axis[0];
|
|
1185
1245
|
const axisV = axis[axis.length - 1];
|
|
1186
1246
|
let _x = x.value;
|
|
@@ -1191,14 +1251,14 @@ var freeDom = defineComponent4({
|
|
|
1191
1251
|
if (axisV === "t") {
|
|
1192
1252
|
_y += offsetH;
|
|
1193
1253
|
}
|
|
1194
|
-
const isValid = sceneContext.check?.({ x: _x, y: _y, width: w, height:
|
|
1254
|
+
const isValid = sceneContext.check?.({ x: _x, y: _y, width: w, height: h5 });
|
|
1195
1255
|
if (!isValid)
|
|
1196
1256
|
return;
|
|
1197
1257
|
width.value = w;
|
|
1198
|
-
height.value =
|
|
1258
|
+
height.value = h5;
|
|
1199
1259
|
x.value = _x;
|
|
1200
1260
|
y.value = _y;
|
|
1201
|
-
props.resizeFn(evt, { node, width: w, height:
|
|
1261
|
+
props.resizeFn(evt, { node, width: w, height: h5, handle: axis });
|
|
1202
1262
|
sceneContext?.emit("move");
|
|
1203
1263
|
};
|
|
1204
1264
|
const onResizeStop = () => {
|
|
@@ -1212,21 +1272,21 @@ var freeDom = defineComponent4({
|
|
|
1212
1272
|
emit("update:modelValue", { x: x.value, y: y.value, w: width.value, h: height.value });
|
|
1213
1273
|
sceneContext.emit("moveup");
|
|
1214
1274
|
};
|
|
1215
|
-
const resizeNode = () =>
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
}
|
|
1229
|
-
expose({
|
|
1275
|
+
const resizeNode = () => {
|
|
1276
|
+
const props2 = {
|
|
1277
|
+
width: width.value,
|
|
1278
|
+
height: height.value,
|
|
1279
|
+
lockAspectRatio: sceneContext.lockAspectRatio.value,
|
|
1280
|
+
dragOpts: { disabled: sceneContext.disabledResize.value },
|
|
1281
|
+
resizeFn: onResize,
|
|
1282
|
+
stopFn: onResizeStop,
|
|
1283
|
+
minHeight: sceneContext.minHeight.value,
|
|
1284
|
+
minWidth: sceneContext.minWidth.value,
|
|
1285
|
+
scale: sceneContext.scale.value
|
|
1286
|
+
};
|
|
1287
|
+
return createRender(resizeDomCore_default, {}, props2)(slots);
|
|
1288
|
+
};
|
|
1289
|
+
expose?.({
|
|
1230
1290
|
syncSize
|
|
1231
1291
|
});
|
|
1232
1292
|
return {
|
|
@@ -1239,14 +1299,21 @@ var freeDom = defineComponent4({
|
|
|
1239
1299
|
};
|
|
1240
1300
|
},
|
|
1241
1301
|
render() {
|
|
1242
|
-
|
|
1243
|
-
ref: "domRef",
|
|
1244
|
-
class: "vv-free-dom--draggable",
|
|
1245
|
-
style: this.style,
|
|
1302
|
+
const props = {
|
|
1246
1303
|
stopFn: this.onDragStop,
|
|
1247
1304
|
dragFn: this.onDrag,
|
|
1248
1305
|
disabled: this.disabled
|
|
1249
|
-
}
|
|
1306
|
+
};
|
|
1307
|
+
const slots = () => this.resizeNode();
|
|
1308
|
+
return createRender(
|
|
1309
|
+
freeDomCore_default,
|
|
1310
|
+
{
|
|
1311
|
+
ref: "domRef",
|
|
1312
|
+
class: "vv-free-dom--draggable",
|
|
1313
|
+
style: this.style
|
|
1314
|
+
},
|
|
1315
|
+
props
|
|
1316
|
+
)?.(slots);
|
|
1250
1317
|
}
|
|
1251
1318
|
});
|
|
1252
1319
|
var freeDom_default = freeDom;
|
|
@@ -1281,6 +1348,7 @@ var FreeDomWrap = defineComponent5({
|
|
|
1281
1348
|
name: "FreeDomWrap",
|
|
1282
1349
|
props: freeDomWrapProps,
|
|
1283
1350
|
setup(props) {
|
|
1351
|
+
const { slots } = useDefaultSlot();
|
|
1284
1352
|
const eventBus = useEventBus();
|
|
1285
1353
|
const rectRef = shallowRef4();
|
|
1286
1354
|
const nodes = ref10([]);
|
|
@@ -1296,19 +1364,21 @@ var FreeDomWrap = defineComponent5({
|
|
|
1296
1364
|
if (!props.width || !props.height) {
|
|
1297
1365
|
if (!rectRef.value)
|
|
1298
1366
|
console.warn("[free-dom] cannot find element, width or height may be set to 0");
|
|
1299
|
-
const { width: w, height:
|
|
1367
|
+
const { width: w, height: h5 } = rectRef.value?.getBoundingClientRect() || {};
|
|
1300
1368
|
if (!props.width)
|
|
1301
1369
|
width.value = w || 0;
|
|
1302
1370
|
if (!props.height)
|
|
1303
|
-
height.value =
|
|
1371
|
+
height.value = h5 || 0;
|
|
1304
1372
|
}
|
|
1305
1373
|
});
|
|
1306
1374
|
function register(uuid, node) {
|
|
1307
1375
|
nodes.value.push({ uuid, node });
|
|
1308
1376
|
}
|
|
1309
1377
|
function checkValid(pos) {
|
|
1310
|
-
const { x, y, width: w, height:
|
|
1311
|
-
return x >= 0 &&
|
|
1378
|
+
const { x, y, width: w, height: h5 } = pos;
|
|
1379
|
+
return x >= 0 && // @ts-expect-error: trigger after mounted
|
|
1380
|
+
x + w <= width.value && y >= 0 && // @ts-expect-error: trigger after mounted
|
|
1381
|
+
y + h5 <= height.value;
|
|
1312
1382
|
}
|
|
1313
1383
|
provide(
|
|
1314
1384
|
SceneToken,
|
|
@@ -1330,24 +1400,29 @@ var FreeDomWrap = defineComponent5({
|
|
|
1330
1400
|
}));
|
|
1331
1401
|
return {
|
|
1332
1402
|
rectRef,
|
|
1333
|
-
style
|
|
1403
|
+
style,
|
|
1404
|
+
slots
|
|
1334
1405
|
};
|
|
1335
1406
|
},
|
|
1336
1407
|
render() {
|
|
1337
|
-
const
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1408
|
+
const marklineComp = createRender(markLine_default, {}, { showLine: this.showLine })();
|
|
1409
|
+
const slots = [this.slots, marklineComp];
|
|
1410
|
+
return createRender(
|
|
1411
|
+
"section",
|
|
1412
|
+
{
|
|
1413
|
+
ref: "rectRef",
|
|
1414
|
+
class: "vv-free-dom--scene",
|
|
1415
|
+
style: this.style
|
|
1416
|
+
}
|
|
1417
|
+
)(slots);
|
|
1343
1418
|
}
|
|
1344
1419
|
});
|
|
1345
1420
|
|
|
1346
1421
|
// src/components/gridLayout.ts
|
|
1347
|
-
import { defineComponent as defineComponent7, h as
|
|
1422
|
+
import { defineComponent as defineComponent7, h as h4, provide as provide2, ref as ref11 } from "vue-demi";
|
|
1348
1423
|
|
|
1349
1424
|
// src/components/gridItem.ts
|
|
1350
|
-
import { defineComponent as defineComponent6,
|
|
1425
|
+
import { defineComponent as defineComponent6, inject as inject3 } from "vue-demi";
|
|
1351
1426
|
|
|
1352
1427
|
// src/components/tokens.ts
|
|
1353
1428
|
var gridLayoutContextKey = Symbol("gridLayoutContext");
|
|
@@ -1431,7 +1506,7 @@ var GridItem = defineComponent6({
|
|
|
1431
1506
|
} = useLayoutItem(props, layout);
|
|
1432
1507
|
const { only, slots } = useDefaultSlot();
|
|
1433
1508
|
const resizeNode = (child) => {
|
|
1434
|
-
|
|
1509
|
+
const _props = {
|
|
1435
1510
|
width: width.value,
|
|
1436
1511
|
height: height.value,
|
|
1437
1512
|
scale: props.scale,
|
|
@@ -1443,20 +1518,26 @@ var GridItem = defineComponent6({
|
|
|
1443
1518
|
startFn: onResizeStart,
|
|
1444
1519
|
resizeFn: onResize,
|
|
1445
1520
|
stopFn: onResizeStop
|
|
1446
|
-
}
|
|
1521
|
+
};
|
|
1522
|
+
return createRender(resizeDomCore_default, {}, _props)(() => child);
|
|
1523
|
+
};
|
|
1524
|
+
const dragNode = (child) => {
|
|
1525
|
+
const _attrs = {
|
|
1526
|
+
class: [
|
|
1527
|
+
dragging.value && "vv-grid-layout--item__draggable",
|
|
1528
|
+
"vv-grid-layout--item",
|
|
1529
|
+
!props.isDraggable && "vv-grid-layout--item__disabled"
|
|
1530
|
+
],
|
|
1531
|
+
style: style.value
|
|
1532
|
+
};
|
|
1533
|
+
const _props = {
|
|
1534
|
+
disabled: !props.isDraggable,
|
|
1535
|
+
startFn: onDragStart,
|
|
1536
|
+
stopFn: onDragStop,
|
|
1537
|
+
dragFn: onDrag
|
|
1538
|
+
};
|
|
1539
|
+
return createRender(freeDomCore_default, _attrs, _props)(() => resizeNode(child));
|
|
1447
1540
|
};
|
|
1448
|
-
const dragNode = (child) => h6(freeDomCore_default, {
|
|
1449
|
-
class: [
|
|
1450
|
-
dragging.value && "vv-grid-layout--item__draggable",
|
|
1451
|
-
"vv-grid-layout--item",
|
|
1452
|
-
!props.isDraggable && "vv-grid-layout--item__disabled"
|
|
1453
|
-
],
|
|
1454
|
-
style: style.value,
|
|
1455
|
-
disabled: !props.isDraggable,
|
|
1456
|
-
startFn: onDragStart,
|
|
1457
|
-
stopFn: onDragStop,
|
|
1458
|
-
dragFn: onDrag
|
|
1459
|
-
}, () => resizeNode(child));
|
|
1460
1541
|
return {
|
|
1461
1542
|
x,
|
|
1462
1543
|
y,
|
|
@@ -1483,10 +1564,6 @@ var GridItem = defineComponent6({
|
|
|
1483
1564
|
|
|
1484
1565
|
// src/components/gridLayout.ts
|
|
1485
1566
|
var gridLayoutProps = {
|
|
1486
|
-
style: {
|
|
1487
|
-
type: Object,
|
|
1488
|
-
default: () => ({})
|
|
1489
|
-
},
|
|
1490
1567
|
modelValue: {
|
|
1491
1568
|
type: Array,
|
|
1492
1569
|
required: true,
|
|
@@ -1534,6 +1611,7 @@ var gridLayoutProps = {
|
|
|
1534
1611
|
};
|
|
1535
1612
|
var GridLayout = defineComponent7({
|
|
1536
1613
|
name: "GridLayout",
|
|
1614
|
+
inheritAttrs: false,
|
|
1537
1615
|
props: gridLayoutProps,
|
|
1538
1616
|
emits: ["update:modelValue"],
|
|
1539
1617
|
setup(props, { emit }) {
|
|
@@ -1549,7 +1627,7 @@ var GridLayout = defineComponent7({
|
|
|
1549
1627
|
return;
|
|
1550
1628
|
const isDraggable = !config.static && !props.disabledDrag;
|
|
1551
1629
|
const isResizable = !config.static && !props.disabledResize;
|
|
1552
|
-
|
|
1630
|
+
const _props = {
|
|
1553
1631
|
x: config.x,
|
|
1554
1632
|
y: config.y,
|
|
1555
1633
|
width: config.w,
|
|
@@ -1586,28 +1664,31 @@ var GridLayout = defineComponent7({
|
|
|
1586
1664
|
height: config.h
|
|
1587
1665
|
};
|
|
1588
1666
|
activeDrag.value = placeholder2;
|
|
1589
|
-
const { w, h:
|
|
1590
|
-
layout.resizeTo(config, w,
|
|
1667
|
+
const { w, h: h5 } = data;
|
|
1668
|
+
layout.resizeTo(config, w, h5);
|
|
1591
1669
|
},
|
|
1592
1670
|
resizeStopFn: (evt, data) => {
|
|
1593
|
-
const { w, h:
|
|
1594
|
-
layout.resizeTo(config, w,
|
|
1671
|
+
const { w, h: h5 } = data;
|
|
1672
|
+
layout.resizeTo(config, w, h5);
|
|
1595
1673
|
activeDrag.value = null;
|
|
1596
1674
|
}
|
|
1597
|
-
}
|
|
1675
|
+
};
|
|
1676
|
+
return createRender(GridItem, {}, _props)({ default: () => node });
|
|
1598
1677
|
}
|
|
1599
1678
|
function placeholder() {
|
|
1600
1679
|
if (!activeDrag.value)
|
|
1601
1680
|
return null;
|
|
1602
1681
|
const { x, y, width, height } = activeDrag.value;
|
|
1603
|
-
|
|
1604
|
-
class: "vv-grid-layout--placeholder",
|
|
1682
|
+
const _props = {
|
|
1605
1683
|
x,
|
|
1606
1684
|
y,
|
|
1607
1685
|
width,
|
|
1608
1686
|
height,
|
|
1609
1687
|
move: false
|
|
1610
|
-
}
|
|
1688
|
+
};
|
|
1689
|
+
return createRender(GridItem, {
|
|
1690
|
+
class: "vv-grid-layout--placeholder"
|
|
1691
|
+
}, _props)();
|
|
1611
1692
|
}
|
|
1612
1693
|
return {
|
|
1613
1694
|
processItem,
|
|
@@ -1617,11 +1698,11 @@ var GridLayout = defineComponent7({
|
|
|
1617
1698
|
},
|
|
1618
1699
|
render() {
|
|
1619
1700
|
const mergedStyle = {
|
|
1620
|
-
...this.style || {},
|
|
1701
|
+
...this.$attrs.style || {},
|
|
1621
1702
|
height: this.layout.calContainerHeight()
|
|
1622
1703
|
};
|
|
1623
1704
|
const defaultSlot = typeof this.$slots.default === "function" ? this.$slots.default() : this.$slots.default || [];
|
|
1624
|
-
return
|
|
1705
|
+
return h4("div", {
|
|
1625
1706
|
class: "vv-grid-layout",
|
|
1626
1707
|
style: mergedStyle
|
|
1627
1708
|
}, [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sepveneto/free-dom",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
},
|
|
16
16
|
"./css": "./dist/index.css"
|
|
17
17
|
},
|
|
18
|
+
"typesVersions": {
|
|
19
|
+
"*": {
|
|
20
|
+
".": [
|
|
21
|
+
"dist/index.d.ts"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
18
25
|
"scripts": {
|
|
19
26
|
"build": "tsup",
|
|
20
27
|
"dev": "vue-demi-switch 3 && vitepress dev docs",
|
|
@@ -25,16 +32,16 @@
|
|
|
25
32
|
"author": "",
|
|
26
33
|
"license": "ISC",
|
|
27
34
|
"dependencies": {
|
|
28
|
-
"
|
|
35
|
+
"lodash": "^4.17.21",
|
|
29
36
|
"uuid": "^9.0.0",
|
|
30
37
|
"vue-demi": "latest"
|
|
31
38
|
},
|
|
32
39
|
"devDependencies": {
|
|
40
|
+
"@types/lodash": "^4.14.195",
|
|
33
41
|
"@types/uuid": "^8.3.4",
|
|
34
42
|
"bumpp": "^8.2.1",
|
|
35
43
|
"esbuild-plugin-sass": "^1.0.1",
|
|
36
|
-
"tsup": "^6.5.0"
|
|
37
|
-
"vue": "^3.2.39"
|
|
44
|
+
"tsup": "^6.5.0"
|
|
38
45
|
},
|
|
39
46
|
"changelog": "https://github.com/SepVeneto/free-dom/blob/master/packages/core/CHANGELOG.md",
|
|
40
47
|
"homepage": "https://github.com/SepVeneto/free-dom/blob/master/readme.md",
|