@searsuite/sear-plugin-selection 0.0.0-stage → 0.0.1
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/LICENSE +29 -0
- package/README.md +8 -2
- package/dist/AnalyzeSheetRangeMove.d.ts +5 -0
- package/dist/AnalyzeSheetRangeMove.d.ts.map +1 -0
- package/dist/AnalyzeSheetRangeMove.js +7 -0
- package/dist/AnalyzeSheetRangeMove.js.map +1 -0
- package/dist/GetActiveCell.d.ts +3 -0
- package/dist/GetActiveCell.d.ts.map +1 -0
- package/dist/GetActiveCell.js +7 -0
- package/dist/GetActiveCell.js.map +1 -0
- package/dist/SheetAxisDrag.d.ts +15 -0
- package/dist/SheetAxisDrag.d.ts.map +1 -0
- package/dist/SheetAxisDrag.js +42 -0
- package/dist/SheetAxisDrag.js.map +1 -0
- package/dist/SheetDragAxis.d.ts +7 -0
- package/dist/SheetDragAxis.d.ts.map +1 -0
- package/dist/SheetDragAxis.js +6 -0
- package/dist/SheetDragAxis.js.map +1 -0
- package/dist/SheetFillRangeCommand.d.ts +18 -0
- package/dist/SheetFillRangeCommand.d.ts.map +1 -0
- package/dist/SheetFillRangeCommand.js +114 -0
- package/dist/SheetFillRangeCommand.js.map +1 -0
- package/dist/SheetFillSeries.d.ts +7 -0
- package/dist/SheetFillSeries.d.ts.map +1 -0
- package/dist/SheetFillSeries.js +46 -0
- package/dist/SheetFillSeries.js.map +1 -0
- package/dist/SheetHighlightPipelineNames.d.ts +5 -0
- package/dist/SheetHighlightPipelineNames.d.ts.map +1 -0
- package/dist/SheetHighlightPipelineNames.js +9 -0
- package/dist/SheetHighlightPipelineNames.js.map +1 -0
- package/dist/SheetHighlightRegistry.d.ts +67 -0
- package/dist/SheetHighlightRegistry.d.ts.map +1 -0
- package/dist/SheetHighlightRegistry.js +114 -0
- package/dist/SheetHighlightRegistry.js.map +1 -0
- package/dist/SheetRangeDrag.d.ts +54 -0
- package/dist/SheetRangeDrag.d.ts.map +1 -0
- package/dist/SheetRangeDrag.js +631 -0
- package/dist/SheetRangeDrag.js.map +1 -0
- package/dist/SheetRangeDragCommand.d.ts +19 -0
- package/dist/SheetRangeDragCommand.d.ts.map +1 -0
- package/dist/SheetRangeDragCommand.js +15 -0
- package/dist/SheetRangeDragCommand.js.map +1 -0
- package/dist/SheetRangeMoveCommands.d.ts +12 -0
- package/dist/SheetRangeMoveCommands.d.ts.map +1 -0
- package/dist/SheetRangeMoveCommands.js +8 -0
- package/dist/SheetRangeMoveCommands.js.map +1 -0
- package/dist/SheetRangeMoveError.d.ts +12 -0
- package/dist/SheetRangeMoveError.d.ts.map +1 -0
- package/dist/SheetRangeMoveError.js +18 -0
- package/dist/SheetRangeMoveError.js.map +1 -0
- package/dist/SheetSelectionCommands.d.ts +52 -0
- package/dist/SheetSelectionCommands.d.ts.map +1 -0
- package/dist/SheetSelectionCommands.js +29 -0
- package/dist/SheetSelectionCommands.js.map +1 -0
- package/dist/SheetSelectionInteractionReducer.d.ts +13 -0
- package/dist/SheetSelectionInteractionReducer.d.ts.map +1 -0
- package/dist/SheetSelectionInteractionReducer.js +21 -0
- package/dist/SheetSelectionInteractionReducer.js.map +1 -0
- package/dist/SheetSelectionPipelineNames.d.ts +21 -0
- package/dist/SheetSelectionPipelineNames.d.ts.map +1 -0
- package/dist/SheetSelectionPipelineNames.js +28 -0
- package/dist/SheetSelectionPipelineNames.js.map +1 -0
- package/dist/SheetSelectionPointerCommand.d.ts +29 -0
- package/dist/SheetSelectionPointerCommand.d.ts.map +1 -0
- package/dist/SheetSelectionPointerCommand.js +15 -0
- package/dist/SheetSelectionPointerCommand.js.map +1 -0
- package/dist/SheetSelectionRenderSemantics.d.ts +6 -0
- package/dist/SheetSelectionRenderSemantics.d.ts.map +1 -0
- package/dist/SheetSelectionRenderSemantics.js +9 -0
- package/dist/SheetSelectionRenderSemantics.js.map +1 -0
- package/dist/createRangeMovePreview.d.ts +5 -0
- package/dist/createRangeMovePreview.d.ts.map +1 -0
- package/dist/createRangeMovePreview.js +21 -0
- package/dist/createRangeMovePreview.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +88 -0
- package/dist/index.js.map +1 -0
- package/dist/resolveAxisInsertionBoundary.d.ts +4 -0
- package/dist/resolveAxisInsertionBoundary.d.ts.map +1 -0
- package/dist/resolveAxisInsertionBoundary.js +16 -0
- package/dist/resolveAxisInsertionBoundary.js.map +1 -0
- package/dist/resolveSheetRangeMove.d.ts +5 -0
- package/dist/resolveSheetRangeMove.d.ts.map +1 -0
- package/dist/resolveSheetRangeMove.js +24 -0
- package/dist/resolveSheetRangeMove.js.map +1 -0
- package/dist/sheetHighlight/SheetHighlightPlugin.d.ts +30 -0
- package/dist/sheetHighlight/SheetHighlightPlugin.d.ts.map +1 -0
- package/dist/sheetHighlight/SheetHighlightPlugin.js +113 -0
- package/dist/sheetHighlight/SheetHighlightPlugin.js.map +1 -0
- package/dist/sheetSelection/SheetSelectionPlugin.d.ts +150 -0
- package/dist/sheetSelection/SheetSelectionPlugin.d.ts.map +1 -0
- package/dist/sheetSelection/SheetSelectionPlugin.js +1652 -0
- package/dist/sheetSelection/SheetSelectionPlugin.js.map +1 -0
- package/package.json +65 -3
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
9
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
21
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
22
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
23
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
24
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
25
|
+
};
|
|
26
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
27
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
28
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
29
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
30
|
+
};
|
|
31
|
+
var _SheetRangeDrag_instances, _SheetRangeDrag_core, _SheetRangeDrag_readSelection, _SheetRangeDrag_session, _SheetRangeDrag_disposeCapture, _SheetRangeDrag_disposers, _SheetRangeDrag_frame, _SheetRangeDrag_generation, _SheetRangeDrag_suppressDoubleClick, _SheetRangeDrag_destroyed, _SheetRangeDrag_interaction, _SheetRangeDrag_commands, _SheetRangeDrag_ownerToken, _SheetRangeDrag_applyInput, _SheetRangeDrag_begin, _SheetRangeDrag_update, _SheetRangeDrag_scheduleScroll, _SheetRangeDrag_advanceScroll, _SheetRangeDrag_finish, _SheetRangeDrag_clearGesture, _SheetRangeDrag_cancel;
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.SheetRangeDrag = void 0;
|
|
34
|
+
const sear_foundation_di_1 = require("@searsuite/sear-foundation-di");
|
|
35
|
+
const sear_foundation_platform_1 = require("@searsuite/sear-foundation-platform");
|
|
36
|
+
const sear_assembly_plugin_1 = require("@searsuite/sear-assembly-plugin");
|
|
37
|
+
const sear_foundation_error_1 = require("@searsuite/sear-foundation-error");
|
|
38
|
+
const sear_domain_cell_types_1 = require("@searsuite/sear-domain-cell-types");
|
|
39
|
+
const sear_plugin_cell_merge_1 = require("@searsuite/sear-plugin-cell-merge");
|
|
40
|
+
const sear_assembly_commands_1 = require("@searsuite/sear-assembly-commands");
|
|
41
|
+
const sear_assembly_core_1 = require("@searsuite/sear-assembly-core");
|
|
42
|
+
const sear_assembly_plugin_2 = require("@searsuite/sear-assembly-plugin");
|
|
43
|
+
const sear_render_coord_1 = require("@searsuite/sear-render-coord");
|
|
44
|
+
const sear_render_cursor_1 = require("@searsuite/sear-render-cursor");
|
|
45
|
+
const sear_render_input_1 = require("@searsuite/sear-render-input");
|
|
46
|
+
const sear_render_engine_1 = require("@searsuite/sear-render-engine");
|
|
47
|
+
const sear_render_registry_1 = require("@searsuite/sear-render-registry");
|
|
48
|
+
const SheetHighlightRegistry_1 = require("./SheetHighlightRegistry");
|
|
49
|
+
const SheetDragAxis_1 = require("./SheetDragAxis");
|
|
50
|
+
const resolveAxisInsertionBoundary_1 = require("./resolveAxisInsertionBoundary");
|
|
51
|
+
const SheetAxisDrag_1 = require("./SheetAxisDrag");
|
|
52
|
+
const SheetRangeMoveCommands_1 = require("./SheetRangeMoveCommands");
|
|
53
|
+
const AnalyzeSheetRangeMove_1 = require("./AnalyzeSheetRangeMove");
|
|
54
|
+
const createRangeMovePreview_1 = require("./createRangeMovePreview");
|
|
55
|
+
const SheetRangeDragCommand_1 = require("./SheetRangeDragCommand");
|
|
56
|
+
const SheetFillRangeCommand_1 = require("./SheetFillRangeCommand");
|
|
57
|
+
const SheetSelectionCommands_1 = require("./SheetSelectionCommands");
|
|
58
|
+
/** Owns one local range-border gesture; document changes enter through the move command. */
|
|
59
|
+
let SheetRangeDrag = class SheetRangeDrag {
|
|
60
|
+
constructor(commands, queries, coordinates, pointer, keyboard, cursorRules, cursor, highlights, platform, interactions, inputValidation, cellCodecs, formats, ownerData) {
|
|
61
|
+
_SheetRangeDrag_instances.add(this);
|
|
62
|
+
this.queries = queries;
|
|
63
|
+
this.coordinates = coordinates;
|
|
64
|
+
this.pointer = pointer;
|
|
65
|
+
this.keyboard = keyboard;
|
|
66
|
+
this.cursorRules = cursorRules;
|
|
67
|
+
this.cursor = cursor;
|
|
68
|
+
this.highlights = highlights;
|
|
69
|
+
this.platform = platform;
|
|
70
|
+
this.interactions = interactions;
|
|
71
|
+
this.inputValidation = inputValidation;
|
|
72
|
+
this.cellCodecs = cellCodecs;
|
|
73
|
+
this.formats = formats;
|
|
74
|
+
this.ownerData = ownerData;
|
|
75
|
+
_SheetRangeDrag_core.set(this, null);
|
|
76
|
+
_SheetRangeDrag_readSelection.set(this, null);
|
|
77
|
+
_SheetRangeDrag_session.set(this, null);
|
|
78
|
+
_SheetRangeDrag_disposeCapture.set(this, null);
|
|
79
|
+
_SheetRangeDrag_disposers.set(this, []);
|
|
80
|
+
_SheetRangeDrag_frame.set(this, null);
|
|
81
|
+
_SheetRangeDrag_generation.set(this, 0);
|
|
82
|
+
_SheetRangeDrag_suppressDoubleClick.set(this, false);
|
|
83
|
+
_SheetRangeDrag_destroyed.set(this, false);
|
|
84
|
+
_SheetRangeDrag_interaction.set(this, void 0);
|
|
85
|
+
_SheetRangeDrag_commands.set(this, void 0);
|
|
86
|
+
_SheetRangeDrag_ownerToken.set(this, null);
|
|
87
|
+
this.escape = () => {
|
|
88
|
+
if (!__classPrivateFieldGet(this, _SheetRangeDrag_destroyed, "f"))
|
|
89
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_commands, "f").run(SheetRangeDragCommand_1.HandleSheetRangeDragCommand, { action: SheetRangeDragCommand_1.SheetRangeDragAction.Cancel });
|
|
90
|
+
};
|
|
91
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_commands, commands, "f");
|
|
92
|
+
}
|
|
93
|
+
/** Binds the optional host-owned confirmation service during assembly. */
|
|
94
|
+
setUserInteraction(service) {
|
|
95
|
+
if (__classPrivateFieldGet(this, _SheetRangeDrag_ownerToken, "f"))
|
|
96
|
+
throw new sear_foundation_error_1.SearError('Sheet range drag interaction is already bound to an editor.');
|
|
97
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_interaction, service, "f");
|
|
98
|
+
}
|
|
99
|
+
/** Routes local pointer and animation inputs through the editor command boundary. */
|
|
100
|
+
registerCommands(commands) {
|
|
101
|
+
if (commands !== __classPrivateFieldGet(this, _SheetRangeDrag_commands, "f"))
|
|
102
|
+
throw new sear_foundation_error_1.SearError('Sheet range drag commands are already bound to an editor.');
|
|
103
|
+
(0, SheetFillRangeCommand_1.registerSheetFillRangeCommand)(commands, this.queries, this.inputValidation, this.cellCodecs, () => __classPrivateFieldGet(this, _SheetRangeDrag_core, "f") ? (0, sear_plugin_cell_merge_1.readSheetCellMerges)(__classPrivateFieldGet(this, _SheetRangeDrag_core, "f").getDataEngine()) : null, () => __classPrivateFieldGet(this, _SheetRangeDrag_core, "f") ? (0, sear_render_engine_1.readSheetRowVisibility)(__classPrivateFieldGet(this, _SheetRangeDrag_core, "f").getDataEngine()) : null, this.formats, this.ownerData);
|
|
104
|
+
commands.register(SheetRangeDragCommand_1.HandleSheetRangeDragCommand, (input) => new sear_assembly_commands_1.LocalActionCommand(SheetRangeDragCommand_1.HandleSheetRangeDragCommand.id, () => __classPrivateFieldGet(this, _SheetRangeDrag_instances, "m", _SheetRangeDrag_applyInput).call(this, input)));
|
|
105
|
+
}
|
|
106
|
+
/** Installs editor-local cursor and preview contributions once Core is available. */
|
|
107
|
+
bind(core, readSelection, ownerToken) {
|
|
108
|
+
if (__classPrivateFieldGet(this, _SheetRangeDrag_ownerToken, "f") || __classPrivateFieldGet(this, _SheetRangeDrag_destroyed, "f"))
|
|
109
|
+
throw new sear_foundation_error_1.SearError('Sheet range drag is already bound to an editor.');
|
|
110
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_ownerToken, ownerToken, "f");
|
|
111
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_core, core, "f");
|
|
112
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_readSelection, readSelection, "f");
|
|
113
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_disposers, "f").push(this.cursorRules.registerPosition({
|
|
114
|
+
key: 'sheet.selection.fill-handle',
|
|
115
|
+
layer: 95,
|
|
116
|
+
cursor: sear_render_cursor_1.CursorToken.Copy,
|
|
117
|
+
test: ({ world, view, target }) => (target === null || target === void 0 ? void 0 : target.region) === sear_render_registry_1.CellRegion.Grid && this.hitsFillHandle(world, view),
|
|
118
|
+
}));
|
|
119
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_disposers, "f").push(this.cursorRules.registerPosition({
|
|
120
|
+
key: 'sheet.selection.move',
|
|
121
|
+
layer: 90,
|
|
122
|
+
cursor: sear_render_cursor_1.CursorToken.Grab,
|
|
123
|
+
test: ({ world, view, target }) => ((target === null || target === void 0 ? void 0 : target.region) === sear_render_registry_1.CellRegion.Grid && this.hitsBorder(world, view)) ||
|
|
124
|
+
this.hitsSelectedHeader(world, view, target === null || target === void 0 ? void 0 : target.region),
|
|
125
|
+
}));
|
|
126
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_disposers, "f").push(this.highlights.register({
|
|
127
|
+
key: 'sheet.selection.move-preview',
|
|
128
|
+
getHighlights: () => {
|
|
129
|
+
const session = __classPrivateFieldGet(this, _SheetRangeDrag_session, "f");
|
|
130
|
+
if (!session)
|
|
131
|
+
return [];
|
|
132
|
+
if (session.mode === 'fill')
|
|
133
|
+
return [{
|
|
134
|
+
start: [Math.min(session.source.start[0], session.target[0]), Math.min(session.source.start[1], session.target[1])],
|
|
135
|
+
end: [Math.max(session.source.end[0], session.target[0]), Math.max(session.source.end[1], session.target[1])],
|
|
136
|
+
stroke: '#16834b', strokeWidth: 2, fill: 'rgba(22, 131, 75, 0.08)', skipHit: true,
|
|
137
|
+
}];
|
|
138
|
+
if (session.axis !== null) {
|
|
139
|
+
const geometry = this.geometry();
|
|
140
|
+
return [
|
|
141
|
+
(0, SheetAxisDrag_1.createAxisDragHighlight)(Object.assign(Object.assign({}, session), { axis: session.axis }), geometry.rows.shape[1], geometry.columns.shape[1]),
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
return session.analysis ? [(0, createRangeMovePreview_1.createRangeMovePreview)(session.analysis)] : [];
|
|
145
|
+
},
|
|
146
|
+
}));
|
|
147
|
+
this.keyboard.subscribe({ onEscape: this.escape });
|
|
148
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_disposers, "f").push(__classPrivateFieldGet(this, _SheetRangeDrag_commands, "f").subscribe((event) => {
|
|
149
|
+
var _a;
|
|
150
|
+
if ((_a = event.result) === null || _a === void 0 ? void 0 : _a.pipeline.steps.some((step) => { var _a; return (_a = step.transaction) === null || _a === void 0 ? void 0 : _a.operations.length; })) {
|
|
151
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_commands, "f").run(SheetRangeDragCommand_1.HandleSheetRangeDragCommand, { action: SheetRangeDragCommand_1.SheetRangeDragAction.Cancel });
|
|
152
|
+
}
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
isActive() {
|
|
156
|
+
return __classPrivateFieldGet(this, _SheetRangeDrag_session, "f") !== null;
|
|
157
|
+
}
|
|
158
|
+
/** Starts on selection borders or already selected axis headers. */
|
|
159
|
+
onMouseDown(event) {
|
|
160
|
+
var _a, _b, _c, _d, _e;
|
|
161
|
+
if (!__classPrivateFieldGet(this, _SheetRangeDrag_core, "f") || __classPrivateFieldGet(this, _SheetRangeDrag_destroyed, "f") || !event.target)
|
|
162
|
+
return false;
|
|
163
|
+
if (((_b = (_a = event.clickCount) !== null && _a !== void 0 ? _a : event.origin.detail) !== null && _b !== void 0 ? _b : 0) < 2)
|
|
164
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_suppressDoubleClick, false, "f");
|
|
165
|
+
const { offsetX, offsetY } = event.origin;
|
|
166
|
+
const world = this.coordinates.screenToWorld(offsetX, offsetY);
|
|
167
|
+
const view = this.coordinates.screenToView(offsetX, offsetY);
|
|
168
|
+
const target = event.target.properties;
|
|
169
|
+
if (target.region === sear_render_registry_1.CellRegion.Grid) {
|
|
170
|
+
if (this.hitsFillHandle(world, view)) {
|
|
171
|
+
if (((_d = (_c = event.clickCount) !== null && _c !== void 0 ? _c : event.origin.detail) !== null && _d !== void 0 ? _d : 0) >= 2) {
|
|
172
|
+
this.onFillHandleDoubleClick(event);
|
|
173
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_suppressDoubleClick, true, "f");
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_commands, "f").run(SheetRangeDragCommand_1.HandleSheetRangeDragCommand, {
|
|
177
|
+
action: SheetRangeDragCommand_1.SheetRangeDragAction.FillBegin,
|
|
178
|
+
point: { view: { x: offsetX, y: offsetY } },
|
|
179
|
+
});
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
if (!this.hitsBorder(world, view))
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
if (!this.hitsSelectedHeader(world, view, target.region))
|
|
187
|
+
return false;
|
|
188
|
+
// Higher-layer handle rules keep resize and hidden-marker gestures available.
|
|
189
|
+
const properties = Object.assign(Object.assign({}, target), { type: (_e = target.type) !== null && _e !== void 0 ? _e : sear_render_registry_1.CellRenderType.Affix });
|
|
190
|
+
if (this.cursorRules.resolve(properties, {
|
|
191
|
+
core: __classPrivateFieldGet(this, _SheetRangeDrag_core, "f"),
|
|
192
|
+
origin: event.origin,
|
|
193
|
+
world,
|
|
194
|
+
view,
|
|
195
|
+
target: properties,
|
|
196
|
+
}) !== sear_render_cursor_1.CursorToken.Grab)
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_commands, "f").run(SheetRangeDragCommand_1.HandleSheetRangeDragCommand, {
|
|
200
|
+
action: SheetRangeDragCommand_1.SheetRangeDragAction.Begin,
|
|
201
|
+
point: { view: { x: offsetX, y: offsetY } },
|
|
202
|
+
});
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
/** Fills down to the end of a continuous adjacent column when the handle is double-clicked. */
|
|
206
|
+
onFillHandleDoubleClick(event) {
|
|
207
|
+
var _a;
|
|
208
|
+
if (__classPrivateFieldGet(this, _SheetRangeDrag_suppressDoubleClick, "f")) {
|
|
209
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_suppressDoubleClick, false, "f");
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
if (!__classPrivateFieldGet(this, _SheetRangeDrag_core, "f") || !__classPrivateFieldGet(this, _SheetRangeDrag_readSelection, "f") || ((_a = event.target) === null || _a === void 0 ? void 0 : _a.properties.region) !== sear_render_registry_1.CellRegion.Grid)
|
|
213
|
+
return false;
|
|
214
|
+
const { offsetX, offsetY } = event.origin;
|
|
215
|
+
if (!this.hitsFillHandle(this.coordinates.screenToWorld(offsetX, offsetY), this.coordinates.screenToView(offsetX, offsetY)))
|
|
216
|
+
return false;
|
|
217
|
+
const range = __classPrivateFieldGet(this, _SheetRangeDrag_readSelection, "f").call(this);
|
|
218
|
+
const source = { start: [...range.getPoint(0)], end: [...range.getPoint(1)] };
|
|
219
|
+
const cells = this.queries.run(sear_render_engine_1.ReadSheetCellDataQuery, void 0);
|
|
220
|
+
const adjacent = [source.start[1] - 1, source.end[1] + 1].find((col) => col >= 0 && col < cells.shape[1] && cells.getItem(source.start[0], col));
|
|
221
|
+
if (adjacent === undefined)
|
|
222
|
+
return true;
|
|
223
|
+
let last = source.end[0];
|
|
224
|
+
while (last + 1 < cells.shape[0] && cells.getItem(last + 1, adjacent))
|
|
225
|
+
last++;
|
|
226
|
+
if (last > source.end[0]) {
|
|
227
|
+
try {
|
|
228
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_commands, "f").run(SheetFillRangeCommand_1.FillSheetRangeCommand, { source, target: [last, source.end[1]] });
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
void this.reportFillError(error);
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_commands, "f").run(SheetSelectionCommands_1.SelectRangeCommand, { anchor: source.start, focus: [last, source.end[1]] });
|
|
235
|
+
}
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
geometry() {
|
|
239
|
+
var _a, _b;
|
|
240
|
+
if (!__classPrivateFieldGet(this, _SheetRangeDrag_core, "f"))
|
|
241
|
+
return null;
|
|
242
|
+
const rows = (0, sear_render_engine_1.readSheetRowSizes)(__classPrivateFieldGet(this, _SheetRangeDrag_core, "f").getDataEngine());
|
|
243
|
+
const columns = (0, sear_render_engine_1.readSheetColumnSizes)(__classPrivateFieldGet(this, _SheetRangeDrag_core, "f").getDataEngine());
|
|
244
|
+
const config = __classPrivateFieldGet(this, _SheetRangeDrag_core, "f").configEngine.getDefaultConfig();
|
|
245
|
+
return rows && columns ? { rows, columns, x: (_a = config.sheetOffsetX) !== null && _a !== void 0 ? _a : 50, y: (_b = config.sheetOffsetY) !== null && _b !== void 0 ? _b : 24 } : null;
|
|
246
|
+
}
|
|
247
|
+
hitsBorder(world, view) {
|
|
248
|
+
var _a;
|
|
249
|
+
const geometry = this.geometry();
|
|
250
|
+
const range = (_a = __classPrivateFieldGet(this, _SheetRangeDrag_readSelection, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
251
|
+
if (!geometry || !range || range.getPoint(0)[0] < 0 || view.x <= geometry.x || view.y <= geometry.y)
|
|
252
|
+
return false;
|
|
253
|
+
if (this.interactions.getState().editSession)
|
|
254
|
+
return false;
|
|
255
|
+
const start = range.getPoint(0);
|
|
256
|
+
const end = range.getPoint(1);
|
|
257
|
+
if (start[0] === 0 &&
|
|
258
|
+
end[0] === geometry.rows.shape[1] - 1 &&
|
|
259
|
+
start[1] === 0 &&
|
|
260
|
+
end[1] === geometry.columns.shape[1] - 1)
|
|
261
|
+
return false;
|
|
262
|
+
const left = geometry.columns.getDimensionLeftBoundaryByIndex(start[1]) + geometry.x;
|
|
263
|
+
const right = geometry.columns.getDimensionRightBoundaryByIndex(end[1]) + geometry.x;
|
|
264
|
+
const top = geometry.rows.getDimensionLeftBoundaryByIndex(start[0]) + geometry.y;
|
|
265
|
+
const bottom = geometry.rows.getDimensionRightBoundaryByIndex(end[0]) + geometry.y;
|
|
266
|
+
const tolerance = 4;
|
|
267
|
+
const axis = this.selectedAxis();
|
|
268
|
+
if (axis === SheetDragAxis_1.SheetDragAxis.Row)
|
|
269
|
+
return Math.abs(world.y - top) <= tolerance || Math.abs(world.y - bottom) <= tolerance;
|
|
270
|
+
if (axis === SheetDragAxis_1.SheetDragAxis.Column)
|
|
271
|
+
return Math.abs(world.x - left) <= tolerance || Math.abs(world.x - right) <= tolerance;
|
|
272
|
+
return ((world.x >= left - tolerance &&
|
|
273
|
+
world.x <= right + tolerance &&
|
|
274
|
+
(Math.abs(world.y - top) <= tolerance || Math.abs(world.y - bottom) <= tolerance)) ||
|
|
275
|
+
(world.y >= top - tolerance &&
|
|
276
|
+
world.y <= bottom + tolerance &&
|
|
277
|
+
(Math.abs(world.x - left) <= tolerance || Math.abs(world.x - right) <= tolerance)));
|
|
278
|
+
}
|
|
279
|
+
hitsFillHandle(world, view) {
|
|
280
|
+
var _a;
|
|
281
|
+
const geometry = this.geometry();
|
|
282
|
+
const range = (_a = __classPrivateFieldGet(this, _SheetRangeDrag_readSelection, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
283
|
+
if (!geometry || !range || range.getPoint(0)[0] < 0 || view.x <= geometry.x || view.y <= geometry.y)
|
|
284
|
+
return false;
|
|
285
|
+
if (this.interactions.getState().editSession || this.selectedAxis() !== null)
|
|
286
|
+
return false;
|
|
287
|
+
const end = range.getPoint(1);
|
|
288
|
+
const right = geometry.columns.getDimensionRightBoundaryByIndex(end[1]) + geometry.x;
|
|
289
|
+
const bottom = geometry.rows.getDimensionRightBoundaryByIndex(end[0]) + geometry.y;
|
|
290
|
+
return Math.abs(world.x - right) <= 6 && Math.abs(world.y - bottom) <= 6;
|
|
291
|
+
}
|
|
292
|
+
selectedAxis() {
|
|
293
|
+
var _a;
|
|
294
|
+
const geometry = this.geometry();
|
|
295
|
+
const selection = (_a = __classPrivateFieldGet(this, _SheetRangeDrag_readSelection, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
296
|
+
if (!geometry || !selection)
|
|
297
|
+
return null;
|
|
298
|
+
const start = selection.getPoint(0);
|
|
299
|
+
const end = selection.getPoint(1);
|
|
300
|
+
if (start[0] < 0 || start[1] < 0)
|
|
301
|
+
return null;
|
|
302
|
+
if (start[0] === 0 &&
|
|
303
|
+
end[0] === geometry.rows.shape[1] - 1 &&
|
|
304
|
+
start[1] === 0 &&
|
|
305
|
+
end[1] === geometry.columns.shape[1] - 1)
|
|
306
|
+
return null;
|
|
307
|
+
if (start[1] === 0 && end[1] === geometry.columns.shape[1] - 1)
|
|
308
|
+
return SheetDragAxis_1.SheetDragAxis.Row;
|
|
309
|
+
if (start[0] === 0 && end[0] === geometry.rows.shape[1] - 1)
|
|
310
|
+
return SheetDragAxis_1.SheetDragAxis.Column;
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
hitsSelectedHeader(world, view, region) {
|
|
314
|
+
var _a;
|
|
315
|
+
const geometry = this.geometry();
|
|
316
|
+
const selection = (_a = __classPrivateFieldGet(this, _SheetRangeDrag_readSelection, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
317
|
+
const axis = this.selectedAxis();
|
|
318
|
+
if (!geometry || !selection || axis === null || this.interactions.getState().editSession)
|
|
319
|
+
return false;
|
|
320
|
+
const rowHeader = view.x >= 0 && view.x < geometry.x && view.y > geometry.y;
|
|
321
|
+
const columnHeader = view.y >= 0 && view.y < geometry.y && view.x > geometry.x;
|
|
322
|
+
if (axis === SheetDragAxis_1.SheetDragAxis.Row ? !rowHeader : !columnHeader)
|
|
323
|
+
return false;
|
|
324
|
+
if (region !== undefined &&
|
|
325
|
+
region !== (axis === SheetDragAxis_1.SheetDragAxis.Row ? sear_render_registry_1.CellRegion.RowHeader : sear_render_registry_1.CellRegion.ColumnHeader))
|
|
326
|
+
return false;
|
|
327
|
+
const dimensions = axis === SheetDragAxis_1.SheetDragAxis.Row ? geometry.rows : geometry.columns;
|
|
328
|
+
const position = axis === SheetDragAxis_1.SheetDragAxis.Row ? world.y - geometry.y : world.x - geometry.x;
|
|
329
|
+
return (position >= dimensions.getDimensionLeftBoundaryByIndex(selection.getPoint(0)[axis]) &&
|
|
330
|
+
position < dimensions.getDimensionRightBoundaryByIndex(selection.getPoint(1)[axis]));
|
|
331
|
+
}
|
|
332
|
+
cellAt(world) {
|
|
333
|
+
const geometry = this.geometry();
|
|
334
|
+
const containingCell = (dimensions, coordinate) => {
|
|
335
|
+
const last = dimensions.shape[1] - 1;
|
|
336
|
+
const position = Math.max(0, Math.min(dimensions.getDimensionRightBoundaryByIndex(last), coordinate));
|
|
337
|
+
const index = dimensions.getRightBoundaryColIndexByDimension(position);
|
|
338
|
+
const right = dimensions.getDimensionRightBoundaryByIndex(index);
|
|
339
|
+
// Shared edges belong to the following cell; the outer sheet edge stays in the last cell.
|
|
340
|
+
return index < last && position >= right ? index + 1 : index;
|
|
341
|
+
};
|
|
342
|
+
return [
|
|
343
|
+
containingCell(geometry.rows, world.y - geometry.y),
|
|
344
|
+
containingCell(geometry.columns, world.x - geometry.x),
|
|
345
|
+
];
|
|
346
|
+
}
|
|
347
|
+
reportFillError(error) {
|
|
348
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
349
|
+
var _a;
|
|
350
|
+
this.platform.warn('Sheet range fill rejected.', error);
|
|
351
|
+
if (!__classPrivateFieldGet(this, _SheetRangeDrag_destroyed, "f") && error instanceof sear_foundation_error_1.SearError) {
|
|
352
|
+
yield ((_a = __classPrivateFieldGet(this, _SheetRangeDrag_interaction, "f")) === null || _a === void 0 ? void 0 : _a.confirm({
|
|
353
|
+
title: 'Cannot fill cells', message: error.message, confirmLabel: 'OK', cancelLabel: 'Close',
|
|
354
|
+
}).catch((feedbackError) => this.platform.warn('Sheet range fill feedback failed.', feedbackError)));
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
/** Idempotently releases preview, cursor, pointer capture and animation resources. */
|
|
359
|
+
destroy(ownerToken) {
|
|
360
|
+
if (__classPrivateFieldGet(this, _SheetRangeDrag_destroyed, "f"))
|
|
361
|
+
return;
|
|
362
|
+
if (__classPrivateFieldGet(this, _SheetRangeDrag_ownerToken, "f") && ownerToken !== __classPrivateFieldGet(this, _SheetRangeDrag_ownerToken, "f")) {
|
|
363
|
+
throw new sear_foundation_error_1.SearError('Sheet range drag destruction requires its editor owner.');
|
|
364
|
+
}
|
|
365
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_destroyed, true, "f");
|
|
366
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_instances, "m", _SheetRangeDrag_cancel).call(this);
|
|
367
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_disposers, "f")
|
|
368
|
+
.splice(0)
|
|
369
|
+
.reverse()
|
|
370
|
+
.forEach((dispose) => dispose());
|
|
371
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_core, null, "f");
|
|
372
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_readSelection, null, "f");
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
exports.SheetRangeDrag = SheetRangeDrag;
|
|
376
|
+
_SheetRangeDrag_core = new WeakMap();
|
|
377
|
+
_SheetRangeDrag_readSelection = new WeakMap();
|
|
378
|
+
_SheetRangeDrag_session = new WeakMap();
|
|
379
|
+
_SheetRangeDrag_disposeCapture = new WeakMap();
|
|
380
|
+
_SheetRangeDrag_disposers = new WeakMap();
|
|
381
|
+
_SheetRangeDrag_frame = new WeakMap();
|
|
382
|
+
_SheetRangeDrag_generation = new WeakMap();
|
|
383
|
+
_SheetRangeDrag_suppressDoubleClick = new WeakMap();
|
|
384
|
+
_SheetRangeDrag_destroyed = new WeakMap();
|
|
385
|
+
_SheetRangeDrag_interaction = new WeakMap();
|
|
386
|
+
_SheetRangeDrag_commands = new WeakMap();
|
|
387
|
+
_SheetRangeDrag_ownerToken = new WeakMap();
|
|
388
|
+
_SheetRangeDrag_instances = new WeakSet();
|
|
389
|
+
_SheetRangeDrag_applyInput = function _SheetRangeDrag_applyInput(input) {
|
|
390
|
+
if (__classPrivateFieldGet(this, _SheetRangeDrag_destroyed, "f"))
|
|
391
|
+
return;
|
|
392
|
+
switch (input.action) {
|
|
393
|
+
case SheetRangeDragCommand_1.SheetRangeDragAction.Begin:
|
|
394
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_instances, "m", _SheetRangeDrag_begin).call(this, input.point);
|
|
395
|
+
break;
|
|
396
|
+
case SheetRangeDragCommand_1.SheetRangeDragAction.FillBegin:
|
|
397
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_instances, "m", _SheetRangeDrag_begin).call(this, input.point, true);
|
|
398
|
+
break;
|
|
399
|
+
case SheetRangeDragCommand_1.SheetRangeDragAction.Update:
|
|
400
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_instances, "m", _SheetRangeDrag_update).call(this, input.point);
|
|
401
|
+
break;
|
|
402
|
+
case SheetRangeDragCommand_1.SheetRangeDragAction.Release:
|
|
403
|
+
void __classPrivateFieldGet(this, _SheetRangeDrag_instances, "m", _SheetRangeDrag_finish).call(this, input.point);
|
|
404
|
+
break;
|
|
405
|
+
case SheetRangeDragCommand_1.SheetRangeDragAction.Cancel:
|
|
406
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_instances, "m", _SheetRangeDrag_cancel).call(this);
|
|
407
|
+
break;
|
|
408
|
+
case SheetRangeDragCommand_1.SheetRangeDragAction.Tick:
|
|
409
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_instances, "m", _SheetRangeDrag_advanceScroll).call(this);
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
_SheetRangeDrag_begin = function _SheetRangeDrag_begin(point, fill = false) {
|
|
414
|
+
if (!__classPrivateFieldGet(this, _SheetRangeDrag_core, "f") || !__classPrivateFieldGet(this, _SheetRangeDrag_readSelection, "f"))
|
|
415
|
+
return;
|
|
416
|
+
const world = this.coordinates.screenToWorld(point.view.x, point.view.y);
|
|
417
|
+
const view = this.coordinates.screenToView(point.view.x, point.view.y);
|
|
418
|
+
if (fill ? !this.hitsFillHandle(world, view) : !this.hitsBorder(world, view) && !this.hitsSelectedHeader(world, view))
|
|
419
|
+
return;
|
|
420
|
+
const selection = __classPrivateFieldGet(this, _SheetRangeDrag_readSelection, "f")();
|
|
421
|
+
const source = {
|
|
422
|
+
start: [...selection.getPoint(0)],
|
|
423
|
+
end: [...selection.getPoint(1)],
|
|
424
|
+
};
|
|
425
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_instances, "m", _SheetRangeDrag_cancel).call(this);
|
|
426
|
+
this.keyboard.subscribe({ onEscape: this.escape });
|
|
427
|
+
const axis = this.selectedAxis();
|
|
428
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_session, {
|
|
429
|
+
mode: fill ? 'fill' : 'move',
|
|
430
|
+
source,
|
|
431
|
+
target: [...source.start],
|
|
432
|
+
pointer: point,
|
|
433
|
+
origin: point,
|
|
434
|
+
startScrollX: __classPrivateFieldGet(this, _SheetRangeDrag_core, "f").renderEngine.scrollManager.getState().x,
|
|
435
|
+
fillDirection: null,
|
|
436
|
+
axis,
|
|
437
|
+
before: source.start[axis !== null && axis !== void 0 ? axis : 0],
|
|
438
|
+
analysis: fill || axis !== null ? null : this.queries.run(AnalyzeSheetRangeMove_1.AnalyzeSheetRangeMove, { source, target: source.start }),
|
|
439
|
+
}, "f");
|
|
440
|
+
this.cursor.override(fill ? sear_render_cursor_1.CursorToken.Copy : sear_render_cursor_1.CursorToken.Grabbing);
|
|
441
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_disposeCapture, this.pointer.start({
|
|
442
|
+
onMove: (point) => __classPrivateFieldGet(this, _SheetRangeDrag_commands, "f").run(SheetRangeDragCommand_1.HandleSheetRangeDragCommand, { action: SheetRangeDragCommand_1.SheetRangeDragAction.Update, point }),
|
|
443
|
+
onRelease: (point) => {
|
|
444
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_commands, "f").run(SheetRangeDragCommand_1.HandleSheetRangeDragCommand, { action: SheetRangeDragCommand_1.SheetRangeDragAction.Release, point });
|
|
445
|
+
},
|
|
446
|
+
}), "f");
|
|
447
|
+
this.highlights.invalidate();
|
|
448
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_instances, "m", _SheetRangeDrag_scheduleScroll).call(this);
|
|
449
|
+
};
|
|
450
|
+
_SheetRangeDrag_update = function _SheetRangeDrag_update(point, refresh = false) {
|
|
451
|
+
const session = __classPrivateFieldGet(this, _SheetRangeDrag_session, "f");
|
|
452
|
+
const geometry = this.geometry();
|
|
453
|
+
if (!session || !geometry)
|
|
454
|
+
return;
|
|
455
|
+
session.pointer = point;
|
|
456
|
+
const world = this.coordinates.screenToWorld(point.view.x, point.view.y);
|
|
457
|
+
if (session.axis !== null) {
|
|
458
|
+
session.before =
|
|
459
|
+
session.axis === SheetDragAxis_1.SheetDragAxis.Row
|
|
460
|
+
? (0, resolveAxisInsertionBoundary_1.resolveAxisInsertionBoundary)(geometry.rows, world.y - geometry.y)
|
|
461
|
+
: (0, resolveAxisInsertionBoundary_1.resolveAxisInsertionBoundary)(geometry.columns, world.x - geometry.x);
|
|
462
|
+
this.highlights.invalidate();
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
const cell = this.cellAt(world);
|
|
466
|
+
if (session.mode === 'fill') {
|
|
467
|
+
if (!session.fillDirection) {
|
|
468
|
+
const dx = point.view.x - session.origin.view.x;
|
|
469
|
+
const dy = point.view.y - session.origin.view.y;
|
|
470
|
+
if (Math.max(Math.abs(dx), Math.abs(dy)) > 6)
|
|
471
|
+
session.fillDirection = Math.abs(dy) >= Math.abs(dx) ? 'row' : 'column';
|
|
472
|
+
}
|
|
473
|
+
session.target = session.fillDirection === 'row'
|
|
474
|
+
? [cell[0], session.source.end[1]]
|
|
475
|
+
: session.fillDirection === 'column'
|
|
476
|
+
? [session.source.end[0], cell[1]]
|
|
477
|
+
: cell;
|
|
478
|
+
this.highlights.invalidate();
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
const target = [
|
|
482
|
+
Math.max(0, Math.min(geometry.rows.shape[1] - 1 - session.source.end[0] + session.source.start[0], cell[0])),
|
|
483
|
+
Math.max(0, Math.min(geometry.columns.shape[1] - 1 - session.source.end[1] + session.source.start[1], cell[1])),
|
|
484
|
+
];
|
|
485
|
+
if (!refresh && session.target[0] === target[0] && session.target[1] === target[1])
|
|
486
|
+
return;
|
|
487
|
+
session.target = target;
|
|
488
|
+
session.analysis = this.queries.run(AnalyzeSheetRangeMove_1.AnalyzeSheetRangeMove, { source: session.source, target });
|
|
489
|
+
this.cursor.override(session.analysis.status === sear_assembly_plugin_2.SheetRangeMoveStatus.Blocked ? sear_render_cursor_1.CursorToken.NotAllowed : sear_render_cursor_1.CursorToken.Grabbing);
|
|
490
|
+
this.highlights.invalidate();
|
|
491
|
+
};
|
|
492
|
+
_SheetRangeDrag_scheduleScroll = function _SheetRangeDrag_scheduleScroll() {
|
|
493
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_frame, this.platform.requestAnimationFrame(() => {
|
|
494
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_frame, null, "f");
|
|
495
|
+
if (!__classPrivateFieldGet(this, _SheetRangeDrag_destroyed, "f"))
|
|
496
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_commands, "f").run(SheetRangeDragCommand_1.HandleSheetRangeDragCommand, { action: SheetRangeDragCommand_1.SheetRangeDragAction.Tick });
|
|
497
|
+
}), "f");
|
|
498
|
+
};
|
|
499
|
+
_SheetRangeDrag_advanceScroll = function _SheetRangeDrag_advanceScroll() {
|
|
500
|
+
const session = __classPrivateFieldGet(this, _SheetRangeDrag_session, "f");
|
|
501
|
+
const geometry = this.geometry();
|
|
502
|
+
if (!session || !geometry || !__classPrivateFieldGet(this, _SheetRangeDrag_core, "f"))
|
|
503
|
+
return;
|
|
504
|
+
const view = this.coordinates.screenToView(session.pointer.view.x, session.pointer.view.y);
|
|
505
|
+
const scroll = __classPrivateFieldGet(this, _SheetRangeDrag_core, "f").renderEngine.scrollManager;
|
|
506
|
+
const [width, height] = scroll.getShape();
|
|
507
|
+
const speed = (value, start, end) => (value < start + 24 ? -12 : value > end - 24 ? 12 : 0);
|
|
508
|
+
const state = scroll.getState();
|
|
509
|
+
const dx = session.axis === SheetDragAxis_1.SheetDragAxis.Row || (session.mode === 'fill' && session.fillDirection !== 'column')
|
|
510
|
+
? 0 : speed(view.x, geometry.x, width);
|
|
511
|
+
const dy = session.axis === SheetDragAxis_1.SheetDragAxis.Column || (session.mode === 'fill' && session.fillDirection === null)
|
|
512
|
+
|| session.fillDirection === 'column' ? 0 : speed(view.y, geometry.y, height);
|
|
513
|
+
if (dx || dy) {
|
|
514
|
+
scroll.scrollTo(state.x + dx, state.y + dy);
|
|
515
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_instances, "m", _SheetRangeDrag_update).call(this, session.pointer);
|
|
516
|
+
}
|
|
517
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_instances, "m", _SheetRangeDrag_scheduleScroll).call(this);
|
|
518
|
+
};
|
|
519
|
+
_SheetRangeDrag_finish = function _SheetRangeDrag_finish(point) {
|
|
520
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
521
|
+
var _a, _b, _c;
|
|
522
|
+
var _d;
|
|
523
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_instances, "m", _SheetRangeDrag_update).call(this, point, true);
|
|
524
|
+
const session = __classPrivateFieldGet(this, _SheetRangeDrag_session, "f");
|
|
525
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_instances, "m", _SheetRangeDrag_clearGesture).call(this);
|
|
526
|
+
if ((session === null || session === void 0 ? void 0 : session.mode) === 'fill') {
|
|
527
|
+
if (session.fillDirection && !session.target.every((value, axis) => value === session.source.end[axis])) {
|
|
528
|
+
try {
|
|
529
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_commands, "f").run(SheetFillRangeCommand_1.FillSheetRangeCommand, { source: session.source, target: session.target });
|
|
530
|
+
}
|
|
531
|
+
catch (error) {
|
|
532
|
+
yield this.reportFillError(error);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_commands, "f").run(SheetSelectionCommands_1.SelectRangeCommand, {
|
|
536
|
+
anchor: [Math.min(session.source.start[0], session.target[0]), Math.min(session.source.start[1], session.target[1])],
|
|
537
|
+
focus: [Math.max(session.source.end[0], session.target[0]), Math.max(session.source.end[1], session.target[1])],
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
if (session.fillDirection === 'row' && __classPrivateFieldGet(this, _SheetRangeDrag_core, "f")) {
|
|
541
|
+
const scroll = __classPrivateFieldGet(this, _SheetRangeDrag_core, "f").renderEngine.scrollManager;
|
|
542
|
+
scroll.scrollTo(session.startScrollX, scroll.getState().y);
|
|
543
|
+
}
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
if ((session === null || session === void 0 ? void 0 : session.axis) !== null && (session === null || session === void 0 ? void 0 : session.axis) !== undefined) {
|
|
547
|
+
try {
|
|
548
|
+
(0, SheetAxisDrag_1.commitAxisDrag)(__classPrivateFieldGet(this, _SheetRangeDrag_commands, "f"), Object.assign(Object.assign({}, session), { axis: session.axis }));
|
|
549
|
+
}
|
|
550
|
+
catch (error) {
|
|
551
|
+
this.platform.warn('Sheet axis move rejected.', error);
|
|
552
|
+
if (!__classPrivateFieldGet(this, _SheetRangeDrag_destroyed, "f") && error instanceof sear_foundation_error_1.SearError) {
|
|
553
|
+
yield ((_a = __classPrivateFieldGet(this, _SheetRangeDrag_interaction, "f")) === null || _a === void 0 ? void 0 : _a.confirm({
|
|
554
|
+
title: 'Cannot reorder rows or columns',
|
|
555
|
+
message: error.message,
|
|
556
|
+
confirmLabel: 'OK',
|
|
557
|
+
cancelLabel: 'Close',
|
|
558
|
+
}).catch((feedbackError) => this.platform.warn('Sheet axis move feedback failed.', feedbackError)));
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
if (!session || session.target.every((value, axis) => value === session.source.start[axis]))
|
|
564
|
+
return;
|
|
565
|
+
const generation = __classPrivateFieldSet(this, _SheetRangeDrag_generation, (_d = __classPrivateFieldGet(this, _SheetRangeDrag_generation, "f"), ++_d), "f");
|
|
566
|
+
const input = { source: session.source, target: session.target };
|
|
567
|
+
try {
|
|
568
|
+
const analysis = this.queries.run(AnalyzeSheetRangeMove_1.AnalyzeSheetRangeMove, input);
|
|
569
|
+
if (analysis.status === sear_assembly_plugin_2.SheetRangeMoveStatus.Blocked)
|
|
570
|
+
throw new sear_assembly_plugin_2.SheetRangeMoveRejectedError(analysis);
|
|
571
|
+
const conflict = analysis.status === sear_assembly_plugin_2.SheetRangeMoveStatus.RequiresConfirmation;
|
|
572
|
+
if (conflict &&
|
|
573
|
+
!(yield ((_b = __classPrivateFieldGet(this, _SheetRangeDrag_interaction, "f")) === null || _b === void 0 ? void 0 : _b.confirm({
|
|
574
|
+
title: 'Move cells',
|
|
575
|
+
message: 'The destination contains data. Replace it?',
|
|
576
|
+
confirmLabel: 'Replace',
|
|
577
|
+
cancelLabel: 'Cancel',
|
|
578
|
+
}))))
|
|
579
|
+
return;
|
|
580
|
+
if (__classPrivateFieldGet(this, _SheetRangeDrag_destroyed, "f") || generation !== __classPrivateFieldGet(this, _SheetRangeDrag_generation, "f"))
|
|
581
|
+
return;
|
|
582
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_commands, "f").run(SheetRangeMoveCommands_1.MoveSheetRangeCommand, Object.assign(Object.assign({}, input), { overwrite: conflict }));
|
|
583
|
+
}
|
|
584
|
+
catch (error) {
|
|
585
|
+
this.platform.warn('Sheet range move rejected.', error);
|
|
586
|
+
if (!__classPrivateFieldGet(this, _SheetRangeDrag_destroyed, "f") && generation === __classPrivateFieldGet(this, _SheetRangeDrag_generation, "f") && error instanceof sear_foundation_error_1.SearError) {
|
|
587
|
+
yield ((_c = __classPrivateFieldGet(this, _SheetRangeDrag_interaction, "f")) === null || _c === void 0 ? void 0 : _c.confirm({
|
|
588
|
+
title: 'Cannot move cells',
|
|
589
|
+
message: error.message,
|
|
590
|
+
confirmLabel: 'OK',
|
|
591
|
+
cancelLabel: 'Close',
|
|
592
|
+
}).catch((feedbackError) => this.platform.warn('Sheet range move feedback failed.', feedbackError)));
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
};
|
|
597
|
+
_SheetRangeDrag_clearGesture = function _SheetRangeDrag_clearGesture() {
|
|
598
|
+
var _a;
|
|
599
|
+
(_a = __classPrivateFieldGet(this, _SheetRangeDrag_disposeCapture, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
600
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_disposeCapture, null, "f");
|
|
601
|
+
if (__classPrivateFieldGet(this, _SheetRangeDrag_frame, "f") !== null)
|
|
602
|
+
this.platform.cancelAnimationFrame(__classPrivateFieldGet(this, _SheetRangeDrag_frame, "f"));
|
|
603
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_frame, null, "f");
|
|
604
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_session, null, "f");
|
|
605
|
+
this.cursor.override(null);
|
|
606
|
+
this.highlights.invalidate();
|
|
607
|
+
};
|
|
608
|
+
_SheetRangeDrag_cancel = function _SheetRangeDrag_cancel() {
|
|
609
|
+
var _a;
|
|
610
|
+
__classPrivateFieldSet(this, _SheetRangeDrag_generation, (_a = __classPrivateFieldGet(this, _SheetRangeDrag_generation, "f"), _a++, _a), "f");
|
|
611
|
+
__classPrivateFieldGet(this, _SheetRangeDrag_instances, "m", _SheetRangeDrag_clearGesture).call(this);
|
|
612
|
+
};
|
|
613
|
+
SheetRangeDrag.symbol = Symbol.for('SheetRangeDrag');
|
|
614
|
+
exports.SheetRangeDrag = SheetRangeDrag = __decorate([
|
|
615
|
+
(0, sear_foundation_di_1.Injectable)(),
|
|
616
|
+
__param(0, (0, sear_foundation_di_1.Inject)(sear_assembly_commands_1.SheetCommandBus.symbol)),
|
|
617
|
+
__param(1, (0, sear_foundation_di_1.Inject)(sear_assembly_commands_1.SheetQueryRegistry.symbol)),
|
|
618
|
+
__param(2, (0, sear_foundation_di_1.Inject)(sear_render_coord_1.CoordinateEngine.symbol)),
|
|
619
|
+
__param(3, (0, sear_foundation_di_1.Inject)(sear_render_input_1.PointerCapture.symbol)),
|
|
620
|
+
__param(4, (0, sear_foundation_di_1.Inject)(sear_render_input_1.KeyboardRouter.symbol)),
|
|
621
|
+
__param(5, (0, sear_foundation_di_1.Inject)(sear_render_cursor_1.CursorRegistry.symbol)),
|
|
622
|
+
__param(6, (0, sear_foundation_di_1.Inject)(sear_render_cursor_1.CursorEngine.symbol)),
|
|
623
|
+
__param(7, (0, sear_foundation_di_1.Inject)(SheetHighlightRegistry_1.SheetHighlightRegistry.symbol)),
|
|
624
|
+
__param(8, (0, sear_foundation_di_1.Inject)(sear_foundation_platform_1.Platform.symbol)),
|
|
625
|
+
__param(9, (0, sear_foundation_di_1.Inject)(sear_assembly_core_1.SheetInteractionStore.symbol)),
|
|
626
|
+
__param(10, (0, sear_foundation_di_1.Inject)(sear_domain_cell_types_1.SheetCellInputValidationRegistry.symbol)),
|
|
627
|
+
__param(11, (0, sear_foundation_di_1.Inject)(sear_domain_cell_types_1.CellClipboardCodecRegistry.symbol)),
|
|
628
|
+
__param(12, (0, sear_foundation_di_1.Inject)(sear_assembly_plugin_1.SheetFormatTransferRegistry.symbol)),
|
|
629
|
+
__param(13, (0, sear_foundation_di_1.Inject)(sear_assembly_plugin_1.SheetClipboardTransferRegistry.symbol))
|
|
630
|
+
], SheetRangeDrag);
|
|
631
|
+
//# sourceMappingURL=SheetRangeDrag.js.map
|