@fileverse-dev/fortune-core 1.0.5 → 1.0.7

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 (346) hide show
  1. package/{dist/packages/core/src → es}/api/cell.d.ts +10 -10
  2. package/es/api/cell.js +204 -0
  3. package/{dist/packages/core/src → es}/api/common.d.ts +66 -66
  4. package/es/api/common.js +79 -0
  5. package/{dist/packages/core/src → es}/api/errors.d.ts +2 -2
  6. package/es/api/errors.js +2 -0
  7. package/{dist/packages/core/src → es}/api/index.d.ts +9 -9
  8. package/es/api/index.js +8 -0
  9. package/{dist/packages/core/src → es}/api/merge.d.ts +5 -5
  10. package/es/api/merge.js +15 -0
  11. package/{dist/packages/core/src → es}/api/range.d.ts +22 -22
  12. package/es/api/range.js +123 -0
  13. package/{dist/packages/core/src → es}/api/rowcol.d.ts +14 -14
  14. package/es/api/rowcol.js +207 -0
  15. package/{dist/packages/core/src → es}/api/sheet.d.ts +10 -10
  16. package/es/api/sheet.js +128 -0
  17. package/{dist/packages/core/src → es}/api/workbook.d.ts +15 -15
  18. package/es/api/workbook.js +85 -0
  19. package/{dist/packages/core/src → es}/canvas.d.ts +46 -46
  20. package/es/canvas.js +1350 -0
  21. package/{dist/packages/core/src → es}/context.d.ts +197 -197
  22. package/es/context.js +380 -0
  23. package/{dist/packages/core/src → es}/events/copy.d.ts +2 -2
  24. package/es/events/copy.js +78 -0
  25. package/{dist/packages/core/src → es}/events/index.d.ts +4 -4
  26. package/es/events/index.js +4 -0
  27. package/{dist/packages/core/src → es}/events/keyboard.d.ts +6 -6
  28. package/es/events/keyboard.js +332 -0
  29. package/{dist/packages/core/src → es}/events/mouse.d.ts +22 -22
  30. package/es/events/mouse.js +1725 -0
  31. package/{dist/packages/core/src → es}/events/paste.d.ts +3 -3
  32. package/es/events/paste.js +1358 -0
  33. package/{dist/packages/core/src → es}/index.d.ts +10 -10
  34. package/es/index.js +10 -0
  35. package/{dist/packages/core/src → es}/locale/en.d.ts +992 -992
  36. package/es/locale/en.js +10564 -0
  37. package/{dist/packages/core/src → es}/locale/es.d.ts +1134 -1134
  38. package/es/locale/es.js +10010 -0
  39. package/{dist/packages/core/src → es}/locale/hi.d.ts +1030 -1030
  40. package/es/locale/hi.js +10550 -0
  41. package/{dist/packages/core/src → es}/locale/index.d.ts +1049 -1049
  42. package/es/locale/index.js +23 -0
  43. package/{dist/packages/core/src → es}/locale/zh.d.ts +1048 -1048
  44. package/es/locale/zh.js +10568 -0
  45. package/{dist/packages/core/src → es}/locale/zh_tw.d.ts +1187 -1187
  46. package/es/locale/zh_tw.js +10072 -0
  47. package/{dist/packages/core/src → es}/modules/ConditionFormat.d.ts +17 -17
  48. package/es/modules/ConditionFormat.js +1258 -0
  49. package/{dist/packages/core/src → es}/modules/border.d.ts +3 -3
  50. package/es/modules/border.js +1240 -0
  51. package/{dist/packages/core/src → es}/modules/cell.d.ts +32 -32
  52. package/es/modules/cell.js +1055 -0
  53. package/{dist/packages/core/src → es}/modules/clipboard.d.ts +3 -3
  54. package/es/modules/clipboard.js +36 -0
  55. package/{dist/packages/core/src → es}/modules/color.d.ts +1 -1
  56. package/es/modules/color.js +1 -0
  57. package/{dist/packages/core/src → es}/modules/comment.d.ts +97 -97
  58. package/es/modules/comment.js +597 -0
  59. package/{dist/packages/core/src → es}/modules/conditionalFormat.d.ts +2 -2
  60. package/es/modules/conditionalFormat.js +441 -0
  61. package/{dist/packages/core/src → es}/modules/cursor.d.ts +3 -3
  62. package/es/modules/cursor.js +62 -0
  63. package/{dist/packages/core/src → es}/modules/dataVerification.d.ts +11 -11
  64. package/es/modules/dataVerification.js +700 -0
  65. package/{dist/packages/core/src → es}/modules/dropCell.d.ts +10 -10
  66. package/es/modules/dropCell.js +2266 -0
  67. package/{dist/packages/core/src → es}/modules/filter.d.ts +45 -45
  68. package/es/modules/filter.js +434 -0
  69. package/{dist/packages/core/src → es}/modules/format.d.ts +6 -6
  70. package/es/modules/format.js +323 -0
  71. package/{dist/packages/core/src → es}/modules/formula.d.ts +54 -54
  72. package/es/modules/formula.js +2301 -0
  73. package/{dist/packages/core/src → es}/modules/freeze.d.ts +5 -5
  74. package/es/modules/freeze.js +148 -0
  75. package/{dist/packages/core/src → es}/modules/hyperlink.d.ts +21 -21
  76. package/es/modules/hyperlink.js +216 -0
  77. package/{dist/packages/core/src → es}/modules/iframe.d.ts +12 -12
  78. package/es/modules/iframe.js +220 -0
  79. package/{dist/packages/core/src → es}/modules/image.d.ts +31 -31
  80. package/es/modules/image.js +253 -0
  81. package/{dist/packages/core/src → es}/modules/index.d.ts +36 -36
  82. package/es/modules/index.js +36 -0
  83. package/{dist/packages/core/src → es}/modules/inline-string.d.ts +36 -36
  84. package/es/modules/inline-string.js +437 -0
  85. package/{dist/packages/core/src → es}/modules/location.d.ts +6 -6
  86. package/es/modules/location.js +46 -0
  87. package/{dist/packages/core/src → es}/modules/locationCondition.d.ts +21 -21
  88. package/es/modules/locationCondition.js +218 -0
  89. package/{dist/packages/core/src → es}/modules/merge.d.ts +3 -3
  90. package/es/modules/merge.js +216 -0
  91. package/{dist/packages/core/src → es}/modules/mobile.d.ts +5 -5
  92. package/es/modules/mobile.js +33 -0
  93. package/{dist/packages/core/src → es}/modules/moveCells.d.ts +5 -5
  94. package/es/modules/moveCells.js +348 -0
  95. package/{dist/packages/core/src → es}/modules/protection.d.ts +5 -5
  96. package/es/modules/protection.js +96 -0
  97. package/{dist/packages/core/src → es}/modules/refresh.d.ts +3 -3
  98. package/es/modules/refresh.js +34 -0
  99. package/{dist/packages/core/src → es}/modules/rowcol.d.ts +19 -19
  100. package/es/modules/rowcol.js +1922 -0
  101. package/{dist/packages/core/src → es}/modules/screenshot.d.ts +2 -2
  102. package/es/modules/screenshot.js +90 -0
  103. package/{dist/packages/core/src → es}/modules/searchReplace.d.ts +36 -36
  104. package/es/modules/searchReplace.js +388 -0
  105. package/{dist/packages/core/src → es}/modules/selection.d.ts +46 -46
  106. package/es/modules/selection.js +1674 -0
  107. package/{dist/packages/core/src → es}/modules/sheet.d.ts +10 -10
  108. package/es/modules/sheet.js +237 -0
  109. package/{dist/packages/core/src → es}/modules/sort.d.ts +7 -7
  110. package/es/modules/sort.js +150 -0
  111. package/{dist/packages/core/src → es}/modules/splitColumn.d.ts +5 -5
  112. package/es/modules/splitColumn.js +126 -0
  113. package/es/modules/ssf.js +1533 -0
  114. package/{dist/packages/core/src → es}/modules/text.d.ts +10 -10
  115. package/es/modules/text.js +1207 -0
  116. package/{dist/packages/core/src → es}/modules/toolbar.d.ts +32 -32
  117. package/es/modules/toolbar.js +970 -0
  118. package/{dist/packages/core/src → es}/modules/validation.d.ts +19 -19
  119. package/es/modules/validation.js +190 -0
  120. package/{dist/packages/core/src → es}/modules/zoom.d.ts +3 -3
  121. package/es/modules/zoom.js +29 -0
  122. package/{dist/packages/core/src → es}/settings.d.ts +100 -100
  123. package/es/settings.js +36 -0
  124. package/{dist/packages/core/src → es}/types.d.ts +371 -371
  125. package/es/types.js +1 -0
  126. package/{dist/packages/core/src → es}/utils/freeze.d.ts +7 -7
  127. package/es/utils/freeze.js +86 -0
  128. package/{dist/packages/core/src → es}/utils/index.d.ts +18 -18
  129. package/es/utils/index.js +173 -0
  130. package/{dist/packages/core/src → es}/utils/patch.d.ts +37 -37
  131. package/es/utils/patch.js +381 -0
  132. package/lib/api/cell.d.ts +10 -0
  133. package/lib/api/cell.js +215 -0
  134. package/lib/api/common.d.ts +66 -0
  135. package/lib/api/common.js +88 -0
  136. package/lib/api/errors.d.ts +2 -0
  137. package/lib/api/errors.js +8 -0
  138. package/lib/api/index.d.ts +9 -0
  139. package/lib/api/index.js +101 -0
  140. package/lib/api/merge.d.ts +5 -0
  141. package/lib/api/merge.js +22 -0
  142. package/lib/api/range.d.ts +22 -0
  143. package/lib/api/range.js +138 -0
  144. package/lib/api/rowcol.d.ts +14 -0
  145. package/lib/api/rowcol.js +222 -0
  146. package/lib/api/sheet.d.ts +10 -0
  147. package/lib/api/sheet.js +145 -0
  148. package/lib/api/workbook.d.ts +15 -0
  149. package/lib/api/workbook.js +98 -0
  150. package/lib/canvas.d.ts +46 -0
  151. package/lib/canvas.js +1356 -0
  152. package/lib/context.d.ts +197 -0
  153. package/lib/context.js +392 -0
  154. package/lib/events/copy.d.ts +2 -0
  155. package/lib/events/copy.js +85 -0
  156. package/lib/events/index.d.ts +4 -0
  157. package/lib/events/index.js +49 -0
  158. package/lib/events/keyboard.d.ts +6 -0
  159. package/lib/events/keyboard.js +342 -0
  160. package/lib/events/mouse.d.ts +22 -0
  161. package/lib/events/mouse.js +1744 -0
  162. package/lib/events/paste.d.ts +3 -0
  163. package/lib/events/paste.js +1366 -0
  164. package/lib/index.d.ts +10 -0
  165. package/lib/index.js +109 -0
  166. package/lib/locale/en.d.ts +992 -0
  167. package/lib/locale/en.js +10570 -0
  168. package/lib/locale/es.d.ts +1134 -0
  169. package/lib/locale/es.js +10016 -0
  170. package/lib/locale/hi.d.ts +1030 -0
  171. package/lib/locale/hi.js +10556 -0
  172. package/lib/locale/index.d.ts +1049 -0
  173. package/lib/locale/index.js +29 -0
  174. package/lib/locale/zh.d.ts +1048 -0
  175. package/lib/locale/zh.js +10574 -0
  176. package/lib/locale/zh_tw.d.ts +1187 -0
  177. package/lib/locale/zh_tw.js +10078 -0
  178. package/lib/modules/ConditionFormat.d.ts +17 -0
  179. package/lib/modules/ConditionFormat.js +1273 -0
  180. package/lib/modules/border.d.ts +3 -0
  181. package/lib/modules/border.js +1248 -0
  182. package/lib/modules/cell.d.ts +32 -0
  183. package/lib/modules/cell.js +1085 -0
  184. package/lib/modules/clipboard.d.ts +3 -0
  185. package/lib/modules/clipboard.js +42 -0
  186. package/lib/modules/color.d.ts +1 -0
  187. package/lib/modules/color.js +7 -0
  188. package/lib/modules/comment.d.ts +97 -0
  189. package/lib/modules/comment.js +625 -0
  190. package/lib/modules/conditionalFormat.d.ts +2 -0
  191. package/lib/modules/conditionalFormat.js +447 -0
  192. package/lib/modules/cursor.d.ts +3 -0
  193. package/lib/modules/cursor.js +70 -0
  194. package/lib/modules/dataVerification.d.ts +11 -0
  195. package/lib/modules/dataVerification.js +715 -0
  196. package/lib/modules/dropCell.d.ts +10 -0
  197. package/lib/modules/dropCell.js +2282 -0
  198. package/lib/modules/filter.d.ts +45 -0
  199. package/lib/modules/filter.js +448 -0
  200. package/lib/modules/format.d.ts +6 -0
  201. package/lib/modules/format.js +334 -0
  202. package/lib/modules/formula.d.ts +54 -0
  203. package/lib/modules/formula.js +2330 -0
  204. package/lib/modules/freeze.d.ts +5 -0
  205. package/lib/modules/freeze.js +158 -0
  206. package/lib/modules/hyperlink.d.ts +21 -0
  207. package/lib/modules/hyperlink.js +232 -0
  208. package/lib/modules/iframe.d.ts +12 -0
  209. package/lib/modules/iframe.js +236 -0
  210. package/lib/modules/image.d.ts +31 -0
  211. package/lib/modules/image.js +272 -0
  212. package/lib/modules/index.d.ts +36 -0
  213. package/lib/modules/index.js +401 -0
  214. package/lib/modules/inline-string.d.ts +36 -0
  215. package/lib/modules/inline-string.js +452 -0
  216. package/lib/modules/location.d.ts +6 -0
  217. package/lib/modules/location.js +57 -0
  218. package/lib/modules/locationCondition.d.ts +21 -0
  219. package/lib/modules/locationCondition.js +229 -0
  220. package/lib/modules/merge.d.ts +3 -0
  221. package/lib/modules/merge.js +223 -0
  222. package/lib/modules/mobile.d.ts +5 -0
  223. package/lib/modules/mobile.js +41 -0
  224. package/lib/modules/moveCells.d.ts +5 -0
  225. package/lib/modules/moveCells.js +357 -0
  226. package/lib/modules/protection.d.ts +5 -0
  227. package/lib/modules/protection.js +106 -0
  228. package/lib/modules/refresh.d.ts +3 -0
  229. package/lib/modules/refresh.js +40 -0
  230. package/lib/modules/rowcol.d.ts +19 -0
  231. package/lib/modules/rowcol.js +1935 -0
  232. package/lib/modules/screenshot.d.ts +2 -0
  233. package/lib/modules/screenshot.js +96 -0
  234. package/lib/modules/searchReplace.d.ts +36 -0
  235. package/lib/modules/searchReplace.js +402 -0
  236. package/lib/modules/selection.d.ts +46 -0
  237. package/lib/modules/selection.js +1703 -0
  238. package/lib/modules/sheet.d.ts +10 -0
  239. package/lib/modules/sheet.js +250 -0
  240. package/lib/modules/sort.d.ts +7 -0
  241. package/lib/modules/sort.js +159 -0
  242. package/lib/modules/splitColumn.d.ts +5 -0
  243. package/lib/modules/splitColumn.js +136 -0
  244. package/lib/modules/ssf.js +1539 -0
  245. package/lib/modules/text.d.ts +10 -0
  246. package/lib/modules/text.js +1221 -0
  247. package/lib/modules/toolbar.d.ts +32 -0
  248. package/lib/modules/toolbar.js +1003 -0
  249. package/lib/modules/validation.d.ts +19 -0
  250. package/lib/modules/validation.js +205 -0
  251. package/lib/modules/zoom.d.ts +3 -0
  252. package/lib/modules/zoom.js +36 -0
  253. package/lib/settings.d.ts +100 -0
  254. package/lib/settings.js +42 -0
  255. package/lib/types.d.ts +371 -0
  256. package/lib/types.js +5 -0
  257. package/lib/utils/freeze.d.ts +7 -0
  258. package/lib/utils/freeze.js +92 -0
  259. package/lib/utils/index.d.ts +18 -0
  260. package/lib/utils/index.js +231 -0
  261. package/lib/utils/patch.d.ts +37 -0
  262. package/lib/utils/patch.js +392 -0
  263. package/package.json +6 -5
  264. package/dist/index.esm.js +0 -80253
  265. package/dist/index.js +0 -80599
  266. package/dist/packages/react/src/components/ChangeColor/index.d.ts +0 -7
  267. package/dist/packages/react/src/components/ConditionFormat/ConditionRules.d.ts +0 -6
  268. package/dist/packages/react/src/components/ConditionFormat/index.d.ts +0 -7
  269. package/dist/packages/react/src/components/ContextMenu/Divider.d.ts +0 -3
  270. package/dist/packages/react/src/components/ContextMenu/FilterMenu.d.ts +0 -3
  271. package/dist/packages/react/src/components/ContextMenu/Menu.d.ts +0 -8
  272. package/dist/packages/react/src/components/ContextMenu/SheetTab.d.ts +0 -4
  273. package/dist/packages/react/src/components/ContextMenu/index.d.ts +0 -5
  274. package/dist/packages/react/src/components/CustomSort/index.d.ts +0 -4
  275. package/dist/packages/react/src/components/DataVerification/DropdownList.d.ts +0 -4
  276. package/dist/packages/react/src/components/DataVerification/RangeDialog.d.ts +0 -4
  277. package/dist/packages/react/src/components/DataVerification/getDisplayedRangeTxt.d.ts +0 -2
  278. package/dist/packages/react/src/components/DataVerification/index.d.ts +0 -4
  279. package/dist/packages/react/src/components/Dialog/index.d.ts +0 -15
  280. package/dist/packages/react/src/components/DuneChartsInputModal/DuneChartsInputModal.d.ts +0 -11
  281. package/dist/packages/react/src/components/DunePreview/DunePreview.d.ts +0 -13
  282. package/dist/packages/react/src/components/FilterOption/index.d.ts +0 -5
  283. package/dist/packages/react/src/components/FormatSearch/index.d.ts +0 -6
  284. package/dist/packages/react/src/components/FormulaSearch/index.d.ts +0 -5
  285. package/dist/packages/react/src/components/FxEditor/NameBox.d.ts +0 -3
  286. package/dist/packages/react/src/components/FxEditor/index.d.ts +0 -4
  287. package/dist/packages/react/src/components/IFrameBoxs/iFrameBoxs.d.ts +0 -4
  288. package/dist/packages/react/src/components/ImgBoxs/index.d.ts +0 -3
  289. package/dist/packages/react/src/components/LinkEidtCard/index.d.ts +0 -5
  290. package/dist/packages/react/src/components/LocationCondition/index.d.ts +0 -3
  291. package/dist/packages/react/src/components/MessageBox/index.d.ts +0 -9
  292. package/dist/packages/react/src/components/NotationBoxes/index.d.ts +0 -3
  293. package/dist/packages/react/src/components/ResetColumnWidth/index.d.ts +0 -2
  294. package/dist/packages/react/src/components/SVGDefines.d.ts +0 -5
  295. package/dist/packages/react/src/components/SVGIcon.d.ts +0 -9
  296. package/dist/packages/react/src/components/SearchReplace/index.d.ts +0 -6
  297. package/dist/packages/react/src/components/Sheet/index.d.ts +0 -8
  298. package/dist/packages/react/src/components/SheetList/SheetHiddenButton.d.ts +0 -8
  299. package/dist/packages/react/src/components/SheetList/SheetListItem.d.ts +0 -9
  300. package/dist/packages/react/src/components/SheetList/index.d.ts +0 -4
  301. package/dist/packages/react/src/components/SheetOverlay/ColumnHeader.d.ts +0 -3
  302. package/dist/packages/react/src/components/SheetOverlay/ContentEditable.d.ts +0 -11
  303. package/dist/packages/react/src/components/SheetOverlay/FormulaHint/index.d.ts +0 -4
  304. package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/constant.d.ts +0 -63
  305. package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/index.d.ts +0 -4
  306. package/dist/packages/react/src/components/SheetOverlay/InputBox.d.ts +0 -3
  307. package/dist/packages/react/src/components/SheetOverlay/RowHeader.d.ts +0 -3
  308. package/dist/packages/react/src/components/SheetOverlay/ScrollBar/index.d.ts +0 -7
  309. package/dist/packages/react/src/components/SheetOverlay/index.d.ts +0 -4
  310. package/dist/packages/react/src/components/SheetTab/SheetItem.d.ts +0 -8
  311. package/dist/packages/react/src/components/SheetTab/index.d.ts +0 -4
  312. package/dist/packages/react/src/components/SplitColumn/index.d.ts +0 -3
  313. package/dist/packages/react/src/components/Toolbar/Button.d.ts +0 -12
  314. package/dist/packages/react/src/components/Toolbar/ColorPicker.d.ts +0 -6
  315. package/dist/packages/react/src/components/Toolbar/Combo.d.ts +0 -12
  316. package/dist/packages/react/src/components/Toolbar/CustomBorder.d.ts +0 -7
  317. package/dist/packages/react/src/components/Toolbar/CustomButton.d.ts +0 -11
  318. package/dist/packages/react/src/components/Toolbar/CustomColor.d.ts +0 -8
  319. package/dist/packages/react/src/components/Toolbar/CustomIcon.d.ts +0 -9
  320. package/dist/packages/react/src/components/Toolbar/Divider.d.ts +0 -4
  321. package/dist/packages/react/src/components/Toolbar/MoreItemsContainer.d.ts +0 -6
  322. package/dist/packages/react/src/components/Toolbar/Select.d.ts +0 -14
  323. package/dist/packages/react/src/components/Toolbar/index.d.ts +0 -10
  324. package/dist/packages/react/src/components/Workbook/api.d.ts +0 -1177
  325. package/dist/packages/react/src/components/Workbook/index.d.ts +0 -1185
  326. package/dist/packages/react/src/components/ZoomControl/index.d.ts +0 -4
  327. package/dist/packages/react/src/components/index.d.ts +0 -4
  328. package/dist/packages/react/src/constants.d.ts +0 -1
  329. package/dist/packages/react/src/context/index.d.ts +0 -25
  330. package/dist/packages/react/src/context/modal.d.ts +0 -10
  331. package/dist/packages/react/src/hooks/useAlert.d.ts +0 -4
  332. package/dist/packages/react/src/hooks/useDialog.d.ts +0 -5
  333. package/dist/packages/react/src/hooks/useOutsideClick.d.ts +0 -2
  334. package/dist/packages/react/src/hooks/usePrevious.d.ts +0 -2
  335. package/dist/packages/react/src/index.d.ts +0 -1
  336. package/dist/packages/react/src/utils/datepickerStyles.d.ts +0 -2
  337. package/dist/stories/API.stories.d.ts +0 -1210
  338. package/dist/stories/Collabration.stories.d.ts +0 -2359
  339. package/dist/stories/Features.stories.d.ts +0 -9430
  340. package/dist/stories/data/cell.d.ts +0 -983
  341. package/dist/stories/data/dataVerification.d.ts +0 -131
  342. package/dist/stories/data/empty.d.ts +0 -10
  343. package/dist/stories/data/formula.d.ts +0 -362
  344. package/dist/stories/data/freeze.d.ts +0 -34
  345. package/dist/stories/data/protected.d.ts +0 -40
  346. package/dist/stories/utils.d.ts +0 -1
@@ -0,0 +1,1055 @@
1
+ import _ from "lodash";
2
+ import { getFlowdata } from "../context";
3
+ import { getSheetIndex, indexToColumnChar, rgbToHex } from "../utils";
4
+ import { checkCF, getComputeMap } from "./ConditionFormat";
5
+ import { getFailureText, validateCellData } from "./dataVerification";
6
+ import { genarate, update } from "./format";
7
+ import { getRowHeight } from "../api";
8
+ import { delFunctionGroup, execfunction, execFunctionGroup, functionHTMLGenerate, getcellrange, iscelldata } from "./formula";
9
+ import { attrToCssName, convertSpanToShareString, isInlineStringCell, isInlineStringCT } from "./inline-string";
10
+ import { isRealNull, isRealNum, valueIsError } from "./validation";
11
+ import { getCellTextInfo } from "./text";
12
+ export function normalizedCellAttr(cell, attr, defaultFontSize) {
13
+ if (defaultFontSize === void 0) {
14
+ defaultFontSize = 10;
15
+ }
16
+ var tf = {
17
+ bl: 1,
18
+ it: 1,
19
+ ff: 1,
20
+ cl: 1,
21
+ un: 1
22
+ };
23
+ var value = cell === null || cell === void 0 ? void 0 : cell[attr];
24
+ if (attr in tf || attr === "fs" && isInlineStringCell(cell)) {
25
+ value || (value = "0");
26
+ } else if (["fc", "bg", "bc"].includes(attr)) {
27
+ if (["fc", "bc"].includes(attr)) {
28
+ value || (value = "#000000");
29
+ }
30
+ if ((value === null || value === void 0 ? void 0 : value.indexOf("rgba")) > -1) {
31
+ value = rgbToHex(value);
32
+ }
33
+ } else if (attr.substring(0, 2) === "bs") {
34
+ value || (value = "none");
35
+ } else if (attr === "ht" || attr === "vt") {
36
+ var defaultValue = attr === "ht" ? "1" : "0";
37
+ value = !_.isNil(value) ? value.toString() : defaultValue;
38
+ if (["0", "1", "2"].indexOf(value.toString()) === -1) {
39
+ value = defaultValue;
40
+ }
41
+ } else if (attr === "fs") {
42
+ value || (value = defaultFontSize.toString());
43
+ } else if (attr === "tb" || attr === "tr") {
44
+ value || (value = "0");
45
+ }
46
+ return value;
47
+ }
48
+ export function normalizedAttr(data, r, c, attr) {
49
+ if (!data || !data[r]) {
50
+ console.warn("cell (%d, %d) is null", r, c);
51
+ return null;
52
+ }
53
+ var cell = data[r][c];
54
+ if (!cell) return undefined;
55
+ return normalizedCellAttr(cell, attr);
56
+ }
57
+ export function getCellValue(r, c, data, attr) {
58
+ if (!attr) {
59
+ attr = "v";
60
+ }
61
+ var d_value;
62
+ if (!_.isNil(r) && !_.isNil(c)) {
63
+ d_value = data[r][c];
64
+ } else if (!_.isNil(r)) {
65
+ d_value = data[r];
66
+ } else if (!_.isNil(c)) {
67
+ var newData = data[0].map(function (col, i) {
68
+ return data.map(function (row) {
69
+ return row[i];
70
+ });
71
+ });
72
+ d_value = newData[c];
73
+ } else {
74
+ return data;
75
+ }
76
+ var retv = d_value;
77
+ if (_.isPlainObject(d_value)) {
78
+ var d = d_value;
79
+ retv = d[attr];
80
+ if (attr === "f" && !_.isNil(retv)) {
81
+ retv = functionHTMLGenerate(retv);
82
+ } else if (attr === "f") {
83
+ retv = d.v;
84
+ } else if (d && d.ct && d.ct.t === "d") {
85
+ retv = d.m;
86
+ }
87
+ }
88
+ if (retv === undefined) {
89
+ retv = null;
90
+ }
91
+ return retv;
92
+ }
93
+ export function setCellValue(ctx, r, c, d, v) {
94
+ var _a, _b, _c, _d, _e, _f;
95
+ if (_.isNil(d)) {
96
+ d = getFlowdata(ctx);
97
+ }
98
+ if (!d) return;
99
+ var cell = d[r][c];
100
+ var vupdate;
101
+ if (_.isPlainObject(v)) {
102
+ if (_.isNil(cell)) {
103
+ cell = v;
104
+ } else {
105
+ if (!_.isNil(v.f)) {
106
+ cell.f = v.f;
107
+ } else if ("f" in cell) {
108
+ delete cell.f;
109
+ }
110
+ if (!_.isNil(v.ct)) {
111
+ cell.ct = v.ct;
112
+ }
113
+ }
114
+ if (_.isPlainObject(v.v)) {
115
+ vupdate = v.v.v;
116
+ } else {
117
+ vupdate = v.v;
118
+ }
119
+ } else {
120
+ vupdate = v;
121
+ }
122
+ if (isRealNull(vupdate)) {
123
+ if (_.isPlainObject(cell)) {
124
+ delete cell.m;
125
+ delete cell.v;
126
+ } else {
127
+ cell = null;
128
+ }
129
+ d[r][c] = cell;
130
+ return;
131
+ }
132
+ if (isRealNull(cell) || (_.isString(cell) || _.isNumber(cell)) && cell === v) {
133
+ cell = {};
134
+ }
135
+ if (!cell) return;
136
+ var vupdateStr = vupdate.toString();
137
+ if (vupdateStr.substr(0, 1) === "'") {
138
+ cell.m = vupdateStr.substr(1);
139
+ cell.ct = {
140
+ fa: "@",
141
+ t: "s"
142
+ };
143
+ cell.v = vupdateStr.substr(1);
144
+ cell.qp = 1;
145
+ } else if (cell.qp === 1) {
146
+ cell.m = vupdateStr;
147
+ cell.ct = {
148
+ fa: "@",
149
+ t: "s"
150
+ };
151
+ cell.v = vupdateStr;
152
+ } else if (vupdateStr.toUpperCase() === "TRUE" && (_.isNil((_a = cell.ct) === null || _a === void 0 ? void 0 : _a.fa) || ((_b = cell.ct) === null || _b === void 0 ? void 0 : _b.fa) !== "@")) {
153
+ cell.m = "TRUE";
154
+ cell.ct = {
155
+ fa: "General",
156
+ t: "b"
157
+ };
158
+ cell.v = true;
159
+ } else if (vupdateStr.toUpperCase() === "FALSE" && (_.isNil((_c = cell.ct) === null || _c === void 0 ? void 0 : _c.fa) || ((_d = cell.ct) === null || _d === void 0 ? void 0 : _d.fa) !== "@")) {
160
+ cell.m = "FALSE";
161
+ cell.ct = {
162
+ fa: "General",
163
+ t: "b"
164
+ };
165
+ cell.v = false;
166
+ } else if (vupdateStr.substr(-1) === "%" && isRealNum(vupdateStr.substring(0, vupdateStr.length - 1)) && (_.isNil((_e = cell.ct) === null || _e === void 0 ? void 0 : _e.fa) || ((_f = cell.ct) === null || _f === void 0 ? void 0 : _f.fa) !== "@")) {
167
+ cell.ct = {
168
+ fa: "0%",
169
+ t: "n"
170
+ };
171
+ cell.v = vupdateStr.substring(0, vupdateStr.length - 1) / 100;
172
+ cell.m = vupdate;
173
+ } else if (valueIsError(vupdate)) {
174
+ cell.m = vupdateStr;
175
+ if (!_.isNil(cell.ct)) {
176
+ cell.ct.t = "e";
177
+ } else {
178
+ cell.ct = {
179
+ fa: "General",
180
+ t: "e"
181
+ };
182
+ }
183
+ cell.v = vupdate;
184
+ } else {
185
+ if (!_.isNil(cell.f) && isRealNum(vupdate) && !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(vupdate)) {
186
+ cell.v = parseFloat(vupdate);
187
+ if (_.isNil(cell.ct)) {
188
+ cell.ct = {
189
+ fa: "General",
190
+ t: "n"
191
+ };
192
+ }
193
+ if (cell.v === Infinity || cell.v === -Infinity) {
194
+ cell.m = cell.v.toString();
195
+ } else {
196
+ if (cell.v.toString().indexOf("e") > -1) {
197
+ var len = void 0;
198
+ if (cell.v.toString().split(".").length === 1) {
199
+ len = 0;
200
+ } else {
201
+ len = cell.v.toString().split(".")[1].split("e")[0].length;
202
+ }
203
+ if (len > 5) {
204
+ len = 5;
205
+ }
206
+ cell.m = cell.v.toExponential(len).toString();
207
+ } else {
208
+ var v_p = Math.round(cell.v * 1000000000) / 1000000000;
209
+ if (_.isNil(cell.ct)) {
210
+ var mask = genarate(v_p);
211
+ if (mask != null) {
212
+ cell.m = mask[0].toString();
213
+ }
214
+ } else {
215
+ var mask = update(cell.ct.fa, v_p);
216
+ cell.m = mask.toString();
217
+ }
218
+ }
219
+ }
220
+ } else if (!_.isNil(cell.ct) && cell.ct.fa === "@") {
221
+ cell.m = vupdateStr;
222
+ cell.v = vupdate;
223
+ } else if (cell.ct != null && cell.ct.t === "d" && _.isString(vupdate)) {
224
+ var mask = genarate(vupdate);
225
+ if (mask[1].t !== "d" || mask[1].fa === cell.ct.fa) {
226
+ cell.m = mask[0], cell.ct = mask[1], cell.v = mask[2];
227
+ } else {
228
+ cell.v = mask[2];
229
+ cell.m = update(cell.ct.fa, cell.v);
230
+ }
231
+ } else if (!_.isNil(cell.ct) && !_.isNil(cell.ct.fa) && cell.ct.fa !== "General") {
232
+ if (isRealNum(vupdate)) {
233
+ vupdate = parseFloat(vupdate);
234
+ }
235
+ var mask = update(cell.ct.fa, vupdate);
236
+ if (mask === vupdate) {
237
+ mask = genarate(vupdate);
238
+ cell.m = mask[0].toString();
239
+ cell.ct = mask[1], cell.v = mask[2];
240
+ } else {
241
+ cell.m = mask.toString();
242
+ cell.v = vupdate;
243
+ }
244
+ } else {
245
+ if (isRealNum(vupdate) && !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(vupdate)) {
246
+ if (typeof vupdate === "string") {
247
+ var flag = vupdate.split("").every(function (ele) {
248
+ return ele === "0" || ele === ".";
249
+ });
250
+ if (flag) {
251
+ vupdate = parseFloat(vupdate);
252
+ }
253
+ }
254
+ cell.v = vupdate;
255
+ cell.ct = {
256
+ fa: "General",
257
+ t: "n"
258
+ };
259
+ if (cell.v === Infinity || cell.v === -Infinity) {
260
+ cell.m = cell.v.toString();
261
+ } else if (cell.v != null) {
262
+ var mask = genarate(cell.v);
263
+ if (mask) {
264
+ cell.m = mask[0].toString();
265
+ }
266
+ }
267
+ } else {
268
+ var mask = genarate(vupdate);
269
+ if (mask) {
270
+ cell.m = mask[0].toString();
271
+ cell.ct = mask[1], cell.v = mask[2];
272
+ }
273
+ }
274
+ }
275
+ }
276
+ d[r][c] = cell;
277
+ }
278
+ export function getRealCellValue(r, c, data, attr) {
279
+ var value = getCellValue(r, c, data, "m");
280
+ if (_.isNil(value)) {
281
+ value = getCellValue(r, c, data, attr);
282
+ if (_.isNil(value)) {
283
+ var ct = getCellValue(r, c, data, "ct");
284
+ if (isInlineStringCT(ct)) {
285
+ value = ct.s;
286
+ }
287
+ }
288
+ }
289
+ return value;
290
+ }
291
+ export function mergeBorder(ctx, d, row_index, col_index) {
292
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
293
+ if (!d || !d[row_index]) {
294
+ console.warn("Merge info is null", row_index, col_index);
295
+ return null;
296
+ }
297
+ var value = d[row_index][col_index];
298
+ if (!value) return null;
299
+ if (value === null || value === void 0 ? void 0 : value.mc) {
300
+ var margeMaindata = value.mc;
301
+ if (!margeMaindata) {
302
+ console.warn("Merge info is null", row_index, col_index);
303
+ return null;
304
+ }
305
+ col_index = margeMaindata.c;
306
+ row_index = margeMaindata.r;
307
+ if (_.isNil((_a = d === null || d === void 0 ? void 0 : d[row_index]) === null || _a === void 0 ? void 0 : _a[col_index])) {
308
+ console.warn("Main merge Cell info is null", row_index, col_index);
309
+ return null;
310
+ }
311
+ var col_rs = (_d = (_c = (_b = d[row_index]) === null || _b === void 0 ? void 0 : _b[col_index]) === null || _c === void 0 ? void 0 : _c.mc) === null || _d === void 0 ? void 0 : _d.cs;
312
+ var row_rs = (_g = (_f = (_e = d[row_index]) === null || _e === void 0 ? void 0 : _e[col_index]) === null || _f === void 0 ? void 0 : _f.mc) === null || _g === void 0 ? void 0 : _g.rs;
313
+ var mergeMain = (_j = (_h = d[row_index]) === null || _h === void 0 ? void 0 : _h[col_index]) === null || _j === void 0 ? void 0 : _j.mc;
314
+ if (!mergeMain || _.isNil(mergeMain === null || mergeMain === void 0 ? void 0 : mergeMain.rs) || _.isNil(mergeMain === null || mergeMain === void 0 ? void 0 : mergeMain.cs) || _.isNil(col_rs) || _.isNil(row_rs)) {
315
+ console.warn("Main merge info is null", mergeMain);
316
+ return null;
317
+ }
318
+ var start_r = void 0;
319
+ var end_r = void 0;
320
+ var row = void 0;
321
+ var row_pre = void 0;
322
+ for (var r = row_index; r < mergeMain.rs + row_index; r += 1) {
323
+ if (r === 0) {
324
+ start_r = -1;
325
+ } else {
326
+ start_r = ctx.visibledatarow[r - 1] - 1;
327
+ }
328
+ end_r = ctx.visibledatarow[r];
329
+ if (row_pre === undefined) {
330
+ row_pre = start_r;
331
+ row = end_r;
332
+ } else if (row !== undefined) {
333
+ row += end_r - start_r - 1;
334
+ }
335
+ }
336
+ var start_c = void 0;
337
+ var end_c = void 0;
338
+ var col = void 0;
339
+ var col_pre = void 0;
340
+ for (var c = col_index; c < mergeMain.cs + col_index; c += 1) {
341
+ if (c === 0) {
342
+ start_c = 0;
343
+ } else {
344
+ start_c = ctx.visibledatacolumn[c - 1];
345
+ }
346
+ end_c = ctx.visibledatacolumn[c];
347
+ if (col_pre === undefined) {
348
+ col_pre = start_c;
349
+ col = end_c;
350
+ } else if (col !== undefined) {
351
+ col += end_c - start_c;
352
+ }
353
+ }
354
+ if (_.isNil(row_pre) || _.isNil(col_pre) || _.isNil(row) || _.isNil(col)) {
355
+ console.warn("Main merge info row_pre or col_pre or row or col is null", mergeMain);
356
+ return null;
357
+ }
358
+ return {
359
+ row: [row_pre, row, row_index, row_index + row_rs - 1],
360
+ column: [col_pre, col, col_index, col_index + col_rs - 1]
361
+ };
362
+ }
363
+ return null;
364
+ }
365
+ function mergeMove(ctx, mc, columnseleted, rowseleted, s, top, height, left, width) {
366
+ var row_st = mc.r;
367
+ var row_ed = mc.r + mc.rs - 1;
368
+ var col_st = mc.c;
369
+ var col_ed = mc.c + mc.cs - 1;
370
+ var ismatch = false;
371
+ columnseleted[0] = Math.min(columnseleted[0], columnseleted[1]);
372
+ rowseleted[0] = Math.min(rowseleted[0], rowseleted[1]);
373
+ if (columnseleted[0] <= col_st && columnseleted[1] >= col_ed && rowseleted[0] <= row_st && rowseleted[1] >= row_ed || !(columnseleted[1] < col_st || columnseleted[0] > col_ed) && !(rowseleted[1] < row_st || rowseleted[0] > row_ed)) {
374
+ var flowdata = getFlowdata(ctx);
375
+ if (!flowdata) return null;
376
+ var margeset = mergeBorder(ctx, flowdata, mc.r, mc.c);
377
+ if (margeset) {
378
+ var row = margeset.row[1];
379
+ var row_pre = margeset.row[0];
380
+ var col = margeset.column[1];
381
+ var col_pre = margeset.column[0];
382
+ if (!(columnseleted[1] < col_st || columnseleted[0] > col_ed)) {
383
+ if (rowseleted[0] <= row_ed && rowseleted[0] >= row_st) {
384
+ height += top - row_pre;
385
+ top = row_pre;
386
+ rowseleted[0] = row_st;
387
+ }
388
+ if (rowseleted[1] >= row_st && rowseleted[1] <= row_ed) {
389
+ if (s.row_focus >= row_st && s.row_focus <= row_ed) {
390
+ height = row - top;
391
+ } else {
392
+ height = row - top;
393
+ }
394
+ rowseleted[1] = row_ed;
395
+ }
396
+ }
397
+ if (!(rowseleted[1] < row_st || rowseleted[0] > row_ed)) {
398
+ if (columnseleted[0] <= col_ed && columnseleted[0] >= col_st) {
399
+ width += left - col_pre;
400
+ left = col_pre;
401
+ columnseleted[0] = col_st;
402
+ }
403
+ if (columnseleted[1] >= col_st && columnseleted[1] <= col_ed) {
404
+ if (s.column_focus >= col_st && s.column_focus <= col_ed) {
405
+ width = col - left;
406
+ } else {
407
+ width = col - left;
408
+ }
409
+ columnseleted[1] = col_ed;
410
+ }
411
+ }
412
+ ismatch = true;
413
+ }
414
+ }
415
+ if (ismatch) {
416
+ return [columnseleted, rowseleted, top, height, left, width];
417
+ }
418
+ return null;
419
+ }
420
+ export function mergeMoveMain(ctx, columnseleted, rowseleted, s, top, height, left, width) {
421
+ var mergesetting = ctx.config.merge;
422
+ if (!mergesetting) {
423
+ return null;
424
+ }
425
+ var mcset = Object.keys(mergesetting);
426
+ rowseleted[1] = Math.max(rowseleted[0], rowseleted[1]);
427
+ columnseleted[1] = Math.max(columnseleted[0], columnseleted[1]);
428
+ var offloop = true;
429
+ var mergeMoveData = {};
430
+ while (offloop) {
431
+ offloop = false;
432
+ for (var i = 0; i < mcset.length; i += 1) {
433
+ var key = mcset[i];
434
+ var mc = mergesetting[key];
435
+ if (key in mergeMoveData) {
436
+ continue;
437
+ }
438
+ var changeparam = mergeMove(ctx, mc, columnseleted, rowseleted, s, top, height, left, width);
439
+ if (changeparam != null) {
440
+ mergeMoveData[key] = mc;
441
+ columnseleted = changeparam[0], rowseleted = changeparam[1], top = changeparam[2], height = changeparam[3], left = changeparam[4], width = changeparam[5];
442
+ offloop = true;
443
+ } else {
444
+ delete mergeMoveData[key];
445
+ }
446
+ }
447
+ }
448
+ return [columnseleted, rowseleted, top, height, left, width];
449
+ }
450
+ export function cancelFunctionrangeSelected(ctx) {
451
+ if (ctx.formulaCache.selectingRangeIndex === -1) {
452
+ ctx.formulaRangeSelect = undefined;
453
+ }
454
+ }
455
+ export function cancelNormalSelected(ctx) {
456
+ cancelFunctionrangeSelected(ctx);
457
+ ctx.luckysheetCellUpdate = [];
458
+ ctx.formulaRangeHighlight = [];
459
+ ctx.functionHint = null;
460
+ ctx.formulaCache.rangestart = false;
461
+ ctx.formulaCache.rangedrag_column_start = false;
462
+ ctx.formulaCache.rangedrag_row_start = false;
463
+ }
464
+ export function updateCell(ctx, r, c, $input, value, canvas) {
465
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
466
+ var inputText = $input === null || $input === void 0 ? void 0 : $input.innerText;
467
+ var inputHtml = $input === null || $input === void 0 ? void 0 : $input.innerHTML;
468
+ var flowdata = getFlowdata(ctx);
469
+ if (!flowdata) return;
470
+ var index = getSheetIndex(ctx, ctx.currentSheetId);
471
+ var dataVerification = ctx.luckysheetfile[index].dataVerification;
472
+ if (!_.isNil(dataVerification)) {
473
+ var dvItem = dataVerification["".concat(r, "_").concat(c)];
474
+ if (!_.isNil(dvItem) && dvItem.prohibitInput && !validateCellData(ctx, dvItem, inputText)) {
475
+ var failureText = getFailureText(ctx, dvItem);
476
+ cancelNormalSelected(ctx);
477
+ ctx.warnDialog = failureText;
478
+ return;
479
+ }
480
+ }
481
+ var curv = flowdata[r][c];
482
+ var oldValue = _.cloneDeep(curv);
483
+ var isPrevInline = isInlineStringCell(curv);
484
+ var isCurInline = (inputText === null || inputText === void 0 ? void 0 : inputText.slice(0, 1)) !== "=" && (inputHtml === null || inputHtml === void 0 ? void 0 : inputHtml.substring(0, 5)) === "<span";
485
+ var isCopyVal = false;
486
+ if (!isCurInline && inputText && inputText.length > 0) {
487
+ var splitArr = inputText.replace(/\r\n/g, "_x000D_").replace(/&#13;&#10;/g, "_x000D_").replace(/\r/g, "_x000D_").replace(/\n/g, "_x000D_").split("_x000D_");
488
+ if (splitArr.length > 1 && inputHtml !== "<br>") {
489
+ isCopyVal = true;
490
+ isCurInline = true;
491
+ inputText = splitArr.join("\r\n");
492
+ }
493
+ }
494
+ if ((curv === null || curv === void 0 ? void 0 : curv.ct) && !value && !isCurInline && isPrevInline) {
495
+ delete curv.ct.s;
496
+ curv.ct.t = "g";
497
+ curv.ct.fa = "General";
498
+ curv.tb = "1";
499
+ value = "";
500
+ } else if (isCurInline) {
501
+ if (!_.isPlainObject(curv)) {
502
+ curv = {};
503
+ }
504
+ curv || (curv = {});
505
+ var fontSize = curv.fs || 10;
506
+ if (!curv.ct) {
507
+ curv.ct = {};
508
+ curv.ct.fa = "General";
509
+ curv.tb = "1";
510
+ }
511
+ curv.ct.t = "inlineStr";
512
+ curv.ct.s = convertSpanToShareString($input.querySelectorAll("span"), curv);
513
+ delete curv.fs;
514
+ delete curv.f;
515
+ delete curv.v;
516
+ delete curv.m;
517
+ curv.fs = fontSize;
518
+ if (isCopyVal) {
519
+ curv.ct.s = [{
520
+ v: inputText,
521
+ fs: fontSize
522
+ }];
523
+ }
524
+ }
525
+ value = value || ($input === null || $input === void 0 ? void 0 : $input.innerText);
526
+ if (((_b = (_a = ctx.hooks).beforeUpdateCell) === null || _b === void 0 ? void 0 : _b.call(_a, r, c, value)) === false) {
527
+ cancelNormalSelected(ctx);
528
+ return;
529
+ }
530
+ if (!isCurInline) {
531
+ if (isRealNull(value) && !isPrevInline) {
532
+ if (!curv || isRealNull(curv.v) && !curv.spl && !curv.f) {
533
+ cancelNormalSelected(ctx);
534
+ return;
535
+ }
536
+ } else if (curv && curv.qp !== 1) {
537
+ if (_.isPlainObject(curv) && (value === curv.f || value === curv.v || value === curv.m)) {
538
+ cancelNormalSelected(ctx);
539
+ return;
540
+ }
541
+ if (value === curv) {
542
+ cancelNormalSelected(ctx);
543
+ return;
544
+ }
545
+ }
546
+ if (_.isString(value) && value.slice(0, 1) === "=" && value.length > 1) {} else if (_.isPlainObject(curv) && curv && curv.ct && curv.ct.fa && curv.ct.fa !== "@" && !isRealNull(value)) {
547
+ delete curv.m;
548
+ if (curv.f) {
549
+ delete curv.f;
550
+ delete curv.spl;
551
+ }
552
+ }
553
+ }
554
+ var isRunExecFunction = true;
555
+ var d = flowdata;
556
+ var dynamicArrayItem = null;
557
+ if (_.isPlainObject(curv)) {
558
+ if (!isCurInline) {
559
+ if (_.isString(value) && value.slice(0, 1) === "=" && value.length > 1) {
560
+ var v = execfunction(ctx, value, r, c, undefined, undefined, true);
561
+ isRunExecFunction = false;
562
+ curv = _.cloneDeep(((_c = d === null || d === void 0 ? void 0 : d[r]) === null || _c === void 0 ? void 0 : _c[c]) || {});
563
+ curv.v = v[1], curv.f = v[2];
564
+ if (v.length === 4 && v[3].type === "sparklines") {
565
+ delete curv.m;
566
+ delete curv.v;
567
+ var curCalv = v[3].data;
568
+ if (_.isArray(curCalv) && !_.isPlainObject(curCalv[0])) {
569
+ curv.v = curCalv[0];
570
+ } else {
571
+ curv.spl = v[3].data;
572
+ }
573
+ } else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
574
+ dynamicArrayItem = v[3].data;
575
+ }
576
+ } else if (_.isPlainObject(value)) {
577
+ var valueFunction = value.f;
578
+ if (_.isString(valueFunction) && valueFunction.slice(0, 1) === "=" && valueFunction.length > 1) {
579
+ var v = execfunction(ctx, valueFunction, r, c, undefined, undefined, true);
580
+ isRunExecFunction = false;
581
+ curv = _.cloneDeep(((_d = d === null || d === void 0 ? void 0 : d[r]) === null || _d === void 0 ? void 0 : _d[c]) || {});
582
+ curv.v = v[1], curv.f = v[2];
583
+ if (v.length === 4 && v[3].type === "sparklines") {
584
+ delete curv.m;
585
+ delete curv.v;
586
+ var curCalv = v[3].data;
587
+ if (_.isArray(curCalv) && !_.isPlainObject(curCalv[0])) {
588
+ curv.v = curCalv[0];
589
+ } else {
590
+ curv.spl = v[3].data;
591
+ }
592
+ } else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
593
+ dynamicArrayItem = v[3].data;
594
+ }
595
+ } else {
596
+ Object.keys(value).forEach(function (attr) {
597
+ curv[attr] = value[attr];
598
+ });
599
+ }
600
+ } else {
601
+ delFunctionGroup(ctx, r, c);
602
+ execFunctionGroup(ctx, r, c, value);
603
+ isRunExecFunction = false;
604
+ curv = _.cloneDeep(((_e = d === null || d === void 0 ? void 0 : d[r]) === null || _e === void 0 ? void 0 : _e[c]) || {});
605
+ curv.v = value;
606
+ delete curv.f;
607
+ delete curv.spl;
608
+ if (curv.qp === 1 && "".concat(value).substring(0, 1) !== "'") {
609
+ curv.qp = 0;
610
+ if (curv.ct) {
611
+ curv.ct.fa = "General";
612
+ curv.ct.t = "n";
613
+ }
614
+ }
615
+ }
616
+ }
617
+ value = curv;
618
+ } else {
619
+ if (_.isString(value) && value.slice(0, 1) === "=" && value.length > 1) {
620
+ var v = execfunction(ctx, value, r, c, undefined, undefined, true);
621
+ isRunExecFunction = false;
622
+ value = {
623
+ v: v[1],
624
+ f: v[2]
625
+ };
626
+ if (v.length === 4 && v[3].type === "sparklines") {
627
+ var curCalv = v[3].data;
628
+ if (_.isArray(curCalv) && !_.isPlainObject(curCalv[0])) {
629
+ value.v = curCalv[0];
630
+ } else {
631
+ value.spl = v[3].data;
632
+ }
633
+ } else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
634
+ dynamicArrayItem = v[3].data;
635
+ }
636
+ } else if (_.isPlainObject(value)) {
637
+ var valueFunction = value.f;
638
+ if (_.isString(valueFunction) && valueFunction.slice(0, 1) === "=" && valueFunction.length > 1) {
639
+ var v = execfunction(ctx, valueFunction, r, c, undefined, undefined, true);
640
+ isRunExecFunction = false;
641
+ value.v = v[1], value.f = v[2];
642
+ if (v.length === 4 && v[3].type === "sparklines") {
643
+ var curCalv = v[3].data;
644
+ if (_.isArray(curCalv) && !_.isPlainObject(curCalv[0])) {
645
+ value.v = curCalv[0];
646
+ } else {
647
+ value.spl = v[3].data;
648
+ }
649
+ } else if (v.length === 4 && v[3].type === "dynamicArrayItem") {
650
+ dynamicArrayItem = v[3].data;
651
+ }
652
+ } else {
653
+ var v = curv;
654
+ if (_.isNil(value.v)) {
655
+ value.v = v;
656
+ }
657
+ }
658
+ } else {
659
+ delFunctionGroup(ctx, r, c);
660
+ execFunctionGroup(ctx, r, c, value);
661
+ isRunExecFunction = false;
662
+ }
663
+ }
664
+ setCellValue(ctx, r, c, d, value);
665
+ cancelNormalSelected(ctx);
666
+ if ((curv === null || curv === void 0 ? void 0 : curv.tb) === "2" && curv.v || isInlineStringCell(d[r][c])) {
667
+ var defaultrowlen = ctx.defaultrowlen;
668
+ var cfg = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].config || {};
669
+ if (!(((_f = cfg.columnlen) === null || _f === void 0 ? void 0 : _f[c]) && ((_g = cfg.rowlen) === null || _g === void 0 ? void 0 : _g[r]))) {
670
+ var cellWidth = ((_h = cfg.columnlen) === null || _h === void 0 ? void 0 : _h[c]) || ctx.defaultcollen;
671
+ var textInfo = canvas ? getCellTextInfo(d[r][c], canvas, ctx, {
672
+ r: r,
673
+ c: c,
674
+ cellWidth: cellWidth
675
+ }) : null;
676
+ var currentRowLen = defaultrowlen;
677
+ if (textInfo) {
678
+ currentRowLen = textInfo.textHeightAll + 2;
679
+ }
680
+ var previousRowHeight = getRowHeight(ctx, [r])[r];
681
+ if (currentRowLen > defaultrowlen && !((_j = cfg.customHeight) === null || _j === void 0 ? void 0 : _j[r]) && previousRowHeight < currentRowLen) {
682
+ if (_.isNil(cfg.rowlen)) cfg.rowlen = {};
683
+ cfg.rowlen[r] = currentRowLen;
684
+ }
685
+ }
686
+ }
687
+ if (ctx.hooks.afterUpdateCell) {
688
+ var newValue_1 = _.cloneDeep(flowdata[r][c]);
689
+ var afterUpdateCell_1 = ctx.hooks.afterUpdateCell;
690
+ setTimeout(function () {
691
+ afterUpdateCell_1 === null || afterUpdateCell_1 === void 0 ? void 0 : afterUpdateCell_1(r, c, oldValue, newValue_1);
692
+ });
693
+ }
694
+ ctx.formulaCache.execFunctionGlobalData = null;
695
+ }
696
+ export function getOrigincell(ctx, r, c, i) {
697
+ var data = getFlowdata(ctx, i);
698
+ if (_.isNil(r) || _.isNil(c)) {
699
+ return null;
700
+ }
701
+ if (!data || !data[r] || !data[r][c]) {
702
+ return null;
703
+ }
704
+ return data[r][c];
705
+ }
706
+ export function getcellFormula(ctx, r, c, i, data) {
707
+ var cell;
708
+ if (_.isNil(data)) {
709
+ cell = getOrigincell(ctx, r, c, i);
710
+ } else {
711
+ cell = data[r][c];
712
+ }
713
+ if (_.isNil(cell)) {
714
+ return null;
715
+ }
716
+ return cell.f;
717
+ }
718
+ export function getRange(ctx) {
719
+ var rangeArr = _.cloneDeep(ctx.luckysheet_select_save);
720
+ var result = [];
721
+ if (!rangeArr) return result;
722
+ for (var i = 0; i < rangeArr.length; i += 1) {
723
+ var rangeItem = rangeArr[i];
724
+ var temp = {
725
+ row: rangeItem.row,
726
+ column: rangeItem.column
727
+ };
728
+ result.push(temp);
729
+ }
730
+ return result;
731
+ }
732
+ export function getFlattenedRange(ctx, range) {
733
+ range = range || getRange(ctx);
734
+ var result = [];
735
+ range.forEach(function (ele) {
736
+ var rs = ele.row;
737
+ var cs = ele.column;
738
+ for (var r = rs[0]; r <= rs[1]; r += 1) {
739
+ for (var c = cs[0]; c <= cs[1]; c += 1) {
740
+ result.push({
741
+ r: r,
742
+ c: c
743
+ });
744
+ }
745
+ }
746
+ });
747
+ return result;
748
+ }
749
+ export function getRangetxt(ctx, sheetId, range, currentId) {
750
+ var sheettxt = "";
751
+ if (currentId == null) {
752
+ currentId = ctx.currentSheetId;
753
+ }
754
+ if (sheetId !== currentId) {
755
+ var index = getSheetIndex(ctx, sheetId);
756
+ if (index == null) return "";
757
+ sheettxt = ctx.luckysheetfile[index].name.replace(/'/g, "''");
758
+ if (/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/.test(sheettxt)) {
759
+ sheettxt += "!";
760
+ } else {
761
+ sheettxt = "'".concat(sheettxt, "'!");
762
+ }
763
+ }
764
+ var row0 = range.row[0];
765
+ var row1 = range.row[1];
766
+ var column0 = range.column[0];
767
+ var column1 = range.column[1];
768
+ if (row0 == null && row1 == null) {
769
+ return "".concat(sheettxt + indexToColumnChar(column0), ":").concat(indexToColumnChar(column1));
770
+ }
771
+ if (column0 == null && column1 == null) {
772
+ return "".concat(sheettxt + (row0 + 1), ":").concat(row1 + 1);
773
+ }
774
+ if (column0 === column1 && row0 === row1) {
775
+ return sheettxt + indexToColumnChar(column0) + (row0 + 1);
776
+ }
777
+ return "".concat(sheettxt + indexToColumnChar(column0) + (row0 + 1), ":").concat(indexToColumnChar(column1)).concat(row1 + 1);
778
+ }
779
+ export function getRangeByTxt(ctx, txt) {
780
+ var range = [];
781
+ if (txt.indexOf(",") !== -1) {
782
+ var arr = txt.split(",");
783
+ for (var i = 0; i < arr.length; i += 1) {
784
+ if (iscelldata(arr[i])) {
785
+ range.push(getcellrange(ctx, arr[i]));
786
+ } else {
787
+ range = [];
788
+ break;
789
+ }
790
+ }
791
+ } else {
792
+ if (iscelldata(txt)) {
793
+ range.push(getcellrange(ctx, txt));
794
+ }
795
+ }
796
+ return range;
797
+ }
798
+ export function isAllSelectedCellsInStatus(ctx, attr, status) {
799
+ var _a, _b, _c, _d;
800
+ if (!_.isEmpty(ctx.luckysheetCellUpdate)) {
801
+ var w = window.getSelection();
802
+ if (!w) return false;
803
+ if (w.rangeCount === 0) return false;
804
+ var range = w.getRangeAt(0);
805
+ if (range.collapsed === true) {
806
+ return false;
807
+ }
808
+ var endContainer = range.endContainer;
809
+ var startContainer = range.startContainer;
810
+ var cssField_1 = _.camelCase(attrToCssName[attr]);
811
+ if (startContainer === endContainer) {
812
+ return !_.isEmpty((_a = startContainer.parentElement) === null || _a === void 0 ? void 0 : _a.style[cssField_1]);
813
+ }
814
+ if (((_b = startContainer.parentElement) === null || _b === void 0 ? void 0 : _b.tagName) === "SPAN" && ((_c = endContainer.parentElement) === null || _c === void 0 ? void 0 : _c.tagName) === "SPAN") {
815
+ var startSpan = startContainer.parentNode;
816
+ var endSpan = endContainer.parentNode;
817
+ var allSpans = (_d = startSpan === null || startSpan === void 0 ? void 0 : startSpan.parentNode) === null || _d === void 0 ? void 0 : _d.querySelectorAll("span");
818
+ if (allSpans) {
819
+ var startSpanIndex = _.indexOf(allSpans, startSpan);
820
+ var endSpanIndex = _.indexOf(allSpans, endSpan);
821
+ var rangeSpans = [];
822
+ for (var i = startSpanIndex; i <= endSpanIndex; i += 1) {
823
+ rangeSpans.push(allSpans[i]);
824
+ }
825
+ return _.every(rangeSpans, function (s) {
826
+ return !_.isEmpty(s.style[cssField_1]);
827
+ });
828
+ }
829
+ }
830
+ }
831
+ var cells = getFlattenedRange(ctx);
832
+ var flowdata = getFlowdata(ctx);
833
+ return cells.every(function (_a) {
834
+ var _b;
835
+ var r = _a.r,
836
+ c = _a.c;
837
+ var cell = (_b = flowdata === null || flowdata === void 0 ? void 0 : flowdata[r]) === null || _b === void 0 ? void 0 : _b[c];
838
+ if (_.isNil(cell)) {
839
+ return false;
840
+ }
841
+ return cell[attr] === status;
842
+ });
843
+ }
844
+ export function getFontStyleByCell(cell, checksAF, checksCF, isCheck) {
845
+ if (isCheck === void 0) {
846
+ isCheck = true;
847
+ }
848
+ var style = {};
849
+ if (!cell) {
850
+ return style;
851
+ }
852
+ _.forEach(cell, function (v, key) {
853
+ var _a, _b, _c, _d;
854
+ var value = cell[key];
855
+ if (isCheck) {
856
+ value = normalizedCellAttr(cell, key);
857
+ }
858
+ var valueNum = Number(value);
859
+ if (key === "bl" && valueNum !== 0) {
860
+ style.fontWeight = "bold";
861
+ }
862
+ if (key === "it" && valueNum !== 0) {
863
+ style.fontStyle = "italic";
864
+ }
865
+ if (key === "fs" && valueNum !== 10) {
866
+ style.fontSize = "".concat(valueNum, "pt");
867
+ }
868
+ if (key === "fc" && value !== "#000000" || ((_a = checksAF === null || checksAF === void 0 ? void 0 : checksAF.length) !== null && _a !== void 0 ? _a : 0) > 0 || (checksCF === null || checksCF === void 0 ? void 0 : checksCF.textColor)) {
869
+ if (checksCF === null || checksCF === void 0 ? void 0 : checksCF.textColor) {
870
+ style.color = checksCF.textColor;
871
+ } else if (((_b = checksAF === null || checksAF === void 0 ? void 0 : checksAF.length) !== null && _b !== void 0 ? _b : 0) > 0) {
872
+ style.color = checksAF[0];
873
+ } else {
874
+ style.color = value;
875
+ }
876
+ }
877
+ if (key === "cl" && valueNum !== 0) {
878
+ style.textDecoration = "line-through";
879
+ }
880
+ if (key === "un" && (valueNum === 1 || valueNum === 3)) {
881
+ var color = (_c = cell._color) !== null && _c !== void 0 ? _c : cell.fc;
882
+ var fs = (_d = cell._fontSize) !== null && _d !== void 0 ? _d : cell.fs;
883
+ style.borderBottom = "".concat(Math.floor(fs / 9), "px solid ").concat(color);
884
+ }
885
+ });
886
+ return style;
887
+ }
888
+ export function getStyleByCell(ctx, d, r, c) {
889
+ var _a;
890
+ var style = {};
891
+ var checksAF = [];
892
+ var cf_compute = getComputeMap(ctx);
893
+ var checksCF = checkCF(r, c, cf_compute);
894
+ var cell = (_a = d === null || d === void 0 ? void 0 : d[r]) === null || _a === void 0 ? void 0 : _a[c];
895
+ if (!cell) return {};
896
+ var isInline = isInlineStringCell(cell);
897
+ if ("bg" in cell) {
898
+ var value = normalizedCellAttr(cell, "bg");
899
+ if (checksCF === null || checksCF === void 0 ? void 0 : checksCF.cellColor) {
900
+ if (checksCF === null || checksCF === void 0 ? void 0 : checksCF.cellColor) {
901
+ style.background = "".concat(checksCF.cellColor);
902
+ } else if (checksAF.length > 1) {
903
+ style.background = "".concat(checksAF[1]);
904
+ } else {
905
+ style.background = "".concat(value);
906
+ }
907
+ }
908
+ }
909
+ if ("ht" in cell) {
910
+ var value = normalizedCellAttr(cell, "ht");
911
+ if (Number(value) === 0) {
912
+ style.textAlign = "center";
913
+ } else if (Number(value) === 2) {
914
+ style.textAlign = "right";
915
+ }
916
+ }
917
+ if ("vt" in cell) {
918
+ var value = normalizedCellAttr(cell, "vt");
919
+ if (Number(value) === 0) {
920
+ style.alignItems = "center";
921
+ } else if (Number(value) === 2) {
922
+ style.alignItems = "flex-end";
923
+ }
924
+ }
925
+ if (!isInline) {
926
+ style = _.assign(style, getFontStyleByCell(cell, checksAF, checksCF));
927
+ }
928
+ return style;
929
+ }
930
+ export function getInlineStringHTML(r, c, data) {
931
+ var ct = getCellValue(r, c, data, "ct");
932
+ if (isInlineStringCT(ct)) {
933
+ var strings = ct.s;
934
+ var value = "";
935
+ for (var i = 0; i < strings.length; i += 1) {
936
+ var strObj = strings[i];
937
+ if (strObj.v) {
938
+ var style = getFontStyleByCell(strObj);
939
+ var styleStr = _.map(style, function (v, key) {
940
+ return "".concat(_.kebabCase(key), ":").concat(_.isNumber(v) ? "".concat(v, "px") : v, ";");
941
+ }).join("");
942
+ value += "<span class=\"luckysheet-input-span\" index='".concat(i, "' style='").concat(styleStr, "'>").concat(strObj.v, "</span>");
943
+ }
944
+ }
945
+ return value;
946
+ }
947
+ return "";
948
+ }
949
+ export function getQKBorder(width, type, color) {
950
+ var bordertype = "";
951
+ if (width.toString().indexOf("pt") > -1) {
952
+ var nWidth = parseFloat(width);
953
+ if (nWidth < 1) {} else if (nWidth < 1.5) {
954
+ bordertype = "Medium";
955
+ } else {
956
+ bordertype = "Thick";
957
+ }
958
+ } else {
959
+ var nWidth = parseFloat(width);
960
+ if (nWidth < 2) {} else if (nWidth < 3) {
961
+ bordertype = "Medium";
962
+ } else {
963
+ bordertype = "Thick";
964
+ }
965
+ }
966
+ var style = 0;
967
+ type = type.toLowerCase();
968
+ if (type === "double") {
969
+ style = 2;
970
+ } else if (type === "dotted") {
971
+ if (bordertype === "Medium" || bordertype === "Thick") {
972
+ style = 3;
973
+ } else {
974
+ style = 10;
975
+ }
976
+ } else if (type === "dashed") {
977
+ if (bordertype === "Medium" || bordertype === "Thick") {
978
+ style = 4;
979
+ } else {
980
+ style = 9;
981
+ }
982
+ } else if (type === "solid") {
983
+ if (bordertype === "Medium") {
984
+ style = 8;
985
+ } else if (bordertype === "Thick") {
986
+ style = 13;
987
+ } else {
988
+ style = 1;
989
+ }
990
+ }
991
+ return [style, color];
992
+ }
993
+ export function getdatabyselection(ctx, range, sheetId) {
994
+ if (range == null && ctx.luckysheet_select_save) {
995
+ range = ctx.luckysheet_select_save[0];
996
+ }
997
+ if (!range) return [];
998
+ if (range.row == null || range.row.length === 0) {
999
+ return [];
1000
+ }
1001
+ var d;
1002
+ var cfg;
1003
+ if (sheetId != null && sheetId !== ctx.currentSheetId) {
1004
+ d = ctx.luckysheetfile[getSheetIndex(ctx, sheetId)].data;
1005
+ cfg = ctx.luckysheetfile[getSheetIndex(ctx, sheetId)].config;
1006
+ } else {
1007
+ d = getFlowdata(ctx);
1008
+ cfg = ctx.config;
1009
+ }
1010
+ var data = [];
1011
+ for (var r = range.row[0]; r <= range.row[1]; r += 1) {
1012
+ if ((d === null || d === void 0 ? void 0 : d[r]) == null) {
1013
+ continue;
1014
+ }
1015
+ if ((cfg === null || cfg === void 0 ? void 0 : cfg.rowhidden) != null && cfg.rowhidden[r] != null) {
1016
+ continue;
1017
+ }
1018
+ var row = [];
1019
+ for (var c = range.column[0]; c <= range.column[1]; c += 1) {
1020
+ if ((cfg === null || cfg === void 0 ? void 0 : cfg.colhidden) != null && cfg.colhidden[c] != null) {
1021
+ continue;
1022
+ }
1023
+ row.push(d[r][c]);
1024
+ }
1025
+ data.push(row);
1026
+ }
1027
+ return data;
1028
+ }
1029
+ export function luckysheetUpdateCell(ctx, row_index, col_index) {
1030
+ ctx.luckysheetCellUpdate = [row_index, col_index];
1031
+ }
1032
+ export function getDataBySelectionNoCopy(ctx, range) {
1033
+ if (!range || !range.row || range.row.length === 0) return [];
1034
+ var data = [];
1035
+ var flowData = getFlowdata(ctx);
1036
+ if (!flowData) return [];
1037
+ for (var r = range.row[0]; r <= range.row[1]; r += 1) {
1038
+ var row = [];
1039
+ if (ctx.config.rowhidden != null && ctx.config.rowhidden[r] != null) {
1040
+ continue;
1041
+ }
1042
+ for (var c = range.column[0]; c <= range.column[1]; c += 1) {
1043
+ var value = null;
1044
+ if (ctx.config.colhidden != null && ctx.config.colhidden[c] != null) {
1045
+ continue;
1046
+ }
1047
+ if (flowData[r] != null && flowData[r][c] != null) {
1048
+ value = flowData[r][c];
1049
+ }
1050
+ row.push(value);
1051
+ }
1052
+ data.push(row);
1053
+ }
1054
+ return data;
1055
+ }