@semcore/data-table 4.49.0-prerelease.4 → 4.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,257 @@
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 = {
24
+ desc: "descending",
25
+ asc: "ascending"
26
+ }, N = {
27
+ display: "contents"
28
+ };
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
+ }
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);
45
+ });
46
+ if (i.lockedCell[1]) {
47
+ if (e.key === "Escape") {
48
+ var a;
49
+ (a = i.lockedCell[0]) === null || a === void 0 || a.focus(), i.lockedCell[1] = !1;
50
+ }
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();
58
+ }
59
+ }
60
+ } else if (e.key === "Enter") {
61
+ var h;
62
+ i.lockedCell[1] = !0, (h = r[0]) === null || h === void 0 || h.focus();
63
+ } else if (e.key === "Tab") {
64
+ var v;
65
+ (v = i.lockedCell[0]) === null || v === void 0 || v.setAttribute("inert", "");
66
+ }
67
+ }
68
+ }), p(m(i), "onFocusCell", function(e) {
69
+ if (e.target === e.currentTarget) {
70
+ var r = Array.from(e.currentTarget.children).flatMap(function(a) {
71
+ return V(a);
72
+ });
73
+ r.length === 1 ? r[0].focus() : r.length > 1 && (i.lockedCell = [e.currentTarget, !1]);
74
+ }
75
+ }), p(m(i), "bindHandlerSortClick", function(e) {
76
+ return function(r) {
77
+ i.asProps.$onSortClick(e, r);
78
+ };
79
+ }), p(m(i), "bindHandlerKeyDown", function(e) {
80
+ return function(r) {
81
+ (r.key === "Enter" || r.key === " ") && (r.preventDefault(), i.asProps.$onSortClick(e, r));
82
+ };
83
+ }), p(m(i), "makeSortRefHandler", function(e) {
84
+ return function(r) {
85
+ r && i.sortWrapperRefs.set(r, e);
86
+ };
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
+ });
97
+ }
98
+ };
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);
103
+ });
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)"));
109
+ }
110
+ };
111
+ if (d.length > 0) {
112
+ var v = e / d.length;
113
+ d.forEach(function(c) {
114
+ h(c, v);
115
+ });
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));
137
+ }
138
+ }), i;
139
+ }
140
+ return j(y, [{
141
+ key: "sortableColumnDescribeId",
142
+ value: function() {
143
+ var t = this.asProps.uid;
144
+ return "".concat(t, "-column-sortable-describer");
145
+ }
146
+ }, {
147
+ 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);
154
+ }
155
+ }, {
156
+ key: "renderColumns",
157
+ value: function(t, s) {
158
+ var l = this;
159
+ return t.map(function(e) {
160
+ return l.renderColumn(e, s);
161
+ });
162
+ }
163
+ }, {
164
+ 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"));
174
+ }
175
+ var T = this.columns.findIndex(function($) {
176
+ return $.name === t.name;
177
+ });
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));
213
+ }
214
+ }, {
215
+ 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,
232
+ role: "rowgroup",
233
+ tabIndex: -1,
234
+ 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, {
245
+ 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"))));
250
+ }
251
+ }]), y;
252
+ }(J);
253
+ p(ne, "displayName", void 0);
254
+ export {
255
+ k as SORT_ICON_WIDTH,
256
+ ne as default
257
+ };
@@ -0,0 +1,8 @@
1
+ import { ROW_GROUP as l, default as r, wrapDataTable as t, wrapDataTableCell as p, wrapDataTableRow as w } from "./DataTable.mjs";
2
+ export {
3
+ l as ROW_GROUP,
4
+ r as default,
5
+ t as wrapDataTable,
6
+ p as wrapDataTableCell,
7
+ w as wrapDataTableRow
8
+ };
@@ -0,0 +1,33 @@
1
+ import r from "./de.json.mjs";
2
+ import o from "./en.json.mjs";
3
+ import m from "./es.json.mjs";
4
+ import t from "./fr.json.mjs";
5
+ import i from "./it.json.mjs";
6
+ import p from "./ja.json.mjs";
7
+ import f from "./ko.json.mjs";
8
+ import e from "./nl.json.mjs";
9
+ import s from "./pt.json.mjs";
10
+ import a from "./tr.json.mjs";
11
+ import l from "./vi.json.mjs";
12
+ import v from "./zh.json.mjs";
13
+ import d from "./pl.json.mjs";
14
+ import n from "./sv.json.mjs";
15
+ var B = {
16
+ de: r,
17
+ en: o,
18
+ es: m,
19
+ fr: t,
20
+ it: i,
21
+ ja: p,
22
+ ko: f,
23
+ nl: e,
24
+ pt: s,
25
+ tr: a,
26
+ vi: l,
27
+ zh: v,
28
+ pl: d,
29
+ sv: n
30
+ };
31
+ export {
32
+ B as localizedMessages
33
+ };
@@ -0,0 +1,7 @@
1
+ const o = "Sortierbar", t = {
2
+ sortableColumn: o
3
+ };
4
+ export {
5
+ t as default,
6
+ o as sortableColumn
7
+ };
@@ -0,0 +1,7 @@
1
+ const o = "Sortable", t = {
2
+ sortableColumn: o
3
+ };
4
+ export {
5
+ t as default,
6
+ o as sortableColumn
7
+ };
@@ -0,0 +1,7 @@
1
+ const e = "Ordenable", o = {
2
+ sortableColumn: e
3
+ };
4
+ export {
5
+ o as default,
6
+ e as sortableColumn
7
+ };
@@ -0,0 +1,7 @@
1
+ const o = "Triable", l = {
2
+ sortableColumn: o
3
+ };
4
+ export {
5
+ l as default,
6
+ o as sortableColumn
7
+ };
@@ -0,0 +1,7 @@
1
+ const o = "Ordinabile", t = {
2
+ sortableColumn: o
3
+ };
4
+ export {
5
+ t as default,
6
+ o as sortableColumn
7
+ };
@@ -0,0 +1,7 @@
1
+ const o = "分類可能", t = {
2
+ sortableColumn: o
3
+ };
4
+ export {
5
+ t as default,
6
+ o as sortableColumn
7
+ };
@@ -0,0 +1,7 @@
1
+ const o = "정렬 가능", t = {
2
+ sortableColumn: o
3
+ };
4
+ export {
5
+ t as default,
6
+ o as sortableColumn
7
+ };
@@ -0,0 +1,7 @@
1
+ const o = "Sorteerbaar", t = {
2
+ sortableColumn: o
3
+ };
4
+ export {
5
+ t as default,
6
+ o as sortableColumn
7
+ };
@@ -0,0 +1,7 @@
1
+ const o = "Umożliwia sortowanie", l = {
2
+ sortableColumn: o
3
+ };
4
+ export {
5
+ l as default,
6
+ o as sortableColumn
7
+ };
@@ -0,0 +1,7 @@
1
+ const l = "Classificável", o = {
2
+ sortableColumn: l
3
+ };
4
+ export {
5
+ o as default,
6
+ l as sortableColumn
7
+ };
@@ -0,0 +1,7 @@
1
+ const o = "Sorterbar", t = {
2
+ sortableColumn: o
3
+ };
4
+ export {
5
+ t as default,
6
+ o as sortableColumn
7
+ };
@@ -0,0 +1,7 @@
1
+ const a = "Sıralanabilir", l = {
2
+ sortableColumn: a
3
+ };
4
+ export {
5
+ l as default,
6
+ a as sortableColumn
7
+ };
@@ -0,0 +1,7 @@
1
+ const o = "Có thể sắp xếp", t = {
2
+ sortableColumn: o
3
+ };
4
+ export {
5
+ t as default,
6
+ o as sortableColumn
7
+ };
@@ -0,0 +1,7 @@
1
+ const o = "可排序", t = {
2
+ sortableColumn: o
3
+ };
4
+ export {
5
+ t as default,
6
+ o as sortableColumn
7
+ };
@@ -0,0 +1,37 @@
1
+ var g = function(n) {
2
+ return n.reduce(function(t, e) {
3
+ return e.fixed === "left" && (t[0] += e.width), e.fixed === "right" && (t[1] += e.width), t;
4
+ }, [0, 0]);
5
+ }, h = function i(n) {
6
+ return n.reduce(function(t, e) {
7
+ var r = "columns" in e && e.columns.length > 0, a = r ? i(e.columns) : [e];
8
+ return t = t.concat(a), t;
9
+ }, []);
10
+ }, x = function(n, t) {
11
+ var e = n.fixed;
12
+ if (!e) return [void 0, void 0];
13
+ var r = n.name.split("/"), a = {
14
+ left: r[0],
15
+ right: r[r.length - 1]
16
+ }, v = a[e], d = t.findIndex(function(u) {
17
+ return u.name === v;
18
+ });
19
+ if (d === -1) return [void 0, void 0];
20
+ var o = {
21
+ left: 0,
22
+ right: d + 1
23
+ }, s = {
24
+ left: d,
25
+ right: t.length
26
+ }, l = t.slice(o[e], s[e]);
27
+ if (l.length < 1) return [e, 0];
28
+ var f = l.map(function(u) {
29
+ return "var(--".concat(u.name, "_width)");
30
+ });
31
+ return [e, f.length === 1 ? f[0] : "calc(".concat(f.join(" + "), ")")];
32
+ };
33
+ export {
34
+ h as flattenColumns,
35
+ x as getFixedStyle,
36
+ g as getScrollOffsetValue
37
+ };
package/package.json CHANGED
@@ -1,18 +1,23 @@
1
1
  {
2
2
  "name": "@semcore/data-table",
3
3
  "description": "Semrush DataTable Component",
4
- "version": "4.49.0-prerelease.4",
4
+ "version": "4.49.0",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
8
8
  "sideEffects": false,
9
9
  "author": "UI-kit team <ui-kit-team@semrush.com>",
10
10
  "license": "MIT",
11
+ "exports": {
12
+ "require": "./lib/cjs/index.js",
13
+ "import": "./lib/esm/index.mjs",
14
+ "types": "./lib/types/index.d.ts"
15
+ },
11
16
  "dependencies": {
12
- "@semcore/flex-box": "5.41.0-prerelease.4",
13
- "@semcore/icon": "4.58.0-prerelease.4",
14
- "@semcore/scroll-area": "5.45.0-prerelease.4",
15
- "@semcore/utils": "4.47.1-prerelease.4"
17
+ "@semcore/flex-box": "5.41.0",
18
+ "@semcore/icon": "4.60.0",
19
+ "@semcore/scroll-area": "5.45.0",
20
+ "@semcore/utils": "4.48.0"
16
21
  },
17
22
  "devDependencies": {
18
23
  "@types/react": "18.0.21",
@@ -32,7 +37,7 @@
32
37
  "csstype": "3.0.8"
33
38
  },
34
39
  "peerDependencies": {
35
- "@semcore/core": "^2.39.0-prerelease.4",
40
+ "@semcore/core": "^2.17.5",
36
41
  "react": "16.8 - 18",
37
42
  "react-dom": "16.8 - 18"
38
43
  },
@@ -42,6 +47,6 @@
42
47
  "directory": "semcore/data-table"
43
48
  },
44
49
  "scripts": {
45
- "build": "pnpm semcore-builder --source=ts"
50
+ "build": "pnpm semcore-builder --source=ts && pnpm vite build"
46
51
  }
47
52
  }
package/vite.config.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { defineConfig, mergeConfig } from 'vite';
2
+
3
+ import viteConfig from '../../commonVite.config';
4
+
5
+ export default mergeConfig(
6
+ viteConfig,
7
+ defineConfig({
8
+ build: {
9
+ lib: {
10
+ entry: './src/index.ts',
11
+ },
12
+ rollupOptions: {
13
+ external: ['react', 'react-dom', 'react/jsx-runtime', /@babel\/runtime\/*/, /@semcore\/*/],
14
+ },
15
+ },
16
+ }),
17
+ );