@ncds/ui-admin 1.8.11 → 1.8.13
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 +9 -5
- 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 +9 -5
- 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.d.ts +1 -0
- package/dist/temp/src/components/data-display/data-grid/DataGrid.js +8 -7
- package/dist/temp/src/components/data-display/data-grid/DataGrid.types.d.ts +6 -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.d.ts +1 -0
- package/dist/types/src/components/data-display/data-grid/DataGrid.types.d.ts +6 -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 +177 -2
- package/package.json +2 -2
|
@@ -82,7 +82,8 @@ const DataGridTable = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
|
|
|
82
82
|
hoverable,
|
|
83
83
|
selectable,
|
|
84
84
|
horizontalScroll,
|
|
85
|
-
minWidth
|
|
85
|
+
minWidth,
|
|
86
|
+
draggable
|
|
86
87
|
} = _ref5;
|
|
87
88
|
return (0, _jsxRuntime.jsx)("div", {
|
|
88
89
|
ref: ref,
|
|
@@ -96,6 +97,7 @@ const DataGridTable = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
|
|
|
96
97
|
selectable: selectable,
|
|
97
98
|
horizontalScroll: horizontalScroll,
|
|
98
99
|
minWidth: minWidth,
|
|
100
|
+
draggable: draggable,
|
|
99
101
|
children: children
|
|
100
102
|
})
|
|
101
103
|
});
|
|
@@ -146,7 +148,7 @@ const sortChildren = children => {
|
|
|
146
148
|
});
|
|
147
149
|
return result;
|
|
148
150
|
};
|
|
149
|
-
const hasTableWrapperContent = sorted => sorted.filterBar.length > 0 || sorted.topActionBar.length > 0 || sorted.dataTable.length > 0 || sorted.bottomActionBar.length > 0;
|
|
151
|
+
const hasTableWrapperContent = (sorted, actionBarVisible) => sorted.filterBar.length > 0 || actionBarVisible && sorted.topActionBar.length > 0 || sorted.dataTable.length > 0 || actionBarVisible && sorted.bottomActionBar.length > 0;
|
|
150
152
|
const isTableSelectable = dataTable => dataTable.some(child => /*#__PURE__*/(0, _react.isValidElement)(child) && child.props.selectable === true);
|
|
151
153
|
// ──────────────────────────────────────────────
|
|
152
154
|
// Main DataGrid component
|
|
@@ -156,17 +158,19 @@ const DataGridComponent = /*#__PURE__*/(0, _react.forwardRef)((_ref7, ref) => {
|
|
|
156
158
|
variant = 'search-result',
|
|
157
159
|
children,
|
|
158
160
|
className,
|
|
161
|
+
showActionBar,
|
|
159
162
|
...rest
|
|
160
163
|
} = _ref7;
|
|
161
164
|
const sorted = sortChildren(children);
|
|
162
|
-
const
|
|
165
|
+
const actionBarVisible = showActionBar !== false;
|
|
166
|
+
const needsEmptyBottomBar = actionBarVisible && sorted.bottomActionBar.length === 0 && isTableSelectable(sorted.dataTable);
|
|
163
167
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
164
168
|
ref: ref,
|
|
165
169
|
className: (0, _classnames.default)('ncua-data-grid', className, `ncua-data-grid--${variant}`),
|
|
166
170
|
...rest,
|
|
167
|
-
children: [sorted.searchFilter, sorted.summary, hasTableWrapperContent(sorted) && (0, _jsxRuntime.jsxs)("div", {
|
|
171
|
+
children: [sorted.searchFilter, sorted.summary, hasTableWrapperContent(sorted, actionBarVisible) && (0, _jsxRuntime.jsxs)("div", {
|
|
168
172
|
className: "ncua-data-grid__table-wrapper",
|
|
169
|
-
children: [sorted.filterBar, sorted.topActionBar, sorted.dataTable, sorted.bottomActionBar, needsEmptyBottomBar && (0, _jsxRuntime.jsx)("div", {
|
|
173
|
+
children: [sorted.filterBar, actionBarVisible && sorted.topActionBar, sorted.dataTable, actionBarVisible && sorted.bottomActionBar, needsEmptyBottomBar && (0, _jsxRuntime.jsx)("div", {
|
|
170
174
|
className: "ncua-data-grid__action-bar ncua-data-grid__action-bar--bottom"
|
|
171
175
|
})]
|
|
172
176
|
}), sorted.pagination]
|
|
@@ -5,10 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Table = void 0;
|
|
7
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
9
|
+
var _disableNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview");
|
|
10
|
+
var _element = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/element");
|
|
11
|
+
var _closestEdge = require("@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge");
|
|
8
12
|
var _uiAdminIcon = require("@ncds/ui-admin-icon");
|
|
9
13
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
14
|
var _react = require("react");
|
|
11
15
|
var _FloatingContext = require("../../../contexts/FloatingContext");
|
|
16
|
+
var _dndContext = require("./dnd-context");
|
|
17
|
+
var _dndPreview = require("./dnd-preview");
|
|
12
18
|
var _useTableScrollbars = require("./useTableScrollbars");
|
|
13
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
20
|
// 가로 스크롤 디자인 기준 폭 — 14인치 모니터 + LNB 고려한 디자인 권장 너비
|
|
@@ -50,35 +56,254 @@ Header.displayName = 'Table.Header';
|
|
|
50
56
|
const Body = _ref2 => {
|
|
51
57
|
let {
|
|
52
58
|
children,
|
|
53
|
-
className
|
|
59
|
+
className,
|
|
60
|
+
onRowDrop
|
|
54
61
|
} = _ref2;
|
|
62
|
+
const {
|
|
63
|
+
tableId
|
|
64
|
+
} = (0, _react.useContext)(_dndContext.TableDndContext);
|
|
65
|
+
// onRowDrop 참조를 ref로 유지 — 콜백이 매 렌더마다 재생성되어도 effect가 재구독하지 않도록
|
|
66
|
+
const onRowDropRef = (0, _react.useRef)(onRowDrop);
|
|
67
|
+
onRowDropRef.current = onRowDrop;
|
|
68
|
+
(0, _react.useEffect)(() => {
|
|
69
|
+
return (0, _adapter.monitorForElements)({
|
|
70
|
+
canMonitor: _ref3 => {
|
|
71
|
+
let {
|
|
72
|
+
source
|
|
73
|
+
} = _ref3;
|
|
74
|
+
return source.data.tableId === tableId;
|
|
75
|
+
},
|
|
76
|
+
onDrop: _ref4 => {
|
|
77
|
+
let {
|
|
78
|
+
source,
|
|
79
|
+
location
|
|
80
|
+
} = _ref4;
|
|
81
|
+
if (!onRowDropRef.current) return;
|
|
82
|
+
const target = location.current.dropTargets[0];
|
|
83
|
+
if (!target) return;
|
|
84
|
+
const fromId = source.data.id;
|
|
85
|
+
const toId = target.data.id;
|
|
86
|
+
if (typeof fromId !== 'string' || typeof toId !== 'string' || fromId === toId) return;
|
|
87
|
+
const edge = (0, _closestEdge.extractClosestEdge)(target.data);
|
|
88
|
+
onRowDropRef.current(fromId, toId, edge === 'bottom' ? 'bottom' : 'top');
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}, [tableId]);
|
|
55
92
|
return (0, _jsxRuntime.jsx)("tbody", {
|
|
56
93
|
className: (0, _classnames.default)('ncua-table__body', className),
|
|
57
94
|
children: children
|
|
58
95
|
});
|
|
59
96
|
};
|
|
60
97
|
Body.displayName = 'Table.Body';
|
|
61
|
-
const Row = /*#__PURE__*/(0, _react.forwardRef)((
|
|
98
|
+
const Row = /*#__PURE__*/(0, _react.forwardRef)((_ref5, forwardedRef) => {
|
|
62
99
|
let {
|
|
63
100
|
children,
|
|
64
101
|
className,
|
|
65
102
|
selected,
|
|
66
103
|
status,
|
|
104
|
+
dragId,
|
|
67
105
|
...rest
|
|
68
|
-
} =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
106
|
+
} = _ref5;
|
|
107
|
+
const {
|
|
108
|
+
isDraggable,
|
|
109
|
+
tableId
|
|
110
|
+
} = (0, _react.useContext)(_dndContext.TableDndContext);
|
|
111
|
+
const internalRef = (0, _react.useRef)(null);
|
|
112
|
+
const [closestEdge, setClosestEdge] = (0, _react.useState)(null);
|
|
113
|
+
const [isDragging, setIsDragging] = (0, _react.useState)(false);
|
|
114
|
+
const setRef = (0, _react.useCallback)(el => {
|
|
115
|
+
internalRef.current = el;
|
|
116
|
+
if (typeof forwardedRef === 'function') {
|
|
117
|
+
forwardedRef(el);
|
|
118
|
+
} else if (forwardedRef) {
|
|
119
|
+
forwardedRef.current = el;
|
|
120
|
+
}
|
|
121
|
+
}, [forwardedRef]);
|
|
122
|
+
(0, _react.useEffect)(() => {
|
|
123
|
+
if (!isDraggable || !dragId || !internalRef.current) return;
|
|
124
|
+
return (0, _adapter.dropTargetForElements)({
|
|
125
|
+
element: internalRef.current,
|
|
126
|
+
getData: _ref6 => {
|
|
127
|
+
let {
|
|
128
|
+
input,
|
|
129
|
+
element
|
|
130
|
+
} = _ref6;
|
|
131
|
+
return (0, _closestEdge.attachClosestEdge)({
|
|
132
|
+
id: dragId,
|
|
133
|
+
tableId
|
|
134
|
+
}, {
|
|
135
|
+
input,
|
|
136
|
+
element,
|
|
137
|
+
allowedEdges: ['top', 'bottom']
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
onDragEnter: _ref7 => {
|
|
141
|
+
let {
|
|
142
|
+
self,
|
|
143
|
+
source
|
|
144
|
+
} = _ref7;
|
|
145
|
+
if (source.data.id === dragId) return;
|
|
146
|
+
const edge = (0, _closestEdge.extractClosestEdge)(self.data);
|
|
147
|
+
setClosestEdge(edge === 'bottom' && internalRef.current?.nextElementSibling ? null : edge);
|
|
148
|
+
},
|
|
149
|
+
onDrag: _ref8 => {
|
|
150
|
+
let {
|
|
151
|
+
self,
|
|
152
|
+
source
|
|
153
|
+
} = _ref8;
|
|
154
|
+
if (source.data.id === dragId) return;
|
|
155
|
+
const edge = (0, _closestEdge.extractClosestEdge)(self.data);
|
|
156
|
+
setClosestEdge(edge === 'bottom' && internalRef.current?.nextElementSibling ? null : edge);
|
|
157
|
+
},
|
|
158
|
+
onDragLeave: () => setClosestEdge(null),
|
|
159
|
+
onDrop: () => setClosestEdge(null)
|
|
160
|
+
});
|
|
161
|
+
}, [isDraggable, dragId, tableId]);
|
|
162
|
+
return (0, _jsxRuntime.jsx)(_dndContext.RowDndContext.Provider, {
|
|
163
|
+
value: {
|
|
164
|
+
dragId,
|
|
165
|
+
setIsDragging
|
|
166
|
+
},
|
|
167
|
+
children: (0, _jsxRuntime.jsx)("tr", {
|
|
168
|
+
ref: setRef,
|
|
169
|
+
"data-draggable-id": dragId,
|
|
170
|
+
className: (0, _classnames.default)('ncua-table__row', className, {
|
|
171
|
+
'ncua-table__row--selected': selected,
|
|
172
|
+
'ncua-table__row--warning': status === 'warning',
|
|
173
|
+
'ncua-table__row--error': status === 'error',
|
|
174
|
+
'ncua-table__row--drag-over-top': closestEdge === 'top',
|
|
175
|
+
'ncua-table__row--drag-over-bottom': closestEdge === 'bottom',
|
|
176
|
+
'is-dragging': isDragging
|
|
177
|
+
}),
|
|
178
|
+
...rest,
|
|
179
|
+
children: children
|
|
180
|
+
})
|
|
78
181
|
});
|
|
79
182
|
});
|
|
80
183
|
Row.displayName = 'Table.Row';
|
|
81
|
-
const
|
|
184
|
+
const DragHeaderCell = _ref9 => {
|
|
185
|
+
let {
|
|
186
|
+
className,
|
|
187
|
+
children
|
|
188
|
+
} = _ref9;
|
|
189
|
+
return (0, _jsxRuntime.jsx)("th", {
|
|
190
|
+
className: (0, _classnames.default)('ncua-table__header-cell', 'ncua-table__drag-header-cell', className),
|
|
191
|
+
children: (0, _jsxRuntime.jsxs)("span", {
|
|
192
|
+
className: "ncua-table__drag-cell-inner",
|
|
193
|
+
children: [(0, _jsxRuntime.jsx)("span", {
|
|
194
|
+
className: "ncua-table__drag-header-icon",
|
|
195
|
+
"aria-hidden": "true",
|
|
196
|
+
children: (0, _jsxRuntime.jsx)(_uiAdminIcon.DotsGrid02, {
|
|
197
|
+
width: 16,
|
|
198
|
+
height: 16
|
|
199
|
+
})
|
|
200
|
+
}), children]
|
|
201
|
+
})
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
DragHeaderCell.displayName = 'Table.DragHeaderCell';
|
|
205
|
+
const DragCell = _ref0 => {
|
|
206
|
+
let {
|
|
207
|
+
disabled,
|
|
208
|
+
className,
|
|
209
|
+
children
|
|
210
|
+
} = _ref0;
|
|
211
|
+
const {
|
|
212
|
+
isDraggable,
|
|
213
|
+
tableId
|
|
214
|
+
} = (0, _react.useContext)(_dndContext.TableDndContext);
|
|
215
|
+
const {
|
|
216
|
+
dragId,
|
|
217
|
+
setIsDragging
|
|
218
|
+
} = (0, _react.useContext)(_dndContext.RowDndContext);
|
|
219
|
+
const handleRef = (0, _react.useRef)(null);
|
|
220
|
+
(0, _react.useEffect)(() => {
|
|
221
|
+
if (!isDraggable || !dragId || !handleRef.current || disabled) return;
|
|
222
|
+
let overlay = null;
|
|
223
|
+
let removePointerMove = null;
|
|
224
|
+
let pendingPreview = null;
|
|
225
|
+
return (0, _adapter.draggable)({
|
|
226
|
+
element: handleRef.current,
|
|
227
|
+
getInitialData: () => ({
|
|
228
|
+
id: dragId,
|
|
229
|
+
tableId
|
|
230
|
+
}),
|
|
231
|
+
onGenerateDragPreview: _ref1 => {
|
|
232
|
+
let {
|
|
233
|
+
nativeSetDragImage,
|
|
234
|
+
location
|
|
235
|
+
} = _ref1;
|
|
236
|
+
if (!handleRef.current) return;
|
|
237
|
+
const rowEl = handleRef.current.closest('tr');
|
|
238
|
+
if (!rowEl) return;
|
|
239
|
+
(0, _disableNativeDragPreview.disableNativeDragPreview)({
|
|
240
|
+
nativeSetDragImage
|
|
241
|
+
});
|
|
242
|
+
const rowRect = rowEl.getBoundingClientRect();
|
|
243
|
+
const badgeHalf = _dndPreview.PREVIEW_BADGE_SIZE / 2;
|
|
244
|
+
const offsetX = Math.round(location.initial.input.clientX - rowRect.left) + badgeHalf;
|
|
245
|
+
const offsetY = Math.round(location.initial.input.clientY - rowRect.top) + badgeHalf;
|
|
246
|
+
const isSelected = rowEl.classList.contains('ncua-table__row--selected');
|
|
247
|
+
const bodyEl = rowEl.closest('.ncua-table__body');
|
|
248
|
+
const selectedRows = isSelected && bodyEl ? Array.from(bodyEl.querySelectorAll('.ncua-table__row--selected')) : [];
|
|
249
|
+
pendingPreview = {
|
|
250
|
+
rows: selectedRows.length > 1 ? selectedRows : [rowEl],
|
|
251
|
+
rowRect,
|
|
252
|
+
offsetX,
|
|
253
|
+
offsetY
|
|
254
|
+
};
|
|
255
|
+
},
|
|
256
|
+
onDragStart: _ref10 => {
|
|
257
|
+
let {
|
|
258
|
+
location
|
|
259
|
+
} = _ref10;
|
|
260
|
+
setIsDragging(true);
|
|
261
|
+
if (!pendingPreview) return;
|
|
262
|
+
const {
|
|
263
|
+
rows,
|
|
264
|
+
rowRect,
|
|
265
|
+
offsetX,
|
|
266
|
+
offsetY
|
|
267
|
+
} = pendingPreview;
|
|
268
|
+
overlay = (0, _dndPreview.buildDragPreview)(rows, rowRect);
|
|
269
|
+
overlay.style.left = `${Math.round(location.initial.input.clientX) - offsetX}px`;
|
|
270
|
+
overlay.style.top = `${Math.round(location.initial.input.clientY) - offsetY}px`;
|
|
271
|
+
document.body.appendChild(overlay);
|
|
272
|
+
const onDragOver = e => {
|
|
273
|
+
if (!overlay) return;
|
|
274
|
+
overlay.style.left = `${e.clientX - offsetX}px`;
|
|
275
|
+
overlay.style.top = `${e.clientY - offsetY}px`;
|
|
276
|
+
};
|
|
277
|
+
document.addEventListener('dragover', onDragOver);
|
|
278
|
+
removePointerMove = () => document.removeEventListener('dragover', onDragOver);
|
|
279
|
+
},
|
|
280
|
+
onDrop: () => {
|
|
281
|
+
setIsDragging(false);
|
|
282
|
+
removePointerMove?.();
|
|
283
|
+
removePointerMove = null;
|
|
284
|
+
overlay?.remove();
|
|
285
|
+
overlay = null;
|
|
286
|
+
pendingPreview = null;
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}, [isDraggable, dragId, tableId, disabled, setIsDragging]);
|
|
290
|
+
return (0, _jsxRuntime.jsx)("td", {
|
|
291
|
+
className: (0, _classnames.default)('ncua-table__drag-cell', className),
|
|
292
|
+
children: (0, _jsxRuntime.jsxs)("span", {
|
|
293
|
+
className: "ncua-table__drag-cell-inner",
|
|
294
|
+
children: [isDraggable && (0, _jsxRuntime.jsx)("button", {
|
|
295
|
+
ref: handleRef,
|
|
296
|
+
type: "button",
|
|
297
|
+
className: "ncua-table__drag-handle",
|
|
298
|
+
"aria-label": "\uD589 \uC21C\uC11C \uBCC0\uACBD",
|
|
299
|
+
disabled: disabled,
|
|
300
|
+
children: (0, _jsxRuntime.jsx)(_uiAdminIcon.DotsGrid02, {})
|
|
301
|
+
}), children]
|
|
302
|
+
})
|
|
303
|
+
});
|
|
304
|
+
};
|
|
305
|
+
DragCell.displayName = 'Table.DragCell';
|
|
306
|
+
const HeaderCell = /*#__PURE__*/(0, _react.forwardRef)((_ref11, ref) => {
|
|
82
307
|
let {
|
|
83
308
|
children,
|
|
84
309
|
className,
|
|
@@ -88,7 +313,7 @@ const HeaderCell = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
|
|
|
88
313
|
minWidth,
|
|
89
314
|
style,
|
|
90
315
|
...rest
|
|
91
|
-
} =
|
|
316
|
+
} = _ref11;
|
|
92
317
|
const isSortable = sortDirection !== undefined && onSort !== undefined;
|
|
93
318
|
const SortIcon = isSortable ? SORT_ICONS[sortDirection] : undefined;
|
|
94
319
|
return (0, _jsxRuntime.jsx)("th", {
|
|
@@ -120,13 +345,13 @@ const HeaderCell = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
|
|
|
120
345
|
});
|
|
121
346
|
});
|
|
122
347
|
HeaderCell.displayName = 'Table.HeaderCell';
|
|
123
|
-
const Cell = /*#__PURE__*/(0, _react.forwardRef)((
|
|
348
|
+
const Cell = /*#__PURE__*/(0, _react.forwardRef)((_ref12, ref) => {
|
|
124
349
|
let {
|
|
125
350
|
children,
|
|
126
351
|
className,
|
|
127
352
|
isHeader,
|
|
128
353
|
...rest
|
|
129
|
-
} =
|
|
354
|
+
} = _ref12;
|
|
130
355
|
if (isHeader) {
|
|
131
356
|
return (0, _jsxRuntime.jsx)("th", {
|
|
132
357
|
ref: ref,
|
|
@@ -144,55 +369,57 @@ const Cell = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
|
|
|
144
369
|
});
|
|
145
370
|
});
|
|
146
371
|
Cell.displayName = 'Table.Cell';
|
|
147
|
-
const Footer =
|
|
372
|
+
const Footer = _ref13 => {
|
|
148
373
|
let {
|
|
149
374
|
children,
|
|
150
375
|
className
|
|
151
|
-
} =
|
|
376
|
+
} = _ref13;
|
|
152
377
|
return (0, _jsxRuntime.jsx)("div", {
|
|
153
378
|
className: (0, _classnames.default)('ncua-table__footer', className),
|
|
154
379
|
children: children
|
|
155
380
|
});
|
|
156
381
|
};
|
|
157
382
|
Footer.displayName = 'Table.Footer';
|
|
158
|
-
const Pagination =
|
|
383
|
+
const Pagination = _ref14 => {
|
|
159
384
|
let {
|
|
160
385
|
children,
|
|
161
386
|
className
|
|
162
|
-
} =
|
|
387
|
+
} = _ref14;
|
|
163
388
|
return (0, _jsxRuntime.jsx)("div", {
|
|
164
389
|
className: (0, _classnames.default)('ncua-table__pagination', className),
|
|
165
390
|
children: children
|
|
166
391
|
});
|
|
167
392
|
};
|
|
168
393
|
Pagination.displayName = 'Table.Pagination';
|
|
169
|
-
const ColGroup =
|
|
394
|
+
const ColGroup = _ref15 => {
|
|
170
395
|
let {
|
|
171
396
|
widths,
|
|
172
397
|
minWidths
|
|
173
|
-
} =
|
|
398
|
+
} = _ref15;
|
|
174
399
|
const resolveColWidth = width => {
|
|
175
400
|
if (width === undefined || width === 'auto') return undefined;
|
|
176
401
|
if (typeof width === 'number') return `${width}px`;
|
|
177
402
|
return width;
|
|
178
403
|
};
|
|
179
404
|
return (0, _jsxRuntime.jsx)("colgroup", {
|
|
180
|
-
children: widths.map((width, index) =>
|
|
181
|
-
|
|
182
|
-
(0, _jsxRuntime.jsx)("col", {
|
|
183
|
-
style: {
|
|
405
|
+
children: widths.map((width, index) => {
|
|
406
|
+
const colStyle = {
|
|
184
407
|
width: resolveColWidth(width),
|
|
185
408
|
minWidth: resolveColWidth(minWidths?.[index])
|
|
186
|
-
}
|
|
187
|
-
|
|
409
|
+
};
|
|
410
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: colgroup columns never reorder or change
|
|
411
|
+
return (0, _jsxRuntime.jsx)("col", {
|
|
412
|
+
style: colStyle
|
|
413
|
+
}, index);
|
|
414
|
+
})
|
|
188
415
|
});
|
|
189
416
|
};
|
|
190
417
|
ColGroup.displayName = 'Table.ColGroup';
|
|
191
|
-
const Empty =
|
|
418
|
+
const Empty = _ref16 => {
|
|
192
419
|
let {
|
|
193
420
|
colSpan,
|
|
194
421
|
children
|
|
195
|
-
} =
|
|
422
|
+
} = _ref16;
|
|
196
423
|
return (0, _jsxRuntime.jsx)("tr", {
|
|
197
424
|
children: (0, _jsxRuntime.jsx)("td", {
|
|
198
425
|
colSpan: colSpan,
|
|
@@ -237,7 +464,7 @@ const sortChildren = children => {
|
|
|
237
464
|
// ──────────────────────────────────────────────
|
|
238
465
|
// Main Table component
|
|
239
466
|
// ──────────────────────────────────────────────
|
|
240
|
-
const TableComponent = /*#__PURE__*/(0, _react.forwardRef)((
|
|
467
|
+
const TableComponent = /*#__PURE__*/(0, _react.forwardRef)((_ref17, ref) => {
|
|
241
468
|
let {
|
|
242
469
|
type = 'horizontal',
|
|
243
470
|
fixedHeader = false,
|
|
@@ -246,16 +473,21 @@ const TableComponent = /*#__PURE__*/(0, _react.forwardRef)((_ref0, ref) => {
|
|
|
246
473
|
selectable = false,
|
|
247
474
|
horizontalScroll = false,
|
|
248
475
|
minWidth,
|
|
476
|
+
draggable = false,
|
|
249
477
|
children,
|
|
250
478
|
className,
|
|
251
479
|
...rest
|
|
252
|
-
} =
|
|
480
|
+
} = _ref17;
|
|
481
|
+
const tableIdRef = (0, _react.useRef)(`ncua-table-${Math.random().toString(_dndPreview.TABLE_DND_ID_RADIX).slice(_dndPreview.TABLE_DND_ID_SLICE_START, _dndPreview.TABLE_DND_ID_SLICE_END)}`);
|
|
482
|
+
const tableId = tableIdRef.current;
|
|
483
|
+
const effectiveDraggable = draggable && type === 'horizontal';
|
|
253
484
|
const tableClasses = (0, _classnames.default)('ncua-table', className, {
|
|
254
485
|
'ncua-table--horizontal': type === 'horizontal',
|
|
255
486
|
'ncua-table--vertical': type === 'vertical',
|
|
256
487
|
'ncua-table--fixed-header': fixedHeader,
|
|
257
488
|
'ncua-table--hoverable': hoverable && type === 'horizontal',
|
|
258
|
-
'ncua-table--selectable': selectable
|
|
489
|
+
'ncua-table--selectable': selectable,
|
|
490
|
+
'ncua-table--draggable': effectiveDraggable
|
|
259
491
|
});
|
|
260
492
|
const {
|
|
261
493
|
headerContent,
|
|
@@ -295,6 +527,13 @@ const TableComponent = /*#__PURE__*/(0, _react.forwardRef)((_ref0, ref) => {
|
|
|
295
527
|
hScrollbarRef,
|
|
296
528
|
hThumbRef
|
|
297
529
|
});
|
|
530
|
+
// fixedHeader 모드에서 드래그 시 자동 스크롤
|
|
531
|
+
(0, _react.useEffect)(() => {
|
|
532
|
+
if (!effectiveDraggable || !fixedScrollEnabled || !scrollContainerRef.current) return;
|
|
533
|
+
return (0, _element.autoScrollForElements)({
|
|
534
|
+
element: scrollContainerRef.current
|
|
535
|
+
});
|
|
536
|
+
}, [effectiveDraggable, fixedScrollEnabled]);
|
|
298
537
|
// <colgroup> + <thead> + <tbody> 묶음 — fixed-header 분기와 horizontalScroll 분기 모두에서 재사용
|
|
299
538
|
const renderTable = () => (0, _jsxRuntime.jsxs)("table", {
|
|
300
539
|
className: "ncua-table__table",
|
|
@@ -326,6 +565,10 @@ const TableComponent = /*#__PURE__*/(0, _react.forwardRef)((_ref0, ref) => {
|
|
|
326
565
|
})]
|
|
327
566
|
}) : renderTable();
|
|
328
567
|
};
|
|
568
|
+
const dndContextValue = {
|
|
569
|
+
isDraggable: effectiveDraggable,
|
|
570
|
+
tableId
|
|
571
|
+
};
|
|
329
572
|
// horizontalScroll=true 시 외곽 wrapper + FloatingProvider 부착.
|
|
330
573
|
// 핵심 — __h-scroll-container 는 <table>(또는 scroll-area) 만 감싸고, footer/pagination 은
|
|
331
574
|
// 그 바깥에서 항상 고정 위치. 세로 스크롤바는 h-scroll-container 형제로 배치되어
|
|
@@ -337,55 +580,61 @@ const TableComponent = /*#__PURE__*/(0, _react.forwardRef)((_ref0, ref) => {
|
|
|
337
580
|
const innerStyle = {
|
|
338
581
|
'--ncua-table-min-width': typeof resolvedMinWidth === 'number' ? `${resolvedMinWidth}px` : resolvedMinWidth
|
|
339
582
|
};
|
|
340
|
-
return (0, _jsxRuntime.jsx)(
|
|
341
|
-
value:
|
|
342
|
-
children: (0, _jsxRuntime.
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
...rest,
|
|
583
|
+
return (0, _jsxRuntime.jsx)(_dndContext.TableDndContext.Provider, {
|
|
584
|
+
value: dndContextValue,
|
|
585
|
+
children: (0, _jsxRuntime.jsx)(_FloatingContext.FloatingProvider, {
|
|
586
|
+
value: FLOATING_PORTAL_VALUE,
|
|
587
|
+
children: (0, _jsxRuntime.jsxs)("div", {
|
|
588
|
+
ref: ref,
|
|
589
|
+
className: "ncua-table-wrapper",
|
|
590
|
+
style: WRAPPER_STYLE,
|
|
349
591
|
children: [(0, _jsxRuntime.jsxs)("div", {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
children: [(0, _jsxRuntime.
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
children:
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
592
|
+
className: tableClasses,
|
|
593
|
+
...rest,
|
|
594
|
+
children: [(0, _jsxRuntime.jsxs)("div", {
|
|
595
|
+
ref: hScrollContainerRef,
|
|
596
|
+
className: "ncua-table__h-scroll-container",
|
|
597
|
+
children: [(0, _jsxRuntime.jsx)("div", {
|
|
598
|
+
className: "ncua-table__h-scroll-inner",
|
|
599
|
+
style: innerStyle,
|
|
600
|
+
children: renderScrollableArea(false)
|
|
601
|
+
}), (0, _jsxRuntime.jsx)("div", {
|
|
602
|
+
ref: hScrollbarRef,
|
|
603
|
+
className: "ncua-table__h-scrollbar",
|
|
604
|
+
"aria-hidden": "true",
|
|
605
|
+
children: (0, _jsxRuntime.jsx)("div", {
|
|
606
|
+
ref: hThumbRef,
|
|
607
|
+
className: "ncua-table__h-scrollbar-thumb",
|
|
608
|
+
onMouseDown: handleHThumbMouseDown
|
|
609
|
+
})
|
|
610
|
+
})]
|
|
611
|
+
}), fixedScrollEnabled && (0, _jsxRuntime.jsx)("div", {
|
|
612
|
+
ref: scrollbarRef,
|
|
613
|
+
className: "ncua-table__scrollbar",
|
|
359
614
|
"aria-hidden": "true",
|
|
360
615
|
children: (0, _jsxRuntime.jsx)("div", {
|
|
361
|
-
ref:
|
|
362
|
-
className: "ncua-
|
|
363
|
-
onMouseDown:
|
|
616
|
+
ref: thumbRef,
|
|
617
|
+
className: "ncua-table__scrollbar-thumb",
|
|
618
|
+
onMouseDown: handleThumbMouseDown
|
|
364
619
|
})
|
|
365
|
-
})]
|
|
366
|
-
}),
|
|
367
|
-
|
|
368
|
-
className: "ncua-table__scrollbar",
|
|
369
|
-
"aria-hidden": "true",
|
|
370
|
-
children: (0, _jsxRuntime.jsx)("div", {
|
|
371
|
-
ref: thumbRef,
|
|
372
|
-
className: "ncua-table__scrollbar-thumb",
|
|
373
|
-
onMouseDown: handleThumbMouseDown
|
|
374
|
-
})
|
|
375
|
-
}), footerContent]
|
|
376
|
-
}), paginationContent]
|
|
620
|
+
}), footerContent]
|
|
621
|
+
}), paginationContent]
|
|
622
|
+
})
|
|
377
623
|
})
|
|
378
624
|
});
|
|
379
625
|
}
|
|
380
|
-
return (0, _jsxRuntime.
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
626
|
+
return (0, _jsxRuntime.jsx)(_dndContext.TableDndContext.Provider, {
|
|
627
|
+
value: dndContextValue,
|
|
628
|
+
children: (0, _jsxRuntime.jsxs)("div", {
|
|
629
|
+
ref: ref,
|
|
630
|
+
className: "ncua-table-wrapper",
|
|
631
|
+
style: WRAPPER_STYLE,
|
|
632
|
+
children: [(0, _jsxRuntime.jsxs)("div", {
|
|
633
|
+
className: tableClasses,
|
|
634
|
+
...rest,
|
|
635
|
+
children: [renderScrollableArea(), footerContent]
|
|
636
|
+
}), paginationContent]
|
|
637
|
+
})
|
|
389
638
|
});
|
|
390
639
|
});
|
|
391
640
|
TableComponent.displayName = 'Table';
|
|
@@ -396,6 +645,8 @@ const Table = exports.Table = Object.assign(TableComponent, {
|
|
|
396
645
|
Header,
|
|
397
646
|
Body,
|
|
398
647
|
Row,
|
|
648
|
+
DragHeaderCell,
|
|
649
|
+
DragCell,
|
|
399
650
|
HeaderCell,
|
|
400
651
|
Cell,
|
|
401
652
|
Footer,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TableDndContext = exports.RowDndContext = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
const TableDndContext = exports.TableDndContext = /*#__PURE__*/(0, _react.createContext)({
|
|
9
|
+
isDraggable: false,
|
|
10
|
+
tableId: ''
|
|
11
|
+
});
|
|
12
|
+
const RowDndContext = exports.RowDndContext = /*#__PURE__*/(0, _react.createContext)({
|
|
13
|
+
dragId: undefined,
|
|
14
|
+
setIsDragging: _v => undefined
|
|
15
|
+
});
|