@xyo-network/react-schema 2.46.7 → 2.46.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/cjs/components/Property/SchemaProperty.js +14 -5
  2. package/dist/cjs/components/Property/SchemaProperty.js.map +1 -1
  3. package/dist/cjs/hooks/index.js +1 -0
  4. package/dist/cjs/hooks/index.js.map +1 -1
  5. package/dist/cjs/hooks/useSchemaList.js +41 -0
  6. package/dist/cjs/hooks/useSchemaList.js.map +1 -0
  7. package/dist/cjs/hooks/useSchemaStats.js +1 -1
  8. package/dist/cjs/hooks/useSchemaStats.js.map +1 -1
  9. package/dist/docs.json +358 -137
  10. package/dist/esm/components/Property/SchemaProperty.js +15 -5
  11. package/dist/esm/components/Property/SchemaProperty.js.map +1 -1
  12. package/dist/esm/hooks/index.js +1 -0
  13. package/dist/esm/hooks/index.js.map +1 -1
  14. package/dist/esm/hooks/useSchemaList.js +36 -0
  15. package/dist/esm/hooks/useSchemaList.js.map +1 -0
  16. package/dist/esm/hooks/useSchemaStats.js +1 -1
  17. package/dist/esm/hooks/useSchemaStats.js.map +1 -1
  18. package/dist/types/components/Property/SchemaProperty.d.ts +44 -1
  19. package/dist/types/components/Property/SchemaProperty.d.ts.map +1 -1
  20. package/dist/types/hooks/index.d.ts +1 -0
  21. package/dist/types/hooks/index.d.ts.map +1 -1
  22. package/dist/types/hooks/useSchemaList.d.ts +4 -0
  23. package/dist/types/hooks/useSchemaList.d.ts.map +1 -0
  24. package/package.json +18 -16
  25. package/src/components/Property/SchemaProperty.stories.tsx +18 -10
  26. package/src/components/Property/SchemaProperty.tsx +62 -33
  27. package/src/hooks/index.ts +1 -0
  28. package/src/hooks/stories/TestSchemaHooks.stories.tsx +26 -26
  29. package/src/hooks/useSchemaList.tsx +48 -0
  30. package/src/hooks/useSchemaStats.tsx +1 -1
@@ -1,13 +1,14 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import NewReleasesIcon from '@mui/icons-material/NewReleases';
3
3
  import OpenInNewIcon from '@mui/icons-material/OpenInNew';
4
4
  import VerifiedIcon from '@mui/icons-material/Verified';
5
5
  import { IconButton } from '@mui/material';
6
6
  import { LinkEx } from '@xylabs/react-link';
7
7
  import { useAsyncEffect } from '@xylabs/react-shared';
8
+ import { useXyoEvent } from '@xyo-network/react-event';
8
9
  import { Property, PropertyValue } from '@xyo-network/react-property';
9
10
  import { XyoSchemaCache } from '@xyo-network/utils';
10
- import { useState } from 'react';
11
+ import { forwardRef, useState } from 'react';
11
12
  const useResolveSchema = (schema) => {
12
13
  const [entry, setEntry] = useState();
13
14
  useAsyncEffect(
@@ -22,8 +23,17 @@ const useResolveSchema = (schema) => {
22
23
  }, [schema]);
23
24
  return entry;
24
25
  };
25
- export const SchemaProperty = ({ titleProps, value, viewSchemaUrl = 'https://explore.xyo.network/', ...props }) => {
26
+ export const SchemaProperty = forwardRef(({ showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props }, forwardedRef) => {
26
27
  const resolvedSchema = useResolveSchema(value);
27
- return (_jsxs(Property, { title: "Schema", value: value, tip: "Schema sent with the payload", titleProps: titleProps, ...props, children: [value ? (resolvedSchema === null ? (_jsx(IconButton, { rel: "noopener noreferrer", size: "small", target: "_blank", href: `${viewSchemaUrl}${value}`, children: _jsx(NewReleasesIcon, { color: "warning", fontSize: "inherit" }) })) : resolvedSchema === undefined ? (_jsx(IconButton, { rel: "noopener noreferrer", size: "small", target: "_blank", href: `${viewSchemaUrl}${value}`, children: _jsx(NewReleasesIcon, { color: "disabled", fontSize: "inherit" }) })) : (_jsx(IconButton, { rel: "noopener noreferrer", size: "small", target: "_blank", href: resolvedSchema?.huri?.href ?? '', children: _jsx(VerifiedIcon, { color: "success", fontSize: "inherit" }) }))) : null, value ? (_jsx(LinkEx, { flexGrow: 1, alignItems: "center", href: `${viewSchemaUrl}${value}`, rel: "noopener noreferrer", display: "flex", children: _jsx(PropertyValue, { value: value, title: "view schema in new window" }) })) : null, value ? (_jsx(LinkEx, { marginX: 1, alignItems: "center", href: `${viewSchemaUrl}${value}`, target: "_blank", rel: "noopener noreferrer", display: "flex", children: _jsx(OpenInNewIcon, { fontSize: "inherit" }) })) : null] }));
28
- };
28
+ const [buttonRef, buttonDispatch] = useXyoEvent(undefined);
29
+ const [divRef, divDispatch] = useXyoEvent(undefined);
30
+ const onClick = (dispatch, openNewWindow = false) => {
31
+ dispatch?.('schema', 'click', JSON.stringify({
32
+ openNewWindow,
33
+ schema: value,
34
+ }));
35
+ };
36
+ return (_jsxs(Property, { ref: forwardedRef, title: "Schema", value: value, tip: "Schema sent with the payload", titleProps: titleProps, ...props, children: [value && showStatusIcon ? (resolvedSchema === null ? (_jsx(IconButton, { ref: buttonRef, size: "small", onClick: () => onClick(buttonDispatch), children: _jsx(NewReleasesIcon, { color: "warning", fontSize: "inherit" }) })) : resolvedSchema === undefined ? (_jsx(IconButton, { ref: buttonRef, size: "small", onClick: () => onClick(buttonDispatch), children: _jsx(NewReleasesIcon, { color: "disabled", fontSize: "inherit" }) })) : (_jsx(IconButton, { rel: "noopener noreferrer", size: "small", target: "_blank", href: resolvedSchema?.huri?.href ?? '', children: _jsx(VerifiedIcon, { color: "success", fontSize: "inherit" }) }))) : null, value ? (_jsxs(_Fragment, { children: [showLinkNames ? (_jsx(LinkEx, { display: "block", width: "100%", sx: { cursor: 'pointer' }, children: _jsx(PropertyValue, { ref: divRef, value: value, title: "view schema", onClick: () => onClick(divDispatch) }) })) : (_jsx(PropertyValue, { ref: divRef, value: value, title: "view schema", onClick: () => onClick(divDispatch) })), showOpenNewWindowLink ? (_jsx(IconButton, { ref: buttonRef, size: "small", onClick: () => onClick(buttonDispatch, true), children: _jsx(OpenInNewIcon, { fontSize: "inherit" }) })) : null] })) : null] }));
37
+ });
38
+ SchemaProperty.displayName = 'SchemaProperty';
29
39
  //# sourceMappingURL=SchemaProperty.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaProperty.js","sourceRoot":"","sources":["../../../../src/components/Property/SchemaProperty.tsx"],"names":[],"mappings":";AAAA,OAAO,eAAe,MAAM,iCAAiC,CAAA;AAC7D,OAAO,aAAa,MAAM,+BAA+B,CAAA;AACzD,OAAO,YAAY,MAAM,8BAA8B,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAiB,aAAa,EAAE,MAAM,6BAA6B,CAAA;AACpF,OAAO,EAAE,cAAc,EAAuB,MAAM,oBAAoB,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAOhC,MAAM,gBAAgB,GAAG,CAAC,MAAe,EAAE,EAAE;IAC3C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAA8B,CAAA;IAChE,cAAc;IACZ,uDAAuD;IACvD,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IAAI,MAAM,EAAE;YACV,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YACvD,IAAI,OAAO,EAAE,EAAE;gBACb,QAAQ,CAAC,KAAK,CAAC,CAAA;aAChB;SACF;IACH,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAA;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAkC,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,GAAG,8BAA8B,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IAC/I,MAAM,cAAc,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;IAC9C,O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,SAAS,EAAE,IAAI,EAAC,OAAO,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,YACnF,KAAC,aAAa,IAAC,QAAQ,EAAC,SAAS,GAAG,GACzB,CACd,CAAC,CAAC,CAAC,IAAI,IACP,CACJ,CAAC,CAAC,CAAC,IAAI,IACC,CACZ,CAAA;AACH,CAAC,CACF,CAAA;AAED,cAAc,CAAC,WAAW,GAAG,gBAAgB,CAAA"}
@@ -1,4 +1,5 @@
1
1
  export * from './useGetSchema';
2
2
  export * from './useSchemaDefinitions';
3
+ export * from './useSchemaList';
3
4
  export * from './useSchemaStats';
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,36 @@
1
+ import { useAsyncEffect } from '@xylabs/react-shared';
2
+ import { SchemaListQuerySchema } from '@xyo-network/node-core-model';
3
+ import { useDiviner } from '@xyo-network/react-diviner';
4
+ import { useMemo, useState } from 'react';
5
+ export const useSchemaList = (address, nameOrAddress = 'SchemaListDiviner', account) => {
6
+ const [schemaList, setSchemaList] = useState();
7
+ const [error, setError] = useState();
8
+ const [diviner, divinerError] = useDiviner(nameOrAddress, account);
9
+ const query = useMemo(() => address
10
+ ? [
11
+ {
12
+ address,
13
+ schema: SchemaListQuerySchema,
14
+ },
15
+ ]
16
+ : undefined, [address]);
17
+ useAsyncEffect(
18
+ // eslint-disable-next-line react-hooks/exhaustive-deps, require-await
19
+ async (mounted) => {
20
+ if (diviner) {
21
+ try {
22
+ const response = (await diviner.divine(query));
23
+ if (mounted()) {
24
+ setSchemaList(response?.[0]);
25
+ setError(undefined);
26
+ }
27
+ }
28
+ catch (e) {
29
+ setError(e);
30
+ setSchemaList(undefined);
31
+ }
32
+ }
33
+ }, [diviner, divinerError, query]);
34
+ return [schemaList, error];
35
+ };
36
+ //# sourceMappingURL=useSchemaList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSchemaList.js","sourceRoot":"","sources":["../../../src/hooks/useSchemaList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,OAAO,EAA6C,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEzC,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAAgB,EAChB,aAAa,GAAG,mBAAmB,EACnC,OAAyB,EAC2B,EAAE;IACtD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,EAAqB,CAAA;IACjE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAS,CAAA;IAC3C,MAAM,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,UAAU,CAAC,aAAa,EAAE,OAAO,CAAC,CAAA;IAElE,MAAM,KAAK,GAAyC,OAAO,CACzD,GAAG,EAAE,CACH,OAAO;QACL,CAAC,CAAC;YACE;gBACE,OAAO;gBACP,MAAM,EAAE,qBAAqB;aAC9B;SACF;QACH,CAAC,CAAC,SAAS,EACf,CAAC,OAAO,CAAC,CACV,CAAA;IAED,cAAc;IACZ,sEAAsE;IACtE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IAAI,OAAO,EAAE;YACX,IAAI;gBACF,MAAM,QAAQ,GAAG,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAwB,CAAA;gBACrE,IAAI,OAAO,EAAE,EAAE;oBACb,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;oBAC5B,QAAQ,CAAC,SAAS,CAAC,CAAA;iBACpB;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,QAAQ,CAAC,CAAU,CAAC,CAAA;gBACpB,aAAa,CAAC,SAAS,CAAC,CAAA;aACzB;SACF;IACH,CAAC,EACD,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,CAAC,CAC/B,CAAA;IACD,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;AAC5B,CAAC,CAAA"}
@@ -12,8 +12,8 @@ export const useSchemaStats = (statsAddress, nameOrAddress = TYPES.SchemaStatsDi
12
12
  const refreshHistory = () => setRefresh((previous) => previous + 1);
13
13
  const [schemaList, setSchemaList] = useState();
14
14
  const query = useMemo(() => ({
15
+ address: statsAddress,
15
16
  schema: SchemaStatsQuerySchema,
16
- statsAddress,
17
17
  }), [statsAddress]);
18
18
  useAsyncEffect(
19
19
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1 +1 @@
1
- {"version":3,"file":"useSchemaStats.js","sourceRoot":"","sources":["../../../src/hooks/useSchemaStats.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,OAAO,EAA+C,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAClH,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAA4B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEnE,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,YAAqB,EACrB,aAAa,GAAG,KAAK,CAAC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EpE,MAAM,KAAK,GAA4B,OAAO,CAC5C,GAAG,EAAE,CAAC,CAAC;QACL,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,sBAAsB;KAC/B,CAAC,EACF,CAAC,YAAY,CAAC,CACf,CAAA;IAED,cAAc;IACZ,uDAAuD;IACvD,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IAAI,OAAO,EAAE;YACX,IAAI,YAAY,EAAE;gBAChB,IAAI,OAAO,EAAE,EAAE;oBACb,QAAQ,CAAC,YAAY,CAAC,CAAA;oBACtB,aAAa,CAAC,SAAS,CAAC,CAAA;iBACzB;aACF;iBAAM;gBACL,IAAI;oBACF,MAAM,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAyB,CAAA;oBACvE,IAAI,OAAO,EAAE,EAAE;wBACb,aAAa,CAAC,OAAO,CAAC,CAAA;wBACtB,QAAQ,CAAC,SAAS,CAAC,CAAA;qBACpB;iBACF;gBAAC,OAAO,EAAE,EAAE;oBACX,QAAQ,CAAC,EAAW,CAAC,CAAA;oBACrB,aAAa,CAAC,SAAS,CAAC,CAAA;iBACzB;aACF;SACF;IACH,CAAC,EACD,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,CAAC,CACxC,CAAA;IAED,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,CAAA;AAC5C,CAAC,CAAA"}
@@ -1,8 +1,51 @@
1
1
  /// <reference types="react" />
2
2
  import { PropertyProps } from '@xyo-network/react-property';
3
3
  export type SchemaPropertyProps = PropertyProps & {
4
+ showLinkNames?: boolean;
5
+ showOpenNewWindowLink?: boolean;
6
+ showStatusIcon?: boolean;
4
7
  value?: string;
8
+ /** @deprecated - use events instead */
5
9
  viewSchemaUrl?: string;
6
10
  };
7
- export declare const SchemaProperty: React.FC<SchemaPropertyProps>;
11
+ export declare const SchemaProperty: import("react").ForwardRefExoticComponent<((import("@xyo-network/react-property").PropertyBaseProps & {
12
+ actions?: import("@xyo-network/react-property").PropertyAction[] | undefined;
13
+ badge?: boolean | undefined;
14
+ required?: boolean | undefined;
15
+ size?: import("@xyo-network/react-shared").SizeProp | undefined;
16
+ value?: string | number | boolean | null | undefined;
17
+ } & import("@xylabs/react-flexbox").BusyBoxProps & {
18
+ paper?: false | undefined;
19
+ } & {
20
+ showLinkNames?: boolean | undefined;
21
+ showOpenNewWindowLink?: boolean | undefined;
22
+ showStatusIcon?: boolean | undefined;
23
+ value?: string | undefined;
24
+ /** @deprecated - use events instead */
25
+ viewSchemaUrl?: string | undefined;
26
+ }) | Omit<import("@xyo-network/react-property").PropertyBaseProps & {
27
+ actions?: import("@xyo-network/react-property").PropertyAction[] | undefined;
28
+ badge?: boolean | undefined;
29
+ required?: boolean | undefined;
30
+ size?: import("@xyo-network/react-shared").SizeProp | undefined;
31
+ value?: string | number | boolean | null | undefined;
32
+ } & {
33
+ children?: import("react").ReactNode;
34
+ classes?: Partial<import("@mui/material").PaperClasses> | undefined;
35
+ elevation?: number | undefined;
36
+ square?: boolean | undefined;
37
+ sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
38
+ variant?: "elevation" | "outlined" | undefined;
39
+ } & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
40
+ ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
41
+ }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "elevation" | "square" | "sx" | "variant"> & {
42
+ paper: true;
43
+ } & {
44
+ showLinkNames?: boolean | undefined;
45
+ showOpenNewWindowLink?: boolean | undefined;
46
+ showStatusIcon?: boolean | undefined;
47
+ value?: string | undefined;
48
+ /** @deprecated - use events instead */
49
+ viewSchemaUrl?: string | undefined;
50
+ }, "ref">) & import("react").RefAttributes<HTMLDivElement>>;
8
51
  //# sourceMappingURL=SchemaProperty.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaProperty.d.ts","sourceRoot":"","sources":["../../../../src/components/Property/SchemaProperty.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAY,aAAa,EAAiB,MAAM,6BAA6B,CAAA;AAIpF,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAChD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAmBD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA+BxD,CAAA"}
1
+ {"version":3,"file":"SchemaProperty.d.ts","sourceRoot":"","sources":["../../../../src/components/Property/SchemaProperty.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAY,aAAa,EAAiB,MAAM,6BAA6B,CAAA;AAIpF,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAChD,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAmBD,eAAO,MAAM,cAAc;;;;;;;;;;;;;IArBzB,uCAAuC;;;;;;;;;;;;;;;;;;;;;;;;IAAvC,uCAAuC;;2DA0ExC,CAAA"}
@@ -1,4 +1,5 @@
1
1
  export * from './useGetSchema';
2
2
  export * from './useSchemaDefinitions';
3
+ export * from './useSchemaList';
3
4
  export * from './useSchemaStats';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { AccountInstance } from '@xyo-network/account-model';
2
+ import { SchemaListPayload } from '@xyo-network/node-core-model';
3
+ export declare const useSchemaList: (address?: string, nameOrAddress?: string, account?: AccountInstance) => [SchemaListPayload | undefined, Error | undefined];
4
+ //# sourceMappingURL=useSchemaList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSchemaList.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSchemaList.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAiD,MAAM,8BAA8B,CAAA;AAI/G,eAAO,MAAM,aAAa,aACd,MAAM,oCAEN,eAAe,KACxB,CAAC,iBAAiB,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CAqCnD,CAAA"}
package/package.json CHANGED
@@ -13,15 +13,17 @@
13
13
  "@xylabs/react-link": "^2.16.11",
14
14
  "@xylabs/react-select": "^2.16.11",
15
15
  "@xylabs/react-shared": "^2.16.11",
16
- "@xyo-network/module": "^2.53.2",
17
- "@xyo-network/node-core-model": "^2.53.2",
18
- "@xyo-network/node-core-types": "^2.53.2",
19
- "@xyo-network/payload-builder": "^2.53.2",
20
- "@xyo-network/react-diviner": "^2.46.7",
21
- "@xyo-network/react-property": "^2.46.7",
22
- "@xyo-network/react-shared": "^2.46.7",
23
- "@xyo-network/schema-payload-plugin": "^2.53.2",
24
- "@xyo-network/utils": "^2.53.2",
16
+ "@xyo-network/account-model": "^2.53.3",
17
+ "@xyo-network/module": "^2.53.3",
18
+ "@xyo-network/node-core-model": "^2.53.3",
19
+ "@xyo-network/node-core-types": "^2.53.3",
20
+ "@xyo-network/payload-builder": "^2.53.3",
21
+ "@xyo-network/react-diviner": "^2.46.9",
22
+ "@xyo-network/react-event": "^2.46.9",
23
+ "@xyo-network/react-property": "^2.46.9",
24
+ "@xyo-network/react-shared": "^2.46.9",
25
+ "@xyo-network/schema-payload-plugin": "^2.53.3",
26
+ "@xyo-network/utils": "^2.53.3",
25
27
  "lodash": "^4.17.21"
26
28
  },
27
29
  "devDependencies": {
@@ -30,12 +32,12 @@
30
32
  "@xylabs/react-flexbox": "^2.16.11",
31
33
  "@xylabs/ts-scripts-yarn3": "^2.16.1",
32
34
  "@xylabs/tsconfig-react": "^2.16.1",
33
- "@xyo-network/account": "^2.53.2",
34
- "@xyo-network/bridge": "^2.53.2",
35
- "@xyo-network/node": "^2.53.2",
36
- "@xyo-network/react-node": "^2.46.7",
37
- "@xyo-network/react-storybook": "^2.46.7",
38
- "@xyo-network/react-wallet": "^2.46.7",
35
+ "@xyo-network/account": "^2.53.3",
36
+ "@xyo-network/bridge": "^2.53.3",
37
+ "@xyo-network/node": "^2.53.3",
38
+ "@xyo-network/react-node": "^2.46.9",
39
+ "@xyo-network/react-storybook": "^2.46.9",
40
+ "@xyo-network/react-wallet": "^2.46.9",
39
41
  "react-json-view": "^1.21.3",
40
42
  "require-from-string": "^2.0.2",
41
43
  "typescript": "^4.9.5"
@@ -92,5 +94,5 @@
92
94
  },
93
95
  "sideEffects": false,
94
96
  "types": "dist/types/index.d.ts",
95
- "version": "2.46.7"
97
+ "version": "2.46.9"
96
98
  }
@@ -1,11 +1,10 @@
1
1
  import { ComponentStory, Meta } from '@storybook/react'
2
+ import { useXyoEvent } from '@xyo-network/react-event'
2
3
  import { useAppThemeDecorator } from '@xyo-network/react-storybook'
3
4
 
4
5
  import { SchemaProperty } from './SchemaProperty'
5
6
 
6
7
  const StorybookEntry: Meta = {
7
- argTypes: {},
8
- args: {},
9
8
  component: SchemaProperty,
10
9
  decorators: [useAppThemeDecorator],
11
10
  parameters: {
@@ -16,21 +15,30 @@ const StorybookEntry: Meta = {
16
15
  title: 'Schema/SchemaProperty',
17
16
  }
18
17
 
19
- const Template: ComponentStory<typeof SchemaProperty> = (args) => <SchemaProperty {...args} />
18
+ const Template: ComponentStory<typeof SchemaProperty> = (args) => {
19
+ const [ref] = useXyoEvent<HTMLDivElement>((noun, verb, data) => {
20
+ console.log(`${noun}|${verb}|${data}`)
21
+ })
22
+ return (
23
+ <div ref={ref}>
24
+ <SchemaProperty {...args} />
25
+ </div>
26
+ )
27
+ }
20
28
 
21
29
  const Default = Template.bind({})
22
30
  Default.args = {}
23
31
 
24
- const WithVerfiedValue = Template.bind({})
25
- WithVerfiedValue.args = { value: 'network.xyo.schema' }
32
+ const WithVerifiedValue = Template.bind({})
33
+ WithVerifiedValue.args = { value: 'network.xyo.schema' }
26
34
 
27
- const WithVerfiedValuePaper = Template.bind({})
28
- WithVerfiedValuePaper.args = { paper: true, value: 'network.xyo.schema' }
35
+ const WithVerifiedValuePaper = Template.bind({})
36
+ WithVerifiedValuePaper.args = { paper: true, value: 'network.xyo.schema' }
29
37
 
30
- const WithUnverfiedValue = Template.bind({})
31
- WithUnverfiedValue.args = { value: 'network.xyo.blahblah' }
38
+ const WithUnverifiedValue = Template.bind({})
39
+ WithUnverifiedValue.args = { value: 'network.xyo.blahblah' }
32
40
 
33
- export { Default, WithUnverfiedValue, WithVerfiedValue, WithVerfiedValuePaper }
41
+ export { Default, WithUnverifiedValue, WithVerifiedValue, WithVerifiedValuePaper }
34
42
 
35
43
  // eslint-disable-next-line import/no-default-export
36
44
  export default StorybookEntry
@@ -4,12 +4,17 @@ import VerifiedIcon from '@mui/icons-material/Verified'
4
4
  import { IconButton } from '@mui/material'
5
5
  import { LinkEx } from '@xylabs/react-link'
6
6
  import { useAsyncEffect } from '@xylabs/react-shared'
7
+ import { useXyoEvent, XyoEventDispatch, XyoEventNoun } from '@xyo-network/react-event'
7
8
  import { Property, PropertyProps, PropertyValue } from '@xyo-network/react-property'
8
9
  import { XyoSchemaCache, XyoSchemaCacheEntry } from '@xyo-network/utils'
9
- import { useState } from 'react'
10
+ import { forwardRef, useState } from 'react'
10
11
 
11
12
  export type SchemaPropertyProps = PropertyProps & {
13
+ showLinkNames?: boolean
14
+ showOpenNewWindowLink?: boolean
15
+ showStatusIcon?: boolean
12
16
  value?: string
17
+ /** @deprecated - use events instead */
13
18
  viewSchemaUrl?: string
14
19
  }
15
20
 
@@ -30,35 +35,59 @@ const useResolveSchema = (schema?: string) => {
30
35
  return entry
31
36
  }
32
37
 
33
- export const SchemaProperty: React.FC<SchemaPropertyProps> = ({ titleProps, value, viewSchemaUrl = 'https://explore.xyo.network/', ...props }) => {
34
- const resolvedSchema = useResolveSchema(value)
35
- return (
36
- <Property title="Schema" value={value} tip="Schema sent with the payload" titleProps={titleProps} {...props}>
37
- {value ? (
38
- resolvedSchema === null ? (
39
- <IconButton rel="noopener noreferrer" size="small" target="_blank" href={`${viewSchemaUrl}${value}`}>
40
- <NewReleasesIcon color="warning" fontSize="inherit" />
41
- </IconButton>
42
- ) : resolvedSchema === undefined ? (
43
- <IconButton rel="noopener noreferrer" size="small" target="_blank" href={`${viewSchemaUrl}${value}`}>
44
- <NewReleasesIcon color="disabled" fontSize="inherit" />
45
- </IconButton>
46
- ) : (
47
- <IconButton rel="noopener noreferrer" size="small" target="_blank" href={resolvedSchema?.huri?.href ?? ''}>
48
- <VerifiedIcon color="success" fontSize="inherit" />
49
- </IconButton>
50
- )
51
- ) : null}
52
- {value ? (
53
- <LinkEx flexGrow={1} alignItems="center" href={`${viewSchemaUrl}${value}`} rel="noopener noreferrer" display="flex">
54
- <PropertyValue value={value} title="view schema in new window" />
55
- </LinkEx>
56
- ) : null}
57
- {value ? (
58
- <LinkEx marginX={1} alignItems="center" href={`${viewSchemaUrl}${value}`} target="_blank" rel="noopener noreferrer" display="flex">
59
- <OpenInNewIcon fontSize="inherit" />
60
- </LinkEx>
61
- ) : null}
62
- </Property>
63
- )
64
- }
38
+ export const SchemaProperty = forwardRef<HTMLDivElement, SchemaPropertyProps>(
39
+ ({ showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props }, forwardedRef) => {
40
+ const resolvedSchema = useResolveSchema(value)
41
+ const [buttonRef, buttonDispatch] = useXyoEvent<HTMLButtonElement>(undefined)
42
+ const [divRef, divDispatch] = useXyoEvent<HTMLDivElement>(undefined)
43
+
44
+ const onClick = (dispatch?: XyoEventDispatch<XyoEventNoun, 'click', string>, openNewWindow = false) => {
45
+ dispatch?.(
46
+ 'schema',
47
+ 'click',
48
+ JSON.stringify({
49
+ openNewWindow,
50
+ schema: value,
51
+ }),
52
+ )
53
+ }
54
+
55
+ return (
56
+ <Property ref={forwardedRef} title="Schema" value={value} tip="Schema sent with the payload" titleProps={titleProps} {...props}>
57
+ {value && showStatusIcon ? (
58
+ resolvedSchema === null ? (
59
+ <IconButton ref={buttonRef} size="small" onClick={() => onClick(buttonDispatch)}>
60
+ <NewReleasesIcon color="warning" fontSize="inherit" />
61
+ </IconButton>
62
+ ) : resolvedSchema === undefined ? (
63
+ <IconButton ref={buttonRef} size="small" onClick={() => onClick(buttonDispatch)}>
64
+ <NewReleasesIcon color="disabled" fontSize="inherit" />
65
+ </IconButton>
66
+ ) : (
67
+ <IconButton rel="noopener noreferrer" size="small" target="_blank" href={resolvedSchema?.huri?.href ?? ''}>
68
+ <VerifiedIcon color="success" fontSize="inherit" />
69
+ </IconButton>
70
+ )
71
+ ) : null}
72
+ {value ? (
73
+ <>
74
+ {showLinkNames ? (
75
+ <LinkEx display="block" width="100%" sx={{ cursor: 'pointer' }}>
76
+ <PropertyValue ref={divRef} value={value} title="view schema" onClick={() => onClick(divDispatch)} />
77
+ </LinkEx>
78
+ ) : (
79
+ <PropertyValue ref={divRef} value={value} title="view schema" onClick={() => onClick(divDispatch)} />
80
+ )}
81
+ {showOpenNewWindowLink ? (
82
+ <IconButton ref={buttonRef} size="small" onClick={() => onClick(buttonDispatch, true)}>
83
+ <OpenInNewIcon fontSize="inherit" />
84
+ </IconButton>
85
+ ) : null}
86
+ </>
87
+ ) : null}
88
+ </Property>
89
+ )
90
+ },
91
+ )
92
+
93
+ SchemaProperty.displayName = 'SchemaProperty'
@@ -1,3 +1,4 @@
1
1
  export * from './useGetSchema'
2
2
  export * from './useSchemaDefinitions'
3
+ export * from './useSchemaList'
3
4
  export * from './useSchemaStats'
@@ -1,20 +1,21 @@
1
- import { Typography } from '@mui/material'
1
+ import { Alert, Button, TextField, Typography } from '@mui/material'
2
2
  import { ComponentStory, DecoratorFn, Meta } from '@storybook/react'
3
+ import { FlexGrowRow } from '@xylabs/react-flexbox'
3
4
  import { useAsyncEffect } from '@xylabs/react-shared'
4
5
  import { HDWallet } from '@xyo-network/account'
5
6
  import { HttpBridge, HttpBridgeConfigSchema } from '@xyo-network/bridge'
6
7
  import { MemoryNode, NodeConfigSchema } from '@xyo-network/node'
7
- import { Payload } from '@xyo-network/payload'
8
- import { NodeProvider, useNode } from '@xyo-network/react-node'
8
+ import { NodeProvider } from '@xyo-network/react-node'
9
9
  import { DefaultSeedPhrase } from '@xyo-network/react-storybook'
10
- import { useAccount, WalletProvider } from '@xyo-network/react-wallet'
10
+ import { WalletProvider } from '@xyo-network/react-wallet'
11
11
  import { XyoSchemaCache } from '@xyo-network/utils'
12
12
  import { useState } from 'react'
13
13
 
14
14
  import { useSchemaDefinitions } from '../useSchemaDefinitions'
15
+ import { useSchemaList } from '../useSchemaList'
15
16
  import { useSchemaStats } from '../useSchemaStats'
16
17
 
17
- const apiConfig = { apiDomain: 'https://beta.api.archivist.xyo.network' }
18
+ const apiConfig = { apiDomain: 'https://api.archivist.xyo.network' }
18
19
  const nodeUri = 'http://localhost:8080/node'
19
20
  const randomWallet = HDWallet.fromMnemonic(DefaultSeedPhrase)
20
21
 
@@ -49,35 +50,34 @@ export default {
49
50
 
50
51
  const Template: ComponentStory<React.FC> = () => {
51
52
  XyoSchemaCache.instance.proxy = `${apiConfig.apiDomain}/domain`
52
- const [account] = useAccount()
53
- const [node] = useNode(undefined, account)
54
- const [discovered, setDiscovered] = useState<Payload[]>([])
55
- const [schemaStats] = useSchemaStats(undefined, undefined, account)
56
- const schemaList = schemaStats?.filter(({ name }) => !!name) as { name: string }[]
57
- const schemaDefinitions = useSchemaDefinitions(schemaList)
58
-
59
- useAsyncEffect(
60
- // eslint-disable-next-line react-hooks/exhaustive-deps
61
- async (mounted) => {
62
- const discovered = await node?.discover()
63
- if (mounted()) {
64
- setDiscovered(discovered ?? [])
65
- }
66
- },
67
- [node],
68
- )
53
+ const [addressText, setAddressText] = useState<string>('')
54
+ const [address, setAddress] = useState<string>()
55
+ const [schemaStats, schemaStatsError] = useSchemaStats(address)
56
+ const [schemaList, schemaListError] = useSchemaList(address)
57
+ const mappedSchemaList = schemaList?.schemas?.map((name) => ({ name })) as { name: string }[]
58
+ const schemaDefinitions = useSchemaDefinitions(mappedSchemaList)
69
59
 
70
60
  return (
71
61
  <div style={{ display: 'flex', flexDirection: 'column', rowGap: '16px' }}>
62
+ {schemaStatsError ? <Alert severity={'error'}>{schemaStatsError.message ?? schemaListError?.message}</Alert> : null}
63
+ <FlexGrowRow columnGap={4}>
64
+ <TextField fullWidth size="small" value={address} label="Address" onChange={(event) => setAddressText(event.target.value)} />
65
+ <Button variant="contained" onClick={() => setAddress(addressText)} sx={{ whiteSpace: 'nowrap' }}>
66
+ Get Stats
67
+ </Button>
68
+ </FlexGrowRow>
72
69
  <Typography variant={'h2'}>Schema Stats</Typography>
73
70
  <code>
74
- {`${JSON.stringify(discovered, null, 2)}`}
75
- {JSON.stringify(schemaStats, null, 2)}
71
+ <pre>{JSON.stringify(schemaStats, null, 2)}</pre>
76
72
  </code>
77
73
  <Typography variant={'h2'}>Schema List</Typography>
78
- <code>{JSON.stringify(schemaList, null, 2)}</code>
74
+ <code>
75
+ <pre>{JSON.stringify(schemaList, null, 2)}</pre>
76
+ </code>
79
77
  <Typography variant={'h2'}>Schema Definitions</Typography>
80
- <code>{JSON.stringify(schemaDefinitions, null, 2)}</code>
78
+ <pre>
79
+ <code>{JSON.stringify(schemaDefinitions, null, 2)}</code>
80
+ </pre>
81
81
  </div>
82
82
  )
83
83
  }
@@ -0,0 +1,48 @@
1
+ import { useAsyncEffect } from '@xylabs/react-shared'
2
+ import { AccountInstance } from '@xyo-network/account-model'
3
+ import { SchemaListPayload, SchemaListQueryPayload, SchemaListQuerySchema } from '@xyo-network/node-core-model'
4
+ import { useDiviner } from '@xyo-network/react-diviner'
5
+ import { useMemo, useState } from 'react'
6
+
7
+ export const useSchemaList = (
8
+ address?: string,
9
+ nameOrAddress = 'SchemaListDiviner',
10
+ account?: AccountInstance,
11
+ ): [SchemaListPayload | undefined, Error | undefined] => {
12
+ const [schemaList, setSchemaList] = useState<SchemaListPayload>()
13
+ const [error, setError] = useState<Error>()
14
+ const [diviner, divinerError] = useDiviner(nameOrAddress, account)
15
+
16
+ const query: SchemaListQueryPayload[] | undefined = useMemo(
17
+ () =>
18
+ address
19
+ ? [
20
+ {
21
+ address,
22
+ schema: SchemaListQuerySchema,
23
+ },
24
+ ]
25
+ : undefined,
26
+ [address],
27
+ )
28
+
29
+ useAsyncEffect(
30
+ // eslint-disable-next-line react-hooks/exhaustive-deps, require-await
31
+ async (mounted) => {
32
+ if (diviner) {
33
+ try {
34
+ const response = (await diviner.divine(query)) as SchemaListPayload[]
35
+ if (mounted()) {
36
+ setSchemaList(response?.[0])
37
+ setError(undefined)
38
+ }
39
+ } catch (e) {
40
+ setError(e as Error)
41
+ setSchemaList(undefined)
42
+ }
43
+ }
44
+ },
45
+ [diviner, divinerError, query],
46
+ )
47
+ return [schemaList, error]
48
+ }
@@ -21,8 +21,8 @@ export const useSchemaStats = (
21
21
 
22
22
  const query: SchemaStatsQueryPayload = useMemo(
23
23
  () => ({
24
+ address: statsAddress,
24
25
  schema: SchemaStatsQuerySchema,
25
- statsAddress,
26
26
  }),
27
27
  [statsAddress],
28
28
  )