polarvo-layout 1.0.19 → 1.0.21

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.
Files changed (28) hide show
  1. package/package.json +1 -1
  2. package/src/components/FastMenu/DesignFastmenu.vue +2 -2
  3. package/src/components/FastMenu/DisplayFastMenu.vue +2 -2
  4. package/src/components/FastMenu/LayoutFastMenu.vue +18 -10
  5. package/src/components/Layout/CanvasContainer.vue +30 -6
  6. package/src/components/SideBar/ElementSideBar.vue +2 -2
  7. package/src/components/SideBar/LayoutSettingSideBar.vue +18 -10
  8. package/src/components/SideBar/LayoutSideBar.vue +19 -8
  9. package/src/configs/index.js +1 -0
  10. package/src/core/engines/DisplayEngine.js +72 -64
  11. package/src/core/engines/FreeDropEngine.js +40 -42
  12. package/src/core/engines/GridDropEngine.js +33 -43
  13. package/src/core/engines/HistoryEngine.js +55 -51
  14. package/src/core/engines/LayoutEngine.js +89 -68
  15. package/src/core/engines/originals/FreeDropEngine_0402.js +786 -0
  16. package/src/core/engines/originals/GridDropEngine_0402.js +557 -0
  17. package/src/core/managers/EngineManager.js +93 -131
  18. package/src/core/managers/originals/EngineManager_0402.js +826 -0
  19. package/src/library/DisplayLibrary.js +14 -17
  20. package/src/library/FreeDropLibrary.js +6 -4
  21. package/src/library/GridDropLibrary.js +3 -5
  22. package/src/library/LayoutLibrary.js +45 -48
  23. package/src/library/originals/DisplayLibrary_0402.js +137 -0
  24. package/src/library/originals/FreeDropLibrary_0402.js +185 -0
  25. package/src/library/originals/GridDropLibrary_0402.js +202 -0
  26. package/src/library/originals/HistoryLibrary_0402.js +98 -0
  27. package/src/library/originals/LayoutLibrary_0402.js +264 -0
  28. package/src/utils/index.js +8 -3
@@ -32,29 +32,38 @@ class LayoutEngine {
32
32
  /** [내부함수] 구독 설정 */
33
33
  _setupSubscriptions() {
34
34
  // 초기화 완료 이벤트 구독 - from EngineManager
35
- this._subscribe('system:engineInitialized', () => {});
36
-
37
- this._subscribe('system:enginesReset', () => {
38
- this.reset();
39
- });
35
+ // this._subscribe('system:engineInitialized', () => {});
36
+
37
+ this._subscribe('system:updateActiveSectionConfig', ({ $section, changes }) => {
38
+ Object.keys(changes).forEach((key) => {
39
+ if (!(key in this.layoutData[$section])) {
40
+ if (key == 'elementIds') {
41
+ this.layoutData[$section][key] = [];
42
+ } else {
43
+ this.layoutData[$section][key] = null;
44
+ }
45
+ }
46
+ });
40
47
 
41
- this._subscribe('system:updateActiveSectionConfig', ({ layoutData }) => {
42
- this.layoutData = layoutData;
43
- // Object.assign(this.layoutData, layoutData);
44
- });
48
+ // 원본 데이터 업데이트
49
+ this.layoutData[$section] = {
50
+ ...this.layoutData[$section],
51
+ ...changes,
52
+ };
45
53
 
46
- this._subscribe('system:requestUpdateData', ({ layoutData, activeData, elements, activeSection }) => {
47
- this.layoutData = layoutData;
54
+ const activeData = this.layoutData[$section];
48
55
 
49
- this.eventBus.emit('layout:requestUpdateData', {
50
- layoutData: cloneDeep(this.layoutData),
51
- activeData: activeData,
52
- elements: elements,
53
- activeSection: activeSection,
56
+ this.eventBus.emit('layout:updateLayoutData', {
57
+ $layoutData: this.layoutData,
58
+ $section: $section,
59
+ $mode: activeData?.mode,
60
+ $config: activeData?.config,
61
+ timestamp: Date.now(),
54
62
  });
55
63
  });
56
64
 
57
65
  this._subscribe('system:restoredState', ({ stateData }) => {
66
+ if (!stateData?.layoutData) return;
58
67
  Object.assign(this.layoutData, stateData.layoutData);
59
68
  });
60
69
  }
@@ -76,6 +85,8 @@ class LayoutEngine {
76
85
  }
77
86
  });
78
87
 
88
+ this.reset();
89
+
79
90
  this._subscriptions = [];
80
91
  this.eventBus = null;
81
92
  this.resource = null;
@@ -170,21 +181,23 @@ class LayoutEngine {
170
181
  // 초기 설정인 경우 설정값 전파
171
182
  if (screenConfig) {
172
183
  this.eventBus.emit('layout:setLayoutName', {
173
- screenConfig: cloneDeep(screenConfig),
174
- gridNumber: cloneDeep(this.gridNumber),
175
- gridRatio: cloneDeep(this.gridRatio),
184
+ $screenConfig: screenConfig,
185
+ $layoutData: this.layoutData,
186
+ $gridNumber: this.gridNumber,
187
+ $gridRatio: this.gridRatio,
176
188
  timestamp: Date.now(),
177
189
  });
178
- }
190
+ }
179
191
  // 그 외 레이아웃 변경인 경우 레이아웃 정보 전파
180
192
  else {
181
193
  this.eventBus.emit('layout:updateLayoutName', {
182
- layoutName: this.layoutName,
183
- layoutData: cloneDeep(this.layoutData),
184
- gridNumber: cloneDeep(this.gridNumber),
185
- gridRatio: cloneDeep(this.gridRatio),
186
- timestamp: Date.now(),
187
- });
194
+ $layoutName: this.layoutName,
195
+ $layoutData: this.layoutData,
196
+ $gridNumber: this.gridNumber,
197
+ $gridRatio: this.gridRatio,
198
+ $gapSize: this.gapSize,
199
+ timestamp: Date.now(),
200
+ });
188
201
  }
189
202
  }
190
203
 
@@ -197,27 +210,17 @@ class LayoutEngine {
197
210
 
198
211
  const newLayoutData = cloneDeep(this.resource[name].sections);
199
212
 
200
- // userData 있는 경우 우선 병합
201
- if (userData) {
202
- Object.keys(newLayoutData).forEach((sectionKey) => {
203
- if (userData[sectionKey]) {
204
- newLayoutData[sectionKey] = { ...newLayoutData[sectionKey], ...userData[sectionKey] };
205
- }
206
- });
207
- }
208
- // 기존 데이터 있는 경우 병합
209
- else if (this.layoutData) {
210
- {
211
- Object.keys(newLayoutData).forEach((sectionKey) => {
212
- if (this.layoutData[sectionKey]) {
213
- newLayoutData[sectionKey] = {
214
- ...newLayoutData[sectionKey],
215
- ...this.layoutData[sectionKey],
216
- };
217
- }
218
- });
213
+ // userData 있는 경우 우선 병합 - 기존 데이터 유지하면서 userData로 덮어쓰기
214
+ const mergeSource = userData || this.layoutData;
215
+
216
+ Object.keys(newLayoutData).forEach((sectionKey) => {
217
+ if (mergeSource[sectionKey]) {
218
+ newLayoutData[sectionKey] = {
219
+ ...newLayoutData[sectionKey],
220
+ ...mergeSource[sectionKey],
221
+ };
219
222
  }
220
- }
223
+ });
221
224
 
222
225
  this.layoutData = newLayoutData;
223
226
  }
@@ -236,18 +239,26 @@ class LayoutEngine {
236
239
  this.gridRatio.column = gridRatio.column;
237
240
  } else {
238
241
  this.gridRatio.column = columnNumber === 1 ? [100] : Array(columnNumber).fill(Math.floor(100 / columnNumber));
242
+
243
+ if (columnNumber === 3) {
244
+ this.gridRatio.column[2] = 100 - this.gridRatio.column[0] - this.gridRatio.column[1];
245
+ }
239
246
  }
240
247
 
241
248
  if (gridRatio?.row) {
242
249
  this.gridRatio.row = gridRatio.row;
243
250
  } else {
244
251
  this.gridRatio.row = rowNumber === 1 ? [100] : Array(rowNumber).fill(Math.floor(100 / rowNumber));
252
+
253
+ if (rowNumber === 3) {
254
+ this.gridRatio.row[2] = 100 - this.gridRatio.row[0] - this.gridRatio.row[1];
255
+ }
245
256
  }
246
257
 
247
258
  this.gridNumber.column = columnNumber;
248
259
  this.gridNumber.row = rowNumber;
249
260
 
250
- if (gapSize) {
261
+ if (gapSize != null) {
251
262
  this.gapSize = gapSize;
252
263
  }
253
264
  }
@@ -256,10 +267,12 @@ class LayoutEngine {
256
267
  * @param {number} size - 새로운 갭 사이즈
257
268
  */
258
269
  setGapSize(size) {
270
+ if (Number(size) < 0 || isNaN(Number(size))) return;
271
+
259
272
  this.gapSize = size;
260
273
 
261
274
  this.eventBus.emit('layout:updateGapSize', {
262
- gapSize: this.gapSize,
275
+ $gapSize: this.gapSize,
263
276
  timestamp: Date.now(),
264
277
  });
265
278
  }
@@ -270,7 +283,7 @@ class LayoutEngine {
270
283
  * @param {number} ratio - 새로운 비율 값
271
284
  */
272
285
  setRatio(type, index, ratio) {
273
- const ratioArray = type === 'column' ? this.gridRatio.column : this.gridRatio.row;
286
+ const ratioArray = this.gridRatio[type];
274
287
  ratioArray[index] = Number(ratio);
275
288
 
276
289
  const totalWithout = ratioArray.reduce((sum, val, idx) => {
@@ -283,34 +296,42 @@ class LayoutEngine {
283
296
  }
284
297
 
285
298
  const total = totalWithout + ratioArray[index];
299
+ const result = { result: true, message: '비율이 성공적으로 변경되었습니다.' };
300
+
286
301
  if (total == 100) {
287
- return;
288
- } else {
289
- if (ratioArray.length == 2) {
290
- index == 0 ? (ratioArray[1] = 100 - ratioArray[0]) : (ratioArray[0] = 100 - ratioArray[1]);
291
- } else if (ratioArray.length == 3) {
292
- const remaining = 100 - total;
293
- if (remaining < 0) {
294
- alert('비율의 합은 100을 초과할 수 없습니다.');
295
- }
302
+ return result;
303
+ }
304
+
305
+ if (ratioArray.length == 2) {
306
+ index == 0 ? (ratioArray[1] = 100 - ratioArray[0]) : (ratioArray[0] = 100 - ratioArray[1]);
307
+ } else if (ratioArray.length == 3) {
308
+ const remaining = 100 - total;
309
+ if (remaining < 0) {
310
+ result.result = false;
311
+ result.message = '비율의 합은 100을 초과할 수 없습니다.';
312
+ }
296
313
 
297
- if (index == 2) {
298
- ratioArray[0] = remaining < 0 ? ratioArray[0] + remaining : ratioArray[0] - remaining;
299
- } else {
300
- ratioArray[index + 1] = remaining < 0 ? ratioArray[index + 1] + remaining : ratioArray[index + 1] - remaining;
314
+ if (index == 2) {
315
+ ratioArray[0] = ratioArray[0] - Math.abs(remaining);
316
+ } else {
317
+ ratioArray[index + 1] = ratioArray[index + 1] - Math.abs(remaining);
318
+
319
+ if (ratioArray[index + 1] < 0) {
320
+ ratioArray[index + 1] = 0;
321
+ ratioArray[2] = 100 - ratioArray[0] - ratioArray[1];
301
322
  }
302
323
  }
303
324
  }
304
- if (type === 'column') {
305
- this.gridRatio.column = ratioArray;
306
- } else if (type === 'row') {
307
- this.gridRatio.row = ratioArray;
308
- }
325
+
326
+ this.gridRatio[type] = ratioArray;
309
327
 
310
328
  this.eventBus.emit('layout:updateRatio', {
311
- gridRatio: cloneDeep(this.gridRatio),
329
+ $type: type,
330
+ $gridRatio: this.gridRatio,
312
331
  timestamp: Date.now(),
313
332
  });
333
+
334
+ return result;
314
335
  }
315
336
  }
316
337