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