@fileverse-dev/fortune-core 1.0.26 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. package/dist/index.esm.js +80254 -0
  2. package/dist/index.js +80600 -0
  3. package/{es → dist/packages/core/src}/api/cell.d.ts +10 -10
  4. package/{lib → dist/packages/core/src}/api/common.d.ts +66 -71
  5. package/{es → dist/packages/core/src}/api/errors.d.ts +2 -2
  6. package/{es → dist/packages/core/src}/api/index.d.ts +9 -9
  7. package/{es → dist/packages/core/src}/api/merge.d.ts +5 -5
  8. package/{lib → dist/packages/core/src}/api/range.d.ts +22 -22
  9. package/{lib → dist/packages/core/src}/api/rowcol.d.ts +14 -14
  10. package/{lib → dist/packages/core/src}/api/sheet.d.ts +10 -10
  11. package/{lib → dist/packages/core/src}/api/workbook.d.ts +15 -15
  12. package/{lib → dist/packages/core/src}/canvas.d.ts +46 -46
  13. package/{es → dist/packages/core/src}/context.d.ts +197 -198
  14. package/{es → dist/packages/core/src}/events/copy.d.ts +2 -2
  15. package/{lib → dist/packages/core/src}/events/index.d.ts +4 -4
  16. package/{lib → dist/packages/core/src}/events/keyboard.d.ts +6 -6
  17. package/{es → dist/packages/core/src}/events/mouse.d.ts +22 -22
  18. package/{es → dist/packages/core/src}/events/paste.d.ts +3 -3
  19. package/{lib → dist/packages/core/src}/index.d.ts +10 -10
  20. package/{lib → dist/packages/core/src}/locale/en.d.ts +992 -992
  21. package/{lib → dist/packages/core/src}/locale/es.d.ts +1134 -1134
  22. package/{lib → dist/packages/core/src}/locale/hi.d.ts +1030 -1030
  23. package/{lib → dist/packages/core/src}/locale/index.d.ts +1049 -1049
  24. package/{es → dist/packages/core/src}/locale/zh.d.ts +1048 -1048
  25. package/{lib → dist/packages/core/src}/locale/zh_tw.d.ts +1187 -1187
  26. package/{lib → dist/packages/core/src}/modules/ConditionFormat.d.ts +17 -17
  27. package/{lib → dist/packages/core/src}/modules/border.d.ts +3 -3
  28. package/{lib → dist/packages/core/src}/modules/cell.d.ts +32 -32
  29. package/{es → dist/packages/core/src}/modules/clipboard.d.ts +3 -3
  30. package/{es → dist/packages/core/src}/modules/color.d.ts +1 -1
  31. package/{lib → dist/packages/core/src}/modules/comment.d.ts +97 -97
  32. package/{es → dist/packages/core/src}/modules/conditionalFormat.d.ts +2 -2
  33. package/{es → dist/packages/core/src}/modules/cursor.d.ts +3 -3
  34. package/{es → dist/packages/core/src}/modules/dataVerification.d.ts +11 -11
  35. package/{es → dist/packages/core/src}/modules/dropCell.d.ts +10 -10
  36. package/{lib → dist/packages/core/src}/modules/filter.d.ts +45 -45
  37. package/{es → dist/packages/core/src}/modules/format.d.ts +6 -6
  38. package/{lib → dist/packages/core/src}/modules/formula.d.ts +54 -54
  39. package/{es → dist/packages/core/src}/modules/freeze.d.ts +5 -5
  40. package/{es → dist/packages/core/src}/modules/hyperlink.d.ts +21 -21
  41. package/{lib → dist/packages/core/src}/modules/iframe.d.ts +12 -12
  42. package/{es → dist/packages/core/src}/modules/image.d.ts +31 -31
  43. package/{es → dist/packages/core/src}/modules/index.d.ts +36 -36
  44. package/{lib → dist/packages/core/src}/modules/inline-string.d.ts +36 -36
  45. package/{es → dist/packages/core/src}/modules/location.d.ts +6 -6
  46. package/{es → dist/packages/core/src}/modules/locationCondition.d.ts +21 -21
  47. package/{es → dist/packages/core/src}/modules/merge.d.ts +3 -3
  48. package/{es → dist/packages/core/src}/modules/mobile.d.ts +5 -5
  49. package/{lib → dist/packages/core/src}/modules/moveCells.d.ts +5 -5
  50. package/{lib → dist/packages/core/src}/modules/protection.d.ts +5 -5
  51. package/{lib → dist/packages/core/src}/modules/refresh.d.ts +3 -3
  52. package/{es → dist/packages/core/src}/modules/rowcol.d.ts +19 -19
  53. package/{lib → dist/packages/core/src}/modules/screenshot.d.ts +2 -2
  54. package/{es → dist/packages/core/src}/modules/searchReplace.d.ts +36 -36
  55. package/{lib → dist/packages/core/src}/modules/selection.d.ts +46 -46
  56. package/{es → dist/packages/core/src}/modules/sheet.d.ts +10 -10
  57. package/{es → dist/packages/core/src}/modules/sort.d.ts +7 -7
  58. package/{es → dist/packages/core/src}/modules/splitColumn.d.ts +5 -5
  59. package/{es → dist/packages/core/src}/modules/text.d.ts +10 -10
  60. package/{lib → dist/packages/core/src}/modules/toolbar.d.ts +32 -32
  61. package/{es → dist/packages/core/src}/modules/validation.d.ts +19 -19
  62. package/{es → dist/packages/core/src}/modules/zoom.d.ts +3 -3
  63. package/{es → dist/packages/core/src}/settings.d.ts +100 -100
  64. package/{es → dist/packages/core/src}/types.d.ts +371 -376
  65. package/{es → dist/packages/core/src}/utils/freeze.d.ts +7 -7
  66. package/{es → dist/packages/core/src}/utils/index.d.ts +18 -19
  67. package/{lib → dist/packages/core/src}/utils/patch.d.ts +37 -37
  68. package/dist/packages/react/src/components/ChangeColor/index.d.ts +7 -0
  69. package/dist/packages/react/src/components/ConditionFormat/ConditionRules.d.ts +6 -0
  70. package/dist/packages/react/src/components/ConditionFormat/index.d.ts +7 -0
  71. package/dist/packages/react/src/components/ContextMenu/Divider.d.ts +3 -0
  72. package/dist/packages/react/src/components/ContextMenu/FilterMenu.d.ts +3 -0
  73. package/dist/packages/react/src/components/ContextMenu/Menu.d.ts +8 -0
  74. package/dist/packages/react/src/components/ContextMenu/SheetTab.d.ts +4 -0
  75. package/dist/packages/react/src/components/ContextMenu/index.d.ts +5 -0
  76. package/dist/packages/react/src/components/CustomSort/index.d.ts +4 -0
  77. package/dist/packages/react/src/components/DataVerification/DropdownList.d.ts +4 -0
  78. package/dist/packages/react/src/components/DataVerification/RangeDialog.d.ts +4 -0
  79. package/dist/packages/react/src/components/DataVerification/getDisplayedRangeTxt.d.ts +2 -0
  80. package/dist/packages/react/src/components/DataVerification/index.d.ts +4 -0
  81. package/dist/packages/react/src/components/Dialog/index.d.ts +15 -0
  82. package/dist/packages/react/src/components/DuneChartsInputModal/DuneChartsInputModal.d.ts +11 -0
  83. package/dist/packages/react/src/components/DunePreview/DunePreview.d.ts +13 -0
  84. package/dist/packages/react/src/components/FilterOption/index.d.ts +5 -0
  85. package/dist/packages/react/src/components/FormatSearch/index.d.ts +6 -0
  86. package/dist/packages/react/src/components/FormulaSearch/index.d.ts +5 -0
  87. package/dist/packages/react/src/components/FxEditor/NameBox.d.ts +3 -0
  88. package/dist/packages/react/src/components/FxEditor/index.d.ts +4 -0
  89. package/dist/packages/react/src/components/IFrameBoxs/iFrameBoxs.d.ts +4 -0
  90. package/dist/packages/react/src/components/ImgBoxs/index.d.ts +3 -0
  91. package/dist/packages/react/src/components/LinkEidtCard/index.d.ts +5 -0
  92. package/dist/packages/react/src/components/LocationCondition/index.d.ts +3 -0
  93. package/dist/packages/react/src/components/MessageBox/index.d.ts +9 -0
  94. package/dist/packages/react/src/components/NotationBoxes/index.d.ts +3 -0
  95. package/dist/packages/react/src/components/ResetColumnWidth/index.d.ts +2 -0
  96. package/dist/packages/react/src/components/SVGDefines.d.ts +5 -0
  97. package/dist/packages/react/src/components/SVGIcon.d.ts +9 -0
  98. package/dist/packages/react/src/components/SearchReplace/index.d.ts +6 -0
  99. package/dist/packages/react/src/components/Sheet/index.d.ts +8 -0
  100. package/dist/packages/react/src/components/SheetList/SheetHiddenButton.d.ts +8 -0
  101. package/dist/packages/react/src/components/SheetList/SheetListItem.d.ts +9 -0
  102. package/dist/packages/react/src/components/SheetList/index.d.ts +4 -0
  103. package/dist/packages/react/src/components/SheetOverlay/ColumnHeader.d.ts +3 -0
  104. package/dist/packages/react/src/components/SheetOverlay/ContentEditable.d.ts +11 -0
  105. package/dist/packages/react/src/components/SheetOverlay/FormulaHint/index.d.ts +4 -0
  106. package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/constant.d.ts +63 -0
  107. package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/index.d.ts +4 -0
  108. package/dist/packages/react/src/components/SheetOverlay/InputBox.d.ts +3 -0
  109. package/dist/packages/react/src/components/SheetOverlay/RowHeader.d.ts +3 -0
  110. package/dist/packages/react/src/components/SheetOverlay/ScrollBar/index.d.ts +7 -0
  111. package/dist/packages/react/src/components/SheetOverlay/index.d.ts +4 -0
  112. package/dist/packages/react/src/components/SheetTab/SheetItem.d.ts +8 -0
  113. package/dist/packages/react/src/components/SheetTab/index.d.ts +4 -0
  114. package/dist/packages/react/src/components/SplitColumn/index.d.ts +3 -0
  115. package/dist/packages/react/src/components/Toolbar/Button.d.ts +12 -0
  116. package/dist/packages/react/src/components/Toolbar/ColorPicker.d.ts +6 -0
  117. package/dist/packages/react/src/components/Toolbar/Combo.d.ts +12 -0
  118. package/dist/packages/react/src/components/Toolbar/CustomBorder.d.ts +7 -0
  119. package/dist/packages/react/src/components/Toolbar/CustomButton.d.ts +11 -0
  120. package/dist/packages/react/src/components/Toolbar/CustomColor.d.ts +8 -0
  121. package/dist/packages/react/src/components/Toolbar/CustomIcon.d.ts +9 -0
  122. package/dist/packages/react/src/components/Toolbar/Divider.d.ts +4 -0
  123. package/dist/packages/react/src/components/Toolbar/MoreItemsContainer.d.ts +6 -0
  124. package/dist/packages/react/src/components/Toolbar/Select.d.ts +14 -0
  125. package/dist/packages/react/src/components/Toolbar/index.d.ts +10 -0
  126. package/dist/packages/react/src/components/Workbook/api.d.ts +1177 -0
  127. package/dist/packages/react/src/components/Workbook/index.d.ts +1185 -0
  128. package/dist/packages/react/src/components/ZoomControl/index.d.ts +4 -0
  129. package/dist/packages/react/src/components/index.d.ts +4 -0
  130. package/dist/packages/react/src/constants.d.ts +1 -0
  131. package/dist/packages/react/src/context/index.d.ts +25 -0
  132. package/dist/packages/react/src/context/modal.d.ts +10 -0
  133. package/dist/packages/react/src/hooks/useAlert.d.ts +4 -0
  134. package/dist/packages/react/src/hooks/useDialog.d.ts +5 -0
  135. package/dist/packages/react/src/hooks/useOutsideClick.d.ts +2 -0
  136. package/dist/packages/react/src/hooks/usePrevious.d.ts +2 -0
  137. package/dist/packages/react/src/index.d.ts +1 -0
  138. package/dist/packages/react/src/utils/datepickerStyles.d.ts +2 -0
  139. package/dist/stories/API.stories.d.ts +1210 -0
  140. package/dist/stories/Collabration.stories.d.ts +2359 -0
  141. package/dist/stories/Features.stories.d.ts +9430 -0
  142. package/dist/stories/data/cell.d.ts +983 -0
  143. package/dist/stories/data/dataVerification.d.ts +131 -0
  144. package/dist/stories/data/empty.d.ts +10 -0
  145. package/dist/stories/data/formula.d.ts +362 -0
  146. package/dist/stories/data/freeze.d.ts +34 -0
  147. package/dist/stories/data/protected.d.ts +40 -0
  148. package/dist/stories/utils.d.ts +1 -0
  149. package/package.json +6 -7
  150. package/es/api/cell.js +0 -204
  151. package/es/api/common.d.ts +0 -71
  152. package/es/api/common.js +0 -79
  153. package/es/api/errors.js +0 -2
  154. package/es/api/index.js +0 -8
  155. package/es/api/merge.js +0 -15
  156. package/es/api/range.d.ts +0 -22
  157. package/es/api/range.js +0 -123
  158. package/es/api/rowcol.d.ts +0 -14
  159. package/es/api/rowcol.js +0 -207
  160. package/es/api/sheet.d.ts +0 -10
  161. package/es/api/sheet.js +0 -128
  162. package/es/api/workbook.d.ts +0 -15
  163. package/es/api/workbook.js +0 -85
  164. package/es/canvas.d.ts +0 -46
  165. package/es/canvas.js +0 -1350
  166. package/es/context.js +0 -381
  167. package/es/events/copy.js +0 -78
  168. package/es/events/index.d.ts +0 -4
  169. package/es/events/index.js +0 -4
  170. package/es/events/keyboard.d.ts +0 -6
  171. package/es/events/keyboard.js +0 -332
  172. package/es/events/mouse.js +0 -1725
  173. package/es/events/paste.js +0 -1378
  174. package/es/index.d.ts +0 -10
  175. package/es/index.js +0 -10
  176. package/es/locale/en.d.ts +0 -992
  177. package/es/locale/en.js +0 -10564
  178. package/es/locale/es.d.ts +0 -1134
  179. package/es/locale/es.js +0 -10010
  180. package/es/locale/hi.d.ts +0 -1030
  181. package/es/locale/hi.js +0 -10550
  182. package/es/locale/index.d.ts +0 -1049
  183. package/es/locale/index.js +0 -23
  184. package/es/locale/zh.js +0 -10568
  185. package/es/locale/zh_tw.d.ts +0 -1187
  186. package/es/locale/zh_tw.js +0 -10072
  187. package/es/modules/ConditionFormat.d.ts +0 -17
  188. package/es/modules/ConditionFormat.js +0 -1258
  189. package/es/modules/border.d.ts +0 -3
  190. package/es/modules/border.js +0 -1240
  191. package/es/modules/cell.d.ts +0 -32
  192. package/es/modules/cell.js +0 -1055
  193. package/es/modules/clipboard.js +0 -36
  194. package/es/modules/color.js +0 -1
  195. package/es/modules/comment.d.ts +0 -97
  196. package/es/modules/comment.js +0 -597
  197. package/es/modules/conditionalFormat.js +0 -441
  198. package/es/modules/cursor.js +0 -62
  199. package/es/modules/dataVerification.js +0 -701
  200. package/es/modules/dropCell.js +0 -2267
  201. package/es/modules/filter.d.ts +0 -45
  202. package/es/modules/filter.js +0 -434
  203. package/es/modules/format.js +0 -323
  204. package/es/modules/formula.d.ts +0 -54
  205. package/es/modules/formula.js +0 -2301
  206. package/es/modules/freeze.js +0 -148
  207. package/es/modules/hyperlink.js +0 -216
  208. package/es/modules/iframe.d.ts +0 -12
  209. package/es/modules/iframe.js +0 -220
  210. package/es/modules/image.js +0 -253
  211. package/es/modules/index.js +0 -36
  212. package/es/modules/inline-string.d.ts +0 -36
  213. package/es/modules/inline-string.js +0 -437
  214. package/es/modules/location.js +0 -46
  215. package/es/modules/locationCondition.js +0 -218
  216. package/es/modules/merge.js +0 -216
  217. package/es/modules/mobile.js +0 -33
  218. package/es/modules/moveCells.d.ts +0 -5
  219. package/es/modules/moveCells.js +0 -348
  220. package/es/modules/protection.d.ts +0 -5
  221. package/es/modules/protection.js +0 -96
  222. package/es/modules/refresh.d.ts +0 -3
  223. package/es/modules/refresh.js +0 -34
  224. package/es/modules/rowcol.js +0 -1922
  225. package/es/modules/screenshot.d.ts +0 -2
  226. package/es/modules/screenshot.js +0 -90
  227. package/es/modules/searchReplace.js +0 -388
  228. package/es/modules/selection.d.ts +0 -46
  229. package/es/modules/selection.js +0 -1674
  230. package/es/modules/sheet.js +0 -237
  231. package/es/modules/sort.js +0 -134
  232. package/es/modules/splitColumn.js +0 -126
  233. package/es/modules/ssf.js +0 -1533
  234. package/es/modules/text.js +0 -1207
  235. package/es/modules/toolbar.d.ts +0 -32
  236. package/es/modules/toolbar.js +0 -970
  237. package/es/modules/validation.js +0 -190
  238. package/es/modules/zoom.js +0 -29
  239. package/es/settings.js +0 -36
  240. package/es/types.js +0 -1
  241. package/es/utils/freeze.js +0 -86
  242. package/es/utils/index.js +0 -198
  243. package/es/utils/patch.d.ts +0 -37
  244. package/es/utils/patch.js +0 -381
  245. package/lib/api/cell.d.ts +0 -10
  246. package/lib/api/cell.js +0 -215
  247. package/lib/api/common.js +0 -88
  248. package/lib/api/errors.d.ts +0 -2
  249. package/lib/api/errors.js +0 -8
  250. package/lib/api/index.d.ts +0 -9
  251. package/lib/api/index.js +0 -101
  252. package/lib/api/merge.d.ts +0 -5
  253. package/lib/api/merge.js +0 -22
  254. package/lib/api/range.js +0 -138
  255. package/lib/api/rowcol.js +0 -222
  256. package/lib/api/sheet.js +0 -145
  257. package/lib/api/workbook.js +0 -98
  258. package/lib/canvas.js +0 -1356
  259. package/lib/context.d.ts +0 -198
  260. package/lib/context.js +0 -393
  261. package/lib/events/copy.d.ts +0 -2
  262. package/lib/events/copy.js +0 -85
  263. package/lib/events/index.js +0 -49
  264. package/lib/events/keyboard.js +0 -342
  265. package/lib/events/mouse.d.ts +0 -22
  266. package/lib/events/mouse.js +0 -1744
  267. package/lib/events/paste.d.ts +0 -3
  268. package/lib/events/paste.js +0 -1386
  269. package/lib/index.js +0 -109
  270. package/lib/locale/en.js +0 -10570
  271. package/lib/locale/es.js +0 -10016
  272. package/lib/locale/hi.js +0 -10556
  273. package/lib/locale/index.js +0 -29
  274. package/lib/locale/zh.d.ts +0 -1048
  275. package/lib/locale/zh.js +0 -10574
  276. package/lib/locale/zh_tw.js +0 -10078
  277. package/lib/modules/ConditionFormat.js +0 -1273
  278. package/lib/modules/border.js +0 -1248
  279. package/lib/modules/cell.js +0 -1085
  280. package/lib/modules/clipboard.d.ts +0 -3
  281. package/lib/modules/clipboard.js +0 -42
  282. package/lib/modules/color.d.ts +0 -1
  283. package/lib/modules/color.js +0 -7
  284. package/lib/modules/comment.js +0 -625
  285. package/lib/modules/conditionalFormat.d.ts +0 -2
  286. package/lib/modules/conditionalFormat.js +0 -447
  287. package/lib/modules/cursor.d.ts +0 -3
  288. package/lib/modules/cursor.js +0 -70
  289. package/lib/modules/dataVerification.d.ts +0 -11
  290. package/lib/modules/dataVerification.js +0 -716
  291. package/lib/modules/dropCell.d.ts +0 -10
  292. package/lib/modules/dropCell.js +0 -2283
  293. package/lib/modules/filter.js +0 -448
  294. package/lib/modules/format.d.ts +0 -6
  295. package/lib/modules/format.js +0 -334
  296. package/lib/modules/formula.js +0 -2330
  297. package/lib/modules/freeze.d.ts +0 -5
  298. package/lib/modules/freeze.js +0 -158
  299. package/lib/modules/hyperlink.d.ts +0 -21
  300. package/lib/modules/hyperlink.js +0 -232
  301. package/lib/modules/iframe.js +0 -236
  302. package/lib/modules/image.d.ts +0 -31
  303. package/lib/modules/image.js +0 -272
  304. package/lib/modules/index.d.ts +0 -36
  305. package/lib/modules/index.js +0 -401
  306. package/lib/modules/inline-string.js +0 -452
  307. package/lib/modules/location.d.ts +0 -6
  308. package/lib/modules/location.js +0 -57
  309. package/lib/modules/locationCondition.d.ts +0 -21
  310. package/lib/modules/locationCondition.js +0 -229
  311. package/lib/modules/merge.d.ts +0 -3
  312. package/lib/modules/merge.js +0 -223
  313. package/lib/modules/mobile.d.ts +0 -5
  314. package/lib/modules/mobile.js +0 -41
  315. package/lib/modules/moveCells.js +0 -357
  316. package/lib/modules/protection.js +0 -106
  317. package/lib/modules/refresh.js +0 -40
  318. package/lib/modules/rowcol.d.ts +0 -19
  319. package/lib/modules/rowcol.js +0 -1935
  320. package/lib/modules/screenshot.js +0 -96
  321. package/lib/modules/searchReplace.d.ts +0 -36
  322. package/lib/modules/searchReplace.js +0 -402
  323. package/lib/modules/selection.js +0 -1703
  324. package/lib/modules/sheet.d.ts +0 -10
  325. package/lib/modules/sheet.js +0 -250
  326. package/lib/modules/sort.d.ts +0 -7
  327. package/lib/modules/sort.js +0 -143
  328. package/lib/modules/splitColumn.d.ts +0 -5
  329. package/lib/modules/splitColumn.js +0 -136
  330. package/lib/modules/ssf.js +0 -1539
  331. package/lib/modules/text.d.ts +0 -10
  332. package/lib/modules/text.js +0 -1221
  333. package/lib/modules/toolbar.js +0 -1003
  334. package/lib/modules/validation.d.ts +0 -19
  335. package/lib/modules/validation.js +0 -205
  336. package/lib/modules/zoom.d.ts +0 -3
  337. package/lib/modules/zoom.js +0 -36
  338. package/lib/settings.d.ts +0 -100
  339. package/lib/settings.js +0 -42
  340. package/lib/types.d.ts +0 -376
  341. package/lib/types.js +0 -5
  342. package/lib/utils/freeze.d.ts +0 -7
  343. package/lib/utils/freeze.js +0 -92
  344. package/lib/utils/index.d.ts +0 -19
  345. package/lib/utils/index.js +0 -258
  346. package/lib/utils/patch.js +0 -392
package/es/modules/ssf.js DELETED
@@ -1,1533 +0,0 @@
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
- /* eslint-disable */
3
- import numeral from "numeral";
4
- var SSF = {};
5
- var make_ssf = function make_ssf(SSF) {
6
- SSF.version = "0.11.2";
7
- function _strrev(x) {
8
- var o = "",
9
- i = x.length - 1;
10
- while (i >= 0) o += x.charAt(i--);
11
- return o;
12
- }
13
- function fill(c, l) {
14
- var o = "";
15
- while (o.length < l) o += c;
16
- return o;
17
- }
18
- function pad0(v, d) {
19
- var t = "" + v;
20
- return t.length >= d ? t : fill("0", d - t.length) + t;
21
- }
22
- function pad_(v, d) {
23
- var t = "" + v;
24
- return t.length >= d ? t : fill(" ", d - t.length) + t;
25
- }
26
- function rpad_(v, d) {
27
- var t = "" + v;
28
- return t.length >= d ? t : t + fill(" ", d - t.length);
29
- }
30
- function pad0r1(v, d) {
31
- var t = "" + Math.round(v);
32
- return t.length >= d ? t : fill("0", d - t.length) + t;
33
- }
34
- function pad0r2(v, d) {
35
- var t = "" + v;
36
- return t.length >= d ? t : fill("0", d - t.length) + t;
37
- }
38
- var p2_32 = Math.pow(2, 32);
39
- function pad0r(v, d) {
40
- if (v > p2_32 || v < -p2_32) return pad0r1(v, d);
41
- var i = Math.round(v);
42
- return pad0r2(i, d);
43
- }
44
- function isgeneral(s, i) {
45
- i = i || 0;
46
- return s.length >= 7 + i && (s.charCodeAt(i) | 32) === 103 && (s.charCodeAt(i + 1) | 32) === 101 && (s.charCodeAt(i + 2) | 32) === 110 && (s.charCodeAt(i + 3) | 32) === 101 && (s.charCodeAt(i + 4) | 32) === 114 && (s.charCodeAt(i + 5) | 32) === 97 && (s.charCodeAt(i + 6) | 32) === 108;
47
- }
48
- var days = [["Sun", "Sunday"], ["Mon", "Monday"], ["Tue", "Tuesday"], ["Wed", "Wednesday"], ["Thu", "Thursday"], ["Fri", "Friday"], ["Sat", "Saturday"]];
49
- var months = [["J", "Jan", "January"], ["F", "Feb", "February"], ["M", "Mar", "March"], ["A", "Apr", "April"], ["M", "May", "May"], ["J", "Jun", "June"], ["J", "Jul", "July"], ["A", "Aug", "August"], ["S", "Sep", "September"], ["O", "Oct", "October"], ["N", "Nov", "November"], ["D", "Dec", "December"]];
50
- function init_table(t) {
51
- t[0] = "General";
52
- t[1] = "0";
53
- t[2] = "0.00";
54
- t[3] = "#,##0";
55
- t[4] = "#,##0.00";
56
- t[9] = "0%";
57
- t[10] = "0.00%";
58
- t[11] = "0.00E+00";
59
- t[12] = "# ?/?";
60
- t[13] = "# ??/??";
61
- t[14] = "m/d/yy";
62
- t[15] = "d-mmm-yy";
63
- t[16] = "d-mmm";
64
- t[17] = "mmm-yy";
65
- t[18] = "h:mm AM/PM";
66
- t[19] = "h:mm:ss AM/PM";
67
- t[20] = "h:mm";
68
- t[21] = "h:mm:ss";
69
- t[22] = "m/d/yy h:mm";
70
- t[37] = "#,##0 ;(#,##0)";
71
- t[38] = "#,##0 ;[Red](#,##0)";
72
- t[39] = "#,##0.00;(#,##0.00)";
73
- t[40] = "#,##0.00;[Red](#,##0.00)";
74
- t[45] = "mm:ss";
75
- t[46] = "[h]:mm:ss";
76
- t[47] = "mmss.0";
77
- t[48] = "##0.0E+0";
78
- t[49] = "@";
79
- t[56] = '"上午/下午 "hh"時"mm"分"ss"秒 "';
80
- t[65535] = "General";
81
- }
82
- var table_fmt = {};
83
- init_table(table_fmt);
84
- /* Defaults determined by systematically testing in Excel 2019 */
85
- /* These formats appear to default to other formats in the table */
86
- var default_map = [];
87
- var defi = 0;
88
- // 5 -> 37 ... 8 -> 40
89
- for (defi = 5; defi <= 8; ++defi) default_map[defi] = 32 + defi;
90
- // 23 -> 0 ... 26 -> 0
91
- for (defi = 23; defi <= 26; ++defi) default_map[defi] = 0;
92
- // 27 -> 14 ... 31 -> 14
93
- for (defi = 27; defi <= 31; ++defi) default_map[defi] = 14;
94
- // 50 -> 14 ... 58 -> 14
95
- for (defi = 50; defi <= 58; ++defi) default_map[defi] = 14;
96
- // 59 -> 1 ... 62 -> 4
97
- for (defi = 59; defi <= 62; ++defi) default_map[defi] = defi - 58;
98
- // 67 -> 9 ... 68 -> 10
99
- for (defi = 67; defi <= 68; ++defi) default_map[defi] = defi - 58;
100
- // 72 -> 14 ... 75 -> 17
101
- for (defi = 72; defi <= 75; ++defi) default_map[defi] = defi - 58;
102
- // 69 -> 12 ... 71 -> 14
103
- for (defi = 67; defi <= 68; ++defi) default_map[defi] = defi - 57;
104
- // 76 -> 20 ... 78 -> 22
105
- for (defi = 76; defi <= 78; ++defi) default_map[defi] = defi - 56;
106
- // 79 -> 45 ... 81 -> 47
107
- for (defi = 79; defi <= 81; ++defi) default_map[defi] = defi - 34;
108
- // 82 -> 0 ... 65536 -> 0 (omitted)
109
- /* These formats technically refer to Accounting formats with no equivalent */
110
- var default_str = [];
111
- // 5 -- Currency, 0 decimal, black negative
112
- default_str[5] = default_str[63] = '"$"#,##0_);\\("$"#,##0\\)';
113
- // 6 -- Currency, 0 decimal, red negative
114
- default_str[6] = default_str[64] = '"$"#,##0_);[Red]\\("$"#,##0\\)';
115
- // 7 -- Currency, 2 decimal, black negative
116
- default_str[7] = default_str[65] = '"$"#,##0.00_);\\("$"#,##0.00\\)';
117
- // 8 -- Currency, 2 decimal, red negative
118
- default_str[8] = default_str[66] = '"$"#,##0.00_);[Red]\\("$"#,##0.00\\)';
119
- // 41 -- Accounting, 0 decimal, No Symbol
120
- default_str[41] = '_(* #,##0_);_(* \\(#,##0\\);_(* "-"_);_(@_)';
121
- // 42 -- Accounting, 0 decimal, $ Symbol
122
- default_str[42] = '_("$"* #,##0_);_("$"* \\(#,##0\\);_("$"* "-"_);_(@_)';
123
- // 43 -- Accounting, 2 decimal, No Symbol
124
- default_str[43] = '_(* #,##0.00_);_(* \\(#,##0.00\\);_(* "-"??_);_(@_)';
125
- // 44 -- Accounting, 2 decimal, $ Symbol
126
- default_str[44] = '_("$"* #,##0.00_);_("$"* \\(#,##0.00\\);_("$"* "-"??_);_(@_)';
127
- function frac(x, D, mixed) {
128
- var sgn = x < 0 ? -1 : 1;
129
- var B = x * sgn;
130
- var P_2 = 0,
131
- P_1 = 1,
132
- P = 0;
133
- var Q_2 = 1,
134
- Q_1 = 0,
135
- Q = 0;
136
- var A = Math.floor(B);
137
- while (Q_1 < D) {
138
- A = Math.floor(B);
139
- P = A * P_1 + P_2;
140
- Q = A * Q_1 + Q_2;
141
- if (B - A < 0.00000005) break;
142
- B = 1 / (B - A);
143
- P_2 = P_1;
144
- P_1 = P;
145
- Q_2 = Q_1;
146
- Q_1 = Q;
147
- }
148
- if (Q > D) {
149
- if (Q_1 > D) {
150
- Q = Q_2;
151
- P = P_2;
152
- } else {
153
- Q = Q_1;
154
- P = P_1;
155
- }
156
- }
157
- if (!mixed) return [0, sgn * P, Q];
158
- var q = Math.floor(sgn * P / Q);
159
- return [q, sgn * P - q * Q, Q];
160
- }
161
- function parse_date_code(v, opts, b2) {
162
- if (v > 2958465 || v < 0) return null;
163
- var date = v | 0,
164
- time = Math.floor(86400 * (v - date)),
165
- dow = 0;
166
- var dout = [];
167
- var out = {
168
- D: date,
169
- T: time,
170
- u: 86400 * (v - date) - time,
171
- y: 0,
172
- m: 0,
173
- d: 0,
174
- H: 0,
175
- M: 0,
176
- S: 0,
177
- q: 0
178
- };
179
- if (Math.abs(out.u) < 1e-6) out.u = 0;
180
- if (opts && opts.date1904) date += 1462;
181
- if (out.u > 0.9999) {
182
- out.u = 0;
183
- if (++time == 86400) {
184
- out.T = time = 0;
185
- ++date;
186
- ++out.D;
187
- }
188
- }
189
- if (date === 60) {
190
- dout = b2 ? [1317, 10, 29] : [1900, 2, 29];
191
- dow = 3;
192
- } else if (date === 0) {
193
- dout = b2 ? [1317, 8, 29] : [1900, 1, 0];
194
- dow = 6;
195
- } else {
196
- if (date > 60) --date;
197
- /* 1 = Jan 1 1900 in Gregorian */
198
- var d = new Date(1900, 0, 1);
199
- d.setDate(d.getDate() + date - 1);
200
- dout = [d.getFullYear(), d.getMonth() + 1, d.getDate()];
201
- dow = d.getDay();
202
- if (date < 60) dow = (dow + 6) % 7;
203
- if (b2) dow = fix_hijri(d, dout);
204
- }
205
- out.y = dout[0];
206
- out.m = dout[1];
207
- out.d = dout[2];
208
- out.S = time % 60;
209
- time = Math.floor(time / 60);
210
- out.M = time % 60;
211
- time = Math.floor(time / 60);
212
- out.H = time;
213
- out.q = dow;
214
- return out;
215
- }
216
- SSF.parse_date_code = parse_date_code;
217
- var basedate = new Date(1899, 11, 31, 0, 0, 0);
218
- var dnthresh = basedate.getTime();
219
- var base1904 = new Date(1900, 2, 1, 0, 0, 0);
220
- function datenum_local(v, date1904) {
221
- var epoch = v.getTime();
222
- if (date1904) epoch -= 1461 * 24 * 60 * 60 * 1000;else if (v >= base1904) epoch += 24 * 60 * 60 * 1000;
223
- return (epoch - (dnthresh + (v.getTimezoneOffset() - basedate.getTimezoneOffset()) * 60000)) / (24 * 60 * 60 * 1000);
224
- }
225
- /* The longest 32-bit integer text is "-4294967296", exactly 11 chars */
226
- function general_fmt_int(v) {
227
- return v.toString(10);
228
- }
229
- SSF._general_int = general_fmt_int;
230
- /* ECMA-376 18.8.30 numFmt*/
231
- /* Note: `toPrecision` uses standard form when prec > E and E >= -6 */
232
- var general_fmt_num = function make_general_fmt_num() {
233
- var trailing_zeroes_and_decimal = /(?:\.0*|(\.\d*[1-9])0+)$/;
234
- function strip_decimal(o) {
235
- return o.indexOf(".") == -1 ? o : o.replace(trailing_zeroes_and_decimal, "$1");
236
- }
237
- /* General Exponential always shows 2 digits exp and trims the mantissa */
238
- var mantissa_zeroes_and_decimal = /(?:\.0*|(\.\d*[1-9])0+)[Ee]/;
239
- var exp_with_single_digit = /(E[+-])(\d)$/;
240
- function normalize_exp(o) {
241
- if (o.indexOf("E") == -1) return o;
242
- return o.replace(mantissa_zeroes_and_decimal, "$1E").replace(exp_with_single_digit, "$10$2");
243
- }
244
- /* exponent >= -9 and <= 9 */
245
- function small_exp(v) {
246
- var w = v < 0 ? 12 : 11;
247
- var o = strip_decimal(v.toFixed(12));
248
- if (o.length <= w) return o;
249
- o = v.toPrecision(10);
250
- if (o.length <= w) return o;
251
- return Number(v).toExponential(5);
252
- }
253
- /* exponent >= 11 or <= -10 likely exponential */
254
- function large_exp(v) {
255
- var o = strip_decimal(v.toFixed(11));
256
- return o.length > (v < 0 ? 12 : 11) || o === "0" || o === "-0" ? v.toPrecision(6) : o;
257
- }
258
- function general_fmt_num_base(v) {
259
- var V = Math.floor(Math.log(Math.abs(v)) * Math.LOG10E),
260
- o;
261
- if (V >= -4 && V <= -1) o = v.toPrecision(10 + V);else if (Math.abs(V) <= 9) o = small_exp(v);else if (V === 10) o = v.toFixed(10).substr(0, 12);else o = large_exp(v);
262
- return strip_decimal(normalize_exp(o.toUpperCase()));
263
- }
264
- return general_fmt_num_base;
265
- }();
266
- SSF._general_num = general_fmt_num;
267
- /*
268
- "General" rules:
269
- - text is passed through ("@")
270
- - booleans are rendered as TRUE/FALSE
271
- - "up to 11 characters" displayed for numbers
272
- - Default date format (code 14) used for Dates
273
- TODO: technically the display depends on the width of the cell
274
- */
275
- function general_fmt(v, opts) {
276
- switch (_typeof(v)) {
277
- case "string":
278
- return v;
279
- case "boolean":
280
- return v ? "TRUE" : "FALSE";
281
- case "number":
282
- return (v | 0) === v ? v.toString(10) : general_fmt_num(v);
283
- case "undefined":
284
- return "";
285
- case "object":
286
- if (v == null) return "";
287
- if (v instanceof Date) return format(14, datenum_local(v, opts && opts.date1904), opts);
288
- }
289
- throw new Error("unsupported value in General format: " + v);
290
- }
291
- SSF._general = general_fmt;
292
- function fix_hijri(date, o) {
293
- /* TODO: properly adjust y/m/d and */
294
- o[0] -= 581;
295
- var dow = date.getDay();
296
- if (date < 60) dow = (dow + 6) % 7;
297
- return dow;
298
- }
299
- var THAI_DIGITS = "\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57\u0E58\u0E59".split("");
300
- /*jshint -W086 */
301
- function write_date(type, fmt, val, ss0) {
302
- var o = "",
303
- ss = 0,
304
- tt = 0,
305
- y = val.y,
306
- out,
307
- outl = 0;
308
- switch (type) {
309
- case 98:
310
- /* 'b' buddhist year */y = val.y + 543;
311
- /* falls through */
312
- case 121:
313
- /* 'y' year */switch (fmt.length) {
314
- case 1:
315
- case 2:
316
- out = y % 100;
317
- outl = 2;
318
- break;
319
- default:
320
- out = y % 10000;
321
- outl = 4;
322
- break;
323
- }
324
- break;
325
- case 109:
326
- /* 'm' month */switch (fmt.length) {
327
- case 1:
328
- case 2:
329
- out = val.m;
330
- outl = fmt.length;
331
- break;
332
- case 3:
333
- return months[val.m - 1][1];
334
- case 5:
335
- return months[val.m - 1][0];
336
- default:
337
- return months[val.m - 1][2];
338
- }
339
- break;
340
- case 100:
341
- /* 'd' day */switch (fmt.length) {
342
- case 1:
343
- case 2:
344
- out = val.d;
345
- outl = fmt.length;
346
- break;
347
- case 3:
348
- return days[val.q][0];
349
- default:
350
- return days[val.q][1];
351
- }
352
- break;
353
- case 104:
354
- /* 'h' 12-hour */switch (fmt.length) {
355
- case 1:
356
- case 2:
357
- out = 1 + (val.H + 11) % 12;
358
- outl = fmt.length;
359
- break;
360
- default:
361
- throw "bad hour format: " + fmt;
362
- }
363
- break;
364
- case 72:
365
- /* 'H' 24-hour */switch (fmt.length) {
366
- case 1:
367
- case 2:
368
- out = val.H;
369
- outl = fmt.length;
370
- break;
371
- default:
372
- throw "bad hour format: " + fmt;
373
- }
374
- break;
375
- case 77:
376
- /* 'M' minutes */switch (fmt.length) {
377
- case 1:
378
- case 2:
379
- out = val.M;
380
- outl = fmt.length;
381
- break;
382
- default:
383
- throw "bad minute format: " + fmt;
384
- }
385
- break;
386
- case 115:
387
- /* 's' seconds */if (fmt != "s" && fmt != "ss" && fmt != ".0" && fmt != ".00" && fmt != ".000") throw "bad second format: " + fmt;
388
- if (val.u === 0 && (fmt == "s" || fmt == "ss")) return pad0(val.S, fmt.length);
389
- if (ss0 >= 2) tt = ss0 === 3 ? 1000 : 100;else tt = ss0 === 1 ? 10 : 1;
390
- ss = Math.round(tt * (val.S + val.u));
391
- if (ss >= 60 * tt) ss = 0;
392
- if (fmt === "s") return ss === 0 ? "0" : "" + ss / tt;
393
- o = pad0(ss, 2 + ss0);
394
- if (fmt === "ss") return o.substr(0, 2);
395
- return "." + o.substr(2, fmt.length - 1);
396
- case 90:
397
- /* 'Z' absolute time */switch (fmt) {
398
- case "[h]":
399
- case "[hh]":
400
- out = val.D * 24 + val.H;
401
- break;
402
- case "[m]":
403
- case "[mm]":
404
- out = (val.D * 24 + val.H) * 60 + val.M;
405
- break;
406
- case "[s]":
407
- case "[ss]":
408
- out = ((val.D * 24 + val.H) * 60 + val.M) * 60 + Math.round(val.S + val.u);
409
- break;
410
- default:
411
- throw "bad abstime format: " + fmt;
412
- }
413
- outl = fmt.length === 3 ? 1 : 2;
414
- break;
415
- case 101:
416
- /* 'e' era */out = y;
417
- outl = 1;
418
- break;
419
- }
420
- var outstr = outl > 0 ? pad0(out, outl) : "";
421
- return outstr;
422
- }
423
- /*jshint +W086 */
424
- function commaify(s) {
425
- var w = 3;
426
- if (s.length <= w) return s;
427
- var j = s.length % w,
428
- o = s.substr(0, j);
429
- for (; j != s.length; j += w) o += (o.length > 0 ? "," : "") + s.substr(j, w);
430
- return o;
431
- }
432
- var write_num = function make_write_num() {
433
- var pct1 = /%/g;
434
- function write_num_pct(type, fmt, val) {
435
- var sfmt = fmt.replace(pct1, ""),
436
- mul = fmt.length - sfmt.length;
437
- return write_num(type, sfmt, val * Math.pow(10, 2 * mul)) + fill("%", mul);
438
- }
439
- function write_num_cm(type, fmt, val) {
440
- var idx = fmt.length - 1;
441
- while (fmt.charCodeAt(idx - 1) === 44) --idx;
442
- return write_num(type, fmt.substr(0, idx), val / Math.pow(10, 3 * (fmt.length - idx)));
443
- }
444
- function write_num_exp(fmt, val) {
445
- var o;
446
- var idx = fmt.indexOf("E") - fmt.indexOf(".") - 1;
447
- if (fmt.match(/^#+0.0E\+0$/)) {
448
- if (val == 0) return "0.0E+0";else if (val < 0) return "-" + write_num_exp(fmt, -val);
449
- var period = fmt.indexOf(".");
450
- if (period === -1) period = fmt.indexOf("E");
451
- var ee = Math.floor(Math.log(val) * Math.LOG10E) % period;
452
- if (ee < 0) ee += period;
453
- o = (val / Math.pow(10, ee)).toPrecision(idx + 1 + (period + ee) % period);
454
- if (o.indexOf("e") === -1) {
455
- var fakee = Math.floor(Math.log(val) * Math.LOG10E);
456
- if (o.indexOf(".") === -1) o = o.charAt(0) + "." + o.substr(1) + "E+" + (fakee - o.length + ee);else o += "E+" + (fakee - ee);
457
- while (o.substr(0, 2) === "0.") {
458
- o = o.charAt(0) + o.substr(2, period) + "." + o.substr(2 + period);
459
- o = o.replace(/^0+([1-9])/, "$1").replace(/^0+\./, "0.");
460
- }
461
- o = o.replace(/\+-/, "-");
462
- }
463
- o = o.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/, function ($$, $1, $2, $3) {
464
- return $1 + $2 + $3.substr(0, (period + ee) % period) + "." + $3.substr(ee) + "E";
465
- });
466
- } else o = Number(val).toExponential(idx);
467
- if (fmt.match(/E\+00$/) && o.match(/e[+-]\d$/)) o = o.substr(0, o.length - 1) + "0" + o.charAt(o.length - 1);
468
- if (fmt.match(/E\-/) && o.match(/e\+/)) o = o.replace(/e\+/, "e");
469
- return o.replace("e", "E");
470
- }
471
- var frac1 = /# (\?+)( ?)\/( ?)(\d+)/;
472
- function write_num_f1(r, aval, sign) {
473
- var den = parseInt(r[4], 10),
474
- rr = Math.round(aval * den),
475
- base = Math.floor(rr / den);
476
- var myn = rr - base * den,
477
- myd = den;
478
- return sign + (base === 0 ? "" : "" + base) + " " + (myn === 0 ? fill(" ", r[1].length + 1 + r[4].length) : pad_(myn, r[1].length) + r[2] + "/" + r[3] + pad0(myd, r[4].length));
479
- }
480
- function write_num_f2(r, aval, sign) {
481
- return sign + (aval === 0 ? "" : "" + aval) + fill(" ", r[1].length + 2 + r[4].length);
482
- }
483
- var dec1 = /^#*0*\.([0#]+)/;
484
- var closeparen = /\).*[0#]/;
485
- var phone = /\(###\) ###\\?-####/;
486
- function hashq(str) {
487
- var o = "",
488
- cc;
489
- for (var i = 0; i != str.length; ++i) switch (cc = str.charCodeAt(i)) {
490
- case 35:
491
- break;
492
- case 63:
493
- o += " ";
494
- break;
495
- case 48:
496
- o += "0";
497
- break;
498
- default:
499
- o += String.fromCharCode(cc);
500
- }
501
- return o;
502
- }
503
- function rnd(val, d) {
504
- var dd = Math.pow(10, d);
505
- return "" + Math.round(val * dd) / dd;
506
- }
507
- function dec(val, d) {
508
- var _frac = val - Math.floor(val),
509
- dd = Math.pow(10, d);
510
- if (d < ("" + Math.round(_frac * dd)).length) return 0;
511
- return Math.round(_frac * dd);
512
- }
513
- function carry(val, d) {
514
- if (d < ("" + Math.round((val - Math.floor(val)) * Math.pow(10, d))).length) {
515
- return 1;
516
- }
517
- return 0;
518
- }
519
- function flr(val) {
520
- if (val < 2147483647 && val > -2147483648) return "" + (val >= 0 ? val | 0 : val - 1 | 0);
521
- return "" + Math.floor(val);
522
- }
523
- function write_num_flt(type, fmt, val) {
524
- if (type.charCodeAt(0) === 40 && !fmt.match(closeparen)) {
525
- var ffmt = fmt.replace(/\( */, "").replace(/ \)/, "").replace(/\)/, "");
526
- if (val >= 0) return write_num_flt("n", ffmt, val);
527
- return "(" + write_num_flt("n", ffmt, -val) + ")";
528
- }
529
- if (fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm(type, fmt, val);
530
- if (fmt.indexOf("%") !== -1) return write_num_pct(type, fmt, val);
531
- if (fmt.indexOf("E") !== -1) return write_num_exp(fmt, val);
532
- if (fmt.charCodeAt(0) === 36) return "$" + write_num_flt(type, fmt.substr(fmt.charAt(1) == " " ? 2 : 1), val);
533
- var o;
534
- var r,
535
- ri,
536
- ff,
537
- aval = Math.abs(val),
538
- sign = val < 0 ? "-" : "";
539
- if (fmt.match(/^00+$/)) return sign + pad0r(aval, fmt.length);
540
- if (fmt.match(/^[#?]+$/)) {
541
- o = pad0r(val, 0);
542
- if (o === "0") o = "";
543
- return o.length > fmt.length ? o : hashq(fmt.substr(0, fmt.length - o.length)) + o;
544
- }
545
- if (r = fmt.match(frac1)) return write_num_f1(r, aval, sign);
546
- if (fmt.match(/^#+0+$/)) return sign + pad0r(aval, fmt.length - fmt.indexOf("0"));
547
- if (r = fmt.match(dec1)) {
548
- o = rnd(val, r[1].length).replace(/^([^\.]+)$/, "$1." + hashq(r[1])).replace(/\.$/, "." + hashq(r[1])).replace(/\.(\d*)$/, function ($$, $1) {
549
- return "." + $1 + fill("0", hashq(r[1]).length - $1.length);
550
- });
551
- return fmt.indexOf("0.") !== -1 ? o : o.replace(/^0\./, ".");
552
- }
553
- fmt = fmt.replace(/^#+([0.])/, "$1");
554
- if (r = fmt.match(/^(0*)\.(#*)$/)) {
555
- return sign + rnd(aval, r[2].length).replace(/\.(\d*[1-9])0*$/, ".$1").replace(/^(-?\d*)$/, "$1.").replace(/^0\./, r[1].length ? "0." : ".");
556
- }
557
- if (r = fmt.match(/^#{1,3},##0(\.?)$/)) return sign + commaify(pad0r(aval, 0));
558
- if (r = fmt.match(/^#,##0\.([#0]*0)$/)) {
559
- return val < 0 ? "-" + write_num_flt(type, fmt, -val) : commaify("" + (Math.floor(val) + carry(val, r[1].length))) + "." + pad0(dec(val, r[1].length), r[1].length);
560
- }
561
- if (r = fmt.match(/^#,#*,#0/)) return write_num_flt(type, fmt.replace(/^#,#*,/, ""), val);
562
- if (r = fmt.match(/^([0#]+)(\\?-([0#]+))+$/)) {
563
- o = _strrev(write_num_flt(type, fmt.replace(/[\\-]/g, ""), val));
564
- ri = 0;
565
- return _strrev(_strrev(fmt.replace(/\\/g, "")).replace(/[0#]/g, function (x) {
566
- return ri < o.length ? o.charAt(ri++) : x === "0" ? "0" : "";
567
- }));
568
- }
569
- if (fmt.match(phone)) {
570
- o = write_num_flt(type, "##########", val);
571
- return "(" + o.substr(0, 3) + ") " + o.substr(3, 3) + "-" + o.substr(6);
572
- }
573
- var oa = "";
574
- if (r = fmt.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/)) {
575
- ri = Math.min(r[4].length, 7);
576
- ff = frac(aval, Math.pow(10, ri) - 1, false);
577
- o = "" + sign;
578
- oa = write_num("n", r[1], ff[1]);
579
- if (oa.charAt(oa.length - 1) == " ") oa = oa.substr(0, oa.length - 1) + "0";
580
- o += oa + r[2] + "/" + r[3];
581
- oa = rpad_(ff[2], ri);
582
- if (oa.length < r[4].length) oa = hashq(r[4].substr(r[4].length - oa.length)) + oa;
583
- o += oa;
584
- return o;
585
- }
586
- if (r = fmt.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/)) {
587
- ri = Math.min(Math.max(r[1].length, r[4].length), 7);
588
- ff = frac(aval, Math.pow(10, ri) - 1, true);
589
- return sign + (ff[0] || (ff[1] ? "" : "0")) + " " + (ff[1] ? pad_(ff[1], ri) + r[2] + "/" + r[3] + rpad_(ff[2], ri) : fill(" ", 2 * ri + 1 + r[2].length + r[3].length));
590
- }
591
- if (r = fmt.match(/^[#0?]+$/)) {
592
- o = pad0r(val, 0);
593
- if (fmt.length <= o.length) return o;
594
- return hashq(fmt.substr(0, fmt.length - o.length)) + o;
595
- }
596
- if (r = fmt.match(/^([#0?]+)\.([#0]+)$/)) {
597
- o = "" + val.toFixed(Math.min(r[2].length, 10)).replace(/([^0])0+$/, "$1");
598
- ri = o.indexOf(".");
599
- var lres = fmt.indexOf(".") - ri,
600
- rres = fmt.length - o.length - lres;
601
- return hashq(fmt.substr(0, lres) + o + fmt.substr(fmt.length - rres));
602
- }
603
- if (r = fmt.match(/^00,000\.([#0]*0)$/)) {
604
- ri = dec(val, r[1].length);
605
- return val < 0 ? "-" + write_num_flt(type, fmt, -val) : commaify(flr(val)).replace(/^\d,\d{3}$/, "0$&").replace(/^\d*$/, function ($$) {
606
- return "00," + ($$.length < 3 ? pad0(0, 3 - $$.length) : "") + $$;
607
- }) + "." + pad0(ri, r[1].length);
608
- }
609
- switch (fmt) {
610
- case "###,##0.00":
611
- return write_num_flt(type, "#,##0.00", val);
612
- case "###,###":
613
- case "##,###":
614
- case "#,###":
615
- var x = commaify(pad0r(aval, 0));
616
- return x !== "0" ? sign + x : "";
617
- case "###,###.00":
618
- return write_num_flt(type, "###,##0.00", val).replace(/^0\./, ".");
619
- case "#,###.00":
620
- return write_num_flt(type, "#,##0.00", val).replace(/^0\./, ".");
621
- default:
622
- }
623
- throw new Error("unsupported format |" + fmt + "|");
624
- }
625
- function write_num_cm2(type, fmt, val) {
626
- var idx = fmt.length - 1;
627
- while (fmt.charCodeAt(idx - 1) === 44) --idx;
628
- return write_num(type, fmt.substr(0, idx), val / Math.pow(10, 3 * (fmt.length - idx)));
629
- }
630
- function write_num_pct2(type, fmt, val) {
631
- var sfmt = fmt.replace(pct1, ""),
632
- mul = fmt.length - sfmt.length;
633
- return write_num(type, sfmt, val * Math.pow(10, 2 * mul)) + fill("%", mul);
634
- }
635
- function write_num_exp2(fmt, val) {
636
- var o;
637
- var idx = fmt.indexOf("E") - fmt.indexOf(".") - 1;
638
- if (fmt.match(/^#+0.0E\+0$/)) {
639
- if (val == 0) return "0.0E+0";else if (val < 0) return "-" + write_num_exp2(fmt, -val);
640
- var period = fmt.indexOf(".");
641
- if (period === -1) period = fmt.indexOf("E");
642
- var ee = Math.floor(Math.log(val) * Math.LOG10E) % period;
643
- if (ee < 0) ee += period;
644
- o = (val / Math.pow(10, ee)).toPrecision(idx + 1 + (period + ee) % period);
645
- if (!o.match(/[Ee]/)) {
646
- var fakee = Math.floor(Math.log(val) * Math.LOG10E);
647
- if (o.indexOf(".") === -1) o = o.charAt(0) + "." + o.substr(1) + "E+" + (fakee - o.length + ee);else o += "E+" + (fakee - ee);
648
- o = o.replace(/\+-/, "-");
649
- }
650
- o = o.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/, function ($$, $1, $2, $3) {
651
- return $1 + $2 + $3.substr(0, (period + ee) % period) + "." + $3.substr(ee) + "E";
652
- });
653
- } else o = Number(val).toExponential(idx);
654
- if (fmt.match(/E\+00$/) && o.match(/e[+-]\d$/)) o = o.substr(0, o.length - 1) + "0" + o.charAt(o.length - 1);
655
- if (fmt.match(/E\-/) && o.match(/e\+/)) o = o.replace(/e\+/, "e");
656
- return o.replace("e", "E");
657
- }
658
- function write_num_int(type, fmt, val) {
659
- if (type.charCodeAt(0) === 40 && !fmt.match(closeparen)) {
660
- var ffmt = fmt.replace(/\( */, "").replace(/ \)/, "").replace(/\)/, "");
661
- if (val >= 0) return write_num_int("n", ffmt, val);
662
- return "(" + write_num_int("n", ffmt, -val) + ")";
663
- }
664
- if (fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm2(type, fmt, val);
665
- if (fmt.indexOf("%") !== -1) return write_num_pct2(type, fmt, val);
666
- if (fmt.indexOf("E") !== -1) return write_num_exp2(fmt, val);
667
- if (fmt.charCodeAt(0) === 36) return "$" + write_num_int(type, fmt.substr(fmt.charAt(1) == " " ? 2 : 1), val);
668
- var o;
669
- var r,
670
- ri,
671
- ff,
672
- aval = Math.abs(val),
673
- sign = val < 0 ? "-" : "";
674
- if (fmt.match(/^00+$/)) return sign + pad0(aval, fmt.length);
675
- if (fmt.match(/^[#?]+$/)) {
676
- o = "" + val;
677
- if (val === 0) o = "";
678
- return o.length > fmt.length ? o : hashq(fmt.substr(0, fmt.length - o.length)) + o;
679
- }
680
- if (r = fmt.match(frac1)) return write_num_f2(r, aval, sign);
681
- if (fmt.match(/^#+0+$/)) return sign + pad0(aval, fmt.length - fmt.indexOf("0"));
682
- if (r = fmt.match(dec1)) {
683
- o = ("" + val).replace(/^([^\.]+)$/, "$1." + hashq(r[1])).replace(/\.$/, "." + hashq(r[1]));
684
- o = o.replace(/\.(\d*)$/, function ($$, $1) {
685
- return "." + $1 + fill("0", hashq(r[1]).length - $1.length);
686
- });
687
- return fmt.indexOf("0.") !== -1 ? o : o.replace(/^0\./, ".");
688
- }
689
- fmt = fmt.replace(/^#+([0.])/, "$1");
690
- if (r = fmt.match(/^(0*)\.(#*)$/)) {
691
- return sign + ("" + aval).replace(/\.(\d*[1-9])0*$/, ".$1").replace(/^(-?\d*)$/, "$1.").replace(/^0\./, r[1].length ? "0." : ".");
692
- }
693
- if (r = fmt.match(/^#{1,3},##0(\.?)$/)) return sign + commaify("" + aval);
694
- if (r = fmt.match(/^#,##0\.([#0]*0)$/)) {
695
- return val < 0 ? "-" + write_num_int(type, fmt, -val) : commaify("" + val) + "." + fill("0", r[1].length);
696
- }
697
- if (r = fmt.match(/^#,#*,#0/)) return write_num_int(type, fmt.replace(/^#,#*,/, ""), val);
698
- if (r = fmt.match(/^([0#]+)(\\?-([0#]+))+$/)) {
699
- o = _strrev(write_num_int(type, fmt.replace(/[\\-]/g, ""), val));
700
- ri = 0;
701
- return _strrev(_strrev(fmt.replace(/\\/g, "")).replace(/[0#]/g, function (x) {
702
- return ri < o.length ? o.charAt(ri++) : x === "0" ? "0" : "";
703
- }));
704
- }
705
- if (fmt.match(phone)) {
706
- o = write_num_int(type, "##########", val);
707
- return "(" + o.substr(0, 3) + ") " + o.substr(3, 3) + "-" + o.substr(6);
708
- }
709
- var oa = "";
710
- if (r = fmt.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/)) {
711
- ri = Math.min(r[4].length, 7);
712
- ff = frac(aval, Math.pow(10, ri) - 1, false);
713
- o = "" + sign;
714
- oa = write_num("n", r[1], ff[1]);
715
- if (oa.charAt(oa.length - 1) == " ") oa = oa.substr(0, oa.length - 1) + "0";
716
- o += oa + r[2] + "/" + r[3];
717
- oa = rpad_(ff[2], ri);
718
- if (oa.length < r[4].length) oa = hashq(r[4].substr(r[4].length - oa.length)) + oa;
719
- o += oa;
720
- return o;
721
- }
722
- if (r = fmt.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/)) {
723
- ri = Math.min(Math.max(r[1].length, r[4].length), 7);
724
- ff = frac(aval, Math.pow(10, ri) - 1, true);
725
- return sign + (ff[0] || (ff[1] ? "" : "0")) + " " + (ff[1] ? pad_(ff[1], ri) + r[2] + "/" + r[3] + rpad_(ff[2], ri) : fill(" ", 2 * ri + 1 + r[2].length + r[3].length));
726
- }
727
- if (r = fmt.match(/^[#0?]+$/)) {
728
- o = "" + val;
729
- if (fmt.length <= o.length) return o;
730
- return hashq(fmt.substr(0, fmt.length - o.length)) + o;
731
- }
732
- if (r = fmt.match(/^([#0]+)\.([#0]+)$/)) {
733
- o = "" + val.toFixed(Math.min(r[2].length, 10)).replace(/([^0])0+$/, "$1");
734
- ri = o.indexOf(".");
735
- var lres = fmt.indexOf(".") - ri,
736
- rres = fmt.length - o.length - lres;
737
- return hashq(fmt.substr(0, lres) + o + fmt.substr(fmt.length - rres));
738
- }
739
- if (r = fmt.match(/^00,000\.([#0]*0)$/)) {
740
- return val < 0 ? "-" + write_num_int(type, fmt, -val) : commaify("" + val).replace(/^\d,\d{3}$/, "0$&").replace(/^\d*$/, function ($$) {
741
- return "00," + ($$.length < 3 ? pad0(0, 3 - $$.length) : "") + $$;
742
- }) + "." + pad0(0, r[1].length);
743
- }
744
- switch (fmt) {
745
- case "###,###":
746
- case "##,###":
747
- case "#,###":
748
- var x = commaify("" + aval);
749
- return x !== "0" ? sign + x : "";
750
- default:
751
- if (fmt.match(/\.[0#?]*$/)) return write_num_int(type, fmt.slice(0, fmt.lastIndexOf(".")), val) + hashq(fmt.slice(fmt.lastIndexOf(".")));
752
- }
753
- throw new Error("unsupported format |" + fmt + "|");
754
- }
755
- return function write_num(type, fmt, val) {
756
- return (val | 0) === val ? write_num_int(type, fmt, val) : write_num_flt(type, fmt, val);
757
- };
758
- }();
759
- function split_fmt(fmt) {
760
- var out = [];
761
- var in_str = false; /*, cc*/
762
- for (var i = 0, j = 0; i < fmt.length; ++i) switch (/*cc=*/fmt.charCodeAt(i)) {
763
- case 34:
764
- /* '"' */in_str = !in_str;
765
- break;
766
- case 95:
767
- case 42:
768
- case 92:
769
- /* '_' '*' '\\' */
770
- ++i;
771
- break;
772
- case 59:
773
- /* ';' */out[out.length] = fmt.substr(j, i - j);
774
- j = i + 1;
775
- }
776
- out[out.length] = fmt.substr(j);
777
- if (in_str === true) throw new Error("Format |" + fmt + "| unterminated string ");
778
- return out;
779
- }
780
- SSF._split = split_fmt;
781
- var abstime = /\[[HhMmSs\u0E0A\u0E19\u0E17]*\]/;
782
- function fmt_is_date(fmt) {
783
- var i = 0,
784
- /*cc = 0,*/c = "",
785
- o = "";
786
- while (i < fmt.length) {
787
- switch (c = fmt.charAt(i)) {
788
- case "G":
789
- if (isgeneral(fmt, i)) i += 6;
790
- i++;
791
- break;
792
- case '"':
793
- for (; /*cc=*/fmt.charCodeAt(++i) !== 34 && i < fmt.length;) {
794
- /*empty*/
795
- }
796
- ++i;
797
- break;
798
- case "\\":
799
- i += 2;
800
- break;
801
- case "_":
802
- i += 2;
803
- break;
804
- case "@":
805
- ++i;
806
- break;
807
- case "B":
808
- case "b":
809
- if (fmt.charAt(i + 1) === "1" || fmt.charAt(i + 1) === "2") return true;
810
- /* falls through */
811
- case "M":
812
- case "D":
813
- case "Y":
814
- case "H":
815
- case "S":
816
- case "E":
817
- /* falls through */
818
- case "m":
819
- case "d":
820
- case "y":
821
- case "h":
822
- case "s":
823
- case "e":
824
- case "g":
825
- return true;
826
- case "A":
827
- case "a":
828
- case "上":
829
- if (fmt.substr(i, 3).toUpperCase() === "A/P") return true;
830
- if (fmt.substr(i, 5).toUpperCase() === "AM/PM") return true;
831
- if (fmt.substr(i, 5).toUpperCase() === "上午/下午") return true;
832
- ++i;
833
- break;
834
- case "[":
835
- o = c;
836
- while (fmt.charAt(i++) !== "]" && i < fmt.length) o += fmt.charAt(i);
837
- if (o.match(abstime)) return true;
838
- break;
839
- case ".":
840
- /* falls through */
841
- case "0":
842
- case "#":
843
- while (i < fmt.length && ("0#?.,E+-%".indexOf(c = fmt.charAt(++i)) > -1 || c == "\\" && fmt.charAt(i + 1) == "-" && "0#".indexOf(fmt.charAt(i + 2)) > -1)) {
844
- /* empty */
845
- }
846
- break;
847
- case "?":
848
- while (fmt.charAt(++i) === c) {
849
- /* empty */
850
- }
851
- break;
852
- case "*":
853
- ++i;
854
- if (fmt.charAt(i) == " " || fmt.charAt(i) == "*") ++i;
855
- break;
856
- case "(":
857
- case ")":
858
- ++i;
859
- break;
860
- case "1":
861
- case "2":
862
- case "3":
863
- case "4":
864
- case "5":
865
- case "6":
866
- case "7":
867
- case "8":
868
- case "9":
869
- while (i < fmt.length && "0123456789".indexOf(fmt.charAt(++i)) > -1) {
870
- /* empty */
871
- }
872
- break;
873
- case " ":
874
- ++i;
875
- break;
876
- default:
877
- ++i;
878
- break;
879
- }
880
- }
881
- return false;
882
- }
883
- SSF.is_date = fmt_is_date;
884
- function eval_fmt(fmt, v, opts, flen) {
885
- var out = [],
886
- o = "",
887
- i = 0,
888
- c = "",
889
- lst = "t",
890
- dt,
891
- j,
892
- cc;
893
- var hr = "H";
894
- /* Tokenize */
895
- while (i < fmt.length) {
896
- switch (c = fmt.charAt(i)) {
897
- case "G":
898
- /* General */if (!isgeneral(fmt, i)) throw new Error("unrecognized character " + c + " in " + fmt);
899
- out[out.length] = {
900
- t: "G",
901
- v: "General"
902
- };
903
- i += 7;
904
- break;
905
- case '"':
906
- /* Literal text */for (o = ""; (cc = fmt.charCodeAt(++i)) !== 34 && i < fmt.length;) o += String.fromCharCode(cc);
907
- out[out.length] = {
908
- t: "t",
909
- v: o
910
- };
911
- ++i;
912
- break;
913
- case "\\":
914
- var w = fmt.charAt(++i),
915
- t = w === "(" || w === ")" ? w : "t";
916
- out[out.length] = {
917
- t: t,
918
- v: w
919
- };
920
- ++i;
921
- break;
922
- case "_":
923
- out[out.length] = {
924
- t: "t",
925
- v: " "
926
- };
927
- i += 2;
928
- break;
929
- case "@":
930
- /* Text Placeholder */out[out.length] = {
931
- t: "T",
932
- v: v
933
- };
934
- ++i;
935
- break;
936
- case "B":
937
- case "b":
938
- if (fmt.charAt(i + 1) === "1" || fmt.charAt(i + 1) === "2") {
939
- if (dt == null) {
940
- dt = parse_date_code(v, opts, fmt.charAt(i + 1) === "2");
941
- if (dt == null) return "";
942
- }
943
- out[out.length] = {
944
- t: "X",
945
- v: fmt.substr(i, 2)
946
- };
947
- lst = c;
948
- i += 2;
949
- break;
950
- }
951
- /* falls through */
952
- case "M":
953
- case "D":
954
- case "Y":
955
- case "H":
956
- case "S":
957
- case "E":
958
- c = c.toLowerCase();
959
- /* falls through */
960
- case "m":
961
- case "d":
962
- case "y":
963
- case "h":
964
- case "s":
965
- case "e":
966
- case "g":
967
- if (v < 0) return "";
968
- if (dt == null) {
969
- dt = parse_date_code(v, opts);
970
- if (dt == null) return "#####";
971
- }
972
- o = c;
973
- while (++i < fmt.length && fmt.charAt(i).toLowerCase() === c) o += c;
974
- if (c === "m" && lst.toLowerCase() === "h") c = "M";
975
- if (c === "h") c = hr;
976
- out[out.length] = {
977
- t: c,
978
- v: o
979
- };
980
- lst = c;
981
- break;
982
- case "A":
983
- case "a":
984
- case "上":
985
- var q = {
986
- t: c,
987
- v: c
988
- };
989
- if (dt == null) dt = parse_date_code(v, opts);
990
- if (fmt.substr(i, 3).toUpperCase() === "A/P") {
991
- if (dt != null) q.v = dt.H >= 12 ? "P" : "A";
992
- q.t = "T";
993
- hr = "h";
994
- i += 3;
995
- } else if (fmt.substr(i, 5).toUpperCase() === "AM/PM") {
996
- if (dt != null) q.v = dt.H >= 12 ? "PM" : "AM";
997
- q.t = "T";
998
- i += 5;
999
- hr = "h";
1000
- } else if (fmt.substr(i, 5).toUpperCase() === "上午/下午") {
1001
- if (dt != null) q.v = dt.H >= 12 ? "下午" : "上午";
1002
- q.t = "T";
1003
- i += 5;
1004
- hr = "h";
1005
- } else {
1006
- q.t = "t";
1007
- ++i;
1008
- }
1009
- if (dt == null && q.t === "T") return "";
1010
- out[out.length] = q;
1011
- lst = c;
1012
- break;
1013
- case "[":
1014
- o = c;
1015
- while (fmt.charAt(i++) !== "]" && i < fmt.length) o += fmt.charAt(i);
1016
- if (o.slice(-1) !== "]") throw 'unterminated "[" block: |' + o + "|";
1017
- if (o.match(abstime)) {
1018
- if (dt == null) {
1019
- dt = parse_date_code(v, opts);
1020
- if (dt == null) return "";
1021
- }
1022
- out[out.length] = {
1023
- t: "Z",
1024
- v: o.toLowerCase()
1025
- };
1026
- lst = o.charAt(1);
1027
- } else if (o.indexOf("$") > -1) {
1028
- o = (o.match(/\$([^-\[\]]*)/) || [])[1] || "$";
1029
- if (!fmt_is_date(fmt)) out[out.length] = {
1030
- t: "t",
1031
- v: o
1032
- };
1033
- }
1034
- break;
1035
- /* Numbers */
1036
- case ".":
1037
- if (dt != null) {
1038
- o = c;
1039
- while (++i < fmt.length && (c = fmt.charAt(i)) === "0") o += c;
1040
- out[out.length] = {
1041
- t: "s",
1042
- v: o
1043
- };
1044
- break;
1045
- }
1046
- /* falls through */
1047
- case "0":
1048
- case "#":
1049
- o = c;
1050
- while (++i < fmt.length && "0#?.,E+-%".indexOf(c = fmt.charAt(i)) > -1) o += c;
1051
- out[out.length] = {
1052
- t: "n",
1053
- v: o
1054
- };
1055
- break;
1056
- case "?":
1057
- o = c;
1058
- while (fmt.charAt(++i) === c) o += c;
1059
- out[out.length] = {
1060
- t: c,
1061
- v: o
1062
- };
1063
- lst = c;
1064
- break;
1065
- case "*":
1066
- ++i;
1067
- if (fmt.charAt(i) == " " || fmt.charAt(i) == "*") ++i;
1068
- break;
1069
- // **
1070
- case "(":
1071
- case ")":
1072
- out[out.length] = {
1073
- t: flen === 1 ? "t" : c,
1074
- v: c
1075
- };
1076
- ++i;
1077
- break;
1078
- case "1":
1079
- case "2":
1080
- case "3":
1081
- case "4":
1082
- case "5":
1083
- case "6":
1084
- case "7":
1085
- case "8":
1086
- case "9":
1087
- o = c;
1088
- while (i < fmt.length && "0123456789".indexOf(fmt.charAt(++i)) > -1) o += fmt.charAt(i);
1089
- out[out.length] = {
1090
- t: "D",
1091
- v: o
1092
- };
1093
- break;
1094
- case " ":
1095
- out[out.length] = {
1096
- t: c,
1097
- v: c
1098
- };
1099
- ++i;
1100
- break;
1101
- case "$":
1102
- out[out.length] = {
1103
- t: "t",
1104
- v: "$"
1105
- };
1106
- ++i;
1107
- break;
1108
- default:
1109
- // if ("¤฿BsBr₵₡₫ƒFtRs.₭kr£₤Lm₥₦₱PQRSkRp৲৳R$S/.〒₮₩¥NT¥zł₴₪៛руб€$,$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP".indexOf(c) === -1) throw new Error('unrecognized character ' + c + ' in ' + fmt);
1110
- if ("¤฿BsBr₵₡₫ƒFtRs.₭kr£₤Lm₥₦₱PQRSkRp৲৳R$S/.〒₮₩¥NT¥zł₴₪៛руб€₹$,$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP$¥LekdinAf$dhAflRial?£BirrKzMOPPGKRsGsB/R$ррlevkrKMzBsPNuFBuKPkrRD$NfkCFA?CVEGMDFrCDHTGNAfLFdjKGSFGGHSRielKCFknKshLSLL£LtRFRONArRfMWKRMMURsMROS/KMDLMTnRC$kr€GELCHFSLLSCRDbSZLSDGSOSSomFCFPTShT$VUVQUGXгрнsomWSTNT$FtDramRpZMWFCFA".indexOf(c) === -1) throw new Error("unrecognized character " + c + " in " + fmt);
1111
- out[out.length] = {
1112
- t: "t",
1113
- v: c
1114
- };
1115
- ++i;
1116
- break;
1117
- }
1118
- }
1119
- /* Scan for date/time parts */
1120
- var bt = 0,
1121
- ss0 = 0,
1122
- ssm;
1123
- for (i = out.length - 1, lst = "t"; i >= 0; --i) {
1124
- switch (out[i].t) {
1125
- case "h":
1126
- case "H":
1127
- out[i].t = hr;
1128
- lst = "h";
1129
- if (bt < 1) bt = 1;
1130
- break;
1131
- case "s":
1132
- if (ssm = out[i].v.match(/\.0+$/)) ss0 = Math.max(ss0, ssm[0].length - 1);
1133
- if (bt < 3) bt = 3;
1134
- /* falls through */
1135
- case "d":
1136
- case "y":
1137
- case "M":
1138
- case "e":
1139
- lst = out[i].t;
1140
- break;
1141
- case "m":
1142
- if (lst === "s") {
1143
- out[i].t = "M";
1144
- if (bt < 2) bt = 2;
1145
- }
1146
- break;
1147
- case "X":
1148
- /*if(out[i].v === "B2");*/break;
1149
- case "Z":
1150
- if (bt < 1 && out[i].v.match(/[Hh]/)) bt = 1;
1151
- if (bt < 2 && out[i].v.match(/[Mm]/)) bt = 2;
1152
- if (bt < 3 && out[i].v.match(/[Ss]/)) bt = 3;
1153
- }
1154
- }
1155
- /* time rounding depends on presence of minute / second / usec fields */
1156
- switch (bt) {
1157
- case 0:
1158
- break;
1159
- case 1:
1160
- if (dt.u >= 0.5) {
1161
- dt.u = 0;
1162
- ++dt.S;
1163
- }
1164
- if (dt.S >= 60) {
1165
- dt.S = 0;
1166
- ++dt.M;
1167
- }
1168
- if (dt.M >= 60) {
1169
- dt.M = 0;
1170
- ++dt.H;
1171
- }
1172
- break;
1173
- case 2:
1174
- if (dt.u >= 0.5) {
1175
- dt.u = 0;
1176
- ++dt.S;
1177
- }
1178
- if (dt.S >= 60) {
1179
- dt.S = 0;
1180
- ++dt.M;
1181
- }
1182
- break;
1183
- }
1184
- /* replace fields */
1185
- var nstr = "",
1186
- jj;
1187
- for (i = 0; i < out.length; ++i) {
1188
- switch (out[i].t) {
1189
- case "t":
1190
- case "T":
1191
- case " ":
1192
- case "D":
1193
- break;
1194
- case "X":
1195
- out[i].v = "";
1196
- out[i].t = ";";
1197
- break;
1198
- case "d":
1199
- case "m":
1200
- case "y":
1201
- case "h":
1202
- case "H":
1203
- case "M":
1204
- case "s":
1205
- case "e":
1206
- case "b":
1207
- case "Z":
1208
- out[i].v = write_date(out[i].t.charCodeAt(0), out[i].v, dt, ss0);
1209
- out[i].t = "t";
1210
- break;
1211
- case "n":
1212
- case "?":
1213
- jj = i + 1;
1214
- while (out[jj] != null && ((c = out[jj].t) === "?" || c === "D" || (c === " " || c === "t") && out[jj + 1] != null && (out[jj + 1].t === "?" || out[jj + 1].t === "t" && out[jj + 1].v === "/") || out[i].t === "(" && (c === " " || c === "n" || c === ")") || c === "t" && (out[jj].v === "/" || out[jj].v === " " && out[jj + 1] != null && out[jj + 1].t == "?"))) {
1215
- out[i].v += out[jj].v;
1216
- out[jj] = {
1217
- v: "",
1218
- t: ";"
1219
- };
1220
- ++jj;
1221
- }
1222
- nstr += out[i].v;
1223
- i = jj - 1;
1224
- break;
1225
- case "G":
1226
- out[i].t = "t";
1227
- out[i].v = general_fmt(v, opts);
1228
- break;
1229
- }
1230
- }
1231
- var vv = "",
1232
- myv,
1233
- ostr;
1234
- if (nstr.length > 0) {
1235
- if (nstr.charCodeAt(0) == 40) {
1236
- /* '(' */myv = v < 0 && nstr.charCodeAt(0) === 45 ? -v : v;
1237
- ostr = write_num("n", nstr, myv);
1238
- } else {
1239
- myv = v < 0 && flen > 1 ? -v : v;
1240
- ostr = write_num("n", nstr, myv);
1241
- if (myv < 0 && out[0] && out[0].t == "t") {
1242
- ostr = ostr.substr(1);
1243
- out[0].v = "-" + out[0].v;
1244
- }
1245
- }
1246
- jj = ostr.length - 1;
1247
- var decpt = out.length;
1248
- for (i = 0; i < out.length; ++i) if (out[i] != null && out[i].t != "t" && out[i].v.indexOf(".") > -1) {
1249
- decpt = i;
1250
- break;
1251
- }
1252
- var lasti = out.length;
1253
- if (decpt === out.length && ostr.indexOf("E") === -1) {
1254
- for (i = out.length - 1; i >= 0; --i) {
1255
- if (out[i] == null || "n?".indexOf(out[i].t) === -1) continue;
1256
- if (jj >= out[i].v.length - 1) {
1257
- jj -= out[i].v.length;
1258
- out[i].v = ostr.substr(jj + 1, out[i].v.length);
1259
- } else if (jj < 0) out[i].v = "";else {
1260
- out[i].v = ostr.substr(0, jj + 1);
1261
- jj = -1;
1262
- }
1263
- out[i].t = "t";
1264
- lasti = i;
1265
- }
1266
- if (jj >= 0 && lasti < out.length) out[lasti].v = ostr.substr(0, jj + 1) + out[lasti].v;
1267
- } else if (decpt !== out.length && ostr.indexOf("E") === -1) {
1268
- jj = ostr.indexOf(".") - 1;
1269
- for (i = decpt; i >= 0; --i) {
1270
- if (out[i] == null || "n?".indexOf(out[i].t) === -1) continue;
1271
- j = out[i].v.indexOf(".") > -1 && i === decpt ? out[i].v.indexOf(".") - 1 : out[i].v.length - 1;
1272
- vv = out[i].v.substr(j + 1);
1273
- for (; j >= 0; --j) {
1274
- if (jj >= 0 && (out[i].v.charAt(j) === "0" || out[i].v.charAt(j) === "#")) vv = ostr.charAt(jj--) + vv;
1275
- }
1276
- out[i].v = vv;
1277
- out[i].t = "t";
1278
- lasti = i;
1279
- }
1280
- if (jj >= 0 && lasti < out.length) out[lasti].v = ostr.substr(0, jj + 1) + out[lasti].v;
1281
- jj = ostr.indexOf(".") + 1;
1282
- for (i = decpt; i < out.length; ++i) {
1283
- if (out[i] == null || "n?(".indexOf(out[i].t) === -1 && i !== decpt) continue;
1284
- j = out[i].v.indexOf(".") > -1 && i === decpt ? out[i].v.indexOf(".") + 1 : 0;
1285
- vv = out[i].v.substr(0, j);
1286
- for (; j < out[i].v.length; ++j) {
1287
- if (jj < ostr.length) vv += ostr.charAt(jj++);
1288
- }
1289
- out[i].v = vv;
1290
- out[i].t = "t";
1291
- lasti = i;
1292
- }
1293
- }
1294
- }
1295
- for (i = 0; i < out.length; ++i) if (out[i] != null && "n?".indexOf(out[i].t) > -1) {
1296
- myv = flen > 1 && v < 0 && i > 0 && out[i - 1].v === "-" ? -v : v;
1297
- out[i].v = write_num(out[i].t, out[i].v, myv);
1298
- out[i].t = "t";
1299
- }
1300
- var retval = "";
1301
- for (i = 0; i !== out.length; ++i) if (out[i] != null) retval += out[i].v;
1302
- return retval;
1303
- }
1304
- SSF._eval = eval_fmt;
1305
- var cfregex = /\[[=<>]/;
1306
- var cfregex2 = /\[(=|>[=]?|<[>=]?)(-?\d+(?:\.\d*)?)\]/;
1307
- function chkcond(v, rr) {
1308
- if (rr == null) return false;
1309
- var thresh = parseFloat(rr[2]);
1310
- switch (rr[1]) {
1311
- case "=":
1312
- if (v == thresh) return true;
1313
- break;
1314
- case ">":
1315
- if (v > thresh) return true;
1316
- break;
1317
- case "<":
1318
- if (v < thresh) return true;
1319
- break;
1320
- case "<>":
1321
- if (v != thresh) return true;
1322
- break;
1323
- case ">=":
1324
- if (v >= thresh) return true;
1325
- break;
1326
- case "<=":
1327
- if (v <= thresh) return true;
1328
- break;
1329
- }
1330
- return false;
1331
- }
1332
- function choose_fmt(f, v) {
1333
- var fmt = split_fmt(f);
1334
- var l = fmt.length,
1335
- lat = fmt[l - 1].indexOf("@");
1336
- if (l < 4 && lat > -1) --l;
1337
- if (fmt.length > 4) throw new Error("cannot find right format for |" + fmt.join("|") + "|");
1338
- // 这行代码弃用,有可能v会有"1"的情况出现,并且需要排查true,false,‘ ’这些值所以需要使用parseFloat(v).toString()去判断是不是Number类型
1339
- // if (typeof v !== "number")
1340
- if (parseFloat(v).toString() == "NaN") return [4, fmt.length === 4 || lat > -1 ? fmt[fmt.length - 1] : "@"];
1341
- switch (fmt.length) {
1342
- case 1:
1343
- fmt = lat > -1 ? ["General", "General", "General", fmt[0]] : [fmt[0], fmt[0], fmt[0], "@"];
1344
- break;
1345
- case 2:
1346
- fmt = lat > -1 ? [fmt[0], fmt[0], fmt[0], fmt[1]] : [fmt[0], fmt[1], fmt[0], "@"];
1347
- break;
1348
- case 3:
1349
- fmt = lat > -1 ? [fmt[0], fmt[1], fmt[0], fmt[2]] : [fmt[0], fmt[1], fmt[2], "@"];
1350
- break;
1351
- case 4:
1352
- break;
1353
- }
1354
- var ff = v > 0 ? fmt[0] : v < 0 ? fmt[1] : fmt[2];
1355
- if (fmt[0].indexOf("[") === -1 && fmt[1].indexOf("[") === -1) return [l, ff];
1356
- if (fmt[0].match(cfregex) != null || fmt[1].match(cfregex) != null) {
1357
- var m1 = fmt[0].match(cfregex2);
1358
- var m2 = fmt[1].match(cfregex2);
1359
- return chkcond(v, m1) ? [l, fmt[0]] : chkcond(v, m2) ? [l, fmt[1]] : [l, fmt[m1 != null && m2 != null ? 2 : 1]];
1360
- }
1361
- return [l, ff];
1362
- }
1363
- function format(fmt, v, o) {
1364
- if (o == null) o = {};
1365
- var sfmt = "";
1366
- switch (_typeof(fmt)) {
1367
- case "string":
1368
- if (fmt == "m/d/yy" && o.dateNF) sfmt = o.dateNF;else sfmt = fmt;
1369
- break;
1370
- case "number":
1371
- if (fmt == 14 && o.dateNF) sfmt = o.dateNF;else sfmt = (o.table != null ? o.table : table_fmt)[fmt];
1372
- if (sfmt == null) sfmt = o.table && o.table[default_map[fmt]] || table_fmt[default_map[fmt]];
1373
- if (sfmt == null) sfmt = default_str[fmt] || "General";
1374
- break;
1375
- }
1376
-
1377
- //new runze 增加万 亿 格式
1378
- //注:"w":2万2500 "w0":2万2500 "w0.0":2万2500.2 "w0.00":2万2500.23......自定义精确度
1379
- var reg = /^(w|W)((0?)|(0\.0+))$/;
1380
- if (!!sfmt.match(reg)) {
1381
- if (isNaN(v)) {
1382
- return v;
1383
- }
1384
-
1385
- //var v =300101886.436;
1386
- var acc = sfmt.slice(1); //取得0/0.0/0.00
1387
- var isNegative = false;
1388
- if (!isNaN(v) && Number(v) < 0) {
1389
- isNegative = true;
1390
- v = Math.abs(v);
1391
- }
1392
- var vInt = parseInt(v);
1393
- var vlength = vInt.toString().length;
1394
- if (vlength > 4) {
1395
- if (vlength > 8) {
1396
- var y = parseInt(v / 100000000); //亿
1397
- var w = parseInt(parseFloat(v) - y * 100000000 / 10000); //万
1398
- var q = parseFloat(v) - (y * 100000000 + w * 10000); //千以后
1399
- if (acc != "") {
1400
- q = numeral(q).format(acc); //处理精确度
1401
- }
1402
- v = y + "亿" + w + "万" + q;
1403
- } else {
1404
- var w = parseInt(v / 10000); //万
1405
- var q = parseFloat(v) - w * 10000; //千以后
1406
- if (acc != "") {
1407
- q = numeral(q).format(acc); //处理精确度
1408
- }
1409
- v = w + "万" + q;
1410
- }
1411
- if (v.indexOf("亿0万0") != -1) {
1412
- v = v.replace("0万0", "");
1413
- } else if (v.indexOf("亿0万") != -1) {
1414
- v = v.replace("0万", "");
1415
- } else if (v.indexOf("万0") != -1) {
1416
- v = v.replace("万0", "万");
1417
- }
1418
-
1419
- //舍弃正则后顾断言写法,旧浏览器不识别(360 V9)
1420
- if (v.indexOf("亿") != -1 && v.indexOf("万") == -1) {
1421
- //1亿/1亿111 => 1亿/1亿0111
1422
- var afterYi = v.substring(v.indexOf("亿") + 1);
1423
- if (afterYi.substring(0, 1) !== "." && afterYi != "") {
1424
- switch ((parseInt(afterYi) + "").length) {
1425
- case 1:
1426
- afterYi = "000" + afterYi;
1427
- break;
1428
- case 2:
1429
- afterYi = "00" + afterYi;
1430
- break;
1431
- case 3:
1432
- afterYi = "0" + afterYi;
1433
- break;
1434
- }
1435
- v = v.substring(0, v.indexOf("亿") + 1) + afterYi;
1436
- }
1437
- } else if (v.indexOf("亿") == -1 && v.indexOf("万") != -1) {
1438
- //3万0011
1439
- var afterWan = v.substring(v.indexOf("万") + 1);
1440
- if (afterWan.substring(0, 1) !== "." && afterWan != "") {
1441
- switch ((parseInt(afterWan) + "").length) {
1442
- case 1:
1443
- afterWan = "000" + afterWan;
1444
- break;
1445
- case 2:
1446
- afterWan = "00" + afterWan;
1447
- break;
1448
- case 3:
1449
- afterWan = "0" + afterWan;
1450
- break;
1451
- }
1452
- v = v.substring(0, v.indexOf("万") + 1) + afterWan;
1453
- }
1454
- } else if (v.indexOf("亿") != -1 && v.indexOf("万") != -1) {
1455
- //1亿0053万0611
1456
- var afterYi = v.substring(v.indexOf("亿") + 1, v.indexOf("万")),
1457
- afterWan = v.substring(v.indexOf("万") + 1);
1458
- switch ((parseInt(afterYi) + "").length) {
1459
- case 1:
1460
- afterYi = "000" + afterYi;
1461
- break;
1462
- case 2:
1463
- afterYi = "00" + afterYi;
1464
- break;
1465
- case 3:
1466
- afterYi = "0" + afterYi;
1467
- break;
1468
- }
1469
- v = v.substring(0, v.indexOf("亿") + 1) + afterYi + v.substring(v.indexOf("万"));
1470
- if (afterWan.substring(0, 1) !== "." && afterWan != "") {
1471
- switch ((parseInt(afterWan) + "").length) {
1472
- case 1:
1473
- afterWan = "000" + afterWan;
1474
- break;
1475
- case 2:
1476
- afterWan = "00" + afterWan;
1477
- break;
1478
- case 3:
1479
- afterWan = "0" + afterWan;
1480
- break;
1481
- }
1482
- v = v.substring(0, v.indexOf("万") + 1) + afterWan;
1483
- }
1484
- }
1485
- } else {
1486
- if (acc != "") {
1487
- v = numeral(v).format(acc); //处理精确度
1488
- }
1489
- }
1490
- if (isNegative) {
1491
- return "-" + v;
1492
- } else {
1493
- return v;
1494
- }
1495
- }
1496
- if (isgeneral(sfmt, 0)) return general_fmt(v, o);
1497
- if (v instanceof Date) v = datenum_local(v, o.date1904);
1498
- var f = choose_fmt(sfmt, v);
1499
- if (isgeneral(f[1])) return general_fmt(v, o);
1500
- if (v === true) v = "TRUE";else if (v === false) v = "FALSE";else if (v === "" || v == null) return "";
1501
- return eval_fmt(f[1], v, o, f[0]);
1502
- }
1503
- function load_entry(fmt, idx) {
1504
- if (typeof idx != "number") {
1505
- idx = +idx || -1;
1506
- for (var i = 0; i < 0x0188; ++i) {
1507
- if (table_fmt[i] == undefined) {
1508
- if (idx < 0) idx = i;
1509
- continue;
1510
- }
1511
- if (table_fmt[i] == fmt) {
1512
- idx = i;
1513
- break;
1514
- }
1515
- }
1516
- if (idx < 0) idx = 0x187;
1517
- }
1518
- table_fmt[idx] = fmt;
1519
- return idx;
1520
- }
1521
- SSF.load = load_entry;
1522
- SSF._table = table_fmt;
1523
- SSF.get_table = function get_table() {
1524
- return table_fmt;
1525
- };
1526
- SSF.load_table = function load_table(tbl) {
1527
- for (var i = 0; i != 0x0188; ++i) if (tbl[i] !== undefined) load_entry(tbl[i], i);
1528
- };
1529
- SSF.init_table = init_table;
1530
- SSF.format = format;
1531
- };
1532
- make_ssf(SSF);
1533
- export default SSF;