@semcore/data-table 4.49.1 → 16.0.0-prerelease.11

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/cjs/Body.js +10 -10
  3. package/lib/cjs/Body.js.map +1 -1
  4. package/lib/cjs/DataTable.js +47 -52
  5. package/lib/cjs/DataTable.js.map +1 -1
  6. package/lib/cjs/Head.js +6 -5
  7. package/lib/cjs/Head.js.map +1 -1
  8. package/lib/cjs/style/data-table.shadow.css +0 -19
  9. package/lib/es6/Body.js +11 -10
  10. package/lib/es6/Body.js.map +1 -1
  11. package/lib/es6/DataTable.js +48 -51
  12. package/lib/es6/DataTable.js.map +1 -1
  13. package/lib/es6/Head.js +6 -5
  14. package/lib/es6/Head.js.map +1 -1
  15. package/lib/es6/style/data-table.shadow.css +0 -19
  16. package/lib/esm/Body.mjs +344 -237
  17. package/lib/esm/DataTable.mjs +476 -336
  18. package/lib/esm/Head.mjs +318 -206
  19. package/lib/esm/index.mjs +6 -6
  20. package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +30 -30
  21. package/lib/esm/translations/de.json.mjs +5 -4
  22. package/lib/esm/translations/en.json.mjs +5 -4
  23. package/lib/esm/translations/es.json.mjs +5 -4
  24. package/lib/esm/translations/fr.json.mjs +5 -4
  25. package/lib/esm/translations/it.json.mjs +5 -4
  26. package/lib/esm/translations/ja.json.mjs +5 -4
  27. package/lib/esm/translations/ko.json.mjs +5 -4
  28. package/lib/esm/translations/nl.json.mjs +5 -4
  29. package/lib/esm/translations/pl.json.mjs +5 -4
  30. package/lib/esm/translations/pt.json.mjs +5 -4
  31. package/lib/esm/translations/sv.json.mjs +5 -4
  32. package/lib/esm/translations/tr.json.mjs +5 -4
  33. package/lib/esm/translations/vi.json.mjs +5 -4
  34. package/lib/esm/translations/zh.json.mjs +5 -4
  35. package/lib/esm/utils.mjs +44 -29
  36. package/lib/types/Body.d.ts +1 -1
  37. package/package.json +5 -8
package/lib/esm/Head.mjs CHANGED
@@ -1,257 +1,369 @@
1
- import P from "@babel/runtime/helpers/esm/objectSpread2";
2
- import F from "@babel/runtime/helpers/esm/slicedToArray";
3
- import L from "@babel/runtime/helpers/esm/classCallCheck";
4
- import j from "@babel/runtime/helpers/esm/createClass";
5
- import m from "@babel/runtime/helpers/esm/assertThisInitialized";
6
- import G from "@babel/runtime/helpers/esm/inherits";
7
- import U from "@babel/runtime/helpers/esm/createSuper";
8
- import p from "@babel/runtime/helpers/esm/defineProperty";
9
- import { sstyled as z, assignProps as q, Component as J } from "@semcore/core";
10
- import n from "react";
11
- import { ScreenReaderOnly as Q, Flex as X, Box as D } from "@semcore/flex-box";
12
- import _, { hideScrollBarsFromScreenReadersContext as Y } from "@semcore/scroll-area";
13
- import Z from "@semcore/icon/SortDesc/m";
14
- import ee from "@semcore/icon/SortAsc/m";
15
- import { callAllEventHandlers as A } from "@semcore/utils/lib/assignProps";
16
- import { flattenColumns as B, getFixedStyle as te, getScrollOffsetValue as re } from "./utils.mjs";
17
- import ie from "@semcore/utils/lib/logger";
18
- import { setRef as O } from "@semcore/utils/lib/ref";
19
- import { getFocusableIn as V } from "@semcore/utils/lib/focus-lock/getFocusableIn";
20
- var k = 20, ae = {
21
- desc: Z,
22
- asc: ee
23
- }, oe = {
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/core/lib/utils/assignProps";
16
+ import { flattenColumns, getFixedStyle, getScrollOffsetValue } from "./utils.mjs";
17
+ import logger from "@semcore/core/lib/utils/logger";
18
+ import { setRef } from "@semcore/core/lib/utils/ref";
19
+ import { getFocusableIn } from "@semcore/core/lib/utils/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
- }, N = {
28
+ };
29
+ var displayContents = {
27
30
  display: "contents"
28
31
  };
29
- function M(R) {
30
- var x = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, y = parseFloat(R);
31
- return Number.isNaN(y) && (y = x), Math.round(y);
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 ne = /* @__PURE__ */ function(R) {
34
- G(y, R);
35
- var x = U(y);
36
- function y() {
37
- var i;
38
- L(this, y);
39
- for (var t = arguments.length, s = new Array(t), l = 0; l < t; l++)
40
- s[l] = arguments[l];
41
- return i = x.call.apply(x, [this].concat(s)), p(m(i), "columns", []), p(m(i), "headCellMap", /* @__PURE__ */ new Map()), p(m(i), "lockedCell", [null, !1]), p(m(i), "sortWrapperRefs", /* @__PURE__ */ new Map()), p(m(i), "defaultWidths", /* @__PURE__ */ new Map()), p(m(i), "handleKeyDown", function(e) {
42
- if (e.currentTarget === i.lockedCell[0]) {
43
- var r = Array.from(i.lockedCell[0].children).flatMap(function(c) {
44
- return V(c);
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 (i.lockedCell[1]) {
60
+ if (_this.lockedCell[1]) {
47
61
  if (e.key === "Escape") {
48
- var a;
49
- (a = i.lockedCell[0]) === null || a === void 0 || a.focus(), i.lockedCell[1] = !1;
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") && e.stopPropagation(), e.key === "Tab") {
52
- if (e.target === r[0] && e.shiftKey) {
53
- var o;
54
- (o = r[r.length - 1]) === null || o === void 0 || o.focus(), e.preventDefault();
55
- } else if (e.target === r[r.length - 1] && !e.shiftKey) {
56
- var d;
57
- (d = r[0]) === null || d === void 0 || d.focus(), e.preventDefault();
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 h;
62
- i.lockedCell[1] = !0, (h = r[0]) === null || h === void 0 || h.focus();
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 v;
65
- (v = i.lockedCell[0]) === null || v === void 0 || v.setAttribute("inert", "");
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
- }), p(m(i), "onFocusCell", function(e) {
89
+ });
90
+ _defineProperty(_assertThisInitialized(_this), "onFocusCell", function(e) {
69
91
  if (e.target === e.currentTarget) {
70
- var r = Array.from(e.currentTarget.children).flatMap(function(a) {
71
- return V(a);
92
+ var focusableChildren = Array.from(e.currentTarget.children).flatMap(function(node) {
93
+ return getFocusableIn(node);
72
94
  });
73
- r.length === 1 ? r[0].focus() : r.length > 1 && (i.lockedCell = [e.currentTarget, !1]);
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
- }), p(m(i), "bindHandlerSortClick", function(e) {
76
- return function(r) {
77
- i.asProps.$onSortClick(e, r);
101
+ });
102
+ _defineProperty(_assertThisInitialized(_this), "bindHandlerSortClick", function(name) {
103
+ return function(event) {
104
+ _this.asProps.$onSortClick(name, event);
78
105
  };
79
- }), p(m(i), "bindHandlerKeyDown", function(e) {
80
- return function(r) {
81
- (r.key === "Enter" || r.key === " ") && (r.preventDefault(), i.asProps.$onSortClick(e, r));
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
- }), p(m(i), "makeSortRefHandler", function(e) {
84
- return function(r) {
85
- r && i.sortWrapperRefs.set(r, e);
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
- }), p(m(i), "makeColumnRefHandler", function(e, r) {
88
- return function(a) {
89
- if (O(e.props.ref, a), i.headCellMap.set(r, a), e.props.forwardRef && O(e.props.forwardRef, a), a && a.getAttribute("scope") === "col" && !i.defaultWidths.has(a)) {
90
- var o = window.getComputedStyle(a);
91
- i.defaultWidths.set(a, {
92
- minWidth: M(o.getPropertyValue("min-width")),
93
- computedWidth: M(o.getPropertyValue("width")),
94
- maxWidth: M(o.getPropertyValue("max-width")) || null,
95
- useForRecalculation: !!e.props.sortSizeRecalculation
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
- }), p(m(i), "changeMaxNodeWidth", function(e, r) {
100
- var a = 0, o = null, d = [];
101
- i.defaultWidths.forEach(function(c, f) {
102
- c.computedWidth > a && f !== r && (o = f, a = c.computedWidth), c.useForRecalculation && d.push(f);
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 h = function(f, g) {
105
- var S, u, W = (S = i.defaultWidths.get(f)) === null || S === void 0 ? void 0 : S.computedWidth, b = (u = i.defaultWidths.get(f)) === null || u === void 0 ? void 0 : u.minWidth;
106
- if (W) {
107
- var C = W - g;
108
- f.style.setProperty("max-width", "".concat(C, "px")), b && f.style.setProperty("min-width", "min(".concat(C, "px, ").concat(b, "px)"));
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 (d.length > 0) {
112
- var v = e / d.length;
113
- d.forEach(function(c) {
114
- h(c, v);
167
+ if (recalculatedNodes.length > 0) {
168
+ var diffPart = diff / recalculatedNodes.length;
169
+ recalculatedNodes.forEach(function(node2) {
170
+ setNodeMinWidth(node2, diffPart);
115
171
  });
116
- } else o !== null && h(o, e);
117
- }), p(m(i), "backToColumnDefaults", function(e) {
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
- }), i;
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
- return j(y, [{
219
+ _createClass(Head2, [{
141
220
  key: "sortableColumnDescribeId",
142
- value: function() {
143
- var t = this.asProps.uid;
144
- return "".concat(t, "-column-sortable-describer");
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 t = this, s = null;
150
- this.columns.forEach(function(l) {
151
- var e = l.props, r = e.changeSortSize, a = e.ref;
152
- l.active && r && a.current && (s = a.current), a.current && t.backToColumnDefaults(a.current);
153
- }), s && this.calculateActiveColumnMinWidth(s);
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(t, s) {
158
- var l = this;
159
- return t.map(function(e) {
160
- return l.renderColumn(e, s);
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(t, s) {
166
- var l, e, r = this.asProps, a = r.styles, o = r.use, d = r.hidden, h = r.uid, v = X, c = D, f = "div", g = ae[t.sortDirection], S = t.sortable && t.active ? oe[t.sortDirection] : void 0, u = ((e = t.columns) === null || e === void 0 ? void 0 : e.length) > 0, W = u ? B(t.columns).length : 1, b = te(t, this.columns), C = F(b, 2), H = C[0], I = C[1], E = P({
167
- flexBasis: t.props.flex === void 0 && "".concat(s * W, "%")
168
- }, t.props.style);
169
- H !== void 0 && I !== void 0 && (E[H] = I), t.setVar || (E.flexBasis = "var(".concat(t.varWidth, ")"));
170
- var w = [];
171
- if (t.sortable && !t.active && w.push(this.sortableColumnDescribeId()), t.parentColumns.length > 0) {
172
- var K = t.parentColumns[0].name;
173
- w.push("igc-table-".concat(h, "-").concat(K, "-group"));
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 T = this.columns.findIndex(function($) {
176
- return $.name === t.name;
281
+ var index = this.columns.findIndex(function(flattenCol) {
282
+ return flattenCol.name === column.name;
177
283
  });
178
- return l = z(a), /* @__PURE__ */ n.createElement(v, l.cn("SColumn", P(P({
179
- role: u ? void 0 : "columnheader",
180
- scope: u ? "colgroup" : "col",
181
- key: t.name,
182
- id: "igc-table-".concat(h, "-").concat(t.name),
183
- use: o,
184
- fixed: t.fixed,
185
- resizable: t.resizable,
186
- sortable: t.sortable,
187
- borderLeft: u ? !1 : t.borderLeft,
188
- borderRight: u ? !1 : t.borderRight,
189
- active: u ? !1 : t.active,
190
- group: u,
191
- tabIndex: u ? void 0 : -1,
192
- __excludeProps: ["hidden"]
193
- }, t.props), {}, {
194
- ref: this.makeColumnRefHandler(t, T),
195
- onClick: A(t.props.onClick, t.sortable ? this.bindHandlerSortClick(t.name) : void 0),
196
- onKeyDown: A(t.props.onKeyDown, t.sortable ? this.bindHandlerKeyDown(t.name) : void 0, this.handleKeyDown),
197
- style: E,
198
- hidden: d,
199
- "aria-sort": S,
200
- "aria-colindex": u ? void 0 : T + 1,
201
- onFocus: this.onFocusCell,
202
- "aria-describedby": w.length > 0 ? w.join(" ") : void 0
203
- })), u ? /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(v, l.cn("SColumn", {
204
- id: "igc-table-".concat(h, "-").concat(t.name, "-group"),
205
- groupHead: !0,
206
- use: o,
207
- active: t.active,
208
- borderLeft: t.borderLeft,
209
- borderRight: t.borderRight
210
- }), /* @__PURE__ */ n.createElement("div", l.cn("div", {}), t.props.children)), /* @__PURE__ */ n.createElement(c, l.cn("SHead", {}), this.renderColumns(t.columns, 100 / W))) : /* @__PURE__ */ n.createElement(n.Fragment, null, t.props.children, t.sortable ? /* @__PURE__ */ n.createElement(f, l.cn("SSortWrapper", {
211
- ref: this.makeSortRefHandler(t.active)
212
- }), /* @__PURE__ */ n.createElement(g, l.cn("SSortIcon", {}))) : null));
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
+ "innerOutline": true
310
+ })), isGroup ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SColumn, _ref2.cn("SColumn", {
311
+ "id": "igc-table-".concat(uid, "-").concat(column.name, "-group"),
312
+ "groupHead": true,
313
+ "use": use,
314
+ "active": column.active,
315
+ "borderLeft": column.borderLeft,
316
+ "borderRight": column.borderRight
317
+ }), /* @__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", {
318
+ "ref": this.makeSortRefHandler(column.active)
319
+ }), /* @__PURE__ */ React.createElement(SSortIcon, _ref2.cn("SSortIcon", {}))) : null));
213
320
  }
214
321
  }, {
215
322
  key: "render",
216
- value: function() {
217
- var t = this.asProps, s, l = D, e = D, r = this.asProps, a = r.Children, o = r.styles, d = r.columnsChildren, h = r.onResize, v = r.$scrollRef, c = r.sticky, f = r.withScrollBar, g = r.animationsDisabled, S = r.getI18nText;
218
- this.columns = B(d);
219
- var u = re(this.columns), W = F(u, 2), b = W[0], C = W[1];
220
- return ie.warn(c, "'sticky' property is deprecated, use '<Sticky/>' wrapper", this.asProps["data-ui-name"] || y.displayName), s = z(o), /* @__PURE__ */ n.createElement(Y.Provider, {
221
- value: !0
222
- }, /* @__PURE__ */ n.createElement(e, s.cn("SHeadWrapper", {
223
- sticky: c,
224
- animationsDisabled: g
225
- }), /* @__PURE__ */ n.createElement(_, s.cn("ScrollArea", {
226
- leftOffset: b,
227
- rightOffset: C,
228
- shadow: !0,
229
- onResize: h
230
- }), /* @__PURE__ */ n.createElement(_.Container, {
231
- ref: v,
323
+ value: function render() {
324
+ var _ref = this.asProps, _ref3;
325
+ var SHead = Box;
326
+ var SHeadWrapper = Box;
327
+ 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;
328
+ this.columns = flattenColumns(columnsChildren);
329
+ var _getScrollOffsetValue = getScrollOffsetValue(this.columns), _getScrollOffsetValue2 = _slicedToArray(_getScrollOffsetValue, 2), offsetLeftSum = _getScrollOffsetValue2[0], offsetRightSum = _getScrollOffsetValue2[1];
330
+ logger.warn(sticky, "'sticky' property is deprecated, use '<Sticky/>' wrapper", this.asProps["data-ui-name"] || Head2.displayName);
331
+ return _ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(hideScrollBarsFromScreenReadersContext.Provider, {
332
+ value: true
333
+ }, /* @__PURE__ */ React.createElement(SHeadWrapper, _ref3.cn("SHeadWrapper", {
334
+ "sticky": sticky,
335
+ "animationsDisabled": animationsDisabled
336
+ }), /* @__PURE__ */ React.createElement(ScrollArea, _ref3.cn("ScrollArea", {
337
+ "leftOffset": offsetLeftSum,
338
+ "rightOffset": offsetRightSum,
339
+ "shadow": true,
340
+ "onResize": onResize
341
+ }), /* @__PURE__ */ React.createElement(ScrollArea.Container, {
342
+ ref: $scrollRef,
232
343
  role: "rowgroup",
233
344
  tabIndex: -1,
234
345
  zIndex: 2
235
- }, /* @__PURE__ */ n.createElement(l, s.cn("SHead", P({}, q({
236
- role: "row",
237
- __excludeProps: ["hidden"]
238
- }, t))), this.renderColumns(d, 100 / this.columns.length))), !!f && /* @__PURE__ */ n.createElement("div", s.cn("div", {
239
- style: N
240
- }), /* @__PURE__ */ n.createElement("div", s.cn("div", {
241
- style: N
242
- }), /* @__PURE__ */ n.createElement("div", s.cn("div", {
243
- style: N
244
- }), /* @__PURE__ */ n.createElement(_.Bar, {
346
+ }, /* @__PURE__ */ React.createElement(SHead, _ref3.cn("SHead", _objectSpread({}, assignProps({
347
+ "role": "row",
348
+ "__excludeProps": ["hidden"]
349
+ }, _ref))), this.renderColumns(columnsChildren, 100 / this.columns.length))), Boolean(withScrollBar) && /* @__PURE__ */ React.createElement("div", _ref3.cn("div", {
350
+ "style": displayContents
351
+ }), /* @__PURE__ */ React.createElement("div", _ref3.cn("div", {
352
+ "style": displayContents
353
+ }), /* @__PURE__ */ React.createElement("div", _ref3.cn("div", {
354
+ "style": displayContents
355
+ }), /* @__PURE__ */ React.createElement(ScrollArea.Bar, {
245
356
  orientation: "horizontal"
246
- }))))), a.origin, /* @__PURE__ */ n.createElement(Q, s.cn("ScreenReaderOnly", {
247
- "aria-hidden": !0,
248
- id: this.sortableColumnDescribeId()
249
- }), S == null ? void 0 : S("sortableColumn"))));
357
+ }))))), Children.origin, /* @__PURE__ */ React.createElement(ScreenReaderOnly, _ref3.cn("ScreenReaderOnly", {
358
+ "aria-hidden": true,
359
+ "id": this.sortableColumnDescribeId()
360
+ }), getI18nText === null || getI18nText === void 0 ? void 0 : getI18nText("sortableColumn"))));
250
361
  }
251
- }]), y;
252
- }(J);
253
- p(ne, "displayName", void 0);
362
+ }]);
363
+ return Head2;
364
+ }(Component);
365
+ _defineProperty(Head, "displayName", void 0);
254
366
  export {
255
- k as SORT_ICON_WIDTH,
256
- ne as default
367
+ SORT_ICON_WIDTH,
368
+ Head as default
257
369
  };
package/lib/esm/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { ROW_GROUP as l, default as r, wrapDataTable as t, wrapDataTableCell as p, wrapDataTableRow as w } from "./DataTable.mjs";
1
+ import { ROW_GROUP, default as default2, wrapDataTable, wrapDataTableCell, wrapDataTableRow } from "./DataTable.mjs";
2
2
  export {
3
- l as ROW_GROUP,
4
- r as default,
5
- t as wrapDataTable,
6
- p as wrapDataTableCell,
7
- w as wrapDataTableRow
3
+ ROW_GROUP,
4
+ default2 as default,
5
+ wrapDataTable,
6
+ wrapDataTableCell,
7
+ wrapDataTableRow
8
8
  };