@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
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { c } from 'react/compiler-runtime';
|
|
2
|
+
import { createContext, useState, useRef, useLayoutEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
const ColumnSizingContext = /*#__PURE__*/createContext({
|
|
5
|
+
freezeWidths: () => undefined,
|
|
6
|
+
commitWidth: () => {}
|
|
7
|
+
});
|
|
8
|
+
function useColumnSizing(t0) {
|
|
9
|
+
const $ = c(35);
|
|
10
|
+
if ($[0] !== "9878f9692d75268d2886c87a6f32578e0dcf9f4921a401f30e432eec4f6a74f8") {
|
|
11
|
+
for (let $i = 0; $i < 35; $i += 1) {
|
|
12
|
+
$[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
13
|
+
}
|
|
14
|
+
$[0] = "9878f9692d75268d2886c87a6f32578e0dcf9f4921a401f30e432eec4f6a74f8";
|
|
15
|
+
}
|
|
16
|
+
const {
|
|
17
|
+
columns,
|
|
18
|
+
onColumnResize,
|
|
19
|
+
tableRef
|
|
20
|
+
} = t0;
|
|
21
|
+
const [internalWidths, setInternalWidths] = useState(_temp);
|
|
22
|
+
let t1;
|
|
23
|
+
if ($[1] !== columns) {
|
|
24
|
+
t1 = columns.some(_temp2);
|
|
25
|
+
$[1] = columns;
|
|
26
|
+
$[2] = t1;
|
|
27
|
+
} else {
|
|
28
|
+
t1 = $[2];
|
|
29
|
+
}
|
|
30
|
+
const hasColgroup = t1;
|
|
31
|
+
let t2;
|
|
32
|
+
if ($[3] !== columns || $[4] !== internalWidths) {
|
|
33
|
+
let t3;
|
|
34
|
+
if ($[6] !== internalWidths) {
|
|
35
|
+
t3 = column_0 => {
|
|
36
|
+
var _column_0$width;
|
|
37
|
+
return (_column_0$width = column_0.width) !== null && _column_0$width !== void 0 ? _column_0$width : internalWidths.get(column_0.key);
|
|
38
|
+
};
|
|
39
|
+
$[6] = internalWidths;
|
|
40
|
+
$[7] = t3;
|
|
41
|
+
} else {
|
|
42
|
+
t3 = $[7];
|
|
43
|
+
}
|
|
44
|
+
t2 = columns.map(t3);
|
|
45
|
+
$[3] = columns;
|
|
46
|
+
$[4] = internalWidths;
|
|
47
|
+
$[5] = t2;
|
|
48
|
+
} else {
|
|
49
|
+
t2 = $[5];
|
|
50
|
+
}
|
|
51
|
+
const widths = t2;
|
|
52
|
+
let t3;
|
|
53
|
+
if ($[8] !== columns || $[9] !== onColumnResize || $[10] !== widths) {
|
|
54
|
+
t3 = {
|
|
55
|
+
columns,
|
|
56
|
+
widths,
|
|
57
|
+
onColumnResize
|
|
58
|
+
};
|
|
59
|
+
$[8] = columns;
|
|
60
|
+
$[9] = onColumnResize;
|
|
61
|
+
$[10] = widths;
|
|
62
|
+
$[11] = t3;
|
|
63
|
+
} else {
|
|
64
|
+
t3 = $[11];
|
|
65
|
+
}
|
|
66
|
+
const latestRef = useRef(t3);
|
|
67
|
+
let t4;
|
|
68
|
+
if ($[12] !== columns || $[13] !== onColumnResize || $[14] !== widths) {
|
|
69
|
+
t4 = () => {
|
|
70
|
+
latestRef.current = {
|
|
71
|
+
columns,
|
|
72
|
+
widths,
|
|
73
|
+
onColumnResize
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
$[12] = columns;
|
|
77
|
+
$[13] = onColumnResize;
|
|
78
|
+
$[14] = widths;
|
|
79
|
+
$[15] = t4;
|
|
80
|
+
} else {
|
|
81
|
+
t4 = $[15];
|
|
82
|
+
}
|
|
83
|
+
useLayoutEffect(t4);
|
|
84
|
+
let t5;
|
|
85
|
+
if ($[16] !== widths) {
|
|
86
|
+
t5 = widths.every(_temp3);
|
|
87
|
+
$[16] = widths;
|
|
88
|
+
$[17] = t5;
|
|
89
|
+
} else {
|
|
90
|
+
t5 = $[17];
|
|
91
|
+
}
|
|
92
|
+
const allWidthsKnown = t5;
|
|
93
|
+
const fixedLayout = hasColgroup && allWidthsKnown;
|
|
94
|
+
let t6;
|
|
95
|
+
if ($[18] !== fixedLayout || $[19] !== widths) {
|
|
96
|
+
t6 = fixedLayout ? widths.reduce(_temp4, 0) : undefined;
|
|
97
|
+
$[18] = fixedLayout;
|
|
98
|
+
$[19] = widths;
|
|
99
|
+
$[20] = t6;
|
|
100
|
+
} else {
|
|
101
|
+
t6 = $[20];
|
|
102
|
+
}
|
|
103
|
+
const totalWidth = t6;
|
|
104
|
+
let t7;
|
|
105
|
+
if ($[21] !== columns || $[22] !== fixedLayout || $[23] !== tableRef || $[24] !== widths) {
|
|
106
|
+
t7 = function freezeWidths() {
|
|
107
|
+
const headerCells = tableRef.current?.tHead?.rows[0]?.cells;
|
|
108
|
+
if (!headerCells) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const frozenWidths = columns.map((_column, index) => {
|
|
112
|
+
var _ref, _widths$index;
|
|
113
|
+
return (_ref = (_widths$index = widths[index]) !== null && _widths$index !== void 0 ? _widths$index : headerCells[index]?.getBoundingClientRect().width) !== null && _ref !== void 0 ? _ref : 0;
|
|
114
|
+
});
|
|
115
|
+
if (!fixedLayout) {
|
|
116
|
+
setInternalWidths(new Map(columns.map((column_1, index_0) => [column_1.key, frozenWidths[index_0]])));
|
|
117
|
+
}
|
|
118
|
+
return frozenWidths;
|
|
119
|
+
};
|
|
120
|
+
$[21] = columns;
|
|
121
|
+
$[22] = fixedLayout;
|
|
122
|
+
$[23] = tableRef;
|
|
123
|
+
$[24] = widths;
|
|
124
|
+
$[25] = t7;
|
|
125
|
+
} else {
|
|
126
|
+
t7 = $[25];
|
|
127
|
+
}
|
|
128
|
+
const freezeWidths = t7;
|
|
129
|
+
let t8;
|
|
130
|
+
if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
|
|
131
|
+
t8 = function commitWidth(columnKey, width_1) {
|
|
132
|
+
const {
|
|
133
|
+
columns: latestColumns,
|
|
134
|
+
widths: latestWidths,
|
|
135
|
+
onColumnResize: latestOnColumnResize
|
|
136
|
+
} = latestRef.current;
|
|
137
|
+
const columnIndex = latestColumns.findIndex(column_2 => column_2.key === columnKey);
|
|
138
|
+
if (columnIndex === -1) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
setInternalWidths(prev => new Map(prev).set(columnKey, width_1));
|
|
142
|
+
const newColumns = latestColumns.map((column_3, index_1) => {
|
|
143
|
+
const newWidth = index_1 === columnIndex ? width_1 : latestWidths[index_1];
|
|
144
|
+
return newWidth === column_3.width ? column_3 : {
|
|
145
|
+
...column_3,
|
|
146
|
+
width: newWidth
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
latestOnColumnResize?.(latestColumns[columnIndex], columnIndex, width_1, newColumns);
|
|
150
|
+
};
|
|
151
|
+
$[26] = t8;
|
|
152
|
+
} else {
|
|
153
|
+
t8 = $[26];
|
|
154
|
+
}
|
|
155
|
+
const commitWidth = t8;
|
|
156
|
+
let t9;
|
|
157
|
+
if ($[27] !== freezeWidths) {
|
|
158
|
+
t9 = {
|
|
159
|
+
freezeWidths,
|
|
160
|
+
commitWidth
|
|
161
|
+
};
|
|
162
|
+
$[27] = freezeWidths;
|
|
163
|
+
$[28] = t9;
|
|
164
|
+
} else {
|
|
165
|
+
t9 = $[28];
|
|
166
|
+
}
|
|
167
|
+
let t10;
|
|
168
|
+
if ($[29] !== fixedLayout || $[30] !== hasColgroup || $[31] !== t9 || $[32] !== totalWidth || $[33] !== widths) {
|
|
169
|
+
t10 = {
|
|
170
|
+
hasColgroup,
|
|
171
|
+
fixedLayout,
|
|
172
|
+
totalWidth,
|
|
173
|
+
widths,
|
|
174
|
+
contextValue: t9
|
|
175
|
+
};
|
|
176
|
+
$[29] = fixedLayout;
|
|
177
|
+
$[30] = hasColgroup;
|
|
178
|
+
$[31] = t9;
|
|
179
|
+
$[32] = totalWidth;
|
|
180
|
+
$[33] = widths;
|
|
181
|
+
$[34] = t10;
|
|
182
|
+
} else {
|
|
183
|
+
t10 = $[34];
|
|
184
|
+
}
|
|
185
|
+
return t10;
|
|
186
|
+
}
|
|
187
|
+
function _temp4(sum, width_0) {
|
|
188
|
+
return sum + width_0;
|
|
189
|
+
}
|
|
190
|
+
function _temp3(width) {
|
|
191
|
+
return width != null;
|
|
192
|
+
}
|
|
193
|
+
function _temp2(column) {
|
|
194
|
+
return column.resizable || column.width != null;
|
|
195
|
+
}
|
|
196
|
+
function _temp() {
|
|
197
|
+
return new Map();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export { ColumnSizingContext, useColumnSizing };
|
|
@@ -13,7 +13,6 @@ import '../global/data-tests.js';
|
|
|
13
13
|
import '../island/adaptive-island-hoc.js';
|
|
14
14
|
import '../global/linear-function.js';
|
|
15
15
|
import 'react/compiler-runtime';
|
|
16
|
-
import 'element-resize-detector';
|
|
17
16
|
import '../global/schedule-raf.js';
|
|
18
17
|
import '../global/get-uid.js';
|
|
19
18
|
import '../shortcuts/shortcuts.js';
|
|
@@ -14,7 +14,6 @@ import '../_helpers/island.js';
|
|
|
14
14
|
import '../island/header.js';
|
|
15
15
|
import 'react/compiler-runtime';
|
|
16
16
|
import '../island/content.js';
|
|
17
|
-
import 'element-resize-detector';
|
|
18
17
|
import '../global/schedule-raf.js';
|
|
19
18
|
import '../global/get-uid.js';
|
|
20
19
|
import '../shortcuts/shortcuts.js';
|
|
@@ -20,7 +20,6 @@ import '../_helpers/island.js';
|
|
|
20
20
|
import '../island/header.js';
|
|
21
21
|
import 'react/compiler-runtime';
|
|
22
22
|
import '../island/content.js';
|
|
23
|
-
import 'element-resize-detector';
|
|
24
23
|
import '../global/schedule-raf.js';
|
|
25
24
|
import '../shortcuts/core.js';
|
|
26
25
|
import 'core-js/modules/es.array.includes.js';
|
|
@@ -349,6 +348,10 @@ class Dialog extends PureComponent {
|
|
|
349
348
|
})]
|
|
350
349
|
});
|
|
351
350
|
if (native) {
|
|
351
|
+
// Chromium lets sequential focus escape a modal dialog backward from its first focusable and
|
|
352
|
+
// drops focus when the dialog unmounts while closing, so honor a requested trap here the same
|
|
353
|
+
// way the non-native branch does.
|
|
354
|
+
const trapEnabled = !getTrapDisabled(trapFocus, trapDisabled);
|
|
352
355
|
return /*#__PURE__*/jsx("dialog", {
|
|
353
356
|
...restProps,
|
|
354
357
|
"aria-label": label,
|
|
@@ -361,7 +364,13 @@ class Dialog extends PureComponent {
|
|
|
361
364
|
children: /*#__PURE__*/jsx(PopupTarget, {
|
|
362
365
|
id: this.uid,
|
|
363
366
|
className: styles.popupTarget,
|
|
364
|
-
children: target => /*#__PURE__*/jsxs(
|
|
367
|
+
children: target => trapEnabled && show ? /*#__PURE__*/jsxs(TabTrap, {
|
|
368
|
+
trapDisabled: false,
|
|
369
|
+
autoFocusFirst: autoFocusFirst,
|
|
370
|
+
focusBackOnClose: focusBackOnClose,
|
|
371
|
+
focusBackOnExit: focusBackOnExit,
|
|
372
|
+
children: [content, target]
|
|
373
|
+
}) : /*#__PURE__*/jsxs(Fragment, {
|
|
365
374
|
children: [content, target]
|
|
366
375
|
})
|
|
367
376
|
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes the vertical position of an indicator that spans the visible part
|
|
3
|
+
* of the table, starting at the header top. Client coordinates.
|
|
4
|
+
*/
|
|
5
|
+
function getColumnIndicatorVerticalSpan(elementInHeader) {
|
|
6
|
+
const thead = elementInHeader.closest('thead');
|
|
7
|
+
const table = thead?.closest('table');
|
|
8
|
+
if (!thead || !table) return null;
|
|
9
|
+
const {
|
|
10
|
+
top: headerTop
|
|
11
|
+
} = thead.getBoundingClientRect();
|
|
12
|
+
const {
|
|
13
|
+
bottom: tableBottom
|
|
14
|
+
} = table.getBoundingClientRect();
|
|
15
|
+
const distanceToTableEnd = tableBottom - headerTop;
|
|
16
|
+
const distanceToViewportEnd = window.innerHeight - headerTop;
|
|
17
|
+
return {
|
|
18
|
+
top: headerTop,
|
|
19
|
+
height: `min(${distanceToTableEnd}px, calc(${distanceToViewportEnd}px - .5rem))`
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { getColumnIndicatorVerticalSpan };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const edgeAreaPx = 100;
|
|
2
|
+
// Keeps the middle of a small scroller free from auto scroll
|
|
3
|
+
const maxEdgeAreaFraction = 0.3;
|
|
4
|
+
const maxStepPx = 16;
|
|
5
|
+
/**
|
|
6
|
+
* The nearest ancestor which scrolls along `axis`, or `null` for the document
|
|
7
|
+
*/
|
|
8
|
+
function getScroller(table, axis) {
|
|
9
|
+
for (let el = table.parentElement; el && el !== document.scrollingElement; el = el.parentElement) {
|
|
10
|
+
// `overflow` of <body> propagates to the viewport unless <html> has its own
|
|
11
|
+
if (el === document.body && window.getComputedStyle(document.documentElement).overflow === 'visible') continue;
|
|
12
|
+
const {
|
|
13
|
+
overflowX,
|
|
14
|
+
overflowY
|
|
15
|
+
} = window.getComputedStyle(el);
|
|
16
|
+
const isScrollable = /auto|scroll/.test(axis === 'x' ? overflowX : overflowY);
|
|
17
|
+
// Ignores sub-pixel overflow
|
|
18
|
+
const overflowPx = axis === 'x' ? el.scrollWidth - el.clientWidth : el.scrollHeight - el.clientHeight;
|
|
19
|
+
if (isScrollable && overflowPx > 1) return el;
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The visible part of the scroller along `axis`, without borders and scrollbars
|
|
25
|
+
*/
|
|
26
|
+
function getVisibleRange(scroller, axis) {
|
|
27
|
+
const isX = axis === 'x';
|
|
28
|
+
if (!scroller) {
|
|
29
|
+
const root = document.documentElement;
|
|
30
|
+
return {
|
|
31
|
+
start: 0,
|
|
32
|
+
end: isX ? root.clientWidth : root.clientHeight
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const rect = scroller.getBoundingClientRect();
|
|
36
|
+
const start = isX ? rect.left + scroller.clientLeft : rect.top + scroller.clientTop;
|
|
37
|
+
const end = start + (isX ? scroller.clientWidth : scroller.clientHeight);
|
|
38
|
+
return {
|
|
39
|
+
start: Math.max(start, 0),
|
|
40
|
+
end: Math.min(end, isX ? window.innerWidth : window.innerHeight)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function getRange(rect, axis) {
|
|
44
|
+
return axis === 'x' ? {
|
|
45
|
+
start: rect.left,
|
|
46
|
+
end: rect.right
|
|
47
|
+
} : {
|
|
48
|
+
start: rect.top,
|
|
49
|
+
end: rect.bottom
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Grows from 1px at the inner boundary of the edge area to `maxStepPx` at the edge.
|
|
54
|
+
* A pointer beyond the edge (negative distance) scrolls at `maxStepPx`.
|
|
55
|
+
*/
|
|
56
|
+
function getSpeed(distanceToEdge, edgeArea) {
|
|
57
|
+
const closeness = Math.min(1 - distanceToEdge / edgeArea, 1);
|
|
58
|
+
return Math.ceil(maxStepPx * closeness);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* While the drag is active, scrolls the nearest scroller of `table` along `axis`
|
|
62
|
+
* when the pointer is near the scroller edge, until the table edge becomes visible.
|
|
63
|
+
* The closer the pointer is to the edge, the faster the scroll.
|
|
64
|
+
*
|
|
65
|
+
* `preferredScroller` is used instead of the nearest scroller when set, e.g. `TableProps.scrollerRef` for `y`.
|
|
66
|
+
*
|
|
67
|
+
* `onScroll` is called with the last pointer position on every frame after the pointer has moved,
|
|
68
|
+
* so that the caller can update anything which depends on the scroll position,
|
|
69
|
+
* including after the user's wheel scroll.
|
|
70
|
+
*/
|
|
71
|
+
function startDragAutoScroll(axis, table, preferredScroller, onScroll) {
|
|
72
|
+
const isX = axis === 'x';
|
|
73
|
+
const scroller = preferredScroller !== null && preferredScroller !== void 0 ? preferredScroller : getScroller(table, axis);
|
|
74
|
+
let pointer = null;
|
|
75
|
+
let rafId = requestAnimationFrame(function tick() {
|
|
76
|
+
let step = 0;
|
|
77
|
+
if (pointer) {
|
|
78
|
+
const visible = getVisibleRange(scroller, axis);
|
|
79
|
+
const edgeArea = Math.min(edgeAreaPx, (visible.end - visible.start) * maxEdgeAreaFraction);
|
|
80
|
+
// The scroller is out of the viewport
|
|
81
|
+
if (edgeArea > 0) {
|
|
82
|
+
const pointerOffset = isX ? pointer.clientX : pointer.clientY;
|
|
83
|
+
const distanceToStart = pointerOffset - visible.start;
|
|
84
|
+
const distanceToEnd = visible.end - pointerOffset;
|
|
85
|
+
const tableRange = getRange(table.getBoundingClientRect(), axis);
|
|
86
|
+
const isTableHiddenAtStart = tableRange.start < visible.start;
|
|
87
|
+
const isTableHiddenAtEnd = tableRange.end > visible.end;
|
|
88
|
+
if (distanceToStart < edgeArea && isTableHiddenAtStart) {
|
|
89
|
+
step = -getSpeed(distanceToStart, edgeArea);
|
|
90
|
+
}
|
|
91
|
+
if (distanceToEnd < edgeArea && isTableHiddenAtEnd) {
|
|
92
|
+
step = getSpeed(distanceToEnd, edgeArea);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Not `smooth` even if the page sets `scroll-behavior: smooth`: each frame would restart the animation
|
|
97
|
+
if (step) (scroller !== null && scroller !== void 0 ? scroller : window).scrollBy({
|
|
98
|
+
[isX ? 'left' : 'top']: step,
|
|
99
|
+
behavior: 'instant'
|
|
100
|
+
});
|
|
101
|
+
if (pointer) onScroll(pointer.clientX, pointer.clientY);
|
|
102
|
+
rafId = requestAnimationFrame(tick);
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
update(clientX, clientY) {
|
|
106
|
+
pointer = {
|
|
107
|
+
clientX,
|
|
108
|
+
clientY
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
stop() {
|
|
112
|
+
cancelAnimationFrame(rafId);
|
|
113
|
+
pointer = null;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { startDragAutoScroll };
|