@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,76 @@
1
+ import type { Component } from 'vue';
2
+ import type { SheetContext } from '../context';
3
+ import type { SheetMessages } from '../locale';
4
+ /** Text shown in a menu or tooltip: fixed, or read from the sheet's messages so it follows the language. */
5
+ export type SheetLabel = string | ((messages: SheetMessages) => string);
6
+ export declare const labelOf: (label: SheetLabel | undefined, messages: SheetMessages) => string;
7
+ /**
8
+ * Something the sheet can do, by name: toolbar items, menu items and keys
9
+ * can all refer to it, and take its label, icon and state from it.
10
+ */
11
+ export interface SheetCommand<Arg = any> {
12
+ label: SheetLabel;
13
+ icon?: Component;
14
+ /**
15
+ * The key shown beside it, written as in `useHotkey` (e.g. `mod+shift+e`).
16
+ * Only a hint: bind the key with the extension's `keymap`.
17
+ */
18
+ shortcut?: string;
19
+ /**
20
+ * Does it. `arg` is what the caller passes to `commands.run`, if anything.
21
+ * Return `false` when there was nothing to do.
22
+ */
23
+ run: (context: SheetContext, arg?: Arg) => boolean | void | Promise<unknown>;
24
+ /** Whether it can be run now; greyed out in menus and the toolbar when not. Defaults to `true`. */
25
+ enabled?: (context: SheetContext) => boolean;
26
+ /** For a command that turns something on and off: whether it is on, e.g. bold for a bold cell. */
27
+ pressed?: (context: SheetContext) => boolean;
28
+ /**
29
+ * Lets it replace the built-in command of the same name. Without it, a
30
+ * name the sheet already has is an error, so a command isn't replaced by accident.
31
+ */
32
+ override?: boolean;
33
+ }
34
+ /** Declares a command; only gives it a type. */
35
+ export declare function defineSheetCommand<Arg = any>(command: SheetCommand<Arg>): SheetCommand<Arg>;
36
+ /** A command as menus and the toolbar show it. */
37
+ export interface SheetCommandInfo {
38
+ name: string;
39
+ label: string;
40
+ icon?: Component;
41
+ shortcut?: string;
42
+ /** Whether it turns something on and off (it has `pressed`). */
43
+ toggle: boolean;
44
+ /** Whether it is the sheet's own, not added or replaced by an extension. */
45
+ builtin: boolean;
46
+ }
47
+ /** The commands of a sheet, by name, for `useSheet().commands`. */
48
+ export interface SheetCommands {
49
+ /**
50
+ * Runs a command. Returns `false` when it can't be run now (`enabled`
51
+ * says no) or it had nothing to do; `true` otherwise, also while an
52
+ * asynchronous one is still running. An unknown name is an error.
53
+ */
54
+ run: (name: string, arg?: unknown) => boolean;
55
+ /** Whether a command is there and can be run now. */
56
+ can: (name: string) => boolean;
57
+ /** Whether a command that turns something on and off is on. */
58
+ pressed: (name: string) => boolean;
59
+ /** A command's label, icon and shortcut, or `undefined` when there is none by that name. */
60
+ get: (name: string) => SheetCommandInfo | undefined;
61
+ /** Whether there is a command by that name. */
62
+ has: (name: string) => boolean;
63
+ /** The names of every command, built in and added. */
64
+ names: () => string[];
65
+ }
66
+ /**
67
+ * Puts the built-in commands and the extensions' together. An extension's
68
+ * command with a name already taken is an error, unless it says `override`
69
+ * and the name is a built-in one.
70
+ */
71
+ export declare function mergeCommands(builtin: Readonly<Record<string, SheetCommand>>, added: readonly {
72
+ extension: string;
73
+ commands: Readonly<Record<string, SheetCommand>>;
74
+ }[]): Map<string, SheetCommand<any>>;
75
+ /** The `commands` of a context, over the commands by name. */
76
+ export declare function createCommands(commands: () => ReadonlyMap<string, SheetCommand>, context: () => SheetContext, builtin?: Readonly<Record<string, SheetCommand>>): SheetCommands;
@@ -0,0 +1,22 @@
1
+ import type { SheetWorkbook } from './model';
2
+ import { type SheetTransaction } from './transaction';
3
+ /** Where a thread is: its sheet (by `id`, or name) and cell. */
4
+ export interface SheetCommentAnchor {
5
+ sheet: string;
6
+ row: number;
7
+ col: number;
8
+ /** The cell as people write it, e.g. `B3`. */
9
+ address: string;
10
+ }
11
+ /** Every anchored thread in a workbook, by thread id. */
12
+ export declare function sheetCommentAnchors(book: SheetWorkbook): Map<string, SheetCommentAnchor>;
13
+ /**
14
+ * Puts back the threads `tr` took off their cells by restoring what the
15
+ * cells held before them, as undo and redo do. `before` is
16
+ * `sheetCommentAnchors` of the workbook `tr` started from. A thread `tr`
17
+ * itself puts on another cell (undoing a move) goes there instead, and one
18
+ * whose row, column or sheet `tr` removed stays off. The threads are put
19
+ * back in `into`, by default `tr` itself; give another transaction that
20
+ * starts where `tr` ended to keep them a separate change.
21
+ */
22
+ export declare function keepCommentAnchors(before: ReadonlyMap<string, SheetCommentAnchor>, tr: SheetTransaction, into?: SheetTransaction): void;
@@ -0,0 +1,114 @@
1
+ import type { Tone } from 'dou-ui';
2
+ import { type SheetBounds } from './address';
3
+ import type { SheetColor, SheetConditionalFormat, SheetRuleRange, SheetStyle } from './model';
4
+ /** What the rules give a cell: a style, and a bar to draw from `from` to `to` (0–1 of its width). */
5
+ export interface SheetLook {
6
+ style?: SheetStyle;
7
+ bar?: {
8
+ from: number;
9
+ to: number;
10
+ color: string;
11
+ };
12
+ /** The same for looks that are the same, to tell when a cell's look changed. */
13
+ key: string;
14
+ }
15
+ /** What working out the looks needs from the grid. */
16
+ export interface SheetLookSource {
17
+ /** What a cell comes to: its formula's result, or its value. */
18
+ valueAt: (row: number, col: number) => unknown;
19
+ /** A cell's text as it shows. */
20
+ textAt: (row: number, col: number) => string;
21
+ /** Works out a formula as if it were in a cell of the sheet. */
22
+ evaluate: (formula: string) => unknown;
23
+ /**
24
+ * What a cell holds now, compared with `===`: the cell as written, or
25
+ * its formula's result. While every cell of a range holds the same, what
26
+ * a rule read of the range is kept from the looks before.
27
+ */
28
+ cellStamp?: (row: number, col: number) => unknown;
29
+ /** The workbook's named styles. */
30
+ styles?: Record<string, SheetStyle>;
31
+ /** How many rows and columns the sheet has, to keep whole rows and columns inside it. */
32
+ size: {
33
+ rows: number;
34
+ cols: number;
35
+ };
36
+ lang?: string;
37
+ }
38
+ /** A scale's color: a tone's soft fill, which follows the color mode, or the color itself. */
39
+ export declare function fillColor(color: SheetColor): string;
40
+ /** A bar's color: a tone's color, lighter so text stays readable over it, or the color itself. */
41
+ export declare function barColor(color: SheetColor): string;
42
+ /** A cell's own style with the look of its conditional formats over it. */
43
+ export declare function layStyle(own: SheetStyle | undefined, look: SheetStyle): {
44
+ bold?: boolean;
45
+ italic?: boolean;
46
+ underline?: boolean;
47
+ strike?: boolean;
48
+ tone?: Tone;
49
+ fill?: Tone;
50
+ color?: string;
51
+ background?: string;
52
+ align?: "left" | "center" | "right";
53
+ valign?: "top" | "middle" | "bottom";
54
+ wrap?: boolean;
55
+ locked?: boolean;
56
+ };
57
+ /** The bounds of a range, kept inside the sheet; `null` when it isn't a range. */
58
+ export declare function boundsIn(text: string, size: {
59
+ rows: number;
60
+ cols: number;
61
+ }): SheetBounds | null;
62
+ /** The ranges of a rule as a list. */
63
+ export declare const rangesOf: (range: SheetRuleRange) => readonly string[];
64
+ /** A rule's ranges as text, such as `'E2:E9, G2:J9'`. */
65
+ export declare const ruleRangeText: (range: SheetRuleRange) => string;
66
+ /**
67
+ * Reads ranges written as text, separated by commas or spaces: one range
68
+ * as a string, several as a list; `null` when one of them isn't a range.
69
+ */
70
+ export declare function readRuleRange(text: string): SheetRuleRange | null;
71
+ /**
72
+ * The bounds of a rule's ranges inside the sheet, leaving out those that
73
+ * aren't ranges or lie outside it, and the cell its formula is written for:
74
+ * the top left of the first range.
75
+ */
76
+ export declare function areasIn(range: SheetRuleRange, size: {
77
+ rows: number;
78
+ cols: number;
79
+ }): {
80
+ areas: SheetBounds[];
81
+ anchor: {
82
+ row: number;
83
+ col: number;
84
+ };
85
+ };
86
+ /**
87
+ * The looks a sheet's conditional formats give its cells. Make a new one
88
+ * when the workbook changes; within one, each cell is worked out once.
89
+ */
90
+ export declare class SheetLooks {
91
+ private source;
92
+ private rules;
93
+ private looks;
94
+ private collator;
95
+ /**
96
+ * `previous`, the looks before a change, lends what its rules read of
97
+ * ranges whose rows are the same, so a change elsewhere doesn't read a
98
+ * large range again.
99
+ */
100
+ constructor(formats: readonly SheetConditionalFormat[] | undefined, source: SheetLookSource, previous?: SheetLooks);
101
+ /** Whether the cells of an old rule's ranges hold what they did. */
102
+ private sameCells;
103
+ /** Whether there are any rules. */
104
+ get empty(): boolean;
105
+ /** The columns of a row that rules cover, as `[left, right]` pairs. */
106
+ spansIn(row: number): [number, number][];
107
+ /** What the rules give a cell, or `undefined` when none applies. */
108
+ lookAt(row: number, col: number): SheetLook | undefined;
109
+ private work;
110
+ private stats;
111
+ private meets;
112
+ private scaleAt;
113
+ private barAt;
114
+ }
@@ -0,0 +1,93 @@
1
+ import { type SheetBounds, type SheetRange } from './address';
2
+ import { type SheetCellInput, type SheetData, type SheetRow, type SheetValue } from './model';
3
+ import { type SheetResult } from '../formula/values';
4
+ /**
5
+ * The delimiter a text most likely uses: of `,`, `;`, tab and `|`, the one
6
+ * found most often outside quotes in its first lines, and the same number
7
+ * of times on each. A comma when none is found.
8
+ */
9
+ export declare function detectDelimiter(text: string): string;
10
+ /**
11
+ * Splits delimited text into rows of fields, reading quoted fields; a
12
+ * byte order mark at the start is dropped. `delimiter` defaults to the one
13
+ * `detectDelimiter` finds.
14
+ */
15
+ export declare function parseCSV(text: string, delimiter?: string): string[][];
16
+ export interface SheetCSVReadOptions {
17
+ /** `,`, `;`, a tab…; found from the text when left out. */
18
+ delimiter?: string;
19
+ /**
20
+ * Reads numbers, dates, times, percentages and `TRUE` / `FALSE` as such,
21
+ * the way typing them does; `false` keeps every field as text. Fields
22
+ * that look like codes, `007` or a long card number, stay text either way.
23
+ */
24
+ typed?: boolean;
25
+ /**
26
+ * The decimal mark of numbers: `,` reads `1,5` as 1.5 and `1.280,5` as
27
+ * 1280.5. Defaults to `,` when fields are split by `;`, as files written
28
+ * with a decimal comma are, otherwise `.`.
29
+ */
30
+ decimal?: '.' | ',';
31
+ /** Reads fields starting with `=` as formulas; by default they are text. */
32
+ formulas?: boolean;
33
+ }
34
+ /** The cells of a CSV, row by row, ready for a sheet's `cells` or `tr.setCells`. */
35
+ export declare function readCSV(text: string, options?: SheetCSVReadOptions): SheetRow[];
36
+ export interface SheetCSVWriteOptions {
37
+ /** `,` by default. */
38
+ delimiter?: string;
39
+ /** Only these cells, such as `'A1:D20'`; by default up to the last row and column with data. */
40
+ range?: string | SheetRange;
41
+ /**
42
+ * Writes what each cell shows, with its format (`¥1,280.00`,
43
+ * `2026年3月5日`), instead of values a spreadsheet can sort and add up
44
+ * (`1280`, `2026-03-05`, what formulas come to). Off by default.
45
+ */
46
+ text?: boolean;
47
+ /**
48
+ * Writes formulas as written (`=A1+B1`) instead of what they come to,
49
+ * to read back with `readCSV(text, { formulas: true })`. Ignored with
50
+ * `text`. Off by default.
51
+ */
52
+ formulas?: boolean;
53
+ /** The language dates are shown in, with `text`. */
54
+ locale?: string;
55
+ /**
56
+ * What a formula comes to, by its row and column in the sheet, e.g. from
57
+ * `SheetFormulaEngine.result`. Without it a formula is written as text,
58
+ * with a `'` before it unless `escapeFormulas` is off; for formulas a
59
+ * spreadsheet can work out, use `formulas`.
60
+ */
61
+ result?: (row: number, col: number) => SheetResult;
62
+ /**
63
+ * With `text`: a cell's text, e.g. as its cell type shows it; `undefined`
64
+ * uses its format. `value` is its value, or its formula's result; `row`
65
+ * and `col` are where it is in the sheet.
66
+ */
67
+ cellText?: (input: SheetCellInput, value: SheetValue, row: number, col: number) => string | undefined;
68
+ /**
69
+ * Without `text`: the value to write for a cell, as a cell type's `plain`
70
+ * gives it; `null` writes nothing, `undefined` writes its value, or its
71
+ * formula's result. Not asked for formulas written with `formulas`.
72
+ */
73
+ cellPlain?: (input: SheetCellInput, value: SheetValue, row: number, col: number) => SheetValue | undefined;
74
+ /** Line breaks between rows; `\r\n` by default, as the format asks. */
75
+ newline?: string;
76
+ /**
77
+ * Starts with a byte order mark, so programs that guess the encoding read
78
+ * it as UTF-8. On by default.
79
+ */
80
+ bom?: boolean;
81
+ /**
82
+ * Puts a `'` before text starting with `=`, `+`, `-`, `@`, a tab or a
83
+ * carriage return, so a spreadsheet program opening the file doesn't run
84
+ * it as a formula. Numbers are written as they are, and so are this grid's
85
+ * formulas with `formulas`. On by default; `false` writes such text as
86
+ * it is.
87
+ */
88
+ escapeFormulas?: boolean;
89
+ }
90
+ /** Where a sheet has data: up to its last row and column with something in them. */
91
+ export declare function dataBounds(sheet: SheetData): SheetBounds | null;
92
+ /** A sheet, or part of it, as CSV. */
93
+ export declare function sheetToCSV(sheet: SheetData, options?: SheetCSVWriteOptions): string;
@@ -0,0 +1,26 @@
1
+ import type { SheetCondition, SheetFilterRule, SheetSortOrder } from './model';
2
+ /** One column to sort by, the first deciding most. */
3
+ export interface SheetSortKey {
4
+ /** The column, by number. */
5
+ col: number;
6
+ order?: SheetSortOrder;
7
+ }
8
+ /** Whether a value counts as empty: empty cells sort last, either way. */
9
+ export declare const isEmptyValue: (value: unknown) => value is "" | null | undefined;
10
+ /** Compares text the way people of `lang` read it: numbers inside by size, case ignored. */
11
+ export declare function textCollator(lang?: string): Intl.Collator;
12
+ /**
13
+ * Compares two values for sorting from small to large: numbers first, then
14
+ * text, then `FALSE` and `TRUE`, then errors. Empty values are not compared
15
+ * here; they go last whatever the order.
16
+ */
17
+ export declare function compareForSort(a: unknown, b: unknown, collator?: Intl.Collator): number;
18
+ /**
19
+ * The order to put rows in, sorted by `keys`: a list of the given rows.
20
+ * Equal rows keep their order; empty values go last in either order.
21
+ */
22
+ export declare function sortRows(rows: readonly number[], keys: readonly SheetSortKey[], valueAt: (row: number, col: number) => unknown, collator?: Intl.Collator): number[];
23
+ /** Whether a cell meets a condition, given what it comes to and how it shows. */
24
+ export declare function meetsCondition(condition: SheetCondition, value: unknown, text: string, collator?: Intl.Collator): boolean;
25
+ /** Whether a cell is kept by a column's filter rule. */
26
+ export declare function meetsRule(rule: SheetFilterRule, value: unknown, text: string, collator?: Intl.Collator): boolean;
@@ -0,0 +1,49 @@
1
+ import { type SheetExtension } from './extension';
2
+ import type { SheetWorkbook } from './model';
3
+ /** A workbook with no sheets, to start from when nothing is saved yet. */
4
+ export declare const emptyWorkbook: () => SheetWorkbook;
5
+ export interface WorkbookProblem {
6
+ code: 'version' | 'shape' | 'missing-name' | 'duplicate-name' | 'duplicate-id' | 'unknown-style' | 'unknown-type' | 'bad-merge';
7
+ /** The name of the sheet at fault; none for the workbook's own problems. */
8
+ sheet?: string;
9
+ /**
10
+ * Where the problem is, as a path into the workbook, e.g. `sheets[1]`,
11
+ * `sheets[0].cells[3][2]` or `types.status`; `version` for the version.
12
+ */
13
+ path: string;
14
+ /** The name, style, type or range at fault, for the editor's message. */
15
+ text: string;
16
+ /** An English description, for logs. */
17
+ message: string;
18
+ }
19
+ export interface CheckWorkbookOptions {
20
+ /**
21
+ * The sheet's `extensions`, for the cell types they add. Without them only
22
+ * the built-in types (`date`, `select`, `checkbox`) and the workbook's own
23
+ * `types` are known.
24
+ */
25
+ extensions?: readonly (SheetExtension | readonly SheetExtension[])[];
26
+ }
27
+ /**
28
+ * The problems of a workbook, before it is saved or shown: an unknown
29
+ * version, sheets without a name or sharing a name or id, cells using a
30
+ * style or type nobody defined, and merges that are not ranges or overlap
31
+ * another.
32
+ */
33
+ export declare function checkWorkbook(workbook: SheetWorkbook, options?: CheckWorkbookOptions): WorkbookProblem[];
34
+ /**
35
+ * Brings a saved workbook up to the current version, and fills what an
36
+ * older or hand-written one may lack (`version`, `sheets`, each sheet's
37
+ * `cells`). Sheets that are not objects are dropped; anything else is kept
38
+ * as it is. Throws for data that is not an object
39
+ * (an array, `null`, a string) and for a version it does not know.
40
+ */
41
+ export declare function migrateWorkbook(input: unknown): SheetWorkbook;
42
+ /**
43
+ * The `v-model` as the sheet reads it. A workbook of the wrong shape (not
44
+ * an object, without `sheets`, without a known `version`) gets a warning in
45
+ * development and is read with what is missing left empty and the version
46
+ * as 1, so the sheet still opens and what it writes back carries
47
+ * `version: 1`.
48
+ */
49
+ export declare function readWorkbook(value: unknown): SheetWorkbook;
@@ -0,0 +1,177 @@
1
+ import type { CommentAction, CommentThread } from 'dou-ui';
2
+ import type { Component, Ref } from 'vue';
3
+ import type { SheetContext } from '../context';
4
+ import type { SheetMenuContext, SheetMenuItem, SheetToolbarItem } from '../types';
5
+ import type { SheetCommand } from './commands';
6
+ import type { SheetExporter, SheetImporter } from './file';
7
+ import type { SheetFunction } from '../formula/functions';
8
+ import type { SheetCellType } from './cell-type';
9
+ import type { SheetClip } from './clipboard';
10
+ import type { SheetWorkbook } from './model';
11
+ import type { SheetTransaction } from './transaction';
12
+ /** What an extension's hooks receive; the same as `useSheet()`. */
13
+ export type SheetExtensionContext = SheetContext;
14
+ /**
15
+ * A key handler: return `false` to let the key through to the next handler
16
+ * and the grid's own keys; anything else means it was handled.
17
+ */
18
+ export type SheetKeyHandler = (event: KeyboardEvent) => boolean | void;
19
+ /** An undo history used instead of the grid's own, e.g. one that only takes back this user's changes. */
20
+ export interface SheetHistoryHandler {
21
+ /** `false` when there was nothing to undo. */
22
+ undo: () => boolean;
23
+ redo: () => boolean;
24
+ canUndo: () => boolean;
25
+ canRedo: () => boolean;
26
+ }
27
+ /** A change the grid has made, as an extension's `update` sees it. */
28
+ export interface SheetUpdate {
29
+ /** The workbook before the change. */
30
+ before: SheetWorkbook;
31
+ /** The workbook now. */
32
+ doc: SheetWorkbook;
33
+ /**
34
+ * The change: typing, commands, undo and redo, `transact` and other
35
+ * people's changes. `transaction.meta.action` says what made it, and
36
+ * other people's changes in collaboration have `meta.origin` `'remote'`.
37
+ * `null` when a new workbook came in through `v-model`.
38
+ */
39
+ transaction: SheetTransaction | null;
40
+ }
41
+ /** Where the comment threads live, when not in `v-model:comments`. */
42
+ export interface SheetCommentsProvider {
43
+ /** The threads, kept up to date. */
44
+ threads: Readonly<Ref<readonly CommentThread[]>>;
45
+ /** Make a change this user asked for. */
46
+ apply: (action: CommentAction) => void;
47
+ }
48
+ /**
49
+ * A piece of the sheet: cell types, keys, menu items, panels drawn over
50
+ * the grid, and a say in every change.
51
+ */
52
+ export interface SheetExtension {
53
+ name: string;
54
+ /** Higher runs first: its keys and hooks come before others. Defaults to 100. */
55
+ priority?: number;
56
+ /** Cell types cells can name with `type`; one with a built-in name replaces it. */
57
+ cellTypes?: SheetCellType[];
58
+ /**
59
+ * Functions formulas can call (see `defineSheetFunction`); one with a
60
+ * built-in name replaces it.
61
+ */
62
+ functions?: SheetFunction[];
63
+ /**
64
+ * Commands, by name: things toolbar items, menu items and keys can refer
65
+ * to. Start the names with the extension's, e.g. `xlsx.export`. A name the
66
+ * sheet already has replaces that command only with `override: true`.
67
+ */
68
+ commands?: Record<string, SheetCommand>;
69
+ /**
70
+ * Ways to write files, offered in the toolbar's export menu and by
71
+ * `exportFile`. One with a built-in name (`csv`, `png`, `svg`) replaces it.
72
+ */
73
+ exporters?: SheetExporter[];
74
+ /**
75
+ * Ways to read files, for the toolbar's import button, `importFile` and
76
+ * dropped files. They are asked before the built-in CSV one.
77
+ */
78
+ importers?: SheetImporter[];
79
+ /**
80
+ * Keys, written as in `useHotkey` (e.g. `mod+b`, `alt+arrowdown`), while the
81
+ * grid has focus and no cell is being edited: a handler, or the name of a
82
+ * command to run. They come before the grid's own.
83
+ */
84
+ keymap?: (context: SheetExtensionContext) => Record<string, SheetKeyHandler | string>;
85
+ /** Items for the right-click menu, put before the built-in ones. */
86
+ contextMenu?: (context: SheetExtensionContext, menu: SheetMenuContext) => SheetMenuItem[];
87
+ /**
88
+ * Items for `DouSheetToolbar`: after the built-in tools, or where its
89
+ * `tools` names them by `key`.
90
+ */
91
+ toolbar?: (context: SheetExtensionContext) => SheetToolbarItem[];
92
+ /**
93
+ * Components drawn over the grid, not scrolled with it, e.g. a panel or
94
+ * marks placed with `cellRect`. They can call `useSheet()`.
95
+ */
96
+ overlays?: Component[];
97
+ /**
98
+ * Components drawn over the cells, kept out of the headers: `below`
99
+ * under the grid's own marks, such as the copied range and formula
100
+ * references, `above` over them; the editor stays on top. They place marks with
101
+ * `useSheet()`'s `cellRect` and `rangeRect`, which follow the scroll, and
102
+ * take no clicks.
103
+ */
104
+ layers?: {
105
+ below?: Component[];
106
+ above?: Component[];
107
+ };
108
+ /**
109
+ * Keeps the comment threads somewhere else than `v-model:comments`, e.g.
110
+ * in a shared document; `v-model:comments` then only mirrors them. Only
111
+ * one extension may.
112
+ */
113
+ comments?: (context: SheetExtensionContext) => SheetCommentsProvider;
114
+ /** Replaces the grid's undo history; the first extension that has one wins. */
115
+ history?: (context: SheetExtensionContext) => SheetHistoryHandler;
116
+ /** Runs once the grid is mounted. Return a function to run when it unmounts. */
117
+ setup?: (context: SheetExtensionContext) => void | (() => void);
118
+ /**
119
+ * Sees every change made in the grid or with `transact` before it is
120
+ * applied, in priority order, and may add steps to it. Undo takes back
121
+ * the added steps with the rest.
122
+ */
123
+ transaction?: (tr: SheetTransaction, context: SheetExtensionContext) => void;
124
+ /**
125
+ * Runs after every change, with the workbook already updated: changes in
126
+ * the grid, `transact`, undo and redo, other people's changes and a new
127
+ * `v-model` workbook. For keeping something else in step, such as a save
128
+ * reminder; to change the change itself use `transaction`.
129
+ */
130
+ update?: (update: SheetUpdate, context: SheetExtensionContext) => void;
131
+ /**
132
+ * Rewrites cells before they are pasted, or imported at the active cell,
133
+ * in priority order; return `null` to stop it. A paste's `paste` event
134
+ * comes after, with what the extensions made of it; an import has none.
135
+ * Cut cells that come back rewritten still leave their place, in the
136
+ * same step, but formulas pointing at them don't follow.
137
+ */
138
+ transformPaste?: (clip: SheetClip, context: SheetExtensionContext) => SheetClip | null;
139
+ }
140
+ /** Declares an extension; only gives it a type. */
141
+ export declare function defineSheetExtension(extension: SheetExtension): SheetExtension;
142
+ /** Everything the extensions contribute, gathered once per list. */
143
+ export interface ResolvedSheetExtensions {
144
+ extensions: SheetExtension[];
145
+ cellTypes: SheetCellType[];
146
+ functions: SheetFunction[];
147
+ commands: {
148
+ extension: string;
149
+ commands: Record<string, SheetCommand>;
150
+ }[];
151
+ exporters: {
152
+ extension: string;
153
+ exporter: SheetExporter;
154
+ }[];
155
+ importers: {
156
+ extension: string;
157
+ importer: SheetImporter;
158
+ }[];
159
+ keymaps: NonNullable<SheetExtension['keymap']>[];
160
+ toolbars: NonNullable<SheetExtension['toolbar']>[];
161
+ menus: NonNullable<SheetExtension['contextMenu']>[];
162
+ setups: NonNullable<SheetExtension['setup']>[];
163
+ transactions: NonNullable<SheetExtension['transaction']>[];
164
+ updates: NonNullable<SheetExtension['update']>[];
165
+ pasteTransforms: NonNullable<SheetExtension['transformPaste']>[];
166
+ overlays: Component[];
167
+ layers: {
168
+ below: Component[];
169
+ above: Component[];
170
+ };
171
+ history?: SheetExtension['history'];
172
+ comments?: SheetExtension['comments'];
173
+ }
174
+ type ExtensionList = readonly (SheetExtension | readonly SheetExtension[])[];
175
+ /** Sorts the extensions by priority and collects what they add. */
176
+ export declare function resolveSheetExtensions(list?: ExtensionList): ResolvedSheetExtensions;
177
+ export {};