@xyo-network/react-schema 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/contexts/Schema/Provider/Memory.d.ts.map +1 -1
- package/dist/browser/hooks/useGetSchema.d.ts +8 -6
- package/dist/browser/hooks/useGetSchema.d.ts.map +1 -1
- package/dist/browser/hooks/useSchemaDefinitions.d.ts +2 -2
- package/dist/browser/hooks/useSchemaDefinitions.d.ts.map +1 -1
- package/dist/browser/hooks/useSchemaList.d.ts +1 -1
- package/dist/browser/hooks/useSchemaList.d.ts.map +1 -1
- package/dist/browser/hooks/useSchemaStats.d.ts +1 -1
- package/dist/browser/hooks/useSchemaStats.d.ts.map +1 -1
- package/dist/browser/index.mjs +309 -298
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +160 -57
- package/src/components/Property/SchemaProperty.stories.tsx +0 -41
- package/src/components/Property/SchemaProperty.tsx +0 -154
- package/src/components/Property/index.ts +0 -1
- package/src/components/SelectEx/SchemaSelectEx.tsx +0 -45
- package/src/components/SelectEx/index.ts +0 -1
- package/src/components/index.ts +0 -2
- package/src/contexts/Schema/Context.ts +0 -5
- package/src/contexts/Schema/Provider/Memory.tsx +0 -31
- package/src/contexts/Schema/Provider/Props.ts +0 -4
- package/src/contexts/Schema/Provider/Route.tsx +0 -73
- package/src/contexts/Schema/Provider/index.ts +0 -3
- package/src/contexts/Schema/State.ts +0 -13
- package/src/contexts/Schema/index.ts +0 -4
- package/src/contexts/Schema/use.ts +0 -8
- package/src/contexts/index.ts +0 -1
- package/src/hooks/index.ts +0 -4
- package/src/hooks/stories/TestSchemaHooks.stories.tsx +0 -102
- package/src/hooks/useGetSchema.stories.tsx +0 -65
- package/src/hooks/useGetSchema.tsx +0 -57
- package/src/hooks/useSchemaDefinitions.tsx +0 -26
- package/src/hooks/useSchemaList.tsx +0 -35
- package/src/hooks/useSchemaStats.tsx +0 -62
- package/src/index.ts +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Property/SchemaProperty.tsx","../../src/components/SelectEx/SchemaSelectEx.tsx","../../src/contexts/Schema/Context.ts","../../src/contexts/Schema/Provider/Memory.tsx","../../src/hooks/useGetSchema.tsx","../../src/hooks/useSchemaDefinitions.tsx","../../src/hooks/useSchemaList.tsx","../../src/hooks/useSchemaStats.tsx","../../src/contexts/Schema/Provider/Route.tsx","../../src/contexts/Schema/use.ts"],"sourcesContent":["import {\n NewReleases as NewReleasesIcon, OpenInNew as OpenInNewIcon, Verified as VerifiedIcon,\n} from '@mui/icons-material'\nimport { IconButton } from '@mui/material'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { LinkEx } from '@xylabs/react-link'\nimport type { EventDispatch, EventNoun } from '@xyo-network/react-event'\nimport { useEvent } from '@xyo-network/react-event'\nimport type { PropertyProps } from '@xyo-network/react-property'\nimport { Property, PropertyValue } from '@xyo-network/react-property'\nimport type { SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport React, { useState } from 'react'\n\nexport type SchemaPropertyProps = PropertyProps & {\n showLinkNames?: boolean\n showOpenNewWindowLink?: boolean\n showStatusIcon?: boolean\n value?: string\n}\n\nconst useResolveSchema = (schema?: string) => {\n const [entry, setEntry] = useState<SchemaCacheEntry | null>()\n useAsyncEffect(\n async (mounted) => {\n if (schema) {\n const entry = await SchemaCache.instance.get(schema)\n if (mounted()) {\n setEntry(entry)\n }\n }\n },\n [schema],\n )\n return entry\n}\n\nexport const SchemaProperty: React.FC<SchemaPropertyProps> = ({\n showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props\n}) => {\n const resolvedSchema = useResolveSchema(value)\n const [buttonRef, buttonDispatch] = useEvent<HTMLButtonElement>()\n const [divRef, divDispatch] = useEvent<HTMLDivElement>()\n\n const onClick = (dispatch?: EventDispatch<EventNoun, 'click', string>, openNewWindow = false) => {\n dispatch?.(\n 'schema',\n 'click',\n JSON.stringify({\n openNewWindow,\n schema: value,\n }),\n )\n }\n\n return (\n <Property title=\"Schema\" value={value} tip=\"Schema sent with the payload\" titleProps={titleProps} {...props}>\n {value && showStatusIcon\n ? resolvedSchema === null\n ? (\n <IconButton\n ref={buttonRef}\n size=\"small\"\n onClick={() => {\n if (!buttonRef.current) {\n console.warn('buttonRef.current is null')\n }\n onClick(buttonDispatch)\n }}\n >\n <NewReleasesIcon color=\"warning\" fontSize=\"inherit\" />\n </IconButton>\n )\n : resolvedSchema === undefined\n ? (\n <IconButton\n ref={buttonRef}\n size=\"small\"\n onClick={() => {\n if (!buttonRef.current) {\n console.warn('buttonRef.current is null')\n }\n onClick(buttonDispatch)\n }}\n >\n <NewReleasesIcon color=\"disabled\" fontSize=\"inherit\" />\n </IconButton>\n )\n : (\n <IconButton rel=\"noopener noreferrer\" size=\"small\" target=\"_blank\" href={resolvedSchema?.huri?.href ?? ''}>\n <VerifiedIcon color=\"success\" fontSize=\"inherit\" />\n </IconButton>\n )\n\n : null}\n {value\n ? (\n <FlexGrowRow ref={divRef} justifyContent=\"space-between\">\n {showLinkNames\n ? (\n <LinkEx\n display=\"block\"\n width=\"100%\"\n sx={{ cursor: 'pointer' }}\n >\n <PropertyValue\n value={value}\n title=\"view schema\"\n onClick={() => {\n if (!divRef.current) {\n console.warn('divRef.current is null')\n }\n onClick(divDispatch)\n }}\n />\n </LinkEx>\n )\n : (\n <PropertyValue\n value={value}\n title=\"view schema\"\n onClick={() => {\n if (!divRef.current) {\n console.warn('divRef.current is null')\n }\n onClick(divDispatch)\n }}\n />\n )}\n {showOpenNewWindowLink\n ? (\n <IconButton\n ref={buttonRef}\n size=\"small\"\n onClick={() => {\n if (!buttonRef.current) {\n console.warn('buttonRef.current is null')\n }\n onClick(buttonDispatch, true)\n }}\n >\n <OpenInNewIcon fontSize=\"inherit\" />\n </IconButton>\n )\n : null}\n </FlexGrowRow>\n )\n : null}\n </Property>\n )\n}\n\nSchemaProperty.displayName = 'SchemaProperty'\n","import { MenuItem, Typography } from '@mui/material'\nimport type { SelectExProps } from '@xylabs/react-select'\nimport { SelectEx } from '@xylabs/react-select'\nimport React from 'react'\n\nimport { useSchema } from '../../contexts/index.ts'\n\nexport type SchemaSelectExProps = SelectExProps<string>\n\nexport const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({\n onChange, variant = 'outlined', ...props\n}) => {\n const {\n schema, setSchema, schemaList,\n } = useSchema(false)\n\n return (\n <SelectEx\n variant={variant}\n size=\"small\"\n value={schema ?? 'none'}\n onChange={(event, child) => {\n if (event.target.value !== schema) {\n onChange?.(event, child)\n setSchema?.(event.target.value)\n }\n }}\n renderValue={(value) => {\n return <Typography>{value === 'none' ? '- None -' : value}</Typography>\n }}\n {...props}\n >\n {schemaList?.map((schema) => {\n return (\n <MenuItem key={schemaList.indexOf(schema)} value={schema}>\n {schema}\n </MenuItem>\n )\n })}\n <MenuItem key=\"none\" value=\"none\">\n - None -\n </MenuItem>\n </SelectEx>\n )\n}\n","import { createContextEx } from '@xylabs/react-shared'\n\nimport type { SchemaContextState } from './State.ts'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { exists } from '@xylabs/sdk-js'\nimport type { PropsWithChildren } from 'react'\nimport React, {\n useEffect, useMemo, useState,\n} from 'react'\n\nimport { useSchemaStats } from '../../../hooks/index.ts'\nimport { SchemaContext } from '../Context.ts'\nimport type { SchemaContextState } from '../State.ts'\nimport type { SchemaProviderProps } from './Props.ts'\n\nexport const SchemaMemoryProvider: React.FC<PropsWithChildren<SchemaProviderProps>> = ({\n defaultSchema, knownSchemaList, ...props\n}) => {\n const [schema, setSchema] = useState(defaultSchema)\n const [schemaList, setSchemaList] = useState<string[] | undefined>(knownSchemaList)\n const [fetchedSchemaStats] = useSchemaStats()\n\n useEffect(() => {\n if (fetchedSchemaStats) {\n const schemaList = (fetchedSchemaStats.map(({ name }) => name)).filter(exists)\n setSchemaList(schemaList)\n }\n }, [fetchedSchemaStats])\n\n const value: SchemaContextState = useMemo(() => ({\n provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList,\n }), [schema, schemaList, knownSchemaList])\n\n return <SchemaContext value={value} {...props} />\n}\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { ModuleError, WithSources } from '@xyo-network/payload-model'\nimport { ModuleErrorSchema } from '@xyo-network/payload-model'\nimport type { SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { useState } from 'react'\n\n/**\n * Gets a Huri and schema payload from a schema string\n */\nconst useGetSchemaPayload = (schema?: string) => {\n const [notFound, setNotFound] = useState(false)\n const [xyoError, setXyoError] = useState<WithSources<ModuleError>>()\n const [schemaCacheEntry, setSchemaCacheEntry] = useState<SchemaCacheEntry | null | undefined>()\n const [schemaLocal, setSchemaLocal] = useState<string>()\n\n useAsyncEffect(\n async (mounted) => {\n const firstRequest = !notFound && !schemaCacheEntry && !xyoError\n const schemaChanged = schema !== schemaLocal\n\n if ((schema && firstRequest) || (schema && schemaChanged)) {\n try {\n const schemaCacheEntry = await SchemaCache.instance.get(schema)\n if (mounted()) {\n setSchemaCacheEntry(schemaCacheEntry)\n setNotFound(schemaCacheEntry === null || schemaCacheEntry === undefined)\n }\n } catch (e) {\n const error = e as Error\n console.error(e)\n if (mounted()) {\n setXyoError({\n message: error.message, schema: ModuleErrorSchema, $sources: [],\n })\n }\n }\n }\n if (schemaChanged) {\n setSchemaLocal(schema)\n }\n },\n [xyoError, notFound, schema, schemaLocal, schemaCacheEntry],\n )\n\n return {\n notFound,\n schemaHuri: schemaCacheEntry?.huri,\n schemaPayload:\n schemaCacheEntry ? new PayloadBuilder<SchemaPayload>(schemaCacheEntry?.payload).fields(schemaCacheEntry.payload).build() : schemaCacheEntry,\n xyoError,\n }\n}\n\nexport { useGetSchemaPayload }\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { useState } from 'react'\n\nexport type SchemaList = { name: string }\n\nexport const useSchemaDefinitions = (schemaList?: SchemaList[]): SchemaPayload[] | undefined => {\n const [schemaPayloads, setSchemaPayloads] = useState<SchemaPayload[]>()\n useAsyncEffect(\n async (mounted) => {\n if (schemaList) {\n const promiseResults = await Promise.allSettled(schemaList?.map(({ name }) => SchemaCache.instance.get(name)))\n if (mounted()) {\n setSchemaPayloads(\n promiseResults\n .map(result => (result.status === 'fulfilled' ? result.value?.payload : undefined))\n .filter(item => item !== undefined && item !== null) as SchemaPayload[],\n )\n }\n }\n },\n [schemaList],\n )\n return schemaPayloads\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport type { Address } from '@xylabs/sdk-js'\nimport type { SchemaListPayload, SchemaListQueryPayload } from '@xyo-network/diviner-schema-list-model'\nimport { SchemaListQuerySchema } from '@xyo-network/diviner-schema-list-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport { useMemo } from 'react'\n\nexport const useSchemaList = (address?: Address, nameOrAddress = 'SchemaListDiviner'): [SchemaListPayload | null | undefined, Error | undefined] => {\n const [diviner, divinerError] = useWeakDivinerFromNode(nameOrAddress)\n\n const query: SchemaListQueryPayload[] | undefined = useMemo(\n () =>\n address\n ? [\n {\n address,\n schema: SchemaListQuerySchema,\n },\n ]\n : undefined,\n [address],\n )\n\n const [schemaList, error] = usePromise(\n async () => {\n const divinerInstance = diviner?.deref()\n if (divinerInstance) {\n const response = (await divinerInstance.divine(query)) as SchemaListPayload[]\n return response.at(0)\n }\n },\n [diviner, divinerError, query],\n )\n return [schemaList, error]\n}\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { type Address, isDefined } from '@xylabs/sdk-js'\nimport type {\n SchemaStatsPayload,\n SchemaStatsQueryPayload,\n} from '@xyo-network/diviner-schema-stats-model'\nimport {\n SchemaStatsDivinerSchema,\n SchemaStatsQuerySchema,\n} from '@xyo-network/diviner-schema-stats-model'\nimport { TYPES } from '@xyo-network/node-core-types'\nimport type { WithSources } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useState } from 'react'\n\nexport const useSchemaStats = (\n statsAddress?: Address,\n nameOrAddress = TYPES.SchemaStatsDiviner,\n): [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>] => {\n const [refresh, setRefresh] = useState(1)\n const [diviner, divinerError] = useWeakDivinerFromNode(nameOrAddress)\n const [error, setError] = useState<Error>()\n const refreshHistory = () => setRefresh(previous => previous + 1)\n\n const [schemaList, setSchemaList] = useState<WithSources<SchemaStatsPayload>[]>()\n\n useAsyncEffect(\n async (mounted) => {\n const instance = diviner?.deref()\n if (isDefined(instance) && isDefined(statsAddress)) {\n if (divinerError) {\n if (mounted()) {\n setError(divinerError)\n setSchemaList(undefined)\n }\n } else {\n try {\n const query = {\n address: statsAddress,\n schema: SchemaStatsQuerySchema,\n }\n const schemas = (await instance.divine([query])).filter(isPayloadOfSchemaType(SchemaStatsDivinerSchema)) as WithSources<\n SchemaStatsPayload\n >[]\n if (mounted()) {\n setSchemaList(schemas)\n setError(undefined)\n }\n } catch (ex) {\n setError(ex as Error)\n setSchemaList(undefined)\n }\n }\n }\n },\n [diviner, refresh, divinerError, statsAddress],\n )\n\n return [schemaList, error, refreshHistory]\n}\n","import type { PropsWithChildren } from 'react'\nimport React, {\n useCallback, useEffect, useMemo,\n} from 'react'\nimport { useSearchParams } from 'react-router-dom'\n\nimport { SchemaContext } from '../Context.ts'\nimport type { SchemaContextState } from '../State.ts'\nimport { useSchema } from '../use.ts'\nimport { SchemaMemoryProvider } from './Memory.tsx'\nimport type { SchemaProviderProps } from './Props.ts'\n\nconst SchemaRouteProviderInner: React.FC<PropsWithChildren> = ({ children }) => {\n const {\n schema, setSchema, schemaList,\n } = useSchema()\n\n const [params, setParams] = useSearchParams()\n\n const routeSchema = params.get('schema')\n\n // update the network stored in the route\n const setSchemaParam = useCallback(\n (schema?: string) => {\n if (schema) {\n params.set('schema', schema)\n setParams(params, { replace: true })\n setSchema?.(schema)\n } else {\n params.delete('network')\n }\n },\n [params, setParams, setSchema],\n )\n\n // if the network is actively changed, update both memory and route\n const setSchemaLocal = useCallback(\n (schema: string) => {\n setSchemaParam(schema)\n setSchema?.(schema)\n },\n [setSchemaParam, setSchema],\n )\n\n // sync memory and route storage of network\n useEffect(() => {\n if (routeSchema !== schema) {\n if (routeSchema === undefined && schema !== undefined) {\n // if the route does not have a network selected, use what is in the memory context\n setSchemaLocal(schema)\n } else if (routeSchema) {\n // if the route has a selection and it is different from memory, update memory\n setSchema?.(routeSchema)\n }\n }\n }, [routeSchema, schema, setSchemaParam, setSchema, setSchemaLocal])\n\n const value: SchemaContextState = useMemo(() => ({\n provided: true, schema, schemaList, setSchema: setSchemaLocal,\n }), [schema, schemaList, setSchemaLocal])\n\n return <SchemaContext value={value}>{children}</SchemaContext>\n}\n\nexport const SchemaRouteProvider: React.FC<PropsWithChildren<SchemaProviderProps>> = ({\n knownSchemaList, defaultSchema, ...props\n}) => {\n return (\n <SchemaMemoryProvider knownSchemaList={knownSchemaList} defaultSchema={defaultSchema}>\n <SchemaRouteProviderInner {...props} />\n </SchemaMemoryProvider>\n )\n}\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { SchemaContext } from './Context.ts'\nimport type { SchemaContextState } from './State.ts'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":";;;;AAAA,SACEA,eAAeC,iBAAiBC,aAAaC,eAAeC,YAAYC,oBACnE;AACP,SAASC,kBAAkB;AAC3B,SAASC,sBAAsB;AAC/B,SAAS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U,UAAAA;MAASC,KAAKb,WAAWc,QAAQhB,OAAAA;MAASO,OAAOP;OAC/CA,OAAAA;EAGP,CAAA,GACA,gBAAAI,OAAA,cAACU,UAAAA;IAASC,KAAI;IAAOR,OAAM;KAAO,UAAA,CAAA;AAKxC,GAnC6D;","names":["NewReleases","NewReleasesIcon","OpenInNew","OpenInNewIcon","Verified","VerifiedIcon","IconButton","useAsyncEffect","FlexGrowRow","LinkEx","useEvent","Property","PropertyValue","SchemaCache","React","useState","useResolveSchema","schema","entry","setEntry","useState","useAsyncEffect","mounted","SchemaCache","instance","get","SchemaProperty","showLinkNames","showOpenNewWindowLink","showStatusIcon","titleProps","value","props","resolvedSchema","buttonRef","buttonDispatch","useEvent","divRef","divDispatch","onClick","dispatch","openNewWindow","JSON","stringify","Property","title","tip","IconButton","ref","size","current","console","warn","NewReleasesIcon","color","fontSize","undefined","rel","target","href","huri","VerifiedIcon","FlexGrowRow","justifyContent","LinkEx","display","width","sx","cursor","PropertyValue","OpenInNewIcon","displayName","MenuItem","Typography","SelectEx","React","createContextEx","SchemaContext","exists","React","useEffect","useMemo","useState","useAsyncEffect","PayloadBuilder","ModuleErrorSchema","SchemaCache","useState","useGetSchemaPayload","schema","notFound","setNotFound","useState","xyoError","setXyoError","schemaCacheEntry","setSchemaCacheEntry","schemaLocal","setSchemaLocal","useAsyncEffect","mounted","firstRequest","schemaChanged","SchemaCache","instance","get","undefined","e","error","console","message","ModuleErrorSchema","$sources","schemaHuri","huri","schemaPayload","PayloadBuilder","payload","fields","build","useAsyncEffect","SchemaCache","useState","useSchemaDefinitions","schemaList","schemaPayloads","setSchemaPayloads","useState","useAsyncEffect","mounted","promiseResults","Promise","allSettled","map","name","SchemaCache","instance","get","result","status","value","payload","undefined","filter","item","usePromise","SchemaListQuerySchema","useWeakDivinerFromNode","useMemo","useSchemaList","address","nameOrAddress","diviner","divinerError","useWeakDivinerFromNode","query","useMemo","schema","SchemaListQuerySchema","undefined","schemaList","error","usePromise","divinerInstance","deref","response","divine","at","useAsyncEffect","isDefined","SchemaStatsDivinerSchema","SchemaStatsQuerySchema","TYPES","isPayloadOfSchemaType","useWeakDivinerFromNode","useState","useSchemaStats","statsAddress","nameOrAddress","TYPES","SchemaStatsDiviner","refresh","setRefresh","useState","diviner","divinerError","useWeakDivinerFromNode","error","setError","refreshHistory","previous","schemaList","setSchemaList","useAsyncEffect","mounted","instance","deref","isDefined","undefined","query","address","schema","SchemaStatsQuerySchema","schemas","divine","filter","isPayloadOfSchemaType","SchemaStatsDivinerSchema","ex","SchemaMemoryProvider","defaultSchema","knownSchemaList","props","schema","setSchema","useState","schemaList","setSchemaList","fetchedSchemaStats","useSchemaStats","useEffect","map","name","filter","exists","value","useMemo","provided","React","SchemaContext","React","useCallback","useEffect","useMemo","useSearchParams","useContextEx","useSchema","required","useContextEx","SchemaContext","SchemaRouteProviderInner","children","schema","setSchema","schemaList","useSchema","params","setParams","useSearchParams","routeSchema","get","setSchemaParam","useCallback","set","replace","delete","setSchemaLocal","useEffect","undefined","value","useMemo","provided","React","SchemaContext","SchemaRouteProvider","knownSchemaList","defaultSchema","props","SchemaMemoryProvider","SchemaSelectEx","onChange","variant","props","schema","setSchema","schemaList","useSchema","React","SelectEx","size","value","event","child","target","renderValue","Typography","map","MenuItem","key","indexOf"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/Property/SchemaProperty.tsx","../../src/components/SelectEx/SchemaSelectEx.tsx","../../src/contexts/Schema/Context.ts","../../src/contexts/Schema/Provider/Memory.tsx","../../src/hooks/useGetSchema.tsx","../../src/hooks/useSchemaDefinitions.tsx","../../src/hooks/useSchemaList.tsx","../../src/hooks/useSchemaStats.tsx","../../src/contexts/Schema/Provider/Route.tsx","../../src/contexts/Schema/use.ts"],"sourcesContent":["import {\n NewReleases as NewReleasesIcon, OpenInNew as OpenInNewIcon, Verified as VerifiedIcon,\n} from '@mui/icons-material'\nimport { IconButton } from '@mui/material'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { LinkEx } from '@xylabs/react-link'\nimport type { EventDispatch, EventNoun } from '@xyo-network/react-event'\nimport { useEvent } from '@xyo-network/react-event'\nimport type { PropertyProps } from '@xyo-network/react-property'\nimport { Property, PropertyValue } from '@xyo-network/react-property'\nimport type { SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport React, { useState } from 'react'\n\nexport type SchemaPropertyProps = PropertyProps & {\n showLinkNames?: boolean\n showOpenNewWindowLink?: boolean\n showStatusIcon?: boolean\n value?: string\n}\n\nconst useResolveSchema = (schema?: string) => {\n const [entry, setEntry] = useState<SchemaCacheEntry | null>()\n useAsyncEffect(\n async (mounted) => {\n if (schema) {\n const entry = await SchemaCache.instance.get(schema)\n if (mounted()) {\n setEntry(entry)\n }\n }\n },\n [schema],\n )\n return entry\n}\n\nexport const SchemaProperty: React.FC<SchemaPropertyProps> = ({\n showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props\n}) => {\n const resolvedSchema = useResolveSchema(value)\n const [buttonRef, buttonDispatch] = useEvent<HTMLButtonElement>()\n const [divRef, divDispatch] = useEvent<HTMLDivElement>()\n\n const onClick = (dispatch?: EventDispatch<EventNoun, 'click', string>, openNewWindow = false) => {\n dispatch?.(\n 'schema',\n 'click',\n JSON.stringify({\n openNewWindow,\n schema: value,\n }),\n )\n }\n\n return (\n <Property title=\"Schema\" value={value} tip=\"Schema sent with the payload\" titleProps={titleProps} {...props}>\n {value && showStatusIcon\n ? resolvedSchema === null\n ? (\n <IconButton\n ref={buttonRef}\n size=\"small\"\n onClick={() => {\n if (!buttonRef.current) {\n console.warn('buttonRef.current is null')\n }\n onClick(buttonDispatch)\n }}\n >\n <NewReleasesIcon color=\"warning\" fontSize=\"inherit\" />\n </IconButton>\n )\n : resolvedSchema === undefined\n ? (\n <IconButton\n ref={buttonRef}\n size=\"small\"\n onClick={() => {\n if (!buttonRef.current) {\n console.warn('buttonRef.current is null')\n }\n onClick(buttonDispatch)\n }}\n >\n <NewReleasesIcon color=\"disabled\" fontSize=\"inherit\" />\n </IconButton>\n )\n : (\n <IconButton rel=\"noopener noreferrer\" size=\"small\" target=\"_blank\" href={resolvedSchema?.huri?.href ?? ''}>\n <VerifiedIcon color=\"success\" fontSize=\"inherit\" />\n </IconButton>\n )\n\n : null}\n {value\n ? (\n <FlexGrowRow ref={divRef} justifyContent=\"space-between\">\n {showLinkNames\n ? (\n <LinkEx\n display=\"block\"\n width=\"100%\"\n sx={{ cursor: 'pointer' }}\n >\n <PropertyValue\n value={value}\n title=\"view schema\"\n onClick={() => {\n if (!divRef.current) {\n console.warn('divRef.current is null')\n }\n onClick(divDispatch)\n }}\n />\n </LinkEx>\n )\n : (\n <PropertyValue\n value={value}\n title=\"view schema\"\n onClick={() => {\n if (!divRef.current) {\n console.warn('divRef.current is null')\n }\n onClick(divDispatch)\n }}\n />\n )}\n {showOpenNewWindowLink\n ? (\n <IconButton\n ref={buttonRef}\n size=\"small\"\n onClick={() => {\n if (!buttonRef.current) {\n console.warn('buttonRef.current is null')\n }\n onClick(buttonDispatch, true)\n }}\n >\n <OpenInNewIcon fontSize=\"inherit\" />\n </IconButton>\n )\n : null}\n </FlexGrowRow>\n )\n : null}\n </Property>\n )\n}\n\nSchemaProperty.displayName = 'SchemaProperty'\n","import { MenuItem, Typography } from '@mui/material'\nimport type { SelectExProps } from '@xylabs/react-select'\nimport { SelectEx } from '@xylabs/react-select'\nimport React from 'react'\n\nimport { useSchema } from '../../contexts/index.ts'\n\nexport type SchemaSelectExProps = SelectExProps<string>\n\nexport const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({\n onChange, variant = 'outlined', ...props\n}) => {\n const {\n schema, setSchema, schemaList,\n } = useSchema(false)\n\n return (\n <SelectEx\n variant={variant}\n size=\"small\"\n value={schema ?? 'none'}\n onChange={(event, child) => {\n if (event.target.value !== schema) {\n onChange?.(event, child)\n setSchema?.(event.target.value)\n }\n }}\n renderValue={(value) => {\n return <Typography>{value === 'none' ? '- None -' : value}</Typography>\n }}\n {...props}\n >\n {schemaList?.map((schema) => {\n return (\n <MenuItem key={schemaList.indexOf(schema)} value={schema}>\n {schema}\n </MenuItem>\n )\n })}\n <MenuItem key=\"none\" value=\"none\">\n - None -\n </MenuItem>\n </SelectEx>\n )\n}\n","import { createContextEx } from '@xylabs/react-shared'\n\nimport type { SchemaContextState } from './State.ts'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { exists } from '@xylabs/sdk-js'\nimport type { PropsWithChildren } from 'react'\nimport React, {\n useEffect, useMemo, useState,\n} from 'react'\n\nimport { useSchemaStats } from '../../../hooks/index.ts'\nimport { SchemaContext } from '../Context.ts'\nimport type { SchemaContextState } from '../State.ts'\nimport type { SchemaProviderProps } from './Props.ts'\n\nexport const SchemaMemoryProvider: React.FC<PropsWithChildren<SchemaProviderProps>> = ({\n defaultSchema, knownSchemaList, ...props\n}) => {\n const [schema, setSchema] = useState(defaultSchema)\n const [schemaList, setSchemaList] = useState<string[] | undefined>(knownSchemaList)\n const [fetchedSchemaStats] = useSchemaStats()\n\n useEffect(() => {\n if (fetchedSchemaStats) {\n const newSchemaList = (fetchedSchemaStats.map(({ name }) => name)).filter(exists)\n // eslint-disable-next-line react-x/set-state-in-effect, react-hooks/set-state-in-effect\n setSchemaList(newSchemaList)\n }\n }, [fetchedSchemaStats])\n\n const value: SchemaContextState = useMemo(() => ({\n provided: true as const, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList,\n }), [schema, schemaList, knownSchemaList])\n\n return <SchemaContext value={value} {...props} />\n}\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { ModuleError, WithSources } from '@xyo-network/payload-model'\nimport { ModuleErrorSchema } from '@xyo-network/payload-model'\nimport type { SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { useState } from 'react'\n\nexport interface UseGetSchemaPayloadResult {\n notFound: boolean\n schemaHuri: SchemaCacheEntry['huri'] | undefined\n schemaPayload: SchemaPayload | null | undefined\n xyoError: WithSources<ModuleError> | undefined\n}\n\n/**\n * Gets a Huri and schema payload from a schema string\n */\nconst useGetSchemaPayload = (schema?: string): UseGetSchemaPayloadResult => {\n const [notFound, setNotFound] = useState(false)\n const [xyoError, setXyoError] = useState<WithSources<ModuleError>>()\n const [schemaCacheEntry, setSchemaCacheEntry] = useState<SchemaCacheEntry | null | undefined>()\n const [schemaLocal, setSchemaLocal] = useState<string>()\n\n useAsyncEffect(\n async (mounted) => {\n const firstRequest = !notFound && !schemaCacheEntry && !xyoError\n const schemaChanged = schema !== schemaLocal\n\n if ((schema && firstRequest) || (schema && schemaChanged)) {\n try {\n const schemaCacheEntry = await SchemaCache.instance.get(schema)\n if (mounted()) {\n setSchemaCacheEntry(schemaCacheEntry)\n setNotFound(schemaCacheEntry === null || schemaCacheEntry === undefined)\n }\n } catch (e) {\n const error = e as Error\n console.error(e)\n if (mounted()) {\n setXyoError({\n message: error.message, schema: ModuleErrorSchema, $sources: [],\n })\n }\n }\n }\n if (schemaChanged) {\n setSchemaLocal(schema)\n }\n },\n [xyoError, notFound, schema, schemaLocal, schemaCacheEntry],\n )\n\n return {\n notFound,\n schemaHuri: schemaCacheEntry?.huri,\n schemaPayload:\n schemaCacheEntry ? new PayloadBuilder<SchemaPayload>(schemaCacheEntry?.payload).fields(schemaCacheEntry.payload).build() : schemaCacheEntry,\n xyoError,\n }\n}\n\nexport { useGetSchemaPayload }\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { useState } from 'react'\n\nexport interface SchemaList { name: string }\n\nexport const useSchemaDefinitions = (schemaList?: SchemaList[]): SchemaPayload[] | undefined => {\n const [schemaPayloads, setSchemaPayloads] = useState<SchemaPayload[]>()\n useAsyncEffect(\n async (mounted) => {\n if (schemaList) {\n const promiseResults = await Promise.allSettled(schemaList?.map(({ name }) => SchemaCache.instance.get(name)))\n if (mounted()) {\n setSchemaPayloads(\n promiseResults\n .map(result => (result.status === 'fulfilled' ? result.value?.payload : undefined))\n .filter(item => item !== undefined && item !== null) as SchemaPayload[],\n )\n }\n }\n },\n [schemaList],\n )\n return schemaPayloads\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport type { Address } from '@xylabs/sdk-js'\nimport type { SchemaListPayload, SchemaListQueryPayload } from '@xyo-network/diviner-schema-list'\nimport { SchemaListQuerySchema } from '@xyo-network/diviner-schema-list'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport { useMemo } from 'react'\n\nexport const useSchemaList = (address?: Address, nameOrAddress = 'SchemaListDiviner'): [SchemaListPayload | null | undefined, Error | undefined] => {\n const [diviner, divinerError] = useWeakDivinerFromNode(nameOrAddress)\n\n const query: SchemaListQueryPayload[] | undefined = useMemo(\n () =>\n address\n ? [\n {\n address,\n schema: SchemaListQuerySchema,\n },\n ]\n : undefined,\n [address],\n )\n\n const [schemaList, error] = usePromise(\n async () => {\n const divinerInstance = diviner?.deref()\n if (divinerInstance) {\n const response = (await divinerInstance.divine(query)) as SchemaListPayload[]\n return response.at(0)\n }\n },\n [diviner, divinerError, query],\n )\n return [schemaList, error]\n}\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { type Address, isDefined } from '@xylabs/sdk-js'\nimport type { SchemaStatsPayload } from '@xyo-network/diviner-schema-stats'\nimport {\n SchemaStatsDivinerSchema,\n SchemaStatsQuerySchema,\n} from '@xyo-network/diviner-schema-stats'\nimport { TYPES } from '@xyo-network/node-core-types'\nimport type { WithSources } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useState } from 'react'\n\nexport const useSchemaStats = (\n statsAddress?: Address,\n nameOrAddress = TYPES.SchemaStatsDiviner,\n): [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>] => {\n const [refresh, setRefresh] = useState(1)\n const [diviner, divinerError] = useWeakDivinerFromNode(nameOrAddress)\n const [error, setError] = useState<Error>()\n const refreshHistory = () => setRefresh(previous => previous + 1)\n\n const [schemaList, setSchemaList] = useState<WithSources<SchemaStatsPayload>[]>()\n\n useAsyncEffect(\n async (mounted) => {\n const instance = diviner?.deref()\n if (isDefined(instance) && isDefined(statsAddress)) {\n if (divinerError) {\n if (mounted()) {\n setError(divinerError)\n setSchemaList(undefined)\n }\n } else {\n try {\n const query = {\n address: statsAddress,\n schema: SchemaStatsQuerySchema,\n }\n const schemas = (await instance.divine([query])).filter(isPayloadOfSchemaType(SchemaStatsDivinerSchema)) as WithSources<\n SchemaStatsPayload\n >[]\n if (mounted()) {\n setSchemaList(schemas)\n setError(undefined)\n }\n } catch (ex) {\n setError(ex as Error)\n setSchemaList(undefined)\n }\n }\n }\n },\n [diviner, refresh, divinerError, statsAddress],\n )\n\n return [schemaList, error, refreshHistory]\n}\n","import type { PropsWithChildren } from 'react'\nimport React, {\n useCallback, useEffect, useMemo,\n} from 'react'\nimport { useSearchParams } from 'react-router-dom'\n\nimport { SchemaContext } from '../Context.ts'\nimport type { SchemaContextState } from '../State.ts'\nimport { useSchema } from '../use.ts'\nimport { SchemaMemoryProvider } from './Memory.tsx'\nimport type { SchemaProviderProps } from './Props.ts'\n\nconst SchemaRouteProviderInner: React.FC<PropsWithChildren> = ({ children }) => {\n const {\n schema, setSchema, schemaList,\n } = useSchema()\n\n const [params, setParams] = useSearchParams()\n\n const routeSchema = params.get('schema')\n\n // update the network stored in the route\n const setSchemaParam = useCallback(\n (schema?: string) => {\n if (schema) {\n params.set('schema', schema)\n setParams(params, { replace: true })\n setSchema?.(schema)\n } else {\n params.delete('network')\n }\n },\n [params, setParams, setSchema],\n )\n\n // if the network is actively changed, update both memory and route\n const setSchemaLocal = useCallback(\n (schema: string) => {\n setSchemaParam(schema)\n setSchema?.(schema)\n },\n [setSchemaParam, setSchema],\n )\n\n // sync memory and route storage of network\n useEffect(() => {\n if (routeSchema !== schema) {\n if (routeSchema === undefined && schema !== undefined) {\n // if the route does not have a network selected, use what is in the memory context\n setSchemaLocal(schema)\n } else if (routeSchema) {\n // if the route has a selection and it is different from memory, update memory\n setSchema?.(routeSchema)\n }\n }\n }, [routeSchema, schema, setSchemaParam, setSchema, setSchemaLocal])\n\n const value: SchemaContextState = useMemo(() => ({\n provided: true, schema, schemaList, setSchema: setSchemaLocal,\n }), [schema, schemaList, setSchemaLocal])\n\n return <SchemaContext value={value}>{children}</SchemaContext>\n}\n\nexport const SchemaRouteProvider: React.FC<PropsWithChildren<SchemaProviderProps>> = ({\n knownSchemaList, defaultSchema, ...props\n}) => {\n return (\n <SchemaMemoryProvider knownSchemaList={knownSchemaList} defaultSchema={defaultSchema}>\n <SchemaRouteProviderInner {...props} />\n </SchemaMemoryProvider>\n )\n}\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { SchemaContext } from './Context.ts'\nimport type { SchemaContextState } from './State.ts'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":";AAAA;AAAA,EACE,eAAe;AAAA,EAAiB,aAAa;AAAA,EAAe,YAAY;AAAA,OACnE;AACP,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AAEvB,SAAS,gBAAgB;AAEzB,SAAS,UAAU,qBAAqB;AAExC,SAAS,mBAAmB;AAC5B,SAAgB,gBAAgB;AA0DhB,cA2BJ,YA3BI;AAjDhB,IAAM,mBAAmB,CAAC,WAAoB;AAC5C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAkC;AAC5D;AAAA,IACE,OAAO,YAAY;AACjB,UA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A,aAAa,CAAC,UAAU;AACtB,eAAO,gBAAAD,KAAC,cAAY,oBAAU,SAAS,aAAa,OAAM;AAAA,MAC5D;AAAA,MACC,GAAG;AAAA,MAEH;AAAA,oBAAY,IAAI,CAACE,YAAW;AAC3B,iBACE,gBAAAF,KAAC,YAA0C,OAAOE,SAC/C,UAAAA,WADY,WAAW,QAAQA,OAAM,CAExC;AAAA,QAEJ,CAAC;AAAA,QACD,gBAAAF,KAAC,YAAoB,OAAM,QAAO,wBAApB,MAEd;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["entry","useMemo","useState","useAsyncEffect","SchemaCache","useState","schemaCacheEntry","useAsyncEffect","SchemaCache","useState","useAsyncEffect","useWeakDivinerFromNode","useState","jsx","useState","useMemo","useEffect","useMemo","jsx","schema","useEffect","useMemo","jsx","jsxs","schema"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/react-schema",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.12",
|
|
4
4
|
"description": "Common React library for all XYO projects that use React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xyo",
|
|
@@ -36,74 +36,177 @@
|
|
|
36
36
|
},
|
|
37
37
|
"./package.json": "./package.json"
|
|
38
38
|
},
|
|
39
|
-
"module": "dist/browser/index.mjs",
|
|
40
|
-
"types": "dist/browser/index.d.ts",
|
|
41
39
|
"files": [
|
|
42
40
|
"dist",
|
|
43
|
-
"
|
|
41
|
+
"README.md"
|
|
44
42
|
],
|
|
45
43
|
"dependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"@xylabs/react-promise": "~7.1.17",
|
|
50
|
-
"@xylabs/react-select": "~7.1.17",
|
|
51
|
-
"@xylabs/react-shared": "~7.1.17",
|
|
52
|
-
"@xylabs/sdk-js": "~5.0.90",
|
|
53
|
-
"@xyo-network/diviner-schema-list-model": "~5.3.17",
|
|
54
|
-
"@xyo-network/diviner-schema-stats-model": "~5.3.17",
|
|
55
|
-
"@xyo-network/node-core-types": "~4.1.7",
|
|
56
|
-
"@xyo-network/payload-builder": "~5.3.17",
|
|
57
|
-
"@xyo-network/payload-model": "~5.3.17",
|
|
58
|
-
"@xyo-network/react-diviner": "7.5.8",
|
|
59
|
-
"@xyo-network/react-event": "7.5.8",
|
|
60
|
-
"@xyo-network/react-property": "7.5.8",
|
|
61
|
-
"@xyo-network/schema-cache": "~5.3.17",
|
|
62
|
-
"@xyo-network/schema-payload-plugin": "~5.3.17",
|
|
63
|
-
"react-router-dom": "^7.13.2"
|
|
44
|
+
"@xyo-network/react-diviner": "~7.5.12",
|
|
45
|
+
"@xyo-network/react-event": "~7.5.12",
|
|
46
|
+
"@xyo-network/react-property": "~7.5.12"
|
|
64
47
|
},
|
|
65
48
|
"devDependencies": {
|
|
66
|
-
"@
|
|
67
|
-
"@emotion/
|
|
68
|
-
"@
|
|
69
|
-
"@mui/material": "
|
|
70
|
-
"@
|
|
49
|
+
"@bitauth/libauth": "~3.0.0",
|
|
50
|
+
"@emotion/react": "^11.14.0",
|
|
51
|
+
"@emotion/styled": "^11.14.1",
|
|
52
|
+
"@mui/icons-material": "^7.3.10",
|
|
53
|
+
"@mui/material": "^7.3.10",
|
|
54
|
+
"@mui/system": "^7.3.10",
|
|
55
|
+
"@mui/x-tree-view": "~8.27.2",
|
|
56
|
+
"@opentelemetry/api": "^1.9.1",
|
|
57
|
+
"@opentelemetry/sdk-trace-base": "^2.7.0",
|
|
58
|
+
"@scure/base": "~2.2.0",
|
|
59
|
+
"@scure/bip39": "~2.2.0",
|
|
60
|
+
"@storybook/react-vite": "~10.3.5",
|
|
61
|
+
"@textea/json-viewer": "~4.0.1",
|
|
62
|
+
"@types/node": "~25.6.0",
|
|
71
63
|
"@types/react": "^19.2.14",
|
|
72
|
-
"@xylabs/react-
|
|
73
|
-
"@xylabs/react-
|
|
74
|
-
"@xylabs/
|
|
75
|
-
"@xylabs/
|
|
76
|
-
"@xylabs/
|
|
77
|
-
"@xylabs/
|
|
78
|
-
"@xylabs/
|
|
79
|
-
"@xylabs/
|
|
80
|
-
"@
|
|
81
|
-
"@
|
|
82
|
-
"@
|
|
83
|
-
"@
|
|
84
|
-
"@
|
|
85
|
-
"@
|
|
86
|
-
"@
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
64
|
+
"@xylabs/react-async-effect": "~7.1.20",
|
|
65
|
+
"@xylabs/react-button": "~7.1.20",
|
|
66
|
+
"@xylabs/react-crypto": "~7.1.20",
|
|
67
|
+
"@xylabs/react-dialogs": "~7.1.20",
|
|
68
|
+
"@xylabs/react-flexbox": "~7.1.20",
|
|
69
|
+
"@xylabs/react-hooks": "~7.1.20",
|
|
70
|
+
"@xylabs/react-identicon": "~7.1.20",
|
|
71
|
+
"@xylabs/react-link": "~7.1.20",
|
|
72
|
+
"@xylabs/react-number-status": "~7.1.20",
|
|
73
|
+
"@xylabs/react-promise": "~7.1.20",
|
|
74
|
+
"@xylabs/react-quick-tip-button": "~7.1.20",
|
|
75
|
+
"@xylabs/react-select": "~7.1.20",
|
|
76
|
+
"@xylabs/react-shared": "~7.1.20",
|
|
77
|
+
"@xylabs/react-theme": "~7.1.20",
|
|
78
|
+
"@xylabs/sdk-js": "^5.0.100",
|
|
79
|
+
"@xylabs/threads": "~5.0.100",
|
|
80
|
+
"@xylabs/toolchain": "~7.11.9",
|
|
81
|
+
"@xylabs/tsconfig": "^7.11.9",
|
|
82
|
+
"@xylabs/tsconfig-dom": "^7.11.9",
|
|
83
|
+
"@xylabs/tsconfig-react": "~7.11.9",
|
|
84
|
+
"@xylabs/zod": "~5.0.100",
|
|
85
|
+
"@xyo-network/account": "~5.5.1",
|
|
86
|
+
"@xyo-network/account-model": "^5.5.1",
|
|
87
|
+
"@xyo-network/boundwitness-builder": "^5.5.1",
|
|
88
|
+
"@xyo-network/boundwitness-model": "^5.5.1",
|
|
89
|
+
"@xyo-network/boundwitness-validator": "^5.5.1",
|
|
90
|
+
"@xyo-network/boundwitness-wrapper": "~5.5.1",
|
|
91
|
+
"@xyo-network/bridge-http": "~5.5.5",
|
|
92
|
+
"@xyo-network/config-payload-plugin": "~5.5.1",
|
|
93
|
+
"@xyo-network/diviner-model": "^5.5.5",
|
|
94
|
+
"@xyo-network/diviner-schema-list": "~5.5.5",
|
|
95
|
+
"@xyo-network/diviner-schema-stats": "~5.5.2",
|
|
96
|
+
"@xyo-network/manifest-model": "~5.5.1",
|
|
97
|
+
"@xyo-network/module-abstract": "^5.5.5",
|
|
98
|
+
"@xyo-network/module-model": "^5.5.5",
|
|
99
|
+
"@xyo-network/network": "~5.5.1",
|
|
100
|
+
"@xyo-network/node-core-types": "~4.1.10",
|
|
101
|
+
"@xyo-network/node-memory": "~5.5.5",
|
|
102
|
+
"@xyo-network/node-model": "^5.5.5",
|
|
103
|
+
"@xyo-network/payload-builder": "^5.5.1",
|
|
104
|
+
"@xyo-network/payload-model": "^5.5.1",
|
|
105
|
+
"@xyo-network/query-payload-plugin": "~5.5.1",
|
|
106
|
+
"@xyo-network/schema-cache": "~5.5.1",
|
|
107
|
+
"@xyo-network/schema-payload-plugin": "~5.5.1",
|
|
108
|
+
"@xyo-network/typeof": "~5.3.30",
|
|
109
|
+
"@xyo-network/wallet": "~5.5.1",
|
|
110
|
+
"@xyo-network/wallet-model": "^5.5.1",
|
|
111
|
+
"ajv": "^8.18.0",
|
|
112
|
+
"async-mutex": "^0.5.0",
|
|
113
|
+
"axios": "^1.15.2",
|
|
114
|
+
"bn.js": "^5.2.3",
|
|
115
|
+
"bowser": "^2.14.1",
|
|
116
|
+
"buffer": "^6.0.3",
|
|
117
|
+
"chalk": "^5.6.2",
|
|
118
|
+
"debug": "~4.4.3",
|
|
119
|
+
"esbuild": "~0.28.0",
|
|
120
|
+
"eslint": "^10.2.1",
|
|
121
|
+
"ethers": "^6.16.0",
|
|
122
|
+
"fast-deep-equal": "~3.1.3",
|
|
123
|
+
"hash-wasm": "~4.12.0",
|
|
124
|
+
"js-cookie": "~3.0.5",
|
|
125
|
+
"lru-cache": "^11.3.5",
|
|
126
|
+
"observable-fns": "~0.6.1",
|
|
127
|
+
"pako": "^2.1.0",
|
|
128
|
+
"react": "^19.2.5",
|
|
129
|
+
"react-dom": "^19.2.5",
|
|
130
|
+
"react-router-dom": "^7.14.2",
|
|
131
|
+
"spark-md5": "~3.0.2",
|
|
132
|
+
"storybook": "^10.3.5",
|
|
90
133
|
"typescript": "^5.9.3",
|
|
91
|
-
"vite": "
|
|
92
|
-
"
|
|
134
|
+
"vite": "^8.0.10",
|
|
135
|
+
"wasm-feature-detect": "~1.8.0",
|
|
136
|
+
"zod": "^4.3.6",
|
|
137
|
+
"@xyo-network/react-payload-raw-info": "~7.5.12",
|
|
138
|
+
"@xyo-network/react-node": "~7.5.12",
|
|
139
|
+
"@xyo-network/react-storybook": "~7.5.12",
|
|
140
|
+
"@xyo-network/react-wallet": "~7.5.12"
|
|
93
141
|
},
|
|
94
142
|
"peerDependencies": {
|
|
95
|
-
"@
|
|
96
|
-
"@mui/material": "
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
143
|
+
"@emotion/react": "^11.14.0",
|
|
144
|
+
"@mui/icons-material": "^7.3.10",
|
|
145
|
+
"@mui/material": "^7.3.10",
|
|
146
|
+
"@mui/system": "^7.3.10",
|
|
147
|
+
"@mui/x-tree-view": "~8.27.2",
|
|
148
|
+
"@opentelemetry/api": "^1.9.1",
|
|
149
|
+
"@opentelemetry/sdk-trace-base": "^2.7.0",
|
|
150
|
+
"@scure/base": "~2.2.0",
|
|
151
|
+
"@xylabs/react-async-effect": "~7.1.20",
|
|
152
|
+
"@xylabs/react-button": "~7.1.20",
|
|
153
|
+
"@xylabs/react-dialogs": "~7.1.20",
|
|
154
|
+
"@xylabs/react-flexbox": "~7.1.20",
|
|
155
|
+
"@xylabs/react-hooks": "~7.1.20",
|
|
156
|
+
"@xylabs/react-identicon": "~7.1.20",
|
|
157
|
+
"@xylabs/react-link": "~7.1.20",
|
|
158
|
+
"@xylabs/react-promise": "~7.1.20",
|
|
159
|
+
"@xylabs/react-quick-tip-button": "~7.1.20",
|
|
160
|
+
"@xylabs/react-select": "~7.1.20",
|
|
161
|
+
"@xylabs/react-shared": "~7.1.20",
|
|
162
|
+
"@xylabs/react-theme": "~7.1.20",
|
|
163
|
+
"@xylabs/sdk-js": "^5.0.100",
|
|
164
|
+
"@xylabs/tsconfig": "^7.11.9",
|
|
165
|
+
"@xylabs/tsconfig-dom": "^7.11.9",
|
|
166
|
+
"@xylabs/zod": "~5.0.100",
|
|
167
|
+
"@xyo-network/account": "~5.5.1",
|
|
168
|
+
"@xyo-network/account-model": "^5.5.1",
|
|
169
|
+
"@xyo-network/boundwitness-builder": "^5.5.1",
|
|
170
|
+
"@xyo-network/boundwitness-model": "^5.5.1",
|
|
171
|
+
"@xyo-network/boundwitness-validator": "^5.5.1",
|
|
172
|
+
"@xyo-network/boundwitness-wrapper": "~5.5.1",
|
|
173
|
+
"@xyo-network/config-payload-plugin": "~5.5.1",
|
|
174
|
+
"@xyo-network/diviner-model": "^5.5.5",
|
|
175
|
+
"@xyo-network/diviner-schema-list": "~5.5.5",
|
|
176
|
+
"@xyo-network/diviner-schema-stats": "~5.5.2",
|
|
177
|
+
"@xyo-network/manifest-model": "~5.5.1",
|
|
178
|
+
"@xyo-network/module-abstract": "^5.5.5",
|
|
179
|
+
"@xyo-network/module-model": "^5.5.5",
|
|
180
|
+
"@xyo-network/node-core-types": "~4.1.10",
|
|
181
|
+
"@xyo-network/node-memory": "~5.5.5",
|
|
182
|
+
"@xyo-network/node-model": "^5.5.5",
|
|
183
|
+
"@xyo-network/payload-builder": "^5.5.1",
|
|
184
|
+
"@xyo-network/payload-model": "^5.5.1",
|
|
185
|
+
"@xyo-network/query-payload-plugin": "~5.5.1",
|
|
186
|
+
"@xyo-network/schema-cache": "~5.5.1",
|
|
187
|
+
"@xyo-network/schema-payload-plugin": "~5.5.1",
|
|
188
|
+
"@xyo-network/typeof": "~5.3.30",
|
|
189
|
+
"@xyo-network/wallet-model": "^5.5.1",
|
|
190
|
+
"ajv": "^8.18.0",
|
|
191
|
+
"async-mutex": "^0.5.0",
|
|
192
|
+
"axios": "^1.15.2",
|
|
193
|
+
"bn.js": "^5.2.3",
|
|
194
|
+
"bowser": "^2.14.1",
|
|
195
|
+
"buffer": "^6.0.3",
|
|
196
|
+
"chalk": "^5.6.2",
|
|
197
|
+
"ethers": "^6.16.0",
|
|
198
|
+
"fast-deep-equal": "~3.1.3",
|
|
199
|
+
"js-cookie": "~3.0.5",
|
|
200
|
+
"lru-cache": "^11.3.5",
|
|
201
|
+
"pako": "^2.1.0",
|
|
202
|
+
"react": "^19.2.5",
|
|
203
|
+
"react-dom": "^19.2.5",
|
|
204
|
+
"react-router-dom": "^7.14.2",
|
|
205
|
+
"spark-md5": "~3.0.2",
|
|
206
|
+
"zod": "^4.3.6"
|
|
104
207
|
},
|
|
105
208
|
"publishConfig": {
|
|
106
209
|
"access": "public"
|
|
107
210
|
},
|
|
108
211
|
"docs": "dist/docs.json"
|
|
109
|
-
}
|
|
212
|
+
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryFn } from '@storybook/react-vite'
|
|
2
|
-
import { useEvent } from '@xyo-network/react-event'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
|
|
5
|
-
import type { SchemaPropertyProps } from './SchemaProperty.tsx'
|
|
6
|
-
import { SchemaProperty } from './SchemaProperty.tsx'
|
|
7
|
-
|
|
8
|
-
const StorybookEntry: Meta = {
|
|
9
|
-
component: SchemaProperty,
|
|
10
|
-
parameters: { docs: { page: null } },
|
|
11
|
-
title: 'Schema/SchemaProperty',
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const Template: StoryFn = (args: SchemaPropertyProps) => {
|
|
15
|
-
const [ref] = useEvent<HTMLDivElement>((noun, verb, data) => {
|
|
16
|
-
console.log(`${noun}|${verb}|${data}`)
|
|
17
|
-
})
|
|
18
|
-
return (
|
|
19
|
-
<div ref={ref}>
|
|
20
|
-
<SchemaProperty {...args} />
|
|
21
|
-
</div>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const Default = Template.bind({})
|
|
26
|
-
Default.args = {}
|
|
27
|
-
|
|
28
|
-
const WithVerifiedValue = Template.bind({})
|
|
29
|
-
WithVerifiedValue.args = { value: 'network.xyo.schema' }
|
|
30
|
-
|
|
31
|
-
const WithVerifiedValuePaper = Template.bind({})
|
|
32
|
-
WithVerifiedValuePaper.args = { paper: true, value: 'network.xyo.schema' }
|
|
33
|
-
|
|
34
|
-
const WithUnverifiedValue = Template.bind({})
|
|
35
|
-
WithUnverifiedValue.args = { value: 'network.xyo.blahblah' }
|
|
36
|
-
|
|
37
|
-
export {
|
|
38
|
-
Default, WithUnverifiedValue, WithVerifiedValue, WithVerifiedValuePaper,
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export default StorybookEntry
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
NewReleases as NewReleasesIcon, OpenInNew as OpenInNewIcon, Verified as VerifiedIcon,
|
|
3
|
-
} from '@mui/icons-material'
|
|
4
|
-
import { IconButton } from '@mui/material'
|
|
5
|
-
import { useAsyncEffect } from '@xylabs/react-async-effect'
|
|
6
|
-
import { FlexGrowRow } from '@xylabs/react-flexbox'
|
|
7
|
-
import { LinkEx } from '@xylabs/react-link'
|
|
8
|
-
import type { EventDispatch, EventNoun } from '@xyo-network/react-event'
|
|
9
|
-
import { useEvent } from '@xyo-network/react-event'
|
|
10
|
-
import type { PropertyProps } from '@xyo-network/react-property'
|
|
11
|
-
import { Property, PropertyValue } from '@xyo-network/react-property'
|
|
12
|
-
import type { SchemaCacheEntry } from '@xyo-network/schema-cache'
|
|
13
|
-
import { SchemaCache } from '@xyo-network/schema-cache'
|
|
14
|
-
import React, { useState } from 'react'
|
|
15
|
-
|
|
16
|
-
export type SchemaPropertyProps = PropertyProps & {
|
|
17
|
-
showLinkNames?: boolean
|
|
18
|
-
showOpenNewWindowLink?: boolean
|
|
19
|
-
showStatusIcon?: boolean
|
|
20
|
-
value?: string
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const useResolveSchema = (schema?: string) => {
|
|
24
|
-
const [entry, setEntry] = useState<SchemaCacheEntry | null>()
|
|
25
|
-
useAsyncEffect(
|
|
26
|
-
async (mounted) => {
|
|
27
|
-
if (schema) {
|
|
28
|
-
const entry = await SchemaCache.instance.get(schema)
|
|
29
|
-
if (mounted()) {
|
|
30
|
-
setEntry(entry)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
[schema],
|
|
35
|
-
)
|
|
36
|
-
return entry
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const SchemaProperty: React.FC<SchemaPropertyProps> = ({
|
|
40
|
-
showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props
|
|
41
|
-
}) => {
|
|
42
|
-
const resolvedSchema = useResolveSchema(value)
|
|
43
|
-
const [buttonRef, buttonDispatch] = useEvent<HTMLButtonElement>()
|
|
44
|
-
const [divRef, divDispatch] = useEvent<HTMLDivElement>()
|
|
45
|
-
|
|
46
|
-
const onClick = (dispatch?: EventDispatch<EventNoun, 'click', string>, openNewWindow = false) => {
|
|
47
|
-
dispatch?.(
|
|
48
|
-
'schema',
|
|
49
|
-
'click',
|
|
50
|
-
JSON.stringify({
|
|
51
|
-
openNewWindow,
|
|
52
|
-
schema: value,
|
|
53
|
-
}),
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<Property title="Schema" value={value} tip="Schema sent with the payload" titleProps={titleProps} {...props}>
|
|
59
|
-
{value && showStatusIcon
|
|
60
|
-
? resolvedSchema === null
|
|
61
|
-
? (
|
|
62
|
-
<IconButton
|
|
63
|
-
ref={buttonRef}
|
|
64
|
-
size="small"
|
|
65
|
-
onClick={() => {
|
|
66
|
-
if (!buttonRef.current) {
|
|
67
|
-
console.warn('buttonRef.current is null')
|
|
68
|
-
}
|
|
69
|
-
onClick(buttonDispatch)
|
|
70
|
-
}}
|
|
71
|
-
>
|
|
72
|
-
<NewReleasesIcon color="warning" fontSize="inherit" />
|
|
73
|
-
</IconButton>
|
|
74
|
-
)
|
|
75
|
-
: resolvedSchema === undefined
|
|
76
|
-
? (
|
|
77
|
-
<IconButton
|
|
78
|
-
ref={buttonRef}
|
|
79
|
-
size="small"
|
|
80
|
-
onClick={() => {
|
|
81
|
-
if (!buttonRef.current) {
|
|
82
|
-
console.warn('buttonRef.current is null')
|
|
83
|
-
}
|
|
84
|
-
onClick(buttonDispatch)
|
|
85
|
-
}}
|
|
86
|
-
>
|
|
87
|
-
<NewReleasesIcon color="disabled" fontSize="inherit" />
|
|
88
|
-
</IconButton>
|
|
89
|
-
)
|
|
90
|
-
: (
|
|
91
|
-
<IconButton rel="noopener noreferrer" size="small" target="_blank" href={resolvedSchema?.huri?.href ?? ''}>
|
|
92
|
-
<VerifiedIcon color="success" fontSize="inherit" />
|
|
93
|
-
</IconButton>
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
: null}
|
|
97
|
-
{value
|
|
98
|
-
? (
|
|
99
|
-
<FlexGrowRow ref={divRef} justifyContent="space-between">
|
|
100
|
-
{showLinkNames
|
|
101
|
-
? (
|
|
102
|
-
<LinkEx
|
|
103
|
-
display="block"
|
|
104
|
-
width="100%"
|
|
105
|
-
sx={{ cursor: 'pointer' }}
|
|
106
|
-
>
|
|
107
|
-
<PropertyValue
|
|
108
|
-
value={value}
|
|
109
|
-
title="view schema"
|
|
110
|
-
onClick={() => {
|
|
111
|
-
if (!divRef.current) {
|
|
112
|
-
console.warn('divRef.current is null')
|
|
113
|
-
}
|
|
114
|
-
onClick(divDispatch)
|
|
115
|
-
}}
|
|
116
|
-
/>
|
|
117
|
-
</LinkEx>
|
|
118
|
-
)
|
|
119
|
-
: (
|
|
120
|
-
<PropertyValue
|
|
121
|
-
value={value}
|
|
122
|
-
title="view schema"
|
|
123
|
-
onClick={() => {
|
|
124
|
-
if (!divRef.current) {
|
|
125
|
-
console.warn('divRef.current is null')
|
|
126
|
-
}
|
|
127
|
-
onClick(divDispatch)
|
|
128
|
-
}}
|
|
129
|
-
/>
|
|
130
|
-
)}
|
|
131
|
-
{showOpenNewWindowLink
|
|
132
|
-
? (
|
|
133
|
-
<IconButton
|
|
134
|
-
ref={buttonRef}
|
|
135
|
-
size="small"
|
|
136
|
-
onClick={() => {
|
|
137
|
-
if (!buttonRef.current) {
|
|
138
|
-
console.warn('buttonRef.current is null')
|
|
139
|
-
}
|
|
140
|
-
onClick(buttonDispatch, true)
|
|
141
|
-
}}
|
|
142
|
-
>
|
|
143
|
-
<OpenInNewIcon fontSize="inherit" />
|
|
144
|
-
</IconButton>
|
|
145
|
-
)
|
|
146
|
-
: null}
|
|
147
|
-
</FlexGrowRow>
|
|
148
|
-
)
|
|
149
|
-
: null}
|
|
150
|
-
</Property>
|
|
151
|
-
)
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
SchemaProperty.displayName = 'SchemaProperty'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './SchemaProperty.tsx'
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { MenuItem, Typography } from '@mui/material'
|
|
2
|
-
import type { SelectExProps } from '@xylabs/react-select'
|
|
3
|
-
import { SelectEx } from '@xylabs/react-select'
|
|
4
|
-
import React from 'react'
|
|
5
|
-
|
|
6
|
-
import { useSchema } from '../../contexts/index.ts'
|
|
7
|
-
|
|
8
|
-
export type SchemaSelectExProps = SelectExProps<string>
|
|
9
|
-
|
|
10
|
-
export const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({
|
|
11
|
-
onChange, variant = 'outlined', ...props
|
|
12
|
-
}) => {
|
|
13
|
-
const {
|
|
14
|
-
schema, setSchema, schemaList,
|
|
15
|
-
} = useSchema(false)
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<SelectEx
|
|
19
|
-
variant={variant}
|
|
20
|
-
size="small"
|
|
21
|
-
value={schema ?? 'none'}
|
|
22
|
-
onChange={(event, child) => {
|
|
23
|
-
if (event.target.value !== schema) {
|
|
24
|
-
onChange?.(event, child)
|
|
25
|
-
setSchema?.(event.target.value)
|
|
26
|
-
}
|
|
27
|
-
}}
|
|
28
|
-
renderValue={(value) => {
|
|
29
|
-
return <Typography>{value === 'none' ? '- None -' : value}</Typography>
|
|
30
|
-
}}
|
|
31
|
-
{...props}
|
|
32
|
-
>
|
|
33
|
-
{schemaList?.map((schema) => {
|
|
34
|
-
return (
|
|
35
|
-
<MenuItem key={schemaList.indexOf(schema)} value={schema}>
|
|
36
|
-
{schema}
|
|
37
|
-
</MenuItem>
|
|
38
|
-
)
|
|
39
|
-
})}
|
|
40
|
-
<MenuItem key="none" value="none">
|
|
41
|
-
- None -
|
|
42
|
-
</MenuItem>
|
|
43
|
-
</SelectEx>
|
|
44
|
-
)
|
|
45
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './SchemaSelectEx.tsx'
|
package/src/components/index.ts
DELETED