@svgrid/enterprise 3.0.1 → 3.0.3

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 (445) hide show
  1. package/LICENSE +94 -24
  2. package/README.md +36 -4
  3. package/dist/SvAdvancedFilter.svelte +1 -1
  4. package/dist/SvAlertsManager.svelte +2 -1
  5. package/dist/SvBoard.svelte +2 -1
  6. package/dist/SvExportMenu.svelte +4 -1
  7. package/dist/SvExportMenu.svelte.d.ts +0 -13
  8. package/dist/SvExpressionEditor.svelte +3 -3
  9. package/dist/SvFormulaBar.svelte +680 -0
  10. package/dist/SvFormulaBar.svelte.d.ts +69 -0
  11. package/dist/SvGridAlerts.svelte +49 -9
  12. package/dist/SvGridBoard.svelte +13 -8
  13. package/dist/SvGridBulkEditDrawer.svelte +26 -2
  14. package/dist/SvGridEditPanel.svelte +3 -0
  15. package/dist/SvGridScheduler.svelte +69 -40
  16. package/dist/SvGridSelectionBar.svelte +10 -3
  17. package/dist/SvPivotDesigner.svelte +263 -54
  18. package/dist/SvPivotDesigner.svelte.d.ts +27 -20
  19. package/dist/SvRibbonIcon.svelte +46 -0
  20. package/dist/SvRibbonIcon.svelte.d.ts +17 -0
  21. package/dist/SvSchemaChart.svelte +4 -2
  22. package/dist/SvSheet.svelte +7914 -0
  23. package/dist/SvSheet.svelte.d.ts +215 -0
  24. package/dist/SvSheetChartSetup.svelte +151 -0
  25. package/dist/SvSheetChartSetup.svelte.d.ts +18 -0
  26. package/dist/SvSheetComment.svelte +283 -0
  27. package/dist/SvSheetComment.svelte.d.ts +22 -0
  28. package/dist/SvSheetConditionalFormat.svelte +159 -0
  29. package/dist/SvSheetConditionalFormat.svelte.d.ts +14 -0
  30. package/dist/SvSheetDataValidation.svelte +273 -0
  31. package/dist/SvSheetDataValidation.svelte.d.ts +14 -0
  32. package/dist/SvSheetEditRanges.svelte +217 -0
  33. package/dist/SvSheetEditRanges.svelte.d.ts +15 -0
  34. package/dist/SvSheetErrors.svelte +125 -0
  35. package/dist/SvSheetErrors.svelte.d.ts +20 -0
  36. package/dist/SvSheetEvaluate.svelte +133 -0
  37. package/dist/SvSheetEvaluate.svelte.d.ts +15 -0
  38. package/dist/SvSheetFilterMenu.svelte +320 -0
  39. package/dist/SvSheetFilterMenu.svelte.d.ts +22 -0
  40. package/dist/SvSheetFindReplace.svelte +132 -0
  41. package/dist/SvSheetFindReplace.svelte.d.ts +10 -0
  42. package/dist/SvSheetFormatCells.svelte +465 -0
  43. package/dist/SvSheetFormatCells.svelte.d.ts +17 -0
  44. package/dist/SvSheetGoalSeek.svelte +145 -0
  45. package/dist/SvSheetGoalSeek.svelte.d.ts +12 -0
  46. package/dist/SvSheetInsertFunction.svelte +149 -0
  47. package/dist/SvSheetInsertFunction.svelte.d.ts +8 -0
  48. package/dist/SvSheetIteration.svelte +81 -0
  49. package/dist/SvSheetIteration.svelte.d.ts +10 -0
  50. package/dist/SvSheetLink.svelte +99 -0
  51. package/dist/SvSheetLink.svelte.d.ts +17 -0
  52. package/dist/SvSheetListPicker.svelte +91 -0
  53. package/dist/SvSheetListPicker.svelte.d.ts +10 -0
  54. package/dist/SvSheetManageRules.svelte +187 -0
  55. package/dist/SvSheetManageRules.svelte.d.ts +16 -0
  56. package/dist/SvSheetNameManager.svelte +227 -0
  57. package/dist/SvSheetNameManager.svelte.d.ts +11 -0
  58. package/dist/SvSheetPageSetup.svelte +159 -0
  59. package/dist/SvSheetPageSetup.svelte.d.ts +13 -0
  60. package/dist/SvSheetPasteSpecial.svelte +107 -0
  61. package/dist/SvSheetPasteSpecial.svelte.d.ts +12 -0
  62. package/dist/SvSheetPivot.svelte +220 -0
  63. package/dist/SvSheetPivot.svelte.d.ts +21 -0
  64. package/dist/SvSheetProtectSheet.svelte +81 -0
  65. package/dist/SvSheetProtectSheet.svelte.d.ts +11 -0
  66. package/dist/SvSheetRemoveDuplicates.svelte +152 -0
  67. package/dist/SvSheetRemoveDuplicates.svelte.d.ts +12 -0
  68. package/dist/SvSheetRibbon.svelte +1254 -0
  69. package/dist/SvSheetRibbon.svelte.d.ts +34 -0
  70. package/dist/SvSheetSizeDialog.svelte +60 -0
  71. package/dist/SvSheetSizeDialog.svelte.d.ts +11 -0
  72. package/dist/SvSheetSort.svelte +218 -0
  73. package/dist/SvSheetSort.svelte.d.ts +28 -0
  74. package/dist/SvSheetSparklines.svelte +135 -0
  75. package/dist/SvSheetSparklines.svelte.d.ts +14 -0
  76. package/dist/SvSheetTable.svelte +160 -0
  77. package/dist/SvSheetTable.svelte.d.ts +24 -0
  78. package/dist/SvSheetTabs.svelte +571 -0
  79. package/dist/SvSheetTabs.svelte.d.ts +50 -0
  80. package/dist/SvSheetTabs.test-harness.svelte.d.ts +17 -0
  81. package/dist/SvSheetTabs.test-harness.svelte.js +22 -0
  82. package/dist/SvSheetTextToColumns.svelte +172 -0
  83. package/dist/SvSheetTextToColumns.svelte.d.ts +13 -0
  84. package/dist/SvSheetValidationAlert.svelte +85 -0
  85. package/dist/SvSheetValidationAlert.svelte.d.ts +15 -0
  86. package/dist/advanced-filter-enable.js +1 -1
  87. package/dist/alerts/alert-engine.d.ts +6 -0
  88. package/dist/alerts/alert-engine.js +21 -4
  89. package/dist/alerts/alert-formats.js +2 -0
  90. package/dist/alerts/alert-types.d.ts +1 -1
  91. package/dist/alerts.d.ts +1 -1
  92. package/dist/alerts.js +2 -2
  93. package/dist/board.js +2 -2
  94. package/dist/bulk-edit.d.ts +3 -1
  95. package/dist/bulk-edit.js +1 -1
  96. package/dist/cdn/svgrid-enterprise.svelte-external.js +43538 -6539
  97. package/dist/designer/assets/GridMenus-8gTNssgV.js +8 -0
  98. package/dist/designer/assets/SvChartMenu-BDoeqGz6.js +1 -0
  99. package/dist/designer/assets/SvChartMenu-BYO9cYdy.css +1 -0
  100. package/dist/designer/assets/SvDateRangeInput-BBRzrQeg.js +1 -0
  101. package/dist/designer/assets/SvDateTimePicker-DCPg7WGN.js +1 -0
  102. package/dist/designer/assets/SvGridCellEditor-DMoWJjEI.js +4 -0
  103. package/dist/designer/assets/SvGridChart-BgLuPO7I.css +1 -0
  104. package/dist/designer/assets/SvGridChart-Cy1ATrWh.js +3 -0
  105. package/dist/designer/assets/SvGridChartBuilder-08YWWeqY.css +1 -0
  106. package/dist/designer/assets/SvGridChartBuilder-eQ3mn0L9.js +1 -0
  107. package/dist/designer/assets/SvGridChartPanel-4Pc8y5yO.css +1 -0
  108. package/dist/designer/assets/SvGridChartPanel-CATdVc9X.js +4 -0
  109. package/dist/designer/assets/{SvGridChartView-DUc-1RUf.css → SvGridChartView-7msfnWZT.css} +1 -1
  110. package/dist/designer/assets/SvGridChartView-CmsZtCED.js +1 -0
  111. package/dist/designer/assets/SvGridDropdown-Cjz0H-fI.js +1 -0
  112. package/dist/designer/assets/SvListBox-BDS66lmZ.js +110 -0
  113. package/dist/designer/assets/SvMenuList-DJ47ba1h.css +1 -0
  114. package/dist/designer/assets/SvMenuList-Dgq2D5VN.js +1 -0
  115. package/dist/designer/assets/SvTabs-2mHC6oaz.js +1 -0
  116. package/dist/designer/assets/SvTabs-DKmwb5p1.css +1 -0
  117. package/dist/designer/assets/cell-formatting-BbubJTVz.js +1 -0
  118. package/dist/designer/assets/chart-Cn7MnNqA.js +1 -0
  119. package/dist/designer/assets/chart-export-B6bkQ3X8.js +11 -0
  120. package/dist/designer/assets/chart-export-pdf-BbA28-gt.js +11 -0
  121. package/dist/designer/assets/chart-panel-messages-Dz7PTIqT.js +1 -0
  122. package/dist/designer/assets/chart-summary-BD1qYB2R.js +1 -0
  123. package/dist/designer/assets/chart-trend-B8xr5LuD.js +1 -0
  124. package/dist/designer/assets/chart-validate-BMqM-qkF.js +1 -0
  125. package/dist/designer/assets/column-resize-BYDzR1Ve.js +1 -0
  126. package/dist/designer/assets/date-format-B8JbEtIG.js +1 -0
  127. package/dist/designer/assets/date-format-DKS-z0xS.css +1 -0
  128. package/dist/designer/assets/{dismissable-BO547MH9.js → dismissable-ChWRPkoa.js} +1 -1
  129. package/dist/designer/assets/editor-contract-Bpoa7A5g.js +1 -0
  130. package/dist/designer/assets/{export-format-D-eP4b2l.js → export-format-DGckmgKr.js} +1 -1
  131. package/dist/designer/assets/focus-trap-V2-6Fy9I.js +1 -0
  132. package/dist/designer/assets/{index-C_a9Cj8Y.js → index-D5bVbuzI.js} +318 -315
  133. package/dist/designer/assets/index-_JVFxt02.css +1 -0
  134. package/dist/designer/assets/list-option-BP_dWS66.js +1 -0
  135. package/dist/designer/assets/row-resize-BInFWCpr.js +1 -0
  136. package/dist/designer/assets/server-block-cache-CXJKkJpy.js +1 -0
  137. package/dist/designer/assets/src-CITpcm6b.js +1 -0
  138. package/dist/designer/assets/src-DUQ4xE3x.js +58 -0
  139. package/dist/designer/assets/validate-C3B8QKsM.js +1 -0
  140. package/dist/designer/index.html +29 -19
  141. package/dist/export-pdf.d.ts +164 -0
  142. package/dist/export-pdf.js +346 -15
  143. package/dist/export.js +25 -10
  144. package/dist/gantt/SvGridGantt.svelte +2890 -0
  145. package/dist/gantt/SvGridGantt.svelte.d.ts +30 -0
  146. package/dist/gantt/gantt-config.d.ts +73 -0
  147. package/dist/gantt/gantt-config.js +1 -0
  148. package/dist/gantt/gantt-critical-path.d.ts +67 -0
  149. package/dist/gantt/gantt-critical-path.js +207 -0
  150. package/dist/gantt/gantt-model.d.ts +257 -0
  151. package/dist/gantt/gantt-model.js +651 -0
  152. package/dist/gantt/gantt-resources.d.ts +59 -0
  153. package/dist/gantt/gantt-resources.js +71 -0
  154. package/dist/gantt/gantt.d.ts +7 -0
  155. package/dist/gantt/gantt.js +36 -0
  156. package/dist/gantt/index.d.ts +15 -0
  157. package/dist/gantt/index.js +22 -0
  158. package/dist/gantt/timeline-arrows.d.ts +102 -0
  159. package/dist/gantt/timeline-arrows.js +181 -0
  160. package/dist/import.d.ts +2 -2
  161. package/dist/import.js +1 -1
  162. package/dist/index.d.ts +93 -3
  163. package/dist/index.js +107 -3
  164. package/dist/install.js +13 -1
  165. package/dist/license-core.d.ts +17 -1
  166. package/dist/license-core.js +16 -5
  167. package/dist/license.d.ts +18 -2
  168. package/dist/license.js +71 -6
  169. package/dist/node/studio.js +203 -9
  170. package/dist/pivot-chart.d.ts +25 -1
  171. package/dist/pivot-chart.js +25 -69
  172. package/dist/pivot-enable.js +2 -2
  173. package/dist/scheduler-dependencies.d.ts +35 -0
  174. package/dist/scheduler-dependencies.js +36 -1
  175. package/dist/scheduler.js +2 -2
  176. package/dist/selection-bar.js +2 -2
  177. package/dist/server/SvGroupCell.svelte +213 -0
  178. package/dist/server/SvGroupCell.svelte.d.ts +62 -0
  179. package/dist/server/SvRowGroupPanel.svelte +322 -0
  180. package/dist/server/SvRowGroupPanel.svelte.d.ts +37 -0
  181. package/dist/server/enable.d.ts +17 -0
  182. package/dist/server/enable.js +49 -0
  183. package/dist/server/index.d.ts +22 -0
  184. package/dist/server/index.js +24 -0
  185. package/dist/server/messages.d.ts +45 -0
  186. package/dist/server/messages.js +35 -0
  187. package/dist/server/server-group-model.d.ts +104 -0
  188. package/dist/server/server-group-model.js +272 -0
  189. package/dist/server/server-pivot.d.ts +46 -0
  190. package/dist/server/server-pivot.js +57 -0
  191. package/dist/server/server-row-model.d.ts +547 -0
  192. package/dist/server/server-row-model.js +1551 -0
  193. package/dist/server/server-selection.d.ts +99 -0
  194. package/dist/server/server-selection.js +215 -0
  195. package/dist/server/svgrid-adapter.d.ts +155 -0
  196. package/dist/server/svgrid-adapter.js +202 -0
  197. package/dist/sheet/address.d.ts +43 -0
  198. package/dist/sheet/address.js +81 -0
  199. package/dist/sheet/ast.d.ts +138 -0
  200. package/dist/sheet/ast.js +70 -0
  201. package/dist/sheet/auto-filter.d.ts +120 -0
  202. package/dist/sheet/auto-filter.js +295 -0
  203. package/dist/sheet/autocomplete.d.ts +51 -0
  204. package/dist/sheet/autocomplete.js +248 -0
  205. package/dist/sheet/cell-images.d.ts +39 -0
  206. package/dist/sheet/cell-images.js +90 -0
  207. package/dist/sheet/cell-types.d.ts +58 -0
  208. package/dist/sheet/cell-types.js +96 -0
  209. package/dist/sheet/coerce.d.ts +71 -0
  210. package/dist/sheet/coerce.js +289 -0
  211. package/dist/sheet/commands.d.ts +89 -0
  212. package/dist/sheet/commands.js +230 -0
  213. package/dist/sheet/comments.d.ts +63 -0
  214. package/dist/sheet/comments.js +131 -0
  215. package/dist/sheet/conditional-formats.d.ts +167 -0
  216. package/dist/sheet/conditional-formats.js +341 -0
  217. package/dist/sheet/csv.d.ts +32 -0
  218. package/dist/sheet/csv.js +158 -0
  219. package/dist/sheet/culture.d.ts +87 -0
  220. package/dist/sheet/culture.js +247 -0
  221. package/dist/sheet/delta.d.ts +102 -0
  222. package/dist/sheet/delta.js +203 -0
  223. package/dist/sheet/deps.d.ts +104 -0
  224. package/dist/sheet/deps.js +274 -0
  225. package/dist/sheet/document.d.ts +252 -0
  226. package/dist/sheet/document.js +465 -0
  227. package/dist/sheet/edit-keys.d.ts +14 -0
  228. package/dist/sheet/edit-keys.js +40 -0
  229. package/dist/sheet/engine.d.ts +67 -0
  230. package/dist/sheet/engine.js +19 -0
  231. package/dist/sheet/entry.d.ts +35 -0
  232. package/dist/sheet/entry.js +226 -0
  233. package/dist/sheet/error-check.d.ts +49 -0
  234. package/dist/sheet/error-check.js +83 -0
  235. package/dist/sheet/evaluate-steps.d.ts +48 -0
  236. package/dist/sheet/evaluate-steps.js +196 -0
  237. package/dist/sheet/evaluate.d.ts +128 -0
  238. package/dist/sheet/evaluate.js +1049 -0
  239. package/dist/sheet/filter-files.d.ts +37 -0
  240. package/dist/sheet/filter-files.js +465 -0
  241. package/dist/sheet/find-replace.d.ts +62 -0
  242. package/dist/sheet/find-replace.js +152 -0
  243. package/dist/sheet/format-store.d.ts +114 -0
  244. package/dist/sheet/format-store.js +243 -0
  245. package/dist/sheet/freeze.d.ts +54 -0
  246. package/dist/sheet/freeze.js +58 -0
  247. package/dist/sheet/from-rows.d.ts +14 -0
  248. package/dist/sheet/from-rows.js +50 -0
  249. package/dist/sheet/function-catalog.d.ts +10 -0
  250. package/dist/sheet/function-catalog.js +385 -0
  251. package/dist/sheet/functions.d.ts +28 -0
  252. package/dist/sheet/functions.js +634 -0
  253. package/dist/sheet/goal-seek.d.ts +73 -0
  254. package/dist/sheet/goal-seek.js +153 -0
  255. package/dist/sheet/index.d.ts +80 -0
  256. package/dist/sheet/index.js +80 -0
  257. package/dist/sheet/links.d.ts +57 -0
  258. package/dist/sheet/links.js +174 -0
  259. package/dist/sheet/merges.d.ts +71 -0
  260. package/dist/sheet/merges.js +137 -0
  261. package/dist/sheet/messages.d.ts +778 -0
  262. package/dist/sheet/messages.js +806 -0
  263. package/dist/sheet/names.d.ts +31 -0
  264. package/dist/sheet/names.js +87 -0
  265. package/dist/sheet/navigate.d.ts +52 -0
  266. package/dist/sheet/navigate.js +135 -0
  267. package/dist/sheet/number-format.d.ts +110 -0
  268. package/dist/sheet/number-format.js +905 -0
  269. package/dist/sheet/objects.d.ts +106 -0
  270. package/dist/sheet/objects.js +149 -0
  271. package/dist/sheet/ods-document.d.ts +44 -0
  272. package/dist/sheet/ods-document.js +1275 -0
  273. package/dist/sheet/open-file.d.ts +26 -0
  274. package/dist/sheet/open-file.js +56 -0
  275. package/dist/sheet/outline.d.ts +82 -0
  276. package/dist/sheet/outline.js +228 -0
  277. package/dist/sheet/packs/array.d.ts +16 -0
  278. package/dist/sheet/packs/array.js +172 -0
  279. package/dist/sheet/packs/database.d.ts +42 -0
  280. package/dist/sheet/packs/database.js +142 -0
  281. package/dist/sheet/packs/engineering.d.ts +2 -0
  282. package/dist/sheet/packs/engineering.js +296 -0
  283. package/dist/sheet/packs/financial.d.ts +5 -0
  284. package/dist/sheet/packs/financial.js +220 -0
  285. package/dist/sheet/packs/math-stats.d.ts +2 -0
  286. package/dist/sheet/packs/math-stats.js +372 -0
  287. package/dist/sheet/packs/special.d.ts +44 -0
  288. package/dist/sheet/packs/special.js +187 -0
  289. package/dist/sheet/packs/stats-dist.d.ts +2 -0
  290. package/dist/sheet/packs/stats-dist.js +785 -0
  291. package/dist/sheet/packs/text-date.d.ts +2 -0
  292. package/dist/sheet/packs/text-date.js +332 -0
  293. package/dist/sheet/packs/trig.d.ts +2 -0
  294. package/dist/sheet/packs/trig.js +73 -0
  295. package/dist/sheet/page-setup.d.ts +73 -0
  296. package/dist/sheet/page-setup.js +73 -0
  297. package/dist/sheet/palette.d.ts +19 -0
  298. package/dist/sheet/palette.js +84 -0
  299. package/dist/sheet/parse.d.ts +13 -0
  300. package/dist/sheet/parse.js +140 -0
  301. package/dist/sheet/paste-special.d.ts +186 -0
  302. package/dist/sheet/paste-special.js +601 -0
  303. package/dist/sheet/pivot-range.d.ts +160 -0
  304. package/dist/sheet/pivot-range.js +333 -0
  305. package/dist/sheet/presence.d.ts +73 -0
  306. package/dist/sheet/presence.js +79 -0
  307. package/dist/sheet/print.d.ts +104 -0
  308. package/dist/sheet/print.js +169 -0
  309. package/dist/sheet/protection.d.ts +75 -0
  310. package/dist/sheet/protection.js +101 -0
  311. package/dist/sheet/rects.d.ts +45 -0
  312. package/dist/sheet/rects.js +112 -0
  313. package/dist/sheet/refs.d.ts +130 -0
  314. package/dist/sheet/refs.js +413 -0
  315. package/dist/sheet/ribbon-icons.d.ts +31 -0
  316. package/dist/sheet/ribbon-icons.js +536 -0
  317. package/dist/sheet/ribbon.d.ts +173 -0
  318. package/dist/sheet/ribbon.js +1054 -0
  319. package/dist/sheet/sheet-kinds.d.ts +74 -0
  320. package/dist/sheet/sheet-kinds.js +91 -0
  321. package/dist/sheet/shortcuts.d.ts +174 -0
  322. package/dist/sheet/shortcuts.js +674 -0
  323. package/dist/sheet/sort.d.ts +51 -0
  324. package/dist/sheet/sort.js +107 -0
  325. package/dist/sheet/sparklines.d.ts +111 -0
  326. package/dist/sheet/sparklines.js +204 -0
  327. package/dist/sheet/structure.d.ts +87 -0
  328. package/dist/sheet/structure.js +166 -0
  329. package/dist/sheet/table-styles.d.ts +74 -0
  330. package/dist/sheet/table-styles.js +152 -0
  331. package/dist/sheet/tables.d.ts +89 -0
  332. package/dist/sheet/tables.js +178 -0
  333. package/dist/sheet/tokenize.d.ts +71 -0
  334. package/dist/sheet/tokenize.js +355 -0
  335. package/dist/sheet/transforms.d.ts +76 -0
  336. package/dist/sheet/transforms.js +154 -0
  337. package/dist/sheet/validation.d.ts +108 -0
  338. package/dist/sheet/validation.js +278 -0
  339. package/dist/sheet/workbook.d.ts +217 -0
  340. package/dist/sheet/workbook.js +1120 -0
  341. package/dist/sheet/xls-cfb.d.ts +32 -0
  342. package/dist/sheet/xls-cfb.js +290 -0
  343. package/dist/sheet/xls-document.d.ts +10 -0
  344. package/dist/sheet/xls-document.js +1243 -0
  345. package/dist/sheet/xls-formula.d.ts +40 -0
  346. package/dist/sheet/xls-formula.js +569 -0
  347. package/dist/sheet/xlsx-document.d.ts +108 -0
  348. package/dist/sheet/xlsx-document.js +1849 -0
  349. package/dist/sheet/xlsx-drawing.d.ts +99 -0
  350. package/dist/sheet/xlsx-drawing.js +420 -0
  351. package/dist/sheet-enable.d.ts +6 -0
  352. package/dist/sheet-enable.js +45 -0
  353. package/dist/sheet-text.d.ts +7 -0
  354. package/dist/sheet-text.js +29 -0
  355. package/dist/sources/auth-supabase.js +2 -2
  356. package/dist/sources/realtime-supabase.js +2 -2
  357. package/dist/sources/rest.d.ts +6 -2
  358. package/dist/sources/rest.js +42 -7
  359. package/dist/sources/supabase.d.ts +10 -1
  360. package/dist/sources/supabase.js +73 -40
  361. package/dist/studio/emit-project.js +14 -1
  362. package/dist/studio/index.js +1 -1
  363. package/dist/studio/project.d.ts +11 -2
  364. package/dist/studio/project.js +5 -2
  365. package/dist/studio/ui-components.generated.js +170 -3
  366. package/dist/sveltekit/in-memory.d.ts +2 -2
  367. package/dist/sveltekit/in-memory.js +125 -4
  368. package/dist/sveltekit/index.d.ts +1 -1
  369. package/dist/sveltekit/index.js +1 -1
  370. package/dist/sveltekit/query-plan.d.ts +50 -4
  371. package/dist/sveltekit/query-plan.js +25 -3
  372. package/dist/sveltekit/sql-source.d.ts +6 -0
  373. package/dist/sveltekit/sql-source.js +34 -6
  374. package/dist/sveltekit/sql.d.ts +31 -0
  375. package/dist/sveltekit/sql.js +135 -25
  376. package/dist/sveltekit/transport.d.ts +10 -2
  377. package/dist/sveltekit/transport.js +30 -6
  378. package/dist/upgrade-prompt.d.ts +1 -1
  379. package/dist/version.d.ts +1 -1
  380. package/dist/version.js +1 -1
  381. package/dist/watermark.js +35 -2
  382. package/dist/wc/GridMenus-By9vPuq0.js +1088 -0
  383. package/dist/wc/SvChartMenu-CQNrQGT2.js +308 -0
  384. package/dist/wc/SvDateRangeInput-DR6m7bSM.js +199 -0
  385. package/dist/wc/SvDateTimePicker-D-vRnaMo.js +771 -0
  386. package/dist/wc/SvField-B_kurx_P.js +149 -0
  387. package/dist/wc/SvGrid.helpers-BdVDtjUm.js +135 -0
  388. package/dist/wc/SvGridCellEditor-Bnf1Kr5C.js +560 -0
  389. package/dist/wc/SvGridChart-BqUJh2pG.js +3572 -0
  390. package/dist/wc/SvGridChartBuilder-CGycC5cn.js +988 -0
  391. package/dist/wc/SvGridChartPanel-CRnizsHD.js +1746 -0
  392. package/dist/wc/SvGridChartView-D1pa_xMy.js +47 -0
  393. package/dist/wc/SvGridDropdown-45WsObLL.js +259 -0
  394. package/dist/wc/SvModal-DrfOYYyX.js +189 -0
  395. package/dist/wc/cell-formatting-CBfgahv1.js +86 -0
  396. package/dist/wc/chart-6OXlybVT.js +4341 -0
  397. package/dist/wc/chart-export-CeSADGfi.js +135 -0
  398. package/dist/wc/chart-export-pdf-BGko7MER.js +104 -0
  399. package/dist/wc/chart-summary-2m3ia1-n.js +137 -0
  400. package/dist/wc/chart-trend-CQOQtTMl.js +50 -0
  401. package/dist/wc/chart-validate-CD6ptiwg.js +180 -0
  402. package/dist/wc/client-DQIzjDBG.js +3064 -0
  403. package/dist/wc/column-resize-DUPgynvc.js +101 -0
  404. package/dist/wc/date-format-DS-z_h9v.js +1130 -0
  405. package/dist/wc/dismissable-CQ6XFXsk.js +45 -0
  406. package/dist/wc/editor-contract-peBDxir_.js +22 -0
  407. package/dist/wc/editor-registry-DxGKqcvx.js +24 -0
  408. package/dist/wc/focus-trap-Dbb2tJxb.js +65 -0
  409. package/dist/wc/list-option-DrRyivWp.js +82 -0
  410. package/dist/wc/popover-WsGlvtQv.js +69 -0
  411. package/dist/wc/positioning-BiKLfu1E.js +112 -0
  412. package/dist/wc/react.d.ts +41 -0
  413. package/dist/wc/react.js +90 -0
  414. package/dist/wc/rolldown-runtime-Dy4uBu1J.js +11 -0
  415. package/dist/wc/row-drag-touch-CycRR65n.js +93 -0
  416. package/dist/wc/row-resize-limG_N1z.js +111 -0
  417. package/dist/wc/sv-sheet-element.d.ts +97 -0
  418. package/dist/wc/sv-sheet-element.js +44213 -0
  419. package/dist/wc/svelte-virtualizer.svelte-CXtQy2TQ.js +530 -0
  420. package/dist/wc/validate-BqDthkNr.js +88 -0
  421. package/dist/wc/vue.d.ts +31 -0
  422. package/dist/wc/vue.js +75 -0
  423. package/package.json +36 -6
  424. package/dist/designer/assets/GridMenus-B1JtIN21.js +0 -8
  425. package/dist/designer/assets/SvDateRangeInput-CjO7nn_x.js +0 -1
  426. package/dist/designer/assets/SvDateTimePicker-ByBD_ov6.js +0 -1
  427. package/dist/designer/assets/SvField-YDLipR6O.css +0 -1
  428. package/dist/designer/assets/SvField-cj1PFNgZ.js +0 -1
  429. package/dist/designer/assets/SvGridCellEditor-0W1L2hJ1.js +0 -2
  430. package/dist/designer/assets/SvGridChart-DBOR4xcz.js +0 -2
  431. package/dist/designer/assets/SvGridChart-fkMWeh1J.css +0 -1
  432. package/dist/designer/assets/SvGridChartPanel-symrhNnR.js +0 -11
  433. package/dist/designer/assets/SvGridChartView-BmRxq6mU.js +0 -1
  434. package/dist/designer/assets/SvGridDropdown-Bb3HH2Aj.js +0 -1
  435. package/dist/designer/assets/SvListBox-1oUF6Iav.js +0 -110
  436. package/dist/designer/assets/cell-formatting-wr5wm7US.js +0 -1
  437. package/dist/designer/assets/chart-DXFganU8.js +0 -1
  438. package/dist/designer/assets/column-resize-C_inr5zT.js +0 -1
  439. package/dist/designer/assets/date-format-DGagAqRc.css +0 -1
  440. package/dist/designer/assets/date-format-onlYDsrY.js +0 -1
  441. package/dist/designer/assets/easing-zaypKrr0.js +0 -3
  442. package/dist/designer/assets/index-k2stW6L8.css +0 -1
  443. package/dist/designer/assets/row-resize-B0FWHcNr.js +0 -1
  444. package/dist/designer/assets/src-D9p27OGC.js +0 -58
  445. package/dist/designer/assets/validate-h-aslRV9.js +0 -1
@@ -0,0 +1,465 @@
1
+ /**
2
+ * The sheet document: the workbook plus everything a sheet keeps beside its
3
+ * cells, per sheet, in one model.
4
+ *
5
+ * The shell used to keep five Maps (format stores, column widths, row
6
+ * heights, hidden lines, frozen panes), each keyed by sheet name, each
7
+ * swapped on a sheet switch and each moved by hand on an insert or delete.
8
+ * Comments, validation rules, conditional formats, protection and merges
9
+ * would have made it ten. The document holds all of it, moves all of it in
10
+ * one `shift()` when rows or columns are inserted or deleted, saves and
11
+ * restores all of it through one `getState()` / `setState()` pair, and tells
12
+ * a listener once per tick what changed. `SvSheet` is a view over it: it
13
+ * puts the active sheet's sizes and hidden lines on the grid and writes
14
+ * them back here whenever they change, so the document is always the
15
+ * truth and the grid a rendering of it.
16
+ *
17
+ * Nothing in here touches the DOM, so a document can be built, edited,
18
+ * saved and restored in Node, in a test, or on a server.
19
+ */
20
+ import { createWorkbook } from './workbook.js';
21
+ import { createFormatStore } from './format-store.js';
22
+ import { lineShift, remapNotes, shiftRect } from './rects.js';
23
+ import { copyProtection, defaultProtection } from './protection.js';
24
+ import { copyPageSetup, defaultPageSetup, shiftPageSetup } from './page-setup.js';
25
+ import { copyObject, objectId, shiftObjects } from './objects.js';
26
+ import { copySparkline, shiftSparklines, sparklineId } from './sparklines.js';
27
+ import { copyPivot, pivotId, shiftPivots } from './pivot-range.js';
28
+ import { copyLinks, shiftLinks } from './links.js';
29
+ import { releaseFilteredRows } from './filter-files.js';
30
+ import { colToLetters, lettersToCol } from './address.js';
31
+ import { shiftValidation } from './validation.js';
32
+ import { shiftCf } from './conditional-formats.js';
33
+ import { shiftAutoFilter } from './auto-filter.js';
34
+ import { copyCellType, shiftCellTypes } from './cell-types.js';
35
+ import { copyGridSheet } from './sheet-kinds.js';
36
+ import { emptyOutline, shiftOutline } from './outline.js';
37
+ /** A deep copy of one axis's outline, absent reading as an empty one. */
38
+ const copyOutline = (o) => (o ? { levels: { ...o.levels }, collapsed: [...o.collapsed] } : emptyOutline());
39
+ /** Which change a patched part of a sheet counts as, so listeners hear it. */
40
+ function reasonsForEntry(entry) {
41
+ const out = [];
42
+ if (entry.formats !== undefined)
43
+ out.push({ kind: 'formats' });
44
+ if (entry.columnWidths !== undefined || entry.rowHeights !== undefined)
45
+ out.push({ kind: 'sizes' });
46
+ if (entry.hidden !== undefined || entry.sheetHidden !== undefined)
47
+ out.push({ kind: 'hidden' });
48
+ if (entry.freeze !== undefined)
49
+ out.push({ kind: 'freeze' });
50
+ if (entry.comments !== undefined)
51
+ out.push({ kind: 'comments' });
52
+ if (entry.protected !== undefined || entry.protection !== undefined)
53
+ out.push({ kind: 'protection' });
54
+ if (entry.pageSetup !== undefined)
55
+ out.push({ kind: 'page-setup' });
56
+ if (entry.objects !== undefined)
57
+ out.push({ kind: 'objects' });
58
+ if (entry.sparklines !== undefined)
59
+ out.push({ kind: 'sparklines' });
60
+ if (entry.pivots !== undefined)
61
+ out.push({ kind: 'pivots' });
62
+ if (entry.links !== undefined)
63
+ out.push({ kind: 'links' });
64
+ if (entry.merges !== undefined)
65
+ out.push({ kind: 'merges' });
66
+ if (entry.validation !== undefined)
67
+ out.push({ kind: 'validation' });
68
+ if (entry.conditionalFormats !== undefined)
69
+ out.push({ kind: 'conditional-formats' });
70
+ if (entry.autoFilter !== undefined)
71
+ out.push({ kind: 'filter' });
72
+ return out;
73
+ }
74
+ function emptySheetState() {
75
+ return {
76
+ formats: createFormatStore(),
77
+ widths: {},
78
+ heights: new Map(),
79
+ hidden: { rows: new Set(), cols: new Set() },
80
+ outline: { rows: emptyOutline(), cols: emptyOutline() },
81
+ freeze: { rows: 0, cols: 0 },
82
+ notes: {},
83
+ protected: false,
84
+ protection: defaultProtection(),
85
+ pageSetup: defaultPageSetup(),
86
+ objects: [],
87
+ sparklines: [],
88
+ pivots: [],
89
+ links: {},
90
+ sheetHidden: false,
91
+ kind: 'cells',
92
+ merges: [],
93
+ validation: [],
94
+ conditionalFormats: [],
95
+ cellTypes: [],
96
+ autoFilter: null,
97
+ filterHidden: new Set(),
98
+ };
99
+ }
100
+ export function createSheetDocument(init = {}) {
101
+ const workbook = init.workbook ??
102
+ createWorkbook(init.state ? init.state.workbook.sheets.map((s) => ({ name: s.name, cells: s.cells })) : (init.sheets ? [...init.sheets] : [{ name: 'Sheet1', cells: [] }]), {
103
+ ...(init.state?.workbook.tables?.length ? { tables: init.state.workbook.tables } : {}),
104
+ ...(init.state?.workbook.iteration ? { iteration: init.state.workbook.iteration } : {}),
105
+ });
106
+ const entries = new Map();
107
+ const listeners = new Set();
108
+ let pending = [];
109
+ let scheduled = false;
110
+ let muted = 0;
111
+ const key = (name) => name.toLowerCase();
112
+ function get(name) {
113
+ let found = entries.get(key(name));
114
+ if (!found) {
115
+ found = emptySheetState();
116
+ entries.set(key(name), found);
117
+ }
118
+ return found;
119
+ }
120
+ function flush() {
121
+ scheduled = false;
122
+ const batch = pending;
123
+ pending = [];
124
+ for (const listener of listeners)
125
+ listener(batch);
126
+ }
127
+ function changed(reason) {
128
+ if (muted > 0)
129
+ return;
130
+ // The same plain reason twice in a tick says nothing new; a structural
131
+ // edit is worth hearing about each time.
132
+ if (reason.kind !== 'structure' && pending.some((r) => r.kind === reason.kind))
133
+ return;
134
+ pending.push(reason);
135
+ if (scheduled)
136
+ return;
137
+ scheduled = true;
138
+ queueMicrotask(flush);
139
+ }
140
+ /** A row of comments copied deep enough that a saved thread is not the live one. */
141
+ function copyLine(line) {
142
+ const out = {};
143
+ for (const [c, v] of Object.entries(line))
144
+ out[c] = typeof v === 'string' ? v : { ...v, ...(v.replies ? { replies: v.replies.map((r) => ({ ...r })) } : {}) };
145
+ return out;
146
+ }
147
+ function serializeEntry(state) {
148
+ return {
149
+ formats: state.formats.serialize(),
150
+ columnWidths: { ...state.widths },
151
+ rowHeights: [...state.heights].map(([r, h]) => [r, h]),
152
+ hidden: { rows: [...state.hidden.rows], cols: [...state.hidden.cols] },
153
+ outline: { rows: copyOutline(state.outline.rows), cols: copyOutline(state.outline.cols) },
154
+ freeze: { ...state.freeze },
155
+ comments: Object.fromEntries(Object.entries(state.notes).map(([r, line]) => [r, copyLine(line)])),
156
+ protected: state.protected,
157
+ protection: copyProtection(state.protection),
158
+ pageSetup: copyPageSetup(state.pageSetup),
159
+ objects: state.objects.map(copyObject),
160
+ sparklines: state.sparklines.map(copySparkline),
161
+ pivots: state.pivots.map(copyPivot),
162
+ links: copyLinks(state.links),
163
+ sheetHidden: state.sheetHidden,
164
+ kind: state.kind,
165
+ ...(state.grid ? { grid: copyGridSheet(state.grid) } : {}),
166
+ merges: state.merges.map(([r1, c1, r2, c2]) => [r1, c1, r2, c2]),
167
+ validation: state.validation.map((rule) => ({ ...rule, rects: rule.rects.map((r) => [...r]), alert: { ...rule.alert } })),
168
+ conditionalFormats: state.conditionalFormats.map((rule) => ({ ...rule, rects: rule.rects.map((r) => [...r]) })),
169
+ cellTypes: state.cellTypes.map(copyCellType),
170
+ autoFilter: state.autoFilter ? { range: [...state.autoFilter.range], filters: { ...state.autoFilter.filters } } : null,
171
+ };
172
+ }
173
+ /**
174
+ * Put back only the parts an entry names, leaving the rest as they are.
175
+ * `hydrateEntry` below is the whole-sheet version, which resets what is
176
+ * absent to its default; this one is what a delta applies, since a delta
177
+ * carries the one feature that changed.
178
+ */
179
+ function patchEntry(state, entry) {
180
+ if (entry.formats !== undefined)
181
+ state.formats.hydrate(entry.formats);
182
+ if (entry.columnWidths !== undefined)
183
+ state.widths = { ...entry.columnWidths };
184
+ if (entry.rowHeights !== undefined)
185
+ state.heights = new Map(entry.rowHeights);
186
+ if (entry.hidden !== undefined)
187
+ state.hidden = { rows: new Set(entry.hidden.rows ?? []), cols: new Set(entry.hidden.cols ?? []) };
188
+ if (entry.outline !== undefined)
189
+ state.outline = { rows: copyOutline(entry.outline.rows), cols: copyOutline(entry.outline.cols) };
190
+ if (entry.freeze !== undefined)
191
+ state.freeze = { rows: entry.freeze.rows ?? 0, cols: entry.freeze.cols ?? 0 };
192
+ if (entry.comments !== undefined)
193
+ state.notes = Object.fromEntries(Object.entries(entry.comments).map(([r, line]) => [r, copyLine(line)]));
194
+ if (entry.protected !== undefined)
195
+ state.protected = entry.protected;
196
+ if (entry.protection !== undefined)
197
+ state.protection = copyProtection({ allow: entry.protection.allow ?? {}, ranges: entry.protection.ranges ?? [] });
198
+ if (entry.pageSetup !== undefined)
199
+ state.pageSetup = copyPageSetup({ ...defaultPageSetup(), ...entry.pageSetup });
200
+ if (entry.objects !== undefined)
201
+ state.objects = entry.objects.map(copyObject);
202
+ if (entry.sparklines !== undefined)
203
+ state.sparklines = entry.sparklines.map(copySparkline);
204
+ if (entry.pivots !== undefined)
205
+ state.pivots = entry.pivots.map(copyPivot);
206
+ if (entry.links !== undefined)
207
+ state.links = copyLinks(entry.links);
208
+ if (entry.sheetHidden !== undefined)
209
+ state.sheetHidden = entry.sheetHidden;
210
+ if (entry.kind !== undefined)
211
+ state.kind = entry.kind;
212
+ if (entry.grid !== undefined)
213
+ state.grid = copyGridSheet(entry.grid);
214
+ if (entry.merges !== undefined)
215
+ state.merges = entry.merges.map(([r1, c1, r2, c2]) => [r1, c1, r2, c2]);
216
+ if (entry.validation !== undefined) {
217
+ state.validation = entry.validation.map((rule) => ({
218
+ ...rule,
219
+ rects: rule.rects.map(([r1, c1, r2, c2]) => [r1, c1, r2, c2]),
220
+ alert: { ...rule.alert },
221
+ }));
222
+ }
223
+ if (entry.conditionalFormats !== undefined) {
224
+ state.conditionalFormats = entry.conditionalFormats.map((rule) => ({
225
+ ...rule,
226
+ rects: rule.rects.map(([r1, c1, r2, c2]) => [r1, c1, r2, c2]),
227
+ }));
228
+ }
229
+ if (entry.cellTypes !== undefined)
230
+ state.cellTypes = entry.cellTypes.map(copyCellType);
231
+ if (entry.autoFilter !== undefined) {
232
+ const af = entry.autoFilter;
233
+ state.autoFilter = af ? { range: [af.range[0], af.range[1], af.range[2], af.range[3]], filters: { ...af.filters } } : null;
234
+ state.filterHidden = new Set();
235
+ }
236
+ }
237
+ function hydrateEntry(state, entry) {
238
+ state.formats.hydrate(entry.formats ?? {});
239
+ state.widths = { ...(entry.columnWidths ?? {}) };
240
+ state.heights = new Map(entry.rowHeights ?? []);
241
+ state.hidden = { rows: new Set(entry.hidden?.rows ?? []), cols: new Set(entry.hidden?.cols ?? []) };
242
+ state.outline = { rows: copyOutline(entry.outline?.rows), cols: copyOutline(entry.outline?.cols) };
243
+ state.freeze = { rows: entry.freeze?.rows ?? 0, cols: entry.freeze?.cols ?? 0 };
244
+ state.notes = Object.fromEntries(Object.entries(entry.comments ?? {}).map(([r, line]) => [r, copyLine(line)]));
245
+ state.protected = entry.protected ?? false;
246
+ state.protection = entry.protection ? copyProtection({ allow: entry.protection.allow ?? {}, ranges: entry.protection.ranges ?? [] }) : defaultProtection();
247
+ state.pageSetup = entry.pageSetup ? copyPageSetup({ ...defaultPageSetup(), ...entry.pageSetup }) : defaultPageSetup();
248
+ state.objects = (entry.objects ?? []).map(copyObject);
249
+ state.sparklines = (entry.sparklines ?? []).map(copySparkline);
250
+ state.pivots = (entry.pivots ?? []).map(copyPivot);
251
+ state.links = copyLinks(entry.links ?? {});
252
+ state.sheetHidden = entry.sheetHidden ?? false;
253
+ state.kind = entry.kind ?? 'cells';
254
+ state.grid = entry.grid ? copyGridSheet(entry.grid) : undefined;
255
+ state.merges = (entry.merges ?? []).map(([r1, c1, r2, c2]) => [r1, c1, r2, c2]);
256
+ state.validation = (entry.validation ?? []).map((rule) => ({
257
+ ...rule,
258
+ rects: rule.rects.map(([r1, c1, r2, c2]) => [r1, c1, r2, c2]),
259
+ alert: { ...rule.alert },
260
+ }));
261
+ state.conditionalFormats = (entry.conditionalFormats ?? []).map((rule) => ({
262
+ ...rule,
263
+ rects: rule.rects.map(([r1, c1, r2, c2]) => [r1, c1, r2, c2]),
264
+ }));
265
+ state.cellTypes = (entry.cellTypes ?? []).map(copyCellType);
266
+ const af = entry.autoFilter;
267
+ state.autoFilter = af ? { range: [af.range[0], af.range[1], af.range[2], af.range[3]], filters: { ...af.filters } } : null;
268
+ state.filterHidden = new Set();
269
+ }
270
+ const document = {
271
+ workbook,
272
+ get,
273
+ patch(name, entry) {
274
+ patchEntry(get(name), entry);
275
+ for (const reason of reasonsForEntry(entry))
276
+ changed(reason);
277
+ },
278
+ has: (name) => entries.has(key(name)),
279
+ rename(from, to) {
280
+ const moved = entries.get(key(from));
281
+ entries.delete(key(from));
282
+ if (moved)
283
+ entries.set(key(to), moved);
284
+ },
285
+ remove(name) {
286
+ entries.delete(key(name));
287
+ },
288
+ duplicate(from, to) {
289
+ const made = workbook.copySheet(from, to);
290
+ if (made === null)
291
+ return null;
292
+ // Through the JSON shape, so nothing is shared between the two.
293
+ const copy = JSON.parse(JSON.stringify(serializeEntry(get(from))));
294
+ copy.sheetHidden = false;
295
+ // The copy's chart, picture, sparkline and pivot are its own, so they
296
+ // get their own ids the way Excel's Move or Copy does. Sharing them
297
+ // would mean a shell that tracks the selected object by id following
298
+ // the copy's one across a sheet switch, and deleting it there.
299
+ copy.objects = copy.objects?.map((object) => ({ ...object, id: objectId() }));
300
+ copy.sparklines = copy.sparklines?.map((group) => ({ ...group, id: sparklineId() }));
301
+ copy.pivots = copy.pivots?.map((pivot) => ({ ...pivot, id: pivotId() }));
302
+ hydrateEntry(get(made), copy);
303
+ changed({ kind: 'sheets' });
304
+ return made;
305
+ },
306
+ names: () => [...entries.keys()],
307
+ shift(name, edit) {
308
+ const state = get(name);
309
+ const shift = lineShift(edit);
310
+ const rows = edit.kind === 'insertRows' || edit.kind === 'deleteRows';
311
+ if (rows) {
312
+ state.formats.remapRows((id) => {
313
+ const i = Number(id.slice(1));
314
+ const next = Number.isInteger(i) ? shift(i) : i;
315
+ return next === null ? null : `r${next}`;
316
+ });
317
+ const heights = new Map();
318
+ for (const [r, h] of state.heights) {
319
+ const next = shift(r);
320
+ if (next !== null)
321
+ heights.set(next, h);
322
+ }
323
+ state.heights = heights;
324
+ const hiddenRows = new Set();
325
+ for (const r of state.hidden.rows) {
326
+ const next = shift(r);
327
+ if (next !== null)
328
+ hiddenRows.add(next);
329
+ }
330
+ state.hidden = { rows: hiddenRows, cols: state.hidden.cols };
331
+ state.notes = remapNotes(state.notes, 'rows', shift);
332
+ }
333
+ else {
334
+ state.formats.remapColumns((id) => {
335
+ const i = lettersToCol(id);
336
+ const next = i < 0 ? i : shift(i);
337
+ return next === null ? null : colToLetters(next);
338
+ });
339
+ const widths = {};
340
+ for (const [letter, w] of Object.entries(state.widths)) {
341
+ const i = lettersToCol(letter);
342
+ const next = i < 0 ? i : shift(i);
343
+ if (next !== null)
344
+ widths[i < 0 ? letter : colToLetters(next)] = w;
345
+ }
346
+ state.widths = widths;
347
+ const hiddenCols = new Set();
348
+ for (const c of state.hidden.cols) {
349
+ const next = shift(c);
350
+ if (next !== null)
351
+ hiddenCols.add(next);
352
+ }
353
+ state.hidden = { rows: state.hidden.rows, cols: hiddenCols };
354
+ state.outline = { rows: state.outline.rows, cols: shiftOutline(state.outline.cols, edit.at, edit.count * (edit.kind === 'deleteCols' ? -1 : 1)) };
355
+ state.notes = remapNotes(state.notes, 'cols', shift);
356
+ }
357
+ state.merges = state.merges.map((m) => shiftRect(m, edit)).filter((m) => m !== null);
358
+ state.validation = shiftValidation(state.validation, edit);
359
+ state.conditionalFormats = shiftCf(state.conditionalFormats, edit);
360
+ state.cellTypes = shiftCellTypes(state.cellTypes, edit);
361
+ state.autoFilter = shiftAutoFilter(state.autoFilter, edit);
362
+ state.pageSetup = shiftPageSetup(state.pageSetup, edit);
363
+ state.objects = shiftObjects(state.objects, edit);
364
+ state.sparklines = shiftSparklines(state.sparklines, edit);
365
+ state.pivots = shiftPivots(state.pivots, edit);
366
+ state.links = shiftLinks(state.links, edit);
367
+ state.protection = {
368
+ allow: state.protection.allow,
369
+ ranges: state.protection.ranges
370
+ .map((range) => ({ ...range, rects: range.rects.map((r) => shiftRect(r, edit)).filter((r) => r !== null) }))
371
+ .filter((range) => range.rects.length > 0),
372
+ };
373
+ },
374
+ getState() {
375
+ const sheets = {};
376
+ for (const name of workbook.sheets)
377
+ sheets[name] = serializeEntry(get(name));
378
+ return { version: 1, workbook: workbook.serialize(), sheets };
379
+ },
380
+ setState(state) {
381
+ document.mute(() => {
382
+ const wanted = state.workbook.sheets.map((s) => s.name);
383
+ const wantedKeys = new Set(wanted.map(key));
384
+ // Sheets to add, then the ones to drop (never the last one standing),
385
+ // then the order, then the cells.
386
+ for (const name of wanted) {
387
+ if (!workbook.sheets.some((s) => key(s) === key(name)))
388
+ workbook.addSheet(name);
389
+ }
390
+ for (const name of [...workbook.sheets]) {
391
+ if (!wantedKeys.has(key(name)) && workbook.sheets.length > 1) {
392
+ workbook.removeSheet(name);
393
+ entries.delete(key(name));
394
+ }
395
+ }
396
+ wanted.forEach((name, index) => {
397
+ if (workbook.sheets[index]?.toLowerCase() !== key(name))
398
+ workbook.moveSheet(name, index);
399
+ });
400
+ for (const sheet of state.workbook.sheets) {
401
+ const rows = Math.max(workbook.rowCount(sheet.name), sheet.cells.length);
402
+ for (let r = 0; r < rows; r += 1) {
403
+ const cols = Math.max(workbook.colCount(sheet.name), sheet.cells[r]?.length ?? 0);
404
+ for (let c = 0; c < cols; c += 1) {
405
+ const text = sheet.cells[r]?.[c] ?? '';
406
+ if (workbook.getRaw(sheet.name, r, c) !== text)
407
+ workbook.setRaw(sheet.name, r, c, text);
408
+ }
409
+ }
410
+ }
411
+ workbook.names.hydrate(state.workbook.names ?? {});
412
+ // Tables are workbook-wide, and the registry is what a structured
413
+ // reference resolves through: put back exactly the saved set.
414
+ workbook.tables.clear();
415
+ for (const table of state.workbook.tables ?? [])
416
+ workbook.tables.define({ ...table });
417
+ // Iterative calculation is workbook-wide too, and absent in a saved
418
+ // document that never turned it on, which means off.
419
+ workbook.setIteration(state.workbook.iteration ?? { enabled: false });
420
+ if (workbook.sheets.some((s) => key(s) === key(state.workbook.active)))
421
+ workbook.setActive(state.workbook.active);
422
+ // Entries are hydrated in place, never replaced: a format store the
423
+ // shell has registered as its target must stay the store in use, or
424
+ // every format written after a restore would land in an orphan.
425
+ const kept = new Set(Object.keys(state.sheets ?? {}).map(key));
426
+ for (const name of [...entries.keys()])
427
+ if (!kept.has(name) && !wantedKeys.has(name))
428
+ entries.delete(name);
429
+ for (const name of workbook.sheets)
430
+ hydrateEntry(get(name), state.sheets?.[name] ?? {});
431
+ for (const name of workbook.sheets)
432
+ releaseFilteredRows(document, name);
433
+ });
434
+ changed({ kind: 'restore' });
435
+ },
436
+ subscribe(listener) {
437
+ listeners.add(listener);
438
+ return () => {
439
+ listeners.delete(listener);
440
+ };
441
+ },
442
+ changed,
443
+ mute(fn) {
444
+ muted += 1;
445
+ try {
446
+ return fn();
447
+ }
448
+ finally {
449
+ muted -= 1;
450
+ }
451
+ },
452
+ };
453
+ if (init.state) {
454
+ document.mute(() => {
455
+ workbook.names.hydrate(init.state.workbook.names ?? {});
456
+ if (workbook.sheets.some((s) => key(s) === key(init.state.workbook.active)))
457
+ workbook.setActive(init.state.workbook.active);
458
+ for (const [name, entry] of Object.entries(init.state.sheets ?? {}))
459
+ hydrateEntry(get(name), entry);
460
+ for (const name of workbook.sheets)
461
+ releaseFilteredRows(document, name);
462
+ });
463
+ }
464
+ return document;
465
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Keys that act on the text of a formula while it is being written.
3
+ *
4
+ * F4 in Excel cycles the reference at the caret through its four anchorings:
5
+ * `A1` -> `$A$1` -> `A$1` -> `$A1` -> `A1`, both ends of a range together.
6
+ * The caret counts as "at" a reference when it sits inside it or right after
7
+ * it, which is where it is after typing one. A sheet prefix (`Orders!A1`)
8
+ * is left as it is; only the cell part turns.
9
+ */
10
+ export type TextEdit = {
11
+ text: string;
12
+ caret: number;
13
+ };
14
+ export declare function cycleReference(text: string, caret: number): TextEdit | null;
@@ -0,0 +1,40 @@
1
+ const CELL = String.raw `\$?[A-Za-z]{1,3}\$?\d+`;
2
+ const REFERENCE = new RegExp(String.raw `(${CELL})(?::(${CELL}))?`, 'g');
3
+ /** The next anchoring in Excel's F4 order. */
4
+ function turn(cell) {
5
+ const m = /^(\$?)([A-Za-z]+)(\$?)(\d+)$/.exec(cell);
6
+ if (!m)
7
+ return cell;
8
+ const [, colAbs, col, rowAbs, row] = m;
9
+ const state = (colAbs ? 2 : 0) + (rowAbs ? 1 : 0);
10
+ // relative -> both -> row only -> column only -> relative
11
+ const next = { 0: 3, 3: 1, 1: 2, 2: 0 }[state];
12
+ return `${next & 2 ? '$' : ''}${col}${next & 1 ? '$' : ''}${row}`;
13
+ }
14
+ export function cycleReference(text, caret) {
15
+ if (!text.startsWith('='))
16
+ return null;
17
+ REFERENCE.lastIndex = 0;
18
+ let m;
19
+ while ((m = REFERENCE.exec(text)) !== null) {
20
+ const start = m.index;
21
+ const end = start + m[0].length;
22
+ if (caret < start || caret > end)
23
+ continue;
24
+ // A word character before the match means this is part of a name or a
25
+ // function (SUM1 is not a cell), not a reference.
26
+ const before = text[start - 1];
27
+ if (before && /[A-Za-z0-9_.]/.test(before))
28
+ continue;
29
+ // And a parenthesis after it makes it a function call: SUM1 is a cell in
30
+ // Excel's grid, SUM1( is not.
31
+ if (text[end] === '(')
32
+ continue;
33
+ const replaced = m[2] ? `${turn(m[1])}:${turn(m[2])}` : turn(m[1]);
34
+ return {
35
+ text: text.slice(0, start) + replaced + text.slice(end),
36
+ caret: start + replaced.length,
37
+ };
38
+ }
39
+ return null;
40
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * The seam between the workbook and whatever works a formula out.
3
+ *
4
+ * The built-in engine (the tokenizer, parser and evaluator beside this
5
+ * file) is the one the sheet ships with and the one it is tested against.
6
+ * The seam is here for an application that has its own evaluator to put
7
+ * behind the same sheet: `createWorkbook(sheets, { engine: mine })`.
8
+ *
9
+ * What an engine is asked for is narrow on purpose: a formula's value in
10
+ * a cell, and the grid it spills when it has one. The workbook keeps
11
+ * everything else, because none of it is the engine's to decide. The
12
+ * dependency graph, the volatile set, the value cache, cycle detection
13
+ * and the spill ranges are all read off the reference grammar, which is
14
+ * Excel's whatever evaluates it, so they stay correct for any engine and
15
+ * an engine cannot get them wrong.
16
+ *
17
+ * `load` and `write` are the lifecycle an engine with a copy of the cells
18
+ * needs: `load` when the workbook is built and whenever its cells change
19
+ * wholesale (a structural edit, a sheet added or renamed, a restore),
20
+ * `write` on a single cell. An engine that reads through `host` on demand,
21
+ * as the built-in does, leaves both off.
22
+ */
23
+ import type { CellValue, Node } from './ast.js';
24
+ import type { EvalContext } from './evaluate.js';
25
+ import type { SheetData } from './workbook.js';
26
+ /** Where a formula sits. */
27
+ export type SheetEngineCell = {
28
+ sheet: string;
29
+ row: number;
30
+ col: number;
31
+ };
32
+ export type SheetEngineHost = {
33
+ /**
34
+ * The context the built-in evaluator uses for this cell: `resolve` reads
35
+ * through the workbook's cache and cycle detection, so an engine that
36
+ * wants a precedent's value asks here rather than reading raw text.
37
+ */
38
+ context: EvalContext;
39
+ /** The workbook's parse cache: one parse per distinct formula text, null when it does not parse. */
40
+ parse(text: string): Node | null;
41
+ };
42
+ export type SheetEngineResult = {
43
+ value: CellValue;
44
+ /**
45
+ * The grid the formula spills, or null / absent for a plain value. The
46
+ * workbook lays it over the cells below and to the right, refuses it
47
+ * with `#SPILL!` where something is in the way, and moves it with an
48
+ * insert or delete.
49
+ */
50
+ spill?: CellValue[][] | null;
51
+ };
52
+ export type SheetEngine = {
53
+ /** For the docs and an error message; the built-in is `'builtin'`. */
54
+ name?: string;
55
+ /** Every sheet's raw text, at creation and after a wholesale change. */
56
+ load?(sheets: ReadonlyArray<SheetData>): void;
57
+ /** One cell's raw text changed. */
58
+ write?(sheet: string, row: number, col: number, text: string): void;
59
+ /** What the formula is worth here. `text` keeps its leading `=`. */
60
+ evaluate(text: string, at: SheetEngineCell, host: SheetEngineHost): SheetEngineResult;
61
+ };
62
+ /**
63
+ * The engine the sheet ships with: the parser and evaluator in this
64
+ * folder, which read the workbook's own cells through the host's context
65
+ * and so need no copy of anything.
66
+ */
67
+ export declare function builtinEngine(): SheetEngine;
@@ -0,0 +1,19 @@
1
+ import { evaluate, evaluateSpill } from './evaluate.js';
2
+ /**
3
+ * The engine the sheet ships with: the parser and evaluator in this
4
+ * folder, which read the workbook's own cells through the host's context
5
+ * and so need no copy of anything.
6
+ */
7
+ export function builtinEngine() {
8
+ return {
9
+ name: 'builtin',
10
+ evaluate(text, _at, host) {
11
+ const ast = host.parse(text);
12
+ if (!ast)
13
+ return { value: { error: '#PARSE!' } };
14
+ const value = evaluate(ast, host.context);
15
+ const spill = typeof value === 'object' && value !== null && 'error' in value ? null : evaluateSpill(ast, host.context);
16
+ return { value, spill };
17
+ },
18
+ };
19
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * What Excel makes of a typed entry before it is stored.
3
+ *
4
+ * `12%` is the number 0.12 shown as a percentage, `$1,200` is 1200 shown
5
+ * as currency, `1,234.5` is 1234.5 with a thousands separator: the text
6
+ * the user typed names both a value and how to show it, and the cell keeps
7
+ * both, so `=A1*2` over a `12%` cell is 0.24 rather than `#VALUE!`. The
8
+ * format is the one Excel would pick, with the decimals the user typed.
9
+ * `3/4/2026` is the sheet's `2026-03-04` under a date format and `10:30`
10
+ * is 0.4375 of a day under a time format, for the same reason. Anything
11
+ * else, formulas included, is stored as typed.
12
+ */
13
+ import { type SheetCulture } from './culture.js';
14
+ export type ParsedEntry = {
15
+ /** The number, as text the workbook stores. */
16
+ value: string;
17
+ /** The Excel format string the entry implies; none for a bare number
18
+ * read out of an accountant's parentheses, which Excel shows as General. */
19
+ numFmt?: string;
20
+ };
21
+ /**
22
+ * Excel's AutoComplete for a column of text.
23
+ *
24
+ * As a cell is typed into, the entries in the same column that run without
25
+ * a blank above and below it are the candidates; when exactly one distinct
26
+ * text entry starts with what was typed, that entry is the completion, in
27
+ * its own case ("jo" completes to "John Smith"). Two candidates that both
28
+ * fit ("Apple", "Apricot" for "Ap") complete nothing until the typing tells
29
+ * them apart. Numbers, formulas and booleans never complete, and a typed
30
+ * text that already is an entry needs none.
31
+ *
32
+ * `entries` are the distinct text entries of the run, any order.
33
+ */
34
+ export declare function completeEntry(typed: string, entries: Iterable<string>): string | null;
35
+ export declare function parseEntry(text: string, culture?: SheetCulture): ParsedEntry | null;