handsontable 0.0.0-next-a262af5-20230913 → 0.0.0-next-ab279a9-20230913
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/base.js +2 -2
- package/base.mjs +2 -2
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +2 -2
- package/dist/handsontable.full.js +67 -37
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +5 -5
- package/dist/handsontable.js +67 -37
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +5 -5
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +1 -1
- package/plugins/autoRowSize/autoRowSize.js +13 -6
- package/plugins/autoRowSize/autoRowSize.mjs +13 -6
- package/utils/ghostTable.js +31 -15
- package/utils/ghostTable.mjs +31 -15
- package/utils/samplesGenerator.js +20 -11
- package/utils/samplesGenerator.mjs +20 -11
package/helpers/mixed.js
CHANGED
@@ -134,7 +134,7 @@ const domMessages = {
|
|
134
134
|
function _injectProductInfo(key, element) {
|
135
135
|
const hasValidType = !isEmpty(key);
|
136
136
|
const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
|
137
|
-
const hotVersion = "0.0.0-next-
|
137
|
+
const hotVersion = "0.0.0-next-ab279a9-20230913";
|
138
138
|
let keyValidityDate;
|
139
139
|
let consoleMessageState = 'invalid';
|
140
140
|
let domMessageState = 'invalid';
|
package/helpers/mixed.mjs
CHANGED
@@ -124,7 +124,7 @@ const domMessages = {
|
|
124
124
|
export function _injectProductInfo(key, element) {
|
125
125
|
const hasValidType = !isEmpty(key);
|
126
126
|
const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
|
127
|
-
const hotVersion = "0.0.0-next-
|
127
|
+
const hotVersion = "0.0.0-next-ab279a9-20230913";
|
128
128
|
let keyValidityDate;
|
129
129
|
let consoleMessageState = 'invalid';
|
130
130
|
let domMessageState = 'invalid';
|
package/package.json
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
"url": "https://github.com/handsontable/handsontable/issues"
|
11
11
|
},
|
12
12
|
"author": "Handsoncode <hello@handsontable.com>",
|
13
|
-
"version": "0.0.0-next-
|
13
|
+
"version": "0.0.0-next-ab279a9-20230913",
|
14
14
|
"main": "index",
|
15
15
|
"module": "index.mjs",
|
16
16
|
"jsnext:main": "index.mjs",
|
@@ -147,12 +147,19 @@ class AutoRowSize extends _base.BasePlugin {
|
|
147
147
|
* @private
|
148
148
|
* @type {SamplesGenerator}
|
149
149
|
*/
|
150
|
-
this.samplesGenerator = new _samplesGenerator.default((row,
|
150
|
+
this.samplesGenerator = new _samplesGenerator.default((row, column) => {
|
151
|
+
if (row >= 0 && column >= 0) {
|
152
|
+
const cellMeta = this.hot.getCellMeta(row, column);
|
153
|
+
if (cellMeta.hidden) {
|
154
|
+
// do not generate samples for cells that are covered by merged cell (null values)
|
155
|
+
return false;
|
156
|
+
}
|
157
|
+
}
|
151
158
|
let cellValue;
|
152
159
|
if (row >= 0) {
|
153
|
-
cellValue = this.hot.getDataAtCell(row,
|
160
|
+
cellValue = this.hot.getDataAtCell(row, column);
|
154
161
|
} else if (row === -1) {
|
155
|
-
cellValue = this.hot.getColHeader(
|
162
|
+
cellValue = this.hot.getColHeader(column);
|
156
163
|
}
|
157
164
|
return {
|
158
165
|
value: cellValue
|
@@ -187,7 +194,7 @@ class AutoRowSize extends _base.BasePlugin {
|
|
187
194
|
this.hot.rowIndexMapper.registerMap(ROW_WIDTHS_MAP_NAME, this.rowHeightsMap);
|
188
195
|
|
189
196
|
// Leave the listener active to allow auto-sizing the rows when the plugin is disabled.
|
190
|
-
// This is
|
197
|
+
// This is necessary for height recalculation for resize handler doubleclick (ManualRowResize).
|
191
198
|
this.addHook('beforeRowResize', (size, row, isDblClick) => this.onBeforeRowResize(size, row, isDblClick));
|
192
199
|
}
|
193
200
|
|
@@ -577,11 +584,11 @@ class AutoRowSize extends _base.BasePlugin {
|
|
577
584
|
this.recalculateAllRowsHeight();
|
578
585
|
} else {
|
579
586
|
// first load - initialization
|
580
|
-
|
587
|
+
this.hot._registerTimeout(() => {
|
581
588
|
if (this.hot) {
|
582
589
|
this.recalculateAllRowsHeight();
|
583
590
|
}
|
584
|
-
}
|
591
|
+
});
|
585
592
|
}
|
586
593
|
}
|
587
594
|
|
@@ -141,12 +141,19 @@ export class AutoRowSize extends BasePlugin {
|
|
141
141
|
* @private
|
142
142
|
* @type {SamplesGenerator}
|
143
143
|
*/
|
144
|
-
this.samplesGenerator = new SamplesGenerator((row,
|
144
|
+
this.samplesGenerator = new SamplesGenerator((row, column) => {
|
145
|
+
if (row >= 0 && column >= 0) {
|
146
|
+
const cellMeta = this.hot.getCellMeta(row, column);
|
147
|
+
if (cellMeta.hidden) {
|
148
|
+
// do not generate samples for cells that are covered by merged cell (null values)
|
149
|
+
return false;
|
150
|
+
}
|
151
|
+
}
|
145
152
|
let cellValue;
|
146
153
|
if (row >= 0) {
|
147
|
-
cellValue = this.hot.getDataAtCell(row,
|
154
|
+
cellValue = this.hot.getDataAtCell(row, column);
|
148
155
|
} else if (row === -1) {
|
149
|
-
cellValue = this.hot.getColHeader(
|
156
|
+
cellValue = this.hot.getColHeader(column);
|
150
157
|
}
|
151
158
|
return {
|
152
159
|
value: cellValue
|
@@ -181,7 +188,7 @@ export class AutoRowSize extends BasePlugin {
|
|
181
188
|
this.hot.rowIndexMapper.registerMap(ROW_WIDTHS_MAP_NAME, this.rowHeightsMap);
|
182
189
|
|
183
190
|
// Leave the listener active to allow auto-sizing the rows when the plugin is disabled.
|
184
|
-
// This is
|
191
|
+
// This is necessary for height recalculation for resize handler doubleclick (ManualRowResize).
|
185
192
|
this.addHook('beforeRowResize', (size, row, isDblClick) => this.onBeforeRowResize(size, row, isDblClick));
|
186
193
|
}
|
187
194
|
|
@@ -571,11 +578,11 @@ export class AutoRowSize extends BasePlugin {
|
|
571
578
|
this.recalculateAllRowsHeight();
|
572
579
|
} else {
|
573
580
|
// first load - initialization
|
574
|
-
|
581
|
+
this.hot._registerTimeout(() => {
|
575
582
|
if (this.hot) {
|
576
583
|
this.recalculateAllRowsHeight();
|
577
584
|
}
|
578
|
-
}
|
585
|
+
});
|
579
586
|
}
|
580
587
|
}
|
581
588
|
|
package/utils/ghostTable.js
CHANGED
@@ -5,6 +5,9 @@ require("core-js/modules/es.error.cause.js");
|
|
5
5
|
require("core-js/modules/es.array.push.js");
|
6
6
|
var _element = require("./../helpers/dom/element");
|
7
7
|
var _array = require("./../helpers/array");
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
10
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
8
11
|
/**
|
9
12
|
* @class GhostTable
|
10
13
|
*/
|
@@ -15,47 +18,48 @@ class GhostTable {
|
|
15
18
|
*
|
16
19
|
* @type {Core}
|
17
20
|
*/
|
18
|
-
this
|
21
|
+
_defineProperty(this, "hot", null);
|
19
22
|
/**
|
20
23
|
* Container element where every table will be injected.
|
21
24
|
*
|
22
25
|
* @type {HTMLElement|null}
|
23
26
|
*/
|
24
|
-
this
|
27
|
+
_defineProperty(this, "container", null);
|
25
28
|
/**
|
26
29
|
* Flag which determine is table was injected to DOM.
|
27
30
|
*
|
28
31
|
* @type {boolean}
|
29
32
|
*/
|
30
|
-
this
|
33
|
+
_defineProperty(this, "injected", false);
|
31
34
|
/**
|
32
35
|
* Added rows collection.
|
33
36
|
*
|
34
37
|
* @type {Array}
|
35
38
|
*/
|
36
|
-
this
|
39
|
+
_defineProperty(this, "rows", []);
|
37
40
|
/**
|
38
41
|
* Added columns collection.
|
39
42
|
*
|
40
43
|
* @type {Array}
|
41
44
|
*/
|
42
|
-
this
|
45
|
+
_defineProperty(this, "columns", []);
|
43
46
|
/**
|
44
47
|
* Samples prepared for calculations.
|
45
48
|
*
|
46
49
|
* @type {Map}
|
47
50
|
* @default {null}
|
48
51
|
*/
|
49
|
-
this
|
52
|
+
_defineProperty(this, "samples", null);
|
50
53
|
/**
|
51
54
|
* Ghost table settings.
|
52
55
|
*
|
53
56
|
* @type {object}
|
54
57
|
* @default {Object}
|
55
58
|
*/
|
56
|
-
this
|
59
|
+
_defineProperty(this, "settings", {
|
57
60
|
useHeaders: true
|
58
|
-
};
|
61
|
+
});
|
62
|
+
this.hot = hotInstance;
|
59
63
|
}
|
60
64
|
|
61
65
|
/**
|
@@ -77,7 +81,7 @@ class GhostTable {
|
|
77
81
|
this.rows.push(rowObject);
|
78
82
|
this.samples = samples;
|
79
83
|
this.table = this.createTable(this.hot.table.className);
|
80
|
-
this.table.colGroup.appendChild(this.createColGroupsCol());
|
84
|
+
this.table.colGroup.appendChild(this.createColGroupsCol(row));
|
81
85
|
this.table.tr.appendChild(this.createRow(row));
|
82
86
|
this.container.container.appendChild(this.table.fragment);
|
83
87
|
rowObject.table = this.table.table;
|
@@ -221,16 +225,17 @@ class GhostTable {
|
|
221
225
|
/**
|
222
226
|
* Create colgroup col elements.
|
223
227
|
*
|
228
|
+
* @param {number} row Visual row index.
|
224
229
|
* @returns {DocumentFragment}
|
225
230
|
*/
|
226
|
-
createColGroupsCol() {
|
231
|
+
createColGroupsCol(row) {
|
227
232
|
const fragment = this.hot.rootDocument.createDocumentFragment();
|
228
233
|
if (this.hot.hasRowHeaders()) {
|
229
|
-
fragment.appendChild(this.createColElement(-1));
|
234
|
+
fragment.appendChild(this.createColElement(-1, -1));
|
230
235
|
}
|
231
236
|
this.samples.forEach(sample => {
|
232
237
|
(0, _array.arrayEach)(sample.strings, string => {
|
233
|
-
fragment.appendChild(this.createColElement(string.col));
|
238
|
+
fragment.appendChild(this.createColElement(string.col, row));
|
234
239
|
});
|
235
240
|
});
|
236
241
|
return fragment;
|
@@ -377,12 +382,23 @@ class GhostTable {
|
|
377
382
|
/**
|
378
383
|
* Create col element.
|
379
384
|
*
|
380
|
-
* @param {number} column
|
385
|
+
* @param {number} column Visual column index.
|
386
|
+
* @param {number} row Visual row index.
|
381
387
|
* @returns {HTMLElement}
|
382
388
|
*/
|
383
|
-
createColElement(column) {
|
389
|
+
createColElement(column, row) {
|
384
390
|
const col = this.hot.rootDocument.createElement('col');
|
385
|
-
|
391
|
+
let colspan = 0;
|
392
|
+
if (row >= 0 && column >= 0) {
|
393
|
+
colspan = this.hot.getCellMeta(row, column).colspan;
|
394
|
+
}
|
395
|
+
let width = this.hot.view._wt.wtTable.getStretchedColumnWidth(column);
|
396
|
+
if (colspan > 1) {
|
397
|
+
for (let nextColumn = column + 1; nextColumn < column + colspan; nextColumn++) {
|
398
|
+
width += this.hot.view._wt.wtTable.getStretchedColumnWidth(nextColumn);
|
399
|
+
}
|
400
|
+
}
|
401
|
+
col.style.width = `${width}px`;
|
386
402
|
return col;
|
387
403
|
}
|
388
404
|
|
package/utils/ghostTable.mjs
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
import "core-js/modules/es.error.cause.js";
|
2
2
|
import "core-js/modules/es.array.push.js";
|
3
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
4
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
5
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
3
6
|
import { addClass, outerHeight } from "./../helpers/dom/element.mjs";
|
4
7
|
import { arrayEach } from "./../helpers/array.mjs";
|
5
8
|
/**
|
@@ -12,47 +15,48 @@ class GhostTable {
|
|
12
15
|
*
|
13
16
|
* @type {Core}
|
14
17
|
*/
|
15
|
-
this
|
18
|
+
_defineProperty(this, "hot", null);
|
16
19
|
/**
|
17
20
|
* Container element where every table will be injected.
|
18
21
|
*
|
19
22
|
* @type {HTMLElement|null}
|
20
23
|
*/
|
21
|
-
this
|
24
|
+
_defineProperty(this, "container", null);
|
22
25
|
/**
|
23
26
|
* Flag which determine is table was injected to DOM.
|
24
27
|
*
|
25
28
|
* @type {boolean}
|
26
29
|
*/
|
27
|
-
this
|
30
|
+
_defineProperty(this, "injected", false);
|
28
31
|
/**
|
29
32
|
* Added rows collection.
|
30
33
|
*
|
31
34
|
* @type {Array}
|
32
35
|
*/
|
33
|
-
this
|
36
|
+
_defineProperty(this, "rows", []);
|
34
37
|
/**
|
35
38
|
* Added columns collection.
|
36
39
|
*
|
37
40
|
* @type {Array}
|
38
41
|
*/
|
39
|
-
this
|
42
|
+
_defineProperty(this, "columns", []);
|
40
43
|
/**
|
41
44
|
* Samples prepared for calculations.
|
42
45
|
*
|
43
46
|
* @type {Map}
|
44
47
|
* @default {null}
|
45
48
|
*/
|
46
|
-
this
|
49
|
+
_defineProperty(this, "samples", null);
|
47
50
|
/**
|
48
51
|
* Ghost table settings.
|
49
52
|
*
|
50
53
|
* @type {object}
|
51
54
|
* @default {Object}
|
52
55
|
*/
|
53
|
-
this
|
56
|
+
_defineProperty(this, "settings", {
|
54
57
|
useHeaders: true
|
55
|
-
};
|
58
|
+
});
|
59
|
+
this.hot = hotInstance;
|
56
60
|
}
|
57
61
|
|
58
62
|
/**
|
@@ -74,7 +78,7 @@ class GhostTable {
|
|
74
78
|
this.rows.push(rowObject);
|
75
79
|
this.samples = samples;
|
76
80
|
this.table = this.createTable(this.hot.table.className);
|
77
|
-
this.table.colGroup.appendChild(this.createColGroupsCol());
|
81
|
+
this.table.colGroup.appendChild(this.createColGroupsCol(row));
|
78
82
|
this.table.tr.appendChild(this.createRow(row));
|
79
83
|
this.container.container.appendChild(this.table.fragment);
|
80
84
|
rowObject.table = this.table.table;
|
@@ -218,16 +222,17 @@ class GhostTable {
|
|
218
222
|
/**
|
219
223
|
* Create colgroup col elements.
|
220
224
|
*
|
225
|
+
* @param {number} row Visual row index.
|
221
226
|
* @returns {DocumentFragment}
|
222
227
|
*/
|
223
|
-
createColGroupsCol() {
|
228
|
+
createColGroupsCol(row) {
|
224
229
|
const fragment = this.hot.rootDocument.createDocumentFragment();
|
225
230
|
if (this.hot.hasRowHeaders()) {
|
226
|
-
fragment.appendChild(this.createColElement(-1));
|
231
|
+
fragment.appendChild(this.createColElement(-1, -1));
|
227
232
|
}
|
228
233
|
this.samples.forEach(sample => {
|
229
234
|
arrayEach(sample.strings, string => {
|
230
|
-
fragment.appendChild(this.createColElement(string.col));
|
235
|
+
fragment.appendChild(this.createColElement(string.col, row));
|
231
236
|
});
|
232
237
|
});
|
233
238
|
return fragment;
|
@@ -374,12 +379,23 @@ class GhostTable {
|
|
374
379
|
/**
|
375
380
|
* Create col element.
|
376
381
|
*
|
377
|
-
* @param {number} column
|
382
|
+
* @param {number} column Visual column index.
|
383
|
+
* @param {number} row Visual row index.
|
378
384
|
* @returns {HTMLElement}
|
379
385
|
*/
|
380
|
-
createColElement(column) {
|
386
|
+
createColElement(column, row) {
|
381
387
|
const col = this.hot.rootDocument.createElement('col');
|
382
|
-
|
388
|
+
let colspan = 0;
|
389
|
+
if (row >= 0 && column >= 0) {
|
390
|
+
colspan = this.hot.getCellMeta(row, column).colspan;
|
391
|
+
}
|
392
|
+
let width = this.hot.view._wt.wtTable.getStretchedColumnWidth(column);
|
393
|
+
if (colspan > 1) {
|
394
|
+
for (let nextColumn = column + 1; nextColumn < column + colspan; nextColumn++) {
|
395
|
+
width += this.hot.view._wt.wtTable.getStretchedColumnWidth(nextColumn);
|
396
|
+
}
|
397
|
+
}
|
398
|
+
col.style.width = `${width}px`;
|
383
399
|
return col;
|
384
400
|
}
|
385
401
|
|
@@ -6,6 +6,9 @@ require("core-js/modules/es.array.push.js");
|
|
6
6
|
var _object = require("./../helpers/object");
|
7
7
|
var _number = require("./../helpers/number");
|
8
8
|
var _mixed = require("./../helpers/mixed");
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
11
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
9
12
|
/**
|
10
13
|
* @class SamplesGenerator
|
11
14
|
*/
|
@@ -18,34 +21,36 @@ class SamplesGenerator {
|
|
18
21
|
static get SAMPLE_COUNT() {
|
19
22
|
return 3;
|
20
23
|
}
|
24
|
+
/**
|
25
|
+
* Samples prepared for calculations.
|
26
|
+
*
|
27
|
+
* @type {Map}
|
28
|
+
* @default {null}
|
29
|
+
*/
|
30
|
+
|
21
31
|
constructor(dataFactory) {
|
22
|
-
|
23
|
-
* Samples prepared for calculations.
|
24
|
-
*
|
25
|
-
* @type {Map}
|
26
|
-
* @default {null}
|
27
|
-
*/
|
28
|
-
this.samples = null;
|
32
|
+
_defineProperty(this, "samples", null);
|
29
33
|
/**
|
30
34
|
* Function which give the data to collect samples.
|
31
35
|
*
|
32
36
|
* @type {Function}
|
33
37
|
*/
|
34
|
-
this
|
38
|
+
_defineProperty(this, "dataFactory", null);
|
35
39
|
/**
|
36
40
|
* Custom number of samples to take of each value length.
|
37
41
|
*
|
38
42
|
* @type {number}
|
39
43
|
* @default {null}
|
40
44
|
*/
|
41
|
-
this
|
45
|
+
_defineProperty(this, "customSampleCount", null);
|
42
46
|
/**
|
43
47
|
* `true` if duplicate samples collection should be allowed, `false` otherwise.
|
44
48
|
*
|
45
49
|
* @type {boolean}
|
46
50
|
* @default {false}
|
47
51
|
*/
|
48
|
-
this
|
52
|
+
_defineProperty(this, "allowDuplicates", false);
|
53
|
+
this.dataFactory = dataFactory;
|
49
54
|
}
|
50
55
|
|
51
56
|
/**
|
@@ -140,10 +145,14 @@ class SamplesGenerator {
|
|
140
145
|
const computedKey = type === 'row' ? 'col' : 'row';
|
141
146
|
const sampledValues = [];
|
142
147
|
(0, _number.rangeEach)(range.from, range.to, index => {
|
148
|
+
const data = type === 'row' ? this.dataFactory(specifierValue, index) : this.dataFactory(index, specifierValue);
|
149
|
+
if (data === false) {
|
150
|
+
return;
|
151
|
+
}
|
143
152
|
const {
|
144
153
|
value,
|
145
154
|
bundleSeed
|
146
|
-
} =
|
155
|
+
} = data;
|
147
156
|
const hasCustomBundleSeed = typeof bundleSeed === 'string' && bundleSeed.length > 0;
|
148
157
|
let seed;
|
149
158
|
if (hasCustomBundleSeed) {
|
@@ -1,5 +1,8 @@
|
|
1
1
|
import "core-js/modules/es.error.cause.js";
|
2
2
|
import "core-js/modules/es.array.push.js";
|
3
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
4
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
5
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
3
6
|
import { isObject } from "./../helpers/object.mjs";
|
4
7
|
import { rangeEach } from "./../helpers/number.mjs";
|
5
8
|
import { stringify } from "./../helpers/mixed.mjs";
|
@@ -15,34 +18,36 @@ class SamplesGenerator {
|
|
15
18
|
static get SAMPLE_COUNT() {
|
16
19
|
return 3;
|
17
20
|
}
|
21
|
+
/**
|
22
|
+
* Samples prepared for calculations.
|
23
|
+
*
|
24
|
+
* @type {Map}
|
25
|
+
* @default {null}
|
26
|
+
*/
|
27
|
+
|
18
28
|
constructor(dataFactory) {
|
19
|
-
|
20
|
-
* Samples prepared for calculations.
|
21
|
-
*
|
22
|
-
* @type {Map}
|
23
|
-
* @default {null}
|
24
|
-
*/
|
25
|
-
this.samples = null;
|
29
|
+
_defineProperty(this, "samples", null);
|
26
30
|
/**
|
27
31
|
* Function which give the data to collect samples.
|
28
32
|
*
|
29
33
|
* @type {Function}
|
30
34
|
*/
|
31
|
-
this
|
35
|
+
_defineProperty(this, "dataFactory", null);
|
32
36
|
/**
|
33
37
|
* Custom number of samples to take of each value length.
|
34
38
|
*
|
35
39
|
* @type {number}
|
36
40
|
* @default {null}
|
37
41
|
*/
|
38
|
-
this
|
42
|
+
_defineProperty(this, "customSampleCount", null);
|
39
43
|
/**
|
40
44
|
* `true` if duplicate samples collection should be allowed, `false` otherwise.
|
41
45
|
*
|
42
46
|
* @type {boolean}
|
43
47
|
* @default {false}
|
44
48
|
*/
|
45
|
-
this
|
49
|
+
_defineProperty(this, "allowDuplicates", false);
|
50
|
+
this.dataFactory = dataFactory;
|
46
51
|
}
|
47
52
|
|
48
53
|
/**
|
@@ -137,10 +142,14 @@ class SamplesGenerator {
|
|
137
142
|
const computedKey = type === 'row' ? 'col' : 'row';
|
138
143
|
const sampledValues = [];
|
139
144
|
rangeEach(range.from, range.to, index => {
|
145
|
+
const data = type === 'row' ? this.dataFactory(specifierValue, index) : this.dataFactory(index, specifierValue);
|
146
|
+
if (data === false) {
|
147
|
+
return;
|
148
|
+
}
|
140
149
|
const {
|
141
150
|
value,
|
142
151
|
bundleSeed
|
143
|
-
} =
|
152
|
+
} = data;
|
144
153
|
const hasCustomBundleSeed = typeof bundleSeed === 'string' && bundleSeed.length > 0;
|
145
154
|
let seed;
|
146
155
|
if (hasCustomBundleSeed) {
|