@fileverse-dev/fortune-core 1.1.0 → 1.1.2

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 +71 -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 +198 -197
  22. package/es/context.js +381 -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 +360 -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 +4 -3
  32. package/es/events/paste.js +1416 -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 +993 -992
  36. package/es/locale/en.js +10140 -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 +1092 -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 +701 -0
  65. package/{dist/packages/core/src → es}/modules/dropCell.d.ts +10 -10
  66. package/es/modules/dropCell.js +2267 -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 +2346 -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 +50 -46
  106. package/es/modules/selection.js +1856 -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 +134 -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 +380 -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 +19 -18
  129. package/es/utils/index.js +198 -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 +71 -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 +198 -0
  153. package/lib/context.js +393 -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 +370 -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 +4 -0
  163. package/lib/events/paste.js +1425 -0
  164. package/lib/index.d.ts +10 -0
  165. package/lib/index.js +109 -0
  166. package/lib/locale/en.d.ts +993 -0
  167. package/lib/locale/en.js +10146 -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 +1122 -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 +716 -0
  196. package/lib/modules/dropCell.d.ts +10 -0
  197. package/lib/modules/dropCell.js +2283 -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 +2375 -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 +50 -0
  237. package/lib/modules/selection.js +1889 -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 +143 -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 +380 -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 +19 -0
  260. package/lib/utils/index.js +258 -0
  261. package/lib/utils/patch.d.ts +37 -0
  262. package/lib/utils/patch.js +392 -0
  263. package/package.json +7 -6
  264. package/dist/index.esm.js +0 -80255
  265. package/dist/index.js +0 -80601
  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,123 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ import _ from "lodash";
3
+ import { getdatabyselection, getFlowdata, getRangetxt } from "..";
4
+ import { normalizeSelection, rangeValueToHtml } from "../modules";
5
+ import { setCellFormat, setCellValue } from "./cell";
6
+ import { getSheet } from "./common";
7
+ import { INVALID_PARAMS } from "./errors";
8
+ export function getSelection(ctx) {
9
+ var _a;
10
+ return (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a.map(function (selection) {
11
+ return {
12
+ row: selection.row,
13
+ column: selection.column
14
+ };
15
+ });
16
+ }
17
+ export function getFlattenRange(ctx, range) {
18
+ range = range || getSelection(ctx);
19
+ var result = [];
20
+ range === null || range === void 0 ? void 0 : range.forEach(function (ele) {
21
+ var rs = ele.row;
22
+ var cs = ele.column;
23
+ for (var r = rs[0]; r <= rs[1]; r += 1) {
24
+ for (var c = cs[0]; c <= cs[1]; c += 1) {
25
+ result.push({
26
+ r: r,
27
+ c: c
28
+ });
29
+ }
30
+ }
31
+ });
32
+ return result;
33
+ }
34
+ export function getCellsByFlattenRange(ctx, range) {
35
+ range = range || getFlattenRange(ctx);
36
+ var flowdata = getFlowdata(ctx);
37
+ if (!flowdata) return [];
38
+ return range.map(function (item) {
39
+ var _a;
40
+ return (_a = flowdata[item.r]) === null || _a === void 0 ? void 0 : _a[item.c];
41
+ });
42
+ }
43
+ export function getSelectionCoordinates(ctx) {
44
+ var result = [];
45
+ var rangeArr = _.cloneDeep(ctx.luckysheet_select_save);
46
+ var sheetId = ctx.currentSheetId;
47
+ rangeArr === null || rangeArr === void 0 ? void 0 : rangeArr.forEach(function (ele) {
48
+ var rangeText = getRangetxt(ctx, sheetId, {
49
+ column: ele.column,
50
+ row: ele.row
51
+ });
52
+ result.push(rangeText);
53
+ });
54
+ return result;
55
+ }
56
+ export function getCellsByRange(ctx, range, options) {
57
+ if (options === void 0) {
58
+ options = {};
59
+ }
60
+ var sheet = getSheet(ctx, options);
61
+ if (!range || _typeof(range) === "object") {
62
+ return getdatabyselection(ctx, range, sheet.id);
63
+ }
64
+ throw INVALID_PARAMS;
65
+ }
66
+ export function getHtmlByRange(ctx, range, options) {
67
+ if (options === void 0) {
68
+ options = {};
69
+ }
70
+ var sheet = getSheet(ctx, options);
71
+ return rangeValueToHtml(ctx, sheet.id, range);
72
+ }
73
+ export function setSelection(ctx, range, options) {
74
+ var sheet = getSheet(ctx, options);
75
+ sheet.luckysheet_select_save = normalizeSelection(ctx, range);
76
+ if (ctx.currentSheetId === sheet.id) {
77
+ ctx.luckysheet_select_save = sheet.luckysheet_select_save;
78
+ }
79
+ }
80
+ export function setCellValuesByRange(ctx, data, range, cellInput, options) {
81
+ if (options === void 0) {
82
+ options = {};
83
+ }
84
+ if (data == null) {
85
+ throw INVALID_PARAMS;
86
+ }
87
+ if (range instanceof Array) {
88
+ throw new Error("setCellValuesByRange does not support multiple ranges");
89
+ }
90
+ if (!_.isPlainObject(range)) {
91
+ throw INVALID_PARAMS;
92
+ }
93
+ var rowCount = range.row[1] - range.row[0] + 1;
94
+ var columnCount = range.column[1] - range.column[0] + 1;
95
+ if (data.length !== rowCount || data[0].length !== columnCount) {
96
+ throw new Error("data size does not match range");
97
+ }
98
+ for (var i = 0; i < rowCount; i += 1) {
99
+ for (var j = 0; j < columnCount; j += 1) {
100
+ var row = range.row[0] + i;
101
+ var column = range.column[0] + j;
102
+ setCellValue(ctx, row, column, data[i][j], cellInput, options);
103
+ }
104
+ }
105
+ }
106
+ export function setCellFormatByRange(ctx, attr, value, range, options) {
107
+ if (options === void 0) {
108
+ options = {};
109
+ }
110
+ if (_.isPlainObject(range)) {
111
+ range = [range];
112
+ }
113
+ if (!_.isArray(range)) {
114
+ throw INVALID_PARAMS;
115
+ }
116
+ range.forEach(function (singleRange) {
117
+ for (var r = singleRange.row[0]; r <= singleRange.row[1]; r += 1) {
118
+ for (var c = singleRange.column[0]; c <= singleRange.column[1]; c += 1) {
119
+ setCellFormat(ctx, r, c, attr, value, options);
120
+ }
121
+ }
122
+ });
123
+ }
@@ -1,14 +1,14 @@
1
- import { Context } from "../context";
2
- import { CommonOptions } from "./common";
3
- export declare function freeze(ctx: Context, type: "row" | "column" | "both", range: {
4
- row: number;
5
- column: number;
6
- }, options?: CommonOptions): void;
7
- export declare function insertRowOrColumn(ctx: Context, type: "row" | "column", index: number, count: number, direction: "lefttop" | "rightbottom", options?: CommonOptions): void;
8
- export declare function deleteRowOrColumn(ctx: Context, type: "row" | "column", start: number, end: number, options?: CommonOptions): void;
9
- export declare function hideRowOrColumn(ctx: Context, rowColInfo: string[], type: "row" | "column"): void;
10
- export declare function showRowOrColumn(ctx: Context, rowColInfo: string[], type: "row" | "column"): void;
11
- export declare function setRowHeight(ctx: Context, rowInfo: Record<string, number>, options?: CommonOptions, custom?: boolean): void;
12
- export declare function setColumnWidth(ctx: Context, columnInfo: Record<string, number>, options?: CommonOptions, custom?: boolean): void;
13
- export declare function getRowHeight(ctx: Context, rows: number[], options?: CommonOptions): Record<number, number>;
14
- export declare function getColumnWidth(ctx: Context, columns: number[], options?: CommonOptions): Record<number, number>;
1
+ import { Context } from "../context";
2
+ import { CommonOptions } from "./common";
3
+ export declare function freeze(ctx: Context, type: "row" | "column" | "both", range: {
4
+ row: number;
5
+ column: number;
6
+ }, options?: CommonOptions): void;
7
+ export declare function insertRowOrColumn(ctx: Context, type: "row" | "column", index: number, count: number, direction: "lefttop" | "rightbottom", options?: CommonOptions): void;
8
+ export declare function deleteRowOrColumn(ctx: Context, type: "row" | "column", start: number, end: number, options?: CommonOptions): void;
9
+ export declare function hideRowOrColumn(ctx: Context, rowColInfo: string[], type: "row" | "column"): void;
10
+ export declare function showRowOrColumn(ctx: Context, rowColInfo: string[], type: "row" | "column"): void;
11
+ export declare function setRowHeight(ctx: Context, rowInfo: Record<string, number>, options?: CommonOptions, custom?: boolean): void;
12
+ export declare function setColumnWidth(ctx: Context, columnInfo: Record<string, number>, options?: CommonOptions, custom?: boolean): void;
13
+ export declare function getRowHeight(ctx: Context, rows: number[], options?: CommonOptions): Record<number, number>;
14
+ export declare function getColumnWidth(ctx: Context, columns: number[], options?: CommonOptions): Record<number, number>;
@@ -0,0 +1,207 @@
1
+ import _ from "lodash";
2
+ import { deleteRowCol, insertRowCol } from "../modules";
3
+ import { getSheet } from "./common";
4
+ import { INVALID_PARAMS } from "./errors";
5
+ import { getSheetIndex } from "../utils";
6
+ export function freeze(ctx, type, range, options) {
7
+ if (options === void 0) {
8
+ options = {};
9
+ }
10
+ var sheet = getSheet(ctx, options);
11
+ var typeMap = {
12
+ row: "rangeRow",
13
+ column: "rangeColumn",
14
+ both: "rangeBoth"
15
+ };
16
+ var innerType = typeMap[type];
17
+ sheet.frozen = {
18
+ type: innerType,
19
+ range: {
20
+ column_focus: range.column,
21
+ row_focus: range.row
22
+ }
23
+ };
24
+ }
25
+ export function insertRowOrColumn(ctx, type, index, count, direction, options) {
26
+ if (options === void 0) {
27
+ options = {};
28
+ }
29
+ if (!["row", "column"].includes(type) || !_.isNumber(index) || !_.isNumber(count) || !["lefttop", "rightbottom"].includes(direction)) {
30
+ throw INVALID_PARAMS;
31
+ }
32
+ var sheet = getSheet(ctx, options);
33
+ try {
34
+ insertRowCol(ctx, {
35
+ type: type,
36
+ index: index,
37
+ count: count,
38
+ direction: direction,
39
+ id: sheet.id
40
+ });
41
+ } catch (e) {
42
+ console.error(e);
43
+ }
44
+ }
45
+ export function deleteRowOrColumn(ctx, type, start, end, options) {
46
+ if (options === void 0) {
47
+ options = {};
48
+ }
49
+ if (!["row", "column"].includes(type) || !_.isNumber(start) || !_.isNumber(end)) {
50
+ throw INVALID_PARAMS;
51
+ }
52
+ var sheet = getSheet(ctx, options);
53
+ deleteRowCol(ctx, {
54
+ type: type,
55
+ start: start,
56
+ end: end,
57
+ id: sheet.id
58
+ });
59
+ }
60
+ export function hideRowOrColumn(ctx, rowColInfo, type) {
61
+ var _a, _b;
62
+ if (!["row", "column"].includes(type)) {
63
+ throw INVALID_PARAMS;
64
+ }
65
+ if (!ctx || !ctx.config) return;
66
+ var index = getSheetIndex(ctx, ctx.currentSheetId);
67
+ if (type === "row") {
68
+ var rowhidden_1 = (_a = ctx.config.rowhidden) !== null && _a !== void 0 ? _a : {};
69
+ rowColInfo.forEach(function (r) {
70
+ rowhidden_1[r] = 0;
71
+ });
72
+ ctx.config.rowhidden = rowhidden_1;
73
+ } else if (type === "column") {
74
+ var colhidden_1 = (_b = ctx.config.colhidden) !== null && _b !== void 0 ? _b : {};
75
+ rowColInfo.forEach(function (r) {
76
+ colhidden_1[r] = 0;
77
+ });
78
+ ctx.config.colhidden = colhidden_1;
79
+ }
80
+ ctx.luckysheetfile[index].config = ctx.config;
81
+ }
82
+ export function showRowOrColumn(ctx, rowColInfo, type) {
83
+ var _a, _b;
84
+ if (!["row", "column"].includes(type)) {
85
+ throw INVALID_PARAMS;
86
+ }
87
+ if (!ctx || !ctx.config) return;
88
+ var index = getSheetIndex(ctx, ctx.currentSheetId);
89
+ if (type === "row") {
90
+ var rowhidden_2 = (_a = ctx.config.rowhidden) !== null && _a !== void 0 ? _a : {};
91
+ rowColInfo.forEach(function (r) {
92
+ delete rowhidden_2[r];
93
+ });
94
+ ctx.config.rowhidden = rowhidden_2;
95
+ } else if (type === "column") {
96
+ var colhidden_2 = (_b = ctx.config.colhidden) !== null && _b !== void 0 ? _b : {};
97
+ rowColInfo.forEach(function (r) {
98
+ delete colhidden_2[r];
99
+ });
100
+ ctx.config.colhidden = colhidden_2;
101
+ }
102
+ ctx.luckysheetfile[index].config = ctx.config;
103
+ }
104
+ export function setRowHeight(ctx, rowInfo, options, custom) {
105
+ if (options === void 0) {
106
+ options = {};
107
+ }
108
+ if (custom === void 0) {
109
+ custom = false;
110
+ }
111
+ if (!_.isPlainObject(rowInfo)) {
112
+ throw INVALID_PARAMS;
113
+ }
114
+ var sheet = getSheet(ctx, options);
115
+ var cfg = sheet.config || {};
116
+ if (cfg.rowlen == null) {
117
+ cfg.rowlen = {};
118
+ }
119
+ _.forEach(rowInfo, function (len, r) {
120
+ var _a;
121
+ if (Number(r) >= 0) {
122
+ if (Number(len) >= 0) {
123
+ cfg.rowlen[Number(r)] = Number(len);
124
+ if (custom && _.isUndefined(cfg.customHeight)) {
125
+ cfg.customHeight = (_a = {}, _a[r] = 1, _a);
126
+ } else if (custom) {
127
+ cfg.customHeight[r] = 1;
128
+ }
129
+ }
130
+ }
131
+ });
132
+ sheet.config = cfg;
133
+ if (ctx.currentSheetId === sheet.id) {
134
+ ctx.config = cfg;
135
+ }
136
+ }
137
+ export function setColumnWidth(ctx, columnInfo, options, custom) {
138
+ if (options === void 0) {
139
+ options = {};
140
+ }
141
+ if (custom === void 0) {
142
+ custom = false;
143
+ }
144
+ if (!_.isPlainObject(columnInfo)) {
145
+ throw INVALID_PARAMS;
146
+ }
147
+ var sheet = getSheet(ctx, options);
148
+ var cfg = sheet.config || {};
149
+ if (cfg.columnlen == null) {
150
+ cfg.columnlen = {};
151
+ }
152
+ _.forEach(columnInfo, function (len, c) {
153
+ var _a;
154
+ if (Number(c) >= 0) {
155
+ if (Number(len) >= 0) {
156
+ cfg.columnlen[Number(c)] = Number(len);
157
+ if (custom && _.isUndefined(cfg.customWidth)) {
158
+ cfg.customWidth = (_a = {}, _a[c] = 1, _a);
159
+ } else if (custom) {
160
+ cfg.customWidth[c] = 1;
161
+ }
162
+ }
163
+ }
164
+ });
165
+ sheet.config = cfg;
166
+ if (ctx.currentSheetId === sheet.id) {
167
+ ctx.config = cfg;
168
+ }
169
+ }
170
+ export function getRowHeight(ctx, rows, options) {
171
+ if (options === void 0) {
172
+ options = {};
173
+ }
174
+ if (!_.isArray(rows) || rows.length === 0) {
175
+ throw INVALID_PARAMS;
176
+ }
177
+ var sheet = getSheet(ctx, options);
178
+ var cfg = sheet.config || {};
179
+ var rowlen = cfg.rowlen || {};
180
+ var rowlenObj = {};
181
+ rows.forEach(function (item) {
182
+ if (Number(item) >= 0) {
183
+ var size = rowlen[Number(item)] || ctx.defaultrowlen;
184
+ rowlenObj[Number(item)] = size;
185
+ }
186
+ });
187
+ return rowlenObj;
188
+ }
189
+ export function getColumnWidth(ctx, columns, options) {
190
+ if (options === void 0) {
191
+ options = {};
192
+ }
193
+ if (!_.isArray(columns) || columns.length === 0) {
194
+ throw INVALID_PARAMS;
195
+ }
196
+ var sheet = getSheet(ctx, options);
197
+ var cfg = sheet.config || {};
198
+ var columnlen = cfg.columnlen || {};
199
+ var columnlenObj = {};
200
+ columns.forEach(function (item) {
201
+ if (Number(item) >= 0) {
202
+ var size = columnlen[Number(item)] || ctx.defaultcollen;
203
+ columnlenObj[Number(item)] = size;
204
+ }
205
+ });
206
+ return columnlenObj;
207
+ }
@@ -1,10 +1,10 @@
1
- import { getSheet } from "./common";
2
- import { Context } from "../context";
3
- import { CellMatrix, Sheet } from "../types";
4
- export declare function getAllSheets(ctx: Context): Sheet[];
5
- export { getSheet };
6
- export declare function initSheetData(draftCtx: Context, index: number, newData: Sheet): CellMatrix | null;
7
- export declare function hideSheet(ctx: Context, sheetId: string): void;
8
- export declare function showSheet(ctx: Context, sheetId: string): void;
9
- export declare function copySheet(ctx: Context, sheetId: string): void;
10
- export declare function calculateSheetFromula(ctx: Context, id: string): void;
1
+ import { getSheet } from "./common";
2
+ import { Context } from "../context";
3
+ import { CellMatrix, Sheet } from "../types";
4
+ export declare function getAllSheets(ctx: Context): Sheet[];
5
+ export { getSheet };
6
+ export declare function initSheetData(draftCtx: Context, index: number, newData: Sheet): CellMatrix | null;
7
+ export declare function hideSheet(ctx: Context, sheetId: string): void;
8
+ export declare function showSheet(ctx: Context, sheetId: string): void;
9
+ export declare function copySheet(ctx: Context, sheetId: string): void;
10
+ export declare function calculateSheetFromula(ctx: Context, id: string): void;
@@ -0,0 +1,128 @@
1
+ import _ from "lodash";
2
+ import { v4 as uuidv4 } from "uuid";
3
+ import { dataToCelldata, getSheet } from "./common";
4
+ import { getSheetIndex } from "../utils";
5
+ import { api, execfunction, insertUpdateFunctionGroup, locale } from "..";
6
+ export function getAllSheets(ctx) {
7
+ return ctx.luckysheetfile;
8
+ }
9
+ export { getSheet };
10
+ export function initSheetData(draftCtx, index, newData) {
11
+ var _a, _b;
12
+ var celldata = newData.celldata,
13
+ row = newData.row,
14
+ column = newData.column;
15
+ var lastRow = _.maxBy(celldata, "r");
16
+ var lastCol = _.maxBy(celldata, "c");
17
+ var lastRowNum = ((_a = lastRow === null || lastRow === void 0 ? void 0 : lastRow.r) !== null && _a !== void 0 ? _a : 0) + 1;
18
+ var lastColNum = ((_b = lastCol === null || lastCol === void 0 ? void 0 : lastCol.c) !== null && _b !== void 0 ? _b : 0) + 1;
19
+ if (row != null && column != null && row > 0 && column > 0) {
20
+ lastRowNum = Math.max(lastRowNum, row);
21
+ lastColNum = Math.max(lastColNum, column);
22
+ } else {
23
+ lastRowNum = Math.max(lastRowNum, draftCtx.defaultrowNum);
24
+ lastColNum = Math.max(lastColNum, draftCtx.defaultcolumnNum);
25
+ }
26
+ if (lastRowNum && lastColNum) {
27
+ var expandedData_1 = _.times(lastRowNum, function () {
28
+ return _.times(lastColNum, function () {
29
+ return null;
30
+ });
31
+ });
32
+ celldata === null || celldata === void 0 ? void 0 : celldata.forEach(function (d) {
33
+ expandedData_1[d.r][d.c] = d.v;
34
+ });
35
+ if (draftCtx.luckysheetfile[index] == null) {
36
+ newData.data = expandedData_1;
37
+ delete newData.celldata;
38
+ draftCtx.luckysheetfile.push(newData);
39
+ } else {
40
+ draftCtx.luckysheetfile[index].data = expandedData_1;
41
+ delete draftCtx.luckysheetfile[index].celldata;
42
+ }
43
+ return expandedData_1;
44
+ }
45
+ return null;
46
+ }
47
+ export function hideSheet(ctx, sheetId) {
48
+ var index = getSheetIndex(ctx, sheetId);
49
+ ctx.luckysheetfile[index].hide = 1;
50
+ ctx.luckysheetfile[index].status = 0;
51
+ var shownSheets = ctx.luckysheetfile.filter(function (sheet) {
52
+ return _.isUndefined(sheet.hide) || (sheet === null || sheet === void 0 ? void 0 : sheet.hide) !== 1;
53
+ });
54
+ ctx.currentSheetId = shownSheets[0].id;
55
+ }
56
+ export function showSheet(ctx, sheetId) {
57
+ var index = getSheetIndex(ctx, sheetId);
58
+ ctx.luckysheetfile[index].hide = undefined;
59
+ }
60
+ function generateCopySheetName(ctx, sheetId) {
61
+ var info = locale(ctx).info;
62
+ var copyWord = "(".concat(info.copy);
63
+ var SheetIndex = getSheetIndex(ctx, sheetId);
64
+ var sheetName = ctx.luckysheetfile[SheetIndex].name;
65
+ var copy_i = sheetName.indexOf(copyWord);
66
+ var index = 0;
67
+ if (copy_i !== -1) {
68
+ sheetName = sheetName.toString().substring(0, copy_i);
69
+ }
70
+ var nameCopy = sheetName + copyWord;
71
+ var sheetNames = [];
72
+ for (var i = 0; i < ctx.luckysheetfile.length; i += 1) {
73
+ var fileName = ctx.luckysheetfile[i].name;
74
+ sheetNames.push(fileName);
75
+ var st_i = fileName.indexOf(nameCopy);
76
+ if (st_i === 0) {
77
+ index = index || 2;
78
+ var ed_i = fileName.indexOf(")", st_i + nameCopy.length);
79
+ var num = fileName.substring(st_i + nameCopy.length, ed_i);
80
+ if (_.isNumber(num)) {
81
+ if (Number.parseInt(num, 10) >= index) {
82
+ index = Number.parseInt(num, 10) + 1;
83
+ }
84
+ }
85
+ }
86
+ }
87
+ var sheetCopyName;
88
+ do {
89
+ var postfix = "".concat(copyWord + (index || ""), ")");
90
+ var lengthLimit = 31 - postfix.length;
91
+ sheetCopyName = sheetName;
92
+ if (sheetCopyName.length > lengthLimit) {
93
+ sheetCopyName = "".concat(sheetCopyName.slice(0, lengthLimit - 1), "\u2026");
94
+ }
95
+ sheetCopyName += postfix;
96
+ index = (index || 1) + 1;
97
+ } while (sheetNames.indexOf(sheetCopyName) !== -1);
98
+ return sheetCopyName;
99
+ }
100
+ export function copySheet(ctx, sheetId) {
101
+ var index = getSheetIndex(ctx, sheetId);
102
+ var order = ctx.luckysheetfile[index].order + 1;
103
+ var sheetName = generateCopySheetName(ctx, sheetId);
104
+ var sheetData = _.cloneDeep(ctx.luckysheetfile[index]);
105
+ delete sheetData.id;
106
+ delete sheetData.status;
107
+ sheetData.celldata = dataToCelldata(sheetData.data);
108
+ delete sheetData.data;
109
+ api.addSheet(ctx, undefined, uuidv4(), ctx.luckysheetfile[index].isPivotTable, sheetName, sheetData);
110
+ var sheetOrderList = {};
111
+ sheetOrderList[ctx.luckysheetfile[ctx.luckysheetfile.length - 1].id] = order;
112
+ api.setSheetOrder(ctx, sheetOrderList);
113
+ }
114
+ export function calculateSheetFromula(ctx, id) {
115
+ var _a, _b, _c;
116
+ var index = getSheetIndex(ctx, id);
117
+ if (!ctx.luckysheetfile[index].data) return;
118
+ for (var r = 0; r < ctx.luckysheetfile[index].data.length; r += 1) {
119
+ for (var c = 0; c < ctx.luckysheetfile[index].data[r].length; c += 1) {
120
+ if (!((_a = ctx.luckysheetfile[index].data[r][c]) === null || _a === void 0 ? void 0 : _a.f) || ((_b = ctx.luckysheetfile[index].data[r][c]) === null || _b === void 0 ? void 0 : _b.isDataBlockFormula)) {
121
+ continue;
122
+ }
123
+ var result = execfunction(ctx, (_c = ctx.luckysheetfile[index].data[r][c]) === null || _c === void 0 ? void 0 : _c.f, r, c, id);
124
+ api.setCellValue(ctx, r, c, result[1], null);
125
+ insertUpdateFunctionGroup(ctx, r, c, id);
126
+ }
127
+ }
128
+ }
@@ -1,15 +1,15 @@
1
- import { Context, Sheet } from "..";
2
- import { Settings } from "../settings";
3
- import { CommonOptions } from "./common";
4
- export declare function addSheet(ctx: Context, settings?: Required<Settings>, newSheetID?: string, isPivotTable?: boolean, sheetname?: string | undefined, sheetData?: Sheet | undefined): void;
5
- export declare function deleteSheet(ctx: Context, options?: CommonOptions): void;
6
- export declare function updateSheet(ctx: Context, data: Sheet[]): void;
7
- export declare function activateSheet(ctx: Context, options?: CommonOptions): void;
8
- export declare function setSheetName(ctx: Context, name: string, options?: CommonOptions): void;
9
- export declare function setSheetOrder(ctx: Context, orderList: Record<string, number>): void;
10
- export declare function scroll(ctx: Context, scrollbarX: HTMLDivElement | null, scrollbarY: HTMLDivElement | null, options: {
11
- scrollLeft?: number;
12
- scrollTop?: number;
13
- targetRow?: number;
14
- targetColumn?: number;
15
- }): void;
1
+ import { Context, Sheet } from "..";
2
+ import { Settings } from "../settings";
3
+ import { CommonOptions } from "./common";
4
+ export declare function addSheet(ctx: Context, settings?: Required<Settings>, newSheetID?: string, isPivotTable?: boolean, sheetname?: string | undefined, sheetData?: Sheet | undefined): void;
5
+ export declare function deleteSheet(ctx: Context, options?: CommonOptions): void;
6
+ export declare function updateSheet(ctx: Context, data: Sheet[]): void;
7
+ export declare function activateSheet(ctx: Context, options?: CommonOptions): void;
8
+ export declare function setSheetName(ctx: Context, name: string, options?: CommonOptions): void;
9
+ export declare function setSheetOrder(ctx: Context, orderList: Record<string, number>): void;
10
+ export declare function scroll(ctx: Context, scrollbarX: HTMLDivElement | null, scrollbarY: HTMLDivElement | null, options: {
11
+ scrollLeft?: number;
12
+ scrollTop?: number;
13
+ targetRow?: number;
14
+ targetColumn?: number;
15
+ }): void;
@@ -0,0 +1,85 @@
1
+ import _ from "lodash";
2
+ import { addSheet as addSheetInternal, deleteSheet as deleteSheetInternal, updateSheet as updateSheetInternal } from "../modules";
3
+ import { getSheet } from "./common";
4
+ import { INVALID_PARAMS } from "./errors";
5
+ export function addSheet(ctx, settings, newSheetID, isPivotTable, sheetname, sheetData) {
6
+ if (isPivotTable === void 0) {
7
+ isPivotTable = false;
8
+ }
9
+ if (sheetname === void 0) {
10
+ sheetname = undefined;
11
+ }
12
+ if (sheetData === void 0) {
13
+ sheetData = undefined;
14
+ }
15
+ addSheetInternal(ctx, settings, newSheetID, isPivotTable, sheetname, sheetData);
16
+ }
17
+ export function deleteSheet(ctx, options) {
18
+ if (options === void 0) {
19
+ options = {};
20
+ }
21
+ var sheet = getSheet(ctx, options);
22
+ deleteSheetInternal(ctx, sheet.id);
23
+ }
24
+ export function updateSheet(ctx, data) {
25
+ updateSheetInternal(ctx, data);
26
+ }
27
+ export function activateSheet(ctx, options) {
28
+ if (options === void 0) {
29
+ options = {};
30
+ }
31
+ var sheet = getSheet(ctx, options);
32
+ ctx.currentSheetId = sheet.id;
33
+ }
34
+ export function setSheetName(ctx, name, options) {
35
+ if (options === void 0) {
36
+ options = {};
37
+ }
38
+ var sheet = getSheet(ctx, options);
39
+ sheet.name = name;
40
+ }
41
+ export function setSheetOrder(ctx, orderList) {
42
+ var _a;
43
+ (_a = ctx.luckysheetfile) === null || _a === void 0 ? void 0 : _a.forEach(function (sheet) {
44
+ if (sheet.id in orderList) {
45
+ sheet.order = orderList[sheet.id];
46
+ }
47
+ });
48
+ _.sortBy(ctx.luckysheetfile, ["order"]).forEach(function (sheet, i) {
49
+ sheet.order = i;
50
+ });
51
+ }
52
+ export function scroll(ctx, scrollbarX, scrollbarY, options) {
53
+ if (options.scrollLeft != null) {
54
+ if (!_.isNumber(options.scrollLeft)) {
55
+ throw INVALID_PARAMS;
56
+ }
57
+ if (scrollbarX) {
58
+ scrollbarX.scrollLeft = options.scrollLeft;
59
+ }
60
+ } else if (options.targetColumn != null) {
61
+ if (!_.isNumber(options.targetColumn)) {
62
+ throw INVALID_PARAMS;
63
+ }
64
+ var col_pre = options.targetColumn <= 0 ? 0 : ctx.visibledatacolumn[options.targetColumn - 1];
65
+ if (scrollbarX) {
66
+ scrollbarX.scrollLeft = col_pre;
67
+ }
68
+ }
69
+ if (options.scrollTop != null) {
70
+ if (!_.isNumber(options.scrollTop)) {
71
+ throw INVALID_PARAMS;
72
+ }
73
+ if (scrollbarY) {
74
+ scrollbarY.scrollTop = options.scrollTop;
75
+ }
76
+ } else if (options.targetRow != null) {
77
+ if (!_.isNumber(options.targetRow)) {
78
+ throw INVALID_PARAMS;
79
+ }
80
+ var row_pre = options.targetRow <= 0 ? 0 : ctx.visibledatarow[options.targetRow - 1];
81
+ if (scrollbarY) {
82
+ scrollbarY.scrollTop = row_pre;
83
+ }
84
+ }
85
+ }