@ape.swap/bonds-sdk 1.0.61 → 1.0.62

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 (124) hide show
  1. package/dist/components/uikit/Button/Button.d.ts +4 -0
  2. package/dist/components/uikit/Button/Button.js +91 -0
  3. package/dist/components/uikit/Button/IconButton.d.ts +4 -0
  4. package/dist/components/uikit/Button/IconButton.js +33 -0
  5. package/dist/components/uikit/Button/index.d.ts +2 -0
  6. package/dist/components/uikit/Button/index.js +2 -0
  7. package/dist/components/uikit/Button/styles.d.ts +3 -0
  8. package/dist/components/uikit/Button/styles.js +30 -0
  9. package/dist/components/uikit/Button/types.d.ts +46 -0
  10. package/dist/components/uikit/Button/types.js +37 -0
  11. package/dist/components/uikit/Checkbox/index.d.ts +4 -0
  12. package/dist/components/uikit/Checkbox/index.js +46 -0
  13. package/dist/components/uikit/Checkbox/types.d.ts +11 -0
  14. package/dist/components/uikit/Checkbox/types.js +5 -0
  15. package/dist/components/uikit/Dropdown/Dropdown.d.ts +4 -0
  16. package/dist/components/uikit/Dropdown/Dropdown.js +58 -0
  17. package/dist/components/uikit/Dropdown/DropdownItem.d.ts +4 -0
  18. package/dist/components/uikit/Dropdown/DropdownItem.js +47 -0
  19. package/dist/components/uikit/Dropdown/index.d.ts +3 -0
  20. package/dist/components/uikit/Dropdown/index.js +2 -0
  21. package/dist/components/uikit/Dropdown/styles.d.ts +4 -0
  22. package/dist/components/uikit/Dropdown/styles.js +16 -0
  23. package/dist/components/uikit/Dropdown/types.d.ts +58 -0
  24. package/dist/components/uikit/Dropdown/types.js +22 -0
  25. package/dist/components/uikit/Flex/index.d.ts +3 -0
  26. package/dist/components/uikit/Flex/index.js +29 -0
  27. package/dist/components/uikit/Input/Input.d.ts +4 -0
  28. package/dist/components/uikit/Input/Input.js +72 -0
  29. package/dist/components/uikit/Input/NumericInput.d.ts +10 -0
  30. package/dist/components/uikit/Input/NumericInput.js +35 -0
  31. package/dist/components/uikit/Input/StyledInput.d.ts +11 -0
  32. package/dist/components/uikit/Input/StyledInput.js +37 -0
  33. package/dist/components/uikit/Input/index.d.ts +3 -0
  34. package/dist/components/uikit/Input/index.js +3 -0
  35. package/dist/components/uikit/Link/index.d.ts +9 -0
  36. package/dist/components/uikit/Link/index.js +29 -0
  37. package/dist/components/uikit/Modal/ModalFooter.d.ts +4 -0
  38. package/dist/components/uikit/Modal/ModalFooter.js +32 -0
  39. package/dist/components/uikit/Modal/ModalHeader.d.ts +4 -0
  40. package/dist/components/uikit/Modal/ModalHeader.js +31 -0
  41. package/dist/components/uikit/Modal/index.d.ts +4 -0
  42. package/dist/components/uikit/Modal/index.js +55 -0
  43. package/dist/components/uikit/Modal/styles.d.ts +3 -0
  44. package/dist/components/uikit/Modal/styles.js +62 -0
  45. package/dist/components/uikit/Modal/types.d.ts +17 -0
  46. package/dist/components/uikit/Modal/types.js +1 -0
  47. package/dist/components/uikit/Select/Select.d.ts +4 -0
  48. package/dist/components/uikit/Select/Select.js +61 -0
  49. package/dist/components/uikit/Select/SelectItem.d.ts +4 -0
  50. package/dist/components/uikit/Select/SelectItem.js +40 -0
  51. package/dist/components/uikit/Select/index.d.ts +2 -0
  52. package/dist/components/uikit/Select/index.js +2 -0
  53. package/dist/components/uikit/Select/styles.d.ts +4 -0
  54. package/dist/components/uikit/Select/styles.js +50 -0
  55. package/dist/components/uikit/Select/types.d.ts +55 -0
  56. package/dist/components/uikit/Select/types.js +37 -0
  57. package/dist/components/uikit/Skeleton/index.d.ts +4 -0
  58. package/dist/components/uikit/Skeleton/index.js +31 -0
  59. package/dist/components/uikit/Skeleton/styles.d.ts +5 -0
  60. package/dist/components/uikit/Skeleton/styles.js +40 -0
  61. package/dist/components/uikit/Skeleton/types.d.ts +18 -0
  62. package/dist/components/uikit/Skeleton/types.js +10 -0
  63. package/dist/components/uikit/Spinner/apeSpinner.json +2764 -0
  64. package/dist/components/uikit/Spinner/index.d.ts +5 -0
  65. package/dist/components/uikit/Spinner/index.js +20 -0
  66. package/dist/components/uikit/SwiperDots/index.d.ts +6 -0
  67. package/dist/components/uikit/SwiperDots/index.js +14 -0
  68. package/dist/components/uikit/Tabs/Tab.d.ts +4 -0
  69. package/dist/components/uikit/Tabs/Tab.js +34 -0
  70. package/dist/components/uikit/Tabs/TabPanel.d.ts +4 -0
  71. package/dist/components/uikit/Tabs/TabPanel.js +29 -0
  72. package/dist/components/uikit/Tabs/Tabs.d.ts +4 -0
  73. package/dist/components/uikit/Tabs/Tabs.js +67 -0
  74. package/dist/components/uikit/Tabs/index.d.ts +2 -0
  75. package/dist/components/uikit/Tabs/index.js +2 -0
  76. package/dist/components/uikit/Tabs/styles.d.ts +3 -0
  77. package/dist/components/uikit/Tabs/styles.js +40 -0
  78. package/dist/components/uikit/Tabs/types.d.ts +54 -0
  79. package/dist/components/uikit/Tabs/types.js +22 -0
  80. package/dist/components/uikit/Tag/ListTag.d.ts +4 -0
  81. package/dist/components/uikit/Tag/ListTag.js +20 -0
  82. package/dist/components/uikit/Tag/Tag.d.ts +4 -0
  83. package/dist/components/uikit/Tag/Tag.js +42 -0
  84. package/dist/components/uikit/Tag/index.d.ts +3 -0
  85. package/dist/components/uikit/Tag/index.js +2 -0
  86. package/dist/components/uikit/Tag/styles.d.ts +5 -0
  87. package/dist/components/uikit/Tag/styles.js +44 -0
  88. package/dist/components/uikit/Tag/types.d.ts +48 -0
  89. package/dist/components/uikit/Tag/types.js +34 -0
  90. package/dist/components/uikit/Text/index.d.ts +4 -0
  91. package/dist/components/uikit/Text/index.js +35 -0
  92. package/dist/components/uikit/Text/types.d.ts +23 -0
  93. package/dist/components/uikit/Text/types.js +13 -0
  94. package/dist/components/uikit/Toggle/index.d.ts +4 -0
  95. package/dist/components/uikit/Toggle/index.js +63 -0
  96. package/dist/components/uikit/Toggle/styles.d.ts +3 -0
  97. package/dist/components/uikit/Toggle/styles.js +39 -0
  98. package/dist/components/uikit/Toggle/types.d.ts +31 -0
  99. package/dist/components/uikit/Toggle/types.js +17 -0
  100. package/dist/components/uikit/Tooltip/index.d.ts +4 -0
  101. package/dist/components/uikit/Tooltip/index.js +66 -0
  102. package/dist/components/uikit/Tooltip/styles.d.ts +4 -0
  103. package/dist/components/uikit/Tooltip/styles.js +60 -0
  104. package/dist/components/uikit/Tooltip/types.d.ts +17 -0
  105. package/dist/components/uikit/Tooltip/types.js +8 -0
  106. package/dist/components/uikit/TutorialModal/index.d.ts +4 -0
  107. package/dist/components/uikit/TutorialModal/index.js +52 -0
  108. package/dist/components/uikit/TutorialModal/styles.d.ts +8 -0
  109. package/dist/components/uikit/TutorialModal/styles.js +86 -0
  110. package/dist/components/uikit/TutorialModal/types.d.ts +22 -0
  111. package/dist/components/uikit/TutorialModal/types.js +1 -0
  112. package/dist/components/uikit/TutorialModal/useTutorialModal.d.ts +6 -0
  113. package/dist/components/uikit/TutorialModal/useTutorialModal.js +20 -0
  114. package/dist/components/uikit/index.d.ts +18 -0
  115. package/dist/components/uikit/index.js +20 -0
  116. package/dist/contexts/ModalContext.d.ts +14 -0
  117. package/dist/contexts/ModalContext.js +78 -0
  118. package/dist/hooks/useIsAbond.d.ts +3 -0
  119. package/dist/hooks/useIsAbond.js +10 -0
  120. package/dist/hooks/useModal.d.ts +3 -0
  121. package/dist/hooks/useModal.js +39 -0
  122. package/dist/utils/numbers.d.ts +5 -0
  123. package/dist/utils/numbers.js +111 -0
  124. package/package.json +7 -1
@@ -0,0 +1,78 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
21
+ import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
22
+ import { Flex } from '../components/uikit';
23
+ import React, { createContext, useState } from 'react';
24
+ export var Context = createContext({
25
+ nodeId: [],
26
+ modalNode: [],
27
+ setModalNode: function () { return null; },
28
+ onPresent: function () { return null; },
29
+ handleClose: function () { return null; },
30
+ setCloseOnOverlayClick: function () { return true; },
31
+ });
32
+ var ModalProvider = function (_a) {
33
+ var children = _a.children;
34
+ var _b = useState([]), nodeId = _b[0], setNodeId = _b[1];
35
+ var _c = useState([]), modalNode = _c[0], setModalNode = _c[1];
36
+ var _d = useState(true), closeOnOverlayClick = _d[0], setCloseOnOverlayClick = _d[1];
37
+ var handlePresent = function (node, newNodeId, clearModalStack) {
38
+ if (clearModalStack) {
39
+ setModalNode([node]);
40
+ setNodeId([newNodeId]);
41
+ }
42
+ else {
43
+ setModalNode(function (prev) { return __spreadArray(__spreadArray([], prev, true), [node], false); });
44
+ setNodeId(function (prev) { return __spreadArray(__spreadArray([], prev, true), [newNodeId], false); });
45
+ }
46
+ };
47
+ var handleDismiss = function () {
48
+ var _a, _b;
49
+ if (modalNode.length > 0) {
50
+ if (React.isValidElement(modalNode[modalNode.length - 1])) {
51
+ // @ts-ignore
52
+ (_b = (_a = modalNode[modalNode.length - 1].props).onDismiss) === null || _b === void 0 ? void 0 : _b.call(_a);
53
+ }
54
+ }
55
+ setModalNode(modalNode.slice(0, modalNode.length - 1));
56
+ setNodeId(nodeId.slice(0, nodeId.length - 1));
57
+ };
58
+ var handleOverlayDismiss = function () {
59
+ if (closeOnOverlayClick) {
60
+ handleDismiss();
61
+ }
62
+ };
63
+ return (_jsxs(Context.Provider, __assign({ value: {
64
+ nodeId: nodeId,
65
+ modalNode: modalNode,
66
+ setModalNode: setModalNode,
67
+ onPresent: handlePresent,
68
+ handleClose: handleDismiss,
69
+ setCloseOnOverlayClick: setCloseOnOverlayClick,
70
+ } }, { children: [modalNode.map(function (modal, i) {
71
+ return (_jsxs(Flex, { children: [_jsx(Flex, { onClick: handleOverlayDismiss }), React.isValidElement(modal) &&
72
+ React.cloneElement(modal, {
73
+ // @ts-ignore
74
+ onDismiss: handleDismiss,
75
+ })] }, nodeId[i]));
76
+ }), children] })));
77
+ };
78
+ export default ModalProvider;
@@ -0,0 +1,3 @@
1
+ export declare const useIsAbond: () => boolean;
2
+ export declare const apeSiteName: () => string;
3
+ export declare const isAbond: () => boolean;
@@ -0,0 +1,10 @@
1
+ //TODO: remove this hooks
2
+ export var useIsAbond = function () {
3
+ return isAbond();
4
+ };
5
+ export var apeSiteName = function () {
6
+ return 'ApeBond';
7
+ };
8
+ export var isAbond = function () {
9
+ return true;
10
+ };
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const useModal: (modal: React.ReactNode, closeOnOverlayClick?: boolean, updateOnPropsChange?: boolean, modalId?: string, clearModalStack?: boolean) => [() => void, () => void];
3
+ export default useModal;
@@ -0,0 +1,39 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
10
+ import { useCallback, useContext, useEffect } from 'react';
11
+ import get from 'lodash/get';
12
+ import { Context } from '../contexts/ModalContext';
13
+ var useModal = function (modal, closeOnOverlayClick, updateOnPropsChange, modalId, clearModalStack) {
14
+ if (closeOnOverlayClick === void 0) { closeOnOverlayClick = true; }
15
+ if (updateOnPropsChange === void 0) { updateOnPropsChange = false; }
16
+ if (modalId === void 0) { modalId = 'defaultNodeId'; }
17
+ if (clearModalStack === void 0) { clearModalStack = false; }
18
+ // Clear modal stack will not update props if the parent modal gets unmounted
19
+ var _a = useContext(Context), nodeId = _a.nodeId, modalNode = _a.modalNode, setModalNode = _a.setModalNode, onPresent = _a.onPresent, handleClose = _a.handleClose, setCloseOnOverlayClick = _a.setCloseOnOverlayClick;
20
+ var onPresentCallback = useCallback(function () {
21
+ onPresent(modal, modalId, clearModalStack);
22
+ }, [modal, modalId, clearModalStack, onPresent]);
23
+ var nodeIdIndex = nodeId.indexOf(modalId);
24
+ useEffect(function () {
25
+ // NodeId is needed in case there are 2 useModal hooks on the same page and one has updateOnPropsChange
26
+ if (updateOnPropsChange) {
27
+ var modalProps = get(modal, 'props');
28
+ var oldModalProps = get(modalNode[nodeIdIndex], 'props');
29
+ if (modalProps && oldModalProps && JSON.stringify(modalProps) !== JSON.stringify(oldModalProps)) {
30
+ setModalNode(function (prev) { return __spreadArray(__spreadArray([], prev.filter(function (_, i) { return i !== nodeIdIndex; }), true), [modal], false); });
31
+ }
32
+ }
33
+ }, [updateOnPropsChange, nodeId, modalId, modal, nodeIdIndex, modalNode, setModalNode]);
34
+ useEffect(function () {
35
+ setCloseOnOverlayClick(closeOnOverlayClick);
36
+ }, [closeOnOverlayClick, setCloseOnOverlayClick]);
37
+ return [onPresentCallback, handleClose];
38
+ };
39
+ export default useModal;
@@ -0,0 +1,5 @@
1
+ export declare const isNumber: (s: string) => boolean;
2
+ export declare const floorFormatter: (n: number) => string;
3
+ export declare const volumeFormatter: (n: number) => string;
4
+ export declare const quantityFormatter: (n: number) => string;
5
+ export declare const roundWholePercentage: (n: number) => string;
@@ -0,0 +1,111 @@
1
+ import numbro from 'numbro';
2
+ export var isNumber = function (s) {
3
+ var reg = /^-?\d+\.?\d*$/;
4
+ return reg.test(s) && !isNaN(parseFloat(s)) && isFinite(parseFloat(s));
5
+ };
6
+ export var floorFormatter = function (n) {
7
+ if (n === 0)
8
+ return '0.00';
9
+ if (!n)
10
+ return '';
11
+ if (n < 0.001) {
12
+ return '<0.001';
13
+ }
14
+ if (n >= 0.001 && n < 1) {
15
+ return "".concat(parseFloat(n.toFixed(3)).toLocaleString('en-US', {
16
+ minimumFractionDigits: 1,
17
+ maximumFractionDigits: 3,
18
+ }));
19
+ }
20
+ if (n >= 1 && n < 1e6) {
21
+ return "".concat(parseFloat(n.toPrecision(6)).toLocaleString('en-US', {
22
+ minimumFractionDigits: 0,
23
+ maximumFractionDigits: 2,
24
+ }));
25
+ }
26
+ if (n >= 1e6 && n < 1e15) {
27
+ return numbro(n)
28
+ .format({
29
+ average: true,
30
+ mantissa: 2,
31
+ optionalMantissa: true,
32
+ abbreviations: {
33
+ million: 'M',
34
+ billion: 'B',
35
+ trillion: 'T',
36
+ },
37
+ })
38
+ .toUpperCase();
39
+ }
40
+ if (n >= 1e15) {
41
+ return "".concat(n.toExponential(3).replace(/(\.[0-9]*[1-9])0*|(\.0*)/, '$1'));
42
+ }
43
+ return "".concat(Number(n.toFixed(2)).toLocaleString('en-US', { minimumFractionDigits: 2 }));
44
+ };
45
+ export var volumeFormatter = function (n) {
46
+ if (n === 0)
47
+ return '0.00';
48
+ if (!n)
49
+ return '';
50
+ if (n < 0.01) {
51
+ return '<0.01';
52
+ }
53
+ if (n >= 0.01 && n < 1) {
54
+ return "".concat(parseFloat(n.toFixed(2)).toLocaleString('en-US'));
55
+ }
56
+ if (n >= 1 && n < 1000) {
57
+ return "".concat(Number(Math.round(n).toLocaleString('en-US')));
58
+ }
59
+ if (n >= 1000) {
60
+ return numbro(n)
61
+ .format({
62
+ average: true,
63
+ mantissa: 1,
64
+ optionalMantissa: true,
65
+ abbreviations: {
66
+ thousand: 'K',
67
+ million: 'M',
68
+ billion: 'B',
69
+ trillion: 'T',
70
+ },
71
+ })
72
+ .toUpperCase();
73
+ }
74
+ return "".concat(Number(n.toFixed(1)).toLocaleString('en-US', { minimumFractionDigits: 1 }));
75
+ };
76
+ export var quantityFormatter = function (n) {
77
+ if (n === 0)
78
+ return '0.00';
79
+ if (!n)
80
+ return '';
81
+ if (n >= 1 && n < 1000) {
82
+ return "".concat(Number(Math.round(n).toLocaleString('en-US')));
83
+ }
84
+ if (n >= 1000) {
85
+ return numbro(n)
86
+ .format({
87
+ average: true,
88
+ mantissa: 1,
89
+ thousandSeparated: true,
90
+ optionalMantissa: true,
91
+ abbreviations: {
92
+ thousand: 'K',
93
+ million: 'M',
94
+ billion: 'B',
95
+ trillion: 'T',
96
+ },
97
+ })
98
+ .toUpperCase();
99
+ }
100
+ return "".concat(Number(n.toFixed(2)).toLocaleString('en-US', { minimumFractionDigits: 2 }));
101
+ };
102
+ export var roundWholePercentage = function (n) {
103
+ if (n === 0)
104
+ return '0';
105
+ if (!n)
106
+ return '';
107
+ if (n < 1) {
108
+ return '<1';
109
+ }
110
+ return Math.round(n).toString();
111
+ };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ape Bond SDK",
4
4
  "author": "Ape Bond",
5
5
  "license": "MIT",
6
- "version": "1.0.61",
6
+ "version": "1.0.62",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",
@@ -26,6 +26,7 @@
26
26
  "@ape.swap/apeswap-lists": "^2.0.9",
27
27
  "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
28
28
  "@babel/plugin-transform-private-property-in-object": "^7.24.7",
29
+ "@types/lodash": "^4.17.6",
29
30
  "@types/react": "^17.0.0 || ^18.0.0",
30
31
  "@types/react-dom": "^17.0.0 || ^18.0.0",
31
32
  "@web3-react/coinbase-wallet": "^8.2.0",
@@ -45,6 +46,11 @@
45
46
  "typescript": "^4.0.0"
46
47
  },
47
48
  "dependencies": {
49
+ "framer-motion": "^11.3.2",
50
+ "lodash": "^4.17.21",
51
+ "lottie-react": "^2.4.0",
52
+ "next": "^14.2.5",
53
+ "numbro": "^2.5.0",
48
54
  "react-scripts": "^5.0.1",
49
55
  "sass": "^1.77.7",
50
56
  "theme-ui": "^0.16.2"