@rowsncolumns/spreadsheet 10.2.74 → 10.2.76

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 (280) hide show
  1. package/dist/cjs/api/excel-validation-kinds.d.ts +71 -0
  2. package/dist/cjs/api/excel-validation-kinds.d.ts.map +1 -0
  3. package/dist/cjs/api/excel-validation-kinds.js +304 -0
  4. package/dist/cjs/api/fill-series.d.ts +38 -0
  5. package/dist/cjs/api/fill-series.d.ts.map +1 -0
  6. package/dist/cjs/api/fill-series.js +89 -0
  7. package/dist/cjs/api/go-to-special.d.ts +32 -0
  8. package/dist/cjs/api/go-to-special.d.ts.map +1 -0
  9. package/dist/cjs/api/go-to-special.js +111 -0
  10. package/dist/cjs/api/spreadsheet-api.d.ts +6 -2
  11. package/dist/cjs/api/spreadsheet-api.d.ts.map +1 -1
  12. package/dist/cjs/api/spreadsheet-api.js +9 -3
  13. package/dist/cjs/api/validation-tooltip.d.ts +17 -0
  14. package/dist/cjs/api/validation-tooltip.d.ts.map +1 -0
  15. package/dist/cjs/api/validation-tooltip.js +42 -0
  16. package/dist/cjs/atoms/advanced-filter-dialog.atom.d.ts +28 -0
  17. package/dist/cjs/atoms/advanced-filter-dialog.atom.d.ts.map +1 -0
  18. package/dist/cjs/atoms/advanced-filter-dialog.atom.js +32 -0
  19. package/dist/cjs/atoms/fill-options.atom.d.ts +36 -0
  20. package/dist/cjs/atoms/fill-options.atom.d.ts.map +1 -0
  21. package/dist/cjs/atoms/fill-options.atom.js +11 -0
  22. package/dist/cjs/atoms/fill-series-dialog.atom.d.ts +26 -0
  23. package/dist/cjs/atoms/fill-series-dialog.atom.d.ts.map +1 -0
  24. package/dist/cjs/atoms/fill-series-dialog.atom.js +14 -0
  25. package/dist/cjs/atoms/go-to-dialog.atom.d.ts +11 -1
  26. package/dist/cjs/atoms/go-to-dialog.atom.d.ts.map +1 -1
  27. package/dist/cjs/atoms/goal-seek-dialog.atom.d.ts +29 -0
  28. package/dist/cjs/atoms/goal-seek-dialog.atom.d.ts.map +1 -0
  29. package/dist/cjs/atoms/goal-seek-dialog.atom.js +30 -0
  30. package/dist/cjs/atoms/index.d.ts +3 -0
  31. package/dist/cjs/atoms/index.d.ts.map +1 -1
  32. package/dist/cjs/atoms/index.js +3 -0
  33. package/dist/cjs/atoms/subtotal-dialog.atom.d.ts +39 -0
  34. package/dist/cjs/atoms/subtotal-dialog.atom.d.ts.map +1 -0
  35. package/dist/cjs/atoms/subtotal-dialog.atom.js +30 -0
  36. package/dist/cjs/atoms/text-to-columns-dialog.atom.d.ts +34 -0
  37. package/dist/cjs/atoms/text-to-columns-dialog.atom.d.ts.map +1 -0
  38. package/dist/cjs/atoms/text-to-columns-dialog.atom.js +36 -0
  39. package/dist/cjs/atoms/watch-window.atom.d.ts +37 -0
  40. package/dist/cjs/atoms/watch-window.atom.d.ts.map +1 -0
  41. package/dist/cjs/atoms/watch-window.atom.js +61 -0
  42. package/dist/cjs/components/advanced-filter-dialog/index.d.ts +28 -0
  43. package/dist/cjs/components/advanced-filter-dialog/index.d.ts.map +1 -0
  44. package/dist/cjs/components/advanced-filter-dialog/index.js +134 -0
  45. package/dist/cjs/components/calculation-options-dialog/index.d.ts +33 -0
  46. package/dist/cjs/components/calculation-options-dialog/index.d.ts.map +1 -0
  47. package/dist/cjs/components/calculation-options-dialog/index.js +69 -0
  48. package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
  49. package/dist/cjs/components/canvas-grid/index.js +328 -71
  50. package/dist/cjs/components/canvas-grid/typings.d.ts +31 -5
  51. package/dist/cjs/components/canvas-grid/typings.d.ts.map +1 -1
  52. package/dist/cjs/components/cell/alignment.d.ts +30 -0
  53. package/dist/cjs/components/cell/alignment.d.ts.map +1 -1
  54. package/dist/cjs/components/cell/alignment.js +56 -1
  55. package/dist/cjs/components/cell/index.d.ts.map +1 -1
  56. package/dist/cjs/components/cell/index.js +15 -7
  57. package/dist/cjs/components/cell-diff/index.d.ts +3 -2
  58. package/dist/cjs/components/cell-diff/index.d.ts.map +1 -1
  59. package/dist/cjs/components/cell-editor/helpers.d.ts +9 -0
  60. package/dist/cjs/components/cell-editor/helpers.d.ts.map +1 -1
  61. package/dist/cjs/components/cell-editor/helpers.js +8 -1
  62. package/dist/cjs/components/cell-editor/helpers.spec.js +14 -0
  63. package/dist/cjs/components/cell-editor/index.d.ts.map +1 -1
  64. package/dist/cjs/components/cell-editor/index.js +7 -3
  65. package/dist/cjs/components/context-menu/index.d.ts +6 -1
  66. package/dist/cjs/components/context-menu/index.d.ts.map +1 -1
  67. package/dist/cjs/components/context-menu/index.js +146 -3
  68. package/dist/cjs/components/embeds/embed-component.d.ts.map +1 -1
  69. package/dist/cjs/components/embeds/embed-component.js +16 -1
  70. package/dist/cjs/components/fill-series-dialog/index.d.ts +29 -0
  71. package/dist/cjs/components/fill-series-dialog/index.d.ts.map +1 -0
  72. package/dist/cjs/components/fill-series-dialog/index.js +156 -0
  73. package/dist/cjs/components/go-to-dialog/index.d.ts +11 -1
  74. package/dist/cjs/components/go-to-dialog/index.d.ts.map +1 -1
  75. package/dist/cjs/components/go-to-dialog/index.js +67 -24
  76. package/dist/cjs/components/goal-seek-dialog/index.d.ts +32 -0
  77. package/dist/cjs/components/goal-seek-dialog/index.d.ts.map +1 -0
  78. package/dist/cjs/components/goal-seek-dialog/index.js +149 -0
  79. package/dist/cjs/components/selection/fill-options-menu.d.ts +32 -0
  80. package/dist/cjs/components/selection/fill-options-menu.d.ts.map +1 -0
  81. package/dist/cjs/components/selection/fill-options-menu.js +65 -0
  82. package/dist/cjs/components/selection/index.d.ts +1 -1
  83. package/dist/cjs/components/selection/index.d.ts.map +1 -1
  84. package/dist/cjs/components/selection/index.js +4 -2
  85. package/dist/cjs/components/selection/types.d.ts +11 -1
  86. package/dist/cjs/components/selection/types.d.ts.map +1 -1
  87. package/dist/cjs/components/subtotal-dialog/index.d.ts +30 -0
  88. package/dist/cjs/components/subtotal-dialog/index.d.ts.map +1 -0
  89. package/dist/cjs/components/subtotal-dialog/index.js +126 -0
  90. package/dist/cjs/components/text-to-columns-dialog/index.d.ts +37 -0
  91. package/dist/cjs/components/text-to-columns-dialog/index.d.ts.map +1 -0
  92. package/dist/cjs/components/text-to-columns-dialog/index.js +166 -0
  93. package/dist/cjs/components/toolbar/background-color-selector.d.ts +13 -1
  94. package/dist/cjs/components/toolbar/background-color-selector.d.ts.map +1 -1
  95. package/dist/cjs/components/toolbar/background-color-selector.js +57 -11
  96. package/dist/cjs/components/toolbar/cell-style-selector.d.ts +15 -2
  97. package/dist/cjs/components/toolbar/cell-style-selector.d.ts.map +1 -1
  98. package/dist/cjs/components/toolbar/cell-style-selector.js +56 -3
  99. package/dist/cjs/components/toolbar/fill-selectors.d.ts +49 -0
  100. package/dist/cjs/components/toolbar/fill-selectors.d.ts.map +1 -0
  101. package/dist/cjs/components/toolbar/fill-selectors.js +196 -0
  102. package/dist/cjs/components/toolbar/index.d.ts +1 -0
  103. package/dist/cjs/components/toolbar/index.d.ts.map +1 -1
  104. package/dist/cjs/components/toolbar/index.js +1 -0
  105. package/dist/cjs/components/toolbar/text-format-selector.d.ts +9 -0
  106. package/dist/cjs/components/toolbar/text-format-selector.d.ts.map +1 -1
  107. package/dist/cjs/components/toolbar/text-format-selector.js +15 -3
  108. package/dist/cjs/components/toolbar/text-horizontal-align-selector.d.ts +8 -0
  109. package/dist/cjs/components/toolbar/text-horizontal-align-selector.d.ts.map +1 -1
  110. package/dist/cjs/components/toolbar/text-horizontal-align-selector.js +23 -4
  111. package/dist/cjs/components/watch-window/index.d.ts +25 -0
  112. package/dist/cjs/components/watch-window/index.d.ts.map +1 -0
  113. package/dist/cjs/components/watch-window/index.js +63 -0
  114. package/dist/cjs/hooks/use-cell-renderer.d.ts.map +1 -1
  115. package/dist/cjs/hooks/use-cell-renderer.js +17 -6
  116. package/dist/cjs/hooks/use-editable.d.ts +11 -2
  117. package/dist/cjs/hooks/use-editable.d.ts.map +1 -1
  118. package/dist/cjs/hooks/use-editable.js +8 -0
  119. package/dist/cjs/hooks/use-editor-submit.d.ts +32 -3
  120. package/dist/cjs/hooks/use-editor-submit.d.ts.map +1 -1
  121. package/dist/cjs/hooks/use-editor-submit.js +111 -2
  122. package/dist/cjs/hooks/use-get-tooltip.d.ts.map +1 -1
  123. package/dist/cjs/hooks/use-get-tooltip.js +7 -2
  124. package/dist/cjs/hooks/use-keyboard-handler.d.ts.map +1 -1
  125. package/dist/cjs/hooks/use-keyboard-handler.js +27 -14
  126. package/dist/cjs/hooks/use-selection-renderer.d.ts +13 -2
  127. package/dist/cjs/hooks/use-selection-renderer.d.ts.map +1 -1
  128. package/dist/cjs/hooks/use-selection-renderer.js +21 -4
  129. package/dist/cjs/hooks/use-selection.d.ts +54 -4
  130. package/dist/cjs/hooks/use-selection.d.ts.map +1 -1
  131. package/dist/cjs/hooks/use-selection.js +232 -37
  132. package/dist/cjs/index.d.ts +12 -0
  133. package/dist/cjs/index.d.ts.map +1 -1
  134. package/dist/cjs/index.js +11 -0
  135. package/dist/cjs/release-date.js +1 -1
  136. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  137. package/dist/cjs/types.d.ts +156 -5
  138. package/dist/cjs/types.d.ts.map +1 -1
  139. package/dist/cjs/types.js +19 -1
  140. package/dist/esm/api/excel-validation-kinds.d.ts +71 -0
  141. package/dist/esm/api/excel-validation-kinds.d.ts.map +1 -0
  142. package/dist/esm/api/excel-validation-kinds.js +287 -0
  143. package/dist/esm/api/fill-series.d.ts +38 -0
  144. package/dist/esm/api/fill-series.d.ts.map +1 -0
  145. package/dist/esm/api/fill-series.js +78 -0
  146. package/dist/esm/api/go-to-special.d.ts +32 -0
  147. package/dist/esm/api/go-to-special.d.ts.map +1 -0
  148. package/dist/esm/api/go-to-special.js +96 -0
  149. package/dist/esm/api/spreadsheet-api.d.ts +6 -2
  150. package/dist/esm/api/spreadsheet-api.d.ts.map +1 -1
  151. package/dist/esm/api/spreadsheet-api.js +8 -3
  152. package/dist/esm/api/validation-tooltip.d.ts +17 -0
  153. package/dist/esm/api/validation-tooltip.d.ts.map +1 -0
  154. package/dist/esm/api/validation-tooltip.js +34 -0
  155. package/dist/esm/atoms/advanced-filter-dialog.atom.d.ts +28 -0
  156. package/dist/esm/atoms/advanced-filter-dialog.atom.d.ts.map +1 -0
  157. package/dist/esm/atoms/advanced-filter-dialog.atom.js +21 -0
  158. package/dist/esm/atoms/fill-options.atom.d.ts +36 -0
  159. package/dist/esm/atoms/fill-options.atom.d.ts.map +1 -0
  160. package/dist/esm/atoms/fill-options.atom.js +5 -0
  161. package/dist/esm/atoms/fill-series-dialog.atom.d.ts +26 -0
  162. package/dist/esm/atoms/fill-series-dialog.atom.d.ts.map +1 -0
  163. package/dist/esm/atoms/fill-series-dialog.atom.js +9 -0
  164. package/dist/esm/atoms/go-to-dialog.atom.d.ts +11 -1
  165. package/dist/esm/atoms/go-to-dialog.atom.d.ts.map +1 -1
  166. package/dist/esm/atoms/goal-seek-dialog.atom.d.ts +29 -0
  167. package/dist/esm/atoms/goal-seek-dialog.atom.d.ts.map +1 -0
  168. package/dist/esm/atoms/goal-seek-dialog.atom.js +21 -0
  169. package/dist/esm/atoms/index.d.ts +3 -0
  170. package/dist/esm/atoms/index.d.ts.map +1 -1
  171. package/dist/esm/atoms/index.js +3 -0
  172. package/dist/esm/atoms/subtotal-dialog.atom.d.ts +39 -0
  173. package/dist/esm/atoms/subtotal-dialog.atom.d.ts.map +1 -0
  174. package/dist/esm/atoms/subtotal-dialog.atom.js +21 -0
  175. package/dist/esm/atoms/text-to-columns-dialog.atom.d.ts +34 -0
  176. package/dist/esm/atoms/text-to-columns-dialog.atom.d.ts.map +1 -0
  177. package/dist/esm/atoms/text-to-columns-dialog.atom.js +25 -0
  178. package/dist/esm/atoms/watch-window.atom.d.ts +37 -0
  179. package/dist/esm/atoms/watch-window.atom.d.ts.map +1 -0
  180. package/dist/esm/atoms/watch-window.atom.js +37 -0
  181. package/dist/esm/components/advanced-filter-dialog/index.d.ts +28 -0
  182. package/dist/esm/components/advanced-filter-dialog/index.d.ts.map +1 -0
  183. package/dist/esm/components/advanced-filter-dialog/index.js +125 -0
  184. package/dist/esm/components/calculation-options-dialog/index.d.ts +33 -0
  185. package/dist/esm/components/calculation-options-dialog/index.d.ts.map +1 -0
  186. package/dist/esm/components/calculation-options-dialog/index.js +61 -0
  187. package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
  188. package/dist/esm/components/canvas-grid/index.js +266 -26
  189. package/dist/esm/components/canvas-grid/typings.d.ts +31 -5
  190. package/dist/esm/components/canvas-grid/typings.d.ts.map +1 -1
  191. package/dist/esm/components/cell/alignment.d.ts +30 -0
  192. package/dist/esm/components/cell/alignment.d.ts.map +1 -1
  193. package/dist/esm/components/cell/alignment.js +51 -0
  194. package/dist/esm/components/cell/index.d.ts.map +1 -1
  195. package/dist/esm/components/cell/index.js +16 -8
  196. package/dist/esm/components/cell-diff/index.d.ts +3 -2
  197. package/dist/esm/components/cell-diff/index.d.ts.map +1 -1
  198. package/dist/esm/components/cell-editor/helpers.d.ts +9 -0
  199. package/dist/esm/components/cell-editor/helpers.d.ts.map +1 -1
  200. package/dist/esm/components/cell-editor/helpers.js +6 -0
  201. package/dist/esm/components/cell-editor/helpers.spec.js +15 -1
  202. package/dist/esm/components/cell-editor/index.d.ts.map +1 -1
  203. package/dist/esm/components/cell-editor/index.js +8 -4
  204. package/dist/esm/components/context-menu/index.d.ts +6 -1
  205. package/dist/esm/components/context-menu/index.d.ts.map +1 -1
  206. package/dist/esm/components/context-menu/index.js +139 -4
  207. package/dist/esm/components/embeds/embed-component.d.ts.map +1 -1
  208. package/dist/esm/components/embeds/embed-component.js +17 -1
  209. package/dist/esm/components/fill-series-dialog/index.d.ts +29 -0
  210. package/dist/esm/components/fill-series-dialog/index.d.ts.map +1 -0
  211. package/dist/esm/components/fill-series-dialog/index.js +151 -0
  212. package/dist/esm/components/go-to-dialog/index.d.ts +11 -1
  213. package/dist/esm/components/go-to-dialog/index.d.ts.map +1 -1
  214. package/dist/esm/components/go-to-dialog/index.js +63 -23
  215. package/dist/esm/components/goal-seek-dialog/index.d.ts +32 -0
  216. package/dist/esm/components/goal-seek-dialog/index.d.ts.map +1 -0
  217. package/dist/esm/components/goal-seek-dialog/index.js +125 -0
  218. package/dist/esm/components/selection/fill-options-menu.d.ts +32 -0
  219. package/dist/esm/components/selection/fill-options-menu.d.ts.map +1 -0
  220. package/dist/esm/components/selection/fill-options-menu.js +63 -0
  221. package/dist/esm/components/selection/index.d.ts +1 -1
  222. package/dist/esm/components/selection/index.d.ts.map +1 -1
  223. package/dist/esm/components/selection/index.js +4 -2
  224. package/dist/esm/components/selection/types.d.ts +11 -1
  225. package/dist/esm/components/selection/types.d.ts.map +1 -1
  226. package/dist/esm/components/subtotal-dialog/index.d.ts +30 -0
  227. package/dist/esm/components/subtotal-dialog/index.d.ts.map +1 -0
  228. package/dist/esm/components/subtotal-dialog/index.js +115 -0
  229. package/dist/esm/components/text-to-columns-dialog/index.d.ts +37 -0
  230. package/dist/esm/components/text-to-columns-dialog/index.d.ts.map +1 -0
  231. package/dist/esm/components/text-to-columns-dialog/index.js +147 -0
  232. package/dist/esm/components/toolbar/background-color-selector.d.ts +13 -1
  233. package/dist/esm/components/toolbar/background-color-selector.d.ts.map +1 -1
  234. package/dist/esm/components/toolbar/background-color-selector.js +61 -11
  235. package/dist/esm/components/toolbar/cell-style-selector.d.ts +15 -2
  236. package/dist/esm/components/toolbar/cell-style-selector.d.ts.map +1 -1
  237. package/dist/esm/components/toolbar/cell-style-selector.js +46 -2
  238. package/dist/esm/components/toolbar/fill-selectors.d.ts +49 -0
  239. package/dist/esm/components/toolbar/fill-selectors.d.ts.map +1 -0
  240. package/dist/esm/components/toolbar/fill-selectors.js +162 -0
  241. package/dist/esm/components/toolbar/index.d.ts +1 -0
  242. package/dist/esm/components/toolbar/index.d.ts.map +1 -1
  243. package/dist/esm/components/toolbar/index.js +1 -0
  244. package/dist/esm/components/toolbar/text-format-selector.d.ts +9 -0
  245. package/dist/esm/components/toolbar/text-format-selector.d.ts.map +1 -1
  246. package/dist/esm/components/toolbar/text-format-selector.js +14 -2
  247. package/dist/esm/components/toolbar/text-horizontal-align-selector.d.ts +8 -0
  248. package/dist/esm/components/toolbar/text-horizontal-align-selector.d.ts.map +1 -1
  249. package/dist/esm/components/toolbar/text-horizontal-align-selector.js +21 -5
  250. package/dist/esm/components/watch-window/index.d.ts +25 -0
  251. package/dist/esm/components/watch-window/index.d.ts.map +1 -0
  252. package/dist/esm/components/watch-window/index.js +54 -0
  253. package/dist/esm/hooks/use-cell-renderer.d.ts.map +1 -1
  254. package/dist/esm/hooks/use-cell-renderer.js +17 -6
  255. package/dist/esm/hooks/use-editable.d.ts +11 -2
  256. package/dist/esm/hooks/use-editable.d.ts.map +1 -1
  257. package/dist/esm/hooks/use-editable.js +8 -0
  258. package/dist/esm/hooks/use-editor-submit.d.ts +32 -3
  259. package/dist/esm/hooks/use-editor-submit.d.ts.map +1 -1
  260. package/dist/esm/hooks/use-editor-submit.js +82 -3
  261. package/dist/esm/hooks/use-get-tooltip.d.ts.map +1 -1
  262. package/dist/esm/hooks/use-get-tooltip.js +7 -2
  263. package/dist/esm/hooks/use-keyboard-handler.d.ts.map +1 -1
  264. package/dist/esm/hooks/use-keyboard-handler.js +27 -14
  265. package/dist/esm/hooks/use-selection-renderer.d.ts +13 -2
  266. package/dist/esm/hooks/use-selection-renderer.d.ts.map +1 -1
  267. package/dist/esm/hooks/use-selection-renderer.js +22 -5
  268. package/dist/esm/hooks/use-selection.d.ts +54 -4
  269. package/dist/esm/hooks/use-selection.d.ts.map +1 -1
  270. package/dist/esm/hooks/use-selection.js +220 -36
  271. package/dist/esm/index.d.ts +12 -0
  272. package/dist/esm/index.d.ts.map +1 -1
  273. package/dist/esm/index.js +11 -0
  274. package/dist/esm/release-date.js +1 -1
  275. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  276. package/dist/esm/types.d.ts +156 -5
  277. package/dist/esm/types.d.ts.map +1 -1
  278. package/dist/esm/types.js +18 -0
  279. package/dist/spreadsheet.min.css +1 -1
  280. package/package.json +7 -7
@@ -0,0 +1,71 @@
1
+ import type { DataValidationRule, SheetRange } from "../types";
2
+ /**
3
+ * Excel's data-validation "Allow" kinds that have no `ConditionType` of
4
+ * their own. Each is authored as Excel's `type` + `operator` + up to two
5
+ * formulas and stored two ways at once:
6
+ *
7
+ * - `condition` — what both engines evaluate for the red Invalid marker:
8
+ * `whole` and `textLength` compose a `CUSTOM_FORMULA` over the range
9
+ * anchor (the same shape both importers synthesize), `time` is a plain
10
+ * `NUMBER_*` comparison over day-fraction serials;
11
+ * - `xlsxSource` — the Excel-native description both xlsx exporters replay
12
+ * verbatim (`type="whole"` …), so the rule round-trips as what the user
13
+ * picked instead of a decimal / custom rule.
14
+ *
15
+ * Imported rules already carry `xlsxSource`, so the editor reads them back
16
+ * as "Whole number between 1 and 10" rather than a custom formula.
17
+ */
18
+ export type ExcelValidationKind = "whole" | "time" | "textLength";
19
+ export type ExcelValidationOperator = "between" | "notBetween" | "equal" | "notEqual" | "greaterThan" | "lessThan" | "greaterThanOrEqual" | "lessThanOrEqual";
20
+ export type ExcelValidationSpec = {
21
+ kind: ExcelValidationKind;
22
+ operator: ExcelValidationOperator;
23
+ /** Bound(s) as the user typed them: a literal (`10`, `9:30 AM`) or `=ref`. */
24
+ formula1?: string;
25
+ formula2?: string;
26
+ };
27
+ export declare const EXCEL_VALIDATION_KIND_LABELS: ReadonlyArray<{
28
+ kind: ExcelValidationKind;
29
+ label: string;
30
+ }>;
31
+ export declare const EXCEL_VALIDATION_OPERATOR_LABELS: ReadonlyArray<{
32
+ operator: ExcelValidationOperator;
33
+ label: string;
34
+ }>;
35
+ /** Two-sided operators need both bounds. */
36
+ export declare const isTwoSidedOperator: (operator: ExcelValidationOperator) => operator is "between" | "notBetween";
37
+ /**
38
+ * Parse a typed time (`9:30`, `9:30 AM`, `21:05:10`, `24:00`, `0.5`) to
39
+ * Excel's serial. A bare non-negative number is taken as a serial already and
40
+ * kept whole (Excel's Time validation compares the full serial, so a
41
+ * date-time is out of a same-day range). `undefined` when unparsable.
42
+ */
43
+ export declare const parseTimeToSerial: (text: string | undefined) => number | undefined;
44
+ /** Render a day-fraction serial as `h:mm AM/PM` (seconds when non-zero). */
45
+ export declare const formatTimeSerial: (serial: number) => string;
46
+ /** The A1 anchor (range top-left) a relative custom formula is written against. */
47
+ export declare const getValidationAnchor: (range: SheetRange | undefined) => string;
48
+ /**
49
+ * Build the `condition` + `xlsxSource` pair for an Excel kind. Returns
50
+ * `undefined` when a required bound is missing (the editor keeps the form
51
+ * open in that case).
52
+ */
53
+ export declare const buildExcelValidationRule: (spec: ExcelValidationSpec, anchor: string) => Pick<DataValidationRule, "condition" | "xlsxSource"> | undefined;
54
+ /**
55
+ * Read an Excel kind back from a rule's `xlsxSource` (imported or authored
56
+ * here); `undefined` for every other rule. Time bounds come back as
57
+ * `h:mm AM/PM` text so the editor shows what the user would type.
58
+ */
59
+ export declare const readExcelValidationSpec: (rule: Pick<DataValidationRule, "xlsxSource"> | undefined | null) => ExcelValidationSpec | undefined;
60
+ /** A typed value that is a formula (`=…`) — validated on its result, not its text. */
61
+ export declare const isFormulaEntry: (value: unknown) => value is string;
62
+ /**
63
+ * Decide an Excel-kind rule for a freshly typed value without the
64
+ * calculator — the commit-time enforcement Excel applies (`stop` blocks a
65
+ * decimal in a whole-number cell). `undefined` when the bounds are
66
+ * formulas / references, or when the typed value is itself a formula
67
+ * (Excel validates the formula's RESULT after the recalc, so `=5` is a
68
+ * valid whole number), so the caller falls back to the flag-only marker.
69
+ */
70
+ export declare const checkExcelValidationValue: (rule: Pick<DataValidationRule, "xlsxSource"> | undefined | null, value: string | boolean) => boolean | undefined;
71
+ //# sourceMappingURL=excel-validation-kinds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"excel-validation-kinds.d.ts","sourceRoot":"","sources":["../../../api/excel-validation-kinds.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,kBAAkB,EAClB,UAAU,EACX,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,MAAM,GAAG,YAAY,CAAC;AAElE,MAAM,MAAM,uBAAuB,GAC/B,SAAS,GACT,YAAY,GACZ,OAAO,GACP,UAAU,GACV,aAAa,GACb,UAAU,GACV,oBAAoB,GACpB,iBAAiB,CAAC;AAEtB,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,uBAAuB,CAAC;IAClC,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,aAAa,CAAC;IACvD,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf,CAIA,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,aAAa,CAAC;IAC3D,QAAQ,EAAE,uBAAuB,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;CACf,CASA,CAAC;AAOF,4CAA4C;AAC5C,eAAO,MAAM,kBAAkB,GAAI,UAAU,uBAAuB,yCACf,CAAC;AAwBtD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,GAAG,SAAS,KACvB,MAAM,GAAG,SAuBX,CAAC;AAEF,4EAA4E;AAC5E,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,MAUjD,CAAC;AAoBF,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,GAAI,OAAO,UAAU,GAAG,SAAS,KAAG,MAKzD,CAAC;AAgCZ;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACnC,MAAM,mBAAmB,EACzB,QAAQ,MAAM,KACb,IAAI,CAAC,kBAAkB,EAAE,WAAW,GAAG,YAAY,CAAC,GAAG,SAiDzD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,MAAM,IAAI,CAAC,kBAAkB,EAAE,YAAY,CAAC,GAAG,SAAS,GAAG,IAAI,KAC9D,mBAAmB,GAAG,SAuBxB,CAAC;AAmCF,sFAAsF;AACtF,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MACE,CAAC;AAE5D;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,GACpC,MAAM,IAAI,CAAC,kBAAkB,EAAE,YAAY,CAAC,GAAG,SAAS,GAAG,IAAI,EAC/D,OAAO,MAAM,GAAG,OAAO,KACtB,OAAO,GAAG,SAmCZ,CAAC"}
@@ -0,0 +1,304 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkExcelValidationValue = exports.isFormulaEntry = exports.readExcelValidationSpec = exports.buildExcelValidationRule = exports.getValidationAnchor = exports.formatTimeSerial = exports.parseTimeToSerial = exports.isTwoSidedOperator = exports.EXCEL_VALIDATION_OPERATOR_LABELS = exports.EXCEL_VALIDATION_KIND_LABELS = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var utils_1 = require("@rowsncolumns/utils");
6
+ exports.EXCEL_VALIDATION_KIND_LABELS = [
7
+ { kind: "whole", label: "Whole number" },
8
+ { kind: "time", label: "Time" },
9
+ { kind: "textLength", label: "Text length" },
10
+ ];
11
+ exports.EXCEL_VALIDATION_OPERATOR_LABELS = [
12
+ { operator: "between", label: "between" },
13
+ { operator: "notBetween", label: "not between" },
14
+ { operator: "equal", label: "equal to" },
15
+ { operator: "notEqual", label: "not equal to" },
16
+ { operator: "greaterThan", label: "greater than" },
17
+ { operator: "lessThan", label: "less than" },
18
+ { operator: "greaterThanOrEqual", label: "greater than or equal to" },
19
+ { operator: "lessThanOrEqual", label: "less than or equal to" },
20
+ ];
21
+ var EXCEL_KINDS = new Set(["whole", "time", "textLength"]);
22
+ var EXCEL_OPERATORS = new Set(exports.EXCEL_VALIDATION_OPERATOR_LABELS.map(function (entry) { return entry.operator; }));
23
+ /** Two-sided operators need both bounds. */
24
+ var isTwoSidedOperator = function (operator) {
25
+ return operator === "between" || operator === "notBetween";
26
+ };
27
+ exports.isTwoSidedOperator = isTwoSidedOperator;
28
+ var NUMBER_CONDITION_BY_OPERATOR = {
29
+ between: "NUMBER_BETWEEN",
30
+ notBetween: "NUMBER_NOT_BETWEEN",
31
+ equal: "NUMBER_EQ",
32
+ notEqual: "NUMBER_NOT_EQ",
33
+ greaterThan: "NUMBER_GREATER",
34
+ lessThan: "NUMBER_LESS",
35
+ greaterThanOrEqual: "NUMBER_GREATER_THAN_EQ",
36
+ lessThanOrEqual: "NUMBER_LESS_THAN_EQ",
37
+ };
38
+ var stripEquals = function (text) {
39
+ var _a;
40
+ var trimmed = (_a = text === null || text === void 0 ? void 0 : text.trim()) !== null && _a !== void 0 ? _a : "";
41
+ return trimmed.startsWith("=") ? trimmed.slice(1).trim() : trimmed;
42
+ };
43
+ var TIME_PATTERN = /^(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?\s*([AaPp][Mm]?)?$/;
44
+ /**
45
+ * Parse a typed time (`9:30`, `9:30 AM`, `21:05:10`, `24:00`, `0.5`) to
46
+ * Excel's serial. A bare non-negative number is taken as a serial already and
47
+ * kept whole (Excel's Time validation compares the full serial, so a
48
+ * date-time is out of a same-day range). `undefined` when unparsable.
49
+ */
50
+ var parseTimeToSerial = function (text) {
51
+ var _a, _b, _c, _d;
52
+ var trimmed = (_a = text === null || text === void 0 ? void 0 : text.trim()) !== null && _a !== void 0 ? _a : "";
53
+ if (!trimmed)
54
+ return undefined;
55
+ var asNumber = Number(trimmed);
56
+ if (Number.isFinite(asNumber)) {
57
+ return asNumber >= 0 ? asNumber : undefined;
58
+ }
59
+ var match = TIME_PATTERN.exec(trimmed);
60
+ if (!match)
61
+ return undefined;
62
+ var hours = Number(match[1]);
63
+ var minutes = Number((_b = match[2]) !== null && _b !== void 0 ? _b : 0);
64
+ var seconds = Number((_c = match[3]) !== null && _c !== void 0 ? _c : 0);
65
+ var meridiem = (_d = match[4]) === null || _d === void 0 ? void 0 : _d.toLowerCase();
66
+ if (minutes > 59 || seconds > 59)
67
+ return undefined;
68
+ if (meridiem) {
69
+ if (hours < 1 || hours > 12)
70
+ return undefined;
71
+ if (meridiem.startsWith("p") && hours !== 12)
72
+ hours += 12;
73
+ if (meridiem.startsWith("a") && hours === 12)
74
+ hours = 0;
75
+ }
76
+ else if (hours > 24 || (hours === 24 && (minutes > 0 || seconds > 0))) {
77
+ // Excel accepts `24:00` as exactly 1.0 (midnight at the end of the day).
78
+ return undefined;
79
+ }
80
+ return (hours * 3600 + minutes * 60 + seconds) / 86400;
81
+ };
82
+ exports.parseTimeToSerial = parseTimeToSerial;
83
+ /** Render a day-fraction serial as `h:mm AM/PM` (seconds when non-zero). */
84
+ var formatTimeSerial = function (serial) {
85
+ var total = Math.round((serial - Math.floor(serial)) * 86400) % 86400;
86
+ var hours24 = Math.floor(total / 3600);
87
+ var minutes = Math.floor((total % 3600) / 60);
88
+ var seconds = total % 60;
89
+ var meridiem = hours24 >= 12 ? "PM" : "AM";
90
+ var hours12 = hours24 % 12 === 0 ? 12 : hours24 % 12;
91
+ var mm = String(minutes).padStart(2, "0");
92
+ var ss = seconds ? ":".concat(String(seconds).padStart(2, "0")) : "";
93
+ return "".concat(hours12, ":").concat(mm).concat(ss, " ").concat(meridiem);
94
+ };
95
+ exports.formatTimeSerial = formatTimeSerial;
96
+ /**
97
+ * A bound as it goes into a formula / `xlsxSource`: references and formulas
98
+ * verbatim (no `=`), times as serials, numbers as typed.
99
+ */
100
+ var toBoundFormula = function (kind, text) {
101
+ var _a;
102
+ var raw = (_a = text === null || text === void 0 ? void 0 : text.trim()) !== null && _a !== void 0 ? _a : "";
103
+ if (!raw)
104
+ return undefined;
105
+ if (raw.startsWith("="))
106
+ return stripEquals(raw);
107
+ if (kind === "time") {
108
+ var serial = (0, exports.parseTimeToSerial)(raw);
109
+ return serial === undefined ? raw : String(serial);
110
+ }
111
+ return raw;
112
+ };
113
+ /** The A1 anchor (range top-left) a relative custom formula is written against. */
114
+ var getValidationAnchor = function (range) {
115
+ var _a;
116
+ return (_a = (0, utils_1.cellToAddress)(range
117
+ ? { rowIndex: range.startRowIndex, columnIndex: range.startColumnIndex }
118
+ : { rowIndex: 1, columnIndex: 1 })) !== null && _a !== void 0 ? _a : "A1";
119
+ };
120
+ exports.getValidationAnchor = getValidationAnchor;
121
+ var comparison = function (subject, operator, a, b) {
122
+ switch (operator) {
123
+ case "between":
124
+ return b === undefined
125
+ ? undefined
126
+ : "AND(".concat(subject, ">=").concat(a, ",").concat(subject, "<=").concat(b, ")");
127
+ case "notBetween":
128
+ return b === undefined
129
+ ? undefined
130
+ : "OR(".concat(subject, "<").concat(a, ",").concat(subject, ">").concat(b, ")");
131
+ case "equal":
132
+ return "".concat(subject, "=").concat(a);
133
+ case "notEqual":
134
+ return "".concat(subject, "<>").concat(a);
135
+ case "greaterThan":
136
+ return "".concat(subject, ">").concat(a);
137
+ case "lessThan":
138
+ return "".concat(subject, "<").concat(a);
139
+ case "greaterThanOrEqual":
140
+ return "".concat(subject, ">=").concat(a);
141
+ case "lessThanOrEqual":
142
+ return "".concat(subject, "<=").concat(a);
143
+ }
144
+ };
145
+ /**
146
+ * Build the `condition` + `xlsxSource` pair for an Excel kind. Returns
147
+ * `undefined` when a required bound is missing (the editor keeps the form
148
+ * open in that case).
149
+ */
150
+ var buildExcelValidationRule = function (spec, anchor) {
151
+ var formula1 = toBoundFormula(spec.kind, spec.formula1);
152
+ var formula2 = toBoundFormula(spec.kind, spec.formula2);
153
+ if (!formula1)
154
+ return undefined;
155
+ if ((0, exports.isTwoSidedOperator)(spec.operator) && !formula2)
156
+ return undefined;
157
+ var xlsxSource = tslib_1.__assign({ type: spec.kind, operator: spec.operator, formula1: formula1 }, ((0, exports.isTwoSidedOperator)(spec.operator) ? { formula2: formula2 } : {}));
158
+ if (spec.kind === "time") {
159
+ var condition = {
160
+ type: NUMBER_CONDITION_BY_OPERATOR[spec.operator],
161
+ values: tslib_1.__spreadArray([
162
+ {
163
+ userEnteredValue: /^[A-Za-z$'!]/.test(formula1)
164
+ ? "=".concat(formula1)
165
+ : formula1,
166
+ }
167
+ ], tslib_1.__read(((0, exports.isTwoSidedOperator)(spec.operator) && formula2
168
+ ? [
169
+ {
170
+ userEnteredValue: /^[A-Za-z$'!]/.test(formula2)
171
+ ? "=".concat(formula2)
172
+ : formula2,
173
+ },
174
+ ]
175
+ : [])), false),
176
+ };
177
+ return { condition: condition, xlsxSource: xlsxSource };
178
+ }
179
+ var subject = spec.kind === "textLength" ? "LEN(".concat(anchor, ")") : anchor;
180
+ var body = comparison(subject, spec.operator, formula1, formula2);
181
+ if (!body)
182
+ return undefined;
183
+ var formula = spec.kind === "whole"
184
+ ? "=AND(ISNUMBER(".concat(anchor, "),").concat(anchor, "=INT(").concat(anchor, "),").concat(body, ")")
185
+ : "=".concat(body);
186
+ return {
187
+ condition: {
188
+ type: "CUSTOM_FORMULA",
189
+ values: [{ userEnteredValue: formula }],
190
+ },
191
+ xlsxSource: xlsxSource,
192
+ };
193
+ };
194
+ exports.buildExcelValidationRule = buildExcelValidationRule;
195
+ /**
196
+ * Read an Excel kind back from a rule's `xlsxSource` (imported or authored
197
+ * here); `undefined` for every other rule. Time bounds come back as
198
+ * `h:mm AM/PM` text so the editor shows what the user would type.
199
+ */
200
+ var readExcelValidationSpec = function (rule) {
201
+ var source = rule === null || rule === void 0 ? void 0 : rule.xlsxSource;
202
+ if (!source || !EXCEL_KINDS.has(source.type))
203
+ return undefined;
204
+ var operator = (source.operator && EXCEL_OPERATORS.has(source.operator)
205
+ ? source.operator
206
+ : "between");
207
+ var kind = source.type;
208
+ var display = function (formula) {
209
+ if (formula === undefined || formula === "")
210
+ return undefined;
211
+ var asNumber = Number(formula);
212
+ if (Number.isFinite(asNumber)) {
213
+ return kind === "time" ? (0, exports.formatTimeSerial)(asNumber) : formula;
214
+ }
215
+ return "=".concat(formula);
216
+ };
217
+ return {
218
+ kind: kind,
219
+ operator: operator,
220
+ formula1: display(source.formula1),
221
+ formula2: display(source.formula2),
222
+ };
223
+ };
224
+ exports.readExcelValidationSpec = readExcelValidationSpec;
225
+ var compare = function (subject, operator, a, b) {
226
+ switch (operator) {
227
+ case "between":
228
+ return (b !== undefined &&
229
+ subject >= Math.min(a, b) &&
230
+ subject <= Math.max(a, b));
231
+ case "notBetween":
232
+ return (b !== undefined &&
233
+ (subject < Math.min(a, b) || subject > Math.max(a, b)));
234
+ case "equal":
235
+ return subject === a;
236
+ case "notEqual":
237
+ return subject !== a;
238
+ case "greaterThan":
239
+ return subject > a;
240
+ case "lessThan":
241
+ return subject < a;
242
+ case "greaterThanOrEqual":
243
+ return subject >= a;
244
+ case "lessThanOrEqual":
245
+ return subject <= a;
246
+ }
247
+ };
248
+ /** A typed value that is a formula (`=…`) — validated on its result, not its text. */
249
+ var isFormulaEntry = function (value) {
250
+ return typeof value === "string" && value.trim().startsWith("=");
251
+ };
252
+ exports.isFormulaEntry = isFormulaEntry;
253
+ /**
254
+ * Decide an Excel-kind rule for a freshly typed value without the
255
+ * calculator — the commit-time enforcement Excel applies (`stop` blocks a
256
+ * decimal in a whole-number cell). `undefined` when the bounds are
257
+ * formulas / references, or when the typed value is itself a formula
258
+ * (Excel validates the formula's RESULT after the recalc, so `=5` is a
259
+ * valid whole number), so the caller falls back to the flag-only marker.
260
+ */
261
+ var checkExcelValidationValue = function (rule, value) {
262
+ var _a;
263
+ var source = rule === null || rule === void 0 ? void 0 : rule.xlsxSource;
264
+ if (!source || !EXCEL_KINDS.has(source.type))
265
+ return undefined;
266
+ if ((0, exports.isFormulaEntry)(value))
267
+ return undefined;
268
+ var operator = ((_a = source.operator) !== null && _a !== void 0 ? _a : "between");
269
+ if (!EXCEL_OPERATORS.has(operator))
270
+ return undefined;
271
+ var a = Number(source.formula1);
272
+ var b = source.formula2 === undefined ? undefined : Number(source.formula2);
273
+ if (!Number.isFinite(a))
274
+ return undefined;
275
+ if ((0, exports.isTwoSidedOperator)(operator) &&
276
+ !(b !== undefined && Number.isFinite(b))) {
277
+ return undefined;
278
+ }
279
+ var text = typeof value === "boolean" ? (value ? "TRUE" : "FALSE") : value;
280
+ switch (source.type) {
281
+ case "textLength":
282
+ return compare(Array.from(text).length, operator, a, b);
283
+ case "whole": {
284
+ if (typeof value === "boolean")
285
+ return false;
286
+ var num = Number(text.trim());
287
+ if (!Number.isFinite(num) || !Number.isInteger(num))
288
+ return false;
289
+ return compare(num, operator, a, b);
290
+ }
291
+ case "time": {
292
+ if (typeof value === "boolean")
293
+ return false;
294
+ // Excel compares the cell's full serial against the bounds (a
295
+ // date-time such as 45292.5 is NOT between 9:00 and 12:00) — the same
296
+ // comparison the composed `NUMBER_*` condition makes for the marker.
297
+ var serial = (0, exports.parseTimeToSerial)(text);
298
+ if (serial === undefined)
299
+ return false;
300
+ return compare(serial, operator, a, b);
301
+ }
302
+ }
303
+ };
304
+ exports.checkExcelValidationValue = checkExcelValidationValue;
@@ -0,0 +1,38 @@
1
+ import type { GridRange } from "@rowsncolumns/grid";
2
+ import type { FillSeriesSpec } from "../types";
3
+ /**
4
+ * The seed line of a Series-dialog fill: Excel treats the target range's first
5
+ * row (Series in Columns — filling down) or first column (Series in Rows —
6
+ * filling across) as the values the series starts from.
7
+ */
8
+ export declare const seedRangeForSeriesSpec: (target: GridRange, spec: FillSeriesSpec) => GridRange;
9
+ /**
10
+ * How many series values fit before `stop` is passed, starting from the seed's
11
+ * last value. `undefined` when the spec has no usable stop (no stop, zero step,
12
+ * a step that walks away from the stop, …) — the caller then fills the target
13
+ * as selected.
14
+ */
15
+ export declare const seriesCountToStop: (last: number, spec: FillSeriesSpec) => number | undefined;
16
+ export type FillRangeForSeriesSpecArgs = {
17
+ /** The range the user selected (seed + cells to fill). */
18
+ target: GridRange;
19
+ /** From {@link seedRangeForSeriesSpec}. */
20
+ seed: GridRange;
21
+ spec: FillSeriesSpec;
22
+ /** Numeric value of a seed cell (`undefined` when not a number). */
23
+ getSeedValue(rowIndex: number, columnIndex: number): number | undefined;
24
+ rowCount: number;
25
+ columnCount: number;
26
+ };
27
+ /**
28
+ * The range a Series-dialog fill covers (seed + cells to fill). A selection
29
+ * that reaches beyond the seed is filled as selected (`undefined` when there
30
+ * is nothing beyond the seed and no stop): the engines apply the `stop` value
31
+ * per fill line — every column (Series in Columns) / row (Rows) ends at the
32
+ * last value within its own stop and the remaining selected cells stay
33
+ * untouched, exactly as Excel leaves them. Only a seed-only selection is
34
+ * extended along the axis by the number of values that stay within the stop —
35
+ * Excel fills down/right from a single line until the value would pass it.
36
+ */
37
+ export declare const fillRangeForSeriesSpec: ({ target, seed, spec, getSeedValue, rowCount, columnCount, }: FillRangeForSeriesSpecArgs) => GridRange | undefined;
38
+ //# sourceMappingURL=fill-series.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fill-series.d.ts","sourceRoot":"","sources":["../../../api/fill-series.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,SAAS,EACjB,MAAM,cAAc,KACnB,SAGyD,CAAC;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,EACZ,MAAM,cAAc,KACnB,MAAM,GAAG,SAuBX,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,0DAA0D;IAC1D,MAAM,EAAE,SAAS,CAAC;IAClB,2CAA2C;IAC3C,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,cAAc,CAAC;IACrB,oEAAoE;IACpE,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACxE,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,GAAI,8DAOpC,0BAA0B,KAAG,SAAS,GAAG,SAwB3C,CAAC"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fillRangeForSeriesSpec = exports.seriesCountToStop = exports.seedRangeForSeriesSpec = void 0;
4
+ var tslib_1 = require("tslib");
5
+ /**
6
+ * The seed line of a Series-dialog fill: Excel treats the target range's first
7
+ * row (Series in Columns — filling down) or first column (Series in Rows —
8
+ * filling across) as the values the series starts from.
9
+ */
10
+ var seedRangeForSeriesSpec = function (target, spec) {
11
+ return spec.in === "columns"
12
+ ? tslib_1.__assign(tslib_1.__assign({}, target), { endRowIndex: target.startRowIndex }) : tslib_1.__assign(tslib_1.__assign({}, target), { endColumnIndex: target.startColumnIndex });
13
+ };
14
+ exports.seedRangeForSeriesSpec = seedRangeForSeriesSpec;
15
+ /**
16
+ * How many series values fit before `stop` is passed, starting from the seed's
17
+ * last value. `undefined` when the spec has no usable stop (no stop, zero step,
18
+ * a step that walks away from the stop, …) — the caller then fills the target
19
+ * as selected.
20
+ */
21
+ var seriesCountToStop = function (last, spec) {
22
+ var _a, _b;
23
+ var stop = spec.stop;
24
+ if (stop === undefined || !Number.isFinite(stop))
25
+ return undefined;
26
+ var step = (_a = spec.step) !== null && _a !== void 0 ? _a : 1;
27
+ if (spec.type === "linear") {
28
+ if (step === 0)
29
+ return undefined;
30
+ var n = Math.floor((stop - last) / step + 1e-9);
31
+ return n >= 0 ? n : 0;
32
+ }
33
+ if (spec.type === "growth") {
34
+ if (last === 0 || step <= 0 || step === 1)
35
+ return undefined;
36
+ if (Math.sign(last) !== Math.sign(stop))
37
+ return 0;
38
+ var n = Math.floor(Math.log(Math.abs(stop) / Math.abs(last)) / Math.log(step) + 1e-9);
39
+ return n >= 0 ? n : 0;
40
+ }
41
+ if (spec.type === "date" && ((_b = spec.dateUnit) !== null && _b !== void 0 ? _b : "day") === "day") {
42
+ if (step === 0)
43
+ return undefined;
44
+ var n = Math.floor((stop - last) / step + 1e-9);
45
+ return n >= 0 ? n : 0;
46
+ }
47
+ return undefined;
48
+ };
49
+ exports.seriesCountToStop = seriesCountToStop;
50
+ /**
51
+ * The range a Series-dialog fill covers (seed + cells to fill). A selection
52
+ * that reaches beyond the seed is filled as selected (`undefined` when there
53
+ * is nothing beyond the seed and no stop): the engines apply the `stop` value
54
+ * per fill line — every column (Series in Columns) / row (Rows) ends at the
55
+ * last value within its own stop and the remaining selected cells stay
56
+ * untouched, exactly as Excel leaves them. Only a seed-only selection is
57
+ * extended along the axis by the number of values that stay within the stop —
58
+ * Excel fills down/right from a single line until the value would pass it.
59
+ */
60
+ var fillRangeForSeriesSpec = function (_a) {
61
+ var _b;
62
+ var target = _a.target, seed = _a.seed, spec = _a.spec, getSeedValue = _a.getSeedValue, rowCount = _a.rowCount, columnCount = _a.columnCount;
63
+ var down = spec.in === "columns";
64
+ // Excel reads the stop against the first seed line's last value.
65
+ var last = down
66
+ ? getSeedValue(seed.endRowIndex, seed.startColumnIndex)
67
+ : getSeedValue(seed.startRowIndex, seed.endColumnIndex);
68
+ var selectedBeyondSeed = down
69
+ ? target.endRowIndex - seed.endRowIndex
70
+ : target.endColumnIndex - seed.endColumnIndex;
71
+ var extent = selectedBeyondSeed > 0
72
+ ? selectedBeyondSeed
73
+ : last === undefined
74
+ ? 0
75
+ : ((_b = (0, exports.seriesCountToStop)(last, spec)) !== null && _b !== void 0 ? _b : 0);
76
+ if (extent <= 0)
77
+ return undefined;
78
+ if (down) {
79
+ var endRowIndex = Math.min(seed.endRowIndex + extent, rowCount - 1);
80
+ if (endRowIndex <= seed.endRowIndex)
81
+ return undefined;
82
+ return tslib_1.__assign(tslib_1.__assign({}, target), { endRowIndex: endRowIndex });
83
+ }
84
+ var endColumnIndex = Math.min(seed.endColumnIndex + extent, columnCount - 1);
85
+ if (endColumnIndex <= seed.endColumnIndex)
86
+ return undefined;
87
+ return tslib_1.__assign(tslib_1.__assign({}, target), { endColumnIndex: endColumnIndex });
88
+ };
89
+ exports.fillRangeForSeriesSpec = fillRangeForSeriesSpec;
@@ -0,0 +1,32 @@
1
+ import type { GridRange } from "@rowsncolumns/grid";
2
+ import type { CellData } from "../types";
3
+ /**
4
+ * Excel's Go To Special categories that can be decided from cell data alone.
5
+ * (Row / column differences, precedents / dependents and objects are served
6
+ * by the trace arrows and the drawing layer, not by this dialog.)
7
+ */
8
+ export type GoToSpecialKind = "blanks" | "constants" | "formulas" | "errors" | "notes" | "visible";
9
+ export declare const GO_TO_SPECIAL_OPTIONS: ReadonlyArray<{
10
+ kind: GoToSpecialKind;
11
+ label: string;
12
+ }>;
13
+ export type GoToSpecialContext<T extends CellData = CellData> = {
14
+ sheetId: number;
15
+ /** The area to scan — the current selection, or the used range for a single cell. */
16
+ range: GridRange;
17
+ getCellData(sheetId: number, rowIndex: number, columnIndex: number): T | null | undefined;
18
+ isRowHidden?(rowIndex: number): boolean;
19
+ isColumnHidden?(columnIndex: number): boolean;
20
+ /** Scan guard — Excel refuses huge Go To Special selections as well. */
21
+ maxCells?: number;
22
+ };
23
+ /** Cells scanned before the search gives up (returns what it found so far). */
24
+ export declare const GO_TO_SPECIAL_MAX_CELLS = 250000;
25
+ /**
26
+ * Resolve a Go To Special category to the matching cells of `range`, packed
27
+ * into per-row runs of adjacent columns (what the selection layer paints).
28
+ * Hidden rows / columns are skipped for every kind — Excel never selects
29
+ * into a hidden cell from Go To Special. Returns `[]` when nothing matches.
30
+ */
31
+ export declare const resolveGoToSpecial: <T extends CellData>(kind: GoToSpecialKind, context: GoToSpecialContext<T>) => GridRange[];
32
+ //# sourceMappingURL=go-to-special.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"go-to-special.d.ts","sourceRoot":"","sources":["../../../api/go-to-special.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;GAIG;AACH,MAAM,MAAM,eAAe,GACvB,QAAQ,GACR,WAAW,GACX,UAAU,GACV,QAAQ,GACR,OAAO,GACP,SAAS,CAAC;AAEd,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC;IAChD,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf,CAOA,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,IAAI;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CACT,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IACxB,WAAW,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IACxC,cAAc,CAAC,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9C,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,uBAAuB,SAAU,CAAC;AAmD/C;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,QAAQ,EACnD,MAAM,eAAe,EACrB,SAAS,kBAAkB,CAAC,CAAC,CAAC,KAC7B,SAAS,EAoCX,CAAC"}
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveGoToSpecial = exports.GO_TO_SPECIAL_MAX_CELLS = exports.GO_TO_SPECIAL_OPTIONS = void 0;
4
+ exports.GO_TO_SPECIAL_OPTIONS = [
5
+ { kind: "notes", label: "Notes" },
6
+ { kind: "constants", label: "Constants" },
7
+ { kind: "formulas", label: "Formulas" },
8
+ { kind: "errors", label: "Errors" },
9
+ { kind: "blanks", label: "Blanks" },
10
+ { kind: "visible", label: "Visible cells only" },
11
+ ];
12
+ /** Cells scanned before the search gives up (returns what it found so far). */
13
+ exports.GO_TO_SPECIAL_MAX_CELLS = 250000;
14
+ var hasContent = function (cell) {
15
+ var _a;
16
+ var ue = (_a = cell === null || cell === void 0 ? void 0 : cell.ue) !== null && _a !== void 0 ? _a : cell === null || cell === void 0 ? void 0 : cell.userEnteredValue;
17
+ if (!ue)
18
+ return false;
19
+ return (ue.fv != null ||
20
+ ue.formulaValue != null ||
21
+ ue.sv != null ||
22
+ ue.stringValue != null ||
23
+ ue.nv != null ||
24
+ ue.numberValue != null ||
25
+ ue.bv != null ||
26
+ ue.boolValue != null);
27
+ };
28
+ var isFormula = function (cell) {
29
+ var _a, _b;
30
+ var ue = (_a = cell === null || cell === void 0 ? void 0 : cell.ue) !== null && _a !== void 0 ? _a : cell === null || cell === void 0 ? void 0 : cell.userEnteredValue;
31
+ return typeof ((_b = ue === null || ue === void 0 ? void 0 : ue.fv) !== null && _b !== void 0 ? _b : ue === null || ue === void 0 ? void 0 : ue.formulaValue) === "string";
32
+ };
33
+ var isError = function (cell) {
34
+ var _a, _b;
35
+ var ev = (_a = cell === null || cell === void 0 ? void 0 : cell.ev) !== null && _a !== void 0 ? _a : cell === null || cell === void 0 ? void 0 : cell.effectiveValue;
36
+ var error = (_b = ev === null || ev === void 0 ? void 0 : ev.ev) !== null && _b !== void 0 ? _b : ev === null || ev === void 0 ? void 0 : ev.errorValue;
37
+ return !!error && error.type === "Error";
38
+ };
39
+ var hasNote = function (cell) {
40
+ return typeof (cell === null || cell === void 0 ? void 0 : cell.note) === "string" && cell.note.trim().length > 0;
41
+ };
42
+ var matches = function (kind, cell) {
43
+ switch (kind) {
44
+ case "blanks":
45
+ return !hasContent(cell);
46
+ case "constants":
47
+ return hasContent(cell) && !isFormula(cell);
48
+ case "formulas":
49
+ return isFormula(cell);
50
+ case "errors":
51
+ return isError(cell);
52
+ case "notes":
53
+ return hasNote(cell);
54
+ case "visible":
55
+ return true;
56
+ }
57
+ };
58
+ /**
59
+ * Resolve a Go To Special category to the matching cells of `range`, packed
60
+ * into per-row runs of adjacent columns (what the selection layer paints).
61
+ * Hidden rows / columns are skipped for every kind — Excel never selects
62
+ * into a hidden cell from Go To Special. Returns `[]` when nothing matches.
63
+ */
64
+ var resolveGoToSpecial = function (kind, context) {
65
+ var _a;
66
+ var sheetId = context.sheetId, range = context.range, getCellData = context.getCellData, isRowHidden = context.isRowHidden, isColumnHidden = context.isColumnHidden;
67
+ var maxCells = (_a = context.maxCells) !== null && _a !== void 0 ? _a : exports.GO_TO_SPECIAL_MAX_CELLS;
68
+ var runs = [];
69
+ var scanned = 0;
70
+ var _loop_1 = function (row) {
71
+ if (isRowHidden === null || isRowHidden === void 0 ? void 0 : isRowHidden(row))
72
+ return "continue";
73
+ var runStart;
74
+ var flush = function (endColumn) {
75
+ if (runStart === undefined)
76
+ return;
77
+ runs.push({
78
+ startRowIndex: row,
79
+ endRowIndex: row,
80
+ startColumnIndex: runStart,
81
+ endColumnIndex: endColumn,
82
+ });
83
+ runStart = undefined;
84
+ };
85
+ for (var col = range.startColumnIndex; col <= range.endColumnIndex; col++) {
86
+ if (++scanned > maxCells) {
87
+ flush(col - 1);
88
+ return { value: runs };
89
+ }
90
+ if (isColumnHidden === null || isColumnHidden === void 0 ? void 0 : isColumnHidden(col)) {
91
+ flush(col - 1);
92
+ continue;
93
+ }
94
+ if (matches(kind, getCellData(sheetId, row, col))) {
95
+ if (runStart === undefined)
96
+ runStart = col;
97
+ }
98
+ else {
99
+ flush(col - 1);
100
+ }
101
+ }
102
+ flush(range.endColumnIndex);
103
+ };
104
+ for (var row = range.startRowIndex; row <= range.endRowIndex; row++) {
105
+ var state_1 = _loop_1(row);
106
+ if (typeof state_1 === "object")
107
+ return state_1.value;
108
+ }
109
+ return runs;
110
+ };
111
+ exports.resolveGoToSpecial = resolveGoToSpecial;