@xyo-network/react-schema 2.81.9 → 2.82.0
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/Property/SchemaProperty.d.cts +6 -5
- package/dist/browser/components/Property/SchemaProperty.d.cts.map +1 -1
- package/dist/browser/components/Property/SchemaProperty.d.mts +6 -5
- package/dist/browser/components/Property/SchemaProperty.d.mts.map +1 -1
- package/dist/browser/components/Property/SchemaProperty.d.ts +6 -5
- package/dist/browser/components/Property/SchemaProperty.d.ts.map +1 -1
- package/dist/browser/components/Property/index.d.cts +1 -1
- package/dist/browser/components/Property/index.d.cts.map +1 -1
- package/dist/browser/components/Property/index.d.mts +1 -1
- package/dist/browser/components/Property/index.d.mts.map +1 -1
- package/dist/browser/components/Property/index.d.ts +1 -1
- package/dist/browser/components/Property/index.d.ts.map +1 -1
- package/dist/browser/components/SelectEx/SchemaSelectEx.d.cts +1 -0
- package/dist/browser/components/SelectEx/SchemaSelectEx.d.cts.map +1 -1
- package/dist/browser/components/SelectEx/SchemaSelectEx.d.mts +1 -0
- package/dist/browser/components/SelectEx/SchemaSelectEx.d.mts.map +1 -1
- package/dist/browser/components/SelectEx/SchemaSelectEx.d.ts +1 -0
- package/dist/browser/components/SelectEx/SchemaSelectEx.d.ts.map +1 -1
- package/dist/browser/components/SelectEx/index.d.cts +1 -1
- package/dist/browser/components/SelectEx/index.d.cts.map +1 -1
- package/dist/browser/components/SelectEx/index.d.mts +1 -1
- package/dist/browser/components/SelectEx/index.d.mts.map +1 -1
- package/dist/browser/components/SelectEx/index.d.ts +1 -1
- package/dist/browser/components/SelectEx/index.d.ts.map +1 -1
- package/dist/browser/components/index.d.cts +2 -2
- package/dist/browser/components/index.d.mts +2 -2
- package/dist/browser/components/index.d.ts +2 -2
- package/dist/browser/contexts/Schema/Context.d.cts +1 -1
- package/dist/browser/contexts/Schema/Context.d.mts +1 -1
- package/dist/browser/contexts/Schema/Context.d.ts +1 -1
- package/dist/browser/contexts/Schema/Provider/Memory.d.cts +2 -1
- package/dist/browser/contexts/Schema/Provider/Memory.d.cts.map +1 -1
- package/dist/browser/contexts/Schema/Provider/Memory.d.mts +2 -1
- package/dist/browser/contexts/Schema/Provider/Memory.d.mts.map +1 -1
- package/dist/browser/contexts/Schema/Provider/Memory.d.ts +2 -1
- package/dist/browser/contexts/Schema/Provider/Memory.d.ts.map +1 -1
- package/dist/browser/contexts/Schema/Provider/Props.d.cts.map +1 -1
- package/dist/browser/contexts/Schema/Provider/Props.d.mts.map +1 -1
- package/dist/browser/contexts/Schema/Provider/Props.d.ts.map +1 -1
- package/dist/browser/contexts/Schema/Provider/Route.d.cts +2 -1
- package/dist/browser/contexts/Schema/Provider/Route.d.cts.map +1 -1
- package/dist/browser/contexts/Schema/Provider/Route.d.mts +2 -1
- package/dist/browser/contexts/Schema/Provider/Route.d.mts.map +1 -1
- package/dist/browser/contexts/Schema/Provider/Route.d.ts +2 -1
- package/dist/browser/contexts/Schema/Provider/Route.d.ts.map +1 -1
- package/dist/browser/contexts/Schema/Provider/index.d.cts +3 -3
- package/dist/browser/contexts/Schema/Provider/index.d.cts.map +1 -1
- package/dist/browser/contexts/Schema/Provider/index.d.mts +3 -3
- package/dist/browser/contexts/Schema/Provider/index.d.mts.map +1 -1
- package/dist/browser/contexts/Schema/Provider/index.d.ts +3 -3
- package/dist/browser/contexts/Schema/Provider/index.d.ts.map +1 -1
- package/dist/browser/contexts/Schema/index.d.cts +4 -4
- package/dist/browser/contexts/Schema/index.d.mts +4 -4
- package/dist/browser/contexts/Schema/index.d.ts +4 -4
- package/dist/browser/contexts/Schema/use.d.cts +1 -1
- package/dist/browser/contexts/Schema/use.d.mts +1 -1
- package/dist/browser/contexts/Schema/use.d.ts +1 -1
- package/dist/browser/contexts/index.d.cts +1 -1
- package/dist/browser/contexts/index.d.mts +1 -1
- package/dist/browser/contexts/index.d.ts +1 -1
- package/dist/browser/hooks/index.d.cts +4 -4
- package/dist/browser/hooks/index.d.cts.map +1 -1
- package/dist/browser/hooks/index.d.mts +4 -4
- package/dist/browser/hooks/index.d.mts.map +1 -1
- package/dist/browser/hooks/index.d.ts +4 -4
- package/dist/browser/hooks/index.d.ts.map +1 -1
- package/dist/browser/hooks/useGetSchema.d.cts.map +1 -1
- package/dist/browser/hooks/useGetSchema.d.mts.map +1 -1
- package/dist/browser/hooks/useGetSchema.d.ts.map +1 -1
- package/dist/browser/hooks/useSchemaDefinitions.d.cts.map +1 -1
- package/dist/browser/hooks/useSchemaDefinitions.d.mts.map +1 -1
- package/dist/browser/hooks/useSchemaDefinitions.d.ts.map +1 -1
- package/dist/browser/hooks/useSchemaList.d.cts.map +1 -1
- package/dist/browser/hooks/useSchemaList.d.mts.map +1 -1
- package/dist/browser/hooks/useSchemaList.d.ts.map +1 -1
- package/dist/browser/hooks/useSchemaStats.d.cts.map +1 -1
- package/dist/browser/hooks/useSchemaStats.d.mts.map +1 -1
- package/dist/browser/hooks/useSchemaStats.d.ts.map +1 -1
- package/dist/browser/index.cjs +301 -205
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +3 -3
- package/dist/browser/index.d.mts +3 -3
- package/dist/browser/index.d.ts +3 -3
- package/dist/browser/index.mjs +422 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/neutral/components/Property/SchemaProperty.d.cts +6 -5
- package/dist/neutral/components/Property/SchemaProperty.d.cts.map +1 -1
- package/dist/neutral/components/Property/SchemaProperty.d.mts +6 -5
- package/dist/neutral/components/Property/SchemaProperty.d.mts.map +1 -1
- package/dist/neutral/components/Property/SchemaProperty.d.ts +6 -5
- package/dist/neutral/components/Property/SchemaProperty.d.ts.map +1 -1
- package/dist/neutral/components/Property/index.d.cts +1 -1
- package/dist/neutral/components/Property/index.d.cts.map +1 -1
- package/dist/neutral/components/Property/index.d.mts +1 -1
- package/dist/neutral/components/Property/index.d.mts.map +1 -1
- package/dist/neutral/components/Property/index.d.ts +1 -1
- package/dist/neutral/components/Property/index.d.ts.map +1 -1
- package/dist/neutral/components/SelectEx/SchemaSelectEx.d.cts +1 -0
- package/dist/neutral/components/SelectEx/SchemaSelectEx.d.cts.map +1 -1
- package/dist/neutral/components/SelectEx/SchemaSelectEx.d.mts +1 -0
- package/dist/neutral/components/SelectEx/SchemaSelectEx.d.mts.map +1 -1
- package/dist/neutral/components/SelectEx/SchemaSelectEx.d.ts +1 -0
- package/dist/neutral/components/SelectEx/SchemaSelectEx.d.ts.map +1 -1
- package/dist/neutral/components/SelectEx/index.d.cts +1 -1
- package/dist/neutral/components/SelectEx/index.d.cts.map +1 -1
- package/dist/neutral/components/SelectEx/index.d.mts +1 -1
- package/dist/neutral/components/SelectEx/index.d.mts.map +1 -1
- package/dist/neutral/components/SelectEx/index.d.ts +1 -1
- package/dist/neutral/components/SelectEx/index.d.ts.map +1 -1
- package/dist/neutral/components/index.d.cts +2 -2
- package/dist/neutral/components/index.d.mts +2 -2
- package/dist/neutral/components/index.d.ts +2 -2
- package/dist/neutral/contexts/Schema/Context.d.cts +1 -1
- package/dist/neutral/contexts/Schema/Context.d.mts +1 -1
- package/dist/neutral/contexts/Schema/Context.d.ts +1 -1
- package/dist/neutral/contexts/Schema/Provider/Memory.d.cts +2 -1
- package/dist/neutral/contexts/Schema/Provider/Memory.d.cts.map +1 -1
- package/dist/neutral/contexts/Schema/Provider/Memory.d.mts +2 -1
- package/dist/neutral/contexts/Schema/Provider/Memory.d.mts.map +1 -1
- package/dist/neutral/contexts/Schema/Provider/Memory.d.ts +2 -1
- package/dist/neutral/contexts/Schema/Provider/Memory.d.ts.map +1 -1
- package/dist/neutral/contexts/Schema/Provider/Props.d.cts.map +1 -1
- package/dist/neutral/contexts/Schema/Provider/Props.d.mts.map +1 -1
- package/dist/neutral/contexts/Schema/Provider/Props.d.ts.map +1 -1
- package/dist/neutral/contexts/Schema/Provider/Route.d.cts +2 -1
- package/dist/neutral/contexts/Schema/Provider/Route.d.cts.map +1 -1
- package/dist/neutral/contexts/Schema/Provider/Route.d.mts +2 -1
- package/dist/neutral/contexts/Schema/Provider/Route.d.mts.map +1 -1
- package/dist/neutral/contexts/Schema/Provider/Route.d.ts +2 -1
- package/dist/neutral/contexts/Schema/Provider/Route.d.ts.map +1 -1
- package/dist/neutral/contexts/Schema/Provider/index.d.cts +3 -3
- package/dist/neutral/contexts/Schema/Provider/index.d.cts.map +1 -1
- package/dist/neutral/contexts/Schema/Provider/index.d.mts +3 -3
- package/dist/neutral/contexts/Schema/Provider/index.d.mts.map +1 -1
- package/dist/neutral/contexts/Schema/Provider/index.d.ts +3 -3
- package/dist/neutral/contexts/Schema/Provider/index.d.ts.map +1 -1
- package/dist/neutral/contexts/Schema/index.d.cts +4 -4
- package/dist/neutral/contexts/Schema/index.d.mts +4 -4
- package/dist/neutral/contexts/Schema/index.d.ts +4 -4
- package/dist/neutral/contexts/Schema/use.d.cts +1 -1
- package/dist/neutral/contexts/Schema/use.d.mts +1 -1
- package/dist/neutral/contexts/Schema/use.d.ts +1 -1
- package/dist/neutral/contexts/index.d.cts +1 -1
- package/dist/neutral/contexts/index.d.mts +1 -1
- package/dist/neutral/contexts/index.d.ts +1 -1
- package/dist/neutral/hooks/index.d.cts +4 -4
- package/dist/neutral/hooks/index.d.cts.map +1 -1
- package/dist/neutral/hooks/index.d.mts +4 -4
- package/dist/neutral/hooks/index.d.mts.map +1 -1
- package/dist/neutral/hooks/index.d.ts +4 -4
- package/dist/neutral/hooks/index.d.ts.map +1 -1
- package/dist/neutral/hooks/useGetSchema.d.cts.map +1 -1
- package/dist/neutral/hooks/useGetSchema.d.mts.map +1 -1
- package/dist/neutral/hooks/useGetSchema.d.ts.map +1 -1
- package/dist/neutral/hooks/useSchemaDefinitions.d.cts.map +1 -1
- package/dist/neutral/hooks/useSchemaDefinitions.d.mts.map +1 -1
- package/dist/neutral/hooks/useSchemaDefinitions.d.ts.map +1 -1
- package/dist/neutral/hooks/useSchemaList.d.cts.map +1 -1
- package/dist/neutral/hooks/useSchemaList.d.mts.map +1 -1
- package/dist/neutral/hooks/useSchemaList.d.ts.map +1 -1
- package/dist/neutral/hooks/useSchemaStats.d.cts.map +1 -1
- package/dist/neutral/hooks/useSchemaStats.d.mts.map +1 -1
- package/dist/neutral/hooks/useSchemaStats.d.ts.map +1 -1
- package/dist/neutral/index.cjs +301 -205
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.d.cts +3 -3
- package/dist/neutral/index.d.mts +3 -3
- package/dist/neutral/index.d.ts +3 -3
- package/dist/neutral/index.mjs +422 -0
- package/dist/neutral/index.mjs.map +1 -0
- package/dist/node/components/Property/SchemaProperty.d.cts +6 -5
- package/dist/node/components/Property/SchemaProperty.d.cts.map +1 -1
- package/dist/node/components/Property/SchemaProperty.d.mts +6 -5
- package/dist/node/components/Property/SchemaProperty.d.mts.map +1 -1
- package/dist/node/components/Property/SchemaProperty.d.ts +6 -5
- package/dist/node/components/Property/SchemaProperty.d.ts.map +1 -1
- package/dist/node/components/Property/index.d.cts +1 -1
- package/dist/node/components/Property/index.d.cts.map +1 -1
- package/dist/node/components/Property/index.d.mts +1 -1
- package/dist/node/components/Property/index.d.mts.map +1 -1
- package/dist/node/components/Property/index.d.ts +1 -1
- package/dist/node/components/Property/index.d.ts.map +1 -1
- package/dist/node/components/SelectEx/SchemaSelectEx.d.cts +1 -0
- package/dist/node/components/SelectEx/SchemaSelectEx.d.cts.map +1 -1
- package/dist/node/components/SelectEx/SchemaSelectEx.d.mts +1 -0
- package/dist/node/components/SelectEx/SchemaSelectEx.d.mts.map +1 -1
- package/dist/node/components/SelectEx/SchemaSelectEx.d.ts +1 -0
- package/dist/node/components/SelectEx/SchemaSelectEx.d.ts.map +1 -1
- package/dist/node/components/SelectEx/index.d.cts +1 -1
- package/dist/node/components/SelectEx/index.d.cts.map +1 -1
- package/dist/node/components/SelectEx/index.d.mts +1 -1
- package/dist/node/components/SelectEx/index.d.mts.map +1 -1
- package/dist/node/components/SelectEx/index.d.ts +1 -1
- package/dist/node/components/SelectEx/index.d.ts.map +1 -1
- package/dist/node/components/index.d.cts +2 -2
- package/dist/node/components/index.d.mts +2 -2
- package/dist/node/components/index.d.ts +2 -2
- package/dist/node/contexts/Schema/Context.d.cts +1 -1
- package/dist/node/contexts/Schema/Context.d.mts +1 -1
- package/dist/node/contexts/Schema/Context.d.ts +1 -1
- package/dist/node/contexts/Schema/Provider/Memory.d.cts +2 -1
- package/dist/node/contexts/Schema/Provider/Memory.d.cts.map +1 -1
- package/dist/node/contexts/Schema/Provider/Memory.d.mts +2 -1
- package/dist/node/contexts/Schema/Provider/Memory.d.mts.map +1 -1
- package/dist/node/contexts/Schema/Provider/Memory.d.ts +2 -1
- package/dist/node/contexts/Schema/Provider/Memory.d.ts.map +1 -1
- package/dist/node/contexts/Schema/Provider/Props.d.cts.map +1 -1
- package/dist/node/contexts/Schema/Provider/Props.d.mts.map +1 -1
- package/dist/node/contexts/Schema/Provider/Props.d.ts.map +1 -1
- package/dist/node/contexts/Schema/Provider/Route.d.cts +2 -1
- package/dist/node/contexts/Schema/Provider/Route.d.cts.map +1 -1
- package/dist/node/contexts/Schema/Provider/Route.d.mts +2 -1
- package/dist/node/contexts/Schema/Provider/Route.d.mts.map +1 -1
- package/dist/node/contexts/Schema/Provider/Route.d.ts +2 -1
- package/dist/node/contexts/Schema/Provider/Route.d.ts.map +1 -1
- package/dist/node/contexts/Schema/Provider/index.d.cts +3 -3
- package/dist/node/contexts/Schema/Provider/index.d.cts.map +1 -1
- package/dist/node/contexts/Schema/Provider/index.d.mts +3 -3
- package/dist/node/contexts/Schema/Provider/index.d.mts.map +1 -1
- package/dist/node/contexts/Schema/Provider/index.d.ts +3 -3
- package/dist/node/contexts/Schema/Provider/index.d.ts.map +1 -1
- package/dist/node/contexts/Schema/index.d.cts +4 -4
- package/dist/node/contexts/Schema/index.d.mts +4 -4
- package/dist/node/contexts/Schema/index.d.ts +4 -4
- package/dist/node/contexts/Schema/use.d.cts +1 -1
- package/dist/node/contexts/Schema/use.d.mts +1 -1
- package/dist/node/contexts/Schema/use.d.ts +1 -1
- package/dist/node/contexts/index.d.cts +1 -1
- package/dist/node/contexts/index.d.mts +1 -1
- package/dist/node/contexts/index.d.ts +1 -1
- package/dist/node/hooks/index.d.cts +4 -4
- package/dist/node/hooks/index.d.cts.map +1 -1
- package/dist/node/hooks/index.d.mts +4 -4
- package/dist/node/hooks/index.d.mts.map +1 -1
- package/dist/node/hooks/index.d.ts +4 -4
- package/dist/node/hooks/index.d.ts.map +1 -1
- package/dist/node/hooks/useGetSchema.d.cts.map +1 -1
- package/dist/node/hooks/useGetSchema.d.mts.map +1 -1
- package/dist/node/hooks/useGetSchema.d.ts.map +1 -1
- package/dist/node/hooks/useSchemaDefinitions.d.cts.map +1 -1
- package/dist/node/hooks/useSchemaDefinitions.d.mts.map +1 -1
- package/dist/node/hooks/useSchemaDefinitions.d.ts.map +1 -1
- package/dist/node/hooks/useSchemaList.d.cts.map +1 -1
- package/dist/node/hooks/useSchemaList.d.mts.map +1 -1
- package/dist/node/hooks/useSchemaList.d.ts.map +1 -1
- package/dist/node/hooks/useSchemaStats.d.cts.map +1 -1
- package/dist/node/hooks/useSchemaStats.d.mts.map +1 -1
- package/dist/node/hooks/useSchemaStats.d.ts.map +1 -1
- package/dist/node/index.cjs +305 -209
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +3 -3
- package/dist/node/index.d.mts +3 -3
- package/dist/node/index.d.ts +3 -3
- package/dist/node/index.mjs +426 -0
- package/dist/node/index.mjs.map +1 -0
- package/package.json +33 -33
- package/src/components/Property/SchemaProperty.stories.tsx +2 -2
- package/src/components/Property/SchemaProperty.tsx +40 -29
- package/src/components/Property/index.ts +1 -1
- package/src/components/SelectEx/SchemaSelectEx.tsx +2 -1
- package/src/components/SelectEx/index.ts +1 -1
- package/src/components/index.ts +2 -2
- package/src/contexts/Schema/Context.ts +1 -1
- package/src/contexts/Schema/Provider/Memory.tsx +8 -6
- package/src/contexts/Schema/Provider/Route.tsx +13 -11
- package/src/contexts/Schema/Provider/index.ts +3 -3
- package/src/contexts/Schema/index.ts +4 -4
- package/src/contexts/Schema/use.ts +2 -2
- package/src/contexts/index.ts +1 -1
- package/src/hooks/index.ts +4 -4
- package/src/hooks/stories/TestSchemaHooks.stories.tsx +12 -14
- package/src/hooks/useGetSchema.stories.tsx +3 -4
- package/src/hooks/useGetSchema.tsx +0 -1
- package/src/hooks/useSchemaDefinitions.tsx +2 -3
- package/src/hooks/useSchemaList.tsx +8 -9
- package/src/hooks/useSchemaStats.tsx +1 -2
- package/src/index.ts +3 -3
- package/dist/browser/index.js +0 -337
- package/dist/browser/index.js.map +0 -1
- package/dist/neutral/index.js +0 -337
- package/dist/neutral/index.js.map +0 -1
- package/dist/node/index.js +0 -341
- package/dist/node/index.js.map +0 -1
- /package/src/contexts/Schema/Provider/{Props.tsx → Props.ts} +0 -0
|
@@ -0,0 +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 { NewReleases as NewReleasesIcon, OpenInNew as OpenInNewIcon, Verified as VerifiedIcon } from '@mui/icons-material'\nimport { IconButton } from '@mui/material'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { LinkEx } from '@xylabs/react-link'\nimport { EventDispatch, EventNoun, useEvent } from '@xyo-network/react-event'\nimport { Property, PropertyProps, PropertyValue } from '@xyo-network/react-property'\nimport { SchemaCache, SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport React, { forwardRef, 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 = forwardRef<HTMLDivElement, SchemaPropertyProps>(\n ({ showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props }, forwardedRef) => {\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 ref={forwardedRef} title=\"Schema\" value={value} tip=\"Schema sent with the payload\" titleProps={titleProps} {...props}>\n {value && showStatusIcon\n ? resolvedSchema === null\n ? (\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch)}>\n <NewReleasesIcon color=\"warning\" fontSize=\"inherit\" />\n </IconButton>\n )\n : resolvedSchema === undefined\n ? (\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch)}>\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 <>\n {showLinkNames\n ? (\n <LinkEx display=\"block\" width=\"100%\" sx={{ cursor: 'pointer' }}>\n <PropertyValue ref={divRef} value={value} title=\"view schema\" onClick={() => onClick(divDispatch)} />\n </LinkEx>\n )\n : <PropertyValue ref={divRef} value={value} title=\"view schema\" onClick={() => onClick(divDispatch)} />}\n {showOpenNewWindowLink\n ? (\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch, true)}>\n <OpenInNewIcon fontSize=\"inherit\" />\n </IconButton>\n )\n : null}\n </>\n )\n : null}\n </Property>\n )\n },\n)\n\nSchemaProperty.displayName = 'SchemaProperty'\n","import { MenuItem, Typography } from '@mui/material'\nimport { SelectEx, SelectExProps } 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> = ({ onChange, variant = 'outlined', ...props }) => {\n const { schema, setSchema, schemaList } = 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, index) => {\n return (\n <MenuItem key={index} 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 '@xyo-network/react-shared'\n\nimport { SchemaContextState } from './State.ts'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { compact } from '@xylabs/lodash'\nimport { WithChildren } from '@xylabs/react-shared'\nimport React, { useEffect, useMemo, useState } from 'react'\n\nimport { useSchemaStats } from '../../../hooks/index.ts'\nimport { SchemaContext } from '../Context.ts'\nimport { SchemaProviderProps } from './Props.ts'\n\nexport const SchemaMemoryProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ defaultSchema, knownSchemaList, ...props }) => {\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 = compact(fetchedSchemaStats.map(({ name }) => name))\n setSchemaList(schemaList)\n }\n }, [fetchedSchemaStats])\n\n const value = useMemo(() => ({ provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList }), [schema, schemaList, knownSchemaList])\n\n return <SchemaContext.Provider value={value} {...props} />\n}\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { ModuleError, ModuleErrorSchema } from '@xyo-network/payload-model'\nimport { SchemaCache, SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { 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, setError] = useState<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 setError({ message: error.message, schema: ModuleErrorSchema, sources: [] })\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 { 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 { Address } from '@xylabs/hex'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { SchemaListPayload, SchemaListQueryPayload, SchemaListQuerySchema } from '@xyo-network/diviner-schema-list-model'\nimport { WithMeta } from '@xyo-network/payload-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport { useEffect, useMemo, useState } from 'react'\n\nexport const useSchemaList = (address?: Address, nameOrAddress = 'SchemaListDiviner'): [SchemaListPayload | null | undefined, Error | undefined] => {\n const [schemaList, setSchemaList] = useState<SchemaListPayload | null>()\n const [error, setError] = useState<Error>()\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 useEffect(() => {\n if (diviner === null) {\n setSchemaList(null)\n setError(undefined)\n }\n }, [diviner])\n\n useAsyncEffect(\n async (mounted) => {\n const divinerInstance = diviner?.deref()\n if (divinerInstance) {\n try {\n const response = (await divinerInstance.divine(query)) as WithMeta<SchemaListPayload>[]\n if (mounted()) {\n setSchemaList(response?.[0])\n setError(undefined)\n }\n } catch (e) {\n setError(e as Error)\n setSchemaList(undefined)\n }\n }\n },\n [diviner, divinerError, query],\n )\n return [schemaList, error]\n}\n","import { Address } from '@xylabs/hex'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport {\n SchemaStatsDivinerSchema,\n SchemaStatsPayload,\n SchemaStatsQueryPayload,\n SchemaStatsQuerySchema,\n} from '@xyo-network/diviner-schema-stats-model'\nimport { TYPES } from '@xyo-network/node-core-types'\nimport { isPayloadOfSchemaTypeWithMeta, WithMeta, WithSources } from '@xyo-network/payload-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport { Dispatch, SetStateAction, useMemo, 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<WithMeta<SchemaStatsPayload>>[]>()\n\n const query: SchemaStatsQueryPayload = useMemo(\n () => ({\n address: statsAddress,\n schema: SchemaStatsQuerySchema,\n }),\n [statsAddress],\n )\n\n useAsyncEffect(\n async (mounted) => {\n const instance = diviner?.deref()\n if (instance) {\n if (divinerError) {\n if (mounted()) {\n setError(divinerError)\n setSchemaList(undefined)\n }\n } else {\n try {\n const schemas = (await instance.divine([query])).filter(isPayloadOfSchemaTypeWithMeta(SchemaStatsDivinerSchema)) as WithSources<\n WithMeta<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, query],\n )\n\n return [schemaList, error, refreshHistory]\n}\n","import type { WithChildren } from '@xylabs/react-shared'\nimport React, { useCallback, useEffect, useMemo } from 'react'\nimport { useSearchParams } from 'react-router-dom'\n\nimport { SchemaContext } from '../Context.ts'\nimport { useSchema } from '../use.ts'\nimport { SchemaMemoryProvider } from './Memory.tsx'\nimport { SchemaProviderProps } from './Props.ts'\n\nconst SchemaRouteProviderInner: React.FC<WithChildren> = ({ children }) => {\n const { schema, setSchema, schemaList } = 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 = useMemo(() => ({ provided: true, schema, schemaList, setSchema: setSchemaLocal }), [schema, schemaList, setSchemaLocal])\n\n return <SchemaContext.Provider value={value}>{children}</SchemaContext.Provider>\n}\n\nexport const SchemaRouteProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ knownSchemaList, defaultSchema, ...props }) => {\n return (\n <SchemaMemoryProvider knownSchemaList={knownSchemaList} defaultSchema={defaultSchema}>\n <SchemaRouteProviderInner {...props} />\n </SchemaMemoryProvider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContext } from './Context.ts'\nimport { SchemaContextState } from './State.ts'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\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ACJ,UAAAA;AACZ,aAAO,gBAAAH,OAAA,cAACQ,YAAAA,MAAYL,UAAU,SAAS,aAAaA,KAAAA;IACtD,GAFa;IAGZ,GAAGR;KAEHG,yCAAYW,IAAI,CAACb,SAAQc,UAAAA;AACxB,WACE,gBAAAV,OAAA,cAACW,UAAAA;MAASC,KAAKF;MAAOP,OAAOP;OAC1BA,OAAAA;EAGP,IACA,gBAAAI,OAAA,cAACW,UAAAA;IAASC,KAAI;IAAOT,OAAM;KAAO,UAAA,CAAA;AAKxC,GA/B6D;","names":["NewReleases","NewReleasesIcon","OpenInNew","OpenInNewIcon","Verified","VerifiedIcon","IconButton","useAsyncEffect","LinkEx","useEvent","Property","PropertyValue","SchemaCache","React","forwardRef","useState","useResolveSchema","schema","entry","setEntry","useState","useAsyncEffect","mounted","SchemaCache","instance","get","SchemaProperty","forwardRef","showLinkNames","showOpenNewWindowLink","showStatusIcon","titleProps","value","props","forwardedRef","resolvedSchema","buttonRef","buttonDispatch","useEvent","divRef","divDispatch","onClick","dispatch","openNewWindow","JSON","stringify","Property","ref","title","tip","IconButton","size","NewReleasesIcon","color","fontSize","undefined","rel","target","href","huri","VerifiedIcon","LinkEx","display","width","sx","cursor","PropertyValue","OpenInNewIcon","displayName","MenuItem","Typography","SelectEx","React","createContextEx","SchemaContext","compact","React","useEffect","useMemo","useState","useAsyncEffect","PayloadBuilder","ModuleErrorSchema","SchemaCache","useState","useGetSchemaPayload","schema","notFound","setNotFound","useState","xyoError","setError","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","useAsyncEffect","SchemaListQuerySchema","useWeakDivinerFromNode","useEffect","useMemo","useState","useSchemaList","address","nameOrAddress","schemaList","setSchemaList","useState","error","setError","diviner","divinerError","useWeakDivinerFromNode","query","useMemo","schema","SchemaListQuerySchema","undefined","useEffect","useAsyncEffect","mounted","divinerInstance","deref","response","divine","e","useAsyncEffect","SchemaStatsDivinerSchema","SchemaStatsQuerySchema","TYPES","isPayloadOfSchemaTypeWithMeta","useWeakDivinerFromNode","useMemo","useState","useSchemaStats","statsAddress","nameOrAddress","TYPES","SchemaStatsDiviner","refresh","setRefresh","useState","diviner","divinerError","useWeakDivinerFromNode","error","setError","refreshHistory","previous","schemaList","setSchemaList","query","useMemo","address","schema","SchemaStatsQuerySchema","useAsyncEffect","mounted","instance","deref","undefined","schemas","divine","filter","isPayloadOfSchemaTypeWithMeta","SchemaStatsDivinerSchema","ex","SchemaMemoryProvider","defaultSchema","knownSchemaList","props","schema","setSchema","useState","schemaList","setSchemaList","fetchedSchemaStats","useSchemaStats","useEffect","compact","map","name","value","useMemo","provided","React","SchemaContext","Provider","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","Provider","SchemaRouteProvider","knownSchemaList","defaultSchema","props","SchemaMemoryProvider","SchemaSelectEx","onChange","variant","props","schema","setSchema","schemaList","useSchema","React","SelectEx","size","value","event","child","target","renderValue","Typography","map","index","MenuItem","key"]}
|
package/package.json
CHANGED
|
@@ -10,37 +10,37 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/hex": "^3.6.
|
|
14
|
-
"@xylabs/lodash": "^3.6.
|
|
15
|
-
"@xylabs/react-async-effect": "^3.4.
|
|
16
|
-
"@xylabs/react-link": "^3.4.
|
|
17
|
-
"@xylabs/react-select": "^3.4.
|
|
18
|
-
"@xylabs/react-shared": "^3.4.
|
|
19
|
-
"@xyo-network/diviner-schema-list-model": "^2.
|
|
20
|
-
"@xyo-network/diviner-schema-stats-model": "^2.
|
|
13
|
+
"@xylabs/hex": "^3.6.12",
|
|
14
|
+
"@xylabs/lodash": "^3.6.12",
|
|
15
|
+
"@xylabs/react-async-effect": "^3.4.2",
|
|
16
|
+
"@xylabs/react-link": "^3.4.2",
|
|
17
|
+
"@xylabs/react-select": "^3.4.2",
|
|
18
|
+
"@xylabs/react-shared": "^3.4.2",
|
|
19
|
+
"@xyo-network/diviner-schema-list-model": "^2.111.3",
|
|
20
|
+
"@xyo-network/diviner-schema-stats-model": "^2.111.3",
|
|
21
21
|
"@xyo-network/node-core-types": "^2.89.1",
|
|
22
|
-
"@xyo-network/payload-builder": "^2.
|
|
23
|
-
"@xyo-network/payload-model": "^2.
|
|
24
|
-
"@xyo-network/react-diviner": "^2.
|
|
25
|
-
"@xyo-network/react-event": "^2.
|
|
26
|
-
"@xyo-network/react-property": "^2.
|
|
27
|
-
"@xyo-network/react-shared": "^2.
|
|
28
|
-
"@xyo-network/schema-cache": "^2.
|
|
29
|
-
"@xyo-network/schema-payload-plugin": "^2.
|
|
30
|
-
"react-router-dom": "^6.
|
|
22
|
+
"@xyo-network/payload-builder": "^2.111.3",
|
|
23
|
+
"@xyo-network/payload-model": "^2.111.3",
|
|
24
|
+
"@xyo-network/react-diviner": "^2.82.0",
|
|
25
|
+
"@xyo-network/react-event": "^2.82.0",
|
|
26
|
+
"@xyo-network/react-property": "^2.82.0",
|
|
27
|
+
"@xyo-network/react-shared": "^2.82.0",
|
|
28
|
+
"@xyo-network/schema-cache": "^2.111.3",
|
|
29
|
+
"@xyo-network/schema-payload-plugin": "^2.111.3",
|
|
30
|
+
"react-router-dom": "^6.26.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@storybook/react": "^
|
|
34
|
-
"@xylabs/react-flexbox": "^3.4.
|
|
35
|
-
"@xylabs/ts-scripts-yarn3": "^3.
|
|
36
|
-
"@xylabs/tsconfig-react": "^3.
|
|
37
|
-
"@xyo-network/bridge-http": "^2.
|
|
38
|
-
"@xyo-network/node-memory": "^2.
|
|
39
|
-
"@xyo-network/node-model": "^2.
|
|
40
|
-
"@xyo-network/react-node": "^2.
|
|
41
|
-
"@xyo-network/react-payload-raw-info": "^2.
|
|
42
|
-
"@xyo-network/react-storybook": "^2.
|
|
43
|
-
"@xyo-network/react-wallet": "^2.
|
|
33
|
+
"@storybook/react": "^8.2.7",
|
|
34
|
+
"@xylabs/react-flexbox": "^3.4.2",
|
|
35
|
+
"@xylabs/ts-scripts-yarn3": "^3.15.16",
|
|
36
|
+
"@xylabs/tsconfig-react": "^3.15.16",
|
|
37
|
+
"@xyo-network/bridge-http": "^2.111.3",
|
|
38
|
+
"@xyo-network/node-memory": "^2.111.3",
|
|
39
|
+
"@xyo-network/node-model": "^2.111.3",
|
|
40
|
+
"@xyo-network/react-node": "^2.82.0",
|
|
41
|
+
"@xyo-network/react-payload-raw-info": "^2.82.0",
|
|
42
|
+
"@xyo-network/react-storybook": "^2.82.0",
|
|
43
|
+
"@xyo-network/react-wallet": "^2.82.0",
|
|
44
44
|
"typescript": "^5.5.4"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"node": {
|
|
60
60
|
"import": {
|
|
61
61
|
"types": "./dist/node/index.d.mts",
|
|
62
|
-
"default": "./dist/node/index.
|
|
62
|
+
"default": "./dist/node/index.mjs"
|
|
63
63
|
},
|
|
64
64
|
"require": {
|
|
65
65
|
"types": "./dist/node/index.d.cts",
|
|
@@ -69,19 +69,19 @@
|
|
|
69
69
|
"browser": {
|
|
70
70
|
"import": {
|
|
71
71
|
"types": "./dist/browser/index.d.mts",
|
|
72
|
-
"default": "./dist/browser/index.
|
|
72
|
+
"default": "./dist/browser/index.mjs"
|
|
73
73
|
},
|
|
74
74
|
"require": {
|
|
75
75
|
"types": "./dist/browser/index.d.cts",
|
|
76
76
|
"default": "./dist/browser/index.cjs"
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
|
-
"default": "./dist/browser/index.
|
|
79
|
+
"default": "./dist/browser/index.mjs"
|
|
80
80
|
},
|
|
81
81
|
"./package.json": "./package.json"
|
|
82
82
|
},
|
|
83
83
|
"main": "dist/browser/index.cjs",
|
|
84
|
-
"module": "dist/browser/index.
|
|
84
|
+
"module": "dist/browser/index.mjs",
|
|
85
85
|
"homepage": "https://xyo.network",
|
|
86
86
|
"keywords": [
|
|
87
87
|
"xyo",
|
|
@@ -103,6 +103,6 @@
|
|
|
103
103
|
},
|
|
104
104
|
"sideEffects": false,
|
|
105
105
|
"types": "dist/browser/index.d.ts",
|
|
106
|
-
"version": "2.
|
|
106
|
+
"version": "2.82.0",
|
|
107
107
|
"type": "module"
|
|
108
108
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Meta, StoryFn } from '@storybook/react'
|
|
2
2
|
import { useEvent } from '@xyo-network/react-event'
|
|
3
|
+
import React from 'react'
|
|
3
4
|
|
|
4
|
-
import { SchemaProperty, SchemaPropertyProps } from './SchemaProperty.
|
|
5
|
+
import { SchemaProperty, SchemaPropertyProps } from './SchemaProperty.tsx'
|
|
5
6
|
|
|
6
7
|
const StorybookEntry: Meta = {
|
|
7
8
|
component: SchemaProperty,
|
|
@@ -38,5 +39,4 @@ WithUnverifiedValue.args = { value: 'network.xyo.blahblah' }
|
|
|
38
39
|
|
|
39
40
|
export { Default, WithUnverifiedValue, WithVerifiedValue, WithVerifiedValuePaper }
|
|
40
41
|
|
|
41
|
-
// eslint-disable-next-line import/no-default-export
|
|
42
42
|
export default StorybookEntry
|
|
@@ -5,7 +5,7 @@ import { LinkEx } from '@xylabs/react-link'
|
|
|
5
5
|
import { EventDispatch, EventNoun, useEvent } from '@xyo-network/react-event'
|
|
6
6
|
import { Property, PropertyProps, PropertyValue } from '@xyo-network/react-property'
|
|
7
7
|
import { SchemaCache, SchemaCacheEntry } from '@xyo-network/schema-cache'
|
|
8
|
-
import { forwardRef, useState } from 'react'
|
|
8
|
+
import React, { forwardRef, useState } from 'react'
|
|
9
9
|
|
|
10
10
|
export type SchemaPropertyProps = PropertyProps & {
|
|
11
11
|
showLinkNames?: boolean
|
|
@@ -17,7 +17,6 @@ export type SchemaPropertyProps = PropertyProps & {
|
|
|
17
17
|
const useResolveSchema = (schema?: string) => {
|
|
18
18
|
const [entry, setEntry] = useState<SchemaCacheEntry | null>()
|
|
19
19
|
useAsyncEffect(
|
|
20
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21
20
|
async (mounted) => {
|
|
22
21
|
if (schema) {
|
|
23
22
|
const entry = await SchemaCache.instance.get(schema)
|
|
@@ -50,34 +49,46 @@ export const SchemaProperty = forwardRef<HTMLDivElement, SchemaPropertyProps>(
|
|
|
50
49
|
|
|
51
50
|
return (
|
|
52
51
|
<Property ref={forwardedRef} title="Schema" value={value} tip="Schema sent with the payload" titleProps={titleProps} {...props}>
|
|
53
|
-
{value && showStatusIcon
|
|
54
|
-
resolvedSchema === null
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
{value && showStatusIcon
|
|
53
|
+
? resolvedSchema === null
|
|
54
|
+
? (
|
|
55
|
+
<IconButton ref={buttonRef} size="small" onClick={() => onClick(buttonDispatch)}>
|
|
56
|
+
<NewReleasesIcon color="warning" fontSize="inherit" />
|
|
57
|
+
</IconButton>
|
|
58
|
+
)
|
|
59
|
+
: resolvedSchema === undefined
|
|
60
|
+
? (
|
|
61
|
+
<IconButton ref={buttonRef} size="small" onClick={() => onClick(buttonDispatch)}>
|
|
62
|
+
<NewReleasesIcon color="disabled" fontSize="inherit" />
|
|
63
|
+
</IconButton>
|
|
64
|
+
)
|
|
65
|
+
: (
|
|
66
|
+
<IconButton rel="noopener noreferrer" size="small" target="_blank" href={resolvedSchema?.huri?.href ?? ''}>
|
|
67
|
+
<VerifiedIcon color="success" fontSize="inherit" />
|
|
68
|
+
</IconButton>
|
|
69
|
+
)
|
|
65
70
|
|
|
66
|
-
|
|
67
|
-
{value
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
: null}
|
|
72
|
+
{value
|
|
73
|
+
? (
|
|
74
|
+
<>
|
|
75
|
+
{showLinkNames
|
|
76
|
+
? (
|
|
77
|
+
<LinkEx display="block" width="100%" sx={{ cursor: 'pointer' }}>
|
|
78
|
+
<PropertyValue ref={divRef} value={value} title="view schema" onClick={() => onClick(divDispatch)} />
|
|
79
|
+
</LinkEx>
|
|
80
|
+
)
|
|
81
|
+
: <PropertyValue ref={divRef} value={value} title="view schema" onClick={() => onClick(divDispatch)} />}
|
|
82
|
+
{showOpenNewWindowLink
|
|
83
|
+
? (
|
|
84
|
+
<IconButton ref={buttonRef} size="small" onClick={() => onClick(buttonDispatch, true)}>
|
|
85
|
+
<OpenInNewIcon fontSize="inherit" />
|
|
86
|
+
</IconButton>
|
|
87
|
+
)
|
|
88
|
+
: null}
|
|
89
|
+
</>
|
|
90
|
+
)
|
|
91
|
+
: null}
|
|
81
92
|
</Property>
|
|
82
93
|
)
|
|
83
94
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './SchemaProperty.
|
|
1
|
+
export * from './SchemaProperty.tsx'
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { MenuItem, Typography } from '@mui/material'
|
|
2
2
|
import { SelectEx, SelectExProps } from '@xylabs/react-select'
|
|
3
|
+
import React from 'react'
|
|
3
4
|
|
|
4
|
-
import { useSchema } from '../../contexts/index.
|
|
5
|
+
import { useSchema } from '../../contexts/index.ts'
|
|
5
6
|
|
|
6
7
|
export type SchemaSelectExProps = SelectExProps<string>
|
|
7
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './SchemaSelectEx.
|
|
1
|
+
export * from './SchemaSelectEx.tsx'
|
package/src/components/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './Property/index.
|
|
2
|
-
export * from './SelectEx/index.
|
|
1
|
+
export * from './Property/index.ts'
|
|
2
|
+
export * from './SelectEx/index.ts'
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { compact } from '@xylabs/lodash'
|
|
2
2
|
import { WithChildren } from '@xylabs/react-shared'
|
|
3
|
-
import { useEffect, useState } from 'react'
|
|
3
|
+
import React, { useEffect, useMemo, useState } from 'react'
|
|
4
4
|
|
|
5
|
-
import { useSchemaStats } from '../../../hooks/index.
|
|
6
|
-
import { SchemaContext } from '../Context.
|
|
7
|
-
import { SchemaProviderProps } from './Props.
|
|
5
|
+
import { useSchemaStats } from '../../../hooks/index.ts'
|
|
6
|
+
import { SchemaContext } from '../Context.ts'
|
|
7
|
+
import { SchemaProviderProps } from './Props.ts'
|
|
8
8
|
|
|
9
|
-
export const SchemaMemoryProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ defaultSchema, knownSchemaList
|
|
9
|
+
export const SchemaMemoryProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ defaultSchema, knownSchemaList, ...props }) => {
|
|
10
10
|
const [schema, setSchema] = useState(defaultSchema)
|
|
11
11
|
const [schemaList, setSchemaList] = useState<string[] | undefined>(knownSchemaList)
|
|
12
12
|
const [fetchedSchemaStats] = useSchemaStats()
|
|
@@ -18,5 +18,7 @@ export const SchemaMemoryProvider: React.FC<WithChildren<SchemaProviderProps>> =
|
|
|
18
18
|
}
|
|
19
19
|
}, [fetchedSchemaStats])
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const value = useMemo(() => ({ provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList }), [schema, schemaList, knownSchemaList])
|
|
22
|
+
|
|
23
|
+
return <SchemaContext.Provider value={value} {...props} />
|
|
22
24
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { WithChildren } from '@xylabs/react-shared'
|
|
2
|
-
import { useCallback, useEffect } from 'react'
|
|
2
|
+
import React, { useCallback, useEffect, useMemo } from 'react'
|
|
3
3
|
import { useSearchParams } from 'react-router-dom'
|
|
4
4
|
|
|
5
|
-
import { SchemaContext } from '../Context.
|
|
6
|
-
import { useSchema } from '../use.
|
|
7
|
-
import { SchemaMemoryProvider } from './Memory.
|
|
8
|
-
import { SchemaProviderProps } from './Props.
|
|
5
|
+
import { SchemaContext } from '../Context.ts'
|
|
6
|
+
import { useSchema } from '../use.ts'
|
|
7
|
+
import { SchemaMemoryProvider } from './Memory.tsx'
|
|
8
|
+
import { SchemaProviderProps } from './Props.ts'
|
|
9
9
|
|
|
10
10
|
const SchemaRouteProviderInner: React.FC<WithChildren> = ({ children }) => {
|
|
11
11
|
const { schema, setSchema, schemaList } = useSchema()
|
|
@@ -14,7 +14,7 @@ const SchemaRouteProviderInner: React.FC<WithChildren> = ({ children }) => {
|
|
|
14
14
|
|
|
15
15
|
const routeSchema = params.get('schema')
|
|
16
16
|
|
|
17
|
-
//update the network stored in the route
|
|
17
|
+
// update the network stored in the route
|
|
18
18
|
const setSchemaParam = useCallback(
|
|
19
19
|
(schema?: string) => {
|
|
20
20
|
if (schema) {
|
|
@@ -28,7 +28,7 @@ const SchemaRouteProviderInner: React.FC<WithChildren> = ({ children }) => {
|
|
|
28
28
|
[params, setParams, setSchema],
|
|
29
29
|
)
|
|
30
30
|
|
|
31
|
-
//if the network is actively changed, update both memory and route
|
|
31
|
+
// if the network is actively changed, update both memory and route
|
|
32
32
|
const setSchemaLocal = useCallback(
|
|
33
33
|
(schema: string) => {
|
|
34
34
|
setSchemaParam(schema)
|
|
@@ -37,20 +37,22 @@ const SchemaRouteProviderInner: React.FC<WithChildren> = ({ children }) => {
|
|
|
37
37
|
[setSchemaParam, setSchema],
|
|
38
38
|
)
|
|
39
39
|
|
|
40
|
-
//sync memory and route storage of network
|
|
40
|
+
// sync memory and route storage of network
|
|
41
41
|
useEffect(() => {
|
|
42
42
|
if (routeSchema !== schema) {
|
|
43
43
|
if (routeSchema === undefined && schema !== undefined) {
|
|
44
|
-
//if the route does not have a network selected, use what is in the memory context
|
|
44
|
+
// if the route does not have a network selected, use what is in the memory context
|
|
45
45
|
setSchemaLocal(schema)
|
|
46
46
|
} else if (routeSchema) {
|
|
47
|
-
//if the route has a selection and it is different from memory, update memory
|
|
47
|
+
// if the route has a selection and it is different from memory, update memory
|
|
48
48
|
setSchema?.(routeSchema)
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}, [routeSchema, schema, setSchemaParam, setSchema, setSchemaLocal])
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
const value = useMemo(() => ({ provided: true, schema, schemaList, setSchema: setSchemaLocal }), [schema, schemaList, setSchemaLocal])
|
|
54
|
+
|
|
55
|
+
return <SchemaContext.Provider value={value}>{children}</SchemaContext.Provider>
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
export const SchemaRouteProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ knownSchemaList, defaultSchema, ...props }) => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './Memory.
|
|
2
|
-
export * from './Props.
|
|
3
|
-
export * from './Route.
|
|
1
|
+
export * from './Memory.tsx'
|
|
2
|
+
export * from './Props.ts'
|
|
3
|
+
export * from './Route.tsx'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './Context.
|
|
2
|
-
export * from './Provider/index.
|
|
3
|
-
export * from './State.
|
|
4
|
-
export * from './use.
|
|
1
|
+
export * from './Context.ts'
|
|
2
|
+
export * from './Provider/index.ts'
|
|
3
|
+
export * from './State.ts'
|
|
4
|
+
export * from './use.ts'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContextEx } from '@xyo-network/react-shared'
|
|
2
2
|
|
|
3
|
-
import { SchemaContext } from './Context.
|
|
4
|
-
import { SchemaContextState } from './State.
|
|
3
|
+
import { SchemaContext } from './Context.ts'
|
|
4
|
+
import { SchemaContextState } from './State.ts'
|
|
5
5
|
|
|
6
6
|
export const useSchema = (required = false) => {
|
|
7
7
|
return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)
|
package/src/contexts/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './Schema/index.
|
|
1
|
+
export * from './Schema/index.ts'
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './useGetSchema.
|
|
2
|
-
export * from './useSchemaDefinitions.
|
|
3
|
-
export * from './useSchemaList.
|
|
4
|
-
export * from './useSchemaStats.
|
|
1
|
+
export * from './useGetSchema.tsx'
|
|
2
|
+
export * from './useSchemaDefinitions.tsx'
|
|
3
|
+
export * from './useSchemaList.tsx'
|
|
4
|
+
export * from './useSchemaStats.tsx'
|
|
@@ -10,11 +10,11 @@ import { NodeProvider } from '@xyo-network/react-node'
|
|
|
10
10
|
import { DefaultSeedPhrase } from '@xyo-network/react-storybook'
|
|
11
11
|
import { useWallet, WalletProvider } from '@xyo-network/react-wallet'
|
|
12
12
|
import { SchemaCache } from '@xyo-network/schema-cache'
|
|
13
|
-
import { useState } from 'react'
|
|
13
|
+
import React, { useState } from 'react'
|
|
14
14
|
|
|
15
|
-
import { useSchemaDefinitions } from '../useSchemaDefinitions.
|
|
16
|
-
import { useSchemaList } from '../useSchemaList.
|
|
17
|
-
import { useSchemaStats } from '../useSchemaStats.
|
|
15
|
+
import { useSchemaDefinitions } from '../useSchemaDefinitions.tsx'
|
|
16
|
+
import { useSchemaList } from '../useSchemaList.tsx'
|
|
17
|
+
import { useSchemaStats } from '../useSchemaStats.tsx'
|
|
18
18
|
|
|
19
19
|
const apiConfig = { apiDomain: 'https://api.archivist.xyo.network' }
|
|
20
20
|
const nodeUrl = 'http://localhost:8080/node'
|
|
@@ -23,7 +23,6 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
|
|
|
23
23
|
const [node, setNode] = useState<MemoryNode>()
|
|
24
24
|
|
|
25
25
|
useAsyncEffect(
|
|
26
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27
26
|
async () => {
|
|
28
27
|
const node = await MemoryNode.create({ config: { schema: NodeConfigSchema } })
|
|
29
28
|
const bridge = await HttpBridge.create({ config: { nodeUrl, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true } } })
|
|
@@ -45,7 +44,6 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
|
|
|
45
44
|
)
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
// eslint-disable-next-line import/no-default-export
|
|
49
47
|
export default {
|
|
50
48
|
decorators: [MemoryNodeDecorator],
|
|
51
49
|
title: 'schema/Hooks',
|
|
@@ -57,29 +55,29 @@ const Template: StoryFn<React.FC> = () => {
|
|
|
57
55
|
const [address, setAddress] = useState<Address>()
|
|
58
56
|
const [schemaStats, schemaStatsError] = useSchemaStats(address)
|
|
59
57
|
const [schemaList, schemaListError] = useSchemaList(address)
|
|
60
|
-
const mappedSchemaList = schemaList?.schemas?.map(
|
|
58
|
+
const mappedSchemaList = schemaList?.schemas?.map(name => ({ name })) as { name: string }[]
|
|
61
59
|
const schemaDefinitions = useSchemaDefinitions(mappedSchemaList)
|
|
62
60
|
|
|
63
61
|
return (
|
|
64
62
|
<div style={{ display: 'flex', flexDirection: 'column', rowGap: '16px' }}>
|
|
65
|
-
{schemaStatsError
|
|
66
|
-
<Alert severity=
|
|
67
|
-
|
|
63
|
+
{schemaStatsError
|
|
64
|
+
? <Alert severity="error">{schemaStatsError.message ?? schemaListError?.message}</Alert>
|
|
65
|
+
: null}
|
|
68
66
|
<FlexGrowRow columnGap={4}>
|
|
69
|
-
<TextField fullWidth size="small" value={address} label="Address" onChange={
|
|
67
|
+
<TextField fullWidth size="small" value={address} label="Address" onChange={event => setAddressText(event.target.value as Address)} />
|
|
70
68
|
<Button variant="contained" onClick={() => setAddress(addressText)} sx={{ whiteSpace: 'nowrap' }}>
|
|
71
69
|
Get Stats
|
|
72
70
|
</Button>
|
|
73
71
|
</FlexGrowRow>
|
|
74
|
-
<Typography variant=
|
|
72
|
+
<Typography variant="h2">Schema Stats</Typography>
|
|
75
73
|
<code>
|
|
76
74
|
<pre>{JSON.stringify(schemaStats, null, 2)}</pre>
|
|
77
75
|
</code>
|
|
78
|
-
<Typography variant=
|
|
76
|
+
<Typography variant="h2">Schema List</Typography>
|
|
79
77
|
<code>
|
|
80
78
|
<pre>{JSON.stringify(schemaList, null, 2)}</pre>
|
|
81
79
|
</code>
|
|
82
|
-
<Typography variant=
|
|
80
|
+
<Typography variant="h2">Schema Definitions</Typography>
|
|
83
81
|
<pre>
|
|
84
82
|
<code>{JSON.stringify(schemaDefinitions, null, 2)}</code>
|
|
85
83
|
</pre>
|
|
@@ -3,9 +3,9 @@ import { Meta, StoryFn } from '@storybook/react'
|
|
|
3
3
|
import { FlexRow } from '@xylabs/react-flexbox'
|
|
4
4
|
import { JsonViewerEx } from '@xyo-network/react-payload-raw-info'
|
|
5
5
|
import { SchemaCache } from '@xyo-network/schema-cache'
|
|
6
|
-
import { useEffect, useState } from 'react'
|
|
6
|
+
import React, { useEffect, useState } from 'react'
|
|
7
7
|
|
|
8
|
-
import { useGetSchemaPayload } from './useGetSchema.
|
|
8
|
+
import { useGetSchemaPayload } from './useGetSchema.tsx'
|
|
9
9
|
|
|
10
10
|
SchemaCache.instance.proxy = 'https://beta.api.archivist.xyo.network/domain'
|
|
11
11
|
|
|
@@ -37,7 +37,7 @@ const UseGetSchemaComponent: React.FC<{ schema: string }> = ({ schema }) => {
|
|
|
37
37
|
))}
|
|
38
38
|
</Typography>
|
|
39
39
|
<FormControl>
|
|
40
|
-
<TextField value={schemaFieldValue} label="Schema Name" onChange={
|
|
40
|
+
<TextField value={schemaFieldValue} label="Schema Name" onChange={e => setSchemaFieldValue(e.target.value)} />
|
|
41
41
|
</FormControl>
|
|
42
42
|
<FlexRow my={3} justifyContent="start">
|
|
43
43
|
<JsonViewerEx value={schemaPayload || {}} />
|
|
@@ -69,5 +69,4 @@ Domain.args = { schema: 'network.xyo.domain' }
|
|
|
69
69
|
|
|
70
70
|
export { Default, Domain }
|
|
71
71
|
|
|
72
|
-
// eslint-disable-next-line import/no-default-export
|
|
73
72
|
export default StorybookEntry
|
|
@@ -15,7 +15,6 @@ const useGetSchemaPayload = (schema?: string) => {
|
|
|
15
15
|
const [schemaLocal, setSchemaLocal] = useState<string>()
|
|
16
16
|
|
|
17
17
|
useAsyncEffect(
|
|
18
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
18
|
async (mounted) => {
|
|
20
19
|
const firstRequest = !notFound && !schemaCacheEntry && !xyoError
|
|
21
20
|
const schemaChanged = schema !== schemaLocal
|
|
@@ -8,15 +8,14 @@ export type SchemaList = { name: string }
|
|
|
8
8
|
export const useSchemaDefinitions = (schemaList?: SchemaList[]): SchemaPayload[] | undefined => {
|
|
9
9
|
const [schemaPayloads, setSchemaPayloads] = useState<SchemaPayload[]>()
|
|
10
10
|
useAsyncEffect(
|
|
11
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
12
11
|
async (mounted) => {
|
|
13
12
|
if (schemaList) {
|
|
14
13
|
const promiseResults = await Promise.allSettled(schemaList?.map(({ name }) => SchemaCache.instance.get(name)))
|
|
15
14
|
if (mounted()) {
|
|
16
15
|
setSchemaPayloads(
|
|
17
16
|
promiseResults
|
|
18
|
-
.map(
|
|
19
|
-
.filter(
|
|
17
|
+
.map(result => (result.status === 'fulfilled' ? result.value?.payload : undefined))
|
|
18
|
+
.filter(item => item !== undefined && item !== null) as SchemaPayload[],
|
|
20
19
|
)
|
|
21
20
|
}
|
|
22
21
|
}
|
|
@@ -12,14 +12,14 @@ export const useSchemaList = (address?: Address, nameOrAddress = 'SchemaListDivi
|
|
|
12
12
|
|
|
13
13
|
const query: SchemaListQueryPayload[] | undefined = useMemo(
|
|
14
14
|
() =>
|
|
15
|
-
address
|
|
16
|
-
[
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
address
|
|
16
|
+
? [
|
|
17
|
+
{
|
|
18
|
+
address,
|
|
19
|
+
schema: SchemaListQuerySchema,
|
|
20
|
+
},
|
|
21
|
+
]
|
|
22
|
+
: undefined,
|
|
23
23
|
[address],
|
|
24
24
|
)
|
|
25
25
|
|
|
@@ -31,7 +31,6 @@ export const useSchemaList = (address?: Address, nameOrAddress = 'SchemaListDivi
|
|
|
31
31
|
}, [diviner])
|
|
32
32
|
|
|
33
33
|
useAsyncEffect(
|
|
34
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps, require-await
|
|
35
34
|
async (mounted) => {
|
|
36
35
|
const divinerInstance = diviner?.deref()
|
|
37
36
|
if (divinerInstance) {
|