@semcore/data-table 4.50.0 → 4.50.1
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 +6 -0
- package/lib/cjs/Body.js +6 -4
- package/lib/cjs/Body.js.map +1 -1
- package/lib/cjs/DataTable.js +39 -37
- package/lib/cjs/DataTable.js.map +1 -1
- package/lib/es6/Body.js +6 -4
- package/lib/es6/Body.js.map +1 -1
- package/lib/es6/DataTable.js +39 -37
- package/lib/es6/DataTable.js.map +1 -1
- package/lib/esm/Body.mjs +348 -238
- package/lib/esm/DataTable.mjs +483 -336
- package/lib/esm/Head.mjs +317 -206
- package/lib/esm/index.mjs +6 -6
- package/lib/esm/style/data-table.shadow.css +413 -0
- package/lib/esm/style/scroll-shadows.shadow.css +7 -0
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +30 -30
- package/lib/esm/translations/de.json.mjs +5 -4
- package/lib/esm/translations/en.json.mjs +5 -4
- package/lib/esm/translations/es.json.mjs +5 -4
- package/lib/esm/translations/fr.json.mjs +5 -4
- package/lib/esm/translations/it.json.mjs +5 -4
- package/lib/esm/translations/ja.json.mjs +5 -4
- package/lib/esm/translations/ko.json.mjs +5 -4
- package/lib/esm/translations/nl.json.mjs +5 -4
- package/lib/esm/translations/pl.json.mjs +5 -4
- package/lib/esm/translations/pt.json.mjs +5 -4
- package/lib/esm/translations/sv.json.mjs +5 -4
- package/lib/esm/translations/tr.json.mjs +5 -4
- package/lib/esm/translations/vi.json.mjs +5 -4
- package/lib/esm/translations/zh.json.mjs +5 -4
- package/lib/esm/utils.mjs +44 -29
- package/package.json +5 -5
package/lib/esm/Head.mjs
CHANGED
|
@@ -1,257 +1,368 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { sstyled
|
|
10
|
-
import
|
|
11
|
-
import { ScreenReaderOnly
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import { callAllEventHandlers
|
|
16
|
-
import { flattenColumns
|
|
17
|
-
import
|
|
18
|
-
import { setRef
|
|
19
|
-
import { getFocusableIn
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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 = {
|
|
24
26
|
desc: "descending",
|
|
25
27
|
asc: "ascending"
|
|
26
|
-
}
|
|
28
|
+
};
|
|
29
|
+
var displayContents = {
|
|
27
30
|
display: "contents"
|
|
28
31
|
};
|
|
29
|
-
function
|
|
30
|
-
var
|
|
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);
|
|
32
39
|
}
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
function
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
for (var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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);
|
|
45
59
|
});
|
|
46
|
-
if (
|
|
60
|
+
if (_this.lockedCell[1]) {
|
|
47
61
|
if (e.key === "Escape") {
|
|
48
|
-
var
|
|
49
|
-
(
|
|
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;
|
|
50
65
|
}
|
|
51
|
-
if (e.key.startsWith("Arrow")
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var
|
|
57
|
-
(
|
|
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();
|
|
58
78
|
}
|
|
59
79
|
}
|
|
60
80
|
} else if (e.key === "Enter") {
|
|
61
|
-
var
|
|
62
|
-
|
|
81
|
+
var _focusableChildren$2;
|
|
82
|
+
_this.lockedCell[1] = true;
|
|
83
|
+
(_focusableChildren$2 = focusableChildren[0]) === null || _focusableChildren$2 === void 0 ? void 0 : _focusableChildren$2.focus();
|
|
63
84
|
} else if (e.key === "Tab") {
|
|
64
|
-
var
|
|
65
|
-
(
|
|
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", "");
|
|
66
87
|
}
|
|
67
88
|
}
|
|
68
|
-
})
|
|
89
|
+
});
|
|
90
|
+
_defineProperty(_assertThisInitialized(_this), "onFocusCell", function(e) {
|
|
69
91
|
if (e.target === e.currentTarget) {
|
|
70
|
-
var
|
|
71
|
-
return
|
|
92
|
+
var focusableChildren = Array.from(e.currentTarget.children).flatMap(function(node) {
|
|
93
|
+
return getFocusableIn(node);
|
|
72
94
|
});
|
|
73
|
-
|
|
95
|
+
if (focusableChildren.length === 1) {
|
|
96
|
+
focusableChildren[0].focus();
|
|
97
|
+
} else if (focusableChildren.length > 1) {
|
|
98
|
+
_this.lockedCell = [e.currentTarget, false];
|
|
99
|
+
}
|
|
74
100
|
}
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
|
|
101
|
+
});
|
|
102
|
+
_defineProperty(_assertThisInitialized(_this), "bindHandlerSortClick", function(name) {
|
|
103
|
+
return function(event) {
|
|
104
|
+
_this.asProps.$onSortClick(name, event);
|
|
78
105
|
};
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
|
|
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
|
+
}
|
|
82
113
|
};
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
|
|
114
|
+
});
|
|
115
|
+
_defineProperty(_assertThisInitialized(_this), "makeSortRefHandler", function(active) {
|
|
116
|
+
return function(ref) {
|
|
117
|
+
if (ref) {
|
|
118
|
+
_this.sortWrapperRefs.set(ref, active);
|
|
119
|
+
}
|
|
86
120
|
};
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
+
}
|
|
97
139
|
}
|
|
98
140
|
};
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
+
}
|
|
103
154
|
});
|
|
104
|
-
var
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
+
}
|
|
109
165
|
}
|
|
110
166
|
};
|
|
111
|
-
if (
|
|
112
|
-
var
|
|
113
|
-
|
|
114
|
-
|
|
167
|
+
if (recalculatedNodes.length > 0) {
|
|
168
|
+
var diffPart = diff / recalculatedNodes.length;
|
|
169
|
+
recalculatedNodes.forEach(function(node2) {
|
|
170
|
+
setNodeMinWidth(node2, diffPart);
|
|
115
171
|
});
|
|
116
|
-
} else
|
|
117
|
-
|
|
118
|
-
var r, a, o = (r = i.defaultWidths.get(e)) === null || r === void 0 ? void 0 : r.minWidth, d = (a = i.defaultWidths.get(e)) === null || a === void 0 ? void 0 : a.maxWidth;
|
|
119
|
-
e.style.setProperty("min-width", o + "px"), d ? e.style.setProperty("max-width", d + "px") : e.style.removeProperty("max-width");
|
|
120
|
-
}), p(m(i), "calculateActiveColumnMinWidth", function(e) {
|
|
121
|
-
var r, a, o = document.createElement("div"), d = window.getComputedStyle(e);
|
|
122
|
-
e.childNodes.forEach(function(g) {
|
|
123
|
-
i.sortWrapperRefs.get(g) || o.append(g.cloneNode(!0));
|
|
124
|
-
}), o.style.setProperty("visibility", "hidden", "important");
|
|
125
|
-
var h = ["display", "flex", "margin", "padding", "background", "font-style", "font-width", "font-size", "font-weight"];
|
|
126
|
-
h.forEach(function(g) {
|
|
127
|
-
o.style.setProperty(g, d.getPropertyValue(g), d.getPropertyPriority(g));
|
|
128
|
-
}), o.style.setProperty("width", "fit-content", "important"), document.body.appendChild(o);
|
|
129
|
-
var v = Math.ceil(o.getBoundingClientRect().width);
|
|
130
|
-
document.body.removeChild(o);
|
|
131
|
-
var c = (r = (a = i.defaultWidths.get(e)) === null || a === void 0 ? void 0 : a.computedWidth) !== null && r !== void 0 ? r : 0;
|
|
132
|
-
if (v >= c)
|
|
133
|
-
e.style.setProperty("min-width", c + k + "px"), i.changeMaxNodeWidth(k, e);
|
|
134
|
-
else {
|
|
135
|
-
var f = c - v;
|
|
136
|
-
f < k && (e.style.setProperty("min-width", v + k + "px"), i.changeMaxNodeWidth(f, e));
|
|
172
|
+
} else if (node !== null) {
|
|
173
|
+
setNodeMinWidth(node, diff);
|
|
137
174
|
}
|
|
138
|
-
})
|
|
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;
|
|
139
218
|
}
|
|
140
|
-
|
|
219
|
+
_createClass(Head2, [{
|
|
141
220
|
key: "sortableColumnDescribeId",
|
|
142
|
-
value: function() {
|
|
143
|
-
var
|
|
144
|
-
return "".concat(
|
|
221
|
+
value: function sortableColumnDescribeId() {
|
|
222
|
+
var uid = this.asProps.uid;
|
|
223
|
+
return "".concat(uid, "-column-sortable-describer");
|
|
145
224
|
}
|
|
146
225
|
}, {
|
|
147
226
|
key: "componentDidUpdate",
|
|
148
|
-
value: function() {
|
|
149
|
-
var
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
+
}
|
|
154
242
|
}
|
|
155
243
|
}, {
|
|
156
244
|
key: "renderColumns",
|
|
157
|
-
value: function(
|
|
158
|
-
var
|
|
159
|
-
return
|
|
160
|
-
return
|
|
245
|
+
value: function renderColumns(columns, width) {
|
|
246
|
+
var _this3 = this;
|
|
247
|
+
return columns.map(function(column) {
|
|
248
|
+
return _this3.renderColumn(column, width);
|
|
161
249
|
});
|
|
162
250
|
}
|
|
163
251
|
}, {
|
|
164
252
|
key: "renderColumn",
|
|
165
|
-
value: function(
|
|
166
|
-
var
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
var
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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"));
|
|
174
280
|
}
|
|
175
|
-
var
|
|
176
|
-
return
|
|
281
|
+
var index = this.columns.findIndex(function(flattenCol) {
|
|
282
|
+
return flattenCol.name === column.name;
|
|
177
283
|
});
|
|
178
|
-
return
|
|
179
|
-
role:
|
|
180
|
-
scope:
|
|
181
|
-
key:
|
|
182
|
-
id: "igc-table-".concat(
|
|
183
|
-
use:
|
|
184
|
-
fixed:
|
|
185
|
-
resizable:
|
|
186
|
-
sortable:
|
|
187
|
-
borderLeft:
|
|
188
|
-
borderRight:
|
|
189
|
-
active:
|
|
190
|
-
group:
|
|
191
|
-
tabIndex:
|
|
192
|
-
__excludeProps: ["hidden"]
|
|
193
|
-
},
|
|
194
|
-
ref: this.makeColumnRefHandler(
|
|
195
|
-
onClick:
|
|
196
|
-
onKeyDown:
|
|
197
|
-
style:
|
|
198
|
-
hidden:
|
|
199
|
-
"aria-sort":
|
|
200
|
-
"aria-colindex":
|
|
201
|
-
onFocus: this.onFocusCell,
|
|
202
|
-
"aria-describedby":
|
|
203
|
-
})),
|
|
204
|
-
id: "igc-table-".concat(
|
|
205
|
-
groupHead:
|
|
206
|
-
use:
|
|
207
|
-
active:
|
|
208
|
-
borderLeft:
|
|
209
|
-
borderRight:
|
|
210
|
-
}), /* @__PURE__ */
|
|
211
|
-
ref: this.makeSortRefHandler(
|
|
212
|
-
}), /* @__PURE__ */
|
|
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));
|
|
213
319
|
}
|
|
214
320
|
}, {
|
|
215
321
|
key: "render",
|
|
216
|
-
value: function() {
|
|
217
|
-
var
|
|
218
|
-
|
|
219
|
-
var
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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,
|
|
232
342
|
role: "rowgroup",
|
|
233
343
|
tabIndex: -1,
|
|
234
344
|
zIndex: 2
|
|
235
|
-
}, /* @__PURE__ */
|
|
236
|
-
role: "row",
|
|
237
|
-
__excludeProps: ["hidden"]
|
|
238
|
-
},
|
|
239
|
-
style:
|
|
240
|
-
}), /* @__PURE__ */
|
|
241
|
-
style:
|
|
242
|
-
}), /* @__PURE__ */
|
|
243
|
-
style:
|
|
244
|
-
}), /* @__PURE__ */
|
|
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, {
|
|
245
355
|
orientation: "horizontal"
|
|
246
|
-
}))))),
|
|
247
|
-
"aria-hidden":
|
|
248
|
-
id: this.sortableColumnDescribeId()
|
|
249
|
-
}),
|
|
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"))));
|
|
250
360
|
}
|
|
251
|
-
}])
|
|
252
|
-
|
|
253
|
-
|
|
361
|
+
}]);
|
|
362
|
+
return Head2;
|
|
363
|
+
}(Component);
|
|
364
|
+
_defineProperty(Head, "displayName", void 0);
|
|
254
365
|
export {
|
|
255
|
-
|
|
256
|
-
|
|
366
|
+
SORT_ICON_WIDTH,
|
|
367
|
+
Head as default
|
|
257
368
|
};
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ROW_GROUP
|
|
1
|
+
import { ROW_GROUP, default as default2, wrapDataTable, wrapDataTableCell, wrapDataTableRow } from "./DataTable.mjs";
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
ROW_GROUP,
|
|
4
|
+
default2 as default,
|
|
5
|
+
wrapDataTable,
|
|
6
|
+
wrapDataTableCell,
|
|
7
|
+
wrapDataTableRow
|
|
8
8
|
};
|