@xyo-network/react-schema 2.25.19 → 2.25.20
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/cjs/components/Property/SchemaProperty.d.ts +7 -0
- package/dist/cjs/components/Property/SchemaProperty.js +34 -0
- package/dist/cjs/components/Property/SchemaProperty.js.map +1 -0
- package/dist/cjs/components/Property/index.d.ts +1 -0
- package/dist/cjs/components/Property/index.js +5 -0
- package/dist/cjs/components/Property/index.js.map +1 -0
- package/dist/cjs/components/index.d.ts +1 -0
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/docs.json +25099 -134
- package/dist/esm/components/Property/SchemaProperty.d.ts +7 -0
- package/dist/esm/components/Property/SchemaProperty.js +28 -0
- package/dist/esm/components/Property/SchemaProperty.js.map +1 -0
- package/dist/esm/components/Property/index.d.ts +1 -0
- package/dist/esm/components/Property/index.js +2 -0
- package/dist/esm/components/Property/index.js.map +1 -0
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/Property/SchemaProperty.stories.tsx +33 -0
- package/src/components/Property/SchemaProperty.tsx +63 -0
- package/src/components/Property/index.ts +1 -0
- package/src/components/index.ts +1 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PropertyProps } from '@xyo-network/react-property';
|
|
3
|
+
export interface SchemaPropertyProps extends PropertyProps {
|
|
4
|
+
value?: string;
|
|
5
|
+
viewSchemaUrl?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const SchemaProperty: React.FC<SchemaPropertyProps>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaProperty = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const NewReleases_1 = tslib_1.__importDefault(require("@mui/icons-material/NewReleases"));
|
|
7
|
+
const OpenInNew_1 = tslib_1.__importDefault(require("@mui/icons-material/OpenInNew"));
|
|
8
|
+
const Verified_1 = tslib_1.__importDefault(require("@mui/icons-material/Verified"));
|
|
9
|
+
const material_1 = require("@mui/material");
|
|
10
|
+
const sdk_react_1 = require("@xylabs/sdk-react");
|
|
11
|
+
const react_property_1 = require("@xyo-network/react-property");
|
|
12
|
+
const utils_1 = require("@xyo-network/utils");
|
|
13
|
+
const react_1 = require("react");
|
|
14
|
+
const useResolveSchema = (schema) => {
|
|
15
|
+
const [entry, setEntry] = (0, react_1.useState)();
|
|
16
|
+
(0, sdk_react_1.useAsyncEffect)(
|
|
17
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18
|
+
(mounted) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
if (schema) {
|
|
20
|
+
const entry = yield utils_1.XyoSchemaCache.instance.get(schema);
|
|
21
|
+
if (mounted()) {
|
|
22
|
+
setEntry(entry);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}), [schema]);
|
|
26
|
+
return entry;
|
|
27
|
+
};
|
|
28
|
+
const SchemaProperty = ({ value, viewSchemaUrl = 'https://explore.xyo.network/' }) => {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
const resolvedSchema = useResolveSchema(value);
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)(react_property_1.Property, Object.assign({ flexGrow: 1, title: "Schema", value: value, tip: "Schema sent with the payload" }, { children: [value ? (resolvedSchema === null ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ rel: "noopener noreferrer", size: "small", target: "_blank", href: `${viewSchemaUrl}${value}` }, { children: (0, jsx_runtime_1.jsx)(NewReleases_1.default, { color: "error", fontSize: "inherit" }) }))) : resolvedSchema === undefined ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ rel: "noopener noreferrer", size: "small", target: "_blank", href: `${viewSchemaUrl}${value}` }, { children: (0, jsx_runtime_1.jsx)(NewReleases_1.default, { color: "disabled", fontSize: "inherit" }) }))) : ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ rel: "noopener noreferrer", size: "small", target: "_blank", href: (_b = (_a = resolvedSchema === null || resolvedSchema === void 0 ? void 0 : resolvedSchema.huri) === null || _a === void 0 ? void 0 : _a.href) !== null && _b !== void 0 ? _b : '' }, { children: (0, jsx_runtime_1.jsx)(Verified_1.default, { color: "success", fontSize: "inherit" }) })))) : null, value ? ((0, jsx_runtime_1.jsx)(sdk_react_1.LinkEx, Object.assign({ flexGrow: 1, alignItems: "center", href: `${viewSchemaUrl}${value}`, rel: "noopener noreferrer", display: "flex" }, { children: (0, jsx_runtime_1.jsx)(react_property_1.PropertyValue, { value: value, title: "view schema in new window" }) }))) : null, value ? ((0, jsx_runtime_1.jsx)(sdk_react_1.LinkEx, Object.assign({ alignItems: "center", href: `${viewSchemaUrl}${value}`, target: "_blank", rel: "noopener noreferrer", display: "flex" }, { children: (0, jsx_runtime_1.jsx)(OpenInNew_1.default, { fontSize: "inherit" }) }))) : null] })));
|
|
32
|
+
};
|
|
33
|
+
exports.SchemaProperty = SchemaProperty;
|
|
34
|
+
//# sourceMappingURL=SchemaProperty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaProperty.js","sourceRoot":"","sources":["../../../../src/components/Property/SchemaProperty.tsx"],"names":[],"mappings":";;;;;AAAA,0FAA6D;AAC7D,sFAAyD;AACzD,oFAAuD;AACvD,4CAA0C;AAC1C,iDAA0D;AAC1D,gEAAoF;AACpF,8CAAwE;AACxE,iCAAgC;AAOhC,MAAM,gBAAgB,GAAG,CAAC,MAAe,EAAE,EAAE;IAC3C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,GAA8B,CAAA;IAChE,IAAA,0BA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qBAAU,kBAAC,GAAG,EAAC,qBAAqB,EAAC,IAAI,EAAC,OAAO,EAAC,MAAM,EAAC,QAAQ,EAAC,IAAI,EAAE,MAAA,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,0CAAE,IAAI,mCAAI,EAAE,gBACvG,uBAAC,kBAAY,IAAC,KAAK,EAAC,SAAS,EAAC,QAAQ,EAAC,SAAS,GAAG,IACxC,CACd,CACF,CAAC,CAAC,CAAC,IAAI,EACP,KAAK,CAAC,CAAC,CAAC,CACP,uBAAC,kBAAM,kBAAC,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAC,QAAQ,EAAC,IAAI,EAAE,GAAG,aAAa,GAAG,KAAK,EAAE,EAAE,GAAG,EAAC,qBAAqB,EAAC,OAAO,EAAC,MAAM,gBACjH,uBAAC,8BAAa,IAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAC,2BAA2B,GAAG,IAC1D,CACV,CAAC,CAAC,CAAC,IAAI,EACP,KAAK,CAAC,CAAC,CAAC,CACP,uBAAC,kBAAM,kBAAC,UAAU,EAAC,QAAQ,EAAC,IAAI,EAAE,GAAG,aAAa,GAAG,KAAK,EAAE,EAAE,MAAM,EAAC,QAAQ,EAAC,GAAG,EAAC,qBAAqB,EAAC,OAAO,EAAC,MAAM,gBACpH,uBAAC,mBAAa,IAAC,QAAQ,EAAC,SAAS,GAAG,IAC7B,CACV,CAAC,CAAC,CAAC,IAAI,KACC,CACZ,CAAA;AACH,CAAC,CAAA;AA/BY,QAAA,cAAc,kBA+B1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SchemaProperty';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Property/index.ts"],"names":[],"mappings":";;;AAAA,2DAAgC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0B;AAC1B,qDAA0B"}
|