@xyo-network/react-payload-details 2.64.9 → 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.
Files changed (74) hide show
  1. package/dist/docs.json +30 -30
  2. package/package.json +14 -14
  3. package/dist/browser/components/Details/DataDetails.cjs +0 -106
  4. package/dist/browser/components/Details/DataDetails.cjs.map +0 -1
  5. package/dist/browser/components/Details/DataDetails.js +0 -85
  6. package/dist/browser/components/Details/DataDetails.js.map +0 -1
  7. package/dist/browser/components/Details/Details.cjs +0 -196
  8. package/dist/browser/components/Details/Details.cjs.map +0 -1
  9. package/dist/browser/components/Details/Details.js +0 -165
  10. package/dist/browser/components/Details/Details.js.map +0 -1
  11. package/dist/browser/components/Details/HashSourceDetails.cjs +0 -47
  12. package/dist/browser/components/Details/HashSourceDetails.cjs.map +0 -1
  13. package/dist/browser/components/Details/HashSourceDetails.js +0 -26
  14. package/dist/browser/components/Details/HashSourceDetails.js.map +0 -1
  15. package/dist/browser/components/Details/JsonDetails.cjs +0 -66
  16. package/dist/browser/components/Details/JsonDetails.cjs.map +0 -1
  17. package/dist/browser/components/Details/JsonDetails.js +0 -35
  18. package/dist/browser/components/Details/JsonDetails.js.map +0 -1
  19. package/dist/browser/components/Details/ValidationDetails/ValidationDetails.cjs +0 -57
  20. package/dist/browser/components/Details/ValidationDetails/ValidationDetails.cjs.map +0 -1
  21. package/dist/browser/components/Details/ValidationDetails/ValidationDetails.js +0 -36
  22. package/dist/browser/components/Details/ValidationDetails/ValidationDetails.js.map +0 -1
  23. package/dist/browser/components/Details/ValidationDetails/ValidationDetailsProps.cjs +0 -19
  24. package/dist/browser/components/Details/ValidationDetails/ValidationDetailsProps.cjs.map +0 -1
  25. package/dist/browser/components/Details/ValidationDetails/ValidationDetailsProps.js +0 -1
  26. package/dist/browser/components/Details/ValidationDetails/ValidationDetailsProps.js.map +0 -1
  27. package/dist/browser/components/Details/ValidationDetails/index.cjs +0 -59
  28. package/dist/browser/components/Details/ValidationDetails/index.cjs.map +0 -1
  29. package/dist/browser/components/Details/ValidationDetails/index.js +0 -36
  30. package/dist/browser/components/Details/ValidationDetails/index.js.map +0 -1
  31. package/dist/browser/components/Details/index.cjs +0 -201
  32. package/dist/browser/components/Details/index.cjs.map +0 -1
  33. package/dist/browser/components/Details/index.js +0 -168
  34. package/dist/browser/components/Details/index.js.map +0 -1
  35. package/dist/browser/components/index.cjs +0 -201
  36. package/dist/browser/components/index.cjs.map +0 -1
  37. package/dist/browser/components/index.js +0 -168
  38. package/dist/browser/components/index.js.map +0 -1
  39. package/dist/node/components/Details/DataDetails.cjs +0 -110
  40. package/dist/node/components/Details/DataDetails.cjs.map +0 -1
  41. package/dist/node/components/Details/DataDetails.js +0 -85
  42. package/dist/node/components/Details/DataDetails.js.map +0 -1
  43. package/dist/node/components/Details/Details.cjs +0 -200
  44. package/dist/node/components/Details/Details.cjs.map +0 -1
  45. package/dist/node/components/Details/Details.js +0 -165
  46. package/dist/node/components/Details/Details.js.map +0 -1
  47. package/dist/node/components/Details/HashSourceDetails.cjs +0 -51
  48. package/dist/node/components/Details/HashSourceDetails.cjs.map +0 -1
  49. package/dist/node/components/Details/HashSourceDetails.js +0 -26
  50. package/dist/node/components/Details/HashSourceDetails.js.map +0 -1
  51. package/dist/node/components/Details/JsonDetails.cjs +0 -70
  52. package/dist/node/components/Details/JsonDetails.cjs.map +0 -1
  53. package/dist/node/components/Details/JsonDetails.js +0 -35
  54. package/dist/node/components/Details/JsonDetails.js.map +0 -1
  55. package/dist/node/components/Details/ValidationDetails/ValidationDetails.cjs +0 -61
  56. package/dist/node/components/Details/ValidationDetails/ValidationDetails.cjs.map +0 -1
  57. package/dist/node/components/Details/ValidationDetails/ValidationDetails.js +0 -36
  58. package/dist/node/components/Details/ValidationDetails/ValidationDetails.js.map +0 -1
  59. package/dist/node/components/Details/ValidationDetails/ValidationDetailsProps.cjs +0 -19
  60. package/dist/node/components/Details/ValidationDetails/ValidationDetailsProps.cjs.map +0 -1
  61. package/dist/node/components/Details/ValidationDetails/ValidationDetailsProps.js +0 -1
  62. package/dist/node/components/Details/ValidationDetails/ValidationDetailsProps.js.map +0 -1
  63. package/dist/node/components/Details/ValidationDetails/index.cjs +0 -63
  64. package/dist/node/components/Details/ValidationDetails/index.cjs.map +0 -1
  65. package/dist/node/components/Details/ValidationDetails/index.js +0 -36
  66. package/dist/node/components/Details/ValidationDetails/index.js.map +0 -1
  67. package/dist/node/components/Details/index.cjs +0 -208
  68. package/dist/node/components/Details/index.cjs.map +0 -1
  69. package/dist/node/components/Details/index.js +0 -168
  70. package/dist/node/components/Details/index.js.map +0 -1
  71. package/dist/node/components/index.cjs +0 -208
  72. package/dist/node/components/index.cjs.map +0 -1
  73. package/dist/node/components/index.js +0 -168
  74. package/dist/node/components/index.js.map +0 -1
@@ -1,168 +0,0 @@
1
- // src/components/Details/DataDetails.tsx
2
- import { ContentCopy as ContentCopyIcon2, Visibility as VisibilityIcon } from "@mui/icons-material";
3
- import { Dialog, DialogActions, DialogContent, DialogTitle } from "@mui/material";
4
- import { ButtonEx } from "@xylabs/react-button";
5
- import { PayloadHasher as PayloadHasher2 } from "@xyo-network/hash";
6
- import { Property } from "@xyo-network/react-property";
7
- import { usePayloadHash } from "@xyo-network/react-shared";
8
- import { useState } from "react";
9
-
10
- // src/components/Details/HashSourceDetails.tsx
11
- import { ContentCopy as ContentCopyIcon } from "@mui/icons-material";
12
- import { IconButton, Typography, useTheme } from "@mui/material";
13
- import { FlexCol, FlexGrowRow, FlexRow } from "@xylabs/react-flexbox";
14
- import { QuickTipButton } from "@xylabs/react-quick-tip-button";
15
- import { PayloadHasher } from "@xyo-network/hash";
16
- import { jsx, jsxs } from "react/jsx-runtime";
17
- var PayloadHashSourceDetails = ({ noTitle = false, payload, ...props }) => {
18
- const theme = useTheme();
19
- const payloadString = payload ? JSON.stringify(PayloadHasher.hashFields(payload), null, 2) : "";
20
- return /* @__PURE__ */ jsxs(FlexCol, { alignItems: "stretch", ...props, children: [
21
- noTitle ? null : /* @__PURE__ */ jsxs(FlexRow, { margin: 1, justifyContent: "flex-start", children: [
22
- /* @__PURE__ */ jsx(Typography, { children: "Hash Source" }),
23
- /* @__PURE__ */ jsx(QuickTipButton, { title: "Hash Source", children: "The actual string used to generate the hash (SHA256)" })
24
- ] }),
25
- /* @__PURE__ */ jsxs(FlexRow, { children: [
26
- /* @__PURE__ */ jsx(FlexGrowRow, { background: true, border: 1, borderColor: theme.palette.divider, justifyContent: "start", children: /* @__PURE__ */ jsx(Typography, { padding: 2, fontFamily: "monospace", variant: "body1", sx: { overflowWrap: "break-word", wordBreak: "break-all" }, children: payloadString }) }),
27
- /* @__PURE__ */ jsx(IconButton, { children: /* @__PURE__ */ jsx(ContentCopyIcon, {}) })
28
- ] }),
29
- noTitle ? /* @__PURE__ */ jsx(FlexRow, { margin: 1, justifyContent: "flex-start", children: /* @__PURE__ */ jsx(Typography, { variant: "body2", children: "The actual string used to generate the hash (SHA256). This can be used to validate the hash manually." }) }) : null
30
- ] });
31
- };
32
-
33
- // src/components/Details/DataDetails.tsx
34
- import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
35
- var PayloadDataDetails = ({ size, badge, payload, ...props }) => {
36
- const payloadString = payload ? JSON.stringify(PayloadHasher2.hashFields(payload), null, 2) : "";
37
- const [viewSourceOpen, setViewSourceOpen] = useState(false);
38
- const hash = usePayloadHash(payload);
39
- let elevation = 2;
40
- if (props.paper) {
41
- elevation += props.elevation ?? 0;
42
- }
43
- const actions = [
44
- {
45
- icon: /* @__PURE__ */ jsx2(VisibilityIcon, {}),
46
- name: "View",
47
- onClick: () => setViewSourceOpen(true)
48
- },
49
- {
50
- icon: /* @__PURE__ */ jsx2(ContentCopyIcon2, {}),
51
- name: "Copy",
52
- onClick: async () => await navigator.clipboard.writeText(hash ?? "")
53
- }
54
- ];
55
- const onCopy = async () => {
56
- await navigator.clipboard.writeText(payloadString);
57
- };
58
- return /* @__PURE__ */ jsxs2(Fragment, { children: [
59
- /* @__PURE__ */ jsx2(
60
- Property,
61
- {
62
- titleProps: { elevation },
63
- badge,
64
- size,
65
- actions,
66
- title: "Payload Hash",
67
- value: hash ?? "<Unknown>",
68
- tip: "This is the payload hash",
69
- ...props
70
- }
71
- ),
72
- /* @__PURE__ */ jsxs2(Dialog, { open: viewSourceOpen, onClose: () => setViewSourceOpen(false), children: [
73
- /* @__PURE__ */ jsx2(DialogTitle, { children: "Hash Source" }),
74
- /* @__PURE__ */ jsx2(DialogContent, { children: /* @__PURE__ */ jsx2(PayloadHashSourceDetails, { noTitle: true, payload }) }),
75
- /* @__PURE__ */ jsxs2(DialogActions, { children: [
76
- /* @__PURE__ */ jsx2(ButtonEx, { color: "secondary", onClick: onCopy, children: "Copy" }),
77
- /* @__PURE__ */ jsx2(ButtonEx, { color: "secondary", onClick: () => setViewSourceOpen(false), children: "Close" })
78
- ] })
79
- ] })
80
- ] });
81
- };
82
-
83
- // src/components/Details/Details.tsx
84
- import { FlexCol as FlexCol3 } from "@xylabs/react-flexbox";
85
- import { forwardRef } from "react";
86
-
87
- // src/components/Details/JsonDetails.tsx
88
- import { Paper, useMediaQuery, useTheme as useTheme2 } from "@mui/material";
89
- import { FlexGrowRow as FlexGrowRow2 } from "@xylabs/react-flexbox";
90
- import { PropertyGroup } from "@xyo-network/react-property";
91
- import { lazy, Suspense } from "react";
92
- import { jsx as jsx3 } from "react/jsx-runtime";
93
- var JsonView = lazy(() => import(
94
- /* webpackChunkName: "jsonView" */
95
- "react-json-view"
96
- ));
97
- var PayloadJsonDetails = ({ jsonViewProps, payload = {}, ...props }) => {
98
- const { breakpoints, palette } = useTheme2();
99
- const belowSm = useMediaQuery(breakpoints.down("sm"));
100
- let elevation = 2;
101
- if (props.paper) {
102
- elevation += props.elevation ?? 0;
103
- }
104
- const jsonTheme = palette.mode === "dark" ? "shapeshifter" : void 0;
105
- return /* @__PURE__ */ jsx3(PropertyGroup, { titleProps: { elevation }, title: "JSON", tip: "The raw JSON of the payload", ...props, children: /* @__PURE__ */ jsx3(Paper, { square: true, variant: "elevation", style: { overflow: "hidden", padding: "16px", width: "100%" }, children: /* @__PURE__ */ jsx3(Suspense, { fallback: /* @__PURE__ */ jsx3(FlexGrowRow2, {}), children: /* @__PURE__ */ jsx3(
106
- JsonView,
107
- {
108
- groupArraysAfterLength: 20,
109
- style: { backgroundColor: void 0, overflow: "hidden" },
110
- src: payload,
111
- enableClipboard: true,
112
- theme: jsonTheme,
113
- collapseStringsAfterLength: belowSm ? 24 : 32,
114
- ...jsonViewProps
115
- }
116
- ) }) }) });
117
- };
118
-
119
- // src/components/Details/ValidationDetails/ValidationDetails.tsx
120
- import { Typography as Typography2 } from "@mui/material";
121
- import { FlexCol as FlexCol2 } from "@xylabs/react-flexbox";
122
- import { usePromise } from "@xylabs/react-promise";
123
- import { PayloadValidator } from "@xyo-network/payload-validator";
124
- import { Property as Property2, PropertyGroup as PropertyGroup2 } from "@xyo-network/react-property";
125
- import { SchemaProperty } from "@xyo-network/react-schema";
126
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
127
- var PayloadValidationDetails = ({ skipBody = false, value, ...props }) => {
128
- const [validateErrors] = usePromise(async () => value ? await new PayloadValidator(value).validate() : void 0, [value]);
129
- const bodyErrors = skipBody ? [] : validateErrors ?? [];
130
- const errors = [...bodyErrors];
131
- let elevation = 2;
132
- if (props.paper) {
133
- elevation += props.elevation ?? 0;
134
- }
135
- return /* @__PURE__ */ jsxs3(PropertyGroup2, { titleProps: { elevation }, title: "Validation", tip: "The results from validating the payload", ...props, children: [
136
- /* @__PURE__ */ jsx4(
137
- Property2,
138
- {
139
- titleProps: { elevation },
140
- flexGrow: 1,
141
- title: "Valid",
142
- value: errors.length === 0 ? "True" : "False",
143
- tip: errors.length > 0 ? /* @__PURE__ */ jsx4(FlexCol2, { children: errors.map((error, index) => {
144
- return /* @__PURE__ */ jsx4(Typography2, { children: error.toString() }, index);
145
- }) }) : /* @__PURE__ */ jsx4(Typography2, { children: "No Errors" })
146
- }
147
- ),
148
- value?.schema && /* @__PURE__ */ jsx4(SchemaProperty, { flexGrow: 1, titleProps: { elevation }, value: value.schema })
149
- ] });
150
- };
151
-
152
- // src/components/Details/Details.tsx
153
- import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
154
- var PayloadDetails = forwardRef(({ paper, payload, ...props }, ref) => {
155
- return /* @__PURE__ */ jsxs4(FlexCol3, { gap: 1, justifyContent: "flex-start", alignItems: "stretch", marginTop: 2, marginBottom: 8, ref, ...props, children: [
156
- /* @__PURE__ */ jsx5(PayloadDataDetails, { paper, size: "large", badge: true, payload }),
157
- /* @__PURE__ */ jsx5(PayloadValidationDetails, { paper, value: payload }),
158
- /* @__PURE__ */ jsx5(PayloadJsonDetails, { paper, payload })
159
- ] });
160
- });
161
- PayloadDetails.displayName = "PayloadDetails";
162
- export {
163
- PayloadDataDetails,
164
- PayloadDetails,
165
- PayloadJsonDetails,
166
- PayloadValidationDetails
167
- };
168
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/components/Details/DataDetails.tsx","../../../../src/components/Details/HashSourceDetails.tsx","../../../../src/components/Details/Details.tsx","../../../../src/components/Details/JsonDetails.tsx","../../../../src/components/Details/ValidationDetails/ValidationDetails.tsx"],"sourcesContent":["import { ContentCopy as ContentCopyIcon, Visibility as VisibilityIcon } from '@mui/icons-material'\nimport { Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { PayloadHasher } from '@xyo-network/hash'\nimport { Payload } from '@xyo-network/payload-model'\nimport { Property, PropertyAction, PropertyProps } from '@xyo-network/react-property'\nimport { SizeProp, usePayloadHash } from '@xyo-network/react-shared'\nimport { useState } from 'react'\n\nimport { PayloadHashSourceDetails } from './HashSourceDetails'\n\nexport type PayloadDataDetailsProps = PropertyProps & {\n badge?: boolean\n payload?: Payload\n size?: SizeProp\n}\n\nexport const PayloadDataDetails: React.FC<PayloadDataDetailsProps> = ({ size, badge, payload, ...props }) => {\n const payloadString = payload ? JSON.stringify(PayloadHasher.hashFields(payload), null, 2) : ''\n\n const [viewSourceOpen, setViewSourceOpen] = useState(false)\n const hash = usePayloadHash(payload)\n\n let elevation = 2\n if (props.paper) {\n elevation += props.elevation ?? 0\n }\n\n const actions: PropertyAction[] = [\n {\n icon: <VisibilityIcon />,\n name: 'View',\n onClick: () => setViewSourceOpen(true),\n },\n {\n icon: <ContentCopyIcon />,\n name: 'Copy',\n onClick: async () => await navigator.clipboard.writeText(hash ?? ''),\n },\n ]\n\n const onCopy = async () => {\n await navigator.clipboard.writeText(payloadString)\n }\n\n return (\n <>\n <Property\n titleProps={{ elevation }}\n badge={badge}\n size={size}\n actions={actions}\n title=\"Payload Hash\"\n value={hash ?? '<Unknown>'}\n tip=\"This is the payload hash\"\n {...props}\n />\n <Dialog open={viewSourceOpen} onClose={() => setViewSourceOpen(false)}>\n <DialogTitle>Hash Source</DialogTitle>\n <DialogContent>\n <PayloadHashSourceDetails noTitle payload={payload} />\n </DialogContent>\n <DialogActions>\n <ButtonEx color=\"secondary\" onClick={onCopy}>\n Copy\n </ButtonEx>\n <ButtonEx color=\"secondary\" onClick={() => setViewSourceOpen(false)}>\n Close\n </ButtonEx>\n </DialogActions>\n </Dialog>\n </>\n )\n}\n","import { ContentCopy as ContentCopyIcon } from '@mui/icons-material'\nimport { IconButton, Typography, useTheme } from '@mui/material'\nimport { FlexBoxProps, FlexCol, FlexGrowRow, FlexRow } from '@xylabs/react-flexbox'\nimport { QuickTipButton } from '@xylabs/react-quick-tip-button'\nimport { PayloadHasher } from '@xyo-network/hash'\nimport { Payload } from '@xyo-network/payload-model'\n\nexport interface PayloadHashSourceDetailsProps extends FlexBoxProps {\n noTitle?: boolean\n payload?: Payload\n}\n\nexport const PayloadHashSourceDetails: React.FC<PayloadHashSourceDetailsProps> = ({ noTitle = false, payload, ...props }) => {\n const theme = useTheme()\n const payloadString = payload ? JSON.stringify(PayloadHasher.hashFields(payload), null, 2) : ''\n\n return (\n <FlexCol alignItems=\"stretch\" {...props}>\n {noTitle ? null : (\n <FlexRow margin={1} justifyContent=\"flex-start\">\n <Typography>Hash Source</Typography>\n <QuickTipButton title=\"Hash Source\">The actual string used to generate the hash (SHA256)</QuickTipButton>\n </FlexRow>\n )}\n <FlexRow>\n <FlexGrowRow background border={1} borderColor={theme.palette.divider} justifyContent=\"start\">\n <Typography padding={2} fontFamily=\"monospace\" variant=\"body1\" sx={{ overflowWrap: 'break-word', wordBreak: 'break-all' }}>\n {payloadString}\n </Typography>\n </FlexGrowRow>\n <IconButton>\n <ContentCopyIcon />\n </IconButton>\n </FlexRow>\n {noTitle ? (\n <FlexRow margin={1} justifyContent=\"flex-start\">\n <Typography variant=\"body2\">\n The actual string used to generate the hash (SHA256). This can be used to validate the hash manually.\n </Typography>\n </FlexRow>\n ) : null}\n </FlexCol>\n )\n}\n","import { FlexBoxProps, FlexCol } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { forwardRef } from 'react'\n\nimport { PayloadDataDetails } from './DataDetails'\nimport { PayloadJsonDetails } from './JsonDetails'\nimport { PayloadValidationDetails } from './ValidationDetails'\n\nexport type WithPaper<T> = T & { paper: true }\nexport type WithoutPaper<T> = T & { paper?: false }\n\nexport type PayloadDetailsProps = FlexBoxProps & {\n paper?: boolean\n payload?: Payload\n}\n\nexport const PayloadDetails = forwardRef<HTMLDivElement, PayloadDetailsProps>(({ paper, payload, ...props }, ref) => {\n return (\n <FlexCol gap={1} justifyContent=\"flex-start\" alignItems=\"stretch\" marginTop={2} marginBottom={8} ref={ref} {...props}>\n <PayloadDataDetails paper={paper} size=\"large\" badge payload={payload} />\n <PayloadValidationDetails paper={paper} value={payload} />\n <PayloadJsonDetails paper={paper} payload={payload} />\n </FlexCol>\n )\n})\n\nPayloadDetails.displayName = 'PayloadDetails'\n","import { Paper, useMediaQuery, useTheme } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { PropertyGroup, PropertyGroupProps } from '@xyo-network/react-property'\nimport { lazy, Suspense } from 'react'\nimport { ReactJsonViewProps } from 'react-json-view'\n\nconst JsonView = lazy(() => import(/* webpackChunkName: \"jsonView\" */ 'react-json-view'))\n\nexport type PayloadJsonDetailsProps = PropertyGroupProps & {\n jsonViewProps?: ReactJsonViewProps\n payload?: Payload\n}\n\nexport const PayloadJsonDetails: React.FC<PayloadJsonDetailsProps> = ({ jsonViewProps, payload = {}, ...props }) => {\n const { breakpoints, palette } = useTheme()\n const belowSm = useMediaQuery(breakpoints.down('sm'))\n\n let elevation = 2\n if (props.paper) {\n elevation += props.elevation ?? 0\n }\n\n const jsonTheme = palette.mode === 'dark' ? 'shapeshifter' : undefined\n\n return (\n <PropertyGroup titleProps={{ elevation }} title=\"JSON\" tip=\"The raw JSON of the payload\" {...props}>\n <Paper square variant=\"elevation\" style={{ overflow: 'hidden', padding: '16px', width: '100%' }}>\n <Suspense fallback={<FlexGrowRow />}>\n <JsonView\n groupArraysAfterLength={20}\n style={{ backgroundColor: undefined, overflow: 'hidden' }}\n src={payload}\n enableClipboard\n theme={jsonTheme}\n collapseStringsAfterLength={belowSm ? 24 : 32}\n {...jsonViewProps}\n />\n </Suspense>\n </Paper>\n </PropertyGroup>\n )\n}\n","import { Typography } from '@mui/material'\nimport { FlexCol } from '@xylabs/react-flexbox'\nimport { usePromise } from '@xylabs/react-promise'\nimport { PayloadValidator } from '@xyo-network/payload-validator'\nimport { Property, PropertyGroup } from '@xyo-network/react-property'\nimport { SchemaProperty } from '@xyo-network/react-schema'\n\nimport { PayloadValidationDetailsProps } from './ValidationDetailsProps'\n\nexport const PayloadValidationDetails: React.FC<PayloadValidationDetailsProps> = ({ skipBody = false, value, ...props }) => {\n const [validateErrors] = usePromise(async () => (value ? await new PayloadValidator(value).validate() : undefined), [value])\n\n const bodyErrors = skipBody ? [] : validateErrors ?? []\n const errors: Error[] = [...bodyErrors]\n\n let elevation = 2\n if (props.paper) {\n elevation += props.elevation ?? 0\n }\n\n return (\n <PropertyGroup titleProps={{ elevation }} title=\"Validation\" tip=\"The results from validating the payload\" {...props}>\n <Property\n titleProps={{ elevation }}\n flexGrow={1}\n title=\"Valid\"\n value={errors.length === 0 ? 'True' : 'False'}\n tip={\n errors.length > 0 ? (\n <FlexCol>\n {errors.map((error, index) => {\n return <Typography key={index}>{error.toString()}</Typography>\n })}\n </FlexCol>\n ) : (\n <Typography>No Errors</Typography>\n )\n }\n />\n {value?.schema && <SchemaProperty flexGrow={1} titleProps={{ elevation }} value={value.schema} />}\n </PropertyGroup>\n )\n}\n"],"mappings":";AAAA,SAAS,eAAeA,kBAAiB,cAAc,sBAAsB;AAC7E,SAAS,QAAQ,eAAe,eAAe,mBAAmB;AAClE,SAAS,gBAAgB;AACzB,SAAS,iBAAAC,sBAAqB;AAE9B,SAAS,gBAA+C;AACxD,SAAmB,sBAAsB;AACzC,SAAS,gBAAgB;;;ACPzB,SAAS,eAAe,uBAAuB;AAC/C,SAAS,YAAY,YAAY,gBAAgB;AACjD,SAAuB,SAAS,aAAa,eAAe;AAC5D,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAetB,SACE,KADF;AAPD,IAAM,2BAAoE,CAAC,EAAE,UAAU,OAAO,SAAS,GAAG,MAAM,MAAM;AAC3H,QAAM,QAAQ,SAAS;AACvB,QAAM,gBAAgB,UAAU,KAAK,UAAU,cAAc,WAAW,OAAO,GAAG,MAAM,CAAC,IAAI;AAE7F,SACE,qBAAC,WAAQ,YAAW,WAAW,GAAG,OAC/B;AAAA,cAAU,OACT,qBAAC,WAAQ,QAAQ,GAAG,gBAAe,cACjC;AAAA,0BAAC,cAAW,yBAAW;AAAA,MACvB,oBAAC,kBAAe,OAAM,eAAc,kEAAoD;AAAA,OAC1F;AAAA,IAEF,qBAAC,WACC;AAAA,0BAAC,eAAY,YAAU,MAAC,QAAQ,GAAG,aAAa,M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AA,QACnD,CAAC,GACH,IAEA,gBAAAI,KAACJ,aAAA,EAAW,uBAAS;AAAA;AAAA,IAG3B;AAAA,IACC,OAAO,UAAU,gBAAAI,KAAC,kBAAe,UAAU,GAAG,YAAY,EAAE,UAAU,GAAG,OAAO,MAAM,QAAQ;AAAA,KACjG;AAEJ;;;AFxBI,SACE,OAAAE,MADF,QAAAC,aAAA;AAFG,IAAM,iBAAiB,WAAgD,CAAC,EAAE,OAAO,SAAS,GAAG,MAAM,GAAG,QAAQ;AACnH,SACE,gBAAAA,MAACC,UAAA,EAAQ,KAAK,GAAG,gBAAe,cAAa,YAAW,WAAU,WAAW,GAAG,cAAc,GAAG,KAAW,GAAG,OAC7G;AAAA,oBAAAF,KAAC,sBAAmB,OAAc,MAAK,SAAQ,OAAK,MAAC,SAAkB;AAAA,IACvE,gBAAAA,KAAC,4BAAyB,OAAc,OAAO,SAAS;AAAA,IACxD,gBAAAA,KAAC,sBAAmB,OAAc,SAAkB;AAAA,KACtD;AAEJ,CAAC;AAED,eAAe,cAAc;","names":["ContentCopyIcon","PayloadHasher","jsx","jsxs","PayloadHasher","ContentCopyIcon","FlexCol","useTheme","FlexGrowRow","jsx","Typography","FlexCol","Property","PropertyGroup","jsx","jsxs","jsx","jsxs","FlexCol"]}
@@ -1,201 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/components/index.ts
31
- var components_exports = {};
32
- __export(components_exports, {
33
- PayloadDataDetails: () => PayloadDataDetails,
34
- PayloadDetails: () => PayloadDetails,
35
- PayloadJsonDetails: () => PayloadJsonDetails,
36
- PayloadValidationDetails: () => PayloadValidationDetails
37
- });
38
- module.exports = __toCommonJS(components_exports);
39
-
40
- // src/components/Details/DataDetails.tsx
41
- var import_icons_material2 = require("@mui/icons-material");
42
- var import_material2 = require("@mui/material");
43
- var import_react_button = require("@xylabs/react-button");
44
- var import_hash2 = require("@xyo-network/hash");
45
- var import_react_property = require("@xyo-network/react-property");
46
- var import_react_shared = require("@xyo-network/react-shared");
47
- var import_react = require("react");
48
-
49
- // src/components/Details/HashSourceDetails.tsx
50
- var import_icons_material = require("@mui/icons-material");
51
- var import_material = require("@mui/material");
52
- var import_react_flexbox = require("@xylabs/react-flexbox");
53
- var import_react_quick_tip_button = require("@xylabs/react-quick-tip-button");
54
- var import_hash = require("@xyo-network/hash");
55
- var import_jsx_runtime = require("react/jsx-runtime");
56
- var PayloadHashSourceDetails = ({ noTitle = false, payload, ...props }) => {
57
- const theme = (0, import_material.useTheme)();
58
- const payloadString = payload ? JSON.stringify(import_hash.PayloadHasher.hashFields(payload), null, 2) : "";
59
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_flexbox.FlexCol, { alignItems: "stretch", ...props, children: [
60
- noTitle ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_flexbox.FlexRow, { margin: 1, justifyContent: "flex-start", children: [
61
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { children: "Hash Source" }),
62
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_quick_tip_button.QuickTipButton, { title: "Hash Source", children: "The actual string used to generate the hash (SHA256)" })
63
- ] }),
64
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_flexbox.FlexRow, { children: [
65
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_flexbox.FlexGrowRow, { background: true, border: 1, borderColor: theme.palette.divider, justifyContent: "start", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { padding: 2, fontFamily: "monospace", variant: "body1", sx: { overflowWrap: "break-word", wordBreak: "break-all" }, children: payloadString }) }),
66
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.IconButton, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.ContentCopy, {}) })
67
- ] }),
68
- noTitle ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_flexbox.FlexRow, { margin: 1, justifyContent: "flex-start", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { variant: "body2", children: "The actual string used to generate the hash (SHA256). This can be used to validate the hash manually." }) }) : null
69
- ] });
70
- };
71
-
72
- // src/components/Details/DataDetails.tsx
73
- var import_jsx_runtime2 = require("react/jsx-runtime");
74
- var PayloadDataDetails = ({ size, badge, payload, ...props }) => {
75
- const payloadString = payload ? JSON.stringify(import_hash2.PayloadHasher.hashFields(payload), null, 2) : "";
76
- const [viewSourceOpen, setViewSourceOpen] = (0, import_react.useState)(false);
77
- const hash = (0, import_react_shared.usePayloadHash)(payload);
78
- let elevation = 2;
79
- if (props.paper) {
80
- elevation += props.elevation ?? 0;
81
- }
82
- const actions = [
83
- {
84
- icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material2.Visibility, {}),
85
- name: "View",
86
- onClick: () => setViewSourceOpen(true)
87
- },
88
- {
89
- icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material2.ContentCopy, {}),
90
- name: "Copy",
91
- onClick: async () => await navigator.clipboard.writeText(hash ?? "")
92
- }
93
- ];
94
- const onCopy = async () => {
95
- await navigator.clipboard.writeText(payloadString);
96
- };
97
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
98
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
99
- import_react_property.Property,
100
- {
101
- titleProps: { elevation },
102
- badge,
103
- size,
104
- actions,
105
- title: "Payload Hash",
106
- value: hash ?? "<Unknown>",
107
- tip: "This is the payload hash",
108
- ...props
109
- }
110
- ),
111
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material2.Dialog, { open: viewSourceOpen, onClose: () => setViewSourceOpen(false), children: [
112
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material2.DialogTitle, { children: "Hash Source" }),
113
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material2.DialogContent, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PayloadHashSourceDetails, { noTitle: true, payload }) }),
114
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material2.DialogActions, { children: [
115
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_button.ButtonEx, { color: "secondary", onClick: onCopy, children: "Copy" }),
116
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_button.ButtonEx, { color: "secondary", onClick: () => setViewSourceOpen(false), children: "Close" })
117
- ] })
118
- ] })
119
- ] });
120
- };
121
-
122
- // src/components/Details/Details.tsx
123
- var import_react_flexbox4 = require("@xylabs/react-flexbox");
124
- var import_react3 = require("react");
125
-
126
- // src/components/Details/JsonDetails.tsx
127
- var import_material3 = require("@mui/material");
128
- var import_react_flexbox2 = require("@xylabs/react-flexbox");
129
- var import_react_property2 = require("@xyo-network/react-property");
130
- var import_react2 = require("react");
131
- var import_jsx_runtime3 = require("react/jsx-runtime");
132
- var JsonView = (0, import_react2.lazy)(() => import(
133
- /* webpackChunkName: "jsonView" */
134
- "react-json-view"
135
- ));
136
- var PayloadJsonDetails = ({ jsonViewProps, payload = {}, ...props }) => {
137
- const { breakpoints, palette } = (0, import_material3.useTheme)();
138
- const belowSm = (0, import_material3.useMediaQuery)(breakpoints.down("sm"));
139
- let elevation = 2;
140
- if (props.paper) {
141
- elevation += props.elevation ?? 0;
142
- }
143
- const jsonTheme = palette.mode === "dark" ? "shapeshifter" : void 0;
144
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_property2.PropertyGroup, { titleProps: { elevation }, title: "JSON", tip: "The raw JSON of the payload", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Paper, { square: true, variant: "elevation", style: { overflow: "hidden", padding: "16px", width: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react2.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_flexbox2.FlexGrowRow, {}), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
145
- JsonView,
146
- {
147
- groupArraysAfterLength: 20,
148
- style: { backgroundColor: void 0, overflow: "hidden" },
149
- src: payload,
150
- enableClipboard: true,
151
- theme: jsonTheme,
152
- collapseStringsAfterLength: belowSm ? 24 : 32,
153
- ...jsonViewProps
154
- }
155
- ) }) }) });
156
- };
157
-
158
- // src/components/Details/ValidationDetails/ValidationDetails.tsx
159
- var import_material4 = require("@mui/material");
160
- var import_react_flexbox3 = require("@xylabs/react-flexbox");
161
- var import_react_promise = require("@xylabs/react-promise");
162
- var import_payload_validator = require("@xyo-network/payload-validator");
163
- var import_react_property3 = require("@xyo-network/react-property");
164
- var import_react_schema = require("@xyo-network/react-schema");
165
- var import_jsx_runtime4 = require("react/jsx-runtime");
166
- var PayloadValidationDetails = ({ skipBody = false, value, ...props }) => {
167
- const [validateErrors] = (0, import_react_promise.usePromise)(async () => value ? await new import_payload_validator.PayloadValidator(value).validate() : void 0, [value]);
168
- const bodyErrors = skipBody ? [] : validateErrors ?? [];
169
- const errors = [...bodyErrors];
170
- let elevation = 2;
171
- if (props.paper) {
172
- elevation += props.elevation ?? 0;
173
- }
174
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_property3.PropertyGroup, { titleProps: { elevation }, title: "Validation", tip: "The results from validating the payload", ...props, children: [
175
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
176
- import_react_property3.Property,
177
- {
178
- titleProps: { elevation },
179
- flexGrow: 1,
180
- title: "Valid",
181
- value: errors.length === 0 ? "True" : "False",
182
- tip: errors.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_flexbox3.FlexCol, { children: errors.map((error, index) => {
183
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material4.Typography, { children: error.toString() }, index);
184
- }) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material4.Typography, { children: "No Errors" })
185
- }
186
- ),
187
- value?.schema && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_schema.SchemaProperty, { flexGrow: 1, titleProps: { elevation }, value: value.schema })
188
- ] });
189
- };
190
-
191
- // src/components/Details/Details.tsx
192
- var import_jsx_runtime5 = require("react/jsx-runtime");
193
- var PayloadDetails = (0, import_react3.forwardRef)(({ paper, payload, ...props }, ref) => {
194
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react_flexbox4.FlexCol, { gap: 1, justifyContent: "flex-start", alignItems: "stretch", marginTop: 2, marginBottom: 8, ref, ...props, children: [
195
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PayloadDataDetails, { paper, size: "large", badge: true, payload }),
196
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PayloadValidationDetails, { paper, value: payload }),
197
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PayloadJsonDetails, { paper, payload })
198
- ] });
199
- });
200
- PayloadDetails.displayName = "PayloadDetails";
201
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/index.ts","../../../src/components/Details/DataDetails.tsx","../../../src/components/Details/HashSourceDetails.tsx","../../../src/components/Details/Details.tsx","../../../src/components/Details/JsonDetails.tsx","../../../src/components/Details/ValidationDetails/ValidationDetails.tsx"],"sourcesContent":["export * from './Details'\n","import { ContentCopy as ContentCopyIcon, Visibility as VisibilityIcon } from '@mui/icons-material'\nimport { Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { PayloadHasher } from '@xyo-network/hash'\nimport { Payload } from '@xyo-network/payload-model'\nimport { Property, PropertyAction, PropertyProps } from '@xyo-network/react-property'\nimport { SizeProp, usePayloadHash } from '@xyo-network/react-shared'\nimport { useState } from 'react'\n\nimport { PayloadHashSourceDetails } from './HashSourceDetails'\n\nexport type PayloadDataDetailsProps = PropertyProps & {\n badge?: boolean\n payload?: Payload\n size?: SizeProp\n}\n\nexport const PayloadDataDetails: React.FC<PayloadDataDetailsProps> = ({ size, badge, payload, ...props }) => {\n const payloadString = payload ? JSON.stringify(PayloadHasher.hashFields(payload), null, 2) : ''\n\n const [viewSourceOpen, setViewSourceOpen] = useState(false)\n const hash = usePayloadHash(payload)\n\n let elevation = 2\n if (props.paper) {\n elevation += props.elevation ?? 0\n }\n\n const actions: PropertyAction[] = [\n {\n icon: <VisibilityIcon />,\n name: 'View',\n onClick: () => setViewSourceOpen(true),\n },\n {\n icon: <ContentCopyIcon />,\n name: 'Copy',\n onClick: async () => await navigator.clipboard.writeText(hash ?? ''),\n },\n ]\n\n const onCopy = async () => {\n await navigator.clipboard.writeText(payloadString)\n }\n\n return (\n <>\n <Property\n titleProps={{ elevation }}\n badge={badge}\n size={size}\n actions={actions}\n title=\"Payload Hash\"\n value={hash ?? '<Unknown>'}\n tip=\"This is the payload hash\"\n {...props}\n />\n <Dialog open={viewSourceOpen} onClose={() => setViewSourceOpen(false)}>\n <DialogTitle>Hash Source</DialogTitle>\n <DialogContent>\n <PayloadHashSourceDetails noTitle payload={payload} />\n </DialogContent>\n <DialogActions>\n <ButtonEx color=\"secondary\" onClick={onCopy}>\n Copy\n </ButtonEx>\n <ButtonEx color=\"secondary\" onClick={() => setViewSourceOpen(false)}>\n Close\n </ButtonEx>\n </DialogActions>\n </Dialog>\n </>\n )\n}\n","import { ContentCopy as ContentCopyIcon } from '@mui/icons-material'\nimport { IconButton, Typography, useTheme } from '@mui/material'\nimport { FlexBoxProps, FlexCol, FlexGrowRow, FlexRow } from '@xylabs/react-flexbox'\nimport { QuickTipButton } from '@xylabs/react-quick-tip-button'\nimport { PayloadHasher } from '@xyo-network/hash'\nimport { Payload } from '@xyo-network/payload-model'\n\nexport interface PayloadHashSourceDetailsProps extends FlexBoxProps {\n noTitle?: boolean\n payload?: Payload\n}\n\nexport const PayloadHashSourceDetails: React.FC<PayloadHashSourceDetailsProps> = ({ noTitle = false, payload, ...props }) => {\n const theme = useTheme()\n const payloadString = payload ? JSON.stringify(PayloadHasher.hashFields(payload), null, 2) : ''\n\n return (\n <FlexCol alignItems=\"stretch\" {...props}>\n {noTitle ? null : (\n <FlexRow margin={1} justifyContent=\"flex-start\">\n <Typography>Hash Source</Typography>\n <QuickTipButton title=\"Hash Source\">The actual string used to generate the hash (SHA256)</QuickTipButton>\n </FlexRow>\n )}\n <FlexRow>\n <FlexGrowRow background border={1} borderColor={theme.palette.divider} justifyContent=\"start\">\n <Typography padding={2} fontFamily=\"monospace\" variant=\"body1\" sx={{ overflowWrap: 'break-word', wordBreak: 'break-all' }}>\n {payloadString}\n </Typography>\n </FlexGrowRow>\n <IconButton>\n <ContentCopyIcon />\n </IconButton>\n </FlexRow>\n {noTitle ? (\n <FlexRow margin={1} justifyContent=\"flex-start\">\n <Typography variant=\"body2\">\n The actual string used to generate the hash (SHA256). This can be used to validate the hash manually.\n </Typography>\n </FlexRow>\n ) : null}\n </FlexCol>\n )\n}\n","import { FlexBoxProps, FlexCol } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { forwardRef } from 'react'\n\nimport { PayloadDataDetails } from './DataDetails'\nimport { PayloadJsonDetails } from './JsonDetails'\nimport { PayloadValidationDetails } from './ValidationDetails'\n\nexport type WithPaper<T> = T & { paper: true }\nexport type WithoutPaper<T> = T & { paper?: false }\n\nexport type PayloadDetailsProps = FlexBoxProps & {\n paper?: boolean\n payload?: Payload\n}\n\nexport const PayloadDetails = forwardRef<HTMLDivElement, PayloadDetailsProps>(({ paper, payload, ...props }, ref) => {\n return (\n <FlexCol gap={1} justifyContent=\"flex-start\" alignItems=\"stretch\" marginTop={2} marginBottom={8} ref={ref} {...props}>\n <PayloadDataDetails paper={paper} size=\"large\" badge payload={payload} />\n <PayloadValidationDetails paper={paper} value={payload} />\n <PayloadJsonDetails paper={paper} payload={payload} />\n </FlexCol>\n )\n})\n\nPayloadDetails.displayName = 'PayloadDetails'\n","import { Paper, useMediaQuery, useTheme } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { PropertyGroup, PropertyGroupProps } from '@xyo-network/react-property'\nimport { lazy, Suspense } from 'react'\nimport { ReactJsonViewProps } from 'react-json-view'\n\nconst JsonView = lazy(() => import(/* webpackChunkName: \"jsonView\" */ 'react-json-view'))\n\nexport type PayloadJsonDetailsProps = PropertyGroupProps & {\n jsonViewProps?: ReactJsonViewProps\n payload?: Payload\n}\n\nexport const PayloadJsonDetails: React.FC<PayloadJsonDetailsProps> = ({ jsonViewProps, payload = {}, ...props }) => {\n const { breakpoints, palette } = useTheme()\n const belowSm = useMediaQuery(breakpoints.down('sm'))\n\n let elevation = 2\n if (props.paper) {\n elevation += props.elevation ?? 0\n }\n\n const jsonTheme = palette.mode === 'dark' ? 'shapeshifter' : undefined\n\n return (\n <PropertyGroup titleProps={{ elevation }} title=\"JSON\" tip=\"The raw JSON of the payload\" {...props}>\n <Paper square variant=\"elevation\" style={{ overflow: 'hidden', padding: '16px', width: '100%' }}>\n <Suspense fallback={<FlexGrowRow />}>\n <JsonView\n groupArraysAfterLength={20}\n style={{ backgroundColor: undefined, overflow: 'hidden' }}\n src={payload}\n enableClipboard\n theme={jsonTheme}\n collapseStringsAfterLength={belowSm ? 24 : 32}\n {...jsonViewProps}\n />\n </Suspense>\n </Paper>\n </PropertyGroup>\n )\n}\n","import { Typography } from '@mui/material'\nimport { FlexCol } from '@xylabs/react-flexbox'\nimport { usePromise } from '@xylabs/react-promise'\nimport { PayloadValidator } from '@xyo-network/payload-validator'\nimport { Property, PropertyGroup } from '@xyo-network/react-property'\nimport { SchemaProperty } from '@xyo-network/react-schema'\n\nimport { PayloadValidationDetailsProps } from './ValidationDetailsProps'\n\nexport const PayloadValidationDetails: React.FC<PayloadValidationDetailsProps> = ({ skipBody = false, value, ...props }) => {\n const [validateErrors] = usePromise(async () => (value ? await new PayloadValidator(value).validate() : undefined), [value])\n\n const bodyErrors = skipBody ? [] : validateErrors ?? []\n const errors: Error[] = [...bodyErrors]\n\n let elevation = 2\n if (props.paper) {\n elevation += props.elevation ?? 0\n }\n\n return (\n <PropertyGroup titleProps={{ elevation }} title=\"Validation\" tip=\"The results from validating the payload\" {...props}>\n <Property\n titleProps={{ elevation }}\n flexGrow={1}\n title=\"Valid\"\n value={errors.length === 0 ? 'True' : 'False'}\n tip={\n errors.length > 0 ? (\n <FlexCol>\n {errors.map((error, index) => {\n return <Typography key={index}>{error.toString()}</Typography>\n })}\n </FlexCol>\n ) : (\n <Typography>No Errors</Typography>\n )\n }\n />\n {value?.schema && <SchemaProperty flexGrow={1} titleProps={{ elevation }} value={value.schema} />}\n </PropertyGroup>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAA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;AAEtC,MAAI,YAAY;AAChB,MAAI,MAAM,OAAO;AACf,iBAAa,MAAM,aAAa;AAAA,EAClC;AAEA,SACE,8CAAC,wCAAc,YAAY,EAAE,UAAU,GAAG,OAAM,cAAa,KAAI,2CAA2C,GAAG,OAC7G;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,YAAY,EAAE,UAAU;AAAA,QACxB,UAAU;AAAA,QACV,OAAM;AAAA,QACN,OAAO,OAAO,WAAW,IAAI,SAAS;AAAA,QACtC,KACE,OAAO,SAAS,IACd,6CAAC,iCACE,iBAAO,IAAI,CAAC,OAAO,UAAU;AAC5B,iBAAO,6CAAC,+BAAwB,gBAAM,SAAS,KAAvB,KAAyB;AAAA,QACnD,CAAC,GACH,IAEA,6CAAC,+BAAW,uBAAS;AAAA;AAAA,IAG3B;AAAA,IACC,OAAO,UAAU,6CAAC,sCAAe,UAAU,GAAG,YAAY,EAAE,UAAU,GAAG,OAAO,MAAM,QAAQ;AAAA,KACjG;AAEJ;;;AFxBI,IAAAC,sBAAA;AAFG,IAAM,qBAAiB,0BAAgD,CAAC,EAAE,OAAO,SAAS,GAAG,MAAM,GAAG,QAAQ;AACnH,SACE,8CAAC,iCAAQ,KAAK,GAAG,gBAAe,cAAa,YAAW,WAAU,WAAW,GAAG,cAAc,GAAG,KAAW,GAAG,OAC7G;AAAA,iDAAC,sBAAmB,OAAc,MAAK,SAAQ,OAAK,MAAC,SAAkB;AAAA,IACvE,6CAAC,4BAAyB,OAAc,OAAO,SAAS;AAAA,IACxD,6CAAC,sBAAmB,OAAc,SAAkB;AAAA,KACtD;AAEJ,CAAC;AAED,eAAe,cAAc;","names":["import_icons_material","import_material","import_hash","ContentCopyIcon","import_jsx_runtime","VisibilityIcon","ContentCopyIcon","import_react_flexbox","import_react","import_material","import_react_flexbox","import_react_property","import_react","import_jsx_runtime","import_material","import_react_flexbox","import_react_property","import_jsx_runtime","import_jsx_runtime"]}
@@ -1,168 +0,0 @@
1
- // src/components/Details/DataDetails.tsx
2
- import { ContentCopy as ContentCopyIcon2, Visibility as VisibilityIcon } from "@mui/icons-material";
3
- import { Dialog, DialogActions, DialogContent, DialogTitle } from "@mui/material";
4
- import { ButtonEx } from "@xylabs/react-button";
5
- import { PayloadHasher as PayloadHasher2 } from "@xyo-network/hash";
6
- import { Property } from "@xyo-network/react-property";
7
- import { usePayloadHash } from "@xyo-network/react-shared";
8
- import { useState } from "react";
9
-
10
- // src/components/Details/HashSourceDetails.tsx
11
- import { ContentCopy as ContentCopyIcon } from "@mui/icons-material";
12
- import { IconButton, Typography, useTheme } from "@mui/material";
13
- import { FlexCol, FlexGrowRow, FlexRow } from "@xylabs/react-flexbox";
14
- import { QuickTipButton } from "@xylabs/react-quick-tip-button";
15
- import { PayloadHasher } from "@xyo-network/hash";
16
- import { jsx, jsxs } from "react/jsx-runtime";
17
- var PayloadHashSourceDetails = ({ noTitle = false, payload, ...props }) => {
18
- const theme = useTheme();
19
- const payloadString = payload ? JSON.stringify(PayloadHasher.hashFields(payload), null, 2) : "";
20
- return /* @__PURE__ */ jsxs(FlexCol, { alignItems: "stretch", ...props, children: [
21
- noTitle ? null : /* @__PURE__ */ jsxs(FlexRow, { margin: 1, justifyContent: "flex-start", children: [
22
- /* @__PURE__ */ jsx(Typography, { children: "Hash Source" }),
23
- /* @__PURE__ */ jsx(QuickTipButton, { title: "Hash Source", children: "The actual string used to generate the hash (SHA256)" })
24
- ] }),
25
- /* @__PURE__ */ jsxs(FlexRow, { children: [
26
- /* @__PURE__ */ jsx(FlexGrowRow, { background: true, border: 1, borderColor: theme.palette.divider, justifyContent: "start", children: /* @__PURE__ */ jsx(Typography, { padding: 2, fontFamily: "monospace", variant: "body1", sx: { overflowWrap: "break-word", wordBreak: "break-all" }, children: payloadString }) }),
27
- /* @__PURE__ */ jsx(IconButton, { children: /* @__PURE__ */ jsx(ContentCopyIcon, {}) })
28
- ] }),
29
- noTitle ? /* @__PURE__ */ jsx(FlexRow, { margin: 1, justifyContent: "flex-start", children: /* @__PURE__ */ jsx(Typography, { variant: "body2", children: "The actual string used to generate the hash (SHA256). This can be used to validate the hash manually." }) }) : null
30
- ] });
31
- };
32
-
33
- // src/components/Details/DataDetails.tsx
34
- import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
35
- var PayloadDataDetails = ({ size, badge, payload, ...props }) => {
36
- const payloadString = payload ? JSON.stringify(PayloadHasher2.hashFields(payload), null, 2) : "";
37
- const [viewSourceOpen, setViewSourceOpen] = useState(false);
38
- const hash = usePayloadHash(payload);
39
- let elevation = 2;
40
- if (props.paper) {
41
- elevation += props.elevation ?? 0;
42
- }
43
- const actions = [
44
- {
45
- icon: /* @__PURE__ */ jsx2(VisibilityIcon, {}),
46
- name: "View",
47
- onClick: () => setViewSourceOpen(true)
48
- },
49
- {
50
- icon: /* @__PURE__ */ jsx2(ContentCopyIcon2, {}),
51
- name: "Copy",
52
- onClick: async () => await navigator.clipboard.writeText(hash ?? "")
53
- }
54
- ];
55
- const onCopy = async () => {
56
- await navigator.clipboard.writeText(payloadString);
57
- };
58
- return /* @__PURE__ */ jsxs2(Fragment, { children: [
59
- /* @__PURE__ */ jsx2(
60
- Property,
61
- {
62
- titleProps: { elevation },
63
- badge,
64
- size,
65
- actions,
66
- title: "Payload Hash",
67
- value: hash ?? "<Unknown>",
68
- tip: "This is the payload hash",
69
- ...props
70
- }
71
- ),
72
- /* @__PURE__ */ jsxs2(Dialog, { open: viewSourceOpen, onClose: () => setViewSourceOpen(false), children: [
73
- /* @__PURE__ */ jsx2(DialogTitle, { children: "Hash Source" }),
74
- /* @__PURE__ */ jsx2(DialogContent, { children: /* @__PURE__ */ jsx2(PayloadHashSourceDetails, { noTitle: true, payload }) }),
75
- /* @__PURE__ */ jsxs2(DialogActions, { children: [
76
- /* @__PURE__ */ jsx2(ButtonEx, { color: "secondary", onClick: onCopy, children: "Copy" }),
77
- /* @__PURE__ */ jsx2(ButtonEx, { color: "secondary", onClick: () => setViewSourceOpen(false), children: "Close" })
78
- ] })
79
- ] })
80
- ] });
81
- };
82
-
83
- // src/components/Details/Details.tsx
84
- import { FlexCol as FlexCol3 } from "@xylabs/react-flexbox";
85
- import { forwardRef } from "react";
86
-
87
- // src/components/Details/JsonDetails.tsx
88
- import { Paper, useMediaQuery, useTheme as useTheme2 } from "@mui/material";
89
- import { FlexGrowRow as FlexGrowRow2 } from "@xylabs/react-flexbox";
90
- import { PropertyGroup } from "@xyo-network/react-property";
91
- import { lazy, Suspense } from "react";
92
- import { jsx as jsx3 } from "react/jsx-runtime";
93
- var JsonView = lazy(() => import(
94
- /* webpackChunkName: "jsonView" */
95
- "react-json-view"
96
- ));
97
- var PayloadJsonDetails = ({ jsonViewProps, payload = {}, ...props }) => {
98
- const { breakpoints, palette } = useTheme2();
99
- const belowSm = useMediaQuery(breakpoints.down("sm"));
100
- let elevation = 2;
101
- if (props.paper) {
102
- elevation += props.elevation ?? 0;
103
- }
104
- const jsonTheme = palette.mode === "dark" ? "shapeshifter" : void 0;
105
- return /* @__PURE__ */ jsx3(PropertyGroup, { titleProps: { elevation }, title: "JSON", tip: "The raw JSON of the payload", ...props, children: /* @__PURE__ */ jsx3(Paper, { square: true, variant: "elevation", style: { overflow: "hidden", padding: "16px", width: "100%" }, children: /* @__PURE__ */ jsx3(Suspense, { fallback: /* @__PURE__ */ jsx3(FlexGrowRow2, {}), children: /* @__PURE__ */ jsx3(
106
- JsonView,
107
- {
108
- groupArraysAfterLength: 20,
109
- style: { backgroundColor: void 0, overflow: "hidden" },
110
- src: payload,
111
- enableClipboard: true,
112
- theme: jsonTheme,
113
- collapseStringsAfterLength: belowSm ? 24 : 32,
114
- ...jsonViewProps
115
- }
116
- ) }) }) });
117
- };
118
-
119
- // src/components/Details/ValidationDetails/ValidationDetails.tsx
120
- import { Typography as Typography2 } from "@mui/material";
121
- import { FlexCol as FlexCol2 } from "@xylabs/react-flexbox";
122
- import { usePromise } from "@xylabs/react-promise";
123
- import { PayloadValidator } from "@xyo-network/payload-validator";
124
- import { Property as Property2, PropertyGroup as PropertyGroup2 } from "@xyo-network/react-property";
125
- import { SchemaProperty } from "@xyo-network/react-schema";
126
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
127
- var PayloadValidationDetails = ({ skipBody = false, value, ...props }) => {
128
- const [validateErrors] = usePromise(async () => value ? await new PayloadValidator(value).validate() : void 0, [value]);
129
- const bodyErrors = skipBody ? [] : validateErrors ?? [];
130
- const errors = [...bodyErrors];
131
- let elevation = 2;
132
- if (props.paper) {
133
- elevation += props.elevation ?? 0;
134
- }
135
- return /* @__PURE__ */ jsxs3(PropertyGroup2, { titleProps: { elevation }, title: "Validation", tip: "The results from validating the payload", ...props, children: [
136
- /* @__PURE__ */ jsx4(
137
- Property2,
138
- {
139
- titleProps: { elevation },
140
- flexGrow: 1,
141
- title: "Valid",
142
- value: errors.length === 0 ? "True" : "False",
143
- tip: errors.length > 0 ? /* @__PURE__ */ jsx4(FlexCol2, { children: errors.map((error, index) => {
144
- return /* @__PURE__ */ jsx4(Typography2, { children: error.toString() }, index);
145
- }) }) : /* @__PURE__ */ jsx4(Typography2, { children: "No Errors" })
146
- }
147
- ),
148
- value?.schema && /* @__PURE__ */ jsx4(SchemaProperty, { flexGrow: 1, titleProps: { elevation }, value: value.schema })
149
- ] });
150
- };
151
-
152
- // src/components/Details/Details.tsx
153
- import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
154
- var PayloadDetails = forwardRef(({ paper, payload, ...props }, ref) => {
155
- return /* @__PURE__ */ jsxs4(FlexCol3, { gap: 1, justifyContent: "flex-start", alignItems: "stretch", marginTop: 2, marginBottom: 8, ref, ...props, children: [
156
- /* @__PURE__ */ jsx5(PayloadDataDetails, { paper, size: "large", badge: true, payload }),
157
- /* @__PURE__ */ jsx5(PayloadValidationDetails, { paper, value: payload }),
158
- /* @__PURE__ */ jsx5(PayloadJsonDetails, { paper, payload })
159
- ] });
160
- });
161
- PayloadDetails.displayName = "PayloadDetails";
162
- export {
163
- PayloadDataDetails,
164
- PayloadDetails,
165
- PayloadJsonDetails,
166
- PayloadValidationDetails
167
- };
168
- //# sourceMappingURL=index.js.map