@fileverse-dev/dsheet 2.0.0 → 2.0.1-search-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.
Files changed (35) hide show
  1. package/dist/editor/components/import-button-ui.d.ts +1 -1
  2. package/dist/editor/utils/csv-import.d.ts +1 -1
  3. package/dist/editor/utils/custom-toolbar-item.d.ts +1 -1
  4. package/dist/editor/utils/export-filename.d.ts +1 -0
  5. package/dist/{es-DHiiPgkU.js → es-BJ3y6kL2.js} +38 -5
  6. package/dist/{hi-DgkuC9mD.js → hi-BLJfbm0w.js} +38 -5
  7. package/dist/index.es.js +20276 -18395
  8. package/dist/sheet-engine/core/api/cell.d.ts +1 -1
  9. package/dist/sheet-engine/core/context.d.ts +36 -0
  10. package/dist/sheet-engine/core/events/mouse.d.ts +1 -1
  11. package/dist/sheet-engine/core/index.d.ts +2 -1
  12. package/dist/sheet-engine/core/locale/en.d.ts +33 -0
  13. package/dist/sheet-engine/core/locale/es.d.ts +33 -0
  14. package/dist/sheet-engine/core/locale/hi.d.ts +33 -0
  15. package/dist/sheet-engine/core/locale/zh.d.ts +33 -0
  16. package/dist/sheet-engine/core/locale/zh_tw.d.ts +33 -0
  17. package/dist/sheet-engine/core/modules/cell.d.ts +5 -0
  18. package/dist/sheet-engine/core/modules/formula.d.ts +13 -4
  19. package/dist/sheet-engine/core/modules/index.d.ts +5 -4
  20. package/dist/sheet-engine/core/modules/inline-string.d.ts +6 -6
  21. package/dist/sheet-engine/core/modules/rowcol.d.ts +7 -3
  22. package/dist/sheet-engine/core/modules/searchReplace.d.ts +118 -26
  23. package/dist/sheet-engine/core/modules/selection.d.ts +12 -6
  24. package/dist/sheet-engine/core/modules/validation.d.ts +11 -0
  25. package/dist/sheet-engine/core/types.d.ts +4 -2
  26. package/dist/sheet-engine/core/utils/patch.d.ts +2 -0
  27. package/dist/sheet-engine/react/components/QuickSearch/index.d.ts +4 -0
  28. package/dist/sheet-engine/react/components/ResetRowHeight/index.d.ts +3 -0
  29. package/dist/sheet-engine/react/components/Workbook/api.d.ts +2 -0
  30. package/dist/sheet-engine/react/components/Workbook/index.d.ts +1 -0
  31. package/dist/sheet-engine/react/hooks/useFormulaEditorHistory.d.ts +1 -1
  32. package/dist/style.css +1 -1
  33. package/dist/{zh-ForBOJJx.js → zh-DNw41bZD.js} +38 -5
  34. package/dist/{zh_tw-CjJceJE_.js → zh_tw-MZjDyZzy.js} +38 -5
  35. package/package.json +1 -1
@@ -1,37 +1,129 @@
1
1
  import { Context } from '../context';
2
- import { CellMatrix, SearchResult, GlobalCache } from '../types';
2
+ import { CellMatrix, Selection, SearchResult, GlobalCache } from '../types';
3
3
 
4
+ /** Where find/replace scans on the current sheet (workbook-wide only applies to find-all). */
5
+ export type FindSearchScope = 'allSheets' | 'thisSheet' | 'specificRange';
6
+ /**
7
+ * Return value of {@link searchNext}.
8
+ *
9
+ * @remarks
10
+ * **Semver:** Older releases returned `string | null` from `searchNext` (a localized message, or `null` on success).
11
+ * The object form is a **breaking change** for callers that still expect `string | null`; update them to read
12
+ * {@link SearchNextResult.alertMsg} (and optionally {@link SearchNextResult.matchIndex} /
13
+ * {@link SearchNextResult.matchTotal} for on-sheet scoped search UI).
14
+ */
15
+ export type SearchNextResult = {
16
+ /** Localized message for an alert dialog, or `null` when the next/previous hit was selected successfully. */
17
+ alertMsg: string | null;
18
+ /**
19
+ * 0-based index of the selected hit in the current sheet's ordered hit list when
20
+ * `scope` is `thisSheet` or `specificRange` and navigation succeeded; otherwise `0`.
21
+ */
22
+ matchIndex: number;
23
+ /**
24
+ * Size of that hit list for `thisSheet` / `specificRange`; `0` when not applicable (e.g. `allSheets`, errors,
25
+ * or empty search).
26
+ */
27
+ matchTotal: number;
28
+ };
29
+ /** Outcome of {@link replaceAll} for UI (inline status vs. error message). */
30
+ export type ReplaceAllResult = {
31
+ ok: false;
32
+ message: string;
33
+ } | {
34
+ ok: true;
35
+ replaced: number;
36
+ skipped: number;
37
+ };
38
+ /** Full used grid on the active sheet for find/replace on this sheet; `null` if the sheet has no cells. */
39
+ export declare function getFindRangeOnCurrentSheet(flowdata: CellMatrix): Selection[] | null;
40
+ export type HyperlinkMap = Record<string, {
41
+ linkType?: string;
42
+ linkAddress?: string;
43
+ }>;
44
+ export interface CheckModes {
45
+ regCheck?: boolean;
46
+ wordCheck?: boolean;
47
+ caseCheck?: boolean;
48
+ /** Also search inside formula strings (cell.f) */
49
+ formulaCheck?: boolean;
50
+ /** Also search sheet hyperlink address/type for the cell */
51
+ linkCheck?: boolean;
52
+ }
53
+ /** Skip cells in hidden rows/columns (manual hide + filter). */
54
+ export type SearchHiddenConfig = {
55
+ rowhidden?: Record<string, number> | null;
56
+ colhidden?: Record<string, number> | null;
57
+ };
4
58
  export declare function getSearchIndexArr(searchText: string, range: {
5
59
  row: number[];
6
60
  column: number[];
7
- }[], flowdata: CellMatrix, { regCheck, wordCheck, caseCheck }?: {
8
- regCheck: boolean;
9
- wordCheck: boolean;
10
- caseCheck: boolean;
11
- }): {
61
+ }[], flowdata: CellMatrix, { regCheck, wordCheck, caseCheck, formulaCheck, linkCheck, }?: CheckModes, hyperlinkMap?: HyperlinkMap, hiddenConfig?: SearchHiddenConfig): {
12
62
  r: number;
13
63
  c: number;
14
64
  }[];
15
- export declare function searchNext(ctx: Context, searchText: string, checkModes: {
16
- regCheck: boolean;
17
- wordCheck: boolean;
18
- caseCheck: boolean;
19
- }): any;
20
- export declare function searchAll(ctx: Context, searchText: string, checkModes: {
21
- regCheck: boolean;
22
- wordCheck: boolean;
23
- caseCheck: boolean;
24
- }): SearchResult[];
65
+ /** Use chunked async scan when the active sheet has at least this many rows. */
66
+ export declare const QUICK_SEARCH_ASYNC_ROW_THRESHOLD = 50000;
67
+ export declare function getQuickSearchHiddenConfig(ctx: Context): SearchHiddenConfig;
68
+ /** Display-only, case-insensitive substring find; skips hidden rows/columns. */
69
+ export declare function getQuickSearchIndexArr(ctx: Context, searchText: string, flowdata: CellMatrix): {
70
+ r: number;
71
+ c: number;
72
+ }[];
73
+ /** Bounding grid rect for overlay (merged region or single cell). */
74
+ export declare function expandCellRectForMerge(ctx: Context, r: number, c: number): {
75
+ r1: number;
76
+ r2: number;
77
+ c1: number;
78
+ c2: number;
79
+ };
80
+ export declare function shouldQuickSearchUseAsync(flowdata: CellMatrix): boolean;
81
+ /**
82
+ * Finds the next or previous match, updates selection and scroll, and optionally switches sheet when
83
+ * `scope` is `allSheets`.
84
+ *
85
+ * @param specificRange - When `scope` is `specificRange`, restricts the scan to this rectangle on the active sheet.
86
+ * @returns Structured result; see {@link SearchNextResult} and semver note on {@link SearchNextResult} remarks.
87
+ */
88
+ export declare function searchNext(ctx: Context, searchText: string, checkModes: CheckModes, scope?: FindSearchScope, direction?: 'next' | 'prev', specificRange?: Selection): SearchNextResult;
89
+ export declare function searchAll(ctx: Context, searchText: string, checkModes: CheckModes, scope?: FindSearchScope, specificRange?: Selection): SearchResult[];
25
90
  export declare function onSearchDialogMoveStart(globalCache: GlobalCache, e: MouseEvent, container: HTMLDivElement): void;
26
91
  export declare function onSearchDialogMove(globalCache: GlobalCache, e: MouseEvent): void;
27
92
  export declare function onSearchDialogMoveEnd(globalCache: GlobalCache): void;
28
- export declare function replace(ctx: Context, searchText: string, replaceText: string, checkModes: {
29
- regCheck: boolean;
30
- wordCheck: boolean;
31
- caseCheck: boolean;
32
- }): any;
33
- export declare function replaceAll(ctx: Context, searchText: string, replaceText: string, checkModes: {
34
- regCheck: boolean;
35
- wordCheck: boolean;
36
- caseCheck: boolean;
37
- }): any;
93
+ export declare function replace(ctx: Context, searchText: string, replaceText: string, checkModes: CheckModes, specificRange?: Selection): any;
94
+ export declare function replaceAll(ctx: Context, searchText: string, replaceText: string, checkModes: CheckModes, specificRange?: Selection): ReplaceAllResult;
95
+ /**
96
+ * Asynchronously scans `flowdata` for `searchText` in chunks, yielding
97
+ * between chunks so the main thread stays responsive.
98
+ *
99
+ * Returns an AbortController — call `.abort()` to cancel an in-flight scan.
100
+ *
101
+ * @param onProgress - called with partial results after each chunk
102
+ * @param onComplete - called once with the full result array when done
103
+ */
104
+ export declare function getSearchIndexArrAsync(searchText: string, range: {
105
+ row: number[];
106
+ column: number[];
107
+ }[], flowdata: CellMatrix, modes: CheckModes, hyperlinkMap?: HyperlinkMap, hiddenConfig?: SearchHiddenConfig, onProgress?: (partial: {
108
+ r: number;
109
+ c: number;
110
+ }[]) => void, onComplete?: (all: {
111
+ r: number;
112
+ c: number;
113
+ }[]) => void): AbortController;
114
+ /** Chunked quick search with hidden row/column skip (same semantics as `getQuickSearchIndexArr`). */
115
+ export declare function runQuickSearchIndexArrAsync(ctx: Context, searchText: string, flowdata: CellMatrix, onProgress: (partial: {
116
+ r: number;
117
+ c: number;
118
+ }[]) => void, onComplete: (all: {
119
+ r: number;
120
+ c: number;
121
+ }[]) => void): AbortController;
122
+ /**
123
+ * Parses an A1-notation range string (e.g. "E10:H14" or "Sheet1!E10:H14")
124
+ * into a `Selection` suitable for scoping find/replace.
125
+ *
126
+ * Returns `null` if the text is empty or cannot be parsed.
127
+ * The sheet-name prefix is stripped before parsing — the active sheet is always used.
128
+ */
129
+ export declare function parseRangeText(rangeText: string, ctx: Context): Selection | null;
@@ -17,7 +17,7 @@ export declare function seletedHighlistByindex(ctx: Context, r1: number, r2: num
17
17
  * else null). Pass `selection` explicitly when normalizing a **new** array that is not
18
18
  * yet assigned to `ctx.luckysheet_select_save`.
19
19
  */
20
- export declare function syncPrimaryCellActiveFromSelection(ctx: Context, selection?: SheetType["luckysheet_select_save"] | null): void;
20
+ export declare function syncPrimaryCellActiveFromSelection(ctx: Context, selection?: SheetType['luckysheet_select_save'] | null): void;
21
21
  /**
22
22
  * Multi-cell range only: move `row_focus` / `column_focus` (and primary) in
23
23
  * column-major order — forward: down then next column right, wrapping top-left;
@@ -32,24 +32,30 @@ export declare function advancePrimaryCellInLastMultiSelection(ctx: Context, for
32
32
  * selection that runs `normalizeSelection` will re-sync from the new range.
33
33
  */
34
34
  export declare function setPrimaryCellActive(ctx: Context, r: number, c: number): void;
35
- export declare function normalizeSelection(ctx: Context, selection: SheetType["luckysheet_select_save"]): import('..').Selection[] | undefined;
35
+ /**
36
+ * After formula segment / delete handling, move selection focus to the edited cell
37
+ * (r,c). If the sheet already has a multi-cell range and (r,c) is inside it, keep
38
+ * that range so Enter-primary navigation + typing do not collapse the yellow box.
39
+ */
40
+ export declare function snapSheetSelectionFocusToCellPreserveMultiRange(ctx: Context, r: number, c: number): void;
41
+ export declare function normalizeSelection(ctx: Context, selection: SheetType['luckysheet_select_save']): import('..').Selection[] | undefined;
36
42
  export declare function selectTitlesMap(rangeMap: Record<string, number>, range1: number, range2: number): Record<string, number>;
37
43
  export declare function selectTitlesRange(map: Record<string, number>): number[][];
38
- export declare function pasteHandlerOfPaintModel(ctx: Context, copyRange: Context["luckysheet_copy_save"]): void;
44
+ export declare function pasteHandlerOfPaintModel(ctx: Context, copyRange: Context['luckysheet_copy_save']): void;
39
45
  export declare function selectionCopyShow(range: any, ctx: Context): void;
40
46
  export declare function rowHasMerged(ctx: Context, r: number, c1: number, c2: number): boolean;
41
47
  export declare function colHasMerged(ctx: Context, c: number, r1: number, r2: number): boolean;
42
48
  export declare function getRowMerge(ctx: Context, rIndex: number, c1: number, c2: number): (number | null)[];
43
49
  export declare function getColMerge(ctx: Context, cIndex: number, r1: number, r2: number): (number | null)[];
44
- export declare function moveHighlightCell(ctx: Context, postion: "down" | "right", index: number, type: "rangeOfSelect" | "rangeOfFormula"): void;
45
- export declare function moveHighlightRange(ctx: Context, postion: "down" | "right", index: number, type: "rangeOfSelect" | "rangeOfFormula"): void;
50
+ export declare function moveHighlightCell(ctx: Context, postion: 'down' | 'right', index: number, type: 'rangeOfSelect' | 'rangeOfFormula'): void;
51
+ export declare function moveHighlightRange(ctx: Context, postion: 'down' | 'right', index: number, type: 'rangeOfSelect' | 'rangeOfFormula'): void;
46
52
  export declare function rangeValueToHtml(ctx: Context, sheetId: string, ranges?: Range): string | null;
47
53
  export declare function copy(ctx: Context): void;
48
54
  export declare function deleteSelectedCellText(ctx: Context): string;
49
55
  export declare function deleteSelectedCellFormat(ctx: Context): string;
50
56
  export declare function fillRightData(ctx: Context): string;
51
57
  export declare function fillDownData(ctx: Context): string;
52
- export declare function textFormat(ctx: Context, type: "left" | "center" | "right"): string;
58
+ export declare function textFormat(ctx: Context, type: 'left' | 'center' | 'right'): string;
53
59
  export declare function fillDate(ctx: Context): string;
54
60
  export declare function fillTime(ctx: Context): string;
55
61
  export declare function selectIsOverlap(ctx: Context, range?: any): boolean;
@@ -16,6 +16,17 @@ export declare function valueIsError(value: string): boolean;
16
16
  export declare function isRealNull(val: any): boolean;
17
17
  export declare function isHexValue(str: string): boolean;
18
18
  export declare function isRealNum(val: any): boolean;
19
+ /**
20
+ * Explicit number format (`t === 'n'`) or General/Automatic with a numeric stored value (`t === 'g'`).
21
+ * Use wherever logic previously required `ct.t === 'n'` so Automatic numeric cells behave the same.
22
+ */
23
+ export declare function isNumericCellType(cell: {
24
+ ct?: {
25
+ t?: string;
26
+ fa?: string;
27
+ };
28
+ v?: unknown;
29
+ } | null | undefined): boolean;
19
30
  export type DateFormatInfo = {
20
31
  year: number;
21
32
  month: number;
@@ -2,7 +2,7 @@ import { Patch as ImmerPatch } from 'immer';
2
2
  import { PatchOptions } from './utils';
3
3
 
4
4
  export type Op = {
5
- op: "replace" | "remove" | "add" | "insertRowCol" | "deleteRowCol" | "addSheet" | "deleteSheet";
5
+ op: 'replace' | 'remove' | 'add' | 'insertRowCol' | 'deleteRowCol' | 'addSheet' | 'deleteSheet';
6
6
  id?: string;
7
7
  path: (string | number)[];
8
8
  value?: any;
@@ -227,7 +227,7 @@ export type Sheet = {
227
227
  dynamicArray_compute?: any;
228
228
  dynamicArray?: any[];
229
229
  frozen?: {
230
- type: "row" | "column" | "both" | "rangeRow" | "rangeColumn" | "rangeBoth";
230
+ type: 'row' | 'column' | 'both' | 'rangeRow' | 'rangeColumn' | 'rangeBoth';
231
231
  range?: {
232
232
  row_focus: number;
233
233
  column_focus: number;
@@ -388,6 +388,8 @@ export type GlobalCache = {
388
388
  } | undefined;
389
389
  };
390
390
  };
391
+ /** Element to restore focus to after closing Quick Search (not stored in Immer context). */
392
+ quickSearchReturnFocus?: Element | null;
391
393
  linkCard?: {
392
394
  mouseEnter?: boolean;
393
395
  rangeSelectionModal?: {
@@ -15,6 +15,8 @@ export type PatchOptions = {
15
15
  count: number;
16
16
  direction: 'lefttop' | 'rightbottom';
17
17
  id: string;
18
+ templateSourceRows?: number[];
19
+ templateSourceColumns?: number[];
18
20
  };
19
21
  deleteRowColOp?: {
20
22
  type: 'row' | 'column';
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+
3
+ declare const QuickSearchBar: React.FC;
4
+ export default QuickSearchBar;
@@ -0,0 +1,3 @@
1
+ import { default as React } from 'react';
2
+
3
+ export declare const ResetRowHeight: React.FC;
@@ -6,6 +6,8 @@ import { useDialog } from '../../hooks/useDialog';
6
6
  export declare function generateAPIs(context: Context, setContext: (recipe: (ctx: Context) => void, options?: SetContextOptions) => void, handleUndo: () => void, handleRedo: () => void, settings: Required<Settings>, cellInput: HTMLDivElement | null, scrollbarX: HTMLDivElement | null, scrollbarY: HTMLDivElement | null, globalCache: GlobalCache | null, refs: any): {
7
7
  applyOp: (ops: Op[]) => void;
8
8
  getCryptoPrice: typeof getCryptoPrice;
9
+ /** Runs the formula engine on every cell in calcChain (all sheets). Use after XLSX import so values are computed, not cached from the file. */
10
+ recalculateAllFormulas: () => void;
9
11
  getCellValue: (row: number, column: number, options?: api.CommonOptions & {
10
12
  type?: keyof Cell;
11
13
  }) => any;
@@ -12,6 +12,7 @@ type AdditionalProps = {
12
12
  declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalProps & React.RefAttributes<{
13
13
  applyOp: (ops: Op[]) => void;
14
14
  getCryptoPrice: typeof getCryptoPrice;
15
+ recalculateAllFormulas: () => void;
15
16
  getCellValue: (row: number, column: number, options?: api.CommonOptions & {
16
17
  type?: keyof import('../../../core').Cell;
17
18
  }) => any;
@@ -7,7 +7,7 @@ export type FormulaHistoryEntry = {
7
7
  caret: number;
8
8
  };
9
9
  /** Which editor receives caret placement and drives history snapshots. */
10
- export type FormulaEditorHistoryPrimary = "cell" | "fx";
10
+ export type FormulaEditorHistoryPrimary = 'cell' | 'fx';
11
11
  type SetContext = (recipe: (ctx: Context) => void, options?: SetContextOptions) => void;
12
12
  /**
13
13
  * Custom undo/redo for the cell overlay and Fx bar — **one code path** for