@semcore/data-table 16.0.0-prerelease.2 → 16.0.0-prerelease.21

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 (152) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/lib/cjs/components/Body/Body.js +439 -0
  3. package/lib/cjs/components/Body/Body.js.map +1 -0
  4. package/lib/cjs/components/Body/Body.types.js +2 -0
  5. package/lib/cjs/components/Body/Body.types.js.map +1 -0
  6. package/lib/cjs/components/Body/Cell.js +195 -0
  7. package/lib/cjs/components/Body/Cell.js.map +1 -0
  8. package/lib/cjs/components/Body/Cell.types.js +2 -0
  9. package/lib/cjs/components/Body/Cell.types.js.map +1 -0
  10. package/lib/cjs/components/Body/MergedCells.js +29 -0
  11. package/lib/cjs/components/Body/MergedCells.js.map +1 -0
  12. package/lib/cjs/components/Body/Row.js +252 -0
  13. package/lib/cjs/components/Body/Row.js.map +1 -0
  14. package/lib/cjs/components/Body/Row.types.js +4 -0
  15. package/lib/cjs/components/Body/Row.types.js.map +1 -0
  16. package/lib/cjs/components/Body/style.shadow.css +263 -0
  17. package/lib/cjs/components/DataTable/DataTable.js +1025 -0
  18. package/lib/cjs/components/DataTable/DataTable.js.map +1 -0
  19. package/lib/cjs/{types.js → components/DataTable/DataTable.types.js} +1 -1
  20. package/lib/cjs/components/DataTable/DataTable.types.js.map +1 -0
  21. package/lib/cjs/components/DataTable/dataTable.shadow.css +17 -0
  22. package/lib/cjs/components/Head/Column.js +311 -0
  23. package/lib/cjs/components/Head/Column.js.map +1 -0
  24. package/lib/cjs/components/Head/Column.types.js +2 -0
  25. package/lib/cjs/components/Head/Column.types.js.map +1 -0
  26. package/lib/cjs/components/Head/Group.js +116 -0
  27. package/lib/cjs/components/Head/Group.js.map +1 -0
  28. package/lib/cjs/components/Head/Group.type.js +2 -0
  29. package/lib/cjs/components/Head/Group.type.js.map +1 -0
  30. package/lib/cjs/components/Head/Head.js +207 -0
  31. package/lib/cjs/components/Head/Head.js.map +1 -0
  32. package/lib/cjs/components/Head/Head.types.js +2 -0
  33. package/lib/cjs/components/Head/Head.types.js.map +1 -0
  34. package/lib/cjs/components/Head/style.shadow.css +180 -0
  35. package/lib/cjs/index.js +25 -15
  36. package/lib/cjs/index.js.map +1 -1
  37. package/lib/cjs/style/scroll-shadows.shadow.css +45 -5
  38. package/lib/cjs/translations/en.json +6 -1
  39. package/lib/es6/components/Body/Body.js +432 -0
  40. package/lib/es6/components/Body/Body.js.map +1 -0
  41. package/lib/es6/components/Body/Body.types.js +2 -0
  42. package/lib/es6/components/Body/Body.types.js.map +1 -0
  43. package/lib/es6/components/Body/Cell.js +188 -0
  44. package/lib/es6/components/Body/Cell.js.map +1 -0
  45. package/lib/es6/components/Body/Cell.types.js +2 -0
  46. package/lib/es6/components/Body/Cell.types.js.map +1 -0
  47. package/lib/es6/components/Body/MergedCells.js +20 -0
  48. package/lib/es6/components/Body/MergedCells.js.map +1 -0
  49. package/lib/es6/components/Body/Row.js +245 -0
  50. package/lib/es6/components/Body/Row.js.map +1 -0
  51. package/lib/es6/components/Body/Row.types.js +2 -0
  52. package/lib/es6/components/Body/Row.types.js.map +1 -0
  53. package/lib/es6/components/Body/style.shadow.css +263 -0
  54. package/lib/es6/components/DataTable/DataTable.js +1013 -0
  55. package/lib/es6/components/DataTable/DataTable.js.map +1 -0
  56. package/lib/es6/components/DataTable/DataTable.types.js +2 -0
  57. package/lib/es6/components/DataTable/DataTable.types.js.map +1 -0
  58. package/lib/es6/components/DataTable/dataTable.shadow.css +17 -0
  59. package/lib/es6/components/Head/Column.js +304 -0
  60. package/lib/es6/components/Head/Column.js.map +1 -0
  61. package/lib/es6/components/Head/Column.types.js +2 -0
  62. package/lib/es6/components/Head/Column.types.js.map +1 -0
  63. package/lib/es6/components/Head/Group.js +109 -0
  64. package/lib/es6/components/Head/Group.js.map +1 -0
  65. package/lib/es6/components/Head/Group.type.js +2 -0
  66. package/lib/es6/components/Head/Group.type.js.map +1 -0
  67. package/lib/es6/components/Head/Head.js +201 -0
  68. package/lib/es6/components/Head/Head.js.map +1 -0
  69. package/lib/es6/components/Head/Head.types.js +2 -0
  70. package/lib/es6/components/Head/Head.types.js.map +1 -0
  71. package/lib/es6/components/Head/style.shadow.css +180 -0
  72. package/lib/es6/index.js +5 -2
  73. package/lib/es6/index.js.map +1 -1
  74. package/lib/es6/style/scroll-shadows.shadow.css +45 -5
  75. package/lib/es6/translations/en.json +6 -1
  76. package/lib/esm/components/Body/Body.mjs +394 -0
  77. package/lib/esm/components/Body/Cell.mjs +186 -0
  78. package/lib/esm/components/Body/MergedCells.mjs +23 -0
  79. package/lib/esm/components/Body/Row.mjs +224 -0
  80. package/lib/esm/components/Body/style.shadow.css +263 -0
  81. package/lib/esm/components/DataTable/DataTable.mjs +944 -0
  82. package/lib/esm/components/DataTable/dataTable.shadow.css +17 -0
  83. package/lib/esm/components/Head/Column.mjs +296 -0
  84. package/lib/esm/components/Head/Group.mjs +103 -0
  85. package/lib/esm/components/Head/Head.mjs +181 -0
  86. package/lib/esm/components/Head/style.shadow.css +180 -0
  87. package/lib/esm/index.mjs +9 -6
  88. package/lib/esm/style/scroll-shadows.shadow.css +47 -0
  89. package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +30 -30
  90. package/lib/esm/translations/de.json.mjs +5 -4
  91. package/lib/esm/translations/en.json.mjs +10 -4
  92. package/lib/esm/translations/es.json.mjs +5 -4
  93. package/lib/esm/translations/fr.json.mjs +5 -4
  94. package/lib/esm/translations/it.json.mjs +5 -4
  95. package/lib/esm/translations/ja.json.mjs +5 -4
  96. package/lib/esm/translations/ko.json.mjs +5 -4
  97. package/lib/esm/translations/nl.json.mjs +5 -4
  98. package/lib/esm/translations/pl.json.mjs +5 -4
  99. package/lib/esm/translations/pt.json.mjs +5 -4
  100. package/lib/esm/translations/sv.json.mjs +5 -4
  101. package/lib/esm/translations/tr.json.mjs +5 -4
  102. package/lib/esm/translations/vi.json.mjs +5 -4
  103. package/lib/esm/translations/zh.json.mjs +5 -4
  104. package/lib/types/components/Body/Body.d.ts +8 -0
  105. package/lib/types/components/Body/Body.types.d.ts +57 -0
  106. package/lib/types/components/Body/Cell.d.ts +3 -0
  107. package/lib/types/components/Body/Cell.types.d.ts +20 -0
  108. package/lib/types/components/Body/MergedCells.d.ts +14 -0
  109. package/lib/types/components/Body/Row.d.ts +3 -0
  110. package/lib/types/components/Body/Row.types.d.ts +43 -0
  111. package/lib/types/components/DataTable/DataTable.d.ts +13 -0
  112. package/lib/types/components/DataTable/DataTable.types.d.ts +125 -0
  113. package/lib/types/components/Head/Column.d.ts +30 -0
  114. package/lib/types/components/Head/Column.types.d.ts +71 -0
  115. package/lib/types/components/Head/Group.d.ts +15 -0
  116. package/lib/types/components/Head/Group.type.d.ts +16 -0
  117. package/lib/types/components/Head/Head.d.ts +98 -0
  118. package/lib/types/components/Head/Head.types.d.ts +40 -0
  119. package/lib/types/index.d.ts +10 -2
  120. package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +5 -0
  121. package/package.json +11 -6
  122. package/vite.config.ts +0 -3
  123. package/lib/cjs/Body.js +0 -475
  124. package/lib/cjs/Body.js.map +0 -1
  125. package/lib/cjs/DataTable.js +0 -622
  126. package/lib/cjs/DataTable.js.map +0 -1
  127. package/lib/cjs/Head.js +0 -399
  128. package/lib/cjs/Head.js.map +0 -1
  129. package/lib/cjs/style/data-table.shadow.css +0 -394
  130. package/lib/cjs/types.js.map +0 -1
  131. package/lib/cjs/utils.js +0 -57
  132. package/lib/cjs/utils.js.map +0 -1
  133. package/lib/es6/Body.js +0 -468
  134. package/lib/es6/Body.js.map +0 -1
  135. package/lib/es6/DataTable.js +0 -614
  136. package/lib/es6/DataTable.js.map +0 -1
  137. package/lib/es6/Head.js +0 -391
  138. package/lib/es6/Head.js.map +0 -1
  139. package/lib/es6/style/data-table.shadow.css +0 -394
  140. package/lib/es6/types.js +0 -2
  141. package/lib/es6/types.js.map +0 -1
  142. package/lib/es6/utils.js +0 -48
  143. package/lib/es6/utils.js.map +0 -1
  144. package/lib/esm/Body.mjs +0 -320
  145. package/lib/esm/DataTable.mjs +0 -439
  146. package/lib/esm/Head.mjs +0 -258
  147. package/lib/esm/utils.mjs +0 -37
  148. package/lib/types/Body.d.ts +0 -61
  149. package/lib/types/DataTable.d.ts +0 -205
  150. package/lib/types/Head.d.ts +0 -45
  151. package/lib/types/types.d.ts +0 -73
  152. package/lib/types/utils.d.ts +0 -4
package/lib/esm/Head.mjs DELETED
@@ -1,258 +0,0 @@
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/core/lib/utils/assignProps";
16
- import { flattenColumns as O, getFixedStyle as te, getScrollOffsetValue as re } from "./utils.mjs";
17
- import ie from "@semcore/core/lib/utils/logger";
18
- import { setRef as B } from "@semcore/core/lib/utils/ref";
19
- import { getFocusableIn as V } from "@semcore/core/lib/utils/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 (B(e.props.ref, a), i.headCellMap.set(r, a), e.props.forwardRef && B(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 ? O(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
- innerOutline: !0
204
- })), u ? /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(v, l.cn("SColumn", {
205
- id: "igc-table-".concat(h, "-").concat(t.name, "-group"),
206
- groupHead: !0,
207
- use: o,
208
- active: t.active,
209
- borderLeft: t.borderLeft,
210
- borderRight: t.borderRight
211
- }), /* @__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", {
212
- ref: this.makeSortRefHandler(t.active)
213
- }), /* @__PURE__ */ n.createElement(g, l.cn("SSortIcon", {}))) : null));
214
- }
215
- }, {
216
- key: "render",
217
- value: function() {
218
- 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;
219
- this.columns = O(d);
220
- var u = re(this.columns), W = F(u, 2), b = W[0], C = W[1];
221
- 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, {
222
- value: !0
223
- }, /* @__PURE__ */ n.createElement(e, s.cn("SHeadWrapper", {
224
- sticky: c,
225
- animationsDisabled: g
226
- }), /* @__PURE__ */ n.createElement(_, s.cn("ScrollArea", {
227
- leftOffset: b,
228
- rightOffset: C,
229
- shadow: !0,
230
- onResize: h
231
- }), /* @__PURE__ */ n.createElement(_.Container, {
232
- ref: v,
233
- role: "rowgroup",
234
- tabIndex: -1,
235
- zIndex: 2
236
- }, /* @__PURE__ */ n.createElement(l, s.cn("SHead", P({}, q({
237
- role: "row",
238
- __excludeProps: ["hidden"]
239
- }, t))), this.renderColumns(d, 100 / this.columns.length))), !!f && /* @__PURE__ */ n.createElement("div", s.cn("div", {
240
- style: N
241
- }), /* @__PURE__ */ n.createElement("div", s.cn("div", {
242
- style: N
243
- }), /* @__PURE__ */ n.createElement("div", s.cn("div", {
244
- style: N
245
- }), /* @__PURE__ */ n.createElement(_.Bar, {
246
- orientation: "horizontal"
247
- }))))), a.origin, /* @__PURE__ */ n.createElement(Q, s.cn("ScreenReaderOnly", {
248
- "aria-hidden": !0,
249
- id: this.sortableColumnDescribeId()
250
- }), S == null ? void 0 : S("sortableColumn"))));
251
- }
252
- }]), y;
253
- }(J);
254
- p(ne, "displayName", void 0);
255
- export {
256
- k as SORT_ICON_WIDTH,
257
- ne as default
258
- };
package/lib/esm/utils.mjs DELETED
@@ -1,37 +0,0 @@
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
- };
@@ -1,61 +0,0 @@
1
- import React from 'react';
2
- import { Component } from '@semcore/core';
3
- import { RowData, Column, NestedCells, PropsLayer, Cell } from './types';
4
- import syncScroll from '@semcore/core/lib/utils/syncScroll';
5
- type AsProps = {
6
- rows: NestedCells[][];
7
- columns: Column[];
8
- $scrollRef: ReturnType<ReturnType<typeof syncScroll>>;
9
- onResize: ResizeObserverCallback;
10
- onScroll?: (event: React.SyntheticEvent<HTMLElement>) => void;
11
- rowPropsLayers: PropsLayer[];
12
- use: 'primary' | 'secondary';
13
- uniqueKey: string;
14
- virtualScroll?: boolean | {
15
- tollerance?: number;
16
- rowHeight?: number;
17
- };
18
- renderRows?: (props: {
19
- rows: NestedCells[][];
20
- columns: Column[];
21
- renderRow: (row: Cell[], details: {
22
- dataIndex: number;
23
- nested: boolean;
24
- }) => React.ReactNode;
25
- }) => React.ReactNode;
26
- disabledScroll?: boolean;
27
- uid?: string;
28
- animationsDisabled?: boolean;
29
- scrollContainerRef: React.Ref<HTMLDivElement>;
30
- };
31
- type State = {
32
- rowHeight: number | undefined;
33
- scrollAreaHeight: undefined | number;
34
- scrollOffset: number;
35
- };
36
- declare class Body extends Component<AsProps, {}, State> {
37
- state: State;
38
- scrollContainerRef: React.RefObject<HTMLDivElement>;
39
- firstRowRef: React.RefObject<HTMLDivElement>;
40
- firstRowResizeObserver: ResizeObserver | null;
41
- lockedCell: [HTMLElement | null, boolean];
42
- getRowHeight: () => number | undefined;
43
- handleKeyDown: (e: React.KeyboardEvent) => void;
44
- onFocusCell: (e: React.FocusEvent<HTMLElement, HTMLElement>) => void;
45
- renderCells(cells: NestedCells, rowData: RowData, dataIndex: number): React.ReactNode[];
46
- renderRow(cells: NestedCells, { dataIndex, topOffset, nested, }: {
47
- dataIndex: number;
48
- topOffset?: number;
49
- nested: boolean;
50
- }): React.ReactNode;
51
- renderRows(rows: NestedCells[], nested?: boolean): React.ReactNode[];
52
- renderVirtualizedRows(rows: NestedCells[]): React.ReactNode[];
53
- handleFirstRowResize: (entries: ResizeObserverEntry[]) => void;
54
- handleScrollAreaResize: (entries: ResizeObserverEntry[]) => void;
55
- handleScrollAreaScroll: (event: React.SyntheticEvent<HTMLElement>) => void;
56
- setupRowSizeObserver: () => void;
57
- handleBodyTransitionEnd: () => void;
58
- componentWillUnmount(): void;
59
- render(): JSX.Element;
60
- }
61
- export default Body;
@@ -1,205 +0,0 @@
1
- import React from 'react';
2
- import { Property } from 'csstype';
3
- import { Component, PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';
4
- import { BoxProps, FlexProps } from '@semcore/flex-box';
5
- import type { Column } from './types';
6
- declare const ROW_GROUP: unique symbol;
7
- export type DataTableData = {
8
- [key: string]: unknown;
9
- };
10
- export type DataTableSort<Column = string> = [sortBy: Column, sortDirection: 'desc' | 'asc'];
11
- export type DataTableTheme = 'muted' | 'info' | 'success' | 'warning' | 'danger';
12
- export type DataTableUse = 'primary' | 'secondary';
13
- export type DataTableRow = DataTableCell[];
14
- export type DataTableCell = {
15
- /** Name of column */
16
- name: string;
17
- /** Data of column */
18
- data: React.ReactNode;
19
- [key: string]: unknown;
20
- };
21
- /**
22
- * Datatable must have an accessible name (aria-table-name).
23
- * It should describe table content.
24
- */
25
- type DataTableAriaProps = Intergalactic.RequireAtLeastOne<{
26
- 'aria-label'?: string;
27
- 'aria-labelledby'?: string;
28
- title?: string;
29
- }>;
30
- /** @deprecated */
31
- export interface IDataTableProps<DataTableData extends {
32
- [key: string]: any;
33
- }[] = UnknownProperties[]> extends Omit<DataTableProps<DataTableData>, keyof DataTableAriaProps> {
34
- }
35
- export type DataTableProps<DataTableData extends {
36
- [key: string]: any;
37
- }[] = UnknownProperties[]> = BoxProps & {
38
- /** Table theme according to visual hierarchy on the page
39
- * @default primary
40
- * */
41
- use?: DataTableUse;
42
- /** Data for table */
43
- data?: DataTableData;
44
- /** Active sort object */
45
- sort?: DataTableSort<keyof DataTableData[0]>;
46
- /** Handler call when request will change sort */
47
- onSortChange?: (sort: DataTableSort<keyof DataTableData[0]>, e?: React.SyntheticEvent) => void;
48
- /** Field name in one data entity that is unique accross all dataset
49
- * @default id
50
- */
51
- uniqueKey?: keyof DataTableData[0];
52
- /** Make cells compact by changing left and right paddings to smaller ones*/
53
- compact?: boolean;
54
- /** Count of total rows if table using virtual scroll. Needs for accessibility */
55
- totalRows?: number;
56
- } & DataTableAriaProps;
57
- /** @deprecated */
58
- export interface IDataTableHeadProps extends DataTableHeadProps, UnknownProperties {
59
- }
60
- export type DataTableHeadProps = BoxProps & {
61
- /** Sticky table header
62
- * @deprecated
63
- * */
64
- sticky?: boolean;
65
- /** Hidden header */
66
- hidden?: boolean;
67
- /** Disabled scroll (as action) */
68
- disabledScroll?: boolean;
69
- /** Enable scroll bar element in header */
70
- withScrollBar?: boolean;
71
- /** Disables column width change animation **/
72
- animationsDisabled?: boolean;
73
- };
74
- /** @deprecated */
75
- export interface IDataTableColumnProps extends DataTableColumnProps, UnknownProperties {
76
- }
77
- export type DataTableColumnProps = FlexProps & {
78
- /** Unique column name */
79
- name?: string;
80
- /** Enable sorting for column. And if you are passing a string, you can also set the default sorting */
81
- sortable?: boolean | 'desc' | 'asc';
82
- /** Enable resize for column
83
- * @ignore */
84
- resizable?: boolean;
85
- /** Fix column on the left o right side of the table */
86
- fixed?: 'left' | 'right';
87
- /** Fields to control the size of the column */
88
- flex?: Property.Flex | 'inherit';
89
- /** Add vertical border to the column */
90
- vBorders?: boolean;
91
- /** Add vertical border to the right side of the cell */
92
- borderRight?: boolean;
93
- /** Add vertical border to the left side of the cell */
94
- borderLeft?: boolean;
95
- /**
96
- * Enable changing column width with sort icon
97
- * @default false
98
- */
99
- changeSortSize?: boolean;
100
- /**
101
- * Enable column to use as a column for recalculation width
102
- * @default false (By default used first column with maximum width)
103
- */
104
- sortSizeRecalculation?: boolean;
105
- };
106
- /** @deprecated */
107
- export interface IDataTableBodyProps extends DataTableBodyProps, UnknownProperties {
108
- }
109
- export type DataTableBodyProps = BoxProps & {
110
- /** Rows table */
111
- rows?: DataTableRow[];
112
- /** When enabled, only visually acessable rows are rendered.
113
- * `tollerance` property controls how many rows outside of viewport are render.
114
- * `rowHeight` fixes the rows height if it has known. If not provided, first row node height is measured.
115
- * @default { tollerance: 2 }
116
- */
117
- virtualScroll?: boolean | {
118
- tollerance?: number;
119
- rowHeight?: number;
120
- };
121
- /** Allows to redefine rows renderning for a very deep and even fragile customization like building custom virtual scrolling */
122
- renderRows?: (props: {
123
- rows: DataTableRow[];
124
- columns: Column[];
125
- renderRow: (row: DataTableRow, details: {
126
- dataIndex: number;
127
- }) => React.ReactNode;
128
- }) => React.ReactNode;
129
- /**
130
- * Called every time user scrolls area
131
- */
132
- onScroll?: (event: React.SyntheticEvent<HTMLElement>) => void;
133
- /** Disabled scroll */
134
- disabledScroll?: boolean;
135
- /** Disables column width change animation **/
136
- animationsDisabled?: boolean;
137
- /** Ref for table body container */
138
- scrollContainerRef?: React.Ref<HTMLDivElement>;
139
- };
140
- /** @deprecated */
141
- export interface IDataTableRowProps extends DataTableRowProps, UnknownProperties {
142
- }
143
- export type DataTableRowProps = BoxProps & {
144
- /** Theme for row */
145
- theme?: DataTableTheme;
146
- /** Sets row state to active*/
147
- active?: boolean;
148
- };
149
- /** @deprecated */
150
- export interface IDataTableCellProps extends DataTableCellProps, UnknownProperties {
151
- }
152
- export type DataTableCellProps<Name extends string = string> = FlexProps & {
153
- /** Unique name for column or columns separated by / */
154
- name: Name;
155
- /** Theme for cell */
156
- theme?: DataTableTheme;
157
- };
158
- type DataTableCtx = {
159
- getHeadProps: PropGetterFn;
160
- getBodyProps: PropGetterFn;
161
- };
162
- type IntergalacticDataTableComponent<PropsExtending extends {} = {}> = (<Data extends DataTableData[], Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.ComponentProps<Tag, 'div', DataTableProps<Data> & PropsExtending, DataTableCtx, never>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', DataTableProps>;
163
- type IntergalacticDataTableRowComponent<PropsExtending extends {} = {}> = (<Data extends DataTableData[], Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.PropsRenderingResultComponentProps<Tag, DataTableRowProps & {
164
- /**
165
- * That property is ONLY used for the component strict typings. In the component runtime `data` prop set on `<DataTable>...</DataTable> is used.
166
- */
167
- data?: Data;
168
- } & PropsExtending, DataTableCtx & {
169
- data: Data;
170
- }, [
171
- row: Data[0],
172
- index: number
173
- ]>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', DataTableRowProps>;
174
- type IntergalacticDataTableCellComponent<PropsExtending extends {} = {}> = (<Data extends DataTableData[] = [], Name extends string = string, Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.PropsRenderingResultComponentProps<Tag, DataTableCellProps<Name> & {
175
- /**
176
- * That property is ONLY used for the componenct strict typings. In the component runtime `data` prop set on `<DataTable>...</DataTable> is used.
177
- */
178
- data?: Data;
179
- } & PropsExtending, DataTableCtx & {
180
- data: Data;
181
- }, [
182
- row: Data[0],
183
- index: number
184
- ]>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', DataTableCellProps>;
185
- declare const DefinitionTable: (<Data extends DataTableData[], Tag extends Intergalactic.InternalTypings.ComponentTag = "div">(props: Intergalactic.InternalTypings.ComponentProps<Tag, "div", DataTableProps<Data> & {}, DataTableCtx, never>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<"div", "div", DataTableProps<UnknownProperties[]>, {}, {}> & {
186
- Head: Intergalactic.Component<'div', DataTableHeadProps>;
187
- Body: Intergalactic.Component<'div', DataTableBodyProps>;
188
- Column: Intergalactic.Component<'div', DataTableColumnProps>;
189
- Row: IntergalacticDataTableRowComponent;
190
- Cell: IntergalacticDataTableCellComponent;
191
- };
192
- export { ROW_GROUP };
193
- export default DefinitionTable;
194
- export declare const wrapDataTable: <PropsExtending extends {}>(wrapper: (props: Intergalactic.InternalTypings.EfficientOmit<Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticDataTableComponent<{}>>, "tag" | "ref"> & {
195
- ref: React.Ref<any>;
196
- tag: Intergalactic.InternalTypings.ComponentTag;
197
- } & PropsExtending) => React.ReactNode) => IntergalacticDataTableComponent<PropsExtending>;
198
- export declare const wrapDataTableRow: <PropsExtending extends {}>(wrapper: (props: Intergalactic.InternalTypings.EfficientOmit<Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticDataTableRowComponent<{}>>, "tag" | "ref"> & {
199
- ref: React.Ref<any>;
200
- tag: Intergalactic.InternalTypings.ComponentTag;
201
- } & PropsExtending) => React.ReactNode) => IntergalacticDataTableRowComponent<PropsExtending>;
202
- export declare const wrapDataTableCell: <PropsExtending extends {}>(wrapper: (props: Intergalactic.InternalTypings.EfficientOmit<Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticDataTableCellComponent<{}>>, "tag" | "ref"> & {
203
- ref: React.Ref<any>;
204
- tag: Intergalactic.InternalTypings.ComponentTag;
205
- } & PropsExtending) => React.ReactNode) => IntergalacticDataTableCellComponent<PropsExtending>;
@@ -1,45 +0,0 @@
1
- import React from 'react';
2
- import { Component } from '@semcore/core';
3
- import { Column } from './types';
4
- export declare const SORT_ICON_WIDTH = 20;
5
- type AsProps = {
6
- $onSortClick: (name: string, event: React.MouseEvent | React.KeyboardEvent) => void;
7
- $scrollRef: (instance: unknown) => void;
8
- use: 'primary' | 'secondary';
9
- columnsChildren: Column[];
10
- onResize: ResizeObserverCallback;
11
- sticky: boolean;
12
- ['data-ui-name']: string;
13
- uid?: string;
14
- withScrollBar?: boolean;
15
- animationsDisabled?: boolean;
16
- getI18nText?: (str: string) => string;
17
- };
18
- declare class Head extends Component<AsProps> {
19
- columns: Column[];
20
- static displayName: string;
21
- headCellMap: Map<number, HTMLElement | null>;
22
- lockedCell: [HTMLElement | null, boolean];
23
- sortWrapperRefs: Map<Node, boolean>;
24
- defaultWidths: Map<HTMLElement, {
25
- minWidth: number;
26
- maxWidth: number | null;
27
- computedWidth: number;
28
- useForRecalculation: boolean;
29
- }>;
30
- sortableColumnDescribeId(): string;
31
- handleKeyDown: (e: React.KeyboardEvent) => void;
32
- onFocusCell: (e: React.FocusEvent<HTMLElement, HTMLElement>) => void;
33
- bindHandlerSortClick: (name: string) => (event: React.MouseEvent) => void;
34
- bindHandlerKeyDown: (name: string) => (event: React.KeyboardEvent) => void;
35
- makeSortRefHandler: (active: boolean) => (ref: HTMLElement | null) => void;
36
- makeColumnRefHandler: (column: Column, index: number) => (ref: HTMLElement | null) => void;
37
- componentDidUpdate(): void;
38
- changeMaxNodeWidth: (diff: number, exceptNode: HTMLElement) => void;
39
- backToColumnDefaults: (node: HTMLElement) => void;
40
- calculateActiveColumnMinWidth: (node: HTMLElement) => void;
41
- renderColumns(columns: Column[], width: number): React.ReactNode[];
42
- renderColumn(column: Column, width: number): React.ReactNode;
43
- render(): React.ReactNode;
44
- }
45
- export default Head;
@@ -1,73 +0,0 @@
1
- import React from 'react';
2
- import { ROW_GROUP } from './DataTable';
3
- import { Property } from 'csstype';
4
- import { FlexProps } from '@semcore/flex-box';
5
- export type PseudoChildPropsGetter = (props: {
6
- [propName: string]: unknown;
7
- }, rowData: {
8
- [columnName: string]: unknown;
9
- }, index: number) => {
10
- [propName: string]: unknown;
11
- };
12
- export type PropsLayer = {
13
- childrenPropsGetter?: PseudoChildPropsGetter;
14
- [propName: string]: unknown;
15
- };
16
- export type SortDirection = 'asc' | 'desc';
17
- export type Column<Props extends {
18
- [propName: string]: unknown;
19
- } = {
20
- [propName: string]: unknown;
21
- }> = {
22
- name: string;
23
- active: boolean;
24
- width: number;
25
- fixed?: 'left' | 'right';
26
- resizable?: boolean;
27
- sortable?: boolean | SortDirection;
28
- sortDirection: SortDirection;
29
- varWidth: string;
30
- setVar: boolean;
31
- data?: unknown;
32
- vBorders?: boolean;
33
- borderLeft?: boolean;
34
- borderRight?: boolean;
35
- props: {
36
- name: string;
37
- ref: React.RefObject<HTMLElement>;
38
- } & FlexProps & Partial<{
39
- flex: Property.Flex;
40
- onClick: (event: React.MouseEvent) => void;
41
- onKeyDown: (event: React.KeyboardEvent) => void;
42
- forwardRef: React.Ref<HTMLElement>;
43
- style: React.CSSProperties;
44
- fixed: 'left' | 'right';
45
- resizable: boolean;
46
- sortable: boolean | SortDirection;
47
- sortDirection: SortDirection;
48
- vBorders: boolean;
49
- borderLeft: Property.BorderLeft;
50
- borderRight: Property.BorderLeft;
51
- changeSortSize?: boolean;
52
- sortSizeRecalculation?: boolean;
53
- }> & Props;
54
- columns: Column[];
55
- parentColumns: Column[];
56
- };
57
- export type Cell = Pick<Column, 'name' | 'fixed' | 'data'> & {
58
- cssVar: string | string[];
59
- cellPropsLayers: PropsLayer[];
60
- };
61
- export type RowData<Data extends {
62
- [columnName: string]: unknown;
63
- } = {
64
- [columnName: string]: unknown;
65
- }> = Data & Partial<{
66
- name: string;
67
- [ROW_GROUP]: RowData[];
68
- }>;
69
- export type NestedCells = (Cell | NestedCells)[] & {
70
- flatRowData?: RowData;
71
- };
72
- export type RowIndex = number;
73
- export type ColIndex = number;