@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,470 @@
1
+ import { type SheetBounds, type SheetPoint, type SheetRange } from './address';
2
+ import { type SheetCell, type SheetCellInput, type SheetConditionalFormat, type SheetData, type SheetFilter, type SheetFilterRule, type SheetProtection, type SheetRow, type SheetStyle, type SheetTypeSetup, type SheetValidation, type SheetValue, type SheetWorkbook } from './model';
3
+ import { type SheetFillMode } from './fill';
4
+ import { type SheetSortKey } from './data';
5
+ type Patch<T> = {
6
+ [K in keyof T]?: T[K] | undefined;
7
+ };
8
+ /** The parts of a sheet set with `updateSheet`. */
9
+ export type SheetPatch = Patch<Omit<SheetData, 'cells' | 'rowSizes' | 'colSizes'>>;
10
+ /** Changes to the workbook's own settings: those besides its sheets, styles and types. */
11
+ export type SheetBookPatch = Patch<Omit<SheetWorkbook, 'sheets' | 'styles' | 'types'>>;
12
+ /** Changes to a style: fields to set, and fields set to `undefined` to take off. */
13
+ export type SheetStylePatch = Patch<SheetStyle>;
14
+ /** A sheet: its index in the workbook, or its `id` or `name`. */
15
+ export type SheetRef = number | string;
16
+ /**
17
+ * A cell: `'B3'`, `'表 2'!B3` for another sheet, or a point with an
18
+ * optional `sheet`. Without a sheet it is on the transaction's sheet.
19
+ */
20
+ export type SheetCellAt = string | (SheetPoint & {
21
+ sheet?: SheetRef;
22
+ });
23
+ /**
24
+ * A range, written like a cell: `'A1:C4'`, `'表 2'!B:B`, or a range or its
25
+ * bounds with an optional `sheet`.
26
+ */
27
+ export type SheetRangeAt = string | ((SheetRange | SheetBounds) & {
28
+ sheet?: SheetRef;
29
+ });
30
+ /** Rows or columns. */
31
+ export type SheetAxisName = 'row' | 'col';
32
+ /**
33
+ * Rows or columns: a zero-based number, or as people write them, `'5'` or
34
+ * `'5:7'` for rows and `'C'` or `'B:C'` for columns.
35
+ */
36
+ export type SheetLinesAt = number | string | {
37
+ from: number;
38
+ count: number;
39
+ };
40
+ /** What made a change, as the `change` and `transaction` events tell it. */
41
+ export type SheetAction = 'input' | 'paste' | 'cut' | 'fill' | 'clear' | 'resize' | 'move' | 'insert' | 'delete' | 'hide' | 'merge' | 'group' | 'note' | 'comment' | 'sort' | 'filter' | 'format' | 'validation' | 'protect' | 'link' | 'style' | 'freeze' | 'sheet' | 'import' | 'restore' | 'replace' | 'undo' | 'redo' | 'api';
42
+ /** What a step calls a sheet: its `id`, or its name when it has none. */
43
+ export declare const sheetKey: (sheet: SheetData) => string;
44
+ export type SheetStep =
45
+ /** Writes a cell; `cell` left out empties it. */
46
+ {
47
+ type: 'setCell';
48
+ sheet: string;
49
+ row: number;
50
+ col: number;
51
+ cell?: SheetCellInput;
52
+ }
53
+ /** Sets a row's height or a column's width; `size` left out goes back to the default. */
54
+ | {
55
+ type: 'setSize';
56
+ sheet: string;
57
+ axis: 'row' | 'col';
58
+ index: number;
59
+ size?: number;
60
+ } | {
61
+ type: 'updateSheet';
62
+ sheet: string;
63
+ patch: SheetPatch;
64
+ }
65
+ /** Changes the workbook's own settings, such as `protect`. */
66
+ | {
67
+ type: 'updateBook';
68
+ patch: SheetBookPatch;
69
+ }
70
+ /** Adds, replaces or (with `style` left out) removes a named style. */
71
+ | {
72
+ type: 'setStyle';
73
+ name: string;
74
+ style?: SheetStyle;
75
+ }
76
+ /** Adds, replaces or (with `setup` left out) removes a named cell type. */
77
+ | {
78
+ type: 'setType';
79
+ name: string;
80
+ setup?: SheetTypeSetup;
81
+ }
82
+ /**
83
+ * Adds `count` rows (or columns) before `index`, moving the rest down (or
84
+ * right). They are empty unless `cells` and `sizes` fill them: for rows,
85
+ * `cells` holds the rows; for columns, each row's cells in them.
86
+ */
87
+ | {
88
+ type: 'insertLines';
89
+ sheet: string;
90
+ axis: SheetAxisName;
91
+ index: number;
92
+ count: number;
93
+ cells?: (SheetRow | null)[];
94
+ sizes?: (number | null)[];
95
+ }
96
+ /** Removes `count` rows (or columns) from `index`, moving the rest up (or left). */
97
+ | {
98
+ type: 'removeLines';
99
+ sheet: string;
100
+ axis: SheetAxisName;
101
+ index: number;
102
+ count: number;
103
+ }
104
+ /**
105
+ * Moves `count` rows (or columns) from `from` to before `to`, both
106
+ * numbered as before the move.
107
+ */
108
+ | {
109
+ type: 'moveLines';
110
+ sheet: string;
111
+ axis: SheetAxisName;
112
+ from: number;
113
+ count: number;
114
+ to: number;
115
+ }
116
+ /** Adds a sheet at `index`, moving the ones from there on along. */
117
+ | {
118
+ type: 'insertSheet';
119
+ index: number;
120
+ data: SheetData;
121
+ } | {
122
+ type: 'removeSheet';
123
+ sheet: string;
124
+ }
125
+ /** Moves a sheet to `index`, counted after it is taken out. */
126
+ | {
127
+ type: 'moveSheet';
128
+ sheet: string;
129
+ index: number;
130
+ };
131
+ export interface SheetTransactionMeta {
132
+ /** Keep out of the undo history, e.g. a change from another client. */
133
+ history?: boolean;
134
+ /** Consecutive transactions in the same group within a second undo as one. */
135
+ group?: string;
136
+ /** Who made the change, passed on to the `transaction` event. */
137
+ origin?: string;
138
+ /** What the change was; the grid sets it, a change made in code is `api`. */
139
+ action?: SheetAction;
140
+ /**
141
+ * With `false`, the grid doesn't hold the change to the protection of
142
+ * sheets and the workbook, e.g. for code that fills in a protected form.
143
+ * A change with `history: false`, such as undo, redo or another person's,
144
+ * isn't held either: it can't be cancelled.
145
+ */
146
+ protection?: boolean;
147
+ }
148
+ /**
149
+ * A batch of changes. Steps apply as they are added, so later calls see
150
+ * earlier ones; `doc` is the result. Cells and ranges without a sheet are
151
+ * on `sheet` (in the grid, the one shown).
152
+ */
153
+ export declare class SheetTransaction {
154
+ readonly before: SheetWorkbook;
155
+ /** The sheet cells and ranges are on when they don't name one. */
156
+ readonly sheet: SheetRef;
157
+ readonly steps: SheetStep[];
158
+ /** What undoes each step, in the order the steps were made. */
159
+ private undoing;
160
+ private reversed;
161
+ /** The steps that undo this transaction, in the order to apply them. */
162
+ get inverse(): readonly SheetStep[];
163
+ meta: SheetTransactionMeta;
164
+ private book;
165
+ /** What this transaction has copied, so it copies each thing once. */
166
+ private own;
167
+ /** The sheets this transaction copied, and the rows it copied of each. */
168
+ private ownSheets;
169
+ private ownRows;
170
+ constructor(before: SheetWorkbook,
171
+ /** The sheet cells and ranges are on when they don't name one. */
172
+ sheet?: SheetRef);
173
+ get doc(): SheetWorkbook;
174
+ /** Whether the change makes any change: it has steps and wasn't cancelled. */
175
+ get changed(): boolean;
176
+ private stopped;
177
+ /**
178
+ * Stops the change: none of it is applied or kept for undo, and the
179
+ * editor fires `transactionCancel` and says why. For an extension's `transaction`
180
+ * hook, e.g. to keep people from changing what they may not; hooks after
181
+ * it don't run. A change kept out of the history (`meta.history: false`),
182
+ * such as undo, redo or another person's, can't be cancelled and goes ahead.
183
+ */
184
+ cancel(reason?: string): this;
185
+ /** Whether `cancel` stopped it. */
186
+ get cancelled(): boolean;
187
+ /** What `cancel` was given, to tell people why. */
188
+ get cancelReason(): string | undefined;
189
+ setMeta(meta: SheetTransactionMeta): this;
190
+ /** The index of a sheet, by index, `id` or name; `-1` when there is none. */
191
+ indexOf(ref?: SheetRef): number;
192
+ /** A sheet as it is now in this transaction. */
193
+ getSheet(ref?: SheetRef): SheetData;
194
+ getCell(at: SheetCellAt): SheetCellInput;
195
+ step(step: SheetStep): this;
196
+ /** Replaces a cell; `undefined` empties it. */
197
+ setCell(at: SheetCellAt, cell: SheetCellInput): this;
198
+ /** Changes some of a cell's fields and keeps the rest. */
199
+ updateCell(at: SheetCellAt, patch: Patch<SheetCell>): this;
200
+ /** Writes a cell's value and keeps its style and format. */
201
+ setValue(at: SheetCellAt, value: SheetValue | undefined): this;
202
+ /** Empties the values in a range, keeping styles and formats. */
203
+ clearValues(at: SheetRangeAt): this;
204
+ /** Writes a cell's note; empty text or `undefined` takes it off. */
205
+ setNote(at: SheetCellAt, note: string | undefined): this;
206
+ /**
207
+ * Puts a comment thread on a cell, or takes it off with `undefined`. Use
208
+ * it with `{ history: false }`: a thread stays when the change before it
209
+ * is undone.
210
+ */
211
+ setComment(at: SheetCellAt, id: string | undefined): this;
212
+ /** Takes the notes off the cells in a range, keeping what they hold. */
213
+ clearNotes(at: SheetRangeAt): this;
214
+ /** Sets a row's height or a column's width in px; `undefined` for the default, `0` hides it. */
215
+ setSize(axis: 'row' | 'col', index: number, size: number | undefined, sheet?: SheetRef): this;
216
+ /** Changes a sheet's name, freeze, row or column count. */
217
+ updateSheet(patch: SheetPatch, sheet?: SheetRef): this;
218
+ /** Changes the workbook's own settings, such as `protect`. */
219
+ updateBook(patch: SheetBookPatch): this;
220
+ /**
221
+ * Protects a sheet, or with `false` stops protecting it: its locked cells
222
+ * (all but those whose style has `locked: false`) can't be changed, nor
223
+ * can the sheet's rows, columns and rules, except what `options` allows.
224
+ */
225
+ protectSheet(protect: boolean | SheetProtection, sheet?: SheetRef): this;
226
+ setStyle(name: string, style: SheetStyle | undefined): this;
227
+ /** Adds, replaces or (with `undefined`) removes a named cell type, such as a list to pick from. */
228
+ setType(name: string, setup: SheetTypeSetup | undefined): this;
229
+ /**
230
+ * Writes a block of cells with its top left corner at `at`, row by row.
231
+ * `undefined` in the block empties a cell; a shorter row leaves the cells
232
+ * past it as they are.
233
+ */
234
+ setCells(at: SheetCellAt, block: readonly (readonly SheetCellInput[])[]): this;
235
+ /**
236
+ * Fills `to` from `from`, the cells it extends down, up, right or left:
237
+ * each line of cells continues as the fill handle does (see
238
+ * `continueValues`), with the styles and formats of the cells it repeats.
239
+ * Formulas are copied with their references moved along. `mode` is
240
+ * `auto` as dragging does, `series` to count a single number up too, or
241
+ * `copy` to only repeat, as Ctrl+D does. With `keepStyle`, the filled
242
+ * cells keep their own styles and formats, as on a protected sheet.
243
+ */
244
+ fill(from: SheetRangeAt, to: SheetRangeAt, options?: {
245
+ mode?: SheetFillMode;
246
+ keepStyle?: boolean;
247
+ }): this;
248
+ /**
249
+ * Sorts the rows of a range by the values in `keys`' columns; the cells
250
+ * outside the range stay. `header` keeps the first row in place. Equal rows
251
+ * keep their order, and empty values go last either way. Formulas move
252
+ * with their rows and their references move along, as when copied.
253
+ * `valueAt` gives what a cell comes to, e.g. a formula's result; the value
254
+ * as written is used without it. Ranges with merged cells are not sorted.
255
+ */
256
+ sortRange(at: SheetRangeAt, keys: readonly SheetSortKey[], options?: {
257
+ header?: boolean;
258
+ valueAt?: (row: number, col: number) => unknown;
259
+ lang?: string;
260
+ }): this;
261
+ /**
262
+ * Puts a filter on a range, headings in its first row; `null` takes the
263
+ * filter off, showing the rows it hid. A new range drops the old rules.
264
+ */
265
+ setFilter(at: SheetRangeAt | null): this;
266
+ /**
267
+ * Sets which rows a column of the filter keeps; `undefined` keeps all.
268
+ * `sorted` marks the column the rows were sorted by, for its button.
269
+ */
270
+ filterColumn(col: number, rule: SheetFilterRule | undefined, sheet?: SheetRef): this;
271
+ /** Remembers the filter column the rows were sorted by, or forgets it with `undefined`. */
272
+ markSorted(sorted: SheetFilter['sorted'], sheet?: SheetRef): this;
273
+ /**
274
+ * Adds a conditional format after the sheet's others; where two give the
275
+ * same part of a cell's look, the earlier one wins. The format's `range`
276
+ * names cells of `sheet`.
277
+ */
278
+ addConditionalFormat(format: SheetConditionalFormat, sheet?: SheetRef): this;
279
+ /** Sets a sheet's conditional formats, in order, e.g. after moving one up; `[]` removes them all. */
280
+ setConditionalFormats(formats: readonly SheetConditionalFormat[], sheet?: SheetRef): this;
281
+ /**
282
+ * Removes the conditional formats whose cells overlap a range, such as
283
+ * the selection; without a range, all of the sheet's.
284
+ */
285
+ clearConditionalFormats(at?: SheetRangeAt): this;
286
+ /**
287
+ * Adds a validation rule after the sheet's others; where two cover a
288
+ * cell, the earlier one applies. The rule's `range` names cells of `sheet`.
289
+ */
290
+ addValidation(rule: SheetValidation, sheet?: SheetRef): this;
291
+ /** Sets a sheet's validation rules, in order; `[]` removes them all. */
292
+ setValidations(rules: readonly SheetValidation[], sheet?: SheetRef): this;
293
+ /**
294
+ * Removes the validation rules whose cells overlap a range, such as the
295
+ * selection; without a range, all of the sheet's.
296
+ */
297
+ clearValidations(at?: SheetRangeAt): this;
298
+ private addRule;
299
+ private setRules;
300
+ private clearRules;
301
+ /**
302
+ * Groups rows so they can be folded away: `groupRows('3:8')` or
303
+ * `groupRows(2, 6)`. A group may hold other groups, at most eight deep;
304
+ * one beside a group of the same level joins it, and one that would cross
305
+ * a group, or nest too deep, throws a `RangeError`.
306
+ */
307
+ groupRows(at: SheetLinesAt, count?: number, sheet?: SheetRef): this;
308
+ /** Groups columns so they can be folded away: `groupCols('B:D')`. */
309
+ groupCols(at: SheetLinesAt, count?: number, sheet?: SheetRef): this;
310
+ /**
311
+ * Takes rows out of their groups: the groups that lie within them go (the
312
+ * outer ones, when groups nest); without any, the rows leave the innermost
313
+ * group they are in, which may split it in two.
314
+ */
315
+ ungroupRows(at: SheetLinesAt, count?: number, sheet?: SheetRef): this;
316
+ /** Takes columns out of their groups, as `ungroupRows` does rows. */
317
+ ungroupCols(at: SheetLinesAt, count?: number, sheet?: SheetRef): this;
318
+ /** Folds a group away: `collapseGroup('3:8')`, `range` being the group's rows or columns. */
319
+ collapseGroup(range: string, sheet?: SheetRef): this;
320
+ /** Shows a folded group again: `expandGroup('3:8')`. */
321
+ expandGroup(range: string, sheet?: SheetRef): this;
322
+ private foldGroup;
323
+ /**
324
+ * Shows the groups of an axis down to a level, as the outline's level
325
+ * buttons do: level 1 folds every group, level 2 shows the outer groups
326
+ * with theirs folded, and one past the deepest shows them all.
327
+ */
328
+ showGroupLevel(axis: SheetAxisName, level: number, sheet?: SheetRef): this;
329
+ private groupLines;
330
+ private ungroupLines;
331
+ /** Rewrites a sheet's groups: each to itself, another, several or none. */
332
+ private setGroups;
333
+ /**
334
+ * Adds empty rows before `at`: `insertRows(4, 2)` or `insertRows('5:6')`
335
+ * both add two rows where row 5 was. Frozen rows and the row count grow
336
+ * with them, and formulas pointing below follow their cells.
337
+ */
338
+ insertRows(at: SheetLinesAt, count?: number, sheet?: SheetRef): this;
339
+ /** Adds empty columns before `at`, `insertCols('C')` or `insertCols(2)`. */
340
+ insertCols(at: SheetLinesAt, count?: number, sheet?: SheetRef): this;
341
+ /**
342
+ * Removes rows with their cells and heights: `deleteRows('5:7')` or
343
+ * `deleteRows(4, 3)`. Formulas pointing at them read `#REF!`.
344
+ */
345
+ deleteRows(at: SheetLinesAt, count?: number, sheet?: SheetRef): this;
346
+ /** Removes columns with their cells and widths: `deleteCols('B:C')`. */
347
+ deleteCols(at: SheetLinesAt, count?: number, sheet?: SheetRef): this;
348
+ /**
349
+ * Moves rows to before row `to`, numbered as before the move:
350
+ * `moveRows('2:3', '6')` puts rows 2 and 3 above what was row 6.
351
+ * Formulas pointing at them follow.
352
+ */
353
+ moveRows(lines: SheetLinesAt, to: number | string, sheet?: SheetRef): this;
354
+ /** Moves columns to before column `to`: `moveCols('C', 'A')`. */
355
+ moveCols(lines: SheetLinesAt, to: number | string, sheet?: SheetRef): this;
356
+ /**
357
+ * Moves a block of cells so its top left corner is at `to`, as cutting
358
+ * and pasting does: the cells at `from` empty, those at `to` are
359
+ * replaced, and formulas pointing at the block follow it.
360
+ */
361
+ moveCells(from: SheetRangeAt, to: SheetCellAt): this;
362
+ private insertLines;
363
+ private deleteLines;
364
+ private moveLines;
365
+ /**
366
+ * After rows or columns of a sheet change: rewrites formulas pointing at
367
+ * it, and moves its merged cells, dropping those that are gone or now
368
+ * one cell.
369
+ */
370
+ private moveRanges;
371
+ /** Moves a sheet's rules with their cells; a rule goes when its cells do. */
372
+ private moveRules;
373
+ /** Moves a sheet's groups with their lines; a group goes when its lines do. */
374
+ private moveGroups;
375
+ /** Moves a sheet's filter with its rows and columns; it goes when its range does. */
376
+ private moveFilter;
377
+ /**
378
+ * Merges a range into one cell. Merges it touches are taken into it. The
379
+ * top left cell keeps its content; the values of the other cells are
380
+ * cleared, keeping their styles, unless `keep` leaves them hidden under the
381
+ * merge, to show again when it is split.
382
+ */
383
+ mergeCells(at: SheetRangeAt, options?: {
384
+ keep?: boolean;
385
+ }): this;
386
+ /** Splits the merged cells a range touches back into single cells. */
387
+ unmergeCells(at: SheetRangeAt): this;
388
+ /**
389
+ * Changes how the cells in a range look: each cell's style with `patch`
390
+ * laid over it, where a field set to `undefined` (or `false`, but for
391
+ * `locked`) is taken off; `null` takes the whole style off. Cells that end up looking the
392
+ * same share one style: one in `styles` that matches, or a new one named
393
+ * `s1`, `s2`…. Whole columns and rows stop at the sheet's edge.
394
+ */
395
+ styleCells(at: SheetRangeAt, patch: SheetStylePatch | null): this;
396
+ /**
397
+ * Sets the number or date format of the cells in a range (`undefined`
398
+ * for none), or changes each with a function of its format and value,
399
+ * such as `(format, value) => changeDecimals(format, value, 1)`.
400
+ */
401
+ formatCells(at: SheetRangeAt, format: string | undefined | ((format: string | undefined, value: SheetValue) => string | undefined)): this;
402
+ /** The name of a style that looks like `name`'s with `patch` laid over it. */
403
+ private styleFor;
404
+ /**
405
+ * Adds a sheet, at the end or at `index`. Its name must not be taken
406
+ * (`uniqueName` gives one that isn't); it is `Sheet1`, `Sheet2`… when
407
+ * left out, whatever the language. Returns the transaction; the new sheet
408
+ * is `tr.getSheet(name)`.
409
+ */
410
+ addSheet(sheet?: Partial<SheetData>, index?: number): this;
411
+ /**
412
+ * Removes a sheet. The last one stays: a workbook always has a sheet.
413
+ * Formulas on other sheets pointing at it read `#REF!`.
414
+ */
415
+ removeSheet(sheet?: SheetRef): this;
416
+ /** Moves a sheet to `index`, counted among the sheets without it. */
417
+ moveSheet(sheet: SheetRef, index: number): this;
418
+ /** Renames a sheet; formulas naming it follow. The name must not be taken. */
419
+ renameSheet(sheet: SheetRef, name: string): this;
420
+ /**
421
+ * Adds a copy of a sheet right after it, named `name` or the sheet's name
422
+ * with a number, such as `数据 (2)`. Formulas on the copy that name the
423
+ * sheet keep pointing at the original.
424
+ */
425
+ duplicateSheet(sheet?: SheetRef, name?: string): this;
426
+ /**
427
+ * `name` if no sheet has it, otherwise the name with the first free
428
+ * number: `门店 (2)`, `门店 (3)`…
429
+ */
430
+ uniqueName(name: string): string;
431
+ /** Passes every formula of the workbook through `rewrite`. */
432
+ private rewriteFormulas;
433
+ /**
434
+ * Rewrites the formulas of every sheet's rules: conditional formats' and
435
+ * validations' formulas, and the references of validation lists.
436
+ */
437
+ private rewriteRuleFormulas;
438
+ /** The first name `prefix` + a number, from the count of sheets on, that no sheet has. */
439
+ private freeName;
440
+ private checkName;
441
+ /** Rewrites the references to cells on sheet `name` in every formula of the workbook. */
442
+ private rewriteReferences;
443
+ private mustIndex;
444
+ private keyOf;
445
+ private cellAt;
446
+ private rangeAt;
447
+ /** A range kept inside its sheet, so whole columns and rows end at its edge. */
448
+ private rangeIn;
449
+ /** Applies a step, returning the step that undoes it, or `null` when nothing changes. */
450
+ private apply;
451
+ private insertAt;
452
+ private removeAt;
453
+ private moveAt;
454
+ private ownBook;
455
+ /** The list of sheets as an array this transaction may change. */
456
+ private ownList;
457
+ private ownSheet;
458
+ /** The row as an array this transaction may change. */
459
+ private row;
460
+ }
461
+ /** Where line `i` ends up when `count` lines from `from` move to before `to`. */
462
+ export declare function movedIndex(from: number, count: number, to: number): (i: number) => number;
463
+ /** Applies steps to a workbook, as one transaction. */
464
+ export declare function applySheetSteps(doc: SheetWorkbook, steps: readonly SheetStep[]): SheetTransaction;
465
+ /**
466
+ * The same changes in fewer steps: of several steps writing the same cell,
467
+ * size or style, keeps only the last, which is the one that counts.
468
+ */
469
+ export declare function compactSheetSteps(steps: readonly SheetStep[]): SheetStep[];
470
+ export {};
@@ -0,0 +1,55 @@
1
+ import type { SheetSelectOption, SheetValidation, SheetValue } from './model';
2
+ import { type SheetMessages } from '../locale';
3
+ /** Where the rules read cells and work out formulas, for the sheet they belong to. */
4
+ export interface SheetCheckSource {
5
+ /** What a cell holds, its formula's result for a formula. */
6
+ valueAt: (row: number, col: number) => unknown;
7
+ /** How a cell shows. */
8
+ textAt: (row: number, col: number) => string;
9
+ /** Works out a formula on the sheet. */
10
+ evaluate: (formula: string) => unknown;
11
+ /** The values of the cells a list refers to, such as `'=$H$2:$H$9'`. */
12
+ listAt: (reference: string) => SheetValue[];
13
+ size: {
14
+ rows: number;
15
+ cols: number;
16
+ };
17
+ lang?: string;
18
+ }
19
+ /** Whether a rule reads other cells, so a cell's mark can change when they do. */
20
+ export declare const readsOthers: (rule: SheetValidation) => boolean;
21
+ /**
22
+ * The validation rules of a sheet. Make a new one when the workbook
23
+ * changes; it reads a list's cells once.
24
+ */
25
+ export declare class SheetChecks {
26
+ private source;
27
+ private rules;
28
+ private collator;
29
+ constructor(validations: readonly SheetValidation[] | undefined, source: SheetCheckSource);
30
+ /** Whether there are any rules. */
31
+ get empty(): boolean;
32
+ /** Whether a rule covering the row reads other cells. */
33
+ readsOthersIn(row: number): boolean;
34
+ private entryAt;
35
+ /** The rule a cell must keep, or `undefined`. */
36
+ ruleAt(row: number, col: number): SheetValidation | undefined;
37
+ /** The options of the list rule a cell must keep, or `undefined` when it has none. */
38
+ optionsAt(row: number, col: number): SheetSelectOption[] | undefined;
39
+ private optionsOf;
40
+ /**
41
+ * Whether a value fits the rule of the cell at `row`, `col`; `text` is how
42
+ * it shows. Without a rule, anything fits.
43
+ */
44
+ fits(row: number, col: number, value: unknown, text: string): boolean;
45
+ /** The rule a cell breaks as it is now, or `undefined`. */
46
+ brokenAt(row: number, col: number): SheetValidation | undefined;
47
+ /** Every cell that breaks its rule, rule by rule. */
48
+ broken(): Generator<{
49
+ row: number;
50
+ col: number;
51
+ rule: SheetValidation;
52
+ }>;
53
+ }
54
+ /** A rule in words: its `message`, or what it asks for. */
55
+ export declare function ruleMessage(rule: SheetValidation, messages: SheetMessages): string;
@@ -0,0 +1,38 @@
1
+ import { type SheetCellInput, type SheetWorkbook } from './model';
2
+ import { type SheetTransaction } from './transaction';
3
+ /** A cell that differs between two versions. */
4
+ export interface SheetCellChange {
5
+ /** The sheet's key: its `id`, or its name. */
6
+ sheet: string;
7
+ row: number;
8
+ col: number;
9
+ /** The cell as people write it, e.g. `B3`. */
10
+ address: string;
11
+ before: SheetCellInput;
12
+ after: SheetCellInput;
13
+ }
14
+ export interface WorkbookDiff {
15
+ /** The cells that differ on the sheets in both versions, sheet by sheet, row by row. */
16
+ cells: SheetCellChange[];
17
+ /** The keys of the sheets only the newer version has. */
18
+ addedSheets: string[];
19
+ /** The keys of the sheets only the older version has. */
20
+ removedSheets: string[];
21
+ /** The keys of the sheets whose other settings (name, sizes, merges, rules, protection…) differ. */
22
+ changedSheets: string[];
23
+ /** The named styles (in `styles`) that differ, such as one now unlocking its cells. */
24
+ changedStyles: string[];
25
+ /** The named cell types (in `types`) that differ. */
26
+ changedTypes: string[];
27
+ /** Whether the workbook's own settings, such as `protect`, differ. */
28
+ bookChanged: boolean;
29
+ }
30
+ /** What changed from `before` to `after`. */
31
+ export declare function diffWorkbooks(before: SheetWorkbook, after: SheetWorkbook): WorkbookDiff;
32
+ /**
33
+ * Adds the steps that bring the workbook to `book`, writing only what
34
+ * differs: cells, sizes and settings of the sheets in both (protection
35
+ * too), sheets added and removed, their order, the workbook's settings,
36
+ * and the named styles and types.
37
+ */
38
+ export declare function restoreWorkbook(tr: SheetTransaction, book: SheetWorkbook): SheetTransaction;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A computed color as `#rrggbb` or `rgba(…)`, which every SVG reader
3
+ * understands. A canvas converts most colors as it parses them; colors
4
+ * it keeps in another space (`oklab(…)`, `color(…)`) are painted on a
5
+ * pixel and read back.
6
+ */
7
+ export declare function plainColor(color: string): string;
@@ -0,0 +1,98 @@
1
+ import type { Component } from 'vue';
2
+ import type { SheetDrawContext, SheetDrawRect } from '../core/cell-type';
3
+ /** The look of a cell's content, in plain colors. */
4
+ export interface DrawLook {
5
+ color: string;
6
+ /** The fill, `null` for none. */
7
+ background: string | null;
8
+ bold: boolean;
9
+ italic: boolean;
10
+ underline: boolean;
11
+ strike: boolean;
12
+ align: 'left' | 'center' | 'right';
13
+ valign: 'top' | 'middle' | 'bottom';
14
+ wrap: boolean;
15
+ /** The cell's own grid line, where it isn't the sheet's, as on a fill. */
16
+ line: string | null;
17
+ }
18
+ /** A cell to draw, at its place among the lines drawn. */
19
+ export interface DrawCell {
20
+ x: number;
21
+ y: number;
22
+ width: number;
23
+ height: number;
24
+ text: string;
25
+ look: DrawLook;
26
+ /** A conditional format's bar, as parts of the cell's width. */
27
+ bar?: {
28
+ from: number;
29
+ to: number;
30
+ color: string;
31
+ };
32
+ /** A checkbox cell's box. */
33
+ check?: boolean;
34
+ /** A merged cell, which hides the grid lines inside it. */
35
+ merged?: boolean;
36
+ /** A select cell's value as a soft tag. */
37
+ tag?: {
38
+ background: string;
39
+ color: string;
40
+ border: string;
41
+ };
42
+ /** A cell type's own drawing, as SVG markup in the cell's own coordinates. */
43
+ draw?: (draw: SheetDrawContext) => string;
44
+ }
45
+ /** The colors and font of the sheet, read from the page. */
46
+ export interface DrawTheme {
47
+ fontFamily: string;
48
+ fontSize: number;
49
+ boldWeight: string;
50
+ surface: string;
51
+ line: string;
52
+ freezeLine: string;
53
+ headerBg: string;
54
+ headerText: string;
55
+ headerLine: string;
56
+ checkBorder: string;
57
+ checkBg: string;
58
+ checkOn: string;
59
+ checkOnBg: string;
60
+ }
61
+ export interface SheetDrawing {
62
+ /** The widths of the columns drawn, left to right. */
63
+ colWidths: number[];
64
+ /** The heights of the rows drawn, top to bottom. */
65
+ rowHeights: number[];
66
+ /** The column letters and row numbers, when the headers are drawn. */
67
+ colNames?: string[];
68
+ rowNames?: string[];
69
+ headerWidth: number;
70
+ headerHeight: number;
71
+ /** How many of the rows and columns drawn are frozen, with a firmer line after them. */
72
+ frozenRows: number;
73
+ frozenCols: number;
74
+ cells: DrawCell[];
75
+ gridlines: boolean;
76
+ background: boolean;
77
+ theme: DrawTheme;
78
+ /** Icons as SVG, for cell types' drawings; none without it. */
79
+ icon?: (icon: Component, box: SheetDrawRect, color: string) => string;
80
+ /** CSS colors as SVG takes them, for cell types' drawings; as they are without it. */
81
+ color?: (value: string) => string;
82
+ }
83
+ /** Measures text in a font, in px. */
84
+ export type MeasureText = (text: string, font: string) => number;
85
+ export declare const escapeXML: (text: string) => string;
86
+ /**
87
+ * Breaks text into lines no wider than `width`: at spaces where it can,
88
+ * between any two characters of CJK text, and inside a word too long
89
+ * for a line.
90
+ */
91
+ export declare function wrapLines(text: string, width: number, measure: (text: string) => number): string[];
92
+ /** The sheet as an SVG document. */
93
+ /** The size of the image a drawing makes, in CSS px. */
94
+ export declare function drawingSize(drawing: SheetDrawing): {
95
+ width: number;
96
+ height: number;
97
+ };
98
+ export declare function drawSheet(drawing: SheetDrawing, measure: MeasureText): string;