handsontable 0.0.0-next-3e0b40d-20241017 → 0.0.0-next-802f59c-20241024

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.

Files changed (116) hide show
  1. package/3rdparty/walkontable/src/calculator/viewportRows.js +1 -5
  2. package/3rdparty/walkontable/src/calculator/viewportRows.mjs +2 -5
  3. package/3rdparty/walkontable/src/core/clone.js +0 -1
  4. package/3rdparty/walkontable/src/core/clone.mjs +0 -1
  5. package/3rdparty/walkontable/src/core/core.js +0 -2
  6. package/3rdparty/walkontable/src/core/core.mjs +0 -2
  7. package/3rdparty/walkontable/src/overlay/_base.js +1 -3
  8. package/3rdparty/walkontable/src/overlay/_base.mjs +1 -3
  9. package/3rdparty/walkontable/src/overlay/bottom.js +2 -2
  10. package/3rdparty/walkontable/src/overlay/bottom.mjs +2 -2
  11. package/3rdparty/walkontable/src/overlay/inlineStart.js +1 -1
  12. package/3rdparty/walkontable/src/overlay/inlineStart.mjs +1 -1
  13. package/3rdparty/walkontable/src/overlay/top.js +1 -1
  14. package/3rdparty/walkontable/src/overlay/top.mjs +1 -1
  15. package/3rdparty/walkontable/src/overlays.js +7 -6
  16. package/3rdparty/walkontable/src/overlays.mjs +7 -6
  17. package/3rdparty/walkontable/src/renderer/colGroup.js +1 -1
  18. package/3rdparty/walkontable/src/renderer/colGroup.mjs +1 -1
  19. package/3rdparty/walkontable/src/renderer/table.js +1 -1
  20. package/3rdparty/walkontable/src/renderer/table.mjs +1 -1
  21. package/3rdparty/walkontable/src/settings.js +2 -7
  22. package/3rdparty/walkontable/src/settings.mjs +2 -7
  23. package/3rdparty/walkontable/src/table.js +8 -35
  24. package/3rdparty/walkontable/src/table.mjs +8 -35
  25. package/3rdparty/walkontable/src/utils/column.js +1 -43
  26. package/3rdparty/walkontable/src/utils/column.mjs +1 -43
  27. package/3rdparty/walkontable/src/viewport.js +66 -88
  28. package/3rdparty/walkontable/src/viewport.mjs +67 -89
  29. package/CHANGELOG.md +5 -0
  30. package/base.js +2 -2
  31. package/base.mjs +2 -2
  32. package/core/hooks/constants.js +2 -0
  33. package/core/hooks/constants.mjs +2 -0
  34. package/core/hooks/index.d.ts +2 -2
  35. package/core.d.ts +2 -2
  36. package/core.js +6 -15
  37. package/core.mjs +6 -15
  38. package/dataMap/metaManager/metaSchema.js +0 -17
  39. package/dataMap/metaManager/metaSchema.mjs +0 -17
  40. package/dist/handsontable.css +5 -236
  41. package/dist/handsontable.full.css +3 -3
  42. package/dist/handsontable.full.js +4539 -4231
  43. package/dist/handsontable.full.min.css +3 -4
  44. package/dist/handsontable.full.min.js +26 -26
  45. package/dist/handsontable.js +4230 -3928
  46. package/dist/handsontable.min.css +4 -9
  47. package/dist/handsontable.min.js +24 -24
  48. package/editors/autocompleteEditor/autocompleteEditor.js +1 -1
  49. package/editors/autocompleteEditor/autocompleteEditor.mjs +1 -1
  50. package/editors/baseEditor/baseEditor.js +1 -1
  51. package/editors/baseEditor/baseEditor.mjs +1 -1
  52. package/editors/dateEditor/dateEditor.js +0 -2
  53. package/editors/dateEditor/dateEditor.mjs +0 -2
  54. package/editors/handsontableEditor/handsontableEditor.js +1 -1
  55. package/editors/handsontableEditor/handsontableEditor.mjs +1 -1
  56. package/editors/passwordEditor/passwordEditor.js +0 -4
  57. package/editors/passwordEditor/passwordEditor.mjs +1 -5
  58. package/editors/selectEditor/selectEditor.js +9 -20
  59. package/editors/selectEditor/selectEditor.mjs +9 -20
  60. package/editors/textEditor/textEditor.js +11 -7
  61. package/editors/textEditor/textEditor.mjs +12 -8
  62. package/helpers/mixed.js +3 -3
  63. package/helpers/mixed.mjs +3 -3
  64. package/index.d.ts +7 -0
  65. package/package.json +8 -10
  66. package/plugins/comments/commentEditor.js +1 -8
  67. package/plugins/comments/commentEditor.mjs +1 -8
  68. package/plugins/comments/comments.js +2 -2
  69. package/plugins/comments/comments.mjs +2 -2
  70. package/plugins/contextMenu/menu/menu.js +4 -4
  71. package/plugins/contextMenu/menu/menu.mjs +4 -4
  72. package/plugins/index.d.ts +3 -0
  73. package/plugins/index.js +3 -0
  74. package/plugins/index.mjs +3 -1
  75. package/plugins/manualColumnMove/manualColumnMove.js +1 -3
  76. package/plugins/manualColumnMove/manualColumnMove.mjs +1 -3
  77. package/plugins/manualColumnResize/manualColumnResize.js +24 -12
  78. package/plugins/manualColumnResize/manualColumnResize.mjs +24 -12
  79. package/plugins/manualRowMove/manualRowMove.js +1 -1
  80. package/plugins/manualRowMove/manualRowMove.mjs +1 -1
  81. package/plugins/mergeCells/mergeCells.js +1 -1
  82. package/plugins/mergeCells/mergeCells.mjs +1 -1
  83. package/plugins/nestedRows/ui/headers.js +1 -3
  84. package/plugins/nestedRows/ui/headers.mjs +1 -3
  85. package/plugins/stretchColumns/calculator.js +159 -0
  86. package/plugins/stretchColumns/calculator.mjs +155 -0
  87. package/plugins/stretchColumns/index.d.ts +1 -0
  88. package/plugins/stretchColumns/index.js +7 -0
  89. package/plugins/stretchColumns/index.mjs +1 -0
  90. package/plugins/stretchColumns/strategies/_base.js +85 -0
  91. package/plugins/stretchColumns/strategies/_base.mjs +81 -0
  92. package/plugins/stretchColumns/strategies/all.js +68 -0
  93. package/plugins/stretchColumns/strategies/all.mjs +64 -0
  94. package/plugins/stretchColumns/strategies/last.js +77 -0
  95. package/plugins/stretchColumns/strategies/last.mjs +73 -0
  96. package/plugins/stretchColumns/stretchColumns.d.ts +11 -0
  97. package/plugins/stretchColumns/stretchColumns.js +211 -0
  98. package/plugins/stretchColumns/stretchColumns.mjs +207 -0
  99. package/tableView.js +39 -39
  100. package/tableView.mjs +39 -39
  101. package/utils/autoResize.js +1 -4
  102. package/utils/autoResize.mjs +1 -4
  103. package/utils/ghostTable.js +1 -1
  104. package/utils/ghostTable.mjs +1 -1
  105. package/3rdparty/walkontable/src/utils/columnStretching.js +0 -197
  106. package/3rdparty/walkontable/src/utils/columnStretching.mjs +0 -193
  107. package/3rdparty/walkontable/src/utils/stylesHandler.js +0 -185
  108. package/3rdparty/walkontable/src/utils/stylesHandler.mjs +0 -181
  109. package/helpers/themes.js +0 -17
  110. package/helpers/themes.mjs +0 -13
  111. package/styles/handsontable.css +0 -1920
  112. package/styles/handsontable.min.css +0 -30
  113. package/styles/ht-theme-gemini.css +0 -690
  114. package/styles/ht-theme-gemini.min.css +0 -30
  115. package/styles/ht-theme-main.css +0 -712
  116. package/styles/ht-theme-main.min.css +0 -30
@@ -1,193 +0,0 @@
1
- import "core-js/modules/es.error.cause.js";
2
- function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
3
- function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
4
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
6
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
- function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
8
- function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
9
- 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"); }
10
- import { DEFAULT_COLUMN_WIDTH } from "../calculator/index.mjs";
11
- /**
12
- * @typedef {object} ColumnStretchingOptions
13
- * @property {number} totalColumns Total number of columns.
14
- * @property {Function} columnWidthFn Function that returns the width of the column at a given index (in px).
15
- * @property {'all' | 'last' | 'none'} stretchMode Stretch mode 'all', 'last' or 'none'.
16
- * @property {Function} stretchingColumnWidthFn Function that returns the new width of the stretched column.
17
- */
18
- /**
19
- * @class ColumnStretching
20
- */
21
- var _totalTargetWidth = /*#__PURE__*/new WeakMap();
22
- var _totalColumns = /*#__PURE__*/new WeakMap();
23
- var _stretchingColumnWidthFn = /*#__PURE__*/new WeakMap();
24
- var _columnWidthFn = /*#__PURE__*/new WeakMap();
25
- var _stretchMode = /*#__PURE__*/new WeakMap();
26
- export class ColumnStretching {
27
- /**
28
- * @param {ColumnStretchingOptions} options Object with all options specified for column viewport calculation.
29
- */
30
- constructor(_ref) {
31
- let {
32
- totalColumns,
33
- stretchMode,
34
- stretchingColumnWidthFn,
35
- columnWidthFn
36
- } = _ref;
37
- /**
38
- * @type {number}
39
- */
40
- _defineProperty(this, "stretchAllRatio", 0);
41
- /**
42
- * @type {number}
43
- */
44
- _defineProperty(this, "stretchLastWidth", 0);
45
- /**
46
- * @type {number[]}
47
- */
48
- _defineProperty(this, "stretchAllColumnsWidth", []);
49
- /**
50
- * @type {number}
51
- */
52
- _classPrivateFieldInitSpec(this, _totalTargetWidth, 0);
53
- /**
54
- * @type {boolean}
55
- */
56
- _defineProperty(this, "needVerifyLastColumnWidth", true);
57
- /**
58
- * The total number of columns.
59
- *
60
- * @type {function(): number}
61
- */
62
- _classPrivateFieldInitSpec(this, _totalColumns, () => 0);
63
- /**
64
- * Function that returns the width of the stretched column at a given index (in px).
65
- *
66
- * @type {function(): number}
67
- */
68
- _classPrivateFieldInitSpec(this, _stretchingColumnWidthFn, width => width);
69
- /**
70
- * Function that returns the width of the column at a given index (in px).
71
- *
72
- * @type {function(): number}
73
- */
74
- _classPrivateFieldInitSpec(this, _columnWidthFn, width => width);
75
- /**
76
- * Stretch mode.
77
- *
78
- * @type {function(): 'all' | 'last' | 'none'}
79
- */
80
- _classPrivateFieldInitSpec(this, _stretchMode, () => 'none');
81
- _classPrivateFieldSet(_totalColumns, this, totalColumns);
82
- _classPrivateFieldSet(_stretchMode, this, stretchMode);
83
- _classPrivateFieldSet(_stretchingColumnWidthFn, this, stretchingColumnWidthFn !== null && stretchingColumnWidthFn !== void 0 ? stretchingColumnWidthFn : _classPrivateFieldGet(_stretchingColumnWidthFn, this));
84
- _classPrivateFieldSet(_columnWidthFn, this, columnWidthFn !== null && columnWidthFn !== void 0 ? columnWidthFn : _classPrivateFieldGet(_columnWidthFn, this));
85
- }
86
-
87
- /**
88
- * Recalculate columns stretching.
89
- *
90
- * @param {number} totalWidth The total width of the table.
91
- */
92
- refreshStretching(totalWidth) {
93
- if (_classPrivateFieldGet(_stretchMode, this).call(this) === 'none') {
94
- return;
95
- }
96
- this.stretchAllRatio = 0;
97
- this.stretchAllColumnsWidth = [];
98
- this.needVerifyLastColumnWidth = true;
99
- this.stretchLastWidth = 0;
100
- _classPrivateFieldSet(_totalTargetWidth, this, totalWidth);
101
- let sumAll = 0;
102
- for (let i = 0; i < _classPrivateFieldGet(_totalColumns, this).call(this); i++) {
103
- const columnWidth = this._getColumnWidth(i);
104
- const permanentColumnWidth = _classPrivateFieldGet(_stretchingColumnWidthFn, this).call(this, undefined, i);
105
- if (typeof permanentColumnWidth === 'number') {
106
- totalWidth -= permanentColumnWidth;
107
- } else {
108
- sumAll += columnWidth;
109
- }
110
- }
111
- const remainingSize = totalWidth - sumAll;
112
- if (_classPrivateFieldGet(_stretchMode, this).call(this) === 'all' && remainingSize > 0) {
113
- this.stretchAllRatio = totalWidth / sumAll;
114
- this.stretchAllColumnsWidth = [];
115
- this.needVerifyLastColumnWidth = true;
116
- } else if (_classPrivateFieldGet(_stretchMode, this).call(this) === 'last' && totalWidth !== Infinity) {
117
- const columnWidth = this._getColumnWidth(_classPrivateFieldGet(_totalColumns, this).call(this) - 1);
118
- const lastColumnWidth = remainingSize + columnWidth;
119
- this.stretchLastWidth = lastColumnWidth >= 0 ? lastColumnWidth : columnWidth;
120
- }
121
- }
122
-
123
- /**
124
- * Get stretched column width based on stretchH (all or last) setting passed in handsontable instance.
125
- *
126
- * @param {number} column The visual column index.
127
- * @param {number} baseWidth The default column width.
128
- * @returns {number|null}
129
- */
130
- getStretchedColumnWidth(column, baseWidth) {
131
- let result = null;
132
- if (_classPrivateFieldGet(_stretchMode, this).call(this) === 'all' && this.stretchAllRatio !== 0) {
133
- result = this._getStretchedAllColumnWidth(column, baseWidth);
134
- } else if (_classPrivateFieldGet(_stretchMode, this).call(this) === 'last' && this.stretchLastWidth !== 0) {
135
- result = this._getStretchedLastColumnWidth(column);
136
- }
137
- return result;
138
- }
139
-
140
- /**
141
- * @param {number} column The visual column index.
142
- * @param {number} baseWidth The default column width.
143
- * @returns {number}
144
- * @private
145
- */
146
- _getStretchedAllColumnWidth(column, baseWidth) {
147
- let sumRatioWidth = 0;
148
- if (!this.stretchAllColumnsWidth[column]) {
149
- const stretchedWidth = Math.round(baseWidth * this.stretchAllRatio);
150
- const newStretchedWidth = _classPrivateFieldGet(_stretchingColumnWidthFn, this).call(this, stretchedWidth, column);
151
- if (newStretchedWidth === undefined) {
152
- this.stretchAllColumnsWidth[column] = stretchedWidth;
153
- } else {
154
- this.stretchAllColumnsWidth[column] = isNaN(newStretchedWidth) ? this._getColumnWidth(column) : newStretchedWidth;
155
- }
156
- }
157
- if (this.stretchAllColumnsWidth.length === _classPrivateFieldGet(_totalColumns, this).call(this) && this.needVerifyLastColumnWidth) {
158
- this.needVerifyLastColumnWidth = false;
159
- for (let i = 0; i < this.stretchAllColumnsWidth.length; i++) {
160
- sumRatioWidth += this.stretchAllColumnsWidth[i];
161
- }
162
- if (sumRatioWidth !== _classPrivateFieldGet(_totalTargetWidth, this)) {
163
- this.stretchAllColumnsWidth[this.stretchAllColumnsWidth.length - 1] += _classPrivateFieldGet(_totalTargetWidth, this) - sumRatioWidth;
164
- }
165
- }
166
- return this.stretchAllColumnsWidth[column];
167
- }
168
-
169
- /**
170
- * @param {number} column The visual column index.
171
- * @returns {number|null}
172
- * @private
173
- */
174
- _getStretchedLastColumnWidth(column) {
175
- if (column === _classPrivateFieldGet(_totalColumns, this).call(this) - 1) {
176
- return this.stretchLastWidth;
177
- }
178
- return null;
179
- }
180
-
181
- /**
182
- * @param {number} column The visual column index.
183
- * @returns {number}
184
- * @private
185
- */
186
- _getColumnWidth(column) {
187
- let width = _classPrivateFieldGet(_columnWidthFn, this).call(this, column);
188
- if (isNaN(width)) {
189
- width = DEFAULT_COLUMN_WIDTH;
190
- }
191
- return width;
192
- }
193
- }
@@ -1,185 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- require("core-js/modules/es.error.cause.js");
5
- function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
6
- function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
7
- function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
8
- function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
9
- function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
10
- 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"); }
11
- var _rootElement = /*#__PURE__*/new WeakMap();
12
- var _rootComputedStyle = /*#__PURE__*/new WeakMap();
13
- var _rootDocument = /*#__PURE__*/new WeakMap();
14
- var _isClassicTheme = /*#__PURE__*/new WeakMap();
15
- var _cssVars = /*#__PURE__*/new WeakMap();
16
- var _computedStyles = /*#__PURE__*/new WeakMap();
17
- var _StylesHandler_brand = /*#__PURE__*/new WeakSet();
18
- /**
19
- * Handles the theme-related style operations.
20
- */
21
- class StylesHandler {
22
- /**
23
- * Initializes a new instance of the `StylesHandler` class.
24
- *
25
- * @param {object} domBindings - The DOM bindings for the instance.
26
- */
27
- constructor(domBindings) {
28
- var _classPrivateFieldGet2;
29
- /**
30
- * Retrieves and processes the computed styles for a `td` element.
31
- *
32
- * This method creates a temporary table structure, appends it to the root element,
33
- * retrieves the computed styles for the `td` element, and then removes the table
34
- * from the DOM. The computed styles are passed to the provided callback function.
35
- *
36
- * @param {Function} getterCallback - A callback function that processes the computed styles.
37
- * It receives a `CSSStyleDeclaration` object as its argument.
38
- * @private
39
- */
40
- _classPrivateMethodInitSpec(this, _StylesHandler_brand);
41
- /**
42
- * The instance's root element.
43
- *
44
- * @type {HTMLElement}
45
- */
46
- _classPrivateFieldInitSpec(this, _rootElement, void 0);
47
- /**
48
- * The computed style of the root element.
49
- *
50
- * @type {CSSStyleDeclaration}
51
- * @private
52
- */
53
- _classPrivateFieldInitSpec(this, _rootComputedStyle, void 0);
54
- /**
55
- * The root document of the instance.
56
- *
57
- * @type {Document}
58
- * @private
59
- */
60
- _classPrivateFieldInitSpec(this, _rootDocument, void 0);
61
- /**
62
- * `true` if the classic theme is enabled, `false` otherwise.
63
- *
64
- * @type {boolean}
65
- */
66
- _classPrivateFieldInitSpec(this, _isClassicTheme, false);
67
- /**
68
- * An object to store CSS variable values.
69
- *
70
- * @type {object}
71
- * @private
72
- */
73
- _classPrivateFieldInitSpec(this, _cssVars, {});
74
- /**
75
- * Stores the computed styles for various elements.
76
- *
77
- * @type {object} - An object containing the computed styles if a nested structore of `element: { [element type]: {property: value} }`.
78
- * @private
79
- */
80
- _classPrivateFieldInitSpec(this, _computedStyles, {});
81
- _classPrivateFieldSet(_rootElement, this, domBindings.rootTable.parentElement);
82
- _classPrivateFieldSet(_rootComputedStyle, this, getComputedStyle(_classPrivateFieldGet(_rootElement, this)));
83
- _classPrivateFieldSet(_rootDocument, this, domBindings.rootDocument);
84
- if (((_classPrivateFieldGet2 = _classPrivateFieldGet(_rootComputedStyle, this)) === null || _classPrivateFieldGet2 === void 0 ? void 0 : _classPrivateFieldGet2.getPropertyValue('--ht-line-height')) === '') {
85
- _classPrivateFieldSet(_isClassicTheme, this, true);
86
- }
87
-
88
- // Some of the properties are not stored in the CSS variables, so we need to get them from the computed style.
89
- _assertClassBrand(_StylesHandler_brand, this, _getStylesForTD).call(this, computedStyle => {
90
- _classPrivateFieldSet(_computedStyles, this, {
91
- ..._classPrivateFieldGet(_computedStyles, this),
92
- ...{
93
- td: {
94
- 'box-sizing': computedStyle['box-sizing'],
95
- 'border-top-width': parseInt(computedStyle['border-top-width'], 10),
96
- 'border-bottom-width': parseInt(computedStyle['border-bottom-width'], 10)
97
- }
98
- }
99
- });
100
- });
101
- }
102
-
103
- /**
104
- * Gets the value indicating whether the classic theme is enabled.
105
- *
106
- * @returns {boolean} `true` if the classic theme is enabled, `false` otherwise.
107
- */
108
- isClassicTheme() {
109
- return _classPrivateFieldGet(_isClassicTheme, this);
110
- }
111
-
112
- /**
113
- * Retrieves the value of a specified CSS variable.
114
- *
115
- * @param {string} variableName - The name of the CSS variable to retrieve.
116
- * @returns {number|string|undefined} The value of the specified CSS variable, or `undefined` if not found.
117
- */
118
- getCSSVariableValue(variableName) {
119
- if (_classPrivateFieldGet(_cssVars, this)[`--ht-${variableName}`]) {
120
- return _classPrivateFieldGet(_cssVars, this)[`--ht-${variableName}`];
121
- }
122
- const acquiredValue = _assertClassBrand(_StylesHandler_brand, this, _getParsedCSSValue).call(this, `--ht-${variableName}`);
123
- if (acquiredValue && acquiredValue !== '') {
124
- _classPrivateFieldSet(_cssVars, this, {
125
- ..._classPrivateFieldGet(_cssVars, this),
126
- ...{
127
- [variableName]: acquiredValue
128
- }
129
- });
130
- return acquiredValue;
131
- }
132
- }
133
-
134
- /**
135
- * Retrieves the computed style value for a specified CSS property of a `td` element.
136
- *
137
- * @param {string} cssProperty - The CSS property to retrieve the value for.
138
- * @returns {number|string|undefined} The value of the specified CSS property, or `undefined` if not found.
139
- */
140
- getStyleForTD(cssProperty) {
141
- var _classPrivateFieldGet3;
142
- const value = (_classPrivateFieldGet3 = _classPrivateFieldGet(_computedStyles, this)) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.td[cssProperty];
143
- if (value !== undefined && value !== '') {
144
- return value;
145
- }
146
- }
147
-
148
- /**
149
- * Calculates the row height based on the current theme and CSS variables.
150
- *
151
- * @returns {number} The calculated row height.
152
- */
153
- getDefaultRowHeight() {
154
- if (_classPrivateFieldGet(_isClassicTheme, this)) {
155
- return 23;
156
- }
157
- return this.getStyleForTD('border-top-width') + this.getCSSVariableValue('cell-vertical-padding') * 2 + this.getCSSVariableValue('line-height') + this.getStyleForTD('border-bottom-width');
158
- }
159
- }
160
- exports.StylesHandler = StylesHandler;
161
- function _getStylesForTD(getterCallback) {
162
- const table = _classPrivateFieldGet(_rootDocument, this).createElement('table');
163
- const tbody = _classPrivateFieldGet(_rootDocument, this).createElement('tbody');
164
- const tr = _classPrivateFieldGet(_rootDocument, this).createElement('tr');
165
- // This needs not to be the first row in order to get "regular" vaules.
166
- const tr2 = _classPrivateFieldGet(_rootDocument, this).createElement('tr');
167
- const td = _classPrivateFieldGet(_rootDocument, this).createElement('td');
168
- tr2.appendChild(td);
169
- tbody.appendChild(tr);
170
- tbody.appendChild(tr2);
171
- table.appendChild(tbody);
172
- _classPrivateFieldGet(_rootElement, this).appendChild(table);
173
- getterCallback(getComputedStyle(td));
174
- _classPrivateFieldGet(_rootElement, this).removeChild(table);
175
- }
176
- /**
177
- * Parses the value of a specified CSS property from the root element's computed style.
178
- *
179
- * @param {string} property - The CSS property to retrieve and parse.
180
- * @returns {number|string} The parsed value of the CSS property.
181
- */
182
- function _getParsedCSSValue(property) {
183
- var _classPrivateFieldGet4;
184
- return parseInt((_classPrivateFieldGet4 = _classPrivateFieldGet(_rootComputedStyle, this)) === null || _classPrivateFieldGet4 === void 0 ? void 0 : _classPrivateFieldGet4.getPropertyValue(property), 10);
185
- }
@@ -1,181 +0,0 @@
1
- import "core-js/modules/es.error.cause.js";
2
- function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
3
- function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
4
- function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
5
- function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
6
- function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
7
- 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"); }
8
- var _rootElement = /*#__PURE__*/new WeakMap();
9
- var _rootComputedStyle = /*#__PURE__*/new WeakMap();
10
- var _rootDocument = /*#__PURE__*/new WeakMap();
11
- var _isClassicTheme = /*#__PURE__*/new WeakMap();
12
- var _cssVars = /*#__PURE__*/new WeakMap();
13
- var _computedStyles = /*#__PURE__*/new WeakMap();
14
- var _StylesHandler_brand = /*#__PURE__*/new WeakSet();
15
- /**
16
- * Handles the theme-related style operations.
17
- */
18
- export class StylesHandler {
19
- /**
20
- * Initializes a new instance of the `StylesHandler` class.
21
- *
22
- * @param {object} domBindings - The DOM bindings for the instance.
23
- */
24
- constructor(domBindings) {
25
- var _classPrivateFieldGet2;
26
- /**
27
- * Retrieves and processes the computed styles for a `td` element.
28
- *
29
- * This method creates a temporary table structure, appends it to the root element,
30
- * retrieves the computed styles for the `td` element, and then removes the table
31
- * from the DOM. The computed styles are passed to the provided callback function.
32
- *
33
- * @param {Function} getterCallback - A callback function that processes the computed styles.
34
- * It receives a `CSSStyleDeclaration` object as its argument.
35
- * @private
36
- */
37
- _classPrivateMethodInitSpec(this, _StylesHandler_brand);
38
- /**
39
- * The instance's root element.
40
- *
41
- * @type {HTMLElement}
42
- */
43
- _classPrivateFieldInitSpec(this, _rootElement, void 0);
44
- /**
45
- * The computed style of the root element.
46
- *
47
- * @type {CSSStyleDeclaration}
48
- * @private
49
- */
50
- _classPrivateFieldInitSpec(this, _rootComputedStyle, void 0);
51
- /**
52
- * The root document of the instance.
53
- *
54
- * @type {Document}
55
- * @private
56
- */
57
- _classPrivateFieldInitSpec(this, _rootDocument, void 0);
58
- /**
59
- * `true` if the classic theme is enabled, `false` otherwise.
60
- *
61
- * @type {boolean}
62
- */
63
- _classPrivateFieldInitSpec(this, _isClassicTheme, false);
64
- /**
65
- * An object to store CSS variable values.
66
- *
67
- * @type {object}
68
- * @private
69
- */
70
- _classPrivateFieldInitSpec(this, _cssVars, {});
71
- /**
72
- * Stores the computed styles for various elements.
73
- *
74
- * @type {object} - An object containing the computed styles if a nested structore of `element: { [element type]: {property: value} }`.
75
- * @private
76
- */
77
- _classPrivateFieldInitSpec(this, _computedStyles, {});
78
- _classPrivateFieldSet(_rootElement, this, domBindings.rootTable.parentElement);
79
- _classPrivateFieldSet(_rootComputedStyle, this, getComputedStyle(_classPrivateFieldGet(_rootElement, this)));
80
- _classPrivateFieldSet(_rootDocument, this, domBindings.rootDocument);
81
- if (((_classPrivateFieldGet2 = _classPrivateFieldGet(_rootComputedStyle, this)) === null || _classPrivateFieldGet2 === void 0 ? void 0 : _classPrivateFieldGet2.getPropertyValue('--ht-line-height')) === '') {
82
- _classPrivateFieldSet(_isClassicTheme, this, true);
83
- }
84
-
85
- // Some of the properties are not stored in the CSS variables, so we need to get them from the computed style.
86
- _assertClassBrand(_StylesHandler_brand, this, _getStylesForTD).call(this, computedStyle => {
87
- _classPrivateFieldSet(_computedStyles, this, {
88
- ..._classPrivateFieldGet(_computedStyles, this),
89
- ...{
90
- td: {
91
- 'box-sizing': computedStyle['box-sizing'],
92
- 'border-top-width': parseInt(computedStyle['border-top-width'], 10),
93
- 'border-bottom-width': parseInt(computedStyle['border-bottom-width'], 10)
94
- }
95
- }
96
- });
97
- });
98
- }
99
-
100
- /**
101
- * Gets the value indicating whether the classic theme is enabled.
102
- *
103
- * @returns {boolean} `true` if the classic theme is enabled, `false` otherwise.
104
- */
105
- isClassicTheme() {
106
- return _classPrivateFieldGet(_isClassicTheme, this);
107
- }
108
-
109
- /**
110
- * Retrieves the value of a specified CSS variable.
111
- *
112
- * @param {string} variableName - The name of the CSS variable to retrieve.
113
- * @returns {number|string|undefined} The value of the specified CSS variable, or `undefined` if not found.
114
- */
115
- getCSSVariableValue(variableName) {
116
- if (_classPrivateFieldGet(_cssVars, this)[`--ht-${variableName}`]) {
117
- return _classPrivateFieldGet(_cssVars, this)[`--ht-${variableName}`];
118
- }
119
- const acquiredValue = _assertClassBrand(_StylesHandler_brand, this, _getParsedCSSValue).call(this, `--ht-${variableName}`);
120
- if (acquiredValue && acquiredValue !== '') {
121
- _classPrivateFieldSet(_cssVars, this, {
122
- ..._classPrivateFieldGet(_cssVars, this),
123
- ...{
124
- [variableName]: acquiredValue
125
- }
126
- });
127
- return acquiredValue;
128
- }
129
- }
130
-
131
- /**
132
- * Retrieves the computed style value for a specified CSS property of a `td` element.
133
- *
134
- * @param {string} cssProperty - The CSS property to retrieve the value for.
135
- * @returns {number|string|undefined} The value of the specified CSS property, or `undefined` if not found.
136
- */
137
- getStyleForTD(cssProperty) {
138
- var _classPrivateFieldGet3;
139
- const value = (_classPrivateFieldGet3 = _classPrivateFieldGet(_computedStyles, this)) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.td[cssProperty];
140
- if (value !== undefined && value !== '') {
141
- return value;
142
- }
143
- }
144
-
145
- /**
146
- * Calculates the row height based on the current theme and CSS variables.
147
- *
148
- * @returns {number} The calculated row height.
149
- */
150
- getDefaultRowHeight() {
151
- if (_classPrivateFieldGet(_isClassicTheme, this)) {
152
- return 23;
153
- }
154
- return this.getStyleForTD('border-top-width') + this.getCSSVariableValue('cell-vertical-padding') * 2 + this.getCSSVariableValue('line-height') + this.getStyleForTD('border-bottom-width');
155
- }
156
- }
157
- function _getStylesForTD(getterCallback) {
158
- const table = _classPrivateFieldGet(_rootDocument, this).createElement('table');
159
- const tbody = _classPrivateFieldGet(_rootDocument, this).createElement('tbody');
160
- const tr = _classPrivateFieldGet(_rootDocument, this).createElement('tr');
161
- // This needs not to be the first row in order to get "regular" vaules.
162
- const tr2 = _classPrivateFieldGet(_rootDocument, this).createElement('tr');
163
- const td = _classPrivateFieldGet(_rootDocument, this).createElement('td');
164
- tr2.appendChild(td);
165
- tbody.appendChild(tr);
166
- tbody.appendChild(tr2);
167
- table.appendChild(tbody);
168
- _classPrivateFieldGet(_rootElement, this).appendChild(table);
169
- getterCallback(getComputedStyle(td));
170
- _classPrivateFieldGet(_rootElement, this).removeChild(table);
171
- }
172
- /**
173
- * Parses the value of a specified CSS property from the root element's computed style.
174
- *
175
- * @param {string} property - The CSS property to retrieve and parse.
176
- * @returns {number|string} The parsed value of the CSS property.
177
- */
178
- function _getParsedCSSValue(property) {
179
- var _classPrivateFieldGet4;
180
- return parseInt((_classPrivateFieldGet4 = _classPrivateFieldGet(_rootComputedStyle, this)) === null || _classPrivateFieldGet4 === void 0 ? void 0 : _classPrivateFieldGet4.getPropertyValue(property), 10);
181
- }
package/helpers/themes.js DELETED
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.getThemeClassName = getThemeClassName;
5
- /**
6
- * Get theme class name from rootElement class.
7
- *
8
- * @param {string} className Class names.
9
- * @returns {string}
10
- */
11
- function getThemeClassName(className) {
12
- if (!className || typeof className !== 'string') {
13
- return false;
14
- }
15
- const [match] = className.match(/ht-theme-[a-zA-Z0-9_-]+/) || [];
16
- return match;
17
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * Get theme class name from rootElement class.
3
- *
4
- * @param {string} className Class names.
5
- * @returns {string}
6
- */
7
- export function getThemeClassName(className) {
8
- if (!className || typeof className !== 'string') {
9
- return false;
10
- }
11
- const [match] = className.match(/ht-theme-[a-zA-Z0-9_-]+/) || [];
12
- return match;
13
- }