@revolist/revogrid 4.27.10 → 4.28.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.
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/revo-grid.cjs.js +1 -1
- package/dist/cjs/revogr-attribution_7.cjs.entry.js +59 -10
- package/dist/cjs/revogr-clipboard_3.cjs.entry.js +7 -1
- package/dist/cjs/{text-editor-CJyQaYei.js → text-editor-COQdD50G.js} +8 -0
- package/dist/collection/components/editors/revogr-edit.js +15 -0
- package/dist/collection/components/editors/text-editor.js +8 -0
- package/dist/collection/components/overlay/keyboard.service.js +48 -8
- package/dist/collection/components/overlay/revogr-overlay-selection.js +11 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/revo-grid.js +1 -1
- package/dist/esm/revogr-attribution_7.entry.js +59 -10
- package/dist/esm/revogr-clipboard_3.entry.js +7 -1
- package/dist/esm/{text-editor-eHtrwvxH.js → text-editor-BVb0idxe.js} +8 -0
- package/dist/revo-grid/index.esm.js +1 -1
- package/dist/revo-grid/revo-grid.esm.js +1 -1
- package/dist/revo-grid/revogr-attribution_7.entry.js +59 -10
- package/dist/revo-grid/revogr-clipboard_3.entry.js +7 -1
- package/dist/revo-grid/{text-editor-eHtrwvxH.js → text-editor-BVb0idxe.js} +8 -0
- package/dist/types/components/editors/revogr-edit.d.ts +1 -0
- package/dist/types/components/editors/text-editor.d.ts +1 -0
- package/dist/types/components/overlay/keyboard.service.d.ts +12 -4
- package/dist/types/types/selection.d.ts +5 -0
- package/hydrate/index.js +74 -11
- package/hydrate/index.mjs +74 -11
- package/package.json +1 -1
- package/standalone/revogr-edit2.js +1 -1
- package/standalone/revogr-overlay-selection2.js +1 -1
package/hydrate/index.js
CHANGED
|
@@ -13833,13 +13833,13 @@ function isEditorCtrConstructible(editor) {
|
|
|
13833
13833
|
return typeof editor === 'function' && typeof editor.prototype === 'object';
|
|
13834
13834
|
}
|
|
13835
13835
|
|
|
13836
|
-
const
|
|
13837
|
-
codesLetter.TAB,
|
|
13836
|
+
const ARROW_CODES = [
|
|
13838
13837
|
codesLetter.ARROW_UP,
|
|
13839
13838
|
codesLetter.ARROW_DOWN,
|
|
13840
13839
|
codesLetter.ARROW_LEFT,
|
|
13841
13840
|
codesLetter.ARROW_RIGHT,
|
|
13842
13841
|
];
|
|
13842
|
+
const DIRECTION_CODES = new Set([codesLetter.TAB, ...ARROW_CODES]);
|
|
13843
13843
|
class KeyboardService {
|
|
13844
13844
|
constructor(sv) {
|
|
13845
13845
|
this.sv = sv;
|
|
@@ -13857,6 +13857,10 @@ class KeyboardService {
|
|
|
13857
13857
|
/**
|
|
13858
13858
|
* Appends printable key input that arrives after edit mode was requested
|
|
13859
13859
|
* but before the editor input has mounted or received focus.
|
|
13860
|
+
*
|
|
13861
|
+
* Once the input is rendered the key goes straight into it: a store update
|
|
13862
|
+
* would only reach the input on the next render, and that render would
|
|
13863
|
+
* overwrite whatever was typed natively into the input in the meantime.
|
|
13860
13864
|
*/
|
|
13861
13865
|
appendPendingEditValue(e) {
|
|
13862
13866
|
if (isShortcutModifier(e) ||
|
|
@@ -13869,6 +13873,9 @@ class KeyboardService {
|
|
|
13869
13873
|
return false;
|
|
13870
13874
|
}
|
|
13871
13875
|
e.preventDefault();
|
|
13876
|
+
if (this.sv.appendEditValue(e.key)) {
|
|
13877
|
+
return true;
|
|
13878
|
+
}
|
|
13872
13879
|
this.sv.selectionStore.set('edit', Object.assign(Object.assign({}, editCell), { val: `${editCell.val}${e.key}` }));
|
|
13873
13880
|
return true;
|
|
13874
13881
|
}
|
|
@@ -13969,7 +13976,9 @@ class KeyboardService {
|
|
|
13969
13976
|
this.applyingKeyChange = true;
|
|
13970
13977
|
let changed;
|
|
13971
13978
|
try {
|
|
13972
|
-
changed =
|
|
13979
|
+
changed = data.edge
|
|
13980
|
+
? this.keyEdgeChange(data.changes, range, focus, !!data.isMulti)
|
|
13981
|
+
: this.keyPositionChange(data.changes, range, focus, data.isMulti);
|
|
13973
13982
|
}
|
|
13974
13983
|
finally {
|
|
13975
13984
|
this.applyingKeyChange = false;
|
|
@@ -14006,10 +14015,33 @@ class KeyboardService {
|
|
|
14006
14015
|
? -1
|
|
14007
14016
|
: 0);
|
|
14008
14017
|
}
|
|
14018
|
+
keyEdgeChange(changes, range, focus, isMulti) {
|
|
14019
|
+
if (!range || !focus) {
|
|
14020
|
+
return false;
|
|
14021
|
+
}
|
|
14022
|
+
const { lastCell } = this.sv.getData();
|
|
14023
|
+
const coordinate = changes.x ? 'x' : 'y';
|
|
14024
|
+
const direction = changes[coordinate];
|
|
14025
|
+
const target = direction > 0 ? lastCell[coordinate] - 1 : 0;
|
|
14026
|
+
if (isMulti) {
|
|
14027
|
+
const edgeCoordinate = coordinate === 'x' ? 'x1' : 'y1';
|
|
14028
|
+
return this.sv.range(Object.assign(Object.assign({}, range), { [coordinate]: direction < 0 ? target : focus[coordinate], [edgeCoordinate]: direction > 0 ? target : focus[coordinate] }));
|
|
14029
|
+
}
|
|
14030
|
+
const edgeFocus = Object.assign(Object.assign({}, focus), { [coordinate]: target });
|
|
14031
|
+
return this.sv.focus(edgeFocus, {
|
|
14032
|
+
[coordinate]: target - focus[coordinate],
|
|
14033
|
+
});
|
|
14034
|
+
}
|
|
14009
14035
|
/** Monitor key direction changes */
|
|
14010
14036
|
changeDirectionKey(e, canRange) {
|
|
14011
14037
|
const isMulti = canRange && e.shiftKey;
|
|
14012
|
-
|
|
14038
|
+
const hasPrimaryModifier = e.ctrlKey || e.metaKey;
|
|
14039
|
+
const isArrow = ARROW_CODES.includes(e.code);
|
|
14040
|
+
const isEdgeShortcut = hasPrimaryModifier && !e.altKey && isArrow;
|
|
14041
|
+
if (hasPrimaryModifier && !isEdgeShortcut) {
|
|
14042
|
+
return;
|
|
14043
|
+
}
|
|
14044
|
+
if (DIRECTION_CODES.has(e.code)) {
|
|
14013
14045
|
e.preventDefault();
|
|
14014
14046
|
}
|
|
14015
14047
|
if (e.shiftKey) {
|
|
@@ -14018,17 +14050,25 @@ class KeyboardService {
|
|
|
14018
14050
|
return { changes: { x: -1 }, isMulti: false };
|
|
14019
14051
|
}
|
|
14020
14052
|
}
|
|
14053
|
+
let changes;
|
|
14021
14054
|
switch (e.code) {
|
|
14022
14055
|
case codesLetter.ARROW_UP:
|
|
14023
|
-
|
|
14056
|
+
changes = { y: -1 };
|
|
14057
|
+
break;
|
|
14024
14058
|
case codesLetter.ARROW_DOWN:
|
|
14025
|
-
|
|
14059
|
+
changes = { y: 1 };
|
|
14060
|
+
break;
|
|
14026
14061
|
case codesLetter.ARROW_LEFT:
|
|
14027
|
-
|
|
14062
|
+
changes = { x: -1 };
|
|
14063
|
+
break;
|
|
14028
14064
|
case codesLetter.TAB:
|
|
14029
14065
|
case codesLetter.ARROW_RIGHT:
|
|
14030
|
-
|
|
14066
|
+
changes = { x: 1 };
|
|
14067
|
+
break;
|
|
14068
|
+
default:
|
|
14069
|
+
return;
|
|
14031
14070
|
}
|
|
14071
|
+
return Object.assign({ changes, isMulti }, (isEdgeShortcut && { edge: true }));
|
|
14032
14072
|
}
|
|
14033
14073
|
}
|
|
14034
14074
|
|
|
@@ -14392,6 +14432,15 @@ class OverlaySelection {
|
|
|
14392
14432
|
await ((_a = this.revogrEdit) === null || _a === void 0 ? void 0 : _a.cancelChanges());
|
|
14393
14433
|
this.closeEdit();
|
|
14394
14434
|
},
|
|
14435
|
+
appendEditValue: value => {
|
|
14436
|
+
if (!this.revogrEdit) {
|
|
14437
|
+
return false;
|
|
14438
|
+
}
|
|
14439
|
+
return !this.revogrEdit.dispatchEvent(new CustomEvent('internalappendeditvalue', {
|
|
14440
|
+
cancelable: true,
|
|
14441
|
+
detail: value,
|
|
14442
|
+
}));
|
|
14443
|
+
},
|
|
14395
14444
|
clearCell: () => !this.readonly && this.clearCell(),
|
|
14396
14445
|
internalPaste: () => !this.readonly && this.beforeRegionPaste.emit(),
|
|
14397
14446
|
getData: () => this.getData(),
|
|
@@ -14515,9 +14564,9 @@ class OverlaySelection {
|
|
|
14515
14564
|
nodes.push(hAsync("revogr-order-editor", { ref: e => (this.orderEditor = e), dataStore: this.dataStore, dimensionRow: this.dimensionRow, dimensionCol: this.dimensionCol, parent: this.element, rowType: this.types.rowType, onRowdragstartinit: e => this.rowDragStart(e) }));
|
|
14516
14565
|
}
|
|
14517
14566
|
}
|
|
14518
|
-
return (hAsync(Host, { key: '
|
|
14567
|
+
return (hAsync(Host, { key: '84d904c108e39ebf82b215afc7052d634eba677e', class: { mobile: this.isMobileDevice }, onDblClick: (e) => this.onElementDblClick(e), onMouseDown: (e) => this.onElementMouseDown(e), onTouchStart: (e) => this.onElementMouseDown(e, true), onCloseedit: (e) => this.closeEdit(e),
|
|
14519
14568
|
// it's done to be able to throw events from different levels, not just from editor
|
|
14520
|
-
onCelledit: (e) => this.onEditCell(e) }, nodes, hAsync("slot", { key: '
|
|
14569
|
+
onCelledit: (e) => this.onEditCell(e) }, nodes, hAsync("slot", { key: '7434c5fceb445de4510675b7627bb5f2efc1a365', name: "data" })));
|
|
14521
14570
|
}
|
|
14522
14571
|
/**
|
|
14523
14572
|
* Executes the focus operation on the specified range of cells.
|
|
@@ -14848,6 +14897,14 @@ class TextEditor {
|
|
|
14848
14897
|
(_a = this.editInput) === null || _a === void 0 ? void 0 : _a.focus();
|
|
14849
14898
|
}
|
|
14850
14899
|
}
|
|
14900
|
+
appendPendingInput(value) {
|
|
14901
|
+
if (!this.editInput) {
|
|
14902
|
+
return false;
|
|
14903
|
+
}
|
|
14904
|
+
this.editInput.value += value;
|
|
14905
|
+
this.editInput.focus();
|
|
14906
|
+
return true;
|
|
14907
|
+
}
|
|
14851
14908
|
onKeyDown(e) {
|
|
14852
14909
|
const isEnter = isEnterKeyValue(e.key);
|
|
14853
14910
|
const isKeyTab = isTab(e.key);
|
|
@@ -14932,6 +14989,12 @@ class RevoEdit {
|
|
|
14932
14989
|
var _a, _b;
|
|
14933
14990
|
(_b = (_a = this.currentEditor) === null || _a === void 0 ? void 0 : _a.beforeDisconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
14934
14991
|
}
|
|
14992
|
+
onInternalAppendEditValue(e) {
|
|
14993
|
+
var _a, _b;
|
|
14994
|
+
if ((_b = (_a = this.currentEditor) === null || _a === void 0 ? void 0 : _a.appendPendingInput) === null || _b === void 0 ? void 0 : _b.call(_a, e.detail)) {
|
|
14995
|
+
e.preventDefault();
|
|
14996
|
+
}
|
|
14997
|
+
}
|
|
14935
14998
|
onAutoSave() {
|
|
14936
14999
|
var _a, _b, _c;
|
|
14937
15000
|
this.preventSaveOnClose = true;
|
|
@@ -15051,7 +15114,7 @@ class RevoEdit {
|
|
|
15051
15114
|
"cancelChanges": [64],
|
|
15052
15115
|
"beforeDisconnect": [64]
|
|
15053
15116
|
},
|
|
15054
|
-
"$listeners$":
|
|
15117
|
+
"$listeners$": [[0, "internalappendeditvalue", "onInternalAppendEditValue"]],
|
|
15055
15118
|
"$lazyBundleId$": "-",
|
|
15056
15119
|
"$attrsToReflect$": []
|
|
15057
15120
|
}; }
|
package/hydrate/index.mjs
CHANGED
|
@@ -13831,13 +13831,13 @@ function isEditorCtrConstructible(editor) {
|
|
|
13831
13831
|
return typeof editor === 'function' && typeof editor.prototype === 'object';
|
|
13832
13832
|
}
|
|
13833
13833
|
|
|
13834
|
-
const
|
|
13835
|
-
codesLetter.TAB,
|
|
13834
|
+
const ARROW_CODES = [
|
|
13836
13835
|
codesLetter.ARROW_UP,
|
|
13837
13836
|
codesLetter.ARROW_DOWN,
|
|
13838
13837
|
codesLetter.ARROW_LEFT,
|
|
13839
13838
|
codesLetter.ARROW_RIGHT,
|
|
13840
13839
|
];
|
|
13840
|
+
const DIRECTION_CODES = new Set([codesLetter.TAB, ...ARROW_CODES]);
|
|
13841
13841
|
class KeyboardService {
|
|
13842
13842
|
constructor(sv) {
|
|
13843
13843
|
this.sv = sv;
|
|
@@ -13855,6 +13855,10 @@ class KeyboardService {
|
|
|
13855
13855
|
/**
|
|
13856
13856
|
* Appends printable key input that arrives after edit mode was requested
|
|
13857
13857
|
* but before the editor input has mounted or received focus.
|
|
13858
|
+
*
|
|
13859
|
+
* Once the input is rendered the key goes straight into it: a store update
|
|
13860
|
+
* would only reach the input on the next render, and that render would
|
|
13861
|
+
* overwrite whatever was typed natively into the input in the meantime.
|
|
13858
13862
|
*/
|
|
13859
13863
|
appendPendingEditValue(e) {
|
|
13860
13864
|
if (isShortcutModifier(e) ||
|
|
@@ -13867,6 +13871,9 @@ class KeyboardService {
|
|
|
13867
13871
|
return false;
|
|
13868
13872
|
}
|
|
13869
13873
|
e.preventDefault();
|
|
13874
|
+
if (this.sv.appendEditValue(e.key)) {
|
|
13875
|
+
return true;
|
|
13876
|
+
}
|
|
13870
13877
|
this.sv.selectionStore.set('edit', Object.assign(Object.assign({}, editCell), { val: `${editCell.val}${e.key}` }));
|
|
13871
13878
|
return true;
|
|
13872
13879
|
}
|
|
@@ -13967,7 +13974,9 @@ class KeyboardService {
|
|
|
13967
13974
|
this.applyingKeyChange = true;
|
|
13968
13975
|
let changed;
|
|
13969
13976
|
try {
|
|
13970
|
-
changed =
|
|
13977
|
+
changed = data.edge
|
|
13978
|
+
? this.keyEdgeChange(data.changes, range, focus, !!data.isMulti)
|
|
13979
|
+
: this.keyPositionChange(data.changes, range, focus, data.isMulti);
|
|
13971
13980
|
}
|
|
13972
13981
|
finally {
|
|
13973
13982
|
this.applyingKeyChange = false;
|
|
@@ -14004,10 +14013,33 @@ class KeyboardService {
|
|
|
14004
14013
|
? -1
|
|
14005
14014
|
: 0);
|
|
14006
14015
|
}
|
|
14016
|
+
keyEdgeChange(changes, range, focus, isMulti) {
|
|
14017
|
+
if (!range || !focus) {
|
|
14018
|
+
return false;
|
|
14019
|
+
}
|
|
14020
|
+
const { lastCell } = this.sv.getData();
|
|
14021
|
+
const coordinate = changes.x ? 'x' : 'y';
|
|
14022
|
+
const direction = changes[coordinate];
|
|
14023
|
+
const target = direction > 0 ? lastCell[coordinate] - 1 : 0;
|
|
14024
|
+
if (isMulti) {
|
|
14025
|
+
const edgeCoordinate = coordinate === 'x' ? 'x1' : 'y1';
|
|
14026
|
+
return this.sv.range(Object.assign(Object.assign({}, range), { [coordinate]: direction < 0 ? target : focus[coordinate], [edgeCoordinate]: direction > 0 ? target : focus[coordinate] }));
|
|
14027
|
+
}
|
|
14028
|
+
const edgeFocus = Object.assign(Object.assign({}, focus), { [coordinate]: target });
|
|
14029
|
+
return this.sv.focus(edgeFocus, {
|
|
14030
|
+
[coordinate]: target - focus[coordinate],
|
|
14031
|
+
});
|
|
14032
|
+
}
|
|
14007
14033
|
/** Monitor key direction changes */
|
|
14008
14034
|
changeDirectionKey(e, canRange) {
|
|
14009
14035
|
const isMulti = canRange && e.shiftKey;
|
|
14010
|
-
|
|
14036
|
+
const hasPrimaryModifier = e.ctrlKey || e.metaKey;
|
|
14037
|
+
const isArrow = ARROW_CODES.includes(e.code);
|
|
14038
|
+
const isEdgeShortcut = hasPrimaryModifier && !e.altKey && isArrow;
|
|
14039
|
+
if (hasPrimaryModifier && !isEdgeShortcut) {
|
|
14040
|
+
return;
|
|
14041
|
+
}
|
|
14042
|
+
if (DIRECTION_CODES.has(e.code)) {
|
|
14011
14043
|
e.preventDefault();
|
|
14012
14044
|
}
|
|
14013
14045
|
if (e.shiftKey) {
|
|
@@ -14016,17 +14048,25 @@ class KeyboardService {
|
|
|
14016
14048
|
return { changes: { x: -1 }, isMulti: false };
|
|
14017
14049
|
}
|
|
14018
14050
|
}
|
|
14051
|
+
let changes;
|
|
14019
14052
|
switch (e.code) {
|
|
14020
14053
|
case codesLetter.ARROW_UP:
|
|
14021
|
-
|
|
14054
|
+
changes = { y: -1 };
|
|
14055
|
+
break;
|
|
14022
14056
|
case codesLetter.ARROW_DOWN:
|
|
14023
|
-
|
|
14057
|
+
changes = { y: 1 };
|
|
14058
|
+
break;
|
|
14024
14059
|
case codesLetter.ARROW_LEFT:
|
|
14025
|
-
|
|
14060
|
+
changes = { x: -1 };
|
|
14061
|
+
break;
|
|
14026
14062
|
case codesLetter.TAB:
|
|
14027
14063
|
case codesLetter.ARROW_RIGHT:
|
|
14028
|
-
|
|
14064
|
+
changes = { x: 1 };
|
|
14065
|
+
break;
|
|
14066
|
+
default:
|
|
14067
|
+
return;
|
|
14029
14068
|
}
|
|
14069
|
+
return Object.assign({ changes, isMulti }, (isEdgeShortcut && { edge: true }));
|
|
14030
14070
|
}
|
|
14031
14071
|
}
|
|
14032
14072
|
|
|
@@ -14390,6 +14430,15 @@ class OverlaySelection {
|
|
|
14390
14430
|
await ((_a = this.revogrEdit) === null || _a === void 0 ? void 0 : _a.cancelChanges());
|
|
14391
14431
|
this.closeEdit();
|
|
14392
14432
|
},
|
|
14433
|
+
appendEditValue: value => {
|
|
14434
|
+
if (!this.revogrEdit) {
|
|
14435
|
+
return false;
|
|
14436
|
+
}
|
|
14437
|
+
return !this.revogrEdit.dispatchEvent(new CustomEvent('internalappendeditvalue', {
|
|
14438
|
+
cancelable: true,
|
|
14439
|
+
detail: value,
|
|
14440
|
+
}));
|
|
14441
|
+
},
|
|
14393
14442
|
clearCell: () => !this.readonly && this.clearCell(),
|
|
14394
14443
|
internalPaste: () => !this.readonly && this.beforeRegionPaste.emit(),
|
|
14395
14444
|
getData: () => this.getData(),
|
|
@@ -14513,9 +14562,9 @@ class OverlaySelection {
|
|
|
14513
14562
|
nodes.push(hAsync("revogr-order-editor", { ref: e => (this.orderEditor = e), dataStore: this.dataStore, dimensionRow: this.dimensionRow, dimensionCol: this.dimensionCol, parent: this.element, rowType: this.types.rowType, onRowdragstartinit: e => this.rowDragStart(e) }));
|
|
14514
14563
|
}
|
|
14515
14564
|
}
|
|
14516
|
-
return (hAsync(Host, { key: '
|
|
14565
|
+
return (hAsync(Host, { key: '84d904c108e39ebf82b215afc7052d634eba677e', class: { mobile: this.isMobileDevice }, onDblClick: (e) => this.onElementDblClick(e), onMouseDown: (e) => this.onElementMouseDown(e), onTouchStart: (e) => this.onElementMouseDown(e, true), onCloseedit: (e) => this.closeEdit(e),
|
|
14517
14566
|
// it's done to be able to throw events from different levels, not just from editor
|
|
14518
|
-
onCelledit: (e) => this.onEditCell(e) }, nodes, hAsync("slot", { key: '
|
|
14567
|
+
onCelledit: (e) => this.onEditCell(e) }, nodes, hAsync("slot", { key: '7434c5fceb445de4510675b7627bb5f2efc1a365', name: "data" })));
|
|
14519
14568
|
}
|
|
14520
14569
|
/**
|
|
14521
14570
|
* Executes the focus operation on the specified range of cells.
|
|
@@ -14846,6 +14895,14 @@ class TextEditor {
|
|
|
14846
14895
|
(_a = this.editInput) === null || _a === void 0 ? void 0 : _a.focus();
|
|
14847
14896
|
}
|
|
14848
14897
|
}
|
|
14898
|
+
appendPendingInput(value) {
|
|
14899
|
+
if (!this.editInput) {
|
|
14900
|
+
return false;
|
|
14901
|
+
}
|
|
14902
|
+
this.editInput.value += value;
|
|
14903
|
+
this.editInput.focus();
|
|
14904
|
+
return true;
|
|
14905
|
+
}
|
|
14849
14906
|
onKeyDown(e) {
|
|
14850
14907
|
const isEnter = isEnterKeyValue(e.key);
|
|
14851
14908
|
const isKeyTab = isTab(e.key);
|
|
@@ -14930,6 +14987,12 @@ class RevoEdit {
|
|
|
14930
14987
|
var _a, _b;
|
|
14931
14988
|
(_b = (_a = this.currentEditor) === null || _a === void 0 ? void 0 : _a.beforeDisconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
14932
14989
|
}
|
|
14990
|
+
onInternalAppendEditValue(e) {
|
|
14991
|
+
var _a, _b;
|
|
14992
|
+
if ((_b = (_a = this.currentEditor) === null || _a === void 0 ? void 0 : _a.appendPendingInput) === null || _b === void 0 ? void 0 : _b.call(_a, e.detail)) {
|
|
14993
|
+
e.preventDefault();
|
|
14994
|
+
}
|
|
14995
|
+
}
|
|
14933
14996
|
onAutoSave() {
|
|
14934
14997
|
var _a, _b, _c;
|
|
14935
14998
|
this.preventSaveOnClose = true;
|
|
@@ -15049,7 +15112,7 @@ class RevoEdit {
|
|
|
15049
15112
|
"cancelChanges": [64],
|
|
15050
15113
|
"beforeDisconnect": [64]
|
|
15051
15114
|
},
|
|
15052
|
-
"$listeners$":
|
|
15115
|
+
"$listeners$": [[0, "internalappendeditvalue", "onInternalAppendEditValue"]],
|
|
15053
15116
|
"$lazyBundleId$": "-",
|
|
15054
15117
|
"$attrsToReflect$": []
|
|
15055
15118
|
}; }
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Built by Revolist OU ❤️
|
|
3
3
|
*/
|
|
4
|
-
import{proxyCustomElement as t,HTMLElement as i,createEvent as n,h as
|
|
4
|
+
import{proxyCustomElement as t,HTMLElement as i,createEvent as n,h as e,Host as s,transformTag as o}from"@stencil/core/internal/client";import{E as r}from"./consts.js";import{K as l,O as h,c as a,k as d}from"./platform.js";import{t as u}from"./index2.js";function c(t){return-1!==[l.ARROW_DOWN,l.ARROW_UP,l.ARROW_LEFT,l.ARROW_RIGHT,l.HOME,l.END,l.DELETE,l.BACKSPACE,l.F1,l.F2,l.F3,l.F4,l.F5,l.F6,l.F7,l.F8,l.F9,l.F10,l.F11,l.F12,l.TAB,l.PAGE_DOWN,l.PAGE_UP,l.ENTER,l.ESCAPE,l.SHIFT,l.CAPS_LOCK,l.ALT].indexOf(t)}function v(t,i){return i.includes(h.mac)?[l.COMMAND_LEFT,l.COMMAND_RIGHT,l.COMMAND_FIREFOX].includes(t):t===l.CONTROL}function p(t){return[l.CONTROL,l.COMMAND_LEFT,l.COMMAND_RIGHT,l.COMMAND_FIREFOX].includes(t)}function f(t){return a.BACKSPACE===t||a.DELETE===t}function g(t){return a.TAB===t}function m(t){return d.TAB===t}function y(t){return d.ENTER===t}function b(t){return t.ctrlKey&&"KeyX"===t.code||t.metaKey&&"KeyX"===t.code}function K(t){return t.ctrlKey&&"KeyC"===t.code||t.metaKey&&"KeyC"===t.code}function k(t){return t.ctrlKey&&"KeyV"===t.code||t.metaKey&&"KeyV"===t.code}function w(t){return t.ctrlKey&&"KeyA"===t.code||t.metaKey&&"KeyA"===t.code}function C(t){var i;return!(null===(i=t.getModifierState)||void 0===i?void 0:i.call(t,"AltGraph"))&&!(t.ctrlKey&&t.altKey&&!t.metaKey&&1===t.key.length)&&(t.ctrlKey||t.metaKey)}class D{constructor(t,i){this.data=t,this.saveCallback=i,this.editInput=null,this.element=null,this.editCell=void 0}async componentDidRender(){var t;this.editInput&&(await u(),null===(t=this.editInput)||void 0===t||t.focus())}appendPendingInput(t){return!!this.editInput&&(this.editInput.value+=t,this.editInput.focus(),!0)}onKeyDown(t){const i=y(t.key),n=g(t.key);(n||i)&&t.target&&this.saveCallback&&!t.isComposing&&(this.beforeDisconnect(),this.saveCallback(this.getValue(),n))}beforeDisconnect(){var t;null===(t=this.editInput)||void 0===t||t.blur()}getValue(){var t;return null===(t=this.editInput)||void 0===t?void 0:t.value}render(t,i){var n,e;return t("input",{type:"text",enterKeyHint:"enter",value:null!==(e=null===(n=this.editCell)||void 0===n?void 0:n.val)&&void 0!==e?e:"",ref:t=>{this.editInput=t},onKeyDown:t=>this.onKeyDown(t)})}}function x(t){return!!(null==t?void 0:t.closest(`.${r}`))}function A(t){return"function"==typeof t&&"object"==typeof t.prototype}const E=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.cellEdit=n(this,"celleditinit",7),this.closeEdit=n(this,"closeedit",7),this.saveOnClose=!1,this.currentEditor=null,this.preventSaveOnClose=!1}async cancelChanges(){this.preventSaveOnClose=!0}async beforeDisconnect(){var t,i;null===(i=null===(t=this.currentEditor)||void 0===t?void 0:t.beforeDisconnect)||void 0===i||i.call(t)}onInternalAppendEditValue(t){var i,n;(null===(n=null===(i=this.currentEditor)||void 0===i?void 0:i.appendPendingInput)||void 0===n?void 0:n.call(i,t.detail))&&t.preventDefault()}onAutoSave(){var t,i,n;this.preventSaveOnClose=!0;const e=null===(i=null===(t=this.currentEditor)||void 0===t?void 0:t.getValue)||void 0===i?void 0:i.call(t);(null===(n=this.currentEditor)||void 0===n?void 0:n.beforeAutoSave)&&!1===this.currentEditor.beforeAutoSave(e)||this.onSave(e,!0)}onSave(t,i){this.preventSaveOnClose=!0,this.editCell&&this.cellEdit.emit({rgCol:this.editCell.x,rgRow:this.editCell.y,type:this.editCell.type,prop:this.editCell.prop,val:t,preventFocus:i})}componentWillRender(){!this.currentEditor&&this.column&&(this.preventSaveOnClose=!1,this.currentEditor=this.editor?A(this.editor)?new this.editor(this.column,((t,i)=>{this.onSave(t,i)}),(t=>{this.preventSaveOnClose=!0,this.closeEdit.emit(t)})):this.editor(this.column,((t,i)=>{this.onSave(t,i)}),(t=>{this.preventSaveOnClose=!0,this.closeEdit.emit(t)})):new D(this.column,((t,i)=>this.onSave(t,i))))}componentDidRender(){var t,i;this.currentEditor&&(this.currentEditor.element=this.element.firstElementChild,null===(i=(t=this.currentEditor).componentDidRender)||void 0===i||i.call(t))}disconnectedCallback(){var t,i;this.saveOnClose&&(this.preventSaveOnClose||this.onAutoSave()),this.preventSaveOnClose=!1,this.currentEditor&&(null===(i=(t=this.currentEditor).disconnectedCallback)||void 0===i||i.call(t),this.currentEditor.element=null,this.currentEditor=null)}render(){return this.currentEditor?(this.currentEditor.editCell=this.editCell,e(s,{class:r},this.currentEditor.render(e,this.additionalData))):""}get element(){return this}static get style(){return"revogr-edit{display:block;position:absolute;background-color:var(--rg-theme-background)}revogr-edit input{height:100%;width:100%;box-sizing:border-box;padding:var(--rg-theme-cell-padding);background-color:var(--rg-theme-background)}revogr-edit revo-dropdown{height:100%}revogr-edit revo-dropdown.shrink fieldset legend>span{display:none}"}},[0,"revogr-edit",{editCell:[16],column:[16],editor:[16],saveOnClose:[4,"save-on-close"],additionalData:[8,"additional-data"],cancelChanges:[64],beforeDisconnect:[64]},[[0,"internalappendeditvalue","onInternalAppendEditValue"]]]);function j(){"undefined"!=typeof customElements&&["revogr-edit"].forEach((t=>{"revogr-edit"===t&&(customElements.get(o(t))||customElements.define(o(t),E))}))}export{E as R,D as T,v as a,p as b,f as c,g as d,m as e,y as f,b as g,K as h,c as i,k as j,w as k,C as l,x as m,A as n,j as o}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Built by Revolist OU ❤️
|
|
3
3
|
*/
|
|
4
|
-
import{h as t,proxyCustomElement as e,HTMLElement as i,createEvent as s,Host as o,transformTag as n}from"@stencil/core/internal/client";import{g as r,N as a,z as l,O as h,b as c}from"./column.service.js";import{c as d}from"./platform.js";import{R as u,i as g,j as v,S as p}from"./consts.js";import{b as f,i as b,c as m,a as y,g as x,d as w,e as j,s as O,f as S,v as C}from"./selection.utils.js";import{l as D,m as k,c as M,d as R,f as E,h as A,g as F,j as P,k as T,o as z}from"./revogr-edit2.js";import{t as K}from"./index2.js";import{d as U}from"./debounce.js";import{d as X}from"./revogr-clipboard2.js";import{d as $}from"./revogr-order-editor2.js";const H=[d.TAB,d.ARROW_UP,d.ARROW_DOWN,d.ARROW_LEFT,d.ARROW_RIGHT];class q{constructor(t){this.sv=t,this.keyChangeQueue=Promise.resolve(!1),this.keyChangeGeneration=0,this.applyingKeyChange=!1}invalidatePendingChanges(){this.applyingKeyChange||(this.keyChangeGeneration+=1)}appendPendingEditValue(t){if(D(t)||1!==t.key.length||t.target instanceof HTMLElement&&k(t.target))return!1;const e=this.sv.selectionStore.get("edit");return"string"==typeof(null==e?void 0:e.val)&&(t.preventDefault(),this.sv.selectionStore.set("edit",Object.assign(Object.assign({},e),{val:`${e.val}${t.key}`})),!0)}async keyDown(t,e,i,{range:s,focus:o}){if(i){if(this.appendPendingEditValue(t))return;switch(t.code){case d.ESCAPE:this.sv.cancel();break;case d.TAB:this.keyChangeSelection(t,e)}}else s&&M(t.code)?this.sv.clearCell():o&&(R(t.code)?this.keyChangeSelection(t,e):E(t.key)?this.sv.change():A(t)||F(t)||(P(t)?this.sv.internalPaste():T(t)?e&&this.selectAll(t):D(t)||1!==t.key.length?await this.keyChangeSelection(t,e):this.sv.change(t.key)&&t.preventDefault()))}selectAll(t){const e=this.sv.selectionStore.get("range"),i=this.sv.selectionStore.get("focus");e&&i&&(t.preventDefault(),this.sv.selectAll())}async keyChangeSelection(t,e){const i=this.changeDirectionKey(t,e);if(!i)return!1;const s=this.keyChangeGeneration;await K(u+30);const o=async()=>{if(s!==this.keyChangeGeneration)return!1;const t=this.sv.selectionStore.get("range"),e=this.sv.selectionStore.get("focus");let o;this.applyingKeyChange=!0;try{o=this.keyPositionChange(i.changes,t,e,i.isMulti)}finally{this.applyingKeyChange=!1}return await new Promise((t=>requestAnimationFrame((()=>{requestAnimationFrame((()=>t()))})))),o},n=this.keyChangeQueue.then(o,o);return this.keyChangeQueue=n.catch((()=>!1)),n}keyPositionChange(t,e,i,s=!1){if(!e||!i)return!1;const o=f(e,i,t,s);if(!o)return!1;const n=this.sv.getData();if(s){if([o.start,o.end].some((t=>b(t,n.lastCell)||m(t))))return!1;const t=r(o.start,o.end);return this.sv.range(t)}return this.sv.focus(o.start,t,b(o.start,n.lastCell)?1:m(o.start)?-1:0)}changeDirectionKey(t,e){const i=e&&t.shiftKey;if(H.includes(t.code)&&t.preventDefault(),t.shiftKey&&t.code===d.TAB)return{changes:{x:-1},isMulti:!1};switch(t.code){case d.ARROW_UP:return{changes:{y:-1},isMulti:i};case d.ARROW_DOWN:return{changes:{y:1},isMulti:i};case d.ARROW_LEFT:return{changes:{x:-1},isMulti:i};case d.TAB:case d.ARROW_RIGHT:return{changes:{x:1},isMulti:i}}}}class L{constructor(t){this.sv=t,this.autoFillType=null,this.autoFillInitial=null,this.autoFillStart=null,this.autoFillLast=null}renderAutofill(e,i,s=!1){let o;return o=y(e||Object.assign(Object.assign({},i),{x1:i.x,y1:i.y}),this.sv.dimensionRow.state,this.sv.dimensionCol.state),t("div",{class:{[v]:!0,[g]:s},style:{left:`${o.right}px`,top:`${o.bottom}px`},onMouseDown:t=>this.autoFillHandler(t),onTouchStart:t=>this.autoFillHandler(t)})}autoFillHandler(t,e="AutoFill"){let i=null;t.target instanceof Element&&(i=t.target),i&&(this.selectionStart(i,this.sv.getData(),e),t.preventDefault())}get isAutoFill(){return!!this.autoFillType}selectionMouseMove(t){this.onMouseMoveAutofill||(this.onMouseMoveAutofill=U(((t,e)=>this.doAutofillMouseMove(t,e)),5)),this.isAutoFill&&this.onMouseMoveAutofill(t,this.sv.getData())}getFocus(t,e){return!t&&e&&(t={x:e.x,y:e.y}),t||null}doAutofillMouseMove(t,e){if(!this.autoFillInitial)return;const i=x(t,"clientX",g),s=x(t,"clientY",g);if(null===i||null===s)return;const o=w({x:i,y:s},e);if(this.autoFillLast||this.autoFillLast||(this.autoFillLast=this.autoFillStart),!b(o,e.lastCell))if(this.autoFillLast=o,o.x===this.autoFillInitial.x&&o.y===this.autoFillInitial.y)this.sv.setTempRange(null);else{const t=r(this.autoFillInitial,this.autoFillLast);this.sv.setTempRange({area:t,type:this.autoFillType})}}selectionStart(t,e,i="Selection"){const{top:s,left:o}=t.getBoundingClientRect();this.autoFillInitial=this.getFocus(e.focus,e.range),this.autoFillType=i,this.autoFillStart=w({x:o,y:s},e)}clearAutoFillSelection(t,e){if(this.autoFillInitial)if(this.autoFillInitial=this.getFocus(t,e),"AutoFill"===this.autoFillType){const t=r(this.autoFillInitial,this.autoFillLast);if(t){const{defaultPrevented:i,detail:{range:s}}=this.sv.clearRangeDataApply({range:t});!i&&e?this.applyRangeWithData(s,e):this.sv.setTempRange(null)}}else this.applyRangeOnly(this.autoFillInitial,this.autoFillLast);this.resetAutoFillState()}resetAutoFillState(){this.autoFillType=null,this.autoFillInitial=null,this.autoFillLast=null,this.autoFillStart=null}onRangeApply(t,e,i){this.sv.rangeDataApply({data:t,models:j(t,this.sv.dataStore),type:this.sv.dataStore.get("type"),oldRange:i,newRange:e}),this.sv.setRange(e)}applyRangeWithData(t,e){const i={type:this.sv.dataStore.get("type"),colType:this.sv.columnService.type,newData:{},mapping:{},newRange:t,oldRange:e},{mapping:s,changed:o}=this.sv.columnService.getRangeData(i,this.sv.columnService.columns);i.newData=o,i.mapping=s;let n=this.sv.selectionChanged(i);n.defaultPrevented?this.sv.setTempRange(null):(n=this.sv.rangeCopy(i),n.defaultPrevented?this.sv.setRange(t):this.onRangeApply(i.newData,t,e))}applyRangeOnly(t,e){if(!t||!e)return;const i=r(t,e);this.sv.setRange(i)}}const N=e(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.beforeCopyRegion=s(this,"beforecopyregion",7),this.beforeRegionPaste=s(this,"beforepasteregion",7),this.cellEditApply=s(this,"celleditapply",7),this.beforeFocusCell=s(this,"beforecellfocusinit",7),this.beforeNextViewportFocus=s(this,"beforenextvpfocus",7),this.setEdit=s(this,"setedit",7),this.beforeApplyRange=s(this,"beforeapplyrange",7),this.beforeSetRange=s(this,"beforesetrange",7),this.setRange=s(this,"setrange",7),this.beforeEditRender=s(this,"beforeeditrender",7),this.selectAll=s(this,"selectall",7),this.cancelEdit=s(this,"canceledit",7),this.setTempRange=s(this,"settemprange",7),this.beforeSetTempRange=s(this,"beforesettemprange",7),this.applyFocus=s(this,"applyfocus",7),this.focusCell=s(this,"focuscell",7),this.beforeRangeDataApply=s(this,"beforerangedataapply",7),this.selectionChange=s(this,"selectionchangeinit",7),this.beforeRangeCopyApply=s(this,"beforerangecopyapply",7),this.rangeEditApply=s(this,"rangeeditapply",7),this.rangeClipboardCopy=s(this,"clipboardrangecopy",7),this.rangeClipboardPaste=s(this,"clipboardrangepaste",7),this.beforeKeyDown=s(this,"beforekeydown",7),this.beforeKeyUp=s(this,"beforekeyup",7),this.beforeCellSave=s(this,"beforecellsave",7),this.cellEditDone=s(this,"celledit",7),this.applyChangesOnClose=!1,this.keyboardService=null,this.autoFillService=null,this.unsubscribeSelectionStore=[]}onMouseMove(t){var e;this.selectionStore.get("focus")&&(null===(e=this.autoFillService)||void 0===e||e.selectionMouseMove(t))}onMouseUp(){var t;null===(t=this.autoFillService)||void 0===t||t.clearAutoFillSelection(this.selectionStore.get("focus"),this.selectionStore.get("range"))}onCellDrag(t){var e;null===(e=this.orderEditor)||void 0===e||e.dragStart(t.detail)}onKeyUp(t){this.beforeKeyUp.emit(Object.assign({original:t},this.getData()))}onKeyDown(t){var e;const i=this.beforeKeyDown.emit(Object.assign({original:t},this.getData()));t.defaultPrevented||i.defaultPrevented||null===(e=this.keyboardService)||void 0===e||e.keyDown(t,this.range,!!this.selectionStore.get("edit"),{focus:this.selectionStore.get("focus"),range:this.selectionStore.get("range")})}selectionServiceSet(t){var e;null===(e=this.keyboardService)||void 0===e||e.invalidatePendingChanges(),this.unsubscribeSelectionStore.forEach((t=>t())),this.unsubscribeSelectionStore.length=0,this.unsubscribeSelectionStore.push(t.onChange("nextFocus",(t=>t&&this.doFocus(t,t)))),this.keyboardService=new q({selectionStore:t,range:t=>!!t&&this.triggerRangeEvent(t),focus:(t,e,i)=>i?(this.beforeNextViewportFocus.emit(t),!1):this.doFocus(t,t,e),change:t=>this.doEdit(t),cancel:async()=>{var t;await(null===(t=this.revogrEdit)||void 0===t?void 0:t.cancelChanges()),this.closeEdit()},clearCell:()=>!this.readonly&&this.clearCell(),internalPaste:()=>!this.readonly&&this.beforeRegionPaste.emit(),getData:()=>this.getData(),selectAll:()=>this.selectAll.emit()}),this.unsubscribeSelectionStore.push(t.onChange("focus",(()=>{var t;return null===(t=this.keyboardService)||void 0===t?void 0:t.invalidatePendingChanges()})),t.onChange("edit",(()=>{var t;return null===(t=this.keyboardService)||void 0===t?void 0:t.invalidatePendingChanges()}))),this.createAutoFillService()}createAutoFillService(){this.autoFillService=new L({dimensionRow:this.dimensionRow,dimensionCol:this.dimensionCol,columnService:this.columnService,dataStore:this.dataStore,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)})),setTempRange:t=>{const e=this.beforeSetTempRange.emit(Object.assign(Object.assign({tempRange:t},this.getData()),this.types));return e.defaultPrevented?null:this.setTempRange.emit(e.detail.tempRange)},selectionChanged:t=>this.selectionChange.emit(t),rangeCopy:t=>this.beforeRangeCopyApply.emit(t),rangeDataApply:t=>this.rangeEditApply.emit(t),setRange:t=>!!t&&this.triggerRangeEvent(t),getData:()=>this.getData()})}columnServiceSet(){var t;null===(t=this.columnService)||void 0===t||t.destroy(),this.columnService=new a(this.dataStore,this.colData),this.createAutoFillService()}connectedCallback(){this.columnServiceSet(),this.selectionServiceSet(this.selectionStore)}disconnectedCallback(){var t,e;null===(t=this.keyboardService)||void 0===t||t.invalidatePendingChanges(),this.unsubscribeSelectionStore.forEach((t=>t())),this.unsubscribeSelectionStore.length=0,null===(e=this.columnService)||void 0===e||e.destroy()}async componentWillRender(){var t,e;this.selectionStore.get("edit")||await(null===(e=null===(t=this.revogrEdit)||void 0===t?void 0:t.beforeDisconnect)||void 0===e?void 0:e.call(t))}renderRange(e){const i=y(e,this.dimensionRow.state,this.dimensionCol.state),s=O(i);return t("div",{class:p,style:s},this.isMobileDevice&&t("div",{class:"range-handlers"},t("span",{class:g}),t("span",{class:g})))}renderEditor(){const e=this.selectionStore.get("edit");if(this.readonly||!e)return null;const i=e.val||l(this.columnService.rowDataModel(e.y,e.x).value),s=Object.assign(Object.assign({},e),this.columnService.getSaveData(e.y,e.x,i)),o=this.beforeEditRender.emit(Object.assign(Object.assign({range:Object.assign(Object.assign({},e),{x1:e.x,y1:e.y})},this.types),{rowDimension:Object.assign({},this.dimensionRow.state),colDimension:Object.assign({},this.dimensionCol.state)}));if(o.defaultPrevented)return null;const n=y(o.detail.range,o.detail.rowDimension,o.detail.colDimension),r=O(n);return t("revogr-edit",{style:r,ref:t=>this.revogrEdit=t,additionalData:this.additionalData,editCell:s,saveOnClose:this.applyChangesOnClose,onCelleditinit:t=>{this.cellEditDone.emit(t.detail)},column:this.columnService.rowDataModel(e.y,e.x),editor:h(this.columnService.columns[e.x],this.editors)})}onEditCell(t){if(t.defaultPrevented)return;const e=this.beforeCellSave.emit(t.detail);e.defaultPrevented||this.cellEdit(e.detail),e.detail.preventFocus||this.focusNext()}render(){var e;const i=[],s=this.renderEditor();if(s)i.push(s);else{const s=this.selectionStore.get("range"),o=this.selectionStore.get("focus");(s||o)&&this.useClipboard&&i.push(t("revogr-clipboard",{readonly:this.readonly,onCopyregion:t=>this.onCopy(t.detail),onClearregion:()=>!this.readonly&&this.clearCell(),ref:t=>this.clipboard=t,onPasteregion:t=>this.onPaste(t.detail)})),s&&i.push(this.renderRange(s)),o&&!this.readonly&&this.range&&i.push(null===(e=this.autoFillService)||void 0===e?void 0:e.renderAutofill(s,o,this.isMobileDevice)),this.canDrag&&i.push(t("revogr-order-editor",{ref:t=>this.orderEditor=t,dataStore:this.dataStore,dimensionRow:this.dimensionRow,dimensionCol:this.dimensionCol,parent:this.element,rowType:this.types.rowType,onRowdragstartinit:t=>this.rowDragStart(t)}))}return t(o,{key:"230e2122c5c7065c072f02019d616a64949d54d0",class:{mobile:this.isMobileDevice},onDblClick:t=>this.onElementDblClick(t),onMouseDown:t=>this.onElementMouseDown(t),onTouchStart:t=>this.onElementMouseDown(t,!0),onCloseedit:t=>this.closeEdit(t),onCelledit:t=>this.onEditCell(t)},i,t("slot",{key:"47740a79c605258b4024384510358be927d000b7",name:"data"}))}doFocus(t,e,i,s){const{defaultPrevented:o}=this.beforeFocusCell.emit(Object.assign(Object.assign({},this.columnService.getSaveData(t.y,t.x)),{originalEvent:s}));if(o)return!1;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);if(r.defaultPrevented)return!1;const{range:a}=r.detail;return!this.focusCell.emit(Object.assign({focus:{x:a.x,y:a.y},end:{x:a.x1,y:a.y1}},r.detail)).defaultPrevented}triggerRangeEvent(t,e){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}));if(s.defaultPrevented)return!1;const o=this.columnService.getRangeTransformedToProps(s.detail.range,this.dataStore);let n=this.beforeSetRange.emit(o);return!n.defaultPrevented&&(n=this.setRange.emit(Object.assign(Object.assign({},s.detail.range),{type:i})),!n.defaultPrevented&&!n.defaultPrevented)}onElementDblClick(t){if(t.defaultPrevented)return;const e=this.getData();S(t,e)&&this.doEdit()}onElementMouseDown(t,e=!1){var i;const s=t.target;if(k(s)||t.defaultPrevented)return;const o=this.getData(),n=S(t,o);n&&(this.focus(n,this.range&&t.shiftKey,t),this.range&&(s&&(null===(i=this.autoFillService)||void 0===i||i.selectionStart(s,this.getData())),e?C(t.touches[0],g)&&t.preventDefault():t.preventDefault()))}doEdit(t=""){if(!this.canEdit())return!1;const e=this.selectionStore.get("focus");if(!e)return!1;const i=this.columnService.getSaveData(e.y,e.x);return!this.setEdit.emit(Object.assign(Object.assign({},i),{val:t})).defaultPrevented}async closeEdit(t){this.cancelEdit.emit(),(null==t?void 0:t.detail)&&await this.focusNext()}cellEdit(t){const e=this.columnService.getSaveData(t.rgRow,t.rgCol,t.val);this.cellEditApply.emit(e)}getRegion(){const t=this.selectionStore.get("focus");let e=this.selectionStore.get("range");return e||(e=r(t,t)),e}onCopy(t){var e;const i=this.getRegion();if(this.beforeCopyRegion.emit(i).defaultPrevented)return!1;let s;if(i){const{data:t,mapping:e}=this.columnService.copyRangeArray(i,this.dataStore),o=this.rangeClipboardCopy.emit(Object.assign({range:i,data:t,mapping:e},this.types));o.defaultPrevented||(s=o.detail.data)}return null===(e=this.clipboard)||void 0===e||e.doCopy(t,s),!0}onPaste(t){var e;const i=this.selectionStore.get("focus"),s=null!==this.selectionStore.get("edit");if(!i||s)return;const o=function(t,e){var i;if(!function(t){return"object"==typeof t&&!0===t.rangeFill}(e))return null;const s=function(t){const e=[...t];for(;e.length>1&&(!(i=e[e.length-1])||i.every((t=>""===t)));)e.pop();var i;return e}(t);return 1===s.length&&1===(null===(i=s[0])||void 0===i?void 0:i.length)?s:null}(t,this.useClipboard),n=o?this.getClipboardPasteTargetRange():null;let{changed:r,range:a}=this.columnService.getTransformedDataToApply({start:i,data:o||t,targetRange:n});const{defaultPrevented:l}=this.rangeClipboardPaste.emit(Object.assign({data:r,models:j(r,this.dataStore),range:a},this.types));l||null===(e=this.autoFillService)||void 0===e||e.onRangeApply(r,a,a)}getClipboardPasteTargetRange(){const t=this.selectionStore.get("range");return t&&!c(t)?t:null}async focusNext(){var t;await(null===(t=this.keyboardService)||void 0===t?void 0:t.keyChangeSelection(new KeyboardEvent("keydown",{code:d.ARROW_DOWN}),this.range))||this.closeEdit()}clearCell(){var t;const e=this.selectionStore.get("range"),i=this.selectionStore.get("focus");if(!e||c(e)&&i){if(this.canEdit()){if(!i)return;const t=this.columnService.getSaveData(i.y,i.x);this.cellEdit({rgRow:i.y,rgCol:i.x,val:"",type:t.type,prop:t.prop})}}else{const i=this.columnService.getRangeStaticData(e,"");null===(t=this.autoFillService)||void 0===t||t.onRangeApply(i,e,e)}}rowDragStart({detail:t}){t.text=l(this.columnService.rowDataModel(t.cell.y,t.cell.x).value)}canEdit(){var t;if(this.readonly)return!1;const e=this.selectionStore.get("focus");return e&&!(null===(t=this.columnService)||void 0===t?void 0:t.isReadOnly(e.y,e.x))}get edited(){return this.selectionStore.get("edit")}focus(t,e=!1,i){if(!t)return!1;const s=t,o=this.selectionStore.get("focus");if(e&&o){const t=r(o,s);if(t)return this.triggerRangeEvent(t,i)}return this.doFocus(t,s,void 0,i)}get types(){return{rowType:this.dataStore.get("type"),colType:this.columnService.type}}getData(){return{el:this.element,rows:this.dimensionRow.state,cols:this.dimensionCol.state,lastCell:this.lastCell,focus:this.selectionStore.get("focus"),range:this.selectionStore.get("range"),edit:this.selectionStore.get("edit")}}get element(){return this}static get watchers(){return{selectionStore:[{selectionServiceSet:0}],dimensionRow:[{createAutoFillService:0}],dimensionCol:[{createAutoFillService:0}],dataStore:[{columnServiceSet:0}],colData:[{columnServiceSet:0}]}}static get style(){return'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:var(--rg-theme-autofill-handle-bg);border:1px solid var(--rg-theme-autofill-handle-border);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:var(--rg-theme-autofill-handle-bg);border:1px solid var(--rg-theme-autofill-handle-border);box-sizing:border-box}revogr-overlay-selection .selection-border-range{position:absolute;pointer-events:none;z-index:9;background-color:var(--rg-theme-selection-bg)}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:var(--rg-theme-range-handle-bg)}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 .selection-border-range{box-shadow:-1px 0 0 var(--rg-theme-selection-border) inset, 1px 0 0 var(--rg-theme-selection-border) inset, 0 -1px 0 var(--rg-theme-selection-border) inset, 0 1px 0 var(--rg-theme-selection-border) inset}revogr-overlay-selection revogr-edit{z-index:10}'}},[260,"revogr-overlay-selection",{readonly:[4],range:[4],canDrag:[4,"can-drag"],useClipboard:[4,"use-clipboard"],selectionStore:[16],dimensionRow:[16],dimensionCol:[16],dataStore:[16],colData:[16],lastCell:[16],editors:[16],applyChangesOnClose:[4,"apply-changes-on-close"],additionalData:[8,"additional-data"],isMobileDevice:[4,"is-mobile-device"]},[[5,"touchmove","onMouseMove"],[5,"mousemove","onMouseMove"],[5,"touchend","onMouseUp"],[5,"mouseup","onMouseUp"],[5,"mouseleave","onMouseUp"],[0,"dragstartcell","onCellDrag"],[4,"keyup","onKeyUp"],[4,"keydown","onKeyDown"]],{selectionStore:[{selectionServiceSet:0}],dimensionRow:[{createAutoFillService:0}],dimensionCol:[{createAutoFillService:0}],dataStore:[{columnServiceSet:0}],colData:[{columnServiceSet:0}]}]);function W(){"undefined"!=typeof customElements&&["revogr-overlay-selection","revogr-clipboard","revogr-edit","revogr-order-editor"].forEach((t=>{switch(t){case"revogr-overlay-selection":customElements.get(n(t))||customElements.define(n(t),N);break;case"revogr-clipboard":customElements.get(n(t))||X();break;case"revogr-edit":customElements.get(n(t))||z();break;case"revogr-order-editor":customElements.get(n(t))||$()}}))}export{N as O,W as d}
|
|
4
|
+
import{h as t,proxyCustomElement as e,HTMLElement as i,createEvent as s,Host as o,transformTag as n}from"@stencil/core/internal/client";import{g as r,N as a,z as l,O as h,b as c}from"./column.service.js";import{c as d}from"./platform.js";import{R as u,i as g,j as v,S as p}from"./consts.js";import{b,i as f,c as m,a as y,g as x,d as j,e as w,s as O,f as S,v as C}from"./selection.utils.js";import{l as D,m as k,c as E,d as R,f as M,h as A,g as F,j as P,k as T,o as z}from"./revogr-edit2.js";import{t as K}from"./index2.js";import{d as U}from"./debounce.js";import{d as X}from"./revogr-clipboard2.js";import{d as $}from"./revogr-order-editor2.js";const H=[d.ARROW_UP,d.ARROW_DOWN,d.ARROW_LEFT,d.ARROW_RIGHT],q=new Set([d.TAB,...H]);class L{constructor(t){this.sv=t,this.keyChangeQueue=Promise.resolve(!1),this.keyChangeGeneration=0,this.applyingKeyChange=!1}invalidatePendingChanges(){this.applyingKeyChange||(this.keyChangeGeneration+=1)}appendPendingEditValue(t){if(D(t)||1!==t.key.length||t.target instanceof HTMLElement&&k(t.target))return!1;const e=this.sv.selectionStore.get("edit");return"string"==typeof(null==e?void 0:e.val)&&(t.preventDefault(),this.sv.appendEditValue(t.key)||this.sv.selectionStore.set("edit",Object.assign(Object.assign({},e),{val:`${e.val}${t.key}`})),!0)}async keyDown(t,e,i,{range:s,focus:o}){if(i){if(this.appendPendingEditValue(t))return;switch(t.code){case d.ESCAPE:this.sv.cancel();break;case d.TAB:this.keyChangeSelection(t,e)}}else s&&E(t.code)?this.sv.clearCell():o&&(R(t.code)?this.keyChangeSelection(t,e):M(t.key)?this.sv.change():A(t)||F(t)||(P(t)?this.sv.internalPaste():T(t)?e&&this.selectAll(t):D(t)||1!==t.key.length?await this.keyChangeSelection(t,e):this.sv.change(t.key)&&t.preventDefault()))}selectAll(t){const e=this.sv.selectionStore.get("range"),i=this.sv.selectionStore.get("focus");e&&i&&(t.preventDefault(),this.sv.selectAll())}async keyChangeSelection(t,e){const i=this.changeDirectionKey(t,e);if(!i)return!1;const s=this.keyChangeGeneration;await K(u+30);const o=async()=>{if(s!==this.keyChangeGeneration)return!1;const t=this.sv.selectionStore.get("range"),e=this.sv.selectionStore.get("focus");let o;this.applyingKeyChange=!0;try{o=i.edge?this.keyEdgeChange(i.changes,t,e,!!i.isMulti):this.keyPositionChange(i.changes,t,e,i.isMulti)}finally{this.applyingKeyChange=!1}return await new Promise((t=>requestAnimationFrame((()=>{requestAnimationFrame((()=>t()))})))),o},n=this.keyChangeQueue.then(o,o);return this.keyChangeQueue=n.catch((()=>!1)),n}keyPositionChange(t,e,i,s=!1){if(!e||!i)return!1;const o=b(e,i,t,s);if(!o)return!1;const n=this.sv.getData();if(s){if([o.start,o.end].some((t=>f(t,n.lastCell)||m(t))))return!1;const t=r(o.start,o.end);return this.sv.range(t)}return this.sv.focus(o.start,t,f(o.start,n.lastCell)?1:m(o.start)?-1:0)}keyEdgeChange(t,e,i,s){if(!e||!i)return!1;const{lastCell:o}=this.sv.getData(),n=t.x?"x":"y",r=t[n],a=r>0?o[n]-1:0;if(s){const t="x"===n?"x1":"y1";return this.sv.range(Object.assign(Object.assign({},e),{[n]:r<0?a:i[n],[t]:r>0?a:i[n]}))}const l=Object.assign(Object.assign({},i),{[n]:a});return this.sv.focus(l,{[n]:a-i[n]})}changeDirectionKey(t,e){const i=e&&t.shiftKey,s=t.ctrlKey||t.metaKey,o=H.includes(t.code),n=s&&!t.altKey&&o;if(s&&!n)return;if(q.has(t.code)&&t.preventDefault(),t.shiftKey&&t.code===d.TAB)return{changes:{x:-1},isMulti:!1};let r;switch(t.code){case d.ARROW_UP:r={y:-1};break;case d.ARROW_DOWN:r={y:1};break;case d.ARROW_LEFT:r={x:-1};break;case d.TAB:case d.ARROW_RIGHT:r={x:1};break;default:return}return Object.assign({changes:r,isMulti:i},n&&{edge:!0})}}class N{constructor(t){this.sv=t,this.autoFillType=null,this.autoFillInitial=null,this.autoFillStart=null,this.autoFillLast=null}renderAutofill(e,i,s=!1){let o;return o=y(e||Object.assign(Object.assign({},i),{x1:i.x,y1:i.y}),this.sv.dimensionRow.state,this.sv.dimensionCol.state),t("div",{class:{[v]:!0,[g]:s},style:{left:`${o.right}px`,top:`${o.bottom}px`},onMouseDown:t=>this.autoFillHandler(t),onTouchStart:t=>this.autoFillHandler(t)})}autoFillHandler(t,e="AutoFill"){let i=null;t.target instanceof Element&&(i=t.target),i&&(this.selectionStart(i,this.sv.getData(),e),t.preventDefault())}get isAutoFill(){return!!this.autoFillType}selectionMouseMove(t){this.onMouseMoveAutofill||(this.onMouseMoveAutofill=U(((t,e)=>this.doAutofillMouseMove(t,e)),5)),this.isAutoFill&&this.onMouseMoveAutofill(t,this.sv.getData())}getFocus(t,e){return!t&&e&&(t={x:e.x,y:e.y}),t||null}doAutofillMouseMove(t,e){if(!this.autoFillInitial)return;const i=x(t,"clientX",g),s=x(t,"clientY",g);if(null===i||null===s)return;const o=j({x:i,y:s},e);if(this.autoFillLast||this.autoFillLast||(this.autoFillLast=this.autoFillStart),!f(o,e.lastCell))if(this.autoFillLast=o,o.x===this.autoFillInitial.x&&o.y===this.autoFillInitial.y)this.sv.setTempRange(null);else{const t=r(this.autoFillInitial,this.autoFillLast);this.sv.setTempRange({area:t,type:this.autoFillType})}}selectionStart(t,e,i="Selection"){const{top:s,left:o}=t.getBoundingClientRect();this.autoFillInitial=this.getFocus(e.focus,e.range),this.autoFillType=i,this.autoFillStart=j({x:o,y:s},e)}clearAutoFillSelection(t,e){if(this.autoFillInitial)if(this.autoFillInitial=this.getFocus(t,e),"AutoFill"===this.autoFillType){const t=r(this.autoFillInitial,this.autoFillLast);if(t){const{defaultPrevented:i,detail:{range:s}}=this.sv.clearRangeDataApply({range:t});!i&&e?this.applyRangeWithData(s,e):this.sv.setTempRange(null)}}else this.applyRangeOnly(this.autoFillInitial,this.autoFillLast);this.resetAutoFillState()}resetAutoFillState(){this.autoFillType=null,this.autoFillInitial=null,this.autoFillLast=null,this.autoFillStart=null}onRangeApply(t,e,i){this.sv.rangeDataApply({data:t,models:w(t,this.sv.dataStore),type:this.sv.dataStore.get("type"),oldRange:i,newRange:e}),this.sv.setRange(e)}applyRangeWithData(t,e){const i={type:this.sv.dataStore.get("type"),colType:this.sv.columnService.type,newData:{},mapping:{},newRange:t,oldRange:e},{mapping:s,changed:o}=this.sv.columnService.getRangeData(i,this.sv.columnService.columns);i.newData=o,i.mapping=s;let n=this.sv.selectionChanged(i);n.defaultPrevented?this.sv.setTempRange(null):(n=this.sv.rangeCopy(i),n.defaultPrevented?this.sv.setRange(t):this.onRangeApply(i.newData,t,e))}applyRangeOnly(t,e){if(!t||!e)return;const i=r(t,e);this.sv.setRange(i)}}const V=e(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.beforeCopyRegion=s(this,"beforecopyregion",7),this.beforeRegionPaste=s(this,"beforepasteregion",7),this.cellEditApply=s(this,"celleditapply",7),this.beforeFocusCell=s(this,"beforecellfocusinit",7),this.beforeNextViewportFocus=s(this,"beforenextvpfocus",7),this.setEdit=s(this,"setedit",7),this.beforeApplyRange=s(this,"beforeapplyrange",7),this.beforeSetRange=s(this,"beforesetrange",7),this.setRange=s(this,"setrange",7),this.beforeEditRender=s(this,"beforeeditrender",7),this.selectAll=s(this,"selectall",7),this.cancelEdit=s(this,"canceledit",7),this.setTempRange=s(this,"settemprange",7),this.beforeSetTempRange=s(this,"beforesettemprange",7),this.applyFocus=s(this,"applyfocus",7),this.focusCell=s(this,"focuscell",7),this.beforeRangeDataApply=s(this,"beforerangedataapply",7),this.selectionChange=s(this,"selectionchangeinit",7),this.beforeRangeCopyApply=s(this,"beforerangecopyapply",7),this.rangeEditApply=s(this,"rangeeditapply",7),this.rangeClipboardCopy=s(this,"clipboardrangecopy",7),this.rangeClipboardPaste=s(this,"clipboardrangepaste",7),this.beforeKeyDown=s(this,"beforekeydown",7),this.beforeKeyUp=s(this,"beforekeyup",7),this.beforeCellSave=s(this,"beforecellsave",7),this.cellEditDone=s(this,"celledit",7),this.applyChangesOnClose=!1,this.keyboardService=null,this.autoFillService=null,this.unsubscribeSelectionStore=[]}onMouseMove(t){var e;this.selectionStore.get("focus")&&(null===(e=this.autoFillService)||void 0===e||e.selectionMouseMove(t))}onMouseUp(){var t;null===(t=this.autoFillService)||void 0===t||t.clearAutoFillSelection(this.selectionStore.get("focus"),this.selectionStore.get("range"))}onCellDrag(t){var e;null===(e=this.orderEditor)||void 0===e||e.dragStart(t.detail)}onKeyUp(t){this.beforeKeyUp.emit(Object.assign({original:t},this.getData()))}onKeyDown(t){var e;const i=this.beforeKeyDown.emit(Object.assign({original:t},this.getData()));t.defaultPrevented||i.defaultPrevented||null===(e=this.keyboardService)||void 0===e||e.keyDown(t,this.range,!!this.selectionStore.get("edit"),{focus:this.selectionStore.get("focus"),range:this.selectionStore.get("range")})}selectionServiceSet(t){var e;null===(e=this.keyboardService)||void 0===e||e.invalidatePendingChanges(),this.unsubscribeSelectionStore.forEach((t=>t())),this.unsubscribeSelectionStore.length=0,this.unsubscribeSelectionStore.push(t.onChange("nextFocus",(t=>t&&this.doFocus(t,t)))),this.keyboardService=new L({selectionStore:t,range:t=>!!t&&this.triggerRangeEvent(t),focus:(t,e,i)=>i?(this.beforeNextViewportFocus.emit(t),!1):this.doFocus(t,t,e),change:t=>this.doEdit(t),cancel:async()=>{var t;await(null===(t=this.revogrEdit)||void 0===t?void 0:t.cancelChanges()),this.closeEdit()},appendEditValue:t=>!!this.revogrEdit&&!this.revogrEdit.dispatchEvent(new CustomEvent("internalappendeditvalue",{cancelable:!0,detail:t})),clearCell:()=>!this.readonly&&this.clearCell(),internalPaste:()=>!this.readonly&&this.beforeRegionPaste.emit(),getData:()=>this.getData(),selectAll:()=>this.selectAll.emit()}),this.unsubscribeSelectionStore.push(t.onChange("focus",(()=>{var t;return null===(t=this.keyboardService)||void 0===t?void 0:t.invalidatePendingChanges()})),t.onChange("edit",(()=>{var t;return null===(t=this.keyboardService)||void 0===t?void 0:t.invalidatePendingChanges()}))),this.createAutoFillService()}createAutoFillService(){this.autoFillService=new N({dimensionRow:this.dimensionRow,dimensionCol:this.dimensionCol,columnService:this.columnService,dataStore:this.dataStore,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)})),setTempRange:t=>{const e=this.beforeSetTempRange.emit(Object.assign(Object.assign({tempRange:t},this.getData()),this.types));return e.defaultPrevented?null:this.setTempRange.emit(e.detail.tempRange)},selectionChanged:t=>this.selectionChange.emit(t),rangeCopy:t=>this.beforeRangeCopyApply.emit(t),rangeDataApply:t=>this.rangeEditApply.emit(t),setRange:t=>!!t&&this.triggerRangeEvent(t),getData:()=>this.getData()})}columnServiceSet(){var t;null===(t=this.columnService)||void 0===t||t.destroy(),this.columnService=new a(this.dataStore,this.colData),this.createAutoFillService()}connectedCallback(){this.columnServiceSet(),this.selectionServiceSet(this.selectionStore)}disconnectedCallback(){var t,e;null===(t=this.keyboardService)||void 0===t||t.invalidatePendingChanges(),this.unsubscribeSelectionStore.forEach((t=>t())),this.unsubscribeSelectionStore.length=0,null===(e=this.columnService)||void 0===e||e.destroy()}async componentWillRender(){var t,e;this.selectionStore.get("edit")||await(null===(e=null===(t=this.revogrEdit)||void 0===t?void 0:t.beforeDisconnect)||void 0===e?void 0:e.call(t))}renderRange(e){const i=y(e,this.dimensionRow.state,this.dimensionCol.state),s=O(i);return t("div",{class:p,style:s},this.isMobileDevice&&t("div",{class:"range-handlers"},t("span",{class:g}),t("span",{class:g})))}renderEditor(){const e=this.selectionStore.get("edit");if(this.readonly||!e)return null;const i=e.val||l(this.columnService.rowDataModel(e.y,e.x).value),s=Object.assign(Object.assign({},e),this.columnService.getSaveData(e.y,e.x,i)),o=this.beforeEditRender.emit(Object.assign(Object.assign({range:Object.assign(Object.assign({},e),{x1:e.x,y1:e.y})},this.types),{rowDimension:Object.assign({},this.dimensionRow.state),colDimension:Object.assign({},this.dimensionCol.state)}));if(o.defaultPrevented)return null;const n=y(o.detail.range,o.detail.rowDimension,o.detail.colDimension),r=O(n);return t("revogr-edit",{style:r,ref:t=>this.revogrEdit=t,additionalData:this.additionalData,editCell:s,saveOnClose:this.applyChangesOnClose,onCelleditinit:t=>{this.cellEditDone.emit(t.detail)},column:this.columnService.rowDataModel(e.y,e.x),editor:h(this.columnService.columns[e.x],this.editors)})}onEditCell(t){if(t.defaultPrevented)return;const e=this.beforeCellSave.emit(t.detail);e.defaultPrevented||this.cellEdit(e.detail),e.detail.preventFocus||this.focusNext()}render(){var e;const i=[],s=this.renderEditor();if(s)i.push(s);else{const s=this.selectionStore.get("range"),o=this.selectionStore.get("focus");(s||o)&&this.useClipboard&&i.push(t("revogr-clipboard",{readonly:this.readonly,onCopyregion:t=>this.onCopy(t.detail),onClearregion:()=>!this.readonly&&this.clearCell(),ref:t=>this.clipboard=t,onPasteregion:t=>this.onPaste(t.detail)})),s&&i.push(this.renderRange(s)),o&&!this.readonly&&this.range&&i.push(null===(e=this.autoFillService)||void 0===e?void 0:e.renderAutofill(s,o,this.isMobileDevice)),this.canDrag&&i.push(t("revogr-order-editor",{ref:t=>this.orderEditor=t,dataStore:this.dataStore,dimensionRow:this.dimensionRow,dimensionCol:this.dimensionCol,parent:this.element,rowType:this.types.rowType,onRowdragstartinit:t=>this.rowDragStart(t)}))}return t(o,{key:"84d904c108e39ebf82b215afc7052d634eba677e",class:{mobile:this.isMobileDevice},onDblClick:t=>this.onElementDblClick(t),onMouseDown:t=>this.onElementMouseDown(t),onTouchStart:t=>this.onElementMouseDown(t,!0),onCloseedit:t=>this.closeEdit(t),onCelledit:t=>this.onEditCell(t)},i,t("slot",{key:"7434c5fceb445de4510675b7627bb5f2efc1a365",name:"data"}))}doFocus(t,e,i,s){const{defaultPrevented:o}=this.beforeFocusCell.emit(Object.assign(Object.assign({},this.columnService.getSaveData(t.y,t.x)),{originalEvent:s}));if(o)return!1;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);if(r.defaultPrevented)return!1;const{range:a}=r.detail;return!this.focusCell.emit(Object.assign({focus:{x:a.x,y:a.y},end:{x:a.x1,y:a.y1}},r.detail)).defaultPrevented}triggerRangeEvent(t,e){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}));if(s.defaultPrevented)return!1;const o=this.columnService.getRangeTransformedToProps(s.detail.range,this.dataStore);let n=this.beforeSetRange.emit(o);return!n.defaultPrevented&&(n=this.setRange.emit(Object.assign(Object.assign({},s.detail.range),{type:i})),!n.defaultPrevented&&!n.defaultPrevented)}onElementDblClick(t){if(t.defaultPrevented)return;const e=this.getData();S(t,e)&&this.doEdit()}onElementMouseDown(t,e=!1){var i;const s=t.target;if(k(s)||t.defaultPrevented)return;const o=this.getData(),n=S(t,o);n&&(this.focus(n,this.range&&t.shiftKey,t),this.range&&(s&&(null===(i=this.autoFillService)||void 0===i||i.selectionStart(s,this.getData())),e?C(t.touches[0],g)&&t.preventDefault():t.preventDefault()))}doEdit(t=""){if(!this.canEdit())return!1;const e=this.selectionStore.get("focus");if(!e)return!1;const i=this.columnService.getSaveData(e.y,e.x);return!this.setEdit.emit(Object.assign(Object.assign({},i),{val:t})).defaultPrevented}async closeEdit(t){this.cancelEdit.emit(),(null==t?void 0:t.detail)&&await this.focusNext()}cellEdit(t){const e=this.columnService.getSaveData(t.rgRow,t.rgCol,t.val);this.cellEditApply.emit(e)}getRegion(){const t=this.selectionStore.get("focus");let e=this.selectionStore.get("range");return e||(e=r(t,t)),e}onCopy(t){var e;const i=this.getRegion();if(this.beforeCopyRegion.emit(i).defaultPrevented)return!1;let s;if(i){const{data:t,mapping:e}=this.columnService.copyRangeArray(i,this.dataStore),o=this.rangeClipboardCopy.emit(Object.assign({range:i,data:t,mapping:e},this.types));o.defaultPrevented||(s=o.detail.data)}return null===(e=this.clipboard)||void 0===e||e.doCopy(t,s),!0}onPaste(t){var e;const i=this.selectionStore.get("focus"),s=null!==this.selectionStore.get("edit");if(!i||s)return;const o=function(t,e){var i;if(!function(t){return"object"==typeof t&&!0===t.rangeFill}(e))return null;const s=function(t){const e=[...t];for(;e.length>1&&(!(i=e[e.length-1])||i.every((t=>""===t)));)e.pop();var i;return e}(t);return 1===s.length&&1===(null===(i=s[0])||void 0===i?void 0:i.length)?s:null}(t,this.useClipboard),n=o?this.getClipboardPasteTargetRange():null;let{changed:r,range:a}=this.columnService.getTransformedDataToApply({start:i,data:o||t,targetRange:n});const{defaultPrevented:l}=this.rangeClipboardPaste.emit(Object.assign({data:r,models:w(r,this.dataStore),range:a},this.types));l||null===(e=this.autoFillService)||void 0===e||e.onRangeApply(r,a,a)}getClipboardPasteTargetRange(){const t=this.selectionStore.get("range");return t&&!c(t)?t:null}async focusNext(){var t;await(null===(t=this.keyboardService)||void 0===t?void 0:t.keyChangeSelection(new KeyboardEvent("keydown",{code:d.ARROW_DOWN}),this.range))||this.closeEdit()}clearCell(){var t;const e=this.selectionStore.get("range"),i=this.selectionStore.get("focus");if(!e||c(e)&&i){if(this.canEdit()){if(!i)return;const t=this.columnService.getSaveData(i.y,i.x);this.cellEdit({rgRow:i.y,rgCol:i.x,val:"",type:t.type,prop:t.prop})}}else{const i=this.columnService.getRangeStaticData(e,"");null===(t=this.autoFillService)||void 0===t||t.onRangeApply(i,e,e)}}rowDragStart({detail:t}){t.text=l(this.columnService.rowDataModel(t.cell.y,t.cell.x).value)}canEdit(){var t;if(this.readonly)return!1;const e=this.selectionStore.get("focus");return e&&!(null===(t=this.columnService)||void 0===t?void 0:t.isReadOnly(e.y,e.x))}get edited(){return this.selectionStore.get("edit")}focus(t,e=!1,i){if(!t)return!1;const s=t,o=this.selectionStore.get("focus");if(e&&o){const t=r(o,s);if(t)return this.triggerRangeEvent(t,i)}return this.doFocus(t,s,void 0,i)}get types(){return{rowType:this.dataStore.get("type"),colType:this.columnService.type}}getData(){return{el:this.element,rows:this.dimensionRow.state,cols:this.dimensionCol.state,lastCell:this.lastCell,focus:this.selectionStore.get("focus"),range:this.selectionStore.get("range"),edit:this.selectionStore.get("edit")}}get element(){return this}static get watchers(){return{selectionStore:[{selectionServiceSet:0}],dimensionRow:[{createAutoFillService:0}],dimensionCol:[{createAutoFillService:0}],dataStore:[{columnServiceSet:0}],colData:[{columnServiceSet:0}]}}static get style(){return'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:var(--rg-theme-autofill-handle-bg);border:1px solid var(--rg-theme-autofill-handle-border);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:var(--rg-theme-autofill-handle-bg);border:1px solid var(--rg-theme-autofill-handle-border);box-sizing:border-box}revogr-overlay-selection .selection-border-range{position:absolute;pointer-events:none;z-index:9;background-color:var(--rg-theme-selection-bg)}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:var(--rg-theme-range-handle-bg)}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 .selection-border-range{box-shadow:-1px 0 0 var(--rg-theme-selection-border) inset, 1px 0 0 var(--rg-theme-selection-border) inset, 0 -1px 0 var(--rg-theme-selection-border) inset, 0 1px 0 var(--rg-theme-selection-border) inset}revogr-overlay-selection revogr-edit{z-index:10}'}},[260,"revogr-overlay-selection",{readonly:[4],range:[4],canDrag:[4,"can-drag"],useClipboard:[4,"use-clipboard"],selectionStore:[16],dimensionRow:[16],dimensionCol:[16],dataStore:[16],colData:[16],lastCell:[16],editors:[16],applyChangesOnClose:[4,"apply-changes-on-close"],additionalData:[8,"additional-data"],isMobileDevice:[4,"is-mobile-device"]},[[5,"touchmove","onMouseMove"],[5,"mousemove","onMouseMove"],[5,"touchend","onMouseUp"],[5,"mouseup","onMouseUp"],[5,"mouseleave","onMouseUp"],[0,"dragstartcell","onCellDrag"],[4,"keyup","onKeyUp"],[4,"keydown","onKeyDown"]],{selectionStore:[{selectionServiceSet:0}],dimensionRow:[{createAutoFillService:0}],dimensionCol:[{createAutoFillService:0}],dataStore:[{columnServiceSet:0}],colData:[{columnServiceSet:0}]}]);function W(){"undefined"!=typeof customElements&&["revogr-overlay-selection","revogr-clipboard","revogr-edit","revogr-order-editor"].forEach((t=>{switch(t){case"revogr-overlay-selection":customElements.get(n(t))||customElements.define(n(t),V);break;case"revogr-clipboard":customElements.get(n(t))||X();break;case"revogr-edit":customElements.get(n(t))||z();break;case"revogr-order-editor":customElements.get(n(t))||$()}}))}export{V as O,W as d}
|