@xyo-network/react-chain-blockchain 1.20.11 → 1.20.13

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 (31) hide show
  1. package/dist/browser/components/account/table/BalanceHistoryTableRow.d.ts.map +1 -1
  2. package/dist/browser/components/account/table/hooks/index.d.ts +2 -0
  3. package/dist/browser/components/account/table/hooks/index.d.ts.map +1 -0
  4. package/dist/browser/components/account/table/hooks/useLinkedBalanceHistoryItem.d.ts +5 -0
  5. package/dist/browser/components/account/table/hooks/useLinkedBalanceHistoryItem.d.ts.map +1 -0
  6. package/dist/browser/components/account/table/index.d.ts +1 -0
  7. package/dist/browser/components/account/table/index.d.ts.map +1 -1
  8. package/dist/browser/components/block/table/row/TableRow.d.ts.map +1 -1
  9. package/dist/browser/components/table/StyledLinkableTableRow.d.ts +6 -0
  10. package/dist/browser/components/table/StyledLinkableTableRow.d.ts.map +1 -0
  11. package/dist/browser/components/table/index.d.ts +2 -0
  12. package/dist/browser/components/table/index.d.ts.map +1 -0
  13. package/dist/browser/index.mjs +97 -61
  14. package/dist/browser/index.mjs.map +1 -1
  15. package/package.json +20 -20
  16. package/src/components/account/table/BalanceHistoryTableEx.stories.tsx +1 -1
  17. package/src/components/account/table/BalanceHistoryTableRow.stories.tsx +51 -0
  18. package/src/components/account/table/BalanceHistoryTableRow.tsx +19 -4
  19. package/src/components/account/table/RawAmountTableCell.tsx +1 -1
  20. package/src/components/account/table/cell/AddressTableCell.tsx +1 -1
  21. package/src/components/account/table/cell/HashTableCell.tsx +1 -1
  22. package/src/components/account/table/hooks/index.ts +1 -0
  23. package/src/components/account/table/hooks/useLinkedBalanceHistoryItem.tsx +29 -0
  24. package/src/components/account/table/index.ts +1 -0
  25. package/src/components/block/BlockHeadingFlexbox.tsx +1 -1
  26. package/src/components/block/table/cell/BlockNumber.tsx +1 -1
  27. package/src/components/block/table/cell/hooks/useLinkedBlockItem.tsx +1 -1
  28. package/src/components/block/table/row/TableRow.stories.tsx +6 -2
  29. package/src/components/block/table/row/TableRow.tsx +5 -12
  30. package/src/components/table/StyledLinkableTableRow.tsx +12 -0
  31. 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.11",
4
+ "version": "1.20.13",
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.11",
60
- "@xyo-network/chain-protocol": "~1.20.11",
61
- "@xyo-network/chain-wrappers": "~1.20.11",
58
+ "@xyo-network/boundwitness-model": "~5.3.20",
59
+ "@xyo-network/chain-analyze": "~1.20.13",
60
+ "@xyo-network/chain-protocol": "~1.20.13",
61
+ "@xyo-network/chain-wrappers": "~1.20.13",
62
62
  "@xyo-network/react-boundwitness-plugin": "~7.5.8",
63
- "@xyo-network/react-chain-blockies": "~1.20.11",
64
- "@xyo-network/react-chain-provider": "~1.20.11",
65
- "@xyo-network/react-chain-shared": "~1.20.11",
63
+ "@xyo-network/react-chain-blockies": "~1.20.13",
64
+ "@xyo-network/react-chain-provider": "~1.20.13",
65
+ "@xyo-network/react-chain-shared": "~1.20.13",
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.11",
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.13",
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,51 @@
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
+ type: 'receive',
20
+ }
21
+
22
+ export default {
23
+ title: 'AccountBalanceHistory/TableRow',
24
+ component: BalanceHistoryTableRow,
25
+ } as Meta<typeof BalanceHistoryTableRow>
26
+
27
+ const Template: StoryFn<typeof BalanceHistoryTableRow> = args => (
28
+ <Table>
29
+ <TableBody>
30
+ <BalanceHistoryTableRow {...args} />
31
+ </TableBody>
32
+ </Table>
33
+ )
34
+
35
+ const Default = Template.bind({})
36
+ Default.args = { row: sampleRow }
37
+
38
+ const WithLinked = Template.bind({})
39
+ WithLinked.args = { row: sampleRow, linked: true }
40
+
41
+ const WithNoTxHash = Template.bind({})
42
+ WithNoTxHash.args = {
43
+ row: {
44
+ ...sampleRow,
45
+ txHash: undefined,
46
+ },
47
+ }
48
+
49
+ export {
50
+ Default, WithLinked, WithNoTxHash,
51
+ }
@@ -1,14 +1,19 @@
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
11
  import { BlockEpochTableCellInner, BlockNumberTableCellInner } from '../../block/index.ts'
12
+ import { StyledLinkableTableRow } from '../../table/index.ts'
10
13
  import { AddressTableCell, HashTableCell } from './cell/index.ts'
14
+ import { useLinkedBalanceHistoryItem } from './hooks/index.ts'
11
15
  import { RawAmountTableCell } from './RawAmountTableCell.tsx'
16
+ import type { BalanceHistoryEventNouns } from './types/index.ts'
12
17
 
13
18
  // const TEXT_TX_HASH = '123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234' as Hash
14
19
 
@@ -25,9 +30,19 @@ export const BalanceHistoryTableRow: React.FC<BalanceHistoryTableRowProps> = ({
25
30
  } = row ?? {}
26
31
 
27
32
  const linkedTableCallProps = useMemo(() => ({ linked }), [linked])
33
+ const [ref, handleClick] = useLinkedBalanceHistoryItem()
34
+
35
+ const noun: BalanceHistoryEventNouns = isDefined(txHash) ? 'tx-hash' : 'blockNumber'
36
+ const data = isDefined(txHash) ? txHash : blockNumber
28
37
 
29
38
  return (
30
- <TableRow key={key} {...props}>
39
+ <StyledLinkableTableRow
40
+ linked={linked}
41
+ key={key}
42
+ onClick={linked ? e => handleClick(e, noun, data) : undefined}
43
+ ref={ref as Ref<HTMLTableRowElement> | undefined}
44
+ {...props}
45
+ >
31
46
  <HashTableCell hash={txHash} toolTipTitle={`Transaction Hash: ${txHash}`} {...linkedTableCallProps} />
32
47
  <BlockNumberTableCellInner blockNumber={blockNumber} {...linkedTableCallProps} />
33
48
  <BlockEpochTableCellInner epoch={timestamp} {...linkedTableCallProps} />
@@ -38,6 +53,6 @@ export const BalanceHistoryTableRow: React.FC<BalanceHistoryTableRowProps> = ({
38
53
  <TableCell>
39
54
  <RawInfoIconButton rawValue={debug as JsonValue} />
40
55
  </TableCell>
41
- </TableRow>
56
+ </StyledLinkableTableRow>
42
57
  )
43
58
  }
@@ -20,7 +20,7 @@ export const RawAmountTableCell: React.FC<RawAmountTableCellProps> = ({
20
20
  amount, linked, sx, type, ...props
21
21
  }) => {
22
22
  const [ref, dispatch] = useEvent<HTMLAnchorElement, BalanceHistoryEventNouns>()
23
- const handleClick = () => dispatch('amount', 'click', isDefined(amount) ? toHex(amount) : '')
23
+ const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => dispatch('amount', 'click', isDefined(amount) ? toHex(amount) : '', event.nativeEvent)
24
24
 
25
25
  const formatAmount = (amount?: bigint) => {
26
26
  if (!isDefined(amount)) {
@@ -15,7 +15,7 @@ export const AddressTableCell: React.FC<AddressTableCellProps> = ({
15
15
  address, linked, toolTipTitle, sx, ...props
16
16
  }) => {
17
17
  const [ref, dispatch] = useEvent()
18
- const handleClick = () => dispatch('address', 'click', address)
18
+ const handleClick = (event: React.MouseEvent<HTMLDivElement>) => dispatch('address', 'click', address, event.nativeEvent)
19
19
  return (
20
20
  <TableCell ref={ref} sx={{ cursor: linked ? 'pointer' : 'default', ...sx }} {...props}>
21
21
  <Tooltip title={toolTipTitle}>
@@ -21,7 +21,7 @@ export const HashTableCell: React.FC<HashTableCellProps> = ({
21
21
  hash, linked, toolTipTitle, sx, ...props
22
22
  }) => {
23
23
  const [ref, dispatch] = useEvent<HTMLTableCellElement, BalanceHistoryEventNouns>()
24
- const handleClick = () => dispatch('tx-hash', 'click', hash)
24
+ const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => dispatch('tx-hash', 'click', hash, event.nativeEvent)
25
25
  const shortenedHash = isDefined(hash) ? ellipsize(hash as string, 6) : 'N/A'
26
26
  return (
27
27
  <TableCell ref={ref} {...props}>
@@ -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'
@@ -22,7 +22,7 @@ export const BlockHeadingFlexbox: React.FC<BlockComponentWithTxsProps> = ({
22
22
 
23
23
  const handleTransactionCountClick = (event: React.MouseEvent, transactions: Hash[]) => {
24
24
  event.stopPropagation()
25
- blockHeadingListener('transaction-count', 'click', JSON.stringify(transactions))
25
+ blockHeadingListener('transaction-count', 'click', JSON.stringify(transactions), event.nativeEvent)
26
26
  }
27
27
 
28
28
  return (
@@ -23,7 +23,7 @@ export const BlockNumberTableCellInner: React.FC<BlockNumberTableCellProps & { b
23
23
  blockNumber, linked, ...props
24
24
  }) => {
25
25
  const [ref, dispatch] = useEvent<HTMLTableCellElement, BlockHeaderEventNouns>()
26
- const handleClick = () => dispatch('block-number', 'click', blockNumber?.toString() ?? '')
26
+ const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => dispatch('block-number', 'click', blockNumber?.toString() ?? '', event.nativeEvent)
27
27
  return (
28
28
  <TableCell ref={ref} {...props}>
29
29
  <Tooltip title={`Block Number: ${blockNumber}`}>
@@ -17,7 +17,7 @@ export const useLinkedBlockItem = (noun?: BlockHeaderEventNouns, data?: string |
17
17
  const isTextSelected = selection && selection.toString().length > 0
18
18
 
19
19
  if (!isTextSelected) {
20
- dispatch(noun, 'click', data)
20
+ dispatch(noun, 'click', data, event.nativeEvent)
21
21
  }
22
22
  }
23
23
 
@@ -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'