@xyo-network/react-chain-blockchain 1.20.12 → 1.20.14

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 (46) hide show
  1. package/dist/browser/components/account/table/BalanceHistoryTableRow.d.ts.map +1 -1
  2. package/dist/browser/components/account/table/RawAmountTableCell.d.ts +2 -0
  3. package/dist/browser/components/account/table/RawAmountTableCell.d.ts.map +1 -1
  4. package/dist/browser/components/account/table/cell/AddressTableCell.d.ts +2 -0
  5. package/dist/browser/components/account/table/cell/AddressTableCell.d.ts.map +1 -1
  6. package/dist/browser/components/account/table/cell/BlockNumber.d.ts +14 -0
  7. package/dist/browser/components/account/table/cell/BlockNumber.d.ts.map +1 -0
  8. package/dist/browser/components/account/table/cell/HashTableCell.d.ts +3 -0
  9. package/dist/browser/components/account/table/cell/HashTableCell.d.ts.map +1 -1
  10. package/dist/browser/components/account/table/cell/index.d.ts +1 -0
  11. package/dist/browser/components/account/table/cell/index.d.ts.map +1 -1
  12. package/dist/browser/components/account/table/hooks/index.d.ts +2 -0
  13. package/dist/browser/components/account/table/hooks/index.d.ts.map +1 -0
  14. package/dist/browser/components/account/table/hooks/useLinkedBalanceHistoryItem.d.ts +5 -0
  15. package/dist/browser/components/account/table/hooks/useLinkedBalanceHistoryItem.d.ts.map +1 -0
  16. package/dist/browser/components/account/table/index.d.ts +1 -0
  17. package/dist/browser/components/account/table/index.d.ts.map +1 -1
  18. package/dist/browser/components/account/table/types/index.d.ts +2 -2
  19. package/dist/browser/components/account/table/types/index.d.ts.map +1 -1
  20. package/dist/browser/components/block/table/cell/BlockNumber.d.ts +2 -0
  21. package/dist/browser/components/block/table/cell/BlockNumber.d.ts.map +1 -1
  22. package/dist/browser/components/block/table/row/TableRow.d.ts.map +1 -1
  23. package/dist/browser/components/table/StyledLinkableTableRow.d.ts +6 -0
  24. package/dist/browser/components/table/StyledLinkableTableRow.d.ts.map +1 -0
  25. package/dist/browser/components/table/index.d.ts +2 -0
  26. package/dist/browser/components/table/index.d.ts.map +1 -0
  27. package/dist/browser/index.mjs +282 -205
  28. package/dist/browser/index.mjs.map +1 -1
  29. package/package.json +20 -20
  30. package/src/components/account/table/BalanceHistoryTableEx.stories.tsx +1 -1
  31. package/src/components/account/table/BalanceHistoryTableRow.stories.tsx +52 -0
  32. package/src/components/account/table/BalanceHistoryTableRow.tsx +31 -14
  33. package/src/components/account/table/RawAmountTableCell.tsx +5 -5
  34. package/src/components/account/table/cell/AddressTableCell.tsx +6 -5
  35. package/src/components/account/table/cell/BlockNumber.tsx +39 -0
  36. package/src/components/account/table/cell/HashTableCell.tsx +6 -5
  37. package/src/components/account/table/cell/index.ts +1 -0
  38. package/src/components/account/table/hooks/index.ts +1 -0
  39. package/src/components/account/table/hooks/useLinkedBalanceHistoryItem.tsx +29 -0
  40. package/src/components/account/table/index.ts +1 -0
  41. package/src/components/account/table/types/index.ts +3 -2
  42. package/src/components/block/table/cell/BlockNumber.tsx +9 -10
  43. package/src/components/block/table/row/TableRow.stories.tsx +6 -2
  44. package/src/components/block/table/row/TableRow.tsx +5 -12
  45. package/src/components/table/StyledLinkableTableRow.tsx +12 -0
  46. package/src/components/table/index.ts +1 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "http://json.schemastore.org/package.json",
3
3
  "name": "@xyo-network/react-chain-blockchain",
4
- "version": "1.20.12",
4
+ "version": "1.20.14",
5
5
  "description": "XYO Layer One React SDK Blockchain",
6
6
  "homepage": "https://xylabs.com",
7
7
  "bugs": {
@@ -55,22 +55,22 @@
55
55
  "@xylabs/react-shared": "~7.1.17",
56
56
  "@xylabs/react-theme": "~7.1.17",
57
57
  "@xylabs/sdk-js": "~5.0.90",
58
- "@xyo-network/boundwitness-model": "~5.3.17",
59
- "@xyo-network/chain-analyze": "~1.20.12",
60
- "@xyo-network/chain-protocol": "~1.20.12",
61
- "@xyo-network/chain-wrappers": "~1.20.12",
58
+ "@xyo-network/boundwitness-model": "~5.3.20",
59
+ "@xyo-network/chain-analyze": "~1.20.14",
60
+ "@xyo-network/chain-protocol": "~1.20.14",
61
+ "@xyo-network/chain-wrappers": "~1.20.14",
62
62
  "@xyo-network/react-boundwitness-plugin": "~7.5.8",
63
- "@xyo-network/react-chain-blockies": "~1.20.12",
64
- "@xyo-network/react-chain-provider": "~1.20.12",
65
- "@xyo-network/react-chain-shared": "~1.20.12",
63
+ "@xyo-network/react-chain-blockies": "~1.20.14",
64
+ "@xyo-network/react-chain-provider": "~1.20.14",
65
+ "@xyo-network/react-chain-shared": "~1.20.14",
66
66
  "@xyo-network/react-error": "~7.5.8",
67
67
  "@xyo-network/react-event": "~7.5.8",
68
68
  "@xyo-network/react-payload-raw-info": "~7.5.8",
69
69
  "@xyo-network/react-payload-table": "~7.5.8",
70
70
  "@xyo-network/react-shared": "~7.5.8",
71
71
  "@xyo-network/react-table": "~7.5.8",
72
- "@xyo-network/sdk-js": "~5.3.17",
73
- "@xyo-network/xl1-sdk": "~1.26.9"
72
+ "@xyo-network/sdk-js": "~5.3.20",
73
+ "@xyo-network/xl1-sdk": "~1.26.11"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@emotion/react": "~11.14.0",
@@ -82,16 +82,16 @@
82
82
  "@types/react": "~19.2.14",
83
83
  "@xylabs/react-button": "~7.1.17",
84
84
  "@xylabs/sdk-js": "~5.0.90",
85
- "@xylabs/ts-scripts-common": "~7.5.10",
86
- "@xylabs/ts-scripts-yarn3": "~7.5.10",
87
- "@xylabs/tsconfig": "~7.5.10",
88
- "@xylabs/tsconfig-dom": "~7.5.10",
89
- "@xylabs/tsconfig-react": "~7.5.10",
90
- "@xyo-network/bridge-http": "~5.3.17",
91
- "@xyo-network/react-chain-network": "~1.20.12",
92
- "@xyo-network/sdk-js": "~5.3.17",
93
- "@xyo-network/xl1-sdk": "~1.26.9",
94
- "axios": "^1.14.0",
85
+ "@xylabs/ts-scripts-common": "~7.5.11",
86
+ "@xylabs/ts-scripts-yarn3": "~7.5.11",
87
+ "@xylabs/tsconfig": "~7.5.11",
88
+ "@xylabs/tsconfig-dom": "~7.5.11",
89
+ "@xylabs/tsconfig-react": "~7.5.11",
90
+ "@xyo-network/bridge-http": "~5.3.20",
91
+ "@xyo-network/react-chain-network": "~1.20.14",
92
+ "@xyo-network/sdk-js": "~5.3.20",
93
+ "@xyo-network/xl1-sdk": "~1.26.11",
94
+ "axios": "^1.13.6",
95
95
  "ethers": "^6.16.0",
96
96
  "react": "~19.2.4",
97
97
  "react-dom": "~19.2.4",
@@ -48,7 +48,7 @@ const TemplateLinked: StoryFn<typeof AccountBalanceHistoryTableEx> = (args) => {
48
48
  noun, verb, data,
49
49
  }))
50
50
 
51
- const results = useFetchBalanceHistory(TEST_ADDRESS)
51
+ const results = useFetchBalanceHistory(TEST_ADDRESS_1)
52
52
  const [history, error, loading] = results
53
53
 
54
54
  return (
@@ -0,0 +1,52 @@
1
+ import { Table, TableBody } from '@mui/material'
2
+ import type { Meta, StoryFn } from '@storybook/react-vite'
3
+ import type { Address, Hash } from '@xylabs/sdk-js'
4
+ import type { AccountBalanceHistoryItemFormatted } from '@xyo-network/react-chain-provider'
5
+ import type { AccountBalanceHistoryItem } from '@xyo-network/xl1-sdk'
6
+ import React from 'react'
7
+
8
+ import { BalanceHistoryTableRow } from './BalanceHistoryTableRow.tsx'
9
+
10
+ const sampleRow: AccountBalanceHistoryItemFormatted = {
11
+ amount: 866_949_573_941_165_034_031n,
12
+ blockNumber: 652_126,
13
+ debug: undefined as unknown as AccountBalanceHistoryItem,
14
+ from: '626cfa5650444825a1633287a0b4bc8a55f54735' as Address,
15
+ key: 'a80ee574-1c52-46bc-a5df-bbd9b9b8082e',
16
+ timestamp: 1_769_423_309_664,
17
+ to: 'd50a55aa2f6c9416cf8ecc9ef4790260564a7ec7' as Address,
18
+ txHash: '123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234' as Hash,
19
+ transferHash: '123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234' as Hash,
20
+ type: 'receive',
21
+ }
22
+
23
+ export default {
24
+ title: 'AccountBalanceHistory/TableRow',
25
+ component: BalanceHistoryTableRow,
26
+ } as Meta<typeof BalanceHistoryTableRow>
27
+
28
+ const Template: StoryFn<typeof BalanceHistoryTableRow> = args => (
29
+ <Table>
30
+ <TableBody>
31
+ <BalanceHistoryTableRow {...args} />
32
+ </TableBody>
33
+ </Table>
34
+ )
35
+
36
+ const Default = Template.bind({})
37
+ Default.args = { row: sampleRow }
38
+
39
+ const WithLinked = Template.bind({})
40
+ WithLinked.args = { row: sampleRow, linked: true }
41
+
42
+ const WithNoTxHash = Template.bind({})
43
+ WithNoTxHash.args = {
44
+ row: {
45
+ ...sampleRow,
46
+ txHash: undefined,
47
+ },
48
+ }
49
+
50
+ export {
51
+ Default, WithLinked, WithNoTxHash,
52
+ }
@@ -1,14 +1,21 @@
1
1
  import {
2
- TableCell, TableRow, type TableRowProps,
2
+ TableCell,
3
+ type TableRowProps,
3
4
  } from '@mui/material'
4
- import type { JsonValue } from '@xylabs/sdk-js'
5
+ import { isDefined, type JsonValue } from '@xylabs/sdk-js'
5
6
  import type { AccountBalanceHistoryItemFormatted } from '@xyo-network/react-chain-provider'
6
7
  import { RawInfoIconButton } from '@xyo-network/react-payload-raw-info'
8
+ import type { Ref } from 'react'
7
9
  import React, { useMemo } from 'react'
8
10
 
9
- import { BlockEpochTableCellInner, BlockNumberTableCellInner } from '../../block/index.ts'
10
- import { AddressTableCell, HashTableCell } from './cell/index.ts'
11
+ import { BlockEpochTableCellInner } from '../../block/index.ts'
12
+ import { StyledLinkableTableRow } from '../../table/index.ts'
13
+ import {
14
+ AddressTableCell, BalanceHistoryBlockNumberTableCellInner, HashTableCell,
15
+ } from './cell/index.ts'
16
+ import { useLinkedBalanceHistoryItem } from './hooks/index.ts'
11
17
  import { RawAmountTableCell } from './RawAmountTableCell.tsx'
18
+ import type { BalanceHistoryEventNouns } from './types/index.ts'
12
19
 
13
20
  // const TEXT_TX_HASH = '123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234' as Hash
14
21
 
@@ -21,23 +28,33 @@ export const BalanceHistoryTableRow: React.FC<BalanceHistoryTableRowProps> = ({
21
28
  linked, row, ...props
22
29
  }) => {
23
30
  const {
24
- amount, blockNumber, debug, from, key, timestamp, to, type, txHash,
25
- } = row ?? {}
31
+ amount, blockNumber, debug, from, key, timestamp, to, type, txHash, transferHash,
32
+ } = row ?? {} as AccountBalanceHistoryItemFormatted
26
33
 
27
34
  const linkedTableCallProps = useMemo(() => ({ linked }), [linked])
35
+ const [ref, handleClick] = useLinkedBalanceHistoryItem()
36
+
37
+ const noun: BalanceHistoryEventNouns = isDefined(txHash) ? 'tx-hash|transfer-hash' : 'block-number|transfer-hash'
38
+ const data = isDefined(txHash) ? `${txHash}|${transferHash}` : `${blockNumber}|${transferHash}`
28
39
 
29
40
  return (
30
- <TableRow key={key} {...props}>
31
- <HashTableCell hash={txHash} toolTipTitle={`Transaction Hash: ${txHash}`} {...linkedTableCallProps} />
32
- <BlockNumberTableCellInner blockNumber={blockNumber} {...linkedTableCallProps} />
41
+ <StyledLinkableTableRow
42
+ linked={linked}
43
+ key={key}
44
+ onClick={linked ? e => handleClick(e, noun, data) : undefined}
45
+ ref={ref as Ref<HTMLTableRowElement> | undefined}
46
+ {...props}
47
+ >
48
+ <HashTableCell hash={txHash} toolTipTitle={`Transaction Hash: ${txHash}`} eventNoun="tx-hash" {...linkedTableCallProps} />
49
+ <BalanceHistoryBlockNumberTableCellInner blockNumber={blockNumber} eventNoun="block-number" {...linkedTableCallProps} />
33
50
  <BlockEpochTableCellInner epoch={timestamp} {...linkedTableCallProps} />
34
- <AddressTableCell address={from} toolTipTitle={`From Address: ${from}`} {...linkedTableCallProps} />
35
- <AddressTableCell address={to} toolTipTitle={`To Address: ${to}`} {...linkedTableCallProps} />
36
- {/* Intentionally not passing linked prop here till we know where a link would go */}
37
- <RawAmountTableCell amount={amount} type={type} />
51
+ <AddressTableCell address={from} toolTipTitle={`From Address: ${from}`} eventNoun="from-address" {...linkedTableCallProps} />
52
+ <AddressTableCell address={to} toolTipTitle={`To Address: ${to}`} eventNoun="to-address" {...linkedTableCallProps} />
53
+ <RawAmountTableCell amount={amount} type={type} eventNoun="amount" />
54
+ <HashTableCell hash={transferHash} toolTipTitle={`Transfer Hash: ${transferHash}`} eventNoun={noun} eventData={data} {...linkedTableCallProps} />
38
55
  <TableCell>
39
56
  <RawInfoIconButton rawValue={debug as JsonValue} />
40
57
  </TableCell>
41
- </TableRow>
58
+ </StyledLinkableTableRow>
42
59
  )
43
60
  }
@@ -4,23 +4,23 @@ import {
4
4
  } from '@mui/material'
5
5
  import { isDefined, toHex } from '@xylabs/sdk-js'
6
6
  import type { BalanceTransactionType } from '@xyo-network/react-chain-provider'
7
- import { useEvent } from '@xyo-network/react-event'
8
7
  import { XL1Amount } from '@xyo-network/xl1-sdk'
9
8
  import React from 'react'
10
9
 
10
+ import { useLinkedBalanceHistoryItem } from './hooks/index.ts'
11
11
  import type { BalanceHistoryEventNouns } from './types/index.ts'
12
12
 
13
13
  export interface RawAmountTableCellProps extends TableCellProps {
14
14
  amount?: bigint
15
+ eventNoun?: BalanceHistoryEventNouns
15
16
  linked?: boolean
16
17
  type?: BalanceTransactionType
17
18
  }
18
19
 
19
20
  export const RawAmountTableCell: React.FC<RawAmountTableCellProps> = ({
20
- amount, linked, sx, type, ...props
21
+ amount, eventNoun = 'amount', linked, sx, type, ...props
21
22
  }) => {
22
- const [ref, dispatch] = useEvent<HTMLAnchorElement, BalanceHistoryEventNouns>()
23
- const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => dispatch('amount', 'click', isDefined(amount) ? toHex(amount) : '', event.nativeEvent)
23
+ const [ref, handleClick] = useLinkedBalanceHistoryItem()
24
24
 
25
25
  const formatAmount = (amount?: bigint) => {
26
26
  if (!isDefined(amount)) {
@@ -36,7 +36,7 @@ export const RawAmountTableCell: React.FC<RawAmountTableCellProps> = ({
36
36
  <Tooltip title={`Raw Amount: ${amount}`}>
37
37
  {linked
38
38
  ? (
39
- <Link onClick={handleClick} sx={{ cursor: 'pointer' }}>
39
+ <Link onClick={e => handleClick(e, eventNoun, isDefined(amount) ? toHex(amount) : '')} sx={{ cursor: 'pointer' }}>
40
40
  {type === 'send' ? '-' : ''}
41
41
  {formatAmount(amount)}
42
42
  </Link>
@@ -1,25 +1,26 @@
1
1
  import type { TableCellProps } from '@mui/material'
2
2
  import { TableCell, Tooltip } from '@mui/material'
3
- import { useEvent } from '@xyo-network/react-event'
4
3
  import React from 'react'
5
4
 
6
5
  import { BlockAddressChip } from '../../../block/index.ts'
6
+ import { useLinkedBalanceHistoryItem } from '../hooks/index.ts'
7
+ import type { BalanceHistoryEventNouns } from '../types/index.ts'
7
8
 
8
9
  export interface AddressTableCellProps extends TableCellProps {
9
10
  address?: string
11
+ eventNoun?: BalanceHistoryEventNouns
10
12
  linked?: boolean
11
13
  toolTipTitle?: string
12
14
  }
13
15
 
14
16
  export const AddressTableCell: React.FC<AddressTableCellProps> = ({
15
- address, linked, toolTipTitle, sx, ...props
17
+ address, eventNoun, linked, toolTipTitle, sx, ...props
16
18
  }) => {
17
- const [ref, dispatch] = useEvent()
18
- const handleClick = (event: React.MouseEvent<HTMLDivElement>) => dispatch('address', 'click', address, event.nativeEvent)
19
+ const [ref, handleClick] = useLinkedBalanceHistoryItem()
19
20
  return (
20
21
  <TableCell ref={ref} sx={{ cursor: linked ? 'pointer' : 'default', ...sx }} {...props}>
21
22
  <Tooltip title={toolTipTitle}>
22
- <BlockAddressChip address={address} onClick={handleClick} />
23
+ <BlockAddressChip address={address} onClick={linked ? e => handleClick(e, eventNoun, address) : undefined} />
23
24
  </Tooltip>
24
25
  </TableCell>
25
26
  )
@@ -0,0 +1,39 @@
1
+ import {
2
+ Link,
3
+ TableCell, Tooltip,
4
+ Typography,
5
+ } from '@mui/material'
6
+ import type { HydratedBlock } from '@xyo-network/xl1-sdk'
7
+ import React from 'react'
8
+
9
+ import { useLinkedBalanceHistoryItem } from '../hooks/index.ts'
10
+ import type { BalanceHistoryEventNouns } from '../types/index.ts'
11
+
12
+ export interface BalanceHistoryBlockNumberTableCellProps {
13
+ block?: HydratedBlock
14
+ eventNoun?: BalanceHistoryEventNouns
15
+ linked?: boolean
16
+ }
17
+
18
+ export const BalanceHistoryBlockNumberTableCell: React.FC<BalanceHistoryBlockNumberTableCellProps> = ({
19
+ block, eventNoun = 'block-number', linked, ...props
20
+ }) => {
21
+ const blockNumber = block?.[0].block
22
+
23
+ return <BalanceHistoryBlockNumberTableCellInner blockNumber={blockNumber} eventNoun={eventNoun} linked={linked} {...props} />
24
+ }
25
+
26
+ export const BalanceHistoryBlockNumberTableCellInner: React.FC<BalanceHistoryBlockNumberTableCellProps & { blockNumber?: number; linked?: boolean }> = ({
27
+ blockNumber, eventNoun = 'block-number', linked, ...props
28
+ }) => {
29
+ const [ref, handleClick] = useLinkedBalanceHistoryItem()
30
+ return (
31
+ <TableCell ref={ref} {...props}>
32
+ <Tooltip title={`Block Number: ${blockNumber}`}>
33
+ <Typography component="span" variant="body1">
34
+ {linked ? <Link onClick={e => handleClick(e, eventNoun, blockNumber?.toString() ?? '')} sx={{ cursor: 'pointer' }}>{blockNumber}</Link> : blockNumber}
35
+ </Typography>
36
+ </Tooltip>
37
+ </TableCell>
38
+ )
39
+ }
@@ -6,22 +6,23 @@ import {
6
6
  import {
7
7
  ellipsize, type Hash, isDefined,
8
8
  } from '@xylabs/sdk-js'
9
- import { useEvent } from '@xyo-network/react-event'
10
9
  import React from 'react'
11
10
 
11
+ import { useLinkedBalanceHistoryItem } from '../hooks/index.ts'
12
12
  import type { BalanceHistoryEventNouns } from '../types/index.ts'
13
13
 
14
14
  export interface HashTableCellProps extends TableCellProps {
15
+ eventData?: string
16
+ eventNoun?: BalanceHistoryEventNouns
15
17
  hash?: Hash
16
18
  linked?: boolean
17
19
  toolTipTitle?: string
18
20
  }
19
21
 
20
22
  export const HashTableCell: React.FC<HashTableCellProps> = ({
21
- hash, linked, toolTipTitle, sx, ...props
23
+ eventData, eventNoun = 'tx-hash', hash, linked, toolTipTitle, sx, ...props
22
24
  }) => {
23
- const [ref, dispatch] = useEvent<HTMLTableCellElement, BalanceHistoryEventNouns>()
24
- const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => dispatch('tx-hash', 'click', hash, event.nativeEvent)
25
+ const [ref, handleClick] = useLinkedBalanceHistoryItem()
25
26
  const shortenedHash = isDefined(hash) ? ellipsize(hash as string, 6) : 'N/A'
26
27
  return (
27
28
  <TableCell ref={ref} {...props}>
@@ -31,7 +32,7 @@ export const HashTableCell: React.FC<HashTableCellProps> = ({
31
32
  <Typography component="span" variant="body1">
32
33
  {linked
33
34
  ? (
34
- <Link onClick={handleClick} sx={{ cursor: 'pointer' }}>
35
+ <Link onClick={e => handleClick(e, eventNoun, eventData)} sx={{ cursor: 'pointer' }}>
35
36
  {shortenedHash}
36
37
  </Link>
37
38
  )
@@ -1,2 +1,3 @@
1
1
  export * from './AddressTableCell.tsx'
2
+ export * from './BlockNumber.tsx'
2
3
  export * from './HashTableCell.tsx'
@@ -0,0 +1 @@
1
+ export * from './useLinkedBalanceHistoryItem.tsx'
@@ -0,0 +1,29 @@
1
+ import { useEvent } from '@xyo-network/react-event'
2
+ import type { Ref } from 'react'
3
+ import type React from 'react'
4
+
5
+ import type { BalanceHistoryEventNouns } from '../types/index.ts'
6
+
7
+ export const useLinkedBalanceHistoryItem = (): [
8
+ Ref<HTMLElement | null>,
9
+ (event: React.MouseEvent, noun?: BalanceHistoryEventNouns, data?: string | number) => void,
10
+ ] => {
11
+ const [ref, dispatch] = useEvent<HTMLAnchorElement, BalanceHistoryEventNouns, string, string | number>()
12
+
13
+ const handleClick = (event: React.MouseEvent, noun?: BalanceHistoryEventNouns, data?: string | number) => {
14
+ event.preventDefault()
15
+ event.stopPropagation()
16
+ if (noun === undefined) {
17
+ console.warn('useLinkedBalanceHistoryItem: noun is required')
18
+ return
19
+ }
20
+ const selection = globalThis.getSelection()
21
+ const isTextSelected = selection && selection.toString().length > 0
22
+
23
+ if (!isTextSelected) {
24
+ dispatch(noun, 'click', data, event.nativeEvent)
25
+ }
26
+ }
27
+
28
+ return [ref, handleClick]
29
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './BalanceHistoryTableEx.tsx'
2
2
  export * from './BalanceHistoryTableRow.tsx'
3
3
  export * from './cell/index.ts'
4
+ export * from './hooks/index.ts'
4
5
  export * from './types/index.ts'
@@ -1,9 +1,9 @@
1
1
  import type { AccountBalanceHistoryItemFormatted } from '@xyo-network/react-chain-provider'
2
2
  import type { ExtendEventNoun } from '@xyo-network/react-event'
3
3
 
4
- export type BalanceHistoryEventNouns = ExtendEventNoun<'amount' | 'blockNumber' | 'tx-hash'>
4
+ export type BalanceHistoryEventNouns = ExtendEventNoun<'from-address' | 'to-address' | 'amount' | 'block-number' | 'tx-hash' | 'transfer-hash' | 'tx-hash|transfer-hash' | 'block-number|transfer-hash'>
5
5
 
6
- export type TableHeadingLabels = 'Tx Hash' | 'BlockNumber' | 'Timestamp' | 'From' | 'To' | 'Amount' | 'Debug'
6
+ export type TableHeadingLabels = 'Tx Hash' | 'BlockNumber' | 'Timestamp' | 'From' | 'To' | 'Amount' | 'Debug' | 'TransferHash'
7
7
  export type TableHeadings = { [key in keyof AccountBalanceHistoryItemFormatted]: TableHeadingLabels }
8
8
 
9
9
  export const TableHeadingLabels: TableHeadingLabels[] = [
@@ -13,5 +13,6 @@ export const TableHeadingLabels: TableHeadingLabels[] = [
13
13
  'From',
14
14
  'To',
15
15
  'Amount',
16
+ 'TransferHash',
16
17
  'Debug',
17
18
  ] as const
@@ -1,29 +1,28 @@
1
1
  import {
2
- Link,
3
- TableCell, Tooltip,
4
- Typography,
2
+ Link, TableCell, Tooltip, Typography,
5
3
  } from '@mui/material'
6
- import { useEvent } from '@xyo-network/react-event'
7
4
  import React from 'react'
8
5
 
9
6
  import type { BlockHeaderEventNouns } from '../../hooks/index.ts'
7
+ import { useLinkedBlockItem } from './hooks/index.ts'
10
8
  import type { BlockTableCellProps } from './lib/index.ts'
11
9
 
12
- export interface BlockNumberTableCellProps extends BlockTableCellProps {}
10
+ export interface BlockNumberTableCellProps extends BlockTableCellProps {
11
+ eventNoun?: BlockHeaderEventNouns
12
+ }
13
13
 
14
14
  export const BlockNumberTableCell: React.FC<BlockNumberTableCellProps> = ({
15
- block, linked, ...props
15
+ block, eventNoun = 'block-number', linked, ...props
16
16
  }) => {
17
17
  const blockNumber = block?.[0].block
18
18
 
19
- return <BlockNumberTableCellInner blockNumber={blockNumber} linked={linked} {...props} />
19
+ return <BlockNumberTableCellInner blockNumber={blockNumber} eventNoun={eventNoun} linked={linked} {...props} />
20
20
  }
21
21
 
22
22
  export const BlockNumberTableCellInner: React.FC<BlockNumberTableCellProps & { blockNumber?: number; linked?: boolean }> = ({
23
- blockNumber, linked, ...props
23
+ blockNumber, eventNoun = 'block-number', linked, ...props
24
24
  }) => {
25
- const [ref, dispatch] = useEvent<HTMLTableCellElement, BlockHeaderEventNouns>()
26
- const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => dispatch('block-number', 'click', blockNumber?.toString() ?? '', event.nativeEvent)
25
+ const [ref, handleClick] = useLinkedBlockItem(eventNoun, blockNumber?.toLocaleString())
27
26
  return (
28
27
  <TableCell ref={ref} {...props}>
29
28
  <Tooltip title={`Block Number: ${blockNumber}`}>
@@ -24,7 +24,11 @@ const Default = Template.bind({})
24
24
  Default.args = {}
25
25
 
26
26
  const WithData = Template.bind({})
27
- // TODO - use buildRandomChain helper
28
27
  WithData.args = { block }
29
28
 
30
- export { Default, WithData }
29
+ const WithDataLinked = Template.bind({})
30
+ WithDataLinked.args = { block, linked: true }
31
+
32
+ export {
33
+ Default, WithData, WithDataLinked,
34
+ }
@@ -1,11 +1,10 @@
1
1
  import type { TableRowProps } from '@mui/material'
2
- import { TableRow, useTheme } from '@mui/material'
3
- import { alphaCss } from '@xylabs/react-theme'
4
2
  import { usePayloadRootHash } from '@xyo-network/react-shared'
5
3
  import type { Ref } from 'react'
6
4
  import React, { useMemo } from 'react'
7
5
 
8
6
  import type { BlockComponentProps } from '../../../../types/index.ts'
7
+ import { StyledLinkableTableRow } from '../../../table/index.ts'
9
8
  import { useLinkedBlockItem } from '../cell/hooks/index.ts'
10
9
  import {
11
10
  BlockEpochTableCell,
@@ -20,24 +19,18 @@ export interface BlockChainTableRowProps extends BlockComponentProps, TableRowPr
20
19
  }
21
20
 
22
21
  export const BlockChainTableRow: React.FC<BlockChainTableRowProps> = ({
23
- block, deepValidation, defaultExpanded, linked, sx, ...props
22
+ block, deepValidation, defaultExpanded, linked, ...props
24
23
  }) => {
25
24
  const linkedTableCellProps = useMemo(() => ({ block, linked }), [block, linked])
26
25
  const defaultTableCellProps = useMemo(() => ({ block }), [block])
27
26
  const hash = usePayloadRootHash(block?.[0])
28
27
  const [ref, handleClick] = useLinkedBlockItem('block-hash', hash)
29
- const theme = useTheme()
30
28
 
31
29
  return (
32
- <TableRow
30
+ <StyledLinkableTableRow
33
31
  onClick={linked ? handleClick : undefined}
34
32
  ref={ref as Ref<HTMLTableRowElement> | undefined}
35
- sx={{
36
- 'cursor': linked ? 'pointer' : 'default',
37
- 'overflowY': 'scroll',
38
- '&:hover': { backgroundColor: alphaCss(theme.vars.palette.secondary.light, 0.15) },
39
- ...sx,
40
- }}
33
+ linked={linked}
41
34
  {...props}
42
35
  >
43
36
  <BlockNumberTableCell align="left" {...linkedTableCellProps} />
@@ -48,6 +41,6 @@ export const BlockChainTableRow: React.FC<BlockChainTableRowProps> = ({
48
41
  <BlockPayloadCountsTableCell align="left" {...linkedTableCellProps} />
49
42
  <BlockVerificationTableCell deepValidation={deepValidation} {...defaultTableCellProps} />
50
43
  <BlockJsonViewTableCell {...defaultTableCellProps} />
51
- </TableRow>
44
+ </StyledLinkableTableRow>
52
45
  )
53
46
  }
@@ -0,0 +1,12 @@
1
+ import type { TableRowProps } from '@mui/material'
2
+ import { styled, TableRow } from '@mui/material'
3
+ import { alphaCss } from '@xylabs/react-theme'
4
+
5
+ export const StyledLinkableTableRow = styled(TableRow, { shouldForwardProp: prop => prop !== 'linked' })<
6
+ TableRowProps & { linked?: boolean }
7
+ >(({ theme, linked }) => ({
8
+ 'cursor': linked ? 'pointer' : 'default',
9
+ 'overflowY': 'scroll',
10
+ '&:hover': { backgroundColor: alphaCss(theme.vars.palette.secondary.light, 0.15) },
11
+ }
12
+ ))
@@ -0,0 +1 @@
1
+ export * from './StyledLinkableTableRow.tsx'