@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,1134 @@
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 * as OOXML from 'ooxml-types';
22
+ import { MapTags } from './ooxml';
23
+ // import * as ElementTree from 'elementtree';
24
+ // import { Element, ElementTree as Tree } from 'elementtree';
25
+ import { Style, IsHTMLColor, IsThemeColor, ThemeColorIndex } from 'treb-base-types';
26
+ import { Theme } from './workbook-theme';
27
+ import { NumberFormatCache } from 'treb-format';
28
+ // import { XMLUtils } from './xml-utils';
29
+ import { Unescape } from './unescape_xml';
30
+ // what's the default font size? ... 11pt?
31
+ const DEFAULT_FONT_SIZE = 11;
32
+ const default_border = {
33
+ top: {}, left: {}, bottom: {}, right: {}, diagonal: {},
34
+ };
35
+ export class StyleCache {
36
+ /**
37
+ * thanks to
38
+ * http://polymathprogrammer.com/2011/02/15/built-in-styles-for-excel-open-xml/
39
+ */
40
+ static default_styles = {
41
+ 0: 'General',
42
+ 1: '0',
43
+ 2: '0.00',
44
+ 3: '#,##0',
45
+ 4: '#,##0.00',
46
+ 9: '0%',
47
+ 10: '0.00%',
48
+ 11: '0.00E+00',
49
+ 12: '# ?/?',
50
+ 13: '# ??/??',
51
+ 14: 'mm-dd-yy',
52
+ 15: 'd-mmm-yy',
53
+ 16: 'd-mmm',
54
+ 17: 'mmm-yy',
55
+ 18: 'h:mm AM/PM',
56
+ 19: 'h:mm:ss AM/PM',
57
+ 20: 'h:mm',
58
+ 21: 'h:mm:ss',
59
+ 22: 'm/d/yy h:mm',
60
+ 37: '#,##0 ;(#,##0)',
61
+ 38: '#,##0 ;[Red](#,##0)',
62
+ 39: '#,##0.00;(#,##0.00)',
63
+ 40: '#,##0.00;[Red](#,##0.00)',
64
+ 45: 'mm:ss',
65
+ 46: '[h]:mm:ss',
66
+ 47: 'mmss.0',
67
+ 48: '##0.0E+0',
68
+ 49: '@',
69
+ };
70
+ theme = new Theme();
71
+ cell_xfs = [];
72
+ fonts = [];
73
+ borders = [];
74
+ fills = [];
75
+ number_formats = [];
76
+ base_number_format_id = 200; // ?
77
+ dxf_styles = [];
78
+ // public dom?: Tree;
79
+ modified = false;
80
+ Clamp(value, min, max) {
81
+ return Math.max(min, Math.min(value, max));
82
+ }
83
+ TintColor(base, tint) {
84
+ let r = parseInt(base.substr(0, 2), 16);
85
+ let g = parseInt(base.substr(2, 2), 16);
86
+ let b = parseInt(base.substr(4, 2), 16);
87
+ if (tint < 0) {
88
+ r = Math.round(r * tint + r);
89
+ g = Math.round(g * tint + g);
90
+ b = Math.round(b * tint + b);
91
+ }
92
+ else {
93
+ r = Math.round((255 - r) * tint + r);
94
+ g = Math.round((255 - g) * tint + g);
95
+ b = Math.round((255 - b) * tint + b);
96
+ }
97
+ return [r, g, b].map((x) => {
98
+ const s = this.Clamp(x, 0, 255).toString(16);
99
+ return s.length < 2 ? ('0' + s) : s;
100
+ }).join('');
101
+ }
102
+ ///
103
+ StyleOptionsFromProperties(source) {
104
+ const composite = // Style.Composite(list);
105
+ JSON.parse(JSON.stringify(source));
106
+ for (const key of Object.keys(composite)) {
107
+ if (composite[key] === 'none') {
108
+ delete composite[key];
109
+ }
110
+ }
111
+ const font = {};
112
+ const fill = { pattern_type: 'none' };
113
+ const border = JSON.parse(JSON.stringify(default_border));
114
+ const options = {
115
+ font, border,
116
+ };
117
+ if (composite.number_format) {
118
+ // we have some symbolic number formats that we'll need to
119
+ // translate. these are defined by the cache.
120
+ options.number_format = {
121
+ format: NumberFormatCache.Translate(composite.number_format),
122
+ symbolic_name: composite.number_format, // for reference later
123
+ };
124
+ if (/Scientific/i.test(composite.number_format)) {
125
+ options.number_format.format = '0.00E+00';
126
+ }
127
+ }
128
+ if (composite.font_size?.unit && composite.font_size.value) {
129
+ if (composite.font_size.unit === 'em') {
130
+ font.size = composite.font_size.value * DEFAULT_FONT_SIZE;
131
+ }
132
+ else if (composite.font_size.unit === '%') {
133
+ font.size = composite.font_size.value * DEFAULT_FONT_SIZE / 100;
134
+ }
135
+ else if (composite.font_size.unit === 'pt') {
136
+ font.size = composite.font_size.value;
137
+ }
138
+ else if (composite.font_size.unit === 'px') {
139
+ font.size = composite.font_size.value * .75; // ?
140
+ }
141
+ else {
142
+ console.warn(`Unhandled font size unit`, composite.font_size);
143
+ }
144
+ }
145
+ if (composite.bold)
146
+ font.bold = true;
147
+ if (composite.italic)
148
+ font.italic = true;
149
+ if (composite.underline)
150
+ font.underline = true;
151
+ //if (composite.text_color && composite.text_color !== Style.DefaultProperties.text_color) {
152
+ // font.color_argb = composite.text_color;
153
+ //}
154
+ if (composite.text) {
155
+ if (IsHTMLColor(composite.text)) {
156
+ font.color_argb = composite.text.text;
157
+ }
158
+ else if (IsThemeColor(composite.text)) {
159
+ font.color_theme = ThemeColorIndex(composite.text);
160
+ if (composite.text.tint) {
161
+ font.color_tint = composite.text.tint;
162
+ }
163
+ }
164
+ }
165
+ const TranslateBorder = (src, dest) => {
166
+ if (src.width) {
167
+ dest.style = 'thin';
168
+ if (IsHTMLColor(src.color)) {
169
+ dest.rgba = src.color.text;
170
+ }
171
+ else if (IsThemeColor(src.color)) {
172
+ dest.theme = ThemeColorIndex(src.color);
173
+ if (src.color.tint) {
174
+ dest.tint = src.color.tint;
175
+ }
176
+ }
177
+ else {
178
+ dest.color = 64;
179
+ }
180
+ }
181
+ };
182
+ const composite_borders = Style.CompositeBorders(composite);
183
+ TranslateBorder(composite_borders.top, border.top);
184
+ TranslateBorder(composite_borders.left, border.left);
185
+ TranslateBorder(composite_borders.right, border.right);
186
+ TranslateBorder(composite_borders.bottom, border.bottom);
187
+ /*
188
+ if (composite.border_top) { // && composite.border_top_fill) {
189
+
190
+ border.top.style = 'thin';
191
+ if (composite.border_top_fill?.text) {
192
+ border.top.rgba = composite.border_top_fill.text;
193
+ }
194
+ else if (typeof composite.border_top_fill?.theme === 'number') {
195
+ border.top.theme = composite.border_top_fill.theme;
196
+ if (composite.border_top_fill.tint) {
197
+ border.top.tint = composite.border_top_fill.tint;
198
+ }
199
+ }
200
+ else {
201
+ border.top.color = 64;
202
+ }
203
+ }
204
+ if (composite.border_bottom) { // && composite.border_bottom_fill) {
205
+
206
+ if (composite.border_bottom > 1) {
207
+ border.bottom.style = 'double';
208
+ }
209
+ else {
210
+ border.bottom.style = 'thin';
211
+ }
212
+ if (composite.border_bottom_fill?.text) {
213
+ border.bottom.rgba = composite.border_bottom_fill.text;
214
+ }
215
+ else if (typeof composite.border_bottom_fill?.theme === 'number') {
216
+ border.bottom.theme = composite.border_bottom_fill.theme;
217
+ if (composite.border_bottom_fill.tint) {
218
+ border.bottom.tint = composite.border_bottom_fill.tint;
219
+ }
220
+ }
221
+ else {
222
+ border.bottom.color = 64;
223
+ }
224
+ }
225
+ if (composite.border_left) { // && composite.border_left_fill) {
226
+
227
+ border.left.style = 'thin';
228
+ if (composite.border_left_fill?.text) {
229
+ border.left.rgba = composite.border_left_fill.text;
230
+ }
231
+ else if (typeof composite.border_left_fill?.theme === 'number') {
232
+ border.left.theme = composite.border_left_fill.theme;
233
+ if (composite.border_left_fill.tint) {
234
+ border.left.tint = composite.border_left_fill.tint;
235
+ }
236
+ }
237
+ else {
238
+ border.left.color = 64;
239
+ }
240
+ }
241
+ if (composite.border_right) { // && composite.border_right_fill) {
242
+
243
+ border.right.style = 'thin';
244
+ if (composite.border_right_fill?.text) {
245
+ border.right.rgba = composite.border_right_fill.text;
246
+ }
247
+ else if (typeof composite.border_right_fill?.theme === 'number') {
248
+ border.right.theme = composite.border_right_fill.theme;
249
+ if (composite.border_right_fill.tint) {
250
+ border.right.tint = composite.border_right_fill.tint;
251
+ }
252
+ }
253
+ else {
254
+ border.right.color = 64;
255
+ }
256
+
257
+ // console.info("BXX", JSON.stringify(composite, undefined, 2), JSON.stringify(border, undefined, 2));
258
+
259
+ }
260
+ */
261
+ // leave blank for bottom, default
262
+ switch (composite.vertical_align) {
263
+ case 'top': // Style.VerticalAlign.Top:
264
+ options.vertical_alignment = 'top';
265
+ break;
266
+ case 'middle': // Style.VerticalAlign.Middle:
267
+ options.vertical_alignment = 'center';
268
+ break;
269
+ }
270
+ switch (composite.horizontal_align) {
271
+ case 'center': // Style.HorizontalAlign.Center:
272
+ options.horizontal_alignment = 'center';
273
+ break;
274
+ case 'left': // Style.HorizontalAlign.Left:
275
+ options.horizontal_alignment = 'left';
276
+ break;
277
+ case 'right': // Style.HorizontalAlign.Right:
278
+ options.horizontal_alignment = 'right';
279
+ break;
280
+ }
281
+ options.indent = composite.indent;
282
+ if (composite.fill) {
283
+ fill.pattern_type = 'solid';
284
+ if (IsHTMLColor(composite.fill)) {
285
+ fill.fg_color = { argb: composite.fill.text };
286
+ options.fill = fill;
287
+ }
288
+ else if (IsThemeColor(composite.fill)) {
289
+ fill.fg_color = { theme: ThemeColorIndex(composite.fill) };
290
+ if (composite.fill.tint) {
291
+ fill.fg_color.tint = composite.fill.tint;
292
+ }
293
+ options.fill = fill;
294
+ }
295
+ else {
296
+ // fill.fg_color = { theme: 1 };
297
+ }
298
+ }
299
+ if (composite.wrap) {
300
+ options.wrap = true;
301
+ }
302
+ return options;
303
+ }
304
+ ///
305
+ CellXfToStyle(xf) {
306
+ const props = {};
307
+ // number format
308
+ let format_string = StyleCache.default_styles[xf.number_format];
309
+ if (!format_string) {
310
+ for (const candidate of this.number_formats) {
311
+ if (candidate.id === xf.number_format) {
312
+ if (candidate.format) {
313
+ format_string = candidate.format;
314
+ break;
315
+ }
316
+ }
317
+ }
318
+ }
319
+ if (format_string) {
320
+ // Excel uses number formats like
321
+ // #,##0.00\ [$€-40C];[Red]\-#,##0.00\ [$€-40C]
322
+ // [$¥-411]#,##0;[Red]\-[$¥-411]#,##0
323
+ // _("$"* #,##0_);_("$"* \(#,##0\);_("$"* "-"??_);_(@_)
324
+ // where [$¥-411] encodes a yen symbol, [$€-40C] is the euro, &c.
325
+ // I have no idea what that encoding is, or where it comes from
326
+ // (can't find it in Excel documentation; should probably check OOo).
327
+ // for the time being we will just drop, and assume the symbol
328
+ // (in position 2) is correct. are we sure there are always 3 hex
329
+ // characters? and always negative? (...)
330
+ // OK, got it, these are Microsoft LCIDs in hex. so the format seems to be:
331
+ //
332
+ // square bracket, dollar sign, symbol, hyphen, hex LCID, square bracket
333
+ //
334
+ // we can safely drop this for now, AFAIAC. LCID seems to be (in hex)
335
+ // usually 3-4 digits, but I suppose lower is conceivable.
336
+ const encoding_regex = /\[\$(.)-[0-9A-Za-z]{1,4}\]/g;
337
+ format_string = format_string.replace(encoding_regex, '$1');
338
+ // there are also locale indicators with no symbol -- we can remove these
339
+ // for now, but we need to consider how to deal with them. (...)
340
+ // also this could be merged with the above.
341
+ const locale_regex = /\[\$-[0-9A-Za-z]{1,4}\]/g;
342
+ format_string = format_string.replace(locale_regex, '');
343
+ props.number_format = format_string;
344
+ }
345
+ // font attributes (atm we are ignoring size, face)
346
+ const base_font = this.fonts[0];
347
+ const font = this.fonts[xf.font || 0];
348
+ if (font) {
349
+ if (font.bold)
350
+ props.bold = true;
351
+ if (font.italic)
352
+ props.italic = true;
353
+ if (font.underline)
354
+ props.underline = true;
355
+ if (font.strike)
356
+ props.strike = true;
357
+ // implement font size... experimental. treat font size as % of
358
+ // base size, which we assume is in slot 0.
359
+ if (base_font && base_font.size && font.size && base_font.size !== font.size) {
360
+ props.font_size = {
361
+ value: 100 * font.size / base_font.size,
362
+ unit: '%',
363
+ };
364
+ }
365
+ if (font.color_argb) {
366
+ props.text = {
367
+ text: '#' + (font.color_argb.length > 6 ?
368
+ font.color_argb.substr(font.color_argb.length - 6) :
369
+ font.color_argb)
370
+ };
371
+ }
372
+ else if (typeof font.color_theme === 'number') {
373
+ // const index = Theme.color_map[];
374
+ // skipping 0, it's implicit
375
+ // no it is not (1 is implicit?)
376
+ props.text = { theme: font.color_theme };
377
+ /*
378
+ // FIXME: update to theme
379
+ console.warn('update to theme colors');
380
+
381
+ const index = Theme.color_map[font.color_theme];
382
+ const color = this.theme.colors[index];
383
+
384
+ // why was I _not_ accepting system here? (...) there's an argument
385
+ // against system 1 -> default...
386
+
387
+ if (color && color.type !== 'system' && color.value) {
388
+ if (typeof font.color_tint === 'number') {
389
+ props.text = '#' + this.TintColor(color.value, font.color_tint);
390
+ }
391
+ else {
392
+ props.text = '#' + color.value;
393
+ }
394
+ }
395
+
396
+ else if (color && color.type === 'system' && color.value) {
397
+
398
+ // let's drop color index 1, as that should be default? (...)
399
+ // should do this higher up
400
+
401
+ if (font.color_theme !== 1) {
402
+ props.text = '#' + color.value;
403
+ }
404
+ }
405
+ */
406
+ }
407
+ }
408
+ const fill = this.fills[xf.fill || 0];
409
+ if (fill && fill.pattern_type !== 'none') {
410
+ if (fill.pattern_type === 'gray') {
411
+ const value = Math.round((fill.pattern_gray || 0) / 1000 * 255);
412
+ // props.background = `rgb(${value}, ${value}, ${value})`;
413
+ props.fill = { text: `rgb(${value}, ${value}, ${value})` };
414
+ }
415
+ if (fill.pattern_type === 'solid') {
416
+ if (fill.fg_color) {
417
+ if (fill.fg_color.argb) {
418
+ props.fill = { text: '#' + (fill.fg_color.argb.length > 6 ?
419
+ fill.fg_color.argb.substr(fill.fg_color.argb.length - 6) :
420
+ fill.fg_color.argb)
421
+ };
422
+ }
423
+ else if (typeof fill.fg_color.theme === 'number') {
424
+ props.fill = {
425
+ theme: fill.fg_color.theme,
426
+ // tint: fill.fg_color.tint,
427
+ };
428
+ if (fill.fg_color.tint) {
429
+ props.fill.tint = Math.round(fill.fg_color.tint * 1000) / 1000;
430
+ }
431
+ /*
432
+ const index = Theme.color_map[fill.fg_color.theme];
433
+ const color = this.theme.colors[index];
434
+ // if (color && color.type !== 'system' && color.value) {
435
+ if (color && color.value) {
436
+ if (typeof fill.fg_color.tint === 'number') {
437
+ props.background = '#' + this.TintColor(color.value, fill.fg_color.tint);
438
+ }
439
+ else {
440
+ props.background = '#' + color.value;
441
+ }
442
+ }
443
+ */
444
+ }
445
+ }
446
+ }
447
+ }
448
+ // alignments (TODO: valign)
449
+ switch (xf.horizontal_alignment) {
450
+ case 'center':
451
+ props.horizontal_align = 'center'; // Style.HorizontalAlign.Center;
452
+ break;
453
+ case 'right':
454
+ props.horizontal_align = 'right'; // Style.HorizontalAlign.Right;
455
+ break;
456
+ case 'left':
457
+ props.horizontal_align = 'left'; // Style.HorizontalAlign.Left;
458
+ break;
459
+ }
460
+ switch (xf.vertical_alignment) {
461
+ case 'center':
462
+ props.vertical_align = 'middle'; // Style.VerticalAlign.Middle;
463
+ break;
464
+ case 'top':
465
+ props.vertical_align = 'top'; // Style.VerticalAlign.Top;
466
+ break;
467
+ case 'bottom':
468
+ props.vertical_align = 'bottom'; // Style.VerticalAlign.Bottom;
469
+ break;
470
+ }
471
+ // indent
472
+ props.indent = (typeof xf.indent === 'string') ? Number(xf.indent) : xf.indent;
473
+ // wrap
474
+ if (xf.wrap_text) {
475
+ props.wrap = true;
476
+ }
477
+ // borders
478
+ const BorderEdgeToColor = (edge) => {
479
+ // TODO: indexed
480
+ if (typeof edge.theme !== 'undefined') {
481
+ return {
482
+ theme: edge.theme,
483
+ tint: edge.tint,
484
+ };
485
+ }
486
+ };
487
+ const border = this.borders[xf.border || 0];
488
+ if (border) {
489
+ if (border.bottom.style) {
490
+ if (border.bottom.style === 'double') {
491
+ props.border_bottom = 2;
492
+ }
493
+ else {
494
+ props.border_bottom = 1;
495
+ }
496
+ props.border_bottom_fill = BorderEdgeToColor(border.bottom);
497
+ }
498
+ if (border.left.style) {
499
+ props.border_left = 1;
500
+ props.border_left_fill = BorderEdgeToColor(border.left);
501
+ }
502
+ if (border.top.style) {
503
+ props.border_top = 1;
504
+ props.border_top_fill = BorderEdgeToColor(border.top);
505
+ }
506
+ if (border.right.style) {
507
+ props.border_right = 1;
508
+ props.border_right_fill = BorderEdgeToColor(border.right);
509
+ }
510
+ }
511
+ return props;
512
+ }
513
+ /** map all cell xfs to styles; retain order */
514
+ CellXfToStyles() {
515
+ /*
516
+ const mapped = this.cell_xfs.map((xf, index) => {
517
+ const style = this.CellXfToStyle(xf);
518
+ if (style.font_size?.value && style.font_size.value > 200) {
519
+ console.info({index, fs: JSON.stringify(style.font_size), style, xf});
520
+ console.info(this);
521
+ }
522
+ return style;
523
+ });
524
+ return mapped;
525
+ */
526
+ return this.cell_xfs.map((xf) => this.CellXfToStyle(xf));
527
+ }
528
+ EnsureNumberFormat(number_format) {
529
+ // there are a lot of default, implicit number formats.
530
+ // we should probably find out what they are. for the time
531
+ // being, just use 0 for no properties.
532
+ if (typeof number_format.format === 'undefined')
533
+ return 0;
534
+ // we changed the casing on this at some point, so let's be
535
+ // broad here. general is important because it has the magic
536
+ // decimal point, we don't want to revert to an explicit style
537
+ // because there's no description syntax for that
538
+ if (number_format.symbolic_name) {
539
+ if (/^general$/i.test(number_format.symbolic_name)) {
540
+ return 0;
541
+ }
542
+ }
543
+ // check the rest of the built-in types... note this is not an array?
544
+ // (why not?) also, is the length guaranteed?
545
+ for (let i = 0; i < 100; i++) {
546
+ const check = StyleCache.default_styles[i];
547
+ if (check && check === number_format.format) {
548
+ return i;
549
+ }
550
+ }
551
+ for (const candidate of this.number_formats) {
552
+ if (candidate.format === number_format.format)
553
+ return candidate.id || 0;
554
+ }
555
+ this.modified = true;
556
+ const new_format = {
557
+ id: this.base_number_format_id++,
558
+ format: number_format.format,
559
+ };
560
+ this.number_formats.push(new_format);
561
+ /*
562
+ if (!this.dom) throw new Error('missing dom');
563
+ let number_formats = this.dom.find('./numFmts');
564
+
565
+ if (!number_formats){
566
+ number_formats = Element('numFmts', {count: '1'});
567
+ const root = this.dom.getroot();
568
+ (root as any)._children = [number_formats].concat((root as any)._children);
569
+ // this.dom.getroot().append(number_formats);
570
+ }
571
+ else {
572
+ number_formats.attrib.count = (Number(number_formats.attrib.count || 0) + 1).toString();
573
+ }
574
+
575
+ number_formats.append(Element('numFmt', {
576
+ numFmtId: new_format.id.toString(),
577
+ formatCode: new_format.format,
578
+ }));
579
+ */
580
+ return new_format.id;
581
+ }
582
+ CompareBorderEdge(a, b) {
583
+ return a.color === b.color
584
+ && a.rgba === b.rgba
585
+ && a.style === b.style
586
+ && a.theme === b.theme
587
+ && a.tint === b.tint;
588
+ }
589
+ CompareBorder(a, b) {
590
+ return this.CompareBorderEdge(a.top, b.top)
591
+ && this.CompareBorderEdge(a.left, b.left)
592
+ && this.CompareBorderEdge(a.bottom, b.bottom)
593
+ && this.CompareBorderEdge(a.right, b.right)
594
+ && this.CompareBorderEdge(a.diagonal, b.diagonal);
595
+ }
596
+ EnsureBorder(border) {
597
+ for (let i = 0; i < this.borders.length; i++) {
598
+ const candidate = this.borders[i];
599
+ if (this.CompareBorder(candidate, border)) {
600
+ return i;
601
+ }
602
+ }
603
+ this.modified = true;
604
+ const new_border = JSON.parse(JSON.stringify(border)); // {...border};
605
+ this.borders.push(new_border);
606
+ /*
607
+
608
+ if (!this.dom) throw new Error('missing dom');
609
+ const borders = this.dom.find('./borders');
610
+
611
+ if (!borders) throw new Error('borders not found');
612
+ borders.attrib.count = (Number(borders.attrib.count || 0) + 1).toString();
613
+
614
+ const new_element = Element('border');
615
+
616
+ const left = Element('left');
617
+ if (border.left_style) {
618
+ left.attrib.style = border.left_style;
619
+ // left.append(Element('color', {indexed: (border.left_color || 0).toString() }));
620
+ const attrs: ColorAttributes = {};
621
+ if (border.left_color_rgba) {
622
+ attrs.rgb = border.left_color_rgba;
623
+ }
624
+ else if (typeof border.left_color_theme === 'number') {
625
+ attrs.theme = border.left_color_theme.toString();
626
+ if (border.left_color_tint) {
627
+ attrs.tint = border.left_color_tint.toString();
628
+ }
629
+ }
630
+ else {
631
+ attrs.indexed = (border.left_color || 0).toString();
632
+ }
633
+ left.append(Element('color', attrs as ElementTree.Attributes));
634
+ }
635
+ new_element.append(left);
636
+
637
+ const right = Element('right');
638
+ if (border.right_style) {
639
+ right.attrib.style = border.right_style;
640
+ // right.append(Element('color', {indexed: (border.right_color || 0).toString() }));
641
+ const attrs: ColorAttributes = {};
642
+ if (border.right_color_rgba) {
643
+ attrs.rgb = border.right_color_rgba;
644
+ }
645
+ else if (typeof border.right_color_theme === 'number') {
646
+ attrs.theme = border.right_color_theme.toString();
647
+ if (border.right_color_tint) {
648
+ attrs.tint = border.right_color_tint.toString();
649
+ }
650
+ }
651
+ else {
652
+ attrs.indexed = (border.right_color || 0).toString();
653
+ }
654
+ right.append(Element('color', attrs as ElementTree.Attributes));
655
+
656
+ }
657
+ new_element.append(right);
658
+
659
+ const top = Element('top');
660
+ if (border.top_style) {
661
+ top.attrib.style = border.top_style;
662
+ const attrs: ColorAttributes = {};
663
+ if (border.top_color_rgba) {
664
+ attrs.rgb = border.top_color_rgba;
665
+ }
666
+ else if (typeof border.top_color_theme === 'number') {
667
+ attrs.theme = border.top_color_theme.toString();
668
+ if (border.top_color_tint) {
669
+ attrs.tint = border.top_color_tint.toString();
670
+ }
671
+ }
672
+ else {
673
+ attrs.indexed = (border.top_color || 0).toString();
674
+ }
675
+ top.append(Element('color', attrs as ElementTree.Attributes));
676
+ }
677
+ new_element.append(top);
678
+
679
+ const bottom = Element('bottom');
680
+ if (border.bottom_style) {
681
+
682
+ // console.info("BOTTOM STYLE", border);
683
+
684
+ bottom.attrib.style = border.bottom_style;
685
+ // bottom.append(Element('color', {indexed: (border.bottom_color || 0).toString() }));
686
+ const attrs: ColorAttributes = {};
687
+ if (border.bottom_color_rgba) {
688
+ attrs.rgb = border.bottom_color_rgba;
689
+ }
690
+ else if (typeof border.bottom_color_theme === 'number') {
691
+ attrs.theme = border.bottom_color_theme.toString();
692
+ if (border.bottom_color_tint) {
693
+ attrs.tint = border.bottom_color_tint.toString();
694
+ }
695
+ }
696
+ else {
697
+ attrs.indexed = (border.bottom_color || 0).toString();
698
+ }
699
+ bottom.append(Element('color', attrs as ElementTree.Attributes));
700
+ }
701
+ new_element.append(bottom);
702
+
703
+ const diagonal = Element('diagonal');
704
+ if (border.diagonal_style) {
705
+ diagonal.attrib.style = border.diagonal_style;
706
+ diagonal.append(Element('color', {indexed: (border.diagonal_color || 0).toString() }));
707
+ }
708
+ new_element.append(diagonal);
709
+
710
+ borders.append(new_element);
711
+ */
712
+ return this.borders.length - 1;
713
+ }
714
+ MatchColor(a, b) {
715
+ if (!a && !b) {
716
+ return true;
717
+ }
718
+ if (!a || !b) {
719
+ return false;
720
+ }
721
+ return (a.argb === b.argb
722
+ && a.indexed === b.indexed
723
+ && a.theme === b.theme
724
+ && a.tint === b.tint);
725
+ }
726
+ EnsureFill(fill) {
727
+ for (let i = 0; i < this.fills.length; i++) {
728
+ const candidate = this.fills[i];
729
+ if (this.MatchColor(fill.bg_color, candidate.bg_color)
730
+ && this.MatchColor(fill.fg_color, candidate.fg_color)
731
+ && fill.pattern_gray === candidate.pattern_gray
732
+ && fill.pattern_type === candidate.pattern_type) {
733
+ return i;
734
+ }
735
+ }
736
+ this.modified = true;
737
+ const new_fill = { ...fill };
738
+ this.fills.push(new_fill);
739
+ return this.fills.length - 1;
740
+ }
741
+ /**
742
+ * for the time being we are ignoring font face, family, size, color and
743
+ * scheme (whatever that is). every font is based on font 0, the default.
744
+ * we add bold/italic/underline as necessary.
745
+ */
746
+ EnsureFont(font) {
747
+ // this is what we create, so we need to test against it
748
+ const composite_font = { ...this.fonts[0], ...font };
749
+ // const props = Object.keys(font).filter((key) => typeof (font as any)[key] !== 'undefined');
750
+ for (let i = 0; i < this.fonts.length; i++) {
751
+ const candidate = this.fonts[i];
752
+ //let match = true;
753
+ //for (const prop of props) {
754
+ // match = match && (font as any)[prop] === (candidate as any)[prop];
755
+ //}
756
+ const match = (candidate.bold === composite_font.bold)
757
+ && (candidate.italic === composite_font.italic)
758
+ && (candidate.underline === composite_font.underline)
759
+ && (candidate.size === composite_font.size)
760
+ && (candidate.strike === composite_font.strike)
761
+ && (candidate.color_argb === composite_font.color_argb)
762
+ && (candidate.color_theme === composite_font.color_theme)
763
+ && (candidate.color_tint === composite_font.color_tint)
764
+ && (candidate.family === composite_font.family);
765
+ if (match) {
766
+ return i;
767
+ }
768
+ }
769
+ this.modified = true;
770
+ // const composite_font = test; // {...this.fonts[0], ...font};
771
+ this.fonts.push(composite_font);
772
+ /*
773
+ // add the node structure
774
+
775
+ if (!this.dom) throw new Error('missing dom');
776
+ const fonts = this.dom.find('./fonts');
777
+
778
+ if (!fonts) throw new Error('fonts not found');
779
+ fonts.attrib.count = (Number(fonts.attrib.count || 0) + 1).toString();
780
+
781
+ const new_element = Element('font');
782
+ new_element.append(Element('sz', { val: (composite_font.size || 0).toString() }));
783
+
784
+ // new_element.append(Element('color', { theme: (new_font.color_theme || 0).toString() }));
785
+ // new_element.append(Element('color', { theme: (new_font.color_theme || 0).toString() }));
786
+
787
+ if (typeof composite_font.color_argb !== 'undefined') {
788
+ new_element.append(Element('color', { rgb: composite_font.color_argb }));
789
+ }
790
+ else {
791
+ new_element.append(Element('color', { theme: (composite_font.color_theme || 0).toString() }));
792
+ }
793
+
794
+ new_element.append(Element('name', { val: composite_font.name }));
795
+ new_element.append(Element('family', { val: (composite_font.family || 0).toString() }));
796
+ new_element.append(Element('scheme', { val: composite_font.scheme }));
797
+
798
+ if (composite_font.bold) new_element.append(Element('b'));
799
+ if (composite_font.underline) new_element.append(Element('u'));
800
+ if (composite_font.italic) new_element.append(Element('i'));
801
+ if (composite_font.strike) new_element.append(Element('strike'));
802
+
803
+ fonts.append(new_element);
804
+ */
805
+ return this.fonts.length - 1;
806
+ }
807
+ EnsureStyle(options) {
808
+ // find indexes for props
809
+ const font_index = this.EnsureFont(options.font || {});
810
+ const border_index = this.EnsureBorder(options.border || default_border);
811
+ const number_format_index = this.EnsureNumberFormat(options.number_format || {});
812
+ const fill_index = this.EnsureFill(options.fill || { pattern_type: 'none' });
813
+ // now find an XF that matches
814
+ for (let i = 0; i < this.cell_xfs.length; i++) {
815
+ const xf = this.cell_xfs[i];
816
+ if (xf.font === font_index &&
817
+ xf.fill === fill_index &&
818
+ xf.border === border_index &&
819
+ xf.number_format === number_format_index &&
820
+ !!xf.wrap_text === !!options.wrap &&
821
+ xf.indent === options.indent &&
822
+ ((!options.horizontal_alignment && !xf.horizontal_alignment) || options.horizontal_alignment === xf.horizontal_alignment) &&
823
+ ((!options.vertical_alignment && !xf.vertical_alignment) || options.vertical_alignment === xf.vertical_alignment)) {
824
+ return i;
825
+ }
826
+ }
827
+ this.modified = true;
828
+ // need a new XF -- defaults?
829
+ const new_xf = {
830
+ font: font_index,
831
+ fill: fill_index,
832
+ border: border_index,
833
+ number_format: number_format_index,
834
+ indent: options.indent,
835
+ };
836
+ if (options.horizontal_alignment) {
837
+ new_xf.horizontal_alignment = options.horizontal_alignment;
838
+ }
839
+ if (options.vertical_alignment) {
840
+ new_xf.vertical_alignment = options.vertical_alignment;
841
+ }
842
+ if (options.wrap) {
843
+ new_xf.wrap_text = true;
844
+ }
845
+ this.cell_xfs.push(new_xf);
846
+ return this.cell_xfs.length - 1;
847
+ }
848
+ FromXML(stylesheet, theme) {
849
+ // const FindAll = XMLUtils.FindAll.bind(XMLUtils, xml);
850
+ this.theme = theme;
851
+ // ---
852
+ this.number_formats = MapTags(stylesheet.numFmts?.numFmt, element => ({
853
+ id: element.$attributes?.numFmtId,
854
+ format: Unescape(element.$attributes?.formatCode || ''),
855
+ }));
856
+ /*
857
+ let composite = FindAll('styleSheet/numFmts/numFmt');
858
+
859
+ this.number_formats = composite.map(element => ({
860
+ id: Number(element.a$?.numFmtId || 0),
861
+ format: Unescape(element.a$?.formatCode || ''),
862
+ }));
863
+
864
+ // ---
865
+ */
866
+ const ElementToBorderEdge = (element, edge) => {
867
+ if (element?.$attributes) {
868
+ edge.style = element.$attributes.style;
869
+ if (element.color) {
870
+ edge.color = element.color.$attributes?.indexed;
871
+ edge.theme = element.color.$attributes?.theme;
872
+ edge.tint = element.color.$attributes?.tint;
873
+ }
874
+ }
875
+ };
876
+ this.borders = MapTags(stylesheet.borders?.border, element => {
877
+ const border = JSON.parse(JSON.stringify(default_border));
878
+ ElementToBorderEdge(element.left, border.left);
879
+ ElementToBorderEdge(element.right, border.right);
880
+ ElementToBorderEdge(element.top, border.top);
881
+ ElementToBorderEdge(element.bottom, border.bottom);
882
+ return border;
883
+ });
884
+ // ---
885
+ this.cell_xfs = MapTags(stylesheet.cellXfs?.xf, element => {
886
+ const xf = {
887
+ number_format: element.$attributes?.numFmtId ?? -1,
888
+ font: element.$attributes?.fontId ?? -1,
889
+ fill: element.$attributes?.fillId ?? -1,
890
+ border: element.$attributes?.borderId ?? -1,
891
+ xfid: element.$attributes?.xfId ?? -1,
892
+ };
893
+ if (element.alignment) {
894
+ xf.horizontal_alignment = element.alignment.$attributes?.horizontal;
895
+ xf.vertical_alignment = element.alignment.$attributes?.vertical;
896
+ xf.wrap_text = !!element.alignment.$attributes?.wrapText;
897
+ xf.indent = element.alignment.$attributes?.indent;
898
+ }
899
+ return xf;
900
+ });
901
+ /*
902
+ composite = FindAll('styleSheet/cellXfs/xf');
903
+ this.cell_xfs = composite.map(element => {
904
+
905
+ const xf: CellXf = {
906
+ number_format: Number(element.a$.numFmtId),
907
+ font: Number(element.a$.fontId),
908
+ fill: Number(element.a$.fillId),
909
+ border: Number(element.a$.borderId),
910
+ xfid: Number(element.a$.xfId),
911
+ };
912
+
913
+ if (element.alignment) {
914
+ xf.horizontal_alignment = element.alignment.a$.horizontal;
915
+ xf.vertical_alignment = element.alignment.a$.vertical;
916
+ xf.wrap_text = !!element.alignment.a$.wrapText;
917
+ xf.indent = element.alignment.a$.indent || undefined;
918
+ }
919
+
920
+ return xf;
921
+
922
+ });
923
+ */
924
+ // ---
925
+ this.fills = MapTags(stylesheet.fills?.fill, element => {
926
+ const fill = { pattern_type: 'none' };
927
+ if (element.patternFill) {
928
+ const type = element.patternFill.$attributes?.patternType;
929
+ switch (type) {
930
+ case 'none':
931
+ case undefined:
932
+ break;
933
+ case 'solid':
934
+ fill.pattern_type = 'solid';
935
+ if (element.patternFill.fgColor) {
936
+ fill.fg_color = {
937
+ theme: element.patternFill.fgColor.$attributes?.theme,
938
+ indexed: element.patternFill.fgColor.$attributes?.indexed,
939
+ tint: element.patternFill.fgColor.$attributes?.tint,
940
+ argb: element.patternFill.fgColor.$attributes?.rgb,
941
+ };
942
+ }
943
+ break;
944
+ default:
945
+ {
946
+ const match = type?.match(/^gray(\d+)$/);
947
+ if (match) {
948
+ fill.pattern_type = 'gray';
949
+ fill.pattern_gray = Number(match[1]);
950
+ }
951
+ }
952
+ break;
953
+ }
954
+ }
955
+ return fill;
956
+ });
957
+ /*
958
+ const ParseFill = (element: any) => {
959
+
960
+ const fill: Fill = { pattern_type: 'none' };
961
+ if (element.patternFill) {
962
+ const type = element.patternFill.a$?.patternType;
963
+ switch (type) {
964
+ case 'none':
965
+ case undefined:
966
+ break;
967
+
968
+ case 'solid':
969
+ fill.pattern_type = 'solid';
970
+ if (element.patternFill.fgColor) {
971
+ fill.fg_color = {
972
+ theme: element.patternFill.fgColor.a$?.theme ? Number(element.patternFill.fgColor.a$.theme) : undefined,
973
+ indexed: element.patternFill.fgColor.a$?.indexed ? Number(element.patternFill.fgColor.a$.indexed) : undefined,
974
+ tint: element.patternFill.fgColor.a$?.tint ? Number(element.patternFill.fgColor.a$.tint) : undefined,
975
+ argb: element.patternFill.fgColor.a$?.rgb,
976
+ };
977
+ }
978
+ break;
979
+
980
+ default:
981
+ {
982
+ const match = type?.match(/^gray(\d+)$/);
983
+ if (match) {
984
+ fill.pattern_type = 'gray';
985
+ fill.pattern_gray = Number(match[1]);
986
+ break;
987
+ }
988
+ }
989
+
990
+ }
991
+ }
992
+
993
+ return fill;
994
+
995
+ };
996
+
997
+ composite = FindAll('styleSheet/fills/fill');
998
+
999
+ this.fills = composite.map(ParseFill);
1000
+ */
1001
+ // ---
1002
+ this.fonts = MapTags(stylesheet.fonts?.font, element => {
1003
+ const font = {};
1004
+ font.italic = !!element.i;
1005
+ font.bold = !!element.b;
1006
+ font.underline = !!element.u;
1007
+ font.strike = !!element.strike;
1008
+ font.size = element.sz?.$attributes?.val;
1009
+ font.scheme = element.scheme?.$attributes?.val;
1010
+ font.name = element.name?.$attributes?.val;
1011
+ font.family = element.family?.$attributes?.val;
1012
+ font.color_theme = element.color?.$attributes?.theme;
1013
+ font.color_tint = element.color?.$attributes?.tint;
1014
+ font.color_argb = element.color?.$attributes?.rgb;
1015
+ return font;
1016
+ });
1017
+ /*
1018
+ const ParseFont = (element: any) => {
1019
+
1020
+ const font: Font = {};
1021
+
1022
+ font.italic = !!(typeof element.i !== 'undefined');
1023
+ font.bold = !!(typeof element.b !== 'undefined');
1024
+ font.underline = !!(typeof element.u !== 'undefined');
1025
+ font.strike = !!(typeof element.strike !== 'undefined');
1026
+
1027
+ if (element.sz) {
1028
+ font.size = Number(element.sz.a$.val);
1029
+ }
1030
+ if (element.scheme) {
1031
+ font.scheme = element.scheme.a$.val;
1032
+ }
1033
+ if (element.name) {
1034
+ font.name = element.name.a$.val;
1035
+ }
1036
+ if (element.family) {
1037
+ font.family = Number(element.family.a$.val);
1038
+ }
1039
+
1040
+ if (element.color) {
1041
+ if (element.color.a$?.theme) {
1042
+ font.color_theme = Number(element.color.a$.theme);
1043
+ }
1044
+ if (element.color.a$?.tint) {
1045
+ font.color_tint = Number(element.color.a$.tint);
1046
+ }
1047
+ if (element.color.a$?.rgb) {
1048
+ font.color_argb = element.color.a$.rgb;
1049
+ }
1050
+
1051
+ }
1052
+
1053
+ return font;
1054
+
1055
+ };
1056
+
1057
+ composite = FindAll('styleSheet/fonts/font');
1058
+ this.fonts = composite.map(ParseFont);
1059
+ */
1060
+ // ---
1061
+ const ParseDXFColor = (element) => {
1062
+ const color = {};
1063
+ if (element.$attributes?.rgb) {
1064
+ color.text = '#' + element.$attributes.rgb.substring(2);
1065
+ }
1066
+ else if (element.$attributes?.theme !== undefined) {
1067
+ color.theme = element.$attributes.theme;
1068
+ if (element.$attributes.tint !== undefined) {
1069
+ color.tint = Math.round(element.$attributes.tint * 1000) / 1000;
1070
+ }
1071
+ }
1072
+ return color;
1073
+ };
1074
+ this.dxf_styles = MapTags(stylesheet.dxfs?.dxf, dxf => {
1075
+ const style = {};
1076
+ if (dxf.font) {
1077
+ style.bold = !!dxf.font?.b;
1078
+ style.italic = !!dxf.font?.i;
1079
+ }
1080
+ if (dxf.font?.color?.$attributes) {
1081
+ style.text = ParseDXFColor(dxf.font.color);
1082
+ }
1083
+ if (dxf.fill?.patternFill?.bgColor?.$attributes) {
1084
+ style.fill = ParseDXFColor(dxf.fill.patternFill.bgColor);
1085
+ }
1086
+ return style;
1087
+ });
1088
+ /*
1089
+ // dxfs (differential formats) are inline. because reasons? not sure
1090
+ // what's allowed in there, atm we're just looking at font color and
1091
+ // background color.
1092
+
1093
+ const ParseDXFColor = (element: any) => {
1094
+ const color: Color = {};
1095
+ if (element.a$.rgb) {
1096
+ (color as HTMLColor).text = '#' + element.a$.rgb.substring(2);
1097
+ }
1098
+ else if (element.a$.theme) {
1099
+ (color as ThemeColor).theme = Number(element.a$.theme) || 0;
1100
+ if (element.a$.tint) {
1101
+ (color as ThemeColor).tint = Math.round(element.a$.tint * 1000) / 1000;
1102
+ }
1103
+ }
1104
+ return color;
1105
+ };
1106
+
1107
+ const dxfs = FindAll('styleSheet/dxfs/dxf');
1108
+ this.dxf_styles = dxfs.map(dxf => {
1109
+
1110
+ const style: CellStyle = {};
1111
+
1112
+ // dxf fonts are different too? this is irritating
1113
+
1114
+ if (dxf.font) {
1115
+ style.bold = !!dxf.font.b;
1116
+ style.italic = !!dxf.font.i && dxf.font.i.a$.val !== '0';
1117
+ }
1118
+
1119
+ // dxfs fills are different? anyway we can't reuse the above code for fill, just grab the color
1120
+
1121
+ if (dxf.font?.color?.a$) {
1122
+ style.text = ParseDXFColor(dxf.font.color);
1123
+ }
1124
+ if (dxf.fill?.patternFill?.bgColor?.a$) {
1125
+ style.fill = ParseDXFColor(dxf.fill.patternFill.bgColor);
1126
+ }
1127
+
1128
+ return style;
1129
+ });
1130
+ */
1131
+ // console.info({dxfs: this.dxf_styles});
1132
+ }
1133
+ }
1134
+ //# sourceMappingURL=workbook-style.js.map