polarvo-layout 1.0.77 → 1.0.79
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/package.json +1 -1
- package/src/components/SideBar/ElementSideBar.vue +16 -1
- package/src/core/engines/FreeDropEngine.js +3 -1
- package/src/core/engines/GridDropEngine.js +2 -1
- package/src/library/FreeDropLibrary.js +1 -1
- package/src/library/GridDropLibrary.js +1 -1
- package/src/library/LayoutLibrary.js +1 -0
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
v-for="(item, index) in currentElements"
|
|
5
5
|
:key="index"
|
|
6
6
|
class="flex flex-col items-center justify-center border border-gray-200 rounded-lg p-2 hover:bg-gray-50 transition-colors cursor-pointer active:scale-95"
|
|
7
|
-
@mousedown.stop="
|
|
7
|
+
@mousedown.stop="handleAddElement($event, item)"
|
|
8
8
|
>
|
|
9
9
|
<img :src="item.imgurl" alt="" class="w-24 h-auto rounded" />
|
|
10
10
|
<h4 class="text-sm">{{ item.label }}</h4>
|
|
@@ -39,8 +39,23 @@ const props = defineProps({
|
|
|
39
39
|
required: false,
|
|
40
40
|
default: () => [],
|
|
41
41
|
},
|
|
42
|
+
generalStyle: {
|
|
43
|
+
type: Object,
|
|
44
|
+
default: () => ({}),
|
|
45
|
+
},
|
|
42
46
|
});
|
|
43
47
|
|
|
48
|
+
function resolveCustomStyle(item) {
|
|
49
|
+
// custom 요소는 기존 세팅된 customStyle을 따름
|
|
50
|
+
const base = props.elType === 'custom' ? item.propDefaults?.customStyle : props.generalStyle?.[item.elName];
|
|
51
|
+
return { ...(base ?? {}) };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function handleAddElement(event, item) {
|
|
55
|
+
const payload = { ...item, customStyle: resolveCustomStyle(item) };
|
|
56
|
+
sectionMode.value === 'free' ? addElementToFree(event, payload) : addElementToGrid(payload);
|
|
57
|
+
}
|
|
58
|
+
|
|
44
59
|
const { addElement: addElementToFree } = props.polarvo.freeDrop;
|
|
45
60
|
const { addElement: addElementToGrid } = props.polarvo.gridDrop;
|
|
46
61
|
|
|
@@ -127,7 +127,7 @@ class FreeDropEngine {
|
|
|
127
127
|
const index = this._elements.findIndex((x) => x.id === elementId);
|
|
128
128
|
|
|
129
129
|
if (index !== -1) {
|
|
130
|
-
this._elements =
|
|
130
|
+
this._elements[index] = element; // 업데이트
|
|
131
131
|
this._activeElement = element;
|
|
132
132
|
this._elementsUpdate = true;
|
|
133
133
|
}
|
|
@@ -432,6 +432,7 @@ class FreeDropEngine {
|
|
|
432
432
|
section: this._activeSection,
|
|
433
433
|
isLocked: false,
|
|
434
434
|
...(item.propDefaults || {}), // 아이템의 기본 props 설정
|
|
435
|
+
customStyle: {...item.customStyle ?? null},
|
|
435
436
|
};
|
|
436
437
|
|
|
437
438
|
this.setActiveElement(element, 'add');
|
|
@@ -899,6 +900,7 @@ class FreeDropEngine {
|
|
|
899
900
|
});
|
|
900
901
|
// }
|
|
901
902
|
this._resetDrag();
|
|
903
|
+
this._alreadyExist = true;
|
|
902
904
|
return;
|
|
903
905
|
}
|
|
904
906
|
};
|
|
@@ -94,7 +94,7 @@ class GridDropEngine {
|
|
|
94
94
|
const index = this._elements.findIndex((x) => x.id === elementId);
|
|
95
95
|
|
|
96
96
|
if (index !== -1) {
|
|
97
|
-
this._elements =
|
|
97
|
+
this._elements[index] = element; // 업데이트
|
|
98
98
|
this._elementsUpdate = true;
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -362,6 +362,7 @@ class GridDropEngine {
|
|
|
362
362
|
section: this._activeSection,
|
|
363
363
|
isLocked: false,
|
|
364
364
|
...(item.propDefaults || {}), // 아이템의 기본 props 설정
|
|
365
|
+
customStyle: { ...(item.customStyle ?? null) },
|
|
365
366
|
};
|
|
366
367
|
|
|
367
368
|
this.setActiveElement(null, 'add');
|
|
@@ -62,7 +62,7 @@ function useFreeDrop(api) {
|
|
|
62
62
|
const index = state.elements.findIndex((el) => el.id === element.id);
|
|
63
63
|
|
|
64
64
|
if (index !== -1) {
|
|
65
|
-
state.elements =
|
|
65
|
+
state.elements[index] = element;
|
|
66
66
|
state.activeElement = element;
|
|
67
67
|
state.activeId = element?.id ?? null;
|
|
68
68
|
}
|
|
@@ -50,7 +50,7 @@ function useGridDrop(api) {
|
|
|
50
50
|
// state.elements = elements;
|
|
51
51
|
const index = state.elements.findIndex((el) => el.id === element.id);
|
|
52
52
|
if (index !== -1) {
|
|
53
|
-
state.elements =
|
|
53
|
+
state.elements[index] = element;
|
|
54
54
|
state.activeElement = element;
|
|
55
55
|
state.activeId = element?.id ?? null;
|
|
56
56
|
}
|
|
@@ -93,6 +93,7 @@ function useLayout(api) {
|
|
|
93
93
|
_subscribe('system:requestUpdateActiveElement', ({ elementId, element }) => {
|
|
94
94
|
const index = state.elements.findIndex((x) => x.id === elementId);
|
|
95
95
|
if (index !== -1) {
|
|
96
|
+
// state.elements[index] = element; // 업데이트
|
|
96
97
|
state.elements = [...state.elements.slice(0, index), element, ...state.elements.slice(index + 1)]; // 배열 자체를 교체하여 갱신
|
|
97
98
|
}
|
|
98
99
|
});
|