@semcore/data-table 16.1.0-prerelease.2 → 16.1.0
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/CHANGELOG.md +1 -0
- package/lib/cjs/components/DataTable/DataTable.js +108 -55
- package/lib/cjs/components/DataTable/DataTable.js.map +1 -1
- package/lib/cjs/components/Head/Column.js +3 -2
- package/lib/cjs/components/Head/Column.js.map +1 -1
- package/lib/cjs/components/Head/Column.types.js.map +1 -1
- package/lib/cjs/components/Head/Head.js +5 -3
- package/lib/cjs/components/Head/Head.js.map +1 -1
- package/lib/cjs/components/Head/Head.types.js.map +1 -1
- package/lib/es6/components/DataTable/DataTable.js +108 -55
- package/lib/es6/components/DataTable/DataTable.js.map +1 -1
- package/lib/es6/components/Head/Column.js +3 -2
- package/lib/es6/components/Head/Column.js.map +1 -1
- package/lib/es6/components/Head/Column.types.js.map +1 -1
- package/lib/es6/components/Head/Head.js +5 -3
- package/lib/es6/components/Head/Head.js.map +1 -1
- package/lib/es6/components/Head/Head.types.js.map +1 -1
- package/lib/esm/components/DataTable/DataTable.mjs +64 -15
- package/lib/esm/components/Head/Column.mjs +2 -2
- package/lib/esm/components/Head/Head.mjs +4 -3
- package/lib/types/components/Head/Column.types.d.ts +1 -0
- package/lib/types/components/Head/Head.types.d.ts +2 -1
- package/package.json +22 -22
package/CHANGELOG.md
CHANGED
|
@@ -24,6 +24,7 @@ CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangel
|
|
|
24
24
|
- Incorrect type for `selectedRows/onSelectedRowsChange` when `uniqueRowKey` type is not a string.
|
|
25
25
|
- Hover styles aren't applied to themed cells.
|
|
26
26
|
- Types for `CellRenderProps` - added ability to compare props.columnName with `ACCORDION` symbol.
|
|
27
|
+
- Sticky header with `width` property doesn't work.
|
|
27
28
|
|
|
28
29
|
### Changed
|
|
29
30
|
|
|
@@ -18,6 +18,7 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
18
18
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
19
|
var _core = require("@semcore/core");
|
|
20
20
|
var _baseComponents = require("@semcore/base-components");
|
|
21
|
+
var _canUseDOM = _interopRequireDefault(require("@semcore/core/lib/utils/canUseDOM"));
|
|
21
22
|
var _i18nEnhance = _interopRequireDefault(require("@semcore/core/lib/utils/enhances/i18nEnhance"));
|
|
22
23
|
var _findComponent = _interopRequireDefault(require("@semcore/core/lib/utils/findComponent"));
|
|
23
24
|
var _hasParent = require("@semcore/core/lib/utils/hasParent");
|
|
@@ -99,6 +100,37 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
|
|
|
99
100
|
selectAllMessage: '',
|
|
100
101
|
shadowVertical: ''
|
|
101
102
|
});
|
|
103
|
+
(0, _defineProperty2["default"])(_this, "handleDocumentScroll", (0, _rafTrottle["default"])(function () {
|
|
104
|
+
var _headerProps$top, _this$scrollAreaRef$c;
|
|
105
|
+
var tableContainer = _this.tableContainerRef.current;
|
|
106
|
+
if (!tableContainer) return;
|
|
107
|
+
var tableContainerTop = tableContainer.getBoundingClientRect().top;
|
|
108
|
+
var headerProps = _this.asProps.headerProps;
|
|
109
|
+
var headerContainer = _this.headerRef.current;
|
|
110
|
+
var elements = headerContainer === null || headerContainer === void 0 ? void 0 : headerContainer.querySelectorAll('[role="columnheader"], [data-ui-name="Head.Group"]');
|
|
111
|
+
var top = tableContainerTop - ((_headerProps$top = headerProps === null || headerProps === void 0 ? void 0 : headerProps.top) !== null && _headerProps$top !== void 0 ? _headerProps$top : 0);
|
|
112
|
+
var headerScrollBar = headerProps !== null && headerProps !== void 0 && headerProps.withScrollBar ? (_this$scrollAreaRef$c = _this.scrollAreaRef.current) === null || _this$scrollAreaRef$c === void 0 ? void 0 : _this$scrollAreaRef$c.querySelector("[role=scrollbar][aria-orientation=horizontal]") : undefined;
|
|
113
|
+
if (top && top < 0) {
|
|
114
|
+
var translate = "translateY(".concat(Math.abs(top), "px)");
|
|
115
|
+
elements === null || elements === void 0 || elements.forEach(function (column) {
|
|
116
|
+
if (column instanceof HTMLElement) {
|
|
117
|
+
column.style.setProperty('transform', translate);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
if (headerScrollBar instanceof HTMLElement) {
|
|
121
|
+
headerScrollBar.style.setProperty('transform', translate);
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
elements === null || elements === void 0 || elements.forEach(function (column) {
|
|
125
|
+
if (column instanceof HTMLElement) {
|
|
126
|
+
column.style.removeProperty('transform');
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
if (headerScrollBar instanceof HTMLElement) {
|
|
130
|
+
headerScrollBar.style.removeProperty('transform');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}));
|
|
102
134
|
(0, _defineProperty2["default"])(_this, "handleCellClick", function (e, opt) {
|
|
103
135
|
if (_core.lastInteraction.isMouse()) {
|
|
104
136
|
_this.initFocusableCell([_this.hasFocusableInHeader() ? opt.rowIndex + 1 : opt.rowIndex, opt.colIndex]);
|
|
@@ -461,6 +493,9 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
|
|
|
461
493
|
_this2.calculateVerticalShadow();
|
|
462
494
|
});
|
|
463
495
|
}
|
|
496
|
+
if (headerProps !== null && headerProps !== void 0 && headerProps.sticky && (0, _canUseDOM["default"])() && this.scrollDirection === 'horizontal') {
|
|
497
|
+
document.addEventListener('scroll', this.handleDocumentScroll);
|
|
498
|
+
}
|
|
464
499
|
}
|
|
465
500
|
}, {
|
|
466
501
|
key: "componentDidUpdate",
|
|
@@ -490,6 +525,13 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
|
|
|
490
525
|
}
|
|
491
526
|
}
|
|
492
527
|
}
|
|
528
|
+
}, {
|
|
529
|
+
key: "componentWillUnmount",
|
|
530
|
+
value: function componentWillUnmount() {
|
|
531
|
+
if ((0, _canUseDOM["default"])()) {
|
|
532
|
+
document.removeEventListener('scroll', this.handleDocumentScroll);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
493
535
|
}, {
|
|
494
536
|
key: "totalRows",
|
|
495
537
|
get: function get() {
|
|
@@ -538,21 +580,41 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
|
|
|
538
580
|
gridTemplateAreas: gridTemplateAreas
|
|
539
581
|
};
|
|
540
582
|
}
|
|
583
|
+
}, {
|
|
584
|
+
key: "scrollDirection",
|
|
585
|
+
get: function get() {
|
|
586
|
+
var _this$asProps6 = this.asProps,
|
|
587
|
+
w = _this$asProps6.w,
|
|
588
|
+
wMax = _this$asProps6.wMax,
|
|
589
|
+
h = _this$asProps6.h,
|
|
590
|
+
hMax = _this$asProps6.hMax;
|
|
591
|
+
var scrollDirection = undefined;
|
|
592
|
+
var hasWidthSettings = Boolean(w) || Boolean(wMax);
|
|
593
|
+
var hasHeightSettings = Boolean(h) && h !== 'fit-content' || Boolean(hMax);
|
|
594
|
+
if (hasWidthSettings && !hasHeightSettings) {
|
|
595
|
+
scrollDirection = 'horizontal';
|
|
596
|
+
} else if (hasHeightSettings && !hasWidthSettings) {
|
|
597
|
+
scrollDirection = 'vertical';
|
|
598
|
+
} else if (hasWidthSettings && hasHeightSettings) {
|
|
599
|
+
scrollDirection = 'both';
|
|
600
|
+
}
|
|
601
|
+
return scrollDirection;
|
|
602
|
+
}
|
|
541
603
|
}, {
|
|
542
604
|
key: "getHeadProps",
|
|
543
605
|
value: function getHeadProps() {
|
|
544
606
|
var _this3 = this;
|
|
545
|
-
var _this$
|
|
546
|
-
use = _this$
|
|
547
|
-
compact = _this$
|
|
548
|
-
sort = _this$
|
|
549
|
-
onSortChange = _this$
|
|
550
|
-
getI18nText = _this$
|
|
551
|
-
uid = _this$
|
|
552
|
-
headerProps = _this$
|
|
553
|
-
onSelectedRowsChange = _this$
|
|
554
|
-
selectedRows = _this$
|
|
555
|
-
sideIndents = _this$
|
|
607
|
+
var _this$asProps7 = this.asProps,
|
|
608
|
+
use = _this$asProps7.use,
|
|
609
|
+
compact = _this$asProps7.compact,
|
|
610
|
+
sort = _this$asProps7.sort,
|
|
611
|
+
onSortChange = _this$asProps7.onSortChange,
|
|
612
|
+
getI18nText = _this$asProps7.getI18nText,
|
|
613
|
+
uid = _this$asProps7.uid,
|
|
614
|
+
headerProps = _this$asProps7.headerProps,
|
|
615
|
+
onSelectedRowsChange = _this$asProps7.onSelectedRowsChange,
|
|
616
|
+
selectedRows = _this$asProps7.selectedRows,
|
|
617
|
+
sideIndents = _this$asProps7.sideIndents;
|
|
556
618
|
var _this$gridSettings = this.gridSettings,
|
|
557
619
|
gridTemplateColumns = _this$gridSettings.gridTemplateColumns,
|
|
558
620
|
gridTemplateAreas = _this$gridSettings.gridTemplateAreas;
|
|
@@ -589,30 +651,31 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
|
|
|
589
651
|
},
|
|
590
652
|
getFixedStyle: this.getFixedStyle,
|
|
591
653
|
onCellClick: this.handleCellClick,
|
|
592
|
-
shadowVertical: shadowVertical
|
|
654
|
+
shadowVertical: shadowVertical,
|
|
655
|
+
scrollDirection: this.scrollDirection
|
|
593
656
|
});
|
|
594
657
|
}
|
|
595
658
|
}, {
|
|
596
659
|
key: "getBodyProps",
|
|
597
660
|
value: function getBodyProps() {
|
|
598
|
-
var _this$
|
|
599
|
-
use = _this$
|
|
600
|
-
compact = _this$
|
|
601
|
-
loading = _this$
|
|
602
|
-
getI18nText = _this$
|
|
603
|
-
expandedRows = _this$
|
|
604
|
-
virtualScroll = _this$
|
|
605
|
-
uid = _this$
|
|
606
|
-
rowProps = _this$
|
|
607
|
-
renderCell = _this$
|
|
608
|
-
headerProps = _this$
|
|
609
|
-
renderEmptyData = _this$
|
|
610
|
-
sideIndents = _this$
|
|
611
|
-
selectedRows = _this$
|
|
612
|
-
accordionDuration = _this$
|
|
613
|
-
accordionMode = _this$
|
|
614
|
-
rawData = _this$
|
|
615
|
-
renderCellOverlay = _this$
|
|
661
|
+
var _this$asProps8 = this.asProps,
|
|
662
|
+
use = _this$asProps8.use,
|
|
663
|
+
compact = _this$asProps8.compact,
|
|
664
|
+
loading = _this$asProps8.loading,
|
|
665
|
+
getI18nText = _this$asProps8.getI18nText,
|
|
666
|
+
expandedRows = _this$asProps8.expandedRows,
|
|
667
|
+
virtualScroll = _this$asProps8.virtualScroll,
|
|
668
|
+
uid = _this$asProps8.uid,
|
|
669
|
+
rowProps = _this$asProps8.rowProps,
|
|
670
|
+
renderCell = _this$asProps8.renderCell,
|
|
671
|
+
headerProps = _this$asProps8.headerProps,
|
|
672
|
+
renderEmptyData = _this$asProps8.renderEmptyData,
|
|
673
|
+
sideIndents = _this$asProps8.sideIndents,
|
|
674
|
+
selectedRows = _this$asProps8.selectedRows,
|
|
675
|
+
accordionDuration = _this$asProps8.accordionDuration,
|
|
676
|
+
accordionMode = _this$asProps8.accordionMode,
|
|
677
|
+
rawData = _this$asProps8.data,
|
|
678
|
+
renderCellOverlay = _this$asProps8.renderCellOverlay;
|
|
616
679
|
var _this$gridSettings2 = this.gridSettings,
|
|
617
680
|
gridTemplateColumns = _this$gridSettings2.gridTemplateColumns,
|
|
618
681
|
gridTemplateAreas = _this$gridSettings2.gridTemplateAreas;
|
|
@@ -688,20 +751,20 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
|
|
|
688
751
|
var _ref = this.asProps,
|
|
689
752
|
_ref2;
|
|
690
753
|
var SDataTable = _baseComponents.Box;
|
|
691
|
-
var _this$
|
|
692
|
-
Children = _this$
|
|
693
|
-
styles = _this$
|
|
694
|
-
w = _this$
|
|
695
|
-
wMax = _this$
|
|
696
|
-
wMin = _this$
|
|
697
|
-
h = _this$
|
|
698
|
-
hMax = _this$
|
|
699
|
-
hMin = _this$
|
|
700
|
-
virtualScroll = _this$
|
|
701
|
-
children = _this$
|
|
702
|
-
headerProps = _this$
|
|
703
|
-
loading = _this$
|
|
704
|
-
selectedRows = _this$
|
|
754
|
+
var _this$asProps9 = this.asProps,
|
|
755
|
+
Children = _this$asProps9.Children,
|
|
756
|
+
styles = _this$asProps9.styles,
|
|
757
|
+
w = _this$asProps9.w,
|
|
758
|
+
wMax = _this$asProps9.wMax,
|
|
759
|
+
wMin = _this$asProps9.wMin,
|
|
760
|
+
h = _this$asProps9.h,
|
|
761
|
+
hMax = _this$asProps9.hMax,
|
|
762
|
+
hMin = _this$asProps9.hMin,
|
|
763
|
+
virtualScroll = _this$asProps9.virtualScroll,
|
|
764
|
+
children = _this$asProps9.children,
|
|
765
|
+
headerProps = _this$asProps9.headerProps,
|
|
766
|
+
loading = _this$asProps9.loading,
|
|
767
|
+
selectedRows = _this$asProps9.selectedRows;
|
|
705
768
|
var _this$getScrollOffset = this.getScrollOffsetValue(),
|
|
706
769
|
_this$getScrollOffset2 = (0, _slicedToArray2["default"])(_this$getScrollOffset, 2),
|
|
707
770
|
offsetLeftSum = _this$getScrollOffset2[0],
|
|
@@ -720,16 +783,6 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
|
|
|
720
783
|
if (virtualScroll && typeof virtualScroll !== 'boolean' && 'rowHeight' in virtualScroll) {
|
|
721
784
|
gridTemplateRows = "auto auto repeat(".concat(this.totalRows, ", minmax(").concat(virtualScroll.rowHeight, "px, auto)");
|
|
722
785
|
}
|
|
723
|
-
var scrollDirection = undefined;
|
|
724
|
-
var hasWidthSettings = Boolean(w) || Boolean(wMax);
|
|
725
|
-
var hasHeightSettings = Boolean(h) && h !== 'fit-content' || Boolean(hMax);
|
|
726
|
-
if (hasWidthSettings && !hasHeightSettings) {
|
|
727
|
-
scrollDirection = 'horizontal';
|
|
728
|
-
} else if (hasHeightSettings && !hasWidthSettings) {
|
|
729
|
-
scrollDirection = 'vertical';
|
|
730
|
-
} else if (hasWidthSettings && hasHeightSettings) {
|
|
731
|
-
scrollDirection = 'both';
|
|
732
|
-
}
|
|
733
786
|
return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/React.createElement(_baseComponents.ScrollArea, _ref2.cn("ScrollArea", {
|
|
734
787
|
"leftOffset": offsetLeftSum,
|
|
735
788
|
"rightOffset": offsetRightSum,
|
|
@@ -750,7 +803,7 @@ var DataTableRoot = /*#__PURE__*/function (_Component) {
|
|
|
750
803
|
tabIndex: -1
|
|
751
804
|
// @ts-ignore
|
|
752
805
|
,
|
|
753
|
-
scrollDirection: scrollDirection
|
|
806
|
+
scrollDirection: this.scrollDirection
|
|
754
807
|
// @ts-ignore
|
|
755
808
|
,
|
|
756
809
|
loading: loading,
|