@gridsheet/preact-core 3.2.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { StoreType, AreaType, PointType } from '../types';
2
- import { UserSheet } from '@gridsheet/core';
2
+ import { UserSheet } from '@gridsheet/web';
3
3
  export declare const clip: (store: StoreType) => AreaType;
4
4
  export type SheetCSVProps = {
5
5
  getter?: (sheet: UserSheet, point: PointType) => string;
@@ -1,4 +1,4 @@
1
- import { BookType, RegistryProps } from '@gridsheet/core';
1
+ import { BookType, RegistryProps } from '@gridsheet/web';
2
2
  export declare const useBrowser: () => {
3
3
  window: Window & typeof globalThis;
4
4
  document: Document;
@@ -1,5 +1,5 @@
1
1
  import { PointType, ZoneType, FilterConfig, StoreType } from '../types';
2
- import { UserSheet } from '@gridsheet/core';
2
+ import { UserSheet } from '@gridsheet/web';
3
3
  import { Dispatcher } from '../store';
4
4
  import { FC } from 'react';
5
5
  export type MenuContext = {
@@ -66,9 +66,22 @@ export type MenuComponentItem<Args extends unknown[] = []> = {
66
66
  componentId: string;
67
67
  visible?: (ctx: MenuContext, ...args: Args) => boolean;
68
68
  };
69
- export type ContextMenuItemDescriptor = MenuDividerItem | MenuItemBase | MenuComponentItem;
70
- export type RowMenuItemDescriptor = MenuDividerItem | MenuItemBase<[y: number]> | MenuComponentItem<[y: number]>;
71
- export type ColMenuItemDescriptor = MenuDividerItem | MenuItemBase<[x: number]> | MenuComponentItem<[x: number]>;
69
+ /**
70
+ * A menu entry that opens a nested flyout of child items on hover. `children` uses the same
71
+ * descriptor shape (items, dividers, or further submenus), so menus can nest arbitrarily —
72
+ * useful when a category (e.g. cell "Format") has more options than fit in one flat list.
73
+ */
74
+ export type MenuSubmenuItem<Args extends unknown[] = []> = {
75
+ type: 'submenu';
76
+ id?: string;
77
+ label: string | ((ctx: MenuContext, ...args: Args) => string);
78
+ visible?: (ctx: MenuContext, ...args: Args) => boolean;
79
+ disabled?: (ctx: MenuContext, ...args: Args) => boolean;
80
+ children: (MenuDividerItem | MenuItemBase<Args> | MenuSubmenuItem<Args>)[];
81
+ };
82
+ export type ContextMenuItemDescriptor = MenuDividerItem | MenuItemBase | MenuComponentItem | MenuSubmenuItem;
83
+ export type RowMenuItemDescriptor = MenuDividerItem | MenuItemBase<[y: number]> | MenuComponentItem<[y: number]> | MenuSubmenuItem<[y: number]>;
84
+ export type ColMenuItemDescriptor = MenuDividerItem | MenuItemBase<[x: number]> | MenuComponentItem<[x: number]> | MenuSubmenuItem<[x: number]>;
72
85
  export declare const defaultContextMenuDescriptors: ContextMenuItemDescriptor[];
73
86
  export declare const defaultRowMenuDescriptors: RowMenuItemDescriptor[];
74
87
  export declare const defaultColMenuDescriptors: ColMenuItemDescriptor[];
@@ -1,3 +1,3 @@
1
- import { PolicyMixinType } from '@gridsheet/core';
1
+ import { PolicyMixinType } from '@gridsheet/web';
2
2
  export declare const CheckboxPolicyMixin: PolicyMixinType;
3
3
  //# sourceMappingURL=checkbox.d.ts.map
@@ -1,6 +1,6 @@
1
- import { RegistryProps } from '@gridsheet/core';
1
+ import { RegistryProps } from '@gridsheet/web';
2
2
  /** useBook with all extended functions pre-loaded. User-supplied additionalFunctions are merged on top. */
3
- export declare const useSpellbook: ({ additionalFunctions, ...rest }?: RegistryProps) => import('@gridsheet/core').BookType;
3
+ export declare const useSpellbook: ({ additionalFunctions, ...rest }?: RegistryProps) => import('@gridsheet/engine').BookType;
4
4
  /** createBook with all extended functions pre-loaded. User-supplied additionalFunctions are merged on top. */
5
- export declare const createSpellbook: ({ additionalFunctions, ...rest }?: RegistryProps) => import('@gridsheet/core').BookType;
5
+ export declare const createSpellbook: ({ additionalFunctions, ...rest }?: RegistryProps) => import('@gridsheet/engine').BookType;
6
6
  //# sourceMappingURL=spellbook.d.ts.map
package/dist/spellbook.js CHANGED
@@ -1,8 +1,7 @@
1
1
  import { allFunctions } from "@gridsheet/functions";
2
- import { createBook } from "@gridsheet/core";
3
- import { U as useBook } from "./hooks-ykrgAwg5.mjs";
2
+ import { aH as useBook, b7 as vn } from "./hooks-BTcuh87d.mjs";
4
3
  const useSpellbook = ({ additionalFunctions, ...rest } = {}) => useBook({ ...rest, additionalFunctions: { ...allFunctions, ...additionalFunctions } });
5
- const createSpellbook = ({ additionalFunctions, ...rest } = {}) => createBook({ ...rest, additionalFunctions: { ...allFunctions, ...additionalFunctions } });
4
+ const createSpellbook = ({ additionalFunctions, ...rest } = {}) => vn({ ...rest, additionalFunctions: { ...allFunctions, ...additionalFunctions } });
6
5
  export {
7
6
  createSpellbook,
8
7
  useSpellbook
@@ -1 +1 @@
1
- {"version":3,"file":"spellbook.js","sources":["../../react-core/src/spellbook.ts"],"sourcesContent":["import { allFunctions } from '@gridsheet/functions';\nimport type { RegistryProps } from '@gridsheet/core';\nimport { createBook } from '@gridsheet/core';\nimport { useBook } from './lib/hooks';\n\n/** useBook with all extended functions pre-loaded. User-supplied additionalFunctions are merged on top. */\nexport const useSpellbook = ({ additionalFunctions, ...rest }: RegistryProps = {}) =>\n useBook({ ...rest, additionalFunctions: { ...allFunctions, ...additionalFunctions } });\n\n/** createBook with all extended functions pre-loaded. User-supplied additionalFunctions are merged on top. */\nexport const createSpellbook = ({ additionalFunctions, ...rest }: RegistryProps = {}) =>\n createBook({ ...rest, additionalFunctions: { ...allFunctions, ...additionalFunctions } });\n"],"names":[],"mappings":";;;AAMa,MAAA,eAAe,CAAC,EAAE,qBAAqB,GAAG,KAAK,IAAmB,CAAA,MAC7E,QAAQ,EAAE,GAAG,MAAM,qBAAqB,EAAE,GAAG,cAAc,GAAG,oBAAA,EAAuB,CAAA;AAG1E,MAAA,kBAAkB,CAAC,EAAE,qBAAqB,GAAG,KAAK,IAAmB,CAAA,MAChF,WAAW,EAAE,GAAG,MAAM,qBAAqB,EAAE,GAAG,cAAc,GAAG,oBAAA,EAAuB,CAAA;"}
1
+ {"version":3,"file":"spellbook.js","sources":["../../react-core/src/spellbook.ts"],"sourcesContent":["import { allFunctions } from '@gridsheet/functions';\nimport type { RegistryProps } from '@gridsheet/web';\nimport { createBook } from '@gridsheet/web';\nimport { useBook } from './lib/hooks';\n\n/** useBook with all extended functions pre-loaded. User-supplied additionalFunctions are merged on top. */\nexport const useSpellbook = ({ additionalFunctions, ...rest }: RegistryProps = {}) =>\n useBook({ ...rest, additionalFunctions: { ...allFunctions, ...additionalFunctions } });\n\n/** createBook with all extended functions pre-loaded. User-supplied additionalFunctions are merged on top. */\nexport const createSpellbook = ({ additionalFunctions, ...rest }: RegistryProps = {}) =>\n createBook({ ...rest, additionalFunctions: { ...allFunctions, ...additionalFunctions } });\n"],"names":["createBook"],"mappings":";;AAMa,MAAA,eAAe,CAAC,EAAE,qBAAqB,GAAG,KAAK,IAAmB,CAAA,MAC7E,QAAQ,EAAE,GAAG,MAAM,qBAAqB,EAAE,GAAG,cAAc,GAAG,oBAAA,EAAuB,CAAA;AAG1E,MAAA,kBAAkB,CAAC,EAAE,qBAAqB,GAAG,KAAK,IAAmB,CAAA,MAChFA,GAAW,EAAE,GAAG,MAAM,qBAAqB,EAAE,GAAG,cAAc,GAAG,oBAAA,EAAuB,CAAA;"}
@@ -1,5 +1,5 @@
1
1
  import { StoreType, RectType, ZoneType, PointType, RangeType, PositionType, RawCellType, OperatorType, FilterConfig } from '../types';
2
- import { Sheet } from '@gridsheet/core';
2
+ import { Sheet } from '@gridsheet/web';
3
3
  type StoreWithCallback = StoreType & {
4
4
  callback?: (store: StoreType) => void;
5
5
  };
@@ -12,6 +12,9 @@ export declare class CoreAction<T> {
12
12
  private actionId;
13
13
  /** Whether this action mutates sheet data (triggers loading indicator). */
14
14
  mutation: boolean;
15
+ /** Whether this action kicks off a chunked async mutation (fill/paste): its reduce
16
+ * sets `pendingAsyncOp` and GridSheet runs it with a progress bar. Locked while one runs. */
17
+ asyncMutation: boolean;
15
18
  reduce(store: StoreType, payload: T): StoreWithCallback;
16
19
  call(payload: T): {
17
20
  type: number;
@@ -24,6 +27,8 @@ export declare class CoreAction<T> {
24
27
  }
25
28
  /** Returns true if the given action type is a mutation (heavy operation). */
26
29
  export declare const isMutationAction: (type: number) => boolean;
30
+ /** Returns true if the action starts a chunked async mutation (fill/paste). */
31
+ export declare const isAsyncMutationAction: (type: number) => boolean;
27
32
  export declare const setSearchQuery: (payload: string | undefined) => {
28
33
  type: number;
29
34
  value: string | undefined;
@@ -296,6 +301,7 @@ export declare const setColumnMenu: (payload: {
296
301
  y: number;
297
302
  x: number;
298
303
  };
304
+ focusLabel?: boolean;
299
305
  } | null) => {
300
306
  type: number;
301
307
  value: {
@@ -304,6 +310,7 @@ export declare const setColumnMenu: (payload: {
304
310
  y: number;
305
311
  x: number;
306
312
  };
313
+ focusLabel?: boolean;
307
314
  } | null;
308
315
  };
309
316
  export declare const setRowMenu: (payload: {
@@ -330,6 +337,36 @@ export declare const setStore: (payload: Partial<StoreType>) => {
330
337
  type: number;
331
338
  value: Partial<StoreType>;
332
339
  };
340
+ export declare const selectToDataEdge: (payload: {
341
+ deltaY: number;
342
+ deltaX: number;
343
+ }) => {
344
+ type: number;
345
+ value: {
346
+ deltaY: number;
347
+ deltaX: number;
348
+ };
349
+ };
350
+ export declare const fillDown: (payload: null) => {
351
+ type: number;
352
+ value: null;
353
+ };
354
+ export declare const fillRight: (payload: null) => {
355
+ type: number;
356
+ value: null;
357
+ };
358
+ export declare const commitAsyncOp: (payload: {
359
+ sheet: Sheet;
360
+ selectingZone: ZoneType;
361
+ finalize?: Partial<StoreType>;
362
+ }) => {
363
+ type: number;
364
+ value: {
365
+ sheet: Sheet;
366
+ selectingZone: ZoneType;
367
+ finalize?: Partial<StoreType>;
368
+ };
369
+ };
333
370
  export declare const userActions: {
334
371
  blur: (payload: null) => {
335
372
  type: number;
@@ -537,6 +574,24 @@ export declare const userActions: {
537
574
  filter?: FilterConfig;
538
575
  };
539
576
  };
577
+ selectToDataEdge: (payload: {
578
+ deltaY: number;
579
+ deltaX: number;
580
+ }) => {
581
+ type: number;
582
+ value: {
583
+ deltaY: number;
584
+ deltaX: number;
585
+ };
586
+ };
587
+ fillDown: (payload: null) => {
588
+ type: number;
589
+ value: null;
590
+ };
591
+ fillRight: (payload: null) => {
592
+ type: number;
593
+ value: null;
594
+ };
540
595
  };
541
596
  export {};
542
597
  //# sourceMappingURL=actions.d.ts.map
@@ -1,4 +1,4 @@
1
- import { Sheet } from '@gridsheet/core';
1
+ import { Sheet } from '@gridsheet/web';
2
2
  import { PointType, StorePatchType, StoreType } from '../types';
3
3
  /**
4
4
  * Strip redundant fields from a StorePatchType before recording in history.
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { RefObject, CSSProperties, KeyboardEvent } from 'react';
2
- import { Sheet, UserSheet, BookType, PolicyType, ModeType, DensityType, GridLinesType, MatrixAlignmentType, PointType, ZoneType, RectType, PositionType, CellsByAddressType, SheetLimits } from '@gridsheet/core';
2
+ import { Sheet, UserSheet, BookType, PolicyType, ModeType, DensityType, GridLinesType, MatrixAlignmentType, PointType, ZoneType, RectType, PositionType, CellsByAddressType, SheetLimits } from '@gridsheet/web';
3
3
  import { ContextMenuItemDescriptor, RowMenuItemDescriptor, ColMenuItemDescriptor } from './lib/menu';
4
- export type { CSSPropertiesLike, RefLike, Resolution, Y, X, Height, Width, ShapeType, RectType, MatrixType, CursorStateType, FeedbackType, ModeType, HeadersType, AsyncCache, System, FilterConditionMethod, FilterCondition, FilterConfig, CellType, RawCellType, CellPatchType, CellFilter, CellsByAddressType, CellsByIdType, SystemsByIdType, RangeType, PointType, ExtraPointType, PositionType, ZoneType, AreaType, WriterType, Id, Ids, IdMatrix, Address, MatricesByAddress, StorePatchType, HistoryUpdateType, MoveRelation, MoveRelations, HistoryMoveType, HistoryInsertRowsType, HistoryRemoveRowsType, HistoryInsertColsType, HistoryRemoveColsType, HistorySortRowsType, HistoryType, Virtualization, OperatorType, OperationType, Dispatcher, StoreDispatchType, ContextsBySheetId, SheetIdsByName, RefPaletteType, } from '@gridsheet/core';
4
+ export type { CSSPropertiesLike, RefLike, Resolution, Y, X, Height, Width, ShapeType, RectType, MatrixType, CursorStateType, FeedbackType, ModeType, HeadersType, AsyncCache, System, FilterConditionMethod, FilterCondition, FilterConfig, CellType, RawCellType, CellPatchType, CellFilter, CellsByAddressType, CellsByIdType, SystemsByIdType, RangeType, PointType, ExtraPointType, PositionType, ZoneType, AreaType, WriterType, Id, Ids, IdMatrix, Address, MatricesByAddress, StorePatchType, HistoryUpdateType, MoveRelation, MoveRelations, HistoryMoveType, HistoryInsertRowsType, HistoryRemoveRowsType, HistoryInsertColsType, HistoryRemoveColsType, HistorySortRowsType, HistoryType, Virtualization, OperatorType, OperationType, Dispatcher, StoreDispatchType, ContextsBySheetId, SheetIdsByName, RefPaletteType, } from '@gridsheet/web';
5
5
  export type Policies = {
6
6
  [s: string]: PolicyType;
7
7
  };
@@ -89,12 +89,21 @@ export type StoreType = {
89
89
  columnMenuState: {
90
90
  x: number;
91
91
  position: PositionType;
92
+ focusLabel?: boolean;
92
93
  } | null;
93
94
  rowMenuState: {
94
95
  y: number;
95
96
  position: PositionType;
96
97
  } | null;
97
98
  editorHovering: boolean;
99
+ pendingAsyncOp: PendingAsyncOp | null;
100
+ };
101
+ export type PendingAsyncOp = {
102
+ run: (onProgress: (ratio: number) => void) => Promise<Sheet>;
103
+ selectingZone: ZoneType;
104
+ label: string;
105
+ finalize?: Partial<StoreType>;
106
+ postCommit?: () => void;
98
107
  };
99
108
  export type Manager<T> = {
100
109
  instance: T;
@@ -115,6 +124,13 @@ export type StoreHandle = {
115
124
  value: any;
116
125
  }>;
117
126
  };
127
+ /** Consumer-driven loading state: show a progress overlay while data isn't ready yet (e.g.
128
+ * the app is fetching/parsing initial cells). `true` = indeterminate spinner; an object =
129
+ * a determinate bar. The consumer decides when loading ends (the grid can't know the source). */
130
+ export type LoadingState = boolean | {
131
+ progress?: number | null;
132
+ label?: string;
133
+ };
118
134
  export type Props = {
119
135
  initialCells: CellsByAddressType;
120
136
  sheetName?: string;
@@ -124,6 +140,7 @@ export type Props = {
124
140
  options?: OptionsType;
125
141
  className?: string;
126
142
  style?: CSSProperties;
143
+ loading?: LoadingState;
127
144
  };
128
145
  export type EditorEvent = KeyboardEvent<HTMLTextAreaElement>;
129
146
  export type EditorEventWithNativeEvent = EditorEvent & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsheet/preact-core",
3
- "version": "3.2.0",
3
+ "version": "3.4.0",
4
4
  "description": "Spreadsheet component for Preact",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -10,7 +10,7 @@
10
10
  "url": "git+https://github.com/walkframe/gridsheet.git"
11
11
  },
12
12
  "dependencies": {
13
- "@gridsheet/core": "3.2.0"
13
+ "@gridsheet/web": "3.4.0"
14
14
  },
15
15
  "exports": {
16
16
  ".": {
@@ -35,7 +35,8 @@
35
35
  "vite": "^6.2.2",
36
36
  "vite-plugin-dts": "^4.5.3",
37
37
  "@preact/preset-vite": "^2.10.1",
38
- "@gridsheet/functions": "3.2.0"
38
+ "@gridsheet/react-core": "3.4.0",
39
+ "@gridsheet/functions": "3.4.0"
39
40
  },
40
41
  "bugs": {
41
42
  "url": "https://github.com/walkframe/gridsheet/issues"