qbs-react-grid 2.2.12 → 2.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/qbs-react-grid.css +1 -1
- package/dist/css/qbs-react-grid.min.css +1 -1
- package/dist/css/qbs-react-grid.min.css.map +1 -1
- package/es/less/qbs-table.less +39 -14
- package/es/qbsTable/utilities/ColumShowHide.js +69 -20
- package/lib/less/qbs-table.less +39 -14
- package/lib/qbsTable/utilities/ColumShowHide.js +70 -20
- package/package.json +1 -1
- package/src/less/qbs-table.less +39 -14
- package/src/qbsTable/utilities/ColumShowHide.tsx +79 -29
package/es/less/qbs-table.less
CHANGED
|
@@ -408,36 +408,34 @@
|
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
.qbs-table-column-popup {
|
|
411
|
-
position:
|
|
412
|
-
top: calc(100% + 4px);
|
|
413
|
-
inset-inline-end: 0;
|
|
414
|
-
inset-inline-start: auto;
|
|
411
|
+
position: fixed;
|
|
415
412
|
padding: 8px;
|
|
416
413
|
z-index: 10060;
|
|
417
414
|
border-radius: 8px;
|
|
418
415
|
background: #fff;
|
|
416
|
+
border: 1px solid #e5e7eb;
|
|
419
417
|
box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.15);
|
|
420
|
-
min-width:
|
|
418
|
+
min-width: 360px;
|
|
421
419
|
width: max-content;
|
|
422
|
-
max-width: min(
|
|
420
|
+
max-width: min(480px, calc(100vw - 16px));
|
|
423
421
|
gap: 4px;
|
|
424
422
|
display: flex;
|
|
425
423
|
flex-direction: column;
|
|
426
424
|
max-height: 500px;
|
|
427
425
|
}
|
|
428
426
|
.qbs-table-popup-container {
|
|
429
|
-
|
|
427
|
+
min-width: 100%;
|
|
428
|
+
max-width: 480px;
|
|
430
429
|
overflow-y: auto;
|
|
431
430
|
}
|
|
432
431
|
|
|
433
432
|
.qbs-table-container {
|
|
434
433
|
padding: 8px 4px;
|
|
435
|
-
white-space: nowrap;
|
|
436
434
|
width: 100%;
|
|
437
435
|
display: flex;
|
|
438
436
|
align-items: center;
|
|
439
|
-
justify-content:
|
|
440
|
-
gap:
|
|
437
|
+
justify-content: flex-start;
|
|
438
|
+
gap: 12px;
|
|
441
439
|
}
|
|
442
440
|
|
|
443
441
|
.qbs-table-columns-container {
|
|
@@ -458,6 +456,14 @@
|
|
|
458
456
|
text-align: right;
|
|
459
457
|
}
|
|
460
458
|
|
|
459
|
+
.qbs-table-column-popup--rtl .qbs-table-columns-container {
|
|
460
|
+
flex-direction: row;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
.qbs-table-column-popup--rtl .qbs-table-container {
|
|
464
|
+
flex-direction: row;
|
|
465
|
+
}
|
|
466
|
+
|
|
461
467
|
.qbs-table-column-popup--rtl .qbs-table-popup-footer {
|
|
462
468
|
flex-direction: row-reverse;
|
|
463
469
|
}
|
|
@@ -480,6 +486,7 @@
|
|
|
480
486
|
|
|
481
487
|
.qbs-table-columns-drag-icon {
|
|
482
488
|
cursor: grab;
|
|
489
|
+
flex: 0 0 16px;
|
|
483
490
|
margin-right: 0;
|
|
484
491
|
}
|
|
485
492
|
|
|
@@ -511,6 +518,11 @@
|
|
|
511
518
|
}
|
|
512
519
|
}
|
|
513
520
|
|
|
521
|
+
.qbs-table-container .qbs-table-checkbox {
|
|
522
|
+
flex: 0 0 24px;
|
|
523
|
+
min-width: 24px;
|
|
524
|
+
}
|
|
525
|
+
|
|
514
526
|
.qbs-table-checkbox {
|
|
515
527
|
position: relative;
|
|
516
528
|
display: flex;
|
|
@@ -598,8 +610,12 @@
|
|
|
598
610
|
|
|
599
611
|
.qbs-table-container .qbs-table-popup-value {
|
|
600
612
|
padding: 0;
|
|
601
|
-
flex: 1;
|
|
602
|
-
|
|
613
|
+
flex: 1 1 0;
|
|
614
|
+
min-width: 0;
|
|
615
|
+
margin-inline-start: 0;
|
|
616
|
+
overflow: hidden;
|
|
617
|
+
text-overflow: ellipsis;
|
|
618
|
+
white-space: nowrap;
|
|
603
619
|
transition: all 0.2s ease;
|
|
604
620
|
}
|
|
605
621
|
.qbs-table-container:hover .qbs-table-popup-value,
|
|
@@ -610,11 +626,20 @@
|
|
|
610
626
|
|
|
611
627
|
.qbs-table-container .qbs-table-popup-label {
|
|
612
628
|
padding: 0;
|
|
613
|
-
flex: 1;
|
|
614
|
-
|
|
629
|
+
flex: 1 1 0;
|
|
630
|
+
min-width: 0;
|
|
631
|
+
margin-inline-start: 0;
|
|
632
|
+
overflow: hidden;
|
|
633
|
+
text-overflow: ellipsis;
|
|
634
|
+
white-space: nowrap;
|
|
615
635
|
transition: all 0.2s ease;
|
|
616
636
|
}
|
|
617
637
|
|
|
638
|
+
.qbs-table-column-popup--rtl .qbs-table-container .qbs-table-popup-value,
|
|
639
|
+
.qbs-table-column-popup--rtl .qbs-table-container .qbs-table-popup-label {
|
|
640
|
+
text-align: right;
|
|
641
|
+
}
|
|
642
|
+
|
|
618
643
|
.qbs-table-reset-link {
|
|
619
644
|
padding: 8px;
|
|
620
645
|
font-size: 14px;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useId, useRef, useState } from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
2
3
|
import { mergeQbsTableLabels } from '../labels';
|
|
3
4
|
import { closeOtherColumnToggles, COLUMN_TOGGLE_CLOSE_OTHERS } from './columnToggleCoordinator';
|
|
4
5
|
import { SettingsIcon } from './icons';
|
|
5
6
|
var ColumnToggle = function ColumnToggle(_ref) {
|
|
7
|
+
var _document$getElementB;
|
|
6
8
|
var columns = _ref.columns,
|
|
7
9
|
onToggle = _ref.onToggle,
|
|
8
10
|
onReorder = _ref.onReorder,
|
|
@@ -21,9 +23,39 @@ var ColumnToggle = function ColumnToggle(_ref) {
|
|
|
21
23
|
draggedItem = _useState[0],
|
|
22
24
|
setDraggedItem = _useState[1];
|
|
23
25
|
var popupRef = useRef(null);
|
|
26
|
+
var settingsBtnRef = useRef(null);
|
|
24
27
|
var _useState2 = useState(),
|
|
25
28
|
dragOverPosition = _useState2[0],
|
|
26
29
|
setDragOverPosition = _useState2[1];
|
|
30
|
+
var _useState3 = useState({
|
|
31
|
+
top: 0,
|
|
32
|
+
left: 0
|
|
33
|
+
}),
|
|
34
|
+
position = _useState3[0],
|
|
35
|
+
setPosition = _useState3[1];
|
|
36
|
+
var updatePopupPosition = useCallback(function () {
|
|
37
|
+
var _popupRef$current, _popupRef$current2;
|
|
38
|
+
if (!settingsBtnRef.current) return;
|
|
39
|
+
var rect = settingsBtnRef.current.getBoundingClientRect();
|
|
40
|
+
var viewportPadding = 8;
|
|
41
|
+
var popupWidth = ((_popupRef$current = popupRef.current) === null || _popupRef$current === void 0 ? void 0 : _popupRef$current.offsetWidth) || 360;
|
|
42
|
+
var popupHeight = ((_popupRef$current2 = popupRef.current) === null || _popupRef$current2 === void 0 ? void 0 : _popupRef$current2.offsetHeight) || 320;
|
|
43
|
+
var left = rtl ? rect.left : rect.right - popupWidth;
|
|
44
|
+
if (left + popupWidth > window.innerWidth - viewportPadding) {
|
|
45
|
+
left = Math.max(viewportPadding, window.innerWidth - popupWidth - viewportPadding);
|
|
46
|
+
}
|
|
47
|
+
if (left < viewportPadding) {
|
|
48
|
+
left = viewportPadding;
|
|
49
|
+
}
|
|
50
|
+
var top = rect.bottom + 4;
|
|
51
|
+
if (top + popupHeight > window.innerHeight - viewportPadding) {
|
|
52
|
+
top = Math.max(viewportPadding, rect.top - popupHeight - 4);
|
|
53
|
+
}
|
|
54
|
+
setPosition({
|
|
55
|
+
top: top,
|
|
56
|
+
left: left
|
|
57
|
+
});
|
|
58
|
+
}, [rtl]);
|
|
27
59
|
useEffect(function () {
|
|
28
60
|
var handleCloseOthers = function handleCloseOthers(event) {
|
|
29
61
|
var detail = event.detail;
|
|
@@ -60,20 +92,29 @@ var ColumnToggle = function ColumnToggle(_ref) {
|
|
|
60
92
|
setDraggedItem(null);
|
|
61
93
|
}, [columns, draggedItem, onReorder]);
|
|
62
94
|
var handleClickOutside = useCallback(function (event) {
|
|
63
|
-
var _popupRef$
|
|
95
|
+
var _popupRef$current3, _settingsBtnRef$curre;
|
|
64
96
|
var target = event.target;
|
|
65
|
-
if ((_popupRef$
|
|
97
|
+
if ((_popupRef$current3 = popupRef.current) !== null && _popupRef$current3 !== void 0 && _popupRef$current3.contains(target) || (_settingsBtnRef$curre = settingsBtnRef.current) !== null && _settingsBtnRef$curre !== void 0 && _settingsBtnRef$curre.contains(target)) {
|
|
66
98
|
return;
|
|
67
99
|
}
|
|
68
100
|
setIsOpen(false);
|
|
69
101
|
}, [setIsOpen]);
|
|
70
102
|
useEffect(function () {
|
|
71
103
|
if (!isOpen) return;
|
|
104
|
+
updatePopupPosition();
|
|
105
|
+
var frame = requestAnimationFrame(function () {
|
|
106
|
+
return updatePopupPosition();
|
|
107
|
+
});
|
|
72
108
|
document.addEventListener('mousedown', handleClickOutside);
|
|
109
|
+
window.addEventListener('resize', updatePopupPosition);
|
|
110
|
+
window.addEventListener('scroll', updatePopupPosition, true);
|
|
73
111
|
return function () {
|
|
74
|
-
|
|
112
|
+
cancelAnimationFrame(frame);
|
|
113
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
114
|
+
window.removeEventListener('resize', updatePopupPosition);
|
|
115
|
+
window.removeEventListener('scroll', updatePopupPosition, true);
|
|
75
116
|
};
|
|
76
|
-
}, [handleClickOutside, isOpen]);
|
|
117
|
+
}, [handleClickOutside, isOpen, updatePopupPosition]);
|
|
77
118
|
var renderFixedColumn = function renderFixedColumn(column, index) {
|
|
78
119
|
return /*#__PURE__*/React.createElement("div", {
|
|
79
120
|
key: column.title,
|
|
@@ -171,23 +212,15 @@ var ColumnToggle = function ColumnToggle(_ref) {
|
|
|
171
212
|
setIsOpen(false);
|
|
172
213
|
handleColumnToggle === null || handleColumnToggle === void 0 ? void 0 : handleColumnToggle(columns);
|
|
173
214
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
177
|
-
type: "button",
|
|
178
|
-
onClick: function onClick(event) {
|
|
179
|
-
event.stopPropagation();
|
|
180
|
-
if (isOpen) {
|
|
181
|
-
setIsOpen(false);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
closeOtherColumnToggles(toggleId);
|
|
185
|
-
setIsOpen(true);
|
|
186
|
-
}
|
|
187
|
-
}, /*#__PURE__*/React.createElement(SettingsIcon, null)), isOpen && /*#__PURE__*/React.createElement("div", {
|
|
215
|
+
var portalTarget = (_document$getElementB = document.getElementById('portal-root')) != null ? _document$getElementB : document.body;
|
|
216
|
+
var popupContent = /*#__PURE__*/React.createElement("div", {
|
|
188
217
|
className: "qbs-table-column-popup" + (rtl ? ' qbs-table-column-popup--rtl' : ''),
|
|
189
218
|
style: {
|
|
190
|
-
|
|
219
|
+
position: 'fixed',
|
|
220
|
+
top: position.top,
|
|
221
|
+
left: position.left,
|
|
222
|
+
maxHeight: Math.min(tableHeight - 40, window.innerHeight - position.top - 16),
|
|
223
|
+
zIndex: 10060
|
|
191
224
|
},
|
|
192
225
|
ref: popupRef,
|
|
193
226
|
dir: rtl ? 'rtl' : 'ltr'
|
|
@@ -243,6 +276,22 @@ var ColumnToggle = function ColumnToggle(_ref) {
|
|
|
243
276
|
onClick: function onClick() {
|
|
244
277
|
return handleColToggle();
|
|
245
278
|
}
|
|
246
|
-
}, labels.save))))
|
|
279
|
+
}, labels.save))));
|
|
280
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
281
|
+
className: "qbs-table-settings-wrapper"
|
|
282
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
283
|
+
type: "button",
|
|
284
|
+
ref: settingsBtnRef,
|
|
285
|
+
onClick: function onClick(event) {
|
|
286
|
+
event.stopPropagation();
|
|
287
|
+
if (isOpen) {
|
|
288
|
+
setIsOpen(false);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
closeOtherColumnToggles(toggleId);
|
|
292
|
+
updatePopupPosition();
|
|
293
|
+
setIsOpen(true);
|
|
294
|
+
}
|
|
295
|
+
}, /*#__PURE__*/React.createElement(SettingsIcon, null)), isOpen && portalTarget && /*#__PURE__*/ReactDOM.createPortal(popupContent, portalTarget));
|
|
247
296
|
};
|
|
248
297
|
export default ColumnToggle;
|
package/lib/less/qbs-table.less
CHANGED
|
@@ -408,36 +408,34 @@
|
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
.qbs-table-column-popup {
|
|
411
|
-
position:
|
|
412
|
-
top: calc(100% + 4px);
|
|
413
|
-
inset-inline-end: 0;
|
|
414
|
-
inset-inline-start: auto;
|
|
411
|
+
position: fixed;
|
|
415
412
|
padding: 8px;
|
|
416
413
|
z-index: 10060;
|
|
417
414
|
border-radius: 8px;
|
|
418
415
|
background: #fff;
|
|
416
|
+
border: 1px solid #e5e7eb;
|
|
419
417
|
box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.15);
|
|
420
|
-
min-width:
|
|
418
|
+
min-width: 360px;
|
|
421
419
|
width: max-content;
|
|
422
|
-
max-width: min(
|
|
420
|
+
max-width: min(480px, calc(100vw - 16px));
|
|
423
421
|
gap: 4px;
|
|
424
422
|
display: flex;
|
|
425
423
|
flex-direction: column;
|
|
426
424
|
max-height: 500px;
|
|
427
425
|
}
|
|
428
426
|
.qbs-table-popup-container {
|
|
429
|
-
|
|
427
|
+
min-width: 100%;
|
|
428
|
+
max-width: 480px;
|
|
430
429
|
overflow-y: auto;
|
|
431
430
|
}
|
|
432
431
|
|
|
433
432
|
.qbs-table-container {
|
|
434
433
|
padding: 8px 4px;
|
|
435
|
-
white-space: nowrap;
|
|
436
434
|
width: 100%;
|
|
437
435
|
display: flex;
|
|
438
436
|
align-items: center;
|
|
439
|
-
justify-content:
|
|
440
|
-
gap:
|
|
437
|
+
justify-content: flex-start;
|
|
438
|
+
gap: 12px;
|
|
441
439
|
}
|
|
442
440
|
|
|
443
441
|
.qbs-table-columns-container {
|
|
@@ -458,6 +456,14 @@
|
|
|
458
456
|
text-align: right;
|
|
459
457
|
}
|
|
460
458
|
|
|
459
|
+
.qbs-table-column-popup--rtl .qbs-table-columns-container {
|
|
460
|
+
flex-direction: row;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
.qbs-table-column-popup--rtl .qbs-table-container {
|
|
464
|
+
flex-direction: row;
|
|
465
|
+
}
|
|
466
|
+
|
|
461
467
|
.qbs-table-column-popup--rtl .qbs-table-popup-footer {
|
|
462
468
|
flex-direction: row-reverse;
|
|
463
469
|
}
|
|
@@ -480,6 +486,7 @@
|
|
|
480
486
|
|
|
481
487
|
.qbs-table-columns-drag-icon {
|
|
482
488
|
cursor: grab;
|
|
489
|
+
flex: 0 0 16px;
|
|
483
490
|
margin-right: 0;
|
|
484
491
|
}
|
|
485
492
|
|
|
@@ -511,6 +518,11 @@
|
|
|
511
518
|
}
|
|
512
519
|
}
|
|
513
520
|
|
|
521
|
+
.qbs-table-container .qbs-table-checkbox {
|
|
522
|
+
flex: 0 0 24px;
|
|
523
|
+
min-width: 24px;
|
|
524
|
+
}
|
|
525
|
+
|
|
514
526
|
.qbs-table-checkbox {
|
|
515
527
|
position: relative;
|
|
516
528
|
display: flex;
|
|
@@ -598,8 +610,12 @@
|
|
|
598
610
|
|
|
599
611
|
.qbs-table-container .qbs-table-popup-value {
|
|
600
612
|
padding: 0;
|
|
601
|
-
flex: 1;
|
|
602
|
-
|
|
613
|
+
flex: 1 1 0;
|
|
614
|
+
min-width: 0;
|
|
615
|
+
margin-inline-start: 0;
|
|
616
|
+
overflow: hidden;
|
|
617
|
+
text-overflow: ellipsis;
|
|
618
|
+
white-space: nowrap;
|
|
603
619
|
transition: all 0.2s ease;
|
|
604
620
|
}
|
|
605
621
|
.qbs-table-container:hover .qbs-table-popup-value,
|
|
@@ -610,11 +626,20 @@
|
|
|
610
626
|
|
|
611
627
|
.qbs-table-container .qbs-table-popup-label {
|
|
612
628
|
padding: 0;
|
|
613
|
-
flex: 1;
|
|
614
|
-
|
|
629
|
+
flex: 1 1 0;
|
|
630
|
+
min-width: 0;
|
|
631
|
+
margin-inline-start: 0;
|
|
632
|
+
overflow: hidden;
|
|
633
|
+
text-overflow: ellipsis;
|
|
634
|
+
white-space: nowrap;
|
|
615
635
|
transition: all 0.2s ease;
|
|
616
636
|
}
|
|
617
637
|
|
|
638
|
+
.qbs-table-column-popup--rtl .qbs-table-container .qbs-table-popup-value,
|
|
639
|
+
.qbs-table-column-popup--rtl .qbs-table-container .qbs-table-popup-label {
|
|
640
|
+
text-align: right;
|
|
641
|
+
}
|
|
642
|
+
|
|
618
643
|
.qbs-table-reset-link {
|
|
619
644
|
padding: 8px;
|
|
620
645
|
font-size: 14px;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
exports.__esModule = true;
|
|
4
5
|
exports["default"] = void 0;
|
|
5
6
|
var _react = _interopRequireWildcard(require("react"));
|
|
7
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
6
8
|
var _labels = require("../labels");
|
|
7
9
|
var _columnToggleCoordinator = require("./columnToggleCoordinator");
|
|
8
10
|
var _icons = require("./icons");
|
|
9
11
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
12
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
13
|
var ColumnToggle = function ColumnToggle(_ref) {
|
|
14
|
+
var _document$getElementB;
|
|
12
15
|
var columns = _ref.columns,
|
|
13
16
|
onToggle = _ref.onToggle,
|
|
14
17
|
onReorder = _ref.onReorder,
|
|
@@ -27,9 +30,39 @@ var ColumnToggle = function ColumnToggle(_ref) {
|
|
|
27
30
|
draggedItem = _useState[0],
|
|
28
31
|
setDraggedItem = _useState[1];
|
|
29
32
|
var popupRef = (0, _react.useRef)(null);
|
|
33
|
+
var settingsBtnRef = (0, _react.useRef)(null);
|
|
30
34
|
var _useState2 = (0, _react.useState)(),
|
|
31
35
|
dragOverPosition = _useState2[0],
|
|
32
36
|
setDragOverPosition = _useState2[1];
|
|
37
|
+
var _useState3 = (0, _react.useState)({
|
|
38
|
+
top: 0,
|
|
39
|
+
left: 0
|
|
40
|
+
}),
|
|
41
|
+
position = _useState3[0],
|
|
42
|
+
setPosition = _useState3[1];
|
|
43
|
+
var updatePopupPosition = (0, _react.useCallback)(function () {
|
|
44
|
+
var _popupRef$current, _popupRef$current2;
|
|
45
|
+
if (!settingsBtnRef.current) return;
|
|
46
|
+
var rect = settingsBtnRef.current.getBoundingClientRect();
|
|
47
|
+
var viewportPadding = 8;
|
|
48
|
+
var popupWidth = ((_popupRef$current = popupRef.current) === null || _popupRef$current === void 0 ? void 0 : _popupRef$current.offsetWidth) || 360;
|
|
49
|
+
var popupHeight = ((_popupRef$current2 = popupRef.current) === null || _popupRef$current2 === void 0 ? void 0 : _popupRef$current2.offsetHeight) || 320;
|
|
50
|
+
var left = rtl ? rect.left : rect.right - popupWidth;
|
|
51
|
+
if (left + popupWidth > window.innerWidth - viewportPadding) {
|
|
52
|
+
left = Math.max(viewportPadding, window.innerWidth - popupWidth - viewportPadding);
|
|
53
|
+
}
|
|
54
|
+
if (left < viewportPadding) {
|
|
55
|
+
left = viewportPadding;
|
|
56
|
+
}
|
|
57
|
+
var top = rect.bottom + 4;
|
|
58
|
+
if (top + popupHeight > window.innerHeight - viewportPadding) {
|
|
59
|
+
top = Math.max(viewportPadding, rect.top - popupHeight - 4);
|
|
60
|
+
}
|
|
61
|
+
setPosition({
|
|
62
|
+
top: top,
|
|
63
|
+
left: left
|
|
64
|
+
});
|
|
65
|
+
}, [rtl]);
|
|
33
66
|
(0, _react.useEffect)(function () {
|
|
34
67
|
var handleCloseOthers = function handleCloseOthers(event) {
|
|
35
68
|
var detail = event.detail;
|
|
@@ -66,20 +99,29 @@ var ColumnToggle = function ColumnToggle(_ref) {
|
|
|
66
99
|
setDraggedItem(null);
|
|
67
100
|
}, [columns, draggedItem, onReorder]);
|
|
68
101
|
var handleClickOutside = (0, _react.useCallback)(function (event) {
|
|
69
|
-
var _popupRef$
|
|
102
|
+
var _popupRef$current3, _settingsBtnRef$curre;
|
|
70
103
|
var target = event.target;
|
|
71
|
-
if ((_popupRef$
|
|
104
|
+
if ((_popupRef$current3 = popupRef.current) !== null && _popupRef$current3 !== void 0 && _popupRef$current3.contains(target) || (_settingsBtnRef$curre = settingsBtnRef.current) !== null && _settingsBtnRef$curre !== void 0 && _settingsBtnRef$curre.contains(target)) {
|
|
72
105
|
return;
|
|
73
106
|
}
|
|
74
107
|
setIsOpen(false);
|
|
75
108
|
}, [setIsOpen]);
|
|
76
109
|
(0, _react.useEffect)(function () {
|
|
77
110
|
if (!isOpen) return;
|
|
111
|
+
updatePopupPosition();
|
|
112
|
+
var frame = requestAnimationFrame(function () {
|
|
113
|
+
return updatePopupPosition();
|
|
114
|
+
});
|
|
78
115
|
document.addEventListener('mousedown', handleClickOutside);
|
|
116
|
+
window.addEventListener('resize', updatePopupPosition);
|
|
117
|
+
window.addEventListener('scroll', updatePopupPosition, true);
|
|
79
118
|
return function () {
|
|
80
|
-
|
|
119
|
+
cancelAnimationFrame(frame);
|
|
120
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
121
|
+
window.removeEventListener('resize', updatePopupPosition);
|
|
122
|
+
window.removeEventListener('scroll', updatePopupPosition, true);
|
|
81
123
|
};
|
|
82
|
-
}, [handleClickOutside, isOpen]);
|
|
124
|
+
}, [handleClickOutside, isOpen, updatePopupPosition]);
|
|
83
125
|
var renderFixedColumn = function renderFixedColumn(column, index) {
|
|
84
126
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
85
127
|
key: column.title,
|
|
@@ -177,23 +219,15 @@ var ColumnToggle = function ColumnToggle(_ref) {
|
|
|
177
219
|
setIsOpen(false);
|
|
178
220
|
handleColumnToggle === null || handleColumnToggle === void 0 ? void 0 : handleColumnToggle(columns);
|
|
179
221
|
};
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}, /*#__PURE__*/_react["default"].createElement("button", {
|
|
183
|
-
type: "button",
|
|
184
|
-
onClick: function onClick(event) {
|
|
185
|
-
event.stopPropagation();
|
|
186
|
-
if (isOpen) {
|
|
187
|
-
setIsOpen(false);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
(0, _columnToggleCoordinator.closeOtherColumnToggles)(toggleId);
|
|
191
|
-
setIsOpen(true);
|
|
192
|
-
}
|
|
193
|
-
}, /*#__PURE__*/_react["default"].createElement(_icons.SettingsIcon, null)), isOpen && /*#__PURE__*/_react["default"].createElement("div", {
|
|
222
|
+
var portalTarget = (_document$getElementB = document.getElementById('portal-root')) != null ? _document$getElementB : document.body;
|
|
223
|
+
var popupContent = /*#__PURE__*/_react["default"].createElement("div", {
|
|
194
224
|
className: "qbs-table-column-popup" + (rtl ? ' qbs-table-column-popup--rtl' : ''),
|
|
195
225
|
style: {
|
|
196
|
-
|
|
226
|
+
position: 'fixed',
|
|
227
|
+
top: position.top,
|
|
228
|
+
left: position.left,
|
|
229
|
+
maxHeight: Math.min(tableHeight - 40, window.innerHeight - position.top - 16),
|
|
230
|
+
zIndex: 10060
|
|
197
231
|
},
|
|
198
232
|
ref: popupRef,
|
|
199
233
|
dir: rtl ? 'rtl' : 'ltr'
|
|
@@ -249,7 +283,23 @@ var ColumnToggle = function ColumnToggle(_ref) {
|
|
|
249
283
|
onClick: function onClick() {
|
|
250
284
|
return handleColToggle();
|
|
251
285
|
}
|
|
252
|
-
}, labels.save))))
|
|
286
|
+
}, labels.save))));
|
|
287
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
288
|
+
className: "qbs-table-settings-wrapper"
|
|
289
|
+
}, /*#__PURE__*/_react["default"].createElement("button", {
|
|
290
|
+
type: "button",
|
|
291
|
+
ref: settingsBtnRef,
|
|
292
|
+
onClick: function onClick(event) {
|
|
293
|
+
event.stopPropagation();
|
|
294
|
+
if (isOpen) {
|
|
295
|
+
setIsOpen(false);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
(0, _columnToggleCoordinator.closeOtherColumnToggles)(toggleId);
|
|
299
|
+
updatePopupPosition();
|
|
300
|
+
setIsOpen(true);
|
|
301
|
+
}
|
|
302
|
+
}, /*#__PURE__*/_react["default"].createElement(_icons.SettingsIcon, null)), isOpen && portalTarget && /*#__PURE__*/_reactDom["default"].createPortal(popupContent, portalTarget));
|
|
253
303
|
};
|
|
254
304
|
var _default = ColumnToggle;
|
|
255
305
|
exports["default"] = _default;
|
package/package.json
CHANGED
package/src/less/qbs-table.less
CHANGED
|
@@ -408,36 +408,34 @@
|
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
.qbs-table-column-popup {
|
|
411
|
-
position:
|
|
412
|
-
top: calc(100% + 4px);
|
|
413
|
-
inset-inline-end: 0;
|
|
414
|
-
inset-inline-start: auto;
|
|
411
|
+
position: fixed;
|
|
415
412
|
padding: 8px;
|
|
416
413
|
z-index: 10060;
|
|
417
414
|
border-radius: 8px;
|
|
418
415
|
background: #fff;
|
|
416
|
+
border: 1px solid #e5e7eb;
|
|
419
417
|
box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.15);
|
|
420
|
-
min-width:
|
|
418
|
+
min-width: 360px;
|
|
421
419
|
width: max-content;
|
|
422
|
-
max-width: min(
|
|
420
|
+
max-width: min(480px, calc(100vw - 16px));
|
|
423
421
|
gap: 4px;
|
|
424
422
|
display: flex;
|
|
425
423
|
flex-direction: column;
|
|
426
424
|
max-height: 500px;
|
|
427
425
|
}
|
|
428
426
|
.qbs-table-popup-container {
|
|
429
|
-
|
|
427
|
+
min-width: 100%;
|
|
428
|
+
max-width: 480px;
|
|
430
429
|
overflow-y: auto;
|
|
431
430
|
}
|
|
432
431
|
|
|
433
432
|
.qbs-table-container {
|
|
434
433
|
padding: 8px 4px;
|
|
435
|
-
white-space: nowrap;
|
|
436
434
|
width: 100%;
|
|
437
435
|
display: flex;
|
|
438
436
|
align-items: center;
|
|
439
|
-
justify-content:
|
|
440
|
-
gap:
|
|
437
|
+
justify-content: flex-start;
|
|
438
|
+
gap: 12px;
|
|
441
439
|
}
|
|
442
440
|
|
|
443
441
|
.qbs-table-columns-container {
|
|
@@ -458,6 +456,14 @@
|
|
|
458
456
|
text-align: right;
|
|
459
457
|
}
|
|
460
458
|
|
|
459
|
+
.qbs-table-column-popup--rtl .qbs-table-columns-container {
|
|
460
|
+
flex-direction: row;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
.qbs-table-column-popup--rtl .qbs-table-container {
|
|
464
|
+
flex-direction: row;
|
|
465
|
+
}
|
|
466
|
+
|
|
461
467
|
.qbs-table-column-popup--rtl .qbs-table-popup-footer {
|
|
462
468
|
flex-direction: row-reverse;
|
|
463
469
|
}
|
|
@@ -480,6 +486,7 @@
|
|
|
480
486
|
|
|
481
487
|
.qbs-table-columns-drag-icon {
|
|
482
488
|
cursor: grab;
|
|
489
|
+
flex: 0 0 16px;
|
|
483
490
|
margin-right: 0;
|
|
484
491
|
}
|
|
485
492
|
|
|
@@ -511,6 +518,11 @@
|
|
|
511
518
|
}
|
|
512
519
|
}
|
|
513
520
|
|
|
521
|
+
.qbs-table-container .qbs-table-checkbox {
|
|
522
|
+
flex: 0 0 24px;
|
|
523
|
+
min-width: 24px;
|
|
524
|
+
}
|
|
525
|
+
|
|
514
526
|
.qbs-table-checkbox {
|
|
515
527
|
position: relative;
|
|
516
528
|
display: flex;
|
|
@@ -598,8 +610,12 @@
|
|
|
598
610
|
|
|
599
611
|
.qbs-table-container .qbs-table-popup-value {
|
|
600
612
|
padding: 0;
|
|
601
|
-
flex: 1;
|
|
602
|
-
|
|
613
|
+
flex: 1 1 0;
|
|
614
|
+
min-width: 0;
|
|
615
|
+
margin-inline-start: 0;
|
|
616
|
+
overflow: hidden;
|
|
617
|
+
text-overflow: ellipsis;
|
|
618
|
+
white-space: nowrap;
|
|
603
619
|
transition: all 0.2s ease;
|
|
604
620
|
}
|
|
605
621
|
.qbs-table-container:hover .qbs-table-popup-value,
|
|
@@ -610,11 +626,20 @@
|
|
|
610
626
|
|
|
611
627
|
.qbs-table-container .qbs-table-popup-label {
|
|
612
628
|
padding: 0;
|
|
613
|
-
flex: 1;
|
|
614
|
-
|
|
629
|
+
flex: 1 1 0;
|
|
630
|
+
min-width: 0;
|
|
631
|
+
margin-inline-start: 0;
|
|
632
|
+
overflow: hidden;
|
|
633
|
+
text-overflow: ellipsis;
|
|
634
|
+
white-space: nowrap;
|
|
615
635
|
transition: all 0.2s ease;
|
|
616
636
|
}
|
|
617
637
|
|
|
638
|
+
.qbs-table-column-popup--rtl .qbs-table-container .qbs-table-popup-value,
|
|
639
|
+
.qbs-table-column-popup--rtl .qbs-table-container .qbs-table-popup-label {
|
|
640
|
+
text-align: right;
|
|
641
|
+
}
|
|
642
|
+
|
|
618
643
|
.qbs-table-reset-link {
|
|
619
644
|
padding: 8px;
|
|
620
645
|
font-size: 14px;
|