@gearbox-protocol/permissionless-ui 1.2.33 → 1.4.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.
- package/README.md +120 -1
- package/dist/cjs/components/asset-line.js +117 -0
- package/dist/cjs/components/assets-list-cell.js +73 -0
- package/dist/cjs/components/assets-ratio.js +98 -0
- package/dist/cjs/components/auth/siwe-provider.js +4 -4
- package/dist/cjs/components/base-link.js +61 -0
- package/dist/cjs/components/block-sync.js +118 -0
- package/dist/cjs/components/breadcrumbs.js +77 -0
- package/dist/cjs/components/buttons/back-button.js +37 -19
- package/dist/cjs/components/buttons/button.js +4 -4
- package/dist/cjs/components/buttons/filter-button.js +68 -0
- package/dist/cjs/components/buttons/index.js +4 -0
- package/dist/cjs/components/buttons/navigation-button.js +2 -2
- package/dist/cjs/components/buttons/range-buttons.js +63 -0
- package/dist/cjs/components/card-grid.js +127 -0
- package/dist/cjs/components/card.js +176 -0
- package/dist/cjs/components/checkbox-item.js +82 -0
- package/dist/cjs/components/compound-apy.js +232 -0
- package/dist/cjs/components/credit-session-status.js +67 -0
- package/dist/cjs/components/description.js +48 -0
- package/dist/cjs/components/detailed-page-title.js +96 -0
- package/dist/cjs/components/dialog/dialog-container.js +75 -0
- package/dist/cjs/components/dialog/dialog-content.js +66 -0
- package/dist/cjs/components/dialog/dialog-description.js +50 -0
- package/dist/cjs/components/dialog/dialog-footer.js +53 -0
- package/dist/cjs/components/dialog/dialog-header.js +53 -0
- package/dist/cjs/components/dialog/dialog-overlay.js +53 -0
- package/dist/cjs/components/dialog/dialog-title.js +50 -0
- package/dist/cjs/components/dialog/dialog.js +45 -0
- package/dist/cjs/components/dialog/index.js +36 -0
- package/dist/cjs/components/dropdown-menu/dropdown-menu-checkbox-item.js +63 -0
- package/dist/cjs/components/dropdown-menu/dropdown-menu-content.js +55 -0
- package/dist/cjs/components/dropdown-menu/dropdown-menu-item.js +54 -0
- package/dist/cjs/components/dropdown-menu/dropdown-menu-label.js +54 -0
- package/dist/cjs/components/dropdown-menu/dropdown-menu-radio-item.js +58 -0
- package/dist/cjs/components/dropdown-menu/dropdown-menu-separator.js +50 -0
- package/dist/cjs/components/dropdown-menu/dropdown-menu-shortcut.js +52 -0
- package/dist/cjs/components/dropdown-menu/dropdown-menu-sub-content.js +53 -0
- package/dist/cjs/components/dropdown-menu/dropdown-menu-sub-trigger.js +59 -0
- package/dist/cjs/components/dropdown-menu/dropdown-menu.js +54 -0
- package/dist/cjs/components/dropdown-menu/index.js +40 -0
- package/dist/cjs/components/error-message.js +70 -0
- package/dist/cjs/components/filter/filter-block.js +52 -0
- package/dist/cjs/components/filter/filter-checkbox-item.js +59 -0
- package/dist/cjs/components/filter/filter-chip.js +74 -0
- package/dist/cjs/components/filter/filter-chips.js +84 -0
- package/dist/cjs/components/filter/filter-dropdown-item.js +54 -0
- package/dist/cjs/components/filter/filter-group.js +43 -0
- package/dist/cjs/components/filter/filter-label.js +54 -0
- package/dist/cjs/components/filter/filter-modal-item.js +55 -0
- package/dist/cjs/components/filter/filter-modal.js +242 -0
- package/dist/cjs/components/filter/filter-radio-item.js +58 -0
- package/dist/cjs/components/filter/filter-separator.js +50 -0
- package/dist/cjs/components/filter/index.js +44 -0
- package/dist/cjs/components/filter/interface.js +16 -0
- package/dist/cjs/components/filter/variants.js +41 -0
- package/dist/cjs/components/form/form-field.js +67 -0
- package/dist/cjs/components/{editable-table → form}/index.js +4 -8
- package/dist/cjs/components/graph/default-config.js +158 -0
- package/dist/cjs/components/graph/formatters.js +175 -0
- package/dist/cjs/components/graph/graph-current-value.js +54 -0
- package/dist/cjs/components/graph/graph-tooltip.js +142 -0
- package/dist/cjs/components/graph/graph-view.js +233 -0
- package/dist/cjs/components/graph/graph.js +637 -0
- package/dist/cjs/components/graph/index.js +44 -0
- package/dist/cjs/components/graph/plugins/vertical-line.js +127 -0
- package/dist/cjs/components/guard.js +34 -0
- package/dist/cjs/components/health-factor.js +100 -0
- package/dist/cjs/components/help-center-container.js +107 -0
- package/dist/cjs/components/hide-on.js +66 -0
- package/dist/cjs/components/horizontal-indicator.js +63 -0
- package/dist/cjs/components/image.js +56 -0
- package/dist/cjs/components/index.js +93 -9
- package/dist/cjs/components/input.js +43 -21
- package/dist/cjs/components/label.js +29 -5
- package/dist/cjs/components/layout/app-logo.js +7 -17
- package/dist/cjs/components/layout/col.js +192 -0
- package/dist/cjs/components/layout/container.js +75 -0
- package/dist/cjs/components/layout/footer.js +137 -52
- package/dist/cjs/components/layout/grid.js +217 -0
- package/dist/cjs/components/layout/header.js +75 -13
- package/dist/cjs/components/layout/index.js +8 -0
- package/dist/cjs/components/layout/layout.js +65 -0
- package/dist/cjs/components/layout/legal-disclaimer.js +4 -14
- package/dist/cjs/components/liquidation/index.js +28 -0
- package/dist/cjs/components/liquidation/liquidation-assets-table.js +95 -0
- package/dist/cjs/components/liquidation/liquidation-graph-legend.js +41 -0
- package/dist/cjs/components/liquidation/liquidation-graph-tip.js +93 -0
- package/dist/cjs/components/liquidation/liquidation-graph.js +214 -0
- package/dist/cjs/components/loader-guard.js +47 -0
- package/dist/cjs/components/loading-guard.js +55 -0
- package/dist/cjs/components/markdown-viewer.js +4 -2
- package/dist/cjs/components/navbar-indicator-context.js +94 -0
- package/dist/cjs/components/navbar.js +131 -0
- package/dist/cjs/components/navitem.js +148 -0
- package/dist/cjs/components/next/back-button.js +43 -0
- package/dist/cjs/components/next/index.js +40 -0
- package/dist/cjs/components/next/siwe-provider.js +35 -0
- package/dist/cjs/components/next/token-icon.js +43 -0
- package/dist/cjs/components/next/web3-providers.js +116 -0
- package/dist/cjs/components/not-found.js +58 -0
- package/dist/cjs/components/options-list.js +88 -0
- package/dist/cjs/components/page-title.js +116 -0
- package/dist/cjs/components/percent-indicator.js +56 -0
- package/dist/cjs/components/pool-points-indicator.js +107 -0
- package/dist/cjs/components/search-bar.js +1 -0
- package/dist/cjs/components/search-line.js +225 -0
- package/dist/cjs/components/select.js +30 -9
- package/dist/cjs/components/short-string.js +58 -0
- package/dist/cjs/components/signatures/vertical-timeline.js +1 -0
- package/dist/cjs/components/skeleton.js +56 -3
- package/dist/cjs/components/stat-badge.js +189 -0
- package/dist/cjs/components/tab-control.js +254 -0
- package/dist/cjs/components/table/editable-grid-table.js +131 -0
- package/dist/cjs/components/{editable-table → table}/editable-table.js +1 -1
- package/dist/cjs/components/table/grid-error-line.js +60 -0
- package/dist/cjs/components/table/grid-loading-line.js +64 -0
- package/dist/cjs/components/table/grid-table-loader.js +56 -0
- package/dist/cjs/components/table/grid-table.js +203 -0
- package/dist/cjs/components/table/index.js +46 -0
- package/dist/cjs/components/table/sortable-head-cell.js +48 -0
- package/dist/cjs/components/table/table-loader-guard.js +55 -0
- package/dist/cjs/components/table/table-loader.js +46 -0
- package/dist/cjs/components/table/table-sm.js +93 -0
- package/dist/cjs/components/{table.js → table/table.js} +78 -22
- package/dist/cjs/components/textarea.js +27 -7
- package/dist/cjs/components/theme-provider.js +127 -0
- package/dist/cjs/components/theme-toggle.js +85 -0
- package/dist/cjs/components/token-icon.js +69 -20
- package/dist/cjs/components/token-symbol.js +84 -0
- package/dist/cjs/components/tooltip.js +1 -1
- package/dist/cjs/components/typed-intl/index.js +57 -0
- package/dist/cjs/components/vspace.js +31 -0
- package/dist/cjs/components/with-filter-button.js +84 -0
- package/dist/cjs/configs/design-tokens.js +109 -0
- package/dist/cjs/configs/index.js +48 -0
- package/dist/cjs/configs/tailwind-preset.js +162 -0
- package/dist/cjs/configs/tailwind.config.js +20 -67
- package/dist/cjs/configs/variants.js +58 -0
- package/dist/cjs/hooks/index.js +34 -0
- package/dist/cjs/hooks/use-controllable-state.js +50 -0
- package/dist/cjs/hooks/use-debounce.js +68 -0
- package/dist/cjs/hooks/use-filter.js +80 -0
- package/dist/cjs/hooks/use-hf.js +62 -0
- package/dist/cjs/hooks/use-liquidation/index.js +204 -0
- package/dist/cjs/hooks/use-liquidation/types.js +16 -0
- package/dist/cjs/hooks/use-liquidation/utils.js +253 -0
- package/dist/cjs/hooks/use-media-query.js +51 -0
- package/dist/cjs/hooks/use-previous.js +36 -0
- package/dist/cjs/index.js +157 -3
- package/dist/cjs/types/component-props.js +16 -0
- package/dist/cjs/types/filter.js +16 -0
- package/dist/cjs/types/footer.js +16 -0
- package/dist/cjs/types/graph.js +16 -0
- package/dist/cjs/types/help.js +16 -0
- package/dist/cjs/types/index.js +16 -0
- package/dist/cjs/types/range-item.js +16 -0
- package/dist/cjs/utils/a11y.js +39 -0
- package/dist/cjs/utils/bn-to-input-view.js +60 -0
- package/dist/cjs/utils/colors.js +96 -0
- package/dist/cjs/utils/format-asset-amount.js +43 -0
- package/dist/cjs/utils/format-money.js +68 -0
- package/dist/cjs/utils/index.js +29 -2
- package/dist/cjs/utils/interface.js +16 -0
- package/dist/cjs/utils/react.js +105 -0
- package/dist/cjs/utils/short-sha.js +28 -0
- package/dist/cjs/utils/sort.js +16 -0
- package/dist/cjs/utils/templates.js +50 -0
- package/dist/esm/components/asset-line.js +83 -0
- package/dist/esm/components/assets-list-cell.js +39 -0
- package/dist/esm/components/assets-ratio.js +64 -0
- package/dist/esm/components/auth/siwe-provider.js +4 -4
- package/dist/esm/components/base-link.js +27 -0
- package/dist/esm/components/block-sync.js +99 -0
- package/dist/esm/components/breadcrumbs.js +43 -0
- package/dist/esm/components/buttons/back-button.js +35 -8
- package/dist/esm/components/buttons/button.js +4 -4
- package/dist/esm/components/buttons/filter-button.js +34 -0
- package/dist/esm/components/buttons/index.js +2 -0
- package/dist/esm/components/buttons/navigation-button.js +2 -2
- package/dist/esm/components/buttons/range-buttons.js +29 -0
- package/dist/esm/components/card-grid.js +92 -0
- package/dist/esm/components/card.js +133 -0
- package/dist/esm/components/checkbox-item.js +48 -0
- package/dist/esm/components/compound-apy.js +203 -0
- package/dist/esm/components/credit-session-status.js +33 -0
- package/dist/esm/components/description.js +14 -0
- package/dist/esm/components/detailed-page-title.js +67 -0
- package/dist/esm/components/dialog/dialog-container.js +41 -0
- package/dist/esm/components/dialog/dialog-content.js +32 -0
- package/dist/esm/components/dialog/dialog-description.js +16 -0
- package/dist/esm/components/dialog/dialog-footer.js +19 -0
- package/dist/esm/components/dialog/dialog-header.js +19 -0
- package/dist/esm/components/dialog/dialog-overlay.js +19 -0
- package/dist/esm/components/dialog/dialog-title.js +16 -0
- package/dist/esm/components/dialog/dialog.js +9 -0
- package/dist/esm/components/dialog/index.js +8 -0
- package/dist/esm/components/dropdown-menu/dropdown-menu-checkbox-item.js +29 -0
- package/dist/esm/components/dropdown-menu/dropdown-menu-content.js +21 -0
- package/dist/esm/components/dropdown-menu/dropdown-menu-item.js +20 -0
- package/dist/esm/components/dropdown-menu/dropdown-menu-label.js +20 -0
- package/dist/esm/components/dropdown-menu/dropdown-menu-radio-item.js +24 -0
- package/dist/esm/components/dropdown-menu/dropdown-menu-separator.js +16 -0
- package/dist/esm/components/dropdown-menu/dropdown-menu-shortcut.js +18 -0
- package/dist/esm/components/dropdown-menu/dropdown-menu-sub-content.js +19 -0
- package/dist/esm/components/dropdown-menu/dropdown-menu-sub-trigger.js +25 -0
- package/dist/esm/components/dropdown-menu/dropdown-menu.js +15 -0
- package/dist/esm/components/dropdown-menu/index.js +10 -0
- package/dist/esm/components/error-message.js +36 -0
- package/dist/esm/components/filter/filter-block.js +18 -0
- package/dist/esm/components/filter/filter-checkbox-item.js +25 -0
- package/dist/esm/components/filter/filter-chip.js +40 -0
- package/dist/esm/components/filter/filter-chips.js +50 -0
- package/dist/esm/components/filter/filter-dropdown-item.js +20 -0
- package/dist/esm/components/filter/filter-group.js +9 -0
- package/dist/esm/components/filter/filter-label.js +20 -0
- package/dist/esm/components/filter/filter-modal-item.js +21 -0
- package/dist/esm/components/filter/filter-modal.js +214 -0
- package/dist/esm/components/filter/filter-radio-item.js +24 -0
- package/dist/esm/components/filter/filter-separator.js +16 -0
- package/dist/esm/components/filter/index.js +12 -0
- package/dist/esm/components/filter/interface.js +0 -0
- package/dist/esm/components/filter/variants.js +17 -0
- package/dist/esm/components/form/form-field.js +43 -0
- package/dist/esm/components/form/index.js +1 -0
- package/dist/esm/components/graph/default-config.js +129 -0
- package/dist/esm/components/graph/formatters.js +150 -0
- package/dist/esm/components/graph/graph-current-value.js +30 -0
- package/dist/esm/components/graph/graph-tooltip.js +118 -0
- package/dist/esm/components/graph/graph-view.js +196 -0
- package/dist/esm/components/graph/graph.js +606 -0
- package/dist/esm/components/graph/index.js +15 -0
- package/dist/esm/components/graph/plugins/vertical-line.js +103 -0
- package/dist/esm/components/guard.js +10 -0
- package/dist/esm/components/health-factor.js +63 -0
- package/dist/esm/components/help-center-container.js +83 -0
- package/dist/esm/components/hide-on.js +41 -0
- package/dist/esm/components/horizontal-indicator.js +34 -0
- package/dist/esm/components/image.js +32 -0
- package/dist/esm/components/index.js +46 -4
- package/dist/esm/components/input.js +41 -20
- package/dist/esm/components/label.js +27 -4
- package/dist/esm/components/layout/app-logo.js +5 -5
- package/dist/esm/components/layout/col.js +158 -0
- package/dist/esm/components/layout/container.js +41 -0
- package/dist/esm/components/layout/footer.js +134 -52
- package/dist/esm/components/layout/grid.js +183 -0
- package/dist/esm/components/layout/header.js +65 -13
- package/dist/esm/components/layout/index.js +4 -0
- package/dist/esm/components/layout/layout.js +31 -0
- package/dist/esm/components/layout/legal-disclaimer.js +4 -4
- package/dist/esm/components/liquidation/index.js +4 -0
- package/dist/esm/components/liquidation/liquidation-assets-table.js +71 -0
- package/dist/esm/components/liquidation/liquidation-graph-legend.js +17 -0
- package/dist/esm/components/liquidation/liquidation-graph-tip.js +72 -0
- package/dist/esm/components/liquidation/liquidation-graph.js +191 -0
- package/dist/esm/components/loader-guard.js +23 -0
- package/dist/esm/components/loading-guard.js +31 -0
- package/dist/esm/components/markdown-viewer.js +4 -2
- package/dist/esm/components/navbar-indicator-context.js +76 -0
- package/dist/esm/components/navbar.js +98 -0
- package/dist/esm/components/navitem.js +113 -0
- package/dist/esm/components/next/back-button.js +11 -0
- package/dist/esm/components/next/index.js +12 -0
- package/dist/esm/components/next/siwe-provider.js +11 -0
- package/dist/esm/components/next/token-icon.js +11 -0
- package/dist/esm/components/next/web3-providers.js +92 -0
- package/dist/esm/components/not-found.js +24 -0
- package/dist/esm/components/options-list.js +53 -0
- package/dist/esm/components/page-title.js +80 -0
- package/dist/esm/components/percent-indicator.js +22 -0
- package/dist/esm/components/pool-points-indicator.js +73 -0
- package/dist/esm/components/search-bar.js +1 -0
- package/dist/esm/components/search-line.js +188 -0
- package/dist/esm/components/select.js +28 -8
- package/dist/esm/components/short-string.js +39 -0
- package/dist/esm/components/signatures/vertical-timeline.js +1 -0
- package/dist/esm/components/skeleton.js +54 -2
- package/dist/esm/components/stat-badge.js +155 -0
- package/dist/esm/components/tab-control.js +216 -0
- package/dist/esm/components/table/editable-grid-table.js +105 -0
- package/dist/esm/components/{editable-table → table}/editable-table.js +1 -1
- package/dist/esm/components/table/grid-error-line.js +36 -0
- package/dist/esm/components/table/grid-loading-line.js +30 -0
- package/dist/esm/components/table/grid-table-loader.js +22 -0
- package/dist/esm/components/table/grid-table.js +159 -0
- package/dist/esm/components/table/index.js +13 -0
- package/dist/esm/components/table/sortable-head-cell.js +24 -0
- package/dist/esm/components/table/table-loader-guard.js +31 -0
- package/dist/esm/components/table/table-loader.js +22 -0
- package/dist/esm/components/table/table-sm.js +58 -0
- package/dist/esm/components/{table.js → table/table.js} +74 -21
- package/dist/esm/components/textarea.js +25 -6
- package/dist/esm/components/theme-provider.js +108 -0
- package/dist/esm/components/theme-toggle.js +61 -0
- package/dist/esm/components/token-icon.js +70 -11
- package/dist/esm/components/token-symbol.js +50 -0
- package/dist/esm/components/tooltip.js +1 -1
- package/dist/esm/components/typed-intl/index.js +32 -0
- package/dist/esm/components/vspace.js +7 -0
- package/dist/esm/components/with-filter-button.js +50 -0
- package/dist/esm/configs/design-tokens.js +85 -0
- package/dist/esm/configs/index.js +9 -0
- package/dist/esm/configs/tailwind-preset.js +128 -0
- package/dist/esm/configs/tailwind.config.js +16 -57
- package/dist/esm/configs/variants.js +31 -0
- package/dist/esm/hooks/index.js +7 -0
- package/dist/esm/hooks/use-controllable-state.js +26 -0
- package/dist/esm/hooks/use-debounce.js +43 -0
- package/dist/esm/hooks/use-filter.js +52 -0
- package/dist/esm/hooks/use-hf.js +38 -0
- package/dist/esm/hooks/use-liquidation/index.js +188 -0
- package/dist/esm/hooks/use-liquidation/types.js +0 -0
- package/dist/esm/hooks/use-liquidation/utils.js +215 -0
- package/dist/esm/hooks/use-media-query.js +24 -0
- package/dist/esm/hooks/use-previous.js +12 -0
- package/dist/esm/index.js +84 -1
- package/dist/esm/types/component-props.js +0 -0
- package/dist/esm/types/filter.js +0 -0
- package/dist/esm/types/footer.js +0 -0
- package/dist/esm/types/graph.js +0 -0
- package/dist/esm/types/help.js +0 -0
- package/dist/esm/types/index.js +0 -0
- package/dist/esm/types/range-item.js +0 -0
- package/dist/esm/utils/a11y.js +14 -0
- package/dist/esm/utils/bn-to-input-view.js +36 -0
- package/dist/esm/utils/colors.js +69 -0
- package/dist/esm/utils/format-asset-amount.js +19 -0
- package/dist/esm/utils/format-money.js +40 -0
- package/dist/esm/utils/index.js +21 -1
- package/dist/esm/utils/interface.js +0 -0
- package/dist/esm/utils/react.js +70 -0
- package/dist/esm/utils/short-sha.js +4 -0
- package/dist/esm/utils/sort.js +0 -0
- package/dist/esm/utils/templates.js +24 -0
- package/dist/globals.css +230 -52
- package/dist/grid-safelist.css +264 -0
- package/dist/types/components/asset-line.d.ts +59 -0
- package/dist/types/components/assets-list-cell.d.ts +48 -0
- package/dist/types/components/assets-ratio.d.ts +9 -0
- package/dist/types/components/auth/signin-required.d.ts +1 -1
- package/dist/types/components/auth/siwe-provider.d.ts +2 -1
- package/dist/types/components/badge.d.ts +1 -1
- package/dist/types/components/base-link.d.ts +58 -0
- package/dist/types/components/block-sync.d.ts +8 -0
- package/dist/types/components/breadcrumbs.d.ts +24 -0
- package/dist/types/components/buttons/back-button.d.ts +15 -20
- package/dist/types/components/buttons/button.d.ts +37 -3
- package/dist/types/components/buttons/filter-button.d.ts +52 -0
- package/dist/types/components/buttons/index.d.ts +2 -0
- package/dist/types/components/buttons/range-buttons.d.ts +49 -0
- package/dist/types/components/card-grid.d.ts +25 -0
- package/dist/types/components/card.d.ts +116 -0
- package/dist/types/components/cards/card.d.ts +2 -2
- package/dist/types/components/checkbox-item.d.ts +56 -0
- package/dist/types/components/compound-apy.d.ts +80 -0
- package/dist/types/components/credit-session-status.d.ts +7 -0
- package/dist/types/components/description.d.ts +26 -0
- package/dist/types/components/detailed-page-title.d.ts +31 -0
- package/dist/types/components/dialog/dialog-container.d.ts +12 -0
- package/dist/types/components/dialog/dialog-content.d.ts +4 -0
- package/dist/types/components/dialog/dialog-description.d.ts +4 -0
- package/dist/types/components/dialog/dialog-footer.d.ts +6 -0
- package/dist/types/components/dialog/dialog-header.d.ts +6 -0
- package/dist/types/components/dialog/dialog-overlay.d.ts +4 -0
- package/dist/types/components/dialog/dialog-title.d.ts +4 -0
- package/dist/types/components/dialog/dialog.d.ts +5 -0
- package/dist/types/components/dialog/index.d.ts +8 -0
- package/dist/types/components/dropdown-menu/dropdown-menu-checkbox-item.d.ts +22 -0
- package/dist/types/components/dropdown-menu/dropdown-menu-content.d.ts +4 -0
- package/dist/types/components/dropdown-menu/dropdown-menu-item.d.ts +6 -0
- package/dist/types/components/dropdown-menu/dropdown-menu-label.d.ts +6 -0
- package/dist/types/components/dropdown-menu/dropdown-menu-radio-item.d.ts +4 -0
- package/dist/types/components/dropdown-menu/dropdown-menu-separator.d.ts +4 -0
- package/dist/types/components/dropdown-menu/dropdown-menu-shortcut.d.ts +6 -0
- package/dist/types/components/dropdown-menu/dropdown-menu-sub-content.d.ts +4 -0
- package/dist/types/components/dropdown-menu/dropdown-menu-sub-trigger.d.ts +6 -0
- package/dist/types/components/dropdown-menu/dropdown-menu.d.ts +8 -0
- package/dist/types/components/dropdown-menu/index.d.ts +10 -0
- package/dist/types/components/error-message.d.ts +21 -0
- package/dist/types/components/filter/filter-block.d.ts +17 -0
- package/dist/types/components/filter/filter-checkbox-item.d.ts +23 -0
- package/dist/types/components/filter/filter-chip.d.ts +34 -0
- package/dist/types/components/filter/filter-chips.d.ts +42 -0
- package/dist/types/components/filter/filter-dropdown-item.d.ts +24 -0
- package/dist/types/components/filter/filter-group.d.ts +22 -0
- package/dist/types/components/filter/filter-label.d.ts +21 -0
- package/dist/types/components/filter/filter-modal-item.d.ts +31 -0
- package/dist/types/components/filter/filter-modal.d.ts +123 -0
- package/dist/types/components/filter/filter-radio-item.d.ts +19 -0
- package/dist/types/components/filter/filter-separator.d.ts +22 -0
- package/dist/types/components/filter/index.d.ts +109 -0
- package/dist/types/components/filter/interface.d.ts +24 -0
- package/dist/types/components/filter/variants.d.ts +3 -0
- package/dist/types/components/form/form-field.d.ts +38 -0
- package/dist/types/components/form/index.d.ts +1 -0
- package/dist/types/components/graph/default-config.d.ts +20 -0
- package/dist/types/components/graph/formatters.d.ts +16 -0
- package/dist/types/components/graph/graph-current-value.d.ts +13 -0
- package/dist/types/components/graph/graph-tooltip.d.ts +24 -0
- package/dist/types/components/graph/graph-view.d.ts +198 -0
- package/dist/types/components/graph/graph.d.ts +49 -0
- package/dist/types/components/graph/index.d.ts +7 -0
- package/dist/types/components/guard.d.ts +34 -0
- package/dist/types/components/health-factor.d.ts +63 -0
- package/dist/types/components/help-center-container.d.ts +22 -0
- package/dist/types/components/hide-on.d.ts +32 -0
- package/dist/types/components/horizontal-indicator.d.ts +22 -0
- package/dist/types/components/image.d.ts +35 -0
- package/dist/types/components/index.d.ts +44 -1
- package/dist/types/components/input.d.ts +26 -9
- package/dist/types/components/label.d.ts +26 -5
- package/dist/types/components/layout/app-logo.d.ts +1 -0
- package/dist/types/components/layout/col.d.ts +43 -0
- package/dist/types/components/layout/container.d.ts +37 -0
- package/dist/types/components/layout/footer.d.ts +44 -5
- package/dist/types/components/layout/grid.d.ts +48 -0
- package/dist/types/components/layout/header.d.ts +68 -12
- package/dist/types/components/layout/index.d.ts +4 -0
- package/dist/types/components/layout/layout.d.ts +12 -0
- package/dist/types/components/liquidation/index.d.ts +4 -0
- package/dist/types/components/liquidation/liquidation-assets-table.d.ts +14 -0
- package/dist/types/components/liquidation/liquidation-graph-legend.d.ts +2 -0
- package/dist/types/components/liquidation/liquidation-graph-tip.d.ts +13 -0
- package/dist/types/components/liquidation/liquidation-graph.d.ts +19 -0
- package/dist/types/components/loader-guard.d.ts +17 -0
- package/dist/types/components/loading-guard.d.ts +18 -0
- package/dist/types/components/navbar-indicator-context.d.ts +13 -0
- package/dist/types/components/navbar.d.ts +25 -0
- package/dist/types/components/navitem.d.ts +67 -0
- package/dist/types/components/next/back-button.d.ts +3 -0
- package/dist/types/components/next/index.d.ts +10 -0
- package/dist/types/components/next/siwe-provider.d.ts +7 -0
- package/dist/types/components/next/token-icon.d.ts +3 -0
- package/dist/types/components/next/web3-providers.d.ts +29 -0
- package/dist/types/components/not-found.d.ts +18 -0
- package/dist/types/components/options-list.d.ts +15 -0
- package/dist/types/components/page-title.d.ts +69 -0
- package/dist/types/components/percent-indicator.d.ts +28 -0
- package/dist/types/components/pool-points-indicator.d.ts +41 -0
- package/dist/types/components/search-line.d.ts +117 -0
- package/dist/types/components/select.d.ts +9 -2
- package/dist/types/components/short-string.d.ts +39 -0
- package/dist/types/components/skeleton.d.ts +28 -3
- package/dist/types/components/stat-badge.d.ts +169 -0
- package/dist/types/components/tab-control.d.ts +39 -0
- package/dist/types/components/table/editable-grid-table.d.ts +120 -0
- package/dist/types/components/table/grid-error-line.d.ts +49 -0
- package/dist/types/components/table/grid-loading-line.d.ts +36 -0
- package/dist/types/components/table/grid-table-loader.d.ts +25 -0
- package/dist/types/components/table/grid-table.d.ts +158 -0
- package/dist/types/components/table/index.d.ts +13 -0
- package/dist/types/components/table/sortable-head-cell.d.ts +36 -0
- package/dist/types/components/table/table-loader-guard.d.ts +45 -0
- package/dist/types/components/table/table-loader.d.ts +46 -0
- package/dist/types/components/table/table-sm.d.ts +94 -0
- package/dist/types/components/{table.d.ts → table/table.d.ts} +39 -12
- package/dist/types/components/{editable-table → table}/updated-value.d.ts +3 -0
- package/dist/types/components/textarea.d.ts +24 -5
- package/dist/types/components/theme-provider.d.ts +34 -0
- package/dist/types/components/theme-toggle.d.ts +5 -0
- package/dist/types/components/token-icon.d.ts +8 -6
- package/dist/types/components/token-symbol.d.ts +71 -0
- package/dist/types/components/typed-intl/index.d.ts +19 -0
- package/dist/types/components/vspace.d.ts +27 -0
- package/dist/types/components/with-filter-button.d.ts +54 -0
- package/dist/types/configs/design-tokens.d.ts +73 -0
- package/dist/types/configs/index.d.ts +4 -0
- package/dist/types/configs/tailwind-preset.d.ts +126 -0
- package/dist/types/configs/tailwind.config.d.ts +29 -0
- package/dist/types/configs/variants.d.ts +28 -0
- package/dist/types/hooks/index.d.ts +7 -0
- package/dist/types/hooks/use-controllable-state.d.ts +24 -0
- package/dist/types/hooks/use-debounce.d.ts +31 -0
- package/dist/types/hooks/use-filter.d.ts +37 -0
- package/dist/types/hooks/use-hf.d.ts +15 -0
- package/dist/types/hooks/use-liquidation/index.d.ts +52 -0
- package/dist/types/hooks/use-liquidation/types.d.ts +16 -0
- package/dist/types/hooks/use-liquidation/utils.d.ts +66 -0
- package/dist/types/hooks/use-media-query.d.ts +25 -0
- package/dist/types/hooks/use-previous.d.ts +10 -0
- package/dist/types/index.d.ts +71 -2
- package/dist/types/types/component-props.d.ts +16 -0
- package/dist/types/types/filter.d.ts +8 -0
- package/dist/types/types/footer.d.ts +30 -0
- package/dist/types/types/graph.d.ts +22 -0
- package/dist/types/types/help.d.ts +4 -0
- package/dist/types/types/index.d.ts +6 -0
- package/dist/types/types/range-item.d.ts +9 -0
- package/dist/types/utils/a11y.d.ts +24 -0
- package/dist/types/utils/bn-to-input-view.d.ts +17 -0
- package/dist/types/utils/colors.d.ts +29 -0
- package/dist/types/utils/format-asset-amount.d.ts +16 -0
- package/dist/types/utils/format-money.d.ts +64 -0
- package/dist/types/utils/index.d.ts +10 -0
- package/dist/types/utils/interface.d.ts +9 -0
- package/dist/types/utils/react.d.ts +31 -0
- package/dist/types/utils/short-sha.d.ts +9 -0
- package/dist/types/utils/sort.d.ts +5 -0
- package/dist/types/utils/templates.d.ts +61 -0
- package/package.json +66 -28
- package/dist/cjs/components/dialog.js +0 -137
- package/dist/cjs/components/dropdown-menu.js +0 -200
- package/dist/esm/components/dialog.js +0 -97
- package/dist/esm/components/dropdown-menu.js +0 -152
- package/dist/esm/components/editable-table/index.js +0 -3
- package/dist/types/components/dialog.d.ts +0 -38
- package/dist/types/components/dropdown-menu.d.ts +0 -59
- package/dist/types/components/editable-table/index.d.ts +0 -3
- /package/dist/cjs/components/{editable-table → table}/edit-button.js +0 -0
- /package/dist/cjs/components/{editable-table → table}/updated-value.js +0 -0
- /package/dist/esm/components/{editable-table → table}/edit-button.js +0 -0
- /package/dist/esm/components/{editable-table → table}/updated-value.js +0 -0
- /package/dist/types/components/{editable-table → table}/edit-button.d.ts +0 -0
- /package/dist/types/components/{editable-table → table}/editable-table.d.ts +0 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatBN,
|
|
3
|
+
PERCENTAGE_FACTOR,
|
|
4
|
+
PRICE_DECIMALS_POW,
|
|
5
|
+
toBN
|
|
6
|
+
} from "@gearbox-protocol/sdk";
|
|
7
|
+
import { useCallback, useMemo, useState } from "react";
|
|
8
|
+
import { bnToInputView } from "../../utils/bn-to-input-view.js";
|
|
9
|
+
const CELL_HOVERED = "rct-chart__heatmap-cell--hovered";
|
|
10
|
+
const CELL_CURRENT = "rct-chart__heatmap-cell--current";
|
|
11
|
+
const CELL_GOOD = "rct-chart__heatmap-cell--good";
|
|
12
|
+
const CELL_OK = "rct-chart__heatmap-cell--ok";
|
|
13
|
+
const CELL_BAD = "rct-chart__heatmap-cell--bad";
|
|
14
|
+
const CELL_LIQUIDATION = "rct-chart__heatmap-cell--liquidation";
|
|
15
|
+
const DEFAULT_AXIS_MIN = 0;
|
|
16
|
+
const DEFAULT_AXIS_MAX = 1;
|
|
17
|
+
function useAxis({
|
|
18
|
+
token,
|
|
19
|
+
currentPrice
|
|
20
|
+
}) {
|
|
21
|
+
const [order, setOrder] = useState("straight");
|
|
22
|
+
const nextOrder = useCallback(() => {
|
|
23
|
+
setOrder(order === "straight" ? "reverse" : "straight");
|
|
24
|
+
}, [order]);
|
|
25
|
+
const boundaries = useMemo(() => {
|
|
26
|
+
return currentPrice !== void 0 ? {
|
|
27
|
+
min: 0,
|
|
28
|
+
max: currentPrice * 1.5,
|
|
29
|
+
minHf: Number(PERCENTAGE_FACTOR)
|
|
30
|
+
} : void 0;
|
|
31
|
+
}, [currentPrice]);
|
|
32
|
+
const r = useMemo(() => {
|
|
33
|
+
return boundaries !== void 0 && token !== void 0 ? {
|
|
34
|
+
...boundaries,
|
|
35
|
+
label: token,
|
|
36
|
+
nextOrder,
|
|
37
|
+
order
|
|
38
|
+
} : void 0;
|
|
39
|
+
}, [boundaries, token, nextOrder, order]);
|
|
40
|
+
return r;
|
|
41
|
+
}
|
|
42
|
+
function useFixedAssets({
|
|
43
|
+
assets,
|
|
44
|
+
liquidationThresholds,
|
|
45
|
+
quotas,
|
|
46
|
+
quotasInfo,
|
|
47
|
+
at = 0,
|
|
48
|
+
length = 2
|
|
49
|
+
}) {
|
|
50
|
+
const b = useMemo(() => {
|
|
51
|
+
const copy = [...assets].filter((a) => {
|
|
52
|
+
const lt = liquidationThresholds[a.token] || 0n;
|
|
53
|
+
const qInfo = quotasInfo[a.token];
|
|
54
|
+
const qBalance = quotas[a.token]?.balance || 0n;
|
|
55
|
+
if (!qInfo) return lt > 0;
|
|
56
|
+
if (!qInfo.isActive) return false;
|
|
57
|
+
return lt > 0 && qBalance > 0;
|
|
58
|
+
});
|
|
59
|
+
const fixed = copy.splice(at, length);
|
|
60
|
+
return [fixed, copy];
|
|
61
|
+
}, [assets, liquidationThresholds, quotas, quotasInfo, at, length]);
|
|
62
|
+
return b;
|
|
63
|
+
}
|
|
64
|
+
const EMPTY_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
65
|
+
function usePriceInNumber({
|
|
66
|
+
asset,
|
|
67
|
+
tokensList,
|
|
68
|
+
prices
|
|
69
|
+
}) {
|
|
70
|
+
const r = useMemo(() => {
|
|
71
|
+
const price = prices[asset?.token || EMPTY_ADDRESS];
|
|
72
|
+
const token = tokensList[asset?.token || EMPTY_ADDRESS];
|
|
73
|
+
const priceNum = price ? Number(bnToInputView(price, 8)) : void 0;
|
|
74
|
+
return [priceNum, token];
|
|
75
|
+
}, [asset, tokensList, prices]);
|
|
76
|
+
return r;
|
|
77
|
+
}
|
|
78
|
+
function useIsAxisInRelativeUnits(axis, underlying) {
|
|
79
|
+
const r = useMemo(() => {
|
|
80
|
+
return !!axis && !!underlying && axis.address !== underlying.address;
|
|
81
|
+
}, [axis, underlying]);
|
|
82
|
+
return r;
|
|
83
|
+
}
|
|
84
|
+
const DECIMALS = 2;
|
|
85
|
+
const MIN_NON_EXP = 1 / 10 ** DECIMALS;
|
|
86
|
+
const MAX_SMALL_DECIMALS = 6;
|
|
87
|
+
function formatAxisTipPrice(v) {
|
|
88
|
+
if (!Number.isFinite(v)) return "\u221E";
|
|
89
|
+
if (v < MIN_NON_EXP && v !== 0) {
|
|
90
|
+
const formatted = v.toFixed(MAX_SMALL_DECIMALS);
|
|
91
|
+
return formatted.replace(/\.?0+$/, "");
|
|
92
|
+
}
|
|
93
|
+
if (v > 1) return formatBN(toBN(v.toString(), DECIMALS), DECIMALS);
|
|
94
|
+
return v.toFixed(DECIMALS);
|
|
95
|
+
}
|
|
96
|
+
function formatAxisTipLabel(token, underlyingToken, order) {
|
|
97
|
+
const [t, u] = order === "straight" ? [token, underlyingToken] : [underlyingToken, token];
|
|
98
|
+
if (!token) return "";
|
|
99
|
+
return [
|
|
100
|
+
...t ? [t.title] : [],
|
|
101
|
+
...u && t && u.address !== t.address ? [u.title] : []
|
|
102
|
+
].join("/");
|
|
103
|
+
}
|
|
104
|
+
function formatAxisLabel(underlyingPrice, isRelative, order = "straight") {
|
|
105
|
+
return (l = 0) => isRelative && underlyingPrice ? formatAxisTipPrice(
|
|
106
|
+
order === "straight" ? priceInPercent(l, underlyingPrice) : priceInPercent(underlyingPrice, l)
|
|
107
|
+
) : `$${formatBN(
|
|
108
|
+
toBN(String(l), PRICE_DECIMALS_POW),
|
|
109
|
+
PRICE_DECIMALS_POW,
|
|
110
|
+
1
|
|
111
|
+
)}`;
|
|
112
|
+
}
|
|
113
|
+
function priceInPercent(price, base) {
|
|
114
|
+
const p = typeof price === "bigint" ? Number(bnToInputView(price, PRICE_DECIMALS_POW)) : price;
|
|
115
|
+
const b = typeof base === "bigint" ? Number(bnToInputView(base, PRICE_DECIMALS_POW)) : base;
|
|
116
|
+
return p / b;
|
|
117
|
+
}
|
|
118
|
+
function useLiquidationGraphActivePrice(activePoint, underlyingPrice, isRelative, order = "straight") {
|
|
119
|
+
const activePrice = useMemo(() => {
|
|
120
|
+
return underlyingPrice && isRelative ? order === "straight" ? priceInPercent(activePoint, underlyingPrice) : priceInPercent(underlyingPrice, activePoint) : activePoint;
|
|
121
|
+
}, [activePoint, underlyingPrice, order, isRelative]);
|
|
122
|
+
return activePrice;
|
|
123
|
+
}
|
|
124
|
+
function useLiquidationGraphCurrentActiveValue() {
|
|
125
|
+
const [activePoint, setActiveX] = useState(null);
|
|
126
|
+
const handleMouseMove = ({
|
|
127
|
+
xValue,
|
|
128
|
+
yValue
|
|
129
|
+
}) => {
|
|
130
|
+
setActiveX([
|
|
131
|
+
xValue === null ? void 0 : xValue,
|
|
132
|
+
yValue === null ? void 0 : yValue
|
|
133
|
+
]);
|
|
134
|
+
};
|
|
135
|
+
const handleMouseLeave = () => {
|
|
136
|
+
setActiveX(null);
|
|
137
|
+
};
|
|
138
|
+
return {
|
|
139
|
+
activePoint,
|
|
140
|
+
handleMouseMove,
|
|
141
|
+
handleMouseLeave
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function useWithLiquidationGraphActivePrices({
|
|
145
|
+
xLabel,
|
|
146
|
+
yLabel,
|
|
147
|
+
activePoint,
|
|
148
|
+
prices
|
|
149
|
+
}) {
|
|
150
|
+
const [activePointX, activePointY] = activePoint || [];
|
|
151
|
+
const r = useMemo(() => {
|
|
152
|
+
return {
|
|
153
|
+
...prices,
|
|
154
|
+
...xLabel && activePointX ? { [xLabel.address]: toBN(String(activePointX), PRICE_DECIMALS_POW) } : {},
|
|
155
|
+
...yLabel && activePointY ? { [yLabel.address]: toBN(String(activePointY), PRICE_DECIMALS_POW) } : {}
|
|
156
|
+
};
|
|
157
|
+
}, [prices, xLabel, yLabel, activePointX, activePointY]);
|
|
158
|
+
return r;
|
|
159
|
+
}
|
|
160
|
+
function isPointInCell(p, c) {
|
|
161
|
+
return p[0] >= c.x && p[0] <= c.xEnd && p[1] >= c.y && p[1] <= c.yEnd;
|
|
162
|
+
}
|
|
163
|
+
const GOOD_HF = 15e3;
|
|
164
|
+
const BAD_HF = 11e3;
|
|
165
|
+
const CRITICAL_HF = 10500;
|
|
166
|
+
function getHFZones(hf) {
|
|
167
|
+
if (hf >= GOOD_HF) return "good";
|
|
168
|
+
if (hf > BAD_HF) return "medium";
|
|
169
|
+
if (hf > CRITICAL_HF) return "bad";
|
|
170
|
+
if (hf > PERCENTAGE_FACTOR) return "critical";
|
|
171
|
+
return "liquidation";
|
|
172
|
+
}
|
|
173
|
+
function getCellClass(p, currentPoint, activePointX, activePointY) {
|
|
174
|
+
const classes = [];
|
|
175
|
+
const z = getHFZones(p.value);
|
|
176
|
+
const isCurrentCell = isPointInCell(currentPoint, p);
|
|
177
|
+
const isHoveredCell = activePointX !== void 0 && activePointY !== void 0 ? isPointInCell([activePointX, activePointY], p) : false;
|
|
178
|
+
if (isHoveredCell) {
|
|
179
|
+
classes.push(CELL_HOVERED);
|
|
180
|
+
}
|
|
181
|
+
if (isCurrentCell) {
|
|
182
|
+
classes.push(CELL_CURRENT);
|
|
183
|
+
} else if (z === "good") {
|
|
184
|
+
classes.push(CELL_GOOD);
|
|
185
|
+
} else if (z === "medium") {
|
|
186
|
+
classes.push(CELL_OK);
|
|
187
|
+
} else if (z === "bad" || z === "critical") {
|
|
188
|
+
classes.push(CELL_BAD);
|
|
189
|
+
} else {
|
|
190
|
+
classes.push(CELL_LIQUIDATION);
|
|
191
|
+
}
|
|
192
|
+
return classes.join(" ");
|
|
193
|
+
}
|
|
194
|
+
export {
|
|
195
|
+
CELL_BAD,
|
|
196
|
+
CELL_CURRENT,
|
|
197
|
+
CELL_GOOD,
|
|
198
|
+
CELL_HOVERED,
|
|
199
|
+
CELL_LIQUIDATION,
|
|
200
|
+
CELL_OK,
|
|
201
|
+
DEFAULT_AXIS_MAX,
|
|
202
|
+
DEFAULT_AXIS_MIN,
|
|
203
|
+
formatAxisLabel,
|
|
204
|
+
formatAxisTipLabel,
|
|
205
|
+
formatAxisTipPrice,
|
|
206
|
+
getCellClass,
|
|
207
|
+
isPointInCell,
|
|
208
|
+
useAxis,
|
|
209
|
+
useFixedAssets,
|
|
210
|
+
useIsAxisInRelativeUnits,
|
|
211
|
+
useLiquidationGraphActivePrice,
|
|
212
|
+
useLiquidationGraphCurrentActiveValue,
|
|
213
|
+
usePriceInNumber,
|
|
214
|
+
useWithLiquidationGraphActivePrices
|
|
215
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
function useMediaQuery(query) {
|
|
4
|
+
const [matches, setMatches] = useState(false);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const media = window.matchMedia(query);
|
|
7
|
+
if (media.matches !== matches) {
|
|
8
|
+
setMatches(media.matches);
|
|
9
|
+
}
|
|
10
|
+
const listener = () => setMatches(media.matches);
|
|
11
|
+
media.addEventListener("change", listener);
|
|
12
|
+
return () => media.removeEventListener("change", listener);
|
|
13
|
+
}, [matches, query]);
|
|
14
|
+
return matches;
|
|
15
|
+
}
|
|
16
|
+
const useIsMobile = () => useMediaQuery("(max-width: 768px)");
|
|
17
|
+
const useIsTablet = () => useMediaQuery("(min-width: 768px) and (max-width: 1024px)");
|
|
18
|
+
const useIsDesktop = () => useMediaQuery("(min-width: 1024px)");
|
|
19
|
+
export {
|
|
20
|
+
useIsDesktop,
|
|
21
|
+
useIsMobile,
|
|
22
|
+
useIsTablet,
|
|
23
|
+
useMediaQuery
|
|
24
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,85 @@
|
|
|
1
|
-
export * from "./components/
|
|
1
|
+
export * from "./components/alert-dialog.js";
|
|
2
|
+
export * from "./components/asset-line.js";
|
|
3
|
+
export * from "./components/assets-list-cell.js";
|
|
4
|
+
export * from "./components/assets-ratio.js";
|
|
5
|
+
export * from "./components/auth/index.js";
|
|
6
|
+
export * from "./components/badge.js";
|
|
7
|
+
export * from "./components/base-link.js";
|
|
8
|
+
export * from "./components/block-sync.js";
|
|
9
|
+
export * from "./components/breadcrumbs.js";
|
|
10
|
+
export * from "./components/buttons/index.js";
|
|
11
|
+
export * from "./components/card-grid.js";
|
|
12
|
+
export * from "./components/cards/index.js";
|
|
13
|
+
export * from "./components/checkbox.js";
|
|
14
|
+
export * from "./components/compound-apy.js";
|
|
15
|
+
export * from "./components/credit-session-status.js";
|
|
16
|
+
export * from "./components/description.js";
|
|
17
|
+
export * from "./components/detailed-page-title.js";
|
|
18
|
+
export * from "./components/dialog/index.js";
|
|
19
|
+
export * from "./components/dropdown-menu/index.js";
|
|
20
|
+
export * from "./components/error-message.js";
|
|
21
|
+
export * from "./components/filter/index.js";
|
|
22
|
+
export * from "./components/form/index.js";
|
|
23
|
+
export * from "./components/graph/index.js";
|
|
24
|
+
export * from "./components/guard.js";
|
|
25
|
+
export * from "./components/health-factor.js";
|
|
26
|
+
export * from "./components/help-center-container.js";
|
|
27
|
+
export * from "./components/hide-on.js";
|
|
28
|
+
export * from "./components/horizontal-indicator.js";
|
|
29
|
+
export * from "./components/input.js";
|
|
30
|
+
export * from "./components/label.js";
|
|
31
|
+
export * from "./components/layout/index.js";
|
|
32
|
+
export * from "./components/liquidation/index.js";
|
|
33
|
+
export * from "./components/loader-guard.js";
|
|
34
|
+
export * from "./components/loading-guard.js";
|
|
35
|
+
export * from "./components/markdown-viewer.js";
|
|
36
|
+
export * from "./components/navbar.js";
|
|
37
|
+
export * from "./components/navitem.js";
|
|
38
|
+
export * from "./components/not-found.js";
|
|
39
|
+
export * from "./components/options-list.js";
|
|
40
|
+
export * from "./components/page-title.js";
|
|
41
|
+
export * from "./components/percent-indicator.js";
|
|
42
|
+
export * from "./components/pool-points-indicator.js";
|
|
43
|
+
export * from "./components/search-bar.js";
|
|
44
|
+
export * from "./components/search-line.js";
|
|
45
|
+
export * from "./components/select.js";
|
|
46
|
+
export * from "./components/short-string.js";
|
|
47
|
+
export * from "./components/signatures/index.js";
|
|
48
|
+
export * from "./components/skeleton.js";
|
|
49
|
+
export * from "./components/stat-badge.js";
|
|
50
|
+
export * from "./components/tab-control.js";
|
|
51
|
+
export * from "./components/table/index.js";
|
|
52
|
+
export * from "./components/tabs.js";
|
|
53
|
+
export * from "./components/textarea.js";
|
|
54
|
+
export * from "./components/theme-provider.js";
|
|
55
|
+
export * from "./components/theme-toggle.js";
|
|
56
|
+
export * from "./components/token-icon.js";
|
|
57
|
+
export * from "./components/token-symbol.js";
|
|
58
|
+
export * from "./components/tooltip.js";
|
|
59
|
+
export * from "./components/typed-intl/index.js";
|
|
60
|
+
export * from "./components/vspace.js";
|
|
61
|
+
export * from "./components/with-filter-button.js";
|
|
62
|
+
export * from "./configs/design-tokens.js";
|
|
63
|
+
export * from "./configs/variants.js";
|
|
64
|
+
export * from "./hooks/index.js";
|
|
2
65
|
export * from "./utils/index.js";
|
|
66
|
+
export * from "./utils/a11y.js";
|
|
67
|
+
import { cn } from "./utils/cn.js";
|
|
68
|
+
export * from "./utils/copy.js";
|
|
69
|
+
export * from "./utils/format.js";
|
|
70
|
+
import {
|
|
71
|
+
formatMoney,
|
|
72
|
+
formatPercentAmount,
|
|
73
|
+
PERCENTAGE_FACTOR,
|
|
74
|
+
percentageTemplate,
|
|
75
|
+
percentTemplate
|
|
76
|
+
} from "./utils/format-money.js";
|
|
77
|
+
export * from "./utils/templates.js";
|
|
78
|
+
export {
|
|
79
|
+
PERCENTAGE_FACTOR,
|
|
80
|
+
cn,
|
|
81
|
+
formatMoney,
|
|
82
|
+
formatPercentAmount,
|
|
83
|
+
percentTemplate,
|
|
84
|
+
percentageTemplate
|
|
85
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useId } from "react";
|
|
2
|
+
function generateId(prefix) {
|
|
3
|
+
return `${prefix}-${Math.random().toString(36).substr(2, 9)}`;
|
|
4
|
+
}
|
|
5
|
+
function useFormFieldIds(_name) {
|
|
6
|
+
const inputId = useId();
|
|
7
|
+
const errorId = `${inputId}-error`;
|
|
8
|
+
const helperId = `${inputId}-helper`;
|
|
9
|
+
return { inputId, errorId, helperId };
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
generateId,
|
|
13
|
+
useFormFieldIds
|
|
14
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const applyPrecision = (num, decimals, precision) => {
|
|
2
|
+
if (precision === void 0) return num;
|
|
3
|
+
const pr = Math.max(0, Math.min(decimals, precision));
|
|
4
|
+
const prD = decimals - pr;
|
|
5
|
+
return num / 10n ** BigInt(prD) * 10n ** BigInt(prD);
|
|
6
|
+
};
|
|
7
|
+
function removeTrailingZeros(numStr) {
|
|
8
|
+
const removeZeros = /\.0*$|(\.\d*[1-9])0+$/gm;
|
|
9
|
+
const withoutZeros = numStr.replace(removeZeros, "$1");
|
|
10
|
+
return withoutZeros;
|
|
11
|
+
}
|
|
12
|
+
function bnWithDecimals(num, decimals) {
|
|
13
|
+
const numStr = num.toString();
|
|
14
|
+
const numLength = numStr.length;
|
|
15
|
+
if (numLength <= decimals) {
|
|
16
|
+
const missingZeros = "0".repeat(decimals - numLength);
|
|
17
|
+
return `0.${missingZeros}${numStr}`;
|
|
18
|
+
}
|
|
19
|
+
const pointPlace = numLength - decimals;
|
|
20
|
+
const integerPart = numStr.slice(0, pointPlace);
|
|
21
|
+
const decimalPart = numStr.slice(pointPlace, numLength);
|
|
22
|
+
return `${integerPart}.${decimalPart}`;
|
|
23
|
+
}
|
|
24
|
+
function bnToInputView(number, decimals, allowNegative = false, precision) {
|
|
25
|
+
const n = applyPrecision(number, decimals, precision);
|
|
26
|
+
if (n < 0 && !allowNegative) {
|
|
27
|
+
return "";
|
|
28
|
+
}
|
|
29
|
+
if (n < 0 && allowNegative) {
|
|
30
|
+
return removeTrailingZeros(bnWithDecimals(n, decimals));
|
|
31
|
+
}
|
|
32
|
+
return removeTrailingZeros(bnWithDecimals(n, decimals));
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
bnToInputView
|
|
36
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
function resolveCSSColor(color, fallback = "#000000") {
|
|
2
|
+
if (!color.includes("var(")) {
|
|
3
|
+
return color;
|
|
4
|
+
}
|
|
5
|
+
try {
|
|
6
|
+
const tempElement = document.createElement("div");
|
|
7
|
+
tempElement.style.color = color;
|
|
8
|
+
tempElement.style.display = "none";
|
|
9
|
+
document.body.appendChild(tempElement);
|
|
10
|
+
const computedColor = window.getComputedStyle(tempElement).color;
|
|
11
|
+
document.body.removeChild(tempElement);
|
|
12
|
+
if (computedColor && computedColor !== "rgba(0, 0, 0, 0)") {
|
|
13
|
+
return computedColor;
|
|
14
|
+
}
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.warn(`Failed to resolve CSS color: ${color}`, error);
|
|
17
|
+
}
|
|
18
|
+
return fallback;
|
|
19
|
+
}
|
|
20
|
+
function getCSSVariable(variableName, fallback = "#000000") {
|
|
21
|
+
const name = variableName.startsWith("--") ? variableName : `--${variableName}`;
|
|
22
|
+
try {
|
|
23
|
+
const value = getComputedStyle(document.documentElement).getPropertyValue(name).trim();
|
|
24
|
+
if (value) {
|
|
25
|
+
if (/^[\d\s.%]+$/.test(value)) {
|
|
26
|
+
return `hsl(${value})`;
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.warn(`Failed to get CSS variable: ${name}`, error);
|
|
32
|
+
}
|
|
33
|
+
return fallback;
|
|
34
|
+
}
|
|
35
|
+
function hexToRgba(hex, alpha) {
|
|
36
|
+
const r = parseInt(hex.slice(1, 3), 16);
|
|
37
|
+
const g = parseInt(hex.slice(3, 5), 16);
|
|
38
|
+
const b = parseInt(hex.slice(5, 7), 16);
|
|
39
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
40
|
+
}
|
|
41
|
+
function generateColorsFromBase(color) {
|
|
42
|
+
if (color.startsWith("rgba")) {
|
|
43
|
+
const rgbaMatch = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
44
|
+
if (rgbaMatch) {
|
|
45
|
+
const [, r, g, b] = rgbaMatch;
|
|
46
|
+
return {
|
|
47
|
+
topColor: `rgba(${r}, ${g}, ${b}, 0.56)`,
|
|
48
|
+
bottomColor: `rgba(${r}, ${g}, ${b}, 0.04)`
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (color.startsWith("#") && (color.length === 7 || color.length === 4)) {
|
|
53
|
+
const fullHex = color.length === 4 ? `#${color[1]}${color[1]}${color[2]}${color[2]}${color[3]}${color[3]}` : color;
|
|
54
|
+
return {
|
|
55
|
+
topColor: hexToRgba(fullHex, 0.56),
|
|
56
|
+
bottomColor: hexToRgba(fullHex, 0.04)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
topColor: color,
|
|
61
|
+
bottomColor: color
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
generateColorsFromBase,
|
|
66
|
+
getCSSVariable,
|
|
67
|
+
hexToRgba,
|
|
68
|
+
resolveCSSColor
|
|
69
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { formatBN } from "@gearbox-protocol/sdk";
|
|
2
|
+
const AMOUNT_PRECISION = 3;
|
|
3
|
+
function isZero(precision) {
|
|
4
|
+
const zero = `0.${"0".repeat(precision)}`;
|
|
5
|
+
return (formattedBn) => zero === formattedBn;
|
|
6
|
+
}
|
|
7
|
+
function formatAssetAmount(amount, decimals, precision = AMOUNT_PRECISION) {
|
|
8
|
+
const formatted = formatBN(amount, decimals, precision);
|
|
9
|
+
if (amount < 10n) {
|
|
10
|
+
return `0.${"0".repeat(precision)}`;
|
|
11
|
+
}
|
|
12
|
+
if (isZero(precision)(formatted)) {
|
|
13
|
+
return `< 0.${"0".repeat(precision - 1)}1`;
|
|
14
|
+
}
|
|
15
|
+
return formatted;
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
formatAssetAmount
|
|
19
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BigIntMath, formatBN, WAD_DECIMALS_POW } from "@gearbox-protocol/sdk";
|
|
2
|
+
const ONE_CENT = 10000000000000000n;
|
|
3
|
+
function moneyToBn(money) {
|
|
4
|
+
return BigInt(money.toFixed(18).replace(".", ""));
|
|
5
|
+
}
|
|
6
|
+
function formatMoney(money, precision) {
|
|
7
|
+
const isNegative = typeof money === "number" && money < 0 || typeof money === "bigint" && money < 0n;
|
|
8
|
+
const sign = isNegative ? "-" : "";
|
|
9
|
+
const moneyBn = typeof money === "number" ? moneyToBn(Math.abs(money)) : BigIntMath.abs(money);
|
|
10
|
+
const lessThanCent = moneyBn < ONE_CENT && moneyBn > 0n;
|
|
11
|
+
const formattedBn = lessThanCent ? "0.01" : formatBN(moneyBn, WAD_DECIMALS_POW, precision);
|
|
12
|
+
const moneyTemplated = `${sign}$${formattedBn}`;
|
|
13
|
+
return lessThanCent ? `< ${moneyTemplated}` : moneyTemplated;
|
|
14
|
+
}
|
|
15
|
+
const MAX_EXPONENTIAL_PERCENT_THRESHOLD = 1e4;
|
|
16
|
+
function formatPercentAmount(value, decimals) {
|
|
17
|
+
const numValue = typeof value === "number" ? value : Number(value);
|
|
18
|
+
if (Number.isNaN(numValue) || numValue === void 0 || numValue === null) {
|
|
19
|
+
return "0";
|
|
20
|
+
}
|
|
21
|
+
if (numValue === 0) return 0;
|
|
22
|
+
if (numValue > MAX_EXPONENTIAL_PERCENT_THRESHOLD)
|
|
23
|
+
return numValue.toExponential(decimals);
|
|
24
|
+
return numValue.toFixed(decimals);
|
|
25
|
+
}
|
|
26
|
+
function percentTemplate(value, decimals = 2) {
|
|
27
|
+
return `${formatPercentAmount(value, decimals)}%`;
|
|
28
|
+
}
|
|
29
|
+
const PERCENTAGE_FACTOR = 1e4;
|
|
30
|
+
function percentageTemplate(value, decimals = 2) {
|
|
31
|
+
const formatted = Number(value) / Number(PERCENTAGE_FACTOR);
|
|
32
|
+
return `${formatPercentAmount(formatted, decimals)}%`;
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
PERCENTAGE_FACTOR,
|
|
36
|
+
formatMoney,
|
|
37
|
+
formatPercentAmount,
|
|
38
|
+
percentTemplate,
|
|
39
|
+
percentageTemplate
|
|
40
|
+
};
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
+
export * from "./a11y.js";
|
|
2
|
+
export * from "./bn-to-input-view.js";
|
|
1
3
|
export * from "./cn.js";
|
|
2
4
|
import { cn } from "./cn.js";
|
|
5
|
+
export * from "./colors.js";
|
|
3
6
|
export * from "./copy.js";
|
|
4
7
|
export * from "./format.js";
|
|
8
|
+
export * from "./format-asset-amount.js";
|
|
9
|
+
import {
|
|
10
|
+
formatMoney,
|
|
11
|
+
formatPercentAmount,
|
|
12
|
+
PERCENTAGE_FACTOR,
|
|
13
|
+
percentageTemplate,
|
|
14
|
+
percentTemplate
|
|
15
|
+
} from "./format-money.js";
|
|
16
|
+
export * from "./interface.js";
|
|
17
|
+
export * from "./react.js";
|
|
18
|
+
export * from "./short-sha.js";
|
|
19
|
+
export * from "./templates.js";
|
|
5
20
|
export {
|
|
6
|
-
|
|
21
|
+
PERCENTAGE_FACTOR,
|
|
22
|
+
cn as default,
|
|
23
|
+
formatMoney,
|
|
24
|
+
formatPercentAmount,
|
|
25
|
+
percentTemplate,
|
|
26
|
+
percentageTemplate
|
|
7
27
|
};
|
|
File without changes
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
function extractTextFromLabel(label) {
|
|
3
|
+
if (label === null || label === void 0) {
|
|
4
|
+
return "";
|
|
5
|
+
}
|
|
6
|
+
if (typeof label === "string" || typeof label === "number") {
|
|
7
|
+
return String(label);
|
|
8
|
+
}
|
|
9
|
+
if (typeof label === "boolean") {
|
|
10
|
+
return label ? "true" : "false";
|
|
11
|
+
}
|
|
12
|
+
if (React.isValidElement(label)) {
|
|
13
|
+
const props = label.props;
|
|
14
|
+
const children = props?.children;
|
|
15
|
+
if (children === void 0 || children === null) {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(children)) {
|
|
19
|
+
return children.map(extractTextFromLabel).join(" ");
|
|
20
|
+
}
|
|
21
|
+
return extractTextFromLabel(children);
|
|
22
|
+
}
|
|
23
|
+
if (Array.isArray(label)) {
|
|
24
|
+
return label.map(extractTextFromLabel).join(" ");
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
return String(label);
|
|
28
|
+
} catch {
|
|
29
|
+
return "";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function serializeValue(value) {
|
|
33
|
+
if (value === null || value === void 0) {
|
|
34
|
+
return String(value);
|
|
35
|
+
}
|
|
36
|
+
const valueType = typeof value;
|
|
37
|
+
if (valueType === "string" || valueType === "number" || valueType === "boolean") {
|
|
38
|
+
return String(value);
|
|
39
|
+
}
|
|
40
|
+
if (valueType === "bigint") {
|
|
41
|
+
return `bigint:${value.toString()}`;
|
|
42
|
+
}
|
|
43
|
+
if (valueType === "symbol" || valueType === "function") {
|
|
44
|
+
return `${valueType}:${String(value)}`;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
return JSON.stringify(value, (_, val) => {
|
|
48
|
+
if (typeof val === "bigint") {
|
|
49
|
+
return `bigint:${val.toString()}`;
|
|
50
|
+
}
|
|
51
|
+
if (typeof val === "symbol") {
|
|
52
|
+
return `symbol:${String(val)}`;
|
|
53
|
+
}
|
|
54
|
+
if (typeof val === "function") {
|
|
55
|
+
return `function:${val.name || "anonymous"}`;
|
|
56
|
+
}
|
|
57
|
+
return val;
|
|
58
|
+
});
|
|
59
|
+
} catch {
|
|
60
|
+
try {
|
|
61
|
+
return `${valueType}:${String(value)}`;
|
|
62
|
+
} catch {
|
|
63
|
+
return `[unserializable:${valueType}]`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
extractTextFromLabel,
|
|
69
|
+
serializeValue
|
|
70
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { formatBN } from "@gearbox-protocol/sdk";
|
|
3
|
+
import { percentTemplate } from "./format-money.js";
|
|
4
|
+
function percentageTemplate(value, decimals = 2) {
|
|
5
|
+
return /* @__PURE__ */ jsx(Fragment, { children: percentTemplate(value, decimals) });
|
|
6
|
+
}
|
|
7
|
+
function tokenTemplate(value, token, precision, spaceSymbol = " ") {
|
|
8
|
+
const { decimals = 18 } = token || {};
|
|
9
|
+
const formattedBn = formatBN(value, decimals, precision);
|
|
10
|
+
const tokenName = token?.title || token?.symbol || "undefined";
|
|
11
|
+
return /* @__PURE__ */ jsx(Fragment, { children: formattedBn === "-" ? formattedBn : `${formattedBn}${spaceSymbol}${tokenName}` });
|
|
12
|
+
}
|
|
13
|
+
function tokenTemplateNumber(value, token, precision = 2) {
|
|
14
|
+
if (value === void 0) return "-";
|
|
15
|
+
const formattedValue = value.toFixed(precision);
|
|
16
|
+
const sign = Math.abs(Number(formattedValue)) > 0 ? "" : "< ";
|
|
17
|
+
const result = sign ? `${formattedValue.slice(0, formattedValue.length - 1)}1` : formattedValue;
|
|
18
|
+
return `${sign}${result} ${token?.title}`;
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
percentageTemplate,
|
|
22
|
+
tokenTemplate,
|
|
23
|
+
tokenTemplateNumber
|
|
24
|
+
};
|