@moda-grid/vue2 2.2.0 → 2.2.3

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/dist/DataGrid.vue CHANGED
@@ -41,6 +41,7 @@ import {
41
41
  leafHasChildren,
42
42
  leafOf,
43
43
  logicalToDomScrollLeft,
44
+ measureRowScrollPads,
44
45
  pinPartition,
45
46
  pinStyleProps,
46
47
  resolveRowDrop,
@@ -49,6 +50,7 @@ import {
49
50
  startColumnResize,
50
51
  startFillDrag,
51
52
  startRowResize,
53
+ syncGridOptions,
52
54
  colKeyOf,
53
55
  resolveColumn,
54
56
  } from "@moda-grid/core";
@@ -367,71 +369,53 @@ defineExpose({ grid });
367
369
  // 컬럼 관리 도구 팝오버 열림 상태
368
370
  const colCtlOpen = ref(false);
369
371
 
370
- // props → core 동기화
372
+ // props → core 동기화 — 세터 디스패치·함수 prop 안정 래퍼는 코어
373
+ // syncGridOptions 단일 경로가 담당한다. watchEffect가 참조한 prop을
374
+ // 추적해 바뀌면 재실행되고, 코어가 엔트리별 deps 비교로 실제 세터
375
+ // 호출을 게이트한다
371
376
  watchEffect(() => {
372
- if (props.data) grid.setData(props.data);
373
- });
374
- watchEffect(() => {
375
- // 외부 grid 경로에서도 defaultColDef prop이 적용되도록 먼저 동기화 —
376
- // undefined는 "미지정"이라 기존 기본값이 유지된다
377
- grid.setDefaultColDef(props.defaultColDef);
378
- grid.setColumns(props.columns);
379
- });
380
- watchEffect(() => {
381
- if (
382
- props.domLayout !== "autoHeight" &&
383
- props.height != null &&
384
- props.rowHeight != null &&
385
- props.rowHeight > 0
386
- ) {
387
- grid.setVirtualScroll({
388
- rowHeight: props.rowHeight,
389
- viewportHeight: props.height,
390
- overscan: props.overscan,
391
- getRowHeight: props.getRowHeight,
392
- });
393
- } else {
394
- grid.setVirtualScroll(null);
395
- }
396
- });
397
- watchEffect(() => {
398
- grid.setVirtualColumns(props.virtualColumns ?? null);
399
- });
400
- watchEffect(() => {
401
- grid.setRowDragAcceptExternal(props.rowDragAcceptExternal ?? null);
402
- });
403
- watchEffect(() => {
404
- grid.setDir(props.dir ?? null);
405
- });
406
- watchEffect(() => {
407
- if (props.selectionMode) grid.setSelectionMode(props.selectionMode);
408
- if (props.rangeTracking) grid.setRangeTracking(props.rangeTracking);
409
- });
410
- watchEffect(() => {
411
- grid.setHiddenRows([...(props.hiddenRowIds ?? [])]);
412
- });
413
- watchEffect(() => {
414
- grid.setHeaderHeight(props.headerHeight ?? null);
415
- });
416
- watchEffect(() => {
417
- grid.setStriped(props.striped ?? false);
418
- });
419
- watchEffect(() => {
420
- grid.setBeforeEdit(props.beforeEdit ?? null);
421
- grid.setIsRowSelectable(props.isRowSelectable ?? null);
422
- grid.setExternalFilter(props.externalFilter ?? null);
423
- grid.setPostSort(props.postSort ?? null);
424
- grid.setBeforePaste(props.beforePaste ?? null);
425
- grid.setBeforeCopy(props.beforeCopy ?? null);
426
- grid.setIsFullWidthRow(props.isFullWidthRow ?? null);
427
- grid.setAnimateRows(props.animateRows ?? false);
428
- // 외부 grid prop 경로에서도 컨텍스트 메뉴 prop이 적용되도록
429
- // 런타임 setter로 동기화한다
430
- grid.setContextMenu(props.contextMenu ?? null);
431
- grid.setHeaderContextMenu(props.headerContextMenu ?? null);
432
- });
433
- watchEffect(() => {
434
- grid.setClipboardDelimiter(props.clipboardDelimiter ?? null);
377
+ syncGridOptions(grid, {
378
+ data: props.data,
379
+ columns: props.columns,
380
+ defaultColDef: props.defaultColDef,
381
+ virtualScroll:
382
+ props.domLayout !== "autoHeight" &&
383
+ props.height != null &&
384
+ props.rowHeight != null &&
385
+ props.rowHeight > 0
386
+ ? {
387
+ rowHeight: props.rowHeight,
388
+ viewportHeight: props.height,
389
+ overscan: props.overscan,
390
+ getRowHeight: props.getRowHeight,
391
+ }
392
+ : null,
393
+ virtualColumns: props.virtualColumns,
394
+ rowDragAcceptExternal: props.rowDragAcceptExternal,
395
+ dir: props.dir,
396
+ clipboardDelimiter: props.clipboardDelimiter,
397
+ selectionMode: props.selectionMode,
398
+ rangeTracking: props.rangeTracking,
399
+ autoRowHeight: props.autoRowHeight,
400
+ fillSeries: props.fillSeries,
401
+ cellFlash: props.cellFlash,
402
+ copyFormatted: props.copyFormatted,
403
+ singleClickEdit: props.singleClickEdit,
404
+ editType: props.editType,
405
+ headerHeight: props.headerHeight,
406
+ hiddenRowIds: props.hiddenRowIds,
407
+ striped: props.striped,
408
+ beforeEdit: props.beforeEdit,
409
+ beforePaste: props.beforePaste,
410
+ beforeCopy: props.beforeCopy,
411
+ contextMenu: props.contextMenu,
412
+ headerContextMenu: props.headerContextMenu,
413
+ isRowSelectable: props.isRowSelectable,
414
+ externalFilter: props.externalFilter,
415
+ isFullWidthRow: props.isFullWidthRow,
416
+ postSort: props.postSort,
417
+ animateRows: props.animateRows,
418
+ });
435
419
  });
436
420
 
437
421
  // 가상 스크롤: 코어가 보정한 scrollTop을 DOM에 동기화 (키보드 scrollIntoView)
@@ -442,6 +426,17 @@ watchEffect(() => {
442
426
  if (v && el && el.scrollTop !== v.scrollTop) el.scrollTop = v.scrollTop;
443
427
  });
444
428
 
429
+ // scroll-padding: sticky thead/pinned-top·tfoot/pinned-bottom이 덮는 높이를
430
+ // 알려 scrollIntoView가 행을 오버레이 아래로 완전히 보이게 한다
431
+ watchEffect(() => {
432
+ void state.value; // 스냅샷 갱신마다 재측정
433
+ const el = scrollEl.value;
434
+ if (!el) return;
435
+ const { top, bottom } = measureRowScrollPads(el);
436
+ el.style.scrollPaddingTop = `${top}px`;
437
+ el.style.scrollPaddingBottom = `${bottom}px`;
438
+ });
439
+
445
440
  // 컬럼 가상화: 코어가 보정한 scrollLeft를 DOM에 동기화한다
446
441
  // (ensureColumnVisible/scrollToColumn 경로). 사용자 스크롤은 같은 값이라 no-op.
447
442
  watchEffect(() => {
@@ -497,25 +492,21 @@ watch(
497
492
  const req = state.value.scrollRequest;
498
493
  if (!req) return;
499
494
  await nextTick();
500
- (scrollEl.value ?? hostEl.value)
501
- ?.querySelector<HTMLElement>(
502
- `td[data-mg-row="${req.rowIndex}"]` +
503
- (req.columnIndex != null ? `[data-mg-col="${req.columnIndex}"]` : ""),
504
- )
505
- ?.scrollIntoView({ block: "nearest", inline: "nearest" });
495
+ const el = scrollEl.value ?? hostEl.value;
496
+ // scrollToBottom — 후행 소계/그룹 행까지 덮도록 스크롤 끝으로
497
+ if (req.toEnd) {
498
+ if (el) el.scrollTop = el.scrollHeight;
499
+ return;
500
+ }
501
+ el?.querySelector<HTMLElement>(
502
+ `td[data-mg-row="${req.rowIndex}"]` +
503
+ (req.columnIndex != null ? `[data-mg-col="${req.columnIndex}"]` : ""),
504
+ )?.scrollIntoView({ block: "nearest", inline: "nearest" });
506
505
  },
507
506
  );
508
507
 
509
- // autoRowHeight prop → core 동기화 (제어 모드 포함)
510
- watchEffect(() => grid.setAutoRowHeight(!!props.autoRowHeight));
511
- // fillSeries prop → core 동기화 (제어 모드 포함)
512
- watchEffect(() => grid.setFillSeries(!!props.fillSeries));
513
- // cellFlash prop → core 동기화
514
- watchEffect(() => grid.setCellFlash(!!props.cellFlash));
515
- // copyFormatted prop → core 동기화
516
- watchEffect(() => grid.setCopyFormatted(!!props.copyFormatted));
517
- watchEffect(() => grid.setSingleClickEdit(!!props.singleClickEdit));
518
- watchEffect(() => grid.setEditType(props.editType ?? "cell"));
508
+ // autoRowHeight·fillSeries·cellFlash·copyFormatted·singleClickEdit·editType은
509
+ // 위 syncGridOptions 단일 경로가 커버한다
519
510
 
520
511
  // 찾기 바 — findNext로 다음/이전 매치 순환 (Enter / Shift+Enter)
521
512
  const findInputEl = ref<HTMLInputElement | null>(null);
@@ -2285,6 +2276,7 @@ watch(
2285
2276
  grid.getHeaderClass(cell.col),
2286
2277
  ]"
2287
2278
  :title="cell.col.headerTooltip"
2279
+ role="columnheader"
2288
2280
  :aria-sort="sortAria(colKeyOf(cell.col))"
2289
2281
  :draggable="reorderable && cell.col.movable !== false"
2290
2282
  @dragstart="onDragStart(cell.col, $event)"
@@ -2621,6 +2613,7 @@ watch(
2621
2613
  <tr
2622
2614
  v-else-if="isFullWidthOf(entry, rowIdx)"
2623
2615
  :key="rowKeyOf(entry, rowIdx)"
2616
+ role="row"
2624
2617
  class="mg-fullwidth-row"
2625
2618
  :data-mg-key="grid.getRowId(rowDataOf(entry))"
2626
2619
  >
@@ -3111,7 +3104,7 @@ watch(
3111
3104
  class="mg-append-btn"
3112
3105
  @click="onLoadMore"
3113
3106
  >
3114
- 더 보기
3107
+ {{ state.locale.appendMore }}
3115
3108
  </button>
3116
3109
  </td>
3117
3110
  </tr>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moda-grid/vue2",
3
- "version": "2.2.0",
3
+ "version": "2.2.3",
4
4
  "description": "Vue 2.7 adapter for @moda-grid — DataGrid SFC and useGrid composable",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -36,7 +36,7 @@
36
36
  "grid"
37
37
  ],
38
38
  "dependencies": {
39
- "@moda-grid/core": "2.2.0"
39
+ "@moda-grid/core": "2.2.3"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "vue": "^2.7.0"
@@ -1,29 +0,0 @@
1
- import type { PropType } from "vue";
2
- import type { Grid } from "@moda-grid/core";
3
- /**
4
- * 기본 테이블 렌더러 (Vue 2.7 render API).
5
- * Vue 2의 h()는 attrs/on을 분리해서 받는다 — Vue 3용 컴포넌트와
6
- * 데이터 객체 형태가 다르므로 주의.
7
- */
8
- export declare const DataGrid: import("vue").DefineComponent<{
9
- grid: {
10
- type: PropType<Grid<any>>;
11
- required: true;
12
- };
13
- selectable: {
14
- type: BooleanConstructor;
15
- default: boolean;
16
- };
17
- }, () => import("vue").VNode, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{
18
- grid: {
19
- type: PropType<Grid<any>>;
20
- required: true;
21
- };
22
- selectable: {
23
- type: BooleanConstructor;
24
- default: boolean;
25
- };
26
- }>>, {
27
- selectable: boolean;
28
- }>;
29
- //# sourceMappingURL=DataGrid.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DataGrid.d.ts","sourceRoot":"","sources":["../src/DataGrid.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAI5C;;;;GAIG;AACH,eAAO,MAAM,QAAQ;;cAIC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;;;;;;;;;cAAnB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;;;;;;;;;EAgHvC,CAAC"}
package/dist/DataGrid.js DELETED
@@ -1,90 +0,0 @@
1
- import { defineComponent, h, onBeforeUnmount, shallowRef } from "vue";
2
- const SORT_ARROWS = { asc: "▲", desc: "▼" };
3
- /**
4
- * 기본 테이블 렌더러 (Vue 2.7 render API).
5
- * Vue 2의 h()는 attrs/on을 분리해서 받는다 — Vue 3용 컴포넌트와
6
- * 데이터 객체 형태가 다르므로 주의.
7
- */
8
- export const DataGrid = defineComponent({
9
- name: "MyGridDataGrid",
10
- props: {
11
- grid: {
12
- type: Object,
13
- required: true,
14
- },
15
- selectable: {
16
- type: Boolean,
17
- default: true,
18
- },
19
- },
20
- setup(props) {
21
- const state = shallowRef(props.grid.getSnapshot());
22
- const unsubscribe = props.grid.subscribe(() => {
23
- state.value = props.grid.getSnapshot();
24
- });
25
- onBeforeUnmount(unsubscribe);
26
- return () => {
27
- const { visibleColumns, rows, sort, selectedRowIds, filters } = state.value;
28
- const grid = props.grid;
29
- const hasFilterRow = visibleColumns.some((c) => c.filterable);
30
- return h("table", { class: "mg-table" }, [
31
- h("thead", [
32
- h("tr", visibleColumns.map((col) => h("th", {
33
- key: col.field,
34
- style: col.width ? { width: `${col.width}px` } : undefined,
35
- class: col.sortable === false ? undefined : "mg-sortable",
36
- attrs: {
37
- "aria-sort": sort?.field === col.field
38
- ? sort.direction === "asc"
39
- ? "ascending"
40
- : "descending"
41
- : "none",
42
- },
43
- on: { click: () => grid.toggleSort(col.field) },
44
- }, [
45
- col.header ?? col.field,
46
- sort?.field === col.field
47
- ? h("span", { class: "mg-sort-arrow" }, SORT_ARROWS[sort.direction])
48
- : null,
49
- ]))),
50
- hasFilterRow
51
- ? h("tr", { class: "mg-filter-row" }, visibleColumns.map((col) => h("th", { key: col.field }, [
52
- col.filterable
53
- ? h("input", {
54
- class: "mg-filter-input",
55
- domProps: { value: filters[col.field] ?? "" },
56
- attrs: {
57
- placeholder: `${col.header ?? col.field} 필터`,
58
- },
59
- on: {
60
- input: (e) => grid.setFilter(col.field, e.target.value),
61
- },
62
- })
63
- : null,
64
- ])))
65
- : null,
66
- ]),
67
- h("tbody", rows.length === 0
68
- ? [
69
- h("tr", [
70
- h("td", {
71
- class: "mg-empty",
72
- attrs: { colspan: visibleColumns.length || 1 },
73
- }, "No rows"),
74
- ]),
75
- ]
76
- : rows.map((row) => {
77
- const id = grid.getRowId(row);
78
- return h("tr", {
79
- key: id,
80
- class: selectedRowIds.has(id) ? "mg-selected" : undefined,
81
- on: {
82
- click: () => props.selectable && grid.toggleRowSelection(id),
83
- },
84
- }, visibleColumns.map((col) => h("td", { key: col.field }, grid.getCellText(row, col))));
85
- })),
86
- ]);
87
- };
88
- },
89
- });
90
- //# sourceMappingURL=DataGrid.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DataGrid.js","sourceRoot":"","sources":["../src/DataGrid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAItE,MAAM,WAAW,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAW,CAAC;AAErD;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAC;IACtC,IAAI,EAA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