@appius-fr/apx 2.7.0 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/APX.dev.mjs +427 -41
- package/dist/APX.mjs +1 -1
- package/dist/APX.prod.mjs +1 -1
- package/dist/APX.standalone.js +488 -46
- package/dist/APX.standalone.js.map +1 -1
- package/modules/scrollableTable/CHANGELOG.md +37 -0
- package/modules/scrollableTable/README.md +59 -3
- package/modules/scrollableTable/css/scrollableTable.css +23 -16
- package/modules/scrollableTable/scrollableTable.mjs +402 -23
- package/package.json +1 -1
package/dist/APX.standalone.js
CHANGED
|
@@ -194,67 +194,74 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
194
194
|
|
|
195
195
|
var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
|
|
196
196
|
// Module
|
|
197
|
-
___CSS_LOADER_EXPORT___.push([module.id, `/* APX Scrollable Table: scrollable tbody with fixed thead/tfoot and aligned columns (CSS Grid + subgrid)
|
|
197
|
+
___CSS_LOADER_EXPORT___.push([module.id, `/* APX Scrollable Table: scrollable tbody with fixed thead/tfoot and aligned columns (CSS Grid + subgrid)
|
|
198
|
+
Use !important so page styles (e.g. display: table) do not override the grid layout. */
|
|
198
199
|
|
|
200
|
+
/* --apx-scrollable-template-columns: set by JS (measured widths + gutter); fallback = equal columns + gutter */
|
|
201
|
+
/* --apx-scrollable-gutter-width: space for vertical scrollbar so it does not overlap the last column (set to 0 to allow overlap) */
|
|
202
|
+
/* --apx-scrollable-body-height: when class apx-scrollable-table--body-height is set, tbody row uses fixed height instead of max-height */
|
|
199
203
|
.apx-scrollable-table {
|
|
200
|
-
display: grid;
|
|
201
|
-
grid-template-columns: repeat(var(--apx-scrollable-cols, 3), minmax(0, 1fr));
|
|
202
|
-
grid-template-rows: auto fit-content(var(--apx-scrollable-body-max-height, 200px)) auto;
|
|
204
|
+
display: grid !important;
|
|
205
|
+
grid-template-columns: var(--apx-scrollable-template-columns, repeat(var(--apx-scrollable-cols, 3), minmax(0, 1fr)) minmax(var(--apx-scrollable-gutter-width, 17px), var(--apx-scrollable-gutter-width, 17px)));
|
|
206
|
+
grid-template-rows: auto var(--apx-scrollable-body-row-size, fit-content(var(--apx-scrollable-body-max-height, 200px))) auto;
|
|
203
207
|
width: 100%;
|
|
208
|
+
table-layout: unset !important;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.apx-scrollable-table--body-height {
|
|
212
|
+
--apx-scrollable-body-row-size: var(--apx-scrollable-body-max-height, 200px);
|
|
204
213
|
}
|
|
205
214
|
|
|
206
215
|
/* Table with no tfoot: thead + tbody only */
|
|
207
216
|
.apx-scrollable-table:not(.apx-scrollable-table--has-tfoot) {
|
|
208
|
-
grid-template-rows: auto fit-content(var(--apx-scrollable-body-max-height, 200px));
|
|
217
|
+
grid-template-rows: auto var(--apx-scrollable-body-row-size, fit-content(var(--apx-scrollable-body-max-height, 200px)));
|
|
209
218
|
}
|
|
210
219
|
|
|
211
220
|
/* Table with no thead: tbody + tfoot only */
|
|
212
221
|
.apx-scrollable-table.apx-scrollable-table--no-thead {
|
|
213
|
-
grid-template-rows: fit-content(var(--apx-scrollable-body-max-height, 200px)) auto;
|
|
222
|
+
grid-template-rows: var(--apx-scrollable-body-row-size, fit-content(var(--apx-scrollable-body-max-height, 200px))) auto;
|
|
214
223
|
}
|
|
215
224
|
|
|
216
225
|
/* Table with neither thead nor tfoot: tbody only */
|
|
217
226
|
.apx-scrollable-table.apx-scrollable-table--no-thead:not(.apx-scrollable-table--has-tfoot) {
|
|
218
|
-
grid-template-rows: fit-content(var(--apx-scrollable-body-max-height, 200px));
|
|
227
|
+
grid-template-rows: var(--apx-scrollable-body-row-size, fit-content(var(--apx-scrollable-body-max-height, 200px)));
|
|
219
228
|
}
|
|
220
229
|
|
|
230
|
+
/* --apx-scrollable-*-template-rows: set by JS (measured heights) or override in CSS / via options */
|
|
221
231
|
.apx-scrollable-table > thead,
|
|
222
232
|
.apx-scrollable-table > tbody,
|
|
223
233
|
.apx-scrollable-table > tfoot {
|
|
224
|
-
display: grid;
|
|
234
|
+
display: grid !important;
|
|
225
235
|
grid-template-columns: subgrid;
|
|
226
236
|
grid-column: 1 / -1;
|
|
227
|
-
grid-template-rows: repeat(var(--apx-scrollable-thead-rows, 1), auto);
|
|
228
237
|
min-height: 0;
|
|
229
238
|
}
|
|
230
239
|
|
|
231
240
|
.apx-scrollable-table > thead {
|
|
232
|
-
grid-template-rows: repeat(var(--apx-scrollable-thead-rows, 1), auto);
|
|
241
|
+
grid-template-rows: var(--apx-scrollable-thead-template-rows, repeat(var(--apx-scrollable-thead-rows, 1), auto));
|
|
233
242
|
}
|
|
234
243
|
|
|
235
244
|
.apx-scrollable-table > tbody {
|
|
236
|
-
grid-template-rows: repeat(var(--apx-scrollable-tbody-rows, 1), auto);
|
|
245
|
+
grid-template-rows: var(--apx-scrollable-tbody-template-rows, repeat(var(--apx-scrollable-tbody-rows, 1), auto));
|
|
237
246
|
overflow: auto;
|
|
238
|
-
/* Reserve space for the vertical scrollbar so it doesn't shrink content width and trigger a horizontal scrollbar */
|
|
239
|
-
scrollbar-gutter: stable;
|
|
240
247
|
}
|
|
241
248
|
|
|
242
249
|
.apx-scrollable-table > tfoot {
|
|
243
|
-
grid-template-rows: repeat(var(--apx-scrollable-tfoot-rows, 1), auto);
|
|
250
|
+
grid-template-rows: var(--apx-scrollable-tfoot-template-rows, repeat(var(--apx-scrollable-tfoot-rows, 1), auto));
|
|
244
251
|
}
|
|
245
252
|
|
|
246
253
|
.apx-scrollable-table > thead > tr,
|
|
247
254
|
.apx-scrollable-table > tbody > tr,
|
|
248
255
|
.apx-scrollable-table > tfoot > tr {
|
|
249
|
-
display: contents;
|
|
256
|
+
display: contents !important;
|
|
250
257
|
}
|
|
251
258
|
|
|
252
259
|
.apx-scrollable-table th,
|
|
253
260
|
.apx-scrollable-table td {
|
|
254
|
-
/* Grid placement set by JS (grid-row, grid-column) for colspan/rowspan */
|
|
255
261
|
min-width: 0;
|
|
262
|
+
box-sizing: border-box;
|
|
256
263
|
}
|
|
257
|
-
`, "",{"version":3,"sources":["webpack://./modules/scrollableTable/css/scrollableTable.css"],"names":[],"mappings":"AAAA
|
|
264
|
+
`, "",{"version":3,"sources":["webpack://./modules/scrollableTable/css/scrollableTable.css"],"names":[],"mappings":"AAAA;yFACyF;;AAEzF,+GAA+G;AAC/G,mIAAmI;AACnI,yIAAyI;AACzI;IACI,wBAAwB;IACxB,+MAA+M;IAC/M,4HAA4H;IAC5H,WAAW;IACX,8BAA8B;AAClC;;AAEA;IACI,4EAA4E;AAChF;;AAEA,4CAA4C;AAC5C;IACI,uHAAuH;AAC3H;;AAEA,4CAA4C;AAC5C;IACI,uHAAuH;AAC3H;;AAEA,mDAAmD;AACnD;IACI,kHAAkH;AACtH;;AAEA,oGAAoG;AACpG;;;IAGI,wBAAwB;IACxB,8BAA8B;IAC9B,mBAAmB;IACnB,aAAa;AACjB;;AAEA;IACI,gHAAgH;AACpH;;AAEA;IACI,gHAAgH;IAChH,cAAc;AAClB;;AAEA;IACI,gHAAgH;AACpH;;AAEA;;;IAGI,4BAA4B;AAChC;;AAEA;;IAEI,YAAY;IACZ,sBAAsB;AAC1B","sourcesContent":["/* APX Scrollable Table: scrollable tbody with fixed thead/tfoot and aligned columns (CSS Grid + subgrid)\r\n Use !important so page styles (e.g. display: table) do not override the grid layout. */\r\n\r\n/* --apx-scrollable-template-columns: set by JS (measured widths + gutter); fallback = equal columns + gutter */\r\n/* --apx-scrollable-gutter-width: space for vertical scrollbar so it does not overlap the last column (set to 0 to allow overlap) */\r\n/* --apx-scrollable-body-height: when class apx-scrollable-table--body-height is set, tbody row uses fixed height instead of max-height */\r\n.apx-scrollable-table {\r\n display: grid !important;\r\n grid-template-columns: var(--apx-scrollable-template-columns, repeat(var(--apx-scrollable-cols, 3), minmax(0, 1fr)) minmax(var(--apx-scrollable-gutter-width, 17px), var(--apx-scrollable-gutter-width, 17px)));\r\n grid-template-rows: auto var(--apx-scrollable-body-row-size, fit-content(var(--apx-scrollable-body-max-height, 200px))) auto;\r\n width: 100%;\r\n table-layout: unset !important;\r\n}\r\n\r\n.apx-scrollable-table--body-height {\r\n --apx-scrollable-body-row-size: var(--apx-scrollable-body-max-height, 200px);\r\n}\r\n\r\n/* Table with no tfoot: thead + tbody only */\r\n.apx-scrollable-table:not(.apx-scrollable-table--has-tfoot) {\r\n grid-template-rows: auto var(--apx-scrollable-body-row-size, fit-content(var(--apx-scrollable-body-max-height, 200px)));\r\n}\r\n\r\n/* Table with no thead: tbody + tfoot only */\r\n.apx-scrollable-table.apx-scrollable-table--no-thead {\r\n grid-template-rows: var(--apx-scrollable-body-row-size, fit-content(var(--apx-scrollable-body-max-height, 200px))) auto;\r\n}\r\n\r\n/* Table with neither thead nor tfoot: tbody only */\r\n.apx-scrollable-table.apx-scrollable-table--no-thead:not(.apx-scrollable-table--has-tfoot) {\r\n grid-template-rows: var(--apx-scrollable-body-row-size, fit-content(var(--apx-scrollable-body-max-height, 200px)));\r\n}\r\n\r\n/* --apx-scrollable-*-template-rows: set by JS (measured heights) or override in CSS / via options */\r\n.apx-scrollable-table > thead,\r\n.apx-scrollable-table > tbody,\r\n.apx-scrollable-table > tfoot {\r\n display: grid !important;\r\n grid-template-columns: subgrid;\r\n grid-column: 1 / -1;\r\n min-height: 0;\r\n}\r\n\r\n.apx-scrollable-table > thead {\r\n grid-template-rows: var(--apx-scrollable-thead-template-rows, repeat(var(--apx-scrollable-thead-rows, 1), auto));\r\n}\r\n\r\n.apx-scrollable-table > tbody {\r\n grid-template-rows: var(--apx-scrollable-tbody-template-rows, repeat(var(--apx-scrollable-tbody-rows, 1), auto));\r\n overflow: auto;\r\n}\r\n\r\n.apx-scrollable-table > tfoot {\r\n grid-template-rows: var(--apx-scrollable-tfoot-template-rows, repeat(var(--apx-scrollable-tfoot-rows, 1), auto));\r\n}\r\n\r\n.apx-scrollable-table > thead > tr,\r\n.apx-scrollable-table > tbody > tr,\r\n.apx-scrollable-table > tfoot > tr {\r\n display: contents !important;\r\n}\r\n\r\n.apx-scrollable-table th,\r\n.apx-scrollable-table td {\r\n min-width: 0;\r\n box-sizing: border-box;\r\n}\r\n"],"sourceRoot":""}]);
|
|
258
265
|
// Exports
|
|
259
266
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
|
|
260
267
|
|
|
@@ -1920,6 +1927,10 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
1920
1927
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
1921
1928
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
1922
1929
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
1930
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
1931
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
1932
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
1933
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
1923
1934
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
1924
1935
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
1925
1936
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
@@ -1927,33 +1938,145 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
1927
1938
|
var DATA_KEY = '_apxScrollableTable';
|
|
1928
1939
|
var CLASS_TABLE = 'apx-scrollable-table';
|
|
1929
1940
|
var DEFAULT_MAX_HEIGHT = '200px';
|
|
1941
|
+
var THROTTLE_MS = 16;
|
|
1942
|
+
|
|
1943
|
+
/** @type {Set<HTMLTableElement>} */
|
|
1944
|
+
var dynamicTables = new Set();
|
|
1945
|
+
/** @type {Map<Element, Set<HTMLTableElement>>} */
|
|
1946
|
+
var scrollSourceToTables = new Map();
|
|
1947
|
+
/** @type {Map<Element, Set<HTMLTableElement>>} */
|
|
1948
|
+
var resizeSourceToTables = new Map();
|
|
1949
|
+
/** @type {boolean} */
|
|
1950
|
+
var resizeWindowAttached = false;
|
|
1951
|
+
/** @type {ResizeObserver|null} */
|
|
1952
|
+
var resizeObserver = null;
|
|
1953
|
+
/** @type {number} */
|
|
1954
|
+
var throttleLast = 0;
|
|
1955
|
+
/** @type {number|null} */
|
|
1956
|
+
var throttleRaf = null;
|
|
1930
1957
|
|
|
1931
1958
|
/**
|
|
1932
|
-
*
|
|
1933
|
-
* @param {
|
|
1959
|
+
* Sum of colspans for one row (direct th/td children of tr).
|
|
1960
|
+
* @param {HTMLTableRowElement} tr
|
|
1934
1961
|
* @returns {number}
|
|
1935
1962
|
*/
|
|
1936
|
-
function
|
|
1937
|
-
var firstRow = section === null || section === void 0 ? void 0 : section.querySelector(':scope > tr');
|
|
1938
|
-
if (!firstRow) return 0;
|
|
1963
|
+
function getRowColumnCount(tr) {
|
|
1939
1964
|
var cols = 0;
|
|
1940
|
-
|
|
1965
|
+
tr.querySelectorAll(':scope > th, :scope > td').forEach(function (cell) {
|
|
1941
1966
|
cols += parseInt(cell.getAttribute('colspan'), 10) || 1;
|
|
1942
1967
|
});
|
|
1943
1968
|
return cols;
|
|
1944
1969
|
}
|
|
1945
1970
|
|
|
1946
1971
|
/**
|
|
1947
|
-
* Get
|
|
1972
|
+
* Get maximum column count in a section (max sum of colspans across all rows).
|
|
1973
|
+
* @param {HTMLTableSectionElement} section - thead, tbody, or tfoot
|
|
1974
|
+
* @returns {number}
|
|
1975
|
+
*/
|
|
1976
|
+
function getColumnCountFromSection(section) {
|
|
1977
|
+
if (!section) return 0;
|
|
1978
|
+
var rows = section.querySelectorAll(':scope > tr');
|
|
1979
|
+
var maxCols = 0;
|
|
1980
|
+
rows.forEach(function (tr) {
|
|
1981
|
+
var sum = getRowColumnCount(tr);
|
|
1982
|
+
if (sum > maxCols) maxCols = sum;
|
|
1983
|
+
});
|
|
1984
|
+
return maxCols;
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
/**
|
|
1988
|
+
* Get total column count for the table (max across thead, tbody, tfoot).
|
|
1948
1989
|
* @param {HTMLTableElement} table
|
|
1949
1990
|
* @returns {number}
|
|
1950
1991
|
*/
|
|
1951
1992
|
function getTableColumnCount(table) {
|
|
1952
1993
|
var thead = table.querySelector('thead');
|
|
1953
1994
|
var tbody = table.querySelector('tbody');
|
|
1954
|
-
var
|
|
1955
|
-
var
|
|
1956
|
-
|
|
1995
|
+
var tfoot = table.querySelector('tfoot');
|
|
1996
|
+
var countThead = thead ? getColumnCountFromSection(thead) : 0;
|
|
1997
|
+
var countTbody = tbody ? getColumnCountFromSection(tbody) : 0;
|
|
1998
|
+
var countTfoot = tfoot ? getColumnCountFromSection(tfoot) : 0;
|
|
1999
|
+
return Math.max(countThead, countTbody, countTfoot, 1);
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
/**
|
|
2003
|
+
* Measure current column widths from the table in its natural layout (before applying scrollable class).
|
|
2004
|
+
* Prefers a row where each cell has colspan 1 so we get one width per column; otherwise splits cell widths by colspan.
|
|
2005
|
+
* @param {HTMLTableElement} table - table not yet with scrollable class
|
|
2006
|
+
* @param {number} numCols
|
|
2007
|
+
* @returns {number[]} pixel widths per column
|
|
2008
|
+
*/
|
|
2009
|
+
function measureColumnWidths(table, numCols) {
|
|
2010
|
+
var thead = table.querySelector('thead');
|
|
2011
|
+
var tbody = table.querySelector('tbody');
|
|
2012
|
+
var sections = [thead, tbody].filter(Boolean);
|
|
2013
|
+
/** @type {HTMLTableRowElement|null} */
|
|
2014
|
+
var bestRow = null;
|
|
2015
|
+
var _iterator = _createForOfIteratorHelper(sections),
|
|
2016
|
+
_step;
|
|
2017
|
+
try {
|
|
2018
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2019
|
+
var section = _step.value;
|
|
2020
|
+
var rows = section.querySelectorAll(':scope > tr');
|
|
2021
|
+
var _iterator3 = _createForOfIteratorHelper(rows),
|
|
2022
|
+
_step3;
|
|
2023
|
+
try {
|
|
2024
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
2025
|
+
var tr = _step3.value;
|
|
2026
|
+
var _cells = tr.querySelectorAll(':scope > th, :scope > td');
|
|
2027
|
+
if (getRowColumnCount(tr) !== numCols) continue;
|
|
2028
|
+
var allSingle = Array.from(_cells).every(function (c) {
|
|
2029
|
+
return (parseInt(c.getAttribute('colspan'), 10) || 1) === 1;
|
|
2030
|
+
});
|
|
2031
|
+
if (allSingle && _cells.length === numCols) {
|
|
2032
|
+
bestRow = tr;
|
|
2033
|
+
break;
|
|
2034
|
+
}
|
|
2035
|
+
if (!bestRow) bestRow = tr;
|
|
2036
|
+
}
|
|
2037
|
+
} catch (err) {
|
|
2038
|
+
_iterator3.e(err);
|
|
2039
|
+
} finally {
|
|
2040
|
+
_iterator3.f();
|
|
2041
|
+
}
|
|
2042
|
+
if (bestRow && Array.from(bestRow.querySelectorAll(':scope > th, :scope > td')).every(function (c) {
|
|
2043
|
+
return (parseInt(c.getAttribute('colspan'), 10) || 1) === 1;
|
|
2044
|
+
})) break;
|
|
2045
|
+
}
|
|
2046
|
+
} catch (err) {
|
|
2047
|
+
_iterator.e(err);
|
|
2048
|
+
} finally {
|
|
2049
|
+
_iterator.f();
|
|
2050
|
+
}
|
|
2051
|
+
if (!bestRow) return [];
|
|
2052
|
+
var widths = new Array(numCols).fill(0);
|
|
2053
|
+
var cells = bestRow.querySelectorAll(':scope > th, :scope > td');
|
|
2054
|
+
var col = 0;
|
|
2055
|
+
var _iterator2 = _createForOfIteratorHelper(cells),
|
|
2056
|
+
_step2;
|
|
2057
|
+
try {
|
|
2058
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2059
|
+
var cell = _step2.value;
|
|
2060
|
+
var span = Math.min(parseInt(cell.getAttribute('colspan'), 10) || 1, numCols - col);
|
|
2061
|
+
if (span <= 0) break;
|
|
2062
|
+
var w = cell.getBoundingClientRect().width;
|
|
2063
|
+
var perCol = w / span;
|
|
2064
|
+
for (var _i = 0; _i < span; _i++) widths[col + _i] = perCol;
|
|
2065
|
+
col += span;
|
|
2066
|
+
}
|
|
2067
|
+
} catch (err) {
|
|
2068
|
+
_iterator2.e(err);
|
|
2069
|
+
} finally {
|
|
2070
|
+
_iterator2.f();
|
|
2071
|
+
}
|
|
2072
|
+
if (col === 0) return [];
|
|
2073
|
+
var fallback = widths.some(function (w) {
|
|
2074
|
+
return w > 0;
|
|
2075
|
+
}) ? Math.max.apply(Math, [80].concat(_toConsumableArray(widths.filter(function (w) {
|
|
2076
|
+
return w > 0;
|
|
2077
|
+
})))) / 2 : 80;
|
|
2078
|
+
for (var i = 0; i < numCols; i++) if (widths[i] <= 0) widths[i] = fallback;
|
|
2079
|
+
return widths.slice(0, numCols);
|
|
1957
2080
|
}
|
|
1958
2081
|
|
|
1959
2082
|
/**
|
|
@@ -1986,11 +2109,11 @@ function computeCellPlacements(section, numRows, numCols) {
|
|
|
1986
2109
|
for (var r = 0; r < rows.length; r++) {
|
|
1987
2110
|
var tr = rows[r];
|
|
1988
2111
|
var cells = tr.querySelectorAll(':scope > th, :scope > td');
|
|
1989
|
-
var
|
|
1990
|
-
|
|
2112
|
+
var _iterator4 = _createForOfIteratorHelper(cells),
|
|
2113
|
+
_step4;
|
|
1991
2114
|
try {
|
|
1992
|
-
for (
|
|
1993
|
-
var cell =
|
|
2115
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
2116
|
+
var cell = _step4.value;
|
|
1994
2117
|
var colspan = Math.min(parseInt(cell.getAttribute('colspan'), 10) || 1, numCols);
|
|
1995
2118
|
var rowspan = Math.min(parseInt(cell.getAttribute('rowspan'), 10) || 1, numRows - r);
|
|
1996
2119
|
var col = 0;
|
|
@@ -2020,9 +2143,9 @@ function computeCellPlacements(section, numRows, numCols) {
|
|
|
2020
2143
|
});
|
|
2021
2144
|
}
|
|
2022
2145
|
} catch (err) {
|
|
2023
|
-
|
|
2146
|
+
_iterator4.e(err);
|
|
2024
2147
|
} finally {
|
|
2025
|
-
|
|
2148
|
+
_iterator4.f();
|
|
2026
2149
|
}
|
|
2027
2150
|
}
|
|
2028
2151
|
return placements;
|
|
@@ -2055,56 +2178,367 @@ function clearPlacements(table) {
|
|
|
2055
2178
|
}
|
|
2056
2179
|
|
|
2057
2180
|
/**
|
|
2058
|
-
* Normalize maxHeight option to a CSS length string.
|
|
2181
|
+
* Normalize height/maxHeight option to a CSS length string.
|
|
2059
2182
|
* @param {number|string} value
|
|
2060
2183
|
* @returns {string}
|
|
2061
2184
|
*/
|
|
2062
|
-
function
|
|
2185
|
+
function normalizeHeight(value) {
|
|
2063
2186
|
if (value == null) return DEFAULT_MAX_HEIGHT;
|
|
2064
2187
|
if (typeof value === 'number') return "".concat(value, "px");
|
|
2065
2188
|
return String(value);
|
|
2066
2189
|
}
|
|
2067
2190
|
|
|
2191
|
+
/**
|
|
2192
|
+
* Resolve current body height from options: either bodyHeightDynamic.get(table) or static height/maxHeight.
|
|
2193
|
+
* @param {Object} options - scrollableTable options (may include bodyHeightDynamic, height, maxHeight)
|
|
2194
|
+
* @param {HTMLTableElement} table
|
|
2195
|
+
* @returns {{ bodySize: string, useFixedHeight: boolean }}
|
|
2196
|
+
*/
|
|
2197
|
+
function resolveBodyHeight(options, table) {
|
|
2198
|
+
var dyn = options.bodyHeightDynamic;
|
|
2199
|
+
if (dyn && typeof dyn.get === 'function') {
|
|
2200
|
+
var value = dyn.get(table);
|
|
2201
|
+
var _bodySize = normalizeHeight(value);
|
|
2202
|
+
var _useFixedHeight = dyn.useAs === 'height';
|
|
2203
|
+
return {
|
|
2204
|
+
bodySize: _bodySize,
|
|
2205
|
+
useFixedHeight: _useFixedHeight
|
|
2206
|
+
};
|
|
2207
|
+
}
|
|
2208
|
+
var useFixedHeight = options.height != null;
|
|
2209
|
+
var raw = useFixedHeight ? options.height : options.maxHeight;
|
|
2210
|
+
var bodySize = normalizeHeight(raw);
|
|
2211
|
+
return {
|
|
2212
|
+
bodySize: bodySize,
|
|
2213
|
+
useFixedHeight: useFixedHeight
|
|
2214
|
+
};
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
/**
|
|
2218
|
+
* Update only the tbody height CSS variable and class (used on scroll/resize for dynamic height).
|
|
2219
|
+
* @param {HTMLTableElement} table
|
|
2220
|
+
* @param {Object} options - full scrollableTable options (with ref.options when called from throttle)
|
|
2221
|
+
*/
|
|
2222
|
+
function updateTableBodyHeight(table, options) {
|
|
2223
|
+
var _resolveBodyHeight = resolveBodyHeight(options, table),
|
|
2224
|
+
bodySize = _resolveBodyHeight.bodySize,
|
|
2225
|
+
useFixedHeight = _resolveBodyHeight.useFixedHeight;
|
|
2226
|
+
table.style.setProperty('--apx-scrollable-body-max-height', bodySize);
|
|
2227
|
+
table.classList.toggle('apx-scrollable-table--body-height', useFixedHeight);
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
/**
|
|
2231
|
+
* Run lazy cleanup then updateTableBodyHeight for all tables still in dynamicTables. (Called by throttled entry point or RAF.)
|
|
2232
|
+
*/
|
|
2233
|
+
function flushDynamicHeightUpdate() {
|
|
2234
|
+
var toRemove = [];
|
|
2235
|
+
dynamicTables.forEach(function (table) {
|
|
2236
|
+
if (!table.isConnected) toRemove.push(table);
|
|
2237
|
+
});
|
|
2238
|
+
toRemove.forEach(function (table) {
|
|
2239
|
+
return removeTableFromDynamicSources(table);
|
|
2240
|
+
});
|
|
2241
|
+
dynamicTables.forEach(function (table) {
|
|
2242
|
+
var ref = table[DATA_KEY];
|
|
2243
|
+
if (ref !== null && ref !== void 0 && ref.options) updateTableBodyHeight(table, ref.options);
|
|
2244
|
+
});
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2247
|
+
/**
|
|
2248
|
+
* Throttled entry: run flushDynamicHeightUpdate now or schedule with RAF.
|
|
2249
|
+
*/
|
|
2250
|
+
function runDynamicHeightUpdate() {
|
|
2251
|
+
var now = Date.now();
|
|
2252
|
+
if (now - throttleLast < THROTTLE_MS) {
|
|
2253
|
+
if (!throttleRaf) {
|
|
2254
|
+
throttleRaf = requestAnimationFrame(function () {
|
|
2255
|
+
throttleRaf = null;
|
|
2256
|
+
throttleLast = Date.now();
|
|
2257
|
+
flushDynamicHeightUpdate();
|
|
2258
|
+
});
|
|
2259
|
+
}
|
|
2260
|
+
return;
|
|
2261
|
+
}
|
|
2262
|
+
throttleLast = now;
|
|
2263
|
+
flushDynamicHeightUpdate();
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
/**
|
|
2267
|
+
* Resolve updateOn into scroll targets (Element[]) and resize: { window: boolean, elements: Element[] }.
|
|
2268
|
+
* @param {Object} options - options.bodyHeightDynamic.updateOn
|
|
2269
|
+
* @returns {{ scrollTargets: Element[], resizeWindow: boolean, resizeElements: Element[] }}
|
|
2270
|
+
*/
|
|
2271
|
+
function resolveUpdateOn(options) {
|
|
2272
|
+
var _options$bodyHeightDy;
|
|
2273
|
+
var u = options === null || options === void 0 || (_options$bodyHeightDy = options.bodyHeightDynamic) === null || _options$bodyHeightDy === void 0 ? void 0 : _options$bodyHeightDy.updateOn;
|
|
2274
|
+
var scrollOn = u === null || u === void 0 ? void 0 : u.scrollOn;
|
|
2275
|
+
var resizeOn = u === null || u === void 0 ? void 0 : u.resizeOn;
|
|
2276
|
+
var scrollTargets = [];
|
|
2277
|
+
if (scrollOn != null && Array.isArray(scrollOn) && scrollOn.length > 0) {
|
|
2278
|
+
scrollOn.forEach(function (x) {
|
|
2279
|
+
if (x === 'document') scrollTargets.push(document.documentElement);else if (x && typeof x.addEventListener === 'function') scrollTargets.push(x);
|
|
2280
|
+
});
|
|
2281
|
+
} else if ((u === null || u === void 0 ? void 0 : u.scroll) === true) {
|
|
2282
|
+
scrollTargets.push(document.documentElement);
|
|
2283
|
+
scrollTargets.push(typeof window !== 'undefined' ? window : document.documentElement);
|
|
2284
|
+
}
|
|
2285
|
+
var resizeWindow = false;
|
|
2286
|
+
var resizeElements = [];
|
|
2287
|
+
if (resizeOn != null && Array.isArray(resizeOn) && resizeOn.length > 0) {
|
|
2288
|
+
resizeOn.forEach(function (x) {
|
|
2289
|
+
if (x === 'window') resizeWindow = true;else if (x && typeof x.addEventListener === 'function') resizeElements.push(x);
|
|
2290
|
+
});
|
|
2291
|
+
} else if ((u === null || u === void 0 ? void 0 : u.resize) !== false) {
|
|
2292
|
+
resizeWindow = true;
|
|
2293
|
+
resizeElements.push(document.documentElement);
|
|
2294
|
+
}
|
|
2295
|
+
return {
|
|
2296
|
+
scrollTargets: scrollTargets,
|
|
2297
|
+
resizeWindow: resizeWindow,
|
|
2298
|
+
resizeElements: resizeElements
|
|
2299
|
+
};
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2302
|
+
/**
|
|
2303
|
+
* Remove table from dynamicTables and from all scroll/resize Maps; detach listeners if Set becomes empty.
|
|
2304
|
+
* @param {HTMLTableElement} table
|
|
2305
|
+
*/
|
|
2306
|
+
function removeTableFromDynamicSources(table) {
|
|
2307
|
+
dynamicTables["delete"](table);
|
|
2308
|
+
scrollSourceToTables.forEach(function (set, el) {
|
|
2309
|
+
set["delete"](table);
|
|
2310
|
+
if (set.size === 0) {
|
|
2311
|
+
scrollSourceToTables["delete"](el);
|
|
2312
|
+
el.removeEventListener('scroll', onScrollThrottled);
|
|
2313
|
+
}
|
|
2314
|
+
});
|
|
2315
|
+
resizeSourceToTables.forEach(function (set, el) {
|
|
2316
|
+
set["delete"](table);
|
|
2317
|
+
if (set.size === 0) {
|
|
2318
|
+
resizeSourceToTables["delete"](el);
|
|
2319
|
+
if (resizeObserver) resizeObserver.unobserve(el);
|
|
2320
|
+
}
|
|
2321
|
+
});
|
|
2322
|
+
if (resizeWindowAttached && dynamicTables.size === 0) {
|
|
2323
|
+
window.removeEventListener('resize', onResizeThrottled);
|
|
2324
|
+
resizeWindowAttached = false;
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
function onScrollThrottled() {
|
|
2328
|
+
runDynamicHeightUpdate();
|
|
2329
|
+
}
|
|
2330
|
+
function onResizeThrottled() {
|
|
2331
|
+
runDynamicHeightUpdate();
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
/**
|
|
2335
|
+
* Register a table with bodyHeightDynamic: add to Set and attach scroll/resize listeners per updateOn.
|
|
2336
|
+
* @param {HTMLTableElement} table
|
|
2337
|
+
* @param {Object} options - full options (ref.options)
|
|
2338
|
+
*/
|
|
2339
|
+
function registerDynamicTable(table, options) {
|
|
2340
|
+
var _resolveUpdateOn = resolveUpdateOn(options),
|
|
2341
|
+
scrollTargets = _resolveUpdateOn.scrollTargets,
|
|
2342
|
+
resizeWindow = _resolveUpdateOn.resizeWindow,
|
|
2343
|
+
resizeElements = _resolveUpdateOn.resizeElements;
|
|
2344
|
+
dynamicTables.add(table);
|
|
2345
|
+
scrollTargets.forEach(function (el) {
|
|
2346
|
+
var set = scrollSourceToTables.get(el);
|
|
2347
|
+
if (!set) {
|
|
2348
|
+
set = new Set();
|
|
2349
|
+
scrollSourceToTables.set(el, set);
|
|
2350
|
+
el.addEventListener('scroll', onScrollThrottled, {
|
|
2351
|
+
passive: true
|
|
2352
|
+
});
|
|
2353
|
+
}
|
|
2354
|
+
set.add(table);
|
|
2355
|
+
});
|
|
2356
|
+
if (resizeWindow) {
|
|
2357
|
+
if (!resizeWindowAttached) {
|
|
2358
|
+
resizeWindowAttached = true;
|
|
2359
|
+
window.addEventListener('resize', onResizeThrottled, {
|
|
2360
|
+
passive: true
|
|
2361
|
+
});
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
resizeElements.forEach(function (el) {
|
|
2365
|
+
var set = resizeSourceToTables.get(el);
|
|
2366
|
+
if (!set) {
|
|
2367
|
+
set = new Set();
|
|
2368
|
+
resizeSourceToTables.set(el, set);
|
|
2369
|
+
if (!resizeObserver) resizeObserver = new ResizeObserver(onResizeThrottled);
|
|
2370
|
+
resizeObserver.observe(el);
|
|
2371
|
+
}
|
|
2372
|
+
set.add(table);
|
|
2373
|
+
});
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
/**
|
|
2377
|
+
* Build grid-template-columns from measured widths and optional overrides per column.
|
|
2378
|
+
* @param {number} numCols
|
|
2379
|
+
* @param {number[]} columnWidths
|
|
2380
|
+
* @param {Object<number, string>|(string|null)[]} columnOverrides - map column index → CSS value (e.g. '2fr'), or array; null/empty = use measured
|
|
2381
|
+
* @returns {string}
|
|
2382
|
+
*/
|
|
2383
|
+
function buildTemplateColumns(numCols, columnWidths, columnOverrides) {
|
|
2384
|
+
if (!columnWidths || columnWidths.length !== numCols) return '';
|
|
2385
|
+
var get = function get(i) {
|
|
2386
|
+
return Array.isArray(columnOverrides) ? columnOverrides[i] : columnOverrides[i];
|
|
2387
|
+
};
|
|
2388
|
+
var parts = [];
|
|
2389
|
+
for (var i = 0; i < numCols; i++) {
|
|
2390
|
+
var ov = get(i);
|
|
2391
|
+
if (ov != null && typeof ov === 'string' && ov.trim() !== '') {
|
|
2392
|
+
parts.push(ov.trim());
|
|
2393
|
+
} else {
|
|
2394
|
+
parts.push("".concat(Math.round(columnWidths[i]), "fr"));
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
return parts.join(' ');
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
/**
|
|
2401
|
+
* Build grid-template-rows from measured heights and optional overrides per row.
|
|
2402
|
+
* @param {number} numRows
|
|
2403
|
+
* @param {number[]} rowHeights
|
|
2404
|
+
* @param {Object<number, string>|(string|null)[]} rowOverrides - map row index → CSS value (e.g. '48px', '2fr'), or array; null/empty = use measured
|
|
2405
|
+
* @returns {string}
|
|
2406
|
+
*/
|
|
2407
|
+
function buildTemplateRows(numRows, rowHeights, rowOverrides) {
|
|
2408
|
+
if (!rowHeights || rowHeights.length < numRows) return '';
|
|
2409
|
+
var get = function get(i) {
|
|
2410
|
+
return Array.isArray(rowOverrides) ? rowOverrides[i] : rowOverrides === null || rowOverrides === void 0 ? void 0 : rowOverrides[i];
|
|
2411
|
+
};
|
|
2412
|
+
var parts = [];
|
|
2413
|
+
for (var i = 0; i < numRows; i++) {
|
|
2414
|
+
var ov = get(i);
|
|
2415
|
+
if (ov != null && typeof ov === 'string' && ov.trim() !== '') {
|
|
2416
|
+
parts.push(ov.trim());
|
|
2417
|
+
} else {
|
|
2418
|
+
var _rowHeights$i;
|
|
2419
|
+
parts.push("".concat(Math.round((_rowHeights$i = rowHeights[i]) !== null && _rowHeights$i !== void 0 ? _rowHeights$i : 0), "px"));
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
return parts.join(' ');
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
/**
|
|
2426
|
+
* Measure each tr height in a section (table must not yet have scrollable class).
|
|
2427
|
+
* @param {HTMLTableSectionElement|null} section
|
|
2428
|
+
* @returns {number[]}
|
|
2429
|
+
*/
|
|
2430
|
+
function measureRowHeights(section) {
|
|
2431
|
+
if (!section) return [];
|
|
2432
|
+
var rows = section.querySelectorAll(':scope > tr');
|
|
2433
|
+
return Array.from(rows).map(function (tr) {
|
|
2434
|
+
return tr.getBoundingClientRect().height;
|
|
2435
|
+
});
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2068
2438
|
/**
|
|
2069
2439
|
* Apply scrollable table layout to a single table.
|
|
2070
2440
|
* @param {HTMLTableElement} table
|
|
2071
|
-
* @param {
|
|
2441
|
+
* @param {Object} options - scrollableTable options
|
|
2442
|
+
* @param {number|string} [options.maxHeight] - Max height of tbody (default '200px'). Ignored when height or bodyHeightDynamic is set.
|
|
2443
|
+
* @param {number|string} [options.height] - Fixed height of tbody. Ignored when bodyHeightDynamic is set.
|
|
2444
|
+
* @param {{ get: (function(HTMLTableElement): number|string), useAs: 'height'|'maxHeight', updateOn?: { scroll?: boolean, resize?: boolean, scrollOn?: ('document'|Element)[], resizeOn?: ('window'|Element)[] } }} [options.bodyHeightDynamic] - When set, body size is computed by get(table) and re-applied when scroll/resize sources fire. updateOn: scrollOn/resizeOn list elements (sentinels 'document'/'window'); or use scroll (default false) / resize (default true) booleans.
|
|
2445
|
+
* @param {string} [options.gridTemplateColumns]
|
|
2446
|
+
* @param {{ thead?: string, tbody?: string, tfoot?: string }} [options.gridTemplateRows]
|
|
2447
|
+
* @param {{ thead?: Object<number, string>|(string|null)[], tbody?: Object<number, string>|(string|null)[], tfoot?: Object<number, string>|(string|null)[] }} [options.rowOverrides]
|
|
2448
|
+
* @param {Object<number, string>|(string|null)[]} [options.columnOverrides]
|
|
2449
|
+
* @param {{ columnWidths?: number[], rowHeights?: { thead?: number[], tbody?: number[], tfoot?: number[] } } | undefined} ref - existing ref when refreshing
|
|
2072
2450
|
*/
|
|
2073
|
-
function applyScrollableTable(table, options) {
|
|
2451
|
+
function applyScrollableTable(table, options, ref) {
|
|
2452
|
+
var _ref$columnWidths, _ref$rowHeights;
|
|
2074
2453
|
var thead = table.querySelector('thead');
|
|
2075
2454
|
var tbody = table.querySelector('tbody');
|
|
2076
2455
|
var tfoot = table.querySelector('tfoot');
|
|
2077
2456
|
var numCols = getTableColumnCount(table);
|
|
2078
2457
|
if (numCols === 0) return;
|
|
2458
|
+
var alreadyScrollable = table.classList.contains(CLASS_TABLE);
|
|
2459
|
+
var customTemplate = typeof options.gridTemplateColumns === 'string' && options.gridTemplateColumns.trim().length > 0;
|
|
2460
|
+
var columnWidths = customTemplate ? null : (_ref$columnWidths = ref === null || ref === void 0 ? void 0 : ref.columnWidths) !== null && _ref$columnWidths !== void 0 ? _ref$columnWidths : alreadyScrollable ? null : measureColumnWidths(table, numCols);
|
|
2079
2461
|
var theadRows = getRowCount(thead);
|
|
2080
2462
|
var tbodyRows = getRowCount(tbody);
|
|
2081
2463
|
var tfootRows = getRowCount(tfoot);
|
|
2464
|
+
var rowHeights = (_ref$rowHeights = ref === null || ref === void 0 ? void 0 : ref.rowHeights) !== null && _ref$rowHeights !== void 0 ? _ref$rowHeights : alreadyScrollable ? null : {
|
|
2465
|
+
thead: measureRowHeights(thead),
|
|
2466
|
+
tbody: measureRowHeights(tbody),
|
|
2467
|
+
tfoot: measureRowHeights(tfoot)
|
|
2468
|
+
};
|
|
2082
2469
|
table.style.setProperty('--apx-scrollable-cols', String(numCols));
|
|
2083
2470
|
table.style.setProperty('--apx-scrollable-thead-rows', String(Math.max(1, theadRows)));
|
|
2084
2471
|
table.style.setProperty('--apx-scrollable-tbody-rows', String(Math.max(1, tbodyRows)));
|
|
2085
2472
|
table.style.setProperty('--apx-scrollable-tfoot-rows', String(Math.max(1, tfootRows)));
|
|
2086
|
-
|
|
2473
|
+
var _resolveBodyHeight2 = resolveBodyHeight(options, table),
|
|
2474
|
+
bodySize = _resolveBodyHeight2.bodySize,
|
|
2475
|
+
useFixedHeight = _resolveBodyHeight2.useFixedHeight;
|
|
2476
|
+
table.style.setProperty('--apx-scrollable-body-max-height', bodySize);
|
|
2477
|
+
table.classList.toggle('apx-scrollable-table--body-height', useFixedHeight);
|
|
2087
2478
|
table.classList.add(CLASS_TABLE);
|
|
2088
2479
|
table.classList.toggle('apx-scrollable-table--has-tfoot', !!(tfoot && tfootRows > 0));
|
|
2089
2480
|
table.classList.toggle('apx-scrollable-table--no-thead', !(thead && theadRows > 0));
|
|
2481
|
+
|
|
2482
|
+
// Force reflow so the grid layout is established before setting measured template-columns.
|
|
2483
|
+
// Without this, the browser batches class + template into one pass and the tbody overflows horizontally.
|
|
2484
|
+
table.offsetHeight; // eslint-disable-line no-unused-expressions
|
|
2485
|
+
|
|
2486
|
+
var gutterSuffix = ' minmax(var(--apx-scrollable-gutter-width, 17px), var(--apx-scrollable-gutter-width, 17px))';
|
|
2487
|
+
if (customTemplate) {
|
|
2488
|
+
table.style.setProperty('--apx-scrollable-template-columns', options.gridTemplateColumns.trim() + gutterSuffix);
|
|
2489
|
+
} else if (columnWidths && columnWidths.length === numCols) {
|
|
2490
|
+
var template = options.columnOverrides != null ? buildTemplateColumns(numCols, columnWidths, options.columnOverrides) : columnWidths.map(function (w) {
|
|
2491
|
+
return "".concat(Math.round(w), "fr");
|
|
2492
|
+
}).join(' ');
|
|
2493
|
+
table.style.setProperty('--apx-scrollable-template-columns', template + gutterSuffix);
|
|
2494
|
+
} else {
|
|
2495
|
+
table.style.removeProperty('--apx-scrollable-template-columns');
|
|
2496
|
+
}
|
|
2090
2497
|
clearPlacements(table);
|
|
2091
2498
|
var sections = [{
|
|
2092
2499
|
section: thead,
|
|
2093
|
-
rows: Math.max(1, theadRows)
|
|
2500
|
+
rows: Math.max(1, theadRows),
|
|
2501
|
+
heights: rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.thead,
|
|
2502
|
+
key: 'thead'
|
|
2094
2503
|
}, {
|
|
2095
2504
|
section: tbody,
|
|
2096
|
-
rows: Math.max(1, tbodyRows)
|
|
2505
|
+
rows: Math.max(1, tbodyRows),
|
|
2506
|
+
heights: rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.tbody,
|
|
2507
|
+
key: 'tbody'
|
|
2097
2508
|
}, {
|
|
2098
2509
|
section: tfoot,
|
|
2099
|
-
rows: Math.max(1, tfootRows)
|
|
2510
|
+
rows: Math.max(1, tfootRows),
|
|
2511
|
+
heights: rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.tfoot,
|
|
2512
|
+
key: 'tfoot'
|
|
2100
2513
|
}];
|
|
2514
|
+
var customRows = options.gridTemplateRows && _typeof(options.gridTemplateRows) === 'object' ? options.gridTemplateRows : null;
|
|
2515
|
+
var rowOverrides = options.rowOverrides && _typeof(options.rowOverrides) === 'object' ? options.rowOverrides : null;
|
|
2101
2516
|
sections.forEach(function (_ref2) {
|
|
2102
2517
|
var section = _ref2.section,
|
|
2103
|
-
rows = _ref2.rows
|
|
2518
|
+
rows = _ref2.rows,
|
|
2519
|
+
heights = _ref2.heights,
|
|
2520
|
+
key = _ref2.key;
|
|
2104
2521
|
if (!section) return;
|
|
2522
|
+
var varName = "--apx-scrollable-".concat(key, "-template-rows");
|
|
2523
|
+
var custom = customRows === null || customRows === void 0 ? void 0 : customRows[key];
|
|
2524
|
+
var overrides = rowOverrides === null || rowOverrides === void 0 ? void 0 : rowOverrides[key];
|
|
2525
|
+
if (typeof custom === 'string' && custom.trim().length > 0) {
|
|
2526
|
+
section.style.setProperty(varName, custom.trim());
|
|
2527
|
+
} else if (heights && heights.length >= rows) {
|
|
2528
|
+
var _template = overrides != null ? buildTemplateRows(rows, heights.slice(0, rows), overrides) : heights.slice(0, rows).map(function (h) {
|
|
2529
|
+
return "".concat(Math.round(h), "px");
|
|
2530
|
+
}).join(' ');
|
|
2531
|
+
section.style.setProperty(varName, _template);
|
|
2532
|
+
} else {
|
|
2533
|
+
section.style.removeProperty(varName);
|
|
2534
|
+
}
|
|
2105
2535
|
var placements = computeCellPlacements(section, rows, numCols);
|
|
2106
2536
|
applyPlacements(placements);
|
|
2107
2537
|
});
|
|
2538
|
+
return {
|
|
2539
|
+
columnWidths: columnWidths,
|
|
2540
|
+
rowHeights: rowHeights
|
|
2541
|
+
};
|
|
2108
2542
|
}
|
|
2109
2543
|
|
|
2110
2544
|
/**
|
|
@@ -2126,18 +2560,26 @@ function augmentWithScrollableTable(apx) {
|
|
|
2126
2560
|
var ref = table[DATA_KEY];
|
|
2127
2561
|
if (ref) {
|
|
2128
2562
|
if (isRefresh) {
|
|
2129
|
-
applyScrollableTable(table, ref.options);
|
|
2563
|
+
applyScrollableTable(table, ref.options, ref);
|
|
2130
2564
|
} else if (options && Object.keys(options).length > 0) {
|
|
2131
2565
|
ref.options = _objectSpread(_objectSpread({}, ref.options), options);
|
|
2132
|
-
applyScrollableTable(table, ref.options);
|
|
2566
|
+
var _result = applyScrollableTable(table, ref.options, ref);
|
|
2567
|
+
if (_result !== null && _result !== void 0 && _result.columnWidths) ref.columnWidths = _result.columnWidths;
|
|
2568
|
+
if (_result !== null && _result !== void 0 && _result.rowHeights) ref.rowHeights = _result.rowHeights;
|
|
2133
2569
|
}
|
|
2570
|
+
var currentOptions = ref.options;
|
|
2571
|
+
if (currentOptions !== null && currentOptions !== void 0 && currentOptions.bodyHeightDynamic) registerDynamicTable(table, currentOptions);else removeTableFromDynamicSources(table);
|
|
2134
2572
|
return;
|
|
2135
2573
|
}
|
|
2136
2574
|
if (isRefresh) return;
|
|
2137
|
-
|
|
2575
|
+
console.log('[APX scrollableTable] create', table);
|
|
2576
|
+
var result = applyScrollableTable(table, options, undefined);
|
|
2138
2577
|
table[DATA_KEY] = {
|
|
2139
|
-
options: _objectSpread({}, options)
|
|
2578
|
+
options: _objectSpread({}, options),
|
|
2579
|
+
columnWidths: (result === null || result === void 0 ? void 0 : result.columnWidths) || undefined,
|
|
2580
|
+
rowHeights: (result === null || result === void 0 ? void 0 : result.rowHeights) || undefined
|
|
2140
2581
|
};
|
|
2582
|
+
if (options !== null && options !== void 0 && options.bodyHeightDynamic) registerDynamicTable(table, options);
|
|
2141
2583
|
});
|
|
2142
2584
|
return apx;
|
|
2143
2585
|
};
|