@ncds/ui-admin 1.8.28-alpha.2 → 1.8.28-alpha.4

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 (56) hide show
  1. package/dist/cjs/assets/scripts/table/rowSpanBlock.js +97 -0
  2. package/dist/cjs/src/components/data-display/table/Table.js +135 -57
  3. package/dist/cjs/src/components/data-display/table/__tests__/Table.dnd.dragCell.test.js +7 -2
  4. package/dist/cjs/src/components/data-display/table/__tests__/Table.dnd.test.js +13 -8
  5. package/dist/cjs/src/components/data-display/table/__tests__/Table.rowGroup.test.js +54 -0
  6. package/dist/cjs/src/components/data-display/table/__tests__/Table.rowGroupDnd.test.js +212 -0
  7. package/dist/cjs/src/components/data-display/table/__tests__/dnd-context.test.js +5 -2
  8. package/dist/cjs/src/components/data-display/table/__tests__/tableSelectableStyle.test.js +75 -0
  9. package/dist/cjs/src/components/data-display/table/dnd-context.js +4 -1
  10. package/dist/cjs/src/components/data-display/table/dnd-move.js +46 -0
  11. package/dist/cjs/src/components/data-display/table/dnd-preview.js +8 -3
  12. package/dist/cjs/src/generated/scoped-css.js +1 -1
  13. package/dist/esm/assets/scripts/table/rowSpanBlock.js +85 -0
  14. package/dist/esm/src/components/data-display/table/Table.js +135 -57
  15. package/dist/esm/src/components/data-display/table/__tests__/Table.dnd.dragCell.test.js +7 -2
  16. package/dist/esm/src/components/data-display/table/__tests__/Table.dnd.test.js +13 -8
  17. package/dist/esm/src/components/data-display/table/__tests__/Table.rowGroup.test.js +51 -0
  18. package/dist/esm/src/components/data-display/table/__tests__/Table.rowGroupDnd.test.js +210 -0
  19. package/dist/esm/src/components/data-display/table/__tests__/dnd-context.test.js +5 -2
  20. package/dist/esm/src/components/data-display/table/__tests__/tableSelectableStyle.test.js +72 -0
  21. package/dist/esm/src/components/data-display/table/dnd-context.js +4 -1
  22. package/dist/esm/src/components/data-display/table/dnd-move.js +38 -0
  23. package/dist/esm/src/components/data-display/table/dnd-preview.js +8 -3
  24. package/dist/esm/src/generated/scoped-css.js +1 -1
  25. package/dist/temp/assets/scripts/table/rowSpanBlock.d.ts +29 -0
  26. package/dist/temp/assets/scripts/table/rowSpanBlock.js +77 -0
  27. package/dist/temp/src/components/data-display/table/Table.d.ts +7 -3
  28. package/dist/temp/src/components/data-display/table/Table.js +107 -47
  29. package/dist/temp/src/components/data-display/table/__tests__/Table.dnd.dragCell.test.js +10 -2
  30. package/dist/temp/src/components/data-display/table/__tests__/Table.dnd.test.js +16 -8
  31. package/dist/temp/src/components/data-display/table/__tests__/Table.rowGroup.test.d.ts +1 -0
  32. package/dist/temp/src/components/data-display/table/__tests__/Table.rowGroup.test.js +52 -0
  33. package/dist/temp/src/components/data-display/table/__tests__/Table.rowGroupDnd.test.d.ts +1 -0
  34. package/dist/temp/src/components/data-display/table/__tests__/Table.rowGroupDnd.test.js +137 -0
  35. package/dist/temp/src/components/data-display/table/__tests__/dnd-context.test.js +2 -2
  36. package/dist/temp/src/components/data-display/table/__tests__/tableSelectableStyle.test.d.ts +1 -0
  37. package/dist/temp/src/components/data-display/table/__tests__/tableSelectableStyle.test.js +71 -0
  38. package/dist/temp/src/components/data-display/table/dnd-context.d.ts +3 -0
  39. package/dist/temp/src/components/data-display/table/dnd-context.js +1 -0
  40. package/dist/temp/src/components/data-display/table/dnd-move.d.ts +17 -0
  41. package/dist/temp/src/components/data-display/table/dnd-move.js +31 -0
  42. package/dist/temp/src/components/data-display/table/dnd-preview.d.ts +5 -1
  43. package/dist/temp/src/components/data-display/table/dnd-preview.js +7 -3
  44. package/dist/temp/src/components/data-display/table/types.d.ts +14 -5
  45. package/dist/temp/src/generated/scoped-css.js +1 -1
  46. package/dist/types/assets/scripts/table/rowSpanBlock.d.ts +29 -0
  47. package/dist/types/src/components/data-display/table/Table.d.ts +7 -3
  48. package/dist/types/src/components/data-display/table/__tests__/Table.rowGroup.test.d.ts +1 -0
  49. package/dist/types/src/components/data-display/table/__tests__/Table.rowGroupDnd.test.d.ts +1 -0
  50. package/dist/types/src/components/data-display/table/__tests__/tableSelectableStyle.test.d.ts +1 -0
  51. package/dist/types/src/components/data-display/table/dnd-context.d.ts +3 -0
  52. package/dist/types/src/components/data-display/table/dnd-move.d.ts +17 -0
  53. package/dist/types/src/components/data-display/table/dnd-preview.d.ts +5 -1
  54. package/dist/types/src/components/data-display/table/types.d.ts +14 -5
  55. package/dist/ui-admin/assets/styles/style.css +60 -4
  56. package/package.json +1 -1
@@ -0,0 +1,137 @@
1
+ // @vitest-environment jsdom
2
+ /**
3
+ * 묶음은 스타일 레이어이므로 드래그앤드롭 동작이 묶음 유무와 무관해야 한다.
4
+ * 드롭 자체는 실제 포인터 이벤트가 필요해 jsdom 으로 재현할 수 없어, 감시 등록 횟수와 콜백 전달만 고정한다.
5
+ */
6
+ import { createElement } from 'react';
7
+ import { createRoot } from 'react-dom/client';
8
+ import { act } from 'react-dom/test-utils';
9
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
10
+ const monitorCalls = [];
11
+ vi.mock('@atlaskit/pragmatic-drag-and-drop/element/adapter', () => ({
12
+ dropTargetForElements: () => () => undefined,
13
+ draggable: () => () => undefined,
14
+ monitorForElements: (args) => {
15
+ monitorCalls.push(args);
16
+ return () => undefined;
17
+ },
18
+ }));
19
+ vi.mock('@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview', () => ({
20
+ disableNativeDragPreview: () => undefined,
21
+ }));
22
+ vi.mock('@atlaskit/pragmatic-drag-and-drop-auto-scroll/element', () => ({
23
+ autoScrollForElements: () => () => undefined,
24
+ }));
25
+ vi.mock('@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge', () => ({
26
+ attachClosestEdge: (data) => data,
27
+ extractClosestEdge: () => 'bottom',
28
+ }));
29
+ import { planMoveIds } from '../dnd-move';
30
+ const { Table } = await import('../Table');
31
+ let container;
32
+ let root;
33
+ beforeEach(() => {
34
+ monitorCalls.length = 0;
35
+ container = document.createElement('div');
36
+ document.body.appendChild(container);
37
+ act(() => {
38
+ root = createRoot(container);
39
+ });
40
+ });
41
+ afterEach(() => {
42
+ act(() => {
43
+ root.unmount();
44
+ });
45
+ container.remove();
46
+ });
47
+ const rowProps = (id) => ({ key: id, dragId: id, children: createElement(Table.Cell, null, id) });
48
+ const row = (id) => createElement(Table.Row, rowProps(id));
49
+ const groupProps = (key, onRowDrop, ids) => ({
50
+ key,
51
+ onRowDrop,
52
+ children: ids.map(row),
53
+ });
54
+ const group = (key, onRowDrop, ids) => createElement(Table.RowGroup, groupProps(key, onRowDrop, ids));
55
+ const bodyProps = (onRowDrop, ids) => ({ onRowDrop, children: ids.map(row) });
56
+ const plainBodyProps = (ids) => ({ children: ids.map(row) });
57
+ const tableProps = (children) => ({ type: 'horizontal', draggable: true, children });
58
+ const renderTable = (children) => {
59
+ act(() => {
60
+ root.render(createElement(Table, tableProps(children)));
61
+ });
62
+ };
63
+ describe('Table.RowGroup — 드래그앤드롭', () => {
64
+ it('묶음이 여러 개여도 드롭 감시는 한 번만 등록된다', () => {
65
+ const onRowDrop = vi.fn();
66
+ renderTable([
67
+ group('g1', onRowDrop, ['a', 'b']),
68
+ group('g2', onRowDrop, ['c', 'd']),
69
+ group('g3', onRowDrop, ['e']),
70
+ ]);
71
+ expect(monitorCalls).toHaveLength(1);
72
+ });
73
+ it('묶음에 넘긴 onRowDrop 이 드롭 1회에 1번만 호출된다', () => {
74
+ const onRowDrop = vi.fn();
75
+ renderTable([group('g1', onRowDrop, ['a', 'b']), group('g2', onRowDrop, ['c', 'd'])]);
76
+ for (const call of monitorCalls) {
77
+ call.onDrop({
78
+ source: { data: { id: 'a' } },
79
+ location: { current: { dropTargets: [{ data: { id: 'c' } }] } },
80
+ });
81
+ }
82
+ expect(onRowDrop).toHaveBeenCalledTimes(1);
83
+ expect(onRowDrop).toHaveBeenCalledWith('a', 'c', 'bottom', ['a']);
84
+ });
85
+ it('다중 선택 드래그는 고른 행과 그 병합 블록을 모두 넘긴다', () => {
86
+ const onRowDrop = vi.fn();
87
+ renderTable(createElement(Table.Body, bodyProps(onRowDrop, ['a', 'b', 'c', 'd'])));
88
+ const rows = Array.from(container.querySelectorAll('tbody tr'));
89
+ // a 가 b 를 덮고, c 는 혼자다 — a·c 를 고르면 b 도 따라와야 한다
90
+ rows[0].cells[0].rowSpan = 2;
91
+ rows[0].classList.add('ncua-table__row--selected');
92
+ rows[2].classList.add('ncua-table__row--selected');
93
+ monitorCalls[0].onDrop({
94
+ source: { data: { id: 'a', moveIds: planMoveIds(rows[0]) } },
95
+ location: { current: { dropTargets: [{ data: { id: 'd' } }] } },
96
+ });
97
+ expect(onRowDrop).toHaveBeenCalledWith('a', 'd', 'bottom', ['a', 'b', 'c']);
98
+ });
99
+ it('고르지 않은 행을 잡으면 그 행의 블록만 넘긴다', () => {
100
+ const onRowDrop = vi.fn();
101
+ renderTable(createElement(Table.Body, bodyProps(onRowDrop, ['a', 'b', 'c', 'd'])));
102
+ const rows = Array.from(container.querySelectorAll('tbody tr'));
103
+ rows[0].cells[0].rowSpan = 2;
104
+ rows[2].classList.add('ncua-table__row--selected');
105
+ monitorCalls[0].onDrop({
106
+ source: { data: { id: 'a', moveIds: planMoveIds(rows[0]) } },
107
+ location: { current: { dropTargets: [{ data: { id: 'd' } }] } },
108
+ });
109
+ expect(onRowDrop).toHaveBeenCalledWith('a', 'd', 'bottom', ['a', 'b']);
110
+ });
111
+ it('onRowDrop 을 거두면 드롭이 더 이상 호출되지 않는다', () => {
112
+ const onRowDrop = vi.fn();
113
+ const drop = () => monitorCalls[0].onDrop({
114
+ source: { data: { id: 'a' } },
115
+ location: { current: { dropTargets: [{ data: { id: 'b' } }] } },
116
+ });
117
+ renderTable(createElement(Table.Body, bodyProps(onRowDrop, ['a', 'b'])));
118
+ drop();
119
+ expect(onRowDrop).toHaveBeenCalledTimes(1);
120
+ act(() => {
121
+ root.render(createElement(Table, tableProps(createElement(Table.Body, plainBodyProps(['a', 'b'])))));
122
+ });
123
+ drop();
124
+ expect(onRowDrop).toHaveBeenCalledTimes(1);
125
+ });
126
+ it('Table.Body 의 onRowDrop 동작은 묶음 도입 전과 같다', () => {
127
+ const onRowDrop = vi.fn();
128
+ renderTable(createElement(Table.Body, bodyProps(onRowDrop, ['a', 'b'])));
129
+ expect(monitorCalls).toHaveLength(1);
130
+ monitorCalls[0].onDrop({
131
+ source: { data: { id: 'a' } },
132
+ location: { current: { dropTargets: [{ data: { id: 'b' } }] } },
133
+ });
134
+ expect(onRowDrop).toHaveBeenCalledTimes(1);
135
+ expect(onRowDrop).toHaveBeenCalledWith('a', 'b', 'bottom', ['a']);
136
+ });
137
+ });
@@ -35,8 +35,8 @@ describe('dnd-context — Provider 밖 기본값 (RSD-05)', () => {
35
35
  expect(row).toEqual({ dragId: undefined, setIsDragging: expect.any(Function) });
36
36
  expect(() => row?.setIsDragging(true)).not.toThrow();
37
37
  });
38
- it('RSD-05 TableDndContext 기본값은 드래그 비활성 · 빈 tableId 다', () => {
38
+ it('RSD-05 TableDndContext 기본값은 드래그 비활성 · 빈 tableId · 비어 있는 드롭 핸들러 자리다', () => {
39
39
  const { table } = readDefaults();
40
- expect(table).toEqual({ isDraggable: false, tableId: '' });
40
+ expect(table).toEqual({ isDraggable: false, tableId: '', onRowDropRef: { current: undefined } });
41
41
  });
42
42
  });
@@ -0,0 +1,71 @@
1
+ import path from 'node:path';
2
+ import { compile as compileSass } from 'sass';
3
+ import { describe, expect, it } from 'vitest';
4
+ // box-shadow 는 jsdom 에서 계산되지 않으므로, 컴파일된 CSS 에서 규칙을 검사한다.
5
+ // (page-title/__tests__/pageTitleStyle.test.ts 와 같은 방식)
6
+ const TABLE_SCSS_PATH = path.resolve(__dirname, '../../../../../assets/styles/components/table/_index.scss');
7
+ const compiledTableCss = compileSass(TABLE_SCSS_PATH).css;
8
+ /** 선택자 → 선언 목록. 같은 선택자가 여러 규칙에 나오면 선언을 이어 붙인다. */
9
+ const parseRules = (css) => {
10
+ const rules = new Map();
11
+ for (const [, selectorList, body] of css.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
12
+ const declarations = body
13
+ .split(';')
14
+ .map((declaration) => declaration.trim().replace(/\s+/g, ' '))
15
+ .filter(Boolean);
16
+ for (const selector of selectorList.split(',').map((selector) => selector.trim().replace(/\s+/g, ' '))) {
17
+ rules.set(selector, [...(rules.get(selector) ?? []), ...declarations]);
18
+ }
19
+ }
20
+ return rules;
21
+ };
22
+ const rules = parseRules(compiledTableCss);
23
+ const declarationsOf = (selector) => rules.get(selector) ?? [];
24
+ const SELECTABLE = '.ncua-table--selectable';
25
+ const IN_DATA_GRID = '.ncua-table--in-data-grid.ncua-table--selectable';
26
+ const UNSELECTED_ROW = '.ncua-table__body .ncua-table__row:not(.ncua-table__row--selected)';
27
+ const HEADER_FIRST_CELL = '.ncua-table__header-cell:first-child';
28
+ const COMPENSATION_LINE = 'box-shadow: inset 1px 0 0 0 var(--gray-100)';
29
+ const NO_SHADOW = 'box-shadow: none';
30
+ describe('Table selectable — 좌측 border 보상선', () => {
31
+ it('행(tr)이 보상선을 갖는다 — 병합 셀이 덮은 행의 첫 셀은 표 왼쪽 끝이 아니다', () => {
32
+ // Given: 컴파일된 Table CSS 에서
33
+ // When: selectable 의 보상 규칙을 찾으면
34
+ const declarations = declarationsOf(`${SELECTABLE} ${UNSELECTED_ROW}`);
35
+ // Then: 셀이 아니라 행 전체에 보상선을 둔다
36
+ expect(declarations).toContain(COMPENSATION_LINE);
37
+ });
38
+ it('헤더 첫 칸도 보상선을 갖는다', () => {
39
+ // Given/When: 헤더 첫 칸 규칙을 찾으면
40
+ // Then: 기존 보상선이 그대로다
41
+ expect(declarationsOf(`${SELECTABLE} ${HEADER_FIRST_CELL}`)).toContain(COMPENSATION_LINE);
42
+ });
43
+ });
44
+ describe('Table selectable — DataGrid 안에서는 보상선을 거둔다', () => {
45
+ it('행(tr)의 보상선이 제거된다 — DataGrid wrapper 가 외곽 border 를 담당한다', () => {
46
+ // Given: 컴파일된 Table CSS 에서
47
+ // When: in-data-grid 조합의 행 규칙을 찾으면
48
+ const declarations = declarationsOf(`${IN_DATA_GRID} ${UNSELECTED_ROW}`);
49
+ // Then: 보상선을 지워 DataGrid 외곽선과 겹치지 않는다
50
+ expect(declarations).toContain(NO_SHADOW);
51
+ });
52
+ it('헤더 첫 칸의 보상선이 제거된다', () => {
53
+ // Given/When: in-data-grid 조합의 헤더 첫 칸 규칙을 찾으면
54
+ // Then: 보상선을 지운다
55
+ expect(declarationsOf(`${IN_DATA_GRID} ${HEADER_FIRST_CELL}`)).toContain(NO_SHADOW);
56
+ });
57
+ it('보상선을 받는 모든 자리에 제거 규칙이 대응한다 — 한쪽만 넓어지면 선이 남는다', () => {
58
+ // Given: 보상선을 받는 selectable 선택자를 모두 모으고
59
+ const compensated = [...rules]
60
+ .filter(([selector, declarations]) => selector.startsWith(SELECTABLE) && declarations.includes(COMPENSATION_LINE))
61
+ .map(([selector]) => selector);
62
+ // When: 각 선택자의 in-data-grid 대응 규칙을 찾으면
63
+ const uncovered = compensated.filter((selector) => {
64
+ const counterpart = selector.replace(SELECTABLE, IN_DATA_GRID);
65
+ return !declarationsOf(counterpart).includes(NO_SHADOW);
66
+ });
67
+ // Then: 대응 없이 남는 자리가 없다
68
+ expect(compensated.length).toBeGreaterThan(0);
69
+ expect(uncovered).toEqual([]);
70
+ });
71
+ });
@@ -1,6 +1,9 @@
1
+ import { type MutableRefObject } from 'react';
2
+ import type { TableRowDropHandler } from './types';
1
3
  type TableDndContextValue = {
2
4
  isDraggable: boolean;
3
5
  tableId: string;
6
+ onRowDropRef: MutableRefObject<TableRowDropHandler | undefined>;
4
7
  };
5
8
  declare const TableDndContext: import("react").Context<TableDndContextValue>;
6
9
  type RowDndContextValue = {
@@ -2,6 +2,7 @@ import { createContext } from 'react';
2
2
  const TableDndContext = createContext({
3
3
  isDraggable: false,
4
4
  tableId: '',
5
+ onRowDropRef: { current: undefined },
5
6
  });
6
7
  const RowDndContext = createContext({
7
8
  dragId: undefined,
@@ -0,0 +1,17 @@
1
+ declare const DRAG_ID_ATTRIBUTE = "data-draggable-id";
2
+ /** 행 위치는 `tbody` 기준이라 묶음이 여러 개면 서로 겹친다 — 어느 `tbody` 인지 함께 본다 */
3
+ export declare const locateRow: (rowEl: HTMLTableRowElement) => {
4
+ bodyIndex: number;
5
+ body: HTMLTableSectionElement;
6
+ index: number;
7
+ } | null;
8
+ /** 병합이 덮는 행은 따로 옮길 수 없다. 드래그 단위를 그 행이 속한 병합 블록으로 넓힌다. */
9
+ export declare const findRowSpanBlock: (rowEl: HTMLTableRowElement) => {
10
+ bodyIndex: number;
11
+ rows: HTMLTableRowElement[];
12
+ start: number;
13
+ end: number;
14
+ } | null;
15
+ /** 이번 드래그로 옮겨야 하는 행 전부. 고른 행이 여럿이면 각자의 병합 블록까지 끌고 온다. */
16
+ export declare const planMoveIds: (rowEl: HTMLTableRowElement) => string[];
17
+ export { DRAG_ID_ATTRIBUTE };
@@ -0,0 +1,31 @@
1
+ import { computeRowSpanBlock, expandRowsToBlocks, locateRow as locateInBody, readRowSpans, } from '../../../../assets/scripts/table/rowSpanBlock';
2
+ const DRAG_ID_ATTRIBUTE = 'data-draggable-id';
3
+ const toDragIds = (rows) => rows.map((row) => row.getAttribute(DRAG_ID_ATTRIBUTE)).filter((id) => id !== null);
4
+ /** 행 위치는 `tbody` 기준이라 묶음이 여러 개면 서로 겹친다 — 어느 `tbody` 인지 함께 본다 */
5
+ export const locateRow = (rowEl) => {
6
+ const located = locateInBody(rowEl);
7
+ const table = located?.body.closest('table');
8
+ if (!located || !table)
9
+ return null;
10
+ return { ...located, bodyIndex: Array.from(table.tBodies).indexOf(located.body) };
11
+ };
12
+ /** 병합이 덮는 행은 따로 옮길 수 없다. 드래그 단위를 그 행이 속한 병합 블록으로 넓힌다. */
13
+ export const findRowSpanBlock = (rowEl) => {
14
+ const located = locateRow(rowEl);
15
+ if (!located)
16
+ return null;
17
+ const { body, bodyIndex, index } = located;
18
+ const block = computeRowSpanBlock(readRowSpans(body), index);
19
+ return { ...block, bodyIndex, rows: Array.from(body.rows).slice(block.start, block.end + 1) };
20
+ };
21
+ /** 이번 드래그로 옮겨야 하는 행 전부. 고른 행이 여럿이면 각자의 병합 블록까지 끌고 온다. */
22
+ export const planMoveIds = (rowEl) => {
23
+ const tableEl = rowEl.closest('table');
24
+ const selectedRows = tableEl
25
+ ? Array.from(tableEl.querySelectorAll('tbody > .ncua-table__row--selected'))
26
+ : [];
27
+ const isMultiSelect = selectedRows.length > 1 && selectedRows.includes(rowEl);
28
+ const rows = isMultiSelect ? expandRowsToBlocks(selectedRows) : (findRowSpanBlock(rowEl)?.rows ?? [rowEl]);
29
+ return toDragIds(rows);
30
+ };
31
+ export { DRAG_ID_ATTRIBUTE };
@@ -2,5 +2,9 @@ declare const TABLE_DND_ID_RADIX = 36;
2
2
  declare const TABLE_DND_ID_SLICE_START = 2;
3
3
  declare const TABLE_DND_ID_SLICE_END = 9;
4
4
  declare const PREVIEW_BADGE_SIZE = 24;
5
- declare const buildDragPreview: (rows: HTMLElement[], rowRect: DOMRect) => HTMLDivElement;
5
+ /**
6
+ * @param rows 미리보기에 그릴 행. 병합 묶음은 한 건이라도 행이 여러 개다
7
+ * @param itemCount 옮기는 건수. 병합 묶음은 행 수와 다르므로, 생략하면 행 수를 건수로 본다
8
+ */
9
+ declare const buildDragPreview: (rows: HTMLElement[], rowRect: DOMRect, itemCount?: number) => HTMLDivElement;
6
10
  export { TABLE_DND_ID_RADIX, TABLE_DND_ID_SLICE_START, TABLE_DND_ID_SLICE_END, PREVIEW_BADGE_SIZE, buildDragPreview };
@@ -84,11 +84,15 @@ const buildRowCard = ({ row, cardLeft, cardTop, cardWidth, rowHeight, zIndex, pa
84
84
  wrapper.appendChild(table);
85
85
  return wrapper;
86
86
  };
87
- const buildDragPreview = (rows, rowRect) => {
87
+ /**
88
+ * @param rows 미리보기에 그릴 행. 병합 묶음은 한 건이라도 행이 여러 개다
89
+ * @param itemCount 옮기는 건수. 병합 묶음은 행 수와 다르므로, 생략하면 행 수를 건수로 본다
90
+ */
91
+ const buildDragPreview = (rows, rowRect, itemCount = rows.length) => {
88
92
  const visibleCount = Math.min(rows.length, PREVIEW_MAX_ROWS);
89
93
  const hasSummary = rows.length > visibleCount;
90
94
  const totalCards = visibleCount + (hasSummary ? 1 : 0);
91
- const isMulti = rows.length > 1;
95
+ const isMulti = itemCount > 1;
92
96
  const parentTable = rows[0]?.closest('table') ?? null;
93
97
  const rowWidth = Math.round(rowRect.width);
94
98
  const rowHeight = Math.round(rowRect.height);
@@ -99,7 +103,7 @@ const buildDragPreview = (rows, rowRect) => {
99
103
  height: `${PREVIEW_BADGE_HALF + rowHeight + PREVIEW_STACK_OFFSET * (totalCards - 1)}px`,
100
104
  });
101
105
  if (isMulti)
102
- container.appendChild(buildCountBadge(rows.length));
106
+ container.appendChild(buildCountBadge(itemCount));
103
107
  if (hasSummary)
104
108
  container.appendChild(buildSummaryCard(rowRect));
105
109
  // 뒤쪽 행 카드부터 렌더해서 앞쪽이 위로 올라오게
@@ -30,14 +30,21 @@ export type TableHeaderProps = {
30
30
  children: ReactNode;
31
31
  className?: string;
32
32
  };
33
+ /**
34
+ * draggable=true 테이블에서 행이 재정렬될 때 호출된다.
35
+ * fromId → toId 로 이동, edge는 toId 행의 위(top)/아래(bottom) 삽입 위치.
36
+ * @param moveIds 이번 드래그로 옮겨야 하는 행 전부 — 다중 선택과 각 행의 병합 블록을 모두 반영한다
37
+ */
38
+ export type TableRowDropHandler = (fromId: string, toId: string, edge: 'top' | 'bottom', moveIds: string[]) => void;
33
39
  export type TableBodyProps = {
34
40
  children: ReactNode;
35
41
  className?: string;
36
- /**
37
- * draggable=true 테이블에서 행이 재정렬될 때 호출된다.
38
- * fromId → toId 로 이동, edge는 toId 행의 위(top)/아래(bottom) 삽입 위치.
39
- */
40
- onRowDrop?: (fromId: string, toId: string, edge: 'top' | 'bottom') => void;
42
+ onRowDrop?: TableRowDropHandler;
43
+ };
44
+ export type TableRowGroupProps = {
45
+ children: ReactNode;
46
+ className?: string;
47
+ onRowDrop?: TableRowDropHandler;
41
48
  };
42
49
  export type TableRowProps = Omit<ComponentProps<'tr'>, 'ref'> & {
43
50
  selected?: boolean;
@@ -48,6 +55,8 @@ export type TableRowProps = Omit<ComponentProps<'tr'>, 'ref'> & {
48
55
  export type TableDragCellProps = {
49
56
  disabled?: boolean;
50
57
  className?: string;
58
+ /** 묶음에서 여러 행을 덮을 때 지정한다. 다른 칸과 달리 병합되지 않으면 묶음 첫 칸만 쪼개져 보인다. */
59
+ rowSpan?: number;
51
60
  /** 드래그 셀에 함께 배치할 콘텐츠 (예: CheckboxInput). 아이콘 우측 8px gap으로 배치된다. */
52
61
  children?: ReactNode;
53
62
  };