@jetbrains/ring-ui-built 8.0.0-beta.13 → 8.0.0-beta.15
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/table.js +1 -1
- package/components/auth/iframe-flow.js +0 -1
- package/components/auth-dialog/auth-dialog.js +0 -1
- package/components/auth-dialog-service/auth-dialog-service.js +0 -1
- package/components/collapsible-group/collapsible-group.d.ts +2 -1
- package/components/collapsible-group/collapsible-group.js +74 -77
- package/components/column-resize/column-group.js +69 -0
- package/components/column-resize/column-resize-drag.js +147 -0
- package/components/column-resize/column-resize-handle.js +86 -0
- package/components/column-resize/column-sizing-context.js +200 -0
- package/components/confirm/confirm.js +0 -1
- package/components/confirm-service/confirm-service.js +0 -1
- package/components/dialog/dialog.js +11 -2
- package/components/internal/column-indicator-vertical-span.js +23 -0
- package/components/internal/drag-auto-scroll.js +118 -0
- package/components/internal/reorder-handle.js +198 -210
- package/components/internal/table-header.js +152 -113
- package/components/island/content.d.ts +2 -4
- package/components/island/content.js +21 -21
- package/components/island/island.js +0 -1
- package/components/login-dialog/login-dialog.js +0 -1
- package/components/login-dialog/service.js +0 -1
- package/components/style.css +1 -1
- package/components/table/default-item-renderer.js +6 -4
- package/components/table/internal/column-indicator-vertical-span.d.ts +8 -0
- package/components/table/internal/column-resize/column-group.d.ts +8 -0
- package/components/table/internal/column-resize/column-resize-drag.d.ts +27 -0
- package/components/table/internal/column-resize/column-resize-handle.d.ts +5 -0
- package/components/table/internal/column-resize/column-sizing-context.d.ts +27 -0
- package/components/table/internal/drag-auto-scroll.d.ts +18 -0
- package/components/table/item-virtualization.d.ts +2 -1
- package/components/table/table-const.d.ts +6 -0
- package/components/table/table-const.js +7 -1
- package/components/table/table-primitives.js +2 -0
- package/components/table/table-props.d.ts +39 -0
- package/components/table/table.d.ts +8 -0
- package/components/table/table.js +239 -165
- package/components/user-agreement/service.js +0 -1
- package/components/user-agreement/user-agreement.js +0 -1
- package/package.json +1 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var styles = {"headerCell":"ring-table-headerCell","columnReorderHandleMirror":"ring-table-columnReorderHandleMirror","columnReorderHandle":"ring-table-columnReorderHandle","table":"ring-table-table","
|
|
1
|
+
var styles = {"headerCell":"ring-table-headerCell","columnReorderHandleMirror":"ring-table-columnReorderHandleMirror","columnReorderHandle":"ring-table-columnReorderHandle","table":"ring-table-table","fixedLayout":"ring-table-fixedLayout","cell":"ring-table-cell","sortAndHeader":"ring-table-sortAndHeader","rightButtons":"ring-table-rightButtons","columnResizeHandle":"ring-table-columnResizeHandle","theadColumnEditing":"ring-table-theadColumnEditing","columnResizeIndicator":"ring-table-columnResizeIndicator","resizableHeaderCell":"ring-table-resizableHeaderCell","stickyHeader":"ring-table-stickyHeader","reorderAnimationInitial":"ring-table-reorderAnimationInitial","reorderAnimationFadeOut":"ring-table-reorderAnimationFadeOut","headerCellInnerWrapper":"ring-table-headerCellInnerWrapper","tableButton":"ring-table-tableButton","deleteColumnButton":"ring-table-deleteColumnButton","itemReorderHandle":"ring-table-itemReorderHandle","editColumnsButton":"ring-table-editColumnsButton","dragFrame":"ring-table-dragFrame","insertionIndicator":"ring-table-insertionIndicator","spacerRow":"ring-table-spacerRow","spacerCell":"ring-table-spacerCell","row":"ring-table-row","clickableRow":"ring-table-clickableRow","selectedRow":"ring-table-selectedRow"};
|
|
2
2
|
|
|
3
3
|
export { styles as s };
|
|
@@ -19,7 +19,6 @@ import '../_helpers/island.js';
|
|
|
19
19
|
import '../island/header.js';
|
|
20
20
|
import 'react/compiler-runtime';
|
|
21
21
|
import '../island/content.js';
|
|
22
|
-
import 'element-resize-detector';
|
|
23
22
|
import '../global/schedule-raf.js';
|
|
24
23
|
import '../global/get-uid.js';
|
|
25
24
|
import '../shortcuts/shortcuts.js';
|
|
@@ -7,7 +7,6 @@ import ContentWrapper from '../island/content.js';
|
|
|
7
7
|
import Dialog from '../dialog/dialog.js';
|
|
8
8
|
import { Button } from '../button/button.js';
|
|
9
9
|
import { H2 } from '../heading/heading.js';
|
|
10
|
-
import 'element-resize-detector';
|
|
11
10
|
import '../global/schedule-raf.js';
|
|
12
11
|
import '../island/adaptive-island-hoc.js';
|
|
13
12
|
import '../global/linear-function.js';
|
|
@@ -9,7 +9,6 @@ import 'classnames';
|
|
|
9
9
|
import '../_helpers/island.js';
|
|
10
10
|
import 'react/compiler-runtime';
|
|
11
11
|
import '../island/content.js';
|
|
12
|
-
import 'element-resize-detector';
|
|
13
12
|
import '../global/schedule-raf.js';
|
|
14
13
|
import '../island/adaptive-island-hoc.js';
|
|
15
14
|
import '../global/linear-function.js';
|
|
@@ -25,9 +25,10 @@ export interface CollapsibleGroupProps {
|
|
|
25
25
|
*/
|
|
26
26
|
headingLevel?: 2 | 3 | 4 | 5 | 6;
|
|
27
27
|
'data-test'?: string | null | undefined;
|
|
28
|
+
expandedShadow?: boolean;
|
|
28
29
|
}
|
|
29
30
|
declare const CollapsibleGroup: {
|
|
30
|
-
({ ref, avatar, title, subtitle, children, className, defaultExpanded, expanded, onChange, disableAnimation, interactive, keepMounted, headingLevel, "data-test": dataTest, }: CollapsibleGroupProps): React.JSX.Element;
|
|
31
|
+
({ ref, avatar, title, subtitle, children, className, defaultExpanded, expanded, onChange, disableAnimation, interactive, keepMounted, headingLevel, "data-test": dataTest, expandedShadow, }: CollapsibleGroupProps): React.JSX.Element;
|
|
31
32
|
displayName: string;
|
|
32
33
|
};
|
|
33
34
|
export default CollapsibleGroup;
|
|
@@ -18,15 +18,15 @@ import '../global/dom.js';
|
|
|
18
18
|
import '../global/parse-css-duration.js';
|
|
19
19
|
import '../collapse/utils.js';
|
|
20
20
|
|
|
21
|
-
var styles = {"expand":"ring-collapsible-group-expand","collapseRoot":"ring-collapsible-group-collapseRoot","
|
|
21
|
+
var styles = {"expand":"ring-collapsible-group-expand","collapseRoot":"ring-collapsible-group-collapseRoot","headerButton":"ring-collapsible-group-headerButton","expandedShadow":"ring-collapsible-group-expandedShadow","header":"ring-collapsible-group-header","heading":"ring-collapsible-group-heading","headerStatic":"ring-collapsible-group-headerStatic","headerContent":"ring-collapsible-group-headerContent","avatarGroup":"ring-collapsible-group-avatarGroup","title":"ring-collapsible-group-title","subtitleGroup":"ring-collapsible-group-subtitleGroup","subtitle":"ring-collapsible-group-subtitle","subtitleChevron":"ring-collapsible-group-subtitleChevron","toggle":"ring-collapsible-group-toggle","toggleIcon":"ring-collapsible-group-toggleIcon","body":"ring-collapsible-group-body"};
|
|
22
22
|
|
|
23
23
|
function CollapsibleGroupHeaderContent(t0) {
|
|
24
24
|
const $ = c(16);
|
|
25
|
-
if ($[0] !== "
|
|
25
|
+
if ($[0] !== "2615250e6936ea59c19eaf09870ac5b92345ac63694f8dd4c63950e29378135f") {
|
|
26
26
|
for (let $i = 0; $i < 16; $i += 1) {
|
|
27
27
|
$[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
28
28
|
}
|
|
29
|
-
$[0] = "
|
|
29
|
+
$[0] = "2615250e6936ea59c19eaf09870ac5b92345ac63694f8dd4c63950e29378135f";
|
|
30
30
|
}
|
|
31
31
|
const {
|
|
32
32
|
avatar,
|
|
@@ -121,11 +121,11 @@ function CollapsibleGroupHeaderContent(t0) {
|
|
|
121
121
|
}
|
|
122
122
|
function CollapsibleGroupHeader(t0) {
|
|
123
123
|
const $ = c(16);
|
|
124
|
-
if ($[0] !== "
|
|
124
|
+
if ($[0] !== "2615250e6936ea59c19eaf09870ac5b92345ac63694f8dd4c63950e29378135f") {
|
|
125
125
|
for (let $i = 0; $i < 16; $i += 1) {
|
|
126
126
|
$[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
127
127
|
}
|
|
128
|
-
$[0] = "
|
|
128
|
+
$[0] = "2615250e6936ea59c19eaf09870ac5b92345ac63694f8dd4c63950e29378135f";
|
|
129
129
|
}
|
|
130
130
|
let avatar;
|
|
131
131
|
let buttonProps;
|
|
@@ -194,11 +194,11 @@ function CollapsibleGroupHeader(t0) {
|
|
|
194
194
|
}
|
|
195
195
|
function CollapsibleGroupHeaderStatic(t0) {
|
|
196
196
|
const $ = c(5);
|
|
197
|
-
if ($[0] !== "
|
|
197
|
+
if ($[0] !== "2615250e6936ea59c19eaf09870ac5b92345ac63694f8dd4c63950e29378135f") {
|
|
198
198
|
for (let $i = 0; $i < 5; $i += 1) {
|
|
199
199
|
$[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
200
200
|
}
|
|
201
|
-
$[0] = "
|
|
201
|
+
$[0] = "2615250e6936ea59c19eaf09870ac5b92345ac63694f8dd4c63950e29378135f";
|
|
202
202
|
}
|
|
203
203
|
const {
|
|
204
204
|
avatar,
|
|
@@ -225,12 +225,12 @@ function CollapsibleGroupHeaderStatic(t0) {
|
|
|
225
225
|
return t1;
|
|
226
226
|
}
|
|
227
227
|
const CollapsibleGroup = t0 => {
|
|
228
|
-
const $ = c(
|
|
229
|
-
if ($[0] !== "
|
|
230
|
-
for (let $i = 0; $i <
|
|
228
|
+
const $ = c(30);
|
|
229
|
+
if ($[0] !== "2615250e6936ea59c19eaf09870ac5b92345ac63694f8dd4c63950e29378135f") {
|
|
230
|
+
for (let $i = 0; $i < 30; $i += 1) {
|
|
231
231
|
$[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
232
232
|
}
|
|
233
|
-
$[0] = "
|
|
233
|
+
$[0] = "2615250e6936ea59c19eaf09870ac5b92345ac63694f8dd4c63950e29378135f";
|
|
234
234
|
}
|
|
235
235
|
const {
|
|
236
236
|
ref,
|
|
@@ -246,7 +246,8 @@ const CollapsibleGroup = t0 => {
|
|
|
246
246
|
interactive: t5,
|
|
247
247
|
keepMounted: t6,
|
|
248
248
|
headingLevel,
|
|
249
|
-
"data-test": dataTest
|
|
249
|
+
"data-test": dataTest,
|
|
250
|
+
expandedShadow
|
|
250
251
|
} = t0;
|
|
251
252
|
const defaultExpanded = t1 === undefined ? false : t1;
|
|
252
253
|
const expanded = t2 === undefined ? null : t2;
|
|
@@ -255,7 +256,6 @@ const CollapsibleGroup = t0 => {
|
|
|
255
256
|
const interactive = t5 === undefined ? true : t5;
|
|
256
257
|
const keepMounted = t6 === undefined ? false : t6;
|
|
257
258
|
const [innerExpanded, setInnerExpanded] = useState(defaultExpanded);
|
|
258
|
-
const [hovered, setHovered] = useState(false);
|
|
259
259
|
const isExpanded = expanded !== null && expanded !== void 0 ? expanded : innerExpanded;
|
|
260
260
|
let t7;
|
|
261
261
|
if ($[1] !== expanded || $[2] !== onChange) {
|
|
@@ -273,107 +273,104 @@ const CollapsibleGroup = t0 => {
|
|
|
273
273
|
t7 = $[3];
|
|
274
274
|
}
|
|
275
275
|
const handleChange = t7;
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
[styles.
|
|
276
|
+
const t8 = expandedShadow && isExpanded;
|
|
277
|
+
let t9;
|
|
278
|
+
if ($[4] !== className || $[5] !== t8) {
|
|
279
|
+
t9 = classNames(styles.expand, className, {
|
|
280
|
+
[styles.expandedShadow]: t8
|
|
281
281
|
});
|
|
282
282
|
$[4] = className;
|
|
283
|
-
$[5] =
|
|
284
|
-
$[6] =
|
|
285
|
-
$[7] = t8;
|
|
283
|
+
$[5] = t8;
|
|
284
|
+
$[6] = t9;
|
|
286
285
|
} else {
|
|
287
|
-
|
|
286
|
+
t9 = $[6];
|
|
288
287
|
}
|
|
289
|
-
const classes =
|
|
290
|
-
let
|
|
291
|
-
if ($[
|
|
292
|
-
|
|
288
|
+
const classes = t9;
|
|
289
|
+
let t10;
|
|
290
|
+
if ($[7] !== avatar || $[8] !== interactive || $[9] !== subtitle || $[10] !== title) {
|
|
291
|
+
t10 = interactive ? /*#__PURE__*/jsx(CollapsibleGroupHeader, {
|
|
293
292
|
avatar: avatar,
|
|
294
293
|
titleContent: title,
|
|
295
|
-
subtitle: subtitle
|
|
296
|
-
onMouseEnter: () => setHovered(true),
|
|
297
|
-
onMouseLeave: () => setHovered(false)
|
|
294
|
+
subtitle: subtitle
|
|
298
295
|
}) : /*#__PURE__*/jsx(CollapsibleGroupHeaderStatic, {
|
|
299
296
|
avatar: avatar,
|
|
300
297
|
titleContent: title,
|
|
301
298
|
subtitle: subtitle
|
|
302
299
|
});
|
|
303
|
-
$[
|
|
304
|
-
$[
|
|
305
|
-
$[
|
|
306
|
-
$[
|
|
307
|
-
$[
|
|
300
|
+
$[7] = avatar;
|
|
301
|
+
$[8] = interactive;
|
|
302
|
+
$[9] = subtitle;
|
|
303
|
+
$[10] = title;
|
|
304
|
+
$[11] = t10;
|
|
308
305
|
} else {
|
|
309
|
-
|
|
306
|
+
t10 = $[11];
|
|
310
307
|
}
|
|
311
|
-
const header =
|
|
312
|
-
const
|
|
313
|
-
const
|
|
314
|
-
let
|
|
315
|
-
if ($[
|
|
316
|
-
|
|
308
|
+
const header = t10;
|
|
309
|
+
const t11 = !defaultExpanded;
|
|
310
|
+
const t12 = expanded == null ? null : !expanded;
|
|
311
|
+
let t13;
|
|
312
|
+
if ($[12] !== header || $[13] !== headingLevel) {
|
|
313
|
+
t13 = headingLevel != null ? /*#__PURE__*/React__default.createElement(`h${headingLevel}`, {
|
|
317
314
|
className: styles.heading
|
|
318
315
|
}, header) : header;
|
|
319
|
-
$[
|
|
320
|
-
$[
|
|
321
|
-
$[
|
|
316
|
+
$[12] = header;
|
|
317
|
+
$[13] = headingLevel;
|
|
318
|
+
$[14] = t13;
|
|
322
319
|
} else {
|
|
323
|
-
|
|
320
|
+
t13 = $[14];
|
|
324
321
|
}
|
|
325
|
-
let
|
|
326
|
-
if ($[
|
|
327
|
-
|
|
322
|
+
let t14;
|
|
323
|
+
if ($[15] !== children) {
|
|
324
|
+
t14 = /*#__PURE__*/jsx(CollapseContent, {
|
|
328
325
|
children: /*#__PURE__*/jsx("div", {
|
|
329
326
|
className: styles.body,
|
|
330
327
|
children: children
|
|
331
328
|
})
|
|
332
329
|
});
|
|
333
|
-
$[
|
|
334
|
-
$[
|
|
330
|
+
$[15] = children;
|
|
331
|
+
$[16] = t14;
|
|
335
332
|
} else {
|
|
336
|
-
|
|
333
|
+
t14 = $[16];
|
|
337
334
|
}
|
|
338
|
-
let
|
|
339
|
-
if ($[
|
|
340
|
-
|
|
341
|
-
defaultCollapsed:
|
|
342
|
-
collapsed:
|
|
335
|
+
let t15;
|
|
336
|
+
if ($[17] !== disableAnimation || $[18] !== handleChange || $[19] !== keepMounted || $[20] !== t11 || $[21] !== t12 || $[22] !== t13 || $[23] !== t14) {
|
|
337
|
+
t15 = /*#__PURE__*/jsxs(Collapse, {
|
|
338
|
+
defaultCollapsed: t11,
|
|
339
|
+
collapsed: t12,
|
|
343
340
|
onChange: handleChange,
|
|
344
341
|
disableAnimation: disableAnimation,
|
|
345
342
|
keepMounted: keepMounted,
|
|
346
343
|
className: styles.collapseRoot,
|
|
347
|
-
children: [
|
|
344
|
+
children: [t13, t14]
|
|
348
345
|
});
|
|
349
|
-
$[
|
|
350
|
-
$[
|
|
351
|
-
$[
|
|
352
|
-
$[
|
|
353
|
-
$[
|
|
354
|
-
$[
|
|
355
|
-
$[
|
|
356
|
-
$[
|
|
346
|
+
$[17] = disableAnimation;
|
|
347
|
+
$[18] = handleChange;
|
|
348
|
+
$[19] = keepMounted;
|
|
349
|
+
$[20] = t11;
|
|
350
|
+
$[21] = t12;
|
|
351
|
+
$[22] = t13;
|
|
352
|
+
$[23] = t14;
|
|
353
|
+
$[24] = t15;
|
|
357
354
|
} else {
|
|
358
|
-
|
|
355
|
+
t15 = $[24];
|
|
359
356
|
}
|
|
360
|
-
let
|
|
361
|
-
if ($[
|
|
362
|
-
|
|
357
|
+
let t16;
|
|
358
|
+
if ($[25] !== classes || $[26] !== dataTest || $[27] !== ref || $[28] !== t15) {
|
|
359
|
+
t16 = /*#__PURE__*/jsx("div", {
|
|
363
360
|
ref: ref,
|
|
364
361
|
className: classes,
|
|
365
362
|
"data-test": dataTest,
|
|
366
|
-
children:
|
|
363
|
+
children: t15
|
|
367
364
|
});
|
|
368
|
-
$[
|
|
369
|
-
$[
|
|
370
|
-
$[
|
|
371
|
-
$[
|
|
372
|
-
$[
|
|
365
|
+
$[25] = classes;
|
|
366
|
+
$[26] = dataTest;
|
|
367
|
+
$[27] = ref;
|
|
368
|
+
$[28] = t15;
|
|
369
|
+
$[29] = t16;
|
|
373
370
|
} else {
|
|
374
|
-
|
|
371
|
+
t16 = $[29];
|
|
375
372
|
}
|
|
376
|
-
return
|
|
373
|
+
return t16;
|
|
377
374
|
};
|
|
378
375
|
CollapsibleGroup.displayName = 'CollapsibleGroup';
|
|
379
376
|
function _temp() {}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { c } from 'react/compiler-runtime';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Sets the column widths. In fixed layout, header and body cells follow them.
|
|
6
|
+
*/
|
|
7
|
+
function ColumnGroup(t0) {
|
|
8
|
+
const $ = c(11);
|
|
9
|
+
if ($[0] !== "373c0340ef06cfc859ce14446d651c19d65a3cfee64152dac1a4c3f84c47e38b") {
|
|
10
|
+
for (let $i = 0; $i < 11; $i += 1) {
|
|
11
|
+
$[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
12
|
+
}
|
|
13
|
+
$[0] = "373c0340ef06cfc859ce14446d651c19d65a3cfee64152dac1a4c3f84c47e38b";
|
|
14
|
+
}
|
|
15
|
+
const {
|
|
16
|
+
columns,
|
|
17
|
+
widths
|
|
18
|
+
} = t0;
|
|
19
|
+
let t1;
|
|
20
|
+
if ($[1] !== columns || $[2] !== widths) {
|
|
21
|
+
let t2;
|
|
22
|
+
if ($[4] !== widths) {
|
|
23
|
+
t2 = (column, index) => /*#__PURE__*/jsx("col", {
|
|
24
|
+
style: {
|
|
25
|
+
width: widths[index]
|
|
26
|
+
}
|
|
27
|
+
}, column.key);
|
|
28
|
+
$[4] = widths;
|
|
29
|
+
$[5] = t2;
|
|
30
|
+
} else {
|
|
31
|
+
t2 = $[5];
|
|
32
|
+
}
|
|
33
|
+
t1 = columns.map(t2);
|
|
34
|
+
$[1] = columns;
|
|
35
|
+
$[2] = widths;
|
|
36
|
+
$[3] = t1;
|
|
37
|
+
} else {
|
|
38
|
+
t1 = $[3];
|
|
39
|
+
}
|
|
40
|
+
let t2;
|
|
41
|
+
if ($[6] !== columns) {
|
|
42
|
+
t2 = columns.some(_temp) && /*#__PURE__*/jsx("col", {
|
|
43
|
+
style: {
|
|
44
|
+
width: 0
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
$[6] = columns;
|
|
48
|
+
$[7] = t2;
|
|
49
|
+
} else {
|
|
50
|
+
t2 = $[7];
|
|
51
|
+
}
|
|
52
|
+
let t3;
|
|
53
|
+
if ($[8] !== t1 || $[9] !== t2) {
|
|
54
|
+
t3 = /*#__PURE__*/jsxs("colgroup", {
|
|
55
|
+
children: [t1, t2]
|
|
56
|
+
});
|
|
57
|
+
$[8] = t1;
|
|
58
|
+
$[9] = t2;
|
|
59
|
+
$[10] = t3;
|
|
60
|
+
} else {
|
|
61
|
+
t3 = $[10];
|
|
62
|
+
}
|
|
63
|
+
return t3;
|
|
64
|
+
}
|
|
65
|
+
function _temp(column_0) {
|
|
66
|
+
return column_0.resizable;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { ColumnGroup };
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { getColumnIndicatorVerticalSpan } from '../internal/column-indicator-vertical-span.js';
|
|
2
|
+
import { s as styles } from '../_helpers/table.js';
|
|
3
|
+
|
|
4
|
+
const defaultMinColumnWidth = 40;
|
|
5
|
+
/**
|
|
6
|
+
* Lets the user resize a column by dragging its handle.
|
|
7
|
+
*
|
|
8
|
+
* The width is previewed by writing directly to the `<col>` elements, without
|
|
9
|
+
* rendering. On release, the DOM is restored and `onCommit` is called, so that
|
|
10
|
+
* React renders the new width. Escape, pointer cancellation, and lost pointer
|
|
11
|
+
* capture cancel the drag.
|
|
12
|
+
*
|
|
13
|
+
* Everything is captured when the drag starts, so re-renders don't affect it.
|
|
14
|
+
* Returns a function that cancels the drag.
|
|
15
|
+
*/
|
|
16
|
+
function startColumnResizeDrag({
|
|
17
|
+
handle,
|
|
18
|
+
pointerId,
|
|
19
|
+
clientX: startClientX,
|
|
20
|
+
columnIndex,
|
|
21
|
+
startWidths,
|
|
22
|
+
minWidth: columnMinWidth = defaultMinColumnWidth,
|
|
23
|
+
maxWidth: columnMaxWidth = Infinity,
|
|
24
|
+
onCommit,
|
|
25
|
+
onEnd
|
|
26
|
+
}) {
|
|
27
|
+
const elements = findDragElements(handle, columnIndex);
|
|
28
|
+
if (!elements) {
|
|
29
|
+
onEnd();
|
|
30
|
+
return () => {};
|
|
31
|
+
}
|
|
32
|
+
const {
|
|
33
|
+
th,
|
|
34
|
+
table,
|
|
35
|
+
column,
|
|
36
|
+
filler
|
|
37
|
+
} = elements;
|
|
38
|
+
const startWidth = startWidths[columnIndex];
|
|
39
|
+
const startTotalWidth = startWidths.reduce((sum, width) => sum + width, 0);
|
|
40
|
+
// The bounds never make the column jump: a column that is already outside of them can only be resized towards them
|
|
41
|
+
const minWidth = Math.min(columnMinWidth, startWidth);
|
|
42
|
+
const maxWidth = Math.max(columnMaxWidth, startWidth);
|
|
43
|
+
// Where the user grabbed the handle, relative to the column edge
|
|
44
|
+
const grabOffset = startClientX - th.getBoundingClientRect().right;
|
|
45
|
+
let width = startWidth;
|
|
46
|
+
let lastClientX = startClientX;
|
|
47
|
+
const indicator = document.createElement('div');
|
|
48
|
+
indicator.className = styles.columnResizeIndicator;
|
|
49
|
+
document.body.appendChild(indicator);
|
|
50
|
+
const previousBodyCursor = document.body.style.cursor;
|
|
51
|
+
const previousBodyUserSelect = document.body.style.userSelect;
|
|
52
|
+
document.body.style.cursor = 'col-resize';
|
|
53
|
+
document.body.style.userSelect = 'none';
|
|
54
|
+
function setDomWidths(columnWidth, fillerWidth) {
|
|
55
|
+
column.style.width = `${columnWidth}px`;
|
|
56
|
+
filler.style.width = `${fillerWidth}px`;
|
|
57
|
+
table.style.width = `${startTotalWidth - startWidth + columnWidth + fillerWidth}px`;
|
|
58
|
+
}
|
|
59
|
+
function positionIndicator(columnRight) {
|
|
60
|
+
const span = getColumnIndicatorVerticalSpan(th);
|
|
61
|
+
if (span) {
|
|
62
|
+
indicator.style.top = `${span.top}px`;
|
|
63
|
+
indicator.style.height = span.height;
|
|
64
|
+
}
|
|
65
|
+
indicator.style.left = `${columnRight - 1}px`;
|
|
66
|
+
}
|
|
67
|
+
// Uses the column's current position rather than the pointer delta,
|
|
68
|
+
// so the edge stays under the pointer when the table scrolls mid-drag.
|
|
69
|
+
function update(clientX) {
|
|
70
|
+
lastClientX = clientX;
|
|
71
|
+
const {
|
|
72
|
+
left
|
|
73
|
+
} = th.getBoundingClientRect();
|
|
74
|
+
width = Math.round(Math.min(maxWidth, Math.max(minWidth, clientX - grabOffset - left)));
|
|
75
|
+
setDomWidths(width, Math.max(0, startWidth - width));
|
|
76
|
+
positionIndicator(left + width);
|
|
77
|
+
}
|
|
78
|
+
function end(commit) {
|
|
79
|
+
handle.removeEventListener('pointermove', handlePointerMove);
|
|
80
|
+
handle.removeEventListener('pointerup', handlePointerUp);
|
|
81
|
+
handle.removeEventListener('pointercancel', cancel);
|
|
82
|
+
handle.removeEventListener('lostpointercapture', cancel);
|
|
83
|
+
window.removeEventListener('keydown', handleKeyDown, {
|
|
84
|
+
capture: true
|
|
85
|
+
});
|
|
86
|
+
document.removeEventListener('scroll', handleScroll, {
|
|
87
|
+
capture: true
|
|
88
|
+
});
|
|
89
|
+
if (handle.hasPointerCapture(pointerId)) handle.releasePointerCapture(pointerId);
|
|
90
|
+
indicator.remove();
|
|
91
|
+
document.body.style.cursor = previousBodyCursor;
|
|
92
|
+
document.body.style.userSelect = previousBodyUserSelect;
|
|
93
|
+
setDomWidths(startWidth, 0);
|
|
94
|
+
if (commit) onCommit(width);
|
|
95
|
+
onEnd();
|
|
96
|
+
}
|
|
97
|
+
function cancel() {
|
|
98
|
+
end(false);
|
|
99
|
+
}
|
|
100
|
+
function handlePointerMove(e) {
|
|
101
|
+
if (e.pointerId === pointerId) update(e.clientX);
|
|
102
|
+
}
|
|
103
|
+
function handlePointerUp(e) {
|
|
104
|
+
if (e.pointerId === pointerId) end(true);
|
|
105
|
+
}
|
|
106
|
+
function handleKeyDown(e) {
|
|
107
|
+
if (e.key !== 'Escape') return;
|
|
108
|
+
// Capture phase on `window`, so that e.g. a surrounding dialog doesn't close
|
|
109
|
+
e.stopPropagation();
|
|
110
|
+
e.preventDefault();
|
|
111
|
+
cancel();
|
|
112
|
+
}
|
|
113
|
+
function handleScroll() {
|
|
114
|
+
update(lastClientX);
|
|
115
|
+
}
|
|
116
|
+
handle.setPointerCapture(pointerId);
|
|
117
|
+
handle.addEventListener('pointermove', handlePointerMove);
|
|
118
|
+
handle.addEventListener('pointerup', handlePointerUp);
|
|
119
|
+
handle.addEventListener('pointercancel', cancel);
|
|
120
|
+
handle.addEventListener('lostpointercapture', cancel);
|
|
121
|
+
window.addEventListener('keydown', handleKeyDown, {
|
|
122
|
+
capture: true
|
|
123
|
+
});
|
|
124
|
+
document.addEventListener('scroll', handleScroll, {
|
|
125
|
+
capture: true,
|
|
126
|
+
passive: true
|
|
127
|
+
});
|
|
128
|
+
positionIndicator(th.getBoundingClientRect().right);
|
|
129
|
+
return cancel;
|
|
130
|
+
}
|
|
131
|
+
function findDragElements(handle, columnIndex) {
|
|
132
|
+
const th = handle.closest('th');
|
|
133
|
+
const table = th?.closest('table');
|
|
134
|
+
const cols = table?.querySelectorAll(':scope > colgroup > col');
|
|
135
|
+
const column = cols?.[columnIndex];
|
|
136
|
+
// The last `<col>` keeps the table width while shrinking (see `ColumnGroup`). Otherwise,
|
|
137
|
+
// a container scrolled to the end reduces its scroll position and the content shifts under the pointer.
|
|
138
|
+
const filler = cols?.[cols.length - 1];
|
|
139
|
+
return th && table && column && filler ? {
|
|
140
|
+
th,
|
|
141
|
+
table,
|
|
142
|
+
column,
|
|
143
|
+
filler
|
|
144
|
+
} : undefined;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export { startColumnResizeDrag };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { c } from 'react/compiler-runtime';
|
|
2
|
+
import { use, useRef, useEffect } from 'react';
|
|
3
|
+
import { flushSync } from 'react-dom';
|
|
4
|
+
import { ColumnSizingContext } from './column-sizing-context.js';
|
|
5
|
+
import { startColumnResizeDrag } from './column-resize-drag.js';
|
|
6
|
+
import { s as styles } from '../_helpers/table.js';
|
|
7
|
+
import { jsx } from 'react/jsx-runtime';
|
|
8
|
+
import '../internal/column-indicator-vertical-span.js';
|
|
9
|
+
|
|
10
|
+
function ColumnResizeHandle(t0) {
|
|
11
|
+
const $ = c(8);
|
|
12
|
+
if ($[0] !== "724b466c3bc637c3ae26bf1fabf5e7e4ac8862a86000b5b36fac6c2ff1e52da4") {
|
|
13
|
+
for (let $i = 0; $i < 8; $i += 1) {
|
|
14
|
+
$[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
15
|
+
}
|
|
16
|
+
$[0] = "724b466c3bc637c3ae26bf1fabf5e7e4ac8862a86000b5b36fac6c2ff1e52da4";
|
|
17
|
+
}
|
|
18
|
+
const {
|
|
19
|
+
column,
|
|
20
|
+
columnIndex
|
|
21
|
+
} = t0;
|
|
22
|
+
const {
|
|
23
|
+
freezeWidths,
|
|
24
|
+
commitWidth
|
|
25
|
+
} = use(ColumnSizingContext);
|
|
26
|
+
const cancelDragRef = useRef(null);
|
|
27
|
+
let t1;
|
|
28
|
+
let t2;
|
|
29
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
30
|
+
t1 = () => () => cancelDragRef.current?.();
|
|
31
|
+
t2 = [];
|
|
32
|
+
$[1] = t1;
|
|
33
|
+
$[2] = t2;
|
|
34
|
+
} else {
|
|
35
|
+
t1 = $[1];
|
|
36
|
+
t2 = $[2];
|
|
37
|
+
}
|
|
38
|
+
useEffect(t1, t2);
|
|
39
|
+
let t3;
|
|
40
|
+
if ($[3] !== column || $[4] !== columnIndex || $[5] !== commitWidth || $[6] !== freezeWidths) {
|
|
41
|
+
const handlePointerDown = function handlePointerDown(e) {
|
|
42
|
+
if (e.button !== 0 || !e.isPrimary || cancelDragRef.current) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const startWidths = flushSync(freezeWidths);
|
|
46
|
+
if (!startWidths) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
e.stopPropagation();
|
|
51
|
+
cancelDragRef.current = startColumnResizeDrag({
|
|
52
|
+
handle: e.currentTarget,
|
|
53
|
+
pointerId: e.pointerId,
|
|
54
|
+
clientX: e.clientX,
|
|
55
|
+
columnIndex,
|
|
56
|
+
startWidths,
|
|
57
|
+
minWidth: column.minWidth,
|
|
58
|
+
maxWidth: column.maxWidth,
|
|
59
|
+
onCommit: newWidth => commitWidth(column.key, newWidth),
|
|
60
|
+
onEnd: () => {
|
|
61
|
+
cancelDragRef.current = null;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
t3 = /*#__PURE__*/jsx("div", {
|
|
66
|
+
"aria-hidden": true,
|
|
67
|
+
"data-test": "ring-table-column-resize-handle",
|
|
68
|
+
className: styles.columnResizeHandle,
|
|
69
|
+
onPointerDown: handlePointerDown,
|
|
70
|
+
onClick: _temp
|
|
71
|
+
});
|
|
72
|
+
$[3] = column;
|
|
73
|
+
$[4] = columnIndex;
|
|
74
|
+
$[5] = commitWidth;
|
|
75
|
+
$[6] = freezeWidths;
|
|
76
|
+
$[7] = t3;
|
|
77
|
+
} else {
|
|
78
|
+
t3 = $[7];
|
|
79
|
+
}
|
|
80
|
+
return t3;
|
|
81
|
+
}
|
|
82
|
+
function _temp(e_0) {
|
|
83
|
+
return e_0.stopPropagation();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { ColumnResizeHandle };
|