@bit.rhplus/ui.grid-layout 0.0.3 → 0.0.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.
- package/ColumnEditorModal.jsx +426 -369
- package/dist/ColumnEditorModal.js +134 -88
- package/dist/ColumnEditorModal.js.map +1 -1
- package/dist/useGridLayout.d.ts +1 -1
- package/dist/useGridLayout.js +1115 -221
- package/dist/useGridLayout.js.map +1 -1
- package/dist/useGridLayoutApi.d.ts +1 -1
- package/dist/useGridLayoutApi.js +102 -65
- package/dist/useGridLayoutApi.js.map +1 -1
- package/gridLayout.js +106 -106
- package/package.json +2 -2
- package/useGridLayout.js +1714 -625
- package/useGridLayoutApi.js +382 -296
- /package/dist/{preview-1755033542068.js → preview-1755777309104.js} +0 -0
package/ColumnEditorModal.jsx
CHANGED
|
@@ -1,370 +1,427 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import React, { useState, useCallback, useMemo } from 'react';
|
|
3
|
-
import { default as Button } from 'antd/es/button';
|
|
4
|
-
import { default as Input } from 'antd/es/input';
|
|
5
|
-
import { default as InputNumber } from 'antd/es/input-number';
|
|
6
|
-
import { default as Space } from 'antd/es/space';
|
|
7
|
-
import { default as Typography } from 'antd/es/typography';
|
|
8
|
-
import { default as Divider } from 'antd/es/divider';
|
|
9
|
-
import {
|
|
10
|
-
HolderOutlined,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from '
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
)
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
setEditingColumns(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
flex:
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
.column-
|
|
359
|
-
flex
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import React, { useState, useCallback, useMemo } from 'react';
|
|
3
|
+
import { default as Button } from 'antd/es/button';
|
|
4
|
+
import { default as Input } from 'antd/es/input';
|
|
5
|
+
import { default as InputNumber } from 'antd/es/input-number';
|
|
6
|
+
import { default as Space } from 'antd/es/space';
|
|
7
|
+
import { default as Typography } from 'antd/es/typography';
|
|
8
|
+
import { default as Divider } from 'antd/es/divider';
|
|
9
|
+
import {
|
|
10
|
+
HolderOutlined,
|
|
11
|
+
SettingOutlined,
|
|
12
|
+
HistoryOutlined
|
|
13
|
+
} from '@ant-design/icons';
|
|
14
|
+
import { default as Checkbox } from 'antd/es/checkbox';
|
|
15
|
+
import { default as Tooltip } from 'antd/es/tooltip';
|
|
16
|
+
import DraggableModal from '@bit.rhplus/draggable-modal';
|
|
17
|
+
import {
|
|
18
|
+
DndContext,
|
|
19
|
+
closestCenter,
|
|
20
|
+
KeyboardSensor,
|
|
21
|
+
PointerSensor,
|
|
22
|
+
useSensor,
|
|
23
|
+
useSensors,
|
|
24
|
+
} from '@dnd-kit/core';
|
|
25
|
+
import {
|
|
26
|
+
arrayMove,
|
|
27
|
+
SortableContext,
|
|
28
|
+
sortableKeyboardCoordinates,
|
|
29
|
+
verticalListSortingStrategy,
|
|
30
|
+
useSortable,
|
|
31
|
+
} from '@dnd-kit/sortable';
|
|
32
|
+
import {
|
|
33
|
+
CSS,
|
|
34
|
+
} from '@dnd-kit/utilities';
|
|
35
|
+
|
|
36
|
+
const { Text, Title } = Typography;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Sortable řádek pro jeden sloupec
|
|
40
|
+
*/
|
|
41
|
+
const SortableColumnRow = ({ column, onVisibilityChange, onWidthChange, onHeaderNameChange, onResetColumn }) => {
|
|
42
|
+
const {
|
|
43
|
+
attributes,
|
|
44
|
+
listeners,
|
|
45
|
+
setNodeRef,
|
|
46
|
+
transform,
|
|
47
|
+
transition,
|
|
48
|
+
isDragging,
|
|
49
|
+
} = useSortable({ id: column.id });
|
|
50
|
+
|
|
51
|
+
const style = {
|
|
52
|
+
transform: CSS.Transform.toString(transform),
|
|
53
|
+
transition,
|
|
54
|
+
opacity: isDragging ? 0.5 : 1,
|
|
55
|
+
backgroundColor: isDragging ? '#f0f0f0' : 'white',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div
|
|
60
|
+
ref={setNodeRef}
|
|
61
|
+
style={style}
|
|
62
|
+
className="column-row"
|
|
63
|
+
>
|
|
64
|
+
<div className="column-row-content">
|
|
65
|
+
{/* Drag Handle */}
|
|
66
|
+
<div className="drag-handle" {...attributes} {...listeners}>
|
|
67
|
+
<HolderOutlined style={{ color: '#999', cursor: 'grab' }} />
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
{/* Visibility Checkbox */}
|
|
71
|
+
<div className="column-checkbox">
|
|
72
|
+
<Checkbox
|
|
73
|
+
checked={column.visible}
|
|
74
|
+
onChange={(e) => onVisibilityChange(column.id, e.target.checked)}
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
{/* Column Name */}
|
|
79
|
+
<div className="column-name">
|
|
80
|
+
<div className="column-name-wrapper">
|
|
81
|
+
<div style={{ position: 'relative', flex: 1, display: 'flex', alignItems: 'center' }}>
|
|
82
|
+
<Input
|
|
83
|
+
value={column.headerName}
|
|
84
|
+
onChange={(e) => onHeaderNameChange(column.id, e.target.value)}
|
|
85
|
+
placeholder="Název sloupce"
|
|
86
|
+
size="small"
|
|
87
|
+
variant="borderless"
|
|
88
|
+
style={{
|
|
89
|
+
fontWeight: '500',
|
|
90
|
+
// Modrá barva, pokud se aktuální text liší od původního textu v columnDefs (ne od uložených preferencí)
|
|
91
|
+
color: column.headerName !== column.originalHeaderName ? '#1890ff' : undefined,
|
|
92
|
+
width: '100%',
|
|
93
|
+
paddingRight: column.headerName !== column.originalHeaderName ? '24px' : '0'
|
|
94
|
+
}}
|
|
95
|
+
title={column.headerName !== column.originalHeaderName ? `Původní text v definici sloupce: ${column.originalHeaderName}` : undefined}
|
|
96
|
+
/>
|
|
97
|
+
{/* Ikona pro obnovení původního textu - zobrazí se pouze při hover a pokud se text liší */}
|
|
98
|
+
{column.headerName !== column.originalHeaderName && (
|
|
99
|
+
<Tooltip title={`Obnovit původní název: "${column.originalHeaderName}"`}>
|
|
100
|
+
<HistoryOutlined
|
|
101
|
+
className="reset-icon"
|
|
102
|
+
onClick={() => onResetColumn(column.id)}
|
|
103
|
+
style={{
|
|
104
|
+
position: 'absolute',
|
|
105
|
+
right: '4px',
|
|
106
|
+
top: '50%',
|
|
107
|
+
transform: 'translateY(-50%)',
|
|
108
|
+
color: '#999',
|
|
109
|
+
cursor: 'pointer',
|
|
110
|
+
fontSize: '14px',
|
|
111
|
+
opacity: 0,
|
|
112
|
+
transition: 'opacity 0.2s, color 0.2s'
|
|
113
|
+
}}
|
|
114
|
+
/>
|
|
115
|
+
</Tooltip>
|
|
116
|
+
)}
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
{/* Width Input */}
|
|
122
|
+
<div className="column-width">
|
|
123
|
+
<InputNumber
|
|
124
|
+
min={50}
|
|
125
|
+
max={1000}
|
|
126
|
+
value={column.width}
|
|
127
|
+
onChange={(value) => onWidthChange(column.id, value)}
|
|
128
|
+
addonAfter="px"
|
|
129
|
+
size="small"
|
|
130
|
+
style={{ width: '100px' }}
|
|
131
|
+
/>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Modal pro editaci sloupců AG-Grid gridu
|
|
140
|
+
* @param {Object} props
|
|
141
|
+
* @param {boolean} props.open - Zda je modal otevřený
|
|
142
|
+
* @param {Function} props.onCancel - Callback pro zavření modalu
|
|
143
|
+
* @param {Function} props.onSave - Callback pro uložení změn
|
|
144
|
+
* @param {Array} props.columns - Pole sloupců k editaci
|
|
145
|
+
* @param {Function} props.getContainer - Container pro modal
|
|
146
|
+
*/
|
|
147
|
+
export default function ColumnEditorModal({
|
|
148
|
+
open,
|
|
149
|
+
onCancel,
|
|
150
|
+
onSave,
|
|
151
|
+
columns = [],
|
|
152
|
+
getContainer
|
|
153
|
+
}) {
|
|
154
|
+
// Lokální stav pro editaci sloupců
|
|
155
|
+
const [editingColumns, setEditingColumns] = useState([]);
|
|
156
|
+
|
|
157
|
+
// Inicializace editovacího stavu při otevření modalu
|
|
158
|
+
React.useEffect(() => {
|
|
159
|
+
if (open && columns.length > 0) {
|
|
160
|
+
// Removed console.log for production
|
|
161
|
+
|
|
162
|
+
const initialColumns = columns.map((col, index) => ({
|
|
163
|
+
id: col.field,
|
|
164
|
+
field: col.field,
|
|
165
|
+
// Prioritně použij aktuální headerName
|
|
166
|
+
headerName: col.headerName || col.field,
|
|
167
|
+
// Zachovej původní originalHeaderName z columnDefs
|
|
168
|
+
originalHeaderName: col.originalHeaderName || col.headerName || col.field,
|
|
169
|
+
// Prioritně použij aktuální šířku
|
|
170
|
+
width: col.width || 100,
|
|
171
|
+
// Zachovej původní originalWidth z columnDefs
|
|
172
|
+
originalWidth: col.originalWidth || col.width || 100,
|
|
173
|
+
// Prioritně použij aktuální viditelnost
|
|
174
|
+
visible: col.visible !== undefined ? col.visible : !col.hide,
|
|
175
|
+
// Zachovej původní originalVisible
|
|
176
|
+
originalVisible: col.originalVisible !== undefined ? col.originalVisible : !col.hide,
|
|
177
|
+
order: index
|
|
178
|
+
}));
|
|
179
|
+
|
|
180
|
+
// Removed console.log for production
|
|
181
|
+
|
|
182
|
+
setEditingColumns(initialColumns);
|
|
183
|
+
}
|
|
184
|
+
}, [open]); // Odstraněna závislost na 'columns' - inicializace jen při otevření
|
|
185
|
+
|
|
186
|
+
// Sensor pro drag&drop
|
|
187
|
+
const sensors = useSensors(
|
|
188
|
+
useSensor(PointerSensor),
|
|
189
|
+
useSensor(KeyboardSensor, {
|
|
190
|
+
coordinateGetter: sortableKeyboardCoordinates,
|
|
191
|
+
})
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
// Handler pro ukončení drag operace
|
|
195
|
+
const handleDragEnd = useCallback((event) => {
|
|
196
|
+
const { active, over } = event;
|
|
197
|
+
|
|
198
|
+
if (active.id !== over?.id) {
|
|
199
|
+
setEditingColumns((items) => {
|
|
200
|
+
const oldIndex = items.findIndex((item) => item.id === active.id);
|
|
201
|
+
const newIndex = items.findIndex((item) => item.id === over.id);
|
|
202
|
+
|
|
203
|
+
return arrayMove(items, oldIndex, newIndex);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}, []);
|
|
207
|
+
|
|
208
|
+
// Handler pro změnu viditelnosti sloupce
|
|
209
|
+
const handleVisibilityChange = useCallback((columnId, visible) => {
|
|
210
|
+
setEditingColumns((prev) =>
|
|
211
|
+
prev.map((col) =>
|
|
212
|
+
col.id === columnId ? { ...col, visible } : col
|
|
213
|
+
)
|
|
214
|
+
);
|
|
215
|
+
}, []);
|
|
216
|
+
|
|
217
|
+
// Handler pro změnu šířky sloupce
|
|
218
|
+
const handleWidthChange = useCallback((columnId, width) => {
|
|
219
|
+
// Akceptujeme všechny hodnoty včetně null/undefined pro reset
|
|
220
|
+
// Minimální validace proběhne při ukládání
|
|
221
|
+
if (width === null || width === undefined || (width && width >= 50)) {
|
|
222
|
+
setEditingColumns((prev) =>
|
|
223
|
+
prev.map((col) =>
|
|
224
|
+
col.id === columnId ? { ...col, width } : col
|
|
225
|
+
)
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
}, []);
|
|
229
|
+
|
|
230
|
+
// Handler pro změnu názvu sloupce
|
|
231
|
+
const handleHeaderNameChange = useCallback((columnId, headerName) => {
|
|
232
|
+
setEditingColumns((prev) =>
|
|
233
|
+
prev.map((col) =>
|
|
234
|
+
col.id === columnId ? { ...col, headerName } : col
|
|
235
|
+
)
|
|
236
|
+
);
|
|
237
|
+
}, []);
|
|
238
|
+
|
|
239
|
+
// Handler pro reset jednotlivého sloupce na původní hodnotu
|
|
240
|
+
const handleResetColumn = useCallback((columnId) => {
|
|
241
|
+
setEditingColumns((prev) =>
|
|
242
|
+
prev.map((col) =>
|
|
243
|
+
col.id === columnId
|
|
244
|
+
? { ...col, headerName: col.originalHeaderName }
|
|
245
|
+
: col
|
|
246
|
+
)
|
|
247
|
+
);
|
|
248
|
+
}, []);
|
|
249
|
+
|
|
250
|
+
// Handler pro uložení změn
|
|
251
|
+
const handleSave = useCallback(() => {
|
|
252
|
+
if (onSave) {
|
|
253
|
+
onSave(editingColumns);
|
|
254
|
+
}
|
|
255
|
+
onCancel();
|
|
256
|
+
}, [editingColumns, onSave, onCancel]);
|
|
257
|
+
|
|
258
|
+
// Handler pro reset na původní stav
|
|
259
|
+
const handleReset = useCallback(() => {
|
|
260
|
+
const resetColumns = columns.map((col) => ({
|
|
261
|
+
id: col.field,
|
|
262
|
+
field: col.field,
|
|
263
|
+
// Prioritně použij originalHeaderName, pokud existuje
|
|
264
|
+
headerName: col.originalHeaderName || col.headerName || col.field,
|
|
265
|
+
// Zachovej původní originalHeaderName
|
|
266
|
+
originalHeaderName: col.originalHeaderName || col.headerName || col.field,
|
|
267
|
+
// Prioritně použij originalWidth, pokud existuje
|
|
268
|
+
width: col.originalWidth || col.width || 100,
|
|
269
|
+
// Zachovej původní originalWidth
|
|
270
|
+
originalWidth: col.originalWidth || col.width || 100,
|
|
271
|
+
// Použij původní viditelnost z columnDefs
|
|
272
|
+
visible: col.originalVisible !== undefined ? col.originalVisible : !col.hide,
|
|
273
|
+
// Zachovej původní originalVisible
|
|
274
|
+
originalVisible: col.originalVisible !== undefined ? col.originalVisible : !col.hide,
|
|
275
|
+
// Použij původní pořadí z columnDefs
|
|
276
|
+
order: col.originalOrder !== undefined ? col.originalOrder : col.order
|
|
277
|
+
}));
|
|
278
|
+
|
|
279
|
+
// Seřadíme podle původního pořadí
|
|
280
|
+
const sortedResetColumns = resetColumns.sort((a, b) => a.order - b.order);
|
|
281
|
+
setEditingColumns(sortedResetColumns);
|
|
282
|
+
}, [columns]);
|
|
283
|
+
|
|
284
|
+
const columnIds = useMemo(() => editingColumns.map((col) => col.id), [editingColumns]);
|
|
285
|
+
|
|
286
|
+
// Dynamická výška podle velikosti obrazovky
|
|
287
|
+
const modalHeight = useMemo(() => {
|
|
288
|
+
if (typeof window !== 'undefined') {
|
|
289
|
+
const screenHeight = window.innerHeight;
|
|
290
|
+
// 80% výšky obrazovky (65% + 25%), minimálně 600px, maximálně 900px
|
|
291
|
+
// Odečteme 80px pro margin/padding aby se modál vždy vešel
|
|
292
|
+
return Math.min(Math.max((screenHeight - 80) * 0.80, 600), 900);
|
|
293
|
+
}
|
|
294
|
+
return 700;
|
|
295
|
+
}, []);
|
|
296
|
+
|
|
297
|
+
return (
|
|
298
|
+
<DraggableModal
|
|
299
|
+
width="650px"
|
|
300
|
+
height={`${modalHeight}px`}
|
|
301
|
+
open={open}
|
|
302
|
+
getContainer={getContainer}
|
|
303
|
+
onCancel={onCancel}
|
|
304
|
+
maskClosable={false}
|
|
305
|
+
zIndex={10000}
|
|
306
|
+
title={
|
|
307
|
+
<Space>
|
|
308
|
+
<SettingOutlined />
|
|
309
|
+
Nastavení sloupců
|
|
310
|
+
</Space>
|
|
311
|
+
}
|
|
312
|
+
footer={
|
|
313
|
+
<Space>
|
|
314
|
+
<Button onClick={handleReset}>
|
|
315
|
+
Obnovit původní
|
|
316
|
+
</Button>
|
|
317
|
+
<Button onClick={onCancel}>
|
|
318
|
+
Storno
|
|
319
|
+
</Button>
|
|
320
|
+
<Button type="primary" onClick={handleSave}>
|
|
321
|
+
Uložit změny
|
|
322
|
+
</Button>
|
|
323
|
+
</Space>
|
|
324
|
+
}
|
|
325
|
+
>
|
|
326
|
+
<div className="column-editor-content">
|
|
327
|
+
<div className="column-list">
|
|
328
|
+
<DndContext
|
|
329
|
+
sensors={sensors}
|
|
330
|
+
collisionDetection={closestCenter}
|
|
331
|
+
onDragEnd={handleDragEnd}
|
|
332
|
+
>
|
|
333
|
+
<SortableContext items={columnIds} strategy={verticalListSortingStrategy}>
|
|
334
|
+
{editingColumns.map((column) => (
|
|
335
|
+
<SortableColumnRow
|
|
336
|
+
key={column.id}
|
|
337
|
+
column={column}
|
|
338
|
+
onVisibilityChange={handleVisibilityChange}
|
|
339
|
+
onWidthChange={handleWidthChange}
|
|
340
|
+
onHeaderNameChange={handleHeaderNameChange}
|
|
341
|
+
onResetColumn={handleResetColumn}
|
|
342
|
+
/>
|
|
343
|
+
))}
|
|
344
|
+
</SortableContext>
|
|
345
|
+
</DndContext>
|
|
346
|
+
</div>
|
|
347
|
+
|
|
348
|
+
</div>
|
|
349
|
+
|
|
350
|
+
<style jsx>{`
|
|
351
|
+
.column-editor-content {
|
|
352
|
+
height: 100%;
|
|
353
|
+
display: flex;
|
|
354
|
+
flex-direction: column;
|
|
355
|
+
overflow: hidden;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.column-list {
|
|
359
|
+
flex: 1;
|
|
360
|
+
overflow-y: auto;
|
|
361
|
+
border: 1px solid #f0f0f0;
|
|
362
|
+
border-radius: 6px;
|
|
363
|
+
min-height: 300px;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.column-row {
|
|
367
|
+
transition: background-color 0.2s, box-shadow 0.2s;
|
|
368
|
+
border-radius: 6px;
|
|
369
|
+
margin: 2px 4px;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.column-row:hover {
|
|
373
|
+
background-color: #fafafa;
|
|
374
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.column-row:hover .reset-icon {
|
|
378
|
+
opacity: 1 !important;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.column-row-content {
|
|
382
|
+
display: flex;
|
|
383
|
+
align-items: center;
|
|
384
|
+
padding: 12px 16px;
|
|
385
|
+
gap: 12px;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.column-checkbox {
|
|
389
|
+
flex-shrink: 0;
|
|
390
|
+
width: 20px;
|
|
391
|
+
display: flex;
|
|
392
|
+
align-items: center;
|
|
393
|
+
justify-content: center;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.column-name {
|
|
397
|
+
flex: 1;
|
|
398
|
+
min-width: 150px;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
.column-name-wrapper {
|
|
402
|
+
display: flex;
|
|
403
|
+
align-items: center;
|
|
404
|
+
width: 100%;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.reset-icon:hover {
|
|
408
|
+
color: #1890ff !important;
|
|
409
|
+
transform: scale(1.1);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
.column-width {
|
|
413
|
+
flex-shrink: 0;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
.drag-handle {
|
|
417
|
+
flex-shrink: 0;
|
|
418
|
+
width: 20px;
|
|
419
|
+
display: flex;
|
|
420
|
+
align-items: center;
|
|
421
|
+
justify-content: center;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
`}</style>
|
|
425
|
+
</DraggableModal>
|
|
426
|
+
);
|
|
370
427
|
}
|