@xylabs/sdk-react 2.9.32 → 2.9.35
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/dist/cjs5/components/EthAccount/EthAccount.stories.d.ts +3 -1
- package/dist/cjs5/components/EthAccount/EthAccountProps.d.ts +1 -0
- package/dist/cjs5/components/LinkEx/LinkToEx.d.ts +4 -2
- package/dist/cjs5/components/LinkEx/index.d.ts +1 -2
- package/dist/cjs5/hooks/index.d.ts +2 -0
- package/dist/cjs5/hooks/useInterval.d.ts +2 -0
- package/dist/cjs5/hooks/useTimeout.d.ts +2 -0
- package/dist/cjs5/index.js +42 -4
- package/dist/cjs5/index.js.map +1 -1
- package/dist/components/BasePage/BasePage.stories.js +2 -1
- package/dist/components/BasePage/BasePage.stories.js.map +1 -1
- package/dist/components/EthAccount/EthAccount.js +2 -2
- package/dist/components/EthAccount/EthAccount.js.map +1 -1
- package/dist/components/EthAccount/EthAccount.stories.d.ts +3 -1
- package/dist/components/EthAccount/EthAccount.stories.js +18 -1
- package/dist/components/EthAccount/EthAccount.stories.js.map +1 -1
- package/dist/components/EthAccount/EthAccountProps.d.ts +1 -0
- package/dist/components/LinkEx/LinkToEx.d.ts +4 -2
- package/dist/components/LinkEx/LinkToEx.js +10 -3
- package/dist/components/LinkEx/LinkToEx.js.map +1 -1
- package/dist/components/LinkEx/index.d.ts +1 -2
- package/dist/components/LinkEx/index.js +1 -2
- package/dist/components/LinkEx/index.js.map +1 -1
- package/dist/esm2015/components/EthAccount/EthAccount.stories.d.ts +3 -1
- package/dist/esm2015/components/EthAccount/EthAccountProps.d.ts +1 -0
- package/dist/esm2015/components/LinkEx/LinkToEx.d.ts +4 -2
- package/dist/esm2015/components/LinkEx/index.d.ts +1 -2
- package/dist/esm2015/hooks/index.d.ts +2 -0
- package/dist/esm2015/hooks/useInterval.d.ts +2 -0
- package/dist/esm2015/hooks/useTimeout.d.ts +2 -0
- package/dist/esm2015/index.js +40 -5
- package/dist/esm2015/index.js.map +1 -1
- package/dist/esm2017/components/EthAccount/EthAccount.stories.d.ts +3 -1
- package/dist/esm2017/components/EthAccount/EthAccountProps.d.ts +1 -0
- package/dist/esm2017/components/LinkEx/LinkToEx.d.ts +4 -2
- package/dist/esm2017/components/LinkEx/index.d.ts +1 -2
- package/dist/esm2017/hooks/index.d.ts +2 -0
- package/dist/esm2017/hooks/useInterval.d.ts +2 -0
- package/dist/esm2017/hooks/useTimeout.d.ts +2 -0
- package/dist/esm2017/index.js +40 -5
- package/dist/esm2017/index.js.map +1 -1
- package/dist/esm5/components/EthAccount/EthAccount.stories.d.ts +3 -1
- package/dist/esm5/components/EthAccount/EthAccountProps.d.ts +1 -0
- package/dist/esm5/components/LinkEx/LinkToEx.d.ts +4 -2
- package/dist/esm5/components/LinkEx/index.d.ts +1 -2
- package/dist/esm5/hooks/index.d.ts +2 -0
- package/dist/esm5/hooks/useInterval.d.ts +2 -0
- package/dist/esm5/hooks/useTimeout.d.ts +2 -0
- package/dist/esm5/index.js +40 -5
- package/dist/esm5/index.js.map +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useInterval.d.ts +2 -0
- package/dist/hooks/useInterval.js +15 -0
- package/dist/hooks/useInterval.js.map +1 -0
- package/dist/hooks/useTimeout.d.ts +2 -0
- package/dist/hooks/useTimeout.js +15 -0
- package/dist/hooks/useTimeout.js.map +1 -0
- package/dist/node/components/EthAccount/EthAccount.stories.d.ts +3 -1
- package/dist/node/components/EthAccount/EthAccountProps.d.ts +1 -0
- package/dist/node/components/LinkEx/LinkToEx.d.ts +4 -2
- package/dist/node/components/LinkEx/index.d.ts +1 -2
- package/dist/node/hooks/index.d.ts +2 -0
- package/dist/node/hooks/useInterval.d.ts +2 -0
- package/dist/node/hooks/useTimeout.d.ts +2 -0
- package/dist/node/index.js +42 -4
- package/dist/node/index.js.map +1 -1
- package/dist/node-esm/components/EthAccount/EthAccount.stories.d.ts +3 -1
- package/dist/node-esm/components/EthAccount/EthAccountProps.d.ts +1 -0
- package/dist/node-esm/components/LinkEx/LinkToEx.d.ts +4 -2
- package/dist/node-esm/components/LinkEx/index.d.ts +1 -2
- package/dist/node-esm/hooks/index.d.ts +2 -0
- package/dist/node-esm/hooks/useInterval.d.ts +2 -0
- package/dist/node-esm/hooks/useTimeout.d.ts +2 -0
- package/dist/node-esm/index.js +40 -5
- package/dist/node-esm/index.js.map +1 -1
- package/package.json +11 -11
- package/src/components/BasePage/BasePage.stories.tsx +6 -1
- package/src/components/EthAccount/EthAccount.stories.tsx +20 -1
- package/src/components/EthAccount/EthAccount.tsx +2 -1
- package/src/components/EthAccount/EthAccountProps.tsx +1 -0
- package/src/components/LinkEx/LinkToEx.tsx +11 -4
- package/src/components/LinkEx/index.ts +1 -3
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useInterval.ts +19 -0
- package/src/hooks/useTimeout.ts +19 -0
package/package.json
CHANGED
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
},
|
|
23
23
|
"description": "Common React library for all XY Labs projects that use React",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@babel/core": "^7.17.
|
|
26
|
-
"@emotion/react": "^11.
|
|
27
|
-
"@emotion/styled": "^11.
|
|
25
|
+
"@babel/core": "^7.17.5",
|
|
26
|
+
"@emotion/react": "^11.8.1",
|
|
27
|
+
"@emotion/styled": "^11.8.1",
|
|
28
28
|
"@ethersproject/abstract-signer": "^5.5.0",
|
|
29
29
|
"@ethersproject/providers": "^5.5.3",
|
|
30
30
|
"@mui/icons-material": "^5.4.2",
|
|
31
|
-
"@mui/material": "^5.4.
|
|
31
|
+
"@mui/material": "^5.4.3",
|
|
32
32
|
"@mui/styles": "^5.4.2",
|
|
33
33
|
"@rollup/plugin-image": "^2.1.1",
|
|
34
34
|
"@rollup/plugin-json": "^4.1.0",
|
|
35
|
-
"@rollup/plugin-replace": "^
|
|
35
|
+
"@rollup/plugin-replace": "^4.0.0",
|
|
36
36
|
"@rollup/plugin-strip": "^2.1.0",
|
|
37
|
-
"@rollup/plugin-typescript": "^8.3.
|
|
37
|
+
"@rollup/plugin-typescript": "^8.3.1",
|
|
38
38
|
"@storybook/addon-actions": "^6.4.19",
|
|
39
39
|
"@storybook/addon-docs": "^6.4.19",
|
|
40
40
|
"@storybook/addon-essentials": "^6.4.19",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"@types/bn.js": "^5.1.0",
|
|
46
46
|
"@types/lodash": "^4.14.178",
|
|
47
47
|
"@types/md5": "^2.3.2",
|
|
48
|
-
"@types/node": "^17.0.
|
|
48
|
+
"@types/node": "^17.0.21",
|
|
49
49
|
"@types/numeral": "^2.0.2",
|
|
50
50
|
"@types/react": "^17.0.39",
|
|
51
51
|
"@types/react-dom": "^17.0.11",
|
|
52
52
|
"@xylabs/eslint-config-react": "^2.1.2",
|
|
53
53
|
"@xylabs/pixel": "^1.3.7",
|
|
54
54
|
"@xylabs/rollup-config": "^1.1.7",
|
|
55
|
-
"@xylabs/ts-scripts": "^1.0.
|
|
55
|
+
"@xylabs/ts-scripts": "^1.0.44",
|
|
56
56
|
"@xylabs/tsconfig": "^1.0.12",
|
|
57
57
|
"babel-loader": "^8.2.3",
|
|
58
58
|
"copyfiles": "^2.4.1",
|
|
@@ -66,12 +66,12 @@
|
|
|
66
66
|
"react-router-dom": "^6.2.1",
|
|
67
67
|
"rimraf": "^3.0.2",
|
|
68
68
|
"rollbar": "^2.24.0",
|
|
69
|
-
"rollup": "^2.
|
|
69
|
+
"rollup": "^2.68.0",
|
|
70
70
|
"rollup-plugin-svg": "^2.0.0",
|
|
71
71
|
"ts-node": "^10.5.0",
|
|
72
72
|
"tslib": "^2.3.1",
|
|
73
73
|
"typescript": "^4.5.5",
|
|
74
|
-
"webpack": "^5.69.
|
|
74
|
+
"webpack": "^5.69.1"
|
|
75
75
|
},
|
|
76
76
|
"esm5": "dist/esm5/index.js",
|
|
77
77
|
"exports": {
|
|
@@ -125,6 +125,6 @@
|
|
|
125
125
|
},
|
|
126
126
|
"sideEffects": false,
|
|
127
127
|
"types": "dist/index.d.ts",
|
|
128
|
-
"version": "2.9.
|
|
128
|
+
"version": "2.9.35",
|
|
129
129
|
"packageManager": "yarn@3.1.1"
|
|
130
130
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ComponentMeta, ComponentStory } from '@storybook/react'
|
|
2
|
+
import { BrowserRouter } from 'react-router-dom'
|
|
2
3
|
|
|
3
4
|
import { BasePage } from './BasePage'
|
|
4
5
|
|
|
@@ -13,7 +14,11 @@ const StorybookEntry = {
|
|
|
13
14
|
title: 'Components/BasePage',
|
|
14
15
|
} as ComponentMeta<typeof BasePage>
|
|
15
16
|
|
|
16
|
-
const Template: ComponentStory<typeof BasePage> = (args) =>
|
|
17
|
+
const Template: ComponentStory<typeof BasePage> = (args) => (
|
|
18
|
+
<BrowserRouter>
|
|
19
|
+
<BasePage {...args}></BasePage>
|
|
20
|
+
</BrowserRouter>
|
|
21
|
+
)
|
|
17
22
|
|
|
18
23
|
const AppBar = () => <div>AppBar</div>
|
|
19
24
|
const FilterBar = () => <div>FilterBar</div>
|
|
@@ -38,6 +38,25 @@ LongEmpty.args = {
|
|
|
38
38
|
toEtherScan: true,
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
const Medium = Template.bind({})
|
|
42
|
+
Medium.args = {
|
|
43
|
+
address: EthAddress.fromString('0x6792b02f88b32c4fe8e31cfa41ae5af44865f930'),
|
|
44
|
+
addressLength: 'short',
|
|
45
|
+
icon: true,
|
|
46
|
+
shortenedLength: 8,
|
|
47
|
+
title: 'Sample EthAccount',
|
|
48
|
+
toEtherScan: true,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const MediumEmpty = Template.bind({})
|
|
52
|
+
MediumEmpty.args = {
|
|
53
|
+
addressLength: 'short',
|
|
54
|
+
icon: true,
|
|
55
|
+
shortenedLength: 8,
|
|
56
|
+
title: 'Sample EthAccount',
|
|
57
|
+
toEtherScan: true,
|
|
58
|
+
}
|
|
59
|
+
|
|
41
60
|
const Short = Template.bind({})
|
|
42
61
|
Short.args = {
|
|
43
62
|
address: EthAddress.fromString('0x6792b02f88b32c4fe8e31cfa41ae5af44865f930'),
|
|
@@ -72,7 +91,7 @@ AutoEmpty.args = {
|
|
|
72
91
|
toEtherScan: true,
|
|
73
92
|
}
|
|
74
93
|
|
|
75
|
-
export { Auto, AutoEmpty, Long, LongEmpty, Short, ShortEmpty }
|
|
94
|
+
export { Auto, AutoEmpty, Long, LongEmpty, Medium, MediumEmpty, Short, ShortEmpty }
|
|
76
95
|
|
|
77
96
|
// eslint-disable-next-line import/no-default-export
|
|
78
97
|
export default StorybookEntry
|
|
@@ -14,6 +14,7 @@ const EthAccount: React.FC<EthAccountProps> = ({
|
|
|
14
14
|
icon = false,
|
|
15
15
|
iconSize = 16,
|
|
16
16
|
iconOnly = false,
|
|
17
|
+
shortenedLength,
|
|
17
18
|
addressLength = 'auto',
|
|
18
19
|
fontFamily = '"Source Code Pro",monospace',
|
|
19
20
|
toEtherScan,
|
|
@@ -40,7 +41,7 @@ const EthAccount: React.FC<EthAccountProps> = ({
|
|
|
40
41
|
addressLength === 'long'
|
|
41
42
|
? addressToDisplay.toString()
|
|
42
43
|
: addressLength === 'short'
|
|
43
|
-
? addressToDisplay.toShortString()
|
|
44
|
+
? addressToDisplay.toShortString(shortenedLength)
|
|
44
45
|
: large
|
|
45
46
|
? addressToDisplay.toString()
|
|
46
47
|
: addressToDisplay.toShortString()
|
|
@@ -3,11 +3,18 @@ import React from 'react'
|
|
|
3
3
|
import { Link as RouterLink, To } from 'react-router-dom'
|
|
4
4
|
|
|
5
5
|
interface Props extends LinkProps {
|
|
6
|
-
to
|
|
6
|
+
to?: To
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
const LinkEx: React.FC<Props> = ({ to, ...props }) => {
|
|
10
|
+
if (to) {
|
|
11
|
+
return <Link component={RouterLink} to={to} {...props} />
|
|
12
|
+
} else {
|
|
13
|
+
return <Link {...props} />
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
/** @deprecated use LinkEx instead */
|
|
18
|
+
const LinkToEx = LinkEx
|
|
19
|
+
|
|
20
|
+
export { LinkEx, LinkToEx }
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export * from './useBreakpoint'
|
|
2
|
+
export * from './useInterval'
|
|
2
3
|
export * from './useLocalStorage'
|
|
3
4
|
export * from './useMediaQuery'
|
|
4
5
|
export * from './useMounted'
|
|
5
6
|
export * from './useNavigateToEthAddress'
|
|
6
7
|
export * from './useSpacing'
|
|
8
|
+
export * from './useTimeout'
|
|
7
9
|
export * from './useUserEvents'
|
|
8
10
|
export * from './useWebP'
|
|
9
11
|
export * from './useWindowSize'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react'
|
|
2
|
+
|
|
3
|
+
export const useInterval = (callback: () => void, delay: number) => {
|
|
4
|
+
const intervalRef = useRef<number>(-1)
|
|
5
|
+
const savedCallback = useRef(callback)
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
savedCallback.current = callback
|
|
9
|
+
}, [callback])
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const tick = () => savedCallback.current()
|
|
13
|
+
intervalRef.current = window.setInterval(tick, delay)
|
|
14
|
+
|
|
15
|
+
return () => window.clearInterval(intervalRef.current)
|
|
16
|
+
}, [delay])
|
|
17
|
+
|
|
18
|
+
return intervalRef
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react'
|
|
2
|
+
|
|
3
|
+
export const useTimeout = (callback: () => void, delay: number) => {
|
|
4
|
+
const timeoutRef = useRef<number>(-1)
|
|
5
|
+
const savedCallback = useRef(callback)
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
savedCallback.current = callback
|
|
9
|
+
}, [callback])
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const tick = () => savedCallback.current()
|
|
13
|
+
timeoutRef.current = window.setTimeout(tick, delay)
|
|
14
|
+
|
|
15
|
+
return () => window.clearTimeout(timeoutRef.current)
|
|
16
|
+
}, [delay])
|
|
17
|
+
|
|
18
|
+
return timeoutRef
|
|
19
|
+
}
|