@jetbrains/ring-ui-built 8.0.0-beta.4 → 8.0.0-beta.5
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/components/_helpers/alert.js +3 -0
- package/components/_helpers/caption.js +1 -1
- package/components/_helpers/header.js +1 -1
- package/components/_helpers/table.js +1 -1
- package/components/alert/alert-actions.d.ts +4 -0
- package/components/alert/alert-actions.js +51 -0
- package/components/alert/alert-heading.d.ts +4 -0
- package/components/alert/alert-heading.js +62 -0
- package/components/alert/alert.d.ts +14 -1
- package/components/alert/alert.js +43 -25
- package/components/alert-service/alert-service.d.ts +2 -1
- package/components/alert-service/alert-service.js +15 -5
- package/components/auth/auth-core.d.ts +5 -9
- package/components/auth/auth-core.js +71 -17
- package/components/auth/auth.js +7 -1
- package/components/auth/down-notification.js +7 -1
- package/components/auth/storage.js +7 -1
- package/components/clipboard/clipboard.js +7 -1
- package/components/date-picker/consts.d.ts +1 -0
- package/components/date-picker/date-input.js +3 -2
- package/components/header/header.js +7 -1
- package/components/header/smart-profile.js +7 -1
- package/components/http/http.d.ts +2 -2
- package/components/http/http.js +2 -2
- package/components/i18n/i18n.d.ts +1 -0
- package/components/i18n/i18n.js +2 -0
- package/components/internal/reorder-animation-context.js +159 -0
- package/components/internal/reorder-handle.js +750 -0
- package/components/internal/reorder-layout-context.js +141 -0
- package/components/internal/table-header.js +221 -645
- package/components/internal/{virtual-items.js → virtualization.js} +29 -14
- package/components/old-browsers-message/white-list.js +2 -2
- package/components/storage/storage-local.js +7 -1
- package/components/storage/storage.js +7 -1
- package/components/style.css +1 -1
- package/components/table/default-item-renderer.d.ts +7 -1
- package/components/table/default-item-renderer.js +119 -67
- package/components/table/internal/reorder-animation-context.d.ts +21 -0
- package/components/table/internal/reorder-handle.d.ts +9 -0
- package/components/table/internal/reorder-layout-context.d.ts +16 -0
- package/components/table/internal/table-header.d.ts +1 -4
- package/components/table/internal/{virtual-items.d.ts → virtualization.d.ts} +10 -3
- package/components/table/item-virtualization.d.ts +5 -3
- package/components/table/item-virtualization.js +13 -11
- package/components/table/reorder-animation.d.ts +37 -0
- package/components/table/reorder-animation.js +18 -0
- package/components/table/reorder-item-layout.d.ts +32 -0
- package/components/table/reorder-item-layout.js +57 -0
- package/components/table/table-const.d.ts +0 -32
- package/components/table/table-const.js +1 -8
- package/components/table/table-primitives.d.ts +43 -0
- package/components/table/table-primitives.js +62 -5
- package/components/table/table-props.d.ts +29 -5
- package/components/table/table.d.ts +31 -5
- package/components/table/table.js +177 -170
- package/components/user-agreement/service.js +7 -1
- package/components/user-card/card.js +7 -1
- package/components/user-card/smart-user-card-tooltip.d.ts +1 -1
- package/components/user-card/smart-user-card-tooltip.js +7 -1
- package/components/user-card/tooltip.js +7 -1
- package/components/user-card/user-card.js +7 -1
- package/components/util-stories.d.ts +2 -2
- package/package.json +2 -2
- package/components/internal/column-animation.js +0 -133
- package/components/table/internal/column-animation.d.ts +0 -16
|
@@ -0,0 +1,750 @@
|
|
|
1
|
+
import { c } from 'react/compiler-runtime';
|
|
2
|
+
import { useRef, use, useEffectEvent, useEffect } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import dragIcon from '@jetbrains/icons/drag-12px';
|
|
5
|
+
import { TablePropsContext } from '../table/table-const.js';
|
|
6
|
+
import Icon from '../icon/icon.js';
|
|
7
|
+
import { useComposedRef } from '../global/compose-refs.js';
|
|
8
|
+
import { parseCssDuration } from '../global/parse-css-duration.js';
|
|
9
|
+
import { ReorderAnimationContext } from './reorder-animation-context.js';
|
|
10
|
+
import { ReorderLayoutContext } from './reorder-layout-context.js';
|
|
11
|
+
import { s as styles } from '../_helpers/table.js';
|
|
12
|
+
import { jsx } from 'react/jsx-runtime';
|
|
13
|
+
import 'util-deprecate';
|
|
14
|
+
import '../icon/icon.constants.js';
|
|
15
|
+
import '../_helpers/icon-svg.js';
|
|
16
|
+
import '../global/memoize.js';
|
|
17
|
+
import 'memoize-one';
|
|
18
|
+
import '../global/schedule-with-cleanup.js';
|
|
19
|
+
|
|
20
|
+
const columnDragFrameAdjustmentPx = -1;
|
|
21
|
+
const itemDragFrameAdjustmentPx = -2;
|
|
22
|
+
const scrollAreaPx = 100;
|
|
23
|
+
const scrollStepPx = 100;
|
|
24
|
+
const scrollIntervalMs = 200;
|
|
25
|
+
function ReorderHandle(t0) {
|
|
26
|
+
var _columns$index$name;
|
|
27
|
+
const $ = c(117);
|
|
28
|
+
if ($[0] !== "4544842fd05f0c29d1fc5074a4df3120dd2baf71388dcaaf57c84e7cd83c8c63") {
|
|
29
|
+
for (let $i = 0; $i < 117; $i += 1) {
|
|
30
|
+
$[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
31
|
+
}
|
|
32
|
+
$[0] = "4544842fd05f0c29d1fc5074a4df3120dd2baf71388dcaaf57c84e7cd83c8c63";
|
|
33
|
+
}
|
|
34
|
+
let className;
|
|
35
|
+
let direction;
|
|
36
|
+
let index;
|
|
37
|
+
let noDragFrame;
|
|
38
|
+
let noHandleTranslate;
|
|
39
|
+
let onKeyDown;
|
|
40
|
+
let onLostPointerCapture;
|
|
41
|
+
let onPointerCancel;
|
|
42
|
+
let onPointerDown;
|
|
43
|
+
let onPointerMove;
|
|
44
|
+
let onPointerUp;
|
|
45
|
+
let onUserDrag;
|
|
46
|
+
let restProps;
|
|
47
|
+
let userRef;
|
|
48
|
+
if ($[1] !== t0) {
|
|
49
|
+
({
|
|
50
|
+
direction,
|
|
51
|
+
index,
|
|
52
|
+
noDragFrame,
|
|
53
|
+
noHandleTranslate,
|
|
54
|
+
onUserDrag,
|
|
55
|
+
ref: userRef,
|
|
56
|
+
className,
|
|
57
|
+
onKeyDown,
|
|
58
|
+
onPointerDown,
|
|
59
|
+
onPointerMove,
|
|
60
|
+
onPointerUp,
|
|
61
|
+
onPointerCancel,
|
|
62
|
+
onLostPointerCapture,
|
|
63
|
+
...restProps
|
|
64
|
+
} = t0);
|
|
65
|
+
$[1] = t0;
|
|
66
|
+
$[2] = className;
|
|
67
|
+
$[3] = direction;
|
|
68
|
+
$[4] = index;
|
|
69
|
+
$[5] = noDragFrame;
|
|
70
|
+
$[6] = noHandleTranslate;
|
|
71
|
+
$[7] = onKeyDown;
|
|
72
|
+
$[8] = onLostPointerCapture;
|
|
73
|
+
$[9] = onPointerCancel;
|
|
74
|
+
$[10] = onPointerDown;
|
|
75
|
+
$[11] = onPointerMove;
|
|
76
|
+
$[12] = onPointerUp;
|
|
77
|
+
$[13] = onUserDrag;
|
|
78
|
+
$[14] = restProps;
|
|
79
|
+
$[15] = userRef;
|
|
80
|
+
} else {
|
|
81
|
+
className = $[2];
|
|
82
|
+
direction = $[3];
|
|
83
|
+
index = $[4];
|
|
84
|
+
noDragFrame = $[5];
|
|
85
|
+
noHandleTranslate = $[6];
|
|
86
|
+
onKeyDown = $[7];
|
|
87
|
+
onLostPointerCapture = $[8];
|
|
88
|
+
onPointerCancel = $[9];
|
|
89
|
+
onPointerDown = $[10];
|
|
90
|
+
onPointerMove = $[11];
|
|
91
|
+
onPointerUp = $[12];
|
|
92
|
+
onUserDrag = $[13];
|
|
93
|
+
restProps = $[14];
|
|
94
|
+
userRef = $[15];
|
|
95
|
+
}
|
|
96
|
+
const localRef = useRef(null);
|
|
97
|
+
const composedRef = useComposedRef(localRef, userRef);
|
|
98
|
+
const isColumn = direction === "columns";
|
|
99
|
+
const tableProps = use(TablePropsContext);
|
|
100
|
+
const data = tableProps?.data;
|
|
101
|
+
const columns = tableProps?.columns;
|
|
102
|
+
const canReorderItem = tableProps?.canReorderItem;
|
|
103
|
+
const onItemReorder = tableProps?.onItemReorder;
|
|
104
|
+
const onColumnReorder = tableProps?.onColumnReorder;
|
|
105
|
+
let t1;
|
|
106
|
+
if ($[16] !== canReorderItem || $[17] !== columns || $[18] !== data || $[19] !== index || $[20] !== isColumn) {
|
|
107
|
+
t1 = function canReorder(insertionIndex) {
|
|
108
|
+
const columnBeingReordered = columns?.[index];
|
|
109
|
+
if (isColumn && columnBeingReordered) {
|
|
110
|
+
const canReorderColumn = columnBeingReordered.canReorder;
|
|
111
|
+
if (canReorderColumn === true) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
if (typeof canReorderColumn === "function") {
|
|
115
|
+
return canReorderColumn(columnBeingReordered, index, insertionIndex, columns);
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
if (!isColumn && data) {
|
|
120
|
+
return canReorderItem ? canReorderItem(data[index], index, insertionIndex, data) : true;
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
};
|
|
124
|
+
$[16] = canReorderItem;
|
|
125
|
+
$[17] = columns;
|
|
126
|
+
$[18] = data;
|
|
127
|
+
$[19] = index;
|
|
128
|
+
$[20] = isColumn;
|
|
129
|
+
$[21] = t1;
|
|
130
|
+
} else {
|
|
131
|
+
t1 = $[21];
|
|
132
|
+
}
|
|
133
|
+
const canReorder = t1;
|
|
134
|
+
const {
|
|
135
|
+
expectReorder
|
|
136
|
+
} = use(ReorderAnimationContext);
|
|
137
|
+
let t2;
|
|
138
|
+
if ($[22] !== columns || $[23] !== data || $[24] !== direction || $[25] !== expectReorder || $[26] !== index || $[27] !== isColumn || $[28] !== onColumnReorder || $[29] !== onItemReorder) {
|
|
139
|
+
t2 = function onReorder(insertionIndex_0) {
|
|
140
|
+
if (isColumn && columns) {
|
|
141
|
+
expectReorder({
|
|
142
|
+
direction,
|
|
143
|
+
fromIndex: index,
|
|
144
|
+
insertionIndex: insertionIndex_0
|
|
145
|
+
});
|
|
146
|
+
onColumnReorder?.(columns[index], index, insertionIndex_0, columns);
|
|
147
|
+
} else {
|
|
148
|
+
if (!isColumn && data) {
|
|
149
|
+
expectReorder({
|
|
150
|
+
direction,
|
|
151
|
+
fromIndex: index,
|
|
152
|
+
insertionIndex: insertionIndex_0
|
|
153
|
+
});
|
|
154
|
+
onItemReorder?.(data[index], index, insertionIndex_0, data);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
$[22] = columns;
|
|
159
|
+
$[23] = data;
|
|
160
|
+
$[24] = direction;
|
|
161
|
+
$[25] = expectReorder;
|
|
162
|
+
$[26] = index;
|
|
163
|
+
$[27] = isColumn;
|
|
164
|
+
$[28] = onColumnReorder;
|
|
165
|
+
$[29] = onItemReorder;
|
|
166
|
+
$[30] = t2;
|
|
167
|
+
} else {
|
|
168
|
+
t2 = $[30];
|
|
169
|
+
}
|
|
170
|
+
const onReorder = t2;
|
|
171
|
+
const activeDragRef = useRef(null);
|
|
172
|
+
let t3;
|
|
173
|
+
if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
|
|
174
|
+
t3 = function getDragFrame() {
|
|
175
|
+
return document.body.querySelector(`.${styles.dragFrame}`);
|
|
176
|
+
};
|
|
177
|
+
$[31] = t3;
|
|
178
|
+
} else {
|
|
179
|
+
t3 = $[31];
|
|
180
|
+
}
|
|
181
|
+
const getDragFrame = t3;
|
|
182
|
+
let t4;
|
|
183
|
+
if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
|
|
184
|
+
t4 = function getInsertionIndicator() {
|
|
185
|
+
return document.body.querySelector(`.${styles.insertionIndicator}`);
|
|
186
|
+
};
|
|
187
|
+
$[32] = t4;
|
|
188
|
+
} else {
|
|
189
|
+
t4 = $[32];
|
|
190
|
+
}
|
|
191
|
+
const getInsertionIndicator = t4;
|
|
192
|
+
const {
|
|
193
|
+
getItemBounds,
|
|
194
|
+
getClosestInsertionPoint
|
|
195
|
+
} = use(ReorderLayoutContext);
|
|
196
|
+
let t5;
|
|
197
|
+
if ($[33] !== isColumn || $[34] !== noDragFrame) {
|
|
198
|
+
t5 = function renderDragFrame(clientX, clientY) {
|
|
199
|
+
const drag = activeDragRef.current;
|
|
200
|
+
if (noDragFrame || !drag) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const {
|
|
204
|
+
startX,
|
|
205
|
+
startY,
|
|
206
|
+
initialItemStart,
|
|
207
|
+
initialItemEnd,
|
|
208
|
+
indicatorStart,
|
|
209
|
+
indicatorSize
|
|
210
|
+
} = drag;
|
|
211
|
+
let dragFrame = getDragFrame();
|
|
212
|
+
if (!dragFrame) {
|
|
213
|
+
dragFrame = document.createElement("div");
|
|
214
|
+
dragFrame.className = styles.dragFrame;
|
|
215
|
+
const frameStart = `calc(max(0px, ${indicatorStart - 2}px))`;
|
|
216
|
+
const frameAcrossSize = `${initialItemEnd - initialItemStart}px`;
|
|
217
|
+
const frameAlongSize = indicatorSize;
|
|
218
|
+
dragFrame.style[isColumn ? "top" : "left"] = frameStart;
|
|
219
|
+
dragFrame.style[isColumn ? "width" : "height"] = frameAcrossSize;
|
|
220
|
+
dragFrame.style[isColumn ? "height" : "width"] = frameAlongSize;
|
|
221
|
+
document.body.appendChild(dragFrame);
|
|
222
|
+
}
|
|
223
|
+
if (isColumn) {
|
|
224
|
+
dragFrame.style.left = `${initialItemStart + clientX - startX + columnDragFrameAdjustmentPx}px`;
|
|
225
|
+
} else {
|
|
226
|
+
dragFrame.style.top = `${initialItemStart + clientY - startY + itemDragFrameAdjustmentPx}px`;
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
$[33] = isColumn;
|
|
230
|
+
$[34] = noDragFrame;
|
|
231
|
+
$[35] = t5;
|
|
232
|
+
} else {
|
|
233
|
+
t5 = $[35];
|
|
234
|
+
}
|
|
235
|
+
const renderDragFrame = t5;
|
|
236
|
+
let t6;
|
|
237
|
+
if ($[36] !== getItemBounds || $[37] !== index || $[38] !== isColumn || $[39] !== noHandleTranslate) {
|
|
238
|
+
t6 = function translateButton(clientX_0, clientY_0) {
|
|
239
|
+
var _getItemBounds;
|
|
240
|
+
const btn = localRef.current;
|
|
241
|
+
const drag_0 = activeDragRef.current;
|
|
242
|
+
if (noHandleTranslate || !btn || !drag_0) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const {
|
|
246
|
+
startX: startX_0,
|
|
247
|
+
startY: startY_0,
|
|
248
|
+
initialItemStart: initialItemStart_0
|
|
249
|
+
} = drag_0;
|
|
250
|
+
const offsetByPointerMove = isColumn ? clientX_0 - startX_0 : clientY_0 - startY_0;
|
|
251
|
+
const {
|
|
252
|
+
start: itemStart
|
|
253
|
+
} = (_getItemBounds = getItemBounds(index)) !== null && _getItemBounds !== void 0 ? _getItemBounds : {
|
|
254
|
+
start: 0};
|
|
255
|
+
const offsetByItemMove = itemStart - initialItemStart_0;
|
|
256
|
+
const offset = offsetByPointerMove - offsetByItemMove;
|
|
257
|
+
btn.style.transform = isColumn ? `translateX(${offset}px)` : `translateY(${offset}px)`;
|
|
258
|
+
};
|
|
259
|
+
$[36] = getItemBounds;
|
|
260
|
+
$[37] = index;
|
|
261
|
+
$[38] = isColumn;
|
|
262
|
+
$[39] = noHandleTranslate;
|
|
263
|
+
$[40] = t6;
|
|
264
|
+
} else {
|
|
265
|
+
t6 = $[40];
|
|
266
|
+
}
|
|
267
|
+
const translateButton = t6;
|
|
268
|
+
let t7;
|
|
269
|
+
if ($[41] !== canReorder || $[42] !== getClosestInsertionPoint || $[43] !== isColumn) {
|
|
270
|
+
t7 = function getClosestInsertionPointLocal(clientX_1, clientY_1) {
|
|
271
|
+
const clientOffset = isColumn ? clientX_1 : clientY_1;
|
|
272
|
+
return getClosestInsertionPoint(clientOffset, canReorder);
|
|
273
|
+
};
|
|
274
|
+
$[41] = canReorder;
|
|
275
|
+
$[42] = getClosestInsertionPoint;
|
|
276
|
+
$[43] = isColumn;
|
|
277
|
+
$[44] = t7;
|
|
278
|
+
} else {
|
|
279
|
+
t7 = $[44];
|
|
280
|
+
}
|
|
281
|
+
const getClosestInsertionPointLocal = t7;
|
|
282
|
+
let t8;
|
|
283
|
+
if ($[45] !== getItemBounds || $[46] !== isColumn) {
|
|
284
|
+
t8 = function renderInsertionIndicator(t9) {
|
|
285
|
+
const {
|
|
286
|
+
itemIndex,
|
|
287
|
+
after
|
|
288
|
+
} = t9;
|
|
289
|
+
const drag_1 = activeDragRef.current;
|
|
290
|
+
if (!drag_1) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
const {
|
|
294
|
+
indicatorStart: indicatorStart_0,
|
|
295
|
+
indicatorSize: indicatorSize_0
|
|
296
|
+
} = drag_1;
|
|
297
|
+
const itemBounds = getItemBounds(itemIndex);
|
|
298
|
+
if (!itemBounds) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const {
|
|
302
|
+
start: itemStart_0,
|
|
303
|
+
end: itemEnd
|
|
304
|
+
} = itemBounds;
|
|
305
|
+
let indicator = getInsertionIndicator();
|
|
306
|
+
if (!indicator) {
|
|
307
|
+
indicator = document.createElement("div");
|
|
308
|
+
indicator.className = styles.insertionIndicator;
|
|
309
|
+
indicator.style[isColumn ? "top" : "left"] = `${indicatorStart_0}px`;
|
|
310
|
+
indicator.style[isColumn ? "height" : "width"] = indicatorSize_0;
|
|
311
|
+
indicator.style[isColumn ? "width" : "height"] = "2px";
|
|
312
|
+
document.body.appendChild(indicator);
|
|
313
|
+
}
|
|
314
|
+
const itemOffset = `${(after ? itemEnd : itemStart_0) - 1}px`;
|
|
315
|
+
indicator.style[isColumn ? "left" : "top"] = itemOffset;
|
|
316
|
+
};
|
|
317
|
+
$[45] = getItemBounds;
|
|
318
|
+
$[46] = isColumn;
|
|
319
|
+
$[47] = t8;
|
|
320
|
+
} else {
|
|
321
|
+
t8 = $[47];
|
|
322
|
+
}
|
|
323
|
+
const renderInsertionIndicator = t8;
|
|
324
|
+
let t9;
|
|
325
|
+
if ($[48] !== onUserDrag) {
|
|
326
|
+
t9 = function cleanupDrag() {
|
|
327
|
+
if (activeDragRef.current) {
|
|
328
|
+
activeDragRef.current.cleanup();
|
|
329
|
+
activeDragRef.current = null;
|
|
330
|
+
}
|
|
331
|
+
const btn_0 = localRef.current;
|
|
332
|
+
if (btn_0) {
|
|
333
|
+
btn_0.style.removeProperty("transform");
|
|
334
|
+
btn_0.style.removeProperty("transition");
|
|
335
|
+
}
|
|
336
|
+
getDragFrame()?.remove();
|
|
337
|
+
getInsertionIndicator()?.remove();
|
|
338
|
+
onUserDrag?.(undefined);
|
|
339
|
+
};
|
|
340
|
+
$[48] = onUserDrag;
|
|
341
|
+
$[49] = t9;
|
|
342
|
+
} else {
|
|
343
|
+
t9 = $[49];
|
|
344
|
+
}
|
|
345
|
+
const cleanupDrag = t9;
|
|
346
|
+
let t10;
|
|
347
|
+
if ($[50] !== cleanupDrag || $[51] !== isColumn || $[52] !== onUserDrag) {
|
|
348
|
+
t10 = function animateNoChangeThenCleanup() {
|
|
349
|
+
const drag_2 = activeDragRef.current;
|
|
350
|
+
if (drag_2?.state !== "is-dragging") {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
drag_2.state = "ended-with-no-change";
|
|
354
|
+
drag_2.cleanup();
|
|
355
|
+
drag_2.cleanup = _temp;
|
|
356
|
+
const dragFrame_0 = getDragFrame();
|
|
357
|
+
if (dragFrame_0) {
|
|
358
|
+
const {
|
|
359
|
+
initialItemStart: initialItemStart_1
|
|
360
|
+
} = drag_2;
|
|
361
|
+
if (isColumn) {
|
|
362
|
+
dragFrame_0.style.left = `${initialItemStart_1 + columnDragFrameAdjustmentPx}px`;
|
|
363
|
+
} else {
|
|
364
|
+
dragFrame_0.style.top = `${initialItemStart_1 + itemDragFrameAdjustmentPx}px`;
|
|
365
|
+
}
|
|
366
|
+
dragFrame_0.style.transition = "left var(--ring-ease), top var(--ring-ease), opacity var(--ring-ease)";
|
|
367
|
+
dragFrame_0.style.opacity = "0";
|
|
368
|
+
}
|
|
369
|
+
const indicator_0 = getInsertionIndicator();
|
|
370
|
+
if (indicator_0) {
|
|
371
|
+
indicator_0.style.opacity = "0";
|
|
372
|
+
indicator_0.style.transition = "opacity var(--ring-ease)";
|
|
373
|
+
}
|
|
374
|
+
const btn_1 = localRef.current;
|
|
375
|
+
if (btn_1) {
|
|
376
|
+
btn_1.style.transform = isColumn ? "translateX(0)" : "translateY(0)";
|
|
377
|
+
btn_1.style.transition = "transform var(--ring-ease)";
|
|
378
|
+
}
|
|
379
|
+
onUserDrag?.("cancelled");
|
|
380
|
+
const ringEaseMs = parseCssDuration(window.getComputedStyle(document.documentElement).getPropertyValue("--ring-ease"));
|
|
381
|
+
setTimeout(cleanupDrag, ringEaseMs);
|
|
382
|
+
};
|
|
383
|
+
$[50] = cleanupDrag;
|
|
384
|
+
$[51] = isColumn;
|
|
385
|
+
$[52] = onUserDrag;
|
|
386
|
+
$[53] = t10;
|
|
387
|
+
} else {
|
|
388
|
+
t10 = $[53];
|
|
389
|
+
}
|
|
390
|
+
const animateNoChangeThenCleanup = t10;
|
|
391
|
+
let t11;
|
|
392
|
+
if ($[54] !== animateNoChangeThenCleanup || $[55] !== getItemBounds || $[56] !== index || $[57] !== isColumn || $[58] !== onPointerDown || $[59] !== onUserDrag || $[60] !== renderDragFrame) {
|
|
393
|
+
t11 = function handlePointerDown(e) {
|
|
394
|
+
var _getItemBounds2;
|
|
395
|
+
onPointerDown?.(e);
|
|
396
|
+
if (e.defaultPrevented) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
const {
|
|
400
|
+
clientX: clientX_2,
|
|
401
|
+
clientY: clientY_2,
|
|
402
|
+
pointerId,
|
|
403
|
+
currentTarget
|
|
404
|
+
} = e;
|
|
405
|
+
const {
|
|
406
|
+
start: initialItemStart_2,
|
|
407
|
+
end: initialItemEnd_0
|
|
408
|
+
} = (_getItemBounds2 = getItemBounds(index)) !== null && _getItemBounds2 !== void 0 ? _getItemBounds2 : {
|
|
409
|
+
start: 0,
|
|
410
|
+
end: 0
|
|
411
|
+
};
|
|
412
|
+
let indicatorStart_1;
|
|
413
|
+
let indicatorSize_1;
|
|
414
|
+
if (isColumn) {
|
|
415
|
+
const thead = currentTarget.closest("thead");
|
|
416
|
+
const table = thead?.closest("table");
|
|
417
|
+
if (!thead || !table) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
const {
|
|
421
|
+
top: headerTop
|
|
422
|
+
} = thead.getBoundingClientRect();
|
|
423
|
+
indicatorStart_1 = headerTop;
|
|
424
|
+
const {
|
|
425
|
+
bottom: tableBottom
|
|
426
|
+
} = table.getBoundingClientRect();
|
|
427
|
+
const visibleTableHeight = tableBottom - headerTop;
|
|
428
|
+
const viewportBottomRelativeToHeaderTop = window.innerHeight - headerTop;
|
|
429
|
+
indicatorSize_1 = `min(${visibleTableHeight}px, calc(${viewportBottomRelativeToHeaderTop}px - .5rem))`;
|
|
430
|
+
} else {
|
|
431
|
+
const tr = currentTarget.closest("tr");
|
|
432
|
+
const tbody = tr?.closest("tbody");
|
|
433
|
+
if (!tr || !tbody) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
const {
|
|
437
|
+
left: itemLeft,
|
|
438
|
+
right: itemRight
|
|
439
|
+
} = tr.getBoundingClientRect();
|
|
440
|
+
indicatorStart_1 = itemLeft;
|
|
441
|
+
const visibleItemWidth = itemRight - itemLeft;
|
|
442
|
+
const viewportRightRelativeToTableLeft = window.innerWidth - itemLeft;
|
|
443
|
+
indicatorSize_1 = `min(${visibleItemWidth}px, calc(${viewportRightRelativeToTableLeft}px - .5rem))`;
|
|
444
|
+
}
|
|
445
|
+
const keydownListener = function keydownListener(keyEvent) {
|
|
446
|
+
if (keyEvent.key === "Escape") {
|
|
447
|
+
animateNoChangeThenCleanup();
|
|
448
|
+
keyEvent.stopPropagation();
|
|
449
|
+
keyEvent.preventDefault();
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
currentTarget.setPointerCapture(pointerId);
|
|
453
|
+
document.addEventListener("keydown", keydownListener);
|
|
454
|
+
currentTarget.style.cursor = "grabbing";
|
|
455
|
+
activeDragRef.current = {
|
|
456
|
+
state: "is-dragging",
|
|
457
|
+
startX: clientX_2,
|
|
458
|
+
startY: clientY_2,
|
|
459
|
+
initialItemStart: initialItemStart_2,
|
|
460
|
+
initialItemEnd: initialItemEnd_0,
|
|
461
|
+
indicatorStart: indicatorStart_1,
|
|
462
|
+
indicatorSize: indicatorSize_1,
|
|
463
|
+
cleanup: () => {
|
|
464
|
+
currentTarget.releasePointerCapture(pointerId);
|
|
465
|
+
document.removeEventListener("keydown", keydownListener);
|
|
466
|
+
currentTarget.style.removeProperty("cursor");
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
renderDragFrame(clientX_2, clientY_2);
|
|
470
|
+
onUserDrag?.("pointerdown");
|
|
471
|
+
e.preventDefault();
|
|
472
|
+
};
|
|
473
|
+
$[54] = animateNoChangeThenCleanup;
|
|
474
|
+
$[55] = getItemBounds;
|
|
475
|
+
$[56] = index;
|
|
476
|
+
$[57] = isColumn;
|
|
477
|
+
$[58] = onPointerDown;
|
|
478
|
+
$[59] = onUserDrag;
|
|
479
|
+
$[60] = renderDragFrame;
|
|
480
|
+
$[61] = t11;
|
|
481
|
+
} else {
|
|
482
|
+
t11 = $[61];
|
|
483
|
+
}
|
|
484
|
+
const handlePointerDown = t11;
|
|
485
|
+
const scrollerRef = tableProps?.scrollerRef;
|
|
486
|
+
const lastScrolledRef = useRef(0);
|
|
487
|
+
let t12;
|
|
488
|
+
if ($[62] !== scrollerRef?.current) {
|
|
489
|
+
t12 = function scrollThrottled(scrollDirection) {
|
|
490
|
+
const now = performance.now();
|
|
491
|
+
if (now > lastScrolledRef.current + scrollIntervalMs) {
|
|
492
|
+
var _scrollerRef$current;
|
|
493
|
+
lastScrolledRef.current = now;
|
|
494
|
+
const top = scrollDirection === "up" ? -scrollStepPx : scrollStepPx;
|
|
495
|
+
const scroller = (_scrollerRef$current = scrollerRef?.current) !== null && _scrollerRef$current !== void 0 ? _scrollerRef$current : window;
|
|
496
|
+
scroller?.scrollBy({
|
|
497
|
+
top,
|
|
498
|
+
behavior: "smooth"
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
$[62] = scrollerRef?.current;
|
|
503
|
+
$[63] = t12;
|
|
504
|
+
} else {
|
|
505
|
+
t12 = $[63];
|
|
506
|
+
}
|
|
507
|
+
const scrollThrottled = t12;
|
|
508
|
+
let t13;
|
|
509
|
+
if ($[64] !== getClosestInsertionPointLocal || $[65] !== isColumn || $[66] !== onPointerMove || $[67] !== onUserDrag || $[68] !== renderDragFrame || $[69] !== renderInsertionIndicator || $[70] !== scrollThrottled || $[71] !== scrollerRef?.current || $[72] !== translateButton) {
|
|
510
|
+
t13 = function handlePointerMove(e_0) {
|
|
511
|
+
onPointerMove?.(e_0);
|
|
512
|
+
if (e_0.defaultPrevented) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
const drag_3 = activeDragRef.current;
|
|
516
|
+
if (drag_3?.state !== "is-dragging") {
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
const {
|
|
520
|
+
clientX: clientX_3,
|
|
521
|
+
clientY: clientY_3
|
|
522
|
+
} = e_0;
|
|
523
|
+
renderDragFrame(clientX_3, clientY_3);
|
|
524
|
+
translateButton(clientX_3, clientY_3);
|
|
525
|
+
const insertionPoint = getClosestInsertionPointLocal(clientX_3, clientY_3);
|
|
526
|
+
if (insertionPoint) {
|
|
527
|
+
renderInsertionIndicator(insertionPoint);
|
|
528
|
+
}
|
|
529
|
+
onUserDrag?.(isColumn ? clientX_3 - drag_3.startX : clientY_3 - drag_3.startY);
|
|
530
|
+
if (!isColumn) {
|
|
531
|
+
var _scrollerRect$top;
|
|
532
|
+
const scrollerRect = scrollerRef?.current?.getBoundingClientRect();
|
|
533
|
+
const scrollerTop = (_scrollerRect$top = scrollerRect?.top) !== null && _scrollerRect$top !== void 0 ? _scrollerRect$top : 0;
|
|
534
|
+
const scrollerBottom = scrollerRect ? Math.min(scrollerRect.bottom, window.innerHeight) : window.innerHeight;
|
|
535
|
+
if (clientY_3 < scrollerTop + scrollAreaPx) {
|
|
536
|
+
scrollThrottled("up");
|
|
537
|
+
} else {
|
|
538
|
+
if (clientY_3 > scrollerBottom - scrollAreaPx) {
|
|
539
|
+
scrollThrottled("down");
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
$[64] = getClosestInsertionPointLocal;
|
|
545
|
+
$[65] = isColumn;
|
|
546
|
+
$[66] = onPointerMove;
|
|
547
|
+
$[67] = onUserDrag;
|
|
548
|
+
$[68] = renderDragFrame;
|
|
549
|
+
$[69] = renderInsertionIndicator;
|
|
550
|
+
$[70] = scrollThrottled;
|
|
551
|
+
$[71] = scrollerRef?.current;
|
|
552
|
+
$[72] = translateButton;
|
|
553
|
+
$[73] = t13;
|
|
554
|
+
} else {
|
|
555
|
+
t13 = $[73];
|
|
556
|
+
}
|
|
557
|
+
const handlePointerMove = t13;
|
|
558
|
+
let t14;
|
|
559
|
+
if ($[74] !== animateNoChangeThenCleanup || $[75] !== cleanupDrag || $[76] !== getClosestInsertionPointLocal || $[77] !== index || $[78] !== onPointerUp || $[79] !== onReorder) {
|
|
560
|
+
t14 = function handlePointerUp(e_1) {
|
|
561
|
+
onPointerUp?.(e_1);
|
|
562
|
+
if (e_1.defaultPrevented) {
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
if (activeDragRef.current?.state !== "is-dragging") {
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
const {
|
|
569
|
+
clientX: clientX_4,
|
|
570
|
+
clientY: clientY_4
|
|
571
|
+
} = e_1;
|
|
572
|
+
const insertionPoint_0 = getClosestInsertionPointLocal(clientX_4, clientY_4);
|
|
573
|
+
const insertionIndex_1 = insertionPoint_0 && insertionPoint_0.itemIndex + (insertionPoint_0.after ? 1 : 0);
|
|
574
|
+
if (insertionIndex_1 == null || insertionIndex_1 === index || insertionIndex_1 === index + 1) {
|
|
575
|
+
animateNoChangeThenCleanup();
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
cleanupDrag();
|
|
579
|
+
onReorder(insertionIndex_1);
|
|
580
|
+
};
|
|
581
|
+
$[74] = animateNoChangeThenCleanup;
|
|
582
|
+
$[75] = cleanupDrag;
|
|
583
|
+
$[76] = getClosestInsertionPointLocal;
|
|
584
|
+
$[77] = index;
|
|
585
|
+
$[78] = onPointerUp;
|
|
586
|
+
$[79] = onReorder;
|
|
587
|
+
$[80] = t14;
|
|
588
|
+
} else {
|
|
589
|
+
t14 = $[80];
|
|
590
|
+
}
|
|
591
|
+
const handlePointerUp = t14;
|
|
592
|
+
let t15;
|
|
593
|
+
if ($[81] !== canReorder || $[82] !== columns || $[83] !== data || $[84] !== index || $[85] !== isColumn || $[86] !== onKeyDown || $[87] !== onReorder) {
|
|
594
|
+
t15 = function handleKeyDown(e_2) {
|
|
595
|
+
onKeyDown?.(e_2);
|
|
596
|
+
if (e_2.defaultPrevented) {
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
const left = isColumn && e_2.key === "ArrowLeft";
|
|
600
|
+
const right = isColumn && e_2.key === "ArrowRight";
|
|
601
|
+
const up = !isColumn && e_2.key === "ArrowUp";
|
|
602
|
+
const down = !isColumn && e_2.key === "ArrowDown";
|
|
603
|
+
if (!left && !right && !up && !down || !columns || !data) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
const backward = left || up;
|
|
607
|
+
const initialInsertionIndex = backward ? index - 1 : index + 2;
|
|
608
|
+
const maxInsertionIndex = isColumn ? columns.length : data.length;
|
|
609
|
+
const step = backward ? -1 : 1;
|
|
610
|
+
for (let i = initialInsertionIndex; 0 <= i && i <= maxInsertionIndex; i = i + step, i) {
|
|
611
|
+
if (canReorder(i)) {
|
|
612
|
+
onReorder(i);
|
|
613
|
+
e_2.preventDefault();
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
$[81] = canReorder;
|
|
619
|
+
$[82] = columns;
|
|
620
|
+
$[83] = data;
|
|
621
|
+
$[84] = index;
|
|
622
|
+
$[85] = isColumn;
|
|
623
|
+
$[86] = onKeyDown;
|
|
624
|
+
$[87] = onReorder;
|
|
625
|
+
$[88] = t15;
|
|
626
|
+
} else {
|
|
627
|
+
t15 = $[88];
|
|
628
|
+
}
|
|
629
|
+
const handleKeyDown = t15;
|
|
630
|
+
let t16;
|
|
631
|
+
if ($[89] !== animateNoChangeThenCleanup || $[90] !== onPointerCancel) {
|
|
632
|
+
t16 = function handlePointerCancel(e_3) {
|
|
633
|
+
onPointerCancel?.(e_3);
|
|
634
|
+
if (!e_3.defaultPrevented) {
|
|
635
|
+
animateNoChangeThenCleanup();
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
$[89] = animateNoChangeThenCleanup;
|
|
639
|
+
$[90] = onPointerCancel;
|
|
640
|
+
$[91] = t16;
|
|
641
|
+
} else {
|
|
642
|
+
t16 = $[91];
|
|
643
|
+
}
|
|
644
|
+
const handlePointerCancel = t16;
|
|
645
|
+
let t17;
|
|
646
|
+
if ($[92] !== animateNoChangeThenCleanup || $[93] !== onLostPointerCapture) {
|
|
647
|
+
t17 = function handleLostPointerCapture(e_4) {
|
|
648
|
+
onLostPointerCapture?.(e_4);
|
|
649
|
+
if (!e_4.defaultPrevented) {
|
|
650
|
+
animateNoChangeThenCleanup();
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
$[92] = animateNoChangeThenCleanup;
|
|
654
|
+
$[93] = onLostPointerCapture;
|
|
655
|
+
$[94] = t17;
|
|
656
|
+
} else {
|
|
657
|
+
t17 = $[94];
|
|
658
|
+
}
|
|
659
|
+
const handleLostPointerCapture = t17;
|
|
660
|
+
let t18;
|
|
661
|
+
if ($[95] !== cleanupDrag) {
|
|
662
|
+
t18 = () => {
|
|
663
|
+
if (activeDragRef.current) {
|
|
664
|
+
cleanupDrag();
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
$[95] = cleanupDrag;
|
|
668
|
+
$[96] = t18;
|
|
669
|
+
} else {
|
|
670
|
+
t18 = $[96];
|
|
671
|
+
}
|
|
672
|
+
const cleanupComponent = useEffectEvent(t18);
|
|
673
|
+
let t19;
|
|
674
|
+
if ($[97] !== cleanupComponent) {
|
|
675
|
+
t19 = () => cleanupComponent;
|
|
676
|
+
$[97] = cleanupComponent;
|
|
677
|
+
$[98] = t19;
|
|
678
|
+
} else {
|
|
679
|
+
t19 = $[98];
|
|
680
|
+
}
|
|
681
|
+
let t20;
|
|
682
|
+
if ($[99] === Symbol.for("react.memo_cache_sentinel")) {
|
|
683
|
+
t20 = [];
|
|
684
|
+
$[99] = t20;
|
|
685
|
+
} else {
|
|
686
|
+
t20 = $[99];
|
|
687
|
+
}
|
|
688
|
+
useEffect(t19, t20);
|
|
689
|
+
const hint = isColumn ? `Reorder column ${(_columns$index$name = columns?.[index]?.name) !== null && _columns$index$name !== void 0 ? _columns$index$name : String(columns?.[index]?.key)}.` : `Reorder item ${index + 1}.`;
|
|
690
|
+
const description = isColumn ? "Use Left and Right arrow keys to move the column." : "Use Up and Down arrow keys to move the item.";
|
|
691
|
+
const shortcuts = isColumn ? "ArrowLeft ArrowRight" : "ArrowUp ArrowDown";
|
|
692
|
+
const t21 = isColumn ? styles.columnReorderHandle : styles.itemReorderHandle;
|
|
693
|
+
let t22;
|
|
694
|
+
if ($[100] !== className || $[101] !== t21) {
|
|
695
|
+
t22 = classNames(styles.tableButton, t21, className);
|
|
696
|
+
$[100] = className;
|
|
697
|
+
$[101] = t21;
|
|
698
|
+
$[102] = t22;
|
|
699
|
+
} else {
|
|
700
|
+
t22 = $[102];
|
|
701
|
+
}
|
|
702
|
+
let t23;
|
|
703
|
+
if ($[103] === Symbol.for("react.memo_cache_sentinel")) {
|
|
704
|
+
t23 = /*#__PURE__*/jsx(Icon, {
|
|
705
|
+
glyph: dragIcon,
|
|
706
|
+
"aria-hidden": "true"
|
|
707
|
+
});
|
|
708
|
+
$[103] = t23;
|
|
709
|
+
} else {
|
|
710
|
+
t23 = $[103];
|
|
711
|
+
}
|
|
712
|
+
let t24;
|
|
713
|
+
if ($[104] !== composedRef || $[105] !== description || $[106] !== handleKeyDown || $[107] !== handleLostPointerCapture || $[108] !== handlePointerCancel || $[109] !== handlePointerDown || $[110] !== handlePointerMove || $[111] !== handlePointerUp || $[112] !== hint || $[113] !== restProps || $[114] !== shortcuts || $[115] !== t22) {
|
|
714
|
+
t24 = /*#__PURE__*/jsx("button", {
|
|
715
|
+
ref: composedRef,
|
|
716
|
+
type: "button",
|
|
717
|
+
className: t22,
|
|
718
|
+
"aria-label": hint,
|
|
719
|
+
"aria-description": description,
|
|
720
|
+
"aria-keyshortcuts": shortcuts,
|
|
721
|
+
onKeyDown: handleKeyDown,
|
|
722
|
+
onPointerDown: handlePointerDown,
|
|
723
|
+
onPointerMove: handlePointerMove,
|
|
724
|
+
onPointerUp: handlePointerUp,
|
|
725
|
+
onPointerCancel: handlePointerCancel,
|
|
726
|
+
onLostPointerCapture: handleLostPointerCapture,
|
|
727
|
+
...restProps,
|
|
728
|
+
children: t23
|
|
729
|
+
});
|
|
730
|
+
$[104] = composedRef;
|
|
731
|
+
$[105] = description;
|
|
732
|
+
$[106] = handleKeyDown;
|
|
733
|
+
$[107] = handleLostPointerCapture;
|
|
734
|
+
$[108] = handlePointerCancel;
|
|
735
|
+
$[109] = handlePointerDown;
|
|
736
|
+
$[110] = handlePointerMove;
|
|
737
|
+
$[111] = handlePointerUp;
|
|
738
|
+
$[112] = hint;
|
|
739
|
+
$[113] = restProps;
|
|
740
|
+
$[114] = shortcuts;
|
|
741
|
+
$[115] = t22;
|
|
742
|
+
$[116] = t24;
|
|
743
|
+
} else {
|
|
744
|
+
t24 = $[116];
|
|
745
|
+
}
|
|
746
|
+
return t24;
|
|
747
|
+
}
|
|
748
|
+
function _temp() {}
|
|
749
|
+
|
|
750
|
+
export { ReorderHandle };
|