@stokr/components-library 3.2.0 → 4.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 (244) hide show
  1. package/dist/components/AdminDashboard/Table/Table.styles.js +7 -13
  2. package/dist/components/BasicTable/BasicTable.js +1 -3
  3. package/dist/components/BlogPost/BlogPost.styles.js +2 -2
  4. package/dist/components/Button/Button.styles.d.ts +28 -0
  5. package/dist/components/Button/Button.styles.js +27 -38
  6. package/dist/components/Button/GlareButton.js +2 -2
  7. package/dist/components/CardTabs/CardTabs.d.ts +41 -0
  8. package/dist/components/CardTabs/CardTabs.js +130 -0
  9. package/dist/components/CardTabs/CardTabs.styles.d.ts +56 -0
  10. package/dist/components/CardTabs/CardTabs.styles.js +171 -0
  11. package/dist/components/Chips/Chip.js +32 -8
  12. package/dist/components/Chips/Chip.styles.js +24 -28
  13. package/dist/components/Collapsible/Collapsible.d.ts +18 -0
  14. package/dist/components/Collapsible/Collapsible.js +44 -0
  15. package/dist/components/Collapsible/Collapsible.styles.d.ts +18 -0
  16. package/dist/components/Collapsible/Collapsible.styles.js +94 -0
  17. package/dist/components/ComponentWrapper/ComponentWrapper.styles.d.ts +31 -0
  18. package/dist/components/ComponentWrapper/ComponentWrapper.styles.js +107 -109
  19. package/dist/components/Copy/Copy.d.ts +20 -0
  20. package/dist/components/Copy/Copy.js +0 -9
  21. package/dist/components/Copy/copySource.d.ts +20 -0
  22. package/dist/components/Copy/flatten.d.ts +3 -0
  23. package/dist/components/CopyToClipboardTooltip/CopyToClipboardTooltip.d.ts +15 -0
  24. package/dist/components/CopyToClipboardTooltip/CopyToClipboardTooltip.styles.d.ts +6 -0
  25. package/dist/components/CryptoAddress/CryptoAddress.js +3 -3
  26. package/dist/components/InfoIcon/InfoIcon.d.ts +33 -0
  27. package/dist/components/InfoIcon/InfoIcon.styles.d.ts +12 -0
  28. package/dist/components/Input/Input.d.ts +23 -0
  29. package/dist/components/Input/Input.js +17 -27
  30. package/dist/components/Input/Input.styles.d.ts +15 -0
  31. package/dist/components/Input/InputPassword.js +1 -0
  32. package/dist/components/Input/InputPassword.styles.js +4 -1
  33. package/dist/components/Input/MultiSelect.js +1 -0
  34. package/dist/components/Input/RangeInput.js +49 -53
  35. package/dist/components/Input/Textarea.styles.js +1 -1
  36. package/dist/components/MaterialIcon/MaterialIcon.d.ts +43 -0
  37. package/dist/components/MaterialIcon/MaterialIcon.js +56 -0
  38. package/dist/components/MaterialIcon/MaterialIcon.styles.d.ts +9 -0
  39. package/dist/components/MaterialIcon/MaterialIcon.styles.js +25 -0
  40. package/dist/components/MaterialIcon/iconConfig.d.ts +3 -0
  41. package/dist/components/MaterialIcon/iconConfig.js +11 -0
  42. package/dist/components/Modal/Modal.d.ts +26 -0
  43. package/dist/components/Modal/Modal.js +1 -18
  44. package/dist/components/Modal/Modal.styles.d.ts +59 -0
  45. package/dist/components/Modal/Modal.styles.js +18 -3
  46. package/dist/components/Modal/PaymentModal.js +16 -19
  47. package/dist/components/Modal/SideModal.d.ts +47 -0
  48. package/dist/components/Modal/SideModal.js +197 -73
  49. package/dist/components/Modal/SideModal.styles.d.ts +28 -0
  50. package/dist/components/Modal/SideModal.styles.js +56 -16
  51. package/dist/components/Modal/SideModalContext.d.ts +12 -0
  52. package/dist/components/Modal/SideModalContext.js +10 -0
  53. package/dist/components/Modal/SideModalParts.d.ts +20 -0
  54. package/dist/components/Modal/SideModalParts.js +95 -0
  55. package/dist/components/Pagination/Pagination.js +2 -2
  56. package/dist/components/Pagination/PaginationControls.js +2 -2
  57. package/dist/components/Payment/TimerComponent.js +1 -2
  58. package/dist/components/RefreshButton/RefreshButton.styles.js +2 -2
  59. package/dist/components/RequestDataBox/RequestDataBox.js +2 -2
  60. package/dist/components/Section/Section.d.ts +32 -0
  61. package/dist/components/Section/Section.js +80 -0
  62. package/dist/components/Section/Section.styles.d.ts +34 -0
  63. package/dist/components/Section/Section.styles.js +143 -0
  64. package/dist/components/Skeleton/Skeleton.d.ts +44 -0
  65. package/dist/components/Skeleton/Skeleton.js +48 -0
  66. package/dist/components/Skeleton/Skeleton.styles.d.ts +14 -0
  67. package/dist/components/Skeleton/Skeleton.styles.js +51 -0
  68. package/dist/components/StokrLoader/StokrLoader.d.ts +20 -0
  69. package/dist/components/StokrLoader/StokrLoader.js +21 -22
  70. package/dist/components/Tabs/Tabs.styles.js +3 -1
  71. package/dist/components/TabsNav/TabsNav.js +1 -1
  72. package/dist/components/TabsNav/TabsNav.styles.js +1 -1
  73. package/dist/components/Text/Text.styles.d.ts +20 -0
  74. package/dist/components/Text/Text.styles.js +2 -2
  75. package/dist/components/TextLink/TextLink.styles.js +1 -2
  76. package/dist/components/Tooltip/Tooltip.d.ts +42 -0
  77. package/dist/components/Tooltip/Tooltip.styles.d.ts +10 -0
  78. package/dist/constants/globalVariables.js +1 -39
  79. package/dist/hooks/useMediaQuery.d.ts +7 -0
  80. package/dist/hooks/useMediaQuery.js +19 -0
  81. package/dist/index.d.ts +299 -0
  82. package/dist/index.js +97 -224
  83. package/dist/styles/colors.d.ts +68 -0
  84. package/dist/styles/colors.js +13 -1
  85. package/dist/styles/elevation.d.ts +13 -0
  86. package/dist/styles/elevation.js +15 -0
  87. package/dist/styles/fonts.js +0 -65
  88. package/dist/styles/global.js +0 -2
  89. package/dist/styles/grid.d.ts +27 -0
  90. package/dist/styles/grid.js +8 -1
  91. package/dist/styles/rwd.d.ts +48 -0
  92. package/dist/styles/rwd.js +33 -17
  93. package/dist/styles/spacing.d.ts +36 -0
  94. package/dist/styles/spacing.js +30 -0
  95. package/dist/styles/theme.d.ts +92 -0
  96. package/dist/styles/theme.js +2 -0
  97. package/dist/styles/typography.d.ts +42 -0
  98. package/dist/styles/typography.js +56 -0
  99. package/dist/utils/capitalize.d.ts +2 -0
  100. package/dist/utils/capitalize.js +4 -0
  101. package/dist/utils/copy-text-to-clipboard.d.ts +10 -0
  102. package/dist/utils/copyToClipboard.d.ts +27 -0
  103. package/dist/utils/csv.d.ts +14 -0
  104. package/dist/utils/csv.js +25 -0
  105. package/dist/utils/customHooks.d.ts +20 -0
  106. package/dist/utils/customHooks.js +16 -11
  107. package/dist/utils/fix-decimals.d.ts +14 -0
  108. package/dist/utils/formatAmount.d.ts +109 -0
  109. package/dist/utils/formatAmount.js +170 -0
  110. package/dist/utils/formatCurrencyValue.d.ts +46 -0
  111. package/dist/utils/formatCurrencyValue.js +6 -21
  112. package/dist/utils/formatDate.d.ts +19 -0
  113. package/dist/utils/formatDate.js +44 -0
  114. package/dist/utils/get-short-address.d.ts +13 -0
  115. package/dist/utils/get-short-address.js +9 -2
  116. package/dist/utils/inertProp.d.ts +5 -0
  117. package/dist/utils/inertProp.js +6 -0
  118. package/dist/utils/isUSInvestor.d.ts +4 -0
  119. package/dist/utils/km_ify.d.ts +5 -0
  120. package/dist/utils/km_ify.js +19 -18
  121. package/dist/utils/password-validation.d.ts +16 -0
  122. package/dist/utils/saveAs.d.ts +2 -0
  123. package/dist/utils/saveAs.js +5 -2
  124. package/dist/utils/scrollUtils.d.ts +25 -0
  125. package/dist/utils/scrollUtils.js +13 -10
  126. package/dist/utils/transition.d.ts +45 -0
  127. package/dist/utils/transition.js +0 -28
  128. package/package.json +11 -13
  129. package/dist/analytics/index.js +0 -185
  130. package/dist/components/AccountBalance/AccountBalance.js +0 -35
  131. package/dist/components/AccountBalance/AccountBalance.styles.js +0 -48
  132. package/dist/components/AdminDashboard/Table/Table.js +0 -123
  133. package/dist/components/ButtonContainer/ButtonContainer.styles.js +0 -51
  134. package/dist/components/CryptoAddressDetails/CryptoAddressDetails.js +0 -34
  135. package/dist/components/CryptoAddressDetails/CryptoAddressDetails.styles.js +0 -125
  136. package/dist/components/DoubleButton/DoubleButton.styles.js +0 -27
  137. package/dist/components/ErrorMessage/ErrorMessage.styles.js +0 -9
  138. package/dist/components/Icon/Icon2.js +0 -12
  139. package/dist/components/Input/InputUsername.js +0 -92
  140. package/dist/components/Input/RangeInput.styles.js +0 -129
  141. package/dist/components/InvestmentStat/InvestmentStat.js +0 -24
  142. package/dist/components/InvestmentStat/InvestmentStat.styles.js +0 -62
  143. package/dist/components/LatestUpdate/LatestUpdate.js +0 -24
  144. package/dist/components/LatestUpdate/LatestUpdate.styles.js +0 -90
  145. package/dist/components/MultiProgressBar/MultiProgressBar.js +0 -28
  146. package/dist/components/MultiProgressBar/MultiProgressBar.styles.js +0 -105
  147. package/dist/components/PageTransition/PageTransition.js +0 -51
  148. package/dist/components/ProfileStat/ProfileStat.js +0 -29
  149. package/dist/components/ProfileStat/ProfileStat.styles.js +0 -90
  150. package/dist/components/SEO/SEO.js +0 -66
  151. package/dist/components/SideLine/SideLine.js +0 -7
  152. package/dist/components/SideLine/SideLine.styles.js +0 -33
  153. package/dist/components/Slider/Slider.js +0 -31
  154. package/dist/components/Slider/Slider.styles.js +0 -120
  155. package/dist/components/StatusBadge/StatusBadge.styles.js +0 -18
  156. package/dist/components/StokrLoader/media.js +0 -23
  157. package/dist/components/SvgIcons/CameraSvg.js +0 -31
  158. package/dist/components/SvgIcons/DocumentBackSvg.js +0 -20
  159. package/dist/components/SvgIcons/DocumentSmallSvg.js +0 -41
  160. package/dist/components/SvgIcons/DocumentSvg.js +0 -39
  161. package/dist/components/SvgIcons/EthSvg.js +0 -28
  162. package/dist/components/SvgIcons/EurSvg.js +0 -27
  163. package/dist/components/SvgIcons/FaceScanIconSvg.js +0 -17
  164. package/dist/components/SvgIcons/FourSvg.js +0 -7
  165. package/dist/components/SvgIcons/Glassess.js +0 -26
  166. package/dist/components/SvgIcons/OneSvg.js +0 -10
  167. package/dist/components/SvgIcons/PassportSvg.js +0 -37
  168. package/dist/components/SvgIcons/SocialInstagram.js +0 -13
  169. package/dist/components/SvgIcons/SocialMedium.js +0 -21
  170. package/dist/components/SvgIcons/SocialReddit.js +0 -21
  171. package/dist/components/SvgIcons/SocialYoutube.js +0 -22
  172. package/dist/components/SvgIcons/ThreeSvg.js +0 -7
  173. package/dist/components/SvgIcons/TwoSidedDocumentSvg.js +0 -48
  174. package/dist/components/SvgIcons/TwoSvg.js +0 -10
  175. package/dist/components/SvgIcons/UpdateDefaultSvg.js +0 -12
  176. package/dist/components/SvgIcons/UpdateHardSvg.js +0 -10
  177. package/dist/components/SvgIcons/UpdateSoftSvg.js +0 -11
  178. package/dist/components/SvgIcons/UploadSvg.js +0 -12
  179. package/dist/components/TeamOverview/TeamOverview.js +0 -79
  180. package/dist/components/TeamOverview/TeamOverview.styles.js +0 -167
  181. package/dist/components/TransactionDetails/TransactionDetails.js +0 -27
  182. package/dist/components/TransactionDetails/TransactionDetails.styles.js +0 -38
  183. package/dist/components/TransactionInfo/TransactionInfo.js +0 -41
  184. package/dist/components/TransactionInfo/TransactionInfo.styles.js +0 -75
  185. package/dist/components/icons/Arrow.js +0 -38
  186. package/dist/components/icons/Check.js +0 -16
  187. package/dist/components/icons/Facebook.js +0 -10
  188. package/dist/components/icons/Info.js +0 -27
  189. package/dist/components/icons/Instagram.js +0 -10
  190. package/dist/components/icons/LinkIcon.js +0 -49
  191. package/dist/components/icons/LinkedIn.js +0 -13
  192. package/dist/components/icons/Medium.js +0 -13
  193. package/dist/components/icons/Reddit.js +0 -16
  194. package/dist/components/icons/Share.js +0 -31
  195. package/dist/components/icons/Telegram.js +0 -13
  196. package/dist/components/icons/Twitter.js +0 -10
  197. package/dist/components/icons/X.js +0 -10
  198. package/dist/components/icons/Youtube.js +0 -10
  199. package/dist/components/icons/index.js +0 -32
  200. package/dist/components/landing-page/List.js +0 -51
  201. package/dist/components/landing-page/PageContent.js +0 -65
  202. package/dist/components/landing-page/PageText.js +0 -171
  203. package/dist/components/landing-page/PageTitle.js +0 -259
  204. package/dist/constants/style.js +0 -48
  205. package/dist/favicon.ico +0 -0
  206. package/dist/logo192.png +0 -0
  207. package/dist/logo512.png +0 -0
  208. package/dist/manifest.json +0 -25
  209. package/dist/robots.txt +0 -3
  210. package/dist/static/fonts/OpenSans/OpenSans-Bold.ttf +0 -0
  211. package/dist/static/fonts/OpenSans/OpenSans-Bold.ttf.js +0 -4
  212. package/dist/static/fonts/OpenSans/OpenSans-Bold.woff +0 -0
  213. package/dist/static/fonts/OpenSans/OpenSans-Bold.woff.js +0 -4
  214. package/dist/static/fonts/OpenSans/OpenSans-Bold.woff2 +0 -0
  215. package/dist/static/fonts/OpenSans/OpenSans-Bold.woff2.js +0 -4
  216. package/dist/static/fonts/OpenSans/OpenSans-ExtraBold.ttf +0 -0
  217. package/dist/static/fonts/OpenSans/OpenSans-ExtraBold.ttf.js +0 -4
  218. package/dist/static/fonts/OpenSans/OpenSans-ExtraBold.woff +0 -0
  219. package/dist/static/fonts/OpenSans/OpenSans-ExtraBold.woff.js +0 -4
  220. package/dist/static/fonts/OpenSans/OpenSans-ExtraBold.woff2 +0 -0
  221. package/dist/static/fonts/OpenSans/OpenSans-ExtraBold.woff2.js +0 -4
  222. package/dist/static/fonts/OpenSans/OpenSans-Light.ttf +0 -0
  223. package/dist/static/fonts/OpenSans/OpenSans-Light.ttf.js +0 -4
  224. package/dist/static/fonts/OpenSans/OpenSans-Light.woff +0 -0
  225. package/dist/static/fonts/OpenSans/OpenSans-Light.woff.js +0 -4
  226. package/dist/static/fonts/OpenSans/OpenSans-Light.woff2 +0 -0
  227. package/dist/static/fonts/OpenSans/OpenSans-Light.woff2.js +0 -4
  228. package/dist/static/fonts/OpenSans/OpenSans-Regular.ttf +0 -0
  229. package/dist/static/fonts/OpenSans/OpenSans-Regular.ttf.js +0 -4
  230. package/dist/static/fonts/OpenSans/OpenSans-Regular.woff +0 -0
  231. package/dist/static/fonts/OpenSans/OpenSans-Regular.woff.js +0 -4
  232. package/dist/static/fonts/OpenSans/OpenSans-Regular.woff2 +0 -0
  233. package/dist/static/fonts/OpenSans/OpenSans-Regular.woff2.js +0 -4
  234. package/dist/static/fonts/OpenSans/OpenSans-SemiBold.ttf +0 -0
  235. package/dist/static/fonts/OpenSans/OpenSans-SemiBold.ttf.js +0 -4
  236. package/dist/static/fonts/OpenSans/OpenSans-SemiBold.woff +0 -0
  237. package/dist/static/fonts/OpenSans/OpenSans-SemiBold.woff.js +0 -4
  238. package/dist/static/fonts/OpenSans/OpenSans-SemiBold.woff2 +0 -0
  239. package/dist/static/fonts/OpenSans/OpenSans-SemiBold.woff2.js +0 -4
  240. package/dist/static/images/avatar-placeholder.png.js +0 -4
  241. package/dist/styles/reactTippy.js +0 -5
  242. package/dist/styles/semanticUi.js +0 -84
  243. package/dist/utils/check-sale-time-left.js +0 -85
  244. package/dist/utils/moment.js +0 -26
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copy text to the clipboard, falling back to a hidden textarea when the async
3
+ * Clipboard API is unavailable *or* rejects (denied permission, unfocused
4
+ * document, sandboxed iframe — all common).
5
+ *
6
+ * Lives in its own module so components can use it without importing
7
+ * `utils/copyToClipboard`, which re-exports components and would cycle.
8
+ */
9
+ export declare const copyTextToClipboard: (text: string, onCopy?: (text: string, success: boolean) => void, onError?: (error: Error) => void) => Promise<boolean>;
10
+ export default copyTextToClipboard;
@@ -0,0 +1,27 @@
1
+ import { ComponentType } from 'react';
2
+ import { CopyToClipboard } from 'react-copy-to-clipboard';
3
+ import { copyTextToClipboard } from './copy-text-to-clipboard';
4
+ import { CopyToClipboardTooltip } from '../components/CopyToClipboardTooltip/CopyToClipboardTooltip';
5
+ export { copyTextToClipboard };
6
+ export type WithCopyToClipboardOptions = {
7
+ /** Prop holding the text to copy. Default 'text'. */
8
+ textProp?: string;
9
+ /** Prop holding the onCopy callback. Default 'onCopy'. */
10
+ onCopyProp?: string;
11
+ /** Prop holding the onError callback. Default 'onError'. */
12
+ onErrorProp?: string;
13
+ };
14
+ /** Higher-order component that wraps a component with copy-to-clipboard functionality. */
15
+ export declare const withCopyToClipboard: <P extends object>(WrappedComponent: ComponentType<P>, options?: WithCopyToClipboardOptions) => ComponentType<P>;
16
+ /** Copies `text` (or a text passed to `copy`); `copied` stays true for 2 seconds. */
17
+ export declare const useCopyToClipboard: (text?: string) => {
18
+ copy: (customText?: string) => Promise<boolean>;
19
+ copied: boolean;
20
+ };
21
+ /**
22
+ * @deprecated Import `CopyToClipboardTooltip` instead — this spelling is kept
23
+ * for the existing call sites.
24
+ */
25
+ export declare const CopyToClipBoardTooltip: ({ value, buttonStyle, onCopy, children, copiedLabel, idleLabel, resetAfter, }: import('..').CopyToClipboardTooltipProps) => import("react/jsx-runtime").JSX.Element;
26
+ export { CopyToClipboardTooltip };
27
+ export { CopyToClipboard };
@@ -0,0 +1,14 @@
1
+ export type CsvCell = string | number | boolean | Date | null | undefined;
2
+ export type CsvOptions = {
3
+ /** Default ','. */
4
+ separator?: string;
5
+ /**
6
+ * Prefix text that a spreadsheet would run as a formula (starting with =, +, -, @, tab or carriage return) with an
7
+ * apostrophe. Default true. Numbers, and text that is just a negative number like '-5', are never changed.
8
+ */
9
+ escapeFormulas?: boolean;
10
+ };
11
+ /** Rows to CSV text (RFC 4180): cells with the separator, quotes or line breaks are quoted. */
12
+ export declare const toCsv: (rows: CsvCell[][], options?: CsvOptions) => string;
13
+ /** Saves rows as a UTF-8 .csv file that Excel opens correctly. Does nothing when there are no rows. */
14
+ export declare const downloadCsv: (rows: CsvCell[][], fileName: string, options?: CsvOptions) => void;
@@ -0,0 +1,25 @@
1
+ import { saveAs } from "./saveAs.js";
2
+ const BYTE_ORDER_MARK = String.fromCharCode(65279);
3
+ const FORMULA_START = /^([=+@\t\r]|-(?!\d+(\.\d+)?$))/;
4
+ const toCell = (cell, separator, escapeFormulas) => {
5
+ if (cell === null || cell === void 0) return "";
6
+ if (cell instanceof Date) return Number.isNaN(cell.getTime()) ? "" : cell.toISOString();
7
+ if (typeof cell !== "string") return String(cell);
8
+ const text = escapeFormulas && FORMULA_START.test(cell) ? `'${cell}` : cell;
9
+ const needsQuotes = text.includes(separator) || /["\r\n]/.test(text);
10
+ return needsQuotes ? `"${text.replace(/"/g, '""')}"` : text;
11
+ };
12
+ const toCsv = (rows, options = {}) => {
13
+ const { separator = ",", escapeFormulas = true } = options;
14
+ return rows.map((row) => row.map((cell) => toCell(cell, separator, escapeFormulas)).join(separator)).join("\r\n");
15
+ };
16
+ const downloadCsv = (rows, fileName, options = {}) => {
17
+ if (rows.length === 0) return;
18
+ const safeName = fileName.replace(/[\\/:*?"<>|]+/g, "-").trim() || "export";
19
+ const name = safeName.toLowerCase().endsWith(".csv") ? safeName : `${safeName}.csv`;
20
+ saveAs(new Blob([BYTE_ORDER_MARK, toCsv(rows, options)], { type: "text/csv;charset=utf-8" }), name);
21
+ };
22
+ export {
23
+ downloadCsv,
24
+ toCsv
25
+ };
@@ -0,0 +1,20 @@
1
+ import { default as React, ComponentType, RefObject } from 'react';
2
+ export declare const useMobileView: (breakpoint?: string) => boolean;
3
+ export declare const useContainerSize: (ref: RefObject<HTMLElement | null>, breakpoint?: number) => boolean;
4
+ export declare function usePrevious<T>(value: T): T | undefined;
5
+ export type Cooldown = {
6
+ isDisabled: boolean;
7
+ secondsRemaining: number;
8
+ startCooldown: (actionCallback?: () => void) => void;
9
+ hasTimerFinished: boolean;
10
+ };
11
+ export declare const useCooldown: (cooldownInSeconds: number) => Cooldown;
12
+ export declare const cooldownHOC: <P extends object>(Component: ComponentType<P & {
13
+ cooldown: Cooldown;
14
+ }>, seconds?: number) => ComponentType<P>;
15
+ /** Closes on a click outside `ref`. Clicks inside `insideRefs` (e.g. a portal or the toggle button) count as inside. */
16
+ export declare function useComponentVisible<T extends HTMLElement = HTMLElement>(initialIsVisible: boolean, insideRefs?: RefObject<HTMLElement | null>[]): {
17
+ ref: React.RefObject<T>;
18
+ isComponentVisible: boolean;
19
+ setIsComponentVisible: React.Dispatch<React.SetStateAction<boolean>>;
20
+ };
@@ -2,10 +2,9 @@ import { jsx } from "react/jsx-runtime";
2
2
  import React__default, { useState, useRef, useEffect, useCallback } from "react";
3
3
  import { sizes } from "../styles/rwd.js";
4
4
  const useMobileView = (breakpoint = sizes.Medium) => {
5
- var breakpointNumber = breakpoint.match(/\d/g);
6
- breakpointNumber = breakpointNumber.join("");
5
+ const breakpointNumber = Number(breakpoint.match(/\d/g).join(""));
7
6
  const [isMobile, setisMobile] = React__default.useState(false);
8
- const timeout = React__default.useRef();
7
+ const timeout = React__default.useRef(void 0);
9
8
  const checkIsMobile = () => typeof window !== "undefined" ? window.innerWidth <= breakpointNumber : false;
10
9
  const onResizeTimeout = () => {
11
10
  setisMobile(checkIsMobile());
@@ -45,8 +44,8 @@ const useContainerSize = (ref, breakpoint = 500) => {
45
44
  return isMobile;
46
45
  };
47
46
  function usePrevious(value) {
48
- const ref = useRef();
49
- const [previous, setPrevious] = useState();
47
+ const ref = useRef(void 0);
48
+ const [previous, setPrevious] = useState(void 0);
50
49
  useEffect(() => {
51
50
  const previousValue = ref.current;
52
51
  ref.current = value;
@@ -100,15 +99,21 @@ const cooldownHOC = (Component, seconds = 60) => {
100
99
  };
101
100
  return Wrapper;
102
101
  };
103
- function useComponentVisible(initialIsVisible) {
102
+ function useComponentVisible(initialIsVisible, insideRefs = []) {
104
103
  const [isComponentVisible, setIsComponentVisible] = useState(initialIsVisible);
105
104
  const ref = useRef(null);
106
- const handleClickOutside = (event) => {
107
- if (ref.current && !ref.current.contains(event.target)) {
108
- setIsComponentVisible(false);
109
- }
110
- };
105
+ const latestInsideRefs = useRef(insideRefs);
106
+ useEffect(() => {
107
+ latestInsideRefs.current = insideRefs;
108
+ });
111
109
  useEffect(() => {
110
+ const handleClickOutside = (event) => {
111
+ const target = event.target;
112
+ const isInside = [ref, ...latestInsideRefs.current].some((inside) => inside.current?.contains(target));
113
+ if (ref.current && !isInside) {
114
+ setIsComponentVisible(false);
115
+ }
116
+ };
112
117
  document.addEventListener("click", handleClickOutside, true);
113
118
  return () => {
114
119
  document.removeEventListener("click", handleClickOutside, true);
@@ -0,0 +1,14 @@
1
+ export type FormatDisplayNumberOptions = {
2
+ minimumFractionDigits?: number;
3
+ maximumFractionDigits?: number;
4
+ };
5
+ export declare const fixDecimals: (value: number | string, decimals: number, roundingFn?: (value: number) => number) => string;
6
+ /**
7
+ * Format a number into a human-readable string with thousands separators
8
+ * (e.g. 20300.5 -> "20,300.50"). Presentation only — no currency symbol or
9
+ * currency-specific decimal logic; pair it with getCurrencyConfig for those.
10
+ *
11
+ * Returns '' when the value is not a finite number.
12
+ */
13
+ export declare const formatDisplayNumber: (value: number | string, { minimumFractionDigits, maximumFractionDigits }?: FormatDisplayNumberOptions) => string;
14
+ export default fixDecimals;
@@ -0,0 +1,109 @@
1
+ import { PaymentCurrencyId } from './formatCurrencyValue';
2
+ /** What a project is denominated in. */
3
+ export type ProjectCurrency = 'EUR' | 'USD' | 'BTC';
4
+ /** A project's own token (AQF, BMN2) with its own number of decimals. */
5
+ export type TokenUnit = {
6
+ symbol: string;
7
+ decimals: number;
8
+ };
9
+ /** Every amount says which of the three kinds it is. */
10
+ export type AmountUnit = {
11
+ project: ProjectCurrency;
12
+ } | {
13
+ payment: PaymentCurrencyId;
14
+ } | {
15
+ token: TokenUnit;
16
+ };
17
+ export type UnitInfo = {
18
+ kind: 'project' | 'payment' | 'token';
19
+ /** USD, BTC, USDC, AQF */
20
+ code: string;
21
+ /** $, €, ₿ — only project currencies have one. */
22
+ symbol?: string;
23
+ decimals: number;
24
+ /** Tokens are never shortened to K/M/Bn. */
25
+ compactable: boolean;
26
+ /** False for an unknown project currency or payment id; those get 2 decimals. */
27
+ matched: boolean;
28
+ };
29
+ export type CodeCase = 'upper' | 'original';
30
+ /** 'round' (default) is half away from zero. Investing or paying: floor what is received, ceil what is paid. */
31
+ export type Rounding = 'round' | 'floor' | 'ceil';
32
+ export type FormatNumberOptions = {
33
+ /** Default 2. */
34
+ decimals?: number;
35
+ /** Round to 2 decimals, then K/M/Bn: 1,865.76 → 1.87K, 999,996 → 1.00M. */
36
+ compact?: boolean;
37
+ rounding?: Rounding;
38
+ /** Show '+' on positive values. */
39
+ signed?: boolean;
40
+ /** Shown for null, undefined, '' and anything that isn't a number. Default '-'. */
41
+ fallback?: string;
42
+ /** Thousands separators. Default true. */
43
+ grouping?: boolean;
44
+ };
45
+ export type FormatAmountOptions = Omit<FormatNumberOptions, 'decimals' | 'grouping'> & {
46
+ /** Overrides the unit's decimals, for prices and fees that need more precision. */
47
+ decimals?: number;
48
+ /** Project currencies only: 'symbol' (default) $12,500.56, 'code' USD 12,500.56. Others always show their code. */
49
+ display?: 'symbol' | 'code';
50
+ /** 'upper' (default) aqf → AQF, keeping XAUt; 'original' keeps the code as given. */
51
+ codeCase?: CodeCase;
52
+ };
53
+ export type AmountParts = {
54
+ /** Same as formatAmount. */
55
+ text: string;
56
+ /** The number only, with its sign: -12,500.56 */
57
+ value: string;
58
+ code: string;
59
+ symbol?: string;
60
+ };
61
+ export declare const isProjectCurrency: (value: unknown) => value is ProjectCurrency;
62
+ export declare const isPaymentCurrency: (value: unknown) => value is PaymentCurrencyId;
63
+ /** `project.tokenCurrency` → unit. Empty falls back to USD. */
64
+ export declare const projectUnit: (tokenCurrency: string | null | undefined) => AmountUnit;
65
+ /** `investment.currencyType` / `sale.currencies[i]` → unit. */
66
+ export declare const paymentUnit: (currencyType: string | null | undefined) => AmountUnit;
67
+ /** Missing decimals fall back to 2. */
68
+ export declare const tokenUnit: (symbol: string | null | undefined, decimals: number | null | undefined) => AmountUnit;
69
+ /** The one place that decides token decimals: `tokenRoundingDecimals`, else `tokenDecimals`. */
70
+ export declare const projectTokenUnit: (project: {
71
+ tokenSymbol?: string | null;
72
+ tokenDecimals?: number | null;
73
+ tokenRoundingDecimals?: number | null;
74
+ }) => AmountUnit;
75
+ /** Code, symbol and decimals of a unit, for components that lay out the number and the code themselves. */
76
+ export declare const getUnitInfo: (unit: AmountUnit, codeCase?: CodeCase) => UnitInfo;
77
+ /** Numbers and numeric strings, commas ignored: '12,500.5' → 12500.5. Anything else → null. */
78
+ export declare const parseAmount: (value: unknown) => number | null;
79
+ /** Rounds without float noise: 1.005 → 1.01, and 0.3 / 0.1 floored is 3, not 2. */
80
+ export declare const roundTo: (value: number, decimals: number, rounding?: Rounding) => number;
81
+ /** formatAmount, with the number and the code also returned separately. */
82
+ export declare const formatAmountParts: (value: unknown, unit: AmountUnit, options?: FormatAmountOptions) => AmountParts;
83
+ /**
84
+ * The formatter for money and token amounts.
85
+ *
86
+ * formatAmount(12500.555, { project: 'USD' }) // $12,500.56
87
+ * formatAmount(12500.555, { project: 'USD' }, { display: 'code' }) // USD 12,500.56
88
+ * formatAmount(1865.76, { project: 'EUR' }, { compact: true }) // €1.87K
89
+ * formatAmount(0.123456785, { payment: 'btc-fb' }) // BTC 0.12345679
90
+ * formatAmount(1250, tokenUnit('aqf', 4)) // AQF 1,250.0000
91
+ */
92
+ export declare const formatAmount: (value: unknown, unit: AmountUnit, options?: FormatAmountOptions) => string;
93
+ /** A number without a unit: 12,500.56 · 1.87K · +4.20 */
94
+ export declare const formatNumber: (value: unknown, options?: FormatNumberOptions) => string;
95
+ /** 12.3456 → 12.35% */
96
+ export declare const formatPercent: (value: unknown, options?: FormatNumberOptions) => string;
97
+ /**
98
+ * '12500.56' — no grouping, no code. For input values, API payloads, QR/payment URIs and components that group
99
+ * the number themselves (PaymentDisplay). Show and send the same result so the two never differ.
100
+ */
101
+ export declare const toFixedAmount: (value: unknown, unit: AmountUnit | number, rounding?: Rounding) => string | null;
102
+ /**
103
+ * Keeps digits and one decimal point, cuts (never rounds) the fraction to `maxDecimals`, and keeps a trailing '.'
104
+ * so typing can continue. A single comma not followed by exactly 3 digits is a decimal comma: '12,5' → '12.5'.
105
+ * '1,000.50' → '1000.50' · '.5' → '0.5' · '007' → '7'
106
+ */
107
+ export declare const sanitizeAmountInput: (input: string | null | undefined, maxDecimals: number) => string;
108
+ /** Groups a sanitized input while typing, keeping the fraction as typed: '12345.' → '12,345.' */
109
+ export declare const formatAmountInput: (raw: string | null | undefined) => string;
@@ -0,0 +1,170 @@
1
+ import { CURRENCY_CONFIG } from "./formatCurrencyValue.js";
2
+ const PROJECT_CURRENCIES = {
3
+ EUR: { symbol: "€", decimals: 2 },
4
+ USD: { symbol: "$", decimals: 2 },
5
+ BTC: { symbol: "₿", decimals: 8 }
6
+ };
7
+ const MIXED_CASE_CODES = ["XAUt"];
8
+ const COMPACT_DECIMALS = 2;
9
+ const COMPACT_STEPS = [
10
+ { size: 1e9, suffix: "Bn" },
11
+ { size: 1e6, suffix: "M" },
12
+ { size: 1e3, suffix: "K" }
13
+ ];
14
+ const ROUND = {
15
+ round: (value) => Math.sign(value) * Math.round(Math.abs(value)),
16
+ floor: Math.floor,
17
+ ceil: Math.ceil
18
+ };
19
+ const hasKey = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
20
+ const isProjectCurrency = (value) => typeof value === "string" && hasKey(PROJECT_CURRENCIES, value);
21
+ const isPaymentCurrency = (value) => typeof value === "string" && hasKey(CURRENCY_CONFIG, value.toLowerCase());
22
+ const projectUnit = (tokenCurrency) => ({
23
+ project: String(tokenCurrency || "USD").toUpperCase()
24
+ });
25
+ const paymentUnit = (currencyType) => ({
26
+ payment: String(currencyType ?? "").toLowerCase()
27
+ });
28
+ const tokenUnit = (symbol, decimals) => ({
29
+ token: { symbol: symbol ?? "", decimals: decimals ?? 2 }
30
+ });
31
+ const projectTokenUnit = (project) => tokenUnit(project.tokenSymbol, project.tokenRoundingDecimals ?? project.tokenDecimals);
32
+ const formatCode = (code, codeCase) => {
33
+ if (codeCase === "original") return code;
34
+ return MIXED_CASE_CODES.find((known) => known.toLowerCase() === code.toLowerCase()) ?? code.toUpperCase();
35
+ };
36
+ const tokenInfo = (token, codeCase) => ({
37
+ kind: "token",
38
+ code: formatCode(token.symbol, codeCase),
39
+ decimals: token.decimals,
40
+ compactable: false,
41
+ matched: true
42
+ });
43
+ const projectInfo = (currency) => {
44
+ const code = String(currency ?? "").toUpperCase();
45
+ const known = isProjectCurrency(code) ? PROJECT_CURRENCIES[code] : void 0;
46
+ return {
47
+ kind: "project",
48
+ code,
49
+ symbol: known?.symbol,
50
+ decimals: known?.decimals ?? 2,
51
+ compactable: true,
52
+ matched: Boolean(known)
53
+ };
54
+ };
55
+ const paymentInfo = (id, codeCase) => {
56
+ const key = String(id ?? "").toLowerCase();
57
+ const known = isPaymentCurrency(key) ? CURRENCY_CONFIG[key] : void 0;
58
+ return {
59
+ kind: "payment",
60
+ code: formatCode(known ? known[0] : String(id ?? ""), codeCase),
61
+ decimals: known ? known[1] : 2,
62
+ compactable: true,
63
+ matched: Boolean(known)
64
+ };
65
+ };
66
+ const getUnitInfo = (unit, codeCase = "upper") => {
67
+ if ("token" in unit) return tokenInfo(unit.token, codeCase);
68
+ if ("project" in unit) return projectInfo(unit.project);
69
+ return paymentInfo(unit.payment, codeCase);
70
+ };
71
+ const parseAmount = (value) => {
72
+ if (typeof value === "number") return Number.isFinite(value) ? value : null;
73
+ if (typeof value !== "string") return null;
74
+ const text = value.replace(/,/g, "").trim();
75
+ const parsed = Number(text);
76
+ return text !== "" && Number.isFinite(parsed) ? parsed : null;
77
+ };
78
+ const roundTo = (value, decimals, rounding = "round") => {
79
+ const factor = 10 ** decimals;
80
+ const scaled = Number((value * factor).toPrecision(15));
81
+ return ROUND[rounding](scaled) / factor || 0;
82
+ };
83
+ const compactStep = (value, decimals, rounding) => {
84
+ if (Math.abs(roundTo(value, decimals, rounding)) < COMPACT_STEPS[COMPACT_STEPS.length - 1].size) return void 0;
85
+ return COMPACT_STEPS.find((step) => Math.abs(roundTo(value / step.size, COMPACT_DECIMALS, rounding)) >= 1);
86
+ };
87
+ const toDigits = (value, options) => {
88
+ const { decimals, compact = false, rounding, signed = false, grouping = true } = options;
89
+ const step = compact ? compactStep(value, decimals, rounding) : void 0;
90
+ const places = step ? COMPACT_DECIMALS : decimals;
91
+ const rounded = roundTo(step ? value / step.size : value, places, rounding);
92
+ const digits = Math.abs(rounded).toLocaleString("en", {
93
+ minimumFractionDigits: places,
94
+ maximumFractionDigits: places,
95
+ useGrouping: grouping
96
+ });
97
+ const sign = rounded < 0 ? "-" : rounded > 0 && signed ? "+" : "";
98
+ return sign + digits + (step?.suffix ?? "");
99
+ };
100
+ const formatAmountParts = (value, unit, options = {}) => {
101
+ const {
102
+ compact = false,
103
+ rounding = "round",
104
+ signed,
105
+ fallback = "-",
106
+ display = "symbol",
107
+ codeCase = "upper"
108
+ } = options;
109
+ const info = getUnitInfo(unit, codeCase);
110
+ const amount = parseAmount(value);
111
+ if (amount === null) return { text: fallback, value: fallback, code: info.code, symbol: info.symbol };
112
+ const number = toDigits(amount, {
113
+ decimals: options.decimals ?? info.decimals,
114
+ compact: compact && info.compactable,
115
+ rounding,
116
+ signed
117
+ });
118
+ const unitText = display === "symbol" && info.symbol ? info.symbol : info.code ? `${info.code} ` : "";
119
+ const hasSign = number.startsWith("-") || number.startsWith("+");
120
+ const text = hasSign ? number[0] + unitText + number.slice(1) : unitText + number;
121
+ return { text, value: number, code: info.code, symbol: info.symbol };
122
+ };
123
+ const formatAmount = (value, unit, options = {}) => formatAmountParts(value, unit, options).text;
124
+ const formatNumber = (value, options = {}) => {
125
+ const { decimals = 2, compact = false, rounding = "round", signed, fallback = "-", grouping = true } = options;
126
+ const amount = parseAmount(value);
127
+ return amount === null ? fallback : toDigits(amount, { decimals, compact, rounding, signed, grouping });
128
+ };
129
+ const formatPercent = (value, options = {}) => parseAmount(value) === null ? options.fallback ?? "-" : `${formatNumber(value, options)}%`;
130
+ const toFixedAmount = (value, unit, rounding = "round") => {
131
+ const amount = parseAmount(value);
132
+ if (amount === null) return null;
133
+ const decimals = typeof unit === "number" ? unit : getUnitInfo(unit).decimals;
134
+ return toDigits(amount, { decimals, rounding, grouping: false });
135
+ };
136
+ const sanitizeAmountInput = (input, maxDecimals) => {
137
+ let text = String(input ?? "").replace(/\s/g, "");
138
+ const commaParts = text.split(",");
139
+ if (!text.includes(".") && commaParts.length === 2 && commaParts[1].length !== 3) text = commaParts.join(".");
140
+ text = text.replace(/[^\d.]/g, "");
141
+ const [whole, ...fractions] = text.split(".");
142
+ const hasPoint = fractions.length > 0;
143
+ const integer = whole.replace(/^0+(?=\d)/, "") || (hasPoint ? "0" : "");
144
+ if (maxDecimals <= 0 || !hasPoint) return integer;
145
+ return `${integer}.${fractions.join("").slice(0, maxDecimals)}`;
146
+ };
147
+ const formatAmountInput = (raw) => {
148
+ const text = String(raw ?? "");
149
+ const [integer, fraction] = text.split(".");
150
+ const grouped = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
151
+ return text.includes(".") ? `${grouped}.${fraction}` : grouped;
152
+ };
153
+ export {
154
+ formatAmount,
155
+ formatAmountInput,
156
+ formatAmountParts,
157
+ formatNumber,
158
+ formatPercent,
159
+ getUnitInfo,
160
+ isPaymentCurrency,
161
+ isProjectCurrency,
162
+ parseAmount,
163
+ paymentUnit,
164
+ projectTokenUnit,
165
+ projectUnit,
166
+ roundTo,
167
+ sanitizeAmountInput,
168
+ toFixedAmount,
169
+ tokenUnit
170
+ };
@@ -0,0 +1,46 @@
1
+ export declare const CURRENCY_CONFIG: {
2
+ readonly tether: readonly ["USDT", 2];
3
+ readonly ether: readonly ["ETH", 4];
4
+ readonly bitcoin: readonly ["BTC", 8];
5
+ readonly lbtc: readonly ["LBTC", 8];
6
+ readonly 'lusdt-bfx': readonly ["USDT", 2];
7
+ readonly 'lbtc-bfx': readonly ["LBTC", 8];
8
+ readonly 'btc-bfx': readonly ["BTC", 8];
9
+ readonly euro: readonly ["EUR", 2, "€"];
10
+ readonly usd: readonly ["USD", 2, "$"];
11
+ readonly chf: readonly ["CHF", 2];
12
+ readonly lusdt: readonly ["USDT", 2];
13
+ readonly 'btc-fb': readonly ["BTC", 8];
14
+ readonly 'usdc-fb': readonly ["USDC", 2];
15
+ readonly 'usdq-fb': readonly ["USDQ", 2];
16
+ readonly 'eth-fb': readonly ["ETH", 4];
17
+ readonly xaut: readonly ["XAUt", 6];
18
+ readonly 'usd-in-kind': readonly ["USD", 2, "$"];
19
+ };
20
+ /** A payment currency id from CURRENCY_CONFIG (e.g. 'btc-fb', 'usdc-fb', 'euro'). */
21
+ export type PaymentCurrencyId = keyof typeof CURRENCY_CONFIG;
22
+ export type CurrencyConfig = {
23
+ symbol: string;
24
+ decimals: number;
25
+ sign: string;
26
+ matched: boolean;
27
+ };
28
+ export type FormatCurrencyValueOptions = {
29
+ valueFirst?: boolean;
30
+ formatter?: (args: {
31
+ symbol: string;
32
+ decimals: number;
33
+ value: number | string;
34
+ valueFirst: boolean;
35
+ currency: string;
36
+ }) => string;
37
+ };
38
+ export declare const getCurrencyConfig: (currency?: string | null, tokenDecimals?: number) => CurrencyConfig;
39
+ export declare const formatCurrencyValue: (currency: string, value: number | string, tokenDecimals?: number, options?: FormatCurrencyValueOptions) => string;
40
+ export declare function formatAmountForDisplay(amount: null): null;
41
+ export declare function formatAmountForDisplay(amount: undefined): undefined;
42
+ export declare function formatAmountForDisplay(amount: string | number): string;
43
+ export declare function formatAmountForDisplay(amount: string | number | null | undefined): string | null | undefined;
44
+ export declare const getCurrencySymbol: (currencySelected: string) => string;
45
+ export declare const getProjectCurrencySign: (tokenCurrency: string) => "\u20AC" | "$" | "\u20BF" | "";
46
+ export declare const getCurrencyIcon: (currency?: string | null, customIcon?: string | null) => string | null;
@@ -9,9 +9,7 @@ import EURLogo from "../static/images/currency/eur.svg.js";
9
9
  import { formatDisplayNumber } from "./fix-decimals.js";
10
10
  const CURRENCY_CONFIG = {
11
11
  tether: ["USDT", 2],
12
- gemini: ["GUSD", 2],
13
12
  ether: ["ETH", 4],
14
- artid: ["ARTID", 2],
15
13
  bitcoin: ["BTC", 8],
16
14
  lbtc: ["LBTC", 8],
17
15
  "lusdt-bfx": ["USDT", 2],
@@ -21,10 +19,6 @@ const CURRENCY_CONFIG = {
21
19
  usd: ["USD", 2, "$"],
22
20
  chf: ["CHF", 2],
23
21
  lusdt: ["USDT", 2],
24
- "bitcoin-private": ["EUR", 2],
25
- "lbtc-private": ["BTC", 8],
26
- bmn1: ["BMN1", 2],
27
- bmn2: ["BMN2", 4],
28
22
  "btc-fb": ["BTC", 8],
29
23
  "usdc-fb": ["USDC", 2],
30
24
  "usdq-fb": ["USDQ", 2],
@@ -32,8 +26,9 @@ const CURRENCY_CONFIG = {
32
26
  xaut: ["XAUt", 6],
33
27
  "usd-in-kind": ["USD", 2, "$"]
34
28
  };
29
+ const lookupConfig = (id) => CURRENCY_CONFIG[id];
35
30
  const getCurrencyConfig = (currency, tokenDecimals = 2) => {
36
- const config = CURRENCY_CONFIG[String(currency ?? "").toLowerCase()];
31
+ const config = lookupConfig(String(currency ?? "").toLowerCase());
37
32
  if (config) {
38
33
  const [symbol, decimals, sign] = config;
39
34
  return { symbol, decimals, sign: sign ?? symbol, matched: true };
@@ -46,19 +41,19 @@ const formatCurrencyValue = (currency, value, tokenDecimals = 2, options = {}) =
46
41
  if (typeof formatter === "function") {
47
42
  return formatter({ symbol, decimals, value, valueFirst, currency });
48
43
  }
49
- const formattedValue = parseFloat(Math.abs(value)).toFixed(decimals);
44
+ const formattedValue = parseFloat(String(Math.abs(value))).toFixed(decimals);
50
45
  return valueFirst ? `${formattedValue} ${symbol}` : `${symbol} ${formattedValue}`;
51
46
  };
52
- const formatAmountForDisplay = (amount) => {
47
+ function formatAmountForDisplay(amount) {
53
48
  if (amount === void 0 || amount === null || amount === "") return amount;
54
49
  const plain = String(amount).replace(/,/g, "");
55
50
  const decimalPart = plain.split(".")[1];
56
51
  const digits = decimalPart ? decimalPart.length : 0;
57
52
  const formatted = formatDisplayNumber(plain, { minimumFractionDigits: digits, maximumFractionDigits: digits });
58
53
  return formatted || amount;
59
- };
54
+ }
60
55
  const getCurrencySymbol = (currencySelected) => {
61
- const config = CURRENCY_CONFIG[currencySelected];
56
+ const config = lookupConfig(currencySelected);
62
57
  if (config) {
63
58
  const [symbol, , sign] = config;
64
59
  return sign ?? symbol;
@@ -100,15 +95,6 @@ const getCurrencyIcon = (currency, customIcon) => {
100
95
  return null;
101
96
  }
102
97
  };
103
- const getLiquidAssetIcon = async (assetId) => {
104
- const url = `https://liquid.network/api/v1/asset/${assetId}/icon`;
105
- return new Promise((resolve) => {
106
- const img = new Image();
107
- img.onload = () => resolve(url);
108
- img.onerror = () => resolve(null);
109
- img.src = url;
110
- });
111
- };
112
98
  export {
113
99
  CURRENCY_CONFIG,
114
100
  formatAmountForDisplay,
@@ -116,6 +102,5 @@ export {
116
102
  getCurrencyConfig,
117
103
  getCurrencyIcon,
118
104
  getCurrencySymbol,
119
- getLiquidAssetIcon,
120
105
  getProjectCurrencySign
121
106
  };
@@ -0,0 +1,19 @@
1
+ export type DateInput = Date | string | number | null | undefined;
2
+ export type FormatDateOptions = {
3
+ /** true adds HH:mm, 'seconds' adds HH:mm:ss (24h). */
4
+ time?: boolean | 'seconds';
5
+ /** Format in UTC instead of the browser's time zone; adds ' UTC' after a time. Same output on server and client. */
6
+ utc?: boolean;
7
+ /** Shown for null, undefined, '' and invalid dates. Default '-'. */
8
+ fallback?: string;
9
+ };
10
+ /**
11
+ * The platform date format: DD MMM YYYY, optionally with time.
12
+ *
13
+ * formatDate('2026-10-05T14:03:09Z') // 05 Oct 2026
14
+ * formatDate(date, { time: true }) // 05 Oct 2026 - 16:03
15
+ * formatDate(date, { time: 'seconds', utc: true }) // 05 Oct 2026 - 14:03:09 UTC
16
+ */
17
+ export declare const formatDate: (value: DateInput, options?: FormatDateOptions) => string;
18
+ /** 05 Oct 2026 - 31 Oct 2026. A missing side shows the fallback; both missing returns the fallback once. */
19
+ export declare const formatDateRange: (start: DateInput, end: DateInput, options?: FormatDateOptions) => string;
@@ -0,0 +1,44 @@
1
+ const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
2
+ const DATE_ONLY = /^(\d{4})-(\d{2})-(\d{2})$/;
3
+ const pad = (value) => String(value).padStart(2, "0");
4
+ const toDate = (value) => {
5
+ if (value === null || value === void 0 || value === "") return null;
6
+ const input = typeof value === "string" ? value.trim().replace(/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2})/, "$1T$2") : value;
7
+ const date = value instanceof Date ? value : new Date(input);
8
+ return Number.isNaN(date.getTime()) ? null : date;
9
+ };
10
+ const formatDate = (value, options = {}) => {
11
+ const { time = false, utc = false, fallback = "-" } = options;
12
+ const dayOnly = typeof value === "string" ? DATE_ONLY.exec(value.trim()) : null;
13
+ if (dayOnly) {
14
+ const [year2, month2, day2] = dayOnly.slice(1).map(Number);
15
+ const check = new Date(Date.UTC(year2, month2 - 1, day2));
16
+ const exists = check.getUTCFullYear() === year2 && check.getUTCMonth() === month2 - 1 && check.getUTCDate() === day2;
17
+ return exists ? `${pad(day2)} ${MONTHS[month2 - 1]} ${year2}` : fallback;
18
+ }
19
+ const date = toDate(value);
20
+ if (!date) return fallback;
21
+ const parts = utc ? [
22
+ date.getUTCFullYear(),
23
+ date.getUTCMonth(),
24
+ date.getUTCDate(),
25
+ date.getUTCHours(),
26
+ date.getUTCMinutes(),
27
+ date.getUTCSeconds()
28
+ ] : [date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()];
29
+ const [year, month, day, hours, minutes, seconds] = parts;
30
+ const text = `${pad(day)} ${MONTHS[month]} ${year}`;
31
+ if (!time) return text;
32
+ const clock = `${pad(hours)}:${pad(minutes)}${time === "seconds" ? `:${pad(seconds)}` : ""}`;
33
+ return `${text} - ${clock}${utc ? " UTC" : ""}`;
34
+ };
35
+ const formatDateRange = (start, end, options = {}) => {
36
+ const fallback = options.fallback ?? "-";
37
+ const from = formatDate(start, options);
38
+ const to = formatDate(end, options);
39
+ return from === fallback && to === fallback ? fallback : `${from} - ${to}`;
40
+ };
41
+ export {
42
+ formatDate,
43
+ formatDateRange
44
+ };
@@ -0,0 +1,13 @@
1
+ export type ShortenAddressOptions = {
2
+ /** Characters kept at the start. Default 6. */
3
+ head?: number;
4
+ /** Characters kept at the end. Default 4. */
5
+ tail?: number;
6
+ /** Default '[...]'. */
7
+ separator?: string;
8
+ /** Values this long or shorter are returned unchanged. Never shorter than the shortened text itself. */
9
+ minLength?: number;
10
+ };
11
+ /** 0x1234abcd…ef567890 → 0x1234[...]7890. Works for any address, hash or id. */
12
+ export declare const shortenAddress: (value: string | null | undefined, options?: ShortenAddressOptions) => string;
13
+ export default shortenAddress;