handsontable 16.1.1-next-895fbb8-20250923 → 16.2.0-next-216dbd0-20251112
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/3rdparty/walkontable/src/overlays.js +1 -1
- package/3rdparty/walkontable/src/overlays.mjs +1 -1
- package/3rdparty/walkontable/src/selection/border/border.js +19 -3
- package/3rdparty/walkontable/src/selection/border/border.mjs +19 -3
- package/CHANGELOG.md +40 -0
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/core/coordsMapper/index.js +11 -0
- package/core/coordsMapper/index.mjs +1 -0
- package/core/hooks/bucket.js +7 -1
- package/core/hooks/bucket.mjs +7 -1
- package/core/hooks/constants.js +54 -0
- package/core/hooks/constants.mjs +54 -0
- package/core/hooks/index.d.ts +6 -0
- package/core/index.js +10 -4
- package/core/index.mjs +2 -1
- package/core.d.ts +3 -2
- package/core.js +67 -26
- package/core.mjs +56 -15
- package/dataMap/metaManager/metaSchema.js +197 -20
- package/dataMap/metaManager/metaSchema.mjs +197 -20
- package/dist/handsontable.css +175 -3
- package/dist/handsontable.full.css +175 -3
- package/dist/handsontable.full.js +10940 -8445
- package/dist/handsontable.full.min.css +5 -4
- package/dist/handsontable.full.min.js +193 -192
- package/dist/handsontable.js +6472 -4116
- package/dist/handsontable.min.css +4 -4
- package/dist/handsontable.min.js +43 -42
- package/dist/languages/all.js +168 -21
- package/dist/languages/all.min.js +1 -1
- package/dist/languages/ar-AR.js +8 -1
- package/dist/languages/ar-AR.min.js +1 -1
- package/dist/languages/cs-CZ.js +8 -1
- package/dist/languages/cs-CZ.min.js +1 -1
- package/dist/languages/de-CH.js +8 -1
- package/dist/languages/de-CH.min.js +1 -1
- package/dist/languages/de-DE.js +8 -1
- package/dist/languages/de-DE.min.js +1 -1
- package/dist/languages/en-US.js +8 -1
- package/dist/languages/en-US.min.js +1 -1
- package/dist/languages/es-MX.js +8 -1
- package/dist/languages/es-MX.min.js +1 -1
- package/dist/languages/fa-IR.js +8 -1
- package/dist/languages/fa-IR.min.js +1 -1
- package/dist/languages/fr-FR.js +8 -1
- package/dist/languages/fr-FR.min.js +1 -1
- package/dist/languages/hr-HR.js +8 -1
- package/dist/languages/hr-HR.min.js +1 -1
- package/dist/languages/it-IT.js +8 -1
- package/dist/languages/it-IT.min.js +1 -1
- package/dist/languages/ja-JP.js +8 -1
- package/dist/languages/ja-JP.min.js +1 -1
- package/dist/languages/ko-KR.js +8 -1
- package/dist/languages/ko-KR.min.js +1 -1
- package/dist/languages/lv-LV.js +8 -1
- package/dist/languages/lv-LV.min.js +1 -1
- package/dist/languages/nb-NO.js +8 -1
- package/dist/languages/nb-NO.min.js +1 -1
- package/dist/languages/nl-NL.js +8 -1
- package/dist/languages/nl-NL.min.js +1 -1
- package/dist/languages/pl-PL.js +8 -1
- package/dist/languages/pl-PL.min.js +1 -1
- package/dist/languages/pt-BR.js +8 -1
- package/dist/languages/pt-BR.min.js +1 -1
- package/dist/languages/ru-RU.js +8 -1
- package/dist/languages/ru-RU.min.js +1 -1
- package/dist/languages/sr-SP.js +8 -1
- package/dist/languages/sr-SP.min.js +1 -1
- package/dist/languages/zh-CN.js +8 -1
- package/dist/languages/zh-CN.min.js +1 -1
- package/dist/languages/zh-TW.js +8 -1
- package/dist/languages/zh-TW.min.js +1 -1
- package/editors/autocompleteEditor/autocompleteEditor.js +21 -1
- package/editors/autocompleteEditor/autocompleteEditor.mjs +22 -2
- package/focusManager/constants.js +25 -0
- package/focusManager/constants.mjs +22 -0
- package/focusManager/eventListener.js +107 -0
- package/focusManager/eventListener.mjs +103 -0
- package/{focusManager.d.ts → focusManager/grid.d.ts} +1 -1
- package/{focusManager.js → focusManager/grid.js} +48 -17
- package/{focusManager.mjs → focusManager/grid.mjs} +47 -16
- package/focusManager/index.d.ts +2 -0
- package/focusManager/index.js +20 -0
- package/focusManager/index.mjs +20 -0
- package/focusManager/scope.js +133 -0
- package/focusManager/scope.mjs +129 -0
- package/focusManager/scopeManager.d.ts +19 -0
- package/focusManager/scopeManager.js +268 -0
- package/focusManager/scopeManager.mjs +263 -0
- package/focusManager/scopes/grid.js +120 -0
- package/focusManager/scopes/grid.mjs +116 -0
- package/focusManager/scopes/index.js +13 -0
- package/focusManager/scopes/index.mjs +9 -0
- package/{utils → focusManager/utils}/focusDetector.js +21 -31
- package/{utils → focusManager/utils}/focusDetector.mjs +21 -31
- package/focusManager/utils/utils.js +95 -0
- package/focusManager/utils/utils.mjs +89 -0
- package/helpers/dom/element.js +1 -1
- package/helpers/dom/element.mjs +2 -2
- package/helpers/dom/event.js +1 -1
- package/helpers/dom/event.mjs +1 -1
- package/helpers/mixed.js +2 -65
- package/helpers/mixed.mjs +2 -63
- package/i18n/constants.js +10 -1
- package/i18n/constants.mjs +10 -1
- package/i18n/languages/ar-AR.js +8 -1
- package/i18n/languages/ar-AR.mjs +8 -1
- package/i18n/languages/cs-CZ.js +8 -1
- package/i18n/languages/cs-CZ.mjs +8 -1
- package/i18n/languages/de-CH.js +8 -1
- package/i18n/languages/de-CH.mjs +8 -1
- package/i18n/languages/de-DE.js +8 -1
- package/i18n/languages/de-DE.mjs +8 -1
- package/i18n/languages/en-US.js +8 -1
- package/i18n/languages/en-US.mjs +8 -1
- package/i18n/languages/es-MX.js +8 -1
- package/i18n/languages/es-MX.mjs +8 -1
- package/i18n/languages/fa-IR.js +8 -1
- package/i18n/languages/fa-IR.mjs +8 -1
- package/i18n/languages/fr-FR.js +8 -1
- package/i18n/languages/fr-FR.mjs +8 -1
- package/i18n/languages/hr-HR.js +8 -1
- package/i18n/languages/hr-HR.mjs +8 -1
- package/i18n/languages/it-IT.js +8 -1
- package/i18n/languages/it-IT.mjs +8 -1
- package/i18n/languages/ja-JP.js +8 -1
- package/i18n/languages/ja-JP.mjs +8 -1
- package/i18n/languages/ko-KR.js +8 -1
- package/i18n/languages/ko-KR.mjs +8 -1
- package/i18n/languages/lv-LV.js +8 -1
- package/i18n/languages/lv-LV.mjs +8 -1
- package/i18n/languages/nb-NO.js +8 -1
- package/i18n/languages/nb-NO.mjs +8 -1
- package/i18n/languages/nl-NL.js +8 -1
- package/i18n/languages/nl-NL.mjs +8 -1
- package/i18n/languages/pl-PL.js +8 -1
- package/i18n/languages/pl-PL.mjs +8 -1
- package/i18n/languages/pt-BR.js +8 -1
- package/i18n/languages/pt-BR.mjs +8 -1
- package/i18n/languages/ru-RU.js +8 -1
- package/i18n/languages/ru-RU.mjs +8 -1
- package/i18n/languages/sr-SP.js +8 -1
- package/i18n/languages/sr-SP.mjs +8 -1
- package/i18n/languages/zh-CN.js +8 -1
- package/i18n/languages/zh-CN.mjs +8 -1
- package/i18n/languages/zh-TW.js +8 -1
- package/i18n/languages/zh-TW.mjs +8 -1
- package/index.d.ts +9 -0
- package/languages/all.js +168 -21
- package/languages/ar-AR.js +8 -1
- package/languages/ar-AR.mjs +8 -1
- package/languages/cs-CZ.js +8 -1
- package/languages/cs-CZ.mjs +8 -1
- package/languages/de-CH.js +8 -1
- package/languages/de-CH.mjs +8 -1
- package/languages/de-DE.js +8 -1
- package/languages/de-DE.mjs +8 -1
- package/languages/en-US.js +8 -1
- package/languages/en-US.mjs +8 -1
- package/languages/es-MX.js +8 -1
- package/languages/es-MX.mjs +8 -1
- package/languages/fa-IR.js +8 -1
- package/languages/fa-IR.mjs +8 -1
- package/languages/fr-FR.js +8 -1
- package/languages/fr-FR.mjs +8 -1
- package/languages/hr-HR.js +8 -1
- package/languages/hr-HR.mjs +8 -1
- package/languages/index.js +168 -21
- package/languages/it-IT.js +8 -1
- package/languages/it-IT.mjs +8 -1
- package/languages/ja-JP.js +8 -1
- package/languages/ja-JP.mjs +8 -1
- package/languages/ko-KR.js +8 -1
- package/languages/ko-KR.mjs +8 -1
- package/languages/lv-LV.js +8 -1
- package/languages/lv-LV.mjs +8 -1
- package/languages/nb-NO.js +8 -1
- package/languages/nb-NO.mjs +8 -1
- package/languages/nl-NL.js +8 -1
- package/languages/nl-NL.mjs +8 -1
- package/languages/pl-PL.js +8 -1
- package/languages/pl-PL.mjs +8 -1
- package/languages/pt-BR.js +8 -1
- package/languages/pt-BR.mjs +8 -1
- package/languages/ru-RU.js +8 -1
- package/languages/ru-RU.mjs +8 -1
- package/languages/sr-SP.js +8 -1
- package/languages/sr-SP.mjs +8 -1
- package/languages/zh-CN.js +8 -1
- package/languages/zh-CN.mjs +8 -1
- package/languages/zh-TW.js +8 -1
- package/languages/zh-TW.mjs +8 -1
- package/package.json +25 -7
- package/plugins/autoRowSize/autoRowSize.js +8 -1
- package/plugins/autoRowSize/autoRowSize.mjs +8 -1
- package/plugins/base/base.js +36 -10
- package/plugins/base/base.mjs +36 -10
- package/plugins/columnSummary/columnSummary.d.ts +2 -2
- package/plugins/columnSummary/columnSummary.js +44 -10
- package/plugins/columnSummary/columnSummary.mjs +44 -10
- package/plugins/columnSummary/endpoints.js +15 -13
- package/plugins/columnSummary/endpoints.mjs +15 -13
- package/plugins/columnSummary/utils.js +31 -0
- package/plugins/columnSummary/utils.mjs +30 -0
- package/plugins/customBorders/customBorders.d.ts +1 -0
- package/plugins/customBorders/customBorders.js +32 -2
- package/plugins/customBorders/customBorders.mjs +32 -2
- package/plugins/dialog/constants.js +7 -0
- package/plugins/dialog/constants.mjs +4 -0
- package/plugins/dialog/dialog.d.ts +22 -2
- package/plugins/dialog/dialog.js +197 -81
- package/plugins/dialog/dialog.mjs +196 -81
- package/plugins/dialog/templates/base.js +60 -0
- package/plugins/dialog/templates/base.mjs +56 -0
- package/plugins/dialog/templates/confirm.js +106 -0
- package/plugins/dialog/templates/confirm.mjs +102 -0
- package/plugins/dialog/templates/index.js +6 -0
- package/plugins/dialog/templates/index.mjs +4 -0
- package/plugins/dialog/ui.js +125 -41
- package/plugins/dialog/ui.mjs +119 -35
- package/plugins/emptyDataState/emptyDataState.d.ts +24 -0
- package/plugins/emptyDataState/emptyDataState.js +526 -0
- package/plugins/emptyDataState/emptyDataState.mjs +521 -0
- package/plugins/emptyDataState/index.d.ts +1 -0
- package/plugins/emptyDataState/index.js +7 -0
- package/plugins/emptyDataState/index.mjs +1 -0
- package/plugins/emptyDataState/ui.js +282 -0
- package/plugins/emptyDataState/ui.mjs +278 -0
- package/plugins/filters/component/value.js +16 -1
- package/plugins/filters/component/value.mjs +16 -1
- package/plugins/filters/filters.d.ts +5 -1
- package/plugins/filters/filters.js +22 -1
- package/plugins/filters/filters.mjs +22 -1
- package/plugins/filters/ui/multipleSelect.js +90 -79
- package/plugins/filters/ui/multipleSelect.mjs +90 -79
- package/plugins/index.d.ts +3 -0
- package/plugins/index.js +3 -0
- package/plugins/index.mjs +3 -1
- package/plugins/mergeCells/utils.js +1 -5
- package/plugins/mergeCells/utils.mjs +1 -5
- package/plugins/pagination/pagination.js +37 -175
- package/plugins/pagination/pagination.mjs +37 -175
- package/plugins/pagination/strategies/autoPageSize.js +2 -2
- package/plugins/pagination/strategies/autoPageSize.mjs +2 -2
- package/plugins/pagination/ui.js +6 -10
- package/plugins/pagination/ui.mjs +7 -11
- package/plugins/stretchColumns/calculator.js +3 -1
- package/plugins/stretchColumns/calculator.mjs +3 -1
- package/plugins/undoRedo/undoRedo.js +16 -6
- package/plugins/undoRedo/undoRedo.mjs +16 -5
- package/renderers/checkboxRenderer/checkboxRenderer.js +12 -15
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +12 -15
- package/selection/selection.js +1 -1
- package/selection/selection.mjs +1 -1
- package/settings.d.ts +3 -0
- package/shortcutContexts/commands/index.js +2 -1
- package/shortcutContexts/commands/index.mjs +2 -1
- package/shortcutContexts/commands/tabNavigation.js +51 -0
- package/shortcutContexts/commands/tabNavigation.mjs +48 -0
- package/shortcutContexts/constants.js +16 -1
- package/shortcutContexts/constants.mjs +16 -1
- package/shortcutContexts/editor.js +2 -2
- package/shortcutContexts/editor.mjs +3 -3
- package/shortcutContexts/grid.js +19 -3
- package/shortcutContexts/grid.mjs +20 -4
- package/shortcuts/manager.d.ts +1 -0
- package/shortcuts/manager.js +17 -2
- package/shortcuts/manager.mjs +17 -2
- package/styles/handsontable.css +192 -35
- package/styles/handsontable.min.css +3 -3
- package/styles/ht-icons-horizon.css +233 -0
- package/styles/ht-icons-horizon.min.css +30 -0
- package/styles/ht-icons-main.css +233 -0
- package/styles/ht-icons-main.min.css +30 -0
- package/styles/ht-theme-classic-no-icons.css +399 -0
- package/styles/ht-theme-classic-no-icons.min.css +30 -0
- package/styles/ht-theme-classic.css +308 -556
- package/styles/ht-theme-classic.min.css +3 -3
- package/styles/ht-theme-horizon-no-icons.css +405 -0
- package/styles/ht-theme-horizon-no-icons.min.css +30 -0
- package/styles/ht-theme-horizon.css +312 -556
- package/styles/ht-theme-horizon.min.css +3 -3
- package/styles/ht-theme-main-no-icons.css +396 -0
- package/styles/ht-theme-main-no-icons.min.css +30 -0
- package/styles/ht-theme-main.css +303 -556
- package/styles/ht-theme-main.min.css +3 -3
- package/tableView.js +23 -5
- package/tableView.mjs +23 -5
- package/utils/dataStructures/uniqueMap.js +10 -0
- package/utils/dataStructures/uniqueMap.mjs +10 -0
- package/utils/ghostTable.js +0 -3
- package/utils/ghostTable.mjs +0 -3
- package/utils/stylesHandler.js +19 -4
- package/utils/stylesHandler.mjs +19 -4
- package/core/focusCatcher/index.js +0 -131
- package/core/focusCatcher/index.mjs +0 -127
- package/core/focusCatcher/utils.js +0 -31
- package/core/focusCatcher/utils.mjs +0 -27
- package/plugins/pagination/focusController.js +0 -27
- package/plugins/pagination/focusController.mjs +0 -23
package/plugins/base/base.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import "core-js/modules/es.error.cause.js";
|
|
|
2
2
|
import "core-js/modules/es.array.push.js";
|
|
3
3
|
import "core-js/modules/esnext.iterator.constructor.js";
|
|
4
4
|
import "core-js/modules/esnext.iterator.for-each.js";
|
|
5
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
5
6
|
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
6
7
|
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; }
|
|
7
8
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
@@ -203,32 +204,57 @@ export class BasePlugin {
|
|
|
203
204
|
* @returns {*}
|
|
204
205
|
*/
|
|
205
206
|
getSetting(settingName) {
|
|
207
|
+
var _this = this;
|
|
206
208
|
const defaultSettings = this.constructor.DEFAULT_SETTINGS;
|
|
209
|
+
const settingsValidators = this.constructor.SETTINGS_VALIDATORS;
|
|
207
210
|
if (settingName === undefined) {
|
|
208
211
|
if (isObject(_classPrivateFieldGet(_pluginSettings, this))) {
|
|
209
212
|
return assignObjectDefaults(_classPrivateFieldGet(_pluginSettings, this), defaultSettings);
|
|
210
213
|
}
|
|
211
214
|
return _classPrivateFieldGet(_pluginSettings, this);
|
|
212
215
|
}
|
|
216
|
+
let settingValue;
|
|
213
217
|
if ((Array.isArray(_classPrivateFieldGet(_pluginSettings, this)) || isObject(_classPrivateFieldGet(_pluginSettings, this))) && defaultSettings[defaultMainSettingSymbol] === settingName) {
|
|
214
|
-
var _classPrivateFieldGet2;
|
|
215
218
|
if (Array.isArray(_classPrivateFieldGet(_pluginSettings, this))) {
|
|
216
|
-
|
|
219
|
+
settingValue = _classPrivateFieldGet(_pluginSettings, this);
|
|
220
|
+
} else {
|
|
221
|
+
var _classPrivateFieldGet2;
|
|
222
|
+
settingValue = (_classPrivateFieldGet2 = _classPrivateFieldGet(_pluginSettings, this)[settingName]) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : defaultSettings[settingName];
|
|
217
223
|
}
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
if (settingName.includes('.')) {
|
|
224
|
+
} else if (settingName.includes('.')) {
|
|
221
225
|
const pluginValue = getProperty(_classPrivateFieldGet(_pluginSettings, this), settingName);
|
|
222
226
|
const defaultValue = getProperty(defaultSettings, settingName);
|
|
223
227
|
if (isObject(pluginValue)) {
|
|
224
|
-
|
|
228
|
+
settingValue = assignObjectDefaults(pluginValue, defaultValue);
|
|
229
|
+
} else {
|
|
230
|
+
settingValue = pluginValue !== undefined ? pluginValue : defaultValue;
|
|
225
231
|
}
|
|
226
|
-
|
|
232
|
+
} else if (isObject(_classPrivateFieldGet(_pluginSettings, this))) {
|
|
233
|
+
settingValue = assignObjectDefaults(_classPrivateFieldGet(_pluginSettings, this), defaultSettings)[settingName];
|
|
234
|
+
} else {
|
|
235
|
+
settingValue = defaultSettings[settingName];
|
|
227
236
|
}
|
|
228
|
-
if (
|
|
229
|
-
|
|
237
|
+
if (typeof settingValue === 'function' && settingsValidators && typeof settingsValidators === 'object') {
|
|
238
|
+
const validator = settingsValidators[settingName];
|
|
239
|
+
if (validator && typeof validator === 'function') {
|
|
240
|
+
return function () {
|
|
241
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
242
|
+
args[_key] = arguments[_key];
|
|
243
|
+
}
|
|
244
|
+
const result = settingValue(...args);
|
|
245
|
+
const isValid = validator(result);
|
|
246
|
+
if (isValid === false) {
|
|
247
|
+
const formattedArgs = args.map(arg => typeof arg === 'string' ? `"${arg}"` : '').join(', ');
|
|
248
|
+
const source = args.length > 0 ? formattedArgs : '';
|
|
249
|
+
warn(`${_this.pluginName} Plugin: "${settingName}" function (${source}) result \
|
|
250
|
+
is not valid and will be ignored.`);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
return result;
|
|
254
|
+
};
|
|
255
|
+
}
|
|
230
256
|
}
|
|
231
|
-
return
|
|
257
|
+
return settingValue;
|
|
232
258
|
}
|
|
233
259
|
|
|
234
260
|
/**
|
|
@@ -8,7 +8,7 @@ export type DetailedSettings = {
|
|
|
8
8
|
reversedRowCoords?: boolean;
|
|
9
9
|
suppressDataTypeErrors?: boolean;
|
|
10
10
|
readOnly?: boolean;
|
|
11
|
-
roundFloat?: boolean | number;
|
|
11
|
+
roundFloat?: boolean | number | 'auto';
|
|
12
12
|
ranges?: number[][];
|
|
13
13
|
sourceColumn?: number;
|
|
14
14
|
} & ({
|
|
@@ -27,7 +27,7 @@ export interface Endpoint {
|
|
|
27
27
|
reversedRowCoords: boolean;
|
|
28
28
|
suppressDataTypeErrors: boolean;
|
|
29
29
|
readOnly: boolean;
|
|
30
|
-
roundFloat: boolean | number;
|
|
30
|
+
roundFloat: boolean | number | 'auto';
|
|
31
31
|
ranges: number[][];
|
|
32
32
|
sourceColumn: number;
|
|
33
33
|
type: 'sum' | 'min' | 'max' | 'count' | 'average' | 'custom';
|
|
@@ -198,37 +198,49 @@ class ColumnSummary extends _base.BasePlugin {
|
|
|
198
198
|
}
|
|
199
199
|
return _assertClassBrand(_ColumnSummary_brand, _this, _onAfterUpdateSettings).call(_this, ...args);
|
|
200
200
|
});
|
|
201
|
+
this.addHook('afterLoadData', function () {
|
|
202
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
203
|
+
args[_key4] = arguments[_key4];
|
|
204
|
+
}
|
|
205
|
+
return _assertClassBrand(_ColumnSummary_brand, _this, _onAfterLoadData).call(_this, ...args);
|
|
206
|
+
});
|
|
207
|
+
this.addHook('afterUpdateData', function () {
|
|
208
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
209
|
+
args[_key5] = arguments[_key5];
|
|
210
|
+
}
|
|
211
|
+
return _assertClassBrand(_ColumnSummary_brand, _this, _onAfterUpdateData).call(_this, ...args);
|
|
212
|
+
});
|
|
201
213
|
this.addHook('beforeCreateRow', (index, amount, source) => this.endpoints.resetSetupBeforeStructureAlteration('insert_row', index, amount, null, source)); // eslint-disable-line max-len
|
|
202
214
|
this.addHook('beforeCreateCol', (index, amount, source) => this.endpoints.resetSetupBeforeStructureAlteration('insert_col', index, amount, null, source)); // eslint-disable-line max-len
|
|
203
215
|
this.addHook('beforeRemoveRow', function () {
|
|
204
|
-
for (var
|
|
205
|
-
args[
|
|
216
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
217
|
+
args[_key6] = arguments[_key6];
|
|
206
218
|
}
|
|
207
219
|
return _this.endpoints.resetSetupBeforeStructureAlteration('remove_row', ...args);
|
|
208
220
|
});
|
|
209
221
|
this.addHook('beforeRemoveCol', function () {
|
|
210
|
-
for (var
|
|
211
|
-
args[
|
|
222
|
+
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
223
|
+
args[_key7] = arguments[_key7];
|
|
212
224
|
}
|
|
213
225
|
return _this.endpoints.resetSetupBeforeStructureAlteration('remove_col', ...args);
|
|
214
226
|
});
|
|
215
227
|
this.addHook('afterCreateRow', (index, amount, source) => this.endpoints.resetSetupAfterStructureAlteration('insert_row', index, amount, null, source)); // eslint-disable-line max-len
|
|
216
228
|
this.addHook('afterCreateCol', (index, amount, source) => this.endpoints.resetSetupAfterStructureAlteration('insert_col', index, amount, null, source)); // eslint-disable-line max-len
|
|
217
229
|
this.addHook('afterRemoveRow', function () {
|
|
218
|
-
for (var
|
|
219
|
-
args[
|
|
230
|
+
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
231
|
+
args[_key8] = arguments[_key8];
|
|
220
232
|
}
|
|
221
233
|
return _this.endpoints.resetSetupAfterStructureAlteration('remove_row', ...args);
|
|
222
234
|
});
|
|
223
235
|
this.addHook('afterRemoveCol', function () {
|
|
224
|
-
for (var
|
|
225
|
-
args[
|
|
236
|
+
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
|
|
237
|
+
args[_key9] = arguments[_key9];
|
|
226
238
|
}
|
|
227
239
|
return _this.endpoints.resetSetupAfterStructureAlteration('remove_col', ...args);
|
|
228
240
|
});
|
|
229
241
|
this.addHook('afterRowMove', function () {
|
|
230
|
-
for (var
|
|
231
|
-
args[
|
|
242
|
+
for (var _len0 = arguments.length, args = new Array(_len0), _key0 = 0; _key0 < _len0; _key0++) {
|
|
243
|
+
args[_key0] = arguments[_key0];
|
|
232
244
|
}
|
|
233
245
|
return _assertClassBrand(_ColumnSummary_brand, _this, _onAfterRowMove).call(_this, ...args);
|
|
234
246
|
});
|
|
@@ -515,6 +527,28 @@ function _onAfterChange(changes, source) {
|
|
|
515
527
|
this.endpoints.refreshChangedEndpoints(changes);
|
|
516
528
|
}
|
|
517
529
|
}
|
|
530
|
+
/**
|
|
531
|
+
* `afterLoadData` hook callback.
|
|
532
|
+
*
|
|
533
|
+
* @param {Array} data The updated data.
|
|
534
|
+
* @param {boolean} firstRun `true` if called on initial load, `false` otherwise.
|
|
535
|
+
*/
|
|
536
|
+
function _onAfterLoadData(data, firstRun) {
|
|
537
|
+
if (!firstRun) {
|
|
538
|
+
this.endpoints.refreshAllEndpoints();
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* `afterUpdateData` hook callback.
|
|
543
|
+
*
|
|
544
|
+
* @param {Array} data The updated data.
|
|
545
|
+
* @param {boolean} firstRun `true` if called on initial load, `false` otherwise.
|
|
546
|
+
*/
|
|
547
|
+
function _onAfterUpdateData(data, firstRun) {
|
|
548
|
+
if (!firstRun) {
|
|
549
|
+
this.endpoints.refreshAllEndpoints();
|
|
550
|
+
}
|
|
551
|
+
}
|
|
518
552
|
/**
|
|
519
553
|
* `beforeRowMove` hook callback.
|
|
520
554
|
*
|
|
@@ -194,37 +194,49 @@ export class ColumnSummary extends BasePlugin {
|
|
|
194
194
|
}
|
|
195
195
|
return _assertClassBrand(_ColumnSummary_brand, _this, _onAfterUpdateSettings).call(_this, ...args);
|
|
196
196
|
});
|
|
197
|
+
this.addHook('afterLoadData', function () {
|
|
198
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
199
|
+
args[_key4] = arguments[_key4];
|
|
200
|
+
}
|
|
201
|
+
return _assertClassBrand(_ColumnSummary_brand, _this, _onAfterLoadData).call(_this, ...args);
|
|
202
|
+
});
|
|
203
|
+
this.addHook('afterUpdateData', function () {
|
|
204
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
205
|
+
args[_key5] = arguments[_key5];
|
|
206
|
+
}
|
|
207
|
+
return _assertClassBrand(_ColumnSummary_brand, _this, _onAfterUpdateData).call(_this, ...args);
|
|
208
|
+
});
|
|
197
209
|
this.addHook('beforeCreateRow', (index, amount, source) => this.endpoints.resetSetupBeforeStructureAlteration('insert_row', index, amount, null, source)); // eslint-disable-line max-len
|
|
198
210
|
this.addHook('beforeCreateCol', (index, amount, source) => this.endpoints.resetSetupBeforeStructureAlteration('insert_col', index, amount, null, source)); // eslint-disable-line max-len
|
|
199
211
|
this.addHook('beforeRemoveRow', function () {
|
|
200
|
-
for (var
|
|
201
|
-
args[
|
|
212
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
213
|
+
args[_key6] = arguments[_key6];
|
|
202
214
|
}
|
|
203
215
|
return _this.endpoints.resetSetupBeforeStructureAlteration('remove_row', ...args);
|
|
204
216
|
});
|
|
205
217
|
this.addHook('beforeRemoveCol', function () {
|
|
206
|
-
for (var
|
|
207
|
-
args[
|
|
218
|
+
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
219
|
+
args[_key7] = arguments[_key7];
|
|
208
220
|
}
|
|
209
221
|
return _this.endpoints.resetSetupBeforeStructureAlteration('remove_col', ...args);
|
|
210
222
|
});
|
|
211
223
|
this.addHook('afterCreateRow', (index, amount, source) => this.endpoints.resetSetupAfterStructureAlteration('insert_row', index, amount, null, source)); // eslint-disable-line max-len
|
|
212
224
|
this.addHook('afterCreateCol', (index, amount, source) => this.endpoints.resetSetupAfterStructureAlteration('insert_col', index, amount, null, source)); // eslint-disable-line max-len
|
|
213
225
|
this.addHook('afterRemoveRow', function () {
|
|
214
|
-
for (var
|
|
215
|
-
args[
|
|
226
|
+
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
227
|
+
args[_key8] = arguments[_key8];
|
|
216
228
|
}
|
|
217
229
|
return _this.endpoints.resetSetupAfterStructureAlteration('remove_row', ...args);
|
|
218
230
|
});
|
|
219
231
|
this.addHook('afterRemoveCol', function () {
|
|
220
|
-
for (var
|
|
221
|
-
args[
|
|
232
|
+
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
|
|
233
|
+
args[_key9] = arguments[_key9];
|
|
222
234
|
}
|
|
223
235
|
return _this.endpoints.resetSetupAfterStructureAlteration('remove_col', ...args);
|
|
224
236
|
});
|
|
225
237
|
this.addHook('afterRowMove', function () {
|
|
226
|
-
for (var
|
|
227
|
-
args[
|
|
238
|
+
for (var _len0 = arguments.length, args = new Array(_len0), _key0 = 0; _key0 < _len0; _key0++) {
|
|
239
|
+
args[_key0] = arguments[_key0];
|
|
228
240
|
}
|
|
229
241
|
return _assertClassBrand(_ColumnSummary_brand, _this, _onAfterRowMove).call(_this, ...args);
|
|
230
242
|
});
|
|
@@ -510,6 +522,28 @@ function _onAfterChange(changes, source) {
|
|
|
510
522
|
this.endpoints.refreshChangedEndpoints(changes);
|
|
511
523
|
}
|
|
512
524
|
}
|
|
525
|
+
/**
|
|
526
|
+
* `afterLoadData` hook callback.
|
|
527
|
+
*
|
|
528
|
+
* @param {Array} data The updated data.
|
|
529
|
+
* @param {boolean} firstRun `true` if called on initial load, `false` otherwise.
|
|
530
|
+
*/
|
|
531
|
+
function _onAfterLoadData(data, firstRun) {
|
|
532
|
+
if (!firstRun) {
|
|
533
|
+
this.endpoints.refreshAllEndpoints();
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* `afterUpdateData` hook callback.
|
|
538
|
+
*
|
|
539
|
+
* @param {Array} data The updated data.
|
|
540
|
+
* @param {boolean} firstRun `true` if called on initial load, `false` otherwise.
|
|
541
|
+
*/
|
|
542
|
+
function _onAfterUpdateData(data, firstRun) {
|
|
543
|
+
if (!firstRun) {
|
|
544
|
+
this.endpoints.refreshAllEndpoints();
|
|
545
|
+
}
|
|
546
|
+
}
|
|
513
547
|
/**
|
|
514
548
|
* `beforeRowMove` hook callback.
|
|
515
549
|
*
|
|
@@ -8,6 +8,7 @@ require("core-js/modules/esnext.iterator.for-each.js");
|
|
|
8
8
|
require("core-js/modules/esnext.iterator.some.js");
|
|
9
9
|
var _array = require("../../helpers/array");
|
|
10
10
|
var _console = require("../../helpers/console");
|
|
11
|
+
var _utils = require("./utils");
|
|
11
12
|
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; }
|
|
12
13
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
13
14
|
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); }
|
|
@@ -229,6 +230,10 @@ class Endpoints {
|
|
|
229
230
|
*/
|
|
230
231
|
resetSetupAfterStructureAlteration(action, index, number, logicRows, source) {
|
|
231
232
|
let forceRefresh = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
233
|
+
// Automatic row/column creation (`minSpareRows`/`minSpareCols`) should not trigger the endpoint recalculation.
|
|
234
|
+
if (source === 'auto') {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
232
237
|
if (this.settingsType === 'function') {
|
|
233
238
|
// We need to run it on a next avaiable hook, because the TrimRows' `afterCreateRow` hook triggers after this one,
|
|
234
239
|
// and it needs to be run to properly calculate the endpoint value.
|
|
@@ -398,7 +403,9 @@ class Endpoints {
|
|
|
398
403
|
(0, _array.arrayEach)(endpoints, endpoint => {
|
|
399
404
|
this.resetEndpointValue(endpoint, useOffset);
|
|
400
405
|
});
|
|
401
|
-
|
|
406
|
+
if (this.cellsToSetCache.length) {
|
|
407
|
+
this.hot.setDataAtCell(this.cellsToSetCache, 'ColumnSummary.reset');
|
|
408
|
+
}
|
|
402
409
|
this.cellsToSetCache = [];
|
|
403
410
|
}
|
|
404
411
|
|
|
@@ -413,7 +420,9 @@ class Endpoints {
|
|
|
413
420
|
this.setEndpointValue(value, 'init');
|
|
414
421
|
});
|
|
415
422
|
this.currentEndpoint = null;
|
|
416
|
-
|
|
423
|
+
if (this.cellsToSetCache.length) {
|
|
424
|
+
this.hot.setDataAtCell(this.cellsToSetCache, 'ColumnSummary.reset');
|
|
425
|
+
}
|
|
417
426
|
this.cellsToSetCache = [];
|
|
418
427
|
}
|
|
419
428
|
|
|
@@ -439,7 +448,9 @@ class Endpoints {
|
|
|
439
448
|
(0, _array.arrayEach)(needToRefresh, value => {
|
|
440
449
|
this.refreshEndpoint(this.getEndpoint(value));
|
|
441
450
|
});
|
|
442
|
-
|
|
451
|
+
if (this.cellsToSetCache.length) {
|
|
452
|
+
this.hot.setDataAtCell(this.cellsToSetCache, 'ColumnSummary.reset');
|
|
453
|
+
}
|
|
443
454
|
this.cellsToSetCache = [];
|
|
444
455
|
}
|
|
445
456
|
|
|
@@ -505,16 +516,7 @@ class Endpoints {
|
|
|
505
516
|
cellMeta.className = 'columnSummaryResult';
|
|
506
517
|
}
|
|
507
518
|
}
|
|
508
|
-
|
|
509
|
-
const roundFloatValue = endpoint.roundFloat;
|
|
510
|
-
let decimalPlacesCount = 0;
|
|
511
|
-
|
|
512
|
-
// `toFixed` method accepts only values between 0 and 100
|
|
513
|
-
if (Number.isInteger(roundFloatValue)) {
|
|
514
|
-
decimalPlacesCount = Math.min(Math.max(0, roundFloatValue), 100);
|
|
515
|
-
}
|
|
516
|
-
endpoint.result = endpoint.result.toFixed(decimalPlacesCount);
|
|
517
|
-
}
|
|
519
|
+
endpoint.result = (0, _utils.roundFloat)(endpoint.result, endpoint.roundFloat);
|
|
518
520
|
if (render) {
|
|
519
521
|
this.hot.setDataAtCell(visualEndpointRowIndex, endpoint.destinationColumn, endpoint.result, 'ColumnSummary.set');
|
|
520
522
|
} else {
|
|
@@ -8,6 +8,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
8
8
|
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); }
|
|
9
9
|
import { arrayEach } from "../../helpers/array.mjs";
|
|
10
10
|
import { warn } from "../../helpers/console.mjs";
|
|
11
|
+
import { roundFloat } from "./utils.mjs";
|
|
11
12
|
/**
|
|
12
13
|
* Class used to make all endpoint-related operations.
|
|
13
14
|
*
|
|
@@ -226,6 +227,10 @@ class Endpoints {
|
|
|
226
227
|
*/
|
|
227
228
|
resetSetupAfterStructureAlteration(action, index, number, logicRows, source) {
|
|
228
229
|
let forceRefresh = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
230
|
+
// Automatic row/column creation (`minSpareRows`/`minSpareCols`) should not trigger the endpoint recalculation.
|
|
231
|
+
if (source === 'auto') {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
229
234
|
if (this.settingsType === 'function') {
|
|
230
235
|
// We need to run it on a next avaiable hook, because the TrimRows' `afterCreateRow` hook triggers after this one,
|
|
231
236
|
// and it needs to be run to properly calculate the endpoint value.
|
|
@@ -395,7 +400,9 @@ class Endpoints {
|
|
|
395
400
|
arrayEach(endpoints, endpoint => {
|
|
396
401
|
this.resetEndpointValue(endpoint, useOffset);
|
|
397
402
|
});
|
|
398
|
-
|
|
403
|
+
if (this.cellsToSetCache.length) {
|
|
404
|
+
this.hot.setDataAtCell(this.cellsToSetCache, 'ColumnSummary.reset');
|
|
405
|
+
}
|
|
399
406
|
this.cellsToSetCache = [];
|
|
400
407
|
}
|
|
401
408
|
|
|
@@ -410,7 +417,9 @@ class Endpoints {
|
|
|
410
417
|
this.setEndpointValue(value, 'init');
|
|
411
418
|
});
|
|
412
419
|
this.currentEndpoint = null;
|
|
413
|
-
|
|
420
|
+
if (this.cellsToSetCache.length) {
|
|
421
|
+
this.hot.setDataAtCell(this.cellsToSetCache, 'ColumnSummary.reset');
|
|
422
|
+
}
|
|
414
423
|
this.cellsToSetCache = [];
|
|
415
424
|
}
|
|
416
425
|
|
|
@@ -436,7 +445,9 @@ class Endpoints {
|
|
|
436
445
|
arrayEach(needToRefresh, value => {
|
|
437
446
|
this.refreshEndpoint(this.getEndpoint(value));
|
|
438
447
|
});
|
|
439
|
-
|
|
448
|
+
if (this.cellsToSetCache.length) {
|
|
449
|
+
this.hot.setDataAtCell(this.cellsToSetCache, 'ColumnSummary.reset');
|
|
450
|
+
}
|
|
440
451
|
this.cellsToSetCache = [];
|
|
441
452
|
}
|
|
442
453
|
|
|
@@ -502,16 +513,7 @@ class Endpoints {
|
|
|
502
513
|
cellMeta.className = 'columnSummaryResult';
|
|
503
514
|
}
|
|
504
515
|
}
|
|
505
|
-
|
|
506
|
-
const roundFloatValue = endpoint.roundFloat;
|
|
507
|
-
let decimalPlacesCount = 0;
|
|
508
|
-
|
|
509
|
-
// `toFixed` method accepts only values between 0 and 100
|
|
510
|
-
if (Number.isInteger(roundFloatValue)) {
|
|
511
|
-
decimalPlacesCount = Math.min(Math.max(0, roundFloatValue), 100);
|
|
512
|
-
}
|
|
513
|
-
endpoint.result = endpoint.result.toFixed(decimalPlacesCount);
|
|
514
|
-
}
|
|
516
|
+
endpoint.result = roundFloat(endpoint.result, endpoint.roundFloat);
|
|
515
517
|
if (render) {
|
|
516
518
|
this.hot.setDataAtCell(visualEndpointRowIndex, endpoint.destinationColumn, endpoint.result, 'ColumnSummary.set');
|
|
517
519
|
} else {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.isNullishOrNaN = isNullishOrNaN;
|
|
5
|
+
exports.roundFloat = roundFloat;
|
|
5
6
|
/**
|
|
6
7
|
* Returns `true` if the value is one of the type: `null`, `undefined` or `NaN`.
|
|
7
8
|
*
|
|
@@ -10,4 +11,34 @@ exports.isNullishOrNaN = isNullishOrNaN;
|
|
|
10
11
|
*/
|
|
11
12
|
function isNullishOrNaN(value) {
|
|
12
13
|
return value === null || value === undefined || isNaN(value);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Rounds a number to a specific number of decimal places.
|
|
18
|
+
*
|
|
19
|
+
* @param {number} value The value to round.
|
|
20
|
+
* @param {number|boolean|string|undefined} [option] Either a number of decimal places to round to, a boolean or "auto".
|
|
21
|
+
* @returns {string|number} The (possibly) rounded number as a string (for displaying the correct precision).
|
|
22
|
+
*/
|
|
23
|
+
function roundFloat(value, option) {
|
|
24
|
+
if (typeof value !== 'number') {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
const stringifyValue = number => number.toString();
|
|
28
|
+
switch (typeof option) {
|
|
29
|
+
case 'number':
|
|
30
|
+
return stringifyValue(value.toFixed(Math.min(Math.max(0, option), 100)));
|
|
31
|
+
case 'boolean':
|
|
32
|
+
return option ? stringifyValue(Math.round(value)) : value;
|
|
33
|
+
case 'string':
|
|
34
|
+
if (option === 'auto') {
|
|
35
|
+
const integerDigits = Math.round(value).toString().length;
|
|
36
|
+
|
|
37
|
+
// Make the entire number fit into 8 digits
|
|
38
|
+
return stringifyValue(value.toFixed(8 - integerDigits));
|
|
39
|
+
}
|
|
40
|
+
return value;
|
|
41
|
+
default:
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
13
44
|
}
|
|
@@ -6,4 +6,34 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export function isNullishOrNaN(value) {
|
|
8
8
|
return value === null || value === undefined || isNaN(value);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Rounds a number to a specific number of decimal places.
|
|
13
|
+
*
|
|
14
|
+
* @param {number} value The value to round.
|
|
15
|
+
* @param {number|boolean|string|undefined} [option] Either a number of decimal places to round to, a boolean or "auto".
|
|
16
|
+
* @returns {string|number} The (possibly) rounded number as a string (for displaying the correct precision).
|
|
17
|
+
*/
|
|
18
|
+
export function roundFloat(value, option) {
|
|
19
|
+
if (typeof value !== 'number') {
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
const stringifyValue = number => number.toString();
|
|
23
|
+
switch (typeof option) {
|
|
24
|
+
case 'number':
|
|
25
|
+
return stringifyValue(value.toFixed(Math.min(Math.max(0, option), 100)));
|
|
26
|
+
case 'boolean':
|
|
27
|
+
return option ? stringifyValue(Math.round(value)) : value;
|
|
28
|
+
case 'string':
|
|
29
|
+
if (option === 'auto') {
|
|
30
|
+
const integerDigits = Math.round(value).toString().length;
|
|
31
|
+
|
|
32
|
+
// Make the entire number fit into 8 digits
|
|
33
|
+
return stringifyValue(value.toFixed(8 - integerDigits));
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
default:
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
9
39
|
}
|
|
@@ -3,14 +3,18 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
require("core-js/modules/es.error.cause.js");
|
|
5
5
|
require("core-js/modules/es.array.push.js");
|
|
6
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
7
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
6
8
|
var _base = require("../base");
|
|
7
9
|
var _object = require("../../helpers/object");
|
|
10
|
+
var _console = require("../../helpers/console");
|
|
8
11
|
var _number = require("../../helpers/number");
|
|
9
12
|
var _array = require("../../helpers/array");
|
|
10
13
|
var C = _interopRequireWildcard(require("../../i18n/constants"));
|
|
11
14
|
var _contextMenuItem = require("./contextMenuItem");
|
|
12
15
|
var _utils = require("./utils");
|
|
13
16
|
var _selection = require("../../selection");
|
|
17
|
+
var _mixed = require("../../helpers/mixed");
|
|
14
18
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
19
|
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
16
20
|
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
@@ -20,6 +24,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
20
24
|
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"); }
|
|
21
25
|
const PLUGIN_KEY = exports.PLUGIN_KEY = 'customBorders';
|
|
22
26
|
const PLUGIN_PRIORITY = exports.PLUGIN_PRIORITY = 90;
|
|
27
|
+
const SUPPORTED_STYLES = ['dashed', 'dotted', 'solid'];
|
|
23
28
|
|
|
24
29
|
/* eslint-disable jsdoc/require-description-complete-sentence */
|
|
25
30
|
|
|
@@ -65,10 +70,12 @@ const PLUGIN_PRIORITY = exports.PLUGIN_PRIORITY = 90;
|
|
|
65
70
|
* start: {
|
|
66
71
|
* width: 2,
|
|
67
72
|
* color: 'red',
|
|
73
|
+
* style: 'dotted'
|
|
68
74
|
* },
|
|
69
75
|
* end: {
|
|
70
76
|
* width: 1,
|
|
71
77
|
* color: 'green',
|
|
78
|
+
* style: 'dashed'
|
|
72
79
|
* },
|
|
73
80
|
* top: '',
|
|
74
81
|
* bottom: '',
|
|
@@ -81,9 +88,10 @@ class CustomBorders extends _base.BasePlugin {
|
|
|
81
88
|
constructor() {
|
|
82
89
|
super(...arguments);
|
|
83
90
|
/**
|
|
84
|
-
*
|
|
91
|
+
* Validate the style settings. If the style value is not supported, the property is removed from the configuration.
|
|
85
92
|
*
|
|
86
|
-
* @
|
|
93
|
+
* @private
|
|
94
|
+
* @param {object[]} customBorders The user defined custom border objects array.
|
|
87
95
|
*/
|
|
88
96
|
_classPrivateMethodInitSpec(this, _CustomBorders_brand);
|
|
89
97
|
/**
|
|
@@ -700,6 +708,7 @@ class CustomBorders extends _base.BasePlugin {
|
|
|
700
708
|
if (this.hot.isRtl() && hasLeftOrRight) {
|
|
701
709
|
throw new Error('The "left"/"right" properties are not supported for RTL. Please use option "start"/"end".');
|
|
702
710
|
}
|
|
711
|
+
_assertClassBrand(_CustomBorders_brand, this, _validateStyleSettings).call(this, customBorders);
|
|
703
712
|
}
|
|
704
713
|
/**
|
|
705
714
|
* Destroys the plugin instance.
|
|
@@ -709,6 +718,27 @@ class CustomBorders extends _base.BasePlugin {
|
|
|
709
718
|
}
|
|
710
719
|
}
|
|
711
720
|
exports.CustomBorders = CustomBorders;
|
|
721
|
+
function _validateStyleSettings(customBorders) {
|
|
722
|
+
customBorders.forEach(customBorder => {
|
|
723
|
+
Object.keys(customBorder).forEach(key => {
|
|
724
|
+
const style = customBorder[key].style;
|
|
725
|
+
if ((0, _mixed.isDefined)(style) && !SUPPORTED_STYLES.includes(style)) {
|
|
726
|
+
// eslint-disable-next-line max-len
|
|
727
|
+
(0, _console.warn)(`The "${style}" border style is not supported. Please use one of the following styles: ${SUPPORTED_STYLES.join(', ')}.
|
|
728
|
+
The border style will be ignored.`);
|
|
729
|
+
delete customBorder[key].style;
|
|
730
|
+
} else if ((0, _mixed.isDefined)(style) && style === 'solid') {
|
|
731
|
+
// 'solid' is the default style
|
|
732
|
+
delete customBorder[key].style;
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Add border options to context menu.
|
|
739
|
+
*
|
|
740
|
+
* @param {object} defaultOptions Context menu items.
|
|
741
|
+
*/
|
|
712
742
|
function _onAfterContextMenuDefaultOptions(defaultOptions) {
|
|
713
743
|
if (!this.hot.getSettings()[PLUGIN_KEY]) {
|
|
714
744
|
return;
|