@trebco/treb 36.1.4 → 37.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (552) hide show
  1. package/api-config.json +1 -1
  2. package/build/package.json +119 -0
  3. package/build/treb-base-types/src/api_types.d.ts +11 -0
  4. package/build/treb-base-types/src/api_types.js +22 -0
  5. package/build/treb-base-types/src/api_types.js.map +1 -0
  6. package/build/treb-base-types/src/area-utils.d.ts +9 -0
  7. package/build/treb-base-types/src/area-utils.js +50 -0
  8. package/build/treb-base-types/src/area-utils.js.map +1 -0
  9. package/build/treb-base-types/src/area.d.ts +182 -0
  10. package/build/treb-base-types/src/area.js +715 -0
  11. package/build/treb-base-types/src/area.js.map +1 -0
  12. package/build/treb-base-types/src/basic_types.d.ts +20 -0
  13. package/build/treb-base-types/src/basic_types.js +22 -0
  14. package/build/treb-base-types/src/basic_types.js.map +1 -0
  15. package/build/treb-base-types/src/cell.d.ts +167 -0
  16. package/build/treb-base-types/src/cell.js +432 -0
  17. package/build/treb-base-types/src/cell.js.map +1 -0
  18. package/build/treb-base-types/src/cells.d.ts +251 -0
  19. package/build/treb-base-types/src/cells.js +1136 -0
  20. package/build/treb-base-types/src/cells.js.map +1 -0
  21. package/build/treb-base-types/src/color.d.ts +35 -0
  22. package/build/treb-base-types/src/color.js +162 -0
  23. package/build/treb-base-types/src/color.js.map +1 -0
  24. package/build/treb-base-types/src/dom-utilities.d.ts +70 -0
  25. package/build/treb-base-types/src/dom-utilities.js +144 -0
  26. package/build/treb-base-types/src/dom-utilities.js.map +1 -0
  27. package/build/treb-base-types/src/evaluate-options.d.ts +35 -0
  28. package/build/treb-base-types/src/evaluate-options.js +22 -0
  29. package/build/treb-base-types/src/evaluate-options.js.map +1 -0
  30. package/build/treb-base-types/src/font-stack.d.ts +37 -0
  31. package/build/treb-base-types/src/font-stack.js +93 -0
  32. package/build/treb-base-types/src/font-stack.js.map +1 -0
  33. package/build/treb-base-types/src/gradient.d.ts +18 -0
  34. package/build/treb-base-types/src/gradient.js +86 -0
  35. package/build/treb-base-types/src/gradient.js.map +1 -0
  36. package/build/treb-base-types/src/import.d.ts +48 -0
  37. package/build/treb-base-types/src/import.js +22 -0
  38. package/build/treb-base-types/src/import.js.map +1 -0
  39. package/build/treb-base-types/src/index-standalone.d.ts +6 -0
  40. package/build/treb-base-types/src/index-standalone.js +27 -0
  41. package/build/treb-base-types/src/index-standalone.js.map +1 -0
  42. package/build/treb-base-types/src/index.d.ts +22 -0
  43. package/build/treb-base-types/src/index.js +45 -0
  44. package/build/treb-base-types/src/index.js.map +1 -0
  45. package/build/treb-base-types/src/layout.d.ts +22 -0
  46. package/build/treb-base-types/src/layout.js +22 -0
  47. package/build/treb-base-types/src/layout.js.map +1 -0
  48. package/build/treb-base-types/src/localization.d.ts +37 -0
  49. package/build/treb-base-types/src/localization.js +157 -0
  50. package/build/treb-base-types/src/localization.js.map +1 -0
  51. package/build/treb-base-types/src/rectangle.d.ts +51 -0
  52. package/build/treb-base-types/src/rectangle.js +123 -0
  53. package/build/treb-base-types/src/rectangle.js.map +1 -0
  54. package/build/treb-base-types/src/render_text.d.ts +34 -0
  55. package/build/treb-base-types/src/render_text.js +22 -0
  56. package/build/treb-base-types/src/render_text.js.map +1 -0
  57. package/build/treb-base-types/src/style.d.ts +214 -0
  58. package/build/treb-base-types/src/style.js +373 -0
  59. package/build/treb-base-types/src/style.js.map +1 -0
  60. package/build/treb-base-types/src/table.d.ts +58 -0
  61. package/build/treb-base-types/src/table.js +27 -0
  62. package/build/treb-base-types/src/table.js.map +1 -0
  63. package/build/treb-base-types/src/text_part.d.ts +26 -0
  64. package/build/treb-base-types/src/text_part.js +47 -0
  65. package/build/treb-base-types/src/text_part.js.map +1 -0
  66. package/build/treb-base-types/src/theme.d.ts +120 -0
  67. package/build/treb-base-types/src/theme.js +460 -0
  68. package/build/treb-base-types/src/theme.js.map +1 -0
  69. package/build/treb-base-types/src/union.d.ts +73 -0
  70. package/build/treb-base-types/src/union.js +61 -0
  71. package/build/treb-base-types/src/union.js.map +1 -0
  72. package/build/treb-base-types/src/value-type.d.ts +86 -0
  73. package/build/treb-base-types/src/value-type.js +168 -0
  74. package/build/treb-base-types/src/value-type.js.map +1 -0
  75. package/build/treb-base-types/src/worker-proxy.d.ts +95 -0
  76. package/build/treb-base-types/src/worker-proxy.js +221 -0
  77. package/build/treb-base-types/src/worker-proxy.js.map +1 -0
  78. package/build/treb-calculator/src/calculator.d.ts +249 -0
  79. package/build/treb-calculator/src/calculator.js +2755 -0
  80. package/build/treb-calculator/src/calculator.js.map +1 -0
  81. package/build/treb-calculator/src/complex-math.d.ts +75 -0
  82. package/build/treb-calculator/src/complex-math.js +559 -0
  83. package/build/treb-calculator/src/complex-math.js.map +1 -0
  84. package/build/treb-calculator/src/dag/array-vertex.d.ts +71 -0
  85. package/build/treb-calculator/src/dag/array-vertex.js +156 -0
  86. package/build/treb-calculator/src/dag/array-vertex.js.map +1 -0
  87. package/build/treb-calculator/src/dag/calculation_leaf_vertex.d.ts +48 -0
  88. package/build/treb-calculator/src/dag/calculation_leaf_vertex.js +84 -0
  89. package/build/treb-calculator/src/dag/calculation_leaf_vertex.js.map +1 -0
  90. package/build/treb-calculator/src/dag/graph.d.ts +134 -0
  91. package/build/treb-calculator/src/dag/graph.js +842 -0
  92. package/build/treb-calculator/src/dag/graph.js.map +1 -0
  93. package/build/treb-calculator/src/dag/spreadsheet_vertex.d.ts +58 -0
  94. package/build/treb-calculator/src/dag/spreadsheet_vertex.js +232 -0
  95. package/build/treb-calculator/src/dag/spreadsheet_vertex.js.map +1 -0
  96. package/build/treb-calculator/src/dag/spreadsheet_vertex_base.d.ts +20 -0
  97. package/build/treb-calculator/src/dag/spreadsheet_vertex_base.js +25 -0
  98. package/build/treb-calculator/src/dag/spreadsheet_vertex_base.js.map +1 -0
  99. package/build/treb-calculator/src/dag/state_leaf_vertex.d.ts +43 -0
  100. package/build/treb-calculator/src/dag/state_leaf_vertex.js +81 -0
  101. package/build/treb-calculator/src/dag/state_leaf_vertex.js.map +1 -0
  102. package/build/treb-calculator/src/dag/vertex.d.ts +71 -0
  103. package/build/treb-calculator/src/dag/vertex.js +274 -0
  104. package/build/treb-calculator/src/dag/vertex.js.map +1 -0
  105. package/build/treb-calculator/src/descriptors.d.ts +189 -0
  106. package/build/treb-calculator/src/descriptors.js +22 -0
  107. package/build/treb-calculator/src/descriptors.js.map +1 -0
  108. package/build/treb-calculator/src/expression-calculator.d.ts +127 -0
  109. package/build/treb-calculator/src/expression-calculator.js +1033 -0
  110. package/build/treb-calculator/src/expression-calculator.js.map +1 -0
  111. package/build/treb-calculator/src/function-error.d.ts +35 -0
  112. package/build/treb-calculator/src/function-error.js +85 -0
  113. package/build/treb-calculator/src/function-error.js.map +1 -0
  114. package/build/treb-calculator/src/function-library.d.ts +22 -0
  115. package/build/treb-calculator/src/function-library.js +96 -0
  116. package/build/treb-calculator/src/function-library.js.map +1 -0
  117. package/build/treb-calculator/src/functions/base-functions.d.ts +7 -0
  118. package/build/treb-calculator/src/functions/base-functions.js +2611 -0
  119. package/build/treb-calculator/src/functions/base-functions.js.map +1 -0
  120. package/build/treb-calculator/src/functions/beta.d.ts +17 -0
  121. package/build/treb-calculator/src/functions/beta.js +201 -0
  122. package/build/treb-calculator/src/functions/beta.js.map +1 -0
  123. package/build/treb-calculator/src/functions/checkbox.d.ts +3 -0
  124. package/build/treb-calculator/src/functions/checkbox.js +128 -0
  125. package/build/treb-calculator/src/functions/checkbox.js.map +1 -0
  126. package/build/treb-calculator/src/functions/complex-functions.d.ts +2 -0
  127. package/build/treb-calculator/src/functions/complex-functions.js +217 -0
  128. package/build/treb-calculator/src/functions/complex-functions.js.map +1 -0
  129. package/build/treb-calculator/src/functions/date-utils.d.ts +3 -0
  130. package/build/treb-calculator/src/functions/date-utils.js +59 -0
  131. package/build/treb-calculator/src/functions/date-utils.js.map +1 -0
  132. package/build/treb-calculator/src/functions/finance-functions.d.ts +2 -0
  133. package/build/treb-calculator/src/functions/finance-functions.js +547 -0
  134. package/build/treb-calculator/src/functions/finance-functions.js.map +1 -0
  135. package/build/treb-calculator/src/functions/fp.d.ts +2 -0
  136. package/build/treb-calculator/src/functions/fp.js +463 -0
  137. package/build/treb-calculator/src/functions/fp.js.map +1 -0
  138. package/build/treb-calculator/src/functions/function-utilities.d.ts +2 -0
  139. package/build/treb-calculator/src/functions/function-utilities.js +36 -0
  140. package/build/treb-calculator/src/functions/function-utilities.js.map +1 -0
  141. package/build/treb-calculator/src/functions/gamma.d.ts +20 -0
  142. package/build/treb-calculator/src/functions/gamma.js +142 -0
  143. package/build/treb-calculator/src/functions/gamma.js.map +1 -0
  144. package/build/treb-calculator/src/functions/information-functions.d.ts +2 -0
  145. package/build/treb-calculator/src/functions/information-functions.js +71 -0
  146. package/build/treb-calculator/src/functions/information-functions.js.map +1 -0
  147. package/build/treb-calculator/src/functions/lambda-functions.d.ts +2 -0
  148. package/build/treb-calculator/src/functions/lambda-functions.js +85 -0
  149. package/build/treb-calculator/src/functions/lambda-functions.js.map +1 -0
  150. package/build/treb-calculator/src/functions/matrix-functions.d.ts +2 -0
  151. package/build/treb-calculator/src/functions/matrix-functions.js +144 -0
  152. package/build/treb-calculator/src/functions/matrix-functions.js.map +1 -0
  153. package/build/treb-calculator/src/functions/normal.d.ts +2 -0
  154. package/build/treb-calculator/src/functions/normal.js +32 -0
  155. package/build/treb-calculator/src/functions/normal.js.map +1 -0
  156. package/build/treb-calculator/src/functions/regex-functions.d.ts +2 -0
  157. package/build/treb-calculator/src/functions/regex-functions.js +188 -0
  158. package/build/treb-calculator/src/functions/regex-functions.js.map +1 -0
  159. package/build/treb-calculator/src/functions/sparkline.d.ts +37 -0
  160. package/build/treb-calculator/src/functions/sparkline.js +264 -0
  161. package/build/treb-calculator/src/functions/sparkline.js.map +1 -0
  162. package/build/treb-calculator/src/functions/statistics-functions.d.ts +6 -0
  163. package/build/treb-calculator/src/functions/statistics-functions.js +989 -0
  164. package/build/treb-calculator/src/functions/statistics-functions.js.map +1 -0
  165. package/build/treb-calculator/src/functions/students-t.d.ts +3 -0
  166. package/build/treb-calculator/src/functions/students-t.js +64 -0
  167. package/build/treb-calculator/src/functions/students-t.js.map +1 -0
  168. package/build/treb-calculator/src/functions/text-functions.d.ts +3 -0
  169. package/build/treb-calculator/src/functions/text-functions.js +320 -0
  170. package/build/treb-calculator/src/functions/text-functions.js.map +1 -0
  171. package/build/treb-calculator/src/index.d.ts +2 -0
  172. package/build/treb-calculator/src/index.js +22 -0
  173. package/build/treb-calculator/src/index.js.map +1 -0
  174. package/build/treb-calculator/src/notifier-types.d.ts +26 -0
  175. package/build/treb-calculator/src/notifier-types.js +22 -0
  176. package/build/treb-calculator/src/notifier-types.js.map +1 -0
  177. package/build/treb-calculator/src/primitives.d.ts +15 -0
  178. package/build/treb-calculator/src/primitives.js +398 -0
  179. package/build/treb-calculator/src/primitives.js.map +1 -0
  180. package/build/treb-calculator/src/utilities.d.ts +68 -0
  181. package/build/treb-calculator/src/utilities.js +324 -0
  182. package/build/treb-calculator/src/utilities.js.map +1 -0
  183. package/build/treb-charts/src/chart-functions.d.ts +8 -0
  184. package/build/treb-charts/src/chart-functions.js +209 -0
  185. package/build/treb-charts/src/chart-functions.js.map +1 -0
  186. package/build/treb-charts/src/chart-types.d.ts +233 -0
  187. package/build/treb-charts/src/chart-types.js +57 -0
  188. package/build/treb-charts/src/chart-types.js.map +1 -0
  189. package/build/treb-charts/src/chart-utils.d.ts +106 -0
  190. package/build/treb-charts/src/chart-utils.js +1060 -0
  191. package/build/treb-charts/src/chart-utils.js.map +1 -0
  192. package/build/treb-charts/src/chart.d.ts +23 -0
  193. package/build/treb-charts/src/chart.js +94 -0
  194. package/build/treb-charts/src/chart.js.map +1 -0
  195. package/build/treb-charts/src/default-chart-renderer.d.ts +16 -0
  196. package/build/treb-charts/src/default-chart-renderer.js +533 -0
  197. package/build/treb-charts/src/default-chart-renderer.js.map +1 -0
  198. package/build/treb-charts/src/index.d.ts +5 -0
  199. package/build/treb-charts/src/index.js +24 -0
  200. package/build/treb-charts/src/index.js.map +1 -0
  201. package/build/treb-charts/src/main.d.ts +1 -0
  202. package/build/treb-charts/src/main.js +34 -0
  203. package/build/treb-charts/src/main.js.map +1 -0
  204. package/build/treb-charts/src/quicksort.d.ts +1 -0
  205. package/build/treb-charts/src/quicksort.js +49 -0
  206. package/build/treb-charts/src/quicksort.js.map +1 -0
  207. package/build/treb-charts/src/rectangle.d.ts +18 -0
  208. package/build/treb-charts/src/rectangle.js +41 -0
  209. package/build/treb-charts/src/rectangle.js.map +1 -0
  210. package/build/treb-charts/src/renderer-type.d.ts +24 -0
  211. package/build/treb-charts/src/renderer-type.js +22 -0
  212. package/build/treb-charts/src/renderer-type.js.map +1 -0
  213. package/build/treb-charts/src/renderer.d.ts +127 -0
  214. package/build/treb-charts/src/renderer.js +1518 -0
  215. package/build/treb-charts/src/renderer.js.map +1 -0
  216. package/build/treb-charts/src/util.d.ts +18 -0
  217. package/build/treb-charts/src/util.js +71 -0
  218. package/build/treb-charts/src/util.js.map +1 -0
  219. package/build/treb-data-model/src/annotation.d.ts +167 -0
  220. package/build/treb-data-model/src/annotation.js +120 -0
  221. package/build/treb-data-model/src/annotation.js.map +1 -0
  222. package/build/treb-data-model/src/conditional_format.d.ts +155 -0
  223. package/build/treb-data-model/src/conditional_format.js +62 -0
  224. package/build/treb-data-model/src/conditional_format.js.map +1 -0
  225. package/build/treb-data-model/src/data-validation.d.ts +28 -0
  226. package/build/treb-data-model/src/data-validation.js +22 -0
  227. package/build/treb-data-model/src/data-validation.js.map +1 -0
  228. package/build/treb-data-model/src/data_model.d.ts +173 -0
  229. package/build/treb-data-model/src/data_model.js +637 -0
  230. package/build/treb-data-model/src/data_model.js.map +1 -0
  231. package/build/treb-data-model/src/index.d.ts +13 -0
  232. package/build/treb-data-model/src/index.js +28 -0
  233. package/build/treb-data-model/src/index.js.map +1 -0
  234. package/build/treb-data-model/src/language-model.d.ts +22 -0
  235. package/build/treb-data-model/src/language-model.js +22 -0
  236. package/build/treb-data-model/src/language-model.js.map +1 -0
  237. package/build/treb-data-model/src/named.d.ts +124 -0
  238. package/build/treb-data-model/src/named.js +372 -0
  239. package/build/treb-data-model/src/named.js.map +1 -0
  240. package/build/treb-data-model/src/serialize_options.d.ts +49 -0
  241. package/build/treb-data-model/src/serialize_options.js +22 -0
  242. package/build/treb-data-model/src/serialize_options.js.map +1 -0
  243. package/build/treb-data-model/src/sheet.d.ts +499 -0
  244. package/build/treb-data-model/src/sheet.js +2904 -0
  245. package/build/treb-data-model/src/sheet.js.map +1 -0
  246. package/build/treb-data-model/src/sheet_collection.d.ts +58 -0
  247. package/build/treb-data-model/src/sheet_collection.js +112 -0
  248. package/build/treb-data-model/src/sheet_collection.js.map +1 -0
  249. package/build/treb-data-model/src/sheet_selection.d.ts +42 -0
  250. package/build/treb-data-model/src/sheet_selection.js +39 -0
  251. package/build/treb-data-model/src/sheet_selection.js.map +1 -0
  252. package/build/treb-data-model/src/sheet_types.d.ts +104 -0
  253. package/build/treb-data-model/src/sheet_types.js +22 -0
  254. package/build/treb-data-model/src/sheet_types.js.map +1 -0
  255. package/build/treb-data-model/src/types.d.ts +59 -0
  256. package/build/treb-data-model/src/types.js +22 -0
  257. package/build/treb-data-model/src/types.js.map +1 -0
  258. package/build/treb-embed/src/custom-element/spreadsheet-constructor.d.ts +75 -0
  259. package/build/treb-embed/src/custom-element/spreadsheet-constructor.js +1144 -0
  260. package/build/treb-embed/src/custom-element/spreadsheet-constructor.js.map +1 -0
  261. package/build/treb-embed/src/custom-element/treb-global.d.ts +36 -0
  262. package/build/treb-embed/src/custom-element/treb-global.js +64 -0
  263. package/build/treb-embed/src/custom-element/treb-global.js.map +1 -0
  264. package/build/treb-embed/src/custom-element/treb-spreadsheet-element.d.ts +1 -0
  265. package/build/treb-embed/src/custom-element/treb-spreadsheet-element.js +61 -0
  266. package/build/treb-embed/src/custom-element/treb-spreadsheet-element.js.map +1 -0
  267. package/build/treb-embed/src/embedded-spreadsheet.d.ts +1358 -0
  268. package/build/treb-embed/src/embedded-spreadsheet.js +5205 -0
  269. package/build/treb-embed/src/embedded-spreadsheet.js.map +1 -0
  270. package/build/treb-embed/src/index.d.ts +12 -0
  271. package/build/treb-embed/src/index.js +34 -0
  272. package/build/treb-embed/src/index.js.map +1 -0
  273. package/build/treb-embed/src/options.d.ts +266 -0
  274. package/build/treb-embed/src/options.js +56 -0
  275. package/build/treb-embed/src/options.js.map +1 -0
  276. package/build/treb-embed/src/plugin.d.ts +9 -0
  277. package/build/treb-embed/src/plugin.js +22 -0
  278. package/build/treb-embed/src/plugin.js.map +1 -0
  279. package/build/treb-embed/src/progress-dialog.d.ts +49 -0
  280. package/build/treb-embed/src/progress-dialog.js +178 -0
  281. package/build/treb-embed/src/progress-dialog.js.map +1 -0
  282. package/build/treb-embed/src/selection-state.d.ts +15 -0
  283. package/build/treb-embed/src/selection-state.js +22 -0
  284. package/build/treb-embed/src/selection-state.js.map +1 -0
  285. package/build/treb-embed/src/spinner.d.ts +8 -0
  286. package/build/treb-embed/src/spinner.js +40 -0
  287. package/build/treb-embed/src/spinner.js.map +1 -0
  288. package/build/treb-embed/src/toolbar-message.d.ts +72 -0
  289. package/build/treb-embed/src/toolbar-message.js +22 -0
  290. package/build/treb-embed/src/toolbar-message.js.map +1 -0
  291. package/build/treb-embed/src/types.d.ts +185 -0
  292. package/build/treb-embed/src/types.js +45 -0
  293. package/build/treb-embed/src/types.js.map +1 -0
  294. package/build/treb-embed/tsconfig.tsbuildinfo +1 -0
  295. package/build/treb-export/src/address-type.d.ts +34 -0
  296. package/build/treb-export/src/address-type.js +53 -0
  297. package/build/treb-export/src/address-type.js.map +1 -0
  298. package/build/treb-export/src/base-template.d.ts +1 -0
  299. package/build/treb-export/src/base-template.js +22 -0
  300. package/build/treb-export/src/base-template.js.map +1 -0
  301. package/build/treb-export/src/column-width.d.ts +2 -0
  302. package/build/treb-export/src/column-width.js +80 -0
  303. package/build/treb-export/src/column-width.js.map +1 -0
  304. package/build/treb-export/src/drawing/bubble-chart-template.d.ts +514 -0
  305. package/build/treb-export/src/drawing/bubble-chart-template.js +544 -0
  306. package/build/treb-export/src/drawing/bubble-chart-template.js.map +1 -0
  307. package/build/treb-export/src/drawing/chart-template-components2.d.ts +365 -0
  308. package/build/treb-export/src/drawing/chart-template-components2.js +386 -0
  309. package/build/treb-export/src/drawing/chart-template-components2.js.map +1 -0
  310. package/build/treb-export/src/drawing/chart.d.ts +26 -0
  311. package/build/treb-export/src/drawing/chart.js +247 -0
  312. package/build/treb-export/src/drawing/chart.js.map +1 -0
  313. package/build/treb-export/src/drawing/column-chart-template2.d.ts +490 -0
  314. package/build/treb-export/src/drawing/column-chart-template2.js +518 -0
  315. package/build/treb-export/src/drawing/column-chart-template2.js.map +1 -0
  316. package/build/treb-export/src/drawing/donut-chart-template2.d.ts +272 -0
  317. package/build/treb-export/src/drawing/donut-chart-template2.js +293 -0
  318. package/build/treb-export/src/drawing/donut-chart-template2.js.map +1 -0
  319. package/build/treb-export/src/drawing/drawing.d.ts +49 -0
  320. package/build/treb-export/src/drawing/drawing.js +193 -0
  321. package/build/treb-export/src/drawing/drawing.js.map +1 -0
  322. package/build/treb-export/src/drawing/embedded-image.d.ts +12 -0
  323. package/build/treb-export/src/drawing/embedded-image.js +54 -0
  324. package/build/treb-export/src/drawing/embedded-image.js.map +1 -0
  325. package/build/treb-export/src/drawing/scatter-chart-template2.d.ts +520 -0
  326. package/build/treb-export/src/drawing/scatter-chart-template2.js +551 -0
  327. package/build/treb-export/src/drawing/scatter-chart-template2.js.map +1 -0
  328. package/build/treb-export/src/export.d.ts +72 -0
  329. package/build/treb-export/src/export.js +2039 -0
  330. package/build/treb-export/src/export.js.map +1 -0
  331. package/build/treb-export/src/import-export-messages.d.ts +31 -0
  332. package/build/treb-export/src/import-export-messages.js +22 -0
  333. package/build/treb-export/src/import-export-messages.js.map +1 -0
  334. package/build/treb-export/src/import.d.ts +33 -0
  335. package/build/treb-export/src/import.js +1258 -0
  336. package/build/treb-export/src/import.js.map +1 -0
  337. package/build/treb-export/src/index.worker.d.ts +1 -0
  338. package/build/treb-export/src/index.worker.js +93 -0
  339. package/build/treb-export/src/index.worker.js.map +1 -0
  340. package/build/treb-export/src/metadata.d.ts +51 -0
  341. package/build/treb-export/src/metadata.js +153 -0
  342. package/build/treb-export/src/metadata.js.map +1 -0
  343. package/build/treb-export/src/ooxml.d.ts +7 -0
  344. package/build/treb-export/src/ooxml.js +41 -0
  345. package/build/treb-export/src/ooxml.js.map +1 -0
  346. package/build/treb-export/src/relationship.d.ts +8 -0
  347. package/build/treb-export/src/relationship.js +27 -0
  348. package/build/treb-export/src/relationship.js.map +1 -0
  349. package/build/treb-export/src/shared-strings.d.ts +11 -0
  350. package/build/treb-export/src/shared-strings.js +105 -0
  351. package/build/treb-export/src/shared-strings.js.map +1 -0
  352. package/build/treb-export/src/template-2.d.ts +1 -0
  353. package/build/treb-export/src/template-2.js +22 -0
  354. package/build/treb-export/src/template-2.js.map +1 -0
  355. package/build/treb-export/src/unescape_xml.d.ts +1 -0
  356. package/build/treb-export/src/unescape_xml.js +61 -0
  357. package/build/treb-export/src/unescape_xml.js.map +1 -0
  358. package/build/treb-export/src/workbook-sheet.d.ts +75 -0
  359. package/build/treb-export/src/workbook-sheet.js +128 -0
  360. package/build/treb-export/src/workbook-sheet.js.map +1 -0
  361. package/build/treb-export/src/workbook-style.d.ts +110 -0
  362. package/build/treb-export/src/workbook-style.js +1134 -0
  363. package/build/treb-export/src/workbook-style.js.map +1 -0
  364. package/build/treb-export/src/workbook-theme.d.ts +13 -0
  365. package/build/treb-export/src/workbook-theme.js +85 -0
  366. package/build/treb-export/src/workbook-theme.js.map +1 -0
  367. package/build/treb-export/src/workbook.d.ts +123 -0
  368. package/build/treb-export/src/workbook.js +644 -0
  369. package/build/treb-export/src/workbook.js.map +1 -0
  370. package/build/treb-export/src/xml-test.d.ts +9 -0
  371. package/build/treb-export/src/xml-test.js +52 -0
  372. package/build/treb-export/src/xml-test.js.map +1 -0
  373. package/build/treb-export/src/xml-utils.d.ts +76 -0
  374. package/build/treb-export/src/xml-utils.js +223 -0
  375. package/build/treb-export/src/xml-utils.js.map +1 -0
  376. package/build/treb-export/src/zip-wrapper.d.ts +22 -0
  377. package/build/treb-export/src/zip-wrapper.js +93 -0
  378. package/build/treb-export/src/zip-wrapper.js.map +1 -0
  379. package/build/treb-format/src/format.d.ts +130 -0
  380. package/build/treb-format/src/format.js +805 -0
  381. package/build/treb-format/src/format.js.map +1 -0
  382. package/build/treb-format/src/format_cache.d.ts +55 -0
  383. package/build/treb-format/src/format_cache.js +166 -0
  384. package/build/treb-format/src/format_cache.js.map +1 -0
  385. package/build/treb-format/src/format_parser.d.ts +70 -0
  386. package/build/treb-format/src/format_parser.js +618 -0
  387. package/build/treb-format/src/format_parser.js.map +1 -0
  388. package/build/treb-format/src/index.d.ts +4 -0
  389. package/build/treb-format/src/index.js +25 -0
  390. package/build/treb-format/src/index.js.map +1 -0
  391. package/build/treb-format/src/number_format_section.d.ts +58 -0
  392. package/build/treb-format/src/number_format_section.js +78 -0
  393. package/build/treb-format/src/number_format_section.js.map +1 -0
  394. package/build/treb-format/src/value_parser.d.ts +48 -0
  395. package/build/treb-format/src/value_parser.js +244 -0
  396. package/build/treb-format/src/value_parser.js.map +1 -0
  397. package/build/treb-grid/src/editors/autocomplete.d.ts +39 -0
  398. package/build/treb-grid/src/editors/autocomplete.js +316 -0
  399. package/build/treb-grid/src/editors/autocomplete.js.map +1 -0
  400. package/build/treb-grid/src/editors/autocomplete_matcher.d.ts +74 -0
  401. package/build/treb-grid/src/editors/autocomplete_matcher.js +212 -0
  402. package/build/treb-grid/src/editors/autocomplete_matcher.js.map +1 -0
  403. package/build/treb-grid/src/editors/editor.d.ts +214 -0
  404. package/build/treb-grid/src/editors/editor.js +879 -0
  405. package/build/treb-grid/src/editors/editor.js.map +1 -0
  406. package/build/treb-grid/src/editors/external_editor.d.ts +11 -0
  407. package/build/treb-grid/src/editors/external_editor.js +118 -0
  408. package/build/treb-grid/src/editors/external_editor.js.map +1 -0
  409. package/build/treb-grid/src/editors/formula_bar.d.ts +85 -0
  410. package/build/treb-grid/src/editors/formula_bar.js +444 -0
  411. package/build/treb-grid/src/editors/formula_bar.js.map +1 -0
  412. package/build/treb-grid/src/editors/overlay_editor.d.ts +85 -0
  413. package/build/treb-grid/src/editors/overlay_editor.js +353 -0
  414. package/build/treb-grid/src/editors/overlay_editor.js.map +1 -0
  415. package/build/treb-grid/src/index.d.ts +12 -0
  416. package/build/treb-grid/src/index.js +28 -0
  417. package/build/treb-grid/src/index.js.map +1 -0
  418. package/build/treb-grid/src/layout/base_layout.d.ts +346 -0
  419. package/build/treb-grid/src/layout/base_layout.js +2050 -0
  420. package/build/treb-grid/src/layout/base_layout.js.map +1 -0
  421. package/build/treb-grid/src/layout/grid_layout.d.ts +19 -0
  422. package/build/treb-grid/src/layout/grid_layout.js +235 -0
  423. package/build/treb-grid/src/layout/grid_layout.js.map +1 -0
  424. package/build/treb-grid/src/layout/mock-layout.d.ts +10 -0
  425. package/build/treb-grid/src/layout/mock-layout.js +37 -0
  426. package/build/treb-grid/src/layout/mock-layout.js.map +1 -0
  427. package/build/treb-grid/src/render/selection-renderer.d.ts +97 -0
  428. package/build/treb-grid/src/render/selection-renderer.js +315 -0
  429. package/build/treb-grid/src/render/selection-renderer.js.map +1 -0
  430. package/build/treb-grid/src/render/svg_header_overlay.d.ts +20 -0
  431. package/build/treb-grid/src/render/svg_header_overlay.js +76 -0
  432. package/build/treb-grid/src/render/svg_header_overlay.js.map +1 -0
  433. package/build/treb-grid/src/render/svg_selection_block.d.ts +27 -0
  434. package/build/treb-grid/src/render/svg_selection_block.js +106 -0
  435. package/build/treb-grid/src/render/svg_selection_block.js.map +1 -0
  436. package/build/treb-grid/src/render/tile_renderer.d.ts +121 -0
  437. package/build/treb-grid/src/render/tile_renderer.js +1609 -0
  438. package/build/treb-grid/src/render/tile_renderer.js.map +1 -0
  439. package/build/treb-grid/src/types/border_constants.d.ts +9 -0
  440. package/build/treb-grid/src/types/border_constants.js +34 -0
  441. package/build/treb-grid/src/types/border_constants.js.map +1 -0
  442. package/build/treb-grid/src/types/clipboard_data.d.ts +11 -0
  443. package/build/treb-grid/src/types/clipboard_data.js +22 -0
  444. package/build/treb-grid/src/types/clipboard_data.js.map +1 -0
  445. package/build/treb-grid/src/types/clipboard_data2.d.ts +46 -0
  446. package/build/treb-grid/src/types/clipboard_data2.js +22 -0
  447. package/build/treb-grid/src/types/clipboard_data2.js.map +1 -0
  448. package/build/treb-grid/src/types/drag_mask.d.ts +10 -0
  449. package/build/treb-grid/src/types/drag_mask.js +78 -0
  450. package/build/treb-grid/src/types/drag_mask.js.map +1 -0
  451. package/build/treb-grid/src/types/external_editor_config.d.ts +33 -0
  452. package/build/treb-grid/src/types/external_editor_config.js +22 -0
  453. package/build/treb-grid/src/types/external_editor_config.js.map +1 -0
  454. package/build/treb-grid/src/types/grid.d.ts +806 -0
  455. package/build/treb-grid/src/types/grid.js +6410 -0
  456. package/build/treb-grid/src/types/grid.js.map +1 -0
  457. package/build/treb-grid/src/types/grid_base.d.ts +442 -0
  458. package/build/treb-grid/src/types/grid_base.js +3523 -0
  459. package/build/treb-grid/src/types/grid_base.js.map +1 -0
  460. package/build/treb-grid/src/types/grid_command.d.ts +408 -0
  461. package/build/treb-grid/src/types/grid_command.js +75 -0
  462. package/build/treb-grid/src/types/grid_command.js.map +1 -0
  463. package/build/treb-grid/src/types/grid_events.d.ts +93 -0
  464. package/build/treb-grid/src/types/grid_events.js +36 -0
  465. package/build/treb-grid/src/types/grid_events.js.map +1 -0
  466. package/build/treb-grid/src/types/grid_options.d.ts +50 -0
  467. package/build/treb-grid/src/types/grid_options.js +34 -0
  468. package/build/treb-grid/src/types/grid_options.js.map +1 -0
  469. package/build/treb-grid/src/types/scale-control.d.ts +21 -0
  470. package/build/treb-grid/src/types/scale-control.js +148 -0
  471. package/build/treb-grid/src/types/scale-control.js.map +1 -0
  472. package/build/treb-grid/src/types/set_range_options.d.ts +24 -0
  473. package/build/treb-grid/src/types/set_range_options.js +22 -0
  474. package/build/treb-grid/src/types/set_range_options.js.map +1 -0
  475. package/build/treb-grid/src/types/tab_bar.d.ts +84 -0
  476. package/build/treb-grid/src/types/tab_bar.js +426 -0
  477. package/build/treb-grid/src/types/tab_bar.js.map +1 -0
  478. package/build/treb-grid/src/types/tile.d.ts +29 -0
  479. package/build/treb-grid/src/types/tile.js +22 -0
  480. package/build/treb-grid/src/types/tile.js.map +1 -0
  481. package/build/treb-grid/src/types/update_flags.d.ts +48 -0
  482. package/build/treb-grid/src/types/update_flags.js +22 -0
  483. package/build/treb-grid/src/types/update_flags.js.map +1 -0
  484. package/build/treb-grid/src/util/fontmetrics.d.ts +21 -0
  485. package/build/treb-grid/src/util/fontmetrics.js +82 -0
  486. package/build/treb-grid/src/util/fontmetrics.js.map +1 -0
  487. package/build/treb-grid/src/util/ua.d.ts +33 -0
  488. package/build/treb-grid/src/util/ua.js +86 -0
  489. package/build/treb-grid/src/util/ua.js.map +1 -0
  490. package/build/treb-parser/src/csv-parser.d.ts +13 -0
  491. package/build/treb-parser/src/csv-parser.js +107 -0
  492. package/build/treb-parser/src/csv-parser.js.map +1 -0
  493. package/build/treb-parser/src/index.d.ts +4 -0
  494. package/build/treb-parser/src/index.js +25 -0
  495. package/build/treb-parser/src/index.js.map +1 -0
  496. package/build/treb-parser/src/md-parser.d.ts +97 -0
  497. package/build/treb-parser/src/md-parser.js +403 -0
  498. package/build/treb-parser/src/md-parser.js.map +1 -0
  499. package/build/treb-parser/src/parser-types.d.ts +345 -0
  500. package/build/treb-parser/src/parser-types.js +53 -0
  501. package/build/treb-parser/src/parser-types.js.map +1 -0
  502. package/build/treb-parser/src/parser.d.ts +422 -0
  503. package/build/treb-parser/src/parser.js +2418 -0
  504. package/build/treb-parser/src/parser.js.map +1 -0
  505. package/build/treb-utils/src/event_source.d.ts +34 -0
  506. package/build/treb-utils/src/event_source.js +110 -0
  507. package/build/treb-utils/src/event_source.js.map +1 -0
  508. package/build/treb-utils/src/ievent_source.d.ts +9 -0
  509. package/build/treb-utils/src/ievent_source.js +22 -0
  510. package/build/treb-utils/src/ievent_source.js.map +1 -0
  511. package/build/treb-utils/src/index.d.ts +6 -0
  512. package/build/treb-utils/src/index.js +30 -0
  513. package/build/treb-utils/src/index.js.map +1 -0
  514. package/build/treb-utils/src/measurement.d.ts +42 -0
  515. package/build/treb-utils/src/measurement.js +145 -0
  516. package/build/treb-utils/src/measurement.js.map +1 -0
  517. package/build/treb-utils/src/scale.d.ts +16 -0
  518. package/build/treb-utils/src/scale.js +106 -0
  519. package/build/treb-utils/src/scale.js.map +1 -0
  520. package/build/treb-utils/src/serialize_html.d.ts +5 -0
  521. package/build/treb-utils/src/serialize_html.js +128 -0
  522. package/build/treb-utils/src/serialize_html.js.map +1 -0
  523. package/build/treb-utils/src/validate_uri.d.ts +20 -0
  524. package/build/treb-utils/src/validate_uri.js +55 -0
  525. package/build/treb-utils/src/validate_uri.js.map +1 -0
  526. package/dist/{chunk-Z4XFMZ2X.mjs → chunk-E35ONJUS.mjs} +1 -1
  527. package/dist/treb-export-worker.mjs +2 -2
  528. package/dist/treb-spreadsheet.mjs +4 -4
  529. package/dist/treb.d.ts +1 -1
  530. package/esbuild-composite.mjs +5 -1
  531. package/package.json +67 -3
  532. package/treb-embed/src/custom-element/spreadsheet-constructor.ts +7 -3
  533. package/treb-embed/src/embedded-spreadsheet.ts +1 -1
  534. package/treb-grid/src/types/grid_options.ts +1 -1
  535. package/tsproject.json +1 -2
  536. package/dist/chunk-43DLP2OX.mjs +0 -11
  537. package/dist/chunk-4CKS56PE.mjs +0 -11
  538. package/dist/chunk-75PARUQE.mjs +0 -11
  539. package/dist/chunk-7QD63AZS.mjs +0 -24601
  540. package/dist/chunk-A55ARVRD.mjs +0 -11
  541. package/dist/chunk-DESAKYW4.mjs +0 -11
  542. package/dist/chunk-EQ2R5W6P.mjs +0 -24565
  543. package/dist/chunk-IYJU2J6D.mjs +0 -24601
  544. package/dist/chunk-KSJFPGXT.mjs +0 -11
  545. package/dist/chunk-MQK4DNXI.mjs +0 -11
  546. package/dist/chunk-ORQFKLXM.mjs +0 -24601
  547. package/dist/chunk-SFDNNDHY.mjs +0 -11
  548. package/dist/chunk-T47DX5MI.mjs +0 -11
  549. package/dist/chunk-T6ILBVEX.mjs +0 -11
  550. package/dist/chunk-TPRCDYYG.mjs +0 -11
  551. package/dist/chunk-YAHNOOHO.mjs +0 -11
  552. package/dist/chunk-YLCFKX2G.mjs +0 -24601
@@ -0,0 +1,1136 @@
1
+ /*
2
+ * This file is part of TREB.
3
+ *
4
+ * TREB is free software: you can redistribute it and/or modify it under the
5
+ * terms of the GNU General Public License as published by the Free Software
6
+ * Foundation, either version 3 of the License, or (at your option) any
7
+ * later version.
8
+ *
9
+ * TREB is distributed in the hope that it will be useful, but WITHOUT ANY
10
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12
+ * details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License along
15
+ * with TREB. If not, see <https://www.gnu.org/licenses/>.
16
+ *
17
+ * Copyright 2022-2026 trebco, llc.
18
+ * info@treb.app
19
+ *
20
+ */
21
+ import { Area, IsCellAddress } from './area';
22
+ // import type { DataValidation } from './cell';
23
+ import { Cell } from './cell';
24
+ import { ValueType, GetValueType, ValueTypeList } from './value-type';
25
+ // some type guards for the various data types
26
+ /** @internal */
27
+ export const IsFlatData = (test) => {
28
+ return !test.cells;
29
+ };
30
+ /** @internal */
31
+ export const IsFlatDataArray = (test) => {
32
+ return (!!test[0]) && IsFlatData(test[0]);
33
+ };
34
+ /** @internal */
35
+ export const IsNestedRowArray = (test) => {
36
+ return (!!test[0]) && (test[0].row !== undefined);
37
+ };
38
+ // ...
39
+ /**
40
+ * this is the reverse map, i.e. type => number
41
+ * FIXME: why is this getting exported by the API generator?
42
+ * FIXME: I get why it's dynamic, but for practical purposes why not just
43
+ * create a static map?
44
+ */
45
+ const ValueTypeMap = ValueTypeList.map((key, index) => ({ [key]: index })).reduce((set, value) => ({ ...set, ...value }), {});
46
+ /**
47
+ * collection of cells, basically a wrapper around an
48
+ * array, with some accessor and control methods.
49
+ */
50
+ export class Cells {
51
+ /** switching to row-major */
52
+ data = [];
53
+ rows_ = 0;
54
+ columns_ = 0;
55
+ get rows() { return this.rows_; }
56
+ get columns() { return this.columns_; }
57
+ /**
58
+ * the sheet wants to make sure this row exists, probably because it has
59
+ * a header. so we will update our dimensions to match. we don't actually
60
+ * add data.
61
+ *
62
+ * this is not serialized. specific headers aren't serialized either, at
63
+ * the moment, so it's sort of irrelevant. if we start serializing headers,
64
+ * the deserialization routine can call this function to pad out, so we
65
+ * don't need to store it here.
66
+ */
67
+ EnsureRow(row) {
68
+ this.rows_ = Math.max(row + 1, this.rows_);
69
+ }
70
+ /** @see EnsureRow */
71
+ EnsureColumn(column) {
72
+ this.columns_ = Math.max(column + 1, this.columns_);
73
+ }
74
+ /**
75
+ * this class does none of the validation/correction
76
+ * required when inserting rows/columns. that should
77
+ * be done by external logic. this method only does
78
+ * the mechanical work of inserting rows/columns.
79
+ */
80
+ InsertColumns(before = 0, count = 1) {
81
+ // const pre = JSON.parse(JSON.stringify(this.data[13]));
82
+ // NOTE: iterating a sparse array, in chrome at least, only
83
+ // hits populated keys. the returned array has the same
84
+ // indexes. that is very nice.
85
+ this.data = this.data.map(row => {
86
+ if (row.length >= before) {
87
+ const tmp = row.slice(0, before);
88
+ let index = before + count;
89
+ // this forEach is broken when there are empty values in the row,
90
+ // which doesn't happen so much anymore but can (and does) happen
91
+ // in some older sheets.
92
+ // row.slice(before).forEach((column) => tmp[index++] = column);
93
+ // do it with an explicit index loop, should resolve
94
+ const after = row.slice(before);
95
+ for (let i = 0; i < after.length; i++) {
96
+ tmp[index++] = after[i];
97
+ }
98
+ return tmp;
99
+ }
100
+ return row;
101
+ });
102
+ this.columns_ += count;
103
+ // wtf is this? some old debug stuff?
104
+ // const clone = JSON.parse(JSON.stringify(this.data[13]));
105
+ // console.info({pre, clone});
106
+ }
107
+ DeleteColumns(index, count = 1) {
108
+ // trap! splice returns _removed_ elements so don't use map()
109
+ this.data.forEach((row) => row.splice(index, count));
110
+ this.columns_ -= count;
111
+ }
112
+ DeleteRows(index, count = 1) {
113
+ this.data.splice(index, count);
114
+ this.rows_ -= count;
115
+ }
116
+ /**
117
+ * this class does none of the validation/correction
118
+ * required when inserting rows/columns. that should
119
+ * be done by external logic. this method only does
120
+ * the mechanical work of inserting rows/columns.
121
+ */
122
+ InsertRows(before = 0, count = 1) {
123
+ const args = [before, 0, []];
124
+ for (let i = 1; i < count; i++)
125
+ args.push([]);
126
+ Array.prototype.splice.apply(this.data, args);
127
+ this.rows_ += count;
128
+ }
129
+ /**
130
+ * return the given cell or `undefined`, optionally creating
131
+ * new cells as necessary
132
+ *
133
+ * @param create_new always return a cell
134
+ */
135
+ GetCell(address, create_new) {
136
+ const { row, column } = address;
137
+ if (!this.data[row]) {
138
+ if (create_new) {
139
+ this.data[row] = [];
140
+ this.rows_ = Math.max(this.rows_, row + 1);
141
+ }
142
+ else
143
+ return undefined;
144
+ }
145
+ if (!this.data[row][column]) {
146
+ if (create_new) {
147
+ this.data[row][column] = new Cell();
148
+ this.columns_ = Math.max(this.columns_, column + 1);
149
+ }
150
+ }
151
+ return this.data[row][column];
152
+ }
153
+ /**
154
+ * apply function to range or address. skips empty cells (for now...)
155
+ * (already have this function, it's called "IterateArea". "Apply" is better.)
156
+ * /
157
+ public Apply(target: ICellAddress|IArea, func: (cell: Cell) => void): void {
158
+
159
+ if (IsCellAddress(target)) {
160
+ target = new Area(target);
161
+ }
162
+
163
+ const start = target.start;
164
+ const end = target.end;
165
+
166
+ for (let r = start.row; r <= end.row; r++) {
167
+ if (this.data[r]) {
168
+ const row = this.data[r];
169
+ for (let c = start.column; c < end.column; c++) {
170
+ if (this.data[r][c]) {
171
+ func.call(undefined, row[c]);
172
+ }
173
+ }
174
+ }
175
+ }
176
+
177
+ }
178
+ */
179
+ /** returns an existing cell or creates a new cell. */
180
+ EnsureCell(address) {
181
+ const { row, column } = address;
182
+ let ref = this.data[row];
183
+ if (!ref) {
184
+ this.data[row] = ref = [];
185
+ this.rows_ = Math.max(this.rows_, row + 1);
186
+ }
187
+ let cell = ref[column];
188
+ if (!cell) {
189
+ cell = ref[column] = new Cell();
190
+ this.columns_ = Math.max(this.columns_, column + 1);
191
+ }
192
+ return cell;
193
+ }
194
+ /**
195
+ * with the update, we assume the passed-in data is row-major.
196
+ * when reading an older file, transpose.
197
+ */
198
+ FromArray(data = [], transpose = false) {
199
+ this.data = [];
200
+ let rows = 0;
201
+ let columns = 0;
202
+ if (transpose) {
203
+ columns = data.length;
204
+ for (let c = 0; c < columns; c++) {
205
+ const ref = data[c];
206
+ rows = Math.max(rows, ref.length);
207
+ for (let r = 0; r < ref.length; r++) {
208
+ if (!this.data[r])
209
+ this.data[r] = [];
210
+ this.data[r][c] = new Cell(ref[r]);
211
+ }
212
+ }
213
+ }
214
+ else {
215
+ rows = data.length;
216
+ for (let r = 0; r < rows; r++) {
217
+ const column = [];
218
+ const ref = data[r];
219
+ columns = Math.max(columns, ref.length);
220
+ for (let c = 0; c < ref.length; c++)
221
+ column[c] = new Cell(ref[c]);
222
+ this.data[r] = column;
223
+ }
224
+ }
225
+ this.rows_ = rows;
226
+ this.columns_ = columns;
227
+ }
228
+ SerializedTypeToValueType(type) {
229
+ if (!type) {
230
+ return undefined;
231
+ }
232
+ if (typeof type === 'number') {
233
+ return type;
234
+ }
235
+ return ValueTypeMap[type] || undefined;
236
+ }
237
+ ValueTypeToSerializedType(type) {
238
+ return type ? ValueTypeList[type] : undefined;
239
+ }
240
+ /* *
241
+ * this method is used for importing legacy data validation types. in those
242
+ * those we used a numeric enum. we're just dropping that altogether (c.f.
243
+ * ValueType, which we're keeping) so we need to translate for backcompat.
244
+ * it's ugly, but it gets us to a better place. we can probably drop at some
245
+ * point in the future.
246
+ *
247
+ * export enum ValidationType {
248
+ * List = 'list',
249
+ * Date = 'date',
250
+ * Range = 'range',
251
+ * Number = 'number',
252
+ * Boolean = 'boolean',
253
+ * }
254
+ *
255
+ * OK, removed
256
+ * /
257
+ public ImportDataValidation(value: DataValidation): DataValidation|undefined {
258
+
259
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
260
+ const type: DataValidation['type']|number = (value as any).type;
261
+
262
+ if (typeof type === 'number') {
263
+ const types: Array<DataValidation['type']> = ['list', 'date', 'range', 'number', 'boolean'];
264
+ value.type = types[type];
265
+ if (!value.type) {
266
+ return undefined;
267
+ }
268
+ }
269
+
270
+ return value;
271
+ }
272
+ */
273
+ /**
274
+ * UPDATE: adding optional style refs, for export
275
+ */
276
+ FromJSON(data = [], style_refs) {
277
+ this.data = [];
278
+ // handle nested data; fix. we can make the simplifying assumption
279
+ // that data is either nested, or not, but never both. therefore, we
280
+ // just need to check the first element.
281
+ if (!IsFlatDataArray(data)) {
282
+ const new_data = [];
283
+ if (IsNestedRowArray(data)) {
284
+ for (const block of data) {
285
+ for (const cell of block.cells) {
286
+ new_data.push({ ...cell, row: block.row });
287
+ }
288
+ }
289
+ }
290
+ else {
291
+ for (const block of data) {
292
+ for (const cell of block.cells) {
293
+ new_data.push({ ...cell, column: block.column });
294
+ }
295
+ }
296
+ }
297
+ data = new_data;
298
+ }
299
+ /*
300
+ if (data[0] && data[0].cells) {
301
+
302
+ // console.info('reading nested data');
303
+
304
+ const new_data: any[] = [];
305
+ for (const element of data) {
306
+ if (typeof element.row !== 'undefined') {
307
+ for (const cell of element.cells) {
308
+ new_data.push({row: element.row, ...cell});
309
+ }
310
+ }
311
+ else if (typeof element.column !== 'undefined') {
312
+ for (const cell of element.cells) {
313
+ new_data.push({column: element.column, ...cell});
314
+ }
315
+ }
316
+ }
317
+ data = new_data;
318
+
319
+ }
320
+ */
321
+ const tables = [];
322
+ for (const obj of data) {
323
+ if (!this.data[obj.row])
324
+ this.data[obj.row] = [];
325
+ const cell = new Cell(obj.value);
326
+ if (typeof obj.calculated !== 'undefined') {
327
+ // cell.calculated = obj.calculated;
328
+ // cell.calculated_type = obj.calculated_type;
329
+ cell.SetCalculatedValue(obj.calculated, this.SerializedTypeToValueType(obj.calculated_type));
330
+ if (obj.spill) {
331
+ cell.spill = new Area(obj.spill.start, obj.spill.end);
332
+ }
333
+ }
334
+ if (style_refs) {
335
+ if (typeof obj.style_ref !== 'undefined') {
336
+ cell.style = style_refs[obj.style_ref];
337
+ }
338
+ }
339
+ if (typeof obj.note !== 'undefined') {
340
+ cell.note = obj.note;
341
+ }
342
+ if (typeof obj.hyperlink !== 'undefined') {
343
+ cell.hyperlink = obj.hyperlink;
344
+ }
345
+ // stop wrecking arrays
346
+ if (this.data[obj.row][obj.column] && this.data[obj.row][obj.column].area) {
347
+ cell.area = this.data[obj.row][obj.column].area;
348
+ }
349
+ this.data[obj.row][obj.column] = cell;
350
+ // since we are serializing the array data (when storing calculated
351
+ // values), is this getting called every time? I think it might be...
352
+ // we're fixing the former, anyway.
353
+ if (obj.area) {
354
+ const area = new Area(obj.area.start, obj.area.end); // isn't there a clone method?
355
+ for (let row = area.start.row; row <= area.end.row; row++) {
356
+ for (let column = area.start.column; column <= area.end.column; column++) {
357
+ if (!this.data[row])
358
+ this.data[row] = [];
359
+ if (!this.data[row][column])
360
+ this.data[row][column] = new Cell();
361
+ this.data[row][column].area = area;
362
+ }
363
+ }
364
+ }
365
+ // collect tables, then apply them after reading all the cells.
366
+ // FIXME: why are we not doing this for merges? would be more
367
+ // efficient, no?
368
+ if (obj.table) {
369
+ tables.push({
370
+ ...obj.table,
371
+ });
372
+ /*
373
+ for ( let row = table.area.start.row; row <= table.area.end.row; row++){
374
+ for ( let column = table.area.start.column; column <= table.area.end.column; column++){
375
+ if (!this.data[row]) this.data[row] = [];
376
+ if (!this.data[row][column]) this.data[row][column] = new Cell();
377
+ this.data[row][column].table = table;
378
+ }
379
+ }
380
+ */
381
+ }
382
+ if (obj.merge_area) {
383
+ const merge_area = new Area(obj.merge_area.start, obj.merge_area.end);
384
+ for (let row = merge_area.start.row; row <= merge_area.end.row; row++) {
385
+ for (let column = merge_area.start.column; column <= merge_area.end.column; column++) {
386
+ if (!this.data[row])
387
+ this.data[row] = [];
388
+ if (!this.data[row][column])
389
+ this.data[row][column] = new Cell();
390
+ this.data[row][column].merge_area = merge_area;
391
+ }
392
+ }
393
+ }
394
+ /*
395
+ if (obj.validation) {
396
+
397
+ // the old type used a numeric enum. we just dropped that in favor
398
+ // of a string enum, so we can export it as a type. but for backwards
399
+ // compatibility we still need to think about the numeric enum.
400
+
401
+ cell.validation = this.ImportDataValidation(obj.validation);
402
+
403
+ }
404
+ */
405
+ }
406
+ for (const table of tables) {
407
+ for (let row = table.area.start.row; row <= table.area.end.row; row++) {
408
+ for (let column = table.area.start.column; column <= table.area.end.column; column++) {
409
+ if (!this.data[row])
410
+ this.data[row] = [];
411
+ if (!this.data[row][column])
412
+ this.data[row][column] = new Cell();
413
+ this.data[row][column].table = table;
414
+ }
415
+ }
416
+ }
417
+ this.rows_ = this.data.length;
418
+ this.columns_ = this.data.reduce((max, row) => Math.max(max, row.length), 0);
419
+ }
420
+ toJSON(options = {}) {
421
+ let start_column = 0;
422
+ let start_row = 0;
423
+ let end_row = this.data.length - 1;
424
+ let end_column;
425
+ if (options.subset) {
426
+ start_column = options.subset.start.column;
427
+ start_row = options.subset.start.row;
428
+ end_row = options.subset.end.row;
429
+ }
430
+ const data = [];
431
+ let last_row = -1;
432
+ let last_col = -1;
433
+ // unifying [FIXME: move into class]
434
+ // FIXME: why not use the original, instead of requiring a method
435
+ // call, and then re-order? that also makes it easier to pivot
436
+ // (order by rows or columns)
437
+ // ... (we did that)
438
+ const row_keys = {};
439
+ const column_keys = {};
440
+ for (let row = start_row; row <= end_row; row++) {
441
+ if (this.data[row]) {
442
+ const ref = this.data[row];
443
+ end_column = ref.length - 1;
444
+ if (options.subset)
445
+ end_column = options.subset.end.column;
446
+ for (let column = start_column; column <= end_column; column++) {
447
+ const cell = ref[column];
448
+ // because only the array head will have a value, this test
449
+ // will filter out empty cells and non-head array cells
450
+ // update: also add merge heads
451
+ const merge_head = cell && cell.merge_area
452
+ && cell.merge_area.start.row === row
453
+ && cell.merge_area.start.column === column;
454
+ const array_head = cell && cell.area
455
+ && cell.area.start.row === row
456
+ && cell.area.start.column === column;
457
+ const table_head = cell && cell.table
458
+ && cell.table.area.start.row === row
459
+ && cell.table.area.start.column === column;
460
+ const is_empty = cell ? (cell.type === ValueType.string && !cell.value) : true;
461
+ // NOTE: we added the check on calculated && calculated_value,
462
+ // so we preserve rendered data for arrays. but that actually writes
463
+ // the array data as well, which is unnecessary (?) -- FIXME
464
+ //
465
+ // actually, check how that's interpreted on load, because it might
466
+ // break if we have a value but not the array area (...)
467
+ // FIXME: what's up with this? we check style? (...) can't recall
468
+ // why we do that, because we should ensure empty cells if there's
469
+ // a style (separately).
470
+ // NOTE: switching test from "calculated" to "calculated type": this
471
+ // should preserve zeros.
472
+ if (cell && (!is_empty || options.preserve_empty_strings) &&
473
+ (merge_head || cell.type || (cell.calculated_type && options.expand_arrays) ||
474
+ (cell.calculated_type && options.calculated_value) ||
475
+ (cell.note) ||
476
+ // (cell.validation) ||
477
+ (options.decorated_cells && cell.style &&
478
+ (cell.style.fill || cell.style.border_bottom ||
479
+ cell.style.border_top || cell.style.border_left || cell.style.border_right)))) {
480
+ const obj = { row, column, value: cell.value };
481
+ if (cell.note) {
482
+ obj.note = cell.note;
483
+ }
484
+ if (cell.hyperlink) {
485
+ obj.hyperlink = cell.hyperlink;
486
+ }
487
+ if (options.preserve_type) {
488
+ obj.type = this.ValueTypeToSerializedType(cell.type);
489
+ }
490
+ if (options.sheet_id)
491
+ obj.sheet_id = options.sheet_id;
492
+ if (options.calculated_value &&
493
+ typeof cell.calculated !== 'undefined') { // && cell.calculated_type !== ValueType.error) {
494
+ obj.calculated = cell.calculated;
495
+ if (cell.spill) {
496
+ obj.spill = cell.spill.toJSON();
497
+ }
498
+ // always preserve error type, because we can't infer
499
+ if (options.preserve_type || cell.calculated_type === ValueType.error) {
500
+ obj.calculated_type = this.ValueTypeToSerializedType(cell.calculated_type);
501
+ }
502
+ }
503
+ if (cell.table && table_head) {
504
+ if (options.tables) {
505
+ obj.table = JSON.parse(JSON.stringify(cell.table));
506
+ }
507
+ }
508
+ if (cell.area && array_head) {
509
+ obj.area = cell.area.toJSON();
510
+ }
511
+ if (cell.merge_area) {
512
+ obj.merge_area = cell.merge_area.toJSON();
513
+ }
514
+ // if (cell.validation) {
515
+ // obj.validation = cell.validation; // safe?
516
+ // }
517
+ if (options.cell_style_refs &&
518
+ options.cell_style_refs[column] &&
519
+ options.cell_style_refs[column][row]) {
520
+ obj.style_ref = options.cell_style_refs[column][row];
521
+ options.cell_style_refs[column][row] = 0; // consume
522
+ // console.info(`consume @ ${column}, ${row}: ${obj.style_ref } => ${options.cell_style_refs[column][row]}`);
523
+ }
524
+ row_keys[row] = row;
525
+ column_keys[column] = column;
526
+ last_row = Math.max(row, last_row);
527
+ last_col = Math.max(column, last_col);
528
+ data.push(obj);
529
+ }
530
+ }
531
+ }
532
+ }
533
+ if (options.nested) {
534
+ const row_key_map = Object.keys(row_keys);
535
+ const col_key_map = Object.keys(column_keys);
536
+ // extra test to make sure it's not empty
537
+ if ((row_key_map.length <= col_key_map.length) && row_key_map.length) {
538
+ const cells = {};
539
+ // use rows
540
+ const new_data = [];
541
+ for (const element of data) {
542
+ // the construction here seems to be removing the
543
+ // "row" key -- is there a better way to do that?
544
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
545
+ const { row, ...remainder } = element;
546
+ if (!cells[element.row])
547
+ cells[element.row] = [];
548
+ cells[element.row].push(remainder);
549
+ }
550
+ for (const key of row_key_map) {
551
+ const row = Number(key);
552
+ new_data.push({ row, cells: cells[row] });
553
+ }
554
+ return { data: new_data, rows: last_row, columns: last_col + 1 };
555
+ }
556
+ else if (col_key_map.length) {
557
+ const cells = {};
558
+ // use columns
559
+ const new_data = [];
560
+ for (const element of data) {
561
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
562
+ const { column, ...remainder } = element;
563
+ if (!cells[element.column])
564
+ cells[element.column] = [];
565
+ cells[element.column].push(remainder);
566
+ }
567
+ for (const key of col_key_map) {
568
+ const column = Number(key);
569
+ new_data.push({ column, cells: cells[column] });
570
+ }
571
+ return { data: new_data, rows: last_row, columns: last_col + 1 };
572
+ }
573
+ }
574
+ return { data, rows: last_row + 1, columns: last_col + 1 };
575
+ }
576
+ GetAll(transpose = false) {
577
+ return this.GetRange({ row: 0, column: 0 }, { row: this.rows_ - 1, column: this.columns_ - 1 }, transpose);
578
+ }
579
+ /** base */
580
+ Normalize(from, to) {
581
+ from = {
582
+ ...from,
583
+ row: from.row == Infinity ? 0 : from.row,
584
+ column: from.column == Infinity ? 0 : from.column,
585
+ };
586
+ if (to) {
587
+ to = {
588
+ ...to,
589
+ row: to.row == Infinity ? this.rows_ - 1 : to.row,
590
+ column: to.column == Infinity ? this.columns_ - 1 : to.column,
591
+ };
592
+ }
593
+ return { from, to };
594
+ }
595
+ /**
596
+ * get raw values (i.e. not calculated). anything outside of actual
597
+ * range will be undefined OR not populated.
598
+ *
599
+ * to match GetRange, we return a single value in the case of a single cell,
600
+ * or a matrix.
601
+ *
602
+ * NOTE that I'm not sure this is good behavior. if you're going to
603
+ * return a single value for one cell, you should return a vector for
604
+ * a single row OR a single column. alternatively, you should always
605
+ * return a matrix.
606
+ *
607
+ * @param from
608
+ * @param to
609
+ * @param transpose
610
+ */
611
+ RawValue(from, to = from) {
612
+ ({ from, to } = this.Normalize(from, to));
613
+ if (from.row === to.row && from.column === to.column) {
614
+ if (this.data[from.row] && this.data[from.row][from.column]) {
615
+ return this.data[from.row][from.column].value;
616
+ }
617
+ return undefined;
618
+ }
619
+ const result = [];
620
+ // grab rows
621
+ const rows = this.data.slice(from.row, to.row + 1);
622
+ // now columns
623
+ const start = from.column;
624
+ const end = to.column + 1;
625
+ for (const source of rows) {
626
+ const target = [];
627
+ for (let column = start, index = 0; column < end; column++, index++) {
628
+ const cell = source[column];
629
+ target.push(cell ? cell.value : undefined);
630
+ }
631
+ result.push(target);
632
+ }
633
+ return result;
634
+ }
635
+ /** gets range as values */
636
+ GetRange(from, to, transpose = false) {
637
+ ({ from, to } = this.Normalize(from, to));
638
+ // console.info("getrange", from, to, transpose);
639
+ if (!to || from === to || (from.column === to.column && from.row === to.row)) {
640
+ if (this.data[from.row] && this.data[from.row][from.column]) {
641
+ return this.data[from.row][from.column].GetValue();
642
+ }
643
+ return undefined;
644
+ }
645
+ const value = [];
646
+ if (transpose) {
647
+ for (let c = from.column; c <= to.column; c++) {
648
+ const column = [];
649
+ for (let r = from.row; r <= to.row; r++) {
650
+ if (this.data[r] && this.data[r][c])
651
+ column.push(this.data[r][c].GetValue());
652
+ else
653
+ column.push(undefined);
654
+ }
655
+ value.push(column);
656
+ }
657
+ }
658
+ else {
659
+ for (let r = from.row; r <= to.row; r++) {
660
+ const row = [];
661
+ for (let c = from.column; c <= to.column; c++) {
662
+ if (this.data[r] && this.data[r][c])
663
+ row.push(this.data[r][c].GetValue());
664
+ else
665
+ row.push(undefined);
666
+ }
667
+ value.push(row);
668
+ }
669
+ }
670
+ // console.info(value)
671
+ return value;
672
+ }
673
+ /* *
674
+ * updated version of GetRange that preserves errors, by calling
675
+ * the GetValue2 cell function.
676
+ * /
677
+ public GetRange2(from: ICellAddress, to?: ICellAddress, transpose = false) {
678
+
679
+ if (!to || from === to || (from.column === to.column && from.row === to.row )){
680
+ if (this.data[from.row] && this.data[from.row][from.column]){
681
+ return this.data[from.row][from.column].GetValue2();
682
+ }
683
+ return undefined;
684
+ }
685
+
686
+ const value = [];
687
+
688
+ if (transpose){
689
+ for ( let c = from.column; c <= to.column; c++ ){
690
+ const column = [];
691
+ for ( let r = from.row; r <= to.row; r++ ){
692
+ if (this.data[r] && this.data[r][c]) column.push(this.data[r][c].GetValue2());
693
+ else column.push(undefined);
694
+ }
695
+ value.push(column);
696
+ }
697
+ }
698
+ else {
699
+ for ( let r = from.row; r <= to.row; r++ ){
700
+ const row = [];
701
+ for ( let c = from.column; c <= to.column; c++ ){
702
+ if (this.data[r] && this.data[r][c]) row.push(this.data[r][c].GetValue2());
703
+ else row.push(undefined);
704
+ }
705
+ value.push(row);
706
+ }
707
+ }
708
+
709
+ return value;
710
+
711
+ }
712
+ */
713
+ GetRange4(from, to = from, transpose = false) {
714
+ ({ from, to } = this.Normalize(from, to));
715
+ if (from.row === to.row && from.column === to.column) {
716
+ if (this.data[from.row] && this.data[from.row][from.column]) {
717
+ return this.data[from.row][from.column].GetValue4();
718
+ }
719
+ return { value: undefined, type: ValueType.undefined };
720
+ }
721
+ const value = [];
722
+ if (transpose) {
723
+ for (let c = from.column; c <= to.column; c++) {
724
+ const column = [];
725
+ for (let r = from.row; r <= to.row; r++) {
726
+ if (this.data[r] && this.data[r][c])
727
+ column.push(this.data[r][c].GetValue4());
728
+ else
729
+ column.push({ type: ValueType.undefined });
730
+ }
731
+ value.push(column);
732
+ }
733
+ }
734
+ else {
735
+ for (let r = from.row; r <= to.row; r++) {
736
+ const row = [];
737
+ for (let c = from.column; c <= to.column; c++) {
738
+ if (this.data[r] && this.data[r][c])
739
+ row.push(this.data[r][c].GetValue4());
740
+ else
741
+ row.push({ type: ValueType.undefined });
742
+ }
743
+ value.push(row);
744
+ }
745
+ }
746
+ return { type: ValueType.array, value };
747
+ }
748
+ /* *
749
+ * apply function to address/area
750
+ * @deprecated - use Apply2
751
+ * /
752
+ public Apply(area: Area|ICellAddress, f: (cell: Cell, c?: number, r?: number) => void, create_missing_cells = false): void {
753
+
754
+ // allow single address
755
+ if (IsCellAddress(area)) {
756
+ area = new Area(area);
757
+ }
758
+
759
+ // why not just cap? (...)
760
+ if (area.entire_column || area.entire_row) {
761
+ throw new Error(`don't iterate infinite cells`);
762
+ }
763
+
764
+ // these are accessors so we don't want them in the loop
765
+ const start = area.start;
766
+ const end = area.end;
767
+
768
+ if (create_missing_cells){
769
+ for ( let r = start.row; r <= end.row; r++ ){
770
+ if (!this.data[r]) this.data[r] = [];
771
+ const row = this.data[r];
772
+ for ( let c = start.column; c <= end.column; c++ ){
773
+ if (!row[c]) row[c] = new Cell();
774
+ f(row[c], c, r);
775
+ }
776
+ }
777
+ }
778
+ else {
779
+ // we can loop over indexes that don't exist, just check for existence
780
+ for ( let r = start.row; r <= end.row; r++ ){
781
+ if (this.data[r]){
782
+ const row = this.data[r];
783
+ for ( let c = start.column; c <= end.column; c++ ){
784
+ if (row[c]) f(row[c], c, r);
785
+ }
786
+ }
787
+ }
788
+ }
789
+ }
790
+ */
791
+ /* *
792
+ * as a replacement for the Apply functions. testing
793
+ *
794
+ * (1) it seems like almost no one uses the cell address, so returning
795
+ * it just adds a wasteful destructuring to every loop iteration.
796
+ *
797
+ * actually there's exactly one, and we could work around it. but
798
+ * it seems like it might be useful in some cases, so... ?
799
+ *
800
+ * (2) can we consolidate with the IterateAll method (named Iterate)?
801
+ * that would only work if we had the same return type, meaning either
802
+ * drop the address from this one or add it to the other one
803
+ *
804
+ * @deprecated use Iterate, if possible
805
+ *
806
+ * /
807
+ public *IterateArea(area: Area|ICellAddress, create_missing_cells = false) {
808
+
809
+ // allow single address
810
+ if (IsCellAddress(area)) {
811
+ area = new Area(area);
812
+ }
813
+
814
+ // why not just cap? (...)
815
+ if (area.entire_column || area.entire_row) {
816
+ throw new Error(`don't iterate infinite cells`);
817
+ }
818
+
819
+ const start = area.start;
820
+ const end = area.end;
821
+
822
+ if (create_missing_cells){
823
+ for ( let r = start.row; r <= end.row; r++ ){
824
+ if (!this.data[r]) this.data[r] = [];
825
+ const row = this.data[r];
826
+ for ( let c = start.column; c <= end.column; c++ ){
827
+ if (!row[c]) row[c] = new Cell();
828
+ yield { row: r, column: c, cell: row[c] };
829
+ }
830
+ }
831
+ }
832
+ else {
833
+ // we can loop over indexes that don't exist, just check for existence
834
+ for ( let r = start.row; r <= end.row; r++ ){
835
+ if (this.data[r]){
836
+ const row = this.data[r];
837
+ for ( let c = start.column; c <= end.column; c++ ){
838
+ if (row[c]) {
839
+ yield { row: r, column: c, cell: row[c] };
840
+ }
841
+ }
842
+ }
843
+ }
844
+ }
845
+
846
+ }
847
+ */
848
+ /* *
849
+ * apply function to address/area
850
+ *
851
+ * this version lets you abort by returning false from the callback function
852
+ * /
853
+ public Apply2(area: Area|ICellAddress, func: (cell: Cell, c?: number, r?: number) => boolean, create_missing_cells = false): void {
854
+
855
+ // allow single address
856
+ if (IsCellAddress(area)) {
857
+ area = new Area(area);
858
+ }
859
+
860
+ // why not just cap? (...)
861
+ if (area.entire_column || area.entire_row) {
862
+ throw new Error(`don't iterate infinite cells`);
863
+ }
864
+
865
+ // these are accessors so we don't want them in the loop
866
+ const start = area.start;
867
+ const end = area.end;
868
+
869
+ if (create_missing_cells){
870
+ for ( let r = start.row; r <= end.row; r++ ){
871
+ if (!this.data[r]) this.data[r] = [];
872
+ const row = this.data[r];
873
+ for ( let c = start.column; c <= end.column; c++ ){
874
+ if (!row[c]) row[c] = new Cell();
875
+ if (!func(row[c], c, r)) {
876
+ return;
877
+ }
878
+ }
879
+ }
880
+ }
881
+ else {
882
+ // we can loop over indexes that don't exist, just check for existence
883
+ for ( let r = start.row; r <= end.row; r++ ){
884
+ if (this.data[r]){
885
+ const row = this.data[r];
886
+ for ( let c = start.column; c <= end.column; c++ ){
887
+ if (row[c]) {
888
+ if (!func(row[c], c, r)) {
889
+ return;
890
+ }
891
+ }
892
+ }
893
+ }
894
+ }
895
+ }
896
+ }
897
+ */
898
+ /**
899
+ * set area. shortcut to reduce overhead. consolidates single value
900
+ * and array value methods, although the implementation is separate.
901
+ *
902
+ * watch out for typed arrays, which do not satisfy Array.isArray
903
+ *
904
+ * when would this function get a 1D typed array? can't figure that out.
905
+ * just drop for the time being.
906
+ *
907
+ */
908
+ SetArea(area, values) {
909
+ if (ArrayBuffer.isView(values)) {
910
+ throw new Error('ABIV');
911
+ }
912
+ if (Array.isArray(values)) { // || ArrayBuffer.isView(values)) {
913
+ for (let r = area.start.row, i = 0; r <= area.end.row; r++, i++) {
914
+ if (!this.data[r])
915
+ this.data[r] = [];
916
+ const row = this.data[r];
917
+ if (values[i]) {
918
+ for (let c = area.start.column, j = 0; c <= area.end.column; c++, j++) {
919
+ if (!row[c])
920
+ row[c] = new Cell();
921
+ row[c].Set(values[i][j]); // undefined should be implicit
922
+ }
923
+ }
924
+ }
925
+ }
926
+ else {
927
+ const value_type = GetValueType(values); // otherwise we'd just call it every time
928
+ for (let r = area.start.row; r <= area.end.row; r++) {
929
+ if (!this.data[r])
930
+ this.data[r] = [];
931
+ const row = this.data[r];
932
+ for (let c = area.start.column; c <= area.end.column; c++) {
933
+ if (!row[c])
934
+ row[c] = new Cell();
935
+ row[c].Set(values, value_type);
936
+ }
937
+ }
938
+ }
939
+ this.rows_ = Math.max(this.rows_, area.end.row + 1);
940
+ this.columns_ = Math.max(this.columns_, area.end.column + 1);
941
+ }
942
+ /**
943
+ * yet another iterator, this one returns cell and address.
944
+ * iterates all cells; does not create missing cells.
945
+ *
946
+ * UPDATE: adding area parameter; not shrinking it (don't call w/ infinities)
947
+ */
948
+ *IterateRC(area, create_missing_cells = false) {
949
+ if (!area && create_missing_cells) {
950
+ area = new Area({
951
+ row: 0,
952
+ column: 0,
953
+ }, {
954
+ row: this.rows_ - 1,
955
+ column: this.columns - 1,
956
+ });
957
+ }
958
+ if (area) {
959
+ if (create_missing_cells) {
960
+ for (let row = area.start.row; row <= area.end.row; row++) {
961
+ if (!this.data[row])
962
+ this.data[row] = [];
963
+ const block = this.data[row];
964
+ for (let column = area.start.column; column <= area.end.column; column++) {
965
+ if (!block[column]) {
966
+ block[column] = new Cell();
967
+ }
968
+ yield { cell: block[column], row, column };
969
+ }
970
+ }
971
+ }
972
+ else {
973
+ for (let row = area.start.row; row <= area.end.row; row++) {
974
+ const block = this.data[row];
975
+ if (block) {
976
+ for (let column = area.start.column; column <= area.end.column; column++) {
977
+ const cell = block[column];
978
+ if (cell) {
979
+ yield { cell, row, column };
980
+ }
981
+ }
982
+ }
983
+ }
984
+ }
985
+ }
986
+ else {
987
+ for (const [row, r] of this.data.entries()) {
988
+ if (r) {
989
+ for (const [column, cell] of r.entries()) {
990
+ if (cell) {
991
+ yield { cell, row, column };
992
+ }
993
+ }
994
+ }
995
+ }
996
+ }
997
+ }
998
+ /**
999
+ * replacement for old callback iterator. this is a composite
1000
+ * of iterating all and iterating an area. I want to remove the
1001
+ * other method, but there are still some calls that use the
1002
+ * cell address.
1003
+ *
1004
+ * Q: is it possible to use Symbol.iterator with arguments?
1005
+ * A: apparently it is, but how would you call it? (...)
1006
+ */
1007
+ *Iterate(area, create_missing_cells = false) {
1008
+ // special case. normally iterating over all cells
1009
+ // doesn't create missing, so we use a simpler loop.
1010
+ if (!area && create_missing_cells) {
1011
+ area = new Area({
1012
+ row: 0,
1013
+ column: 0,
1014
+ }, {
1015
+ row: this.rows_ - 1,
1016
+ column: this.columns - 1,
1017
+ });
1018
+ }
1019
+ // if we have an area, iterate over the area. we need indexes.
1020
+ if (area) {
1021
+ // allow single address
1022
+ if (IsCellAddress(area)) {
1023
+ area = new Area(area);
1024
+ }
1025
+ // why not just cap? (...)
1026
+ // if (area.entire_column || area.entire_row) {
1027
+ // throw new Error(`don't iterate infinite cells`);
1028
+ //}
1029
+ if (area.entire_column || area.entire_row) {
1030
+ area = new Area(area.start, area.end);
1031
+ if (area.start.column === Infinity) {
1032
+ area.start.column = 0;
1033
+ area.end.column = this.columns_ - 1;
1034
+ }
1035
+ if (area.start.row === Infinity) {
1036
+ area.start.row = 0;
1037
+ area.end.row = this.rows_ - 1;
1038
+ }
1039
+ }
1040
+ const start = area.start;
1041
+ const end = area.end;
1042
+ if (create_missing_cells) {
1043
+ for (let r = start.row; r <= end.row; r++) {
1044
+ if (!this.data[r])
1045
+ this.data[r] = [];
1046
+ const row = this.data[r];
1047
+ for (let c = start.column; c <= end.column; c++) {
1048
+ if (!row[c])
1049
+ row[c] = new Cell();
1050
+ yield row[c]; // { row: r, column: c, cell: row[c] };
1051
+ }
1052
+ }
1053
+ }
1054
+ else {
1055
+ // we can loop over indexes that don't exist, just check for existence
1056
+ for (let r = start.row; r <= end.row; r++) {
1057
+ if (this.data[r]) {
1058
+ const row = this.data[r];
1059
+ for (let c = start.column; c <= end.column; c++) {
1060
+ if (row[c]) {
1061
+ yield row[c]; // { row: r, column: c, cell: row[c] };
1062
+ }
1063
+ }
1064
+ }
1065
+ }
1066
+ }
1067
+ }
1068
+ else {
1069
+ // no area; just iterate all cells. implicitly skip undefined cells.
1070
+ for (const row of this.data) {
1071
+ if (row) {
1072
+ for (const cell of row) {
1073
+ if (cell) {
1074
+ yield cell;
1075
+ }
1076
+ }
1077
+ }
1078
+ }
1079
+ }
1080
+ }
1081
+ /* *
1082
+ * iterates over all cells (using loops) and runs function per-cell.
1083
+ * FIXME: switch to indexing on empty indexes? (...)
1084
+ *
1085
+ * removed in favor of generator-based function
1086
+ *
1087
+ * /
1088
+ public IterateAll(func: (cell: Cell) => void){
1089
+ / *
1090
+ const row_keys = Object.keys(this.data);
1091
+ for (const row of row_keys){
1092
+ const n_row = Number(row) || 0;
1093
+ const column_keys = Object.keys(this.data[n_row]);
1094
+ for (const column_key of column_keys){
1095
+ f(this.data[n_row][Number(column_key)]);
1096
+ }
1097
+ }
1098
+ * /
1099
+ for (const row of this.data) {
1100
+ if (row) {
1101
+ for (const cell of row) {
1102
+ if (cell) {
1103
+ func(cell);
1104
+ }
1105
+ }
1106
+ }
1107
+ }
1108
+
1109
+ }
1110
+ */
1111
+ /** moved from sheet, so we can do it non-functional style (for perf) */
1112
+ FlushCellStyles() {
1113
+ for (const row of this.data) {
1114
+ if (row) {
1115
+ for (const cell of row) {
1116
+ if (cell) {
1117
+ cell.FlushStyle();
1118
+ }
1119
+ }
1120
+ }
1121
+ }
1122
+ }
1123
+ /** moved from sheet, so we can do it non-functional style (for perf) */
1124
+ FlushCachedValues() {
1125
+ for (const row of this.data) {
1126
+ if (row) {
1127
+ for (const cell of row) {
1128
+ if (cell) {
1129
+ cell.FlushCache();
1130
+ }
1131
+ }
1132
+ }
1133
+ }
1134
+ }
1135
+ }
1136
+ //# sourceMappingURL=cells.js.map