handsontable 0.0.0-next-9a52a6a-20241128 → 0.0.0-next-b3759c7-20241203
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of handsontable might be problematic. Click here for more details.
- package/3rdparty/walkontable/src/calculator/index.js +1 -2
- package/3rdparty/walkontable/src/calculator/index.mjs +2 -2
- package/3rdparty/walkontable/src/calculator/viewportRows.js +3 -3
- package/3rdparty/walkontable/src/calculator/viewportRows.mjs +3 -3
- package/3rdparty/walkontable/src/core/_base.js +3 -0
- package/3rdparty/walkontable/src/core/_base.mjs +3 -0
- package/3rdparty/walkontable/src/core/clone.js +1 -0
- package/3rdparty/walkontable/src/core/clone.mjs +1 -0
- package/3rdparty/walkontable/src/core/core.js +2 -0
- package/3rdparty/walkontable/src/core/core.mjs +2 -0
- package/3rdparty/walkontable/src/facade/core.js +3 -0
- package/3rdparty/walkontable/src/facade/core.mjs +3 -0
- package/3rdparty/walkontable/src/index.js +0 -1
- package/3rdparty/walkontable/src/index.mjs +2 -2
- package/3rdparty/walkontable/src/overlay/_base.js +3 -1
- package/3rdparty/walkontable/src/overlay/_base.mjs +3 -1
- package/3rdparty/walkontable/src/overlay/bottom.js +2 -2
- package/3rdparty/walkontable/src/overlay/bottom.mjs +2 -2
- package/3rdparty/walkontable/src/overlay/inlineStart.js +2 -1
- package/3rdparty/walkontable/src/overlay/inlineStart.mjs +3 -2
- package/3rdparty/walkontable/src/overlay/top.js +3 -2
- package/3rdparty/walkontable/src/overlay/top.mjs +4 -3
- package/3rdparty/walkontable/src/renderer/index.js +4 -2
- package/3rdparty/walkontable/src/renderer/index.mjs +4 -2
- package/3rdparty/walkontable/src/renderer/table.js +12 -3
- package/3rdparty/walkontable/src/renderer/table.mjs +12 -3
- package/3rdparty/walkontable/src/selection/border/border.js +19 -13
- package/3rdparty/walkontable/src/selection/border/border.mjs +19 -13
- package/3rdparty/walkontable/src/selection/border/utils.js +26 -0
- package/3rdparty/walkontable/src/selection/border/utils.mjs +22 -0
- package/3rdparty/walkontable/src/selection/index.js +4 -4
- package/3rdparty/walkontable/src/selection/index.mjs +1 -1
- package/3rdparty/walkontable/src/settings.js +0 -2
- package/3rdparty/walkontable/src/settings.mjs +0 -2
- package/3rdparty/walkontable/src/table.js +17 -9
- package/3rdparty/walkontable/src/table.mjs +17 -9
- package/3rdparty/walkontable/src/types.js +1 -0
- package/3rdparty/walkontable/src/types.mjs +1 -0
- package/3rdparty/walkontable/src/utils/column.js +1 -1
- package/3rdparty/walkontable/src/utils/column.mjs +1 -1
- package/3rdparty/walkontable/src/utils/stylesHandler.js +295 -0
- package/3rdparty/walkontable/src/utils/stylesHandler.mjs +291 -0
- package/3rdparty/walkontable/src/viewport.js +1 -0
- package/3rdparty/walkontable/src/viewport.mjs +1 -0
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/core/hooks/constants.js +9 -0
- package/core/hooks/constants.mjs +9 -0
- package/core/hooks/index.d.ts +1 -0
- package/core.d.ts +2 -0
- package/core.js +50 -1
- package/core.mjs +50 -1
- package/dataMap/metaManager/metaSchema.js +23 -3
- package/dataMap/metaManager/metaSchema.mjs +23 -3
- package/dist/handsontable.css +84 -72
- package/dist/handsontable.full.css +317 -304
- package/dist/handsontable.full.js +5888 -5727
- package/dist/handsontable.full.min.css +15 -10
- package/dist/handsontable.full.min.js +54 -53
- package/dist/handsontable.js +4337 -3944
- package/dist/handsontable.min.css +10 -6
- package/dist/handsontable.min.js +32 -32
- package/editors/autocompleteEditor/autocompleteEditor.js +1 -1
- package/editors/autocompleteEditor/autocompleteEditor.mjs +1 -1
- package/editors/baseEditor/baseEditor.js +1 -1
- package/editors/baseEditor/baseEditor.mjs +1 -1
- package/editors/dateEditor/dateEditor.js +9 -0
- package/editors/dateEditor/dateEditor.mjs +10 -1
- package/editors/handsontableEditor/handsontableEditor.js +7 -1
- package/editors/handsontableEditor/handsontableEditor.mjs +7 -1
- package/editors/selectEditor/selectEditor.js +20 -9
- package/editors/selectEditor/selectEditor.mjs +20 -9
- package/editors/textEditor/textEditor.js +4 -11
- package/editors/textEditor/textEditor.mjs +4 -11
- package/helpers/dom/element.js +32 -1
- package/helpers/dom/element.mjs +31 -1
- package/helpers/mixed.js +2 -2
- package/helpers/mixed.mjs +2 -2
- package/helpers/themes.js +17 -0
- package/helpers/themes.mjs +13 -0
- package/package.json +12 -3
- package/plugins/comments/commentEditor.js +9 -0
- package/plugins/comments/commentEditor.mjs +9 -0
- package/plugins/comments/comments.js +14 -0
- package/plugins/comments/comments.mjs +15 -1
- package/plugins/contextMenu/menu/menu.js +9 -4
- package/plugins/contextMenu/menu/menu.mjs +9 -4
- package/plugins/filters/ui/multipleSelect.js +6 -0
- package/plugins/filters/ui/multipleSelect.mjs +6 -0
- package/plugins/manualRowMove/manualRowMove.js +1 -1
- package/plugins/manualRowMove/manualRowMove.mjs +1 -1
- package/plugins/manualRowResize/manualRowResize.js +1 -2
- package/plugins/manualRowResize/manualRowResize.mjs +2 -3
- package/plugins/mergeCells/mergeCells.js +1 -1
- package/plugins/mergeCells/mergeCells.mjs +1 -1
- package/plugins/nestedRows/ui/headers.js +7 -1
- package/plugins/nestedRows/ui/headers.mjs +7 -1
- package/plugins/stretchColumns/calculator.js +2 -1
- package/plugins/stretchColumns/calculator.mjs +3 -2
- package/settings.d.ts +1 -0
- package/styles/handsontable.css +2307 -0
- package/styles/handsontable.min.css +30 -0
- package/styles/ht-theme-horizon.css +607 -0
- package/styles/ht-theme-horizon.min.css +30 -0
- package/styles/ht-theme-main.css +613 -0
- package/styles/ht-theme-main.min.css +30 -0
- package/tableView.js +67 -0
- package/tableView.mjs +68 -1
- package/utils/autoResize.js +4 -1
- package/utils/autoResize.mjs +4 -1
- package/utils/ghostTable.js +5 -3
- package/utils/ghostTable.mjs +5 -3
- package/3rdparty/walkontable/src/selection/border/constants.js +0 -15
- package/3rdparty/walkontable/src/selection/border/constants.mjs +0 -12
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
const getCornerStyle = wot => {
|
5
|
+
const stylesHandler = wot.stylesHandler;
|
6
|
+
if (stylesHandler.isClassicTheme()) {
|
7
|
+
return Object.freeze({
|
8
|
+
width: 6,
|
9
|
+
height: 6,
|
10
|
+
borderWidth: 1,
|
11
|
+
borderStyle: 'solid',
|
12
|
+
borderColor: '#FFF'
|
13
|
+
});
|
14
|
+
}
|
15
|
+
const cornerSizeFromVar = stylesHandler.getCSSVariableValue('cell-autofill-size');
|
16
|
+
const cornerBorderWidthFromVar = stylesHandler.getCSSVariableValue('cell-autofill-border-width');
|
17
|
+
const cornerColorFromVar = stylesHandler.getCSSVariableValue('cell-autofill-border-color');
|
18
|
+
return Object.freeze({
|
19
|
+
width: cornerSizeFromVar,
|
20
|
+
height: cornerSizeFromVar,
|
21
|
+
borderWidth: cornerBorderWidthFromVar,
|
22
|
+
borderStyle: 'solid',
|
23
|
+
borderColor: cornerColorFromVar
|
24
|
+
});
|
25
|
+
};
|
26
|
+
exports.getCornerStyle = getCornerStyle;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
export const getCornerStyle = wot => {
|
2
|
+
const stylesHandler = wot.stylesHandler;
|
3
|
+
if (stylesHandler.isClassicTheme()) {
|
4
|
+
return Object.freeze({
|
5
|
+
width: 6,
|
6
|
+
height: 6,
|
7
|
+
borderWidth: 1,
|
8
|
+
borderStyle: 'solid',
|
9
|
+
borderColor: '#FFF'
|
10
|
+
});
|
11
|
+
}
|
12
|
+
const cornerSizeFromVar = stylesHandler.getCSSVariableValue('cell-autofill-size');
|
13
|
+
const cornerBorderWidthFromVar = stylesHandler.getCSSVariableValue('cell-autofill-border-width');
|
14
|
+
const cornerColorFromVar = stylesHandler.getCSSVariableValue('cell-autofill-border-color');
|
15
|
+
return Object.freeze({
|
16
|
+
width: cornerSizeFromVar,
|
17
|
+
height: cornerSizeFromVar,
|
18
|
+
borderWidth: cornerBorderWidthFromVar,
|
19
|
+
borderStyle: 'solid',
|
20
|
+
borderColor: cornerColorFromVar
|
21
|
+
});
|
22
|
+
};
|
@@ -16,12 +16,12 @@ Object.keys(_constants).forEach(function (key) {
|
|
16
16
|
if (key in exports && exports[key] === _constants[key]) return;
|
17
17
|
exports[key] = _constants[key];
|
18
18
|
});
|
19
|
-
var
|
20
|
-
Object.keys(
|
19
|
+
var _utils = require("./border/utils");
|
20
|
+
Object.keys(_utils).forEach(function (key) {
|
21
21
|
if (key === "default" || key === "__esModule") return;
|
22
22
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
23
|
-
if (key in exports && exports[key] ===
|
24
|
-
exports[key] =
|
23
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
24
|
+
exports[key] = _utils[key];
|
25
25
|
});
|
26
26
|
var _manager = require("./manager");
|
27
27
|
exports.SelectionManager = _manager.SelectionManager;
|
@@ -19,7 +19,6 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
19
19
|
* @property {Option} currentRowClassName Option `currentRowClassName`.
|
20
20
|
* @property {Option} data Option `data`.
|
21
21
|
* @property {Option} defaultColumnWidth Option `defaultColumnWidth`.
|
22
|
-
* @property {Option} defaultRowHeight Option `defaultRowHeight`.
|
23
22
|
* @property {Option} externalRowCalculator Option `externalRowCalculator`.
|
24
23
|
* @property {Option} fixedColumnsStart Option `fixedColumnsStart`.
|
25
24
|
* @property {Option} fixedRowsBottom Option `fixedRowsBottom`.
|
@@ -185,7 +184,6 @@ class Settings {
|
|
185
184
|
rowHeightByOverlayName() {
|
186
185
|
// return undefined means use default size for the rendered cell content
|
187
186
|
},
|
188
|
-
defaultRowHeight: 23,
|
189
187
|
defaultColumnWidth: 50,
|
190
188
|
selections: null,
|
191
189
|
hideBorderOnMouseDownOver: false,
|
@@ -16,7 +16,6 @@ import { objectEach } from "../../../helpers/object.mjs";
|
|
16
16
|
* @property {Option} currentRowClassName Option `currentRowClassName`.
|
17
17
|
* @property {Option} data Option `data`.
|
18
18
|
* @property {Option} defaultColumnWidth Option `defaultColumnWidth`.
|
19
|
-
* @property {Option} defaultRowHeight Option `defaultRowHeight`.
|
20
19
|
* @property {Option} externalRowCalculator Option `externalRowCalculator`.
|
21
20
|
* @property {Option} fixedColumnsStart Option `fixedColumnsStart`.
|
22
21
|
* @property {Option} fixedRowsBottom Option `fixedRowsBottom`.
|
@@ -180,7 +179,6 @@ export default class Settings {
|
|
180
179
|
rowHeightByOverlayName() {
|
181
180
|
// return undefined means use default size for the rendered cell content
|
182
181
|
},
|
183
|
-
defaultRowHeight: 23,
|
184
182
|
defaultColumnWidth: 50,
|
185
183
|
selections: null,
|
186
184
|
hideBorderOnMouseDownOver: false,
|
@@ -117,7 +117,8 @@ class Table {
|
|
117
117
|
TBODY: this.TBODY,
|
118
118
|
rowUtils: this.rowUtils,
|
119
119
|
columnUtils: this.columnUtils,
|
120
|
-
cellRenderer: this.wtSettings.getSettingPure('cellRenderer')
|
120
|
+
cellRenderer: this.wtSettings.getSettingPure('cellRenderer'),
|
121
|
+
stylesHandler: this.dataAccessObject.stylesHandler
|
121
122
|
});
|
122
123
|
}
|
123
124
|
|
@@ -353,7 +354,7 @@ class Table {
|
|
353
354
|
markIfOversizedColumnHeader(col) {
|
354
355
|
const sourceColIndex = this.columnFilter.renderedToSource(col);
|
355
356
|
let level = this.wtSettings.getSetting('columnHeaders').length;
|
356
|
-
const defaultRowHeight = this.
|
357
|
+
const defaultRowHeight = this.dataAccessObject.stylesHandler.getDefaultRowHeight();
|
357
358
|
let previousColHeaderHeight;
|
358
359
|
let currentHeader;
|
359
360
|
let currentHeaderHeight;
|
@@ -631,10 +632,14 @@ class Table {
|
|
631
632
|
return;
|
632
633
|
}
|
633
634
|
let rowCount = this.TBODY.childNodes.length;
|
634
|
-
const expectedTableHeight = rowCount * this.
|
635
|
+
const expectedTableHeight = rowCount * this.dataAccessObject.stylesHandler.getDefaultRowHeight();
|
635
636
|
const actualTableHeight = (0, _element.innerHeight)(this.TBODY) - 1;
|
637
|
+
const borderBoxSizing = this.wot.stylesHandler.areCellsBorderBox();
|
638
|
+
const rowHeightFn = borderBoxSizing ? _element.outerHeight : _element.innerHeight;
|
639
|
+
const borderCompensation = borderBoxSizing ? 0 : 1;
|
640
|
+
const firstRowBorderCompensation = borderBoxSizing ? 1 : 0;
|
636
641
|
let previousRowHeight;
|
637
|
-
let
|
642
|
+
let rowCurrentHeight;
|
638
643
|
let sourceRowIndex;
|
639
644
|
let currentTr;
|
640
645
|
let rowHeader;
|
@@ -648,14 +653,17 @@ class Table {
|
|
648
653
|
previousRowHeight = this.getRowHeight(sourceRowIndex);
|
649
654
|
currentTr = this.getTrForRow(sourceRowIndex);
|
650
655
|
rowHeader = currentTr.querySelector('th');
|
656
|
+
const topBorderCompensation = sourceRowIndex === 0 ? firstRowBorderCompensation : 0;
|
651
657
|
if (rowHeader) {
|
652
|
-
|
658
|
+
rowCurrentHeight = rowHeightFn(rowHeader);
|
653
659
|
} else {
|
654
|
-
|
660
|
+
rowCurrentHeight = rowHeightFn(currentTr) - borderCompensation;
|
655
661
|
}
|
656
|
-
if (!previousRowHeight && this.
|
657
|
-
|
658
|
-
|
662
|
+
if (!previousRowHeight && this.dataAccessObject.stylesHandler.getDefaultRowHeight() < rowCurrentHeight - topBorderCompensation || previousRowHeight < rowCurrentHeight) {
|
663
|
+
if (!borderBoxSizing) {
|
664
|
+
rowCurrentHeight += 1;
|
665
|
+
}
|
666
|
+
this.dataAccessObject.wtViewport.oversizedRows[sourceRowIndex] = rowCurrentHeight;
|
659
667
|
}
|
660
668
|
}
|
661
669
|
}
|
@@ -113,7 +113,8 @@ class Table {
|
|
113
113
|
TBODY: this.TBODY,
|
114
114
|
rowUtils: this.rowUtils,
|
115
115
|
columnUtils: this.columnUtils,
|
116
|
-
cellRenderer: this.wtSettings.getSettingPure('cellRenderer')
|
116
|
+
cellRenderer: this.wtSettings.getSettingPure('cellRenderer'),
|
117
|
+
stylesHandler: this.dataAccessObject.stylesHandler
|
117
118
|
});
|
118
119
|
}
|
119
120
|
|
@@ -349,7 +350,7 @@ class Table {
|
|
349
350
|
markIfOversizedColumnHeader(col) {
|
350
351
|
const sourceColIndex = this.columnFilter.renderedToSource(col);
|
351
352
|
let level = this.wtSettings.getSetting('columnHeaders').length;
|
352
|
-
const defaultRowHeight = this.
|
353
|
+
const defaultRowHeight = this.dataAccessObject.stylesHandler.getDefaultRowHeight();
|
353
354
|
let previousColHeaderHeight;
|
354
355
|
let currentHeader;
|
355
356
|
let currentHeaderHeight;
|
@@ -627,10 +628,14 @@ class Table {
|
|
627
628
|
return;
|
628
629
|
}
|
629
630
|
let rowCount = this.TBODY.childNodes.length;
|
630
|
-
const expectedTableHeight = rowCount * this.
|
631
|
+
const expectedTableHeight = rowCount * this.dataAccessObject.stylesHandler.getDefaultRowHeight();
|
631
632
|
const actualTableHeight = innerHeight(this.TBODY) - 1;
|
633
|
+
const borderBoxSizing = this.wot.stylesHandler.areCellsBorderBox();
|
634
|
+
const rowHeightFn = borderBoxSizing ? outerHeight : innerHeight;
|
635
|
+
const borderCompensation = borderBoxSizing ? 0 : 1;
|
636
|
+
const firstRowBorderCompensation = borderBoxSizing ? 1 : 0;
|
632
637
|
let previousRowHeight;
|
633
|
-
let
|
638
|
+
let rowCurrentHeight;
|
634
639
|
let sourceRowIndex;
|
635
640
|
let currentTr;
|
636
641
|
let rowHeader;
|
@@ -644,14 +649,17 @@ class Table {
|
|
644
649
|
previousRowHeight = this.getRowHeight(sourceRowIndex);
|
645
650
|
currentTr = this.getTrForRow(sourceRowIndex);
|
646
651
|
rowHeader = currentTr.querySelector('th');
|
652
|
+
const topBorderCompensation = sourceRowIndex === 0 ? firstRowBorderCompensation : 0;
|
647
653
|
if (rowHeader) {
|
648
|
-
|
654
|
+
rowCurrentHeight = rowHeightFn(rowHeader);
|
649
655
|
} else {
|
650
|
-
|
656
|
+
rowCurrentHeight = rowHeightFn(currentTr) - borderCompensation;
|
651
657
|
}
|
652
|
-
if (!previousRowHeight && this.
|
653
|
-
|
654
|
-
|
658
|
+
if (!previousRowHeight && this.dataAccessObject.stylesHandler.getDefaultRowHeight() < rowCurrentHeight - topBorderCompensation || previousRowHeight < rowCurrentHeight) {
|
659
|
+
if (!borderBoxSizing) {
|
660
|
+
rowCurrentHeight += 1;
|
661
|
+
}
|
662
|
+
this.dataAccessObject.wtViewport.oversizedRows[sourceRowIndex] = rowCurrentHeight;
|
655
663
|
}
|
656
664
|
}
|
657
665
|
}
|
@@ -66,6 +66,7 @@
|
|
66
66
|
* @property {Walkontable} cloneSource CloneSource.
|
67
67
|
* @property {Walkontable} wot Wot.
|
68
68
|
* @property {number} parentTableOffset ParentTableOffset.
|
69
|
+
* @property {StylesHandler} stylesHandler StylesHandler.
|
69
70
|
* @property {number|null} startColumnRendered StartColumnRendered.
|
70
71
|
* @property {number|null} startColumnVisible StartColumnVisible.
|
71
72
|
* @property {number|null} endColumnRendered EndColumnRendered.
|
@@ -66,6 +66,7 @@
|
|
66
66
|
* @property {Walkontable} cloneSource CloneSource.
|
67
67
|
* @property {Walkontable} wot Wot.
|
68
68
|
* @property {number} parentTableOffset ParentTableOffset.
|
69
|
+
* @property {StylesHandler} stylesHandler StylesHandler.
|
69
70
|
* @property {number|null} startColumnRendered StartColumnRendered.
|
70
71
|
* @property {number|null} startColumnVisible StartColumnVisible.
|
71
72
|
* @property {number|null} endColumnRendered EndColumnRendered.
|
@@ -50,7 +50,7 @@ class ColumnUtils {
|
|
50
50
|
* @returns {number}
|
51
51
|
*/
|
52
52
|
getHeaderHeight(level) {
|
53
|
-
let height = this.
|
53
|
+
let height = this.dataAccessObject.stylesHandler.getDefaultRowHeight();
|
54
54
|
const oversizedHeight = this.dataAccessObject.wtViewport.oversizedColumnHeaders[level];
|
55
55
|
if (oversizedHeight !== undefined) {
|
56
56
|
height = height ? Math.max(height, oversizedHeight) : oversizedHeight;
|
@@ -47,7 +47,7 @@ export default class ColumnUtils {
|
|
47
47
|
* @returns {number}
|
48
48
|
*/
|
49
49
|
getHeaderHeight(level) {
|
50
|
-
let height = this.
|
50
|
+
let height = this.dataAccessObject.stylesHandler.getDefaultRowHeight();
|
51
51
|
const oversizedHeight = this.dataAccessObject.wtViewport.oversizedColumnHeaders[level];
|
52
52
|
if (oversizedHeight !== undefined) {
|
53
53
|
height = height ? Math.max(height, oversizedHeight) : oversizedHeight;
|
@@ -0,0 +1,295 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
require("core-js/modules/es.error.cause.js");
|
5
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
6
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
7
|
+
var _element = require("../../../../helpers/dom/element");
|
8
|
+
var _console = require("../../../../helpers/console");
|
9
|
+
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
10
|
+
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
11
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
12
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
13
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
14
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
15
|
+
const CLASSIC_THEME_DEFAULT_HEIGHT = 23;
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Handles the theme-related style operations.
|
19
|
+
*/
|
20
|
+
var _themeName = /*#__PURE__*/new WeakMap();
|
21
|
+
var _rootElement = /*#__PURE__*/new WeakMap();
|
22
|
+
var _rootComputedStyle = /*#__PURE__*/new WeakMap();
|
23
|
+
var _rootDocument = /*#__PURE__*/new WeakMap();
|
24
|
+
var _isClassicTheme = /*#__PURE__*/new WeakMap();
|
25
|
+
var _cssVars = /*#__PURE__*/new WeakMap();
|
26
|
+
var _computedStyles = /*#__PURE__*/new WeakMap();
|
27
|
+
var _StylesHandler_brand = /*#__PURE__*/new WeakSet();
|
28
|
+
class StylesHandler {
|
29
|
+
/**
|
30
|
+
* Initializes a new instance of the `StylesHandler` class.
|
31
|
+
*
|
32
|
+
* @param {object} domBindings - The DOM bindings for the instance.
|
33
|
+
*/
|
34
|
+
constructor(domBindings) {
|
35
|
+
/**
|
36
|
+
* Calculates the row height based on the current theme and CSS variables.
|
37
|
+
*
|
38
|
+
* @returns {number|null} The calculated row height, or `null` if any required CSS variable is not found.
|
39
|
+
*/
|
40
|
+
_classPrivateMethodInitSpec(this, _StylesHandler_brand);
|
41
|
+
/**
|
42
|
+
* The name of the theme.
|
43
|
+
*
|
44
|
+
* @type {string|undefined}
|
45
|
+
*/
|
46
|
+
_classPrivateFieldInitSpec(this, _themeName, void 0);
|
47
|
+
/**
|
48
|
+
* The instance's root element.
|
49
|
+
*
|
50
|
+
* @type {HTMLElement}
|
51
|
+
*/
|
52
|
+
_classPrivateFieldInitSpec(this, _rootElement, void 0);
|
53
|
+
/**
|
54
|
+
* The computed style of the root element.
|
55
|
+
*
|
56
|
+
* @type {CSSStyleDeclaration}
|
57
|
+
* @private
|
58
|
+
*/
|
59
|
+
_classPrivateFieldInitSpec(this, _rootComputedStyle, void 0);
|
60
|
+
/**
|
61
|
+
* The root document of the instance.
|
62
|
+
*
|
63
|
+
* @type {Document}
|
64
|
+
* @private
|
65
|
+
*/
|
66
|
+
_classPrivateFieldInitSpec(this, _rootDocument, void 0);
|
67
|
+
/**
|
68
|
+
* `true` if the classic theme is enabled, `false` otherwise.
|
69
|
+
*
|
70
|
+
* @type {boolean}
|
71
|
+
*/
|
72
|
+
_classPrivateFieldInitSpec(this, _isClassicTheme, true);
|
73
|
+
/**
|
74
|
+
* An object to store CSS variable values.
|
75
|
+
*
|
76
|
+
* @type {object}
|
77
|
+
* @private
|
78
|
+
*/
|
79
|
+
_classPrivateFieldInitSpec(this, _cssVars, {});
|
80
|
+
/**
|
81
|
+
* Stores the computed styles for various elements.
|
82
|
+
*
|
83
|
+
* @type {object} - An object containing the computed styles if a nested structore of `element: { [element type]: {property: value} }`.
|
84
|
+
* @private
|
85
|
+
*/
|
86
|
+
_classPrivateFieldInitSpec(this, _computedStyles, {});
|
87
|
+
_classPrivateFieldSet(_rootElement, this, domBindings.rootTable.parentElement.parentElement);
|
88
|
+
_classPrivateFieldSet(_rootDocument, this, domBindings.rootDocument);
|
89
|
+
}
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Gets the value indicating whether the classic theme is enabled.
|
93
|
+
*
|
94
|
+
* @returns {boolean} `true` if the classic theme is enabled, `false` otherwise.
|
95
|
+
*/
|
96
|
+
isClassicTheme() {
|
97
|
+
return _classPrivateFieldGet(_isClassicTheme, this);
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Retrieves the value of a specified CSS variable.
|
102
|
+
*
|
103
|
+
* @param {string} variableName - The name of the CSS variable to retrieve.
|
104
|
+
* @returns {number|null|undefined} The value of the specified CSS variable, or `undefined` if not found.
|
105
|
+
*/
|
106
|
+
getCSSVariableValue(variableName) {
|
107
|
+
var _assertClassBrand$cal;
|
108
|
+
if (_classPrivateFieldGet(_isClassicTheme, this)) {
|
109
|
+
return null;
|
110
|
+
}
|
111
|
+
if (_classPrivateFieldGet(_cssVars, this)[`--ht-${variableName}`]) {
|
112
|
+
return _classPrivateFieldGet(_cssVars, this)[`--ht-${variableName}`];
|
113
|
+
}
|
114
|
+
const acquiredValue = (_assertClassBrand$cal = _assertClassBrand(_StylesHandler_brand, this, _getParsedNumericCSSValue).call(this, `--ht-${variableName}`)) !== null && _assertClassBrand$cal !== void 0 ? _assertClassBrand$cal : _assertClassBrand(_StylesHandler_brand, this, _getCSSValue).call(this, `--ht-${variableName}`);
|
115
|
+
if (acquiredValue !== null) {
|
116
|
+
_classPrivateFieldGet(_cssVars, this)[`--ht-${variableName}`] = acquiredValue;
|
117
|
+
return acquiredValue;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
/**
|
122
|
+
* Retrieves the computed style value for a specified CSS property of a `td` element.
|
123
|
+
*
|
124
|
+
* @param {string} cssProperty - The CSS property to retrieve the value for.
|
125
|
+
* @returns {number|string|undefined} The value of the specified CSS property, or `undefined` if not found.
|
126
|
+
*/
|
127
|
+
getStyleForTD(cssProperty) {
|
128
|
+
var _classPrivateFieldGet2;
|
129
|
+
return (_classPrivateFieldGet2 = _classPrivateFieldGet(_computedStyles, this)) === null || _classPrivateFieldGet2 === void 0 ? void 0 : _classPrivateFieldGet2.td[cssProperty];
|
130
|
+
}
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Calculates the row height based on the current theme and CSS variables.
|
134
|
+
*
|
135
|
+
* @returns {number} The calculated row height.
|
136
|
+
*/
|
137
|
+
getDefaultRowHeight() {
|
138
|
+
if (_classPrivateFieldGet(_isClassicTheme, this)) {
|
139
|
+
return CLASSIC_THEME_DEFAULT_HEIGHT;
|
140
|
+
}
|
141
|
+
const calculatedRowHeight = _assertClassBrand(_StylesHandler_brand, this, _calculateRowHeight).call(this);
|
142
|
+
if (!calculatedRowHeight && (0, _element.hasClass)(_classPrivateFieldGet(_rootElement, this), 'ht-wrapper')) {
|
143
|
+
(0, _console.warn)(`The "${_classPrivateFieldGet(_themeName, this)}" theme is enabled, but its stylesheets are missing or not imported correctly. \
|
144
|
+
Import the correct CSS files in order to use that theme.`);
|
145
|
+
_classPrivateFieldSet(_isClassicTheme, this, true);
|
146
|
+
this.useTheme();
|
147
|
+
return CLASSIC_THEME_DEFAULT_HEIGHT;
|
148
|
+
}
|
149
|
+
return calculatedRowHeight;
|
150
|
+
}
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Checks if the cells are using the `border-box` box-sizing model.
|
154
|
+
*
|
155
|
+
* @returns {boolean}
|
156
|
+
*/
|
157
|
+
areCellsBorderBox() {
|
158
|
+
return this.getStyleForTD('box-sizing') === 'border-box';
|
159
|
+
}
|
160
|
+
|
161
|
+
/**
|
162
|
+
* Applies the specified theme to the instance.
|
163
|
+
*
|
164
|
+
* @param {string|undefined|boolean} [themeName] - The name of the theme to apply.
|
165
|
+
*/
|
166
|
+
useTheme(themeName) {
|
167
|
+
if (!themeName) {
|
168
|
+
_assertClassBrand(_StylesHandler_brand, this, _cacheStylesheetValues).call(this);
|
169
|
+
_classPrivateFieldSet(_isClassicTheme, this, true);
|
170
|
+
_classPrivateFieldSet(_themeName, this, themeName || undefined);
|
171
|
+
return;
|
172
|
+
}
|
173
|
+
if (themeName && themeName !== _classPrivateFieldGet(_themeName, this)) {
|
174
|
+
if (_classPrivateFieldGet(_themeName, this)) {
|
175
|
+
_assertClassBrand(_StylesHandler_brand, this, _clearCachedValues).call(this);
|
176
|
+
}
|
177
|
+
_classPrivateFieldSet(_themeName, this, themeName);
|
178
|
+
_classPrivateFieldSet(_isClassicTheme, this, false);
|
179
|
+
_assertClassBrand(_StylesHandler_brand, this, _applyClassNames).call(this);
|
180
|
+
_assertClassBrand(_StylesHandler_brand, this, _cacheStylesheetValues).call(this);
|
181
|
+
}
|
182
|
+
}
|
183
|
+
|
184
|
+
/**
|
185
|
+
* Gets the name of the theme.
|
186
|
+
*
|
187
|
+
* @returns {string|undefined}
|
188
|
+
*/
|
189
|
+
getThemeName() {
|
190
|
+
return _classPrivateFieldGet(_themeName, this);
|
191
|
+
}
|
192
|
+
|
193
|
+
/**
|
194
|
+
* Removes the theme-related class names from the root element.
|
195
|
+
*/
|
196
|
+
removeClassNames() {
|
197
|
+
if ((0, _element.hasClass)(_classPrivateFieldGet(_rootElement, this), _classPrivateFieldGet(_themeName, this))) {
|
198
|
+
(0, _element.removeClass)(_classPrivateFieldGet(_rootElement, this), _classPrivateFieldGet(_themeName, this));
|
199
|
+
}
|
200
|
+
}
|
201
|
+
}
|
202
|
+
exports.StylesHandler = StylesHandler;
|
203
|
+
function _calculateRowHeight() {
|
204
|
+
const lineHeightVarValue = this.getCSSVariableValue('line-height');
|
205
|
+
const verticalPaddingVarValue = this.getCSSVariableValue('cell-vertical-padding');
|
206
|
+
const bottomBorderWidth = Math.ceil(parseFloat(this.getStyleForTD('border-bottom-width')));
|
207
|
+
if (lineHeightVarValue === null || verticalPaddingVarValue === null || isNaN(bottomBorderWidth)) {
|
208
|
+
return null;
|
209
|
+
}
|
210
|
+
return lineHeightVarValue + 2 * verticalPaddingVarValue + bottomBorderWidth;
|
211
|
+
}
|
212
|
+
/**
|
213
|
+
* Applies the necessary class names to the root element.
|
214
|
+
*/
|
215
|
+
function _applyClassNames() {
|
216
|
+
(0, _element.removeClass)(_classPrivateFieldGet(_rootElement, this), /ht-theme-.*/g);
|
217
|
+
(0, _element.addClass)(_classPrivateFieldGet(_rootElement, this), _classPrivateFieldGet(_themeName, this));
|
218
|
+
}
|
219
|
+
/**
|
220
|
+
* Caches the computed style values for the root element and `td` element.
|
221
|
+
*/
|
222
|
+
function _cacheStylesheetValues() {
|
223
|
+
if (!this.isClassicTheme()) {
|
224
|
+
_classPrivateFieldSet(_rootComputedStyle, this, getComputedStyle(_classPrivateFieldGet(_rootElement, this)));
|
225
|
+
}
|
226
|
+
const stylesForTD = _assertClassBrand(_StylesHandler_brand, this, _getStylesForTD).call(this, ['box-sizing', 'border-bottom-width']);
|
227
|
+
_classPrivateFieldGet(_computedStyles, this).td = {
|
228
|
+
..._classPrivateFieldGet(_computedStyles, this).td,
|
229
|
+
...{
|
230
|
+
'box-sizing': stylesForTD['box-sizing'],
|
231
|
+
'border-bottom-width': stylesForTD['border-bottom-width']
|
232
|
+
}
|
233
|
+
};
|
234
|
+
}
|
235
|
+
/**
|
236
|
+
* Retrieves and processes the computed styles for a `td` element.
|
237
|
+
*
|
238
|
+
* This method creates a temporary table structure, appends it to the root element,
|
239
|
+
* retrieves the computed styles for the `td` element, and then removes the table
|
240
|
+
* from the DOM. The computed styles are passed to the provided callback function.
|
241
|
+
*
|
242
|
+
* @param {Array} cssProps - An array of CSS properties to retrieve.
|
243
|
+
* @returns {object} An object containing the requested computed styles for the `td` element.
|
244
|
+
* @private
|
245
|
+
*/
|
246
|
+
function _getStylesForTD(cssProps) {
|
247
|
+
const rootDocument = _classPrivateFieldGet(_rootDocument, this);
|
248
|
+
const rootElement = _classPrivateFieldGet(_rootElement, this);
|
249
|
+
const table = rootDocument.createElement('table');
|
250
|
+
const tbody = rootDocument.createElement('tbody');
|
251
|
+
const tr = rootDocument.createElement('tr');
|
252
|
+
// This needs not to be the first row in order to get "regular" vaules.
|
253
|
+
const tr2 = rootDocument.createElement('tr');
|
254
|
+
const td = rootDocument.createElement('td');
|
255
|
+
tr2.appendChild(td);
|
256
|
+
tbody.appendChild(tr);
|
257
|
+
tbody.appendChild(tr2);
|
258
|
+
table.appendChild(tbody);
|
259
|
+
rootElement.appendChild(table);
|
260
|
+
const computedStyle = getComputedStyle(td);
|
261
|
+
const returnObject = {};
|
262
|
+
cssProps.forEach(prop => {
|
263
|
+
returnObject[prop] = computedStyle.getPropertyValue(prop);
|
264
|
+
});
|
265
|
+
rootElement.removeChild(table);
|
266
|
+
return returnObject;
|
267
|
+
}
|
268
|
+
/**
|
269
|
+
* Parses the numeric value of a specified CSS property from the root element's computed style.
|
270
|
+
*
|
271
|
+
* @param {string} property - The CSS property to retrieve and parse.
|
272
|
+
* @returns {number|null} The parsed value of the CSS property or `null` if non-existent.
|
273
|
+
*/
|
274
|
+
function _getParsedNumericCSSValue(property) {
|
275
|
+
const parsedValue = Math.ceil(parseFloat(_assertClassBrand(_StylesHandler_brand, this, _getCSSValue).call(this, property)));
|
276
|
+
return Number.isNaN(parsedValue) ? null : parsedValue;
|
277
|
+
}
|
278
|
+
/**
|
279
|
+
* Retrieves the non-numeric value of a specified CSS property from the root element's computed style.
|
280
|
+
*
|
281
|
+
* @param {string} property - The CSS property to retrieve.
|
282
|
+
* @returns {string|null} The value of the specified CSS property or `null` if non-existent.
|
283
|
+
*/
|
284
|
+
function _getCSSValue(property) {
|
285
|
+
const acquiredValue = _classPrivateFieldGet(_rootComputedStyle, this).getPropertyValue(property);
|
286
|
+
return acquiredValue === '' ? null : acquiredValue;
|
287
|
+
}
|
288
|
+
/**
|
289
|
+
* Clears the cached values.
|
290
|
+
*/
|
291
|
+
function _clearCachedValues() {
|
292
|
+
_classPrivateFieldSet(_computedStyles, this, {});
|
293
|
+
_classPrivateFieldSet(_cssVars, this, {});
|
294
|
+
_classPrivateFieldSet(_isClassicTheme, this, true);
|
295
|
+
}
|