@wipco/sdui-editor 0.4.0 → 0.4.1

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 (2) hide show
  1. package/dist/index.js +40 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2569,6 +2569,20 @@ function resizePlanOf(node, catalog) {
2569
2569
  }
2570
2570
  return { kind: "style", axis: resize.axis ?? "both", label: styleLabel(node) };
2571
2571
  }
2572
+ var SPACE_SCALE = [4, 8, 12, 16, 20, 24, 32];
2573
+ var COARSE_STEP = 8;
2574
+ function snapToScale(value) {
2575
+ const last = SPACE_SCALE[SPACE_SCALE.length - 1];
2576
+ if (value > last) return Math.max(last, Math.round(value / COARSE_STEP) * COARSE_STEP);
2577
+ let best = SPACE_SCALE[0];
2578
+ for (const step of SPACE_SCALE) {
2579
+ if (Math.abs(step - value) < Math.abs(best - value)) best = step;
2580
+ }
2581
+ return best;
2582
+ }
2583
+ function sized(value, free) {
2584
+ return Math.max(1, free ? Math.round(value) : snapToScale(value));
2585
+ }
2572
2586
  function currentEnum(node, prop, values, catalog) {
2573
2587
  const raw = node.props[prop];
2574
2588
  const asText = raw === void 0 || raw === null ? void 0 : String(raw);
@@ -2599,7 +2613,7 @@ function styleLabel(node) {
2599
2613
  const h = typeof style.height === "string" ? style.height : "\uC790\uB3D9";
2600
2614
  return `${w} \xD7 ${h}`;
2601
2615
  }
2602
- function resizePatch(start, startRect, dx, dy, catalog) {
2616
+ function resizePatch(start, startRect, dx, dy, catalog, free = false) {
2603
2617
  const meta = getComponentMeta(start.component, catalog);
2604
2618
  if (!meta) return null;
2605
2619
  const { resize } = meta;
@@ -2617,12 +2631,12 @@ function resizePatch(start, startRect, dx, dy, catalog) {
2617
2631
  if (resize.widthProp && resize.widthProp === resize.heightProp && resize.unit !== "row") {
2618
2632
  const delta = Math.abs(dx) >= Math.abs(dy) ? dx : dy;
2619
2633
  const base = numberProp(start, resize.widthProp, startRect.width, catalog);
2620
- patch[resize.widthProp] = Math.max(1, Math.round(base + delta));
2634
+ patch[resize.widthProp] = sized(base + delta, free);
2621
2635
  return sameAsNow(start, patch) ? null : patch;
2622
2636
  }
2623
2637
  if (resize.widthProp) {
2624
2638
  const base = numberProp(start, resize.widthProp, startRect.width, catalog);
2625
- patch[resize.widthProp] = Math.max(1, Math.round(base + dx));
2639
+ patch[resize.widthProp] = sized(base + dx, free);
2626
2640
  }
2627
2641
  if (resize.heightProp) {
2628
2642
  if (resize.unit === "row") {
@@ -2631,7 +2645,7 @@ function resizePatch(start, startRect, dx, dy, catalog) {
2631
2645
  patch[resize.heightProp] = Math.max(1, Math.round(rows + dy / rowPx));
2632
2646
  } else {
2633
2647
  const base = numberProp(start, resize.heightProp, startRect.height, catalog);
2634
- patch[resize.heightProp] = Math.max(1, Math.round(base + dy));
2648
+ patch[resize.heightProp] = sized(base + dy, free);
2635
2649
  }
2636
2650
  }
2637
2651
  return sameAsNow(start, patch) ? null : patch;
@@ -3354,7 +3368,9 @@ function Canvas({
3354
3368
  rect,
3355
3369
  axis === "y" ? 0 : move_.clientX - startX,
3356
3370
  axis === "x" ? 0 : move_.clientY - startY,
3357
- catalog
3371
+ catalog,
3372
+ // Shift = 디자인 척도 스냅 해제. 매 이동마다 읽어야 드래그 중간에 눌러도 먹는다.
3373
+ move_.shiftKey
3358
3374
  );
3359
3375
  if (!patch) return;
3360
3376
  const result = setProps(docRef.current, id, patch);
@@ -8946,9 +8962,19 @@ function useShellWidth() {
8946
8962
  var SHELL_STYLE_ID = "sdui-editor-builder-shell";
8947
8963
  var SHELL_CSS = `
8948
8964
  /* \uC178\uC744 \uC549\uD788\uB294 \uC790\uB9AC. EditorView\uC758 .sdui-editor-split\uACFC \uAC19\uC740 \uC131\uC9C8\uC744 \uAC16\uAC8C \uB9DE\uCDC4\uB2E4 \u2014
8949
- \uBD80\uBAA8 \uB192\uC774\uAC00 auto\uC5EC\uB3C4 \uCE94\uBC84\uC2A4\uAC00 \uC4F8 \uB9CC\uD55C \uD06C\uAE30\uB97C \uAC16\uB294\uB2E4. */
8965
+ \uBD80\uBAA8 \uB192\uC774\uAC00 auto\uC5EC\uB3C4 \uCE94\uBC84\uC2A4\uAC00 \uC4F8 \uB9CC\uD55C \uD06C\uAE30\uB97C \uAC16\uB294\uB2E4.
8966
+ *
8967
+ * 'min-height'\uB9CC \uC788\uACE0 \uC704\uCABD \uD55C\uACC4\uAC00 \uC5C6\uC5C8\uB2E4. \uBD80\uBAA8\uAC00 \uB192\uC774\uB97C \uC548 \uBB36\uC73C\uBA74 '70vh'\uC5D0 \uBA48\uCDB0\uC11C,
8968
+ * \uC2E4\uCE21(\uBDF0\uD3EC\uD2B8 900\xB7ERP \uC178 \uC548)\uC5D0\uC11C \uBE4C\uB354\uAC00 630px\uC5D0 \uBA38\uBB3C\uACE0 \uADF8 \uC548\uC5D0\uC11C \uD314\uB808\uD2B8\uAC00 **177px**\uB9CC
8969
+ * \uBC1B\uC558\uB2E4 \u2014 \uC5B4\uD718 69\uC885 \uC911 \uB124 \uAC1C\uAC00 \uBCF4\uC774\uB294 \uD654\uBA74\uC774\uB2E4. \uC2A4\uD06C\uB864\uC740 \uB418\uC9C0\uB9CC "\uC798\uB838\uB2E4"\uACE0 \uB290\uB07C\uB294
8970
+ * \uAC83\uC774 \uB2F9\uC5F0\uD558\uB2E4.
8971
+ *
8972
+ * \uADF8\uB798\uC11C \uBD80\uBAA8\uAC00 \uB192\uC774\uB97C \uC8FC\uBA74 \uADF8\uAC83\uC744 \uCC44\uC6B0\uACE0('height: 100%'), \uC548 \uC8FC\uBA74 \uC885\uC804\uB300\uB85C 'min-height'\uAC00
8973
+ * \uBC14\uB2E5\uC744 \uBC1B\uCE5C\uB2E4. \uC9E7\uC740 \uCC3D\uC5D0\uC11C\uB294 480px \uC544\uB798\uB85C \uB20C\uB9AC\uC9C0 \uC54A\uACE0 \uBC14\uAE65 \uBB38\uC11C\uAC00 \uC2A4\uD06C\uB864\uD55C\uB2E4 \u2014
8974
+ * \uB124 \uCE78\uC744 \uC5B5\uC9C0\uB85C \uC6B1\uC5EC\uB123\uC5B4 \uC804\uBD80 \uBABB \uC4F0\uAC8C \uB9CC\uB4DC\uB294 \uAC83\uBCF4\uB2E4 \uB0AB\uB2E4. */
8950
8975
  .sdui-editor-builder-host {
8951
- flex: 1; display: flex; min-height: clamp(480px, 70vh, 900px);
8976
+ flex: 1; display: flex; height: 100%;
8977
+ min-height: clamp(480px, 70vh, 900px);
8952
8978
  }
8953
8979
  .sdui-editor-builder-host > * { flex: 1; min-width: 0; }
8954
8980
 
@@ -8984,7 +9010,8 @@ var SHELL_CSS = `
8984
9010
  .sdui-bv__body { flex: 1; min-height: 0; display: flex; align-items: stretch; }
8985
9011
 
8986
9012
  .sdui-bv__left {
8987
- flex: none; width: var(--sdui-bv-left); min-width: 0;
9013
+ /* min-height:0 \uC774 \uC5C6\uC73C\uBA74 flex \uCE7C\uB7FC\uC758 \uC790\uC2DD\uC774 \uB0B4\uC6A9 \uD06C\uAE30 \uC544\uB798\uB85C \uBABB \uC904\uC5B4 \uBC30\uBD84\uC744 \uB118\uC5B4 \uC790\uB780\uB2E4. */
9014
+ flex: none; width: var(--sdui-bv-left); min-width: 0; min-height: 0;
8988
9015
  display: flex; flex-direction: column;
8989
9016
  border-right: var(--wp-border-w) solid var(--wp-border-subtle);
8990
9017
  }
@@ -8992,9 +9019,12 @@ var SHELL_CSS = `
8992
9019
  .sdui-bv__pane > * { min-width: 0; width: 100%; }
8993
9020
  /* \uD314\uB808\uD2B8\uC640 \uD2B8\uB9AC\uAC00 \uC138\uB85C\uB97C \uB098\uB220 \uC4F4\uB2E4. \uD2B8\uB9AC\uB97C \uC870\uAE08 \uB354 \uC900 \uAC83\uC740 \uC2E4\uCE21 \uC911\uCCA9\uC774 \uCD5C\uB300 14\uB2E8\uACC4\uB77C
8994
9021
  \uD589\uC774 \uAE08\uBC29 \uAE38\uC5B4\uC9C0\uAE30 \uB54C\uBB38\uC774\uB2E4. */
8995
- .sdui-bv__pane--palette { flex: 4 1 0; }
9022
+ /* \uD314\uB808\uD2B8 4 : \uD2B8\uB9AC 5 \uC600\uB2E4. \uD2B8\uB9AC\uB294 \uC811\uACE0 \uD3BC\uCE58\uB294 \uAD6C\uC870\uB77C \uC9E7\uC544\uB3C4 \uC6D0\uD558\uB294 \uAC00\uC9C0\uB97C \uCC3E\uC544\uAC08 \uC218
9023
+ \uC788\uC9C0\uB9CC, \uD314\uB808\uD2B8\uB294 69\uC885\uC744 \uD6D1\uC5B4 \uACE0\uB974\uB294 \uC790\uB9AC\uB77C \uC9E7\uC73C\uBA74 \uADF8\uB9CC\uD07C \uBABB \uC4F4\uB2E4. 5:4\uB85C \uB4A4\uC9D1\uC5C8\uB2E4.
9024
+ \uB458 \uB2E4 \uC790\uAE30 \uC2A4\uD06C\uB864\uC774 \uC788\uC5B4('__body'\xB7'__rows') \uC5B4\uB290 \uCABD\uB3C4 \uC798\uB9AC\uC9C0\uB294 \uC54A\uB294\uB2E4. */
9025
+ .sdui-bv__pane--palette { flex: 5 1 0; min-height: 0; }
8996
9026
  .sdui-bv__pane--tree {
8997
- flex: 5 1 0;
9027
+ flex: 4 1 0; min-height: 0;
8998
9028
  border-top: var(--wp-border-w) solid var(--wp-border-subtle);
8999
9029
  }
9000
9030
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wipco/sdui-editor",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "SDUI 페이지 스펙 편집기 — 소비 프로젝트가 자기 라우트에 마운트하는 React 컴포넌트",
5
5
  "keywords": [
6
6
  "sdui",