logisheets-engine 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/logisheets-engine.css +1 -1
- package/dist/logisheets-engine.es.js +537 -379
- package/dist/logisheets-engine.umd.js +1 -1
- package/dist/types/lib/adapters/react.d.ts +6 -5
- package/dist/types/lib/components/contextMenuTypes.d.ts +22 -0
- package/dist/types/lib/index.d.ts +1 -1
- package/dist/types/lib/session.d.ts +13 -4
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { SelectedData, SheetInfo, CellLayout } from "logisheets-web";
|
|
7
7
|
import type { Grid, EngineConfig } from "$types/index";
|
|
8
|
-
import type {
|
|
8
|
+
import type { ContextMenuContext } from "../components/contextMenuTypes";
|
|
9
9
|
/**
|
|
10
10
|
* Props for the React Spreadsheet component adapter.
|
|
11
11
|
* These mirror the Svelte component props but follow React conventions.
|
|
@@ -23,8 +23,6 @@ export interface SpreadsheetAdapterProps {
|
|
|
23
23
|
showSheetTabs?: boolean;
|
|
24
24
|
/** Show scrollbars */
|
|
25
25
|
showScrollbars?: boolean;
|
|
26
|
-
/** Custom context menu items */
|
|
27
|
-
contextMenuItems?: ContextMenuItem[];
|
|
28
26
|
/** Callback when selection changes */
|
|
29
27
|
onSelectedDataChange?: (data: SelectedData) => void;
|
|
30
28
|
/** Callback when active sheet changes */
|
|
@@ -33,8 +31,11 @@ export interface SpreadsheetAdapterProps {
|
|
|
33
31
|
onGridChange?: (grid: Grid | null) => void;
|
|
34
32
|
/** Callback when sheets list changes */
|
|
35
33
|
onSheetsChange?: (sheets: readonly SheetInfo[]) => void;
|
|
36
|
-
/**
|
|
37
|
-
|
|
34
|
+
/**
|
|
35
|
+
* The user opened the context menu. The engine renders no menu — the host
|
|
36
|
+
* renders its own at `(x, y)` (viewport coords) using `context`.
|
|
37
|
+
*/
|
|
38
|
+
onContextMenu?: (context: ContextMenuContext, x: number, y: number) => void;
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
41
|
* LogiSheets-compatible props that follow the existing LogiSheets naming conventions.
|
|
@@ -17,6 +17,28 @@ export interface ContextMenuItem {
|
|
|
17
17
|
shortcut?: string;
|
|
18
18
|
/** Sub-menu items (if any) */
|
|
19
19
|
children?: ContextMenuItem[];
|
|
20
|
+
/**
|
|
21
|
+
* Which trigger targets this item applies to. When omitted the item shows
|
|
22
|
+
* for every target; otherwise it only shows when the menu was opened on one
|
|
23
|
+
* of the listed targets (e.g. `["row", "column"]` for an insert/delete
|
|
24
|
+
* action, `["cell"]` for "Clear Cells").
|
|
25
|
+
*/
|
|
26
|
+
targets?: ContextMenuTarget[];
|
|
27
|
+
/**
|
|
28
|
+
* Item kind. `"action"` (default) is a plain clickable row. `"stepper"`
|
|
29
|
+
* renders an inline numeric control (− value +) the user adjusts in place;
|
|
30
|
+
* its current value is passed as the third argument to the menu's click
|
|
31
|
+
* handler for every action item, so a sibling action (e.g. "Insert rows
|
|
32
|
+
* above") can act on the chosen amount. A stepper row is not itself
|
|
33
|
+
* clickable and does not close the menu.
|
|
34
|
+
*/
|
|
35
|
+
type?: "action" | "stepper";
|
|
36
|
+
/** Minimum value for a `stepper` item (default 1). */
|
|
37
|
+
min?: number;
|
|
38
|
+
/** Maximum value for a `stepper` item (default 1000). */
|
|
39
|
+
max?: number;
|
|
40
|
+
/** Initial value for a `stepper` item (default `min`). */
|
|
41
|
+
value?: number;
|
|
20
42
|
}
|
|
21
43
|
/**
|
|
22
44
|
* The target type where context menu was triggered
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Spreadsheet, ColumnHeaders, RowHeaders, Selector, SheetTabs, Scrollbar, ContextMenu, match, xForColStart, xForColEnd, yForRowStart, yForRowEnd, getPosition, getSelectedCellRange, getSelectedRows, getSelectedColumns, getSelectedLines, findVisibleRowIdxRange, findVisibleColIdxRange, buildSelectedDataFromCell, buildSelectedDataFromCellRange, ptToPx, pxToPt, pxToWidth, simpleUuid, } from "./components";
|
|
2
|
-
export type { ContextMenuItem, ContextMenuContext, } from "./components/contextMenuTypes";
|
|
2
|
+
export type { ContextMenuItem, ContextMenuContext, ContextMenuTarget, } from "./components/contextMenuTypes";
|
|
3
3
|
export { DataService, WorkbookClient, OffscreenClient } from "./clients";
|
|
4
4
|
export { WorkbookWorkerService, OffscreenWorkerService } from "./worker";
|
|
5
5
|
export { BlockManager, EnumSetManager, FieldManager, LOGISHEETS_BUILTIN_CRAFT_ID, FIELD_AND_VALIDATION_TAG, } from "./block";
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
import type { SheetInfo, SelectedData, CellLayout } from "logisheets-web";
|
|
19
19
|
import type { DataService } from "./clients/service";
|
|
20
20
|
import type { Grid, EngineConfig } from "$types/index";
|
|
21
|
-
import type {
|
|
21
|
+
import type { ContextMenuContext } from "./components/contextMenuTypes";
|
|
22
22
|
/** Events scoped to a single view. */
|
|
23
|
-
export type SessionEventType = "selectionChange" | "gridChange" | "activeSheetChange" | "startEdit" | "invalidFormula" | "error";
|
|
23
|
+
export type SessionEventType = "selectionChange" | "gridChange" | "activeSheetChange" | "startEdit" | "invalidFormula" | "contextMenu" | "error";
|
|
24
24
|
export interface SessionEventMap {
|
|
25
25
|
selectionChange: SelectedData;
|
|
26
26
|
gridChange: Grid | null;
|
|
@@ -31,6 +31,17 @@ export interface SessionEventMap {
|
|
|
31
31
|
initialText: string;
|
|
32
32
|
};
|
|
33
33
|
invalidFormula: void;
|
|
34
|
+
/**
|
|
35
|
+
* The user opened the context menu (right-clicked a cell or a row/column
|
|
36
|
+
* header). The engine renders NO menu of its own — the host listens for
|
|
37
|
+
* this and renders whatever menu it likes at `(x, y)` (viewport
|
|
38
|
+
* coordinates), using `context` to decide the items.
|
|
39
|
+
*/
|
|
40
|
+
contextMenu: {
|
|
41
|
+
context: ContextMenuContext;
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
};
|
|
34
45
|
error: Error;
|
|
35
46
|
}
|
|
36
47
|
type SessionEventCallback<T extends SessionEventType> = (data: SessionEventMap[T]) => void;
|
|
@@ -39,8 +50,6 @@ export interface SessionMountOptions {
|
|
|
39
50
|
showSheetTabs?: boolean;
|
|
40
51
|
/** Show scrollbars */
|
|
41
52
|
showScrollbars?: boolean;
|
|
42
|
-
/** Custom context menu items */
|
|
43
|
-
contextMenuItems?: ContextMenuItem[];
|
|
44
53
|
/** Cell layouts for custom rendering */
|
|
45
54
|
cellLayouts?: CellLayout[];
|
|
46
55
|
/** Getter for whether a formula is being edited (prevents canvas from taking focus) */
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "logisheets-engine",
|
|
3
3
|
"author": "Jeremy He<yiliang.he@qq.com>",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.2",
|
|
6
6
|
"description": "LogiSheets spreadsheet engine - a high-performance spreadsheet rendering and editing library",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./dist/logisheets-engine.umd.js",
|