@uzum-tech/ui 2.0.4 → 2.0.6
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/index.js +1039 -493
- package/dist/index.mjs +1039 -493
- package/dist/index.prod.js +2 -2
- package/dist/index.prod.mjs +2 -2
- package/es/_internal/icons/DragHandleRound.d.ts +2 -0
- package/es/_internal/icons/DragHandleRound.mjs +16 -0
- package/es/_internal/icons/index.d.ts +1 -0
- package/es/_internal/icons/index.mjs +1 -0
- package/es/components.d.ts +32 -0
- package/es/data-table/src/DataTable.d.ts +24 -0
- package/es/data-table/src/DataTable.mjs +31 -0
- package/es/data-table/src/HeaderButton/FilterButton.d.ts +6 -0
- package/es/data-table/src/HeaderButton/FilterMenu.d.ts +6 -0
- package/es/data-table/src/TableParts/Body.d.ts +17 -9
- package/es/data-table/src/TableParts/Body.mjs +81 -274
- package/es/data-table/src/TableParts/BodyEmpty.d.ts +3 -0
- package/es/data-table/src/TableParts/BodyEmpty.mjs +22 -0
- package/es/data-table/src/TableParts/BodyRow.d.ts +3 -0
- package/es/data-table/src/TableParts/BodyRow.mjs +257 -0
- package/es/data-table/src/TableParts/BodySkeleton.mjs +5 -2
- package/es/data-table/src/TableParts/Header.d.ts +6 -0
- package/es/data-table/src/TableParts/Header.mjs +5 -1
- package/es/data-table/src/TableParts/VirtualListItemWrapper.d.ts +36 -0
- package/es/data-table/src/TableParts/VirtualListItemWrapper.mjs +46 -0
- package/es/data-table/src/interface.d.ts +161 -2
- package/es/data-table/src/styles/index.cssr.mjs +26 -3
- package/es/data-table/src/use-group-header.d.ts +3 -3
- package/es/data-table/src/use-row-drag.d.ts +2 -0
- package/es/data-table/src/use-row-drag.mjs +241 -0
- package/es/data-table/src/use-sorter.d.ts +4 -8
- package/es/data-table/src/use-sorter.mjs +14 -2
- package/es/data-table/src/use-table-data.d.ts +11 -14
- package/es/data-table/src/use-table-data.mjs +4 -2
- package/es/data-table/src/use-table-storage.d.ts +2 -2
- package/es/data-table/src/use-table-storage.mjs +1 -1
- package/es/data-table/src/utils/column-utils.d.ts +3 -2
- package/es/data-table/src/utils/column-utils.mjs +9 -1
- package/es/data-table/src/utils/csv-utils.mjs +1 -1
- package/es/data-table/src/utils/flatten-rows.d.ts +2 -0
- package/es/data-table/src/utils/flatten-rows.mjs +33 -0
- package/es/data-table/src/utils/index.d.ts +1 -0
- package/es/data-table/src/utils/index.mjs +1 -0
- package/es/data-table/src/utils/resize-orchestrator-utils.d.ts +3 -5
- package/es/data-table/src/utils/width-utils.d.ts +2 -2
- package/es/data-table/styles/light.d.ts +6 -0
- package/es/data-table/styles/light.mjs +3 -0
- package/es/mapping-card/src/MappingCard.d.ts +8 -0
- package/es/mapping-card/src/MappingCard.mjs +3 -1
- package/es/mapping-card/src/MappingCardParts/Header.mjs +31 -10
- package/es/mapping-card/src/interface.d.ts +8 -0
- package/es/mapping-card/src/interface.mjs +4 -0
- package/es/mapping-card/src/styles/index.cssr.mjs +8 -1
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/lib/_internal/icons/DragHandleRound.d.ts +2 -0
- package/lib/_internal/icons/DragHandleRound.js +10 -0
- package/lib/_internal/icons/index.d.ts +1 -0
- package/lib/_internal/icons/index.js +4 -2
- package/lib/components.d.ts +32 -0
- package/lib/data-table/src/DataTable.d.ts +24 -0
- package/lib/data-table/src/DataTable.js +19 -1
- package/lib/data-table/src/HeaderButton/FilterButton.d.ts +6 -0
- package/lib/data-table/src/HeaderButton/FilterMenu.d.ts +6 -0
- package/lib/data-table/src/TableParts/Body.d.ts +18 -10
- package/lib/data-table/src/TableParts/Body.js +65 -237
- package/lib/data-table/src/TableParts/BodyEmpty.d.ts +3 -0
- package/lib/data-table/src/TableParts/BodyEmpty.js +15 -0
- package/lib/data-table/src/TableParts/BodyRow.d.ts +3 -0
- package/lib/data-table/src/TableParts/BodyRow.js +210 -0
- package/lib/data-table/src/TableParts/BodySkeleton.js +8 -2
- package/lib/data-table/src/TableParts/Header.d.ts +6 -0
- package/lib/data-table/src/TableParts/Header.js +6 -0
- package/lib/data-table/src/TableParts/VirtualListItemWrapper.d.ts +36 -0
- package/lib/data-table/src/TableParts/VirtualListItemWrapper.js +29 -0
- package/lib/data-table/src/interface.d.ts +161 -2
- package/lib/data-table/src/styles/index.cssr.js +26 -3
- package/lib/data-table/src/use-group-header.d.ts +3 -3
- package/lib/data-table/src/use-row-drag.d.ts +2 -0
- package/lib/data-table/src/use-row-drag.js +270 -0
- package/lib/data-table/src/use-sorter.d.ts +4 -8
- package/lib/data-table/src/use-sorter.js +14 -0
- package/lib/data-table/src/use-table-data.d.ts +11 -14
- package/lib/data-table/src/use-table-data.js +5 -1
- package/lib/data-table/src/use-table-storage.d.ts +2 -2
- package/lib/data-table/src/use-table-storage.js +1 -0
- package/lib/data-table/src/utils/column-utils.d.ts +3 -2
- package/lib/data-table/src/utils/column-utils.js +11 -2
- package/lib/data-table/src/utils/csv-utils.js +1 -0
- package/lib/data-table/src/utils/flatten-rows.d.ts +2 -0
- package/lib/data-table/src/utils/flatten-rows.js +35 -0
- package/lib/data-table/src/utils/index.d.ts +1 -0
- package/lib/data-table/src/utils/index.js +1 -0
- package/lib/data-table/src/utils/resize-orchestrator-utils.d.ts +3 -5
- package/lib/data-table/src/utils/width-utils.d.ts +2 -2
- package/lib/data-table/styles/light.d.ts +6 -0
- package/lib/data-table/styles/light.js +3 -0
- package/lib/mapping-card/src/MappingCard.d.ts +8 -0
- package/lib/mapping-card/src/MappingCard.js +5 -1
- package/lib/mapping-card/src/MappingCardParts/Header.js +29 -5
- package/lib/mapping-card/src/interface.d.ts +8 -0
- package/lib/mapping-card/src/interface.js +4 -0
- package/lib/mapping-card/src/styles/index.cssr.js +8 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +9 -8
- package/web-types.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComputedRef, CSSProperties } from 'vue';
|
|
2
|
-
import type { ColumnKey,
|
|
2
|
+
import type { ColumnKey, DataRelatedColumn, DataTableSetupProps, TableColumn } from './interface';
|
|
3
3
|
export interface RowItem {
|
|
4
4
|
colSpan: number;
|
|
5
5
|
rowSpan: number;
|
|
@@ -9,11 +9,11 @@ export interface RowItem {
|
|
|
9
9
|
export interface ColItem {
|
|
10
10
|
key: string | number;
|
|
11
11
|
style: CSSProperties;
|
|
12
|
-
column:
|
|
12
|
+
column: DataRelatedColumn;
|
|
13
13
|
}
|
|
14
14
|
export declare function useGroupHeader(props: DataTableSetupProps, getResizableWidth: (key: ColumnKey) => number | undefined): {
|
|
15
15
|
rowsRef: ComputedRef<RowItem[][]>;
|
|
16
16
|
colsRef: ComputedRef<ColItem[]>;
|
|
17
17
|
hasEllipsisRef: ComputedRef<boolean>;
|
|
18
|
-
dataRelatedColsRef: ComputedRef<
|
|
18
|
+
dataRelatedColsRef: ComputedRef<DataRelatedColumn[]>;
|
|
19
19
|
};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { useMemo } from 'vooks';
|
|
2
|
+
import { computed, ref } from 'vue';
|
|
3
|
+
const DROP_HALF_DIVISOR = 2;
|
|
4
|
+
const DROP_STEP_BIAS = 1;
|
|
5
|
+
const FALLBACK_ORDER = 0;
|
|
6
|
+
const SINGLE_ROW_DRAG_SIZE = 1;
|
|
7
|
+
const DRAG_IMAGE_OFFSET = 0;
|
|
8
|
+
const GHOST_OFFSCREEN_TOP_PX = -10000;
|
|
9
|
+
const GHOST_CLEANUP_DELAY_MS = 0;
|
|
10
|
+
export function useRowDrag(props, {
|
|
11
|
+
paginatedDataRef,
|
|
12
|
+
mergedCheckedRowKeySetRef,
|
|
13
|
+
mergedClsPrefixRef
|
|
14
|
+
}) {
|
|
15
|
+
const draggableColumnRef = useMemo(() => {
|
|
16
|
+
const findDraggableColumn = columns => {
|
|
17
|
+
for (const column of columns) {
|
|
18
|
+
if ('children' in column) {
|
|
19
|
+
const nested = findDraggableColumn(column.children);
|
|
20
|
+
if (nested) return nested;
|
|
21
|
+
} else if (column.type === 'draggable') {
|
|
22
|
+
return column;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
return findDraggableColumn(props.columns);
|
|
28
|
+
});
|
|
29
|
+
const draggingRowKeysRef = ref([]);
|
|
30
|
+
const draggingRowKeySetRef = computed(() => new Set(draggingRowKeysRef.value));
|
|
31
|
+
const droppingRowKeyRef = ref(null);
|
|
32
|
+
const droppingPositionRef = ref(null);
|
|
33
|
+
function resetDropState() {
|
|
34
|
+
droppingRowKeyRef.value = null;
|
|
35
|
+
droppingPositionRef.value = null;
|
|
36
|
+
}
|
|
37
|
+
function isRowDraggable(rowData) {
|
|
38
|
+
const column = draggableColumnRef.value;
|
|
39
|
+
if (!column) return false;
|
|
40
|
+
if (typeof column.draggable === 'function') {
|
|
41
|
+
return column.draggable(rowData);
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
function getRowByKey(targetKey) {
|
|
46
|
+
var _a;
|
|
47
|
+
return (_a = paginatedDataRef.value.find(node => node.key === targetKey)) === null || _a === void 0 ? void 0 : _a.rawNode;
|
|
48
|
+
}
|
|
49
|
+
function resolveDragKeys(initialRowKey) {
|
|
50
|
+
const checkedSet = mergedCheckedRowKeySetRef.value;
|
|
51
|
+
if (!checkedSet.has(initialRowKey)) return [initialRowKey];
|
|
52
|
+
const keysInOrder = [];
|
|
53
|
+
for (const node of paginatedDataRef.value) {
|
|
54
|
+
if (checkedSet.has(node.key) && isRowDraggable(node.rawNode)) {
|
|
55
|
+
keysInOrder.push(node.key);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return keysInOrder.length ? keysInOrder : [initialRowKey];
|
|
59
|
+
}
|
|
60
|
+
function applyDragImage(event) {
|
|
61
|
+
if (!event.dataTransfer || typeof event.dataTransfer.setDragImage !== 'function') {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const cellElement = event.currentTarget;
|
|
65
|
+
const rowElement = cellElement === null || cellElement === void 0 ? void 0 : cellElement.closest('tr');
|
|
66
|
+
if (!rowElement) return;
|
|
67
|
+
const draggedSet = draggingRowKeySetRef.value;
|
|
68
|
+
if (draggedSet.size <= SINGLE_ROW_DRAG_SIZE) {
|
|
69
|
+
event.dataTransfer.setDragImage(rowElement, DRAG_IMAGE_OFFSET, DRAG_IMAGE_OFFSET);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const tableElement = rowElement.closest('table');
|
|
73
|
+
if (!tableElement) {
|
|
74
|
+
event.dataTransfer.setDragImage(rowElement, DRAG_IMAGE_OFFSET, DRAG_IMAGE_OFFSET);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const mergedClsPrefix = mergedClsPrefixRef.value;
|
|
78
|
+
const keyStringSet = new Set(Array.from(draggedSet).map(String));
|
|
79
|
+
const ghost = tableElement.cloneNode(true);
|
|
80
|
+
ghost.classList.add(`${mergedClsPrefix}-data-table-drag-ghost`);
|
|
81
|
+
ghost.querySelectorAll('thead').forEach(headElement => headElement.remove());
|
|
82
|
+
ghost.querySelectorAll('tbody > tr').forEach(rowChild => {
|
|
83
|
+
const childKey = rowChild.getAttribute('data-row-key');
|
|
84
|
+
if (childKey === null || !keyStringSet.has(childKey)) rowChild.remove();
|
|
85
|
+
});
|
|
86
|
+
ghost.style.position = 'fixed';
|
|
87
|
+
ghost.style.top = `${GHOST_OFFSCREEN_TOP_PX}px`;
|
|
88
|
+
ghost.style.left = '0';
|
|
89
|
+
ghost.style.pointerEvents = 'none';
|
|
90
|
+
ghost.style.width = `${tableElement.offsetWidth}px`;
|
|
91
|
+
const hostElement = tableElement.closest(`.${mergedClsPrefix}-data-table`) || document.body;
|
|
92
|
+
hostElement.appendChild(ghost);
|
|
93
|
+
event.dataTransfer.setDragImage(ghost, DRAG_IMAGE_OFFSET, DRAG_IMAGE_OFFSET);
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
if (ghost.parentNode) ghost.parentNode.removeChild(ghost);
|
|
96
|
+
}, GHOST_CLEANUP_DELAY_MS);
|
|
97
|
+
}
|
|
98
|
+
function handleRowDragStart(event, rowKey) {
|
|
99
|
+
const row = getRowByKey(rowKey);
|
|
100
|
+
if (!row || !isRowDraggable(row)) {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
draggingRowKeysRef.value = resolveDragKeys(rowKey);
|
|
105
|
+
if (event.dataTransfer) {
|
|
106
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
107
|
+
event.dataTransfer.setData('text/plain', draggingRowKeysRef.value.map(String).join(','));
|
|
108
|
+
}
|
|
109
|
+
applyDragImage(event);
|
|
110
|
+
}
|
|
111
|
+
function handleRowDragOver(event, rowKey) {
|
|
112
|
+
if (!draggableColumnRef.value) return;
|
|
113
|
+
if (!draggingRowKeysRef.value.length) return;
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
if (event.dataTransfer) {
|
|
116
|
+
event.dataTransfer.dropEffect = 'move';
|
|
117
|
+
}
|
|
118
|
+
if (draggingRowKeySetRef.value.has(rowKey)) {
|
|
119
|
+
resetDropState();
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const target = event.currentTarget;
|
|
123
|
+
if (!target) return;
|
|
124
|
+
const rect = target.getBoundingClientRect();
|
|
125
|
+
const offset = event.clientY - rect.top;
|
|
126
|
+
const position = offset < rect.height / DROP_HALF_DIVISOR ? 'before' : 'after';
|
|
127
|
+
droppingRowKeyRef.value = rowKey;
|
|
128
|
+
droppingPositionRef.value = position;
|
|
129
|
+
}
|
|
130
|
+
function handleRowDragLeave(event, rowKey) {
|
|
131
|
+
if (droppingRowKeyRef.value !== rowKey) return;
|
|
132
|
+
const related = event.relatedTarget;
|
|
133
|
+
const current = event.currentTarget;
|
|
134
|
+
if (related && current && current.contains(related)) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
resetDropState();
|
|
138
|
+
}
|
|
139
|
+
function handleRowDragEnd() {
|
|
140
|
+
draggingRowKeysRef.value = [];
|
|
141
|
+
resetDropState();
|
|
142
|
+
}
|
|
143
|
+
function readOrder(row, orderKey) {
|
|
144
|
+
const value = row === null || row === void 0 ? void 0 : row[orderKey];
|
|
145
|
+
return typeof value === 'number' ? value : Number(value) || FALLBACK_ORDER;
|
|
146
|
+
}
|
|
147
|
+
function computeNewOrders(draggedKeys, dropIndex, position, orderKey) {
|
|
148
|
+
var _a, _b, _c;
|
|
149
|
+
const rows = paginatedDataRef.value;
|
|
150
|
+
if (!rows.length) return null;
|
|
151
|
+
const draggedSet = new Set(draggedKeys);
|
|
152
|
+
const draggedIndexes = rows.map((node, index) => draggedSet.has(node.key) ? index : -1).filter(index => index >= 0);
|
|
153
|
+
if (!draggedIndexes.length) return null;
|
|
154
|
+
const filtered = rows.filter(node => !draggedSet.has(node.key));
|
|
155
|
+
const targetIndex = position === 'before' ? dropIndex : dropIndex + 1;
|
|
156
|
+
const removedBefore = draggedIndexes.filter(index => index < targetIndex).length;
|
|
157
|
+
const insertAt = Math.max(0, targetIndex - removedBefore);
|
|
158
|
+
const prev = (_a = filtered[insertAt - 1]) === null || _a === void 0 ? void 0 : _a.rawNode;
|
|
159
|
+
const next = (_b = filtered[insertAt]) === null || _b === void 0 ? void 0 : _b.rawNode;
|
|
160
|
+
const draggedCount = draggedKeys.length;
|
|
161
|
+
const orders = [];
|
|
162
|
+
if (prev && next) {
|
|
163
|
+
const prevOrder = readOrder(prev, orderKey);
|
|
164
|
+
const nextOrder = readOrder(next, orderKey);
|
|
165
|
+
const step = (nextOrder - prevOrder) / (draggedCount + DROP_STEP_BIAS);
|
|
166
|
+
for (let index = 0; index < draggedCount; index++) {
|
|
167
|
+
orders.push(prevOrder + step * (index + DROP_STEP_BIAS));
|
|
168
|
+
}
|
|
169
|
+
} else if (!prev && next) {
|
|
170
|
+
const nextOrder = readOrder(next, orderKey);
|
|
171
|
+
for (let index = 0; index < draggedCount; index++) {
|
|
172
|
+
orders.push(nextOrder - (draggedCount - index));
|
|
173
|
+
}
|
|
174
|
+
} else if (prev && !next) {
|
|
175
|
+
const prevOrder = readOrder(prev, orderKey);
|
|
176
|
+
for (let index = 0; index < draggedCount; index++) {
|
|
177
|
+
orders.push(prevOrder + (index + DROP_STEP_BIAS));
|
|
178
|
+
}
|
|
179
|
+
} else {
|
|
180
|
+
for (const key of draggedKeys) {
|
|
181
|
+
const row = (_c = rows.find(node => node.key === key)) === null || _c === void 0 ? void 0 : _c.rawNode;
|
|
182
|
+
orders.push(readOrder(row, orderKey));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return orders;
|
|
186
|
+
}
|
|
187
|
+
function handleRowDrop(event, rowKey) {
|
|
188
|
+
event.preventDefault();
|
|
189
|
+
const column = draggableColumnRef.value;
|
|
190
|
+
const draggedKeys = draggingRowKeysRef.value;
|
|
191
|
+
const position = droppingPositionRef.value;
|
|
192
|
+
if (!column || !draggedKeys.length || position === null || draggingRowKeySetRef.value.has(rowKey)) {
|
|
193
|
+
handleRowDragEnd();
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const rows = paginatedDataRef.value;
|
|
197
|
+
const dropIndex = rows.findIndex(node => node.key === rowKey);
|
|
198
|
+
if (dropIndex < 0) {
|
|
199
|
+
handleRowDragEnd();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const orderKey = column.key;
|
|
203
|
+
const newOrders = computeNewOrders(draggedKeys, dropIndex, position, orderKey);
|
|
204
|
+
const dispatchPlan = draggedKeys.map((key, index) => {
|
|
205
|
+
var _a;
|
|
206
|
+
const row = (_a = rows.find(node => node.key === key)) === null || _a === void 0 ? void 0 : _a.rawNode;
|
|
207
|
+
return row ? {
|
|
208
|
+
row,
|
|
209
|
+
oldOrder: readOrder(row, orderKey),
|
|
210
|
+
newOrder: newOrders ? newOrders[index] : readOrder(row, orderKey)
|
|
211
|
+
} : null;
|
|
212
|
+
});
|
|
213
|
+
const targetIndex = position === 'before' ? dropIndex : dropIndex + 1;
|
|
214
|
+
const draggedSet = draggingRowKeySetRef.value;
|
|
215
|
+
const draggedIndexes = rows.map((node, index) => draggedSet.has(node.key) ? index : -1).filter(index => index >= 0);
|
|
216
|
+
const removedBefore = draggedIndexes.filter(index => index < targetIndex).length;
|
|
217
|
+
const baseIndex = Math.max(0, targetIndex - removedBefore);
|
|
218
|
+
handleRowDragEnd();
|
|
219
|
+
if (!newOrders) return;
|
|
220
|
+
dispatchPlan.forEach((entry, index) => {
|
|
221
|
+
var _a;
|
|
222
|
+
if (!entry) return;
|
|
223
|
+
(_a = column.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(column, entry.row, {
|
|
224
|
+
index: baseIndex + index,
|
|
225
|
+
oldOrder: entry.oldOrder,
|
|
226
|
+
newOrder: entry.newOrder
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
draggableColumnRef,
|
|
232
|
+
draggingRowKeySetRef,
|
|
233
|
+
droppingRowKeyRef,
|
|
234
|
+
droppingPositionRef,
|
|
235
|
+
handleRowDragStart,
|
|
236
|
+
handleRowDragOver,
|
|
237
|
+
handleRowDragLeave,
|
|
238
|
+
handleRowDragEnd,
|
|
239
|
+
handleRowDrop
|
|
240
|
+
};
|
|
241
|
+
}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare function useSorter(props: DataTableSetupProps, { dataRelatedColsRef, filteredDataRef }: {
|
|
4
|
-
dataRelatedColsRef: ComputedRef<Array<TableSelectionColumn | TableBaseColumn | TableExpandColumn>>;
|
|
5
|
-
filteredDataRef: ComputedRef<TmNode[]>;
|
|
6
|
-
}): {
|
|
1
|
+
import type { ColumnKey, CompareFn, DataTableSetupProps, InternalRowData, SortOrder, SortState, TmNode, UseSorterDeps } from './interface';
|
|
2
|
+
export declare function useSorter(props: DataTableSetupProps, { dataRelatedColsRef, filteredDataRef }: UseSorterDeps): {
|
|
7
3
|
clearSorter: () => void;
|
|
8
4
|
sort: (columnKey: ColumnKey, order?: SortOrder) => void;
|
|
9
|
-
sortedDataRef: ComputedRef<TmNode[]>;
|
|
10
|
-
mergedSortStateRef: ComputedRef<{
|
|
5
|
+
sortedDataRef: import("vue").ComputedRef<TmNode[]>;
|
|
6
|
+
mergedSortStateRef: import("vue").ComputedRef<{
|
|
11
7
|
columnKey: ColumnKey;
|
|
12
8
|
order: SortOrder;
|
|
13
9
|
sorter: boolean | "default" | CompareFn<InternalRowData> | {
|
|
@@ -51,7 +51,7 @@ export function useSorter(props, {
|
|
|
51
51
|
const mergedSortStateRef = computed(() => {
|
|
52
52
|
// If one of the columns's sort order is false or 'ascend' or 'descend',
|
|
53
53
|
// the table's controll functionality should work in controlled manner.
|
|
54
|
-
const columnsWithControlledSortOrder = dataRelatedColsRef.value.filter(column => column.type !== 'selection' && column.sorter !== undefined && (column.sortOrder === 'ascend' || column.sortOrder === 'descend' || column.sortOrder === false));
|
|
54
|
+
const columnsWithControlledSortOrder = dataRelatedColsRef.value.filter(column => column.type !== 'selection' && column.type !== 'draggable' && column.sorter !== undefined && (column.sortOrder === 'ascend' || column.sortOrder === 'descend' || column.sortOrder === false));
|
|
55
55
|
// if multiple columns are controlled sortable, then we need to find columns with active sortOrder
|
|
56
56
|
const columnToSort = columnsWithControlledSortOrder.filter(col => col.sortOrder !== false);
|
|
57
57
|
if (columnToSort.length) {
|
|
@@ -108,6 +108,18 @@ export function useSorter(props, {
|
|
|
108
108
|
return compareResult;
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
+
const draggableColumn = dataRelatedColsRef.value.find(column => column.type === 'draggable' && column.sortByKey !== false);
|
|
112
|
+
if (draggableColumn) {
|
|
113
|
+
const orderKey = draggableColumn.key;
|
|
114
|
+
return filteredDataRef.value.slice().sort((tmNode1, tmNode2) => {
|
|
115
|
+
const order1 = tmNode1.rawNode[orderKey];
|
|
116
|
+
const order2 = tmNode2.rawNode[orderKey];
|
|
117
|
+
if (typeof order1 === 'number' && typeof order2 === 'number') {
|
|
118
|
+
return order1 - order2;
|
|
119
|
+
}
|
|
120
|
+
return 0;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
111
123
|
return filteredDataRef.value;
|
|
112
124
|
});
|
|
113
125
|
function getUpdatedSorterState(sortState) {
|
|
@@ -150,7 +162,7 @@ export function useSorter(props, {
|
|
|
150
162
|
if (!columnKey) {
|
|
151
163
|
clearSorter();
|
|
152
164
|
} else {
|
|
153
|
-
const columnToSort = dataRelatedColsRef.value.find(column => column.type !== 'selection' && column.type !== 'expand' && column.key === columnKey);
|
|
165
|
+
const columnToSort = dataRelatedColsRef.value.find(column => column.type !== 'selection' && column.type !== 'expand' && column.type !== 'draggable' && column.key === columnKey);
|
|
154
166
|
if (!(columnToSort === null || columnToSort === void 0 ? void 0 : columnToSort.sorter)) return;
|
|
155
167
|
const sorter = columnToSort.sorter;
|
|
156
168
|
deriveNextSorter({
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import type { ComputedRef } from 'vue';
|
|
2
1
|
import type { PaginationProps } from '../../pagination/src/Pagination';
|
|
3
|
-
import type { ColumnKey, DataTableSetupProps, FilterState, InternalRowData, RowKey, SortState, TableBaseColumn,
|
|
4
|
-
export declare function useTableData(props: DataTableSetupProps, { dataRelatedColsRef }: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
mergedFilterStateRef: ComputedRef<FilterState>;
|
|
13
|
-
mergedSortStateRef: ComputedRef<{
|
|
2
|
+
import type { ColumnKey, DataTableSetupProps, FilterState, InternalRowData, RowKey, SortState, TableBaseColumn, TableSelectionColumn, TmNode, UseTableDataDeps } from './interface';
|
|
3
|
+
export declare function useTableData(props: DataTableSetupProps, { dataRelatedColsRef }: UseTableDataDeps): {
|
|
4
|
+
treeMateRef: import("vue").ComputedRef<import("treemate").TreeMate<InternalRowData, InternalRowData, InternalRowData>>;
|
|
5
|
+
mergedCurrentPageRef: import("vue").ComputedRef<number>;
|
|
6
|
+
mergedPaginationRef: import("vue").ComputedRef<PaginationProps>;
|
|
7
|
+
paginatedDataRef: import("vue").ComputedRef<TmNode[]>;
|
|
8
|
+
rawPaginatedDataRef: import("vue").ComputedRef<InternalRowData[]>;
|
|
9
|
+
mergedFilterStateRef: import("vue").ComputedRef<FilterState>;
|
|
10
|
+
mergedSortStateRef: import("vue").ComputedRef<{
|
|
14
11
|
columnKey: ColumnKey;
|
|
15
12
|
order: import("./interface").SortOrder;
|
|
16
13
|
sorter: boolean | "default" | import("./interface").CompareFn<InternalRowData> | {
|
|
@@ -19,8 +16,8 @@ export declare function useTableData(props: DataTableSetupProps, { dataRelatedCo
|
|
|
19
16
|
};
|
|
20
17
|
}[]>;
|
|
21
18
|
hoverKeyRef: import("vue").Ref<RowKey | null, RowKey | null>;
|
|
22
|
-
selectionColumnRef: ComputedRef<TableSelectionColumn | null>;
|
|
23
|
-
childTriggerColIndexRef: ComputedRef<number>;
|
|
19
|
+
selectionColumnRef: import("vue").ComputedRef<TableSelectionColumn | null>;
|
|
20
|
+
childTriggerColIndexRef: import("vue").ComputedRef<number>;
|
|
24
21
|
doUpdateFilters: (filters: FilterState, sourceColumn: TableBaseColumn) => void;
|
|
25
22
|
deriveNextSorter: (sortState: SortState | null) => void;
|
|
26
23
|
doUpdatePageSize: (pageSize: number) => void;
|
|
@@ -68,7 +68,9 @@ export function useTableData(props, {
|
|
|
68
68
|
const controlledFilterState = {};
|
|
69
69
|
columnsWithControlledFilter.forEach(column => {
|
|
70
70
|
var _a;
|
|
71
|
-
if (column.type === 'selection' || column.type === 'expand')
|
|
71
|
+
if (column.type === 'selection' || column.type === 'expand' || column.type === 'draggable') {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
72
74
|
if (column.filterOptionValues === undefined) {
|
|
73
75
|
controlledFilterState[column.key] = (_a = column.filterOptionValue) !== null && _a !== void 0 ? _a : null;
|
|
74
76
|
} else {
|
|
@@ -93,7 +95,7 @@ export function useTableData(props, {
|
|
|
93
95
|
} = treeMateRef;
|
|
94
96
|
const columnEntries = [];
|
|
95
97
|
columns.forEach(column => {
|
|
96
|
-
if (column.type === 'selection' || column.type === 'expand' || 'children' in column) {
|
|
98
|
+
if (column.type === 'selection' || column.type === 'expand' || column.type === 'draggable' || 'children' in column) {
|
|
97
99
|
return;
|
|
98
100
|
}
|
|
99
101
|
columnEntries.push([column.key, column]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataTableStorageState, SortState
|
|
1
|
+
import type { DataRelatedColumn, DataTableStorageState, SortState } from './interface';
|
|
2
2
|
export declare function loadTableState(localStorageKey: string): DataTableStorageState | null;
|
|
3
3
|
export declare function saveTableState(localStorageKey: string, state: DataTableStorageState): void;
|
|
4
|
-
export declare function restoreSortStateFromStored(stored: DataTableStorageState['sortState'], dataRelatedCols:
|
|
4
|
+
export declare function restoreSortStateFromStored(stored: DataTableStorageState['sortState'], dataRelatedCols: DataRelatedColumn[]): SortState[] | null;
|
|
@@ -22,7 +22,7 @@ export function restoreSortStateFromStored(stored, dataRelatedCols) {
|
|
|
22
22
|
if (!(stored === null || stored === void 0 ? void 0 : stored.length)) return null;
|
|
23
23
|
const result = [];
|
|
24
24
|
for (const item of stored) {
|
|
25
|
-
const column = dataRelatedCols.find(col => col.type !== 'selection' && col.type !== 'expand' && 'key' in col && col.key === item.columnKey && col.sorter !== undefined);
|
|
25
|
+
const column = dataRelatedCols.find(col => col.type !== 'selection' && col.type !== 'expand' && col.type !== 'draggable' && 'key' in col && col.key === item.columnKey && col.sorter !== undefined);
|
|
26
26
|
if (column === null || column === void 0 ? void 0 : column.sorter) {
|
|
27
27
|
result.push({
|
|
28
28
|
columnKey: item.columnKey,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { CSSProperties } from 'vue';
|
|
2
|
-
import type { CreateRowClassName,
|
|
2
|
+
import type { CreateRowClassName, DataRelatedColumn, InternalRowData, TableColumn } from '../interface';
|
|
3
3
|
export declare const SELECTION_COL_WIDTH = 40;
|
|
4
4
|
export declare const EXPAND_COL_WIDTH = 40;
|
|
5
|
+
export declare const DRAGGABLE_COL_WIDTH = 40;
|
|
5
6
|
export declare function getNumberColWidth(column: TableColumn): number | undefined;
|
|
6
7
|
export declare function getStringColWidth(column: TableColumn): string | undefined;
|
|
7
8
|
export declare function getColKey(column: TableColumn): string | number;
|
|
8
|
-
export declare function createCustomWidthStyle(column:
|
|
9
|
+
export declare function createCustomWidthStyle(column: DataRelatedColumn, resizedWidth?: string): CSSProperties;
|
|
9
10
|
export declare function createRowClassName(row: InternalRowData, index: number, rowClassName?: string | CreateRowClassName): string;
|
|
10
11
|
export declare function isColumnSortable(column: TableColumn): boolean;
|
|
11
12
|
export declare function isColumnEllipsisEnabled(column: Pick<TableColumn, 'ellipsis'>): boolean;
|
|
@@ -3,6 +3,7 @@ import { formatLength } from "../../../_utils/index.mjs";
|
|
|
3
3
|
import { clampValueFollowCSSRules, parseLengthToNumber } from "./width-utils.mjs";
|
|
4
4
|
export const SELECTION_COL_WIDTH = 40;
|
|
5
5
|
export const EXPAND_COL_WIDTH = 40;
|
|
6
|
+
export const DRAGGABLE_COL_WIDTH = 40;
|
|
6
7
|
export function getNumberColWidth(column) {
|
|
7
8
|
if (column.type === 'selection') {
|
|
8
9
|
return column.width === undefined ? SELECTION_COL_WIDTH : depx(column.width);
|
|
@@ -10,6 +11,9 @@ export function getNumberColWidth(column) {
|
|
|
10
11
|
if (column.type === 'expand') {
|
|
11
12
|
return column.width === undefined ? EXPAND_COL_WIDTH : depx(column.width);
|
|
12
13
|
}
|
|
14
|
+
if (column.type === 'draggable') {
|
|
15
|
+
return column.width === undefined ? DRAGGABLE_COL_WIDTH : depx(column.width);
|
|
16
|
+
}
|
|
13
17
|
if ('children' in column) return undefined;
|
|
14
18
|
if (typeof column.width === 'string') {
|
|
15
19
|
return depx(column.width);
|
|
@@ -17,13 +21,16 @@ export function getNumberColWidth(column) {
|
|
|
17
21
|
return column.width;
|
|
18
22
|
}
|
|
19
23
|
export function getStringColWidth(column) {
|
|
20
|
-
var _a, _b;
|
|
24
|
+
var _a, _b, _c;
|
|
21
25
|
if (column.type === 'selection') {
|
|
22
26
|
return formatLength((_a = column.width) !== null && _a !== void 0 ? _a : SELECTION_COL_WIDTH);
|
|
23
27
|
}
|
|
24
28
|
if (column.type === 'expand') {
|
|
25
29
|
return formatLength((_b = column.width) !== null && _b !== void 0 ? _b : EXPAND_COL_WIDTH);
|
|
26
30
|
}
|
|
31
|
+
if (column.type === 'draggable') {
|
|
32
|
+
return formatLength((_c = column.width) !== null && _c !== void 0 ? _c : DRAGGABLE_COL_WIDTH);
|
|
33
|
+
}
|
|
27
34
|
if ('children' in column) {
|
|
28
35
|
return undefined;
|
|
29
36
|
}
|
|
@@ -32,6 +39,7 @@ export function getStringColWidth(column) {
|
|
|
32
39
|
export function getColKey(column) {
|
|
33
40
|
if (column.type === 'selection') return '__n_selection__';
|
|
34
41
|
if (column.type === 'expand') return '__n_expand__';
|
|
42
|
+
if (column.type === 'draggable') return '__n_draggable__';
|
|
35
43
|
return column.key;
|
|
36
44
|
}
|
|
37
45
|
export function createCustomWidthStyle(column, resizedWidth) {
|
|
@@ -8,7 +8,7 @@ function formatCsvCell(value) {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
export function generateCsv(columns, data, getCsvCell, getCsvHeader) {
|
|
11
|
-
const exportableColumns = columns.filter(column => column.type !== 'expand' && column.type !== 'selection' && column.allowExport !== false);
|
|
11
|
+
const exportableColumns = columns.filter(column => column.type !== 'expand' && column.type !== 'selection' && column.type !== 'draggable' && column.allowExport !== false);
|
|
12
12
|
const header = exportableColumns.map(col => {
|
|
13
13
|
return getCsvHeader ? getCsvHeader(col) : col.title;
|
|
14
14
|
}).join(',');
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function flattenExpandedRows(rowInfos, expandedRowKeys) {
|
|
2
|
+
const flattenedRows = [];
|
|
3
|
+
function traverse(nodes, rootIndex) {
|
|
4
|
+
nodes.forEach(node => {
|
|
5
|
+
if (node.children && expandedRowKeys.has(node.key)) {
|
|
6
|
+
flattenedRows.push({
|
|
7
|
+
tmNode: node,
|
|
8
|
+
striped: false,
|
|
9
|
+
key: node.key,
|
|
10
|
+
index: rootIndex
|
|
11
|
+
});
|
|
12
|
+
traverse(node.children, rootIndex);
|
|
13
|
+
} else {
|
|
14
|
+
flattenedRows.push({
|
|
15
|
+
key: node.key,
|
|
16
|
+
tmNode: node,
|
|
17
|
+
striped: false,
|
|
18
|
+
index: rootIndex
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
rowInfos.forEach(rowInfo => {
|
|
24
|
+
flattenedRows.push(rowInfo);
|
|
25
|
+
const {
|
|
26
|
+
children
|
|
27
|
+
} = rowInfo.tmNode;
|
|
28
|
+
if (children && expandedRowKeys.has(rowInfo.key)) {
|
|
29
|
+
traverse(children, rowInfo.index);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return flattenedRows;
|
|
33
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { ColumnWidthComputationItem,
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function deriveResizableColumnWidthItems(columns: ResizableLeafColumn[]): ColumnWidthComputationItem[];
|
|
1
|
+
import type { ColumnWidthComputationItem, DataRelatedColumn } from '../interface';
|
|
2
|
+
export declare function deriveVisibleLeafColumnWidthItems(columns: DataRelatedColumn[]): ColumnWidthComputationItem[];
|
|
3
|
+
export declare function deriveResizableColumnWidthItems(columns: DataRelatedColumn[]): ColumnWidthComputationItem[];
|
|
5
4
|
export declare function deriveColumnWidthSignature(columns: ColumnWidthComputationItem[]): string;
|
|
6
|
-
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ColumnKey, ColumnWidthComputationItem,
|
|
1
|
+
import type { ColumnKey, ColumnWidthComputationItem, DataRelatedColumn } from '../interface';
|
|
2
2
|
export interface ColumnWidthConstraint {
|
|
3
3
|
min?: number;
|
|
4
4
|
max?: number;
|
|
5
5
|
}
|
|
6
6
|
export declare function clampValueFollowCSSRules(value: number, min?: number | string, max?: number | string): number;
|
|
7
7
|
export declare function parseLengthToNumber(value: number | string | undefined): number | undefined;
|
|
8
|
-
export declare function resolveColumnWidthConstraint(column:
|
|
8
|
+
export declare function resolveColumnWidthConstraint(column: DataRelatedColumn | ColumnWidthComputationItem, systemMinWidth?: number | string, systemMaxWidth?: number | string): ColumnWidthConstraint;
|
|
9
9
|
export declare function computeFixedTableColumnWidths(columns: ColumnWidthComputationItem[], { containerWidth, systemMinWidth, systemMaxWidth, preferredWidths }: {
|
|
10
10
|
containerWidth?: number;
|
|
11
11
|
systemMinWidth?: number | string;
|
|
@@ -41,6 +41,9 @@ export declare function self(vars: ThemeCommonVars): {
|
|
|
41
41
|
thButtonColorHover: string;
|
|
42
42
|
thIconColor: string;
|
|
43
43
|
thIconColorActive: string;
|
|
44
|
+
dropMarkColor: string;
|
|
45
|
+
dragGhostOpacity: string;
|
|
46
|
+
dragGhostFilter: string;
|
|
44
47
|
borderColorModal: string;
|
|
45
48
|
tdColorHoverModal: string;
|
|
46
49
|
tdColorStripedModal: string;
|
|
@@ -102,6 +105,9 @@ declare const dataTableLight: import("../../_mixins").Theme<"DataTable", {
|
|
|
102
105
|
thButtonColorHover: string;
|
|
103
106
|
thIconColor: string;
|
|
104
107
|
thIconColorActive: string;
|
|
108
|
+
dropMarkColor: string;
|
|
109
|
+
dragGhostOpacity: string;
|
|
110
|
+
dragGhostFilter: string;
|
|
105
111
|
borderColorModal: string;
|
|
106
112
|
tdColorHoverModal: string;
|
|
107
113
|
tdColorStripedModal: string;
|
|
@@ -71,6 +71,9 @@ export function self(vars) {
|
|
|
71
71
|
thButtonColorHover: elementsTertiary,
|
|
72
72
|
thIconColor: elementsPrimary,
|
|
73
73
|
thIconColorActive: brandPrimary500,
|
|
74
|
+
dropMarkColor: brandPrimary500,
|
|
75
|
+
dragGhostOpacity: '0.85',
|
|
76
|
+
dragGhostFilter: 'drop-shadow(0 4px 12px rgba(0, 0, 0, 0.18))',
|
|
74
77
|
// modal
|
|
75
78
|
borderColorModal: elementsQuaternary,
|
|
76
79
|
tdColorHoverModal: elementsTertiary,
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
2
|
title: import("vue").PropType<import("./interface").MappingCardInterface["title"]>;
|
|
3
3
|
description: import("vue").PropType<import("./interface").MappingCardInterface["description"]>;
|
|
4
|
+
subTitle: import("vue").PropType<import("./interface").MappingCardInterface["subTitle"]>;
|
|
5
|
+
subDescription: import("vue").PropType<import("./interface").MappingCardInterface["subDescription"]>;
|
|
6
|
+
headerInfo: import("vue").PropType<import("./interface").MappingCardInterface["headerInfo"]>;
|
|
7
|
+
headerSubInfo: import("vue").PropType<import("./interface").MappingCardInterface["headerSubInfo"]>;
|
|
4
8
|
rows: import("vue").PropType<import("./interface").MappingCardInterface["rows"]>;
|
|
5
9
|
cols: {
|
|
6
10
|
readonly type: import("vue").PropType<import("./interface").MappingCardInterface["cols"]>;
|
|
@@ -1055,6 +1059,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
1055
1059
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
1056
1060
|
title: import("vue").PropType<import("./interface").MappingCardInterface["title"]>;
|
|
1057
1061
|
description: import("vue").PropType<import("./interface").MappingCardInterface["description"]>;
|
|
1062
|
+
subTitle: import("vue").PropType<import("./interface").MappingCardInterface["subTitle"]>;
|
|
1063
|
+
subDescription: import("vue").PropType<import("./interface").MappingCardInterface["subDescription"]>;
|
|
1064
|
+
headerInfo: import("vue").PropType<import("./interface").MappingCardInterface["headerInfo"]>;
|
|
1065
|
+
headerSubInfo: import("vue").PropType<import("./interface").MappingCardInterface["headerSubInfo"]>;
|
|
1058
1066
|
rows: import("vue").PropType<import("./interface").MappingCardInterface["rows"]>;
|
|
1059
1067
|
cols: {
|
|
1060
1068
|
readonly type: import("vue").PropType<import("./interface").MappingCardInterface["cols"]>;
|
|
@@ -71,7 +71,9 @@ export default defineComponent({
|
|
|
71
71
|
class: [`${this.mergedClsPrefix}-mapping-card`, themeClass],
|
|
72
72
|
style: cssVars
|
|
73
73
|
}, h(MappingCardHeader, null, {
|
|
74
|
-
headerActions: this.$slots.headerActions
|
|
74
|
+
headerActions: this.$slots.headerActions,
|
|
75
|
+
headerInfo: this.$slots.headerInfo,
|
|
76
|
+
headerSubInfo: this.$slots.headerSubInfo
|
|
75
77
|
}), h(MappingCardBody, null));
|
|
76
78
|
}
|
|
77
79
|
});
|