polarvo-layout 1.0.70 → 1.0.72

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.70",
3
+ "version": "1.0.72",
4
4
  "type": "module",
5
5
  "author": "unigence <unigencelab@gmail.com>",
6
6
  "repository": {
@@ -71,8 +71,8 @@ const { layoutName, layoutData, activeSection, gapSize, gridNumber, gridRatio }
71
71
 
72
72
  const getBaseStyle = computed(() => {
73
73
  return {
74
- gridTemplateColumns: gridRatio.value?.column.map((ratio) => `${ratio}%`).join(' '),
75
- gridTemplateRows: gridRatio.value?.row.map((ratio) => `${ratio}%`).join(' '),
74
+ gridTemplateColumns: gridRatio.value?.column.map((ratio) => `${ratio}fr`).join(' '),
75
+ gridTemplateRows: gridRatio.value?.row.map((ratio) => `${ratio}fr`).join(' '),
76
76
  marginRight: layoutType.value === 'no-split' ? '0' : layoutType.value === 'three-column-split' ? '14px' : '8px',
77
77
  gap: `${gapSize.value}px`,
78
78
  };
@@ -23,32 +23,20 @@ export const elementResource = {
23
23
  w: 300,
24
24
  h: 200,
25
25
  },
26
- basicCalendar: {
27
- w: 300,
28
- h: 280,
29
- },
30
- basicPagination: {
31
- w: 150,
32
- h: 40,
33
- },
34
- basicRadio: {
35
- w: 120,
36
- h: 40,
37
- },
38
- basicSearch: {
39
- w: 260,
40
- h: 40,
26
+ email: {
27
+ w: 480,
28
+ h: 580,
41
29
  },
42
- basicTable: {
43
- w: 240,
44
- h: 120,
30
+ fax: {
31
+ w: 440,
32
+ h: 420,
45
33
  },
46
- basicTextbox: {
47
- w: 200,
48
- h: 80,
34
+ colorMake: {
35
+ w: 960,
36
+ h: 600,
49
37
  },
50
- basicToggle: {
51
- w: 120,
52
- h: 40,
38
+ dyeMaker: {
39
+ w: 860,
40
+ h: 620,
53
41
  },
54
42
  };
@@ -226,7 +226,9 @@ class FreeDropEngine {
226
226
  if (this._elementsUpdate) {
227
227
  this._elementsUpdate = false;
228
228
 
229
- const base = this._elements.filter((x) => x.mode === 'free');
229
+ // mode 관계없이 모든 요소 렌더링
230
+ // const base = this._elements.filter((x) => x.mode === 'free');
231
+ const base = this._elements;
230
232
 
231
233
  if (this._activeElement) {
232
234
  const exists = base.find((x) => x.id === this._activeElement?.id);
@@ -384,6 +386,29 @@ class FreeDropEngine {
384
386
  }
385
387
 
386
388
  /** ---------------------------------- 배치요소 관련 메소드 ---------------------------------- **/
389
+ getCurrentPosition() {
390
+ const currentElements = this.freeElements.filter((x) => x.section === this._activeSection);
391
+ if (!currentElements?.length) return { col: 1, row: 1 };
392
+
393
+ let lastRow = 0;
394
+ let lastCol = 0;
395
+
396
+ for (const element of currentElements) {
397
+ const endRow = element?.position.row + element?.size.rowSpan - 1;
398
+ const endCol = element?.position.col + element?.size.colSpan - 1;
399
+
400
+ // 최대 행 위치보다 크거나 같은 행에서 열 위치가 더 큰 경우 업데이트
401
+ if (endRow > lastRow || (endRow === lastRow && endCol > lastCol)) {
402
+ lastRow = endRow;
403
+ lastCol = endCol;
404
+ }
405
+ }
406
+
407
+ const { gridColumns = 2 } = this._activeConfig ?? {};
408
+ // 마지막 행의 최대 열 위치가 columnCount 이상이면 다음 행으로 이동
409
+ return lastCol >= gridColumns ? { col: 1, row: lastRow + 1 } : { col: lastCol + 1, row: lastRow };
410
+ }
411
+
387
412
  /** 배치요소 신규 추가 - 메뉴에서 추가 아이템 선택
388
413
  * @param {MouseEvent} event - 마우스 이벤트
389
414
  * @param {object} item - 추가할 아이템 정보
@@ -395,12 +420,15 @@ class FreeDropEngine {
395
420
  this._startPos = { x: event.clientX, y: event.clientY };
396
421
 
397
422
  const elementSource = this.getResourceByName('elements');
423
+
398
424
  const element = {
399
425
  id: elName + '_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 7),
400
426
  type: elName,
401
427
  mode: 'free',
402
- position: this._startPos,
403
- size: elementSource[elName] || { w: 100, h: 100 },
428
+ // position: this._startPos,
429
+ position: { ...this.getCurrentPosition(), ...this._startPos },
430
+ // size: elementSource[elName] || { w: 100, h: 100 },
431
+ size: { ...(elementSource[elName] || { w: 100, h: 100 }), colSpan: 1, rowSpan: 1 },
404
432
  section: this._activeSection,
405
433
  isLocked: false,
406
434
  ...(item.propDefaults || {}), // 아이템의 기본 props 설정
@@ -178,7 +178,9 @@ class GridDropEngine {
178
178
  if (this._elementsUpdate) {
179
179
  this._elementsUpdate = false;
180
180
 
181
- const base = this._elements.filter((x) => x.mode === 'grid');
181
+ // mode 관계없이 모든 요소 렌더링
182
+ // const base = this._elements.filter((x) => x.mode === 'grid');
183
+ const base = this._elements;
182
184
 
183
185
  if (this._activeElement) {
184
186
  const exists = base.find((x) => x.id === this._activeElement?.id);
@@ -347,13 +349,16 @@ class GridDropEngine {
347
349
  if (this._activeMode !== 'grid') return;
348
350
 
349
351
  const elName = item.elName;
352
+ const elementSource = this.elementResource;
350
353
 
351
354
  const element = {
352
355
  id: elName + '_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 7),
353
356
  type: elName,
354
357
  mode: 'grid',
355
- position: { ...this._dragState.activeCell },
356
- size: { colSpan: 1, rowSpan: 1 },
358
+ // position: { ...this._dragState.activeCell },
359
+ position: { x: 0, y: 0, ...this._dragState.activeCell },
360
+ // size: { colSpan: 1, rowSpan: 1 },
361
+ size: { ...(elementSource[elName] || { w: 100, h: 100 }), colSpan: 1, rowSpan: 1 },
357
362
  section: this._activeSection,
358
363
  isLocked: false,
359
364
  ...(item.propDefaults || {}), // 아이템의 기본 props 설정
@@ -384,7 +384,7 @@ class EngineManager {
384
384
  * @param {string} type - 'column' | 'row'
385
385
  * @param {object} oldValue - 변경 전 gridRatio ({ column, row })
386
386
  * @param {object} newValue - 변경 후 gridRatio ({ column, row })
387
- * @param {object} oldLayoutData - 변경 전 layoutData.
387
+ * @param {object} oldLayoutData - 변경 전 layoutData.
388
388
  * 생략 시: 섹션 비율만 조정하는 경우
389
389
  * 레이아웃 자체가 바뀌는 호출은 변경 전 layoutData를 넘겨야 함
390
390
  */
@@ -408,7 +408,6 @@ class EngineManager {
408
408
  return ratios.slice(start, start + span).reduce((sum, v) => sum + v, 0) / 100;
409
409
  };
410
410
 
411
-
412
411
  this.state.elements = this.state.elements.map((el) => {
413
412
  const oldPos = oldLayoutData?.[el.section]?.layoutPosition; // 변경 전 요소의 섹션 위치
414
413
  const newPos = this.state.layoutData?.[el.section]?.layoutPosition; // 변경 후 요소의 섹션 위치
@@ -454,23 +453,34 @@ class EngineManager {
454
453
  }
455
454
 
456
455
  if (!this.activeData || this.activeData.mode === mode) return;
456
+ // mode 관계없이 모든 요소 렌더링
457
457
  const updates = {
458
458
  mode: mode,
459
- elementIds: this.state.elements.filter((x) => x.section === this.state.activeSection && x.mode === mode).map((x) => x.id),
459
+ elementIds: this.state.elements.filter((x) => x.section === this.state.activeSection).map((x) => x.id),
460
+ // elementIds: this.state.elements.filter((x) => x.section === this.state.activeSection && x.mode === mode).map((x) => x.id),
460
461
  };
461
462
 
462
- if (mode === 'grid') {
463
+ // if (mode === 'grid') {
464
+ // updates.config = {
465
+ // gridColumns: this.activeData.config?.gridColumns || 2,
466
+ // gridRows: this.activeData.config?.gridRows || 2,
467
+ // gridGap: this.activeData.config?.gridGap || 4,
468
+ // gridRowRatio: this.activeData.config?.gridRowRatio || [],
469
+ // gridColumnRatio: this.activeData.config?.gridColumnRatio || [],
470
+ // };
471
+ // } else if (mode === 'free') {
472
+ // updates.config = {
473
+ // showGuideLine: this.activeData.config?.showGuideLine || false,
474
+ // };
475
+ // }
476
+
463
477
  updates.config = {
464
478
  gridColumns: this.activeData.config?.gridColumns || 2,
465
479
  gridRows: this.activeData.config?.gridRows || 2,
466
480
  gridGap: this.activeData.config?.gridGap || 4,
467
481
  gridRowRatio: this.activeData.config?.gridRowRatio || [],
468
482
  gridColumnRatio: this.activeData.config?.gridColumnRatio || [],
469
- };
470
- } else if (mode === 'free') {
471
- updates.config = {
472
483
  showGuideLine: this.activeData.config?.showGuideLine || false,
473
- };
474
484
  }
475
485
 
476
486
  this._updateActiveSectionConfig('mode', updates);
@@ -556,7 +566,11 @@ class EngineManager {
556
566
 
557
567
  this.state.elements.push(element);
558
568
  const targetSectionData = this.state.layoutData?.[element.section];
559
- this._updateActiveSectionConfig('elementIds', { elementIds: [...(targetSectionData?.elementIds || []), element.id] }, element.section);
569
+ this._updateActiveSectionConfig(
570
+ 'elementIds',
571
+ { elementIds: [...(targetSectionData?.elementIds || []), element.id] },
572
+ element.section,
573
+ );
560
574
 
561
575
  this.eventBus.emit('system:requestUpdateElement', {
562
576
  action: 'add',
@@ -576,9 +590,13 @@ class EngineManager {
576
590
  const target = this.state.elements.find((el) => el.id === elementId);
577
591
  this.state.elements = this.state.elements.filter((el) => el.id !== elementId);
578
592
  const targetSectionData = this.state.layoutData?.[target?.section];
579
- this._updateActiveSectionConfig('elementIds', {
580
- elementIds: (targetSectionData?.elementIds || []).filter((elId) => elId !== elementId),
581
- }, target?.section);
593
+ this._updateActiveSectionConfig(
594
+ 'elementIds',
595
+ {
596
+ elementIds: (targetSectionData?.elementIds || []).filter((elId) => elId !== elementId),
597
+ },
598
+ target?.section,
599
+ );
582
600
  // this._updateActiveElementIds(this.activeData.elementIds.filter((elId) => elId !== elementId));
583
601
 
584
602
  this.eventBus.emit('system:requestUpdateElement', {
@@ -630,7 +648,11 @@ class EngineManager {
630
648
 
631
649
  this.state.elements.push(element);
632
650
  const targetSectionData = this.state.layoutData?.[element.section];
633
- this._updateActiveSectionConfig('elementIds', { elementIds: [...(targetSectionData?.elementIds || []), element.id] }, element.section);
651
+ this._updateActiveSectionConfig(
652
+ 'elementIds',
653
+ { elementIds: [...(targetSectionData?.elementIds || []), element.id] },
654
+ element.section,
655
+ );
634
656
  // this._updateActiveElementIds([...this.activeData.elementIds, element.id]);
635
657
 
636
658
  this.eventBus.emit('system:requestUpdateElement', {
@@ -651,9 +673,13 @@ class EngineManager {
651
673
  const target = this.state.elements.find((el) => el.id === elementId);
652
674
  this.state.elements = this.state.elements.filter((el) => el.id !== elementId);
653
675
  const targetSectionData = this.state.layoutData?.[target?.section];
654
- this._updateActiveSectionConfig('elementIds', {
655
- elementIds: (targetSectionData?.elementIds || []).filter((elId) => elId !== elementId),
656
- }, target?.section);
676
+ this._updateActiveSectionConfig(
677
+ 'elementIds',
678
+ {
679
+ elementIds: (targetSectionData?.elementIds || []).filter((elId) => elId !== elementId),
680
+ },
681
+ target?.section,
682
+ );
657
683
  // this._updateActiveElementIds(this.activeData.elementIds.filter((elId) => elId !== elementId));
658
684
 
659
685
  this.eventBus.emit('system:requestUpdateElement', {