@revolist/revogrid 3.2.12 → 3.2.13

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.
Files changed (55) hide show
  1. package/custom-element/index.d.ts +98 -15
  2. package/custom-element/index.js +29221 -15
  3. package/package.json +1 -1
  4. package/custom-element/_baseIteratee.js +0 -2070
  5. package/custom-element/columnService.js +0 -743
  6. package/custom-element/consts.js +0 -46
  7. package/custom-element/data.store.js +0 -545
  8. package/custom-element/debounce.js +0 -217
  9. package/custom-element/dimension.helpers.js +0 -340
  10. package/custom-element/each.js +0 -180
  11. package/custom-element/filter.button.js +0 -36
  12. package/custom-element/identity.js +0 -26
  13. package/custom-element/isSymbol.js +0 -220
  14. package/custom-element/keys.js +0 -561
  15. package/custom-element/localScrollService.js +0 -86
  16. package/custom-element/revo-grid.d.ts +0 -11
  17. package/custom-element/revo-grid.js +0 -3661
  18. package/custom-element/revogr-clipboard.d.ts +0 -11
  19. package/custom-element/revogr-clipboard.js +0 -71
  20. package/custom-element/revogr-data.d.ts +0 -11
  21. package/custom-element/revogr-data.js +0 -9
  22. package/custom-element/revogr-data2.js +0 -170
  23. package/custom-element/revogr-edit.d.ts +0 -11
  24. package/custom-element/revogr-edit.js +0 -9
  25. package/custom-element/revogr-edit2.js +0 -401
  26. package/custom-element/revogr-filter-panel.d.ts +0 -11
  27. package/custom-element/revogr-filter-panel.js +0 -307
  28. package/custom-element/revogr-focus.d.ts +0 -11
  29. package/custom-element/revogr-focus.js +0 -9
  30. package/custom-element/revogr-focus2.js +0 -63
  31. package/custom-element/revogr-header.d.ts +0 -11
  32. package/custom-element/revogr-header.js +0 -9
  33. package/custom-element/revogr-header2.js +0 -590
  34. package/custom-element/revogr-order-editor.d.ts +0 -11
  35. package/custom-element/revogr-order-editor.js +0 -9
  36. package/custom-element/revogr-order-editor2.js +0 -189
  37. package/custom-element/revogr-overlay-selection.d.ts +0 -11
  38. package/custom-element/revogr-overlay-selection.js +0 -9
  39. package/custom-element/revogr-overlay-selection2.js +0 -740
  40. package/custom-element/revogr-row-headers.d.ts +0 -11
  41. package/custom-element/revogr-row-headers.js +0 -9
  42. package/custom-element/revogr-row-headers2.js +0 -402
  43. package/custom-element/revogr-scroll-virtual.d.ts +0 -11
  44. package/custom-element/revogr-scroll-virtual.js +0 -9
  45. package/custom-element/revogr-scroll-virtual2.js +0 -134
  46. package/custom-element/revogr-temp-range.d.ts +0 -11
  47. package/custom-element/revogr-temp-range.js +0 -9
  48. package/custom-element/revogr-temp-range2.js +0 -17274
  49. package/custom-element/revogr-viewport-scroll.d.ts +0 -11
  50. package/custom-element/revogr-viewport-scroll.js +0 -9
  51. package/custom-element/revogr-viewport-scroll2.js +0 -366
  52. package/custom-element/selection.utils.js +0 -106
  53. package/custom-element/toInteger.js +0 -107
  54. package/custom-element/toNumber.js +0 -105
  55. package/custom-element/utils.js +0 -69
@@ -1,740 +0,0 @@
1
- /*!
2
- * Built by Revolist
3
- */
4
- import { h, proxyCustomElement, HTMLElement, createEvent, Host } from '@stencil/core/internal/client';
5
- import { n as getRange, C as ColumnService, o as isRangeSingleCell } from './columnService.js';
6
- import { a as isCtrlKey, c as codesLetter, b as isClear, e as isEnterKey, f as isLetterKey, d as defineCustomElement$2 } from './revogr-edit2.js';
7
- import { E as EDIT_INPUT_WR, C as CELL_HANDLER_CLASS, S as SELECTION_BORDER_CLASS } from './consts.js';
8
- import { a as getCoordinate, i as isAfterLast, b as isBeforeFirst, c as getCell, d as getCurrentCell, e as getDirectionCoordinate, f as getLargestAxis, g as getElStyle } from './selection.utils.js';
9
- import { t as timeout } from './utils.js';
10
- import { d as debounce_1 } from './debounce.js';
11
- import { e as each } from './each.js';
12
- import { _ as _isIterateeCall, g as getSourceItem } from './data.store.js';
13
- import { t as toInteger_1 } from './toInteger.js';
14
- import { d as defineCustomElement$1 } from './revogr-order-editor2.js';
15
-
16
- class SelectionStoreService {
17
- constructor(store, config) {
18
- this.store = store;
19
- this.config = config;
20
- this.store = store;
21
- }
22
- get edited() {
23
- return this.store.get('edit');
24
- }
25
- get focused() {
26
- return this.store.get('focus');
27
- }
28
- get ranged() {
29
- return this.store.get('range');
30
- }
31
- changeRange(range) {
32
- return this.config.changeRange(range);
33
- }
34
- focus(cell, isMulti = false) {
35
- if (!cell) {
36
- return false;
37
- }
38
- let end = cell;
39
- // range edit
40
- if (isMulti) {
41
- let start = this.store.get('focus');
42
- if (start) {
43
- return this.config.changeRange(getRange(start, end));
44
- }
45
- }
46
- // single focus
47
- return this.config.focus(cell, end);
48
- }
49
- }
50
-
51
- // is edit input
52
- function isEditInput(el) {
53
- return !!(el === null || el === void 0 ? void 0 : el.closest(`.${EDIT_INPUT_WR}`));
54
- }
55
-
56
- class KeyboardService {
57
- constructor(sv) {
58
- this.sv = sv;
59
- this.ctrlDown = false;
60
- }
61
- async keyDown(e, canRange) {
62
- if (!this.sv.selectionStoreService.focused) {
63
- return;
64
- }
65
- if (isCtrlKey(e.keyCode, navigator.platform)) {
66
- this.ctrlDown = true;
67
- }
68
- // tab key means same as arrow right
69
- if (codesLetter.TAB === e.code) {
70
- this.keyChangeSelection(e, canRange);
71
- return;
72
- }
73
- /**
74
- * IF EDIT MODE
75
- */
76
- if (this.sv.selectionStoreService.edited) {
77
- switch (e.code) {
78
- case codesLetter.ESCAPE:
79
- this.sv.doEdit(undefined, true);
80
- break;
81
- }
82
- return;
83
- }
84
- /**
85
- * IF NOT EDIT MODE
86
- */
87
- // pressed clear key
88
- if (isClear(e.code)) {
89
- this.sv.clearCell();
90
- return;
91
- }
92
- // pressed enter
93
- if (isEnterKey(e.code)) {
94
- this.sv.doEdit();
95
- return;
96
- }
97
- // copy operation
98
- if (this.isCopy(e)) {
99
- return;
100
- }
101
- // paste operation
102
- if (this.isPaste(e)) {
103
- this.sv.internalPaste();
104
- return;
105
- }
106
- // pressed letter key
107
- if (isLetterKey(e.keyCode)) {
108
- this.sv.doEdit(e.key);
109
- return;
110
- }
111
- // pressed arrow, change selection position
112
- if (await this.keyChangeSelection(e, canRange)) {
113
- return;
114
- }
115
- }
116
- async keyChangeSelection(e, canRange) {
117
- const data = this.changeDirectionKey(e, canRange);
118
- if (!data) {
119
- return false;
120
- }
121
- await timeout();
122
- const range = this.sv.selectionStore.get('range');
123
- const focus = this.sv.selectionStore.get('focus');
124
- return this.keyPositionChange(data.changes, this.sv.getData(), range, focus, data.isMulti);
125
- }
126
- keyPositionChange(changes, eData, range, focus, isMulti = false) {
127
- if (!range || !focus) {
128
- return false;
129
- }
130
- const data = getCoordinate(range, focus, changes, isMulti);
131
- if (!data) {
132
- return false;
133
- }
134
- if (isMulti) {
135
- if (isAfterLast(data.end, eData) || isBeforeFirst(data.start)) {
136
- return false;
137
- }
138
- const range = getRange(data.start, data.end);
139
- return this.sv.selectionStoreService.changeRange(range);
140
- }
141
- return this.sv.selectionStoreService.focus(data.start);
142
- }
143
- keyUp(e) {
144
- if (isCtrlKey(e.keyCode, navigator.platform)) {
145
- this.ctrlDown = false;
146
- }
147
- }
148
- isCopy(e) {
149
- return this.ctrlDown && e.code == codesLetter.C;
150
- }
151
- isPaste(e) {
152
- return this.ctrlDown && e.code == codesLetter.V;
153
- }
154
- /** Monitor key direction changes */
155
- changeDirectionKey(e, canRange) {
156
- const isMulti = canRange && e.shiftKey;
157
- switch (e.code) {
158
- case codesLetter.TAB:
159
- case codesLetter.ARROW_UP:
160
- case codesLetter.ARROW_DOWN:
161
- case codesLetter.ARROW_LEFT:
162
- case codesLetter.ARROW_RIGHT:
163
- e.preventDefault();
164
- break;
165
- }
166
- switch (e.code) {
167
- case codesLetter.ARROW_UP:
168
- return { changes: { y: -1 }, isMulti };
169
- case codesLetter.ARROW_DOWN:
170
- return { changes: { y: 1 }, isMulti };
171
- case codesLetter.ARROW_LEFT:
172
- return { changes: { x: -1 }, isMulti };
173
- case codesLetter.TAB:
174
- case codesLetter.ARROW_RIGHT:
175
- return { changes: { x: 1 }, isMulti };
176
- }
177
- }
178
- }
179
-
180
- /**
181
- * The base implementation of `_.slice` without an iteratee call guard.
182
- *
183
- * @private
184
- * @param {Array} array The array to slice.
185
- * @param {number} [start=0] The start position.
186
- * @param {number} [end=array.length] The end position.
187
- * @returns {Array} Returns the slice of `array`.
188
- */
189
- function baseSlice(array, start, end) {
190
- var index = -1,
191
- length = array.length;
192
-
193
- if (start < 0) {
194
- start = -start > length ? 0 : (length + start);
195
- }
196
- end = end > length ? length : end;
197
- if (end < 0) {
198
- end += length;
199
- }
200
- length = start > end ? 0 : ((end - start) >>> 0);
201
- start >>>= 0;
202
-
203
- var result = Array(length);
204
- while (++index < length) {
205
- result[index] = array[index + start];
206
- }
207
- return result;
208
- }
209
-
210
- var _baseSlice = baseSlice;
211
-
212
- /**
213
- * Creates a slice of `array` from `start` up to, but not including, `end`.
214
- *
215
- * **Note:** This method is used instead of
216
- * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
217
- * returned.
218
- *
219
- * @static
220
- * @memberOf _
221
- * @since 3.0.0
222
- * @category Array
223
- * @param {Array} array The array to slice.
224
- * @param {number} [start=0] The start position.
225
- * @param {number} [end=array.length] The end position.
226
- * @returns {Array} Returns the slice of `array`.
227
- */
228
- function slice(array, start, end) {
229
- var length = array == null ? 0 : array.length;
230
- if (!length) {
231
- return [];
232
- }
233
- if (end && typeof end != 'number' && _isIterateeCall(array, start, end)) {
234
- start = 0;
235
- end = length;
236
- }
237
- else {
238
- start = start == null ? 0 : toInteger_1(start);
239
- end = end === undefined ? length : toInteger_1(end);
240
- }
241
- return _baseSlice(array, start, end);
242
- }
243
-
244
- var slice_1 = slice;
245
-
246
- var AutoFillType;
247
- (function (AutoFillType) {
248
- AutoFillType["selection"] = "Selection";
249
- AutoFillType["autoFill"] = "AutoFill";
250
- })(AutoFillType || (AutoFillType = {}));
251
- class AutoFillService {
252
- constructor(sv) {
253
- this.sv = sv;
254
- this.autoFillType = null;
255
- this.autoFillInitial = null;
256
- this.autoFillStart = null;
257
- this.autoFillLast = null;
258
- }
259
- /**
260
- * Render autofill box
261
- * @param range
262
- * @param selectionFocus
263
- */
264
- renderAutofill(range, selectionFocus) {
265
- let handlerStyle;
266
- if (range) {
267
- handlerStyle = getCell(range, this.sv.dimensionRow.state, this.sv.dimensionCol.state);
268
- }
269
- else {
270
- handlerStyle = getCell(Object.assign(Object.assign({}, selectionFocus), { x1: selectionFocus.x, y1: selectionFocus.y }), this.sv.dimensionRow.state, this.sv.dimensionCol.state);
271
- }
272
- return (h("div", { class: CELL_HANDLER_CLASS, style: { left: `${handlerStyle.right}px`, top: `${handlerStyle.bottom}px` }, onMouseDown: (e) => this.selectionStart(e, this.sv.getData(), AutoFillType.autoFill) }));
273
- }
274
- get isAutoFill() {
275
- return !!this.autoFillType;
276
- }
277
- /** Process mouse move events */
278
- selectionMouseMove(e) {
279
- // initiate mouse move debounce if not present
280
- if (!this.onMouseMoveAutofill) {
281
- this.onMouseMoveAutofill = debounce_1((e, data) => this.doAutofillMouseMove(e, data), 5);
282
- }
283
- if (this.isAutoFill) {
284
- this.onMouseMoveAutofill(e, this.sv.getData());
285
- }
286
- }
287
- getFocus() {
288
- let focus = this.sv.selectionStoreService.focused;
289
- const range = this.sv.selectionStoreService.ranged;
290
- if (range) {
291
- focus = { x: range.x, y: range.y };
292
- }
293
- if (!focus && !range) {
294
- return null;
295
- }
296
- return focus;
297
- }
298
- /**
299
- * Autofill logic:
300
- * on mouse move apply based on previous direction (if present)
301
- */
302
- doAutofillMouseMove({ x, y }, data) {
303
- if (!this.autoFillInitial) {
304
- return;
305
- }
306
- let current = getCurrentCell({ x, y }, data);
307
- let direction;
308
- if (this.autoFillLast) {
309
- direction = getDirectionCoordinate(this.autoFillStart, this.autoFillLast);
310
- }
311
- // first time or direction equal to start(same as first time)
312
- if (!this.autoFillLast || !direction) {
313
- direction = getLargestAxis(this.autoFillStart, current);
314
- if (!this.autoFillLast) {
315
- this.autoFillLast = this.autoFillStart;
316
- }
317
- }
318
- // nothing changed
319
- if (!direction) {
320
- return;
321
- }
322
- each(direction, (v, k) => {
323
- if (v) {
324
- current = Object.assign(Object.assign({}, this.autoFillLast), { [k]: current[k] });
325
- }
326
- });
327
- // check if not the latest
328
- if (isAfterLast(current, data)) {
329
- return;
330
- }
331
- this.autoFillLast = current;
332
- this.sv.setTempRange({
333
- area: getRange(this.autoFillInitial, this.autoFillLast),
334
- type: this.autoFillType,
335
- });
336
- }
337
- /**
338
- * Range selection started
339
- * Mode @param type:
340
- * Can be triggered from MouseDown selection on element
341
- * Or can be triggered on corner square drag
342
- */
343
- selectionStart(e, data, type = AutoFillType.selection) {
344
- /** Get cell by autofill element */
345
- const { top, left } = e.target.getBoundingClientRect();
346
- this.autoFillInitial = this.getFocus();
347
- this.autoFillType = type;
348
- this.autoFillStart = getCurrentCell({ x: left, y: top }, data);
349
- e.preventDefault();
350
- }
351
- /** Clear current range selection */
352
- clearAutoFillSelection() {
353
- // Apply autofill values on mouse up
354
- if (this.autoFillInitial) {
355
- // Get latest
356
- this.autoFillInitial = this.getFocus();
357
- if (this.autoFillType === AutoFillType.autoFill) {
358
- this.applyRangeWithData(this.autoFillInitial, this.autoFillLast);
359
- }
360
- else {
361
- this.applyRangeOnly(this.autoFillInitial, this.autoFillLast);
362
- }
363
- }
364
- this.autoFillType = null;
365
- this.autoFillInitial = null;
366
- this.autoFillLast = null;
367
- this.autoFillStart = null;
368
- }
369
- /** Trigger range apply events and handle responses */
370
- onRangeApply(data, range) {
371
- const models = {};
372
- for (let rowIndex in data) {
373
- models[rowIndex] = getSourceItem(this.sv.dataStore, parseInt(rowIndex, 10));
374
- }
375
- const dataEvent = this.sv.internalRangeDataApply({
376
- data,
377
- models,
378
- type: this.sv.dataStore.get('type'),
379
- });
380
- if (!dataEvent.defaultPrevented) {
381
- this.sv.columnService.applyRangeData(data);
382
- }
383
- this.sv.setRange(range);
384
- }
385
- /** Apply range and copy data during range application */
386
- applyRangeWithData(start, end) {
387
- // no changes to apply
388
- if (!start || !end) {
389
- return;
390
- }
391
- const oldRange = this.sv.selectionStoreService.ranged;
392
- const newRange = getRange(start, end);
393
- const columns = [...this.sv.columnService.columns];
394
- const rangeData = {
395
- type: this.sv.dataStore.get('type'),
396
- newData: {},
397
- newRange,
398
- oldRange,
399
- newProps: slice_1(columns, newRange.x, newRange.x1 + 1).map(v => v.prop),
400
- oldProps: slice_1(columns, oldRange.x, oldRange.x1 + 1).map(v => v.prop),
401
- };
402
- rangeData.newData = this.sv.columnService.getRangeData(rangeData);
403
- const selectionEndEvent = this.sv.internalSelectionChanged(rangeData);
404
- if (selectionEndEvent.defaultPrevented) {
405
- this.sv.setTempRange(null);
406
- return;
407
- }
408
- this.onRangeApply(rangeData.newData, newRange);
409
- }
410
- /** Update range selection ony, no data change (mouse selection) */
411
- applyRangeOnly(start, end) {
412
- // no changes to apply
413
- if (!start || !end) {
414
- return;
415
- }
416
- const newRange = getRange(start, end);
417
- this.sv.setRange(newRange);
418
- }
419
- }
420
-
421
- class ClipboardService {
422
- constructor(sv) {
423
- this.sv = sv;
424
- }
425
- onCopy(e) {
426
- const canCopy = this.sv.internalCopy();
427
- if (canCopy.defaultPrevented) {
428
- return false;
429
- }
430
- let focus = this.sv.selectionStoreService.focused;
431
- let range = this.sv.selectionStoreService.ranged;
432
- let data;
433
- if (!range) {
434
- range = getRange(focus, focus);
435
- }
436
- if (range) {
437
- const columns = [...this.sv.columnService.columns];
438
- const props = slice_1(columns, range.x, range.x1 + 1).map(v => v.prop);
439
- data = this.sv.columnService.copyRangeArray(range, props, this.sv.dataStore);
440
- }
441
- this.clipboard.doCopy(e, data);
442
- return true;
443
- }
444
- renderClipboard() {
445
- return h("revogr-clipboard", { onCopyRegion: e => this.onCopy(e.detail), ref: e => (this.clipboard = e), onPasteRegion: e => this.onPaste(e.detail) });
446
- }
447
- onPaste(data) {
448
- const focus = this.sv.selectionStoreService.focused;
449
- const isEditing = this.sv.selectionStoreService.edited !== null;
450
- if (!focus || isEditing) {
451
- return;
452
- }
453
- const { changed, range } = this.sv.columnService.getTransformedDataToApply(focus, data);
454
- this.sv.onRangeApply(changed, range);
455
- }
456
- }
457
-
458
- const revogrOverlayStyleCss = ".revo-drag-icon{-webkit-mask-image:url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 438 383' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Cpath d='M421.875,70.40625 C426.432292,70.40625 430.175781,68.9414062 433.105469,66.0117188 C436.035156,63.0820312 437.5,59.3385417 437.5,54.78125 L437.5,54.78125 L437.5,15.71875 C437.5,11.1614583 436.035156,7.41796875 433.105469,4.48828125 C430.175781,1.55859375 426.432292,0.09375 421.875,0.09375 L421.875,0.09375 L15.625,0.09375 C11.0677083,0.09375 7.32421875,1.55859375 4.39453125,4.48828125 C1.46484375,7.41796875 0,11.1614583 0,15.71875 L0,15.71875 L0,54.78125 C0,59.3385417 1.46484375,63.0820312 4.39453125,66.0117188 C7.32421875,68.9414062 11.0677083,70.40625 15.625,70.40625 L15.625,70.40625 L421.875,70.40625 Z M421.875,226.65625 C426.432292,226.65625 430.175781,225.191406 433.105469,222.261719 C436.035156,219.332031 437.5,215.588542 437.5,211.03125 L437.5,211.03125 L437.5,171.96875 C437.5,167.411458 436.035156,163.667969 433.105469,160.738281 C430.175781,157.808594 426.432292,156.34375 421.875,156.34375 L421.875,156.34375 L15.625,156.34375 C11.0677083,156.34375 7.32421875,157.808594 4.39453125,160.738281 C1.46484375,163.667969 0,167.411458 0,171.96875 L0,171.96875 L0,211.03125 C0,215.588542 1.46484375,219.332031 4.39453125,222.261719 C7.32421875,225.191406 11.0677083,226.65625 15.625,226.65625 L15.625,226.65625 L421.875,226.65625 Z M421.875,382.90625 C426.432292,382.90625 430.175781,381.441406 433.105469,378.511719 C436.035156,375.582031 437.5,371.838542 437.5,367.28125 L437.5,367.28125 L437.5,328.21875 C437.5,323.661458 436.035156,319.917969 433.105469,316.988281 C430.175781,314.058594 426.432292,312.59375 421.875,312.59375 L421.875,312.59375 L15.625,312.59375 C11.0677083,312.59375 7.32421875,314.058594 4.39453125,316.988281 C1.46484375,319.917969 0,323.661458 0,328.21875 L0,328.21875 L0,367.28125 C0,371.838542 1.46484375,375.582031 4.39453125,378.511719 C7.32421875,381.441406 11.0677083,382.90625 15.625,382.90625 L15.625,382.90625 L421.875,382.90625 Z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 438 383' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Cpath d='M421.875,70.40625 C426.432292,70.40625 430.175781,68.9414062 433.105469,66.0117188 C436.035156,63.0820312 437.5,59.3385417 437.5,54.78125 L437.5,54.78125 L437.5,15.71875 C437.5,11.1614583 436.035156,7.41796875 433.105469,4.48828125 C430.175781,1.55859375 426.432292,0.09375 421.875,0.09375 L421.875,0.09375 L15.625,0.09375 C11.0677083,0.09375 7.32421875,1.55859375 4.39453125,4.48828125 C1.46484375,7.41796875 0,11.1614583 0,15.71875 L0,15.71875 L0,54.78125 C0,59.3385417 1.46484375,63.0820312 4.39453125,66.0117188 C7.32421875,68.9414062 11.0677083,70.40625 15.625,70.40625 L15.625,70.40625 L421.875,70.40625 Z M421.875,226.65625 C426.432292,226.65625 430.175781,225.191406 433.105469,222.261719 C436.035156,219.332031 437.5,215.588542 437.5,211.03125 L437.5,211.03125 L437.5,171.96875 C437.5,167.411458 436.035156,163.667969 433.105469,160.738281 C430.175781,157.808594 426.432292,156.34375 421.875,156.34375 L421.875,156.34375 L15.625,156.34375 C11.0677083,156.34375 7.32421875,157.808594 4.39453125,160.738281 C1.46484375,163.667969 0,167.411458 0,171.96875 L0,171.96875 L0,211.03125 C0,215.588542 1.46484375,219.332031 4.39453125,222.261719 C7.32421875,225.191406 11.0677083,226.65625 15.625,226.65625 L15.625,226.65625 L421.875,226.65625 Z M421.875,382.90625 C426.432292,382.90625 430.175781,381.441406 433.105469,378.511719 C436.035156,375.582031 437.5,371.838542 437.5,367.28125 L437.5,367.28125 L437.5,328.21875 C437.5,323.661458 436.035156,319.917969 433.105469,316.988281 C430.175781,314.058594 426.432292,312.59375 421.875,312.59375 L421.875,312.59375 L15.625,312.59375 C11.0677083,312.59375 7.32421875,314.058594 4.39453125,316.988281 C1.46484375,319.917969 0,323.661458 0,328.21875 L0,328.21875 L0,367.28125 C0,371.838542 1.46484375,375.582031 4.39453125,378.511719 C7.32421875,381.441406 11.0677083,382.90625 15.625,382.90625 L15.625,382.90625 L421.875,382.90625 Z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E\");width:11px;height:7px;background-size:cover;background-repeat:no-repeat}.revo-alt-icon{-webkit-mask-image:url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 384 383' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Cpath d='M192.4375,383 C197.424479,383 201.663411,381.254557 205.154297,377.763672 L205.154297,377.763672 L264.25,318.667969 C270.234375,312.683594 271.605794,306.075846 268.364258,298.844727 C265.122721,291.613607 259.51237,287.998047 251.533203,287.998047 L251.533203,287.998047 L213.382812,287.998047 L213.382812,212.445312 L288.935547,212.445312 L288.935547,250.595703 C288.935547,258.57487 292.551107,264.185221 299.782227,267.426758 C307.013346,270.668294 313.621094,269.296875 319.605469,263.3125 L319.605469,263.3125 L378.701172,204.216797 C382.192057,200.725911 383.9375,196.486979 383.9375,191.5 C383.9375,186.513021 382.192057,182.274089 378.701172,178.783203 L378.701172,178.783203 L319.605469,119.6875 C313.621094,114.201823 307.013346,112.955078 299.782227,115.947266 C292.551107,118.939453 288.935547,124.42513 288.935547,132.404297 L288.935547,132.404297 L288.935547,170.554688 L213.382812,170.554688 L213.382812,95.0019531 L251.533203,95.0019531 C259.51237,95.0019531 264.998047,91.3863932 267.990234,84.1552734 C270.982422,76.9241536 269.735677,70.3164062 264.25,64.3320312 L264.25,64.3320312 L205.154297,5.23632812 C201.663411,1.74544271 197.424479,0 192.4375,0 C187.450521,0 183.211589,1.74544271 179.720703,5.23632812 L179.720703,5.23632812 L120.625,64.3320312 C114.640625,70.3164062 113.269206,76.9241536 116.510742,84.1552734 C119.752279,91.3863932 125.36263,95.0019531 133.341797,95.0019531 L133.341797,95.0019531 L171.492188,95.0019531 L171.492188,170.554688 L95.9394531,170.554688 L95.9394531,132.404297 C95.9394531,124.42513 92.3238932,118.814779 85.0927734,115.573242 C77.8616536,112.331706 71.2539062,113.703125 65.2695312,119.6875 L65.2695312,119.6875 L6.17382812,178.783203 C2.68294271,182.274089 0.9375,186.513021 0.9375,191.5 C0.9375,196.486979 2.68294271,200.725911 6.17382812,204.216797 L6.17382812,204.216797 L65.2695312,263.3125 C71.2539062,268.798177 77.8616536,270.044922 85.0927734,267.052734 C92.3238932,264.060547 95.9394531,258.57487 95.9394531,250.595703 L95.9394531,250.595703 L95.9394531,212.445312 L171.492188,212.445312 L171.492188,287.998047 L133.341797,287.998047 C125.36263,287.998047 119.876953,291.613607 116.884766,298.844727 C113.892578,306.075846 115.139323,312.683594 120.625,318.667969 L120.625,318.667969 L179.720703,377.763672 C183.211589,381.254557 187.450521,383 192.4375,383 Z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 384 383' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Cpath d='M192.4375,383 C197.424479,383 201.663411,381.254557 205.154297,377.763672 L205.154297,377.763672 L264.25,318.667969 C270.234375,312.683594 271.605794,306.075846 268.364258,298.844727 C265.122721,291.613607 259.51237,287.998047 251.533203,287.998047 L251.533203,287.998047 L213.382812,287.998047 L213.382812,212.445312 L288.935547,212.445312 L288.935547,250.595703 C288.935547,258.57487 292.551107,264.185221 299.782227,267.426758 C307.013346,270.668294 313.621094,269.296875 319.605469,263.3125 L319.605469,263.3125 L378.701172,204.216797 C382.192057,200.725911 383.9375,196.486979 383.9375,191.5 C383.9375,186.513021 382.192057,182.274089 378.701172,178.783203 L378.701172,178.783203 L319.605469,119.6875 C313.621094,114.201823 307.013346,112.955078 299.782227,115.947266 C292.551107,118.939453 288.935547,124.42513 288.935547,132.404297 L288.935547,132.404297 L288.935547,170.554688 L213.382812,170.554688 L213.382812,95.0019531 L251.533203,95.0019531 C259.51237,95.0019531 264.998047,91.3863932 267.990234,84.1552734 C270.982422,76.9241536 269.735677,70.3164062 264.25,64.3320312 L264.25,64.3320312 L205.154297,5.23632812 C201.663411,1.74544271 197.424479,0 192.4375,0 C187.450521,0 183.211589,1.74544271 179.720703,5.23632812 L179.720703,5.23632812 L120.625,64.3320312 C114.640625,70.3164062 113.269206,76.9241536 116.510742,84.1552734 C119.752279,91.3863932 125.36263,95.0019531 133.341797,95.0019531 L133.341797,95.0019531 L171.492188,95.0019531 L171.492188,170.554688 L95.9394531,170.554688 L95.9394531,132.404297 C95.9394531,124.42513 92.3238932,118.814779 85.0927734,115.573242 C77.8616536,112.331706 71.2539062,113.703125 65.2695312,119.6875 L65.2695312,119.6875 L6.17382812,178.783203 C2.68294271,182.274089 0.9375,186.513021 0.9375,191.5 C0.9375,196.486979 2.68294271,200.725911 6.17382812,204.216797 L6.17382812,204.216797 L65.2695312,263.3125 C71.2539062,268.798177 77.8616536,270.044922 85.0927734,267.052734 C92.3238932,264.060547 95.9394531,258.57487 95.9394531,250.595703 L95.9394531,250.595703 L95.9394531,212.445312 L171.492188,212.445312 L171.492188,287.998047 L133.341797,287.998047 C125.36263,287.998047 119.876953,291.613607 116.884766,298.844727 C113.892578,306.075846 115.139323,312.683594 120.625,318.667969 L120.625,318.667969 L179.720703,377.763672 C183.211589,381.254557 187.450521,383 192.4375,383 Z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E\");width:11px;height:11px;background-size:cover;background-repeat:no-repeat}.arrow-down{position:absolute;right:5px;top:0}.arrow-down svg{width:8px;margin-top:5px;margin-left:5px;opacity:0.4}.cell-value-wrapper{margin-right:10px;overflow:hidden;text-overflow:ellipsis}.revo-button{position:relative;overflow:hidden;color:#fff;background-color:#6200ee;height:34px;line-height:34px;padding:0 15px;outline:0;border:0;border-radius:7px;box-sizing:border-box;cursor:pointer}.revo-button.green{background-color:#2ee072;border:1px solid #20d565}.revo-button.red{background-color:#E0662E;border:1px solid #d55920}.revo-button:disabled,.revo-button[disabled]{cursor:not-allowed !important;filter:opacity(0.35) !important}.revo-button.light{border:2px solid #cedefa;line-height:32px;background:none;color:#4876ca;box-shadow:none}revogr-overlay-selection{display:block;position:relative;width:100%}revogr-overlay-selection .autofill-handle{position:absolute;width:10px;height:10px;background:#0d63e8;margin-left:-9px;margin-top:-9px;border:1px solid white;box-sizing:border-box;z-index:10;cursor:crosshair}revogr-overlay-selection .selection-border-range{position:absolute;pointer-events:none;z-index:9}revogr-overlay-selection .selection-border-range{box-shadow:-1px 0 0 #0d63e8 inset, 1px 0 0 #0d63e8 inset, 0 -1px 0 #0d63e8 inset, 0 1px 0 #0d63e8 inset}revogr-overlay-selection revogr-edit{z-index:10}";
459
-
460
- const OverlaySelection = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
461
- constructor() {
462
- super();
463
- this.__registerHost();
464
- this.internalCopy = createEvent(this, "internalCopy", 7);
465
- this.internalPaste = createEvent(this, "internalPaste", 7);
466
- this.internalCellEdit = createEvent(this, "internalCellEdit", 7);
467
- this.internalFocusCell = createEvent(this, "internalFocusCell", 7);
468
- this.setEdit = createEvent(this, "setEdit", 3);
469
- this.setRange = createEvent(this, "setRange", 7);
470
- this.setTempRange = createEvent(this, "setTempRange", 7);
471
- this.focusCell = createEvent(this, "focusCell", 3);
472
- this.internalSelectionChanged = createEvent(this, "internalSelectionChanged", 7);
473
- this.internalRangeDataApply = createEvent(this, "internalRangeDataApply", 7);
474
- this.keyboardService = null;
475
- this.autoFillService = null;
476
- this.clipboardService = null;
477
- }
478
- // --------------------------------------------------------------------------
479
- //
480
- // Listeners
481
- //
482
- // --------------------------------------------------------------------------
483
- onMouseMove(e) {
484
- if (this.selectionStoreService.focused) {
485
- this.autoFillService.selectionMouseMove(e);
486
- }
487
- }
488
- /** Pointer left document, clear any active operation */
489
- onMouseOut() {
490
- this.autoFillService.clearAutoFillSelection();
491
- }
492
- /** Action finished inside of the document */
493
- onMouseUp() {
494
- this.autoFillService.clearAutoFillSelection();
495
- }
496
- /** Row drag started */
497
- onCellDrag(e) {
498
- var _a;
499
- (_a = this.orderEditor) === null || _a === void 0 ? void 0 : _a.dragStart(e.detail);
500
- }
501
- /** Recived keyboard down from element */
502
- onKeyUp(e) {
503
- var _a;
504
- (_a = this.keyboardService) === null || _a === void 0 ? void 0 : _a.keyUp(e);
505
- }
506
- /** Recived keyboard down from element */
507
- onKeyDown(e) {
508
- var _a;
509
- if (e.defaultPrevented) {
510
- return;
511
- }
512
- (_a = this.keyboardService) === null || _a === void 0 ? void 0 : _a.keyDown(e, this.range);
513
- }
514
- /** Create selection store */
515
- selectionServiceSet(s) {
516
- this.selectionStoreService = new SelectionStoreService(s, {
517
- changeRange: range => { var _a; return !((_a = this.setRange.emit(range)) === null || _a === void 0 ? void 0 : _a.defaultPrevented); },
518
- focus: (focus, end) => {
519
- var _a;
520
- const focused = { focus, end };
521
- const { defaultPrevented } = this.internalFocusCell.emit(this.columnService.getSaveData(focus.y, focus.x));
522
- if (defaultPrevented) {
523
- return false;
524
- }
525
- return !((_a = this.focusCell.emit(focused)) === null || _a === void 0 ? void 0 : _a.defaultPrevented);
526
- },
527
- });
528
- this.keyboardService = new KeyboardService({
529
- selectionStoreService: this.selectionStoreService,
530
- selectionStore: s,
531
- doEdit: (v, c) => this.doEdit(v, c),
532
- clearCell: () => this.clearCell(),
533
- getData: () => this.getData(),
534
- internalPaste: () => this.internalPaste.emit()
535
- });
536
- this.createAutoFillService();
537
- this.createClipboardService();
538
- }
539
- createAutoFillService() {
540
- this.autoFillService = new AutoFillService({
541
- selectionStoreService: this.selectionStoreService,
542
- dimensionRow: this.dimensionRow,
543
- dimensionCol: this.dimensionCol,
544
- columnService: this.columnService,
545
- dataStore: this.dataStore,
546
- setTempRange: (e) => this.setTempRange.emit(e),
547
- internalSelectionChanged: (e) => this.internalSelectionChanged.emit(e),
548
- internalRangeDataApply: (e) => this.internalRangeDataApply.emit(e),
549
- setRange: (e) => this.setRange.emit(e),
550
- getData: () => this.getData(),
551
- });
552
- }
553
- columnServiceSet() {
554
- var _a;
555
- (_a = this.columnService) === null || _a === void 0 ? void 0 : _a.destroy();
556
- this.columnService = new ColumnService(this.dataStore, this.colData);
557
- this.createAutoFillService();
558
- this.createClipboardService();
559
- }
560
- createClipboardService() {
561
- this.clipboardService = new ClipboardService({
562
- selectionStoreService: this.selectionStoreService,
563
- columnService: this.columnService,
564
- dataStore: this.dataStore,
565
- onRangeApply: (d, r) => this.autoFillService.onRangeApply(d, r),
566
- internalCopy: () => this.internalCopy.emit()
567
- });
568
- }
569
- connectedCallback() {
570
- this.columnServiceSet();
571
- this.selectionServiceSet(this.selectionStore);
572
- }
573
- disconnectedCallback() {
574
- var _a;
575
- (_a = this.columnService) === null || _a === void 0 ? void 0 : _a.destroy();
576
- }
577
- renderRange(range) {
578
- const style = getElStyle(range, this.dimensionRow.state, this.dimensionCol.state);
579
- return [h("div", { class: SELECTION_BORDER_CLASS, style: style })];
580
- }
581
- renderEditCell() {
582
- // if can edit
583
- const editCell = this.selectionStore.get('edit');
584
- if (this.readonly || !editCell) {
585
- return;
586
- }
587
- const val = editCell.val || this.columnService.getCellData(editCell.y, editCell.x);
588
- const editable = Object.assign(Object.assign({}, editCell), this.columnService.getSaveData(editCell.y, editCell.x, val));
589
- const style = getElStyle(Object.assign(Object.assign({}, editCell), { x1: editCell.x, y1: editCell.y }), this.dimensionRow.state, this.dimensionCol.state);
590
- return (h("revogr-edit", { onCellEdit: e => this.onCellEdit(e.detail), onCloseEdit: e => this.closeEdit(e), editCell: editable, column: this.columnService.columns[editCell.x], editor: this.columnService.getCellEditor(editCell.y, editCell.x, this.editors), style: style }));
591
- }
592
- render() {
593
- const range = this.selectionStoreService.ranged;
594
- const selectionFocus = this.selectionStoreService.focused;
595
- const els = [];
596
- if ((range || selectionFocus) && this.useClipboard) {
597
- els.push(this.clipboardService.renderClipboard());
598
- }
599
- if (range) {
600
- els.push(...this.renderRange(range));
601
- }
602
- const editCell = this.renderEditCell();
603
- if (editCell) {
604
- els.push(editCell);
605
- }
606
- if (selectionFocus && !this.readonly && !editCell && this.range) {
607
- els.push(this.autoFillService.renderAutofill(range, selectionFocus));
608
- }
609
- if (this.canDrag) {
610
- els.push(h("revogr-order-editor", { ref: e => (this.orderEditor = e), dataStore: this.dataStore, dimensionRow: this.dimensionRow, dimensionCol: this.dimensionCol, parent: this.element, onInternalRowDragStart: e => this.onRowDragStart(e) }));
611
- }
612
- return (h(Host, { onDblClick: () => this.doEdit(), onMouseDown: (e) => this.onElementMouseDown(e) }, els, h("slot", { name: "data" })));
613
- }
614
- onElementMouseDown(e) {
615
- // Ignore focus if clicked input
616
- if (isEditInput(e.target)) {
617
- return;
618
- }
619
- const data = this.getData();
620
- if (e.defaultPrevented) {
621
- return;
622
- }
623
- // Regular cell click
624
- const focusCell = getCurrentCell({ x: e.x, y: e.y }, data);
625
- this.selectionStoreService.focus(focusCell, this.range && e.shiftKey);
626
- // Initiate autofill selection
627
- if (this.range) {
628
- this.autoFillService.selectionStart(e, data);
629
- }
630
- }
631
- doEdit(val = '', isCancel = false) {
632
- var _a;
633
- if (this.canEdit()) {
634
- const editCell = this.selectionStore.get('focus');
635
- const data = this.columnService.getSaveData(editCell.y, editCell.x);
636
- (_a = this.setEdit) === null || _a === void 0 ? void 0 : _a.emit(Object.assign(Object.assign({}, data), { isCancel,
637
- val }));
638
- }
639
- }
640
- closeEdit(e) {
641
- this.doEdit(undefined, true);
642
- if (e === null || e === void 0 ? void 0 : e.detail) {
643
- this.focusNext();
644
- }
645
- }
646
- async focusNext() {
647
- const canFocus = await this.keyboardService.keyChangeSelection(new KeyboardEvent('keydown', {
648
- code: codesLetter.ARROW_DOWN,
649
- }), this.range);
650
- if (!canFocus) {
651
- this.closeEdit();
652
- }
653
- }
654
- clearCell() {
655
- if (this.selectionStoreService.ranged && !isRangeSingleCell(this.selectionStoreService.ranged)) {
656
- const data = this.columnService.getRangeStaticData(this.selectionStoreService.ranged, '');
657
- this.autoFillService.onRangeApply(data, this.selectionStoreService.ranged);
658
- }
659
- else if (this.canEdit()) {
660
- const focused = this.selectionStoreService.focused;
661
- this.onCellEdit({ rgRow: focused.y, rgCol: focused.x, val: '' }, true);
662
- }
663
- }
664
- /** Edit finished, close cell and save */
665
- onCellEdit(e, clear = false) {
666
- const dataToSave = this.columnService.getSaveData(e.rgRow, e.rgCol, e.val);
667
- this.internalCellEdit.emit(dataToSave);
668
- // if not clear navigate to next cell after edit
669
- if (!clear && !e.preventFocus) {
670
- this.focusNext();
671
- }
672
- }
673
- onRowDragStart({ detail }) {
674
- detail.text = this.columnService.getCellData(detail.cell.y, detail.cell.x);
675
- }
676
- /** Check if edit possible */
677
- canEdit() {
678
- var _a;
679
- if (this.readonly) {
680
- return false;
681
- }
682
- const editCell = this.selectionStoreService.focused;
683
- return editCell && !((_a = this.columnService) === null || _a === void 0 ? void 0 : _a.isReadOnly(editCell.y, editCell.x));
684
- }
685
- /** Collect data from element */
686
- getData() {
687
- return {
688
- el: this.element,
689
- rows: this.dimensionRow.state,
690
- cols: this.dimensionCol.state,
691
- lastCell: this.lastCell,
692
- };
693
- }
694
- get element() { return this; }
695
- static get watchers() { return {
696
- "selectionStore": ["selectionServiceSet"],
697
- "dimensionRow": ["createAutoFillService"],
698
- "dimensionCol": ["createAutoFillService"],
699
- "dataStore": ["columnServiceSet"],
700
- "colData": ["columnServiceSet"]
701
- }; }
702
- static get style() { return revogrOverlayStyleCss; }
703
- }, [4, "revogr-overlay-selection", {
704
- "readonly": [4],
705
- "range": [4],
706
- "canDrag": [4, "can-drag"],
707
- "useClipboard": [4, "use-clipboard"],
708
- "selectionStore": [16],
709
- "dimensionRow": [16],
710
- "dimensionCol": [16],
711
- "dataStore": [16],
712
- "colData": [16],
713
- "lastCell": [16],
714
- "editors": [16]
715
- }, [[5, "mousemove", "onMouseMove"], [5, "mouseleave", "onMouseOut"], [5, "mouseup", "onMouseUp"], [0, "dragStartCell", "onCellDrag"], [4, "keyup", "onKeyUp"], [4, "keydown", "onKeyDown"]]]);
716
- function defineCustomElement() {
717
- if (typeof customElements === "undefined") {
718
- return;
719
- }
720
- const components = ["revogr-overlay-selection", "revogr-edit", "revogr-order-editor"];
721
- components.forEach(tagName => { switch (tagName) {
722
- case "revogr-overlay-selection":
723
- if (!customElements.get(tagName)) {
724
- customElements.define(tagName, OverlaySelection);
725
- }
726
- break;
727
- case "revogr-edit":
728
- if (!customElements.get(tagName)) {
729
- defineCustomElement$2();
730
- }
731
- break;
732
- case "revogr-order-editor":
733
- if (!customElements.get(tagName)) {
734
- defineCustomElement$1();
735
- }
736
- break;
737
- } });
738
- }
739
-
740
- export { OverlaySelection as O, defineCustomElement as d };