@endge/ui-vue 0.33.1 → 0.35.0

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.
@@ -1,967 +0,0 @@
1
- import { r as f, h as c, H as S, c as l, q as O, f as E, N as L, O as p, P as H, Q as T, U as W, W as m, X as A, Y as u, V as B, p as P, Z as V, _ as D, $ as N, a0 as $, o as b, t as K, a1 as U, l as X, a2 as Y, R as G, a3 as _ } from "./main-CTvK8fpg.js";
2
- import { v as Z, g as C } from "./events-BvSmBueA-Doh7RyHn.js";
3
- import { i as z, a as j, b as q, c as Q, d as J, e as ee, f as te, g as ie, h as se } from "./edit.utils-Dnnbd0xG-D5rAByEo.js";
4
- import { H as oe } from "./viewport.helpers-CoCAvmZs-f555rwPU.js";
5
- import { L as ne, a as re, g as le, t as ae } from "./throttle-Cpk1LoGk-BRnDVCTo.js";
6
- /*!
7
- * Built by Revolist OU ❤️
8
- */
9
- const _e = class {
10
- constructor(t) {
11
- f(this, t);
12
- }
13
- render() {
14
- return c(S, { key: "3d66475a019010c24b6c610ccc047e01c35178f9" }, c("a", { key: "777afddffef0309a697b9c14ee73c0001ac22b71", href: "https://rv-grid.com/guide/attribution", target: "_blank", rel: "noopener noreferrer", title: "Made with ❤️ by Revolist OU Team", class: "value" }, "RevoGrid"));
15
- }
16
- }, je = class {
17
- constructor(t) {
18
- f(this, t), this.nodes = [], this.update = 1;
19
- }
20
- /**
21
- * Refreshes the extra component. Useful if you want to manually
22
- * force the component to re-render.
23
- */
24
- async refresh() {
25
- this.update *= -1;
26
- }
27
- render() {
28
- var t;
29
- return (t = this.nodes) === null || t === void 0 ? void 0 : t.map((e) => {
30
- if (typeof e == "function") {
31
- const i = {}, s = () => [e({ refresh: () => {
32
- var o;
33
- return (o = i.refresh) === null || o === void 0 ? void 0 : o.call(i);
34
- } })];
35
- return c("revogr-extra", { nodes: s(), ref: (o) => {
36
- o && (i.refresh = () => {
37
- o.nodes = s();
38
- });
39
- } });
40
- }
41
- return e;
42
- });
43
- }
44
- };
45
- function M(t, e) {
46
- const i = {};
47
- for (let s in t) {
48
- const o = parseInt(s, 10);
49
- i[o] = O(e, o);
50
- }
51
- return i;
52
- }
53
- function k(t, e) {
54
- if (t.defaultPrevented)
55
- return null;
56
- const i = C(t, "clientX"), s = C(t, "clientY");
57
- if (i === null || s === null)
58
- return null;
59
- const o = F({ x: i, y: s }, e);
60
- return w(o, e.lastCell) ? null : o;
61
- }
62
- function F({ x: t, y: e }, { el: i, rows: s, cols: o }) {
63
- const { top: n, left: r, height: a, width: h } = i.getBoundingClientRect();
64
- let d = e - n, g = t - r;
65
- d >= a && (d = a - 1), g >= h && (g = h - 1);
66
- const v = _(s, d + (s.renderOffset || 0)), R = _(o, g + (o.renderOffset || 0));
67
- return R.itemIndex < 0 && (R.itemIndex = 0), v.itemIndex < 0 && (v.itemIndex = 0), { x: R.itemIndex, y: v.itemIndex };
68
- }
69
- function ce(t, e, i, s = !1) {
70
- const o = (n, r = 0) => {
71
- const a = { x: t.x, y: t.y }, h = s ? { x: t.x1, y: t.y1 } : a, d = h[n] > e[n] ? h : a;
72
- return d[n] += r, { start: a, end: h };
73
- };
74
- return i.x ? o("x", i.x) : i.y ? o("y", i.y) : null;
75
- }
76
- function w({ x: t, y: e }, i) {
77
- return t >= i.x || e >= i.y;
78
- }
79
- function I({ x: t, y: e }) {
80
- return t < 0 || e < 0;
81
- }
82
- function x(t) {
83
- return {
84
- left: `${t.left}px`,
85
- top: `${t.top}px`,
86
- width: `${t.width}px`,
87
- height: `${t.height}px`
88
- };
89
- }
90
- function y({ x: t, y: e, x1: i, y1: s }, o, n) {
91
- const r = o.renderOffset || 0, a = n.renderOffset || 0, h = b(o, e).start - r, d = b(n, t).start - a, g = b(o, s).end - r, v = b(n, i).end - a;
92
- return {
93
- left: d,
94
- right: v,
95
- top: h,
96
- bottom: g,
97
- width: v - d,
98
- height: g - h
99
- };
100
- }
101
- const he = () => "revogr-focus.focused-cell{box-shadow:-1px 0 0 #0d63e8 inset, 1px 0 0 #0d63e8 inset, 0 -1px 0 #0d63e8 inset, 0 1px 0 #0d63e8 inset;position:absolute;pointer-events:none;z-index:9;display:block !important}", de = class {
102
- constructor(e) {
103
- f(this, e), this.beforeFocusRender = l(this, "beforefocusrender", 7), this.beforeScrollIntoView = l(this, "beforescrollintoview", 7), this.afterFocus = l(this, "afterfocus", 7), this.focusTemplate = null, this.activeFocus = null;
104
- }
105
- componentDidRender() {
106
- var e, i;
107
- const s = this.selectionStore.get("focus");
108
- if (!(((e = this.activeFocus) === null || e === void 0 ? void 0 : e.x) === (s == null ? void 0 : s.x) && ((i = this.activeFocus) === null || i === void 0 ? void 0 : i.y) === (s == null ? void 0 : s.y)) && (this.activeFocus = s, s && this.el)) {
109
- this.beforeScrollIntoView.emit({ el: this.el }).defaultPrevented || this.el.scrollIntoView({
110
- block: "nearest",
111
- inline: "nearest"
112
- });
113
- const n = O(this.dataStore, s.y), r = O(this.colData, s.x);
114
- this.afterFocus.emit({
115
- model: n,
116
- column: r,
117
- rowType: this.rowType,
118
- colType: this.colType,
119
- rowIndex: s.y,
120
- colIndex: s.x
121
- });
122
- }
123
- }
124
- render() {
125
- var e;
126
- if (this.selectionStore.get("edit"))
127
- return;
128
- const s = this.selectionStore.get("focus");
129
- if (!s)
130
- return;
131
- const o = this.beforeFocusRender.emit({
132
- range: Object.assign(Object.assign({}, s), { x1: s.x, y1: s.y }),
133
- rowType: this.rowType,
134
- colType: this.colType,
135
- rowDimension: Object.assign({}, this.dimensionRow.state),
136
- colDimension: Object.assign({}, this.dimensionCol.state)
137
- });
138
- if (o.defaultPrevented)
139
- return c("slot", null);
140
- const { detail: n } = o, r = y(n.range, o.detail.rowDimension, o.detail.colDimension), a = x(r), h = (e = this.focusTemplate) === null || e === void 0 ? void 0 : e.call(this, c, n), d = {
141
- class: { [$]: !0 },
142
- style: a
143
- };
144
- return c(S, Object.assign({}, d), c("slot", null), h);
145
- }
146
- get el() {
147
- return E(this);
148
- }
149
- };
150
- de.style = he();
151
- const ue = [
152
- u.TAB,
153
- u.ARROW_UP,
154
- u.ARROW_DOWN,
155
- u.ARROW_LEFT,
156
- u.ARROW_RIGHT
157
- ];
158
- class ge {
159
- constructor(e) {
160
- this.sv = e;
161
- }
162
- /**
163
- * Appends printable key input that arrives after edit mode was requested
164
- * but before the editor input has mounted or received focus.
165
- */
166
- appendPendingEditValue(e) {
167
- if (j(e) || e.key.length !== 1 || e.target instanceof HTMLElement && z(e.target))
168
- return !1;
169
- const i = this.sv.selectionStore.get("edit");
170
- return typeof (i == null ? void 0 : i.val) != "string" ? !1 : (this.sv.selectionStore.set("edit", Object.assign(Object.assign({}, i), { val: `${i.val}${e.key}` })), !0);
171
- }
172
- async keyDown(e, i, s, { range: o, focus: n }) {
173
- if (s) {
174
- if (this.appendPendingEditValue(e))
175
- return;
176
- switch (e.code) {
177
- case u.ESCAPE:
178
- this.sv.cancel();
179
- break;
180
- case u.TAB:
181
- this.keyChangeSelection(e, i);
182
- break;
183
- }
184
- return;
185
- }
186
- if (o && q(e.code)) {
187
- this.sv.clearCell();
188
- return;
189
- }
190
- if (n) {
191
- if (Q(e.code)) {
192
- this.keyChangeSelection(e, i);
193
- return;
194
- }
195
- if (J(e.key)) {
196
- this.sv.change();
197
- return;
198
- }
199
- if (!ee(e) && !te(e)) {
200
- if (ie(e)) {
201
- this.sv.internalPaste();
202
- return;
203
- }
204
- if (se(e)) {
205
- i && this.selectAll(e);
206
- return;
207
- }
208
- if (!j(e) && e.key.length === 1) {
209
- this.sv.change(e.key);
210
- return;
211
- }
212
- await this.keyChangeSelection(e, i);
213
- }
214
- }
215
- }
216
- selectAll(e) {
217
- const i = this.sv.selectionStore.get("range"), s = this.sv.selectionStore.get("focus");
218
- !i || !s || (e.preventDefault(), this.sv.selectAll());
219
- }
220
- async keyChangeSelection(e, i) {
221
- const s = this.changeDirectionKey(e, i);
222
- if (!s)
223
- return !1;
224
- await K(G + 30);
225
- const o = this.sv.selectionStore.get("range"), n = this.sv.selectionStore.get("focus");
226
- return this.keyPositionChange(s.changes, o, n, s.isMulti);
227
- }
228
- keyPositionChange(e, i, s, o = !1) {
229
- if (!i || !s)
230
- return !1;
231
- const n = ce(i, s, e, o);
232
- if (!n)
233
- return !1;
234
- const r = this.sv.getData();
235
- if (o) {
236
- if ([n.start, n.end].some((d) => w(d, r.lastCell) || I(d)))
237
- return !1;
238
- const h = m(n.start, n.end);
239
- return this.sv.range(h);
240
- }
241
- return this.sv.focus(n.start, e, w(n.start, r.lastCell) ? 1 : I(n.start) ? -1 : 0);
242
- }
243
- /** Monitor key direction changes */
244
- changeDirectionKey(e, i) {
245
- const s = i && e.shiftKey;
246
- if (ue.includes(e.code) && e.preventDefault(), e.shiftKey)
247
- switch (e.code) {
248
- case u.TAB:
249
- return { changes: { x: -1 }, isMulti: !1 };
250
- }
251
- switch (e.code) {
252
- case u.ARROW_UP:
253
- return { changes: { y: -1 }, isMulti: s };
254
- case u.ARROW_DOWN:
255
- return { changes: { y: 1 }, isMulti: s };
256
- case u.ARROW_LEFT:
257
- return { changes: { x: -1 }, isMulti: s };
258
- case u.TAB:
259
- case u.ARROW_RIGHT:
260
- return { changes: { x: 1 }, isMulti: s };
261
- }
262
- }
263
- }
264
- class fe {
265
- constructor(e) {
266
- this.sv = e, this.autoFillType = null, this.autoFillInitial = null, this.autoFillStart = null, this.autoFillLast = null;
267
- }
268
- /**
269
- * Render autofill box
270
- * @param range
271
- * @param selectionFocus
272
- */
273
- renderAutofill(e, i, s = !1) {
274
- let o;
275
- return e ? o = y(e, this.sv.dimensionRow.state, this.sv.dimensionCol.state) : o = y(Object.assign(Object.assign({}, i), { x1: i.x, y1: i.y }), this.sv.dimensionRow.state, this.sv.dimensionCol.state), c("div", { class: {
276
- [U]: !0,
277
- [p]: s
278
- }, style: {
279
- left: `${o.right}px`,
280
- top: `${o.bottom}px`
281
- }, onMouseDown: (n) => this.autoFillHandler(n), onTouchStart: (n) => this.autoFillHandler(n) });
282
- }
283
- autoFillHandler(e, i = "AutoFill") {
284
- let s = null;
285
- e.target instanceof Element && (s = e.target), s && (this.selectionStart(s, this.sv.getData(), i), e.preventDefault());
286
- }
287
- get isAutoFill() {
288
- return !!this.autoFillType;
289
- }
290
- /**
291
- * Process mouse move events
292
- */
293
- selectionMouseMove(e) {
294
- this.onMouseMoveAutofill || (this.onMouseMoveAutofill = X((i, s) => this.doAutofillMouseMove(i, s), 5)), this.isAutoFill && this.onMouseMoveAutofill(e, this.sv.getData());
295
- }
296
- getFocus(e, i) {
297
- return !e && i && (e = { x: i.x, y: i.y }), e || null;
298
- }
299
- /**
300
- * Autofill logic:
301
- * on mouse move apply based on previous direction (if present)
302
- */
303
- doAutofillMouseMove(e, i) {
304
- if (!this.autoFillInitial)
305
- return;
306
- const s = C(e, "clientX", p), o = C(e, "clientY", p);
307
- if (s === null || o === null)
308
- return;
309
- const n = F({ x: s, y: o }, i);
310
- if (this.autoFillLast || this.autoFillLast || (this.autoFillLast = this.autoFillStart), w(n, i.lastCell))
311
- return;
312
- if (this.autoFillLast = n, n.x === this.autoFillInitial.x && n.y === this.autoFillInitial.y)
313
- this.sv.setTempRange(null);
314
- else {
315
- const a = m(this.autoFillInitial, this.autoFillLast);
316
- this.sv.setTempRange({
317
- area: a,
318
- type: this.autoFillType
319
- });
320
- }
321
- }
322
- /**
323
- * Range selection started
324
- * Mode @param type:
325
- * Can be triggered from MouseDown selection on element
326
- * Or can be triggered on corner square drag
327
- */
328
- selectionStart(e, i, s = "Selection") {
329
- const { top: o, left: n } = e.getBoundingClientRect();
330
- this.autoFillInitial = this.getFocus(i.focus, i.range), this.autoFillType = s, this.autoFillStart = F({ x: n, y: o }, i);
331
- }
332
- /**
333
- * Clear current range selection on mouse up and mouse leave events
334
- */
335
- clearAutoFillSelection(e, i) {
336
- if (this.autoFillInitial)
337
- if (this.autoFillInitial = this.getFocus(e, i), this.autoFillType === "AutoFill") {
338
- const s = m(this.autoFillInitial, this.autoFillLast);
339
- if (s) {
340
- const { defaultPrevented: o, detail: { range: n } } = this.sv.clearRangeDataApply({
341
- range: s
342
- });
343
- !o && i ? this.applyRangeWithData(n, i) : this.sv.setTempRange(null);
344
- }
345
- } else
346
- this.applyRangeOnly(this.autoFillInitial, this.autoFillLast);
347
- this.resetAutoFillState();
348
- }
349
- /**
350
- * Reset autofill state
351
- */
352
- resetAutoFillState() {
353
- this.autoFillType = null, this.autoFillInitial = null, this.autoFillLast = null, this.autoFillStart = null;
354
- }
355
- /**
356
- * Trigger range apply events and handle responses
357
- */
358
- onRangeApply(e, i, s) {
359
- this.sv.rangeDataApply({
360
- data: e,
361
- models: M(e, this.sv.dataStore),
362
- type: this.sv.dataStore.get("type"),
363
- oldRange: s,
364
- newRange: i
365
- }), this.sv.setRange(i);
366
- }
367
- /** Apply range and copy data during range application */
368
- applyRangeWithData(e, i) {
369
- const s = {
370
- type: this.sv.dataStore.get("type"),
371
- colType: this.sv.columnService.type,
372
- newData: {},
373
- mapping: {},
374
- newRange: e,
375
- oldRange: i
376
- }, { mapping: o, changed: n } = this.sv.columnService.getRangeData(s, this.sv.columnService.columns);
377
- s.newData = n, s.mapping = o;
378
- let r = this.sv.selectionChanged(s);
379
- if (r.defaultPrevented) {
380
- this.sv.setTempRange(null);
381
- return;
382
- }
383
- if (r = this.sv.rangeCopy(s), r.defaultPrevented) {
384
- this.sv.setRange(e);
385
- return;
386
- }
387
- this.onRangeApply(s.newData, e, i);
388
- }
389
- /**
390
- * Update range selection only,
391
- * no data change (mouse selection)
392
- */
393
- applyRangeOnly(e, i) {
394
- if (!e || !i)
395
- return;
396
- const s = m(e, i);
397
- this.sv.setRange(s);
398
- }
399
- }
400
- function ve(t, e) {
401
- var i;
402
- if (!pe(e))
403
- return null;
404
- const s = me(t);
405
- return s.length === 1 && ((i = s[0]) === null || i === void 0 ? void 0 : i.length) === 1 ? s : null;
406
- }
407
- function pe(t) {
408
- return typeof t == "object" && t.rangeFill === !0;
409
- }
410
- function me(t) {
411
- const e = [...t];
412
- for (; e.length > 1 && ye(e[e.length - 1]); )
413
- e.pop();
414
- return e;
415
- }
416
- function ye(t) {
417
- return !t || t.every((e) => e === "");
418
- }
419
- const Se = () => 'revogr-overlay-selection{display:block;position:relative;width:100%}revogr-overlay-selection .autofill-handle{position:absolute;width:14px;height:14px;margin-left:-13px;margin-top:-13px;z-index:10;cursor:crosshair}revogr-overlay-selection .autofill-handle::before{content:"";position:absolute;right:0;bottom:0;width:10px;height:10px;background:#0d63e8;border:1px solid white;box-sizing:border-box}revogr-overlay-selection.mobile .autofill-handle{position:absolute;width:30px;height:30px;margin-left:-29px;margin-top:-29px;z-index:10;cursor:crosshair}revogr-overlay-selection.mobile .autofill-handle::before{content:"";position:absolute;right:0;bottom:0;width:12px;height:12px;background:#0d63e8;border:1px solid white;box-sizing:border-box}revogr-overlay-selection .selection-border-range{position:absolute;pointer-events:none;z-index:9;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 .selection-border-range .range-handlers{height:100%;background-color:transparent;width:75%;max-width:50px;min-width:20px;left:50%;transform:translateX(-50%);position:absolute}revogr-overlay-selection .selection-border-range .range-handlers>span{pointer-events:auto;height:20px;width:20px;position:absolute;left:50%;transform:translateX(-50%)}revogr-overlay-selection .selection-border-range .range-handlers>span:before,revogr-overlay-selection .selection-border-range .range-handlers>span:after{position:absolute;border-radius:5px;width:15px;height:5px;left:50%;transform:translateX(-50%);background-color:rgba(0, 0, 0, 0.2)}revogr-overlay-selection .selection-border-range .range-handlers>span:first-child{top:-7px}revogr-overlay-selection .selection-border-range .range-handlers>span:first-child:before{content:"";top:0}revogr-overlay-selection .selection-border-range .range-handlers>span:last-child{bottom:-7px}revogr-overlay-selection .selection-border-range .range-handlers>span:last-child:after{content:"";bottom:0}revogr-overlay-selection revogr-edit{z-index:10}', be = class {
420
- constructor(t) {
421
- f(this, t), this.beforeCopyRegion = l(this, "beforecopyregion", 7), this.beforeRegionPaste = l(this, "beforepasteregion", 7), this.cellEditApply = l(this, "celleditapply", 7), this.beforeFocusCell = l(this, "beforecellfocusinit", 7), this.beforeNextViewportFocus = l(this, "beforenextvpfocus", 7), this.setEdit = l(this, "setedit", 7), this.beforeApplyRange = l(this, "beforeapplyrange", 7), this.beforeSetRange = l(this, "beforesetrange", 7), this.setRange = l(this, "setrange", 7), this.beforeEditRender = l(this, "beforeeditrender", 7), this.selectAll = l(this, "selectall", 7), this.cancelEdit = l(this, "canceledit", 7), this.setTempRange = l(this, "settemprange", 7), this.beforeSetTempRange = l(this, "beforesettemprange", 7), this.applyFocus = l(this, "applyfocus", 7), this.focusCell = l(this, "focuscell", 7), this.beforeRangeDataApply = l(this, "beforerangedataapply", 7), this.selectionChange = l(this, "selectionchangeinit", 7), this.beforeRangeCopyApply = l(this, "beforerangecopyapply", 7), this.rangeEditApply = l(this, "rangeeditapply", 7), this.rangeClipboardCopy = l(this, "clipboardrangecopy", 7), this.rangeClipboardPaste = l(this, "clipboardrangepaste", 7), this.beforeKeyDown = l(this, "beforekeydown", 7), this.beforeKeyUp = l(this, "beforekeyup", 7), this.beforeCellSave = l(this, "beforecellsave", 7), this.cellEditDone = l(this, "celledit", 7), this.applyChangesOnClose = !1, this.keyboardService = null, this.autoFillService = null, this.unsubscribeSelectionStore = [];
422
- }
423
- // #endregion
424
- // #region Listeners
425
- onMouseMove(t) {
426
- var e;
427
- this.selectionStore.get("focus") && ((e = this.autoFillService) === null || e === void 0 || e.selectionMouseMove(t));
428
- }
429
- /**
430
- * Action finished inside the document.
431
- * Pointer left document, clear any active operation.
432
- */
433
- onMouseUp() {
434
- var t;
435
- (t = this.autoFillService) === null || t === void 0 || t.clearAutoFillSelection(this.selectionStore.get("focus"), this.selectionStore.get("range"));
436
- }
437
- /**
438
- * Row drag started.
439
- * This event is fired when drag action started on cell.
440
- */
441
- onCellDrag(t) {
442
- var e;
443
- (e = this.orderEditor) === null || e === void 0 || e.dragStart(t.detail);
444
- }
445
- /**
446
- * Get keyboard down from element.
447
- * This event is fired when keyboard key is released.
448
- */
449
- onKeyUp(t) {
450
- this.beforeKeyUp.emit(Object.assign({ original: t }, this.getData()));
451
- }
452
- /**
453
- * Get keyboard down from element.
454
- * This event is fired when keyboard key is pressed.
455
- */
456
- onKeyDown(t) {
457
- var e;
458
- const i = this.beforeKeyDown.emit(Object.assign({ original: t }, this.getData()));
459
- t.defaultPrevented || i.defaultPrevented || (e = this.keyboardService) === null || e === void 0 || e.keyDown(t, this.range, !!this.selectionStore.get("edit"), {
460
- focus: this.selectionStore.get("focus"),
461
- range: this.selectionStore.get("range")
462
- });
463
- }
464
- // #endregion
465
- /**
466
- * Selection & Keyboard
467
- */
468
- selectionServiceSet(t) {
469
- this.unsubscribeSelectionStore.forEach((e) => e()), this.unsubscribeSelectionStore.length = 0, this.unsubscribeSelectionStore.push(t.onChange("nextFocus", (e) => e && this.doFocus(e, e))), this.keyboardService = new ge({
470
- selectionStore: t,
471
- range: (e) => !!e && this.triggerRangeEvent(e),
472
- focus: (e, i, s) => s ? (this.beforeNextViewportFocus.emit(e), !1) : this.doFocus(e, e, i),
473
- change: (e) => {
474
- this.readonly || this.doEdit(e);
475
- },
476
- cancel: async () => {
477
- var e;
478
- await ((e = this.revogrEdit) === null || e === void 0 ? void 0 : e.cancelChanges()), this.closeEdit();
479
- },
480
- clearCell: () => !this.readonly && this.clearCell(),
481
- internalPaste: () => !this.readonly && this.beforeRegionPaste.emit(),
482
- getData: () => this.getData(),
483
- selectAll: () => this.selectAll.emit()
484
- }), this.createAutoFillService();
485
- }
486
- /** Autofill */
487
- createAutoFillService() {
488
- this.autoFillService = new fe({
489
- dimensionRow: this.dimensionRow,
490
- dimensionCol: this.dimensionCol,
491
- columnService: this.columnService,
492
- dataStore: this.dataStore,
493
- clearRangeDataApply: (t) => this.beforeRangeDataApply.emit(Object.assign(Object.assign(Object.assign({}, t), this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) })),
494
- setTempRange: (t) => {
495
- const e = this.beforeSetTempRange.emit(Object.assign(Object.assign({ tempRange: t }, this.getData()), this.types));
496
- return e.defaultPrevented ? null : this.setTempRange.emit(e.detail.tempRange);
497
- },
498
- selectionChanged: (t) => this.selectionChange.emit(t),
499
- rangeCopy: (t) => this.beforeRangeCopyApply.emit(t),
500
- rangeDataApply: (t) => this.rangeEditApply.emit(t),
501
- setRange: (t) => !!t && this.triggerRangeEvent(t),
502
- getData: () => this.getData()
503
- });
504
- }
505
- /** Columns */
506
- columnServiceSet() {
507
- var t;
508
- (t = this.columnService) === null || t === void 0 || t.destroy(), this.columnService = new L(this.dataStore, this.colData), this.createAutoFillService();
509
- }
510
- connectedCallback() {
511
- this.columnServiceSet(), this.selectionServiceSet(this.selectionStore);
512
- }
513
- disconnectedCallback() {
514
- var t;
515
- this.unsubscribeSelectionStore.forEach((e) => e()), this.unsubscribeSelectionStore.length = 0, (t = this.columnService) === null || t === void 0 || t.destroy();
516
- }
517
- async componentWillRender() {
518
- var t, e;
519
- this.selectionStore.get("edit") || await ((e = (t = this.revogrEdit) === null || t === void 0 ? void 0 : t.beforeDisconnect) === null || e === void 0 ? void 0 : e.call(t));
520
- }
521
- renderRange(t) {
522
- const e = y(t, this.dimensionRow.state, this.dimensionCol.state), i = x(e);
523
- return [
524
- c("div", { class: H, style: i }, this.isMobileDevice && c("div", { class: "range-handlers" }, c("span", { class: p }), c("span", { class: p })))
525
- ];
526
- }
527
- renderEditor() {
528
- const t = this.selectionStore.get("edit");
529
- if (this.readonly || !t)
530
- return null;
531
- const e = t.val || T(this.columnService.rowDataModel(t.y, t.x).value), i = Object.assign(Object.assign({}, t), this.columnService.getSaveData(t.y, t.x, e)), s = this.beforeEditRender.emit(Object.assign(Object.assign({ range: Object.assign(Object.assign({}, t), { x1: t.x, y1: t.y }) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) }));
532
- if (s.defaultPrevented)
533
- return null;
534
- const o = y(s.detail.range, s.detail.rowDimension, s.detail.colDimension), n = x(o);
535
- return c("revogr-edit", { style: n, ref: (r) => this.revogrEdit = r, additionalData: this.additionalData, editCell: i, saveOnClose: this.applyChangesOnClose, onCelleditinit: (r) => {
536
- this.cellEditDone.emit(r.detail);
537
- }, column: this.columnService.rowDataModel(t.y, t.x), editor: W(this.columnService.columns[t.x], this.editors) });
538
- }
539
- onEditCell(t) {
540
- if (t.defaultPrevented)
541
- return;
542
- const e = this.beforeCellSave.emit(t.detail);
543
- e.defaultPrevented || this.cellEdit(e.detail), e.detail.preventFocus || this.focusNext();
544
- }
545
- render() {
546
- var t;
547
- const e = [], i = this.renderEditor();
548
- if (i)
549
- e.push(i);
550
- else {
551
- const s = this.selectionStore.get("range"), o = this.selectionStore.get("focus");
552
- (s || o) && this.useClipboard && e.push(c("revogr-clipboard", { readonly: this.readonly, onCopyregion: (n) => this.onCopy(n.detail), onClearregion: () => !this.readonly && this.clearCell(), ref: (n) => this.clipboard = n, onPasteregion: (n) => this.onPaste(n.detail) })), s && e.push(...this.renderRange(s)), o && !this.readonly && this.range && e.push((t = this.autoFillService) === null || t === void 0 ? void 0 : t.renderAutofill(s, o, this.isMobileDevice)), this.canDrag && e.push(c("revogr-order-editor", { ref: (n) => this.orderEditor = n, dataStore: this.dataStore, dimensionRow: this.dimensionRow, dimensionCol: this.dimensionCol, parent: this.element, rowType: this.types.rowType, onRowdragstartinit: (n) => this.rowDragStart(n) }));
553
- }
554
- return c(S, {
555
- key: "ff303c39d59e4ef217421fa11b9a80de07311b07",
556
- class: { mobile: this.isMobileDevice },
557
- onDblClick: (s) => this.onElementDblClick(s),
558
- onMouseDown: (s) => this.onElementMouseDown(s),
559
- onTouchStart: (s) => this.onElementMouseDown(s, !0),
560
- onCloseedit: (s) => this.closeEdit(s),
561
- // it's done to be able to throw events from different levels, not just from editor
562
- onCelledit: (s) => this.onEditCell(s)
563
- }, e, c("slot", { key: "3cbe4c3ad7d447f779e9e20f73eec2e3107275e0", name: "data" }));
564
- }
565
- /**
566
- * Executes the focus operation on the specified range of cells.
567
- */
568
- doFocus(t, e, i, s) {
569
- const { defaultPrevented: o } = this.beforeFocusCell.emit(Object.assign(Object.assign({}, this.columnService.getSaveData(t.y, t.x)), { originalEvent: s }));
570
- if (o)
571
- return !1;
572
- const n = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, t), { x1: e.x, y1: e.y }), next: i }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent: s }), r = this.applyFocus.emit(n);
573
- if (r.defaultPrevented)
574
- return !1;
575
- const { range: a } = r.detail;
576
- return !this.focusCell.emit(Object.assign({ focus: {
577
- x: a.x,
578
- y: a.y
579
- }, end: {
580
- x: a.x1,
581
- y: a.y1
582
- } }, r.detail)).defaultPrevented;
583
- }
584
- triggerRangeEvent(t, e) {
585
- const i = this.types.rowType, s = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, t) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent: e }));
586
- if (s.defaultPrevented)
587
- return !1;
588
- const o = this.columnService.getRangeTransformedToProps(s.detail.range, this.dataStore);
589
- let n = this.beforeSetRange.emit(o);
590
- return n.defaultPrevented || (n = this.setRange.emit(Object.assign(Object.assign({}, s.detail.range), { type: i })), n.defaultPrevented) ? !1 : !n.defaultPrevented;
591
- }
592
- /**
593
- * Open Editor on DblClick
594
- */
595
- onElementDblClick(t) {
596
- if (t.defaultPrevented)
597
- return;
598
- const e = this.getData();
599
- k(t, e) && this.doEdit();
600
- }
601
- /**
602
- * Handle mouse down event on Host element
603
- */
604
- onElementMouseDown(t, e = !1) {
605
- var i;
606
- const s = t.target;
607
- if (z(s) || t.defaultPrevented)
608
- return;
609
- const o = this.getData(), n = k(t, o);
610
- n && (this.focus(n, this.range && t.shiftKey, t), this.range && (s && ((i = this.autoFillService) === null || i === void 0 || i.selectionStart(s, this.getData())), e ? Z(t.touches[0], p) && t.preventDefault() : t.preventDefault()));
611
- }
612
- /**
613
- * Start cell editing
614
- */
615
- doEdit(t = "") {
616
- var e;
617
- if (this.canEdit()) {
618
- const i = this.selectionStore.get("focus");
619
- if (!i)
620
- return;
621
- const s = this.columnService.getSaveData(i.y, i.x);
622
- (e = this.setEdit) === null || e === void 0 || e.emit(Object.assign(Object.assign({}, s), { val: t }));
623
- }
624
- }
625
- /**
626
- * Close editor event triggered
627
- * @param details - if it requires focus next
628
- */
629
- async closeEdit(t) {
630
- this.cancelEdit.emit(), t != null && t.detail && await this.focusNext();
631
- }
632
- /**
633
- * Edit finished.
634
- * Close Editor and save.
635
- */
636
- cellEdit(t) {
637
- const e = this.columnService.getSaveData(t.rgRow, t.rgCol, t.val);
638
- this.cellEditApply.emit(e);
639
- }
640
- getRegion() {
641
- const t = this.selectionStore.get("focus");
642
- let e = this.selectionStore.get("range");
643
- return e || (e = m(t, t)), e;
644
- }
645
- onCopy(t) {
646
- var e;
647
- const i = this.getRegion();
648
- if (this.beforeCopyRegion.emit(i).defaultPrevented)
649
- return !1;
650
- let o;
651
- if (i) {
652
- const { data: n, mapping: r } = this.columnService.copyRangeArray(i, this.dataStore), a = this.rangeClipboardCopy.emit(Object.assign({
653
- range: i,
654
- data: n,
655
- mapping: r
656
- }, this.types));
657
- a.defaultPrevented || (o = a.detail.data);
658
- }
659
- return (e = this.clipboard) === null || e === void 0 || e.doCopy(t, o), !0;
660
- }
661
- onPaste(t) {
662
- var e;
663
- const i = this.selectionStore.get("focus"), s = this.selectionStore.get("edit") !== null;
664
- if (!i || s)
665
- return;
666
- const o = ve(t, this.useClipboard), n = o ? this.getClipboardPasteTargetRange() : null;
667
- let { changed: r, range: a } = this.columnService.getTransformedDataToApply({
668
- start: i,
669
- data: o || t,
670
- targetRange: n
671
- });
672
- const { defaultPrevented: h } = this.rangeClipboardPaste.emit(Object.assign({ data: r, models: M(r, this.dataStore), range: a }, this.types));
673
- h || (e = this.autoFillService) === null || e === void 0 || e.onRangeApply(r, a, a);
674
- }
675
- getClipboardPasteTargetRange() {
676
- const t = this.selectionStore.get("range");
677
- return t && !A(t) ? t : null;
678
- }
679
- async focusNext() {
680
- var t;
681
- await ((t = this.keyboardService) === null || t === void 0 ? void 0 : t.keyChangeSelection(new KeyboardEvent("keydown", {
682
- code: u.ARROW_DOWN
683
- }), this.range)) || this.closeEdit();
684
- }
685
- clearCell() {
686
- var t;
687
- const e = this.selectionStore.get("range");
688
- if (e && !A(e)) {
689
- const i = this.columnService.getRangeStaticData(e, "");
690
- (t = this.autoFillService) === null || t === void 0 || t.onRangeApply(i, e, e);
691
- } else if (this.canEdit()) {
692
- const i = this.selectionStore.get("focus");
693
- if (!i)
694
- return;
695
- const s = this.columnService.getSaveData(i.y, i.x);
696
- this.cellEdit({
697
- rgRow: i.y,
698
- rgCol: i.x,
699
- val: "",
700
- type: s.type,
701
- prop: s.prop
702
- });
703
- }
704
- }
705
- rowDragStart({ detail: t }) {
706
- t.text = T(this.columnService.rowDataModel(t.cell.y, t.cell.x).value);
707
- }
708
- /**
709
- * Verify if edit allowed.
710
- */
711
- canEdit() {
712
- var t;
713
- if (this.readonly)
714
- return !1;
715
- const e = this.selectionStore.get("focus");
716
- return e && !(!((t = this.columnService) === null || t === void 0) && t.isReadOnly(e.y, e.x));
717
- }
718
- get edited() {
719
- return this.selectionStore.get("edit");
720
- }
721
- /**
722
- * Sets the focus on a cell and optionally edits a range.
723
- */
724
- focus(t, e = !1, i) {
725
- if (!t)
726
- return !1;
727
- const s = t, o = this.selectionStore.get("focus");
728
- if (e && o) {
729
- const n = m(o, s);
730
- if (n)
731
- return this.triggerRangeEvent(n, i);
732
- }
733
- return this.doFocus(t, s, void 0, i);
734
- }
735
- get types() {
736
- return {
737
- rowType: this.dataStore.get("type"),
738
- colType: this.columnService.type
739
- };
740
- }
741
- /**
742
- * Collect data
743
- */
744
- getData() {
745
- return {
746
- el: this.element,
747
- rows: this.dimensionRow.state,
748
- cols: this.dimensionCol.state,
749
- lastCell: this.lastCell,
750
- focus: this.selectionStore.get("focus"),
751
- range: this.selectionStore.get("range"),
752
- edit: this.selectionStore.get("edit")
753
- };
754
- }
755
- get element() {
756
- return E(this);
757
- }
758
- static get watchers() {
759
- return {
760
- selectionStore: [{
761
- selectionServiceSet: 0
762
- }],
763
- dimensionRow: [{
764
- createAutoFillService: 0
765
- }],
766
- dimensionCol: [{
767
- createAutoFillService: 0
768
- }],
769
- dataStore: [{
770
- columnServiceSet: 0
771
- }],
772
- colData: [{
773
- columnServiceSet: 0
774
- }]
775
- };
776
- }
777
- };
778
- be.style = Se();
779
- const Ce = (t) => (e, { rowIndex: i }) => t + i, Ie = class {
780
- constructor(t) {
781
- f(this, t), this.scrollViewport = l(this, "scrollview", 3), this.elementToScroll = l(this, "ref", 3), this.jobsBeforeRender = [];
782
- }
783
- render() {
784
- const t = [], e = new B("colPinStart");
785
- let i = 1;
786
- for (let r of this.dataPorts) {
787
- const a = r.dataStore.get("items").length, h = new P(r.type, Object.assign({}, r.dataStore.state)), d = new P("colPinStart"), g = Object.assign({ cellTemplate: Ce(i) }, this.rowHeaderColumn);
788
- d.updateData([g]), t.push(c("revogr-data", Object.assign({}, r, { colType: "rowHeaders", jobsBeforeRender: this.jobsBeforeRender, rowClass: this.rowClass, dataStore: h.store, colData: d.store, viewportCol: e.store, readonly: !0, range: !1 }))), i += a;
789
- }
790
- const s = V(i, this.rowHeaderColumn);
791
- e.setViewport({
792
- realCount: 1,
793
- virtualSize: 0,
794
- items: [
795
- {
796
- size: s,
797
- start: 0,
798
- end: s,
799
- itemIndex: 0
800
- }
801
- ]
802
- });
803
- const o = {
804
- contentHeight: this.height,
805
- contentWidth: 0,
806
- style: { minWidth: `${s}px` },
807
- colType: "rowHeaders",
808
- ref: (r) => this.elementToScroll.emit(r),
809
- onScrollviewport: (r) => this.scrollViewport.emit(r.detail)
810
- }, n = Object.assign(Object.assign({}, this.headerProp), {
811
- // groups not present on row headers
812
- groups: [],
813
- colData: typeof this.rowHeaderColumn == "object" ? [this.rowHeaderColumn] : [],
814
- viewportCol: e.store,
815
- canResize: !1,
816
- type: D,
817
- // parent,
818
- slot: oe
819
- });
820
- return c(S, { class: { [D]: !0 }, key: D }, c("revogr-viewport-scroll", Object.assign({ key: "c401e82e02e4bdb7afb25f2f49c6776f2e115c81" }, o, { "row-header": !0 }), c("revogr-header", Object.assign({ key: "3c73d27bd96e23a34fc0cf47eda4d2e65751df98" }, n)), t));
821
- }
822
- };
823
- class we {
824
- constructor(e) {
825
- this.element = e, this.autohideScrollTimeout = 0;
826
- }
827
- /**
828
- * When scroll size updates set it up for autohide
829
- */
830
- setScrollSize(e) {
831
- e ? this.element.removeAttribute("autohide") : this.element.setAttribute("autohide", "true");
832
- }
833
- /**
834
- * On each scroll check if it's time to show
835
- */
836
- checkScroll({ scrollSize: e, contentSize: i, virtualSize: s }) {
837
- const o = i > s;
838
- !e && o && (this.element.setAttribute("visible", "true"), this.autohideScrollTimeout = this.show(this.element, this.autohideScrollTimeout));
839
- }
840
- show(e, i) {
841
- return clearTimeout(i), Number(setTimeout(() => {
842
- e == null || e.removeAttribute("visible");
843
- }, 1e3));
844
- }
845
- clear() {
846
- clearTimeout(this.autohideScrollTimeout);
847
- }
848
- }
849
- const xe = () => "revogr-scroll-virtual[autohide]{position:absolute;z-index:100 !important}revogr-scroll-virtual[autohide].vertical{top:0;right:0}revogr-scroll-virtual[autohide].vertical[visible]{min-width:20px !important}revogr-scroll-virtual[autohide].horizontal{bottom:0;left:0}revogr-scroll-virtual[autohide].horizontal[visible]{min-height:20px !important}revogr-scroll-virtual.vertical{overflow-y:auto;overflow-x:hidden;height:100%}revogr-scroll-virtual.vertical>div{width:1px}revogr-scroll-virtual.horizontal{overflow-x:auto;overflow-y:hidden;width:100%}revogr-scroll-virtual.horizontal>div{height:1px}", Re = class {
850
- constructor(t) {
851
- f(this, t), this.scrollVirtual = l(this, "scrollvirtual", 7), this.dimension = "rgRow", this.scrollSize = 0;
852
- }
853
- async setScroll(t) {
854
- var e;
855
- this.dimension === t.dimension && (this.localScrollTimer.latestScrollUpdate(t.dimension), (e = this.localScrollService) === null || e === void 0 || e.setScroll(t), t.coordinate && this.autohideScrollPlugin.checkScroll({
856
- scrollSize: this.scrollSize,
857
- contentSize: this.realSize,
858
- virtualSize: this.virtualSize
859
- }));
860
- }
861
- /**
862
- * Update if `delta` exists in case we don't know current position or if it's external change
863
- */
864
- async changeScroll(t) {
865
- if (t.delta) {
866
- const e = t.dimension === "rgRow" ? "scrollTop" : "scrollLeft", i = this.element[e];
867
- return this.localScrollService.setScrollByDelta(t, i);
868
- }
869
- return t;
870
- }
871
- connectedCallback() {
872
- this.autohideScrollPlugin = new we(this.element), this.localScrollTimer = new ne("ontouchstart" in document.documentElement ? 0 : 10), this.localScrollService = new re({
873
- runScroll: (t) => this.scrollVirtual.emit(t),
874
- applyScroll: (t) => {
875
- this.localScrollTimer.setCoordinate(t);
876
- const e = t.dimension === "rgRow" ? "scrollTop" : "scrollLeft";
877
- this.element[e] = t.coordinate;
878
- }
879
- });
880
- }
881
- disconnectedCallback() {
882
- this.autohideScrollPlugin.clear();
883
- }
884
- componentWillLoad() {
885
- this.scrollSize = N(document);
886
- }
887
- componentDidRender() {
888
- let t = 0;
889
- this.dimension === "rgRow" ? (t = this.element.scrollHeight > this.element.clientHeight ? this.scrollSize : 0, this.element.style.minWidth = `${t}px`) : (t = this.element.scrollWidth > this.element.clientWidth ? this.scrollSize : 0, this.element.style.minHeight = `${t}px`), this.autohideScrollPlugin.setScrollSize(t), this.localScrollService.setParams({
890
- contentSize: this.realSize,
891
- clientSize: this.dimension === "rgRow" ? this.element.clientHeight : this.element.clientWidth,
892
- virtualSize: this.clientSize
893
- }, this.dimension);
894
- }
895
- onScroll(t) {
896
- if (!(t.target instanceof Element))
897
- return;
898
- const e = t.target;
899
- let i = "scrollLeft";
900
- this.dimension === "rgRow" && (i = "scrollTop");
901
- const s = () => {
902
- var o;
903
- (o = this.localScrollService) === null || o === void 0 || o.scroll(e[i] || 0, this.dimension);
904
- };
905
- this.localScrollTimer.isReady(this.dimension, e[i]) ? s() : this.localScrollTimer.throttleLastScrollUpdate(this.dimension, e[i] || 0, () => s());
906
- }
907
- render() {
908
- const t = le(this.realSize, this.dimension === "rgRow" ? this.element.clientHeight : this.element.clientWidth, this.clientSize);
909
- return c(S, { key: "7213817ef941eee4050b714266598ec0c2961ee9", onScroll: (e) => this.onScroll(e) }, c("div", { key: "501da49c63253ab943172494b9dbf5399be56cee", style: {
910
- [this.dimension === "rgRow" ? "height" : "width"]: `${t}px`
911
- } }));
912
- }
913
- get element() {
914
- return E(this);
915
- }
916
- };
917
- Re.style = xe();
918
- const De = () => ".temp-bg-range{display:block !important;position:absolute;pointer-events:none;z-index:9;border:1px solid rgb(255, 94, 0);box-sizing:border-box}.temp-bg-range.Selection{border:1px dashed gray}.temp-bg-range>div{width:1px;height:1px;position:absolute}.temp-bg-range>div.top{top:-1px}.temp-bg-range>div.bottom{bottom:-1px}.temp-bg-range>div.left{left:-1px}.temp-bg-range>div.right{right:-1px}", Oe = class {
919
- constructor(t) {
920
- f(this, t), this.onChange = ae((e) => this.doChange(e), 300);
921
- }
922
- doChange(t) {
923
- t == null || t.scrollIntoView({
924
- block: "nearest",
925
- inline: "nearest"
926
- });
927
- }
928
- componentDidRender() {
929
- this.el && this.onChange(this.el);
930
- }
931
- render() {
932
- const t = this.selectionStore.get("tempRange"), e = this.selectionStore.get("tempRangeType");
933
- if (!t)
934
- return;
935
- let i = "bottom", s = "right";
936
- const o = this.getRange();
937
- if (!o)
938
- return;
939
- t.y < o.y && (i = "top"), t.x < o.x && (s = "left");
940
- const n = `${s} ${i}`, r = y(t, this.dimensionRow.state, this.dimensionCol.state), a = x(r), h = {
941
- class: {
942
- [Y]: !0,
943
- [e || ""]: !0
944
- },
945
- style: a,
946
- hidden: !1
947
- };
948
- return c(S, Object.assign({}, h), c("div", { class: n, ref: (d) => this.el = d }));
949
- }
950
- getRange() {
951
- const t = this.selectionStore.get("range");
952
- if (t)
953
- return t;
954
- const e = this.selectionStore.get("focus");
955
- return e ? Object.assign(Object.assign({}, e), { x1: e.x, y1: e.y }) : null;
956
- }
957
- };
958
- Oe.style = De();
959
- export {
960
- _e as revogr_attribution,
961
- je as revogr_extra,
962
- de as revogr_focus,
963
- be as revogr_overlay_selection,
964
- Ie as revogr_row_headers,
965
- Re as revogr_scroll_virtual,
966
- Oe as revogr_temp_range
967
- };