@xyo-network/react-shared 7.5.8 → 7.5.12
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/browser/components/BasicHero/BasicHero.d.ts.map +1 -1
- package/dist/browser/components/bigint/InputAdornment.d.ts.map +1 -1
- package/dist/browser/components/bigint/TextField.d.ts.map +1 -1
- package/dist/browser/hooks/payload/types/ValidatedResponse.d.ts +2 -2
- package/dist/browser/hooks/payload/types/ValidatedResponse.d.ts.map +1 -1
- package/dist/browser/hooks/payload/usePayloadValidate.d.ts.map +1 -1
- package/dist/browser/hooks/useShareForwardRef.d.ts.map +1 -1
- package/dist/browser/index.mjs +641 -594
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +88 -40
- package/src/SizeProp.ts +0 -1
- package/src/components/Ampersand.tsx +0 -11
- package/src/components/BasicHero/BasicHero.stories.tsx +0 -54
- package/src/components/BasicHero/BasicHero.tsx +0 -270
- package/src/components/BasicHero/default-desktop.svg +0 -1
- package/src/components/BasicHero/index.ts +0 -1
- package/src/components/Ellipsize.tsx +0 -103
- package/src/components/LabeledTextFieldWrapper.tsx +0 -20
- package/src/components/ListItemButtonEx.tsx +0 -30
- package/src/components/LoadResult.stories.tsx +0 -33
- package/src/components/LoadResult.tsx +0 -27
- package/src/components/NotFound.tsx +0 -16
- package/src/components/Pipe.tsx +0 -11
- package/src/components/ScrollTableOnSm.tsx +0 -13
- package/src/components/SectionSpacingRow/SectionSpacingRow.stories.tsx +0 -32
- package/src/components/SectionSpacingRow/SectionSpacingRow.tsx +0 -26
- package/src/components/SectionSpacingRow/index.ts +0 -1
- package/src/components/StyleGuide/AppBars.example.tsx +0 -29
- package/src/components/StyleGuide/Buttons.example.tsx +0 -46
- package/src/components/StyleGuide/Papers.example.tsx +0 -23
- package/src/components/StyleGuide/StyleGuide.example.tsx +0 -20
- package/src/components/StyleGuide/StyleGuide.stories.tsx +0 -21
- package/src/components/StyleGuide/Texts.example.tsx +0 -34
- package/src/components/StyleGuide/VariantContext.example.tsx +0 -3
- package/src/components/TableCell/AddressTableCell.tsx +0 -24
- package/src/components/TableCell/EllipsisTableCell.tsx +0 -58
- package/src/components/TableCell/EllipsizeTableCell.stories.tsx +0 -105
- package/src/components/TableCell/HashTableCell.tsx +0 -28
- package/src/components/TableCell/findParent.ts +0 -10
- package/src/components/TableCell/getRemainingRowWidth.ts +0 -12
- package/src/components/TableCell/getSmallestParentWidth.ts +0 -13
- package/src/components/TableCell/index.ts +0 -3
- package/src/components/ThemeTokenAvatar/ThemeTokenAvatar.stories.tsx +0 -25
- package/src/components/ThemeTokenAvatar/ThemeTokenAvatar.tsx +0 -8
- package/src/components/ThemeTokenAvatar/index.ts +0 -1
- package/src/components/ThemeTokenAvatarGroup/ThemeTokenAvatarGroup.stories.tsx +0 -38
- package/src/components/ThemeTokenAvatarGroup/ThemeTokenAvatarGroup.tsx +0 -13
- package/src/components/ThemeTokenAvatarGroup/index.ts +0 -1
- package/src/components/TokenBar/TokenBar.stories.tsx +0 -33
- package/src/components/TokenBar/TokenBar.tsx +0 -32
- package/src/components/TokenBar/index.ts +0 -1
- package/src/components/TokenData/TokenData.ts +0 -141
- package/src/components/TokenData/img/ada.png +0 -0
- package/src/components/TokenData/img/btc.png +0 -0
- package/src/components/TokenData/img/busd.png +0 -0
- package/src/components/TokenData/img/dai.png +0 -0
- package/src/components/TokenData/img/dogecoin.png +0 -0
- package/src/components/TokenData/img/dot.png +0 -0
- package/src/components/TokenData/img/ethereum.png +0 -0
- package/src/components/TokenData/img/frax.png +0 -0
- package/src/components/TokenData/img/images.d.ts +0 -5
- package/src/components/TokenData/img/index.ts +0 -16
- package/src/components/TokenData/img/link.png +0 -0
- package/src/components/TokenData/img/sol.png +0 -0
- package/src/components/TokenData/img/tether.png +0 -0
- package/src/components/TokenData/img/usd-coin.png +0 -0
- package/src/components/TokenData/img/weth.png +0 -0
- package/src/components/TokenData/img/wrapped-bitcoin.png +0 -0
- package/src/components/TokenData/img/xl1.png +0 -0
- package/src/components/TokenData/img/xyo.png +0 -0
- package/src/components/TokenData/index.ts +0 -2
- package/src/components/TokenData/useGetTokenData.tsx +0 -16
- package/src/components/TokenSummary/TokenSummary.stories.tsx +0 -37
- package/src/components/TokenSummary/TokenSummary.tsx +0 -32
- package/src/components/TokenSummary/index.ts +0 -1
- package/src/components/TypographyEx.tsx +0 -14
- package/src/components/bigint/FixedPointPopover.tsx +0 -27
- package/src/components/bigint/Input.stories.tsx +0 -79
- package/src/components/bigint/Input.ts +0 -6
- package/src/components/bigint/InputAdornment.tsx +0 -44
- package/src/components/bigint/TextField.tsx +0 -128
- package/src/components/bigint/helpers/formatBigIntInput.ts +0 -11
- package/src/components/bigint/helpers/index.ts +0 -1
- package/src/components/bigint/index.ts +0 -5
- package/src/components/index.ts +0 -19
- package/src/components/pluginValidation/DataMissing.tsx +0 -16
- package/src/components/pluginValidation/index.ts +0 -1
- package/src/contexts/ListMode/Context.ts +0 -5
- package/src/contexts/ListMode/Provider.tsx +0 -29
- package/src/contexts/ListMode/State.ts +0 -9
- package/src/contexts/ListMode/index.ts +0 -4
- package/src/contexts/ListMode/use.ts +0 -7
- package/src/contexts/diviner/Context.ts +0 -4
- package/src/contexts/diviner/Provider.tsx +0 -45
- package/src/contexts/diviner/State.ts +0 -7
- package/src/contexts/diviner/index.ts +0 -3
- package/src/contexts/index.ts +0 -2
- package/src/global.d.ts +0 -1
- package/src/hooks/GradientStyles/GradientStyle.stories.tsx +0 -66
- package/src/hooks/GradientStyles/GradientStyles.tsx +0 -54
- package/src/hooks/GradientStyles/index.ts +0 -1
- package/src/hooks/index.ts +0 -5
- package/src/hooks/payload/index.ts +0 -4
- package/src/hooks/payload/types/ValidatedResponse.ts +0 -3
- package/src/hooks/payload/types/index.ts +0 -1
- package/src/hooks/payload/useBoundWitnessValidate.tsx +0 -29
- package/src/hooks/payload/usePayloadHash.tsx +0 -26
- package/src/hooks/payload/usePayloadValidate.tsx +0 -22
- package/src/hooks/useDataState.ts +0 -18
- package/src/hooks/useMediaQuery.ts +0 -3
- package/src/hooks/useShareForwardRef.ts +0 -23
- package/src/index.ts +0 -6
- package/src/lib/assertDefinedEx.ts +0 -7
- package/src/lib/getActualPaddingX.ts +0 -63
- package/src/lib/index.ts +0 -3
- package/src/lib/networkComponents.tsx +0 -48
- package/src/lib/xyo.tsx +0 -15
- package/src/models/ListMode.ts +0 -1
- package/src/models/index.ts +0 -1
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { usePromise } from '@xylabs/react-promise'
|
|
2
|
-
import type { Hash } from '@xylabs/sdk-js'
|
|
3
|
-
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
4
|
-
import { type Payload } from '@xyo-network/payload-model'
|
|
5
|
-
|
|
6
|
-
export const usePayloadHash = <TPayload extends Payload>(payload: TPayload | undefined | null) => {
|
|
7
|
-
return usePayloadRootHash<TPayload>(payload)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const usePayloadDataHash = <TPayload extends Payload>(payload: TPayload | undefined | null) => {
|
|
11
|
-
return usePromise(async () => (payload ? await PayloadBuilder.dataHash(payload) : undefined), [payload])[0]
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const usePayloadRootHash = <TPayload extends Payload>(payload: TPayload | undefined | null) => {
|
|
15
|
-
return usePromise(async () => (payload ? await PayloadBuilder.hash(payload) : undefined), [payload])[0]
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const usePayloadHashes = <TPayload extends Payload>(payloads: TPayload[] | undefined | null) => {
|
|
19
|
-
return usePromise(
|
|
20
|
-
async () =>
|
|
21
|
-
payloads
|
|
22
|
-
? await Promise.all(payloads.map<Promise<[TPayload, Hash]>>(async payload => [payload, await PayloadBuilder.dataHash(payload)]))
|
|
23
|
-
: undefined,
|
|
24
|
-
[payloads],
|
|
25
|
-
)[0]
|
|
26
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/sdk-js'
|
|
2
|
-
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
3
|
-
import type { AnyPayload, Payload } from '@xyo-network/payload-model'
|
|
4
|
-
import { isAnyPayload } from '@xyo-network/payload-model'
|
|
5
|
-
import { useMemo } from 'react'
|
|
6
|
-
|
|
7
|
-
import type { ValidatedResponse } from './types/index.ts'
|
|
8
|
-
|
|
9
|
-
export const usePayloadValidate = <TPayload extends AnyPayload>(input?: string): ValidatedResponse => {
|
|
10
|
-
return useMemo(() => {
|
|
11
|
-
if (!input) return {}
|
|
12
|
-
try {
|
|
13
|
-
const object = JSON.parse(input)
|
|
14
|
-
const validPayload = assertEx(isAnyPayload(object) ? object : null, () => 'Invalid payload')
|
|
15
|
-
const { schema, ...fields } = validPayload
|
|
16
|
-
const payload = new PayloadBuilder({ schema }).fields(fields).build() as TPayload
|
|
17
|
-
return { payload }
|
|
18
|
-
} catch (error) {
|
|
19
|
-
return { errors: [error as Error] }
|
|
20
|
-
}
|
|
21
|
-
}, [input])
|
|
22
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Dispatch, SetStateAction } from 'react'
|
|
2
|
-
import { useState } from 'react'
|
|
3
|
-
|
|
4
|
-
export const useDataState = <T>(defaultValue: T | undefined): [T | undefined, Dispatch<SetStateAction<T | undefined>>] => {
|
|
5
|
-
const [state, setState] = useState(defaultValue)
|
|
6
|
-
|
|
7
|
-
const setDataState: Dispatch<SetStateAction<T | undefined>> = (value: SetStateAction<T | undefined>) => {
|
|
8
|
-
try {
|
|
9
|
-
if (JSON.stringify(value) !== JSON.stringify(state)) {
|
|
10
|
-
setState(value)
|
|
11
|
-
}
|
|
12
|
-
} catch {
|
|
13
|
-
console.error('setDataState failed! Make sure data type is stringifiable!')
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return [state, setDataState]
|
|
18
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ForwardedRef } from 'react'
|
|
2
|
-
import { useEffect, useRef } from 'react'
|
|
3
|
-
|
|
4
|
-
/** @deprecated */
|
|
5
|
-
export const useShareForwardedRef = <T>(forwardedRef: ForwardedRef<T> | null | undefined, refresh = 0) => {
|
|
6
|
-
// final ref that will share value with forward ref. this is the one to be attached to components
|
|
7
|
-
const innerRef = useRef<T>(null)
|
|
8
|
-
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
if (!forwardedRef) {
|
|
11
|
-
return
|
|
12
|
-
}
|
|
13
|
-
if (typeof forwardedRef === 'function') {
|
|
14
|
-
forwardedRef(innerRef.current)
|
|
15
|
-
} else {
|
|
16
|
-
// suppressing since this is older and deprecated
|
|
17
|
-
// eslint-disable-next-line react-hooks/immutability
|
|
18
|
-
forwardedRef.current = innerRef.current
|
|
19
|
-
}
|
|
20
|
-
}, [forwardedRef, refresh])
|
|
21
|
-
|
|
22
|
-
return innerRef
|
|
23
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
export const parseMeausureString = (measure?: string, absolute?: number) => {
|
|
2
|
-
if (measure !== undefined && measure !== null && measure.length > 0) {
|
|
3
|
-
if (measure.endsWith('px')) {
|
|
4
|
-
return Number.parseFloat(measure.slice(0, Math.max(0, measure.length - 2)))
|
|
5
|
-
} else if (measure.endsWith('%')) {
|
|
6
|
-
if (absolute !== undefined) {
|
|
7
|
-
return (Number.parseFloat(measure.slice(0, Math.max(0, measure.length - 1))) / 100) * absolute
|
|
8
|
-
}
|
|
9
|
-
throw new Error('Error Parsing Measure [missing absolute]')
|
|
10
|
-
} else if (measure.endsWith('vw')) {
|
|
11
|
-
return (Number.parseFloat(measure.slice(0, Math.max(0, measure.length - 2))) / 100) * window.innerWidth
|
|
12
|
-
} else if (measure.endsWith('vh')) {
|
|
13
|
-
return (Number.parseFloat(measure.slice(0, Math.max(0, measure.length - 2))) / 100) * window.innerHeight
|
|
14
|
-
}
|
|
15
|
-
throw new Error(`Error Parsing Measure [${measure}]`)
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const parsePadding = (padding: string) => {
|
|
20
|
-
const parts = padding.split(' ')
|
|
21
|
-
switch (parts.length) {
|
|
22
|
-
case 4: {
|
|
23
|
-
return {
|
|
24
|
-
bottom: parts[2],
|
|
25
|
-
left: parts[3],
|
|
26
|
-
right: parts[1],
|
|
27
|
-
top: parts[0],
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
case 3: {
|
|
31
|
-
return {
|
|
32
|
-
bottom: parts[2],
|
|
33
|
-
right: parts[1],
|
|
34
|
-
top: parts[0],
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
case 2: {
|
|
38
|
-
return {
|
|
39
|
-
bottom: parts[0],
|
|
40
|
-
left: parts[1],
|
|
41
|
-
right: parts[1],
|
|
42
|
-
top: parts[0],
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
case 1: {
|
|
46
|
-
return {
|
|
47
|
-
bottom: parts[0],
|
|
48
|
-
left: parts[0],
|
|
49
|
-
right: parts[0],
|
|
50
|
-
top: parts[0],
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const getActualPaddingX = (element: HTMLElement) => {
|
|
57
|
-
const padding = parsePadding(globalThis.getComputedStyle(element, null).getPropertyValue('padding'))
|
|
58
|
-
const paddingLeft
|
|
59
|
-
= parseMeausureString(globalThis.getComputedStyle(element, null).getPropertyValue('padding-left') ?? padding?.left, element.clientWidth) ?? 0
|
|
60
|
-
const paddingRight
|
|
61
|
-
= parseMeausureString(globalThis.getComputedStyle(element, null).getPropertyValue('padding-right') ?? padding?.right, element.clientWidth) ?? 0
|
|
62
|
-
return paddingLeft + paddingRight
|
|
63
|
-
}
|
package/src/lib/index.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BubbleChartRounded as BubbleChartRoundedIcon,
|
|
3
|
-
HubRounded as HubRoundedIcon,
|
|
4
|
-
InsertLinkRounded as InsertLinkRoundedIcon,
|
|
5
|
-
Inventory2Rounded as Inventory2RoundedIcon,
|
|
6
|
-
TimerRounded as TimerRoundedIcon,
|
|
7
|
-
VisibilityRounded as VisibilityRoundedIcon,
|
|
8
|
-
} from '@mui/icons-material'
|
|
9
|
-
import type { SvgIconProps } from '@mui/material'
|
|
10
|
-
import type { ReactElement } from 'react'
|
|
11
|
-
import React from 'react'
|
|
12
|
-
|
|
13
|
-
export type NetworkComponentSlug = 'sentinel' | 'bridge' | 'archivist' | 'diviner' | 'node' | 'witness'
|
|
14
|
-
|
|
15
|
-
export interface NetworkComponentDetails {
|
|
16
|
-
icon: (props?: SvgIconProps) => ReactElement
|
|
17
|
-
name: string
|
|
18
|
-
slug: NetworkComponentSlug
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const networkComponents: NetworkComponentDetails[] = [
|
|
22
|
-
{
|
|
23
|
-
icon: props => <HubRoundedIcon {...props} />, name: 'Node', slug: 'node',
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
icon: props => <TimerRoundedIcon {...props} />, name: 'Sentinel', slug: 'sentinel',
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
icon: props => <InsertLinkRoundedIcon {...props} />, name: 'Bridge', slug: 'bridge',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
icon: props => <Inventory2RoundedIcon {...props} />, name: 'Archivist', slug: 'archivist',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
icon: props => <BubbleChartRoundedIcon {...props} />, name: 'Diviner', slug: 'diviner',
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
icon: props => <VisibilityRoundedIcon {...props} />, name: 'Witness', slug: 'witness',
|
|
39
|
-
},
|
|
40
|
-
]
|
|
41
|
-
|
|
42
|
-
export const findNetworkComponentIndex = (slug: string) => {
|
|
43
|
-
return networkComponents.findIndex(info => info.slug === slug)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const findNetworkComponent = (slug: string) => {
|
|
47
|
-
return networkComponents.find(info => info.slug === slug)
|
|
48
|
-
}
|
package/src/lib/xyo.tsx
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @stylistic/max-len */
|
|
2
|
-
import type { SvgIconProps } from '@mui/material'
|
|
3
|
-
import { SvgIcon } from '@mui/material'
|
|
4
|
-
import React from 'react'
|
|
5
|
-
|
|
6
|
-
export const Logo: React.FC<SvgIconProps> = (props) => {
|
|
7
|
-
return (
|
|
8
|
-
<SvgIcon data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 238" {...props}>
|
|
9
|
-
<path d="M74.5,28.33,21.29,120.5,74.5,212.67H180.94l1.76-3,51.46-89.13L180.94,28.33ZM84.65,40.54h78.83L111.65,56.93a15.85,15.85,0,0,1,2,5l59.66-18.81L185.22,101a20.12,20.12,0,0,1,5.36-.78l-10-47.91,37.87,65.53h-7.62a24.21,24.21,0,0,1,.15,2.68,23.29,23.29,0,0,1-.15,2.68h7.62l-39.1,67.75,10.92-50.13A20.57,20.57,0,0,1,185,140l-12.88,59-58.37-19.53a17.61,17.61,0,0,1-1.7,5l47.5,15.92H84.65l4-6.85A20.17,20.17,0,0,1,83.93,191L80,197.78,42.67,133.13l37,32.66a20.52,20.52,0,0,1,3.6-4L36.69,120.66,85,77.79a17.45,17.45,0,0,1-3.19-4.32l-39.46,35L80,43.22l5.56,9.69A17.51,17.51,0,0,1,90.12,50Zm28.24,31.17a16.15,16.15,0,0,1-2.68,4.64l62,35.81a19.74,19.74,0,0,1,2.83-4.54Zm-20,10.51v75.33a18,18,0,0,1,2.47-.16,17.18,17.18,0,0,1,2.89.21v-75a11.21,11.21,0,0,1-1.29,0,17.57,17.57,0,0,1-4.07-.47Zm79.34,46.63-62.08,35.81a18.45,18.45,0,0,1,2.68,4.68l62.23-36a19.68,19.68,0,0,1-2.83-4.53Z" />
|
|
10
|
-
<path d="M97,48.58a17.06,17.06,0,1,0,17,17,17.08,17.08,0,0,0-17-17Zm0,5.36a11.7,11.7,0,1,1-11.7,11.69A11.65,11.65,0,0,1,97,53.94Z" />
|
|
11
|
-
<path d="M95.37,157.39a18.73,18.73,0,1,0,18.7,18.7,18.74,18.74,0,0,0-18.7-18.7Zm0,5.31A13.4,13.4,0,1,1,82,176.09a13.37,13.37,0,0,1,13.4-13.39Z" />
|
|
12
|
-
<path d="M190.73,100.2A20.3,20.3,0,1,0,211,120.5a20.34,20.34,0,0,0-20.3-20.3Zm0,5.36a14.94,14.94,0,1,1-14.94,14.94,14.88,14.88,0,0,1,14.94-14.94Z" />
|
|
13
|
-
</SvgIcon>
|
|
14
|
-
)
|
|
15
|
-
}
|
package/src/models/ListMode.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type ListMode = 'table' | 'grid' | 'default'
|
package/src/models/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './ListMode.ts'
|