polarvo-layout 1.0.9 → 1.0.11

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polarvo-layout",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "type": "module",
5
5
  "author": "unigence <unigencelab@gmail.com>",
6
6
  "repository": {
@@ -7,7 +7,7 @@
7
7
  class="absolute user-select-none"
8
8
  :style="getElementStyle(item)"
9
9
  :class="{ 'z-50': item.id === activeId, 'bg-white border-2 border-blue-400': item.id === activeId }"
10
- @mousedown.stop="startDrag($event, item.id)"
10
+ @mousedown.stop="activeEditMode ? null : startDrag($event, item.id)"
11
11
  >
12
12
  <!-- 리사이즈 핸들 -->
13
13
  <div v-if="item.id === activeId" class="absolute inset-0 pointer-events-none">
@@ -34,13 +34,15 @@
34
34
  </div>
35
35
  </div>
36
36
  </div>
37
+
37
38
  <component
38
39
  :is="dynamicComponent(item.type)"
39
40
  :id="`${sectionKey}-${index}`"
41
+ :rootId="item.id"
40
42
  :ref="(el) => setComponentRef(el, item.id)"
41
43
  v-bind="item"
42
44
  class="hover:opacity-80"
43
- :class="activeEditMode ? `pointer-events-auto` : `pointer-events-none`"
45
+ :class="activeEditMode ? `pointer-events-auto ` : `pointer-events-none`"
44
46
  />
45
47
  </div>
46
48
 
@@ -124,8 +126,8 @@ function setComponentRef(el, elementId) {
124
126
  }
125
127
 
126
128
  const selectedElement = inject('selectedElement');
127
-
128
129
  const activeEditMode = inject('activeEditMode');
130
+
129
131
  function toggleEditMode() {
130
132
  activeEditMode.value = !activeEditMode.value;
131
133
  }
@@ -159,6 +161,7 @@ watch(
159
161
 
160
162
  onMounted(() => {
161
163
  props.polarvo.components.register('sections', props.sectionKey, getCurrentInstance());
164
+ activeEditMode.value = false;
162
165
  });
163
166
 
164
167
  onUnmounted(() => {
@@ -5,15 +5,12 @@
5
5
  :key="index"
6
6
  :id="item.id"
7
7
  class="relative bg-gray-200"
8
- :class="{
9
- 'z-50': activeElement?.id === item.id,
10
- 'bg-white border-2 border-blue-400': activeElement?.id === item.id,
11
- }"
12
8
  :style="getElementStyle('element', item)"
13
- @mousedown.stop="startDrag($event, item.id)"
9
+ :class="{ 'z-50': item.id === activeId, 'bg-white border-2 border-blue-400': item.id === activeId }"
10
+ @mousedown.stop="activeEditMode ? null : startDrag($event, item.id)"
14
11
  >
15
12
  <!-- 리사이즈 핸들 -->
16
- <div v-if="activeElement?.id === item.id">
13
+ <div v-if="item.id === activeId">
17
14
  <div class="absolute w-4 h-4 bottom-0 right-0 bg-blue-400 z-10 cursor-se-resize" @mousedown="startResize($event, item.id)"></div>
18
15
  <div class="flex gap-1 m-1">
19
16
  <!-- 잠금 토글-->
@@ -36,10 +33,11 @@
36
33
  <component
37
34
  :is="dynamicComponent(item.type)"
38
35
  :id="`${sectionKey}-${index}`"
36
+ :rootId="item.id"
39
37
  :ref="(el) => setComponentRef(el, item.id)"
40
38
  v-bind="item"
41
39
  class="hover:opacity-80"
42
- :class="activeEditMode ? `pointer-events-auto` : `pointer-events-none`"
40
+ :class="activeEditMode ? `pointer-events-auto ` : `pointer-events-none`"
43
41
  />
44
42
  </div>
45
43
 
@@ -68,7 +66,19 @@
68
66
  import LockIcon from '../../icons/action/LockIcon.vue';
69
67
  import UnlockIcon from '../../icons/action/UnlockIcon.vue';
70
68
 
71
- import { toRefs, defineAsyncComponent, markRaw, getCurrentInstance, onMounted, onUnmounted, inject, watch, toRaw, computed } from 'vue';
69
+ import {
70
+ nextTick,
71
+ toRefs,
72
+ defineAsyncComponent,
73
+ markRaw,
74
+ getCurrentInstance,
75
+ onMounted,
76
+ onUnmounted,
77
+ inject,
78
+ watch,
79
+ toRaw,
80
+ computed,
81
+ } from 'vue';
72
82
  const emit = defineEmits(['click:element']);
73
83
  const props = defineProps({
74
84
  polarvo: {
@@ -91,7 +101,7 @@ const props = defineProps({
91
101
 
92
102
  const { setActiveDesign } = props.polarvo.display;
93
103
  const { updateActiveElement } = props.polarvo.layout;
94
- const { elements, emptyData, activeCell, activeElement } = toRefs(props.polarvo.gridDrop.state);
104
+ const { elements, emptyData, activeId, activeCell, activeElement } = toRefs(props.polarvo.gridDrop.state);
95
105
  const { getElementStyle, setActiveElement, toggleLock, startDrag, detectHoverCell, startResize } = props.polarvo.gridDrop;
96
106
  const filteredElements = computed(() => {
97
107
  return elements.value.filter((el) => props.elementIds?.includes(el.id) && el.section === props.sectionKey);
@@ -155,6 +165,7 @@ watch(
155
165
 
156
166
  onMounted(() => {
157
167
  props.polarvo.components.register('sections', props.sectionKey, getCurrentInstance());
168
+ activeEditMode.value = false;
158
169
  });
159
170
 
160
171
  onUnmounted(() => {
@@ -108,9 +108,15 @@ class GridDropEngine {
108
108
  });
109
109
  });
110
110
 
111
- this._subscribe('system:requestUpdateActiveElement', ({ elements }) => {
111
+ this._subscribe('system:requestUpdateActiveElement', ({ elements, elementId }) => {
112
112
  this._elements = elements;
113
113
  this._elementsUpdate = true;
114
+ this.setActiveElement(this._elements.find((x) => x.id === elementId) || null);
115
+
116
+ this.eventBus.emit('gridDrop:requestUpdateActiveElement', {
117
+ elements: cloneDeep(this.gridElements),
118
+ timestamp: Date.now(),
119
+ });
114
120
  });
115
121
 
116
122
  this._subscribe('system:requestUpdateElements', ({ elements }) => {
@@ -291,6 +297,7 @@ class GridDropEngine {
291
297
  this._elementsUpdate = true;
292
298
  }
293
299
 
300
+
294
301
  this.eventBus.emit('gridDrop:setActiveElement', {
295
302
  action: action,
296
303
  activeElement: this._activeElement,
@@ -479,10 +486,6 @@ class GridDropEngine {
479
486
  }
480
487
  this.setActiveElement(element);
481
488
 
482
- if (!this._activeElement) {
483
- console.error('[GridDropEngine] 활성화된 아이템 정보를 찾을 수 없습니다.');
484
- return false;
485
- }
486
489
  // 배치요소 잠겨 있으면 드래그/삭제 불가
487
490
  if (this._activeElement.isLocked) return;
488
491
 
@@ -222,7 +222,7 @@ class EngineManager {
222
222
  this._subscribe('layout:setLayoutName', ({ screenConfig }) => {
223
223
  this._layoutData = screenConfig.layoutData;
224
224
  this._dataUpdate = true;
225
- this.setActiveSection(null, true);
225
+ this.setActiveSection('section1', true);
226
226
 
227
227
  this.eventBus.emit('system:updateLayoutData', {
228
228
  layoutData: cloneDeep(this._layoutData),
@@ -54,6 +54,10 @@ function useGridDrop(api) {
54
54
  state.activeId = activeElement?.id ?? null;
55
55
  });
56
56
 
57
+ _subscribe('gridDrop:requestUpdateActiveElement', ({ elements }) => {
58
+ state.elements = elements;
59
+ });
60
+
57
61
  _subscribe('gridDrop:toggleLock', ({ elementId }) => {
58
62
  const element = state.elements.find((el) => el.id === elementId);
59
63
  if (element) {