@xylabs/sdk-react 2.9.31 → 2.9.34

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 (63) hide show
  1. package/dist/cjs5/components/LinkEx/LinkToEx.d.ts +4 -2
  2. package/dist/cjs5/components/LinkEx/index.d.ts +1 -2
  3. package/dist/cjs5/hooks/index.d.ts +2 -0
  4. package/dist/cjs5/hooks/useInterval.d.ts +2 -0
  5. package/dist/cjs5/hooks/useTimeout.d.ts +2 -0
  6. package/dist/cjs5/index.js +40 -2
  7. package/dist/cjs5/index.js.map +1 -1
  8. package/dist/components/LinkEx/LinkToEx.d.ts +4 -2
  9. package/dist/components/LinkEx/LinkToEx.js +10 -3
  10. package/dist/components/LinkEx/LinkToEx.js.map +1 -1
  11. package/dist/components/LinkEx/index.d.ts +1 -2
  12. package/dist/components/LinkEx/index.js +1 -2
  13. package/dist/components/LinkEx/index.js.map +1 -1
  14. package/dist/esm2015/components/LinkEx/LinkToEx.d.ts +4 -2
  15. package/dist/esm2015/components/LinkEx/index.d.ts +1 -2
  16. package/dist/esm2015/hooks/index.d.ts +2 -0
  17. package/dist/esm2015/hooks/useInterval.d.ts +2 -0
  18. package/dist/esm2015/hooks/useTimeout.d.ts +2 -0
  19. package/dist/esm2015/index.js +38 -3
  20. package/dist/esm2015/index.js.map +1 -1
  21. package/dist/esm2017/components/LinkEx/LinkToEx.d.ts +4 -2
  22. package/dist/esm2017/components/LinkEx/index.d.ts +1 -2
  23. package/dist/esm2017/hooks/index.d.ts +2 -0
  24. package/dist/esm2017/hooks/useInterval.d.ts +2 -0
  25. package/dist/esm2017/hooks/useTimeout.d.ts +2 -0
  26. package/dist/esm2017/index.js +38 -3
  27. package/dist/esm2017/index.js.map +1 -1
  28. package/dist/esm5/components/LinkEx/LinkToEx.d.ts +4 -2
  29. package/dist/esm5/components/LinkEx/index.d.ts +1 -2
  30. package/dist/esm5/hooks/index.d.ts +2 -0
  31. package/dist/esm5/hooks/useInterval.d.ts +2 -0
  32. package/dist/esm5/hooks/useTimeout.d.ts +2 -0
  33. package/dist/esm5/index.js +38 -3
  34. package/dist/esm5/index.js.map +1 -1
  35. package/dist/hooks/index.d.ts +2 -0
  36. package/dist/hooks/index.js +2 -0
  37. package/dist/hooks/index.js.map +1 -1
  38. package/dist/hooks/useInterval.d.ts +2 -0
  39. package/dist/hooks/useInterval.js +15 -0
  40. package/dist/hooks/useInterval.js.map +1 -0
  41. package/dist/hooks/useTimeout.d.ts +2 -0
  42. package/dist/hooks/useTimeout.js +15 -0
  43. package/dist/hooks/useTimeout.js.map +1 -0
  44. package/dist/node/components/LinkEx/LinkToEx.d.ts +4 -2
  45. package/dist/node/components/LinkEx/index.d.ts +1 -2
  46. package/dist/node/hooks/index.d.ts +2 -0
  47. package/dist/node/hooks/useInterval.d.ts +2 -0
  48. package/dist/node/hooks/useTimeout.d.ts +2 -0
  49. package/dist/node/index.js +40 -2
  50. package/dist/node/index.js.map +1 -1
  51. package/dist/node-esm/components/LinkEx/LinkToEx.d.ts +4 -2
  52. package/dist/node-esm/components/LinkEx/index.d.ts +1 -2
  53. package/dist/node-esm/hooks/index.d.ts +2 -0
  54. package/dist/node-esm/hooks/useInterval.d.ts +2 -0
  55. package/dist/node-esm/hooks/useTimeout.d.ts +2 -0
  56. package/dist/node-esm/index.js +38 -3
  57. package/dist/node-esm/index.js.map +1 -1
  58. package/package.json +11 -11
  59. package/src/components/LinkEx/LinkToEx.tsx +11 -4
  60. package/src/components/LinkEx/index.ts +1 -3
  61. package/src/hooks/index.ts +2 -0
  62. package/src/hooks/useInterval.ts +19 -0
  63. 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.4",
26
- "@emotion/react": "^11.7.1",
27
- "@emotion/styled": "^11.6.0",
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.2",
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": "^3.1.0",
35
+ "@rollup/plugin-replace": "^4.0.0",
36
36
  "@rollup/plugin-strip": "^2.1.0",
37
- "@rollup/plugin-typescript": "^8.3.0",
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.18",
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.43",
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.67.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.0"
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.31",
128
+ "version": "2.9.34",
129
129
  "packageManager": "yarn@3.1.1"
130
130
  }
@@ -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: To
6
+ to?: To
7
7
  }
8
8
 
9
- const LinkToEx: React.FC<Props> = ({ to, ...props }) => {
10
- return <Link component={RouterLink} to={to} {...props} />
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
- export { LinkToEx }
17
+ /** @deprecated use LinkEx instead */
18
+ const LinkToEx = LinkEx
19
+
20
+ export { LinkEx, LinkToEx }
@@ -1,3 +1 @@
1
- import { LinkToEx } from './LinkToEx'
2
-
3
- export { LinkToEx }
1
+ export * from './LinkToEx'
@@ -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
+ }