@ncds/ui-admin 1.8.11 → 1.8.12
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/cjs/src/components/data-display/data-grid/DataGrid.js +3 -1
- package/dist/cjs/src/components/data-display/table/Table.js +326 -75
- package/dist/cjs/src/components/data-display/table/dnd-context.js +15 -0
- package/dist/cjs/src/components/data-display/table/dnd-preview.js +127 -0
- package/dist/esm/src/components/data-display/data-grid/DataGrid.js +3 -1
- package/dist/esm/src/components/data-display/table/Table.js +328 -77
- package/dist/esm/src/components/data-display/table/dnd-context.js +10 -0
- package/dist/esm/src/components/data-display/table/dnd-preview.js +121 -0
- package/dist/temp/src/components/data-display/data-grid/DataGrid.js +1 -1
- package/dist/temp/src/components/data-display/data-grid/DataGrid.types.d.ts +5 -0
- package/dist/temp/src/components/data-display/table/Table.d.ts +14 -4
- package/dist/temp/src/components/data-display/table/Table.js +172 -14
- package/dist/temp/src/components/data-display/table/dnd-context.d.ts +12 -0
- package/dist/temp/src/components/data-display/table/dnd-context.js +10 -0
- package/dist/temp/src/components/data-display/table/dnd-preview.d.ts +6 -0
- package/dist/temp/src/components/data-display/table/dnd-preview.js +120 -0
- package/dist/temp/src/components/data-display/table/types.d.ts +24 -1
- package/dist/types/src/components/data-display/data-grid/DataGrid.types.d.ts +5 -0
- package/dist/types/src/components/data-display/table/Table.d.ts +14 -4
- package/dist/types/src/components/data-display/table/dnd-context.d.ts +12 -0
- package/dist/types/src/components/data-display/table/dnd-preview.d.ts +6 -0
- package/dist/types/src/components/data-display/table/types.d.ts +24 -1
- package/dist/ui-admin/assets/styles/style.css +166 -2
- package/package.json +2 -2
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buildDragPreview = exports.TABLE_DND_ID_SLICE_START = exports.TABLE_DND_ID_SLICE_END = exports.TABLE_DND_ID_RADIX = exports.PREVIEW_BADGE_SIZE = void 0;
|
|
7
|
+
const TABLE_DND_ID_RADIX = exports.TABLE_DND_ID_RADIX = 36;
|
|
8
|
+
const TABLE_DND_ID_SLICE_START = exports.TABLE_DND_ID_SLICE_START = 2;
|
|
9
|
+
const TABLE_DND_ID_SLICE_END = exports.TABLE_DND_ID_SLICE_END = 9;
|
|
10
|
+
const PREVIEW_MAX_ROWS = 3;
|
|
11
|
+
const PREVIEW_STACK_OFFSET = 5;
|
|
12
|
+
const PREVIEW_MAX_STACK_OFFSET = PREVIEW_STACK_OFFSET * PREVIEW_MAX_ROWS;
|
|
13
|
+
const PREVIEW_BADGE_SIZE = exports.PREVIEW_BADGE_SIZE = 24;
|
|
14
|
+
const PREVIEW_BADGE_HALF = PREVIEW_BADGE_SIZE / 2;
|
|
15
|
+
// hover의 color-mix 반투명 배경을 우회해 불투명 RGB 배경색을 클래스 기반으로 직접 결정
|
|
16
|
+
const getRowBackground = rowEl => {
|
|
17
|
+
const resolveCssVar = name => getComputedStyle(document.documentElement).getPropertyValue(name).trim();
|
|
18
|
+
const isSelected = rowEl.classList.contains('ncua-table__row--selected');
|
|
19
|
+
const isError = rowEl.classList.contains('ncua-table__row--error');
|
|
20
|
+
const isWarning = rowEl.classList.contains('ncua-table__row--warning');
|
|
21
|
+
if (isSelected && isError) return resolveCssVar('--primary-red-50');
|
|
22
|
+
if (isSelected && isWarning) return resolveCssVar('--orange-50');
|
|
23
|
+
if (isSelected) return resolveCssVar('--gray-50');
|
|
24
|
+
return resolveCssVar('--base-white');
|
|
25
|
+
};
|
|
26
|
+
// cloneNode는 HTML attribute만 복사하므로 checkbox.checked를 직접 동기화
|
|
27
|
+
const cloneRowWithState = sourceRow => {
|
|
28
|
+
const clone = sourceRow.cloneNode(true);
|
|
29
|
+
const srcInputs = sourceRow.querySelectorAll('input[type="checkbox"]');
|
|
30
|
+
const clnInputs = clone.querySelectorAll('input[type="checkbox"]');
|
|
31
|
+
srcInputs.forEach((src, i) => {
|
|
32
|
+
const cln = clnInputs[i];
|
|
33
|
+
if (cln) cln.checked = src.checked;
|
|
34
|
+
});
|
|
35
|
+
clone.style.backgroundColor = getRowBackground(sourceRow);
|
|
36
|
+
// 열 너비는 테이블 레이아웃 컨텍스트에서 결정되므로 직접 복사 — ceil로 올림해 프리뷰 셀이 실제보다 좁아지지 않게 함
|
|
37
|
+
const srcCells = Array.from(sourceRow.querySelectorAll('td, th'));
|
|
38
|
+
const clnCells = Array.from(clone.querySelectorAll('td, th'));
|
|
39
|
+
srcCells.forEach((src, i) => {
|
|
40
|
+
const cln = clnCells[i];
|
|
41
|
+
if (!cln) return;
|
|
42
|
+
const w = `${Math.ceil(src.getBoundingClientRect().width)}px`;
|
|
43
|
+
cln.style.width = w;
|
|
44
|
+
cln.style.minWidth = w;
|
|
45
|
+
cln.style.maxWidth = w;
|
|
46
|
+
});
|
|
47
|
+
return clone;
|
|
48
|
+
};
|
|
49
|
+
const buildCountBadge = count => {
|
|
50
|
+
const badge = document.createElement('div');
|
|
51
|
+
badge.className = 'ncua-table-dnd-preview__badge';
|
|
52
|
+
badge.textContent = String(count);
|
|
53
|
+
return badge;
|
|
54
|
+
};
|
|
55
|
+
const buildSummaryCard = rowRect => {
|
|
56
|
+
const wrapper = document.createElement('div');
|
|
57
|
+
wrapper.className = 'ncua-table-dnd-preview__summary';
|
|
58
|
+
Object.assign(wrapper.style, {
|
|
59
|
+
top: `${Math.round(PREVIEW_BADGE_HALF + PREVIEW_MAX_STACK_OFFSET)}px`,
|
|
60
|
+
left: `${Math.round(PREVIEW_BADGE_HALF + PREVIEW_MAX_STACK_OFFSET)}px`,
|
|
61
|
+
width: `${Math.round(rowRect.width) - PREVIEW_MAX_STACK_OFFSET}px`,
|
|
62
|
+
height: `${Math.round(rowRect.height)}px`
|
|
63
|
+
});
|
|
64
|
+
return wrapper;
|
|
65
|
+
};
|
|
66
|
+
const buildRowCard = _ref => {
|
|
67
|
+
let {
|
|
68
|
+
row,
|
|
69
|
+
cardLeft,
|
|
70
|
+
cardTop,
|
|
71
|
+
cardWidth,
|
|
72
|
+
rowHeight,
|
|
73
|
+
zIndex,
|
|
74
|
+
parentTable
|
|
75
|
+
} = _ref;
|
|
76
|
+
const wrapper = document.createElement('div');
|
|
77
|
+
wrapper.className = 'ncua-table-dnd-preview__card';
|
|
78
|
+
Object.assign(wrapper.style, {
|
|
79
|
+
zIndex: String(zIndex),
|
|
80
|
+
top: `${cardTop}px`,
|
|
81
|
+
left: `${cardLeft}px`,
|
|
82
|
+
width: `${cardWidth}px`,
|
|
83
|
+
height: `${rowHeight}px`,
|
|
84
|
+
backgroundColor: getRowBackground(row)
|
|
85
|
+
});
|
|
86
|
+
const table = document.createElement('table');
|
|
87
|
+
if (parentTable) table.className = parentTable.className;
|
|
88
|
+
table.style.width = `${cardWidth}px`;
|
|
89
|
+
const tbody = document.createElement('tbody');
|
|
90
|
+
tbody.className = 'ncua-table__body';
|
|
91
|
+
tbody.appendChild(cloneRowWithState(row));
|
|
92
|
+
table.appendChild(tbody);
|
|
93
|
+
wrapper.appendChild(table);
|
|
94
|
+
return wrapper;
|
|
95
|
+
};
|
|
96
|
+
const buildDragPreview = (rows, rowRect) => {
|
|
97
|
+
const visibleCount = Math.min(rows.length, PREVIEW_MAX_ROWS);
|
|
98
|
+
const hasSummary = rows.length > visibleCount;
|
|
99
|
+
const totalCards = visibleCount + (hasSummary ? 1 : 0);
|
|
100
|
+
const isMulti = rows.length > 1;
|
|
101
|
+
const parentTable = rows[0]?.closest('table') ?? null;
|
|
102
|
+
const rowWidth = Math.round(rowRect.width);
|
|
103
|
+
const rowHeight = Math.round(rowRect.height);
|
|
104
|
+
const container = document.createElement('div');
|
|
105
|
+
container.className = 'ncua-table-dnd-preview';
|
|
106
|
+
Object.assign(container.style, {
|
|
107
|
+
width: `${PREVIEW_BADGE_HALF + rowWidth}px`,
|
|
108
|
+
height: `${PREVIEW_BADGE_HALF + rowHeight + PREVIEW_STACK_OFFSET * (totalCards - 1)}px`
|
|
109
|
+
});
|
|
110
|
+
if (isMulti) container.appendChild(buildCountBadge(rows.length));
|
|
111
|
+
if (hasSummary) container.appendChild(buildSummaryCard(rowRect));
|
|
112
|
+
// 뒤쪽 행 카드부터 렌더해서 앞쪽이 위로 올라오게
|
|
113
|
+
for (let i = visibleCount - 1; i >= 0; i--) {
|
|
114
|
+
const stackShift = isMulti ? i * PREVIEW_STACK_OFFSET : 0;
|
|
115
|
+
container.appendChild(buildRowCard({
|
|
116
|
+
row: rows[i],
|
|
117
|
+
cardLeft: Math.round(PREVIEW_BADGE_HALF + stackShift),
|
|
118
|
+
cardTop: Math.round(PREVIEW_BADGE_HALF + stackShift),
|
|
119
|
+
cardWidth: rowWidth - stackShift,
|
|
120
|
+
rowHeight,
|
|
121
|
+
zIndex: visibleCount - i,
|
|
122
|
+
parentTable
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
return container;
|
|
126
|
+
};
|
|
127
|
+
exports.buildDragPreview = buildDragPreview;
|
|
@@ -75,7 +75,8 @@ const DataGridTable = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
75
75
|
hoverable,
|
|
76
76
|
selectable,
|
|
77
77
|
horizontalScroll,
|
|
78
|
-
minWidth
|
|
78
|
+
minWidth,
|
|
79
|
+
draggable
|
|
79
80
|
} = _ref5;
|
|
80
81
|
return _jsx("div", {
|
|
81
82
|
ref: ref,
|
|
@@ -89,6 +90,7 @@ const DataGridTable = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
89
90
|
selectable: selectable,
|
|
90
91
|
horizontalScroll: horizontalScroll,
|
|
91
92
|
minWidth: minWidth,
|
|
93
|
+
draggable: draggable,
|
|
92
94
|
children: children
|
|
93
95
|
})
|
|
94
96
|
});
|