@xyo-network/react-schema 2.64.8 → 2.64.10
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/docs.json +38 -38
- package/package.json +26 -26
- package/dist/browser/components/Property/SchemaProperty.cjs +0 -76
- package/dist/browser/components/Property/SchemaProperty.cjs.map +0 -1
- package/dist/browser/components/Property/SchemaProperty.js +0 -55
- package/dist/browser/components/Property/SchemaProperty.js.map +0 -1
- package/dist/browser/components/Property/index.cjs +0 -78
- package/dist/browser/components/Property/index.cjs.map +0 -1
- package/dist/browser/components/Property/index.js +0 -55
- package/dist/browser/components/Property/index.js.map +0 -1
- package/dist/browser/components/SelectEx/SchemaSelectEx.cjs +0 -68
- package/dist/browser/components/SelectEx/SchemaSelectEx.cjs.map +0 -1
- package/dist/browser/components/SelectEx/SchemaSelectEx.js +0 -47
- package/dist/browser/components/SelectEx/SchemaSelectEx.js.map +0 -1
- package/dist/browser/components/SelectEx/index.cjs +0 -70
- package/dist/browser/components/SelectEx/index.cjs.map +0 -1
- package/dist/browser/components/SelectEx/index.js +0 -47
- package/dist/browser/components/SelectEx/index.js.map +0 -1
- package/dist/browser/components/index.cjs +0 -123
- package/dist/browser/components/index.cjs.map +0 -1
- package/dist/browser/components/index.js +0 -100
- package/dist/browser/components/index.js.map +0 -1
- package/dist/browser/contexts/Schema/Context.cjs +0 -28
- package/dist/browser/contexts/Schema/Context.cjs.map +0 -1
- package/dist/browser/contexts/Schema/Context.js +0 -7
- package/dist/browser/contexts/Schema/Context.js.map +0 -1
- package/dist/browser/contexts/Schema/Provider/Memory.cjs +0 -94
- package/dist/browser/contexts/Schema/Provider/Memory.cjs.map +0 -1
- package/dist/browser/contexts/Schema/Provider/Memory.js +0 -73
- package/dist/browser/contexts/Schema/Provider/Memory.js.map +0 -1
- package/dist/browser/contexts/Schema/Provider/Props.cjs +0 -19
- package/dist/browser/contexts/Schema/Provider/Props.cjs.map +0 -1
- package/dist/browser/contexts/Schema/Provider/Props.js +0 -1
- package/dist/browser/contexts/Schema/Provider/Props.js.map +0 -1
- package/dist/browser/contexts/Schema/Provider/Route.cjs +0 -144
- package/dist/browser/contexts/Schema/Provider/Route.cjs.map +0 -1
- package/dist/browser/contexts/Schema/Provider/Route.js +0 -123
- package/dist/browser/contexts/Schema/Provider/Route.js.map +0 -1
- package/dist/browser/contexts/Schema/Provider/index.cjs +0 -147
- package/dist/browser/contexts/Schema/Provider/index.cjs.map +0 -1
- package/dist/browser/contexts/Schema/Provider/index.js +0 -124
- package/dist/browser/contexts/Schema/Provider/index.js.map +0 -1
- package/dist/browser/contexts/Schema/State.cjs +0 -19
- package/dist/browser/contexts/Schema/State.cjs.map +0 -1
- package/dist/browser/contexts/Schema/State.js +0 -1
- package/dist/browser/contexts/Schema/State.js.map +0 -1
- package/dist/browser/contexts/Schema/index.cjs +0 -149
- package/dist/browser/contexts/Schema/index.cjs.map +0 -1
- package/dist/browser/contexts/Schema/index.js +0 -126
- package/dist/browser/contexts/Schema/index.js.map +0 -1
- package/dist/browser/contexts/Schema/use.cjs +0 -36
- package/dist/browser/contexts/Schema/use.cjs.map +0 -1
- package/dist/browser/contexts/Schema/use.js +0 -15
- package/dist/browser/contexts/Schema/use.js.map +0 -1
- package/dist/browser/contexts/index.cjs +0 -149
- package/dist/browser/contexts/index.cjs.map +0 -1
- package/dist/browser/contexts/index.js +0 -126
- package/dist/browser/contexts/index.js.map +0 -1
- package/dist/browser/hooks/index.cjs +0 -189
- package/dist/browser/hooks/index.cjs.map +0 -1
- package/dist/browser/hooks/index.js +0 -166
- package/dist/browser/hooks/index.js.map +0 -1
- package/dist/browser/hooks/useGetSchema.cjs +0 -69
- package/dist/browser/hooks/useGetSchema.cjs.map +0 -1
- package/dist/browser/hooks/useGetSchema.js +0 -48
- package/dist/browser/hooks/useGetSchema.js.map +0 -1
- package/dist/browser/hooks/useSchemaDefinitions.cjs +0 -47
- package/dist/browser/hooks/useSchemaDefinitions.cjs.map +0 -1
- package/dist/browser/hooks/useSchemaDefinitions.js +0 -26
- package/dist/browser/hooks/useSchemaDefinitions.js.map +0 -1
- package/dist/browser/hooks/useSchemaList.cjs +0 -69
- package/dist/browser/hooks/useSchemaList.cjs.map +0 -1
- package/dist/browser/hooks/useSchemaList.js +0 -48
- package/dist/browser/hooks/useSchemaList.js.map +0 -1
- package/dist/browser/hooks/useSchemaStats.cjs +0 -71
- package/dist/browser/hooks/useSchemaStats.cjs.map +0 -1
- package/dist/browser/hooks/useSchemaStats.js +0 -50
- package/dist/browser/hooks/useSchemaStats.js.map +0 -1
- package/dist/node/components/Property/SchemaProperty.cjs +0 -81
- package/dist/node/components/Property/SchemaProperty.cjs.map +0 -1
- package/dist/node/components/Property/SchemaProperty.js +0 -56
- package/dist/node/components/Property/SchemaProperty.js.map +0 -1
- package/dist/node/components/Property/index.cjs +0 -83
- package/dist/node/components/Property/index.cjs.map +0 -1
- package/dist/node/components/Property/index.js +0 -56
- package/dist/node/components/Property/index.js.map +0 -1
- package/dist/node/components/SelectEx/SchemaSelectEx.cjs +0 -72
- package/dist/node/components/SelectEx/SchemaSelectEx.cjs.map +0 -1
- package/dist/node/components/SelectEx/SchemaSelectEx.js +0 -47
- package/dist/node/components/SelectEx/SchemaSelectEx.js.map +0 -1
- package/dist/node/components/SelectEx/index.cjs +0 -74
- package/dist/node/components/SelectEx/index.cjs.map +0 -1
- package/dist/node/components/SelectEx/index.js +0 -47
- package/dist/node/components/SelectEx/index.js.map +0 -1
- package/dist/node/components/index.cjs +0 -129
- package/dist/node/components/index.cjs.map +0 -1
- package/dist/node/components/index.js +0 -101
- package/dist/node/components/index.js.map +0 -1
- package/dist/node/contexts/Schema/Context.cjs +0 -32
- package/dist/node/contexts/Schema/Context.cjs.map +0 -1
- package/dist/node/contexts/Schema/Context.js +0 -7
- package/dist/node/contexts/Schema/Context.js.map +0 -1
- package/dist/node/contexts/Schema/Provider/Memory.cjs +0 -98
- package/dist/node/contexts/Schema/Provider/Memory.cjs.map +0 -1
- package/dist/node/contexts/Schema/Provider/Memory.js +0 -73
- package/dist/node/contexts/Schema/Provider/Memory.js.map +0 -1
- package/dist/node/contexts/Schema/Provider/Props.cjs +0 -19
- package/dist/node/contexts/Schema/Provider/Props.cjs.map +0 -1
- package/dist/node/contexts/Schema/Provider/Props.js +0 -1
- package/dist/node/contexts/Schema/Provider/Props.js.map +0 -1
- package/dist/node/contexts/Schema/Provider/Route.cjs +0 -148
- package/dist/node/contexts/Schema/Provider/Route.cjs.map +0 -1
- package/dist/node/contexts/Schema/Provider/Route.js +0 -123
- package/dist/node/contexts/Schema/Provider/Route.js.map +0 -1
- package/dist/node/contexts/Schema/Provider/index.cjs +0 -152
- package/dist/node/contexts/Schema/Provider/index.cjs.map +0 -1
- package/dist/node/contexts/Schema/Provider/index.js +0 -124
- package/dist/node/contexts/Schema/Provider/index.js.map +0 -1
- package/dist/node/contexts/Schema/State.cjs +0 -19
- package/dist/node/contexts/Schema/State.cjs.map +0 -1
- package/dist/node/contexts/Schema/State.js +0 -1
- package/dist/node/contexts/Schema/State.js.map +0 -1
- package/dist/node/contexts/Schema/index.cjs +0 -156
- package/dist/node/contexts/Schema/index.cjs.map +0 -1
- package/dist/node/contexts/Schema/index.js +0 -126
- package/dist/node/contexts/Schema/index.js.map +0 -1
- package/dist/node/contexts/Schema/use.cjs +0 -40
- package/dist/node/contexts/Schema/use.cjs.map +0 -1
- package/dist/node/contexts/Schema/use.js +0 -15
- package/dist/node/contexts/Schema/use.js.map +0 -1
- package/dist/node/contexts/index.cjs +0 -156
- package/dist/node/contexts/index.cjs.map +0 -1
- package/dist/node/contexts/index.js +0 -126
- package/dist/node/contexts/index.js.map +0 -1
- package/dist/node/hooks/index.cjs +0 -199
- package/dist/node/hooks/index.cjs.map +0 -1
- package/dist/node/hooks/index.js +0 -169
- package/dist/node/hooks/index.js.map +0 -1
- package/dist/node/hooks/useGetSchema.cjs +0 -73
- package/dist/node/hooks/useGetSchema.cjs.map +0 -1
- package/dist/node/hooks/useGetSchema.js +0 -48
- package/dist/node/hooks/useGetSchema.js.map +0 -1
- package/dist/node/hooks/useSchemaDefinitions.cjs +0 -54
- package/dist/node/hooks/useSchemaDefinitions.cjs.map +0 -1
- package/dist/node/hooks/useSchemaDefinitions.js +0 -29
- package/dist/node/hooks/useSchemaDefinitions.js.map +0 -1
- package/dist/node/hooks/useSchemaList.cjs +0 -73
- package/dist/node/hooks/useSchemaList.cjs.map +0 -1
- package/dist/node/hooks/useSchemaList.js +0 -48
- package/dist/node/hooks/useSchemaList.js.map +0 -1
- package/dist/node/hooks/useSchemaStats.cjs +0 -75
- package/dist/node/hooks/useSchemaStats.cjs.map +0 -1
- package/dist/node/hooks/useSchemaStats.js +0 -50
- package/dist/node/hooks/useSchemaStats.js.map +0 -1
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/components/Property/index.ts
|
|
21
|
-
var Property_exports = {};
|
|
22
|
-
__export(Property_exports, {
|
|
23
|
-
SchemaProperty: () => SchemaProperty
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(Property_exports);
|
|
26
|
-
|
|
27
|
-
// src/components/Property/SchemaProperty.tsx
|
|
28
|
-
var import_icons_material = require("@mui/icons-material");
|
|
29
|
-
var import_material = require("@mui/material");
|
|
30
|
-
var import_react_async_effect = require("@xylabs/react-async-effect");
|
|
31
|
-
var import_react_link = require("@xylabs/react-link");
|
|
32
|
-
var import_react_event = require("@xyo-network/react-event");
|
|
33
|
-
var import_react_property = require("@xyo-network/react-property");
|
|
34
|
-
var import_schema_cache = require("@xyo-network/schema-cache");
|
|
35
|
-
var import_react = require("react");
|
|
36
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
-
var useResolveSchema = (schema) => {
|
|
38
|
-
const [entry, setEntry] = (0, import_react.useState)();
|
|
39
|
-
(0, import_react_async_effect.useAsyncEffect)(
|
|
40
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
-
async (mounted) => {
|
|
42
|
-
if (schema) {
|
|
43
|
-
const entry2 = await import_schema_cache.SchemaCache.instance.get(schema);
|
|
44
|
-
if (mounted()) {
|
|
45
|
-
setEntry(entry2);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
[schema]
|
|
50
|
-
);
|
|
51
|
-
return entry;
|
|
52
|
-
};
|
|
53
|
-
var SchemaProperty = (0, import_react.forwardRef)(
|
|
54
|
-
({ showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props }, forwardedRef) => {
|
|
55
|
-
const resolvedSchema = useResolveSchema(value);
|
|
56
|
-
const [buttonRef, buttonDispatch] = (0, import_react_event.useEvent)(void 0);
|
|
57
|
-
const [divRef, divDispatch] = (0, import_react_event.useEvent)(void 0);
|
|
58
|
-
const onClick = (dispatch, openNewWindow = false) => {
|
|
59
|
-
dispatch?.(
|
|
60
|
-
"schema",
|
|
61
|
-
"click",
|
|
62
|
-
JSON.stringify({
|
|
63
|
-
openNewWindow,
|
|
64
|
-
schema: value
|
|
65
|
-
})
|
|
66
|
-
);
|
|
67
|
-
};
|
|
68
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_property.Property, { ref: forwardedRef, title: "Schema", value, tip: "Schema sent with the payload", titleProps, ...props, children: [
|
|
69
|
-
value && showStatusIcon ? resolvedSchema === null ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.IconButton, { ref: buttonRef, size: "small", onClick: () => onClick(buttonDispatch), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.NewReleases, { color: "warning", fontSize: "inherit" }) }) : resolvedSchema === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.IconButton, { ref: buttonRef, size: "small", onClick: () => onClick(buttonDispatch), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.NewReleases, { color: "disabled", fontSize: "inherit" }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.IconButton, { rel: "noopener noreferrer", size: "small", target: "_blank", href: resolvedSchema?.huri?.href ?? "", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.Verified, { color: "success", fontSize: "inherit" }) }) : null,
|
|
70
|
-
value ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
71
|
-
showLinkNames ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_link.LinkEx, { display: "block", width: "100%", sx: { cursor: "pointer" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_property.PropertyValue, { ref: divRef, value, title: "view schema", onClick: () => onClick(divDispatch) }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_property.PropertyValue, { ref: divRef, value, title: "view schema", onClick: () => onClick(divDispatch) }),
|
|
72
|
-
showOpenNewWindowLink ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.IconButton, { ref: buttonRef, size: "small", onClick: () => onClick(buttonDispatch, true), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.OpenInNew, { fontSize: "inherit" }) }) : null
|
|
73
|
-
] }) : null
|
|
74
|
-
] });
|
|
75
|
-
}
|
|
76
|
-
);
|
|
77
|
-
SchemaProperty.displayName = "SchemaProperty";
|
|
78
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Property/index.ts","../../../../src/components/Property/SchemaProperty.tsx"],"sourcesContent":["export * from './SchemaProperty'\n","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 { 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 // eslint-disable-next-line react-hooks/exhaustive-deps\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>(undefined)\n const [divRef, divDispatch] = useEvent<HTMLDivElement>(undefined)\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 <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch)}>\n <NewReleasesIcon color=\"warning\" fontSize=\"inherit\" />\n </IconButton>\n ) : resolvedSchema === undefined ? (\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch)}>\n <NewReleasesIcon color=\"disabled\" fontSize=\"inherit\" />\n </IconButton>\n ) : (\n <IconButton rel=\"noopener noreferrer\" size=\"small\" target=\"_blank\" href={resolvedSchema?.huri?.href ?? ''}>\n <VerifiedIcon color=\"success\" fontSize=\"inherit\" />\n </IconButton>\n )\n ) : null}\n {value ? (\n <>\n {showLinkNames ? (\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 )}\n {showOpenNewWindowLink ? (\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch, true)}>\n <OpenInNewIcon fontSize=\"inherit\" />\n </IconButton>\n ) : null}\n </>\n ) : null}\n </Property>\n )\n },\n)\n\nSchemaProperty.displayName = 'SchemaProperty'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,4BAAqG;AACrG,sBAA2B;AAC3B,gCAA+B;AAC/B,wBAAuB;AACvB,yBAAmD;AACnD,4BAAuD;AACvD,0BAA8C;AAC9C,mBAAqC;AAgDvB;AAvCd,IAAM,mBAAmB,CAAC,WAAoB;AAC5C,QAAM,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AAU,UAAS,WAAU,GACnD,IAEA;AAAA,MACH,QACC,4EACG;AAAA,wBACC,4CAAC,4BAAO,SAAQ,SAAQ,OAAM,QAAO,IAAI,EAAE,QAAQ,UAAU,GAC3D,sDAAC,uCAAc,KAAK,QAAQ,OAAc,OAAM,eAAc,SAAS,MAAM,QAAQ,WAAW,GAAG,GACrG,IAEA,4CAAC,uCAAc,KAAK,QAAQ,OAAc,OAAM,eAAc,SAAS,MAAM,QAAQ,WAAW,GAAG;AAAA,QAEpG,wBACC,4CAAC,8BAAW,KAAK,WAAW,MAAK,SAAQ,SAAS,MAAM,QAAQ,gBAAgB,IAAI,GAClF,sDAAC,sBAAAC,WAAA,EAAc,UAAS,WAAU,GACpC,IACE;AAAA,SACN,IACE;AAAA,OACN;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;","names":["entry","NewReleasesIcon","VerifiedIcon","OpenInNewIcon"]}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// src/components/Property/SchemaProperty.tsx
|
|
2
|
-
import { NewReleases as NewReleasesIcon, OpenInNew as OpenInNewIcon, Verified as VerifiedIcon } from "@mui/icons-material";
|
|
3
|
-
import { IconButton } from "@mui/material";
|
|
4
|
-
import { useAsyncEffect } from "@xylabs/react-async-effect";
|
|
5
|
-
import { LinkEx } from "@xylabs/react-link";
|
|
6
|
-
import { useEvent } from "@xyo-network/react-event";
|
|
7
|
-
import { Property, PropertyValue } from "@xyo-network/react-property";
|
|
8
|
-
import { SchemaCache } from "@xyo-network/schema-cache";
|
|
9
|
-
import { forwardRef, useState } from "react";
|
|
10
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
var useResolveSchema = (schema) => {
|
|
12
|
-
const [entry, setEntry] = useState();
|
|
13
|
-
useAsyncEffect(
|
|
14
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15
|
-
async (mounted) => {
|
|
16
|
-
if (schema) {
|
|
17
|
-
const entry2 = await SchemaCache.instance.get(schema);
|
|
18
|
-
if (mounted()) {
|
|
19
|
-
setEntry(entry2);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
[schema]
|
|
24
|
-
);
|
|
25
|
-
return entry;
|
|
26
|
-
};
|
|
27
|
-
var SchemaProperty = forwardRef(
|
|
28
|
-
({ showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props }, forwardedRef) => {
|
|
29
|
-
const resolvedSchema = useResolveSchema(value);
|
|
30
|
-
const [buttonRef, buttonDispatch] = useEvent(void 0);
|
|
31
|
-
const [divRef, divDispatch] = useEvent(void 0);
|
|
32
|
-
const onClick = (dispatch, openNewWindow = false) => {
|
|
33
|
-
dispatch?.(
|
|
34
|
-
"schema",
|
|
35
|
-
"click",
|
|
36
|
-
JSON.stringify({
|
|
37
|
-
openNewWindow,
|
|
38
|
-
schema: value
|
|
39
|
-
})
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
return /* @__PURE__ */ jsxs(Property, { ref: forwardedRef, title: "Schema", value, tip: "Schema sent with the payload", titleProps, ...props, children: [
|
|
43
|
-
value && showStatusIcon ? resolvedSchema === null ? /* @__PURE__ */ jsx(IconButton, { ref: buttonRef, size: "small", onClick: () => onClick(buttonDispatch), children: /* @__PURE__ */ jsx(NewReleasesIcon, { color: "warning", fontSize: "inherit" }) }) : resolvedSchema === void 0 ? /* @__PURE__ */ jsx(IconButton, { ref: buttonRef, size: "small", onClick: () => onClick(buttonDispatch), children: /* @__PURE__ */ jsx(NewReleasesIcon, { color: "disabled", fontSize: "inherit" }) }) : /* @__PURE__ */ jsx(IconButton, { rel: "noopener noreferrer", size: "small", target: "_blank", href: resolvedSchema?.huri?.href ?? "", children: /* @__PURE__ */ jsx(VerifiedIcon, { color: "success", fontSize: "inherit" }) }) : null,
|
|
44
|
-
value ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
45
|
-
showLinkNames ? /* @__PURE__ */ jsx(LinkEx, { display: "block", width: "100%", sx: { cursor: "pointer" }, children: /* @__PURE__ */ jsx(PropertyValue, { ref: divRef, value, title: "view schema", onClick: () => onClick(divDispatch) }) }) : /* @__PURE__ */ jsx(PropertyValue, { ref: divRef, value, title: "view schema", onClick: () => onClick(divDispatch) }),
|
|
46
|
-
showOpenNewWindowLink ? /* @__PURE__ */ jsx(IconButton, { ref: buttonRef, size: "small", onClick: () => onClick(buttonDispatch, true), children: /* @__PURE__ */ jsx(OpenInNewIcon, { fontSize: "inherit" }) }) : null
|
|
47
|
-
] }) : null
|
|
48
|
-
] });
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
SchemaProperty.displayName = "SchemaProperty";
|
|
52
|
-
export {
|
|
53
|
-
SchemaProperty
|
|
54
|
-
};
|
|
55
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Property/SchemaProperty.tsx"],"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 { 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 // eslint-disable-next-line react-hooks/exhaustive-deps\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>(undefined)\n const [divRef, divDispatch] = useEvent<HTMLDivElement>(undefined)\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 <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch)}>\n <NewReleasesIcon color=\"warning\" fontSize=\"inherit\" />\n </IconButton>\n ) : resolvedSchema === undefined ? (\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch)}>\n <NewReleasesIcon color=\"disabled\" fontSize=\"inherit\" />\n </IconButton>\n ) : (\n <IconButton rel=\"noopener noreferrer\" size=\"small\" target=\"_blank\" href={resolvedSchema?.huri?.href ?? ''}>\n <VerifiedIcon color=\"success\" fontSize=\"inherit\" />\n </IconButton>\n )\n ) : null}\n {value ? (\n <>\n {showLinkNames ? (\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 )}\n {showOpenNewWindowLink ? (\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch, true)}>\n <OpenInNewIcon fontSize=\"inherit\" />\n </IconButton>\n ) : null}\n </>\n ) : null}\n </Property>\n )\n },\n)\n\nSchemaProperty.displayName = 'SchemaProperty'\n"],"mappings":";AAAA,S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,SACrB,oBAAC,cAAW,KAAK,WAAW,MAAK,SAAQ,SAAS,MAAM,QAAQ,cAAc,GAC5E,8BAAC,mBAAgB,OAAM,YAAW,UAAS,WAAU,GACvD,IAEA,oBAAC,cAAW,KAAI,uBAAsB,MAAK,SAAQ,QAAO,UAAS,MAAM,gBAAgB,MAAM,QAAQ,IACrG,8BAAC,gBAAa,OAAM,WAAU,UAAS,WAAU,GACnD,IAEA;AAAA,MACH,QACC,iCACG;AAAA,wBACC,oBAAC,UAAO,SAAQ,SAAQ,OAAM,QAAO,IAAI,EAAE,QAAQ,UAAU,GAC3D,8BAAC,iBAAc,KAAK,QAAQ,OAAc,OAAM,eAAc,SAAS,MAAM,QAAQ,WAAW,GAAG,GACrG,IAEA,oBAAC,iBAAc,KAAK,QAAQ,OAAc,OAAM,eAAc,SAAS,MAAM,QAAQ,WAAW,GAAG;AAAA,QAEpG,wBACC,oBAAC,cAAW,KAAK,WAAW,MAAK,SAAQ,SAAS,MAAM,QAAQ,gBAAgB,IAAI,GAClF,8BAAC,iBAAc,UAAS,WAAU,GACpC,IACE;AAAA,SACN,IACE;AAAA,OACN;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;","names":["entry"]}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/components/SelectEx/SchemaSelectEx.tsx
|
|
21
|
-
var SchemaSelectEx_exports = {};
|
|
22
|
-
__export(SchemaSelectEx_exports, {
|
|
23
|
-
SchemaSelectEx: () => SchemaSelectEx
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(SchemaSelectEx_exports);
|
|
26
|
-
var import_material = require("@mui/material");
|
|
27
|
-
var import_react_select = require("@xylabs/react-select");
|
|
28
|
-
|
|
29
|
-
// src/contexts/Schema/Context.ts
|
|
30
|
-
var import_react_shared = require("@xyo-network/react-shared");
|
|
31
|
-
var SchemaContext = (0, import_react_shared.createContextEx)();
|
|
32
|
-
|
|
33
|
-
// src/contexts/Schema/use.ts
|
|
34
|
-
var import_react_shared2 = require("@xyo-network/react-shared");
|
|
35
|
-
var useSchema = (required = false) => {
|
|
36
|
-
return (0, import_react_shared2.useContextEx)(SchemaContext, "Schema", required);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// src/components/SelectEx/SchemaSelectEx.tsx
|
|
40
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
|
-
var SchemaSelectEx = ({ onChange, ...props }) => {
|
|
42
|
-
const { schema, setSchema, schemaList } = useSchema(false);
|
|
43
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
44
|
-
import_react_select.SelectEx,
|
|
45
|
-
{
|
|
46
|
-
variant: "outlined",
|
|
47
|
-
size: "small",
|
|
48
|
-
value: schema ?? "none",
|
|
49
|
-
onChange: (event, child) => {
|
|
50
|
-
if (event.target.value !== schema) {
|
|
51
|
-
onChange?.(event, child);
|
|
52
|
-
setSchema?.(event.target.value);
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
renderValue: (value) => {
|
|
56
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { children: value === "none" ? "- None -" : value });
|
|
57
|
-
},
|
|
58
|
-
...props,
|
|
59
|
-
children: [
|
|
60
|
-
schemaList?.map((schema2, index) => {
|
|
61
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.MenuItem, { value: schema2, children: schema2 }, index);
|
|
62
|
-
}),
|
|
63
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.MenuItem, { value: "none", children: "- None -" }, "none")
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=SchemaSelectEx.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/SelectEx/SchemaSelectEx.tsx","../../../../src/contexts/Schema/Context.ts","../../../../src/contexts/Schema/use.ts"],"sourcesContent":["import { MenuItem, Typography } from '@mui/material'\nimport { SelectEx, SelectExProps } from '@xylabs/react-select'\n\nimport { useSchema } from '../../contexts'\n\nexport type SchemaSelectExProps = SelectExProps<string>\n\nexport const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({ onChange, ...props }) => {\n const { schema, setSchema, schemaList } = useSchema(false)\n\n return (\n <SelectEx\n variant=\"outlined\"\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'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContext } from './Context'\nimport { SchemaContextState } from './State'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqC;AACrC,0BAAwC;;;ACDxC,0BAAgC;AAIzB,IAAM,oBAAgB,qCAAoC;;;ACJjE,IAAAA,uBAA6B;AAKtB,IAAM,YAAY,CAAC,WAAW,UAAU;AAC7C,aAAO,mCAAiC,eAAe,UAAU,QAAQ;AAC3E;;;AFII;AAJG,IAAM,iBAAgD,CAAC,EAAE,UAAU,GAAG,MAAM,MAAM;AACvF,QAAM,EAAE,QAAQ,WAAW,WAAW,IAAI,UAAU,KAAK;AAEzD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,OAAO,UAAU;AAAA,MACjB,UAAU,CAAC,OAAO,UAAU;AAC1B,YAAI,MAAM,OAAO,UAAU,QAAQ;AACjC,qBAAW,OAAO,KAAK;AACvB,sBAAY,MAAM,OAAO,KAAK;AAAA,QAChC;AAAA,MACF;AAAA,MACA,aAAa,CAAC,UAAU;AACtB,eAAO,4CAAC,8BAAY,oBAAU,SAAS,aAAa,OAAM;AAAA,MAC5D;AAAA,MACC,GAAG;AAAA,MAEH;AAAA,oBAAY,IAAI,CAACC,SAAQ,UAAU;AAClC,iBACE,4CAAC,4BAAqB,OAAOA,SAC1B,UAAAA,WADY,KAEf;AAAA,QAEJ,CAAC;AAAA,QACD,4CAAC,4BAAoB,OAAM,QAAO,wBAApB,MAEd;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["import_react_shared","schema"]}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// src/components/SelectEx/SchemaSelectEx.tsx
|
|
2
|
-
import { MenuItem, Typography } from "@mui/material";
|
|
3
|
-
import { SelectEx } from "@xylabs/react-select";
|
|
4
|
-
|
|
5
|
-
// src/contexts/Schema/Context.ts
|
|
6
|
-
import { createContextEx } from "@xyo-network/react-shared";
|
|
7
|
-
var SchemaContext = createContextEx();
|
|
8
|
-
|
|
9
|
-
// src/contexts/Schema/use.ts
|
|
10
|
-
import { useContextEx } from "@xyo-network/react-shared";
|
|
11
|
-
var useSchema = (required = false) => {
|
|
12
|
-
return useContextEx(SchemaContext, "Schema", required);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// src/components/SelectEx/SchemaSelectEx.tsx
|
|
16
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
-
var SchemaSelectEx = ({ onChange, ...props }) => {
|
|
18
|
-
const { schema, setSchema, schemaList } = useSchema(false);
|
|
19
|
-
return /* @__PURE__ */ jsxs(
|
|
20
|
-
SelectEx,
|
|
21
|
-
{
|
|
22
|
-
variant: "outlined",
|
|
23
|
-
size: "small",
|
|
24
|
-
value: schema ?? "none",
|
|
25
|
-
onChange: (event, child) => {
|
|
26
|
-
if (event.target.value !== schema) {
|
|
27
|
-
onChange?.(event, child);
|
|
28
|
-
setSchema?.(event.target.value);
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
renderValue: (value) => {
|
|
32
|
-
return /* @__PURE__ */ jsx(Typography, { children: value === "none" ? "- None -" : value });
|
|
33
|
-
},
|
|
34
|
-
...props,
|
|
35
|
-
children: [
|
|
36
|
-
schemaList?.map((schema2, index) => {
|
|
37
|
-
return /* @__PURE__ */ jsx(MenuItem, { value: schema2, children: schema2 }, index);
|
|
38
|
-
}),
|
|
39
|
-
/* @__PURE__ */ jsx(MenuItem, { value: "none", children: "- None -" }, "none")
|
|
40
|
-
]
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
export {
|
|
45
|
-
SchemaSelectEx
|
|
46
|
-
};
|
|
47
|
-
//# sourceMappingURL=SchemaSelectEx.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/SelectEx/SchemaSelectEx.tsx","../../../../src/contexts/Schema/Context.ts","../../../../src/contexts/Schema/use.ts"],"sourcesContent":["import { MenuItem, Typography } from '@mui/material'\nimport { SelectEx, SelectExProps } from '@xylabs/react-select'\n\nimport { useSchema } from '../../contexts'\n\nexport type SchemaSelectExProps = SelectExProps<string>\n\nexport const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({ onChange, ...props }) => {\n const { schema, setSchema, schemaList } = useSchema(false)\n\n return (\n <SelectEx\n variant=\"outlined\"\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'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContext } from './Context'\nimport { SchemaContextState } from './State'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":";AAAA,SAAS,UAAU,kBAAkB;AACrC,SAAS,gBAA+B;;;ACDxC,SAAS,uBAAuB;AAIzB,IAAM,gBAAgB,gBAAoC;;;ACJjE,SAAS,oBAAoB;AAKtB,IAAM,YAAY,CAAC,WAAW,UAAU;AAC7C,SAAO,aAAiC,eAAe,UAAU,QAAQ;AAC3E;;;AFII,SAWW,KAXX;AAJG,IAAM,iBAAgD,CAAC,EAAE,UAAU,GAAG,MAAM,MAAM;AACvF,QAAM,EAAE,QAAQ,WAAW,WAAW,IAAI,UAAU,KAAK;AAEzD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,OAAO,UAAU;AAAA,MACjB,UAAU,CAAC,OAAO,UAAU;AAC1B,YAAI,MAAM,OAAO,UAAU,QAAQ;AACjC,qBAAW,OAAO,KAAK;AACvB,sBAAY,MAAM,OAAO,KAAK;AAAA,QAChC;AAAA,MACF;AAAA,MACA,aAAa,CAAC,UAAU;AACtB,eAAO,oBAAC,cAAY,oBAAU,SAAS,aAAa,OAAM;AAAA,MAC5D;AAAA,MACC,GAAG;AAAA,MAEH;AAAA,oBAAY,IAAI,CAACA,SAAQ,UAAU;AAClC,iBACE,oBAAC,YAAqB,OAAOA,SAC1B,UAAAA,WADY,KAEf;AAAA,QAEJ,CAAC;AAAA,QACD,oBAAC,YAAoB,OAAM,QAAO,wBAApB,MAEd;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["schema"]}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/components/SelectEx/index.ts
|
|
21
|
-
var SelectEx_exports = {};
|
|
22
|
-
__export(SelectEx_exports, {
|
|
23
|
-
SchemaSelectEx: () => SchemaSelectEx
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(SelectEx_exports);
|
|
26
|
-
|
|
27
|
-
// src/components/SelectEx/SchemaSelectEx.tsx
|
|
28
|
-
var import_material = require("@mui/material");
|
|
29
|
-
var import_react_select = require("@xylabs/react-select");
|
|
30
|
-
|
|
31
|
-
// src/contexts/Schema/Context.ts
|
|
32
|
-
var import_react_shared = require("@xyo-network/react-shared");
|
|
33
|
-
var SchemaContext = (0, import_react_shared.createContextEx)();
|
|
34
|
-
|
|
35
|
-
// src/contexts/Schema/use.ts
|
|
36
|
-
var import_react_shared2 = require("@xyo-network/react-shared");
|
|
37
|
-
var useSchema = (required = false) => {
|
|
38
|
-
return (0, import_react_shared2.useContextEx)(SchemaContext, "Schema", required);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// src/components/SelectEx/SchemaSelectEx.tsx
|
|
42
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
43
|
-
var SchemaSelectEx = ({ onChange, ...props }) => {
|
|
44
|
-
const { schema, setSchema, schemaList } = useSchema(false);
|
|
45
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
46
|
-
import_react_select.SelectEx,
|
|
47
|
-
{
|
|
48
|
-
variant: "outlined",
|
|
49
|
-
size: "small",
|
|
50
|
-
value: schema ?? "none",
|
|
51
|
-
onChange: (event, child) => {
|
|
52
|
-
if (event.target.value !== schema) {
|
|
53
|
-
onChange?.(event, child);
|
|
54
|
-
setSchema?.(event.target.value);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
renderValue: (value) => {
|
|
58
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { children: value === "none" ? "- None -" : value });
|
|
59
|
-
},
|
|
60
|
-
...props,
|
|
61
|
-
children: [
|
|
62
|
-
schemaList?.map((schema2, index) => {
|
|
63
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.MenuItem, { value: schema2, children: schema2 }, index);
|
|
64
|
-
}),
|
|
65
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.MenuItem, { value: "none", children: "- None -" }, "none")
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/SelectEx/index.ts","../../../../src/components/SelectEx/SchemaSelectEx.tsx","../../../../src/contexts/Schema/Context.ts","../../../../src/contexts/Schema/use.ts"],"sourcesContent":["export * from './SchemaSelectEx'\n","import { MenuItem, Typography } from '@mui/material'\nimport { SelectEx, SelectExProps } from '@xylabs/react-select'\n\nimport { useSchema } from '../../contexts'\n\nexport type SchemaSelectExProps = SelectExProps<string>\n\nexport const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({ onChange, ...props }) => {\n const { schema, setSchema, schemaList } = useSchema(false)\n\n return (\n <SelectEx\n variant=\"outlined\"\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'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContext } from './Context'\nimport { SchemaContextState } from './State'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAAqC;AACrC,0BAAwC;;;ACDxC,0BAAgC;AAIzB,IAAM,oBAAgB,qCAAoC;;;ACJjE,IAAAA,uBAA6B;AAKtB,IAAM,YAAY,CAAC,WAAW,UAAU;AAC7C,aAAO,mCAAiC,eAAe,UAAU,QAAQ;AAC3E;;;AFII;AAJG,IAAM,iBAAgD,CAAC,EAAE,UAAU,GAAG,MAAM,MAAM;AACvF,QAAM,EAAE,QAAQ,WAAW,WAAW,IAAI,UAAU,KAAK;AAEzD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,OAAO,UAAU;AAAA,MACjB,UAAU,CAAC,OAAO,UAAU;AAC1B,YAAI,MAAM,OAAO,UAAU,QAAQ;AACjC,qBAAW,OAAO,KAAK;AACvB,sBAAY,MAAM,OAAO,KAAK;AAAA,QAChC;AAAA,MACF;AAAA,MACA,aAAa,CAAC,UAAU;AACtB,eAAO,4CAAC,8BAAY,oBAAU,SAAS,aAAa,OAAM;AAAA,MAC5D;AAAA,MACC,GAAG;AAAA,MAEH;AAAA,oBAAY,IAAI,CAACC,SAAQ,UAAU;AAClC,iBACE,4CAAC,4BAAqB,OAAOA,SAC1B,UAAAA,WADY,KAEf;AAAA,QAEJ,CAAC;AAAA,QACD,4CAAC,4BAAoB,OAAM,QAAO,wBAApB,MAEd;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["import_react_shared","schema"]}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// src/components/SelectEx/SchemaSelectEx.tsx
|
|
2
|
-
import { MenuItem, Typography } from "@mui/material";
|
|
3
|
-
import { SelectEx } from "@xylabs/react-select";
|
|
4
|
-
|
|
5
|
-
// src/contexts/Schema/Context.ts
|
|
6
|
-
import { createContextEx } from "@xyo-network/react-shared";
|
|
7
|
-
var SchemaContext = createContextEx();
|
|
8
|
-
|
|
9
|
-
// src/contexts/Schema/use.ts
|
|
10
|
-
import { useContextEx } from "@xyo-network/react-shared";
|
|
11
|
-
var useSchema = (required = false) => {
|
|
12
|
-
return useContextEx(SchemaContext, "Schema", required);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// src/components/SelectEx/SchemaSelectEx.tsx
|
|
16
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
-
var SchemaSelectEx = ({ onChange, ...props }) => {
|
|
18
|
-
const { schema, setSchema, schemaList } = useSchema(false);
|
|
19
|
-
return /* @__PURE__ */ jsxs(
|
|
20
|
-
SelectEx,
|
|
21
|
-
{
|
|
22
|
-
variant: "outlined",
|
|
23
|
-
size: "small",
|
|
24
|
-
value: schema ?? "none",
|
|
25
|
-
onChange: (event, child) => {
|
|
26
|
-
if (event.target.value !== schema) {
|
|
27
|
-
onChange?.(event, child);
|
|
28
|
-
setSchema?.(event.target.value);
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
renderValue: (value) => {
|
|
32
|
-
return /* @__PURE__ */ jsx(Typography, { children: value === "none" ? "- None -" : value });
|
|
33
|
-
},
|
|
34
|
-
...props,
|
|
35
|
-
children: [
|
|
36
|
-
schemaList?.map((schema2, index) => {
|
|
37
|
-
return /* @__PURE__ */ jsx(MenuItem, { value: schema2, children: schema2 }, index);
|
|
38
|
-
}),
|
|
39
|
-
/* @__PURE__ */ jsx(MenuItem, { value: "none", children: "- None -" }, "none")
|
|
40
|
-
]
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
export {
|
|
45
|
-
SchemaSelectEx
|
|
46
|
-
};
|
|
47
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/SelectEx/SchemaSelectEx.tsx","../../../../src/contexts/Schema/Context.ts","../../../../src/contexts/Schema/use.ts"],"sourcesContent":["import { MenuItem, Typography } from '@mui/material'\nimport { SelectEx, SelectExProps } from '@xylabs/react-select'\n\nimport { useSchema } from '../../contexts'\n\nexport type SchemaSelectExProps = SelectExProps<string>\n\nexport const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({ onChange, ...props }) => {\n const { schema, setSchema, schemaList } = useSchema(false)\n\n return (\n <SelectEx\n variant=\"outlined\"\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'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContext } from './Context'\nimport { SchemaContextState } from './State'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":";AAAA,SAAS,UAAU,kBAAkB;AACrC,SAAS,gBAA+B;;;ACDxC,SAAS,uBAAuB;AAIzB,IAAM,gBAAgB,gBAAoC;;;ACJjE,SAAS,oBAAoB;AAKtB,IAAM,YAAY,CAAC,WAAW,UAAU;AAC7C,SAAO,aAAiC,eAAe,UAAU,QAAQ;AAC3E;;;AFII,SAWW,KAXX;AAJG,IAAM,iBAAgD,CAAC,EAAE,UAAU,GAAG,MAAM,MAAM;AACvF,QAAM,EAAE,QAAQ,WAAW,WAAW,IAAI,UAAU,KAAK;AAEzD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,OAAO,UAAU;AAAA,MACjB,UAAU,CAAC,OAAO,UAAU;AAC1B,YAAI,MAAM,OAAO,UAAU,QAAQ;AACjC,qBAAW,OAAO,KAAK;AACvB,sBAAY,MAAM,OAAO,KAAK;AAAA,QAChC;AAAA,MACF;AAAA,MACA,aAAa,CAAC,UAAU;AACtB,eAAO,oBAAC,cAAY,oBAAU,SAAS,aAAa,OAAM;AAAA,MAC5D;AAAA,MACC,GAAG;AAAA,MAEH;AAAA,oBAAY,IAAI,CAACA,SAAQ,UAAU;AAClC,iBACE,oBAAC,YAAqB,OAAOA,SAC1B,UAAAA,WADY,KAEf;AAAA,QAEJ,CAAC;AAAA,QACD,oBAAC,YAAoB,OAAM,QAAO,wBAApB,MAEd;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["schema"]}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/components/index.ts
|
|
21
|
-
var components_exports = {};
|
|
22
|
-
__export(components_exports, {
|
|
23
|
-
SchemaProperty: () => SchemaProperty,
|
|
24
|
-
SchemaSelectEx: () => SchemaSelectEx
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(components_exports);
|
|
27
|
-
|
|
28
|
-
// src/components/Property/SchemaProperty.tsx
|
|
29
|
-
var import_icons_material = require("@mui/icons-material");
|
|
30
|
-
var import_material = require("@mui/material");
|
|
31
|
-
var import_react_async_effect = require("@xylabs/react-async-effect");
|
|
32
|
-
var import_react_link = require("@xylabs/react-link");
|
|
33
|
-
var import_react_event = require("@xyo-network/react-event");
|
|
34
|
-
var import_react_property = require("@xyo-network/react-property");
|
|
35
|
-
var import_schema_cache = require("@xyo-network/schema-cache");
|
|
36
|
-
var import_react = require("react");
|
|
37
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
38
|
-
var useResolveSchema = (schema) => {
|
|
39
|
-
const [entry, setEntry] = (0, import_react.useState)();
|
|
40
|
-
(0, import_react_async_effect.useAsyncEffect)(
|
|
41
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
|
-
async (mounted) => {
|
|
43
|
-
if (schema) {
|
|
44
|
-
const entry2 = await import_schema_cache.SchemaCache.instance.get(schema);
|
|
45
|
-
if (mounted()) {
|
|
46
|
-
setEntry(entry2);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
[schema]
|
|
51
|
-
);
|
|
52
|
-
return entry;
|
|
53
|
-
};
|
|
54
|
-
var SchemaProperty = (0, import_react.forwardRef)(
|
|
55
|
-
({ showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props }, forwardedRef) => {
|
|
56
|
-
const resolvedSchema = useResolveSchema(value);
|
|
57
|
-
const [buttonRef, buttonDispatch] = (0, import_react_event.useEvent)(void 0);
|
|
58
|
-
const [divRef, divDispatch] = (0, import_react_event.useEvent)(void 0);
|
|
59
|
-
const onClick = (dispatch, openNewWindow = false) => {
|
|
60
|
-
dispatch?.(
|
|
61
|
-
"schema",
|
|
62
|
-
"click",
|
|
63
|
-
JSON.stringify({
|
|
64
|
-
openNewWindow,
|
|
65
|
-
schema: value
|
|
66
|
-
})
|
|
67
|
-
);
|
|
68
|
-
};
|
|
69
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_property.Property, { ref: forwardedRef, title: "Schema", value, tip: "Schema sent with the payload", titleProps, ...props, children: [
|
|
70
|
-
value && showStatusIcon ? resolvedSchema === null ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.IconButton, { ref: buttonRef, size: "small", onClick: () => onClick(buttonDispatch), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.NewReleases, { color: "warning", fontSize: "inherit" }) }) : resolvedSchema === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.IconButton, { ref: buttonRef, size: "small", onClick: () => onClick(buttonDispatch), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.NewReleases, { color: "disabled", fontSize: "inherit" }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.IconButton, { rel: "noopener noreferrer", size: "small", target: "_blank", href: resolvedSchema?.huri?.href ?? "", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.Verified, { color: "success", fontSize: "inherit" }) }) : null,
|
|
71
|
-
value ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
72
|
-
showLinkNames ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_link.LinkEx, { display: "block", width: "100%", sx: { cursor: "pointer" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_property.PropertyValue, { ref: divRef, value, title: "view schema", onClick: () => onClick(divDispatch) }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_property.PropertyValue, { ref: divRef, value, title: "view schema", onClick: () => onClick(divDispatch) }),
|
|
73
|
-
showOpenNewWindowLink ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.IconButton, { ref: buttonRef, size: "small", onClick: () => onClick(buttonDispatch, true), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.OpenInNew, { fontSize: "inherit" }) }) : null
|
|
74
|
-
] }) : null
|
|
75
|
-
] });
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
SchemaProperty.displayName = "SchemaProperty";
|
|
79
|
-
|
|
80
|
-
// src/components/SelectEx/SchemaSelectEx.tsx
|
|
81
|
-
var import_material2 = require("@mui/material");
|
|
82
|
-
var import_react_select = require("@xylabs/react-select");
|
|
83
|
-
|
|
84
|
-
// src/contexts/Schema/Context.ts
|
|
85
|
-
var import_react_shared = require("@xyo-network/react-shared");
|
|
86
|
-
var SchemaContext = (0, import_react_shared.createContextEx)();
|
|
87
|
-
|
|
88
|
-
// src/contexts/Schema/use.ts
|
|
89
|
-
var import_react_shared2 = require("@xyo-network/react-shared");
|
|
90
|
-
var useSchema = (required = false) => {
|
|
91
|
-
return (0, import_react_shared2.useContextEx)(SchemaContext, "Schema", required);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// src/components/SelectEx/SchemaSelectEx.tsx
|
|
95
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
96
|
-
var SchemaSelectEx = ({ onChange, ...props }) => {
|
|
97
|
-
const { schema, setSchema, schemaList } = useSchema(false);
|
|
98
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
99
|
-
import_react_select.SelectEx,
|
|
100
|
-
{
|
|
101
|
-
variant: "outlined",
|
|
102
|
-
size: "small",
|
|
103
|
-
value: schema ?? "none",
|
|
104
|
-
onChange: (event, child) => {
|
|
105
|
-
if (event.target.value !== schema) {
|
|
106
|
-
onChange?.(event, child);
|
|
107
|
-
setSchema?.(event.target.value);
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
renderValue: (value) => {
|
|
111
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material2.Typography, { children: value === "none" ? "- None -" : value });
|
|
112
|
-
},
|
|
113
|
-
...props,
|
|
114
|
-
children: [
|
|
115
|
-
schemaList?.map((schema2, index) => {
|
|
116
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material2.MenuItem, { value: schema2, children: schema2 }, index);
|
|
117
|
-
}),
|
|
118
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material2.MenuItem, { value: "none", children: "- None -" }, "none")
|
|
119
|
-
]
|
|
120
|
-
}
|
|
121
|
-
);
|
|
122
|
-
};
|
|
123
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/index.ts","../../../src/components/Property/SchemaProperty.tsx","../../../src/components/SelectEx/SchemaSelectEx.tsx","../../../src/contexts/Schema/Context.ts","../../../src/contexts/Schema/use.ts"],"sourcesContent":["export * from './Property'\nexport * from './SelectEx'\n","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 { 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 // eslint-disable-next-line react-hooks/exhaustive-deps\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>(undefined)\n const [divRef, divDispatch] = useEvent<HTMLDivElement>(undefined)\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 <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch)}>\n <NewReleasesIcon color=\"warning\" fontSize=\"inherit\" />\n </IconButton>\n ) : resolvedSchema === undefined ? (\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch)}>\n <NewReleasesIcon color=\"disabled\" fontSize=\"inherit\" />\n </IconButton>\n ) : (\n <IconButton rel=\"noopener noreferrer\" size=\"small\" target=\"_blank\" href={resolvedSchema?.huri?.href ?? ''}>\n <VerifiedIcon color=\"success\" fontSize=\"inherit\" />\n </IconButton>\n )\n ) : null}\n {value ? (\n <>\n {showLinkNames ? (\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 )}\n {showOpenNewWindowLink ? (\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch, true)}>\n <OpenInNewIcon fontSize=\"inherit\" />\n </IconButton>\n ) : null}\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'\n\nimport { useSchema } from '../../contexts'\n\nexport type SchemaSelectExProps = SelectExProps<string>\n\nexport const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({ onChange, ...props }) => {\n const { schema, setSchema, schemaList } = useSchema(false)\n\n return (\n <SelectEx\n variant=\"outlined\"\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'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContext } from './Context'\nimport { SchemaContextState } from './State'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,4BAAqG;AACrG,sBAA2B;AAC3B,gCAA+B;AAC/B,wBAAuB;AACvB,yBAAmD;AACnD,4BAAuD;AACvD,0BAA8C;AAC9C,mBAAqC;AAgDvB;AAvCd,IAAM,mBAAmB,CAAC,WAAoB;AAC5C,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAkC;AAC5D;AAAA;AAAA,IAEE,OAAO,YAAY;AACjB,UAAI,QAAQ;AACV,cAAMA,SAAQ,MAAM,gCAAY,SAAS,IAAI,MAAM;AACnD,YAAI,QAAQ,GAAG;AACb,mBAASA,MAAK;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,MAAM;A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