@semcore/data-table 4.51.0-prerelease.5 → 4.51.0-prerelease.6
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/lib/cjs/Body.js +477 -0
- package/lib/cjs/Body.js.map +1 -0
- package/lib/cjs/DataTable.js +629 -0
- package/lib/cjs/DataTable.js.map +1 -0
- package/lib/cjs/Head.js +398 -0
- package/lib/cjs/Head.js.map +1 -0
- package/lib/cjs/index.js +15 -38
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/data-table.shadow.css +413 -0
- package/lib/cjs/style/scroll-shadows.shadow.css +5 -50
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +5 -4
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/cjs/translations/de.json +1 -6
- package/lib/cjs/translations/en.json +1 -6
- package/lib/cjs/translations/es.json +1 -6
- package/lib/cjs/translations/fr.json +1 -6
- package/lib/cjs/translations/it.json +1 -6
- package/lib/cjs/translations/ja.json +1 -6
- package/lib/cjs/translations/ko.json +1 -6
- package/lib/cjs/translations/nl.json +1 -6
- package/lib/cjs/translations/pl.json +1 -6
- package/lib/cjs/translations/pt.json +1 -6
- package/lib/cjs/translations/sv.json +1 -6
- package/lib/cjs/translations/tr.json +1 -6
- package/lib/cjs/translations/vi.json +1 -6
- package/lib/cjs/translations/zh.json +1 -6
- package/lib/cjs/types.js +4 -0
- package/lib/cjs/types.js.map +1 -0
- package/lib/cjs/utils.js +57 -0
- package/lib/cjs/utils.js.map +1 -0
- package/lib/es6/Body.js +469 -0
- package/lib/es6/Body.js.map +1 -0
- package/lib/es6/DataTable.js +619 -0
- package/lib/es6/DataTable.js.map +1 -0
- package/lib/es6/Head.js +390 -0
- package/lib/es6/Head.js.map +1 -0
- package/lib/es6/index.js +2 -7
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/data-table.shadow.css +413 -0
- package/lib/es6/style/scroll-shadows.shadow.css +5 -50
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +2 -2
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/translations/de.json +1 -6
- package/lib/es6/translations/en.json +1 -6
- package/lib/es6/translations/es.json +1 -6
- package/lib/es6/translations/fr.json +1 -6
- package/lib/es6/translations/it.json +1 -6
- package/lib/es6/translations/ja.json +1 -6
- package/lib/es6/translations/ko.json +1 -6
- package/lib/es6/translations/nl.json +1 -6
- package/lib/es6/translations/pl.json +1 -6
- package/lib/es6/translations/pt.json +1 -6
- package/lib/es6/translations/sv.json +1 -6
- package/lib/es6/translations/tr.json +1 -6
- package/lib/es6/translations/vi.json +1 -6
- package/lib/es6/translations/zh.json +1 -6
- package/lib/es6/types.js +2 -0
- package/lib/es6/types.js.map +1 -0
- package/lib/es6/utils.js +48 -0
- package/lib/es6/utils.js.map +1 -0
- package/lib/esm/Body.mjs +430 -0
- package/lib/esm/DataTable.mjs +589 -0
- package/lib/esm/Head.mjs +368 -0
- package/lib/esm/index.mjs +5 -12
- package/lib/esm/style/data-table.shadow.css +413 -0
- package/lib/esm/style/scroll-shadows.shadow.css +5 -50
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +2 -2
- package/lib/esm/translations/de.json.mjs +1 -6
- package/lib/esm/translations/en.json.mjs +1 -6
- package/lib/esm/translations/es.json.mjs +1 -6
- package/lib/esm/translations/fr.json.mjs +1 -6
- package/lib/esm/translations/it.json.mjs +1 -6
- package/lib/esm/translations/ja.json.mjs +1 -6
- package/lib/esm/translations/ko.json.mjs +1 -6
- package/lib/esm/translations/nl.json.mjs +1 -6
- package/lib/esm/translations/pl.json.mjs +1 -6
- package/lib/esm/translations/pt.json.mjs +1 -6
- package/lib/esm/translations/sv.json.mjs +1 -6
- package/lib/esm/translations/tr.json.mjs +1 -6
- package/lib/esm/translations/vi.json.mjs +1 -6
- package/lib/esm/translations/zh.json.mjs +1 -6
- package/lib/esm/utils.mjs +52 -0
- package/lib/types/Body.d.ts +61 -0
- package/lib/types/DataTable.d.ts +205 -0
- package/lib/types/Head.d.ts +45 -0
- package/lib/types/index.d.ts +2 -10
- package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +0 -70
- package/lib/types/types.d.ts +73 -0
- package/lib/types/utils.d.ts +4 -0
- package/package.json +6 -6
- package/lib/cjs/components/AccordionRows/AccordionRows.js +0 -177
- package/lib/cjs/components/AccordionRows/AccordionRows.js.map +0 -1
- package/lib/cjs/components/Body/Body.js +0 -445
- package/lib/cjs/components/Body/Body.js.map +0 -1
- package/lib/cjs/components/Body/Body.types.js +0 -2
- package/lib/cjs/components/Body/Body.types.js.map +0 -1
- package/lib/cjs/components/Body/Cell.js +0 -205
- package/lib/cjs/components/Body/Cell.js.map +0 -1
- package/lib/cjs/components/Body/Cell.types.js +0 -2
- package/lib/cjs/components/Body/Cell.types.js.map +0 -1
- package/lib/cjs/components/Body/LimitOverlay.js +0 -191
- package/lib/cjs/components/Body/LimitOverlay.js.map +0 -1
- package/lib/cjs/components/Body/MergedCells.js +0 -31
- package/lib/cjs/components/Body/MergedCells.js.map +0 -1
- package/lib/cjs/components/Body/Row.js +0 -630
- package/lib/cjs/components/Body/Row.js.map +0 -1
- package/lib/cjs/components/Body/Row.types.js +0 -2
- package/lib/cjs/components/Body/Row.types.js.map +0 -1
- package/lib/cjs/components/Body/RowGroup.js +0 -118
- package/lib/cjs/components/Body/RowGroup.js.map +0 -1
- package/lib/cjs/components/Body/style.shadow.css +0 -367
- package/lib/cjs/components/DataTable/DataTable.js +0 -1303
- package/lib/cjs/components/DataTable/DataTable.js.map +0 -1
- package/lib/cjs/components/DataTable/DataTable.types.js +0 -2
- package/lib/cjs/components/DataTable/DataTable.types.js.map +0 -1
- package/lib/cjs/components/DataTable/ScrollBars.js +0 -63
- package/lib/cjs/components/DataTable/ScrollBars.js.map +0 -1
- package/lib/cjs/components/DataTable/dataTable.shadow.css +0 -43
- package/lib/cjs/components/Head/Column.js +0 -350
- package/lib/cjs/components/Head/Column.js.map +0 -1
- package/lib/cjs/components/Head/Column.types.js +0 -2
- package/lib/cjs/components/Head/Column.types.js.map +0 -1
- package/lib/cjs/components/Head/Group.js +0 -116
- package/lib/cjs/components/Head/Group.js.map +0 -1
- package/lib/cjs/components/Head/Group.type.js +0 -2
- package/lib/cjs/components/Head/Group.type.js.map +0 -1
- package/lib/cjs/components/Head/Head.js +0 -350
- package/lib/cjs/components/Head/Head.js.map +0 -1
- package/lib/cjs/components/Head/Head.types.js +0 -2
- package/lib/cjs/components/Head/Head.types.js.map +0 -1
- package/lib/cjs/components/Head/style.shadow.css +0 -292
- package/lib/cjs/components/RowSelector/RowsSelector.js +0 -132
- package/lib/cjs/components/RowSelector/RowsSelector.js.map +0 -1
- package/lib/cjs/components/RowSelector/SRAnnouncer.js +0 -62
- package/lib/cjs/components/RowSelector/SRAnnouncer.js.map +0 -1
- package/lib/cjs/components/RowSelector/SRReactiveAnnouncer.js +0 -39
- package/lib/cjs/components/RowSelector/SRReactiveAnnouncer.js.map +0 -1
- package/lib/cjs/enhancers/focusableCell.js +0 -76
- package/lib/cjs/enhancers/focusableCell.js.map +0 -1
- package/lib/cjs/store/SelectableRows.js +0 -211
- package/lib/cjs/store/SelectableRows.js.map +0 -1
- package/lib/es6/components/AccordionRows/AccordionRows.js +0 -171
- package/lib/es6/components/AccordionRows/AccordionRows.js.map +0 -1
- package/lib/es6/components/Body/Body.js +0 -439
- package/lib/es6/components/Body/Body.js.map +0 -1
- package/lib/es6/components/Body/Body.types.js +0 -2
- package/lib/es6/components/Body/Body.types.js.map +0 -1
- package/lib/es6/components/Body/Cell.js +0 -199
- package/lib/es6/components/Body/Cell.js.map +0 -1
- package/lib/es6/components/Body/Cell.types.js +0 -2
- package/lib/es6/components/Body/Cell.types.js.map +0 -1
- package/lib/es6/components/Body/LimitOverlay.js +0 -184
- package/lib/es6/components/Body/LimitOverlay.js.map +0 -1
- package/lib/es6/components/Body/MergedCells.js +0 -24
- package/lib/es6/components/Body/MergedCells.js.map +0 -1
- package/lib/es6/components/Body/Row.js +0 -624
- package/lib/es6/components/Body/Row.js.map +0 -1
- package/lib/es6/components/Body/Row.types.js +0 -2
- package/lib/es6/components/Body/Row.types.js.map +0 -1
- package/lib/es6/components/Body/RowGroup.js +0 -111
- package/lib/es6/components/Body/RowGroup.js.map +0 -1
- package/lib/es6/components/Body/style.shadow.css +0 -367
- package/lib/es6/components/DataTable/DataTable.js +0 -1298
- package/lib/es6/components/DataTable/DataTable.js.map +0 -1
- package/lib/es6/components/DataTable/DataTable.types.js +0 -2
- package/lib/es6/components/DataTable/DataTable.types.js.map +0 -1
- package/lib/es6/components/DataTable/ScrollBars.js +0 -57
- package/lib/es6/components/DataTable/ScrollBars.js.map +0 -1
- package/lib/es6/components/DataTable/dataTable.shadow.css +0 -43
- package/lib/es6/components/Head/Column.js +0 -344
- package/lib/es6/components/Head/Column.js.map +0 -1
- package/lib/es6/components/Head/Column.types.js +0 -2
- package/lib/es6/components/Head/Column.types.js.map +0 -1
- package/lib/es6/components/Head/Group.js +0 -111
- package/lib/es6/components/Head/Group.js.map +0 -1
- package/lib/es6/components/Head/Group.type.js +0 -2
- package/lib/es6/components/Head/Group.type.js.map +0 -1
- package/lib/es6/components/Head/Head.js +0 -345
- package/lib/es6/components/Head/Head.js.map +0 -1
- package/lib/es6/components/Head/Head.types.js +0 -2
- package/lib/es6/components/Head/Head.types.js.map +0 -1
- package/lib/es6/components/Head/style.shadow.css +0 -292
- package/lib/es6/components/RowSelector/RowsSelector.js +0 -125
- package/lib/es6/components/RowSelector/RowsSelector.js.map +0 -1
- package/lib/es6/components/RowSelector/SRAnnouncer.js +0 -55
- package/lib/es6/components/RowSelector/SRAnnouncer.js.map +0 -1
- package/lib/es6/components/RowSelector/SRReactiveAnnouncer.js +0 -32
- package/lib/es6/components/RowSelector/SRReactiveAnnouncer.js.map +0 -1
- package/lib/es6/enhancers/focusableCell.js +0 -69
- package/lib/es6/enhancers/focusableCell.js.map +0 -1
- package/lib/es6/store/SelectableRows.js +0 -204
- package/lib/es6/store/SelectableRows.js.map +0 -1
- package/lib/esm/components/AccordionRows/AccordionRows.mjs +0 -155
- package/lib/esm/components/Body/Body.mjs +0 -395
- package/lib/esm/components/Body/Cell.mjs +0 -192
- package/lib/esm/components/Body/LimitOverlay.mjs +0 -179
- package/lib/esm/components/Body/MergedCells.mjs +0 -27
- package/lib/esm/components/Body/Row.mjs +0 -556
- package/lib/esm/components/Body/RowGroup.mjs +0 -113
- package/lib/esm/components/Body/style.shadow.css +0 -367
- package/lib/esm/components/DataTable/DataTable.mjs +0 -1216
- package/lib/esm/components/DataTable/ScrollBars.mjs +0 -61
- package/lib/esm/components/DataTable/dataTable.shadow.css +0 -43
- package/lib/esm/components/Head/Column.mjs +0 -321
- package/lib/esm/components/Head/Group.mjs +0 -111
- package/lib/esm/components/Head/Head.mjs +0 -307
- package/lib/esm/components/Head/style.shadow.css +0 -292
- package/lib/esm/components/RowSelector/RowsSelector.mjs +0 -105
- package/lib/esm/components/RowSelector/SRAnnouncer.mjs +0 -51
- package/lib/esm/components/RowSelector/SRReactiveAnnouncer.mjs +0 -31
- package/lib/esm/enhancers/focusableCell.mjs +0 -72
- package/lib/esm/store/SelectableRows.mjs +0 -201
- package/lib/types/components/AccordionRows/AccordionRows.d.ts +0 -41
- package/lib/types/components/Body/Body.d.ts +0 -6
- package/lib/types/components/Body/Body.types.d.ts +0 -87
- package/lib/types/components/Body/Cell.d.ts +0 -1
- package/lib/types/components/Body/Cell.types.d.ts +0 -36
- package/lib/types/components/Body/LimitOverlay.d.ts +0 -17
- package/lib/types/components/Body/MergedCells.d.ts +0 -17
- package/lib/types/components/Body/Row.d.ts +0 -47
- package/lib/types/components/Body/Row.types.d.ts +0 -74
- package/lib/types/components/Body/RowGroup.d.ts +0 -19
- package/lib/types/components/DataTable/DataTable.d.ts +0 -14
- package/lib/types/components/DataTable/DataTable.types.d.ts +0 -202
- package/lib/types/components/DataTable/ScrollBars.d.ts +0 -11
- package/lib/types/components/Head/Column.d.ts +0 -39
- package/lib/types/components/Head/Column.types.d.ts +0 -85
- package/lib/types/components/Head/Group.d.ts +0 -15
- package/lib/types/components/Head/Group.type.d.ts +0 -18
- package/lib/types/components/Head/Head.d.ts +0 -9
- package/lib/types/components/Head/Head.types.d.ts +0 -58
- package/lib/types/components/RowSelector/RowsSelector.d.ts +0 -32
- package/lib/types/components/RowSelector/SRAnnouncer.d.ts +0 -10
- package/lib/types/components/RowSelector/SRReactiveAnnouncer.d.ts +0 -8
- package/lib/types/enhancers/focusableCell.d.ts +0 -9
- package/lib/types/store/SelectableRows.d.ts +0 -60
package/lib/esm/Head.mjs
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
+
import { sstyled, assignProps, Component } from "@semcore/core";
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { ScreenReaderOnly, Flex, Box } from "@semcore/flex-box";
|
|
12
|
+
import ScrollArea, { hideScrollBarsFromScreenReadersContext } from "@semcore/scroll-area";
|
|
13
|
+
import SortDesc from "@semcore/icon/SortDesc/m";
|
|
14
|
+
import SortAsc from "@semcore/icon/SortAsc/m";
|
|
15
|
+
import { callAllEventHandlers } from "@semcore/utils/lib/assignProps";
|
|
16
|
+
import { flattenColumns, getFixedStyle, getScrollOffsetValue } from "./utils.mjs";
|
|
17
|
+
import logger from "@semcore/utils/lib/logger";
|
|
18
|
+
import { setRef } from "@semcore/utils/lib/ref";
|
|
19
|
+
import { getFocusableIn } from "@semcore/utils/lib/focus-lock/getFocusableIn";
|
|
20
|
+
var SORT_ICON_WIDTH = 20;
|
|
21
|
+
var SORTING_ICON = {
|
|
22
|
+
desc: SortDesc,
|
|
23
|
+
asc: SortAsc
|
|
24
|
+
};
|
|
25
|
+
var ariaSort = {
|
|
26
|
+
desc: "descending",
|
|
27
|
+
asc: "ascending"
|
|
28
|
+
};
|
|
29
|
+
var displayContents = {
|
|
30
|
+
display: "contents"
|
|
31
|
+
};
|
|
32
|
+
function cssToIntDefault(value) {
|
|
33
|
+
var defaultValue = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
|
|
34
|
+
var result = parseFloat(value);
|
|
35
|
+
if (Number.isNaN(result)) {
|
|
36
|
+
result = defaultValue;
|
|
37
|
+
}
|
|
38
|
+
return Math.round(result);
|
|
39
|
+
}
|
|
40
|
+
var Head = /* @__PURE__ */ function(_Component) {
|
|
41
|
+
_inherits(Head2, _Component);
|
|
42
|
+
var _super = _createSuper(Head2);
|
|
43
|
+
function Head2() {
|
|
44
|
+
var _this;
|
|
45
|
+
_classCallCheck(this, Head2);
|
|
46
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
47
|
+
args[_key] = arguments[_key];
|
|
48
|
+
}
|
|
49
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
50
|
+
_defineProperty(_assertThisInitialized(_this), "columns", []);
|
|
51
|
+
_defineProperty(_assertThisInitialized(_this), "headCellMap", /* @__PURE__ */ new Map());
|
|
52
|
+
_defineProperty(_assertThisInitialized(_this), "lockedCell", [null, false]);
|
|
53
|
+
_defineProperty(_assertThisInitialized(_this), "sortWrapperRefs", /* @__PURE__ */ new Map());
|
|
54
|
+
_defineProperty(_assertThisInitialized(_this), "defaultWidths", /* @__PURE__ */ new Map());
|
|
55
|
+
_defineProperty(_assertThisInitialized(_this), "handleKeyDown", function(e) {
|
|
56
|
+
if (e.currentTarget === _this.lockedCell[0]) {
|
|
57
|
+
var focusableChildren = Array.from(_this.lockedCell[0].children).flatMap(function(node) {
|
|
58
|
+
return getFocusableIn(node);
|
|
59
|
+
});
|
|
60
|
+
if (_this.lockedCell[1]) {
|
|
61
|
+
if (e.key === "Escape") {
|
|
62
|
+
var _this$lockedCell$;
|
|
63
|
+
(_this$lockedCell$ = _this.lockedCell[0]) === null || _this$lockedCell$ === void 0 ? void 0 : _this$lockedCell$.focus();
|
|
64
|
+
_this.lockedCell[1] = false;
|
|
65
|
+
}
|
|
66
|
+
if (e.key.startsWith("Arrow")) {
|
|
67
|
+
e.stopPropagation();
|
|
68
|
+
}
|
|
69
|
+
if (e.key === "Tab") {
|
|
70
|
+
if (e.target === focusableChildren[0] && e.shiftKey) {
|
|
71
|
+
var _focusableChildren;
|
|
72
|
+
(_focusableChildren = focusableChildren[focusableChildren.length - 1]) === null || _focusableChildren === void 0 ? void 0 : _focusableChildren.focus();
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
} else if (e.target === focusableChildren[focusableChildren.length - 1] && !e.shiftKey) {
|
|
75
|
+
var _focusableChildren$;
|
|
76
|
+
(_focusableChildren$ = focusableChildren[0]) === null || _focusableChildren$ === void 0 ? void 0 : _focusableChildren$.focus();
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
} else if (e.key === "Enter") {
|
|
81
|
+
var _focusableChildren$2;
|
|
82
|
+
_this.lockedCell[1] = true;
|
|
83
|
+
(_focusableChildren$2 = focusableChildren[0]) === null || _focusableChildren$2 === void 0 ? void 0 : _focusableChildren$2.focus();
|
|
84
|
+
} else if (e.key === "Tab") {
|
|
85
|
+
var _this$lockedCell$2;
|
|
86
|
+
(_this$lockedCell$2 = _this.lockedCell[0]) === null || _this$lockedCell$2 === void 0 ? void 0 : _this$lockedCell$2.setAttribute("inert", "");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
_defineProperty(_assertThisInitialized(_this), "onFocusCell", function(e) {
|
|
91
|
+
if (e.target === e.currentTarget) {
|
|
92
|
+
var focusableChildren = Array.from(e.currentTarget.children).flatMap(function(node) {
|
|
93
|
+
return getFocusableIn(node);
|
|
94
|
+
});
|
|
95
|
+
if (focusableChildren.length === 1) {
|
|
96
|
+
focusableChildren[0].focus();
|
|
97
|
+
} else if (focusableChildren.length > 1) {
|
|
98
|
+
_this.lockedCell = [e.currentTarget, false];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
_defineProperty(_assertThisInitialized(_this), "bindHandlerSortClick", function(name) {
|
|
103
|
+
return function(event) {
|
|
104
|
+
_this.asProps.$onSortClick(name, event);
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
_defineProperty(_assertThisInitialized(_this), "bindHandlerKeyDown", function(name) {
|
|
108
|
+
return function(event) {
|
|
109
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
_this.asProps.$onSortClick(name, event);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
_defineProperty(_assertThisInitialized(_this), "makeSortRefHandler", function(active) {
|
|
116
|
+
return function(ref) {
|
|
117
|
+
if (ref) {
|
|
118
|
+
_this.sortWrapperRefs.set(ref, active);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
_defineProperty(_assertThisInitialized(_this), "makeColumnRefHandler", function(column, index) {
|
|
123
|
+
return function(ref) {
|
|
124
|
+
setRef(column.props.ref, ref);
|
|
125
|
+
_this.headCellMap.set(index, ref);
|
|
126
|
+
if (column.props.forwardRef) {
|
|
127
|
+
setRef(column.props.forwardRef, ref);
|
|
128
|
+
}
|
|
129
|
+
if (ref && ref.getAttribute("scope") === "col") {
|
|
130
|
+
if (!_this.defaultWidths.has(ref)) {
|
|
131
|
+
var computedStyle = window.getComputedStyle(ref);
|
|
132
|
+
_this.defaultWidths.set(ref, {
|
|
133
|
+
minWidth: cssToIntDefault(computedStyle.getPropertyValue("min-width")),
|
|
134
|
+
computedWidth: cssToIntDefault(computedStyle.getPropertyValue("width")),
|
|
135
|
+
maxWidth: cssToIntDefault(computedStyle.getPropertyValue("max-width")) || null,
|
|
136
|
+
useForRecalculation: Boolean(column.props.sortSizeRecalculation)
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
_defineProperty(_assertThisInitialized(_this), "changeMaxNodeWidth", function(diff, exceptNode) {
|
|
143
|
+
var lastMaxWidth = 0;
|
|
144
|
+
var node = null;
|
|
145
|
+
var recalculatedNodes = [];
|
|
146
|
+
_this.defaultWidths.forEach(function(value, key) {
|
|
147
|
+
if (value.computedWidth > lastMaxWidth && key !== exceptNode) {
|
|
148
|
+
node = key;
|
|
149
|
+
lastMaxWidth = value.computedWidth;
|
|
150
|
+
}
|
|
151
|
+
if (value.useForRecalculation) {
|
|
152
|
+
recalculatedNodes.push(key);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
var setNodeMinWidth = function setNodeMinWidth2(node2, diff2) {
|
|
156
|
+
var _this$defaultWidths$g, _this$defaultWidths$g2;
|
|
157
|
+
var defaultNodeWidth = (_this$defaultWidths$g = _this.defaultWidths.get(node2)) === null || _this$defaultWidths$g === void 0 ? void 0 : _this$defaultWidths$g.computedWidth;
|
|
158
|
+
var defaultNodeMinWidth = (_this$defaultWidths$g2 = _this.defaultWidths.get(node2)) === null || _this$defaultWidths$g2 === void 0 ? void 0 : _this$defaultWidths$g2.minWidth;
|
|
159
|
+
if (defaultNodeWidth) {
|
|
160
|
+
var maxWidth = defaultNodeWidth - diff2;
|
|
161
|
+
node2.style.setProperty("max-width", "".concat(maxWidth, "px"));
|
|
162
|
+
if (defaultNodeMinWidth) {
|
|
163
|
+
node2.style.setProperty("min-width", "min(".concat(maxWidth, "px, ").concat(defaultNodeMinWidth, "px)"));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
if (recalculatedNodes.length > 0) {
|
|
168
|
+
var diffPart = diff / recalculatedNodes.length;
|
|
169
|
+
recalculatedNodes.forEach(function(node2) {
|
|
170
|
+
setNodeMinWidth(node2, diffPart);
|
|
171
|
+
});
|
|
172
|
+
} else if (node !== null) {
|
|
173
|
+
setNodeMinWidth(node, diff);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
_defineProperty(_assertThisInitialized(_this), "backToColumnDefaults", function(node) {
|
|
177
|
+
var _this$defaultWidths$g3, _this$defaultWidths$g4;
|
|
178
|
+
var defaultNodeMinWidth = (_this$defaultWidths$g3 = _this.defaultWidths.get(node)) === null || _this$defaultWidths$g3 === void 0 ? void 0 : _this$defaultWidths$g3.minWidth;
|
|
179
|
+
var defaultNodeMaxWidth = (_this$defaultWidths$g4 = _this.defaultWidths.get(node)) === null || _this$defaultWidths$g4 === void 0 ? void 0 : _this$defaultWidths$g4.maxWidth;
|
|
180
|
+
node.style.setProperty("min-width", defaultNodeMinWidth + "px");
|
|
181
|
+
if (defaultNodeMaxWidth) {
|
|
182
|
+
node.style.setProperty("max-width", defaultNodeMaxWidth + "px");
|
|
183
|
+
} else {
|
|
184
|
+
node.style.removeProperty("max-width");
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
_defineProperty(_assertThisInitialized(_this), "calculateActiveColumnMinWidth", function(node) {
|
|
188
|
+
var _this$defaultWidths$g5, _this$defaultWidths$g6;
|
|
189
|
+
var clonedColumn = document.createElement("div");
|
|
190
|
+
var computedStyle = window.getComputedStyle(node);
|
|
191
|
+
node.childNodes.forEach(function(node2) {
|
|
192
|
+
if (!_this.sortWrapperRefs.get(node2)) {
|
|
193
|
+
clonedColumn.append(node2.cloneNode(true));
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
clonedColumn.style.setProperty("visibility", "hidden", "important");
|
|
197
|
+
var styles = ["display", "flex", "margin", "padding", "background", "font-style", "font-width", "font-size", "font-weight"];
|
|
198
|
+
styles.forEach(function(key) {
|
|
199
|
+
clonedColumn.style.setProperty(key, computedStyle.getPropertyValue(key), computedStyle.getPropertyPriority(key));
|
|
200
|
+
});
|
|
201
|
+
clonedColumn.style.setProperty("width", "fit-content", "important");
|
|
202
|
+
document.body.appendChild(clonedColumn);
|
|
203
|
+
var computedWidth = Math.ceil(clonedColumn.getBoundingClientRect().width);
|
|
204
|
+
document.body.removeChild(clonedColumn);
|
|
205
|
+
var defaultNodeWidth = (_this$defaultWidths$g5 = (_this$defaultWidths$g6 = _this.defaultWidths.get(node)) === null || _this$defaultWidths$g6 === void 0 ? void 0 : _this$defaultWidths$g6.computedWidth) !== null && _this$defaultWidths$g5 !== void 0 ? _this$defaultWidths$g5 : 0;
|
|
206
|
+
if (computedWidth >= defaultNodeWidth) {
|
|
207
|
+
node.style.setProperty("min-width", defaultNodeWidth + SORT_ICON_WIDTH + "px");
|
|
208
|
+
_this.changeMaxNodeWidth(SORT_ICON_WIDTH, node);
|
|
209
|
+
} else {
|
|
210
|
+
var freeSpace = defaultNodeWidth - computedWidth;
|
|
211
|
+
if (freeSpace < SORT_ICON_WIDTH) {
|
|
212
|
+
node.style.setProperty("min-width", computedWidth + SORT_ICON_WIDTH + "px");
|
|
213
|
+
_this.changeMaxNodeWidth(freeSpace, node);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
return _this;
|
|
218
|
+
}
|
|
219
|
+
_createClass(Head2, [{
|
|
220
|
+
key: "sortableColumnDescribeId",
|
|
221
|
+
value: function sortableColumnDescribeId() {
|
|
222
|
+
var uid = this.asProps.uid;
|
|
223
|
+
return "".concat(uid, "-column-sortable-describer");
|
|
224
|
+
}
|
|
225
|
+
}, {
|
|
226
|
+
key: "componentDidUpdate",
|
|
227
|
+
value: function componentDidUpdate() {
|
|
228
|
+
var _this2 = this;
|
|
229
|
+
var activeColumn = null;
|
|
230
|
+
this.columns.forEach(function(column) {
|
|
231
|
+
var _column$props = column.props, changeSortSize = _column$props.changeSortSize, ref = _column$props.ref;
|
|
232
|
+
if (column.active && changeSortSize && ref.current) {
|
|
233
|
+
activeColumn = ref.current;
|
|
234
|
+
}
|
|
235
|
+
if (ref.current) {
|
|
236
|
+
_this2.backToColumnDefaults(ref.current);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
if (activeColumn) {
|
|
240
|
+
this.calculateActiveColumnMinWidth(activeColumn);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}, {
|
|
244
|
+
key: "renderColumns",
|
|
245
|
+
value: function renderColumns(columns, width) {
|
|
246
|
+
var _this3 = this;
|
|
247
|
+
return columns.map(function(column) {
|
|
248
|
+
return _this3.renderColumn(column, width);
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}, {
|
|
252
|
+
key: "renderColumn",
|
|
253
|
+
value: function renderColumn(column, width) {
|
|
254
|
+
var _ref2, _column$columns;
|
|
255
|
+
var _this$asProps = this.asProps, styles = _this$asProps.styles, use = _this$asProps.use, hidden = _this$asProps.hidden, uid = _this$asProps.uid;
|
|
256
|
+
var SColumn = Flex;
|
|
257
|
+
var SHead = Box;
|
|
258
|
+
var SSortWrapper = "div";
|
|
259
|
+
var SSortIcon = SORTING_ICON[column.sortDirection];
|
|
260
|
+
var ariaSortValue = column.sortable && column.active ? ariaSort[column.sortDirection] : void 0;
|
|
261
|
+
var isGroup = ((_column$columns = column.columns) === null || _column$columns === void 0 ? void 0 : _column$columns.length) > 0;
|
|
262
|
+
var cSize = isGroup ? flattenColumns(column.columns).length : 1;
|
|
263
|
+
var _getFixedStyle = getFixedStyle(column, this.columns), _getFixedStyle2 = _slicedToArray(_getFixedStyle, 2), name = _getFixedStyle2[0], value = _getFixedStyle2[1];
|
|
264
|
+
var style = _objectSpread({
|
|
265
|
+
flexBasis: column.props.flex === void 0 && "".concat(width * cSize, "%")
|
|
266
|
+
}, column.props.style);
|
|
267
|
+
if (name !== void 0 && value !== void 0) {
|
|
268
|
+
style[name] = value;
|
|
269
|
+
}
|
|
270
|
+
if (!column.setVar) {
|
|
271
|
+
style["flexBasis"] = "var(".concat(column.varWidth, ")");
|
|
272
|
+
}
|
|
273
|
+
var ariaDescribedBy = [];
|
|
274
|
+
if (column.sortable && !column.active) {
|
|
275
|
+
ariaDescribedBy.push(this.sortableColumnDescribeId());
|
|
276
|
+
}
|
|
277
|
+
if (column.parentColumns.length > 0) {
|
|
278
|
+
var parentName = column.parentColumns[0].name;
|
|
279
|
+
ariaDescribedBy.push("igc-table-".concat(uid, "-").concat(parentName, "-group"));
|
|
280
|
+
}
|
|
281
|
+
var index = this.columns.findIndex(function(flattenCol) {
|
|
282
|
+
return flattenCol.name === column.name;
|
|
283
|
+
});
|
|
284
|
+
return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(SColumn, _ref2.cn("SColumn", _objectSpread(_objectSpread({
|
|
285
|
+
"role": isGroup ? void 0 : "columnheader",
|
|
286
|
+
"scope": isGroup ? "colgroup" : "col",
|
|
287
|
+
"key": column.name,
|
|
288
|
+
"id": "igc-table-".concat(uid, "-").concat(column.name),
|
|
289
|
+
"use": use,
|
|
290
|
+
"fixed": column.fixed,
|
|
291
|
+
"resizable": column.resizable,
|
|
292
|
+
"sortable": column.sortable,
|
|
293
|
+
"borderLeft": isGroup ? false : column.borderLeft,
|
|
294
|
+
"borderRight": isGroup ? false : column.borderRight,
|
|
295
|
+
"active": isGroup ? false : column.active,
|
|
296
|
+
"group": isGroup,
|
|
297
|
+
"tabIndex": isGroup ? void 0 : -1,
|
|
298
|
+
"__excludeProps": ["hidden"]
|
|
299
|
+
}, column.props), {}, {
|
|
300
|
+
"ref": this.makeColumnRefHandler(column, index),
|
|
301
|
+
"onClick": callAllEventHandlers(column.props.onClick, column.sortable ? this.bindHandlerSortClick(column.name) : void 0),
|
|
302
|
+
"onKeyDown": callAllEventHandlers(column.props.onKeyDown, column.sortable ? this.bindHandlerKeyDown(column.name) : void 0, this.handleKeyDown),
|
|
303
|
+
"style": style,
|
|
304
|
+
"hidden": hidden,
|
|
305
|
+
"aria-sort": ariaSortValue,
|
|
306
|
+
"aria-colindex": isGroup ? void 0 : index + 1,
|
|
307
|
+
"onFocus": this.onFocusCell,
|
|
308
|
+
"aria-describedby": ariaDescribedBy.length > 0 ? ariaDescribedBy.join(" ") : void 0
|
|
309
|
+
})), isGroup ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SColumn, _ref2.cn("SColumn", {
|
|
310
|
+
"id": "igc-table-".concat(uid, "-").concat(column.name, "-group"),
|
|
311
|
+
"groupHead": true,
|
|
312
|
+
"use": use,
|
|
313
|
+
"active": column.active,
|
|
314
|
+
"borderLeft": column.borderLeft,
|
|
315
|
+
"borderRight": column.borderRight
|
|
316
|
+
}), /* @__PURE__ */ React.createElement("div", _ref2.cn("div", {}), column.props.children)), /* @__PURE__ */ React.createElement(SHead, _ref2.cn("SHead", {}), this.renderColumns(column.columns, 100 / cSize))) : /* @__PURE__ */ React.createElement(React.Fragment, null, column.props.children, column.sortable ? /* @__PURE__ */ React.createElement(SSortWrapper, _ref2.cn("SSortWrapper", {
|
|
317
|
+
"ref": this.makeSortRefHandler(column.active)
|
|
318
|
+
}), /* @__PURE__ */ React.createElement(SSortIcon, _ref2.cn("SSortIcon", {}))) : null));
|
|
319
|
+
}
|
|
320
|
+
}, {
|
|
321
|
+
key: "render",
|
|
322
|
+
value: function render() {
|
|
323
|
+
var _ref = this.asProps, _ref3;
|
|
324
|
+
var SHead = Box;
|
|
325
|
+
var SHeadWrapper = Box;
|
|
326
|
+
var _this$asProps2 = this.asProps, Children = _this$asProps2.Children, styles = _this$asProps2.styles, columnsChildren = _this$asProps2.columnsChildren, onResize = _this$asProps2.onResize, $scrollRef = _this$asProps2.$scrollRef, sticky = _this$asProps2.sticky, withScrollBar = _this$asProps2.withScrollBar, animationsDisabled = _this$asProps2.animationsDisabled, getI18nText = _this$asProps2.getI18nText;
|
|
327
|
+
this.columns = flattenColumns(columnsChildren);
|
|
328
|
+
var _getScrollOffsetValue = getScrollOffsetValue(this.columns), _getScrollOffsetValue2 = _slicedToArray(_getScrollOffsetValue, 2), offsetLeftSum = _getScrollOffsetValue2[0], offsetRightSum = _getScrollOffsetValue2[1];
|
|
329
|
+
logger.warn(sticky, "'sticky' property is deprecated, use '<Sticky/>' wrapper", this.asProps["data-ui-name"] || Head2.displayName);
|
|
330
|
+
return _ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(hideScrollBarsFromScreenReadersContext.Provider, {
|
|
331
|
+
value: true
|
|
332
|
+
}, /* @__PURE__ */ React.createElement(SHeadWrapper, _ref3.cn("SHeadWrapper", {
|
|
333
|
+
"sticky": sticky,
|
|
334
|
+
"animationsDisabled": animationsDisabled
|
|
335
|
+
}), /* @__PURE__ */ React.createElement(ScrollArea, _ref3.cn("ScrollArea", {
|
|
336
|
+
"leftOffset": offsetLeftSum,
|
|
337
|
+
"rightOffset": offsetRightSum,
|
|
338
|
+
"shadow": true,
|
|
339
|
+
"onResize": onResize
|
|
340
|
+
}), /* @__PURE__ */ React.createElement(ScrollArea.Container, {
|
|
341
|
+
ref: $scrollRef,
|
|
342
|
+
role: "rowgroup",
|
|
343
|
+
tabIndex: -1,
|
|
344
|
+
zIndex: 2
|
|
345
|
+
}, /* @__PURE__ */ React.createElement(SHead, _ref3.cn("SHead", _objectSpread({}, assignProps({
|
|
346
|
+
"role": "row",
|
|
347
|
+
"__excludeProps": ["hidden"]
|
|
348
|
+
}, _ref))), this.renderColumns(columnsChildren, 100 / this.columns.length))), Boolean(withScrollBar) && /* @__PURE__ */ React.createElement("div", _ref3.cn("div", {
|
|
349
|
+
"style": displayContents
|
|
350
|
+
}), /* @__PURE__ */ React.createElement("div", _ref3.cn("div", {
|
|
351
|
+
"style": displayContents
|
|
352
|
+
}), /* @__PURE__ */ React.createElement("div", _ref3.cn("div", {
|
|
353
|
+
"style": displayContents
|
|
354
|
+
}), /* @__PURE__ */ React.createElement(ScrollArea.Bar, {
|
|
355
|
+
orientation: "horizontal"
|
|
356
|
+
}))))), Children.origin, /* @__PURE__ */ React.createElement(ScreenReaderOnly, _ref3.cn("ScreenReaderOnly", {
|
|
357
|
+
"aria-hidden": true,
|
|
358
|
+
"id": this.sortableColumnDescribeId()
|
|
359
|
+
}), getI18nText === null || getI18nText === void 0 ? void 0 : getI18nText("sortableColumn"))));
|
|
360
|
+
}
|
|
361
|
+
}]);
|
|
362
|
+
return Head2;
|
|
363
|
+
}(Component);
|
|
364
|
+
_defineProperty(Head, "displayName", void 0);
|
|
365
|
+
export {
|
|
366
|
+
SORT_ICON_WIDTH,
|
|
367
|
+
Head as default
|
|
368
|
+
};
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ACCORDION, DataTable, ROW_GROUP } from "./components/DataTable/DataTable.mjs";
|
|
3
|
-
import { SelectableRows } from "./store/SelectableRows.mjs";
|
|
4
|
-
var wrapDataTable = function wrapDataTable2(wrapper) {
|
|
5
|
-
return wrapper;
|
|
6
|
-
};
|
|
1
|
+
import { ROW_GROUP, default as default2, wrapDataTable, wrapDataTableCell, wrapDataTableRow } from "./DataTable.mjs";
|
|
7
2
|
export {
|
|
8
|
-
ACCORDION,
|
|
9
|
-
DataTable,
|
|
10
|
-
MergedColumnsCell,
|
|
11
|
-
MergedRowsCell,
|
|
12
3
|
ROW_GROUP,
|
|
13
|
-
|
|
14
|
-
wrapDataTable
|
|
4
|
+
default2 as default,
|
|
5
|
+
wrapDataTable,
|
|
6
|
+
wrapDataTableCell,
|
|
7
|
+
wrapDataTableRow
|
|
15
8
|
};
|