@gridsheet/react-core 1.4.0-alpha.9 → 2.0.0-rc.0

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 (400) hide show
  1. package/README.md +27 -0
  2. package/dist/components/Cell.d.ts +3 -3
  3. package/dist/components/Cell.d.ts.map +1 -1
  4. package/dist/components/ContextMenu.d.ts +19 -2
  5. package/dist/components/ContextMenu.d.ts.map +1 -1
  6. package/dist/components/Editor.d.ts +5 -4
  7. package/dist/components/Editor.d.ts.map +1 -1
  8. package/dist/components/Emitter.d.ts +2 -2
  9. package/dist/components/Emitter.d.ts.map +1 -1
  10. package/dist/components/Fixed.d.ts +3 -3
  11. package/dist/components/Fixed.d.ts.map +1 -1
  12. package/dist/components/FormulaBar.d.ts +1 -2
  13. package/dist/components/FormulaBar.d.ts.map +1 -1
  14. package/dist/components/GridSheet.d.ts +1 -2
  15. package/dist/components/GridSheet.d.ts.map +1 -1
  16. package/dist/components/HeaderCellLeft.d.ts +2 -2
  17. package/dist/components/HeaderCellLeft.d.ts.map +1 -1
  18. package/dist/components/HeaderCellTop.d.ts +2 -2
  19. package/dist/components/HeaderCellTop.d.ts.map +1 -1
  20. package/dist/components/PluginBase.d.ts +4 -4
  21. package/dist/components/PluginBase.d.ts.map +1 -1
  22. package/dist/components/Resizer.d.ts +1 -2
  23. package/dist/components/Resizer.d.ts.map +1 -1
  24. package/dist/components/ScrollHandle.d.ts +9 -0
  25. package/dist/components/ScrollHandle.d.ts.map +1 -0
  26. package/dist/components/SearchBar.d.ts +1 -2
  27. package/dist/components/SearchBar.d.ts.map +1 -1
  28. package/dist/components/StoreObserver.d.ts +8 -0
  29. package/dist/components/StoreObserver.d.ts.map +1 -0
  30. package/dist/components/Tabular.d.ts +2 -3
  31. package/dist/components/Tabular.d.ts.map +1 -1
  32. package/dist/components/hooks.d.ts +2 -0
  33. package/dist/components/hooks.d.ts.map +1 -1
  34. package/dist/components/svg/AddIcon.d.ts +1 -2
  35. package/dist/components/svg/AddIcon.d.ts.map +1 -1
  36. package/dist/components/svg/Base.d.ts +4 -4
  37. package/dist/components/svg/Base.d.ts.map +1 -1
  38. package/dist/components/svg/CloseIcon.d.ts +1 -2
  39. package/dist/components/svg/CloseIcon.d.ts.map +1 -1
  40. package/dist/components/svg/SearchIcon.d.ts +1 -2
  41. package/dist/components/svg/SearchIcon.d.ts.map +1 -1
  42. package/dist/constants.d.ts +3 -2
  43. package/dist/constants.d.ts.map +1 -1
  44. package/dist/formula/evaluator.d.ts +31 -13
  45. package/dist/formula/evaluator.d.ts.map +1 -1
  46. package/dist/formula/functions/__base.d.ts +4 -1
  47. package/dist/formula/functions/__base.d.ts.map +1 -1
  48. package/dist/formula/functions/__utils.d.ts.map +1 -1
  49. package/dist/formula/functions/abs.d.ts.map +1 -1
  50. package/dist/formula/functions/acos.d.ts.map +1 -1
  51. package/dist/formula/functions/add.d.ts.map +1 -1
  52. package/dist/formula/functions/and.d.ts.map +1 -1
  53. package/dist/formula/functions/asin.d.ts.map +1 -1
  54. package/dist/formula/functions/atan.d.ts.map +1 -1
  55. package/dist/formula/functions/atan2.d.ts.map +1 -1
  56. package/dist/formula/functions/average.d.ts.map +1 -1
  57. package/dist/formula/functions/col.d.ts +1 -2
  58. package/dist/formula/functions/col.d.ts.map +1 -1
  59. package/dist/formula/functions/concat.d.ts.map +1 -1
  60. package/dist/formula/functions/concatenate.d.ts.map +1 -1
  61. package/dist/formula/functions/cos.d.ts.map +1 -1
  62. package/dist/formula/functions/count.d.ts.map +1 -1
  63. package/dist/formula/functions/counta.d.ts.map +1 -1
  64. package/dist/formula/functions/countif.d.ts.map +1 -1
  65. package/dist/formula/functions/divide.d.ts.map +1 -1
  66. package/dist/formula/functions/eq.d.ts.map +1 -1
  67. package/dist/formula/functions/exp.d.ts.map +1 -1
  68. package/dist/formula/functions/gt.d.ts.map +1 -1
  69. package/dist/formula/functions/gte.d.ts.map +1 -1
  70. package/dist/formula/functions/hlookup.d.ts.map +1 -1
  71. package/dist/formula/functions/if.d.ts.map +1 -1
  72. package/dist/formula/functions/iferror.d.ts.map +1 -1
  73. package/dist/formula/functions/len.d.ts.map +1 -1
  74. package/dist/formula/functions/lenb.d.ts.map +1 -1
  75. package/dist/formula/functions/ln.d.ts.map +1 -1
  76. package/dist/formula/functions/log.d.ts.map +1 -1
  77. package/dist/formula/functions/log10.d.ts.map +1 -1
  78. package/dist/formula/functions/lt.d.ts.map +1 -1
  79. package/dist/formula/functions/lte.d.ts.map +1 -1
  80. package/dist/formula/functions/max.d.ts.map +1 -1
  81. package/dist/formula/functions/min.d.ts.map +1 -1
  82. package/dist/formula/functions/minus.d.ts.map +1 -1
  83. package/dist/formula/functions/mod.d.ts.map +1 -1
  84. package/dist/formula/functions/multiply.d.ts.map +1 -1
  85. package/dist/formula/functions/ne.d.ts.map +1 -1
  86. package/dist/formula/functions/not.d.ts.map +1 -1
  87. package/dist/formula/functions/now.d.ts.map +1 -1
  88. package/dist/formula/functions/or.d.ts.map +1 -1
  89. package/dist/formula/functions/pi.d.ts.map +1 -1
  90. package/dist/formula/functions/power.d.ts.map +1 -1
  91. package/dist/formula/functions/product.d.ts.map +1 -1
  92. package/dist/formula/functions/radians.d.ts.map +1 -1
  93. package/dist/formula/functions/rand.d.ts.map +1 -1
  94. package/dist/formula/functions/round.d.ts.map +1 -1
  95. package/dist/formula/functions/rounddown.d.ts.map +1 -1
  96. package/dist/formula/functions/roundup.d.ts.map +1 -1
  97. package/dist/formula/functions/row.d.ts +1 -2
  98. package/dist/formula/functions/row.d.ts.map +1 -1
  99. package/dist/formula/functions/sin.d.ts.map +1 -1
  100. package/dist/formula/functions/sqrt.d.ts.map +1 -1
  101. package/dist/formula/functions/sum.d.ts.map +1 -1
  102. package/dist/formula/functions/sumif.d.ts.map +1 -1
  103. package/dist/formula/functions/tan.d.ts.map +1 -1
  104. package/dist/formula/functions/uminus.d.ts.map +1 -1
  105. package/dist/formula/functions/vlookup.d.ts.map +1 -1
  106. package/dist/formula/mapping.d.ts.map +1 -1
  107. package/dist/formula/solver.d.ts +3 -2
  108. package/dist/formula/solver.d.ts.map +1 -1
  109. package/dist/index.d.ts +9 -5
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +9914 -20
  112. package/dist/index.js.map +1 -1
  113. package/dist/lib/autofill.d.ts +2 -2
  114. package/dist/lib/autofill.d.ts.map +1 -1
  115. package/dist/lib/clipboard.d.ts.map +1 -1
  116. package/dist/lib/converters.d.ts +3 -4
  117. package/dist/lib/converters.d.ts.map +1 -1
  118. package/dist/lib/events.d.ts +6 -0
  119. package/dist/lib/events.d.ts.map +1 -0
  120. package/dist/lib/hub.d.ts +39 -0
  121. package/dist/lib/hub.d.ts.map +1 -0
  122. package/dist/lib/input.d.ts +12 -2
  123. package/dist/lib/input.d.ts.map +1 -1
  124. package/dist/lib/operation.d.ts +27 -0
  125. package/dist/lib/operation.d.ts.map +1 -0
  126. package/dist/lib/palette.d.ts +1 -1
  127. package/dist/lib/palette.d.ts.map +1 -1
  128. package/dist/lib/paste.d.ts +4 -0
  129. package/dist/lib/paste.d.ts.map +1 -0
  130. package/dist/lib/sheet.d.ts +3 -0
  131. package/dist/lib/sheet.d.ts.map +1 -0
  132. package/dist/lib/structs.d.ts +7 -3
  133. package/dist/lib/structs.d.ts.map +1 -1
  134. package/dist/lib/table.d.ts +138 -76
  135. package/dist/lib/table.d.ts.map +1 -1
  136. package/dist/lib/time.d.ts +8 -1
  137. package/dist/lib/time.d.ts.map +1 -1
  138. package/dist/lib/virtualization.d.ts +3 -2
  139. package/dist/lib/virtualization.d.ts.map +1 -1
  140. package/dist/parsers/core.d.ts.map +1 -1
  141. package/dist/policy/core.d.ts +47 -0
  142. package/dist/policy/core.d.ts.map +1 -0
  143. package/dist/renderers/checkbox.d.ts +2 -2
  144. package/dist/renderers/checkbox.d.ts.map +1 -1
  145. package/dist/renderers/core.d.ts +39 -25
  146. package/dist/renderers/core.d.ts.map +1 -1
  147. package/dist/renderers/thousand_separator.d.ts.map +1 -1
  148. package/dist/store/actions.d.ts +25 -49
  149. package/dist/store/actions.d.ts.map +1 -1
  150. package/dist/store/dispatchers.d.ts +13 -0
  151. package/dist/store/dispatchers.d.ts.map +1 -0
  152. package/dist/store/helpers.d.ts +1 -0
  153. package/dist/store/helpers.d.ts.map +1 -1
  154. package/dist/store/index.d.ts +1 -2
  155. package/dist/store/index.d.ts.map +1 -1
  156. package/dist/styles/embedder.d.ts.map +1 -1
  157. package/dist/styles/minified.d.ts +2 -2
  158. package/dist/styles/minified.d.ts.map +1 -1
  159. package/dist/types.d.ts +112 -51
  160. package/dist/types.d.ts.map +1 -1
  161. package/dist/utils.d.ts.map +1 -1
  162. package/package.json +7 -10
  163. package/dist/_virtual/_commonjsHelpers.js +0 -7
  164. package/dist/_virtual/_commonjsHelpers.js.map +0 -1
  165. package/dist/_virtual/dayjs.min.js +0 -8
  166. package/dist/_virtual/dayjs.min.js.map +0 -1
  167. package/dist/_virtual/dayjs.min2.js +0 -5
  168. package/dist/_virtual/dayjs.min2.js.map +0 -1
  169. package/dist/_virtual/timezone.js +0 -8
  170. package/dist/_virtual/timezone.js.map +0 -1
  171. package/dist/_virtual/timezone2.js +0 -5
  172. package/dist/_virtual/timezone2.js.map +0 -1
  173. package/dist/_virtual/utc.js +0 -8
  174. package/dist/_virtual/utc.js.map +0 -1
  175. package/dist/_virtual/utc2.js +0 -5
  176. package/dist/_virtual/utc2.js.map +0 -1
  177. package/dist/components/Cell.js +0 -232
  178. package/dist/components/Cell.js.map +0 -1
  179. package/dist/components/ContextMenu.js +0 -297
  180. package/dist/components/ContextMenu.js.map +0 -1
  181. package/dist/components/Editor.js +0 -455
  182. package/dist/components/Editor.js.map +0 -1
  183. package/dist/components/Emitter.js +0 -26
  184. package/dist/components/Emitter.js.map +0 -1
  185. package/dist/components/Fixed.js +0 -17
  186. package/dist/components/Fixed.js.map +0 -1
  187. package/dist/components/FormulaBar.js +0 -149
  188. package/dist/components/FormulaBar.js.map +0 -1
  189. package/dist/components/GridSheet.js +0 -246
  190. package/dist/components/GridSheet.js.map +0 -1
  191. package/dist/components/HeaderCellLeft.js +0 -131
  192. package/dist/components/HeaderCellLeft.js.map +0 -1
  193. package/dist/components/HeaderCellTop.js +0 -132
  194. package/dist/components/HeaderCellTop.js.map +0 -1
  195. package/dist/components/PluginBase.js +0 -35
  196. package/dist/components/PluginBase.js.map +0 -1
  197. package/dist/components/Resizer.js +0 -98
  198. package/dist/components/Resizer.js.map +0 -1
  199. package/dist/components/SearchBar.js +0 -108
  200. package/dist/components/SearchBar.js.map +0 -1
  201. package/dist/components/SheetProvider.d.ts +0 -28
  202. package/dist/components/SheetProvider.d.ts.map +0 -1
  203. package/dist/components/SheetProvider.js +0 -56
  204. package/dist/components/SheetProvider.js.map +0 -1
  205. package/dist/components/StoreInitializer.d.ts +0 -4
  206. package/dist/components/StoreInitializer.d.ts.map +0 -1
  207. package/dist/components/StoreInitializer.js +0 -84
  208. package/dist/components/StoreInitializer.js.map +0 -1
  209. package/dist/components/Tabular.js +0 -308
  210. package/dist/components/Tabular.js.map +0 -1
  211. package/dist/components/Toggle.d.ts +0 -12
  212. package/dist/components/Toggle.d.ts.map +0 -1
  213. package/dist/components/hooks.js +0 -15
  214. package/dist/components/hooks.js.map +0 -1
  215. package/dist/components/svg/Base.js +0 -24
  216. package/dist/components/svg/Base.js.map +0 -1
  217. package/dist/components/svg/CloseIcon.js +0 -13
  218. package/dist/components/svg/CloseIcon.js.map +0 -1
  219. package/dist/components/svg/SearchIcon.js +0 -13
  220. package/dist/components/svg/SearchIcon.js.map +0 -1
  221. package/dist/constants.js +0 -43
  222. package/dist/constants.js.map +0 -1
  223. package/dist/formula/evaluator.js +0 -674
  224. package/dist/formula/evaluator.js.map +0 -1
  225. package/dist/formula/functions/__base.js +0 -19
  226. package/dist/formula/functions/__base.js.map +0 -1
  227. package/dist/formula/functions/__utils.js +0 -145
  228. package/dist/formula/functions/__utils.js.map +0 -1
  229. package/dist/formula/functions/abs.js +0 -24
  230. package/dist/formula/functions/abs.js.map +0 -1
  231. package/dist/formula/functions/abs.spec.d.ts +0 -2
  232. package/dist/formula/functions/abs.spec.d.ts.map +0 -1
  233. package/dist/formula/functions/acos.js +0 -32
  234. package/dist/formula/functions/acos.js.map +0 -1
  235. package/dist/formula/functions/add.js +0 -57
  236. package/dist/formula/functions/add.js.map +0 -1
  237. package/dist/formula/functions/and.js +0 -28
  238. package/dist/formula/functions/and.js.map +0 -1
  239. package/dist/formula/functions/asin.js +0 -32
  240. package/dist/formula/functions/asin.js.map +0 -1
  241. package/dist/formula/functions/atan.js +0 -29
  242. package/dist/formula/functions/atan.js.map +0 -1
  243. package/dist/formula/functions/atan2.js +0 -35
  244. package/dist/formula/functions/atan2.js.map +0 -1
  245. package/dist/formula/functions/average.js +0 -44
  246. package/dist/formula/functions/average.js.map +0 -1
  247. package/dist/formula/functions/col.js +0 -31
  248. package/dist/formula/functions/col.js.map +0 -1
  249. package/dist/formula/functions/concat.js +0 -27
  250. package/dist/formula/functions/concat.js.map +0 -1
  251. package/dist/formula/functions/concatenate.js +0 -28
  252. package/dist/formula/functions/concatenate.js.map +0 -1
  253. package/dist/formula/functions/cos.js +0 -29
  254. package/dist/formula/functions/cos.js.map +0 -1
  255. package/dist/formula/functions/count.js +0 -38
  256. package/dist/formula/functions/count.js.map +0 -1
  257. package/dist/formula/functions/counta.js +0 -38
  258. package/dist/formula/functions/counta.js.map +0 -1
  259. package/dist/formula/functions/countif.js +0 -32
  260. package/dist/formula/functions/countif.js.map +0 -1
  261. package/dist/formula/functions/countif.spec.d.ts +0 -2
  262. package/dist/formula/functions/countif.spec.d.ts.map +0 -1
  263. package/dist/formula/functions/divide.js +0 -33
  264. package/dist/formula/functions/divide.js.map +0 -1
  265. package/dist/formula/functions/eq.js +0 -29
  266. package/dist/formula/functions/eq.js.map +0 -1
  267. package/dist/formula/functions/eq.spec.d.ts +0 -2
  268. package/dist/formula/functions/eq.spec.d.ts.map +0 -1
  269. package/dist/formula/functions/exp.js +0 -29
  270. package/dist/formula/functions/exp.js.map +0 -1
  271. package/dist/formula/functions/gt.js +0 -29
  272. package/dist/formula/functions/gt.js.map +0 -1
  273. package/dist/formula/functions/gte.js +0 -29
  274. package/dist/formula/functions/gte.js.map +0 -1
  275. package/dist/formula/functions/hlookup.js +0 -75
  276. package/dist/formula/functions/hlookup.js.map +0 -1
  277. package/dist/formula/functions/if.js +0 -39
  278. package/dist/formula/functions/if.js.map +0 -1
  279. package/dist/formula/functions/iferror.js +0 -45
  280. package/dist/formula/functions/iferror.js.map +0 -1
  281. package/dist/formula/functions/iferror.spec.d.ts +0 -2
  282. package/dist/formula/functions/iferror.spec.d.ts.map +0 -1
  283. package/dist/formula/functions/len.js +0 -29
  284. package/dist/formula/functions/len.js.map +0 -1
  285. package/dist/formula/functions/lenb.js +0 -29
  286. package/dist/formula/functions/lenb.js.map +0 -1
  287. package/dist/formula/functions/ln.js +0 -32
  288. package/dist/formula/functions/ln.js.map +0 -1
  289. package/dist/formula/functions/log.js +0 -36
  290. package/dist/formula/functions/log.js.map +0 -1
  291. package/dist/formula/functions/log10.js +0 -32
  292. package/dist/formula/functions/log10.js.map +0 -1
  293. package/dist/formula/functions/lt.js +0 -29
  294. package/dist/formula/functions/lt.js.map +0 -1
  295. package/dist/formula/functions/lte.js +0 -29
  296. package/dist/formula/functions/lte.js.map +0 -1
  297. package/dist/formula/functions/max.js +0 -47
  298. package/dist/formula/functions/max.js.map +0 -1
  299. package/dist/formula/functions/min.js +0 -47
  300. package/dist/formula/functions/min.js.map +0 -1
  301. package/dist/formula/functions/minus.js +0 -57
  302. package/dist/formula/functions/minus.js.map +0 -1
  303. package/dist/formula/functions/mod.js +0 -33
  304. package/dist/formula/functions/mod.js.map +0 -1
  305. package/dist/formula/functions/mod.spec.d.ts +0 -2
  306. package/dist/formula/functions/mod.spec.d.ts.map +0 -1
  307. package/dist/formula/functions/multiply.js +0 -27
  308. package/dist/formula/functions/multiply.js.map +0 -1
  309. package/dist/formula/functions/ne.js +0 -29
  310. package/dist/formula/functions/ne.js.map +0 -1
  311. package/dist/formula/functions/not.js +0 -30
  312. package/dist/formula/functions/not.js.map +0 -1
  313. package/dist/formula/functions/now.js +0 -22
  314. package/dist/formula/functions/now.js.map +0 -1
  315. package/dist/formula/functions/or.js +0 -28
  316. package/dist/formula/functions/or.js.map +0 -1
  317. package/dist/formula/functions/pi.js +0 -22
  318. package/dist/formula/functions/pi.js.map +0 -1
  319. package/dist/formula/functions/power.js +0 -27
  320. package/dist/formula/functions/power.js.map +0 -1
  321. package/dist/formula/functions/product.js +0 -40
  322. package/dist/formula/functions/product.js.map +0 -1
  323. package/dist/formula/functions/radians.js +0 -29
  324. package/dist/formula/functions/radians.js.map +0 -1
  325. package/dist/formula/functions/rand.js +0 -22
  326. package/dist/formula/functions/rand.js.map +0 -1
  327. package/dist/formula/functions/round.js +0 -35
  328. package/dist/formula/functions/round.js.map +0 -1
  329. package/dist/formula/functions/rounddown.js +0 -35
  330. package/dist/formula/functions/rounddown.js.map +0 -1
  331. package/dist/formula/functions/roundup.js +0 -35
  332. package/dist/formula/functions/roundup.js.map +0 -1
  333. package/dist/formula/functions/row.js +0 -31
  334. package/dist/formula/functions/row.js.map +0 -1
  335. package/dist/formula/functions/sin.js +0 -29
  336. package/dist/formula/functions/sin.js.map +0 -1
  337. package/dist/formula/functions/sqrt.js +0 -32
  338. package/dist/formula/functions/sqrt.js.map +0 -1
  339. package/dist/formula/functions/sum.js +0 -47
  340. package/dist/formula/functions/sum.js.map +0 -1
  341. package/dist/formula/functions/sum.spec.d.ts +0 -2
  342. package/dist/formula/functions/sum.spec.d.ts.map +0 -1
  343. package/dist/formula/functions/sumif.js +0 -65
  344. package/dist/formula/functions/sumif.js.map +0 -1
  345. package/dist/formula/functions/tan.js +0 -29
  346. package/dist/formula/functions/tan.js.map +0 -1
  347. package/dist/formula/functions/uminus.js +0 -24
  348. package/dist/formula/functions/uminus.js.map +0 -1
  349. package/dist/formula/functions/vlookup.js +0 -75
  350. package/dist/formula/functions/vlookup.js.map +0 -1
  351. package/dist/formula/mapping.js +0 -118
  352. package/dist/formula/mapping.js.map +0 -1
  353. package/dist/formula/solver.js +0 -70
  354. package/dist/formula/solver.js.map +0 -1
  355. package/dist/lib/autofill.js +0 -391
  356. package/dist/lib/autofill.js.map +0 -1
  357. package/dist/lib/clipboard.js +0 -46
  358. package/dist/lib/clipboard.js.map +0 -1
  359. package/dist/lib/converters.js +0 -141
  360. package/dist/lib/converters.js.map +0 -1
  361. package/dist/lib/input.js +0 -52
  362. package/dist/lib/input.js.map +0 -1
  363. package/dist/lib/palette.js +0 -24
  364. package/dist/lib/palette.js.map +0 -1
  365. package/dist/lib/prevention.d.ts +0 -24
  366. package/dist/lib/prevention.d.ts.map +0 -1
  367. package/dist/lib/prevention.js +0 -82
  368. package/dist/lib/prevention.js.map +0 -1
  369. package/dist/lib/structs.js +0 -276
  370. package/dist/lib/structs.js.map +0 -1
  371. package/dist/lib/table.js +0 -1248
  372. package/dist/lib/table.js.map +0 -1
  373. package/dist/lib/time.js +0 -79
  374. package/dist/lib/time.js.map +0 -1
  375. package/dist/lib/virtualization.js +0 -129
  376. package/dist/lib/virtualization.js.map +0 -1
  377. package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/dayjs.min.js +0 -287
  378. package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/dayjs.min.js.map +0 -1
  379. package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/timezone.js +0 -72
  380. package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/timezone.js.map +0 -1
  381. package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/utc.js +0 -85
  382. package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/utc.js.map +0 -1
  383. package/dist/parsers/core.js +0 -139
  384. package/dist/parsers/core.js.map +0 -1
  385. package/dist/renderers/checkbox.js +0 -20
  386. package/dist/renderers/checkbox.js.map +0 -1
  387. package/dist/renderers/core.js +0 -147
  388. package/dist/renderers/core.js.map +0 -1
  389. package/dist/renderers/thousand_separator.js +0 -17
  390. package/dist/renderers/thousand_separator.js.map +0 -1
  391. package/dist/store/actions.js +0 -762
  392. package/dist/store/actions.js.map +0 -1
  393. package/dist/store/helpers.js +0 -88
  394. package/dist/store/helpers.js.map +0 -1
  395. package/dist/store/index.js +0 -8
  396. package/dist/store/index.js.map +0 -1
  397. package/dist/styles/embedder.js +0 -19
  398. package/dist/styles/embedder.js.map +0 -1
  399. package/dist/styles/minified.js +0 -7
  400. package/dist/styles/minified.js.map +0 -1
package/dist/lib/table.js DELETED
@@ -1,1248 +0,0 @@
1
- import { defaultParser } from "../parsers/core.js";
2
- import { defaultRenderer } from "../renderers/core.js";
3
- import { getMaxSizesFromCells, expandRange, createMatrix, putMatrix, areaShape, matrixShape } from "./structs.js";
4
- import { p2a, x2c, grantAddressAbsolute, a2p, y2r } from "./converters.js";
5
- import { functions } from "../formula/mapping.js";
6
- import { absolutizeFormula, Lexer, stripSheetName } from "../formula/evaluator.js";
7
- import { solveFormula } from "../formula/solver.js";
8
- import { HISTORY_LIMIT, HEADER_HEIGHT, HEADER_WIDTH, DEFAULT_WIDTH, DEFAULT_HEIGHT } from "../constants.js";
9
- import { shouldTracking } from "../store/helpers.js";
10
- import { isPrevented, MoveFrom, MoveTo, Update, Write, Style, Resize, SetRenderer, SetParser, DeleteRow, DeleteCol } from "./prevention.js";
11
- const noFilter = () => true;
12
- class Table {
13
- constructor({
14
- parsers = {},
15
- renderers = {},
16
- labelers = {},
17
- useBigInt = false,
18
- historyLimit,
19
- minNumRows = 1,
20
- maxNumRows = -1,
21
- minNumCols = 1,
22
- maxNumCols = -1,
23
- headerWidth = HEADER_WIDTH,
24
- headerHeight = HEADER_HEIGHT,
25
- functions: functions$1 = functions
26
- }) {
27
- this.totalWidth = 0;
28
- this.totalHeight = 0;
29
- this.headerWidth = 0;
30
- this.headerHeight = 0;
31
- this.sheetId = 0;
32
- this.sheetName = "";
33
- this.sheets = {};
34
- this.tables = {};
35
- this.data = {};
36
- this.area = { top: 0, left: 0, bottom: 0, right: 0 };
37
- this.functions = {};
38
- this.head = useBigInt ? BigInt(0) : 0;
39
- this.parsers = parsers || {};
40
- this.renderers = renderers || {};
41
- this.labelers = labelers || {};
42
- this.idMatrix = [];
43
- this.histories = [];
44
- this.historyIndex = -1;
45
- this.addressesById = {};
46
- this.historyLimit = historyLimit || HISTORY_LIMIT;
47
- this.changedAt = /* @__PURE__ */ new Date();
48
- this.minNumRows = minNumRows || 0;
49
- this.maxNumRows = maxNumRows || 0;
50
- this.minNumCols = minNumCols || 0;
51
- this.maxNumCols = maxNumCols || 0;
52
- this.solvedCaches = {};
53
- this.headerHeight = headerHeight;
54
- this.headerWidth = headerWidth;
55
- this.functions = functions$1;
56
- this.idsToBeAbsoluted = [];
57
- }
58
- getTableBySheetName(sheetName) {
59
- const sheetId = this.sheets[sheetName];
60
- return this.tables[sheetId];
61
- }
62
- initialize(cells) {
63
- var _a, _b;
64
- const auto = getMaxSizesFromCells(cells);
65
- this.area = {
66
- top: 0,
67
- left: 0,
68
- bottom: auto.numRows || 0,
69
- right: auto.numCols || 0
70
- };
71
- for (let y = 0; y < auto.numRows + 1; y++) {
72
- const ids = [];
73
- this.idMatrix.push(ids);
74
- for (let x = 0; x < auto.numCols + 1; x++) {
75
- const id = this.generateId();
76
- ids.push(id);
77
- const address = p2a({ y, x });
78
- this.addressesById[id] = address;
79
- }
80
- }
81
- Object.keys(cells).forEach((address) => {
82
- const range = expandRange(address);
83
- const data = cells[address];
84
- range.forEach((address2) => {
85
- const origin = cells[address2];
86
- cells[address2] = {
87
- ...origin,
88
- ...data,
89
- style: {
90
- ...origin == null ? void 0 : origin.style,
91
- ...data == null ? void 0 : data.style
92
- },
93
- prevention: ((origin == null ? void 0 : origin.prevention) || 0) | ((data == null ? void 0 : data.prevention) || 0)
94
- };
95
- });
96
- });
97
- const common = cells == null ? void 0 : cells["default"];
98
- for (let y = 0; y < auto.numRows + 1; y++) {
99
- const rowId = y2r(y);
100
- const rowDefault = cells == null ? void 0 : cells[rowId];
101
- for (let x = 0; x < auto.numCols + 1; x++) {
102
- const id = this.getId({ y, x });
103
- const address = p2a({ y, x });
104
- const colId = x2c(x);
105
- const colDefault = cells == null ? void 0 : cells[colId];
106
- const cell = cells == null ? void 0 : cells[address];
107
- const stacked = {
108
- ...common,
109
- ...rowDefault,
110
- ...colDefault,
111
- ...cell,
112
- style: {
113
- ...common == null ? void 0 : common.style,
114
- ...rowDefault == null ? void 0 : rowDefault.style,
115
- ...colDefault == null ? void 0 : colDefault.style,
116
- ...cell == null ? void 0 : cell.style
117
- },
118
- prevention: ((common == null ? void 0 : common.prevention) || 0) | ((rowDefault == null ? void 0 : rowDefault.prevention) || 0) | ((colDefault == null ? void 0 : colDefault.prevention) || 0) | ((cell == null ? void 0 : cell.prevention) || 0)
119
- };
120
- if ((_b = (_a = stacked == null ? void 0 : stacked.value) == null ? void 0 : _a.startsWith) == null ? void 0 : _b.call(_a, "=")) {
121
- this.idsToBeAbsoluted.push(id);
122
- }
123
- if (y === 0) {
124
- if (stacked.width == null) {
125
- stacked.width = DEFAULT_WIDTH;
126
- }
127
- } else if (x === 0) {
128
- if (stacked.height == null) {
129
- stacked.height = DEFAULT_HEIGHT;
130
- }
131
- } else {
132
- delete stacked.height;
133
- delete stacked.width;
134
- delete stacked.labeler;
135
- }
136
- this.data[id] = stacked;
137
- }
138
- }
139
- this.setTotalSize();
140
- }
141
- absolutizeFormula() {
142
- this.idsToBeAbsoluted.forEach((id) => {
143
- const cell = this.data[id];
144
- if (cell == null) {
145
- return;
146
- }
147
- cell.value = absolutizeFormula({
148
- value: cell == null ? void 0 : cell.value,
149
- table: this
150
- });
151
- });
152
- }
153
- generateId() {
154
- return (this.head++).toString(36);
155
- }
156
- getRectSize({ top, left, bottom, right }) {
157
- var _a, _b;
158
- let width = 0, height = 0;
159
- for (let x = left || 1; x < right; x++) {
160
- width += ((_a = this.getByPoint({ y: 0, x })) == null ? void 0 : _a.width) || DEFAULT_WIDTH;
161
- }
162
- for (let y = top || 1; y < bottom; y++) {
163
- height += ((_b = this.getByPoint({ y, x: 0 })) == null ? void 0 : _b.height) || DEFAULT_HEIGHT;
164
- }
165
- return { width, height };
166
- }
167
- setTotalSize() {
168
- const { bottom, right } = this.area;
169
- const { width, height } = this.getRectSize({
170
- top: 1,
171
- left: 1,
172
- bottom: bottom + 1,
173
- right: right + 1
174
- });
175
- this.totalWidth = width + this.headerWidth;
176
- this.totalHeight = height + this.headerHeight;
177
- }
178
- shallowCopy({ copyCache = true } = {}) {
179
- const copied = Object.assign(Object.create(Object.getPrototypeOf(this)), this);
180
- copied.changedAt = /* @__PURE__ */ new Date();
181
- copied.lastChangedAt = this.changedAt;
182
- copied.setTotalSize();
183
- copied.idsToBeAbsoluted = [];
184
- copied.solvedCaches = {};
185
- if (!copyCache) {
186
- this.addressesById = {};
187
- }
188
- return copied;
189
- }
190
- getAddressById(id, slideY = 0, slideX = 0) {
191
- const absCol = id.startsWith("$");
192
- if (absCol) {
193
- id = id.slice(1);
194
- slideX = 0;
195
- }
196
- const absRow = id.endsWith("$");
197
- if (absRow) {
198
- id = id.slice(0, -1);
199
- slideY = 0;
200
- }
201
- for (let y = 0; y < this.idMatrix.length; y++) {
202
- const ids = this.idMatrix[y];
203
- for (let x = 0; x < ids.length; x++) {
204
- const existing = ids[x];
205
- const address = p2a({ y, x });
206
- this.addressesById[existing] = address;
207
- if (existing === id) {
208
- const slidedAddress = p2a({
209
- y: y + slideY,
210
- x: x + slideX
211
- });
212
- return grantAddressAbsolute(slidedAddress, absCol, absRow);
213
- }
214
- }
215
- }
216
- }
217
- getAddressesByIds(ids) {
218
- const addresses = {};
219
- Object.keys(ids).forEach((id) => {
220
- const cell = ids[id];
221
- const address = this.getAddressById(id);
222
- if (cell && address) {
223
- addresses[address] = cell;
224
- }
225
- });
226
- return addresses;
227
- }
228
- getPointById(id) {
229
- const address = this.getAddressById(id);
230
- if (address) {
231
- return a2p(address);
232
- }
233
- return { y: 0, x: 0 };
234
- }
235
- getId(point) {
236
- var _a;
237
- const { y, x } = point;
238
- return (_a = this.idMatrix[Math.abs(y)]) == null ? void 0 : _a[Math.abs(x)];
239
- }
240
- getByPoint(point) {
241
- var _a;
242
- const { y, x } = point;
243
- if (y === -1 || x === -1) {
244
- return void 0;
245
- }
246
- const id = (_a = this.idMatrix[y]) == null ? void 0 : _a[x];
247
- if (id == null) {
248
- return void 0;
249
- }
250
- const value = this.data[id];
251
- return value;
252
- }
253
- getById(id) {
254
- return this.data[id];
255
- }
256
- getNumRows(base = 0) {
257
- const { top, bottom } = this.area;
258
- return base + bottom - top;
259
- }
260
- getNumCols(base = 0) {
261
- const { left, right } = this.area;
262
- return base + right - left;
263
- }
264
- get top() {
265
- return this.area.top;
266
- }
267
- get left() {
268
- return this.area.left;
269
- }
270
- get bottom() {
271
- return this.area.bottom;
272
- }
273
- get right() {
274
- return this.area.right;
275
- }
276
- getMatrixFlatten({
277
- area,
278
- key = "value",
279
- evaluates = true,
280
- raise = false,
281
- filter = noFilter
282
- } = {}) {
283
- const { top, left, bottom, right } = area || {
284
- top: 1,
285
- left: 1,
286
- bottom: this.area.bottom,
287
- right: this.area.right
288
- };
289
- const matrix = createMatrix(bottom - top + 1, right - left + 1);
290
- for (let y = top; y <= bottom; y++) {
291
- for (let x = left; x <= right; x++) {
292
- const cell = this.getByPoint({ y, x }) || {};
293
- if (!filter(cell)) {
294
- continue;
295
- }
296
- matrix[y - top][x - left] = solveFormula({
297
- value: cell[key],
298
- table: this,
299
- raise,
300
- evaluates
301
- });
302
- }
303
- }
304
- return matrix;
305
- }
306
- getObjectFlatten({ key = "value", evaluates = true, raise = false, filter = noFilter } = {}) {
307
- const result = {};
308
- const { top, left, bottom, right } = this.area;
309
- for (let y = top; y <= bottom; y++) {
310
- for (let x = left; x <= right; x++) {
311
- const cell = this.getByPoint({ y: y - top, x: x - left });
312
- if (cell != null && filter(cell)) {
313
- result[p2a({ y, x })] = solveFormula({
314
- value: cell[key],
315
- table: this,
316
- raise,
317
- evaluates
318
- });
319
- }
320
- }
321
- }
322
- return result;
323
- }
324
- getRowsFlatten({ key = "value", evaluates = true, raise = false, filter = noFilter } = {}) {
325
- const result = [];
326
- const { top, left, bottom, right } = this.area;
327
- for (let y = top; y <= bottom; y++) {
328
- const row = {};
329
- result.push(row);
330
- for (let x = left; x <= right; x++) {
331
- const cell = this.getByPoint({ y: y - top, x: x - left });
332
- if (cell != null && filter(cell)) {
333
- row[x2c(x) || y2r(y)] = solveFormula({
334
- value: cell[key],
335
- table: this,
336
- raise,
337
- evaluates
338
- });
339
- }
340
- }
341
- }
342
- return result;
343
- }
344
- getColsFlatten({ key = "value", evaluates = true, raise = false, filter = noFilter } = {}) {
345
- const result = [];
346
- const { top, left, bottom, right } = this.area;
347
- for (let x = left; x <= right; x++) {
348
- const col = {};
349
- result.push(col);
350
- for (let y = top; y <= bottom; y++) {
351
- const cell = this.getByPoint({ y: y - top, x: x - left });
352
- if (cell != null && filter(cell)) {
353
- col[y2r(y) || x2c(x)] = solveFormula({
354
- value: cell[key],
355
- table: this,
356
- raise,
357
- evaluates
358
- });
359
- }
360
- }
361
- }
362
- return result;
363
- }
364
- getMatrix({
365
- area,
366
- evaluates = true,
367
- raise = false,
368
- filter = noFilter
369
- } = {}) {
370
- const { top, left, bottom, right } = area || {
371
- top: 1,
372
- left: 1,
373
- bottom: this.area.bottom,
374
- right: this.area.right
375
- };
376
- const matrix = createMatrix(bottom - top + 1, right - left + 1);
377
- for (let y = top; y <= bottom; y++) {
378
- for (let x = left; x <= right; x++) {
379
- const cell = this.getByPoint({ y, x });
380
- if (cell != null && filter(cell)) {
381
- matrix[y - top][x - left] = {
382
- ...cell,
383
- value: solveFormula({
384
- value: cell == null ? void 0 : cell.value,
385
- table: this,
386
- raise,
387
- evaluates
388
- })
389
- };
390
- }
391
- }
392
- }
393
- return matrix;
394
- }
395
- getObject({ evaluates = true, raise = false, filter = noFilter } = {}) {
396
- const result = {};
397
- const { top, left, bottom, right } = this.area;
398
- for (let y = top; y <= bottom; y++) {
399
- for (let x = left; x <= right; x++) {
400
- const cell = this.getByPoint({ y: y - top, x: x - left });
401
- if (cell != null && filter(cell)) {
402
- result[p2a({ y, x })] = {
403
- ...cell,
404
- value: solveFormula({
405
- value: cell == null ? void 0 : cell.value,
406
- table: this,
407
- raise,
408
- evaluates
409
- })
410
- };
411
- }
412
- }
413
- }
414
- return result;
415
- }
416
- getRows({ evaluates = true, raise = false, filter = noFilter } = {}) {
417
- const result = [];
418
- const { top, left, bottom, right } = this.area;
419
- for (let y = top; y <= bottom; y++) {
420
- const row = {};
421
- result.push(row);
422
- for (let x = left; x <= right; x++) {
423
- const cell = this.getByPoint({ y: y - top, x: x - left });
424
- if (cell != null && filter(cell)) {
425
- row[x2c(x) || y2r(y)] = {
426
- ...cell,
427
- value: solveFormula({
428
- value: cell == null ? void 0 : cell.value,
429
- table: this,
430
- raise,
431
- evaluates
432
- })
433
- };
434
- }
435
- }
436
- }
437
- return result;
438
- }
439
- getCols({ evaluates = true, raise = false, filter = noFilter } = {}) {
440
- const result = [];
441
- const { top, left, bottom, right } = this.area;
442
- for (let x = left; x <= right; x++) {
443
- const col = {};
444
- result.push(col);
445
- for (let y = top; y <= bottom; y++) {
446
- const cell = this.getByPoint({ y: y - top, x: x - left });
447
- if (cell != null && filter(cell)) {
448
- col[y2r(y) || x2c(x)] = {
449
- ...cell,
450
- value: solveFormula({
451
- value: cell == null ? void 0 : cell.value,
452
- table: this,
453
- raise,
454
- evaluates
455
- })
456
- };
457
- }
458
- }
459
- }
460
- return result;
461
- }
462
- pushHistory(history) {
463
- const strayedHistories = this.histories.splice(this.historyIndex + 1, this.histories.length);
464
- strayedHistories.forEach(this.cleanStrayed.bind(this));
465
- this.histories.push(history);
466
- this.lastHistory = this.currentHistory = history;
467
- if (this.histories.length > this.historyLimit) {
468
- const kickedOut = this.histories.splice(0, 1)[0];
469
- this.cleanObsolete(kickedOut);
470
- } else {
471
- this.historyIndex++;
472
- }
473
- }
474
- cleanObsolete(history) {
475
- if (history.operation === "DELETE_ROWS" || history.operation === "DELETE_COLS") {
476
- history.deleted.forEach((ids) => {
477
- ids.forEach((id) => {
478
- delete this.data[id];
479
- });
480
- });
481
- }
482
- if (history.operation === "MOVE") {
483
- Object.keys(history.lostRows).forEach((address) => {
484
- const idMatrix = history.lostRows[address];
485
- idMatrix.map(
486
- (ids) => ids.forEach((id) => {
487
- if (id != null) {
488
- delete this.data[id];
489
- }
490
- })
491
- );
492
- });
493
- }
494
- }
495
- cleanStrayed(history) {
496
- if (history.operation === "ADD_ROWS" || history.operation === "ADD_COLS") {
497
- history.idMatrix.forEach((ids) => {
498
- ids.forEach((id) => {
499
- delete this.data[id];
500
- });
501
- });
502
- }
503
- }
504
- getNewIdMatrix(area) {
505
- const matrix = [];
506
- const { top, left, bottom, right } = area;
507
- for (let y = top; y <= bottom; y++) {
508
- const ids = [];
509
- matrix.push(ids);
510
- for (let x = left; x <= right; x++) {
511
- ids.push(this.generateId());
512
- }
513
- }
514
- return matrix;
515
- }
516
- getIdMatrixFromArea(area) {
517
- var _a;
518
- const matrix = [];
519
- const { top, left, bottom, right } = area;
520
- for (let y = top; y <= bottom; y++) {
521
- const ids = [];
522
- matrix.push(ids);
523
- for (let x = left; x <= right; x++) {
524
- const id = (_a = this.idMatrix[y]) == null ? void 0 : _a[x];
525
- if (id == null) {
526
- continue;
527
- }
528
- ids.push(id);
529
- }
530
- }
531
- return matrix;
532
- }
533
- setChangedAt(cell, changedAt) {
534
- if (cell == null) {
535
- return null;
536
- }
537
- cell.changedAt = changedAt || /* @__PURE__ */ new Date();
538
- return cell;
539
- }
540
- copyCellLayout(cell) {
541
- if (cell == null) {
542
- return void 0;
543
- }
544
- const newCell = {};
545
- if (cell.style != null) {
546
- newCell.style = cell.style;
547
- }
548
- if (cell.justifyContent != null) {
549
- newCell.justifyContent = cell.justifyContent;
550
- }
551
- if (cell.alignItems != null) {
552
- newCell.alignItems = cell.alignItems;
553
- }
554
- if (cell.renderer != null) {
555
- newCell.renderer = cell.renderer;
556
- }
557
- if (cell.parser != null) {
558
- newCell.parser = cell.parser;
559
- }
560
- if (cell.width != null) {
561
- newCell.width = cell.width;
562
- }
563
- if (cell.height != null) {
564
- newCell.height = cell.height;
565
- }
566
- if (cell.labeler != null) {
567
- newCell.labeler = cell.labeler;
568
- }
569
- return newCell;
570
- }
571
- move({ src, dst, historicize = true, operator = "SYSTEM", reflection = {} }) {
572
- const matrixNew = this.getNewIdMatrix(src);
573
- const matrixFrom = this.getIdMatrixFromArea(src);
574
- const matrixTo = this.getIdMatrixFromArea(dst);
575
- putMatrix(this.idMatrix, matrixNew, src, (_, id) => {
576
- const cell = this.data[id];
577
- if (operator === "USER" && isPrevented(cell == null ? void 0 : cell.prevention, MoveFrom)) {
578
- return false;
579
- }
580
- return true;
581
- });
582
- const lostRows = putMatrix(this.idMatrix, matrixFrom, dst, (srcId, dstId) => {
583
- const srcCell = this.data[srcId];
584
- const dstCell = this.data[dstId];
585
- if (operator === "USER" && (isPrevented(srcCell == null ? void 0 : srcCell.prevention, MoveFrom) || isPrevented(dstCell == null ? void 0 : dstCell.prevention, MoveTo))) {
586
- return false;
587
- }
588
- if (srcCell != null) {
589
- this.setChangedAt(srcCell, /* @__PURE__ */ new Date());
590
- }
591
- return true;
592
- });
593
- if (historicize) {
594
- this.pushHistory({
595
- applyed: true,
596
- operation: "MOVE",
597
- reflection,
598
- src,
599
- dst,
600
- matrixFrom,
601
- matrixTo,
602
- matrixNew,
603
- lostRows
604
- });
605
- }
606
- return this.shallowCopy({ copyCache: false });
607
- }
608
- copy({ src, dst, operator = "SYSTEM", reflection = {} }) {
609
- const { height: maxHeight, width: maxWidth } = areaShape({
610
- ...src,
611
- base: 1
612
- });
613
- const { top: topFrom, left: leftFrom } = src;
614
- const { top: topTo, left: leftTo, bottom: bottomTo, right: rightTo } = dst;
615
- const diff = {};
616
- const changedAt = /* @__PURE__ */ new Date();
617
- for (let i = 0; i <= bottomTo - topTo; i++) {
618
- const toY = topTo + i;
619
- if (toY > this.getNumRows()) {
620
- continue;
621
- }
622
- for (let j = 0; j <= rightTo - leftTo; j++) {
623
- const toX = leftTo + j;
624
- if (toX > this.getNumCols()) {
625
- continue;
626
- }
627
- const fromY = topFrom + i % maxHeight;
628
- const fromX = leftFrom + j % maxWidth;
629
- const slideY = toY - fromY;
630
- const slideX = toX - fromX;
631
- const cell = {
632
- ...this.getByPoint({
633
- y: topFrom + i % maxHeight,
634
- x: leftFrom + j % maxWidth
635
- }),
636
- prevention: 0
637
- // Is this okay?
638
- };
639
- const value = absolutizeFormula({
640
- value: cell == null ? void 0 : cell.value,
641
- table: this,
642
- slideY,
643
- slideX
644
- });
645
- this.setChangedAt(cell, changedAt);
646
- diff[p2a({ y: toY, x: toX })] = {
647
- ...cell,
648
- style: { ...cell == null ? void 0 : cell.style },
649
- value
650
- };
651
- }
652
- }
653
- return this.update({
654
- diff,
655
- partial: false,
656
- operator,
657
- reflection
658
- });
659
- }
660
- _update({
661
- diff,
662
- partial = true,
663
- updateChangedAt = true,
664
- ignoreFields = ["labeler", "prevention"],
665
- operator = "SYSTEM"
666
- }) {
667
- const diffBefore = {};
668
- const diffAfter = {};
669
- const changedAt = /* @__PURE__ */ new Date();
670
- Object.keys(diff).forEach((address) => {
671
- const cell = { ...diff[address] };
672
- if (operator === "USER" && isPrevented(cell == null ? void 0 : cell.prevention, Update)) {
673
- return;
674
- }
675
- cell.value = absolutizeFormula({
676
- value: cell.value,
677
- table: this
678
- });
679
- const point = a2p(address);
680
- const id = this.getId(point);
681
- const current = this.data[id];
682
- ignoreFields.forEach((key) => {
683
- cell[key] = current == null ? void 0 : current[key];
684
- });
685
- if (operator === "USER" && isPrevented(current == null ? void 0 : current.prevention, Write)) {
686
- cell.value = current == null ? void 0 : current.value;
687
- }
688
- if (operator === "USER" && isPrevented(current == null ? void 0 : current.prevention, Style)) {
689
- cell.style = current == null ? void 0 : current.style;
690
- cell.justifyContent = current == null ? void 0 : current.justifyContent;
691
- cell.alignItems = current == null ? void 0 : current.alignItems;
692
- }
693
- if (operator === "USER" && isPrevented(current == null ? void 0 : current.prevention, Resize)) {
694
- cell.width = current == null ? void 0 : current.width;
695
- cell.height = current == null ? void 0 : current.height;
696
- }
697
- if (operator === "USER" && isPrevented(current == null ? void 0 : current.prevention, SetRenderer)) {
698
- cell.renderer = current == null ? void 0 : current.renderer;
699
- }
700
- if (operator === "USER" && isPrevented(current == null ? void 0 : current.prevention, SetParser)) {
701
- cell.parser = current == null ? void 0 : current.parser;
702
- }
703
- if (updateChangedAt) {
704
- this.setChangedAt(cell, changedAt);
705
- }
706
- diffBefore[id] = this.getByPoint(point);
707
- diffAfter[id] = cell;
708
- if (partial) {
709
- this.data[id] = { ...current, ...cell };
710
- } else {
711
- this.data[id] = cell;
712
- }
713
- });
714
- this.solvedCaches = {};
715
- return {
716
- diffBefore,
717
- diffAfter
718
- };
719
- }
720
- update({
721
- diff,
722
- partial = true,
723
- updateChangedAt = true,
724
- historicize = true,
725
- operator = "SYSTEM",
726
- reflection = {}
727
- }) {
728
- const { diffBefore, diffAfter } = this._update({
729
- diff,
730
- partial,
731
- operator,
732
- updateChangedAt
733
- });
734
- if (historicize) {
735
- this.pushHistory({
736
- applyed: true,
737
- operation: "UPDATE",
738
- reflection,
739
- diffBefore,
740
- diffAfter,
741
- partial
742
- });
743
- }
744
- return this.shallowCopy({ copyCache: true });
745
- }
746
- writeMatrix({
747
- point,
748
- matrix,
749
- updateChangedAt = true,
750
- historicize = true,
751
- operator = "SYSTEM",
752
- reflection = {}
753
- }) {
754
- const { y: baseY, x: baseX } = point;
755
- const diff = {};
756
- matrix.forEach((cols, i) => {
757
- const y = baseY + i;
758
- if (y > this.bottom) {
759
- return;
760
- }
761
- cols.forEach((value, j) => {
762
- const x = baseX + j;
763
- if (x > this.right) {
764
- return;
765
- }
766
- const cell = this.parse({ y, x }, value);
767
- diff[p2a({ y, x })] = cell;
768
- });
769
- });
770
- return this.update({
771
- diff,
772
- partial: true,
773
- updateChangedAt,
774
- historicize,
775
- operator,
776
- reflection
777
- });
778
- }
779
- write({
780
- point,
781
- value,
782
- updateChangedAt = true,
783
- historicize = true,
784
- operator = "SYSTEM",
785
- reflection = {}
786
- }) {
787
- return this.writeMatrix({
788
- point,
789
- matrix: [[value]],
790
- updateChangedAt,
791
- historicize,
792
- operator,
793
- reflection
794
- });
795
- }
796
- addRowsAndUpdate({
797
- y,
798
- numRows,
799
- baseY,
800
- diff,
801
- partial,
802
- updateChangedAt,
803
- operator = "SYSTEM",
804
- reflection = {}
805
- }) {
806
- const returned = this.addRows({
807
- y,
808
- numRows,
809
- baseY,
810
- reflection
811
- });
812
- Object.assign(this.lastHistory, this._update({ diff, partial, updateChangedAt, operator }), { partial });
813
- return returned;
814
- }
815
- addRows({
816
- y,
817
- numRows,
818
- baseY,
819
- // operator = 'SYSTEM',
820
- reflection = {}
821
- }) {
822
- if (this.maxNumRows !== -1 && this.getNumRows() + numRows > this.maxNumRows) {
823
- console.error(`Rows are limited to ${this.maxNumRows}.`);
824
- return this;
825
- }
826
- const numCols = this.getNumCols(1);
827
- const rows = [];
828
- const changedAt = /* @__PURE__ */ new Date();
829
- for (let i = 0; i < numRows; i++) {
830
- const row = [];
831
- for (let j = 0; j < numCols; j++) {
832
- const id = this.generateId();
833
- row.push(id);
834
- const cell = this.getByPoint({ y: baseY, x: j });
835
- const copied = this.copyCellLayout(cell);
836
- this.data[id] = { ...copied, changedAt };
837
- }
838
- rows.push(row);
839
- }
840
- this.idMatrix.splice(y, 0, ...rows);
841
- this.area.bottom += numRows;
842
- this.pushHistory({
843
- applyed: true,
844
- operation: "ADD_ROWS",
845
- reflection,
846
- y,
847
- numRows,
848
- idMatrix: rows
849
- });
850
- return this.shallowCopy({ copyCache: false });
851
- }
852
- deleteRows({
853
- y,
854
- numRows,
855
- operator = "SYSTEM",
856
- reflection = {}
857
- }) {
858
- if (this.minNumRows !== -1 && this.getNumRows() - numRows < this.minNumRows) {
859
- console.error(`At least ${this.minNumRows} row(s) are required.`);
860
- return this;
861
- }
862
- const ys = [];
863
- for (let i = y; i < y + numRows; i++) {
864
- const cell = this.getByPoint({ y: i, x: 0 });
865
- if (operator === "USER" && isPrevented(cell == null ? void 0 : cell.prevention, DeleteRow)) {
866
- console.warn(`Cannot delete row ${i}.`);
867
- return this;
868
- }
869
- ys.unshift(i);
870
- }
871
- const deleted = [];
872
- ys.forEach((y2) => {
873
- const row = this.idMatrix.splice(y2, 1);
874
- deleted.unshift(row[0]);
875
- });
876
- this.area.bottom -= ys.length;
877
- this.pushHistory({
878
- applyed: true,
879
- operation: "DELETE_ROWS",
880
- reflection,
881
- ys: ys.reverse(),
882
- deleted
883
- });
884
- return this.shallowCopy({ copyCache: false });
885
- }
886
- addColsAndUpdate({
887
- x,
888
- numCols,
889
- baseX,
890
- diff,
891
- partial,
892
- updateChangedAt,
893
- reflection = {}
894
- }) {
895
- const returned = this.addCols({
896
- x,
897
- numCols,
898
- baseX,
899
- reflection
900
- });
901
- Object.assign(this.lastHistory, this._update({ diff, partial, updateChangedAt }), { partial });
902
- return returned;
903
- }
904
- addCols({
905
- x,
906
- numCols,
907
- baseX,
908
- reflection = {}
909
- }) {
910
- if (this.maxNumCols !== -1 && this.getNumCols() + numCols > this.maxNumCols) {
911
- console.error(`Columns are limited to ${this.maxNumCols}.`);
912
- return this;
913
- }
914
- const numRows = this.getNumRows(1);
915
- const rows = [];
916
- const changedAt = /* @__PURE__ */ new Date();
917
- for (let i = 0; i < numRows; i++) {
918
- const row = [];
919
- for (let j = 0; j < numCols; j++) {
920
- const id = this.generateId();
921
- row.push(id);
922
- const cell = this.getByPoint({ y: i, x: baseX });
923
- const copied = this.copyCellLayout(cell);
924
- this.idMatrix[i].splice(x, 0, id);
925
- this.data[id] = { ...copied, changedAt };
926
- }
927
- rows.push(row);
928
- }
929
- this.area.right += numCols;
930
- this.pushHistory({
931
- applyed: true,
932
- operation: "ADD_COLS",
933
- reflection,
934
- x,
935
- numCols,
936
- idMatrix: rows
937
- });
938
- return this.shallowCopy({ copyCache: false });
939
- }
940
- deleteCols({
941
- x,
942
- numCols,
943
- operator = "SYSTEM",
944
- reflection = {}
945
- }) {
946
- if (this.minNumCols !== -1 && this.getNumCols() - numCols < this.minNumCols) {
947
- console.error(`At least ${this.minNumCols} column(s) are required.`);
948
- return this;
949
- }
950
- const xs = [];
951
- for (let i = x; i < x + numCols; i++) {
952
- const cell = this.getByPoint({ y: 0, x: i });
953
- if (operator === "USER" && isPrevented(cell == null ? void 0 : cell.prevention, DeleteCol)) {
954
- console.warn(`Cannot delete col ${i}.`);
955
- continue;
956
- }
957
- xs.unshift(i);
958
- }
959
- const deleted = [];
960
- this.idMatrix.forEach((row) => {
961
- const deleting = [];
962
- deleted.push(deleting);
963
- xs.forEach((x2) => {
964
- deleting.unshift(...row.splice(x2, 1));
965
- });
966
- });
967
- this.area.right -= xs.length;
968
- this.pushHistory({
969
- applyed: true,
970
- operation: "DELETE_COLS",
971
- reflection,
972
- xs: xs.reverse(),
973
- deleted
974
- });
975
- return this.shallowCopy({ copyCache: false });
976
- }
977
- getHistories() {
978
- return [...this.histories];
979
- }
980
- getHistoryIndex() {
981
- return this.historyIndex;
982
- }
983
- getHistorySize() {
984
- return this.histories.length;
985
- }
986
- getHistoryLimit() {
987
- return this.historyLimit;
988
- }
989
- setFunctions(additionalFunctions) {
990
- this.functions = { ...functions, ...additionalFunctions };
991
- }
992
- getArea() {
993
- return { ...this.area };
994
- }
995
- parse(point, value) {
996
- const cell = this.getByPoint(point) || {};
997
- const parser = this.parsers[cell.parser || ""] || defaultParser;
998
- return parser.call(value, cell);
999
- }
1000
- render(point, writer) {
1001
- const cell = this.getByPoint(point) || {};
1002
- const renderer = this.renderers[cell.renderer || ""] || defaultRenderer;
1003
- return renderer.call(this, point, writer);
1004
- }
1005
- stringify(point, value, evaluates = false) {
1006
- const cell = this.getByPoint(point);
1007
- const renderer = this.renderers[(cell == null ? void 0 : cell.renderer) || ""] || defaultRenderer;
1008
- const s = renderer.stringify(typeof value === "undefined" ? { ...cell } : { ...cell, value });
1009
- if (s[0] === "=") {
1010
- if (evaluates) {
1011
- return String(solveFormula({ value: s, table: this, raise: false, evaluates }));
1012
- }
1013
- const lexer = new Lexer(s.substring(1));
1014
- lexer.tokenize();
1015
- return "=" + lexer.stringifyToRef(this);
1016
- }
1017
- return s;
1018
- }
1019
- trim(area) {
1020
- const copied = Object.assign(Object.create(Object.getPrototypeOf(this)), this);
1021
- copied.area = area;
1022
- return copied;
1023
- }
1024
- getIdByAddress(address) {
1025
- let table = this;
1026
- if (address.indexOf("!") !== -1) {
1027
- const [sheetName, addr] = address.split("!");
1028
- const sheetId = this.sheets[stripSheetName(sheetName)];
1029
- table = this.tables[sheetId];
1030
- address = addr;
1031
- }
1032
- const { y, x } = a2p(address);
1033
- const id = table.getId({ y, x });
1034
- if (id) {
1035
- const prefix = table === this ? "" : `#${table.sheetId}!`;
1036
- return `${prefix}#${x < 0 ? "$" : ""}${id}${y < 0 ? "$" : ""}`;
1037
- }
1038
- }
1039
- applyDiff(diff, partial = true) {
1040
- if (!partial) {
1041
- Object.assign(this.data, diff);
1042
- return;
1043
- }
1044
- Object.keys(diff).map((id) => {
1045
- const cell = diff[id];
1046
- this.data[id] = { ...this.getById(id), ...cell };
1047
- });
1048
- }
1049
- undo() {
1050
- if (this.historyIndex < 0) {
1051
- return { history: null, newTable: this };
1052
- }
1053
- const history = this.histories[this.historyIndex--];
1054
- history.applyed = false;
1055
- this.currentHistory = history;
1056
- switch (history.operation) {
1057
- case "UPDATE":
1058
- this.applyDiff(history.diffBefore, false);
1059
- break;
1060
- case "ADD_ROWS": {
1061
- if (history.diffBefore) {
1062
- this.applyDiff(history.diffBefore, false);
1063
- }
1064
- const { height } = matrixShape({ matrix: history.idMatrix });
1065
- this.idMatrix.splice(history.y, height);
1066
- this.area.bottom -= height;
1067
- break;
1068
- }
1069
- case "ADD_COLS": {
1070
- if (history.diffBefore) {
1071
- this.applyDiff(history.diffBefore, false);
1072
- }
1073
- const { width } = matrixShape({ matrix: history.idMatrix });
1074
- this.idMatrix.forEach((row) => {
1075
- row.splice(history.x, width);
1076
- });
1077
- this.area.right -= width;
1078
- break;
1079
- }
1080
- case "DELETE_ROWS": {
1081
- const { ys, deleted } = history;
1082
- ys.forEach((y, i) => {
1083
- this.idMatrix.splice(y, 0, deleted[i]);
1084
- });
1085
- this.area.bottom += ys.length;
1086
- break;
1087
- }
1088
- case "DELETE_COLS": {
1089
- const { xs, deleted } = history;
1090
- this.idMatrix.forEach((row, i) => {
1091
- for (let j = 0; j < xs.length; j++) {
1092
- row.splice(xs[j], 0, deleted[i][j]);
1093
- }
1094
- });
1095
- this.area.right += xs.length;
1096
- break;
1097
- }
1098
- case "MOVE": {
1099
- const { top: yFrom, left: xFrom } = history.src;
1100
- const { top: yTo, left: xTo } = history.dst;
1101
- const { height: rows, width: cols } = matrixShape({
1102
- matrix: history.matrixFrom,
1103
- base: -1
1104
- });
1105
- putMatrix(this.idMatrix, history.matrixFrom, {
1106
- top: yFrom,
1107
- left: xFrom,
1108
- bottom: yFrom + rows,
1109
- right: xFrom + cols
1110
- });
1111
- putMatrix(this.idMatrix, history.matrixTo, {
1112
- top: yTo,
1113
- left: xTo,
1114
- bottom: yTo + rows,
1115
- right: xTo + cols
1116
- });
1117
- break;
1118
- }
1119
- }
1120
- return {
1121
- history,
1122
- newTable: this.shallowCopy({
1123
- copyCache: !shouldTracking(history.operation)
1124
- })
1125
- };
1126
- }
1127
- redo() {
1128
- if (this.historyIndex + 1 >= this.histories.length) {
1129
- return { history: null, newTable: this };
1130
- }
1131
- const history = this.histories[++this.historyIndex];
1132
- history.applyed = true;
1133
- this.currentHistory = history;
1134
- switch (history.operation) {
1135
- case "UPDATE":
1136
- this.applyDiff(history.diffAfter, history.partial);
1137
- break;
1138
- case "ADD_ROWS": {
1139
- if (history.diffAfter) {
1140
- this.applyDiff(history.diffAfter, history.partial);
1141
- }
1142
- const { height } = matrixShape({ matrix: history.idMatrix });
1143
- this.idMatrix.splice(history.y, 0, ...history.idMatrix);
1144
- this.area.bottom += height;
1145
- break;
1146
- }
1147
- case "ADD_COLS": {
1148
- if (history.diffAfter) {
1149
- this.applyDiff(history.diffAfter, history.partial);
1150
- }
1151
- const { width } = matrixShape({ matrix: history.idMatrix });
1152
- this.idMatrix.map((row, i) => {
1153
- row.splice(history.x, 0, ...history.idMatrix[i]);
1154
- });
1155
- this.area.right += width;
1156
- break;
1157
- }
1158
- case "DELETE_ROWS": {
1159
- const { ys } = history;
1160
- [...ys].reverse().forEach((y) => {
1161
- this.idMatrix.splice(y, 1);
1162
- });
1163
- this.area.bottom -= ys.length;
1164
- break;
1165
- }
1166
- case "DELETE_COLS": {
1167
- const { xs } = history;
1168
- [...xs].reverse().forEach((x) => {
1169
- this.idMatrix.forEach((row) => {
1170
- row.splice(x, 1);
1171
- });
1172
- });
1173
- this.area.right -= xs.length;
1174
- break;
1175
- }
1176
- case "MOVE": {
1177
- const { src, dst } = history;
1178
- this.move({ src, dst, operator: "USER", historicize: false });
1179
- }
1180
- }
1181
- return {
1182
- history,
1183
- newTable: this.shallowCopy({
1184
- copyCache: !shouldTracking(history.operation)
1185
- })
1186
- };
1187
- }
1188
- getFunction(name) {
1189
- return this.functions[name];
1190
- }
1191
- getLabel(key, n) {
1192
- const labeler = this.labelers[key];
1193
- return labeler == null ? void 0 : labeler(n);
1194
- }
1195
- getBase() {
1196
- return this;
1197
- }
1198
- getSolvedCache(key) {
1199
- return this.solvedCaches[key];
1200
- }
1201
- setSolvedCache(key, value) {
1202
- this.solvedCaches[key] = value;
1203
- }
1204
- wrappedSheetName() {
1205
- const sheetName = this.sheetName;
1206
- if (sheetName.indexOf(" ") !== -1) {
1207
- return `'${sheetName}'`;
1208
- }
1209
- return sheetName;
1210
- }
1211
- sheetPrefix(omit = false) {
1212
- if (omit) {
1213
- return "";
1214
- }
1215
- if (this.sheetName) {
1216
- return `${this.wrappedSheetName()}!`;
1217
- }
1218
- return "";
1219
- }
1220
- rangeToArea(range) {
1221
- const cells = range.split(":");
1222
- let [start, end] = cells;
1223
- if (start.match(/[a-zA-Z]$/)) {
1224
- start += "1";
1225
- }
1226
- if (start.match(/^[1-9]/)) {
1227
- start = `A${start}`;
1228
- }
1229
- if (end == null ? void 0 : end.match(/[a-zA-Z]$/)) {
1230
- end += this.bottom;
1231
- }
1232
- if (end == null ? void 0 : end.match(/^[1-9]/)) {
1233
- end = `${x2c(this.right)}${end}`;
1234
- }
1235
- const { y: top, x: left } = a2p(start);
1236
- const { y: bottom, x: right } = a2p(end || start);
1237
- return {
1238
- top: Math.abs(top),
1239
- left: Math.abs(left),
1240
- bottom: Math.abs(bottom),
1241
- right: Math.abs(right)
1242
- };
1243
- }
1244
- }
1245
- export {
1246
- Table
1247
- };
1248
- //# sourceMappingURL=table.js.map