polarvo-layout 1.0.78 → 1.0.80

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.78",
3
+ "version": "1.0.80",
4
4
  "type": "module",
5
5
  "author": "unigence <unigencelab@gmail.com>",
6
6
  "repository": {
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div
3
3
  :id="preview ? 'previewLayout' : 'baseLayout'"
4
- class="grid h-full p-2 bg-transparent rounded-lg"
4
+ class="grid h-full p-[10px] bg-transparent rounded-lg"
5
5
  :class="[layoutType + '-layout', `grid-cols-${gridNumber?.column}`, { 'mb-4': layoutType === 'three-column-split' }]"
6
6
  :style="getBaseStyle"
7
7
  @contextmenu.prevent
@@ -26,7 +26,7 @@ const props = defineProps({
26
26
  const DEFAULT_DISPLAY_SIZE = {
27
27
  px: 1200,
28
28
  percent: 100,
29
- gridSize: 16,
29
+ gridSize: 10,
30
30
  aspectRatio: '16/9',
31
31
  };
32
32
 
@@ -74,7 +74,7 @@ const containerStyle = computed(() => {
74
74
  linear-gradient(90deg, rgba(0,0,0,0.05) 1px, transparent 1px)
75
75
  `,
76
76
  backgroundSize: `${DEFAULT_DISPLAY_SIZE.gridSize}px ${DEFAULT_DISPLAY_SIZE.gridSize}px`,
77
- backgroundPosition: '8px 8px', // BaseLayout의 p-2(8px)와 맞춰 좌상단 기준으로 정렬
77
+ backgroundPosition: '10px 10px', // BaseLayout의 p-[10px]와 맞춰 좌상단 기준으로 정렬 (gridSize와 무관한 고정값)
78
78
  };
79
79
  }
80
80
 
@@ -90,7 +90,7 @@ const containerStyle = computed(() => {
90
90
  linear-gradient(90deg, rgba(0,0,0,0.05) 1px, transparent 1px)
91
91
  `,
92
92
  backgroundSize: `${displaySize.value.gridSize}px ${displaySize.value.gridSize}px`,
93
- backgroundPosition: '8px 8px', // BaseLayout의 p-2(8px)와 맞춰 좌상단 기준으로 정렬
93
+ backgroundPosition: '10px 10px', // BaseLayout의 p-[10px]와 맞춰 좌상단 기준으로 정렬 (gridSize와 무관한 고정값)
94
94
  };
95
95
  });
96
96
  </script>
@@ -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="sectionMode == 'free' ? addElementToFree($event, item) : addElementToGrid(item)"
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
 
@@ -7,7 +7,7 @@ import MobileIcon from '../../icons/display/MobileIcon.vue';
7
7
 
8
8
  export const displayResource = (icon = {}) => ({
9
9
  desktop: {
10
- gridSize: 16,
10
+ gridSize: 10,
11
11
  aspectRatio: '16/9',
12
12
  defaultWidth: 1200,
13
13
  icon: markRaw(icon.DesktopIcon || DesktopIcon),
@@ -9,7 +9,7 @@ const DISPLAY_LIMITS = {
9
9
  const DEFAULT_DISPLAY_SIZE = {
10
10
  px: 1200,
11
11
  percent: 100,
12
- gridSize: 16,
12
+ gridSize: 10,
13
13
  aspectRatio: '16/9',
14
14
  };
15
15
 
@@ -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');
@@ -541,22 +542,15 @@ class FreeDropEngine {
541
542
  const rawX = event.clientX - layoutRect.left - offsetPos.x;
542
543
  const rawY = event.clientY - layoutRect.top - offsetPos.y;
543
544
 
544
- // const maxX = layoutRect.width - this._activeElement.size.w;
545
- // const maxY = layoutRect.height - this._activeElement.size.h;
545
+ // grid snap을 먼저 적용한 경계로 clamp해야 함
546
+ // (clamp 후 snap하면 반올림으로 인해 경계값(maxX/maxY, grid 배수가 아님)보다 커질 수 있어
547
+ // 우측/하단 경계를 넘어가는 문제가 발생함)
548
+ const gridX = this._snapToGrid(rawX);
549
+ const gridY = this._snapToGrid(rawY);
546
550
 
547
- // // 클램핑: 경계 밖으로 나가도 경계에서 멈추고 마우스를 계속 추적
548
- // const clampedX = Math.min(Math.max(0, rawX), maxX);
549
- // const clampedY = Math.min(Math.max(0, rawY), maxY);
551
+ const clamped = this._clampToLayoutBounds(gridX, gridY, layoutRect);
550
552
 
551
- const clamped = this._clampToLayoutBounds(rawX, rawY, layoutRect);
552
-
553
- // const gridX = this._snapToGrid(rawX);
554
- // const gridY = this._snapToGrid(rawY);
555
-
556
- const gridX = this._snapToGrid(clamped.x);
557
- const gridY = this._snapToGrid(clamped.y);
558
-
559
- return { x: gridX, y: gridY };
553
+ return { x: clamped.x, y: clamped.y };
560
554
  }
561
555
 
562
556
  /** [내부함수] 새로운 크기와 위치 계산
@@ -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[index] = element; // 업데이트
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');