@stellar-expert/ui-framework 1.16.8 → 1.19.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 (85) hide show
  1. package/README.md +1168 -3
  2. package/account/account-address.js +127 -127
  3. package/account/available-balance.js +22 -22
  4. package/account/identicon.js +90 -90
  5. package/account/signer-key.js +65 -64
  6. package/api/explorer-api-hooks.js +209 -202
  7. package/api/explorer-api-paginated-list-hooks.js +441 -440
  8. package/api/explorer-batch-info-loader.js +111 -85
  9. package/api/explorer-tx-api.js +28 -28
  10. package/api/ledger-stream.js +15 -0
  11. package/asset/amount.js +56 -56
  12. package/asset/asset-icon.js +41 -41
  13. package/asset/asset-issuer.js +21 -21
  14. package/asset/asset-link.js +107 -107
  15. package/asset/asset-list-hooks.js +59 -59
  16. package/asset/asset-meta-hooks.js +88 -88
  17. package/asset/asset-selector.js +72 -71
  18. package/claimable-balance/claimable-balance-claimants.js +23 -18
  19. package/contract/contract-api.js +15 -0
  20. package/contract/invocation-info-view.js +10 -2
  21. package/contract/sc-val.js +131 -107
  22. package/controls/button-group.js +25 -19
  23. package/controls/button.js +93 -78
  24. package/controls/code-block.js +42 -34
  25. package/controls/dropdown.js +318 -287
  26. package/controls/external-link.js +10 -4
  27. package/controls/info-tooltip.js +23 -16
  28. package/controls/slider.js +29 -19
  29. package/controls/tabs.js +94 -94
  30. package/controls/tooltip.js +244 -240
  31. package/controls/update-highlighter.js +32 -27
  32. package/date/date-selector.js +56 -54
  33. package/date/elapsed-time.js +28 -21
  34. package/dex/price-dynamic.js +53 -44
  35. package/directory/directory-hooks.js +109 -97
  36. package/effect/effect-description.js +346 -344
  37. package/errors/error-boundary.js +110 -97
  38. package/filter/editors/account-filter-view.js +20 -0
  39. package/filter/editors/asset-filter-view.js +9 -0
  40. package/filter/editors/timestamp-filter-view.js +34 -0
  41. package/filter/editors/type-filter-view.js +148 -0
  42. package/filter/filter-editors.js +102 -0
  43. package/filter/filter-view.js +218 -0
  44. package/filter/filter.scss +57 -0
  45. package/horizon/horizon-account-helpers.js +104 -104
  46. package/horizon/horizon-ledger-helpers.js +35 -35
  47. package/horizon/horizon-trades-helper.js +88 -88
  48. package/horizon/horizon-transaction-helpers.js +36 -36
  49. package/index.d.ts +1271 -0
  50. package/index.js +95 -93
  51. package/interaction/accordion.js +43 -35
  52. package/interaction/autofocus.js +13 -9
  53. package/interaction/block-select.js +64 -53
  54. package/interaction/copy-to-clipboard.js +25 -18
  55. package/interaction/inline-progress.js +20 -15
  56. package/interaction/qr-code.js +34 -34
  57. package/interaction/responsive.js +20 -20
  58. package/interaction/spoiler.js +52 -39
  59. package/interaction/theme-selector.js +13 -10
  60. package/ledger/ledger-entry-href-formatter.js +27 -26
  61. package/ledger/ledger-entry-link.js +93 -58
  62. package/ledger/ledger-info-parser.js +46 -18
  63. package/meta/page-meta-tags.js +243 -238
  64. package/module/dynamic-module.js +47 -47
  65. package/package.json +71 -40
  66. package/state/on-screen-hooks.js +22 -22
  67. package/state/page-visibility-helpers.js +29 -16
  68. package/state/page-visibility-hooks.js +13 -11
  69. package/state/screen-orientation-hooks.js +19 -15
  70. package/state/state-hooks.js +76 -76
  71. package/state/stellar-network-hooks.js +56 -44
  72. package/state/theme.js +29 -28
  73. package/stellar/key-type.js +92 -91
  74. package/stellar/ledger-generic-id.js +39 -39
  75. package/stellar/signature-hint-utils.js +65 -65
  76. package/toast/toast-notifications-block.js +59 -59
  77. package/tx/op-description-view.js +945 -942
  78. package/tx/op-icon.js +98 -98
  79. package/tx/parser/op-balance-changes.js +66 -66
  80. package/tx/parser/op-descriptor.js +51 -48
  81. package/tx/parser/tx-details-parser.js +81 -81
  82. package/tx/parser/tx-matcher.js +371 -371
  83. package/tx/parser/type-filter-matcher.js +126 -126
  84. package/tx/tx-list-hooks.js +32 -18
  85. package/tx/tx-operations-list.js +117 -116
@@ -1,40 +1,53 @@
1
- import React, {useCallback, useEffect, useState} from 'react'
2
- import PropTypes from 'prop-types'
3
- import cn from 'classnames'
4
- import './spoiler.scss'
5
-
6
- export const Spoiler = React.memo(function Spoiler({expanded, showMore = 'Show more', showLess = 'Show less', onChange, className, micro, style, active, children}) {
7
- const [expandedState, setExpandedState] = useState(expanded || false)
8
- useEffect(() => {
9
- setExpandedState(expanded)
10
- }, [expanded])
11
-
12
- const toggle = useCallback(() => {
13
- setExpandedState(prevState => {
14
- const newState = !prevState
15
- setExpandedState(newState)
16
- onChange && onChange({expanded: newState})
17
- })
18
- }, [onChange])
19
-
20
- const text = expandedState ? showLess : showMore
21
- return <>
22
- <span className={cn('spoiler', className)}>
23
- <a href="#" className={!active ? 'dimmed' : undefined} title={micro ? text : undefined} style={style} onClick={toggle}>
24
- {!micro && <span className="spoiler-text">{text}</span>}
25
- <i className={`icon ${expandedState ? 'icon-less' : 'icon-more'}`}/>
26
- </a>
27
- </span>
28
- {expandedState ? children : null}
29
- </>
30
- })
31
-
32
- Spoiler.propTypes = {
33
- expanded: PropTypes.bool,
34
- micro: PropTypes.bool,
35
- onChange: PropTypes.func,
36
- showMore: PropTypes.string,
37
- showLess: PropTypes.string,
38
- active: PropTypes.bool,
39
- style: PropTypes.object
1
+ import React, {useCallback, useEffect, useState} from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import cn from 'classnames'
4
+ import './spoiler.scss'
5
+
6
+ /**
7
+ * Expandable/collapsible content toggle
8
+ * @param {Object} props
9
+ * @param {boolean} [props.expanded] - Whether the content is initially expanded
10
+ * @param {string} [props.showMore='Show more'] - Label for the expand action
11
+ * @param {string} [props.showLess='Show less'] - Label for the collapse action
12
+ * @param {function({expanded: boolean}): void} [props.onChange] - Callback invoked on toggle
13
+ * @param {string} [props.className] - Additional CSS classes
14
+ * @param {boolean} [props.micro] - Show only an icon without text label
15
+ * @param {Object} [props.style] - Inline styles
16
+ * @param {boolean} [props.active] - Highlight the toggle link
17
+ * @param {*} [props.children] - Content revealed when expanded
18
+ */
19
+ export const Spoiler = React.memo(function Spoiler({expanded, showMore = 'Show more', showLess = 'Show less', onChange, className, micro, style, active, children}) {
20
+ const [expandedState, setExpandedState] = useState(expanded || false)
21
+ useEffect(() => {
22
+ setExpandedState(expanded)
23
+ }, [expanded])
24
+
25
+ const toggle = useCallback(() => {
26
+ setExpandedState(prevState => {
27
+ const newState = !prevState
28
+ setExpandedState(newState)
29
+ onChange && onChange({expanded: newState})
30
+ })
31
+ }, [onChange])
32
+
33
+ const text = expandedState ? showLess : showMore
34
+ return <>
35
+ <span className={cn('spoiler', className)}>
36
+ <a href="#" className={!active ? 'dimmed' : undefined} title={micro ? text : undefined} style={style} onClick={toggle}>
37
+ {!micro && <span className="spoiler-text">{text}</span>}
38
+ <i className={`icon ${expandedState ? 'icon-less' : 'icon-more'}`}/>
39
+ </a>
40
+ </span>
41
+ {expandedState ? children : null}
42
+ </>
43
+ })
44
+
45
+ Spoiler.propTypes = {
46
+ expanded: PropTypes.bool,
47
+ micro: PropTypes.bool,
48
+ onChange: PropTypes.func,
49
+ showMore: PropTypes.string,
50
+ showLess: PropTypes.string,
51
+ active: PropTypes.bool,
52
+ style: PropTypes.object
40
53
  }
@@ -1,11 +1,14 @@
1
- import React from 'react'
2
- import {useTheme} from '../state/theme'
3
-
4
- export const ThemeSelector = React.memo(function ThemeSelector() {
5
- const [theme, setTheme] = useTheme()
6
- return <a href="#" onClick={() => setTheme(current => current === 'day' ? 'night' : 'day')}>
7
- {theme === 'day' ?
8
- <><i className="icon icon-night"/> Dark theme</> :
9
- <><i className="icon icon-day"/> Light theme</>}
10
- </a>
1
+ import React from 'react'
2
+ import {useTheme} from '../state/theme'
3
+
4
+ /**
5
+ * Theme toggle button that switches between day (light) and night (dark) themes
6
+ */
7
+ export const ThemeSelector = React.memo(function ThemeSelector() {
8
+ const [theme, setTheme] = useTheme()
9
+ return <a href="#" onClick={() => setTheme(current => current === 'day' ? 'night' : 'day')}>
10
+ {theme === 'day' ?
11
+ <><i className="icon icon-night"/> Dark theme</> :
12
+ <><i className="icon icon-day"/> Light theme</>}
13
+ </a>
11
14
  })
@@ -1,27 +1,28 @@
1
- import {getCurrentStellarNetwork} from '../state/stellar-network-hooks'
2
-
3
- /**
4
- * @param {'account'|'asset'|'ledger'|'tx'|'op'|'offer'|'contract'|'liquidity-pool'|'claimable-balance'} type
5
- * @param {String|Number} id
6
- * @param {String} [network]
7
- * @return {String}
8
- */
9
- export function formatExplorerLink(type, id, network = null) {
10
- if (typeof window.explorerLinkFormatter === 'function') {
11
- const link = window.explorerLinkFormatter(type, id, network)
12
- if (link)
13
- return link
14
- }
15
- const segments = [
16
- explorerFrontendOrigin !== window.origin ? explorerFrontendOrigin : '',
17
- 'explorer',
18
- network || getCurrentStellarNetwork()
19
- ]
20
- if (type) {
21
- segments.push(type)
22
- }
23
- if (id) {
24
- segments.push(id)
25
- }
26
- return segments.join('/')
1
+ import {getCurrentStellarNetwork} from '../state/stellar-network-hooks'
2
+
3
+ /**
4
+ * Build URL path to StellarExpert explorer page for given ledger entry
5
+ * @param {'account'|'asset'|'ledger'|'tx'|'op'|'offer'|'contract'|'liquidity-pool'|'claimable-balance'} type
6
+ * @param {string|number} id
7
+ * @param {string} [network]
8
+ * @return {string}
9
+ */
10
+ export function formatExplorerLink(type, id, network = null) {
11
+ if (typeof window.explorerLinkFormatter === 'function') {
12
+ const link = window.explorerLinkFormatter(type, id, network)
13
+ if (link)
14
+ return link
15
+ }
16
+ const segments = [
17
+ explorerFrontendOrigin !== window.origin ? explorerFrontendOrigin : '',
18
+ 'explorer',
19
+ network || getCurrentStellarNetwork()
20
+ ]
21
+ if (type) {
22
+ segments.push(type)
23
+ }
24
+ if (id) {
25
+ segments.push(id)
26
+ }
27
+ return segments.join('/')
27
28
  }
@@ -1,59 +1,94 @@
1
- import React from 'react'
2
- import PropTypes from 'prop-types'
3
- import {formatExplorerLink} from './ledger-entry-href-formatter'
4
- import {useStellarNetwork} from '../state/stellar-network-hooks'
5
-
6
- function LedgerEntryLink({type, id, network, children}) {
7
- const globallySetNetwork = useStellarNetwork()
8
- return <a href={formatExplorerLink(type, id, network || globallySetNetwork)} target="_blank">{children || id}</a>
9
- }
10
-
11
- export const TxLink = React.memo(function TxLink({tx, network, children}) {
12
- return React.createElement(LedgerEntryLink, {type: 'tx', id: tx, network, children})
13
- })
14
-
15
- TxLink.propTypes = {
16
- tx: PropTypes.string.isRequired,
17
- network: PropTypes.string,
18
- children: PropTypes.any
19
- }
20
-
21
- export const OpLink = React.memo(function OpLink({op, network, children}) {
22
- return React.createElement(LedgerEntryLink, {type: 'op', id: op, network, children})
23
- })
24
-
25
- OpLink.propTypes = {
26
- op: PropTypes.string.isRequired,
27
- network: PropTypes.string,
28
- children: PropTypes.any
29
- }
30
-
31
- export const LedgerLink = React.memo(function LedgerLink({sequence, network, children}) {
32
- return React.createElement(LedgerEntryLink, {type: 'ledger', id: sequence, network, children})
33
- })
34
-
35
- LedgerLink.propTypes = {
36
- sequence: PropTypes.number.isRequired,
37
- network: PropTypes.string,
38
- children: PropTypes.any
39
- }
40
-
41
- export const OfferLink = React.memo(function OfferLink({offer, network, children}) {
42
- return React.createElement(LedgerEntryLink, {type: 'offer', id: offer, network, children})
43
- })
44
-
45
- OfferLink.propTypes = {
46
- offer: PropTypes.string.isRequired,
47
- network: PropTypes.string,
48
- children: PropTypes.any
49
- }
50
-
51
- export const PoolLink = React.memo(function PoolLink({pool, network, children}) {
52
- return React.createElement(LedgerEntryLink, {type: 'pool', id: pool, network, children})
53
- })
54
-
55
- PoolLink.propTypes = {
56
- pool: PropTypes.string.isRequired,
57
- network: PropTypes.string,
58
- children: PropTypes.any
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import {formatExplorerLink} from './ledger-entry-href-formatter'
4
+ import {useStellarNetwork} from '../state/stellar-network-hooks'
5
+
6
+ function LedgerEntryLink({type, id, network, children}) {
7
+ const globallySetNetwork = useStellarNetwork()
8
+ return <a href={formatExplorerLink(type, id, network || globallySetNetwork)} target="_blank">{children || id}</a>
9
+ }
10
+
11
+ /**
12
+ * Link to a transaction on StellarExpert
13
+ * @param {Object} props
14
+ * @param {string} props.tx - Transaction hash
15
+ * @param {string} [props.network] - Stellar network override
16
+ * @param {*} [props.children] - Custom link content (defaults to the tx hash)
17
+ */
18
+ export const TxLink = React.memo(function TxLink({tx, network, children}) {
19
+ return React.createElement(LedgerEntryLink, {type: 'tx', id: tx, network, children})
20
+ })
21
+
22
+ TxLink.propTypes = {
23
+ tx: PropTypes.string.isRequired,
24
+ network: PropTypes.string,
25
+ children: PropTypes.any
26
+ }
27
+
28
+ /**
29
+ * Link to an operation on StellarExpert
30
+ * @param {Object} props
31
+ * @param {string} props.op - Operation ID
32
+ * @param {string} [props.network] - Stellar network override
33
+ * @param {*} [props.children] - Custom link content
34
+ */
35
+ export const OpLink = React.memo(function OpLink({op, network, children}) {
36
+ return React.createElement(LedgerEntryLink, {type: 'op', id: op, network, children})
37
+ })
38
+
39
+ OpLink.propTypes = {
40
+ op: PropTypes.string.isRequired,
41
+ network: PropTypes.string,
42
+ children: PropTypes.any
43
+ }
44
+
45
+ /**
46
+ * Link to a ledger on StellarExpert
47
+ * @param {Object} props
48
+ * @param {number} props.sequence - Ledger sequence number
49
+ * @param {string} [props.network] - Stellar network override
50
+ * @param {*} [props.children] - Custom link content
51
+ */
52
+ export const LedgerLink = React.memo(function LedgerLink({sequence, network, children}) {
53
+ return React.createElement(LedgerEntryLink, {type: 'ledger', id: sequence, network, children})
54
+ })
55
+
56
+ LedgerLink.propTypes = {
57
+ sequence: PropTypes.number.isRequired,
58
+ network: PropTypes.string,
59
+ children: PropTypes.any
60
+ }
61
+
62
+ /**
63
+ * Link to a DEX offer on StellarExpert
64
+ * @param {Object} props
65
+ * @param {string} props.offer - Offer ID
66
+ * @param {string} [props.network] - Stellar network override
67
+ * @param {*} [props.children] - Custom link content
68
+ */
69
+ export const OfferLink = React.memo(function OfferLink({offer, network, children}) {
70
+ return React.createElement(LedgerEntryLink, {type: 'offer', id: offer, network, children})
71
+ })
72
+
73
+ OfferLink.propTypes = {
74
+ offer: PropTypes.string.isRequired,
75
+ network: PropTypes.string,
76
+ children: PropTypes.any
77
+ }
78
+
79
+ /**
80
+ * Link to a liquidity pool on StellarExpert
81
+ * @param {Object} props
82
+ * @param {string} props.pool - Pool ID
83
+ * @param {string} [props.network] - Stellar network override
84
+ * @param {*} [props.children] - Custom link content
85
+ */
86
+ export const PoolLink = React.memo(function PoolLink({pool, network, children}) {
87
+ return React.createElement(LedgerEntryLink, {type: 'pool', id: pool, network, children})
88
+ })
89
+
90
+ PoolLink.propTypes = {
91
+ pool: PropTypes.string.isRequired,
92
+ network: PropTypes.string,
93
+ children: PropTypes.any
59
94
  }
@@ -1,18 +1,46 @@
1
- import {xdr} from '@stellar/stellar-base'
2
-
3
- export function retrieveLedgerInfo(data) {
4
- const parsed = xdr.LedgerHeader.fromXDR(data.xdr, 'base64')
5
- return {
6
- sequence: data.sequence,
7
- ts: data.ts,
8
- protocol: data.protocol,
9
- operations: data.successful_operations || 0,
10
- failedOperations: data.failed_operations || 0,
11
- txSuccess: data.successful_transactions,
12
- txFailed: data.failed_transactions,
13
- xlm: parsed.totalCoins().toBigInt(),
14
- feePool: parsed.feePool().toBigInt(),
15
- baseFee: parsed.baseFee(),
16
- baseReserve: parsed.baseReserve()
17
- }
18
- }
1
+ import {xdr} from '@stellar/stellar-base'
2
+
3
+ /**
4
+ * @typedef {Object} LedgerInfo
5
+ * @property {number} sequence - Ledger sequence number
6
+ * @property {number} ts - Ledger close timestamp
7
+ * @property {number} protocol - Protocol version
8
+ * @property {number} operations - number of successful operations
9
+ * @property {number} failedOperations - number of failed operations
10
+ * @property {number} txSuccess - number of successful transactions
11
+ * @property {number} txFailed - number of failed transactions
12
+ * @property {bigint} xlm - Total lumens in circulation
13
+ * @property {bigint} feePool - Fee pool amount
14
+ * @property {number} baseFee - Base fee in stroops
15
+ * @property {number} baseReserve - Base reserve in stroops
16
+ */
17
+
18
+ /**
19
+ * Parse raw ledger data including XDR header into structured ledger info
20
+ * @param {Object} data - Raw ledger data from the API
21
+ * @param {string} data.xdr - Base64-encoded XDR ledger header
22
+ * @param {number} data.sequence - Ledger sequence number
23
+ * @param {number} data.ts - Ledger close timestamp
24
+ * @param {number} data.protocol - Protocol version
25
+ * @param {number} [data.successful_operations] - Successful operation count
26
+ * @param {number} [data.failed_operations] - Failed operation count
27
+ * @param {number} [data.successful_transactions] - Successful transaction count
28
+ * @param {number} [data.failed_transactions] - Failed transaction count
29
+ * @return {LedgerInfo}
30
+ */
31
+ export function retrieveLedgerInfo(data) {
32
+ const parsed = xdr.LedgerHeader.fromXDR(data.xdr, 'base64')
33
+ return {
34
+ sequence: data.sequence,
35
+ ts: data.ts,
36
+ protocol: data.protocol,
37
+ operations: data.successful_operations || 0,
38
+ failedOperations: data.failed_operations || 0,
39
+ txSuccess: data.successful_transactions,
40
+ txFailed: data.failed_transactions,
41
+ xlm: parsed.totalCoins().toBigInt(),
42
+ feePool: parsed.feePool().toBigInt(),
43
+ baseFee: parsed.baseFee(),
44
+ baseReserve: parsed.baseReserve()
45
+ }
46
+ }