@guiexpert/table 1.1.5 → 1.1.8

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.
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @type {ReadonlyArray<string>}
5
5
  */
6
- export declare const actionIds: readonly ["START_EDITING", "TOGGLE_SELECTION", "SELECT_ALL", "DESELECT_ALL", "NAVIGATE_LEFT", "NAVIGATE_RIGHT", "NAVIGATE_UP", "NAVIGATE_DOWN"];
6
+ export declare const actionIds: readonly ["COPY_2_CLIPBOARD", "START_EDITING", "TOGGLE_SELECTION", "SELECT_ALL", "DESELECT_ALL", "NAVIGATE_LEFT", "NAVIGATE_RIGHT", "NAVIGATE_UP", "NAVIGATE_DOWN"];
7
7
  /**
8
8
  * Represents an action ID.
9
9
  *
@@ -2,6 +2,8 @@ import { ActionId } from "./action-id.type";
2
2
  /**
3
3
  * Class representing the mapping of OS X shortcut actions to action IDs.
4
4
  *
5
+ * Use 'meta' for the MacOS 'cmd' key.
6
+ *
5
7
  * @class OsxShortcutActionIdMapping
6
8
  */
7
9
  export declare class OsxShortcutActionIdMapping {
@@ -1,4 +1,5 @@
1
1
  import { TableScope } from "../table-scope";
2
+ import { ShortcutActionIdMapping } from "./shortcut-actionid-mapping.type";
2
3
  import { OnActionTriggeredIf } from "./on-action-triggered.if";
3
4
  /**
4
5
  * Represents a service for managing shortcuts and triggering actions based on keyboard events.
@@ -8,14 +9,31 @@ export declare class ShortcutService {
8
9
  private shortcutActionIdMapping;
9
10
  private listener;
10
11
  constructor(tableScope: TableScope);
12
+ /**
13
+ * Adds a listener to the list of listeners.
14
+ *
15
+ * @param {OnActionTriggeredIf} listener - The listener to be added.
16
+ * @returns {void}
17
+ */
11
18
  addListener(listener: OnActionTriggeredIf): void;
19
+ /**
20
+ * Initializes the ShortcutService by assigning shortcut action id mappings based on the current operating system.
21
+ * Also adds key down event listener to the table host element.
22
+ */
12
23
  init(): void;
24
+ private assignPredefinedSystemShortcutMappings;
13
25
  private isMacintosh;
14
26
  private isDebug;
15
27
  private isLocalhost;
16
28
  private onKeyDown;
17
29
  private emit;
18
- private findEnty;
30
+ private findEntity;
19
31
  private areTokensEquals;
20
32
  private getTokenByEvent;
33
+ /**
34
+ * Retrieves the shortcut action mapping object.
35
+ *
36
+ * @returns {ShortcutActionIdMapping} - The shortcut action mapping object.
37
+ */
38
+ getShortcutActionMapping(): ShortcutActionIdMapping;
21
39
  }
@@ -1,6 +1,8 @@
1
1
  import { ActionId } from "./action-id.type";
2
2
  /**
3
3
  * Class representing a mapping of Windows shortcut keys to action IDs.
4
+ *
5
+ * Use 'meta' for the MacOS 'cmd' key.
4
6
  */
5
7
  export declare class WindowsShortcutActionIdMapping {
6
8
  get(): {
@@ -17,6 +17,7 @@ export declare abstract class AbstractAreaModel<T> implements AreaModelIf, HasDe
17
17
  constructor(areaIdent: AreaIdent, columnDefs?: ColumnDefIf[], defaultRowHeight?: number);
18
18
  abstract getRowCount(): number;
19
19
  abstract getValueAt(rowIndex: number, columnIndex: number): any;
20
+ getTextValueAt(rowIndex: number, columnIndex: number): string;
20
21
  getTooltipAt(_rowIndex: number, _columnIndex: number): any;
21
22
  abstract getRowHeight(rowIndex: number): number;
22
23
  getCellRenderer(_rowIndex: number, columnIndex: number): CellRendererIf | undefined;
@@ -38,6 +38,7 @@ export declare class AreaModelCellGroups implements AreaModelIf {
38
38
  getRowspanAt(rowIndex: number, columnIndex: number): number;
39
39
  getTooltipAt(_rowIndex: number, _columnIndex: number): any;
40
40
  getValueAt(rowIndex: number, columnIndex: number): any;
41
+ getTextValueAt(rowIndex: number, columnIndex: number): string;
41
42
  getYPosByRowIndex(_rowIndex: number): number;
42
43
  init(): void;
43
44
  getRowHeight(_rowIndex: number): number;
@@ -14,6 +14,7 @@ export declare class AreaModelHidden implements AreaModelIf {
14
14
  constructor(areaIdent?: AreaIdent);
15
15
  getRowCount(): number;
16
16
  getValueAt(_rowIndex: number, _columnIndex: number): any;
17
+ getTextValueAt(_rowIndex: number, _columnIndex: number): string;
17
18
  getCellRenderer(_rowIndex: number, _columnIndex: number): CellRendererIf | undefined;
18
19
  getRowHeight(_rowIndex: number): number;
19
20
  getColspanAt(_rowIndex: number, _columnIndex: number): number;
@@ -28,6 +28,7 @@ export declare class AreaModel implements AreaModelIf {
28
28
  getRowspanAt(_rowIndex: number, _columnIndex: number): number;
29
29
  getTooltipAt(_rowIndex: number, _columnIndex: number): any;
30
30
  getValueAt(_rowIndex: number, _columnIndex: number): any;
31
+ getTextValueAt(_rowIndex: number, _columnIndex: number): string;
31
32
  getYPosByRowIndex(_rowIndex: number): number;
32
33
  init(): void;
33
34
  isEditable(_rowIndex: number, _columnIndex: number): boolean;
@@ -39,6 +39,11 @@ export interface AreaModelIf {
39
39
  * Returns the value of the cell at position rowIndex/columnIndex.
40
40
  */
41
41
  getValueAt(rowIndex: number, columnIndex: number): any;
42
+ /**
43
+ * Returns a string value of the cell at position rowIndex/columnIndex.
44
+ * This function will be called by 'export' or 'copy to clipboard'.
45
+ */
46
+ getTextValueAt(rowIndex: number, columnIndex: number): string;
42
47
  /**
43
48
  * Returns the value of a colspan of the cell at position rowIndex/columnIndex.
44
49
  * A value below 2 is ignored.
@@ -6,6 +6,12 @@ import { GeMouseEvent } from "./data/common/event/ge-mouse-event";
6
6
  */
7
7
  export declare class MouseHandler {
8
8
  protected tableScope: TableScope;
9
+ /**
10
+ * Represents the delay in milliseconds between two consecutive double clicks.
11
+ *
12
+ * @type {number}
13
+ */
14
+ doubleClickDelay: number;
9
15
  mouseEvent?: MouseEvent;
10
16
  startMouseEvent?: GeMouseEvent;
11
17
  geMouseEvent?: GeMouseEvent;
@@ -22,6 +28,7 @@ export declare class MouseHandler {
22
28
  * @return {void}
23
29
  */
24
30
  private onContextmenu;
31
+ private lastClicked;
25
32
  /**
26
33
  * Handles the click event on the host element.
27
34
  *
@@ -45,7 +45,14 @@ export declare class RenderScope extends EleScope {
45
45
  protected editing: boolean;
46
46
  isEditing(): boolean;
47
47
  resetEditorRenderer(): void;
48
- clearSelection(): void;
48
+ /**
49
+ * Clears the selection in the component.
50
+ *
51
+ * @param {boolean} rerender - Indicates whether to rerender the component after clearing the selection. Default value is false.
52
+ *
53
+ * @return {void}
54
+ */
55
+ clearSelection(rerender?: boolean): void;
49
56
  initRenderEditor(rowIdx: number, colIdx: number): void;
50
57
  repaint(): void;
51
58
  adjustAfterScrolling(): void;
@@ -0,0 +1,4 @@
1
+ import { AreaIdent, AreaModelIf, CellRendererIf, DomServiceIf, RendererCleanupFnType } from '../../../index.ts';
2
+ export declare class PositiveAndNegativeNumberRenderer implements CellRendererIf {
3
+ render(cellDiv: HTMLDivElement, rowIndex: number, columnIndex: number, areaIdent: AreaIdent, _areaModel: AreaModelIf, cellValue: any, domService: DomServiceIf): RendererCleanupFnType | undefined;
4
+ }
@@ -1,13 +1,14 @@
1
1
  import { CellRange } from "../data/common/cell-range";
2
- import { SelectionMode, SelectionType } from "./selection.type";
2
+ import { ExtendedSelectionType, SelectionMode } from './selection.type';
3
3
  import { SelectionModelIf } from "./selection-model.if";
4
4
  export declare class SelectionModel implements SelectionModelIf {
5
- selectionType: SelectionType;
5
+ selectionType: ExtendedSelectionType;
6
6
  selectionMode: SelectionMode;
7
7
  protected ranges: CellRange[];
8
8
  protected negativeRanges: CellRange[];
9
9
  protected allSelected: boolean;
10
- constructor(selectionType?: SelectionType, selectionMode?: SelectionMode);
10
+ constructor(selectionType?: ExtendedSelectionType, selectionMode?: SelectionMode);
11
+ firstClick(rowIndex: number, columnIndex: number): void;
11
12
  getSelectionCount(rowIndex: number, columnIndex: number): number;
12
13
  isInNegativeRange(rowIndex: number, columnIndex: number): boolean;
13
14
  getRanges(): CellRange[];
@@ -17,5 +18,6 @@ export declare class SelectionModel implements SelectionModelIf {
17
18
  addSelection(range: CellRange): void;
18
19
  removeSelection(range: CellRange): void;
19
20
  togglePoint(row: number, col: number): void;
21
+ isSelected(row: number, col: number): boolean;
20
22
  private addRange;
21
23
  }
@@ -1,6 +1,7 @@
1
1
  import { CellRange } from "../data/common/cell-range";
2
2
  export interface SelectionModelIf {
3
3
  togglePoint(row: number, col: number): void;
4
+ isSelected(row: number, col: number): boolean;
4
5
  getRanges(): CellRange[];
5
6
  clear(): void;
6
7
  hasSelection(): boolean;
@@ -8,4 +9,5 @@ export interface SelectionModelIf {
8
9
  removeSelection(range: CellRange): void;
9
10
  getSelectionCount(rowIndex: number, columnIndex: number): number;
10
11
  selectAll(): void;
12
+ firstClick(rowIndex: number, columnIndex: number): void;
11
13
  }
@@ -7,8 +7,8 @@ import { OnActionTriggeredIf } from "../action/on-action-triggered.if";
7
7
  import { ActionId } from "../action/action-id.type";
8
8
  export declare class SelectionService implements OnActionTriggeredIf {
9
9
  protected readonly tableScope: TableScope;
10
- protected getSelectionModel?: GetT<SelectionModelIf>;
11
- protected getFocusModel?: GetT<FocusModelIf>;
10
+ getSelectionModel?: GetT<SelectionModelIf>;
11
+ getFocusModel?: GetT<FocusModelIf>;
12
12
  protected previousEvt?: GeMouseEvent;
13
13
  constructor(tableScope: TableScope);
14
14
  onMouseClicked(evt: GeMouseEvent, _previousEvt: GeMouseEvent | undefined): boolean;
@@ -1,2 +1,3 @@
1
- export type SelectionType = "none" | "cell" | "row" | "column" | "range";
1
+ export type ExtendedSelectionType = SelectionType | "range";
2
+ export type SelectionType = "none" | "cell" | "row" | "column";
2
3
  export type SelectionMode = "single" | "multi";
@@ -0,0 +1,11 @@
1
+ import { TableModelIf } from '../data/tablemodel/table-model.if';
2
+ import { SelectionModelIf } from '../selection/selection-model.if';
3
+ import { FocusModelIf } from '../focus/focus-model.if';
4
+ import { CopyServiceIf } from './copy-service.if';
5
+ export declare class CopyService implements CopyServiceIf {
6
+ static columnSeparatorChar: string;
7
+ static rowSeparatorChar: string;
8
+ createContent(tableModel: TableModelIf, selectionModel: SelectionModelIf, focusModel: FocusModelIf): Promise<string>;
9
+ copyContent(content: string): Promise<void>;
10
+ private mergeRanges;
11
+ }
@@ -0,0 +1,7 @@
1
+ import { TableModelIf } from '../data/tablemodel/table-model.if';
2
+ import { SelectionModelIf } from '../selection/selection-model.if';
3
+ import { FocusModelIf } from '../focus/focus-model.if';
4
+ export interface CopyServiceIf {
5
+ createContent(tableModel: TableModelIf, selectionModel: SelectionModelIf | undefined, focusModel: FocusModelIf | undefined): Promise<string>;
6
+ copyContent(content: string): Promise<void>;
7
+ }
@@ -1,6 +1,9 @@
1
1
  import { TableScope } from "./table-scope";
2
2
  import { ColumnDefIf } from "./data/tablemodel/column/column-def.if";
3
3
  import { TableCellUpdateEventIf } from "./data/common/event/input/table-cell-update-event.if";
4
+ import { SelectionModel } from './selection/selection-model';
5
+ import { ActionId } from './action/action-id.type';
6
+ import { ShortcutActionIdMapping } from './action/shortcut-actionid-mapping.type';
4
7
  export declare class TableApi {
5
8
  private readonly tableScope;
6
9
  constructor(tableScope: TableScope);
@@ -87,4 +90,34 @@ export declare class TableApi {
87
90
  * to update and redraw the table based on the latest data.
88
91
  */
89
92
  repaint(): void;
93
+ /**
94
+ * Clears the current selection of the table.
95
+ * The table will be rendered automatically.
96
+ *
97
+ * @returns {void}
98
+ */
99
+ clearSelection(): void;
100
+ /**
101
+ * Sets the selection model for the table scope.
102
+ *
103
+ * @param {SelectionModel} sm - The selection model to be set.
104
+ * @param {boolean} [repaint=true] - Indicates whether the table should be repainted after setting the selection model. Default value is true.
105
+ *
106
+ * @return {void}
107
+ */
108
+ setSelectionModel(sm: SelectionModel, repaint?: boolean): void;
109
+ /**
110
+ * Triggers the action with the given action ID.
111
+ * This function can be invoked programmatically.
112
+ *
113
+ * @param {ActionId} actionId - The ID of the action to trigger.
114
+ * @return {void}
115
+ */
116
+ triggerAction(actionId: ActionId): void;
117
+ /**
118
+ * Retrieves the mapping of shortcuts to corresponding action in the current table scope.
119
+ *
120
+ * @return {ShortcutActionIdMapping} The mapping of shortcuts to corresponding action.
121
+ */
122
+ getShortcutActionMapping(): ShortcutActionIdMapping;
90
123
  }
@@ -16,6 +16,8 @@ import { OnActionTriggeredIf } from "./action/on-action-triggered.if";
16
16
  import { ActionId } from "./action/action-id.type";
17
17
  import { ShortcutService } from "./action/shortcut.service";
18
18
  import { LicenseManager } from './license-manager';
19
+ import { SelectionModel } from './selection/selection-model';
20
+ import { CopyServiceIf } from './service/copy-service.if';
19
21
  /**
20
22
  * Creates a TableScope instance.
21
23
  * @param {HTMLDivElement} hostElement - The host element.
@@ -26,6 +28,7 @@ import { LicenseManager } from './license-manager';
26
28
  */
27
29
  export declare class TableScope extends RenderScope implements OnActionTriggeredIf {
28
30
  protected readonly eventListener: EventListenerIf;
31
+ protected readonly copyService: CopyServiceIf;
29
32
  licenseManager: LicenseManager;
30
33
  mouseHandler: MouseHandler;
31
34
  inputHandler: InputHandler;
@@ -51,8 +54,16 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
51
54
  *
52
55
  * @return {TableScope} - The newly created TableScope instance.
53
56
  */
54
- static create(hostElement: HTMLDivElement, tableModel: TableModelIf, tableOptions?: TableOptionsIf, eventListener?: EventListenerIf, domService?: DomServiceIf): TableScope;
55
- constructor(hostElement: HTMLDivElement, tableModel: TableModelIf, domService: DomServiceIf, tableOptions: TableOptionsIf, eventListener: EventListenerIf);
57
+ static create(hostElement: HTMLDivElement, tableModel: TableModelIf, tableOptions?: TableOptionsIf, eventListener?: EventListenerIf, domService?: DomServiceIf, copyService?: CopyServiceIf): TableScope;
58
+ constructor(hostElement: HTMLDivElement, tableModel: TableModelIf, domService: DomServiceIf, tableOptions: TableOptionsIf, eventListener: EventListenerIf, copyService?: CopyServiceIf);
59
+ /**
60
+ * Triggers an action based on the provided actionId.
61
+ *
62
+ * This function can be invoked manually via the table API or by keyboard shortcuts.
63
+ *
64
+ * @param {ActionId} actionId - The identifier of the action to be triggered.
65
+ * @return {boolean} - Returns true if the action was triggered successfully, false otherwise.
66
+ */
56
67
  onActionTriggered(actionId: ActionId): boolean;
57
68
  updateModelValueAfterEdit(areaIdent: AreaIdent, rowIndex: number, columnIndex: number, value: string): void;
58
69
  /**
@@ -137,7 +148,9 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
137
148
  * @param {GeMouseEvent | undefined} previousEvt - The previous mouse click event, if any.
138
149
  * @returns {void}
139
150
  */
140
- onMouseClicked(evt: GeMouseEvent, previousEvt: GeMouseEvent | undefined): void;
151
+ onMouseClicked(evt: GeMouseEvent, previousEvt: GeMouseEvent | undefined): boolean;
152
+ debounceRepaint(): void;
153
+ publishGeMouseEvent(evt: GeMouseEvent): void;
141
154
  /**
142
155
  * Updates the table (repaint) when an external filter is changed.
143
156
  *
@@ -179,8 +192,6 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
179
192
  /**
180
193
  * Restores the scroll position of the table if auto restore options are enabled.
181
194
  *
182
- * @private
183
- * @memberof ClassName
184
195
  *
185
196
  * @returns {void}
186
197
  */
@@ -224,4 +235,13 @@ export declare class TableScope extends RenderScope implements OnActionTriggered
224
235
  * @return {void}
225
236
  */
226
237
  scrollToIndex(_indexX: number, indexY: number): void;
238
+ /**
239
+ * Sets the selection model for the table.
240
+ *
241
+ * @param {SelectionModel} sm - The selection model to be set.
242
+ * @param {boolean} rerender - Optional parameter indicating whether to rerender the table after setting the selection model. Default value is false.
243
+ *
244
+ * @return {void} - This method does not return any value.
245
+ */
246
+ setSelectionModel(sm: SelectionModel, rerender?: boolean): void;
227
247
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guiexpert/table",
3
- "version": "1.1.5",
3
+ "version": "1.1.8",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.0"
6
6
  },
@@ -25,3 +25,4 @@
25
25
  }
26
26
  }
27
27
 
28
+