@dou-ui/sheet 0.0.0-stage → 0.1.0-alpha.1

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 (262) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +10 -2
  3. package/dist/cell-types.js +20 -0
  4. package/dist/cell-types.js.map +1 -0
  5. package/dist/code/code-formula-bar.js +6 -0
  6. package/dist/code/code-formula-bar.js.map +1 -0
  7. package/dist/code/code-formula-bar.vue_vue_type_script_setup_true_lang.js +192 -0
  8. package/dist/code/code-formula-bar.vue_vue_type_script_setup_true_lang.js.map +1 -0
  9. package/dist/code/index.js +12 -0
  10. package/dist/code/index.js.map +1 -0
  11. package/dist/code/language.js +51 -0
  12. package/dist/code/language.js.map +1 -0
  13. package/dist/code/style.d.ts +1 -0
  14. package/dist/code/style.js +2 -0
  15. package/dist/collaboration/anchor.js +143 -0
  16. package/dist/collaboration/anchor.js.map +1 -0
  17. package/dist/collaboration/index.js +770 -0
  18. package/dist/collaboration/index.js.map +1 -0
  19. package/dist/collaboration/peers.js +87 -0
  20. package/dist/collaboration/peers.js.map +1 -0
  21. package/dist/collaboration/shared.js +450 -0
  22. package/dist/collaboration/shared.js.map +1 -0
  23. package/dist/components/cell-panel.js +6 -0
  24. package/dist/components/cell-panel.js.map +1 -0
  25. package/dist/components/cell-panel.vue_vue_type_script_setup_true_lang.js +70 -0
  26. package/dist/components/cell-panel.vue_vue_type_script_setup_true_lang.js.map +1 -0
  27. package/dist/components/cell-renders.js +40 -0
  28. package/dist/components/cell-renders.js.map +1 -0
  29. package/dist/components/date-panel.js +6 -0
  30. package/dist/components/date-panel.js.map +1 -0
  31. package/dist/components/date-panel.vue_vue_type_script_setup_true_lang.js +48 -0
  32. package/dist/components/date-panel.vue_vue_type_script_setup_true_lang.js.map +1 -0
  33. package/dist/components/filter-panel.js +6 -0
  34. package/dist/components/filter-panel.js.map +1 -0
  35. package/dist/components/filter-panel.vue_vue_type_script_setup_true_lang.js +259 -0
  36. package/dist/components/filter-panel.vue_vue_type_script_setup_true_lang.js.map +1 -0
  37. package/dist/components/format-dialog.js +6 -0
  38. package/dist/components/format-dialog.js.map +1 -0
  39. package/dist/components/format-dialog.vue_vue_type_script_setup_true_lang.js +432 -0
  40. package/dist/components/format-dialog.vue_vue_type_script_setup_true_lang.js.map +1 -0
  41. package/dist/components/format-list.js +6 -0
  42. package/dist/components/format-list.js.map +1 -0
  43. package/dist/components/format-list.vue_vue_type_script_setup_true_lang.js +187 -0
  44. package/dist/components/format-list.vue_vue_type_script_setup_true_lang.js.map +1 -0
  45. package/dist/components/format-presets.js +97 -0
  46. package/dist/components/format-presets.js.map +1 -0
  47. package/dist/components/option-panel.js +6 -0
  48. package/dist/components/option-panel.js.map +1 -0
  49. package/dist/components/option-panel.vue_vue_type_script_setup_true_lang.js +117 -0
  50. package/dist/components/option-panel.vue_vue_type_script_setup_true_lang.js.map +1 -0
  51. package/dist/components/sheet-comment.js +6 -0
  52. package/dist/components/sheet-comment.js.map +1 -0
  53. package/dist/components/sheet-comment.vue_vue_type_script_setup_true_lang.js +104 -0
  54. package/dist/components/sheet-comment.vue_vue_type_script_setup_true_lang.js.map +1 -0
  55. package/dist/components/sheet-formula-bar.js +6 -0
  56. package/dist/components/sheet-formula-bar.js.map +1 -0
  57. package/dist/components/sheet-formula-bar.vue_vue_type_script_setup_true_lang.js +124 -0
  58. package/dist/components/sheet-formula-bar.vue_vue_type_script_setup_true_lang.js.map +1 -0
  59. package/dist/components/sheet-link.js +6 -0
  60. package/dist/components/sheet-link.js.map +1 -0
  61. package/dist/components/sheet-link.vue_vue_type_script_setup_true_lang.js +249 -0
  62. package/dist/components/sheet-link.vue_vue_type_script_setup_true_lang.js.map +1 -0
  63. package/dist/components/sheet-menu.js +6 -0
  64. package/dist/components/sheet-menu.js.map +1 -0
  65. package/dist/components/sheet-menu.vue_vue_type_script_setup_true_lang.js +115 -0
  66. package/dist/components/sheet-menu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  67. package/dist/components/sheet-name-box.js +6 -0
  68. package/dist/components/sheet-name-box.js.map +1 -0
  69. package/dist/components/sheet-name-box.vue_vue_type_script_setup_true_lang.js +91 -0
  70. package/dist/components/sheet-name-box.vue_vue_type_script_setup_true_lang.js.map +1 -0
  71. package/dist/components/sheet-note.js +6 -0
  72. package/dist/components/sheet-note.js.map +1 -0
  73. package/dist/components/sheet-note.vue_vue_type_script_setup_true_lang.js +146 -0
  74. package/dist/components/sheet-note.vue_vue_type_script_setup_true_lang.js.map +1 -0
  75. package/dist/components/sheet-outline.js +6 -0
  76. package/dist/components/sheet-outline.js.map +1 -0
  77. package/dist/components/sheet-outline.vue_vue_type_script_setup_true_lang.js +237 -0
  78. package/dist/components/sheet-outline.vue_vue_type_script_setup_true_lang.js.map +1 -0
  79. package/dist/components/sheet-tabs.js +6 -0
  80. package/dist/components/sheet-tabs.js.map +1 -0
  81. package/dist/components/sheet-tabs.vue_vue_type_script_setup_true_lang.js +487 -0
  82. package/dist/components/sheet-tabs.vue_vue_type_script_setup_true_lang.js.map +1 -0
  83. package/dist/components/sheet-toolbar.js +6 -0
  84. package/dist/components/sheet-toolbar.js.map +1 -0
  85. package/dist/components/sheet-toolbar.vue_vue_type_script_setup_true_lang.js +1562 -0
  86. package/dist/components/sheet-toolbar.vue_vue_type_script_setup_true_lang.js.map +1 -0
  87. package/dist/components/validation-dialog.js +6 -0
  88. package/dist/components/validation-dialog.js.map +1 -0
  89. package/dist/components/validation-dialog.vue_vue_type_script_setup_true_lang.js +370 -0
  90. package/dist/components/validation-dialog.vue_vue_type_script_setup_true_lang.js.map +1 -0
  91. package/dist/context.js +12 -0
  92. package/dist/context.js.map +1 -0
  93. package/dist/core/address.js +256 -0
  94. package/dist/core/address.js.map +1 -0
  95. package/dist/core/axis.js +72 -0
  96. package/dist/core/axis.js.map +1 -0
  97. package/dist/core/cell-type.js +30 -0
  98. package/dist/core/cell-type.js.map +1 -0
  99. package/dist/core/clipboard.js +141 -0
  100. package/dist/core/clipboard.js.map +1 -0
  101. package/dist/core/commands.js +63 -0
  102. package/dist/core/commands.js.map +1 -0
  103. package/dist/core/comments.js +74 -0
  104. package/dist/core/comments.js.map +1 -0
  105. package/dist/core/conditional.js +362 -0
  106. package/dist/core/conditional.js.map +1 -0
  107. package/dist/core/csv.js +191 -0
  108. package/dist/core/csv.js.map +1 -0
  109. package/dist/core/data.js +118 -0
  110. package/dist/core/data.js.map +1 -0
  111. package/dist/core/document.js +187 -0
  112. package/dist/core/document.js.map +1 -0
  113. package/dist/core/extension.js +60 -0
  114. package/dist/core/extension.js.map +1 -0
  115. package/dist/core/file.js +336 -0
  116. package/dist/core/file.js.map +1 -0
  117. package/dist/core/fill.js +153 -0
  118. package/dist/core/fill.js.map +1 -0
  119. package/dist/core/find.js +42 -0
  120. package/dist/core/find.js.map +1 -0
  121. package/dist/core/format.js +404 -0
  122. package/dist/core/format.js.map +1 -0
  123. package/dist/core/group.js +134 -0
  124. package/dist/core/group.js.map +1 -0
  125. package/dist/core/history.js +68 -0
  126. package/dist/core/history.js.map +1 -0
  127. package/dist/core/index.js +17 -0
  128. package/dist/core/link.js +34 -0
  129. package/dist/core/link.js.map +1 -0
  130. package/dist/core/merge.js +105 -0
  131. package/dist/core/merge.js.map +1 -0
  132. package/dist/core/model.js +48 -0
  133. package/dist/core/model.js.map +1 -0
  134. package/dist/core/nav.js +44 -0
  135. package/dist/core/nav.js.map +1 -0
  136. package/dist/core/paint.js +106 -0
  137. package/dist/core/paint.js.map +1 -0
  138. package/dist/core/plain-cell-types.js +54 -0
  139. package/dist/core/plain-cell-types.js.map +1 -0
  140. package/dist/core/protect.js +246 -0
  141. package/dist/core/protect.js.map +1 -0
  142. package/dist/core/selection.js +37 -0
  143. package/dist/core/selection.js.map +1 -0
  144. package/dist/core/transaction.js +1582 -0
  145. package/dist/core/transaction.js.map +1 -0
  146. package/dist/core/validation.js +135 -0
  147. package/dist/core/validation.js.map +1 -0
  148. package/dist/core/versions.js +161 -0
  149. package/dist/core/versions.js.map +1 -0
  150. package/dist/export/color.js +36 -0
  151. package/dist/export/color.js.map +1 -0
  152. package/dist/export/draw.js +316 -0
  153. package/dist/export/draw.js.map +1 -0
  154. package/dist/export/index.js +390 -0
  155. package/dist/export/index.js.map +1 -0
  156. package/dist/formula/edit.js +210 -0
  157. package/dist/formula/edit.js.map +1 -0
  158. package/dist/formula/engine.js +526 -0
  159. package/dist/formula/engine.js.map +1 -0
  160. package/dist/formula/error.js +39 -0
  161. package/dist/formula/error.js.map +1 -0
  162. package/dist/formula/functions.js +1493 -0
  163. package/dist/formula/functions.js.map +1 -0
  164. package/dist/formula/help.js +408 -0
  165. package/dist/formula/help.js.map +1 -0
  166. package/dist/formula/index.js +7 -0
  167. package/dist/formula/parse.js +369 -0
  168. package/dist/formula/parse.js.map +1 -0
  169. package/dist/formula/values.js +123 -0
  170. package/dist/formula/values.js.map +1 -0
  171. package/dist/formulas.js +30 -0
  172. package/dist/formulas.js.map +1 -0
  173. package/dist/index.js +39 -0
  174. package/dist/index.js.map +1 -0
  175. package/dist/locale.js +1312 -0
  176. package/dist/locale.js.map +1 -0
  177. package/dist/sheet.js +6 -0
  178. package/dist/sheet.js.map +1 -0
  179. package/dist/sheet.vue_vue_type_script_setup_true_lang.js +7166 -0
  180. package/dist/sheet.vue_vue_type_script_setup_true_lang.js.map +1 -0
  181. package/dist/style.css +1 -0
  182. package/dist/style.d.ts +1 -0
  183. package/dist/style.js +17 -0
  184. package/dist/types/cell-types.d.ts +2 -0
  185. package/dist/types/code/code-formula-bar.vue.d.ts +3 -0
  186. package/dist/types/code/index.d.ts +12 -0
  187. package/dist/types/code/language.d.ts +13 -0
  188. package/dist/types/collaboration/anchor.d.ts +65 -0
  189. package/dist/types/collaboration/index.d.ts +59 -0
  190. package/dist/types/collaboration/peers.d.ts +21 -0
  191. package/dist/types/collaboration/shared.d.ts +75 -0
  192. package/dist/types/components/cell-panel.vue.d.ts +20 -0
  193. package/dist/types/components/cell-renders.d.ts +9 -0
  194. package/dist/types/components/date-panel.vue.d.ts +9 -0
  195. package/dist/types/components/filter-panel.vue.d.ts +21 -0
  196. package/dist/types/components/format-dialog.vue.d.ts +24 -0
  197. package/dist/types/components/format-list.vue.d.ts +25 -0
  198. package/dist/types/components/format-presets.d.ts +30 -0
  199. package/dist/types/components/option-panel.vue.d.ts +13 -0
  200. package/dist/types/components/sheet-comment.vue.d.ts +29 -0
  201. package/dist/types/components/sheet-formula-bar.vue.d.ts +3 -0
  202. package/dist/types/components/sheet-link.vue.d.ts +32 -0
  203. package/dist/types/components/sheet-menu.vue.d.ts +20 -0
  204. package/dist/types/components/sheet-name-box.vue.d.ts +3 -0
  205. package/dist/types/components/sheet-note.vue.d.ts +22 -0
  206. package/dist/types/components/sheet-outline.vue.d.ts +36 -0
  207. package/dist/types/components/sheet-tabs.vue.d.ts +9 -0
  208. package/dist/types/components/sheet-toolbar.vue.d.ts +11 -0
  209. package/dist/types/components/validation-dialog.vue.d.ts +25 -0
  210. package/dist/types/context.d.ts +189 -0
  211. package/dist/types/core/address.d.ts +109 -0
  212. package/dist/types/core/axis.d.ts +23 -0
  213. package/dist/types/core/cell-type.d.ts +157 -0
  214. package/dist/types/core/clipboard.d.ts +48 -0
  215. package/dist/types/core/commands.d.ts +76 -0
  216. package/dist/types/core/comments.d.ts +22 -0
  217. package/dist/types/core/conditional.d.ts +114 -0
  218. package/dist/types/core/csv.d.ts +93 -0
  219. package/dist/types/core/data.d.ts +26 -0
  220. package/dist/types/core/document.d.ts +49 -0
  221. package/dist/types/core/extension.d.ts +177 -0
  222. package/dist/types/core/file.d.ts +301 -0
  223. package/dist/types/core/fill.d.ts +23 -0
  224. package/dist/types/core/find.d.ts +39 -0
  225. package/dist/types/core/format.d.ts +47 -0
  226. package/dist/types/core/group.d.ts +76 -0
  227. package/dist/types/core/history.d.ts +27 -0
  228. package/dist/types/core/index.d.ts +33 -0
  229. package/dist/types/core/link.d.ts +14 -0
  230. package/dist/types/core/merge.d.ts +26 -0
  231. package/dist/types/core/model.d.ts +363 -0
  232. package/dist/types/core/nav.d.ts +15 -0
  233. package/dist/types/core/paint.d.ts +19 -0
  234. package/dist/types/core/plain-cell-types.d.ts +6 -0
  235. package/dist/types/core/protect.d.ts +34 -0
  236. package/dist/types/core/selection.d.ts +25 -0
  237. package/dist/types/core/transaction.d.ts +470 -0
  238. package/dist/types/core/validation.d.ts +55 -0
  239. package/dist/types/core/versions.d.ts +38 -0
  240. package/dist/types/export/color.d.ts +7 -0
  241. package/dist/types/export/draw.d.ts +98 -0
  242. package/dist/types/export/index.d.ts +47 -0
  243. package/dist/types/formula/edit.d.ts +62 -0
  244. package/dist/types/formula/engine.d.ts +99 -0
  245. package/dist/types/formula/error.d.ts +30 -0
  246. package/dist/types/formula/functions.d.ts +62 -0
  247. package/dist/types/formula/help.d.ts +12 -0
  248. package/dist/types/formula/index.d.ts +13 -0
  249. package/dist/types/formula/parse.d.ts +92 -0
  250. package/dist/types/formula/values.d.ts +65 -0
  251. package/dist/types/formulas.d.ts +32 -0
  252. package/dist/types/index.d.ts +225 -0
  253. package/dist/types/locale.d.ts +531 -0
  254. package/dist/types/sheet.vue.d.ts +60 -0
  255. package/dist/types/types.d.ts +498 -0
  256. package/dist/types/use-comments.d.ts +47 -0
  257. package/dist/types/use-messages.d.ts +7 -0
  258. package/dist/use-comments.js +130 -0
  259. package/dist/use-comments.js.map +1 -0
  260. package/dist/use-messages.js +29 -0
  261. package/dist/use-messages.js.map +1 -0
  262. package/package.json +93 -4
@@ -0,0 +1,301 @@
1
+ import type { Component } from 'vue';
2
+ import type { SheetFunction } from '../formula/functions';
3
+ import { type SheetResult } from '../formula/values';
4
+ import { type SheetMessages } from '../locale';
5
+ import { type SheetBounds } from './address';
6
+ import { type SheetCellType, type SheetResolvedType } from './cell-type';
7
+ import type { SheetExtension } from './extension';
8
+ import { type SheetData, type SheetStyle, type SheetValue, type SheetWorkbook } from './model';
9
+ import { type SheetRef } from './transaction';
10
+ import { type SheetLabel } from './commands';
11
+ import type { SheetDrawing } from '../export/draw';
12
+ /** What is exported: every sheet, the sheet shown, or the selected cells. */
13
+ export type SheetExportScope = 'workbook' | 'sheet' | 'selection';
14
+ /** A sheet to export, with the cells to write. */
15
+ export interface SheetFileSheet {
16
+ /** Its place in the workbook. */
17
+ index: number;
18
+ data: SheetData;
19
+ /** The cells to write: the selection, or from `A1` to the last cell with data; `null` when it is empty. */
20
+ bounds: SheetBounds | null;
21
+ }
22
+ /** What an exporter reads: the workbook and how its cells show, without the grid. */
23
+ export interface SheetFileSource {
24
+ /** The workbook as it is stored. */
25
+ book: SheetWorkbook;
26
+ /** What is being exported. */
27
+ scope: SheetExportScope;
28
+ /** The sheets to write, in order: one, unless `scope` is `'workbook'`. */
29
+ sheets: SheetFileSheet[];
30
+ /** The language dates and numbers are written in. */
31
+ locale?: string;
32
+ messages: SheetMessages;
33
+ /** The grid's default column width and row height in px, for columns and rows without their own. */
34
+ colWidth: number;
35
+ rowHeight: number;
36
+ /** A cell's value as stored: for a formula, the formula. */
37
+ value: (sheet: number, row: number, col: number) => SheetValue;
38
+ /** What a cell comes to: its formula's result (an error as a `SheetError`), or its value. */
39
+ result: (sheet: number, row: number, col: number) => SheetResult;
40
+ /** The text a cell shows, with its format and cell type, as the grid draws it. */
41
+ text: (sheet: number, row: number, col: number) => string;
42
+ /**
43
+ * The value to write into another spreadsheet program: the cell type's
44
+ * `plain`, or what the cell comes to (an error as its code, such as `#DIV/0!`).
45
+ */
46
+ plain: (sheet: number, row: number, col: number) => SheetValue;
47
+ /**
48
+ * How the cell looks: its named style with what its conditional formats
49
+ * give it over it, `tone` and `fill` as the colors they are in the light
50
+ * theme (in `color` and `background`). `{}` for a plain cell.
51
+ */
52
+ style: (sheet: number, row: number, col: number) => SheetStyle;
53
+ /** The cell's number or date format. */
54
+ format: (sheet: number, row: number, col: number) => string | undefined;
55
+ /** The cell's type and its settings, or `undefined` for a plain cell. */
56
+ cellType: (sheet: number, row: number, col: number) => SheetResolvedType | undefined;
57
+ /** Aborted when the export is called off. */
58
+ signal?: AbortSignal;
59
+ /** Only for exporters with `needs: 'view'`, in the grid: the cells as the grid draws them. */
60
+ view?: SheetFileView;
61
+ }
62
+ /** What an exporter with `needs: 'view'` gets of the grid. */
63
+ export interface SheetFileView {
64
+ /**
65
+ * The cells exported laid out as the grid draws them: column widths, row
66
+ * heights, text and looks in plain colors of the page's theme.
67
+ */
68
+ drawing: (options?: {
69
+ headers?: boolean;
70
+ gridlines?: boolean;
71
+ background?: boolean;
72
+ }) => SheetDrawing;
73
+ }
74
+ /** A way to write the workbook as a file, such as CSV; see `defineSheetExporter`. */
75
+ export interface SheetExporter<Options = any> {
76
+ /** Unique among the exporters; `exportFile` takes it. */
77
+ name: string;
78
+ /** Its name in the toolbar's export menu. */
79
+ label: SheetLabel;
80
+ /**
81
+ * Its icon in the toolbar's export menu; by default a file icon for its
82
+ * `extension`, so an exporter needn't load icons (and Vue), as in a Worker.
83
+ */
84
+ icon?: Component;
85
+ /** The file name's extension, without the dot, e.g. `xlsx`. */
86
+ extension: string;
87
+ /** The file's media type. */
88
+ mime: string;
89
+ /** What it can export, the first being what the toolbar exports. Defaults to every scope. */
90
+ scopes?: SheetExportScope[];
91
+ /**
92
+ * `'view'` for an exporter that draws the cells as the grid shows them
93
+ * (sizes, the page's colors), which gets `source.view` and only works in
94
+ * the grid; `exportWorkbook` refuses it. Defaults to `'data'`.
95
+ */
96
+ needs?: 'data' | 'view';
97
+ /** Writes the file. A string is wrapped in a `Blob` of `mime`. */
98
+ export: (source: SheetFileSource, options?: Options) => Blob | string | Promise<Blob | string>;
99
+ }
100
+ /**
101
+ * The options an exporter or importer takes; for either of two, either's,
102
+ * so one picked at run time, e.g. by a message, can be passed as it is.
103
+ */
104
+ type OptionsOf<Handler> = Handler extends SheetExporter<infer Options> | SheetImporter<infer Options, any> ? Options : never;
105
+ /** What an importer gives back, as it declares it. */
106
+ type ResultOf<Importer> = Importer extends SheetImporter<any, infer Result> ? Result : SheetImportResult;
107
+ /** Declares an exporter; only gives it a type. */
108
+ export declare function defineSheetExporter<Options = any>(exporter: SheetExporter<Options>): SheetExporter<Options>;
109
+ /** An exporter as menus show it, its label in the sheet's language. */
110
+ export interface SheetExporterInfo {
111
+ name: string;
112
+ label: string;
113
+ icon?: Component;
114
+ extension: string;
115
+ mime: string;
116
+ /** What it can export, the first being what it exports by default. */
117
+ scopes: SheetExportScope[];
118
+ }
119
+ /** An importer as menus show it, its label in the sheet's language. */
120
+ export interface SheetImporterInfo {
121
+ name: string;
122
+ label: string;
123
+ accept: string[];
124
+ }
125
+ export declare const exporterInfo: (exporter: SheetExporter, messages: SheetMessages) => SheetExporterInfo;
126
+ export declare const importerInfo: (importer: SheetImporter, messages: SheetMessages) => SheetImporterInfo;
127
+ /** Something an importer couldn't bring over, such as images or borders. */
128
+ export interface SheetImportWarning {
129
+ /** A short name for what was lost, e.g. `'border'`. */
130
+ code: string;
131
+ /** It in words, for people. */
132
+ message: string;
133
+ /** How many times it came up. */
134
+ count?: number;
135
+ /** The sheet it was on. */
136
+ sheet?: string;
137
+ }
138
+ /** What an importer read. */
139
+ export interface SheetImportResult {
140
+ book: SheetWorkbook;
141
+ warnings?: SheetImportWarning[];
142
+ }
143
+ /** What an importer gets besides the file. */
144
+ export interface SheetImportContext {
145
+ messages: SheetMessages;
146
+ locale?: string;
147
+ signal?: AbortSignal;
148
+ }
149
+ /** A way to read a file into a workbook, such as CSV; see `defineSheetImporter`. */
150
+ export interface SheetImporter<Options = any, Result extends SheetImportResult = SheetImportResult> {
151
+ /** Unique among the importers; `importFile`'s `importer` takes it. */
152
+ name: string;
153
+ /**
154
+ * What the files it reads are called, such as “CSV 文件”: in the hints the
155
+ * grid shows about a file without a name, and in `useSheet().importers`
156
+ * for a menu of your own.
157
+ */
158
+ label: SheetLabel;
159
+ /**
160
+ * The files it reads, as the file picker's `accept` takes them: extensions
161
+ * such as `.csv` and media types such as `text/csv`.
162
+ */
163
+ accept: string[];
164
+ /** Tells from the file's first bytes whether it reads it, for files whose name says nothing. */
165
+ sniff?: (head: Uint8Array) => boolean;
166
+ import: (file: Blob, context: SheetImportContext, options?: Options) => Result | Promise<Result>;
167
+ }
168
+ /**
169
+ * Declares an importer; only gives it a type. `defineSheetImporter<Options, Result>`
170
+ * also says what it gives back, such as warnings it always has.
171
+ */
172
+ export declare function defineSheetImporter<Options = any>(importer: SheetImporter<Options>): SheetImporter<Options>;
173
+ export declare function defineSheetImporter<Options, Result extends SheetImportResult>(importer: SheetImporter<Options, Result>): SheetImporter<Options, Result>;
174
+ /**
175
+ * An import or export that can't be done, for a reason people can be told:
176
+ * the grid shows `reason` in its hint, while `message` is for developers.
177
+ * `code` tells the cases apart, such as `'locked'`.
178
+ */
179
+ export declare class SheetFileError<Code extends string = string> extends Error {
180
+ readonly code: Code;
181
+ readonly reason: string;
182
+ name: string;
183
+ constructor(message: string, code: Code, reason: string, options?: ErrorOptions);
184
+ }
185
+ /** What to tell people of a failed import or export: an error's `reason` when it gives one. */
186
+ export declare function reasonOf(error: unknown): string;
187
+ /** Whether an importer takes a file, by its name, type or first bytes. */
188
+ export declare function importerTakes(importer: SheetImporter, file: Blob): Promise<boolean>;
189
+ /** The first importer that takes a file, or `undefined`. */
190
+ export declare function findImporter(importers: readonly SheetImporter[], file: Blob): Promise<SheetImporter<any, SheetImportResult> | undefined>;
191
+ /** How a source reads a workbook. */
192
+ export interface SheetFileSourceOptions {
193
+ scope?: SheetExportScope;
194
+ /** The sheet for `'sheet'` and `'selection'`; the first by default. */
195
+ sheet?: number;
196
+ /** For `'selection'` (or to write part of a sheet): the cells. */
197
+ bounds?: SheetBounds;
198
+ /** What formulas come to, by sheet key; a new engine works them out by default. */
199
+ result?: (key: string, row: number, col: number) => SheetResult;
200
+ cellTypes?: ReadonlyMap<string, SheetCellType>;
201
+ functions?: readonly SheetFunction[];
202
+ locale?: string;
203
+ messages?: SheetMessages;
204
+ /** The grid's default column width in px; `96` by default. */
205
+ colWidth?: number;
206
+ /** The grid's default row height in px; `28` by default. */
207
+ rowHeight?: number;
208
+ /** Works out a formula as if it were in a cell of a sheet, by key, for conditional formats; with `result`. */
209
+ evaluate?: (formula: string, key: string) => unknown;
210
+ signal?: AbortSignal;
211
+ view?: SheetFileView;
212
+ }
213
+ /** The cell types by name: the built-in ones, then these, the first named winning. */
214
+ export declare function cellTypeMap(added?: readonly SheetCellType[]): Map<string, SheetCellType>;
215
+ /** What exporters read: a workbook and how its cells show. */
216
+ export declare function createFileSource(book: SheetWorkbook, options?: SheetFileSourceOptions): SheetFileSource;
217
+ /** Options of `exportWorkbook`. */
218
+ export interface SheetExportWorkbookOptions<Options = any> {
219
+ /** The extensions whose cell types and functions the workbook uses. */
220
+ extensions?: (SheetExtension | SheetExtension[])[];
221
+ /** `'workbook'` by default, or the exporter's first scope when it can't. */
222
+ scope?: SheetExportScope;
223
+ /** The sheet, by index, `id` or name, for `'sheet'` and `'selection'`; the first by default. */
224
+ sheet?: SheetRef;
225
+ /** The cells, such as `'A1:D20'`, for `'selection'`. */
226
+ range?: string;
227
+ locale?: string;
228
+ messages?: SheetMessages;
229
+ /** The default column width and row height in px the workbook is laid out with, as `DouSheet`'s `col-width` and `row-height`. */
230
+ colWidth?: number;
231
+ rowHeight?: number;
232
+ signal?: AbortSignal;
233
+ /** Passed on to the exporter. */
234
+ options?: Options;
235
+ }
236
+ /** The scope an exporter writes: the one asked for when it can, otherwise its first. */
237
+ export declare function scopeFor(exporter: SheetExporter, asked?: SheetExportScope): SheetExportScope;
238
+ /** An exporter's output as a `Blob`. */
239
+ export declare const toBlob: (out: Blob | string, mime: string) => Blob;
240
+ /**
241
+ * Writes a workbook with an exporter, without a grid: in a script, a
242
+ * worker or on a server. Formulas are worked out on the way.
243
+ */
244
+ export declare function exportWorkbook<Exporter extends SheetExporter>(book: SheetWorkbook, exporter: Exporter, options?: SheetExportWorkbookOptions<OptionsOf<Exporter>>): Promise<Blob>;
245
+ /** Options of `readWorkbook`. */
246
+ export interface SheetReadWorkbookOptions<Options = any> {
247
+ locale?: string;
248
+ messages?: SheetMessages;
249
+ signal?: AbortSignal;
250
+ /** Passed on to the importer. */
251
+ options?: Options;
252
+ }
253
+ /** Reads a file with an importer, without a grid. */
254
+ export declare function readWorkbook<Importer extends SheetImporter>(file: Blob, importer: Importer, options?: SheetReadWorkbookOptions<OptionsOf<Importer>>): Promise<ResultOf<Importer>>;
255
+ /** The name of a file without its extension, for a sheet's name. */
256
+ export declare const baseName: (file: Blob) => string;
257
+ /** Options of the CSV exporter. */
258
+ export interface SheetCSVExportOptions {
259
+ /** `,` by default. */
260
+ delimiter?: string;
261
+ /** Starts with a byte order mark, so programs that guess the encoding read it as UTF-8. On by default. */
262
+ bom?: boolean;
263
+ /**
264
+ * Writes what the cells show (`¥1,280.00`, `2026年3月5日`) instead of
265
+ * values a spreadsheet can sort and add up (`1280`, `2026-03-05`, what
266
+ * formulas come to). Off by default.
267
+ */
268
+ text?: boolean;
269
+ /** Writes formulas as written instead of what they come to. Ignored with `text`. */
270
+ formulas?: boolean;
271
+ /** Line breaks between rows; `\r\n` by default. */
272
+ newline?: string;
273
+ /** Puts a `'` before text a spreadsheet program would run as a formula. On by default. */
274
+ escapeFormulas?: boolean;
275
+ }
276
+ /** CSV: one sheet (or the selected cells), with the cells' values. */
277
+ export declare const csvExporter: SheetExporter<SheetCSVExportOptions>;
278
+ /** CSV and tab-separated text: a new sheet named after the file. */
279
+ export declare const csvImporter: SheetImporter<unknown, {
280
+ book: {
281
+ version: 1;
282
+ sheets: {
283
+ name: string;
284
+ cells: import("./model").SheetRow[];
285
+ }[];
286
+ };
287
+ }>;
288
+ /** A label as text. */
289
+ export declare const fileLabel: (label: SheetLabel, messages: SheetMessages) => string;
290
+ /**
291
+ * Puts the built-in exporters (or importers) and the extensions' together,
292
+ * by name: an extension's replaces a built-in one of the same name; two
293
+ * extensions with the same name are an error.
294
+ */
295
+ export declare function mergeFileHandlers<T extends {
296
+ name: string;
297
+ }>(builtin: readonly T[], added: readonly {
298
+ extension: string;
299
+ handler: T;
300
+ }[], kind: 'exporter' | 'importer'): T[];
301
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { SheetValue } from './model';
2
+ /**
3
+ * How the fill handle fills: `auto` continues runs it recognises and
4
+ * copies a single number; `series` also counts a single number up by one;
5
+ * `copy` only repeats.
6
+ */
7
+ export type SheetFillMode = 'auto' | 'series' | 'copy';
8
+ export interface SheetFillOptions {
9
+ /** @default 'auto' */
10
+ mode?: SheetFillMode;
11
+ /**
12
+ * The values are in reverse, filling up or left: a single value counts
13
+ * down.
14
+ */
15
+ back?: boolean;
16
+ }
17
+ /** The `count` values that follow `values`, as the fill handle continues them. */
18
+ export declare function continueValues(values: readonly SheetValue[], count: number, options?: SheetFillOptions): SheetValue[];
19
+ /**
20
+ * Whether filling in `auto` mode continues the values rather than copying
21
+ * them. Ctrl / ⌘ while dragging the fill handle does the other.
22
+ */
23
+ export declare function fillContinues(values: readonly SheetValue[]): boolean;
@@ -0,0 +1,39 @@
1
+ /** What to look for in the cells, and how. */
2
+ export interface SheetSearchQuery {
3
+ /** The text to find. */
4
+ search: string;
5
+ /** What `replace` puts in place of each match. */
6
+ replace?: string;
7
+ /** Tells upper and lower case apart. */
8
+ caseSensitive?: boolean;
9
+ /** A cell matches only when its whole text is the search, not when it contains it. */
10
+ wholeCell?: boolean;
11
+ /**
12
+ * Where to look: `'values'` (the default) reads the text cells show, a
13
+ * formula's result included; `'formulas'` reads what was typed, so a
14
+ * formula is found by the formula itself.
15
+ */
16
+ lookIn?: 'values' | 'formulas';
17
+ /** Which cells: the sheet shown (the default) or every sheet of the workbook. */
18
+ scope?: 'sheet' | 'workbook';
19
+ }
20
+ /** A cell that matches, on the sheet with index `sheet`. */
21
+ export interface SheetMatch {
22
+ sheet: number;
23
+ row: number;
24
+ col: number;
25
+ }
26
+ /**
27
+ * Tells whether a cell's text matches the query; `null` when there is
28
+ * nothing to look for.
29
+ */
30
+ export declare function cellMatcher(query: SheetSearchQuery): ((text: string) => boolean) | null;
31
+ /**
32
+ * The text with every match of the query replaced; the text as it is when
33
+ * nothing in it matches. With `wholeCell` the whole text is replaced.
34
+ */
35
+ export declare function replaceInText(text: string, query: SheetSearchQuery): string;
36
+ /** Whether `a` comes before `b`: by sheet, then row, then column. */
37
+ export declare const foundBefore: (a: SheetMatch, b: SheetMatch) => boolean;
38
+ /** The index of the first match at or after `at` (wrapping round to the first); `-1` for none. */
39
+ export declare function foundFrom(list: readonly SheetMatch[], at: SheetMatch): number;
@@ -0,0 +1,47 @@
1
+ import type { SheetValue } from './model';
2
+ /** Whether a format has date parts, outside quoted and escaped text. */
3
+ export declare const isDateFormat: (format: string) => boolean;
4
+ /** Up to 15 significant digits, so 0.1 + 0.2 shows as 0.3. */
5
+ export declare function generalNumber(value: number): string;
6
+ /**
7
+ * A value as the cell shows it, with its format. `locale` names the
8
+ * language for weekdays (`ddd`, `dddd`).
9
+ */
10
+ export declare function formatValue(value: SheetValue | undefined, format?: string, locale?: string): string;
11
+ /** Text as it shows: `'=…` is text starting with `=`, shown without its mark. */
12
+ export declare const textOf: (value: string) => string;
13
+ /**
14
+ * A number without a format, in at most `chars` characters, for a cell
15
+ * too narrow for all its digits: fewer decimals first, then `1.2E+11`.
16
+ * Only what the cell shows changes, never the value.
17
+ */
18
+ export declare function fitNumber(value: number, chars: number): string;
19
+ /**
20
+ * A number format with `by` more digits after the point, or fewer when
21
+ * `by` is below 0, as the toolbar's buttons change it: `0.00` → `0.000`,
22
+ * `#,##0` → `#,##0.0`, `0.0%` → `0%`. Without a format it starts from the
23
+ * digits `value` shows. Date, time and text formats stay as they are.
24
+ */
25
+ export declare function changeDecimals(format: string | undefined, value: SheetValue, by: number): string | undefined;
26
+ /**
27
+ * How a value lines up in its cell unless its style says otherwise:
28
+ * numbers, dates and times to the right, `TRUE` and `FALSE` in the middle,
29
+ * text to the left.
30
+ */
31
+ export declare function alignOf(value: SheetValue | undefined): 'left' | 'center' | 'right';
32
+ /** What typing `text` into a cell writes: the value, and a format when the text implies one. */
33
+ export interface SheetInput {
34
+ value: SheetValue;
35
+ format?: string;
36
+ }
37
+ /**
38
+ * Reads typed text: numbers (with thousands commas, `12%`, `¥1,200.50`),
39
+ * `TRUE` and `FALSE`, dates (`2026-10-31`, `2026/3/5`, `2026.3.5`, with a
40
+ * time or not), times (`9:30`), formulas (`=…`) and text. A leading `'`
41
+ * keeps the rest as text. Dates and times are written the standard way
42
+ * (`2026-03-05`, `09:30`); when typed another way, the format shows them
43
+ * as typed.
44
+ */
45
+ export declare function parseInput(text: string): SheetInput;
46
+ /** The text a cell's editor starts with: what was typed, so editing it changes nothing. */
47
+ export declare function inputText(value: SheetValue | undefined): string;
@@ -0,0 +1,76 @@
1
+ import type { SheetData, SheetGroup } from './model';
2
+ /** How deep groups may nest. */
3
+ export declare const MAX_GROUP_DEPTH = 8;
4
+ /** How wide each lane of the outline beside the headers is. */
5
+ export declare const OUTLINE_LANE = 16;
6
+ type Axis = 'row' | 'col';
7
+ /** A group of a sheet, laid out. */
8
+ export interface SheetGroupLines {
9
+ /** Its place in the sheet's `groups`. */
10
+ index: number;
11
+ axis: Axis;
12
+ /** Its first and last line. */
13
+ start: number;
14
+ end: number;
15
+ /** 1 for a group inside no other. */
16
+ depth: number;
17
+ collapsed: boolean;
18
+ }
19
+ /** The lines a group's range covers, or `null` when it isn't whole rows or columns. */
20
+ export declare function groupSpan(range: string): {
21
+ axis: Axis;
22
+ start: number;
23
+ end: number;
24
+ } | null;
25
+ /** A group's range for its lines: `'3:8'` or `'B:D'`. */
26
+ export declare const groupRange: (axis: Axis, start: number, end: number) => string;
27
+ /** One axis of a sheet's groups. */
28
+ export declare class SheetGroupAxis {
29
+ /** Outer groups before the ones inside them. */
30
+ readonly list: readonly SheetGroupLines[];
31
+ /** Groups left out for crossing another or nesting too deep. */
32
+ readonly dropped: number;
33
+ /** Lines inside a folded group. */
34
+ readonly hidden: Set<number>;
35
+ /** The deepest a group nests; `0` without groups. */
36
+ readonly depth: number;
37
+ constructor(
38
+ /** Outer groups before the ones inside them. */
39
+ list: readonly SheetGroupLines[],
40
+ /** Groups left out for crossing another or nesting too deep. */
41
+ dropped: number);
42
+ /** The groups around a line, outer first. */
43
+ around(line: number): SheetGroupLines[];
44
+ /** The group with exactly these lines. */
45
+ find(start: number, end: number): SheetGroupLines | undefined;
46
+ /**
47
+ * The line a group's button sits on: its summary line, before or after
48
+ * it; the other side when that line is missing or inside a group beside
49
+ * it; `-1` when neither side will do.
50
+ */
51
+ buttonLine(g: SheetGroupLines, count: number, summary?: SheetGroupSummary): number;
52
+ /**
53
+ * Why lines can't be grouped: a group they would cross, or `'deep'` for
54
+ * nesting more than eight deep; `null` when they can.
55
+ */
56
+ problem(start: number, end: number): {
57
+ cross: SheetGroupLines;
58
+ } | 'deep' | null;
59
+ /** The groups at a depth that sit right beside these lines, inside the same parent. */
60
+ beside(start: number, end: number): SheetGroupLines[];
61
+ }
62
+ /** Which side of a group holds its heading or subtotal, and its button. */
63
+ export type SheetGroupSummary = 'before' | 'after';
64
+ /** The groups of a sheet, laid out per axis. */
65
+ export declare class SheetGroups {
66
+ static readonly EMPTY: SheetGroups;
67
+ readonly rows: SheetGroupAxis;
68
+ readonly cols: SheetGroupAxis;
69
+ constructor(groups: readonly SheetGroup[] | undefined,
70
+ /** Whether a group is folded, when it isn't what the sheet says. */
71
+ collapsed?: (group: SheetGroup, index: number) => boolean);
72
+ axis(axis: Axis): SheetGroupAxis;
73
+ }
74
+ /** A sheet's groups, read once per list. */
75
+ export declare function groupsOf(sheet: SheetData): SheetGroups;
76
+ export {};
@@ -0,0 +1,27 @@
1
+ import { type SheetTransaction } from './transaction';
2
+ import type { SheetWorkbook } from './model';
3
+ import type { SheetSelection } from './selection';
4
+ /** What an undo or redo puts back: the sheet and the selection that went with the change. */
5
+ export interface SheetHistoryView {
6
+ /** The sheet's key (`id`, or its name), so it is found again after sheets move. */
7
+ sheet: string;
8
+ selection: SheetSelection;
9
+ }
10
+ export declare class SheetHistory {
11
+ private depth;
12
+ private done;
13
+ private undone;
14
+ constructor(depth?: number);
15
+ get canUndo(): boolean;
16
+ get canRedo(): boolean;
17
+ record(tr: SheetTransaction, before: SheetHistoryView, after: SheetHistoryView, now?: number): void;
18
+ undo(doc: SheetWorkbook): {
19
+ tr: SheetTransaction;
20
+ view: SheetHistoryView;
21
+ } | null;
22
+ redo(doc: SheetWorkbook): {
23
+ tr: SheetTransaction;
24
+ view: SheetHistoryView;
25
+ } | null;
26
+ clear(): void;
27
+ }
@@ -0,0 +1,33 @@
1
+ export { createFileSource, csvExporter, csvImporter, defineSheetExporter, defineSheetImporter, SheetFileError, exportWorkbook, readWorkbook, } from './file';
2
+ export type { SheetCSVExportOptions, SheetExporter, SheetExporterInfo, SheetExportScope, SheetExportWorkbookOptions, SheetFileSheet, SheetFileSource, SheetFileSourceOptions, SheetFileView, SheetImportContext, SheetImporter, SheetImporterInfo, SheetImportResult, SheetImportWarning, SheetReadWorkbookOptions, } from './file';
3
+ export { boundsOf, columnIndex, columnName, formatCell, formatRange, moveReferences, dropReferences, renameReferences, renameReferencesAll, parseCell, parseRange, quoteSheet, shiftFormula, splitSheet, } from './address';
4
+ export { detectDelimiter, parseCSV, readCSV, sheetToCSV } from './csv';
5
+ export type { SheetCSVReadOptions, SheetCSVWriteOptions } from './csv';
6
+ export type { SheetBounds, SheetCellTarget, SheetPoint, SheetRange, SheetRefMap } from './address';
7
+ export { defineSheetExtension } from './extension';
8
+ export type { SheetExtension, SheetUpdate } from './extension';
9
+ export { keepCommentAnchors, sheetCommentAnchors } from './comments';
10
+ export { diffWorkbooks, restoreWorkbook } from './versions';
11
+ export type { SheetCellChange, WorkbookDiff } from './versions';
12
+ export type { SheetCommentAnchor } from './comments';
13
+ export type { SheetClip } from './clipboard';
14
+ export type { SheetLabel } from './commands';
15
+ export { defineSheetCellType, optionOf } from './cell-type';
16
+ export type { SheetCellType, SheetDrawContext, SheetDrawRect, SheetDrawTextOptions, SheetResolvedType, } from './cell-type';
17
+ export { cellOf, valueOf } from './model';
18
+ export { checkWorkbook, emptyWorkbook, migrateWorkbook } from './document';
19
+ export type { CheckWorkbookOptions, WorkbookProblem } from './document';
20
+ export type { SheetCell, SheetCellInput, SheetColor, SheetCondition, SheetConditionalAverage, SheetConditionalBar, SheetConditionalDuplicates, SheetConditionalFormat, SheetConditionalFormula, SheetConditionalRank, SheetConditionalScale, SheetConditionalStyle, SheetConditionalUnique, SheetConditionalWhen, SheetData, SheetFilter, SheetFilterRule, SheetFreeze, SheetProtection, SheetRow, SheetRuleRange, SheetSelectOption, SheetSortOrder, SheetStyle, SheetTypeSetup, SheetValidation, SheetValidationFormula, SheetValidationList, SheetValidationWhen, SheetValue, SheetWorkbook, } from './model';
21
+ export { compareForSort, meetsRule, sortRows, textCollator } from './data';
22
+ export type { SheetSortKey } from './data';
23
+ export { changeDecimals, formatValue, parseInput } from './format';
24
+ export type { SheetInput } from './format';
25
+ export { lightThemeColor, plainStyle } from './paint';
26
+ export { sheetMessagesFor, sheetLocales } from '../locale';
27
+ export type { SheetFileMessages, SheetMessages } from '../locale';
28
+ export { checkProtection, isLocked, protectionOf } from './protect';
29
+ export { linkTarget } from './link';
30
+ export type { SheetLinkTarget } from './link';
31
+ export type { SheetProtectionCheck, SheetProtectionRefusal } from './protect';
32
+ export { applySheetSteps, compactSheetSteps, sheetKey, SheetTransaction } from './transaction';
33
+ export type { SheetAction, SheetAxisName, SheetCellAt, SheetLinesAt, SheetBookPatch, SheetPatch, SheetRangeAt, SheetRef, SheetStep, SheetStylePatch, SheetTransactionMeta, } from './transaction';
@@ -0,0 +1,14 @@
1
+ import { type SheetRange } from './address';
2
+ /** Where a link goes: a web page or app, or cells of the workbook. */
3
+ export type SheetLinkTarget = {
4
+ kind: 'web';
5
+ href: string;
6
+ } | {
7
+ kind: 'cell';
8
+ sheet?: string;
9
+ range: SheetRange;
10
+ };
11
+ /** Where a link goes, or `null` for one that isn't followed, such as `javascript:`. */
12
+ export declare function linkTarget(link: string | undefined): SheetLinkTarget | null;
13
+ /** Whether typed text is a web address, which then becomes the cell's link. */
14
+ export declare const isTypedLink: (text: string) => boolean;
@@ -0,0 +1,26 @@
1
+ import { type SheetBounds, type SheetPoint } from './address';
2
+ import type { SheetData } from './model';
3
+ /** The merged ranges of a sheet, read once, with quick lookups by cell. */
4
+ export declare class SheetMerges {
5
+ readonly list: readonly SheetBounds[];
6
+ static readonly EMPTY: SheetMerges;
7
+ /** By row, the merges that cover it. */
8
+ private byRow;
9
+ constructor(list: readonly SheetBounds[]);
10
+ get size(): number;
11
+ /** The merge covering a cell, or `undefined`. */
12
+ at(row: number, col: number): SheetBounds | undefined;
13
+ /** The merges that cover a row. */
14
+ inRow(row: number): readonly SheetBounds[];
15
+ /** The top left cell of the merge a cell is in, or the cell itself. */
16
+ anchor(point: SheetPoint): SheetPoint;
17
+ /** The cell's bounds: its merge, or just itself. */
18
+ cell(point: SheetPoint): SheetBounds;
19
+ /** Grows a range until no merge sticks out of it. */
20
+ expand(range: SheetBounds): SheetBounds;
21
+ /** The merges that touch a range. */
22
+ touching(range: SheetBounds): SheetBounds[];
23
+ }
24
+ /** A sheet's merges, read once per list. Ranges that aren't ranges, or are one cell, are left out. */
25
+ export declare function mergesOf(sheet: SheetData): SheetMerges;
26
+ export declare const overlaps: (a: SheetBounds, b: SheetBounds) => boolean;