@xyo-network/react-xns 7.5.7 → 7.5.11

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 (26) hide show
  1. package/dist/browser/components/XnsNameCapture/hooks/routing/useXnsNameCaptureRouting.d.ts +1 -414
  2. package/dist/browser/components/XnsNameCapture/hooks/routing/useXnsNameCaptureRouting.d.ts.map +1 -1
  3. package/dist/browser/index.mjs +200 -186
  4. package/dist/browser/index.mjs.map +1 -1
  5. package/package.json +113 -33
  6. package/src/components/EstimateName/EstimateNameTextField.stories.tsx +0 -23
  7. package/src/components/EstimateName/EstimateNameTextField.tsx +0 -70
  8. package/src/components/EstimateName/index.ts +0 -1
  9. package/src/components/XnsNameCapture/Errors.tsx +0 -56
  10. package/src/components/XnsNameCapture/Props.ts +0 -48
  11. package/src/components/XnsNameCapture/SecondaryLink.stories.tsx +0 -18
  12. package/src/components/XnsNameCapture/SecondaryLink.tsx +0 -61
  13. package/src/components/XnsNameCapture/XnsNameCapture.stories.tsx +0 -19
  14. package/src/components/XnsNameCapture/XnsNameCapture.tsx +0 -116
  15. package/src/components/XnsNameCapture/XnsNameCaptureWithContext.stories.tsx +0 -61
  16. package/src/components/XnsNameCapture/XnsNameCaptureWithContext.tsx +0 -18
  17. package/src/components/XnsNameCapture/hooks/index.ts +0 -1
  18. package/src/components/XnsNameCapture/hooks/routing/index.ts +0 -2
  19. package/src/components/XnsNameCapture/hooks/routing/useXnsNameCaptureRouting.ts +0 -21
  20. package/src/components/XnsNameCapture/hooks/routing/useXnsNameFromLocation.ts +0 -26
  21. package/src/components/XnsNameCapture/index.ts +0 -6
  22. package/src/components/XnsNameCapture/lib/index.ts +0 -1
  23. package/src/components/XnsNameCapture/lib/navigateWithUsername.ts +0 -21
  24. package/src/components/index.ts +0 -2
  25. package/src/global.d.ts +0 -1
  26. package/src/index.ts +0 -1
@@ -1,2 +0,0 @@
1
- export * from './useXnsNameCaptureRouting.ts'
2
- export * from './useXnsNameFromLocation.ts'
@@ -1,21 +0,0 @@
1
- import { useMemo } from 'react'
2
- import { useNavigate, useSearchParams } from 'react-router-dom'
3
-
4
- import type { XnsNameCaptureProps } from '../../Props.ts'
5
- import { useXnsNameFromLocation } from './useXnsNameFromLocation.ts'
6
-
7
- export const useXnsNameCaptureRouting = (props: XnsNameCaptureProps) => {
8
- const [params] = useSearchParams()
9
-
10
- const navigate = useNavigate()
11
-
12
- const [name, error] = useXnsNameFromLocation()
13
-
14
- return useMemo(() => ({
15
- ...props,
16
- defaultXnsName: name,
17
- routingError: error,
18
- navigate: props.navigate ?? ((to: string) => navigate(to)),
19
- paramsString: props.paramsString ? `${props.paramsString}${params.toString()}` : params.toString(),
20
- }), [props, name, error, params, navigate])
21
- }
@@ -1,26 +0,0 @@
1
- import { useLocation } from 'react-router-dom'
2
-
3
- /**
4
- * Assumes the user was redirected with a link that contains a username query parameter.
5
- * @returns The xNS name from the URI username query parameter.
6
- */
7
- export const useXnsNameFromLocation = (): [name: string | undefined, error: Error | undefined] => {
8
- const location = useLocation()
9
- const search = new URLSearchParams(location.search)
10
- const rawName = (search.get('xnsname') ?? search.get('name') ?? search.get('username') ?? '').toLowerCase()
11
- switch (rawName?.split('.').length) {
12
- case 1: {
13
- return [rawName, undefined]
14
- }
15
- case 2: {
16
- const rawNameParts = rawName.split('.')
17
- if (rawNameParts[1] !== 'xyo') {
18
- return [, new Error('Invalid xNS name [Bad root]')]
19
- }
20
- return [rawNameParts[0], undefined]
21
- }
22
- default: {
23
- return [, new Error('Invalid xNS name [Too many parts]')]
24
- }
25
- }
26
- }
@@ -1,6 +0,0 @@
1
- export * from './Errors.tsx'
2
- export * from './hooks/index.ts'
3
- export * from './Props.ts'
4
- export * from './SecondaryLink.tsx'
5
- export * from './XnsNameCapture.tsx'
6
- export * from './XnsNameCaptureWithContext.tsx'
@@ -1 +0,0 @@
1
- export * from './navigateWithUsername.ts'
@@ -1,21 +0,0 @@
1
- import type { To } from 'react-router-dom'
2
-
3
- export const navigateWithUsername = (xnsName: string, paramsString: string, navigate?: ((to: string) => void), to?: To) => {
4
- // avoid duplicating the username param
5
- const params = new URLSearchParams(paramsString)
6
- const usernameParam = params.get('username')
7
- if (usernameParam) {
8
- // if username param is the same as the xnsName, navigate
9
- if (usernameParam === xnsName) {
10
- navigate?.(`${to}?${paramsString}`)
11
- }
12
- if (usernameParam !== xnsName) {
13
- // if username param is different, replace it
14
- params.set('username', xnsName)
15
- navigate?.(`${to}?${params.toString()}`)
16
- }
17
- } else {
18
- // if no username param, include it
19
- navigate?.(`${to}?username=${xnsName}&${paramsString}`)
20
- }
21
- }
@@ -1,2 +0,0 @@
1
- export * from './EstimateName/index.ts'
2
- export * from './XnsNameCapture/index.ts'
package/src/global.d.ts DELETED
@@ -1 +0,0 @@
1
- import '@mui/material/themeCssVarsAugmentation'
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './components/index.ts'