@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,363 @@
1
+ import type { Tone } from 'dou-ui';
2
+ /**
3
+ * What a cell holds. A string starting with `=` is a formula; text that
4
+ * starts with `=` is written `'=…` and shows without the `'`.
5
+ */
6
+ export type SheetValue = string | number | boolean | null;
7
+ /** A cell with more than a value. */
8
+ export interface SheetCell {
9
+ value?: SheetValue;
10
+ /** The name of a style in the workbook's `styles`. */
11
+ style?: string;
12
+ /**
13
+ * How a number or date shows, such as `0.00`, `#,##0`, `0%`, `¥#,##0.00`
14
+ * or `yyyy-mm-dd`. The value itself is kept as it is.
15
+ */
16
+ format?: string;
17
+ /** A note on the cell. */
18
+ note?: string;
19
+ /**
20
+ * The id of the comment thread about the cell, one of `v-model:comments`.
21
+ * Copying a cell leaves it behind; cutting moves it.
22
+ */
23
+ comment?: string;
24
+ /**
25
+ * Where the cell links to: a web address (`https:`, `http:`, `mailto:`
26
+ * or `tel:`), or a place in the workbook written `#` and a reference,
27
+ * such as `#A20` or `#'汇总'!B2`. Other addresses are not followed.
28
+ */
29
+ link?: string;
30
+ /**
31
+ * What kind of cell it is: `date`, `select`, `checkbox`, a type an
32
+ * extension adds, or a name in the workbook's `types`. It decides how the
33
+ * value shows and how it is edited.
34
+ */
35
+ type?: string;
36
+ }
37
+ /** A cell as written in the data: a bare value, or a cell with a style or format. */
38
+ export type SheetCellInput = SheetValue | SheetCell | undefined;
39
+ /** One row of cells, left to right. Empty cells can be left out (`undefined` or `null`). */
40
+ export type SheetRow = SheetCellInput[];
41
+ export interface SheetFreeze {
42
+ /** Rows kept at the top while scrolling. */
43
+ rows?: number;
44
+ /** Columns kept at the left while scrolling. */
45
+ cols?: number;
46
+ }
47
+ /** One sheet of a workbook. */
48
+ export interface SheetData {
49
+ /**
50
+ * A stable name for the sheet that changes and collaboration refer to.
51
+ * Without one they use `name`; give an `id` when sheets can be renamed
52
+ * while changes are on their way, e.g. from another client.
53
+ */
54
+ id?: string;
55
+ /** Shown on the sheet's tab and used by formulas to refer to it. Unique in the workbook. */
56
+ name: string;
57
+ /** The cells, row by row. Rows and cells past the data can be left out. */
58
+ cells: (SheetRow | null | undefined)[];
59
+ /** How many rows the sheet has; at least the rows in `cells`. Defaults to 1000. */
60
+ rowCount?: number;
61
+ /** How many columns the sheet has; at least the widest row. Defaults to 26. */
62
+ colCount?: number;
63
+ /** Row heights that differ from the default, by row number; `0` hides the row. */
64
+ rowSizes?: Record<number, number>;
65
+ /** Column widths that differ from the default, by column number; `0` hides the column. */
66
+ colSizes?: Record<number, number>;
67
+ freeze?: SheetFreeze;
68
+ /**
69
+ * Merged cells, as ranges such as `'A1:C1'`. The top left cell of each
70
+ * holds what it shows; the cells it covers keep their data but are not
71
+ * shown. Merges must not overlap.
72
+ */
73
+ merges?: string[];
74
+ /** A filter on a range: rows whose cells don't match its rules are hidden. */
75
+ filter?: SheetFilter;
76
+ /**
77
+ * Rows or columns that fold away together, such as the detail rows under
78
+ * a subtotal. Groups on the same axis nest or stay apart, at most eight
79
+ * deep.
80
+ */
81
+ groups?: SheetGroup[];
82
+ /**
83
+ * Where a group's heading or subtotal is, and so its button: on the row
84
+ * above it (the column left of it) with `'before'`, the default, or below
85
+ * it (right of it) with `'after'`.
86
+ */
87
+ groupSummary?: 'before' | 'after';
88
+ /**
89
+ * Looks cells take on when they meet a rule, such as a red fill for
90
+ * amounts over budget. Where two formats give the same part of the look,
91
+ * the earlier one wins.
92
+ */
93
+ conditionalFormats?: SheetConditionalFormat[];
94
+ /**
95
+ * What cells may hold, such as one of a list or a number from 1 to 5.
96
+ * Where two rules cover a cell, the earlier one applies.
97
+ */
98
+ validations?: SheetValidation[];
99
+ /**
100
+ * Keeps the locked cells from being changed: every cell but those whose
101
+ * style says `locked: false`, such as the blanks of a form to fill in.
102
+ * Rows, columns and the sheet's rules can't be changed either, except
103
+ * what the options allow. Code changes it with `tr.protectSheet`.
104
+ */
105
+ protect?: boolean | SheetProtection;
106
+ }
107
+ /**
108
+ * What people may still do on a protected sheet besides changing unlocked
109
+ * cells. Everything is `false` by default.
110
+ */
111
+ export interface SheetProtection {
112
+ /** Change the look and number format of locked cells, and merge cells. */
113
+ formatCells?: boolean;
114
+ /** Change column widths and hide columns. */
115
+ formatColumns?: boolean;
116
+ /** Change row heights and hide rows. */
117
+ formatRows?: boolean;
118
+ insertRows?: boolean;
119
+ insertColumns?: boolean;
120
+ deleteRows?: boolean;
121
+ deleteColumns?: boolean;
122
+ /** Use the sheet's filter to pick which rows show. Sorting moves cells, so only unlocked ones. */
123
+ filter?: boolean;
124
+ }
125
+ /** Rows or columns that fold away together. */
126
+ export interface SheetGroup {
127
+ /** Whole rows such as `'3:8'`, or whole columns such as `'B:D'`. */
128
+ range: string;
129
+ /** Folded: its rows or columns are hidden until it is expanded. */
130
+ collapsed?: boolean;
131
+ }
132
+ /**
133
+ * A look for the cells of `range` that meet a rule. The rule is one of
134
+ * `when`, `formula`, `top`, `bottom`, `average`, `duplicates` or `unique`, with
135
+ * `style` as the look; or the cells are shaded by their numbers, with
136
+ * `scale` or `bar`.
137
+ */
138
+ export type SheetConditionalFormat = SheetConditionalWhen | SheetConditionalFormula | SheetConditionalRank | SheetConditionalAverage | SheetConditionalDuplicates | SheetConditionalUnique | SheetConditionalScale | SheetConditionalBar;
139
+ interface SheetConditionalBase {
140
+ /**
141
+ * The cells, such as `'D2:D40'`, or several ranges taken as one, such as
142
+ * `['D2:D40', 'G2:G40']`.
143
+ */
144
+ range: SheetRuleRange;
145
+ }
146
+ /**
147
+ * The cells of a rule: a range, or several ranges taken as one. A rule's
148
+ * formula is written for the top left cell of the first.
149
+ */
150
+ export type SheetRuleRange = string | string[];
151
+ /** A look: a style's name in the workbook's `styles`, or a style. */
152
+ export type SheetConditionalStyle = string | SheetStyle;
153
+ /** Cells whose value meets a condition, e.g. `{ op: 'gt', value: 100 }`. */
154
+ export interface SheetConditionalWhen extends SheetConditionalBase {
155
+ when: SheetCondition;
156
+ style: SheetConditionalStyle;
157
+ }
158
+ /**
159
+ * Cells for which a formula comes to `TRUE` (or a number other than 0).
160
+ * It is written for the range's top left cell and moves with each cell, as
161
+ * a copied formula does: `'=$E2>$D2'` on `'A2:F40'` checks each row's E and D.
162
+ */
163
+ export interface SheetConditionalFormula extends SheetConditionalBase {
164
+ formula: string;
165
+ style: SheetConditionalStyle;
166
+ }
167
+ /** The largest (`top`) or smallest (`bottom`) numbers of the range: a count, or a percent of them. */
168
+ export type SheetConditionalRank = SheetConditionalBase & {
169
+ /** With `percent`, a percent of the numbers, e.g. `10` for the top 10%. */
170
+ percent?: boolean;
171
+ style: SheetConditionalStyle;
172
+ } & ({
173
+ top: number;
174
+ bottom?: never;
175
+ } | {
176
+ bottom: number;
177
+ top?: never;
178
+ });
179
+ /** Numbers above or below the range's average. */
180
+ export interface SheetConditionalAverage extends SheetConditionalBase {
181
+ average: 'above' | 'below';
182
+ style: SheetConditionalStyle;
183
+ }
184
+ /** Values that show up more than once in the range, compared as they show, without case. */
185
+ export interface SheetConditionalDuplicates extends SheetConditionalBase {
186
+ duplicates: true;
187
+ style: SheetConditionalStyle;
188
+ }
189
+ /** Values that show up only once in the range, compared as they show, without case. */
190
+ export interface SheetConditionalUnique extends SheetConditionalBase {
191
+ unique: true;
192
+ style: SheetConditionalStyle;
193
+ }
194
+ /** A tone, or any CSS color. */
195
+ export type SheetColor = Tone | (string & {});
196
+ /**
197
+ * Fills each number's cell with a color between two or three, from the
198
+ * smallest number to the largest (through the middle one with three), e.g.
199
+ * `['danger', 'warning', 'success']`.
200
+ */
201
+ export interface SheetConditionalScale extends SheetConditionalBase {
202
+ scale: [SheetColor, SheetColor] | [SheetColor, SheetColor, SheetColor];
203
+ }
204
+ /**
205
+ * Draws a bar in each number's cell, as long as the number is large
206
+ * against the others. Negative numbers draw to the left of zero, in the
207
+ * same color. `true` uses the neutral tone.
208
+ */
209
+ export interface SheetConditionalBar extends SheetConditionalBase {
210
+ bar: true | SheetColor;
211
+ }
212
+ /**
213
+ * What the cells of `range` may hold: one of a `list`, a value that meets
214
+ * a condition (`when`), or one for which a `formula` comes to `TRUE`.
215
+ * Empty cells always fit.
216
+ */
217
+ export type SheetValidation = SheetValidationList | SheetValidationWhen | SheetValidationFormula;
218
+ interface SheetValidationBase {
219
+ /** The cells, such as `'D2:D40'`, or several ranges, such as `['E2:E9', 'G2:J9']`. */
220
+ range: SheetRuleRange;
221
+ /**
222
+ * Whether a typed value that doesn't fit is refused, `true` by default.
223
+ * With `false` it is kept and marked. Pasted and filled values are always
224
+ * kept and marked.
225
+ */
226
+ strict?: boolean;
227
+ /** Said when a value doesn't fit; by default the rule in words. */
228
+ message?: string;
229
+ /** Shown beside the cell while it is the active one, e.g. what to enter. */
230
+ prompt?: string;
231
+ }
232
+ /**
233
+ * One of a list: the values, or a reference to cells holding them, such as
234
+ * `'=$H$2:$H$9'` or `'=城市!A2:A20'`. The cells get a list to pick from.
235
+ */
236
+ export interface SheetValidationList extends SheetValidationBase {
237
+ list: SheetSelectOption[] | string;
238
+ }
239
+ /**
240
+ * A value that meets a condition, e.g. `{ op: 'between', value: 1, to: 5 }`.
241
+ * A number in the condition asks for a number; with `integer`, a whole one.
242
+ */
243
+ export interface SheetValidationWhen extends SheetValidationBase {
244
+ when: SheetCondition;
245
+ integer?: boolean;
246
+ }
247
+ /**
248
+ * A value for which a formula comes to `TRUE` (or a number other than 0).
249
+ * It is written for the range's top left cell and moves with each cell:
250
+ * `'=COUNTIF($A$2:$A$40, A2) = 1'` on `'A2:A40'` asks for values not repeated.
251
+ */
252
+ export interface SheetValidationFormula extends SheetValidationBase {
253
+ formula: string;
254
+ }
255
+ /**
256
+ * A filter on a range of rows. The range's first row holds the headings,
257
+ * which get the filter buttons; the rows below are filtered. Rows hidden by
258
+ * a filter are not stored as hidden: clearing the rules shows them again.
259
+ */
260
+ export interface SheetFilter {
261
+ /** The range, headings included, such as `'A1:E40'`. */
262
+ range: string;
263
+ /** The rule of each filtered column, by column number. */
264
+ columns?: Record<number, SheetFilterRule>;
265
+ /** The column the rows were last sorted by from the filter, shown on its button. */
266
+ sorted?: {
267
+ col: number;
268
+ order: SheetSortOrder;
269
+ };
270
+ }
271
+ /**
272
+ * Which rows a column keeps: those whose shown text is one of `values` (an
273
+ * empty cell is `''`), or those that meet `condition`.
274
+ */
275
+ export type SheetFilterRule = {
276
+ values: string[];
277
+ } | {
278
+ condition: SheetCondition;
279
+ };
280
+ /**
281
+ * A condition on a cell; numbers compare as numbers, text without case.
282
+ * `between` and `notBetween` take `value` and `to`, both ends included.
283
+ */
284
+ export interface SheetCondition {
285
+ op: 'eq' | 'ne' | 'gt' | 'ge' | 'lt' | 'le' | 'between' | 'notBetween' | 'contains' | 'notContains' | 'begins' | 'ends' | 'blank' | 'notBlank';
286
+ value?: SheetValue;
287
+ /** The other end for `between` and `notBetween`. */
288
+ to?: SheetValue;
289
+ }
290
+ export type SheetSortOrder = 'asc' | 'desc';
291
+ /** How cells that use a style look. Tones follow the color mode; colors are used as given. */
292
+ export interface SheetStyle {
293
+ bold?: boolean;
294
+ italic?: boolean;
295
+ underline?: boolean;
296
+ strike?: boolean;
297
+ /** Text in a tone's color. */
298
+ tone?: Tone;
299
+ /** A soft fill in a tone's color. */
300
+ fill?: Tone;
301
+ /** Any CSS color for the text; wins over `tone`. */
302
+ color?: string;
303
+ /** Any CSS color for the fill; wins over `fill`. */
304
+ background?: string;
305
+ /** Defaults to the value's own: numbers right, true and false centered, text left. */
306
+ align?: 'left' | 'center' | 'right';
307
+ valign?: 'top' | 'middle' | 'bottom';
308
+ /** Wrap long text onto more lines instead of cutting it off. */
309
+ wrap?: boolean;
310
+ /**
311
+ * With `false`, the cell can still be changed while its sheet is
312
+ * protected. Cells are locked by default.
313
+ */
314
+ locked?: boolean;
315
+ }
316
+ /**
317
+ * A cell type with its settings, which cells refer to by name, e.g.
318
+ * `{ type: 'select', options: ['未开始', '进行中', '已完成'] }`.
319
+ */
320
+ export interface SheetTypeSetup {
321
+ /** The cell type it sets up: `select`, or a type an extension adds. */
322
+ type: string;
323
+ /** For `select`: the values to pick from, each a value or a value with a tone. */
324
+ options?: SheetSelectOption[];
325
+ /** Settings of types from extensions. */
326
+ [key: string]: unknown;
327
+ }
328
+ /** A value of a `select` cell; with a `tone` it shows as a soft tag in that tone. */
329
+ export type SheetSelectOption = SheetValue | {
330
+ value: SheetValue;
331
+ tone?: Tone;
332
+ };
333
+ export interface SheetWorkbook {
334
+ /** The version of the format; see `migrateWorkbook`. */
335
+ version: 1;
336
+ sheets: SheetData[];
337
+ /** Named styles, which cells refer to by name. */
338
+ styles?: Record<string, SheetStyle>;
339
+ /** Named cell types with their settings, which cells refer to with `type`. */
340
+ types?: Record<string, SheetTypeSetup>;
341
+ /**
342
+ * Keeps the sheets as they are: none can be added, removed, moved or
343
+ * renamed. Code changes it with `tr.updateBook({ protect })`.
344
+ */
345
+ protect?: boolean;
346
+ }
347
+ export declare const DEFAULT_ROWS = 1000;
348
+ export declare const DEFAULT_COLS = 26;
349
+ /** The cell as an object, or `undefined` when it is empty. */
350
+ export declare function cellOf(input: SheetCellInput): SheetCell | undefined;
351
+ /** The value of a cell as written in the data. */
352
+ export declare function valueOf(input: SheetCellInput): SheetValue;
353
+ /** Whether a cell has no value (it may still have a style). */
354
+ export declare const isBlank: (input: SheetCellInput) => boolean;
355
+ /** The shortest way to write a cell: a bare value when that is all it has. */
356
+ export declare function compactCell(cell: SheetCell | undefined): SheetCellInput;
357
+ /** The cell at a row and column. */
358
+ export declare const cellAt: (sheet: SheetData, row: number, col: number) => SheetCellInput;
359
+ /** How many rows a sheet has, counting its data. */
360
+ export declare const rowCountOf: (sheet: SheetData) => number;
361
+ /** How many columns a sheet has, counting its widest row. */
362
+ export declare function colCountOf(sheet: SheetData): number;
363
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { SheetPoint } from './address';
2
+ import type { SheetAxis } from './axis';
3
+ /** One step from `index` along an axis, skipping hidden rows or columns; stays put at the edge. */
4
+ export declare function stepIndex(axis: SheetAxis, index: number, step: 1 | -1): number;
5
+ /**
6
+ * Where `mod` + an arrow goes: to the edge of the block of filled cells the
7
+ * cell is in, or on to the next filled cell, or to the sheet's edge.
8
+ */
9
+ export declare function edgeIndex(axis: SheetAxis, index: number, step: 1 | -1, filled: (index: number) => boolean): number;
10
+ export type SheetDirection = 'up' | 'down' | 'left' | 'right';
11
+ /** A point moved one cell, or to the data edge with `jump`. */
12
+ export declare function movePoint(point: SheetPoint, direction: SheetDirection, axes: {
13
+ rows: SheetAxis;
14
+ cols: SheetAxis;
15
+ }, filled: (row: number, col: number) => boolean, jump?: boolean): SheetPoint;
@@ -0,0 +1,19 @@
1
+ import type { SheetStyle } from './model';
2
+ /**
3
+ * The text color that reads on a background of a set color, whatever the
4
+ * page's theme: dark on light backgrounds, light on dark ones. `undefined`
5
+ * for a color it can't work out, such as a theme variable, which follows
6
+ * the theme along with the text.
7
+ */
8
+ export declare function textOn(background: string): string | undefined;
9
+ /**
10
+ * A color as the light theme paints it, as `#rrggbb` where it can be
11
+ * worked out: theme variables and `color-mix(in oklab, …)` of them. Other
12
+ * colors, such as `red`, are given back as they are.
13
+ */
14
+ export declare function lightThemeColor(css: string): string;
15
+ /**
16
+ * A style with its `tone` and `fill` as the colors they are in the light
17
+ * theme, in `color` and `background`, and every color plain.
18
+ */
19
+ export declare function plainStyle(style: SheetStyle): SheetStyle;
@@ -0,0 +1,6 @@
1
+ import { type SheetCellType } from './cell-type';
2
+ /**
3
+ * The built-in types without what they draw or edit with, so files can be
4
+ * read and written where there is no page, such as in a Worker.
5
+ */
6
+ export declare const plainCellTypes: readonly SheetCellType[];
@@ -0,0 +1,34 @@
1
+ import { type SheetCellInput, type SheetData, type SheetProtection, type SheetWorkbook } from './model';
2
+ import { SheetTransaction } from './transaction';
3
+ /** Why a change to a protected sheet or workbook isn't allowed. */
4
+ export type SheetProtectionRefusal =
5
+ /** It changes what a locked cell holds. */
6
+ 'cell'
7
+ /** It changes the look or number format of a locked cell, or merges cells. */
8
+ | 'format'
9
+ /** It locks or unlocks cells. */
10
+ | 'lock' | 'formatRows' | 'formatColumns' | 'insertRows' | 'insertColumns' | 'deleteRows' | 'deleteColumns' | 'filter'
11
+ /** It changes the sheet's rules, groups or other settings. */
12
+ | 'sheet'
13
+ /** It adds, removes, moves or renames a sheet of a protected workbook. */
14
+ | 'structure';
15
+ /** What a refused change runs into: the reason, the sheet and, for a cell, where it is. */
16
+ export interface SheetProtectionCheck {
17
+ reason: SheetProtectionRefusal;
18
+ /** The sheet's key. */
19
+ sheet?: string;
20
+ row?: number;
21
+ col?: number;
22
+ }
23
+ /** A sheet's protection, `null` when it isn't protected. */
24
+ export declare function protectionOf(sheet: SheetData | undefined): SheetProtection | null;
25
+ /** Whether a cell is locked: unless its style says `locked: false`. Takes a cell as `cells` hold it. */
26
+ export declare function isLocked(cell: SheetCellInput, book: SheetWorkbook): boolean;
27
+ /** Whether anything in the workbook is protected, so changes need checking. */
28
+ export declare function hasProtection(book: SheetWorkbook): boolean;
29
+ /**
30
+ * Checks a change against the protection of the workbook it started from,
31
+ * step by step, so each step meets the cells as they were when it ran. Gives
32
+ * the first thing that isn't allowed, or `null` when all of it is.
33
+ */
34
+ export declare function checkProtection(tr: SheetTransaction): SheetProtectionCheck | null;
@@ -0,0 +1,25 @@
1
+ import { type SheetPoint, type SheetRange } from './address';
2
+ /**
3
+ * What is selected on a sheet: one or more ranges, and the cell the
4
+ * keyboard is on, which is inside the last range.
5
+ */
6
+ export interface SheetSelection {
7
+ active: SheetPoint;
8
+ ranges: SheetRange[];
9
+ }
10
+ /** One cell selected. */
11
+ export declare const selectCell: (point: SheetPoint) => SheetSelection;
12
+ /** Whether a cell is in any of the selected ranges. */
13
+ export declare function isSelected(selection: SheetSelection, row: number, col: number): boolean;
14
+ /** Keeps a point inside a sheet of `rows` × `cols`. */
15
+ export declare const clampPoint: (point: SheetPoint, rows: number, cols: number) => SheetPoint;
16
+ /** The selection kept inside a sheet of `rows` × `cols`, e.g. after it shrank. */
17
+ export declare function clampSelection(selection: SheetSelection, rows: number, cols: number): {
18
+ active: SheetPoint;
19
+ ranges: {
20
+ start: SheetPoint;
21
+ end: SheetPoint;
22
+ }[];
23
+ };
24
+ export declare const samePoint: (a: SheetPoint, b: SheetPoint) => boolean;
25
+ export declare function sameSelection(a: SheetSelection, b: SheetSelection): boolean;