@odoo/o-spreadsheet 16.3.0-alpha.4 → 16.3.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import * as _odoo_owl from '@odoo/owl';
2
- import { ComponentConstructor, EventBus as EventBus$1, Component } from '@odoo/owl';
2
+ import { ComponentConstructor, Component } from '@odoo/owl';
3
3
  import { ChartConfiguration, ChartData, ChartDataSets, ChartOptions } from 'chart.js';
4
4
 
5
5
  declare enum CellErrorLevel {
@@ -160,195 +160,129 @@ interface Subscription {
160
160
  callback: Callback;
161
161
  }
162
162
 
163
- /**
164
- * RGBA to HEX representation (#RRGGBBAA).
165
- *
166
- * https://css-tricks.com/converting-color-spaces-in-javascript/
167
- */
168
- declare function rgbaToHex(rgba: RGBA): Color;
169
- /**
170
- * Color string to RGBA representation
171
- */
172
- declare function colorToRGBA(color: Color): RGBA;
173
-
174
- /**
175
- * Convert a (col) number to the corresponding letter.
176
- *
177
- * Examples:
178
- * 0 => 'A'
179
- * 25 => 'Z'
180
- * 26 => 'AA'
181
- * 27 => 'AB'
182
- */
183
- declare function numberToLetters(n: number): string;
184
- /**
185
- * Convert a "XC" coordinate to cartesian coordinates.
186
- *
187
- * Examples:
188
- * A1 => [0,0]
189
- * B3 => [1,2]
190
- *
191
- * Note: it also accepts lowercase coordinates, but not fixed references
192
- */
193
- declare function toCartesian(xc: string): Position$1;
194
- /**
195
- * Convert from cartesian coordinate to the "XC" coordinate system.
196
- *
197
- * Examples:
198
- * - 0,0 => A1
199
- * - 1,2 => B3
200
- * - 0,0, {colFixed: false, rowFixed: true} => A$1
201
- * - 1,2, {colFixed: true, rowFixed: false} => $B3
202
- */
203
- declare function toXC(col: HeaderIndex, row: HeaderIndex, rangePart?: RangePart): string;
204
-
205
- /**
206
- * Formats a cell value with its format.
207
- */
208
- declare function formatValue(value: CellValue, format?: Format): FormattedValue;
209
-
210
- declare function computeTextWidth(context: CanvasRenderingContext2D, text: string, style: Style): number;
211
- declare function isMarkdownLink(str: string): boolean;
212
- /**
213
- * Build a markdown link from a label and an url
214
- */
215
- declare function markdownLink(label: string, url: string): string;
216
- declare function parseMarkdownLink(str: string): {
217
- url: string;
218
- label: string;
219
- };
220
- /**
221
- * This helper function can be used as a type guard when filtering arrays.
222
- * const foo: number[] = [1, 2, undefined, 4].filter(isDefined)
223
- */
224
- declare function isDefined<T>(argument: T | undefined): argument is T;
225
- /**
226
- * Lazy value computed by the provided function.
227
- */
228
- declare function lazy<T>(fn: (() => T) | T): Lazy<T>;
229
-
230
- interface ConstructorArgs {
231
- readonly zone: Readonly<Zone | UnboundedZone>;
232
- readonly parts: readonly RangePart[];
233
- readonly invalidXc?: string;
234
- /** true if the user provided the range with the sheet name */
235
- readonly prefixSheet: boolean;
236
- /** the name of any sheet that is invalid */
237
- readonly invalidSheetName?: string;
238
- /** the sheet on which the range is defined */
239
- readonly sheetId: UID;
240
- }
241
- declare class RangeImpl implements Range {
242
- private getSheetSize;
243
- private readonly _zone;
244
- readonly parts: Range["parts"];
245
- readonly invalidXc?: string;
246
- readonly prefixSheet: boolean;
247
- readonly sheetId: UID;
248
- readonly invalidSheetName?: string;
249
- constructor(args: ConstructorArgs, getSheetSize: (sheetId: UID) => ZoneDimension);
250
- static fromRange(range: Range, getters: CoreGetters): RangeImpl;
251
- get unboundedZone(): UnboundedZone;
252
- get zone(): Zone;
253
- static getRangeParts(xc: string, zone: UnboundedZone): RangePart[];
254
- get isFullCol(): boolean;
255
- get isFullRow(): boolean;
256
- get rangeData(): RangeData;
163
+ declare class SelectiveHistory<T = unknown> {
164
+ private applyOperation;
165
+ private revertOperation;
166
+ private buildEmpty;
167
+ private readonly buildTransformation;
168
+ private HEAD_BRANCH;
169
+ private HEAD_OPERATION;
170
+ private tree;
257
171
  /**
258
- * Check that a zone is valid regarding the order of top-bottom and left-right.
259
- * Left should be smaller than right, top should be smaller than bottom.
260
- * If it's not the case, simply invert them, and invert the linked parts
172
+ * The selective history is a data structure used to register changes/updates of a state.
173
+ * Each change/update is called an "operation".
174
+ * The data structure allows to easily cancel (and redo) any operation individually.
175
+ * An operation can be represented by any data structure. It can be a "command", a "diff", etc.
176
+ * However it must have the following properties:
177
+ * - it can be applied to modify the state
178
+ * - it can be reverted on the state such that it was never executed.
179
+ * - it can be transformed given other operation (Operational Transformation)
180
+ *
181
+ * Since this data structure doesn't know anything about the state nor the structure of
182
+ * operations, the actual work must be performed by external functions given as parameters.
183
+ * @param initialOperationId
184
+ * @param applyOperation a function which can apply an operation to the state
185
+ * @param revertOperation a function which can revert an operation from the state
186
+ * @param buildEmpty a function returning an "empty" operation.
187
+ * i.e an operation that leaves the state unmodified once applied or reverted
188
+ * (used for internal implementation)
189
+ * @param buildTransformation Factory used to build transformations
261
190
  */
262
- orderZone(): RangeImpl;
191
+ constructor(initialOperationId: UID, applyOperation: (data: T) => void, revertOperation: (data: T) => void, buildEmpty: (id: UID) => T, buildTransformation: TransformationFactory<T>);
263
192
  /**
264
- *
265
- * @param rangeParams optional, values to put in the cloned range instead of the current values of the range
193
+ * Return the operation identified by its id.
266
194
  */
267
- clone(rangeParams?: Partial<ConstructorArgs>): RangeImpl;
195
+ get(operationId: UID): T;
196
+ /**
197
+ * Append a new operation as the last one
198
+ */
199
+ append(operationId: UID, data: T): void;
200
+ /**
201
+ * Insert a new operation after a specific operation (may not be the last operation).
202
+ * Following operations will be transformed according
203
+ * to the new operation.
204
+ */
205
+ insert(operationId: UID, data: T, insertAfter: UID): void;
206
+ /**
207
+ * @param operationId operation to undo
208
+ * @param undoId the id of the "undo operation"
209
+ * @param insertAfter the id of the operation after which to insert the undo
210
+ */
211
+ undo(operationId: UID, undoId: UID, insertAfter: UID): void;
212
+ /**
213
+ * @param operationId operation to redo
214
+ * @param redoId the if of the "redo operation"
215
+ * @param insertAfter the id of the operation after which to insert the redo
216
+ */
217
+ redo(operationId: UID, redoId: UID, insertAfter: UID): void;
218
+ drop(operationId: UID): void;
219
+ getRevertedExecution(): T[];
220
+ /**
221
+ * Revert the state as it was *before* the given operation was executed.
222
+ */
223
+ private revertBefore;
224
+ /**
225
+ * Revert the state as it was *after* the given operation was executed.
226
+ */
227
+ private revertTo;
228
+ /**
229
+ * Revert an execution
230
+ */
231
+ private revert;
232
+ /**
233
+ * Replay the operations between the current HEAD_BRANCH and the end of the tree
234
+ */
235
+ private fastForward;
268
236
  }
269
237
 
270
- declare class UuidGenerator {
271
- private isFastIdStrategy;
272
- private fastIdStart;
273
- setIsFastStrategy(isFast: boolean): void;
274
- uuidv4(): string;
238
+ declare type ClientId = string;
239
+ interface Client {
240
+ id: ClientId;
241
+ name: string;
242
+ position?: ClientPosition;
275
243
  }
276
-
277
- /**
278
- * Convert from a cartesian reference to a Zone.
279
- * Will return throw an error if given a unbounded zone (eg : A:A).
280
- *
281
- * Examples:
282
- * "A1" ==> Top 0, Bottom 0, Left: 0, Right: 0
283
- * "B1:B3" ==> Top 0, Bottom 3, Left: 1, Right: 1
284
- * "Sheet1!A1" ==> Top 0, Bottom 0, Left: 0, Right: 0
285
- * "Sheet1!B1:B3" ==> Top 0, Bottom 3, Left: 1, Right: 1
286
- *
287
- * @param xc the string reference to convert
288
- *
289
- */
290
- declare function toZone(xc: string): Zone;
291
- /**
292
- * This function will compare the modifications of selection to determine
293
- * a cell that is part of the new zone and not the previous one.
294
- */
295
- declare function findCellInNewZone(oldZone: Zone, currentZone: Zone): Position$1;
296
- declare function positionToZone(position: Position$1): {
297
- left: HeaderIndex;
298
- right: HeaderIndex;
299
- top: HeaderIndex;
300
- bottom: HeaderIndex;
301
- };
302
-
303
- interface SelectionEventPayload {
304
- anchor: AnchorZone;
305
- previousAnchor: AnchorZone;
306
- mode: "newAnchor" | "overrideSelection" | "updateAnchor";
244
+ interface ClientPosition {
245
+ sheetId: UID;
246
+ col: HeaderIndex;
247
+ row: HeaderIndex;
307
248
  }
308
- interface ZonesSelected extends SelectionEventPayload {
309
- type: "ZonesSelected";
249
+ interface RemoteRevisionReceivedEvent {
250
+ type: "remote-revision-received";
251
+ commands: readonly CoreCommand[];
310
252
  }
311
- interface HeadersSelected extends SelectionEventPayload {
312
- type: "HeadersSelected";
253
+ interface RevisionAcknowledgedEvent {
254
+ type: "revision-acknowledged";
255
+ revisionId: UID;
313
256
  }
314
- interface AlterZone extends SelectionEventPayload {
315
- type: "AlterZone";
257
+ interface RevisionUndone {
258
+ type: "revision-undone";
259
+ revisionId: UID;
260
+ commands: readonly CoreCommand[];
316
261
  }
317
- declare type SelectionEvent = Readonly<ZonesSelected | HeadersSelected | AlterZone>;
318
-
319
- interface StreamCallbacks<Event> {
320
- handleEvent: (event: Event) => void;
321
- /** this callback will only be called when another consumer captures the stream,
322
- * not when the current consumer decides to release itself */
323
- release?: () => void;
262
+ interface RevisionRedone {
263
+ type: "revision-redone";
264
+ revisionId: UID;
265
+ commands: readonly CoreCommand[];
324
266
  }
325
-
326
- declare type StatefulStream<Event, State> = {
327
- capture(owner: unknown, state: State, callbacks: StreamCallbacks<Event>): void;
328
- registerAsDefault: (owner: unknown, state: State, callbacks: StreamCallbacks<Event>) => void;
329
- resetDefaultAnchor: (owner: unknown, state: State) => void;
330
- resetAnchor: (owner: unknown, state: State) => void;
331
- observe: (owner: unknown, callbacks: StreamCallbacks<Event>) => void;
332
- release: (owner: unknown) => void;
333
- getBackToDefault(): void;
334
- };
335
- /**
336
- * Allows to select cells in the grid and update the selection
337
- */
338
- interface SelectionProcessor {
339
- selectZone(anchor: AnchorZone): DispatchResult;
340
- selectCell(col: number, row: number): DispatchResult;
341
- moveAnchorCell(direction: SelectionDirection, step: SelectionStep): DispatchResult;
342
- setAnchorCorner(col: number, row: number): DispatchResult;
343
- addCellToSelection(col: number, row: number): DispatchResult;
344
- resizeAnchorZone(direction: SelectionDirection, step: SelectionStep): DispatchResult;
345
- selectColumn(index: number, mode: SelectionEvent["mode"]): DispatchResult;
346
- selectRow(index: number, mode: SelectionEvent["mode"]): DispatchResult;
347
- selectAll(): DispatchResult;
348
- loopSelection(): DispatchResult;
349
- selectTableAroundSelection(): DispatchResult;
267
+ interface CollaborativeEventReceived {
268
+ type: "collaborative-event-received";
350
269
  }
351
- declare type SelectionStreamProcessor = SelectionProcessor & StatefulStream<SelectionEvent, AnchorZone>;
270
+ interface UnexpectedRevisionIdEvent {
271
+ type: "unexpected-revision-id";
272
+ revisionId: UID;
273
+ }
274
+ interface NewLocalStateUpdateEvent {
275
+ type: "new-local-state-update";
276
+ id: UID;
277
+ }
278
+ interface RevisionsDroppedEvent {
279
+ type: "pending-revisions-dropped";
280
+ revisionIds: UID[];
281
+ }
282
+ interface SnapshotEvent {
283
+ type: "snapshot";
284
+ }
285
+ declare type CollaborativeEvent = NewLocalStateUpdateEvent | UnexpectedRevisionIdEvent | RemoteRevisionReceivedEvent | RevisionAcknowledgedEvent | RevisionUndone | RevisionRedone | RevisionsDroppedEvent | SnapshotEvent | CollaborativeEventReceived;
352
286
 
353
287
  declare type XLSXExportFile = XLSXExportImageFile | XLSXExportXMLFile;
354
288
  interface XLSXExportXMLFile {
@@ -725,55 +659,6 @@ interface ExcelFilterData {
725
659
  filteredValues: string[];
726
660
  }
727
661
 
728
- declare type ClientId = string;
729
- interface Client {
730
- id: ClientId;
731
- name: string;
732
- position?: ClientPosition;
733
- }
734
- interface ClientPosition {
735
- sheetId: UID;
736
- col: HeaderIndex;
737
- row: HeaderIndex;
738
- }
739
- interface RemoteRevisionReceivedEvent {
740
- type: "remote-revision-received";
741
- commands: readonly CoreCommand[];
742
- }
743
- interface RevisionAcknowledgedEvent {
744
- type: "revision-acknowledged";
745
- revisionId: UID;
746
- }
747
- interface RevisionUndone {
748
- type: "revision-undone";
749
- revisionId: UID;
750
- commands: readonly CoreCommand[];
751
- }
752
- interface RevisionRedone {
753
- type: "revision-redone";
754
- revisionId: UID;
755
- commands: readonly CoreCommand[];
756
- }
757
- interface CollaborativeEventReceived {
758
- type: "collaborative-event-received";
759
- }
760
- interface UnexpectedRevisionIdEvent {
761
- type: "unexpected-revision-id";
762
- revisionId: UID;
763
- }
764
- interface NewLocalStateUpdateEvent {
765
- type: "new-local-state-update";
766
- id: UID;
767
- }
768
- interface RevisionsDroppedEvent {
769
- type: "pending-revisions-dropped";
770
- revisionIds: UID[];
771
- }
772
- interface SnapshotEvent {
773
- type: "snapshot";
774
- }
775
- declare type CollaborativeEvent = NewLocalStateUpdateEvent | UnexpectedRevisionIdEvent | RemoteRevisionReceivedEvent | RevisionAcknowledgedEvent | RevisionUndone | RevisionRedone | RevisionsDroppedEvent | SnapshotEvent | CollaborativeEventReceived;
776
-
777
662
  interface AbstractMessage {
778
663
  version: number;
779
664
  }
@@ -817,48 +702,349 @@ interface SnapshotMessage extends AbstractMessage {
817
702
  serverRevisionId: UID;
818
703
  nextRevisionId: UID;
819
704
  }
820
- /**
821
- * Notify all clients that the server has a new snapshot of the
822
- * spreadsheet and that the previous history may be lost.
823
- */
824
- interface SnapshotCreatedMessage extends AbstractMessage {
825
- type: "SNAPSHOT_CREATED";
826
- serverRevisionId: UID;
827
- nextRevisionId: UID;
705
+ /**
706
+ * Notify all clients that the server has a new snapshot of the
707
+ * spreadsheet and that the previous history may be lost.
708
+ */
709
+ interface SnapshotCreatedMessage extends AbstractMessage {
710
+ type: "SNAPSHOT_CREATED";
711
+ serverRevisionId: UID;
712
+ nextRevisionId: UID;
713
+ }
714
+ declare type CollaborationMessage = RevisionUndoneMessage | RevisionRedoneMessage | RemoteRevisionMessage | SnapshotMessage | SnapshotCreatedMessage | ClientMovedMessage | ClientJoinedMessage | ClientLeftMessage;
715
+ declare type StateUpdateMessage = Extract<CollaborationMessage, {
716
+ nextRevisionId: UID;
717
+ }>;
718
+ declare type NewMessageCallback<T = any> = (message: T) => void;
719
+ /**
720
+ * The transport service allows to communicate between multiple clients.
721
+ * A client can send any message to others.
722
+ * The service will handle all networking details internally.
723
+ */
724
+ interface TransportService<T = any> {
725
+ /**
726
+ * Send a message to all clients
727
+ */
728
+ sendMessage: (message: T) => void;
729
+ /**
730
+ * Register a callback function which will be called each time
731
+ * a new message is received.
732
+ * The new message is given to the callback.
733
+ *
734
+ * ```js
735
+ * transportService.onNewMessage(id, (message) => {
736
+ * // ... handle the new message
737
+ * })
738
+ * ```
739
+ * The `id` is used to unregister this callback when the session is closed.
740
+ */
741
+ onNewMessage: (id: UID, callback: NewMessageCallback<T>) => void;
742
+ /**
743
+ * Unregister a callback linked to the given id
744
+ */
745
+ leave: (id: UID) => void;
746
+ }
747
+
748
+ declare class Revision implements RevisionData {
749
+ readonly rootCommand?: "SNAPSHOT" | Command | "REMOTE" | undefined;
750
+ readonly id: UID;
751
+ readonly clientId: ClientId;
752
+ private _commands;
753
+ private _changes;
754
+ /**
755
+ * A revision represents a whole client action (Create a sheet, merge a Zone, Undo, ...).
756
+ * A revision contains the following information:
757
+ * - id: ID of the revision
758
+ * - commands: CoreCommands that are linked to the action, and should be
759
+ * dispatched in other clients
760
+ * - clientId: Client who initiated the action
761
+ * - changes: List of changes applied on the state.
762
+ */
763
+ constructor(id: UID, clientId: ClientId, commands: readonly CoreCommand[], rootCommand?: "SNAPSHOT" | Command | "REMOTE" | undefined, changes?: readonly HistoryChange[]);
764
+ setChanges(changes: readonly HistoryChange[]): void;
765
+ get commands(): readonly CoreCommand[];
766
+ get changes(): readonly HistoryChange[];
767
+ }
768
+
769
+ declare class Session extends EventBus<CollaborativeEvent> {
770
+ private revisions;
771
+ private transportService;
772
+ private serverRevisionId;
773
+ /**
774
+ * Positions of the others client.
775
+ */
776
+ private clients;
777
+ private clientId;
778
+ /**
779
+ * Id of the server revision
780
+ */
781
+ private debouncedMove;
782
+ private pendingMessages;
783
+ private waitingAck;
784
+ /**
785
+ * Flag used to block all commands when an undo or redo is triggered, until
786
+ * it is accepted on the server
787
+ */
788
+ private waitingUndoRedoAck;
789
+ private isReplayingInitialRevisions;
790
+ private processedRevisions;
791
+ private uuidGenerator;
792
+ /**
793
+ * Manages the collaboration between multiple users on the same spreadsheet.
794
+ * It can forward local state changes to other users to ensure they all eventually
795
+ * reach the same state.
796
+ * It also manages the positions of each clients in the spreadsheet to provide
797
+ * a visual indication of what other users are doing in the spreadsheet.
798
+ *
799
+ * @param revisions
800
+ * @param transportService communication channel used to send and receive messages
801
+ * between all connected clients
802
+ * @param client the client connected locally
803
+ * @param serverRevisionId
804
+ */
805
+ constructor(revisions: SelectiveHistory<Revision>, transportService: TransportService<CollaborationMessage>, serverRevisionId?: UID);
806
+ canApplyOptimisticUpdate(): boolean;
807
+ /**
808
+ * Add a new revision to the collaborative session.
809
+ * It will be transmitted to all other connected clients.
810
+ */
811
+ save(rootCommand: Command, commands: CoreCommand[], changes: HistoryChange[]): void;
812
+ undo(revisionId: UID): void;
813
+ redo(revisionId: UID): void;
814
+ /**
815
+ * Notify that the position of the client has changed
816
+ */
817
+ move(position: ClientPosition): void;
818
+ join(client?: Client): void;
819
+ loadInitialMessages(messages: StateUpdateMessage[]): void;
820
+ /**
821
+ * Notify the server that the user client left the collaborative session
822
+ */
823
+ leave(): void;
824
+ /**
825
+ * Send a snapshot of the spreadsheet to the collaboration server
826
+ */
827
+ snapshot(data: WorkbookData): void;
828
+ getClient(): Client;
829
+ getConnectedClients(): Set<Client>;
830
+ getRevisionId(): UID;
831
+ isFullySynchronized(): boolean;
832
+ /**
833
+ * Get the last local revision whose root command isn't in the given list of ignored commands
834
+ * */
835
+ getLastLocalNonEmptyRevision(ignoredRootCommands: CommandTypes[]): Revision | undefined;
836
+ private _move;
837
+ /**
838
+ * Handles messages received from other clients in the collaborative
839
+ * session.
840
+ */
841
+ private onMessageReceived;
842
+ private onClientMoved;
843
+ /**
844
+ * Register the new client and send your
845
+ * own position back.
846
+ */
847
+ private onClientJoined;
848
+ private onClientLeft;
849
+ private sendUpdateMessage;
850
+ /**
851
+ * Send the next pending message
852
+ */
853
+ private sendPendingMessage;
854
+ private acknowledge;
855
+ private isAlreadyProcessed;
856
+ private dropPendingHistoryMessages;
857
+ }
858
+
859
+ /**
860
+ * RGBA to HEX representation (#RRGGBBAA).
861
+ *
862
+ * https://css-tricks.com/converting-color-spaces-in-javascript/
863
+ */
864
+ declare function rgbaToHex(rgba: RGBA): Color;
865
+ /**
866
+ * Color string to RGBA representation
867
+ */
868
+ declare function colorToRGBA(color: Color): RGBA;
869
+
870
+ /**
871
+ * Convert a (col) number to the corresponding letter.
872
+ *
873
+ * Examples:
874
+ * 0 => 'A'
875
+ * 25 => 'Z'
876
+ * 26 => 'AA'
877
+ * 27 => 'AB'
878
+ */
879
+ declare function numberToLetters(n: number): string;
880
+ /**
881
+ * Convert a "XC" coordinate to cartesian coordinates.
882
+ *
883
+ * Examples:
884
+ * A1 => [0,0]
885
+ * B3 => [1,2]
886
+ *
887
+ * Note: it also accepts lowercase coordinates, but not fixed references
888
+ */
889
+ declare function toCartesian(xc: string): Position$1;
890
+ /**
891
+ * Convert from cartesian coordinate to the "XC" coordinate system.
892
+ *
893
+ * Examples:
894
+ * - 0,0 => A1
895
+ * - 1,2 => B3
896
+ * - 0,0, {colFixed: false, rowFixed: true} => A$1
897
+ * - 1,2, {colFixed: true, rowFixed: false} => $B3
898
+ */
899
+ declare function toXC(col: HeaderIndex, row: HeaderIndex, rangePart?: RangePart): string;
900
+
901
+ /**
902
+ * Formats a cell value with its format.
903
+ */
904
+ declare function formatValue(value: CellValue, format?: Format): FormattedValue;
905
+
906
+ declare function computeTextWidth(context: CanvasRenderingContext2D, text: string, style: Style): number;
907
+ declare function isMarkdownLink(str: string): boolean;
908
+ /**
909
+ * Build a markdown link from a label and an url
910
+ */
911
+ declare function markdownLink(label: string, url: string): string;
912
+ declare function parseMarkdownLink(str: string): {
913
+ url: string;
914
+ label: string;
915
+ };
916
+ /**
917
+ * This helper function can be used as a type guard when filtering arrays.
918
+ * const foo: number[] = [1, 2, undefined, 4].filter(isDefined)
919
+ */
920
+ declare function isDefined<T>(argument: T | undefined): argument is T;
921
+ /**
922
+ * Lazy value computed by the provided function.
923
+ */
924
+ declare function lazy<T>(fn: (() => T) | T): Lazy<T>;
925
+
926
+ interface ConstructorArgs {
927
+ readonly zone: Readonly<Zone | UnboundedZone>;
928
+ readonly parts: readonly RangePart[];
929
+ readonly invalidXc?: string;
930
+ /** true if the user provided the range with the sheet name */
931
+ readonly prefixSheet: boolean;
932
+ /** the name of any sheet that is invalid */
933
+ readonly invalidSheetName?: string;
934
+ /** the sheet on which the range is defined */
935
+ readonly sheetId: UID;
936
+ }
937
+ declare class RangeImpl implements Range {
938
+ private getSheetSize;
939
+ private readonly _zone;
940
+ readonly parts: Range["parts"];
941
+ readonly invalidXc?: string;
942
+ readonly prefixSheet: boolean;
943
+ readonly sheetId: UID;
944
+ readonly invalidSheetName?: string;
945
+ constructor(args: ConstructorArgs, getSheetSize: (sheetId: UID) => ZoneDimension);
946
+ static fromRange(range: Range, getters: CoreGetters): RangeImpl;
947
+ get unboundedZone(): UnboundedZone;
948
+ get zone(): Zone;
949
+ static getRangeParts(xc: string, zone: UnboundedZone): RangePart[];
950
+ get isFullCol(): boolean;
951
+ get isFullRow(): boolean;
952
+ get rangeData(): RangeData;
953
+ /**
954
+ * Check that a zone is valid regarding the order of top-bottom and left-right.
955
+ * Left should be smaller than right, top should be smaller than bottom.
956
+ * If it's not the case, simply invert them, and invert the linked parts
957
+ */
958
+ orderZone(): RangeImpl;
959
+ /**
960
+ *
961
+ * @param rangeParams optional, values to put in the cloned range instead of the current values of the range
962
+ */
963
+ clone(rangeParams?: Partial<ConstructorArgs>): RangeImpl;
964
+ }
965
+
966
+ declare class UuidGenerator {
967
+ private isFastIdStrategy;
968
+ private fastIdStart;
969
+ setIsFastStrategy(isFast: boolean): void;
970
+ uuidv4(): string;
971
+ }
972
+
973
+ /**
974
+ * Convert from a cartesian reference to a Zone.
975
+ * Will return throw an error if given a unbounded zone (eg : A:A).
976
+ *
977
+ * Examples:
978
+ * "A1" ==> Top 0, Bottom 0, Left: 0, Right: 0
979
+ * "B1:B3" ==> Top 0, Bottom 3, Left: 1, Right: 1
980
+ * "Sheet1!A1" ==> Top 0, Bottom 0, Left: 0, Right: 0
981
+ * "Sheet1!B1:B3" ==> Top 0, Bottom 3, Left: 1, Right: 1
982
+ *
983
+ * @param xc the string reference to convert
984
+ *
985
+ */
986
+ declare function toZone(xc: string): Zone;
987
+ /**
988
+ * This function will compare the modifications of selection to determine
989
+ * a cell that is part of the new zone and not the previous one.
990
+ */
991
+ declare function findCellInNewZone(oldZone: Zone, currentZone: Zone): Position$1;
992
+ declare function positionToZone(position: Position$1): {
993
+ left: HeaderIndex;
994
+ right: HeaderIndex;
995
+ top: HeaderIndex;
996
+ bottom: HeaderIndex;
997
+ };
998
+
999
+ interface SelectionEventPayload {
1000
+ anchor: AnchorZone;
1001
+ previousAnchor: AnchorZone;
1002
+ mode: "newAnchor" | "overrideSelection" | "updateAnchor";
1003
+ }
1004
+ interface ZonesSelected extends SelectionEventPayload {
1005
+ type: "ZonesSelected";
1006
+ }
1007
+ interface HeadersSelected extends SelectionEventPayload {
1008
+ type: "HeadersSelected";
828
1009
  }
829
- declare type CollaborationMessage = RevisionUndoneMessage | RevisionRedoneMessage | RemoteRevisionMessage | SnapshotMessage | SnapshotCreatedMessage | ClientMovedMessage | ClientJoinedMessage | ClientLeftMessage;
830
- declare type StateUpdateMessage = Extract<CollaborationMessage, {
831
- nextRevisionId: UID;
832
- }>;
833
- declare type NewMessageCallback<T = any> = (message: T) => void;
1010
+ interface AlterZone extends SelectionEventPayload {
1011
+ type: "AlterZone";
1012
+ }
1013
+ declare type SelectionEvent = Readonly<ZonesSelected | HeadersSelected | AlterZone>;
1014
+
1015
+ interface StreamCallbacks<Event> {
1016
+ handleEvent: (event: Event) => void;
1017
+ /** this callback will only be called when another consumer captures the stream,
1018
+ * not when the current consumer decides to release itself */
1019
+ release?: () => void;
1020
+ }
1021
+
1022
+ declare type StatefulStream<Event, State> = {
1023
+ capture(owner: unknown, state: State, callbacks: StreamCallbacks<Event>): void;
1024
+ registerAsDefault: (owner: unknown, state: State, callbacks: StreamCallbacks<Event>) => void;
1025
+ resetDefaultAnchor: (owner: unknown, state: State) => void;
1026
+ resetAnchor: (owner: unknown, state: State) => void;
1027
+ observe: (owner: unknown, callbacks: StreamCallbacks<Event>) => void;
1028
+ release: (owner: unknown) => void;
1029
+ getBackToDefault(): void;
1030
+ };
834
1031
  /**
835
- * The transport service allows to communicate between multiple clients.
836
- * A client can send any message to others.
837
- * The service will handle all networking details internally.
1032
+ * Allows to select cells in the grid and update the selection
838
1033
  */
839
- interface TransportService<T = any> {
840
- /**
841
- * Send a message to all clients
842
- */
843
- sendMessage: (message: T) => void;
844
- /**
845
- * Register a callback function which will be called each time
846
- * a new message is received.
847
- * The new message is given to the callback.
848
- *
849
- * ```js
850
- * transportService.onNewMessage(id, (message) => {
851
- * // ... handle the new message
852
- * })
853
- * ```
854
- * The `id` is used to unregister this callback when the session is closed.
855
- */
856
- onNewMessage: (id: UID, callback: NewMessageCallback<T>) => void;
857
- /**
858
- * Unregister a callback linked to the given id
859
- */
860
- leave: (id: UID) => void;
1034
+ interface SelectionProcessor {
1035
+ selectZone(anchor: AnchorZone): DispatchResult;
1036
+ selectCell(col: number, row: number): DispatchResult;
1037
+ moveAnchorCell(direction: SelectionDirection, step: SelectionStep): DispatchResult;
1038
+ setAnchorCorner(col: number, row: number): DispatchResult;
1039
+ addCellToSelection(col: number, row: number): DispatchResult;
1040
+ resizeAnchorZone(direction: SelectionDirection, step: SelectionStep): DispatchResult;
1041
+ selectColumn(index: number, mode: SelectionEvent["mode"]): DispatchResult;
1042
+ selectRow(index: number, mode: SelectionEvent["mode"]): DispatchResult;
1043
+ selectAll(): DispatchResult;
1044
+ loopSelection(): DispatchResult;
1045
+ selectTableAroundSelection(): DispatchResult;
861
1046
  }
1047
+ declare type SelectionStreamProcessor = SelectionProcessor & StatefulStream<SelectionEvent, AnchorZone>;
862
1048
 
863
1049
  declare type FilePath = string;
864
1050
  /**
@@ -944,7 +1130,6 @@ declare class Model extends EventBus<any> implements CommandDispatcher {
944
1130
  private featurePlugins;
945
1131
  private statefulUIPlugins;
946
1132
  private coreViewsPlugins;
947
- private history;
948
1133
  private range;
949
1134
  private session;
950
1135
  /**
@@ -984,10 +1169,9 @@ declare class Model extends EventBus<any> implements CommandDispatcher {
984
1169
  */
985
1170
  private coreGetters;
986
1171
  uuidGenerator: UuidGenerator;
1172
+ private readonly handlers;
1173
+ private readonly coreHandlers;
987
1174
  constructor(data?: any, config?: Partial<ModelConfig>, stateUpdateMessages?: StateUpdateMessage[], uuidGenerator?: UuidGenerator, verboseImport?: boolean);
988
- get handlers(): CommandHandler<Command>[];
989
- get coreHandlers(): CommandHandler<Command>[];
990
- get allUIPlugins(): UIPlugin[];
991
1175
  joinSession(): void;
992
1176
  leaveSession(): void;
993
1177
  private setupUiPlugin;
@@ -1172,6 +1356,7 @@ interface UIPluginConfig {
1172
1356
  readonly uiActions: UIActions;
1173
1357
  readonly custom: ModelConfig["custom"];
1174
1358
  readonly lazyEvaluation: boolean;
1359
+ readonly session: Session;
1175
1360
  }
1176
1361
  interface UIPluginConstructor {
1177
1362
  new (config: UIPluginConfig): UIPlugin;
@@ -1476,8 +1661,8 @@ interface PositionDependentCommand {
1476
1661
  col: number;
1477
1662
  row: number;
1478
1663
  }
1479
- declare const invalidateEvaluationCommands: Set<"UPDATE_CELL" | "UPDATE_CELL_POSITION" | "CLEAR_CELL" | "DELETE_CONTENT" | "ADD_COLUMNS_ROWS" | "REMOVE_COLUMNS_ROWS" | "RESIZE_COLUMNS_ROWS" | "HIDE_COLUMNS_ROWS" | "UNHIDE_COLUMNS_ROWS" | "SET_GRID_LINES_VISIBILITY" | "FREEZE_COLUMNS" | "FREEZE_ROWS" | "UNFREEZE_COLUMNS_ROWS" | "UNFREEZE_COLUMNS" | "UNFREEZE_ROWS" | "ADD_MERGE" | "REMOVE_MERGE" | "CREATE_SHEET" | "DELETE_SHEET" | "DUPLICATE_SHEET" | "MOVE_SHEET" | "RENAME_SHEET" | "HIDE_SHEET" | "SHOW_SHEET" | "MOVE_RANGES" | "ADD_CONDITIONAL_FORMAT" | "REMOVE_CONDITIONAL_FORMAT" | "MOVE_CONDITIONAL_FORMAT" | "CREATE_FIGURE" | "DELETE_FIGURE" | "UPDATE_FIGURE" | "SET_FORMATTING" | "CLEAR_FORMATTING" | "SET_BORDER" | "CREATE_CHART" | "UPDATE_CHART" | "CREATE_IMAGE" | "CREATE_FILTER_TABLE" | "REMOVE_FILTER_TABLE" | "REQUEST_UNDO" | "REQUEST_REDO" | "UNDO" | "REDO" | "ENABLE_NEW_SELECTION_INPUT" | "DISABLE_SELECTION_INPUT" | "UNFOCUS_SELECTION_INPUT" | "FOCUS_RANGE" | "ADD_EMPTY_RANGE" | "REMOVE_RANGE" | "CHANGE_RANGE" | "COPY" | "CUT" | "PASTE" | "CLEAN_CLIPBOARD_HIGHLIGHT" | "AUTOFILL_CELL" | "PASTE_FROM_OS_CLIPBOARD" | "ACTIVATE_PAINT_FORMAT" | "PASTE_CONDITIONAL_FORMAT" | "AUTORESIZE_COLUMNS" | "AUTORESIZE_ROWS" | "MOVE_COLUMNS_ROWS" | "ACTIVATE_SHEET" | "PREPARE_SELECTION_INPUT_EXPANSION" | "STOP_SELECTION_INPUT" | "EVALUATE_CELLS" | "CHANGE_HIGHLIGHT" | "START_CHANGE_HIGHLIGHT" | "SET_HIGHLIGHT_COLOR" | "STOP_COMPOSER_RANGE_SELECTION" | "START_EDITION" | "STOP_EDITION" | "SET_CURRENT_CONTENT" | "CHANGE_COMPOSER_CURSOR_SELECTION" | "REPLACE_COMPOSER_CURSOR_SELECTION" | "CYCLE_EDITION_REFERENCES" | "START" | "AUTOFILL" | "AUTOFILL_SELECT" | "SET_FORMULA_VISIBILITY" | "AUTOFILL_AUTO" | "SELECT_FIGURE" | "UPDATE_SEARCH" | "REFRESH_SEARCH" | "CLEAR_SEARCH" | "SELECT_SEARCH_PREVIOUS_MATCH" | "SELECT_SEARCH_NEXT_MATCH" | "REPLACE_SEARCH" | "REPLACE_ALL_SEARCH" | "SORT_CELLS" | "SET_DECIMAL" | "RESIZE_SHEETVIEW" | "SUM_SELECTION" | "DELETE_CELL" | "INSERT_CELL" | "SET_VIEWPORT_OFFSET" | "SHIFT_VIEWPORT_DOWN" | "SHIFT_VIEWPORT_UP" | "OPEN_CELL_POPOVER" | "CLOSE_CELL_POPOVER" | "ACTIVATE_NEXT_SHEET" | "ACTIVATE_PREVIOUS_SHEET" | "UPDATE_FILTER">;
1480
- declare const readonlyAllowedCommands: Set<"UPDATE_CELL" | "UPDATE_CELL_POSITION" | "CLEAR_CELL" | "DELETE_CONTENT" | "ADD_COLUMNS_ROWS" | "REMOVE_COLUMNS_ROWS" | "RESIZE_COLUMNS_ROWS" | "HIDE_COLUMNS_ROWS" | "UNHIDE_COLUMNS_ROWS" | "SET_GRID_LINES_VISIBILITY" | "FREEZE_COLUMNS" | "FREEZE_ROWS" | "UNFREEZE_COLUMNS_ROWS" | "UNFREEZE_COLUMNS" | "UNFREEZE_ROWS" | "ADD_MERGE" | "REMOVE_MERGE" | "CREATE_SHEET" | "DELETE_SHEET" | "DUPLICATE_SHEET" | "MOVE_SHEET" | "RENAME_SHEET" | "HIDE_SHEET" | "SHOW_SHEET" | "MOVE_RANGES" | "ADD_CONDITIONAL_FORMAT" | "REMOVE_CONDITIONAL_FORMAT" | "MOVE_CONDITIONAL_FORMAT" | "CREATE_FIGURE" | "DELETE_FIGURE" | "UPDATE_FIGURE" | "SET_FORMATTING" | "CLEAR_FORMATTING" | "SET_BORDER" | "CREATE_CHART" | "UPDATE_CHART" | "CREATE_IMAGE" | "CREATE_FILTER_TABLE" | "REMOVE_FILTER_TABLE" | "REQUEST_UNDO" | "REQUEST_REDO" | "UNDO" | "REDO" | "ENABLE_NEW_SELECTION_INPUT" | "DISABLE_SELECTION_INPUT" | "UNFOCUS_SELECTION_INPUT" | "FOCUS_RANGE" | "ADD_EMPTY_RANGE" | "REMOVE_RANGE" | "CHANGE_RANGE" | "COPY" | "CUT" | "PASTE" | "CLEAN_CLIPBOARD_HIGHLIGHT" | "AUTOFILL_CELL" | "PASTE_FROM_OS_CLIPBOARD" | "ACTIVATE_PAINT_FORMAT" | "PASTE_CONDITIONAL_FORMAT" | "AUTORESIZE_COLUMNS" | "AUTORESIZE_ROWS" | "MOVE_COLUMNS_ROWS" | "ACTIVATE_SHEET" | "PREPARE_SELECTION_INPUT_EXPANSION" | "STOP_SELECTION_INPUT" | "EVALUATE_CELLS" | "CHANGE_HIGHLIGHT" | "START_CHANGE_HIGHLIGHT" | "SET_HIGHLIGHT_COLOR" | "STOP_COMPOSER_RANGE_SELECTION" | "START_EDITION" | "STOP_EDITION" | "SET_CURRENT_CONTENT" | "CHANGE_COMPOSER_CURSOR_SELECTION" | "REPLACE_COMPOSER_CURSOR_SELECTION" | "CYCLE_EDITION_REFERENCES" | "START" | "AUTOFILL" | "AUTOFILL_SELECT" | "SET_FORMULA_VISIBILITY" | "AUTOFILL_AUTO" | "SELECT_FIGURE" | "UPDATE_SEARCH" | "REFRESH_SEARCH" | "CLEAR_SEARCH" | "SELECT_SEARCH_PREVIOUS_MATCH" | "SELECT_SEARCH_NEXT_MATCH" | "REPLACE_SEARCH" | "REPLACE_ALL_SEARCH" | "SORT_CELLS" | "SET_DECIMAL" | "RESIZE_SHEETVIEW" | "SUM_SELECTION" | "DELETE_CELL" | "INSERT_CELL" | "SET_VIEWPORT_OFFSET" | "SHIFT_VIEWPORT_DOWN" | "SHIFT_VIEWPORT_UP" | "OPEN_CELL_POPOVER" | "CLOSE_CELL_POPOVER" | "ACTIVATE_NEXT_SHEET" | "ACTIVATE_PREVIOUS_SHEET" | "UPDATE_FILTER">;
1664
+ declare const invalidateEvaluationCommands: Set<"UPDATE_CELL" | "UPDATE_CELL_POSITION" | "CLEAR_CELL" | "DELETE_CONTENT" | "ADD_COLUMNS_ROWS" | "REMOVE_COLUMNS_ROWS" | "RESIZE_COLUMNS_ROWS" | "HIDE_COLUMNS_ROWS" | "UNHIDE_COLUMNS_ROWS" | "SET_GRID_LINES_VISIBILITY" | "FREEZE_COLUMNS" | "FREEZE_ROWS" | "UNFREEZE_COLUMNS_ROWS" | "UNFREEZE_COLUMNS" | "UNFREEZE_ROWS" | "ADD_MERGE" | "REMOVE_MERGE" | "CREATE_SHEET" | "DELETE_SHEET" | "DUPLICATE_SHEET" | "MOVE_SHEET" | "RENAME_SHEET" | "HIDE_SHEET" | "SHOW_SHEET" | "MOVE_RANGES" | "ADD_CONDITIONAL_FORMAT" | "REMOVE_CONDITIONAL_FORMAT" | "MOVE_CONDITIONAL_FORMAT" | "CREATE_FIGURE" | "DELETE_FIGURE" | "UPDATE_FIGURE" | "SET_FORMATTING" | "CLEAR_FORMATTING" | "SET_BORDER" | "CREATE_CHART" | "UPDATE_CHART" | "CREATE_IMAGE" | "CREATE_FILTER_TABLE" | "REMOVE_FILTER_TABLE" | "SORT_CELLS" | "SET_DECIMAL" | "REQUEST_UNDO" | "REQUEST_REDO" | "UNDO" | "REDO" | "ENABLE_NEW_SELECTION_INPUT" | "DISABLE_SELECTION_INPUT" | "UNFOCUS_SELECTION_INPUT" | "FOCUS_RANGE" | "ADD_EMPTY_RANGE" | "REMOVE_RANGE" | "CHANGE_RANGE" | "COPY" | "CUT" | "PASTE" | "REPEAT_PASTE" | "CLEAN_CLIPBOARD_HIGHLIGHT" | "AUTOFILL_CELL" | "PASTE_FROM_OS_CLIPBOARD" | "ACTIVATE_PAINT_FORMAT" | "PASTE_CONDITIONAL_FORMAT" | "AUTORESIZE_COLUMNS" | "AUTORESIZE_ROWS" | "MOVE_COLUMNS_ROWS" | "ACTIVATE_SHEET" | "PREPARE_SELECTION_INPUT_EXPANSION" | "STOP_SELECTION_INPUT" | "EVALUATE_CELLS" | "CHANGE_HIGHLIGHT" | "START_CHANGE_HIGHLIGHT" | "SET_HIGHLIGHT_COLOR" | "STOP_COMPOSER_RANGE_SELECTION" | "START_EDITION" | "STOP_EDITION" | "SET_CURRENT_CONTENT" | "CHANGE_COMPOSER_CURSOR_SELECTION" | "REPLACE_COMPOSER_CURSOR_SELECTION" | "CYCLE_EDITION_REFERENCES" | "START" | "AUTOFILL" | "AUTOFILL_SELECT" | "SET_FORMULA_VISIBILITY" | "AUTOFILL_AUTO" | "SELECT_FIGURE" | "UPDATE_SEARCH" | "REFRESH_SEARCH" | "CLEAR_SEARCH" | "SELECT_SEARCH_PREVIOUS_MATCH" | "SELECT_SEARCH_NEXT_MATCH" | "REPLACE_SEARCH" | "REPLACE_ALL_SEARCH" | "RESIZE_SHEETVIEW" | "SUM_SELECTION" | "DELETE_CELL" | "INSERT_CELL" | "SET_VIEWPORT_OFFSET" | "SHIFT_VIEWPORT_DOWN" | "SHIFT_VIEWPORT_UP" | "OPEN_CELL_POPOVER" | "CLOSE_CELL_POPOVER" | "ACTIVATE_NEXT_SHEET" | "ACTIVATE_PREVIOUS_SHEET" | "UPDATE_FILTER" | "SPLIT_TEXT_INTO_COLUMNS">;
1665
+ declare const readonlyAllowedCommands: Set<"UPDATE_CELL" | "UPDATE_CELL_POSITION" | "CLEAR_CELL" | "DELETE_CONTENT" | "ADD_COLUMNS_ROWS" | "REMOVE_COLUMNS_ROWS" | "RESIZE_COLUMNS_ROWS" | "HIDE_COLUMNS_ROWS" | "UNHIDE_COLUMNS_ROWS" | "SET_GRID_LINES_VISIBILITY" | "FREEZE_COLUMNS" | "FREEZE_ROWS" | "UNFREEZE_COLUMNS_ROWS" | "UNFREEZE_COLUMNS" | "UNFREEZE_ROWS" | "ADD_MERGE" | "REMOVE_MERGE" | "CREATE_SHEET" | "DELETE_SHEET" | "DUPLICATE_SHEET" | "MOVE_SHEET" | "RENAME_SHEET" | "HIDE_SHEET" | "SHOW_SHEET" | "MOVE_RANGES" | "ADD_CONDITIONAL_FORMAT" | "REMOVE_CONDITIONAL_FORMAT" | "MOVE_CONDITIONAL_FORMAT" | "CREATE_FIGURE" | "DELETE_FIGURE" | "UPDATE_FIGURE" | "SET_FORMATTING" | "CLEAR_FORMATTING" | "SET_BORDER" | "CREATE_CHART" | "UPDATE_CHART" | "CREATE_IMAGE" | "CREATE_FILTER_TABLE" | "REMOVE_FILTER_TABLE" | "SORT_CELLS" | "SET_DECIMAL" | "REQUEST_UNDO" | "REQUEST_REDO" | "UNDO" | "REDO" | "ENABLE_NEW_SELECTION_INPUT" | "DISABLE_SELECTION_INPUT" | "UNFOCUS_SELECTION_INPUT" | "FOCUS_RANGE" | "ADD_EMPTY_RANGE" | "REMOVE_RANGE" | "CHANGE_RANGE" | "COPY" | "CUT" | "PASTE" | "REPEAT_PASTE" | "CLEAN_CLIPBOARD_HIGHLIGHT" | "AUTOFILL_CELL" | "PASTE_FROM_OS_CLIPBOARD" | "ACTIVATE_PAINT_FORMAT" | "PASTE_CONDITIONAL_FORMAT" | "AUTORESIZE_COLUMNS" | "AUTORESIZE_ROWS" | "MOVE_COLUMNS_ROWS" | "ACTIVATE_SHEET" | "PREPARE_SELECTION_INPUT_EXPANSION" | "STOP_SELECTION_INPUT" | "EVALUATE_CELLS" | "CHANGE_HIGHLIGHT" | "START_CHANGE_HIGHLIGHT" | "SET_HIGHLIGHT_COLOR" | "STOP_COMPOSER_RANGE_SELECTION" | "START_EDITION" | "STOP_EDITION" | "SET_CURRENT_CONTENT" | "CHANGE_COMPOSER_CURSOR_SELECTION" | "REPLACE_COMPOSER_CURSOR_SELECTION" | "CYCLE_EDITION_REFERENCES" | "START" | "AUTOFILL" | "AUTOFILL_SELECT" | "SET_FORMULA_VISIBILITY" | "AUTOFILL_AUTO" | "SELECT_FIGURE" | "UPDATE_SEARCH" | "REFRESH_SEARCH" | "CLEAR_SEARCH" | "SELECT_SEARCH_PREVIOUS_MATCH" | "SELECT_SEARCH_NEXT_MATCH" | "REPLACE_SEARCH" | "REPLACE_ALL_SEARCH" | "RESIZE_SHEETVIEW" | "SUM_SELECTION" | "DELETE_CELL" | "INSERT_CELL" | "SET_VIEWPORT_OFFSET" | "SHIFT_VIEWPORT_DOWN" | "SHIFT_VIEWPORT_UP" | "OPEN_CELL_POPOVER" | "CLOSE_CELL_POPOVER" | "ACTIVATE_NEXT_SHEET" | "ACTIVATE_PREVIOUS_SHEET" | "UPDATE_FILTER" | "SPLIT_TEXT_INTO_COLUMNS">;
1481
1666
  declare const coreTypes: Set<"UPDATE_CELL" | "UPDATE_CELL_POSITION" | "CLEAR_CELL" | "DELETE_CONTENT" | "ADD_COLUMNS_ROWS" | "REMOVE_COLUMNS_ROWS" | "RESIZE_COLUMNS_ROWS" | "HIDE_COLUMNS_ROWS" | "UNHIDE_COLUMNS_ROWS" | "SET_GRID_LINES_VISIBILITY" | "FREEZE_COLUMNS" | "FREEZE_ROWS" | "UNFREEZE_COLUMNS_ROWS" | "UNFREEZE_COLUMNS" | "UNFREEZE_ROWS" | "ADD_MERGE" | "REMOVE_MERGE" | "CREATE_SHEET" | "DELETE_SHEET" | "DUPLICATE_SHEET" | "MOVE_SHEET" | "RENAME_SHEET" | "HIDE_SHEET" | "SHOW_SHEET" | "MOVE_RANGES" | "ADD_CONDITIONAL_FORMAT" | "REMOVE_CONDITIONAL_FORMAT" | "MOVE_CONDITIONAL_FORMAT" | "CREATE_FIGURE" | "DELETE_FIGURE" | "UPDATE_FIGURE" | "SET_FORMATTING" | "CLEAR_FORMATTING" | "SET_BORDER" | "CREATE_CHART" | "UPDATE_CHART" | "CREATE_IMAGE" | "CREATE_FILTER_TABLE" | "REMOVE_FILTER_TABLE">;
1482
1667
  interface UpdateCellCommand extends PositionDependentCommand {
1483
1668
  type: "UPDATE_CELL";
@@ -1690,6 +1875,11 @@ interface PasteCommand {
1690
1875
  target: Zone[];
1691
1876
  pasteOption?: ClipboardPasteOptions;
1692
1877
  }
1878
+ interface RepeatPasteCommand {
1879
+ type: "REPEAT_PASTE";
1880
+ target: Zone[];
1881
+ pasteOption?: ClipboardPasteOptions;
1882
+ }
1693
1883
  interface CleanClipBoardHighlightCommand {
1694
1884
  type: "CLEAN_CLIPBOARD_HIGHLIGHT";
1695
1885
  }
@@ -1800,1036 +1990,833 @@ interface DeleteContentCommand {
1800
1990
  sheetId: UID;
1801
1991
  target: Zone[];
1802
1992
  }
1803
- interface ClearCellCommand {
1804
- type: "CLEAR_CELL";
1805
- sheetId: UID;
1806
- col: HeaderIndex;
1807
- row: HeaderIndex;
1808
- }
1809
- interface UndoCommand {
1810
- type: "UNDO";
1811
- commands: readonly CoreCommand[];
1812
- }
1813
- interface RedoCommand {
1814
- type: "REDO";
1815
- commands: readonly CoreCommand[];
1816
- }
1817
- interface RequestUndoCommand {
1818
- type: "REQUEST_UNDO";
1819
- }
1820
- interface RequestRedoCommand {
1821
- type: "REQUEST_REDO";
1822
- }
1823
- interface StartCommand {
1824
- type: "START";
1825
- }
1826
- interface AutofillCommand {
1827
- type: "AUTOFILL";
1828
- }
1829
- interface AutofillSelectCommand {
1830
- type: "AUTOFILL_SELECT";
1831
- col: HeaderIndex;
1832
- row: HeaderIndex;
1833
- }
1834
- interface AutofillAutoCommand {
1835
- type: "AUTOFILL_AUTO";
1836
- }
1837
- /**
1838
- * Create a new state for a SelectionInput component
1839
- */
1840
- interface NewInputCommand {
1841
- type: "ENABLE_NEW_SELECTION_INPUT";
1842
- /**
1843
- * Identifier to use to reference this state.
1844
- */
1845
- id: string;
1846
- /**
1847
- * Initial ranges for the state.
1848
- * e.g. ["B4", "A1:A3"]
1849
- */
1850
- initialRanges?: string[];
1851
- /**
1852
- * is the input limited to one range or has no limit ?
1853
- */
1854
- hasSingleRange?: boolean;
1855
- }
1856
- /**
1857
- * Delete an identified SelectionInput state.
1858
- */
1859
- interface RemoveInputCommand {
1860
- type: "DISABLE_SELECTION_INPUT";
1861
- /** SelectionComponent id */
1862
- id: string;
1863
- }
1864
- interface UnfocusInputCommand {
1865
- type: "UNFOCUS_SELECTION_INPUT";
1866
- }
1867
- /**
1868
- * Set the focus on a given range of a SelectionComponent state.
1869
- */
1870
- interface FocusInputCommand {
1871
- type: "FOCUS_RANGE";
1872
- /** SelectionComponent id */
1873
- id: string;
1874
- /**
1875
- * Range to focus
1876
- */
1877
- rangeId: number;
1878
- }
1879
- /**
1880
- * Add an empty range at the end of a SelectionComponent state
1881
- * and focus it.
1882
- */
1883
- interface AddEmptyRangeCommand {
1884
- type: "ADD_EMPTY_RANGE";
1885
- /** SelectionComponent id */
1886
- id: string;
1887
- }
1888
- /**
1889
- * Remove a given range in a SelectionComponent state
1890
- */
1891
- interface RemoveRangeCommand {
1892
- type: "REMOVE_RANGE";
1893
- /** SelectionComponent id */
1894
- id: string;
1895
- /** The range to be removed */
1896
- rangeId: number;
1897
- }
1898
- /**
1899
- * Set a new value for a given range of a SelectionComponent state.
1900
- */
1901
- interface ChangeRangeCommand {
1902
- type: "CHANGE_RANGE";
1903
- /** SelectionComponent id */
1904
- id: string;
1905
- /** The range to be changed */
1906
- rangeId: number;
1907
- /**
1908
- * Range to set in the input. Invalid ranges are also accepted.
1909
- * e.g. "B2:B3" or the invalid "A5:"
1910
- */
1911
- value: string;
1912
- }
1913
- interface SelectFigureCommand {
1914
- type: "SELECT_FIGURE";
1915
- id: UID;
1916
- }
1917
- interface UpdateSearchCommand {
1918
- type: "UPDATE_SEARCH";
1919
- toSearch: string;
1920
- searchOptions: SearchOptions;
1921
- }
1922
- interface ClearSearchCommand {
1923
- type: "CLEAR_SEARCH";
1924
- }
1925
- interface RefreshSearchCommand {
1926
- type: "REFRESH_SEARCH";
1927
- }
1928
- interface SelectSearchPreviousCommand {
1929
- type: "SELECT_SEARCH_PREVIOUS_MATCH";
1930
- }
1931
- interface SelectSearchNextCommand {
1932
- type: "SELECT_SEARCH_NEXT_MATCH";
1933
- }
1934
- interface ReplaceSearchCommand {
1935
- type: "REPLACE_SEARCH";
1936
- replaceWith: string;
1937
- }
1938
- interface ReplaceAllSearchCommand {
1939
- type: "REPLACE_ALL_SEARCH";
1940
- replaceWith: string;
1941
- }
1942
- interface SortCommand {
1943
- type: "SORT_CELLS";
1944
- sheetId: UID;
1945
- col: number;
1946
- row: number;
1947
- zone: Zone;
1948
- sortDirection: SortDirection;
1949
- sortOptions?: SortOptions;
1950
- }
1951
- declare type SortDirection = "ascending" | "descending";
1952
- interface ResizeViewportCommand {
1953
- type: "RESIZE_SHEETVIEW";
1954
- width: Pixel;
1955
- height: Pixel;
1956
- gridOffsetX?: Pixel;
1957
- gridOffsetY?: Pixel;
1958
- }
1959
- interface SetViewportOffsetCommand {
1960
- type: "SET_VIEWPORT_OFFSET";
1961
- offsetX: Pixel;
1962
- offsetY: Pixel;
1963
- }
1964
- /**
1965
- * Shift the viewport down by the viewport height
1966
- */
1967
- interface MoveViewportDownCommand {
1968
- type: "SHIFT_VIEWPORT_DOWN";
1969
- }
1970
- /**
1971
- * Shift the viewport up by the viewport height
1972
- */
1973
- interface MoveViewportUpCommand {
1974
- type: "SHIFT_VIEWPORT_UP";
1975
- }
1976
- /**
1977
- * Sum data according to the selected zone(s) in the appropriated
1978
- * cells.
1979
- */
1980
- interface SumSelectionCommand {
1981
- type: "SUM_SELECTION";
1993
+ interface ClearCellCommand extends PositionDependentCommand {
1994
+ type: "CLEAR_CELL";
1982
1995
  }
1983
- interface DeleteCellCommand {
1984
- type: "DELETE_CELL";
1985
- shiftDimension: Dimension;
1986
- zone: Zone;
1996
+ interface UndoCommand {
1997
+ type: "UNDO";
1998
+ commands: readonly CoreCommand[];
1987
1999
  }
1988
- interface InsertCellCommand {
1989
- type: "INSERT_CELL";
1990
- shiftDimension: Dimension;
1991
- zone: Zone;
2000
+ interface RedoCommand {
2001
+ type: "REDO";
2002
+ commands: readonly CoreCommand[];
1992
2003
  }
1993
- interface PasteCFCommand {
1994
- type: "PASTE_CONDITIONAL_FORMAT";
1995
- origin: CellPosition;
1996
- target: CellPosition;
1997
- operation: "CUT" | "COPY";
2004
+ interface RequestUndoCommand {
2005
+ type: "REQUEST_UNDO";
1998
2006
  }
1999
- interface ActivateNextSheetCommand {
2000
- type: "ACTIVATE_NEXT_SHEET";
2007
+ interface RequestRedoCommand {
2008
+ type: "REQUEST_REDO";
2001
2009
  }
2002
- interface ActivatePreviousSheetCommand {
2003
- type: "ACTIVATE_PREVIOUS_SHEET";
2010
+ interface StartCommand {
2011
+ type: "START";
2004
2012
  }
2005
- interface OpenCellPopoverCommand {
2006
- type: "OPEN_CELL_POPOVER";
2007
- col: number;
2008
- row: number;
2009
- popoverType: CellPopoverType;
2013
+ interface AutofillCommand {
2014
+ type: "AUTOFILL";
2010
2015
  }
2011
- interface CloseCellPopoverCommand {
2012
- type: "CLOSE_CELL_POPOVER";
2016
+ interface AutofillSelectCommand {
2017
+ type: "AUTOFILL_SELECT";
2018
+ col: HeaderIndex;
2019
+ row: HeaderIndex;
2020
+ }
2021
+ interface AutofillAutoCommand {
2022
+ type: "AUTOFILL_AUTO";
2013
2023
  }
2014
- declare type CoreCommand =
2015
- /** CELLS */
2016
- UpdateCellCommand | UpdateCellPositionCommand | ClearCellCommand | DeleteContentCommand
2017
- /** GRID SHAPE */
2018
- | AddColumnsRowsCommand | RemoveColumnsRowsCommand | ResizeColumnsRowsCommand | HideColumnsRowsCommand | UnhideColumnsRowsCommand | SetGridLinesVisibilityCommand | FreezeColumnsCommand | FreezeRowsCommand | UnfreezeColumnsRowsCommand | UnfreezeColumnsCommand | UnfreezeRowsCommand
2019
- /** MERGE */
2020
- | AddMergeCommand | RemoveMergeCommand
2021
- /** SHEETS MANIPULATION */
2022
- | CreateSheetCommand | DeleteSheetCommand | DuplicateSheetCommand | MoveSheetCommand | RenameSheetCommand | HideSheetCommand | ShowSheetCommand
2023
- /** RANGES MANIPULATION */
2024
- | MoveRangeCommand
2025
- /** CONDITIONAL FORMAT */
2026
- | AddConditionalFormatCommand | RemoveConditionalFormatCommand | MoveConditionalFormatCommand
2027
- /** FIGURES */
2028
- | CreateFigureCommand | DeleteFigureCommand | UpdateFigureCommand
2029
- /** FORMATTING */
2030
- | SetFormattingCommand | ClearFormattingCommand | SetBorderCommand
2031
- /** CHART */
2032
- | CreateChartCommand | UpdateChartCommand
2033
- /** Image */
2034
- | CreateImageOverCommand
2035
- /** FILTERS */
2036
- | CreateFilterTableCommand | RemoveFilterTableCommand;
2037
- declare type LocalCommand = RequestUndoCommand | RequestRedoCommand | UndoCommand | RedoCommand | NewInputCommand | RemoveInputCommand | UnfocusInputCommand | FocusInputCommand | AddEmptyRangeCommand | RemoveRangeCommand | ChangeRangeCommand | CopyCommand | CutCommand | PasteCommand | CleanClipBoardHighlightCommand | AutoFillCellCommand | PasteFromOSClipboardCommand | ActivatePaintFormatCommand | PasteCFCommand | AutoresizeColumnsCommand | AutoresizeRowsCommand | MoveColumnsRowsCommand | ActivateSheetCommand | PrepareExpansionCommand | StopSelectionCommand | EvaluateCellsCommand | ChangeHighlightCommand | StartChangeHighlightCommand | SetColorCommand | StopComposerSelectionCommand | StartEditionCommand | StopEditionCommand | SetCurrentContentCommand | ChangeComposerSelectionCommand | ReplaceComposerSelectionCommand | CycleEditionReferencesCommand | StartCommand | AutofillCommand | AutofillSelectCommand | ShowFormulaCommand | AutofillAutoCommand | SelectFigureCommand | UpdateSearchCommand | RefreshSearchCommand | ClearSearchCommand | SelectSearchPreviousCommand | SelectSearchNextCommand | ReplaceSearchCommand | ReplaceAllSearchCommand | SortCommand | SetDecimalCommand | ResizeViewportCommand | SumSelectionCommand | DeleteCellCommand | InsertCellCommand | SetViewportOffsetCommand | MoveViewportDownCommand | MoveViewportUpCommand | OpenCellPopoverCommand | CloseCellPopoverCommand | ActivateNextSheetCommand | ActivatePreviousSheetCommand | UpdateFilterCommand;
2038
- declare type Command = CoreCommand | LocalCommand;
2039
2024
  /**
2040
- * Holds the result of a command dispatch.
2041
- * The command may have been successfully dispatched or cancelled
2042
- * for one or more reasons.
2025
+ * Create a new state for a SelectionInput component
2043
2026
  */
2044
- declare class DispatchResult {
2045
- readonly reasons: CancelledReason[];
2046
- constructor(results?: CommandResult | CommandResult[]);
2027
+ interface NewInputCommand {
2028
+ type: "ENABLE_NEW_SELECTION_INPUT";
2047
2029
  /**
2048
- * Static helper which returns a successful DispatchResult
2030
+ * Identifier to use to reference this state.
2049
2031
  */
2050
- static get Success(): DispatchResult;
2051
- get isSuccessful(): boolean;
2032
+ id: string;
2052
2033
  /**
2053
- * Check if the dispatch has been cancelled because of
2054
- * the given reason.
2034
+ * Initial ranges for the state.
2035
+ * e.g. ["B4", "A1:A3"]
2055
2036
  */
2056
- isCancelledBecause(reason: CancelledReason): boolean;
2057
- }
2058
- declare type CancelledReason = Exclude<CommandResult, CommandResult.Success>;
2059
- declare const enum CommandResult {
2060
- Success = 0,
2061
- CancelledForUnknownReason = 1,
2062
- WillRemoveExistingMerge = 2,
2063
- MergeIsDestructive = 3,
2064
- CellIsMerged = 4,
2065
- InvalidTarget = 5,
2066
- EmptyUndoStack = 6,
2067
- EmptyRedoStack = 7,
2068
- NotEnoughElements = 8,
2069
- NotEnoughSheets = 9,
2070
- MissingSheetName = 10,
2071
- DuplicatedSheetName = 11,
2072
- DuplicatedSheetId = 12,
2073
- ForbiddenCharactersInSheetName = 13,
2074
- WrongSheetMove = 14,
2075
- WrongSheetPosition = 15,
2076
- InvalidAnchorZone = 16,
2077
- SelectionOutOfBound = 17,
2078
- TargetOutOfSheet = 18,
2079
- WrongCutSelection = 19,
2080
- WrongPasteSelection = 20,
2081
- WrongPasteOption = 21,
2082
- WrongFigurePasteOption = 22,
2083
- EmptyClipboard = 23,
2084
- EmptyRange = 24,
2085
- InvalidRange = 25,
2086
- InvalidZones = 26,
2087
- InvalidSheetId = 27,
2088
- InvalidFigureId = 28,
2089
- InputAlreadyFocused = 29,
2090
- MaximumRangesReached = 30,
2091
- InvalidChartDefinition = 31,
2092
- InvalidDataSet = 32,
2093
- InvalidLabelRange = 33,
2094
- InvalidScorecardKeyValue = 34,
2095
- InvalidScorecardBaseline = 35,
2096
- InvalidGaugeDataRange = 36,
2097
- EmptyGaugeRangeMin = 37,
2098
- GaugeRangeMinNaN = 38,
2099
- EmptyGaugeRangeMax = 39,
2100
- GaugeRangeMaxNaN = 40,
2101
- GaugeRangeMinBiggerThanRangeMax = 41,
2102
- GaugeLowerInflectionPointNaN = 42,
2103
- GaugeUpperInflectionPointNaN = 43,
2104
- GaugeLowerBiggerThanUpper = 44,
2105
- InvalidAutofillSelection = 45,
2106
- WrongComposerSelection = 46,
2107
- MinBiggerThanMax = 47,
2108
- LowerBiggerThanUpper = 48,
2109
- MidBiggerThanMax = 49,
2110
- MinBiggerThanMid = 50,
2111
- FirstArgMissing = 51,
2112
- SecondArgMissing = 52,
2113
- MinNaN = 53,
2114
- MidNaN = 54,
2115
- MaxNaN = 55,
2116
- ValueUpperInflectionNaN = 56,
2117
- ValueLowerInflectionNaN = 57,
2118
- MinInvalidFormula = 58,
2119
- MidInvalidFormula = 59,
2120
- MaxInvalidFormula = 60,
2121
- ValueUpperInvalidFormula = 61,
2122
- ValueLowerInvalidFormula = 62,
2123
- InvalidSortZone = 63,
2124
- WaitingSessionConfirmation = 64,
2125
- MergeOverlap = 65,
2126
- TooManyHiddenElements = 66,
2127
- Readonly = 67,
2128
- InvalidViewportSize = 68,
2129
- InvalidScrollingDirection = 69,
2130
- FigureDoesNotExist = 70,
2131
- InvalidConditionalFormatId = 71,
2132
- InvalidCellPopover = 72,
2133
- EmptyTarget = 73,
2134
- InvalidFreezeQuantity = 74,
2135
- FrozenPaneOverlap = 75,
2136
- ValuesNotChanged = 76,
2137
- InvalidFilterZone = 77,
2138
- FilterOverlap = 78,
2139
- FilterNotFound = 79,
2140
- MergeInFilter = 80,
2141
- NonContinuousTargets = 81,
2142
- DuplicatedFigureId = 82,
2143
- InvalidSelectionStep = 83,
2144
- DuplicatedChartId = 84,
2145
- ChartDoesNotExist = 85
2146
- }
2147
- interface CommandHandler<T> {
2148
- allowDispatch(command: T): CommandResult | CommandResult[];
2149
- beforeHandle(command: T): void;
2150
- handle(command: T): void;
2151
- finalize(): void;
2152
- }
2153
- interface CommandDispatcher {
2154
- dispatch<T extends CommandTypes, C extends Extract<Command, {
2155
- type: T;
2156
- }>>(type: {} extends Omit<C, "type"> ? T : never): DispatchResult;
2157
- dispatch<T extends CommandTypes, C extends Extract<Command, {
2158
- type: T;
2159
- }>>(type: T, r: Omit<C, "type">): DispatchResult;
2160
- canDispatch<T extends CommandTypes, C extends Extract<Command, {
2161
- type: T;
2162
- }>>(type: T, r: Omit<C, "type">): DispatchResult;
2163
- }
2164
- interface CoreCommandDispatcher {
2165
- dispatch<T extends CoreCommandTypes, C extends Extract<CoreCommand, {
2166
- type: T;
2167
- }>>(type: {} extends Omit<C, "type"> ? T : never): DispatchResult;
2168
- dispatch<T extends CoreCommandTypes, C extends Extract<CoreCommand, {
2169
- type: T;
2170
- }>>(type: T, r: Omit<C, "type">): DispatchResult;
2171
- canDispatch<T extends CoreCommandTypes, C extends Extract<CoreCommand, {
2172
- type: T;
2173
- }>>(type: T, r: Omit<C, "type">): DispatchResult;
2174
- }
2175
- declare type CommandTypes = Command["type"];
2176
- declare type CoreCommandTypes = CoreCommand["type"];
2177
-
2178
- /**
2179
- * The following type is meant to be used in union with other aliases to prevent
2180
- * Intellisense from resolving it.
2181
- * See https://github.com/microsoft/TypeScript/issues/31940#issuecomment-841712377
2182
- */
2183
- declare type Alias = {} & {};
2184
- declare type HeaderIndex = number & Alias;
2185
- declare type Pixel = number & Alias;
2186
- declare type UID = string & Alias;
2187
- declare type SetDecimalStep = 1 | -1;
2188
- declare type FilterId = UID & Alias;
2189
- declare type FilterTableId = UID & Alias;
2190
- /**
2191
- * CSS style color string
2192
- * e.g. "#ABC", "#AAAFFF", "rgb(30, 80, 16)"
2193
- */
2194
- declare type Color = string & Alias;
2195
- interface RGBA {
2196
- a: number;
2197
- r: number;
2198
- g: number;
2199
- b: number;
2200
- }
2201
- interface Link {
2202
- readonly label: string;
2203
- readonly url: string;
2204
- readonly isExternal: boolean;
2037
+ initialRanges?: string[];
2205
2038
  /**
2206
- * Specifies if the URL is editable by the end user.
2207
- * Special links might not allow it.
2039
+ * is the input limited to one range or has no limit ?
2208
2040
  */
2209
- readonly isUrlEditable: boolean;
2210
- }
2211
- interface Zone {
2212
- left: HeaderIndex;
2213
- right: HeaderIndex;
2214
- top: HeaderIndex;
2215
- bottom: HeaderIndex;
2216
- }
2217
- interface AnchorZone {
2218
- zone: Zone;
2219
- cell: Position$1;
2220
- }
2221
- interface Selection {
2222
- anchor: AnchorZone;
2223
- zones: Zone[];
2041
+ hasSingleRange?: boolean;
2224
2042
  }
2225
- interface UnboundedZone {
2226
- top: HeaderIndex;
2227
- bottom: HeaderIndex | undefined;
2228
- left: HeaderIndex;
2229
- right: HeaderIndex | undefined;
2230
- hasHeader?: boolean;
2043
+ /**
2044
+ * Delete an identified SelectionInput state.
2045
+ */
2046
+ interface RemoveInputCommand {
2047
+ type: "DISABLE_SELECTION_INPUT";
2048
+ /** SelectionComponent id */
2049
+ id: string;
2231
2050
  }
2232
- interface ZoneDimension {
2233
- numberOfRows: HeaderIndex;
2234
- numberOfCols: HeaderIndex;
2051
+ interface UnfocusInputCommand {
2052
+ type: "UNFOCUS_SELECTION_INPUT";
2235
2053
  }
2236
- declare type Align = "left" | "right" | "center" | undefined;
2237
- declare type VerticalAlign = "top" | "middle" | "bottom" | undefined;
2238
- declare type Wrapping = "overflow" | "wrap" | "clip" | undefined;
2239
- interface Style {
2240
- bold?: boolean;
2241
- italic?: boolean;
2242
- strikethrough?: boolean;
2243
- underline?: boolean;
2244
- align?: Align;
2245
- wrapping?: Wrapping;
2246
- verticalAlign?: VerticalAlign;
2247
- fillColor?: Color;
2248
- textColor?: Color;
2249
- fontSize?: number;
2054
+ /**
2055
+ * Set the focus on a given range of a SelectionComponent state.
2056
+ */
2057
+ interface FocusInputCommand {
2058
+ type: "FOCUS_RANGE";
2059
+ /** SelectionComponent id */
2060
+ id: string;
2061
+ /**
2062
+ * Range to focus
2063
+ */
2064
+ rangeId: number;
2250
2065
  }
2251
- interface UpdateCellData {
2252
- content?: string;
2253
- formula?: string;
2254
- style?: Style | null;
2255
- format?: Format;
2066
+ /**
2067
+ * Add an empty range at the end of a SelectionComponent state
2068
+ * and focus it.
2069
+ */
2070
+ interface AddEmptyRangeCommand {
2071
+ type: "ADD_EMPTY_RANGE";
2072
+ /** SelectionComponent id */
2073
+ id: string;
2256
2074
  }
2257
- interface Sheet {
2258
- id: UID;
2259
- name: string;
2260
- numberOfCols: number;
2261
- rows: Row[];
2262
- areGridLinesVisible: boolean;
2263
- isVisible: boolean;
2264
- panes: PaneDivision;
2075
+ /**
2076
+ * Remove a given range in a SelectionComponent state
2077
+ */
2078
+ interface RemoveRangeCommand {
2079
+ type: "REMOVE_RANGE";
2080
+ /** SelectionComponent id */
2081
+ id: string;
2082
+ /** The range to be removed */
2083
+ rangeId: number;
2265
2084
  }
2266
- interface CellPosition {
2267
- col: HeaderIndex;
2268
- row: HeaderIndex;
2269
- sheetId: UID;
2085
+ /**
2086
+ * Set a new value for a given range of a SelectionComponent state.
2087
+ */
2088
+ interface ChangeRangeCommand {
2089
+ type: "CHANGE_RANGE";
2090
+ /** SelectionComponent id */
2091
+ id: string;
2092
+ /** The range to be changed */
2093
+ rangeId: number;
2094
+ /**
2095
+ * Range to set in the input. Invalid ranges are also accepted.
2096
+ * e.g. "B2:B3" or the invalid "A5:"
2097
+ */
2098
+ value: string;
2270
2099
  }
2271
- declare type BorderStyle = "thin" | "medium" | "thick" | "dashed" | "dotted" | "double";
2272
- declare type BorderDescr = [BorderStyle, Color];
2273
- interface Border$1 {
2274
- top?: BorderDescr;
2275
- left?: BorderDescr;
2276
- bottom?: BorderDescr;
2277
- right?: BorderDescr;
2100
+ interface SelectFigureCommand {
2101
+ type: "SELECT_FIGURE";
2102
+ id: UID;
2278
2103
  }
2279
- declare type ReferenceDenormalizer = (range: Range, isMeta: boolean, functionName: string, paramNumber: number) => any | any[][];
2280
- declare type EnsureRange = (range: Range) => any[][];
2281
- declare type _CompiledFormula = (deps: Range[], refFn: ReferenceDenormalizer, range: EnsureRange, ctx: {}) => FormulaReturn;
2282
- interface CompiledFormula {
2283
- execute: _CompiledFormula;
2284
- tokens: Token[];
2285
- dependencies: string[];
2104
+ interface UpdateSearchCommand {
2105
+ type: "UPDATE_SEARCH";
2106
+ toSearch: string;
2107
+ searchOptions: SearchOptions;
2286
2108
  }
2287
- declare type Arg = MatrixArg | PrimitiveArg;
2288
- declare type MatrixArg = ({
2289
- value: CellValue;
2290
- format?: Format;
2291
- } | undefined)[][];
2292
- declare type PrimitiveArg = {
2293
- value: PrimitiveArgValue;
2294
- format?: Format;
2295
- };
2296
- declare type ArgValue = PrimitiveArgValue | MatrixArgValue;
2297
- declare type MatrixArgValue = (CellValue | undefined)[][];
2298
- declare type PrimitiveArgValue = string | number | boolean | null;
2299
- declare type FunctionReturn = {
2300
- value: FunctionReturnValue;
2301
- format?: Format;
2302
- };
2303
- interface FormulaReturn extends Omit<FunctionReturn, "value"> {
2304
- value: FunctionReturnValue | null;
2305
- format?: Format;
2109
+ interface ClearSearchCommand {
2110
+ type: "CLEAR_SEARCH";
2306
2111
  }
2307
- declare type FunctionReturnValue = string | number | boolean;
2308
- interface HeaderDimensions {
2309
- start: Pixel;
2310
- size: Pixel;
2311
- end: Pixel;
2112
+ interface RefreshSearchCommand {
2113
+ type: "REFRESH_SEARCH";
2312
2114
  }
2313
- interface Row {
2314
- cells: Record<number, UID | undefined>;
2115
+ interface SelectSearchPreviousCommand {
2116
+ type: "SELECT_SEARCH_PREVIOUS_MATCH";
2315
2117
  }
2316
- interface Position$1 {
2317
- col: HeaderIndex;
2318
- row: HeaderIndex;
2118
+ interface SelectSearchNextCommand {
2119
+ type: "SELECT_SEARCH_NEXT_MATCH";
2319
2120
  }
2320
- interface PixelPosition {
2321
- x: Pixel;
2322
- y: Pixel;
2121
+ interface ReplaceSearchCommand {
2122
+ type: "REPLACE_SEARCH";
2123
+ replaceWith: string;
2323
2124
  }
2324
- interface Merge extends Zone {
2325
- id: number;
2326
- topLeft: Position$1;
2125
+ interface ReplaceAllSearchCommand {
2126
+ type: "REPLACE_ALL_SEARCH";
2127
+ replaceWith: string;
2327
2128
  }
2328
- interface Highlight$1 {
2329
- zone: Zone;
2129
+ interface SortCommand {
2130
+ type: "SORT_CELLS";
2330
2131
  sheetId: UID;
2331
- color: Color | null;
2132
+ col: number;
2133
+ row: number;
2134
+ zone: Zone;
2135
+ sortDirection: SortDirection;
2136
+ sortOptions?: SortOptions;
2332
2137
  }
2333
- interface PaneDivision {
2334
- /** Represents the number of frozen columns */
2335
- xSplit: number;
2336
- /** Represents the number of frozen rows */
2337
- ySplit: number;
2138
+ declare type SortDirection = "ascending" | "descending";
2139
+ interface ResizeViewportCommand {
2140
+ type: "RESIZE_SHEETVIEW";
2141
+ width: Pixel;
2142
+ height: Pixel;
2143
+ gridOffsetX?: Pixel;
2144
+ gridOffsetY?: Pixel;
2338
2145
  }
2339
- declare type BorderCommand = "all" | "hv" | "h" | "v" | "external" | "left" | "top" | "right" | "bottom" | "clear";
2340
- declare type BorderDescription = {
2341
- vertical?: BorderDescr;
2342
- horizontal?: BorderDescr;
2343
- } | undefined;
2344
- declare const enum DIRECTION {
2345
- UP = "up",
2346
- DOWN = "down",
2347
- LEFT = "left",
2348
- RIGHT = "right"
2146
+ interface SetViewportOffsetCommand {
2147
+ type: "SET_VIEWPORT_OFFSET";
2148
+ offsetX: Pixel;
2149
+ offsetY: Pixel;
2349
2150
  }
2350
- declare type ChangeType = "REMOVE" | "RESIZE" | "MOVE" | "CHANGE" | "NONE";
2351
- declare type ApplyRangeChangeResult = {
2352
- changeType: Exclude<ChangeType, "NONE">;
2353
- range: Range;
2354
- } | {
2355
- changeType: "NONE";
2356
- };
2357
- declare type ApplyRangeChange = (range: Range) => ApplyRangeChangeResult;
2358
- declare type Dimension = "COL" | "ROW";
2359
- declare type ConsecutiveIndexes = HeaderIndex[];
2360
- interface RangeProvider {
2361
- adaptRanges: (applyChange: ApplyRangeChange, sheetId?: UID) => void;
2151
+ /**
2152
+ * Shift the viewport down by the viewport height
2153
+ */
2154
+ interface MoveViewportDownCommand {
2155
+ type: "SHIFT_VIEWPORT_DOWN";
2362
2156
  }
2363
- declare type Validation<T> = (toValidate: T) => CommandResult | CommandResult[];
2364
2157
  /**
2365
- * Return the prop's type of a component
2158
+ * Shift the viewport up by the viewport height
2366
2159
  */
2367
- declare type PropsOf<C> = C extends ComponentConstructor<infer Props> ? Props : never;
2160
+ interface MoveViewportUpCommand {
2161
+ type: "SHIFT_VIEWPORT_UP";
2162
+ }
2368
2163
  /**
2369
- * Container for a lazy computed value
2164
+ * Sum data according to the selected zone(s) in the appropriated
2165
+ * cells.
2370
2166
  */
2371
- interface Lazy<T> {
2372
- /**
2373
- * Return the computed value.
2374
- * The value is computed only once and memoized.
2375
- */
2376
- (): T;
2377
- /**
2378
- * Map a lazy value to another lazy value.
2379
- *
2380
- * ```ts
2381
- * // neither function is called here
2382
- * const lazyValue = lazy(() => veryExpensive(...)).map((result) => alsoVeryExpensive(result));
2383
- *
2384
- * // both values are computed now
2385
- * const value = lazyValue()
2386
- * ```
2387
- */
2388
- map: <U>(callback: (value: T) => U) => Lazy<U>;
2167
+ interface SumSelectionCommand {
2168
+ type: "SUM_SELECTION";
2389
2169
  }
2390
- interface Cloneable<T> {
2391
- clone: (args?: Partial<T>) => T;
2170
+ interface DeleteCellCommand {
2171
+ type: "DELETE_CELL";
2172
+ shiftDimension: Dimension;
2173
+ zone: Zone;
2174
+ }
2175
+ interface InsertCellCommand {
2176
+ type: "INSERT_CELL";
2177
+ shiftDimension: Dimension;
2178
+ zone: Zone;
2179
+ }
2180
+ interface PasteCFCommand {
2181
+ type: "PASTE_CONDITIONAL_FORMAT";
2182
+ origin: CellPosition;
2183
+ target: CellPosition;
2184
+ operation: "CUT" | "COPY";
2392
2185
  }
2393
- declare type CSSProperties<P extends string = string> = Record<P, string | undefined>;
2394
- interface SortOptions {
2395
- /** If true sort the headers of the range along with the rest */
2396
- sortHeaders?: boolean;
2397
- /** If true treat empty cells as "0" instead of undefined */
2398
- emptyCellAsZero?: boolean;
2186
+ interface ActivateNextSheetCommand {
2187
+ type: "ACTIVATE_NEXT_SHEET";
2399
2188
  }
2400
- interface MenuMouseEvent extends MouseEvent {
2401
- closedMenuId?: UID;
2189
+ interface ActivatePreviousSheetCommand {
2190
+ type: "ACTIVATE_PREVIOUS_SHEET";
2402
2191
  }
2403
-
2404
- declare type Format = string & Alias;
2405
- declare type FormattedValue = string & Alias;
2406
-
2407
- interface CellAttributes {
2408
- readonly id: UID;
2409
- /**
2410
- * Raw cell content
2411
- */
2412
- readonly content: string;
2413
- readonly style?: Style;
2414
- readonly format?: Format;
2192
+ interface OpenCellPopoverCommand {
2193
+ type: "OPEN_CELL_POPOVER";
2194
+ col: number;
2195
+ row: number;
2196
+ popoverType: CellPopoverType;
2415
2197
  }
2416
- interface LiteralCell extends CellAttributes {
2417
- readonly isFormula: false;
2198
+ interface CloseCellPopoverCommand {
2199
+ type: "CLOSE_CELL_POPOVER";
2418
2200
  }
2419
- interface FormulaCell extends CellAttributes {
2420
- readonly isFormula: true;
2421
- readonly compiledFormula: CompiledFormula;
2422
- readonly dependencies: Range[];
2201
+ interface SplitTextIntoColumnsCommand {
2202
+ type: "SPLIT_TEXT_INTO_COLUMNS";
2203
+ separator: string;
2204
+ addNewColumns: boolean;
2205
+ force?: boolean;
2423
2206
  }
2424
- declare type Cell = LiteralCell | FormulaCell;
2425
- interface EvaluatedCellProperties {
2426
- readonly format?: Format;
2207
+ declare type CoreCommand =
2208
+ /** CELLS */
2209
+ UpdateCellCommand | UpdateCellPositionCommand | ClearCellCommand | DeleteContentCommand
2210
+ /** GRID SHAPE */
2211
+ | AddColumnsRowsCommand | RemoveColumnsRowsCommand | ResizeColumnsRowsCommand | HideColumnsRowsCommand | UnhideColumnsRowsCommand | SetGridLinesVisibilityCommand | FreezeColumnsCommand | FreezeRowsCommand | UnfreezeColumnsRowsCommand | UnfreezeColumnsCommand | UnfreezeRowsCommand
2212
+ /** MERGE */
2213
+ | AddMergeCommand | RemoveMergeCommand
2214
+ /** SHEETS MANIPULATION */
2215
+ | CreateSheetCommand | DeleteSheetCommand | DuplicateSheetCommand | MoveSheetCommand | RenameSheetCommand | HideSheetCommand | ShowSheetCommand
2216
+ /** RANGES MANIPULATION */
2217
+ | MoveRangeCommand
2218
+ /** CONDITIONAL FORMAT */
2219
+ | AddConditionalFormatCommand | RemoveConditionalFormatCommand | MoveConditionalFormatCommand
2220
+ /** FIGURES */
2221
+ | CreateFigureCommand | DeleteFigureCommand | UpdateFigureCommand
2222
+ /** FORMATTING */
2223
+ | SetFormattingCommand | ClearFormattingCommand | SetBorderCommand
2224
+ /** CHART */
2225
+ | CreateChartCommand | UpdateChartCommand
2226
+ /** Image */
2227
+ | CreateImageOverCommand
2228
+ /** FILTERS */
2229
+ | CreateFilterTableCommand | RemoveFilterTableCommand;
2230
+ declare type LocalCommand = RequestUndoCommand | RequestRedoCommand | UndoCommand | RedoCommand | NewInputCommand | RemoveInputCommand | UnfocusInputCommand | FocusInputCommand | AddEmptyRangeCommand | RemoveRangeCommand | ChangeRangeCommand | CopyCommand | CutCommand | PasteCommand | RepeatPasteCommand | CleanClipBoardHighlightCommand | AutoFillCellCommand | PasteFromOSClipboardCommand | ActivatePaintFormatCommand | PasteCFCommand | AutoresizeColumnsCommand | AutoresizeRowsCommand | MoveColumnsRowsCommand | ActivateSheetCommand | PrepareExpansionCommand | StopSelectionCommand | EvaluateCellsCommand | ChangeHighlightCommand | StartChangeHighlightCommand | SetColorCommand | StopComposerSelectionCommand | StartEditionCommand | StopEditionCommand | SetCurrentContentCommand | ChangeComposerSelectionCommand | ReplaceComposerSelectionCommand | CycleEditionReferencesCommand | StartCommand | AutofillCommand | AutofillSelectCommand | ShowFormulaCommand | AutofillAutoCommand | SelectFigureCommand | UpdateSearchCommand | RefreshSearchCommand | ClearSearchCommand | SelectSearchPreviousCommand | SelectSearchNextCommand | ReplaceSearchCommand | ReplaceAllSearchCommand | SortCommand | SetDecimalCommand | ResizeViewportCommand | SumSelectionCommand | DeleteCellCommand | InsertCellCommand | SetViewportOffsetCommand | MoveViewportDownCommand | MoveViewportUpCommand | OpenCellPopoverCommand | CloseCellPopoverCommand | ActivateNextSheetCommand | ActivatePreviousSheetCommand | UpdateFilterCommand | SplitTextIntoColumnsCommand;
2231
+ declare type Command = CoreCommand | LocalCommand;
2232
+ /**
2233
+ * Holds the result of a command dispatch.
2234
+ * The command may have been successfully dispatched or cancelled
2235
+ * for one or more reasons.
2236
+ */
2237
+ declare class DispatchResult {
2238
+ readonly reasons: CancelledReason[];
2239
+ constructor(results?: CommandResult | CommandResult[]);
2427
2240
  /**
2428
- * Cell value formatted based on the format
2241
+ * Static helper which returns a successful DispatchResult
2429
2242
  */
2430
- readonly formattedValue: FormattedValue;
2431
- readonly defaultAlign: "right" | "center" | "left";
2243
+ static get Success(): DispatchResult;
2244
+ get isSuccessful(): boolean;
2432
2245
  /**
2433
- * Can the cell appear in an automatic sum zone.
2246
+ * Check if the dispatch has been cancelled because of
2247
+ * the given reason.
2434
2248
  */
2435
- readonly isAutoSummable: boolean;
2436
- readonly link?: Link;
2249
+ isCancelledBecause(reason: CancelledReason): boolean;
2437
2250
  }
2438
- declare type CellValue = string | number | boolean;
2439
- declare type EvaluatedCell = NumberCell | TextCell | BooleanCell | EmptyCell | ErrorCell;
2440
- interface NumberCell extends EvaluatedCellProperties {
2441
- readonly type: CellValueType.number;
2442
- readonly value: number;
2251
+ declare type CancelledReason = Exclude<CommandResult, CommandResult.Success>;
2252
+ declare const enum CommandResult {
2253
+ Success = 0,
2254
+ CancelledForUnknownReason = 1,
2255
+ WillRemoveExistingMerge = 2,
2256
+ MergeIsDestructive = 3,
2257
+ CellIsMerged = 4,
2258
+ InvalidTarget = 5,
2259
+ EmptyUndoStack = 6,
2260
+ EmptyRedoStack = 7,
2261
+ NotEnoughElements = 8,
2262
+ NotEnoughSheets = 9,
2263
+ MissingSheetName = 10,
2264
+ DuplicatedSheetName = 11,
2265
+ DuplicatedSheetId = 12,
2266
+ ForbiddenCharactersInSheetName = 13,
2267
+ WrongSheetMove = 14,
2268
+ WrongSheetPosition = 15,
2269
+ InvalidAnchorZone = 16,
2270
+ SelectionOutOfBound = 17,
2271
+ TargetOutOfSheet = 18,
2272
+ WrongCutSelection = 19,
2273
+ WrongPasteSelection = 20,
2274
+ WrongPasteOption = 21,
2275
+ WrongFigurePasteOption = 22,
2276
+ EmptyClipboard = 23,
2277
+ EmptyRange = 24,
2278
+ InvalidRange = 25,
2279
+ InvalidZones = 26,
2280
+ InvalidSheetId = 27,
2281
+ InvalidFigureId = 28,
2282
+ InputAlreadyFocused = 29,
2283
+ MaximumRangesReached = 30,
2284
+ InvalidChartDefinition = 31,
2285
+ InvalidDataSet = 32,
2286
+ InvalidLabelRange = 33,
2287
+ InvalidScorecardKeyValue = 34,
2288
+ InvalidScorecardBaseline = 35,
2289
+ InvalidGaugeDataRange = 36,
2290
+ EmptyGaugeRangeMin = 37,
2291
+ GaugeRangeMinNaN = 38,
2292
+ EmptyGaugeRangeMax = 39,
2293
+ GaugeRangeMaxNaN = 40,
2294
+ GaugeRangeMinBiggerThanRangeMax = 41,
2295
+ GaugeLowerInflectionPointNaN = 42,
2296
+ GaugeUpperInflectionPointNaN = 43,
2297
+ GaugeLowerBiggerThanUpper = 44,
2298
+ InvalidAutofillSelection = 45,
2299
+ WrongComposerSelection = 46,
2300
+ MinBiggerThanMax = 47,
2301
+ LowerBiggerThanUpper = 48,
2302
+ MidBiggerThanMax = 49,
2303
+ MinBiggerThanMid = 50,
2304
+ FirstArgMissing = 51,
2305
+ SecondArgMissing = 52,
2306
+ MinNaN = 53,
2307
+ MidNaN = 54,
2308
+ MaxNaN = 55,
2309
+ ValueUpperInflectionNaN = 56,
2310
+ ValueLowerInflectionNaN = 57,
2311
+ MinInvalidFormula = 58,
2312
+ MidInvalidFormula = 59,
2313
+ MaxInvalidFormula = 60,
2314
+ ValueUpperInvalidFormula = 61,
2315
+ ValueLowerInvalidFormula = 62,
2316
+ InvalidSortZone = 63,
2317
+ WaitingSessionConfirmation = 64,
2318
+ MergeOverlap = 65,
2319
+ TooManyHiddenElements = 66,
2320
+ Readonly = 67,
2321
+ InvalidViewportSize = 68,
2322
+ InvalidScrollingDirection = 69,
2323
+ FigureDoesNotExist = 70,
2324
+ InvalidConditionalFormatId = 71,
2325
+ InvalidCellPopover = 72,
2326
+ EmptyTarget = 73,
2327
+ InvalidFreezeQuantity = 74,
2328
+ FrozenPaneOverlap = 75,
2329
+ ValuesNotChanged = 76,
2330
+ InvalidFilterZone = 77,
2331
+ FilterOverlap = 78,
2332
+ FilterNotFound = 79,
2333
+ MergeInFilter = 80,
2334
+ NonContinuousTargets = 81,
2335
+ DuplicatedFigureId = 82,
2336
+ InvalidSelectionStep = 83,
2337
+ DuplicatedChartId = 84,
2338
+ ChartDoesNotExist = 85,
2339
+ InvalidHeaderIndex = 86,
2340
+ InvalidQuantity = 87,
2341
+ MoreThanOneColumnSelected = 88,
2342
+ EmptySplitSeparator = 89,
2343
+ SplitWillOverwriteContent = 90,
2344
+ NoSplitSeparatorInSelection = 91
2443
2345
  }
2444
- interface TextCell extends EvaluatedCellProperties {
2445
- readonly type: CellValueType.text;
2446
- readonly value: string;
2346
+ interface CommandHandler<T> {
2347
+ allowDispatch(command: T): CommandResult | CommandResult[];
2348
+ beforeHandle(command: T): void;
2349
+ handle(command: T): void;
2350
+ finalize(): void;
2447
2351
  }
2448
- interface BooleanCell extends EvaluatedCellProperties {
2449
- readonly type: CellValueType.boolean;
2450
- readonly value: boolean;
2352
+ interface CommandDispatcher {
2353
+ dispatch<T extends CommandTypes, C extends Extract<Command, {
2354
+ type: T;
2355
+ }>>(type: {} extends Omit<C, "type"> ? T : never): DispatchResult;
2356
+ dispatch<T extends CommandTypes, C extends Extract<Command, {
2357
+ type: T;
2358
+ }>>(type: T, r: Omit<C, "type">): DispatchResult;
2359
+ canDispatch<T extends CommandTypes, C extends Extract<Command, {
2360
+ type: T;
2361
+ }>>(type: T, r: Omit<C, "type">): DispatchResult;
2451
2362
  }
2452
- interface EmptyCell extends EvaluatedCellProperties {
2453
- readonly type: CellValueType.empty;
2454
- readonly value: "";
2363
+ interface CoreCommandDispatcher {
2364
+ dispatch<T extends CoreCommandTypes, C extends Extract<CoreCommand, {
2365
+ type: T;
2366
+ }>>(type: {} extends Omit<C, "type"> ? T : never): DispatchResult;
2367
+ dispatch<T extends CoreCommandTypes, C extends Extract<CoreCommand, {
2368
+ type: T;
2369
+ }>>(type: T, r: Omit<C, "type">): DispatchResult;
2370
+ canDispatch<T extends CoreCommandTypes, C extends Extract<CoreCommand, {
2371
+ type: T;
2372
+ }>>(type: T, r: Omit<C, "type">): DispatchResult;
2455
2373
  }
2456
- interface ErrorCell extends EvaluatedCellProperties {
2457
- readonly type: CellValueType.error;
2458
- readonly value: string;
2459
- readonly error: EvaluationError;
2374
+ declare type CommandTypes = Command["type"];
2375
+ declare type CoreCommandTypes = CoreCommand["type"];
2376
+
2377
+ /**
2378
+ * The following type is meant to be used in union with other aliases to prevent
2379
+ * Intellisense from resolving it.
2380
+ * See https://github.com/microsoft/TypeScript/issues/31940#issuecomment-841712377
2381
+ */
2382
+ declare type Alias = {} & {};
2383
+ declare type HeaderIndex = number & Alias;
2384
+ declare type Pixel = number & Alias;
2385
+ declare type UID = string & Alias;
2386
+ declare type SetDecimalStep = 1 | -1;
2387
+ declare type FilterId = UID & Alias;
2388
+ declare type FilterTableId = UID & Alias;
2389
+ /**
2390
+ * CSS style color string
2391
+ * e.g. "#ABC", "#AAAFFF", "rgb(30, 80, 16)"
2392
+ */
2393
+ declare type Color = string & Alias;
2394
+ interface RGBA {
2395
+ a: number;
2396
+ r: number;
2397
+ g: number;
2398
+ b: number;
2460
2399
  }
2461
- declare enum CellValueType {
2462
- boolean = "boolean",
2463
- number = "number",
2464
- text = "text",
2465
- empty = "empty",
2466
- error = "error"
2400
+ interface Link {
2401
+ readonly label: string;
2402
+ readonly url: string;
2403
+ readonly isExternal: boolean;
2404
+ /**
2405
+ * Specifies if the URL is editable by the end user.
2406
+ * Special links might not allow it.
2407
+ */
2408
+ readonly isUrlEditable: boolean;
2467
2409
  }
2468
-
2469
- /**
2470
- * An AutofillModifier describe the possible operations to apply to the
2471
- * content of a cell when we autofill this cell.
2472
- *
2473
- * It could be:
2474
- * - Increment: increment the content by a given step
2475
- * - Copy: simply copy the content
2476
- * - Formula: update the formula, with the same behavior than paste
2477
- */
2478
-
2479
- interface IncrementModifier {
2480
- type: "INCREMENT_MODIFIER";
2481
- increment: number;
2482
- current: number;
2410
+ interface Zone {
2411
+ left: HeaderIndex;
2412
+ right: HeaderIndex;
2413
+ top: HeaderIndex;
2414
+ bottom: HeaderIndex;
2483
2415
  }
2484
- interface AlphanumericIncrementModifier {
2485
- type: "ALPHANUMERIC_INCREMENT_MODIFIER";
2486
- increment: number;
2487
- current: number;
2488
- prefix: string;
2489
- numberPostfixLength: number;
2416
+ interface AnchorZone {
2417
+ zone: Zone;
2418
+ cell: Position$1;
2490
2419
  }
2491
- interface CopyModifier {
2492
- type: "COPY_MODIFIER";
2420
+ interface Selection {
2421
+ anchor: AnchorZone;
2422
+ zones: Zone[];
2493
2423
  }
2494
- interface FormulaModifier {
2495
- type: "FORMULA_MODIFIER";
2496
- increment: number;
2497
- current: number;
2424
+ interface UnboundedZone {
2425
+ top: HeaderIndex;
2426
+ bottom: HeaderIndex | undefined;
2427
+ left: HeaderIndex;
2428
+ right: HeaderIndex | undefined;
2429
+ hasHeader?: boolean;
2498
2430
  }
2499
- declare type AutofillModifier = IncrementModifier | AlphanumericIncrementModifier | CopyModifier | FormulaModifier;
2500
- interface Tooltip {
2501
- props: any;
2502
- component?: any;
2431
+ interface ZoneDimension {
2432
+ numberOfRows: HeaderIndex;
2433
+ numberOfCols: HeaderIndex;
2503
2434
  }
2504
- interface AutofillCellData extends UpdateCellData {
2505
- border?: Border$1;
2435
+ declare type Align = "left" | "right" | "center" | undefined;
2436
+ declare type VerticalAlign = "top" | "middle" | "bottom" | undefined;
2437
+ declare type Wrapping = "overflow" | "wrap" | "clip" | undefined;
2438
+ interface Style {
2439
+ bold?: boolean;
2440
+ italic?: boolean;
2441
+ strikethrough?: boolean;
2442
+ underline?: boolean;
2443
+ align?: Align;
2444
+ wrapping?: Wrapping;
2445
+ verticalAlign?: VerticalAlign;
2446
+ fillColor?: Color;
2447
+ textColor?: Color;
2448
+ fontSize?: number;
2506
2449
  }
2507
- interface AutofillData {
2508
- cell?: Cell;
2509
- col: number;
2510
- row: number;
2511
- sheetId: UID;
2512
- border?: Border$1;
2450
+ interface UpdateCellData {
2451
+ content?: string;
2452
+ formula?: string;
2453
+ style?: Style | null;
2454
+ format?: Format;
2513
2455
  }
2514
- interface AutofillResult {
2515
- cellData: AutofillCellData;
2516
- tooltip?: Tooltip;
2517
- origin: {
2518
- col: number;
2519
- row: number;
2520
- };
2456
+ interface Sheet {
2457
+ id: UID;
2458
+ name: string;
2459
+ numberOfCols: number;
2460
+ rows: Row[];
2461
+ areGridLinesVisible: boolean;
2462
+ isVisible: boolean;
2463
+ panes: PaneDivision;
2521
2464
  }
2522
- interface AutofillModifierImplementation {
2523
- apply: (rule: AutofillModifier, data: AutofillData, getters: Getters, direction: DIRECTION) => Omit<AutofillResult, "origin">;
2465
+ interface CellPosition {
2466
+ col: HeaderIndex;
2467
+ row: HeaderIndex;
2468
+ sheetId: UID;
2524
2469
  }
2525
-
2526
- interface RevisionData {
2527
- readonly id: UID;
2528
- readonly clientId: ClientId;
2529
- readonly commands: readonly CoreCommand[];
2470
+ declare type BorderStyle = "thin" | "medium" | "thick" | "dashed" | "dotted" | "double";
2471
+ declare type BorderDescr = [BorderStyle, Color];
2472
+ interface Border$1 {
2473
+ top?: BorderDescr;
2474
+ left?: BorderDescr;
2475
+ bottom?: BorderDescr;
2476
+ right?: BorderDescr;
2530
2477
  }
2531
-
2532
- interface Currency {
2533
- name: string;
2534
- code: string;
2535
- symbol: string;
2536
- decimalPlaces: number;
2537
- position: "before" | "after";
2478
+ declare type ReferenceDenormalizer = (range: Range, isMeta: boolean, functionName: string, paramNumber: number) => any | any[][];
2479
+ declare type EnsureRange = (range: Range) => any[][];
2480
+ declare type _CompiledFormula = (deps: Range[], refFn: ReferenceDenormalizer, range: EnsureRange, ctx: {}) => FormulaReturn;
2481
+ interface CompiledFormula {
2482
+ execute: _CompiledFormula;
2483
+ tokens: Token[];
2484
+ dependencies: string[];
2538
2485
  }
2539
-
2540
- declare type ClipboardReadResult = {
2541
- status: "ok";
2542
- content: string;
2543
- } | {
2544
- status: "permissionDenied" | "notImplemented";
2486
+ declare type Arg = MatrixArg | PrimitiveArg;
2487
+ declare type MatrixArg = ({
2488
+ value: CellValue;
2489
+ format?: Format;
2490
+ } | undefined)[][];
2491
+ declare type PrimitiveArg = {
2492
+ value: PrimitiveArgValue;
2493
+ format?: Format;
2545
2494
  };
2546
- interface ClipboardInterface {
2547
- write(clipboardContent: ClipboardContent): Promise<void>;
2548
- writeText(text: string): Promise<void>;
2549
- readText(): Promise<ClipboardReadResult>;
2495
+ declare type ArgValue = PrimitiveArgValue | MatrixArgValue;
2496
+ declare type MatrixArgValue = (CellValue | undefined)[][];
2497
+ declare type PrimitiveArgValue = string | number | boolean | null;
2498
+ declare type FunctionReturn = {
2499
+ value: FunctionReturnValue;
2500
+ format?: Format;
2501
+ };
2502
+ interface FormulaReturn extends Omit<FunctionReturn, "value"> {
2503
+ value: FunctionReturnValue | null;
2504
+ format?: Format;
2550
2505
  }
2551
-
2552
- declare type TranslationFunction = (string: string, ...values: string[] | [{
2553
- [key: string]: string;
2554
- }]) => string;
2555
- /***
2556
- * Allow to inject a translation function from outside o-spreadsheet.
2557
- * @param tfn the function that will do the translation
2558
- */
2559
- declare function setTranslationMethod(tfn: TranslationFunction): void;
2560
-
2561
- interface EditTextOptions {
2562
- error?: string;
2563
- placeholder?: string;
2506
+ declare type FunctionReturnValue = string | number | boolean;
2507
+ interface HeaderDimensions {
2508
+ start: Pixel;
2509
+ size: Pixel;
2510
+ end: Pixel;
2564
2511
  }
2565
- interface InformationNotification {
2566
- text: string;
2567
- tag: string;
2512
+ interface Row {
2513
+ cells: Record<number, UID | undefined>;
2568
2514
  }
2569
- interface SpreadsheetEnv {
2570
- notifyUser: (notification: InformationNotification) => any;
2571
- raiseError: (text: string, callback?: () => void) => any;
2572
- askConfirmation: (content: string, confirm: () => any, cancel?: () => any) => any;
2573
- editText: (title: string, callback: (text: string | null) => any, options?: EditTextOptions) => any;
2515
+ interface Position$1 {
2516
+ col: HeaderIndex;
2517
+ row: HeaderIndex;
2574
2518
  }
2575
- interface SpreadsheetChildEnv extends SpreadsheetEnv {
2576
- model: Model;
2577
- imageProvider?: ImageProviderInterface;
2578
- isDashboard: () => boolean;
2579
- openSidePanel: (panel: string, panelProps?: any) => void;
2580
- toggleSidePanel: (panel: string, panelProps?: any) => void;
2581
- clipboard: ClipboardInterface;
2582
- _t: TranslationFunction;
2583
- startCellEdition: (content: string) => void;
2584
- loadCurrencies?: () => Promise<Currency[]>;
2519
+ interface PixelPosition {
2520
+ x: Pixel;
2521
+ y: Pixel;
2585
2522
  }
2586
-
2587
- declare type ArgType = "ANY" | "BOOLEAN" | "NUMBER" | "STRING" | "DATE" | "RANGE" | "RANGE<BOOLEAN>" | "RANGE<NUMBER>" | "RANGE<DATE>" | "RANGE<STRING>" | "META";
2588
- interface ArgDefinition {
2589
- repeating?: boolean;
2590
- optional?: boolean;
2591
- lazy?: boolean;
2592
- description: string;
2593
- name: string;
2594
- type: ArgType[];
2595
- default?: boolean;
2596
- defaultValue?: any;
2523
+ interface Merge extends Zone {
2524
+ id: number;
2525
+ topLeft: Position$1;
2597
2526
  }
2598
- declare type ComputeFunctionArg<T> = T | (() => T) | undefined;
2599
- declare type ComputeFunction<T, R> = (this: EvalContext, ...args: ComputeFunctionArg<T>[]) => R;
2600
- interface AddFunctionDescription {
2601
- description: string;
2602
- compute: ComputeFunction<ArgValue, FunctionReturnValue>;
2603
- computeFormat?: ComputeFunction<Arg, Format | undefined>;
2604
- category?: string;
2605
- args: ArgDefinition[];
2606
- returns: [ArgType];
2607
- isExported?: boolean;
2608
- hidden?: boolean;
2527
+ interface Highlight$1 {
2528
+ zone: Zone;
2529
+ sheetId: UID;
2530
+ color: Color | null;
2609
2531
  }
2610
- interface FunctionDescription extends AddFunctionDescription {
2611
- minArgRequired: number;
2612
- maxArgPossible: number;
2613
- nbrArgRepeating: number;
2614
- getArgToFocus: (argPosition: number) => number;
2532
+ interface PaneDivision {
2533
+ /** Represents the number of frozen columns */
2534
+ xSplit: number;
2535
+ /** Represents the number of frozen rows */
2536
+ ySplit: number;
2615
2537
  }
2616
- declare type EvalContext = {
2617
- __lastFnCalled?: string;
2618
- __originCellXC?: () => string;
2619
- [key: string]: any;
2538
+ declare type BorderCommand = "all" | "hv" | "h" | "v" | "external" | "left" | "top" | "right" | "bottom" | "clear";
2539
+ declare type BorderDescription = {
2540
+ vertical?: BorderDescr;
2541
+ horizontal?: BorderDescr;
2542
+ } | undefined;
2543
+ declare const enum DIRECTION {
2544
+ UP = "up",
2545
+ DOWN = "down",
2546
+ LEFT = "left",
2547
+ RIGHT = "right"
2548
+ }
2549
+ declare type ChangeType = "REMOVE" | "RESIZE" | "MOVE" | "CHANGE" | "NONE";
2550
+ declare type ApplyRangeChangeResult = {
2551
+ changeType: Exclude<ChangeType, "NONE">;
2552
+ range: Range;
2553
+ } | {
2554
+ changeType: "NONE";
2620
2555
  };
2621
-
2622
- declare class SelectiveHistory<T = unknown> {
2623
- private applyOperation;
2624
- private revertOperation;
2625
- private buildEmpty;
2626
- private readonly buildTransformation;
2627
- private HEAD_BRANCH;
2628
- private HEAD_OPERATION;
2629
- private tree;
2630
- /**
2631
- * The selective history is a data structure used to register changes/updates of a state.
2632
- * Each change/update is called an "operation".
2633
- * The data structure allows to easily cancel (and redo) any operation individually.
2634
- * An operation can be represented by any data structure. It can be a "command", a "diff", etc.
2635
- * However it must have the following properties:
2636
- * - it can be applied to modify the state
2637
- * - it can be reverted on the state such that it was never executed.
2638
- * - it can be transformed given other operation (Operational Transformation)
2639
- *
2640
- * Since this data structure doesn't know anything about the state nor the structure of
2641
- * operations, the actual work must be performed by external functions given as parameters.
2642
- * @param initialOperationId
2643
- * @param applyOperation a function which can apply an operation to the state
2644
- * @param revertOperation a function which can revert an operation from the state
2645
- * @param buildEmpty a function returning an "empty" operation.
2646
- * i.e an operation that leaves the state unmodified once applied or reverted
2647
- * (used for internal implementation)
2648
- * @param buildTransformation Factory used to build transformations
2649
- */
2650
- constructor(initialOperationId: UID, applyOperation: (data: T) => void, revertOperation: (data: T) => void, buildEmpty: (id: UID) => T, buildTransformation: TransformationFactory<T>);
2651
- /**
2652
- * Return the operation identified by its id.
2653
- */
2654
- get(operationId: UID): T;
2655
- /**
2656
- * Append a new operation as the last one
2657
- */
2658
- append(operationId: UID, data: T): void;
2659
- /**
2660
- * Insert a new operation after a specific operation (may not be the last operation).
2661
- * Following operations will be transformed according
2662
- * to the new operation.
2663
- */
2664
- insert(operationId: UID, data: T, insertAfter: UID): void;
2665
- /**
2666
- * @param operationId operation to undo
2667
- * @param undoId the id of the "undo operation"
2668
- * @param insertAfter the id of the operation after which to insert the undo
2669
- */
2670
- undo(operationId: UID, undoId: UID, insertAfter: UID): void;
2671
- /**
2672
- * @param operationId operation to redo
2673
- * @param redoId the if of the "redo operation"
2674
- * @param insertAfter the id of the operation after which to insert the redo
2675
- */
2676
- redo(operationId: UID, redoId: UID, insertAfter: UID): void;
2677
- drop(operationId: UID): void;
2678
- /**
2679
- * Revert the state as it was *before* the given operation was executed.
2680
- */
2681
- private revertBefore;
2682
- /**
2683
- * Revert the state as it was *after* the given operation was executed.
2684
- */
2685
- private revertTo;
2556
+ declare type ApplyRangeChange = (range: Range) => ApplyRangeChangeResult;
2557
+ declare type Dimension = "COL" | "ROW";
2558
+ declare type ConsecutiveIndexes = HeaderIndex[];
2559
+ interface RangeProvider {
2560
+ adaptRanges: (applyChange: ApplyRangeChange, sheetId?: UID) => void;
2561
+ }
2562
+ declare type Validation<T> = (toValidate: T) => CommandResult | CommandResult[];
2563
+ /**
2564
+ * Return the prop's type of a component
2565
+ */
2566
+ declare type PropsOf<C> = C extends ComponentConstructor<infer Props> ? Props : never;
2567
+ /**
2568
+ * Container for a lazy computed value
2569
+ */
2570
+ interface Lazy<T> {
2686
2571
  /**
2687
- * Revert an execution
2572
+ * Return the computed value.
2573
+ * The value is computed only once and memoized.
2688
2574
  */
2689
- private revert;
2575
+ (): T;
2690
2576
  /**
2691
- * Replay the operations between the current HEAD_BRANCH and the end of the tree
2577
+ * Map a lazy value to another lazy value.
2578
+ *
2579
+ * ```ts
2580
+ * // neither function is called here
2581
+ * const lazyValue = lazy(() => veryExpensive(...)).map((result) => alsoVeryExpensive(result));
2582
+ *
2583
+ * // both values are computed now
2584
+ * const value = lazyValue()
2585
+ * ```
2692
2586
  */
2693
- private fastForward;
2587
+ map: <U>(callback: (value: T) => U) => Lazy<U>;
2588
+ }
2589
+ interface Cloneable<T> {
2590
+ clone: (args?: Partial<T>) => T;
2591
+ }
2592
+ declare type CSSProperties<P extends string = string> = Record<P, string | undefined>;
2593
+ interface SortOptions {
2594
+ /** If true sort the headers of the range along with the rest */
2595
+ sortHeaders?: boolean;
2596
+ /** If true treat empty cells as "0" instead of undefined */
2597
+ emptyCellAsZero?: boolean;
2598
+ }
2599
+ interface MenuMouseEvent extends MouseEvent {
2600
+ closedMenuId?: UID;
2694
2601
  }
2695
2602
 
2696
- declare class Revision implements RevisionData {
2603
+ declare type Format = string & Alias;
2604
+ declare type FormattedValue = string & Alias;
2605
+
2606
+ interface CellAttributes {
2697
2607
  readonly id: UID;
2698
- readonly clientId: ClientId;
2699
- private _commands;
2700
- private _changes;
2701
2608
  /**
2702
- * A revision represents a whole client action (Create a sheet, merge a Zone, Undo, ...).
2703
- * A revision contains the following information:
2704
- * - id: ID of the revision
2705
- * - commands: CoreCommands that are linked to the action, and should be
2706
- * dispatched in other clients
2707
- * - clientId: Client who initiated the action
2708
- * - changes: List of changes applied on the state.
2609
+ * Raw cell content
2709
2610
  */
2710
- constructor(id: UID, clientId: ClientId, commands: readonly CoreCommand[], changes?: readonly HistoryChange[]);
2711
- setChanges(changes: readonly HistoryChange[]): void;
2712
- get commands(): readonly CoreCommand[];
2713
- get changes(): readonly HistoryChange[];
2611
+ readonly content: string;
2612
+ readonly style?: Style;
2613
+ readonly format?: Format;
2714
2614
  }
2715
-
2716
- declare class Session extends EventBus<CollaborativeEvent> {
2717
- private revisions;
2718
- private transportService;
2719
- private serverRevisionId;
2720
- /**
2721
- * Positions of the others client.
2722
- */
2723
- private clients;
2724
- private clientId;
2725
- /**
2726
- * Id of the server revision
2727
- */
2728
- private debouncedMove;
2729
- private pendingMessages;
2730
- private waitingAck;
2731
- /**
2732
- * Flag used to block all commands when an undo or redo is triggered, until
2733
- * it is accepted on the server
2734
- */
2735
- private waitingUndoRedoAck;
2736
- private isReplayingInitialRevisions;
2737
- private processedRevisions;
2738
- private uuidGenerator;
2739
- /**
2740
- * Manages the collaboration between multiple users on the same spreadsheet.
2741
- * It can forward local state changes to other users to ensure they all eventually
2742
- * reach the same state.
2743
- * It also manages the positions of each clients in the spreadsheet to provide
2744
- * a visual indication of what other users are doing in the spreadsheet.
2745
- *
2746
- * @param revisions
2747
- * @param transportService communication channel used to send and receive messages
2748
- * between all connected clients
2749
- * @param client the client connected locally
2750
- * @param serverRevisionId
2751
- */
2752
- constructor(revisions: SelectiveHistory<Revision>, transportService: TransportService<CollaborationMessage>, serverRevisionId?: UID);
2753
- canApplyOptimisticUpdate(): boolean;
2754
- /**
2755
- * Add a new revision to the collaborative session.
2756
- * It will be transmitted to all other connected clients.
2757
- */
2758
- save(commands: CoreCommand[], changes: HistoryChange[]): void;
2759
- undo(revisionId: UID): void;
2760
- redo(revisionId: UID): void;
2761
- /**
2762
- * Notify that the position of the client has changed
2763
- */
2764
- move(position: ClientPosition): void;
2765
- join(client?: Client): void;
2766
- loadInitialMessages(messages: StateUpdateMessage[]): void;
2767
- /**
2768
- * Notify the server that the user client left the collaborative session
2769
- */
2770
- leave(): void;
2771
- /**
2772
- * Send a snapshot of the spreadsheet to the collaboration server
2773
- */
2774
- snapshot(data: WorkbookData): void;
2775
- getClient(): Client;
2776
- getConnectedClients(): Set<Client>;
2777
- getRevisionId(): UID;
2778
- isFullySynchronized(): boolean;
2779
- private _move;
2780
- /**
2781
- * Handles messages received from other clients in the collaborative
2782
- * session.
2783
- */
2784
- private onMessageReceived;
2785
- private onClientMoved;
2615
+ interface LiteralCell extends CellAttributes {
2616
+ readonly isFormula: false;
2617
+ }
2618
+ interface FormulaCell extends CellAttributes {
2619
+ readonly isFormula: true;
2620
+ readonly compiledFormula: CompiledFormula;
2621
+ readonly dependencies: Range[];
2622
+ }
2623
+ declare type Cell = LiteralCell | FormulaCell;
2624
+ interface EvaluatedCellProperties {
2625
+ readonly format?: Format;
2786
2626
  /**
2787
- * Register the new client and send your
2788
- * own position back.
2627
+ * Cell value formatted based on the format
2789
2628
  */
2790
- private onClientJoined;
2791
- private onClientLeft;
2792
- private sendUpdateMessage;
2629
+ readonly formattedValue: FormattedValue;
2630
+ readonly defaultAlign: "right" | "center" | "left";
2793
2631
  /**
2794
- * Send the next pending message
2632
+ * Can the cell appear in an automatic sum zone.
2795
2633
  */
2796
- private sendPendingMessage;
2797
- private acknowledge;
2798
- private isAlreadyProcessed;
2799
- private dropPendingHistoryMessages;
2634
+ readonly isAutoSummable: boolean;
2635
+ readonly link?: Link;
2636
+ }
2637
+ declare type CellValue = string | number | boolean;
2638
+ declare type EvaluatedCell = NumberCell | TextCell | BooleanCell | EmptyCell | ErrorCell;
2639
+ interface NumberCell extends EvaluatedCellProperties {
2640
+ readonly type: CellValueType.number;
2641
+ readonly value: number;
2642
+ }
2643
+ interface TextCell extends EvaluatedCellProperties {
2644
+ readonly type: CellValueType.text;
2645
+ readonly value: string;
2646
+ }
2647
+ interface BooleanCell extends EvaluatedCellProperties {
2648
+ readonly type: CellValueType.boolean;
2649
+ readonly value: boolean;
2650
+ }
2651
+ interface EmptyCell extends EvaluatedCellProperties {
2652
+ readonly type: CellValueType.empty;
2653
+ readonly value: "";
2654
+ }
2655
+ interface ErrorCell extends EvaluatedCellProperties {
2656
+ readonly type: CellValueType.error;
2657
+ readonly value: string;
2658
+ readonly error: EvaluationError;
2659
+ }
2660
+ declare enum CellValueType {
2661
+ boolean = "boolean",
2662
+ number = "number",
2663
+ text = "text",
2664
+ empty = "empty",
2665
+ error = "error"
2800
2666
  }
2801
2667
 
2802
2668
  /**
2803
- * Local History
2669
+ * An AutofillModifier describe the possible operations to apply to the
2670
+ * content of a cell when we autofill this cell.
2804
2671
  *
2805
- * The local history is responsible of tracking the locally state updates
2806
- * It maintains the local undo and redo stack to allow to undo/redo only local
2807
- * changes
2672
+ * It could be:
2673
+ * - Increment: increment the content by a given step
2674
+ * - Copy: simply copy the content
2675
+ * - Formula: update the formula, with the same behavior than paste
2808
2676
  */
2809
- declare class LocalHistory extends EventBus$1 implements CommandHandler<Command> {
2810
- protected dispatch: CommandDispatcher["dispatch"];
2811
- private session;
2812
- /**
2813
- * Ids of the revisions which can be undone
2814
- */
2815
- private undoStack;
2816
- /**
2817
- * Ids of the revisions which can be redone
2818
- */
2819
- private redoStack;
2820
- constructor(dispatch: CommandDispatcher["dispatch"], session: Session);
2821
- allowDispatch(cmd: Command): CommandResult;
2822
- beforeHandle(cmd: Command): void;
2823
- handle(cmd: Command): void;
2824
- finalize(): void;
2825
- private requestHistoryChange;
2826
- canUndo(): boolean;
2827
- canRedo(): boolean;
2828
- private drop;
2829
- private onNewLocalStateUpdate;
2830
- private selectiveUndo;
2831
- private selectiveRedo;
2677
+
2678
+ interface IncrementModifier {
2679
+ type: "INCREMENT_MODIFIER";
2680
+ increment: number;
2681
+ current: number;
2682
+ }
2683
+ interface AlphanumericIncrementModifier {
2684
+ type: "ALPHANUMERIC_INCREMENT_MODIFIER";
2685
+ increment: number;
2686
+ current: number;
2687
+ prefix: string;
2688
+ numberPostfixLength: number;
2689
+ }
2690
+ interface CopyModifier {
2691
+ type: "COPY_MODIFIER";
2692
+ }
2693
+ interface FormulaModifier {
2694
+ type: "FORMULA_MODIFIER";
2695
+ increment: number;
2696
+ current: number;
2697
+ }
2698
+ declare type AutofillModifier = IncrementModifier | AlphanumericIncrementModifier | CopyModifier | FormulaModifier;
2699
+ interface Tooltip {
2700
+ props: any;
2701
+ component?: any;
2702
+ }
2703
+ interface AutofillCellData extends UpdateCellData {
2704
+ border?: Border$1;
2705
+ }
2706
+ interface AutofillData {
2707
+ cell?: Cell;
2708
+ col: number;
2709
+ row: number;
2710
+ sheetId: UID;
2711
+ border?: Border$1;
2712
+ }
2713
+ interface AutofillResult {
2714
+ cellData: AutofillCellData;
2715
+ tooltip?: Tooltip;
2716
+ origin: {
2717
+ col: number;
2718
+ row: number;
2719
+ };
2720
+ }
2721
+ interface AutofillModifierImplementation {
2722
+ apply: (rule: AutofillModifier, data: AutofillData, getters: Getters, direction: DIRECTION) => Omit<AutofillResult, "origin">;
2723
+ }
2724
+
2725
+ interface RevisionData {
2726
+ readonly id: UID;
2727
+ readonly clientId: ClientId;
2728
+ readonly commands: readonly CoreCommand[];
2729
+ }
2730
+
2731
+ interface Currency {
2732
+ name: string;
2733
+ code: string;
2734
+ symbol: string;
2735
+ decimalPlaces: number;
2736
+ position: "before" | "after";
2737
+ }
2738
+
2739
+ declare type ClipboardReadResult = {
2740
+ status: "ok";
2741
+ content: string;
2742
+ } | {
2743
+ status: "permissionDenied" | "notImplemented";
2744
+ };
2745
+ interface ClipboardInterface {
2746
+ write(clipboardContent: ClipboardContent): Promise<void>;
2747
+ writeText(text: string): Promise<void>;
2748
+ readText(): Promise<ClipboardReadResult>;
2749
+ }
2750
+
2751
+ declare type TranslationFunction = (string: string, ...values: string[] | [{
2752
+ [key: string]: string;
2753
+ }]) => string;
2754
+ /***
2755
+ * Allow to inject a translation function from outside o-spreadsheet.
2756
+ * @param tfn the function that will do the translation
2757
+ */
2758
+ declare function setTranslationMethod(tfn: TranslationFunction): void;
2759
+
2760
+ interface EditTextOptions {
2761
+ error?: string;
2762
+ placeholder?: string;
2763
+ }
2764
+ interface InformationNotification {
2765
+ text: string;
2766
+ tag: string;
2767
+ }
2768
+ interface SpreadsheetEnv {
2769
+ notifyUser: (notification: InformationNotification) => any;
2770
+ raiseError: (text: string, callback?: () => void) => any;
2771
+ askConfirmation: (content: string, confirm: () => any, cancel?: () => any) => any;
2772
+ editText: (title: string, callback: (text: string | null) => any, options?: EditTextOptions) => any;
2773
+ }
2774
+ interface SpreadsheetChildEnv extends SpreadsheetEnv {
2775
+ model: Model;
2776
+ imageProvider?: ImageProviderInterface;
2777
+ isDashboard: () => boolean;
2778
+ openSidePanel: (panel: string, panelProps?: any) => void;
2779
+ toggleSidePanel: (panel: string, panelProps?: any) => void;
2780
+ clipboard: ClipboardInterface;
2781
+ _t: TranslationFunction;
2782
+ startCellEdition: (content: string) => void;
2783
+ loadCurrencies?: () => Promise<Currency[]>;
2784
+ }
2785
+
2786
+ declare type ArgType = "ANY" | "BOOLEAN" | "NUMBER" | "STRING" | "DATE" | "RANGE" | "RANGE<BOOLEAN>" | "RANGE<NUMBER>" | "RANGE<DATE>" | "RANGE<STRING>" | "META";
2787
+ interface ArgDefinition {
2788
+ repeating?: boolean;
2789
+ optional?: boolean;
2790
+ lazy?: boolean;
2791
+ description: string;
2792
+ name: string;
2793
+ type: ArgType[];
2794
+ default?: boolean;
2795
+ defaultValue?: any;
2796
+ }
2797
+ declare type ComputeFunctionArg<T> = T | (() => T) | undefined;
2798
+ declare type ComputeFunction<T, R> = (this: EvalContext, ...args: ComputeFunctionArg<T>[]) => R;
2799
+ interface AddFunctionDescription {
2800
+ description: string;
2801
+ compute: ComputeFunction<ArgValue, FunctionReturnValue>;
2802
+ computeFormat?: ComputeFunction<Arg, Format | undefined>;
2803
+ category?: string;
2804
+ args: ArgDefinition[];
2805
+ returns: [ArgType];
2806
+ isExported?: boolean;
2807
+ hidden?: boolean;
2808
+ }
2809
+ interface FunctionDescription extends AddFunctionDescription {
2810
+ minArgRequired: number;
2811
+ maxArgPossible: number;
2812
+ nbrArgRepeating: number;
2813
+ getArgToFocus: (argPosition: number) => number;
2832
2814
  }
2815
+ declare type EvalContext = {
2816
+ __lastFnCalled?: string;
2817
+ __originCellXC?: () => string;
2818
+ [key: string]: any;
2819
+ };
2833
2820
 
2834
2821
  declare class RangeAdapter implements CommandHandler<CoreCommand> {
2835
2822
  private getters;
@@ -3404,14 +3391,16 @@ declare class HeaderSizePlugin extends CorePlugin<HeaderSizeState> implements He
3404
3391
  }
3405
3392
 
3406
3393
  declare class HeaderVisibilityPlugin extends CorePlugin {
3407
- static getters: readonly ["getHiddenColsGroups", "getHiddenRowsGroups", "isRowHiddenByUser", "isColHiddenByUser"];
3394
+ static getters: readonly ["canRemoveHeaders", "getHiddenColsGroups", "getHiddenRowsGroups", "isRowHiddenByUser", "isColHiddenByUser"];
3408
3395
  private readonly hiddenHeaders;
3409
- allowDispatch(cmd: Command): CommandResult.Success | CommandResult.InvalidSheetId | CommandResult.TooManyHiddenElements;
3396
+ allowDispatch(cmd: Command): CommandResult.Success | CommandResult.NotEnoughElements | CommandResult.InvalidSheetId | CommandResult.TooManyHiddenElements | CommandResult.InvalidHeaderIndex;
3410
3397
  handle(cmd: Command): void;
3398
+ canRemoveHeaders(sheetId: UID, dimension: Dimension, elements: HeaderIndex[]): boolean;
3411
3399
  isRowHiddenByUser(sheetId: UID, index: HeaderIndex): boolean;
3412
3400
  isColHiddenByUser(sheetId: UID, index: HeaderIndex): boolean;
3413
3401
  getHiddenColsGroups(sheetId: UID): ConsecutiveIndexes[];
3414
3402
  getHiddenRowsGroups(sheetId: UID): ConsecutiveIndexes[];
3403
+ private getAllVisibleHeaders;
3415
3404
  import(data: WorkbookData): void;
3416
3405
  exportForExcel(data: ExcelWorkbookData): void;
3417
3406
  export(data: WorkbookData): void;
@@ -4214,13 +4203,41 @@ declare class CellPopoverPlugin extends UIPlugin {
4214
4203
  private computePopoverAnchorRect;
4215
4204
  }
4216
4205
 
4206
+ interface ClientToDisplay extends Required<Client> {
4207
+ color: Color;
4208
+ }
4209
+ declare class CollaborativePlugin extends UIPlugin {
4210
+ static getters: readonly ["getClientsToDisplay", "getClient", "getConnectedClients", "isFullySynchronized"];
4211
+ static layers: LAYERS[];
4212
+ private availableColors;
4213
+ private colors;
4214
+ private session;
4215
+ constructor(config: UIPluginConfig);
4216
+ private isPositionValid;
4217
+ private chooseNewColor;
4218
+ getClient(): Client;
4219
+ getConnectedClients(): Set<Client>;
4220
+ isFullySynchronized(): boolean;
4221
+ /**
4222
+ * Get the list of others connected clients which are present in the same sheet
4223
+ * and with a valid position
4224
+ */
4225
+ getClientsToDisplay(): ClientToDisplay[];
4226
+ drawGrid(renderingContext: GridRenderingContext): void;
4227
+ }
4228
+
4217
4229
  declare class HeaderVisibilityUIPlugin extends UIPlugin {
4218
4230
  static getters: readonly ["getNextVisibleCellPosition", "findVisibleHeader", "findLastVisibleColRowIndex", "findFirstVisibleColRowIndex", "isRowHidden", "isColHidden", "isHeaderHidden"];
4219
4231
  isRowHidden(sheetId: UID, index: number): boolean;
4220
4232
  isColHidden(sheetId: UID, index: number): boolean;
4221
4233
  isHeaderHidden(sheetId: UID, dimension: Dimension, index: number): boolean;
4222
4234
  getNextVisibleCellPosition({ sheetId, col, row }: CellPosition): CellPosition;
4223
- findVisibleHeader(sheetId: UID, dimension: Dimension, indexes: number[]): number | undefined;
4235
+ /**
4236
+ * Find the first visible header in the range [`from` => `to`].
4237
+ *
4238
+ * Both `from` and `to` are inclusive.
4239
+ */
4240
+ findVisibleHeader(sheetId: UID, dimension: Dimension, from: number, to: number): number | undefined;
4224
4241
  findLastVisibleColRowIndex(sheetId: UID, dimension: Dimension, { last, first }: {
4225
4242
  first: HeaderIndex;
4226
4243
  last: HeaderIndex;
@@ -4240,6 +4257,42 @@ declare class HighlightPlugin extends UIPlugin {
4240
4257
  drawGrid(renderingContext: GridRenderingContext): void;
4241
4258
  }
4242
4259
 
4260
+ /**
4261
+ * Local History
4262
+ *
4263
+ * The local history is responsible of tracking the locally state updates
4264
+ * It maintains the local undo and redo stack to allow to undo/redo only local
4265
+ * changes
4266
+ */
4267
+ declare class HistoryPlugin extends UIPlugin {
4268
+ static getters: readonly ["canUndo", "canRedo"];
4269
+ /**
4270
+ * Ids of the revisions which can be undone
4271
+ */
4272
+ private undoStack;
4273
+ /**
4274
+ * Ids of the revisions which can be redone
4275
+ */
4276
+ private redoStack;
4277
+ private session;
4278
+ constructor(config: UIPluginConfig);
4279
+ allowDispatch(cmd: Command): CommandResult;
4280
+ handle(cmd: Command): void;
4281
+ finalize(): void;
4282
+ private requestHistoryChange;
4283
+ canUndo(): boolean;
4284
+ canRedo(): boolean;
4285
+ private drop;
4286
+ private onNewLocalStateUpdate;
4287
+ /**
4288
+ * Fetch the last revision which is not empty and not a repeated command
4289
+ *
4290
+ * Ignore repeated commands (REQUEST_REDO command as root command)
4291
+ * Ignore standard undo/redo revisions (that are empty)
4292
+ */
4293
+ private getPossibleRevisionToRepeat;
4294
+ }
4295
+
4243
4296
  declare class RendererPlugin extends UIPlugin {
4244
4297
  static layers: LAYERS[];
4245
4298
  static getters: readonly ["getColDimensionsInViewport", "getRowDimensionsInViewport"];
@@ -4380,24 +4433,6 @@ declare class SelectionInputsManagerPlugin extends UIPlugin {
4380
4433
  private unfocus;
4381
4434
  }
4382
4435
 
4383
- interface ClientToDisplay extends Required<Client> {
4384
- color: Color;
4385
- }
4386
- declare class SelectionMultiUserPlugin extends UIPlugin {
4387
- static getters: readonly ["getClientsToDisplay"];
4388
- static layers: LAYERS[];
4389
- private availableColors;
4390
- private colors;
4391
- private isPositionValid;
4392
- private chooseNewColor;
4393
- /**
4394
- * Get the list of others connected clients which are present in the same sheet
4395
- * and with a valid position
4396
- */
4397
- getClientsToDisplay(): ClientToDisplay[];
4398
- drawGrid(renderingContext: GridRenderingContext): void;
4399
- }
4400
-
4401
4436
  declare class SortPlugin extends UIPlugin {
4402
4437
  static getters: readonly ["getContiguousZone"];
4403
4438
  allowDispatch(cmd: LocalCommand): CommandResult | CommandResult[];
@@ -4472,6 +4507,26 @@ declare class SortPlugin extends UIPlugin {
4472
4507
  private mainCells;
4473
4508
  }
4474
4509
 
4510
+ declare class SplitToColumnsPlugin extends UIPlugin {
4511
+ static getters: readonly ["getAutomaticSeparator"];
4512
+ allowDispatch(cmd: Command): CommandResult | CommandResult[];
4513
+ handle(cmd: Command): void;
4514
+ getAutomaticSeparator(): string;
4515
+ private getAutoSeparatorForString;
4516
+ private splitIntoColumns;
4517
+ private getSplittedCols;
4518
+ private splitAndRemoveTrailingEmpty;
4519
+ private willSplittedColsOverwriteContent;
4520
+ private removeMergesInSplitZone;
4521
+ private addColsToAvoidCollisions;
4522
+ private getColsToAddToAvoidCollision;
4523
+ private addColumnsToNotOverflowSheet;
4524
+ private checkSingleColSelected;
4525
+ private checkNonEmptySelector;
4526
+ private checkNotOverwritingContent;
4527
+ private checkSeparatorInSelection;
4528
+ }
4529
+
4475
4530
  declare class UIOptionsPlugin extends UIPlugin {
4476
4531
  static getters: readonly ["shouldShowFormulas"];
4477
4532
  private showFormulas;
@@ -4523,6 +4578,7 @@ declare class ClipboardPlugin extends UIPlugin {
4523
4578
  static getters: readonly ["getClipboardContent", "getClipboardTextContent", "isCutOperation", "isPaintingFormat"];
4524
4579
  private status;
4525
4580
  private state?;
4581
+ private lastPasteState?;
4526
4582
  private _isPaintingFormat;
4527
4583
  allowDispatch(cmd: LocalCommand): CommandResult;
4528
4584
  handle(cmd: Command): void;
@@ -4556,7 +4612,7 @@ declare class ClipboardPlugin extends UIPlugin {
4556
4612
  */
4557
4613
  declare class GridSelectionPlugin extends UIPlugin {
4558
4614
  static layers: LAYERS[];
4559
- static getters: readonly ["getActiveSheet", "getActiveSheetId", "getActiveCell", "getActiveCols", "getActiveRows", "getCurrentStyle", "getSelectedZones", "getSelectedZone", "getStatisticFnResults", "getAggregate", "getSelectedFigureId", "getSelection", "getActivePosition", "getSheetPosition", "isSelected", "getElementsFromSelection"];
4615
+ static getters: readonly ["getActiveSheet", "getActiveSheetId", "getActiveCell", "getActiveCols", "getActiveRows", "getCurrentStyle", "getSelectedZones", "getSelectedZone", "getSelectedCells", "getStatisticFnResults", "getAggregate", "getSelectedFigureId", "getSelection", "getActivePosition", "getSheetPosition", "isSelected", "isSingleColSelected", "getElementsFromSelection"];
4560
4616
  private gridSelection;
4561
4617
  private selectedFigureId;
4562
4618
  private sheetsData;
@@ -4575,6 +4631,7 @@ declare class GridSelectionPlugin extends UIPlugin {
4575
4631
  getSelectedZones(): Zone[];
4576
4632
  getSelectedZone(): Zone;
4577
4633
  getSelection(): Selection;
4634
+ getSelectedCells(): EvaluatedCell[];
4578
4635
  getSelectedFigureId(): UID | null;
4579
4636
  getActivePosition(): CellPosition;
4580
4637
  getSheetPosition(sheetId: UID): CellPosition;
@@ -4583,6 +4640,7 @@ declare class GridSelectionPlugin extends UIPlugin {
4583
4640
  };
4584
4641
  getAggregate(): string | null;
4585
4642
  isSelected(zone: Zone): boolean;
4643
+ isSingleColSelected(): boolean;
4586
4644
  /**
4587
4645
  * Returns a sorted array of indexes of all columns (respectively rows depending
4588
4646
  * on the dimension parameter) intersected by the currently selected zones.
@@ -4663,10 +4721,7 @@ declare type ImageGetters = Pick<ImagePlugin, GetterNames<typeof ImagePlugin>>;
4663
4721
  declare type FigureGetters = Pick<FigurePlugin, GetterNames<typeof FigurePlugin>>;
4664
4722
  declare type RangeAdapterGetters = Pick<RangeAdapter, GetterNames<typeof RangeAdapter>>;
4665
4723
  declare type ConditionalFormatGetters = Pick<ConditionalFormatPlugin, GetterNames<typeof ConditionalFormatPlugin>>;
4666
- declare type LocalHistoryGetters = {
4667
- canUndo: LocalHistory["canUndo"];
4668
- canRedo: LocalHistory["canRedo"];
4669
- };
4724
+ declare type LocalHistoryGetters = Pick<HistoryPlugin, GetterNames<typeof HistoryPlugin>>;
4670
4725
  declare type FiltersGetters = Pick<FiltersPlugin, GetterNames<typeof FiltersPlugin>>;
4671
4726
  declare type CoreGetters = SheetGetters & HeaderSizeGetters & HeaderVisibilityGetters & CellGetters & MergeGetters & BordersGetters & ChartGetters & ImageGetters & ConditionalFormatGetters & FigureGetters & RangeAdapterGetters & FiltersGetters;
4672
4727
  declare type AutofillGetters = Pick<AutofillPlugin, GetterNames<typeof AutofillPlugin>>;
@@ -4683,22 +4738,18 @@ declare type CustomColorsGetters = Pick<CustomColorsPlugin, GetterNames<typeof C
4683
4738
  declare type RendererGetters = Pick<RendererPlugin, GetterNames<typeof RendererPlugin>>;
4684
4739
  declare type SelectionGetters = Pick<GridSelectionPlugin, GetterNames<typeof GridSelectionPlugin>>;
4685
4740
  declare type SelectionInputGetters = Pick<SelectionInputsManagerPlugin, GetterNames<typeof SelectionInputsManagerPlugin>>;
4686
- declare type SelectionMultiUserGetters = Pick<SelectionMultiUserPlugin, GetterNames<typeof SelectionMultiUserPlugin>>;
4741
+ declare type CollaborativeGetters = Pick<CollaborativePlugin, GetterNames<typeof CollaborativePlugin>>;
4687
4742
  declare type SortGetters = Pick<SortPlugin, GetterNames<typeof SortPlugin>>;
4688
4743
  declare type UIOptionsGetters = Pick<UIOptionsPlugin, GetterNames<typeof UIOptionsPlugin>>;
4689
4744
  declare type SheetUIGetters = Pick<SheetUIPlugin, GetterNames<typeof SheetUIPlugin>>;
4690
4745
  declare type ViewportGetters = Pick<SheetViewPlugin, GetterNames<typeof SheetViewPlugin>>;
4691
- declare type SessionGetters = {
4692
- getClient: Session["getClient"];
4693
- getConnectedClients: Session["getConnectedClients"];
4694
- isFullySynchronized: Session["isFullySynchronized"];
4695
- };
4696
4746
  declare type CellPopoverPluginGetters = Pick<CellPopoverPlugin, GetterNames<typeof CellPopoverPlugin>>;
4697
4747
  declare type FilterEvaluationGetters = Pick<FilterEvaluationPlugin, GetterNames<typeof FilterEvaluationPlugin>>;
4748
+ declare type SplitToColumnsGetters = Pick<SplitToColumnsPlugin, GetterNames<typeof SplitToColumnsPlugin>>;
4698
4749
  declare type Getters = {
4699
4750
  isReadonly: () => boolean;
4700
4751
  isDashboard: () => boolean;
4701
- } & LocalHistoryGetters & CoreGetters & SessionGetters & AutofillGetters & AutomaticSumGetters & ClipboardGetters & EditionGetters & EvaluationGetters & EvaluationChartGetters & EvaluationConditionalFormatGetters & FindAndReplaceGetters & HighlightGetters & CustomColorsGetters & RendererGetters & SelectionGetters & SelectionInputGetters & SelectionMultiUserGetters & SortGetters & UIOptionsGetters & SheetUIGetters & ViewportGetters & CellPopoverPluginGetters & FilterEvaluationGetters & HeaderVisibilityIUIGetters;
4752
+ } & LocalHistoryGetters & CoreGetters & AutofillGetters & AutomaticSumGetters & ClipboardGetters & EditionGetters & EvaluationGetters & EvaluationChartGetters & EvaluationConditionalFormatGetters & FindAndReplaceGetters & HighlightGetters & CustomColorsGetters & RendererGetters & SelectionGetters & SelectionInputGetters & CollaborativeGetters & SortGetters & UIOptionsGetters & SheetUIGetters & ViewportGetters & CellPopoverPluginGetters & FilterEvaluationGetters & HeaderVisibilityIUIGetters & SplitToColumnsGetters;
4702
4753
 
4703
4754
  interface HistoryChange {
4704
4755
  root: any;
@@ -5403,7 +5454,7 @@ declare class Menu extends Component<Props$s, SpreadsheetChildEnv> {
5403
5454
  get subMenuPosition(): DOMCoordinates;
5404
5455
  get popoverProps(): PopoverProps;
5405
5456
  get childrenHaveIcon(): boolean;
5406
- getIconName(menu: Action): "" | "o-spreadsheet-Icon.CHECK";
5457
+ getIconName(menu: Action): string;
5407
5458
  getColor(menu: Action): string | undefined;
5408
5459
  activateMenu(menu: Action): Promise<void>;
5409
5460
  private close;
@@ -5702,6 +5753,7 @@ declare class FilterIconsOverlay extends Component<Props$k, SpreadsheetChildEnv>
5702
5753
  };
5703
5754
  getVisibleFilterHeaders(): Position$1[];
5704
5755
  getFilterHeaderPosition(position: Position$1): DOMCoordinates;
5756
+ private getIconVerticalPosition;
5705
5757
  isFilterActive(position: Position$1): boolean;
5706
5758
  toggleFilterMenu(position: Position$1): void;
5707
5759
  private isPositionVisible;
@@ -6861,6 +6913,8 @@ declare class Grid extends Component<Props$1, SpreadsheetChildEnv> {
6861
6913
  copy(cut: boolean, ev: ClipboardEvent): void;
6862
6914
  paste(ev: ClipboardEvent): void;
6863
6915
  private displayWarningCopyPasteNotSupported;
6916
+ private clearFormatting;
6917
+ private setHorizontalAlign;
6864
6918
  closeMenu(): void;
6865
6919
  }
6866
6920
 
@@ -6918,6 +6972,8 @@ declare function createEmptySheet(sheetId: UID, name: string): SheetData;
6918
6972
  declare function createEmptyWorkbookData(sheetName?: string): WorkbookData;
6919
6973
  declare function createEmptyExcelSheet(sheetId: UID, name: string): ExcelSheetData;
6920
6974
 
6975
+ declare function genericRepeat<T extends Command>(getters: Getters, command: T): T;
6976
+
6921
6977
  /**
6922
6978
  * We export here all entities that needs to be accessed publicly by Odoo.
6923
6979
  *
@@ -6989,6 +7045,8 @@ declare const registries: {
6989
7045
  urlRegistry: Registry<LinkSpec>;
6990
7046
  cellPopoverRegistry: Registry<PopoverBuilders>;
6991
7047
  numberFormatMenuRegistry: MenuItemRegistry;
7048
+ repeatLocalCommandTransformRegistry: Registry<(getters: Getters, cmd: LocalCommand, childCommands: readonly CoreCommand[]) => LocalCommand | CoreCommand[] | undefined>;
7049
+ repeatCommandTransformRegistry: Registry<(getters: Getters, cmd: CoreCommand) => CoreCommand | undefined>;
6992
7050
  };
6993
7051
  declare const helpers: {
6994
7052
  arg: typeof arg;
@@ -7017,6 +7075,7 @@ declare const helpers: {
7017
7075
  positionToZone: typeof positionToZone;
7018
7076
  isDefined: typeof isDefined;
7019
7077
  lazy: typeof lazy;
7078
+ genericRepeat: typeof genericRepeat;
7020
7079
  };
7021
7080
  declare const links: {
7022
7081
  isMarkdownLink: typeof isMarkdownLink;