@semcore/data-table 4.49.0-prerelease.1 → 4.49.0-prerelease.12

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 CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
- ## [4.49.0] - 2025-02-27
5
+ ## [4.49.0] - 2025-03-14
6
6
 
7
- ### Changed
7
+ ### Added
8
8
 
9
- - Version minor update due to children dependencies update (`@semcore/flex-box` [5.40.1 ~> 5.41.0], `@semcore/icon` [4.57.1 ~> 4.58.0], `@semcore/utils` [4.45.1 ~> 4.47.0], `@semcore/core` [2.38.1 ~> 2.39.0]).
9
+ - Build for ESM.
10
10
 
11
11
  ## [4.48.1] - 2025-02-05
12
12
 
@@ -0,0 +1,320 @@
1
+ import oe from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ import D from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import ue from "@babel/runtime/helpers/esm/toConsumableArray";
4
+ import ie from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
5
+ import ae from "@babel/runtime/helpers/esm/slicedToArray";
6
+ import j from "@babel/runtime/helpers/esm/typeof";
7
+ import he from "@babel/runtime/helpers/esm/classCallCheck";
8
+ import ge from "@babel/runtime/helpers/esm/createClass";
9
+ import p from "@babel/runtime/helpers/esm/assertThisInitialized";
10
+ import me from "@babel/runtime/helpers/esm/inherits";
11
+ import pe from "@babel/runtime/helpers/esm/createSuper";
12
+ import R from "@babel/runtime/helpers/esm/defineProperty";
13
+ import { sstyled as Re } from "@semcore/utils/lib/core/index";
14
+ import { sstyled as M, assignProps as we, Component as ye } from "@semcore/core";
15
+ import s from "react";
16
+ import { Flex as Se, Box as K } from "@semcore/flex-box";
17
+ import W, { hideScrollBarsFromScreenReadersContext as ze } from "@semcore/scroll-area";
18
+ import { getFixedStyle as _e, getScrollOffsetValue as He } from "./utils.mjs";
19
+ import G, { callAllEventHandlers as ne } from "@semcore/utils/lib/assignProps";
20
+ import N from "@semcore/utils/lib/rafTrottle";
21
+ import { forkRef as Oe } from "@semcore/utils/lib/ref";
22
+ import be from "@semcore/utils/lib/canUseDOM";
23
+ import { SORT_ICON_WIDTH as Pe } from "./Head.mjs";
24
+ import { getFocusableIn as le } from "@semcore/utils/lib/focus-lock/getFocusableIn";
25
+ var Ee = ["childrenPropsGetter"], xe = ["childrenPropsGetter"], Ae = (
26
+ /*__reshadow_css_start__*/
27
+ (Re.insert(
28
+ /*__inner_css_start__*/
29
+ ".___SShadowHorizontal_ezz95_gg_:after,.___SShadowHorizontal_ezz95_gg_:before,.___SShadowVertical_ezz95_gg_:after,.___SShadowVertical_ezz95_gg_:before{z-index:1}",
30
+ "ezz95_gg_"
31
+ ), {
32
+ __SShadowHorizontal: "___SShadowHorizontal_ezz95_gg_",
33
+ __SShadowVertical: "___SShadowVertical_ezz95_gg_"
34
+ })
35
+ ), ke = process.env.NODE_ENV === "test", Ie = function(V) {
36
+ var x = V.flat(20);
37
+ return Object.fromEntries(x.map(function(r) {
38
+ return [r.name, r.data];
39
+ }));
40
+ }, J = {
41
+ display: "contents"
42
+ }, or = /* @__PURE__ */ function(Q) {
43
+ me(x, Q);
44
+ var V = pe(x);
45
+ function x() {
46
+ var r;
47
+ he(this, x);
48
+ for (var l = arguments.length, i = new Array(l), c = 0; c < l; c++)
49
+ i[c] = arguments[c];
50
+ return r = V.call.apply(V, [this].concat(i)), R(p(r), "state", {
51
+ rowHeight: void 0,
52
+ scrollAreaHeight: void 0,
53
+ scrollOffset: 0
54
+ }), R(p(r), "scrollContainerRef", /* @__PURE__ */ s.createRef()), R(p(r), "firstRowRef", /* @__PURE__ */ s.createRef()), R(p(r), "firstRowResizeObserver", null), R(p(r), "lockedCell", [null, !1]), R(p(r), "getRowHeight", function() {
55
+ var e = r.asProps.virtualScroll, o = j(e) === "object" && (e == null ? void 0 : e.rowHeight);
56
+ return o || r.state.rowHeight;
57
+ }), R(p(r), "handleKeyDown", function(e) {
58
+ if (e.currentTarget === r.lockedCell[0]) {
59
+ var o = Array.from(r.lockedCell[0].children).flatMap(function(g) {
60
+ return le(g);
61
+ });
62
+ if (r.lockedCell[1]) {
63
+ if (e.key === "Escape") {
64
+ var t;
65
+ (t = r.lockedCell[0]) === null || t === void 0 || t.focus(), r.lockedCell[1] = !1;
66
+ }
67
+ if (e.key.startsWith("Arrow") && (e.stopPropagation(), e.preventDefault()), e.key === "Tab") {
68
+ if (e.target === o[0] && e.shiftKey) {
69
+ var n;
70
+ (n = o[o.length - 1]) === null || n === void 0 || n.focus(), e.preventDefault();
71
+ } else if (e.target === o[o.length - 1] && !e.shiftKey) {
72
+ var a;
73
+ (a = o[0]) === null || a === void 0 || a.focus(), e.preventDefault();
74
+ }
75
+ e.stopPropagation();
76
+ }
77
+ } else if (e.key === "Enter") {
78
+ var f;
79
+ e.preventDefault(), e.stopPropagation(), r.lockedCell[1] = !0, (f = o[0]) === null || f === void 0 || f.focus();
80
+ }
81
+ }
82
+ }), R(p(r), "onFocusCell", function(e) {
83
+ if (e.target === e.currentTarget && e.target.matches(":focus-visible")) {
84
+ var o = Array.from(e.currentTarget.children).flatMap(function(t) {
85
+ return le(t);
86
+ });
87
+ o.length === 1 ? o[0].focus() : o.length > 1 && (r.lockedCell = [e.currentTarget, !1]);
88
+ }
89
+ }), R(p(r), "handleFirstRowResize", N(function(e) {
90
+ var o = e[0].contentRect, t = o.height;
91
+ r.setState(function(n) {
92
+ return n.rowHeight === t ? n : {
93
+ rowHeight: t
94
+ };
95
+ });
96
+ })), R(p(r), "handleScrollAreaResize", N(function(e) {
97
+ var o = r.asProps.virtualScroll;
98
+ if (o) {
99
+ var t = e[0].contentRect, n = t.height;
100
+ r.setState(function(a) {
101
+ return a.scrollAreaHeight === n ? a : {
102
+ scrollAreaHeight: n
103
+ };
104
+ });
105
+ }
106
+ })), R(p(r), "handleScrollAreaScroll", function(e) {
107
+ var o = e.target, t = o.scrollTop, n = r.asProps.virtualScroll;
108
+ n && r.setState(function(a) {
109
+ return a.scrollOffset === t ? a : {
110
+ scrollOffset: t
111
+ };
112
+ });
113
+ }), R(p(r), "setupRowSizeObserver", function() {
114
+ r.firstRowRef.current && r.asProps.virtualScroll && be() && (r.firstRowResizeObserver = new ResizeObserver(r.handleFirstRowResize), r.firstRowResizeObserver.observe(r.firstRowRef.current));
115
+ }), R(p(r), "handleBodyTransitionEnd", N(function() {
116
+ r.forceUpdate();
117
+ })), r;
118
+ }
119
+ return ge(x, [{
120
+ key: "renderCells",
121
+ value: function(l, i, c) {
122
+ var e = this, o = Se, t = this.asProps, n = t.styles, a = t.columns, f = t.use, g = t.uid;
123
+ return l.map(function(d, y) {
124
+ if (Array.isArray(d)) {
125
+ var S, A = "div";
126
+ return S = M(n), /* @__PURE__ */ s.createElement(A, S.cn("SGroupCell", {
127
+ key: "".concat(y),
128
+ "data-ui-name": "group-cell"
129
+ }), e.renderRows(d, !0));
130
+ } else {
131
+ var z, _, m, u, w, H, b, P, E = d.name.split("/"), k = E[0], I = E[E.length - 1], O = a.find(function(h) {
132
+ return h.name === k;
133
+ }), T = a.find(function(h) {
134
+ return h.name === I;
135
+ }), v = a.find(function(h) {
136
+ return h.name === d.name;
137
+ }), L = _e(d, a), F = ae(L, 2), X = F[0], Y = F[1], se = (_ = v == null ? void 0 : v.parentColumns.map(function(h) {
138
+ return h.name;
139
+ })) !== null && _ !== void 0 ? _ : [], U = (Array.isArray(d.cssVar) ? d.cssVar : [d.cssVar]).map(function(h) {
140
+ return "var(".concat(h, ")");
141
+ }), de = v == null || (m = v.props) === null || m === void 0 || (u = m.ref.current) === null || u === void 0 ? void 0 : u.style.getPropertyValue("min-width"), q = v == null || (w = v.props) === null || w === void 0 || (H = w.ref.current) === null || H === void 0 ? void 0 : H.style.getPropertyValue("max-width"), C = {
142
+ name: d.name,
143
+ children: /* @__PURE__ */ s.createElement(s.Fragment, null, d.data),
144
+ justifyContent: v == null || (b = v.props) === null || b === void 0 ? void 0 : b.justifyContent,
145
+ alignItems: v == null || (P = v.props) === null || P === void 0 ? void 0 : P.alignItems,
146
+ borderLeft: O == null ? void 0 : O.borderLeft,
147
+ borderRight: T == null ? void 0 : T.borderRight,
148
+ style: {
149
+ width: U.length === 1 ? U[0] : "calc(".concat(U.join(" + "), ")"),
150
+ minWidth: de,
151
+ maxWidth: q && v !== null && v !== void 0 && v.sortable ? "calc(".concat(Pe, "px + ").concat(q, ")") : q
152
+ }
153
+ };
154
+ X !== void 0 && Y !== void 0 && (C.style[X] = Y);
155
+ var B = ie(d.cellPropsLayers || []), Z;
156
+ try {
157
+ for (B.s(); !(Z = B.n()).done; ) {
158
+ var $ = Z.value, ee = $.childrenPropsGetter, ve = ee === void 0 ? function(h) {
159
+ return h;
160
+ } : ee, fe = oe($, Ee), re = G(fe, C);
161
+ C = G(ve(re, i, c), re);
162
+ }
163
+ } catch (h) {
164
+ B.e(h);
165
+ } finally {
166
+ B.f();
167
+ }
168
+ var ce = [d.name].concat(ue(se)).filter(Boolean).map(function(h) {
169
+ return "igc-table-".concat(g, "-").concat(h);
170
+ }), te = E.length;
171
+ return z = M(n), /* @__PURE__ */ s.createElement(o, z.cn("SCell", D(D({
172
+ key: d.name,
173
+ role: "gridcell",
174
+ headers: ce.join(" "),
175
+ __excludeProps: ["data"]
176
+ }, C), {}, {
177
+ fixed: d.fixed,
178
+ theme: C.theme,
179
+ use: f,
180
+ borderLeft: C.borderLeft,
181
+ borderRight: C.borderRight,
182
+ tabIndex: -1,
183
+ onKeyDown: e.handleKeyDown,
184
+ onFocus: e.onFocusCell,
185
+ "aria-colindex": y + 1,
186
+ "aria-colspan": te === 1 ? void 0 : te
187
+ })));
188
+ }
189
+ }, []);
190
+ }
191
+ }, {
192
+ key: "renderRow",
193
+ value: function(l, i) {
194
+ var c, e = i.dataIndex, o = i.topOffset, t = i.nested, n = t === void 0 ? !1 : t, a = K, f = this.asProps, g = f.styles, d = f.rowPropsLayers, y = f.uniqueKey, S = f.virtualScroll, A = j(S) === "object" && (S == null ? void 0 : S.rowHeight), z = l.flatRowData || Ie(l), _ = z[y] ? String(z[y]) : "row_".concat(e), m = e === 0 && !A, u = {
195
+ children: this.renderCells(l, z, e),
196
+ theme: void 0,
197
+ active: void 0,
198
+ positioned: o !== void 0,
199
+ top: o,
200
+ ref: m ? this.firstRowRef : void 0,
201
+ key: _,
202
+ "aria-rowindex": n ? void 0 : e + 2
203
+ }, w = ie(d), H;
204
+ try {
205
+ for (w.s(); !(H = w.n()).done; ) {
206
+ var b = H.value, P = b.childrenPropsGetter, E = P === void 0 ? function(O) {
207
+ return O;
208
+ } : P, k = oe(b, xe), I = G(k, u);
209
+ u = G(E(I, z, e), I);
210
+ }
211
+ } catch (O) {
212
+ w.e(O);
213
+ } finally {
214
+ w.f();
215
+ }
216
+ return c = M(g), /* @__PURE__ */ s.createElement(a, c.cn("SRow", D({
217
+ "data-nested": n.toString(),
218
+ role: n ? void 0 : "row",
219
+ __excludeProps: ["data"]
220
+ }, u)));
221
+ }
222
+ }, {
223
+ key: "renderRows",
224
+ value: function(l) {
225
+ var i = this, c = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
226
+ return l.map(function(e, o) {
227
+ return i.renderRow(e, {
228
+ dataIndex: o,
229
+ nested: c
230
+ });
231
+ });
232
+ }
233
+ }, {
234
+ key: "renderVirtualizedRows",
235
+ value: function(l) {
236
+ var i, c = this;
237
+ if (l.length === 0) return [];
238
+ var e = this.asProps.virtualScroll, o = this.state, t = o.scrollOffset, n = o.scrollAreaHeight, a = this.getRowHeight(), f = (i = j(e) === "object" ? e == null ? void 0 : e.tollerance : 2) !== null && i !== void 0 ? i : 2, g = Math.max(Math.floor(t / a) - f, 0), d = Math.min(Math.ceil((t + n) / a) + f, l.length), y = j(e) === "object" && (e == null ? void 0 : e.rowHeight), S = !y, A = {
239
+ cells: l[0],
240
+ dataIndex: 0,
241
+ topOffset: 0
242
+ }, z = a !== void 0 ? l.slice(g, d) : [], _ = z.map(function(m, u) {
243
+ return {
244
+ cells: m,
245
+ dataIndex: g + u,
246
+ topOffset: a * (g + u)
247
+ };
248
+ });
249
+ return S && g !== 0 && _.unshift(A), _.map(function(m) {
250
+ var u = m.cells, w = m.dataIndex, H = m.topOffset;
251
+ return c.renderRow(u, {
252
+ dataIndex: w,
253
+ topOffset: H,
254
+ nested: !1
255
+ });
256
+ });
257
+ }
258
+ }, {
259
+ key: "componentWillUnmount",
260
+ value: function() {
261
+ var l;
262
+ (l = this.firstRowResizeObserver) === null || l === void 0 || l.disconnect();
263
+ }
264
+ }, {
265
+ key: "render",
266
+ value: function() {
267
+ var l = this.asProps, i, c = K, e = K, o = K, t = this.asProps, n = t.Children, a = t.styles, f = t.rows, g = t.columns, d = t.$scrollRef, y = t.virtualScroll, S = t.onResize, A = t.onScroll, z = t.disabledScroll, _ = t.renderRows, m = t.animationsDisabled, u = t.scrollContainerRef, w = g.reduce(function(v, L) {
268
+ var F = L.width;
269
+ return v + F;
270
+ }, 0) > 0 || ke, H = He(g), b = ae(H, 2), P = b[0], E = b[1], k = this.getRowHeight(), I = k !== void 0 && y ? k * f.length : void 0;
271
+ y && w && !k && requestAnimationFrame(this.setupRowSizeObserver);
272
+ var O = (i = M(a), /* @__PURE__ */ s.createElement(c, i.cn("SBody", D({}, we({
273
+ animationsDisabled: m,
274
+ onTransitionEnd: this.handleBodyTransitionEnd
275
+ }, l))), _ ? _({
276
+ rows: f,
277
+ columns: g,
278
+ renderRow: this.renderRow.bind(this)
279
+ }) || null : /* @__PURE__ */ s.createElement(s.Fragment, null, I ? /* @__PURE__ */ s.createElement(o, i.cn("SHeightHold", {
280
+ hMin: I,
281
+ "aria-hidden": !0
282
+ })) : null, y ? this.renderVirtualizedRows(f) : this.renderRows(f))));
283
+ if (z)
284
+ return /* @__PURE__ */ s.createElement(e, null, O);
285
+ var T = [d, this.scrollContainerRef];
286
+ return u && T.push(u), /* @__PURE__ */ s.createElement(ze.Provider, {
287
+ value: !0
288
+ }, /* @__PURE__ */ s.createElement(e, i.cn("SBodyWrapper", {}), /* @__PURE__ */ s.createElement(W, i.cn("ScrollArea", {
289
+ shadow: !0,
290
+ leftOffset: P,
291
+ rightOffset: E,
292
+ onResize: ne(S, this.handleScrollAreaResize),
293
+ onScroll: ne(A, this.handleScrollAreaScroll),
294
+ styles: Ae
295
+ }), /* @__PURE__ */ s.createElement(W.Container, {
296
+ ref: Oe.apply(void 0, T),
297
+ role: "rowgroup",
298
+ focusRingTopOffset: "3px",
299
+ tabIndex: -1
300
+ }, O), /* @__PURE__ */ s.createElement("div", i.cn("div", {
301
+ style: J
302
+ }), /* @__PURE__ */ s.createElement("div", i.cn("div", {
303
+ style: J
304
+ }), /* @__PURE__ */ s.createElement("div", i.cn("div", {
305
+ style: J
306
+ }), /* @__PURE__ */ s.createElement(W.Bar, {
307
+ orientation: "horizontal",
308
+ bottom: 0,
309
+ container: this.scrollContainerRef
310
+ }), /* @__PURE__ */ s.createElement(W.Bar, {
311
+ orientation: "vertical",
312
+ w: "12px",
313
+ zIndex: 2
314
+ }))))), n.origin));
315
+ }
316
+ }]), x;
317
+ }(ye);
318
+ export {
319
+ or as default
320
+ };