@cloudtower/eagle 0.27.53 → 0.27.55

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 (323) hide show
  1. package/dist/cjs/UIKitProvider/index.js +77 -0
  2. package/dist/cjs/core/AccordionCard/index.js +59 -0
  3. package/dist/cjs/core/Alert/index.js +80 -0
  4. package/dist/cjs/core/Arch/index.js +17 -0
  5. package/dist/cjs/core/Badge/index.js +51 -0
  6. package/dist/cjs/core/BaseIcon/index.js +76 -0
  7. package/dist/cjs/core/Bit/index.js +40 -0
  8. package/dist/cjs/core/BitPerSecond/index.js +40 -0
  9. package/dist/cjs/core/Bps/index.js +40 -0
  10. package/dist/cjs/core/Breadcrumb/index.js +58 -0
  11. package/dist/cjs/core/Button/HoverableElement.js +14 -0
  12. package/dist/cjs/core/Button/index.js +89 -0
  13. package/dist/cjs/core/ButtonGroup/index.js +110 -0
  14. package/dist/cjs/core/Byte/index.js +49 -0
  15. package/dist/cjs/core/Calendar/index.js +25 -0
  16. package/dist/cjs/core/Card/CardBody.js +12 -0
  17. package/dist/cjs/core/Card/CardTitle.js +12 -0
  18. package/dist/cjs/core/Card/CardWrapper.js +55 -0
  19. package/dist/cjs/core/Card/index.js +94 -0
  20. package/dist/cjs/core/Cascader/cascader.style.js +23 -0
  21. package/dist/cjs/core/Cascader/cascader.widget.js +86 -0
  22. package/dist/cjs/core/Cascader/index.js +74 -0
  23. package/dist/cjs/core/Checkbox/checkbox.style.js +5 -0
  24. package/dist/cjs/core/Checkbox/index.js +53 -0
  25. package/dist/cjs/core/DetailCard/index.js +23 -0
  26. package/dist/cjs/core/DonutChart/index.js +167 -0
  27. package/dist/cjs/core/DropdownMenu/index.js +66 -0
  28. package/dist/cjs/core/Empty/index.js +11 -0
  29. package/dist/cjs/core/ExpandableList/ExpandIcon.js +17 -0
  30. package/dist/cjs/core/ExpandableList/ExpandableContainer.js +17 -0
  31. package/dist/cjs/core/ExpandableList/ExpandableItem.js +48 -0
  32. package/dist/cjs/core/ExpandableList/RoundOrder.js +22 -0
  33. package/dist/cjs/core/FailedLoad/index.js +32 -0
  34. package/dist/cjs/core/Fields/FieldsBoolean/index.js +47 -0
  35. package/dist/cjs/core/Fields/FieldsDateTime/index.js +24 -0
  36. package/dist/cjs/core/Fields/FieldsDateTimeRange/index.js +50 -0
  37. package/dist/cjs/core/Fields/FieldsEnum/index.js +60 -0
  38. package/dist/cjs/core/Fields/FieldsFloat/index.js +60 -0
  39. package/dist/cjs/core/Fields/FieldsInt/index.js +78 -0
  40. package/dist/cjs/core/Fields/FieldsInteger/index.js +57 -0
  41. package/dist/cjs/core/Fields/FieldsString/index.js +116 -0
  42. package/dist/cjs/core/Fields/FieldsTextArea/index.js +64 -0
  43. package/dist/cjs/core/Fields/FieldsTimePicker/index.js +54 -0
  44. package/dist/cjs/core/Fields/index.js +28 -0
  45. package/dist/cjs/core/Form/index.js +10 -0
  46. package/dist/cjs/core/FormItem/index.js +38 -0
  47. package/dist/cjs/core/Frequency/index.js +40 -0
  48. package/dist/cjs/core/Icon/index.js +117 -0
  49. package/dist/cjs/core/Input/index.js +66 -0
  50. package/dist/cjs/core/InputGroup/index.js +14 -0
  51. package/dist/cjs/core/InputInteger/formatterInteger.js +15 -0
  52. package/dist/cjs/core/InputInteger/index.js +97 -0
  53. package/dist/cjs/core/InputNumber/index.js +90 -0
  54. package/dist/cjs/core/InputTagItem/index.js +12 -0
  55. package/dist/cjs/core/KitStoreProvider/index.js +23 -0
  56. package/dist/cjs/core/Link/index.js +56 -0
  57. package/dist/cjs/core/Loading/index.js +33 -0
  58. package/dist/cjs/core/Loading/style.js +11 -0
  59. package/dist/cjs/core/Metric/metric.js +21 -0
  60. package/dist/cjs/core/Modal/index.js +214 -0
  61. package/dist/cjs/core/ModalStack/index.js +47 -0
  62. package/dist/cjs/core/Overflow/index.js +117 -0
  63. package/dist/cjs/core/Pagination/index.js +120 -0
  64. package/dist/cjs/core/ParrotTrans/index.js +28 -0
  65. package/dist/cjs/core/Percent/index.js +41 -0
  66. package/dist/cjs/core/Progress/index.js +25 -0
  67. package/dist/cjs/core/Radio/index.js +142 -0
  68. package/dist/cjs/core/SearchInput/index.js +50 -0
  69. package/dist/cjs/core/Second/index.js +43 -0
  70. package/dist/cjs/core/SegmentControl/index.js +43 -0
  71. package/dist/cjs/core/Select/index.js +140 -0
  72. package/dist/cjs/core/SimplePagination/index.js +90 -0
  73. package/dist/cjs/core/Speed/index.js +40 -0
  74. package/dist/cjs/core/StatusCapsule/index.js +100 -0
  75. package/dist/cjs/core/StepProgress/index.js +44 -0
  76. package/dist/cjs/core/Steps/index.js +126 -0
  77. package/dist/cjs/core/Steps/style.js +13 -0
  78. package/dist/cjs/core/Styled/index.js +57 -0
  79. package/dist/cjs/core/Switch/index.js +61 -0
  80. package/dist/cjs/core/Table/TableWidget.js +47 -0
  81. package/dist/cjs/core/Table/common.js +46 -0
  82. package/dist/cjs/core/Table/index.js +112 -0
  83. package/dist/cjs/core/TableForm/AddRowButton.js +108 -0
  84. package/dist/cjs/core/TableForm/Columns/AffixColumn.js +48 -0
  85. package/dist/cjs/core/TableForm/Columns/CheckboxColumn.js +35 -0
  86. package/dist/cjs/core/TableForm/Columns/FormItem.js +20 -0
  87. package/dist/cjs/core/TableForm/Columns/InputColumn.js +117 -0
  88. package/dist/cjs/core/TableForm/Columns/TextColumn.js +44 -0
  89. package/dist/cjs/core/TableForm/Columns/index.js +24 -0
  90. package/dist/cjs/core/TableForm/TableFormBodyCell.js +165 -0
  91. package/dist/cjs/core/TableForm/TableFormBodyRows.js +215 -0
  92. package/dist/cjs/core/TableForm/TableFormHeaderCell.js +93 -0
  93. package/dist/cjs/core/TableForm/index.js +187 -0
  94. package/dist/cjs/core/TableForm/style.js +35 -0
  95. package/dist/cjs/core/TableForm/types.js +10 -0
  96. package/dist/cjs/core/TableForm/utils.js +36 -0
  97. package/dist/cjs/core/Tag/SplitTag.js +64 -0
  98. package/dist/cjs/core/Tag/const.js +12 -0
  99. package/dist/cjs/core/Tag/index.js +96 -0
  100. package/dist/cjs/core/Tag/style.js +14 -0
  101. package/dist/cjs/core/TextArea/index.js +72 -0
  102. package/dist/cjs/core/Time/index.js +31 -0
  103. package/dist/cjs/core/TimePicker/index.js +66 -0
  104. package/dist/cjs/core/TimeZoneSelect/index.js +165 -0
  105. package/dist/cjs/core/Token/index.js +86 -0
  106. package/dist/cjs/core/Token/style.js +5 -0
  107. package/dist/cjs/core/Tooltip/index.js +89 -0
  108. package/dist/cjs/core/Truncate/index.js +49 -0
  109. package/dist/cjs/core/Typo/index.js +130 -0
  110. package/dist/cjs/core/antd.js +208 -0
  111. package/dist/cjs/core/message/index.js +203 -0
  112. package/dist/cjs/core/message-group/index.js +147 -0
  113. package/dist/cjs/coreX/BarChart/index.js +39 -0
  114. package/dist/cjs/coreX/BatchOperation/index.js +149 -0
  115. package/dist/cjs/coreX/ChartWithTooltip/index.js +154 -0
  116. package/dist/cjs/coreX/Counting/index.js +22 -0
  117. package/dist/cjs/coreX/CronCalendar/index.js +105 -0
  118. package/dist/cjs/coreX/CronPlan/index.js +462 -0
  119. package/dist/cjs/coreX/DateRangePicker/AbsoluteDate.js +179 -0
  120. package/dist/cjs/coreX/DateRangePicker/Calendar.js +286 -0
  121. package/dist/cjs/coreX/DateRangePicker/DateRangePicker.style.js +84 -0
  122. package/dist/cjs/coreX/DateRangePicker/InputTime.js +151 -0
  123. package/dist/cjs/coreX/DateRangePicker/RelativeTime.js +53 -0
  124. package/dist/cjs/coreX/DateRangePicker/common.js +195 -0
  125. package/dist/cjs/coreX/DateRangePicker/index.js +331 -0
  126. package/dist/cjs/coreX/DeprecatedDonutChart/index.js +39 -0
  127. package/dist/cjs/coreX/DropdownTransition/index.js +73 -0
  128. package/dist/cjs/coreX/GoBackButton/index.js +45 -0
  129. package/dist/cjs/coreX/I18nNameTag/index.js +37 -0
  130. package/dist/cjs/coreX/NamesTooltip/index.js +34 -0
  131. package/dist/cjs/coreX/OverflowTooltip/index.js +92 -0
  132. package/dist/cjs/coreX/SidebarSubtitle/index.js +13 -0
  133. package/dist/cjs/coreX/SortableList/index.js +33 -0
  134. package/dist/cjs/coreX/SummaryTable/index.js +113 -0
  135. package/dist/cjs/coreX/SwitchWithText/index.js +59 -0
  136. package/dist/cjs/coreX/TabMenu/index.js +152 -0
  137. package/dist/cjs/coreX/TruncatedTextWithTooltip/index.js +69 -0
  138. package/dist/cjs/coreX/UnitWithChart/index.js +118 -0
  139. package/dist/cjs/coreX/common/getCalendarTitle.js +26 -0
  140. package/dist/cjs/hooks/useElementIntersectionRatio.js +30 -0
  141. package/dist/cjs/hooks/useElementResize.js +69 -0
  142. package/dist/cjs/hooks/useElementsSize.js +58 -0
  143. package/dist/cjs/hooks/useMemoCompare.js +17 -0
  144. package/dist/cjs/hooks/useParrotTranslation.js +13 -0
  145. package/dist/cjs/index.js +120 -0
  146. package/dist/cjs/spec/type.js +9 -0
  147. package/dist/{umd → cjs}/stats1.html +1 -1
  148. package/dist/cjs/store/chart.js +65 -0
  149. package/dist/cjs/store/index.js +48 -0
  150. package/dist/cjs/store/modal.js +67 -0
  151. package/dist/cjs/styles/token/color.js +273 -0
  152. package/dist/cjs/utils/constants.js +8 -0
  153. package/dist/cjs/utils/cron-time.js +450 -0
  154. package/dist/cjs/utils/dom.js +16 -0
  155. package/dist/cjs/utils/icon.js +22 -0
  156. package/dist/cjs/utils/isEmpty.js +12 -0
  157. package/dist/cjs/utils/time.js +86 -0
  158. package/dist/cjs/utils/tower.js +188 -0
  159. package/dist/components.css +3101 -2209
  160. package/dist/esm/UIKitProvider/index.js +71 -0
  161. package/dist/esm/core/AccordionCard/index.js +57 -0
  162. package/dist/esm/core/Alert/index.js +78 -0
  163. package/dist/esm/core/Arch/index.js +15 -0
  164. package/dist/esm/core/Badge/index.js +49 -0
  165. package/dist/esm/core/BaseIcon/index.js +74 -0
  166. package/dist/esm/core/Bit/index.js +38 -0
  167. package/dist/esm/core/BitPerSecond/index.js +38 -0
  168. package/dist/esm/core/Bps/index.js +38 -0
  169. package/dist/esm/core/Breadcrumb/index.js +53 -0
  170. package/dist/esm/core/Button/HoverableElement.js +12 -0
  171. package/dist/esm/core/Button/index.js +87 -0
  172. package/dist/esm/core/ButtonGroup/index.js +105 -0
  173. package/dist/esm/core/Byte/index.js +47 -0
  174. package/dist/esm/core/Calendar/index.js +23 -0
  175. package/dist/esm/core/Card/CardBody.js +10 -0
  176. package/dist/esm/core/Card/CardTitle.js +10 -0
  177. package/dist/esm/core/Card/CardWrapper.js +53 -0
  178. package/dist/esm/core/Card/index.js +92 -0
  179. package/dist/esm/core/Cascader/cascader.style.js +12 -0
  180. package/dist/esm/core/Cascader/cascader.widget.js +79 -0
  181. package/dist/esm/core/Cascader/index.js +72 -0
  182. package/dist/esm/core/Checkbox/checkbox.style.js +3 -0
  183. package/dist/esm/core/Checkbox/index.js +51 -0
  184. package/dist/esm/core/DetailCard/index.js +21 -0
  185. package/dist/esm/core/DonutChart/index.js +161 -0
  186. package/dist/esm/core/DropdownMenu/index.js +61 -0
  187. package/dist/esm/core/Empty/index.js +9 -0
  188. package/dist/esm/core/ExpandableList/ExpandIcon.js +15 -0
  189. package/dist/esm/core/ExpandableList/ExpandableContainer.js +15 -0
  190. package/dist/esm/core/ExpandableList/ExpandableItem.js +46 -0
  191. package/dist/esm/core/ExpandableList/RoundOrder.js +20 -0
  192. package/dist/esm/core/FailedLoad/index.js +30 -0
  193. package/dist/esm/core/Fields/FieldsBoolean/index.js +45 -0
  194. package/dist/esm/core/Fields/FieldsDateTime/index.js +22 -0
  195. package/dist/esm/core/Fields/FieldsDateTimeRange/index.js +48 -0
  196. package/dist/esm/core/Fields/FieldsEnum/index.js +58 -0
  197. package/dist/esm/core/Fields/FieldsFloat/index.js +58 -0
  198. package/dist/esm/core/Fields/FieldsInt/index.js +76 -0
  199. package/dist/esm/core/Fields/FieldsInteger/index.js +55 -0
  200. package/dist/esm/core/Fields/FieldsString/index.js +114 -0
  201. package/dist/esm/core/Fields/FieldsTextArea/index.js +62 -0
  202. package/dist/esm/core/Fields/FieldsTimePicker/index.js +52 -0
  203. package/dist/esm/core/Fields/index.js +26 -0
  204. package/dist/esm/core/Form/index.js +8 -0
  205. package/dist/esm/core/FormItem/index.js +36 -0
  206. package/dist/esm/core/Frequency/index.js +38 -0
  207. package/dist/esm/core/Icon/index.js +115 -0
  208. package/dist/esm/core/Input/index.js +64 -0
  209. package/dist/esm/core/InputGroup/index.js +12 -0
  210. package/dist/esm/core/InputInteger/formatterInteger.js +13 -0
  211. package/dist/esm/core/InputInteger/index.js +92 -0
  212. package/dist/esm/core/InputNumber/index.js +85 -0
  213. package/dist/esm/core/InputTagItem/index.js +10 -0
  214. package/dist/esm/core/KitStoreProvider/index.js +17 -0
  215. package/dist/esm/core/Link/index.js +54 -0
  216. package/dist/esm/core/Loading/index.js +31 -0
  217. package/dist/esm/core/Loading/style.js +6 -0
  218. package/dist/esm/core/Metric/metric.js +19 -0
  219. package/dist/esm/core/Modal/index.js +212 -0
  220. package/dist/esm/core/ModalStack/index.js +45 -0
  221. package/dist/esm/core/Overflow/index.js +112 -0
  222. package/dist/esm/core/Pagination/index.js +115 -0
  223. package/dist/esm/core/ParrotTrans/index.js +26 -0
  224. package/dist/esm/core/Percent/index.js +39 -0
  225. package/dist/esm/core/Progress/index.js +23 -0
  226. package/dist/esm/core/Radio/index.js +136 -0
  227. package/dist/esm/core/SearchInput/index.js +48 -0
  228. package/dist/esm/core/Second/index.js +41 -0
  229. package/dist/esm/core/SegmentControl/index.js +41 -0
  230. package/dist/esm/core/Select/index.js +138 -0
  231. package/dist/esm/core/SimplePagination/index.js +88 -0
  232. package/dist/esm/core/Speed/index.js +38 -0
  233. package/dist/esm/core/StatusCapsule/index.js +94 -0
  234. package/dist/esm/core/StepProgress/index.js +42 -0
  235. package/dist/esm/core/Steps/index.js +124 -0
  236. package/dist/esm/core/Steps/style.js +7 -0
  237. package/dist/esm/core/Styled/index.js +45 -0
  238. package/dist/esm/core/Switch/index.js +59 -0
  239. package/dist/esm/core/Table/TableWidget.js +44 -0
  240. package/dist/esm/core/Table/common.js +44 -0
  241. package/dist/esm/core/Table/index.js +104 -0
  242. package/dist/esm/core/TableForm/AddRowButton.js +106 -0
  243. package/dist/esm/core/TableForm/Columns/AffixColumn.js +46 -0
  244. package/dist/esm/core/TableForm/Columns/CheckboxColumn.js +32 -0
  245. package/dist/esm/core/TableForm/Columns/FormItem.js +18 -0
  246. package/dist/esm/core/TableForm/Columns/InputColumn.js +114 -0
  247. package/dist/esm/core/TableForm/Columns/TextColumn.js +41 -0
  248. package/dist/esm/core/TableForm/Columns/index.js +21 -0
  249. package/dist/esm/core/TableForm/TableFormBodyCell.js +163 -0
  250. package/dist/esm/core/TableForm/TableFormBodyRows.js +213 -0
  251. package/dist/esm/core/TableForm/TableFormHeaderCell.js +91 -0
  252. package/dist/esm/core/TableForm/index.js +185 -0
  253. package/dist/esm/core/TableForm/style.js +27 -0
  254. package/dist/esm/core/TableForm/types.js +8 -0
  255. package/dist/esm/core/TableForm/utils.js +32 -0
  256. package/dist/esm/core/Tag/SplitTag.js +62 -0
  257. package/dist/esm/core/Tag/const.js +10 -0
  258. package/dist/esm/core/Tag/index.js +91 -0
  259. package/dist/esm/core/Tag/style.js +9 -0
  260. package/dist/esm/core/TextArea/index.js +70 -0
  261. package/dist/esm/core/Time/index.js +29 -0
  262. package/dist/esm/core/TimePicker/index.js +64 -0
  263. package/dist/esm/core/TimeZoneSelect/index.js +163 -0
  264. package/dist/esm/core/Token/index.js +81 -0
  265. package/dist/esm/core/Token/style.js +3 -0
  266. package/dist/esm/core/Tooltip/index.js +87 -0
  267. package/dist/esm/core/Truncate/index.js +47 -0
  268. package/dist/esm/core/Typo/index.js +128 -0
  269. package/dist/esm/core/antd.js +205 -0
  270. package/dist/esm/core/message/index.js +179 -0
  271. package/dist/esm/core/message-group/index.js +143 -0
  272. package/dist/esm/coreX/BarChart/index.js +34 -0
  273. package/dist/esm/coreX/BatchOperation/index.js +144 -0
  274. package/dist/esm/coreX/ChartWithTooltip/index.js +149 -0
  275. package/dist/esm/coreX/Counting/index.js +20 -0
  276. package/dist/esm/coreX/CronCalendar/index.js +103 -0
  277. package/dist/esm/coreX/CronPlan/index.js +457 -0
  278. package/dist/esm/coreX/DateRangePicker/AbsoluteDate.js +177 -0
  279. package/dist/esm/coreX/DateRangePicker/Calendar.js +284 -0
  280. package/dist/esm/coreX/DateRangePicker/DateRangePicker.style.js +77 -0
  281. package/dist/esm/coreX/DateRangePicker/InputTime.js +149 -0
  282. package/dist/esm/coreX/DateRangePicker/RelativeTime.js +51 -0
  283. package/dist/esm/coreX/DateRangePicker/common.js +183 -0
  284. package/dist/esm/coreX/DateRangePicker/index.js +325 -0
  285. package/dist/esm/coreX/DeprecatedDonutChart/index.js +37 -0
  286. package/dist/esm/coreX/DropdownTransition/index.js +71 -0
  287. package/dist/esm/coreX/GoBackButton/index.js +43 -0
  288. package/dist/esm/coreX/I18nNameTag/index.js +35 -0
  289. package/dist/esm/coreX/NamesTooltip/index.js +32 -0
  290. package/dist/esm/coreX/OverflowTooltip/index.js +90 -0
  291. package/dist/esm/coreX/SidebarSubtitle/index.js +11 -0
  292. package/dist/esm/coreX/SortableList/index.js +31 -0
  293. package/dist/esm/coreX/SummaryTable/index.js +108 -0
  294. package/dist/esm/coreX/SwitchWithText/index.js +57 -0
  295. package/dist/esm/coreX/TabMenu/index.js +150 -0
  296. package/dist/esm/coreX/TruncatedTextWithTooltip/index.js +67 -0
  297. package/dist/esm/coreX/UnitWithChart/index.js +113 -0
  298. package/dist/esm/coreX/common/getCalendarTitle.js +24 -0
  299. package/dist/esm/hooks/useElementIntersectionRatio.js +28 -0
  300. package/dist/esm/hooks/useElementResize.js +67 -0
  301. package/dist/esm/hooks/useElementsSize.js +56 -0
  302. package/dist/esm/hooks/useMemoCompare.js +15 -0
  303. package/dist/esm/hooks/useParrotTranslation.js +11 -0
  304. package/dist/esm/index.js +34 -10233
  305. package/dist/esm/spec/type.js +7 -0
  306. package/dist/esm/stats1.html +1 -1
  307. package/dist/esm/store/chart.js +62 -0
  308. package/dist/esm/store/index.js +37 -0
  309. package/dist/esm/store/modal.js +63 -0
  310. package/dist/esm/styles/token/color.js +271 -0
  311. package/dist/esm/utils/constants.js +5 -0
  312. package/dist/esm/utils/cron-time.js +448 -0
  313. package/dist/esm/utils/dom.js +14 -0
  314. package/dist/esm/utils/icon.js +20 -0
  315. package/dist/esm/utils/isEmpty.js +10 -0
  316. package/dist/esm/utils/time.js +76 -0
  317. package/dist/esm/utils/tower.js +173 -0
  318. package/dist/src/index.d.ts +0 -1
  319. package/dist/style.css +2011 -2011
  320. package/dist/token.css +209 -415
  321. package/package.json +8 -6
  322. package/dist/src/styles/token/token.d.ts +0 -1
  323. package/dist/umd/index.js +0 -10322
@@ -0,0 +1,188 @@
1
+ 'use strict';
2
+
3
+ const MAGIC_METRIC_NULL = -2;
4
+ function formatBits(bits, decimals = 2) {
5
+ if (bits <= 0 || bits === MAGIC_METRIC_NULL) {
6
+ return {
7
+ value: 0,
8
+ unit: "b"
9
+ };
10
+ }
11
+ const k = 1e3;
12
+ const units = ["b", "Kb", "Mb", "Gb", "Tb", "Pb"];
13
+ let i = Math.floor(Math.log(bits) / Math.log(k));
14
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
15
+ return {
16
+ value: parseFloat((bits / Math.pow(k, i)).toFixed(decimals)),
17
+ unit: units[i]
18
+ };
19
+ }
20
+ function formatFrequency(frequency, decimals = 2) {
21
+ if (frequency <= 0 || frequency === MAGIC_METRIC_NULL) {
22
+ return {
23
+ value: 0,
24
+ unit: "Hz"
25
+ };
26
+ }
27
+ const k = 1e3;
28
+ const units = ["Hz", "KHz", "MHz", "GHz", "THz"];
29
+ let i = Math.floor(Math.log(frequency) / Math.log(k));
30
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
31
+ return {
32
+ value: parseFloat((frequency / Math.pow(k, i)).toFixed(decimals)),
33
+ unit: units[i]
34
+ };
35
+ }
36
+ const SECOND = 1;
37
+ const MINUTE = 60 * SECOND;
38
+ const HOUR = 60 * MINUTE;
39
+ const DAY = 24 * HOUR;
40
+ const WEEK = 7 * DAY;
41
+ function formatSeconds(seconds, decimals = 0) {
42
+ if (seconds <= MAGIC_METRIC_NULL) {
43
+ seconds = 0;
44
+ }
45
+ const units = [
46
+ {
47
+ value: WEEK,
48
+ unit: "week"
49
+ },
50
+ {
51
+ value: DAY,
52
+ unit: "day"
53
+ },
54
+ {
55
+ value: HOUR,
56
+ unit: "hour"
57
+ },
58
+ {
59
+ value: MINUTE,
60
+ unit: "minute"
61
+ },
62
+ {
63
+ value: SECOND,
64
+ unit: "second"
65
+ }
66
+ ];
67
+ for (const unit of units) {
68
+ if (seconds > unit.value) {
69
+ return {
70
+ value: parseFloat((seconds / unit.value).toFixed(decimals)),
71
+ unit: unit.unit
72
+ };
73
+ }
74
+ }
75
+ return {
76
+ value: parseFloat((seconds / SECOND).toFixed(decimals)),
77
+ unit: "second"
78
+ };
79
+ }
80
+ function formatBitPerSecond(input, decimals = 1) {
81
+ if (input <= 0 || input === MAGIC_METRIC_NULL) {
82
+ return {
83
+ value: 0,
84
+ unit: "bps"
85
+ };
86
+ }
87
+ const k = 1e3;
88
+ const units = ["bps", "Kbps", "Mbps", "Gbps", "Tbps"];
89
+ let i = Math.floor(Math.log(input) / Math.log(k));
90
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
91
+ return {
92
+ value: parseFloat((input / Math.pow(k, i)).toFixed(decimals)),
93
+ unit: units[i]
94
+ };
95
+ }
96
+ function formatBps(input, decimals = 1) {
97
+ if (input <= 0 || input === MAGIC_METRIC_NULL) {
98
+ return {
99
+ value: 0,
100
+ unit: "Bps"
101
+ };
102
+ }
103
+ const k = 1e3;
104
+ const units = ["Bps", "KBps", "MBps", "GBps", "TBps"];
105
+ let i = Math.floor(Math.log(input) / Math.log(k));
106
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
107
+ return {
108
+ value: parseFloat((input / Math.pow(k, i)).toFixed(decimals)),
109
+ unit: units[i]
110
+ };
111
+ }
112
+ function formatBytes(bytes, decimals = 2) {
113
+ if (bytes <= 0 || bytes === MAGIC_METRIC_NULL) {
114
+ return {
115
+ value: 0,
116
+ unit: "B"
117
+ };
118
+ }
119
+ const k = 1024;
120
+ const units = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"];
121
+ let i = Math.floor(Math.log(bytes) / Math.log(k));
122
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
123
+ return {
124
+ value: parseFloat((bytes / Math.pow(k, i)).toFixed(decimals)),
125
+ unit: units[i]
126
+ };
127
+ }
128
+ function formatPercent(input, decimals = 2, saturated = true) {
129
+ if (input === MAGIC_METRIC_NULL) {
130
+ input = 0;
131
+ }
132
+ if (saturated) {
133
+ if (input <= 0) {
134
+ input = 0;
135
+ }
136
+ if (input > 100) {
137
+ input = 100;
138
+ }
139
+ }
140
+ const value = input.toFixed(decimals);
141
+ if (parseFloat(value) === 0 && input > 0) {
142
+ if (decimals >= 1) {
143
+ return {
144
+ value: `0.${"0".repeat(decimals - 1)}1`,
145
+ numberValue: parseFloat(`0.${"0".repeat(decimals - 1)}1`),
146
+ unit: "%"
147
+ };
148
+ }
149
+ return {
150
+ value: "1",
151
+ numberValue: 1,
152
+ unit: "%"
153
+ };
154
+ }
155
+ return {
156
+ value,
157
+ numberValue: parseFloat(input.toFixed(decimals)),
158
+ unit: "%"
159
+ };
160
+ }
161
+ function formatSpeed(input, decimals = 0) {
162
+ input /= 1e3;
163
+ if (input < 1)
164
+ return { value: "-", unit: "" };
165
+ const units = ["KbE", "MbE", "GbE", "TbE"];
166
+ const k = 1e3;
167
+ let i = Math.floor(Math.log(input) / Math.log(k));
168
+ i = i < 0 ? 0 : i > units.length - 1 ? units.length - 1 : i;
169
+ return {
170
+ value: parseFloat((input / Math.pow(k, i)).toFixed(decimals)),
171
+ unit: units[i]
172
+ };
173
+ }
174
+
175
+ exports.DAY = DAY;
176
+ exports.HOUR = HOUR;
177
+ exports.MAGIC_METRIC_NULL = MAGIC_METRIC_NULL;
178
+ exports.MINUTE = MINUTE;
179
+ exports.SECOND = SECOND;
180
+ exports.WEEK = WEEK;
181
+ exports.formatBitPerSecond = formatBitPerSecond;
182
+ exports.formatBits = formatBits;
183
+ exports.formatBps = formatBps;
184
+ exports.formatBytes = formatBytes;
185
+ exports.formatFrequency = formatFrequency;
186
+ exports.formatPercent = formatPercent;
187
+ exports.formatSeconds = formatSeconds;
188
+ exports.formatSpeed = formatSpeed;