@xyo-network/react-embed 7.4.2 → 7.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/components/stories/XyoEmbedPlugin.examples.stories.d.ts +2 -2
- package/dist/browser/components/stories/XyoEmbedPlugin.examples.stories.d.ts.map +1 -1
- package/dist/browser/components/stories/XyoEmbedPlugin.states.stories.d.ts +7 -7
- package/dist/browser/components/stories/XyoEmbedPlugin.states.stories.d.ts.map +1 -1
- package/dist/browser/components/stories/storyPayload.d.ts +3 -1
- package/dist/browser/components/stories/storyPayload.d.ts.map +1 -1
- package/dist/browser/contexts/ResolvePayloadContext/Provider.d.ts.map +1 -1
- package/dist/browser/contexts/ValidatePayloadContext/Provider.d.ts.map +1 -1
- package/dist/browser/contexts/ValidatePayloadContext/Provider.stories.d.ts +3 -3
- package/dist/browser/contexts/ValidatePayloadContext/Provider.stories.d.ts.map +1 -1
- package/dist/browser/index.mjs +388 -458
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +32 -31
- package/src/components/embed-card/card/EmbedCardHeader.tsx +1 -1
- package/src/components/embed-card/card/EmbedPluginCard.tsx +1 -1
- package/src/components/embed-card/error-handling/EmbedErrorCard.tsx +1 -1
- package/src/components/embed-card/menu/JsonMenuItem.tsx +1 -1
- package/src/components/stories/storyPayload.ts +3 -1
- package/src/contexts/ResolvePayloadContext/Provider.tsx +1 -2
- package/src/contexts/ValidatePayloadContext/Provider.stories.tsx +3 -2
- package/src/contexts/ValidatePayloadContext/Provider.tsx +2 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -1,36 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
1
4
|
// src/components/embed-card/card/BusyCard.tsx
|
|
2
5
|
import { Card } from "@mui/material";
|
|
3
6
|
import { useBusyTiming } from "@xylabs/react-flexbox";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "@xylabs/react-shared";
|
|
8
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
var BusyCard = ({
|
|
10
|
-
busy,
|
|
11
|
-
busyMinimum = 500,
|
|
12
|
-
busyVariant = "circular",
|
|
13
|
-
busyVariantProps,
|
|
14
|
-
children,
|
|
15
|
-
...props
|
|
16
|
-
}) => {
|
|
7
|
+
import { BusyCircularProgress, BusyLinearProgress } from "@xylabs/react-shared";
|
|
8
|
+
import React from "react";
|
|
9
|
+
var BusyCard = /* @__PURE__ */ __name(({ busy, busyMinimum = 500, busyVariant = "circular", busyVariantProps, children, ...props }) => {
|
|
17
10
|
const internalBusy = useBusyTiming(busy, busyMinimum);
|
|
18
|
-
return /* @__PURE__ */
|
|
19
|
-
|
|
20
|
-
busyVariant === "circular" && internalBusy ? /* @__PURE__ */ jsx(BusyCircularProgress, { ...busyVariantProps }) : null,
|
|
21
|
-
busyVariant === "linear" && internalBusy ? /* @__PURE__ */ jsx(BusyLinearProgress, { ...busyVariantProps }) : null
|
|
22
|
-
] });
|
|
23
|
-
};
|
|
11
|
+
return /* @__PURE__ */ React.createElement(Card, props, children, busyVariant === "circular" && internalBusy ? /* @__PURE__ */ React.createElement(BusyCircularProgress, busyVariantProps) : null, busyVariant === "linear" && internalBusy ? /* @__PURE__ */ React.createElement(BusyLinearProgress, busyVariantProps) : null);
|
|
12
|
+
}, "BusyCard");
|
|
24
13
|
|
|
25
14
|
// src/components/embed-card/card/EmbedCardHeader.tsx
|
|
26
15
|
import { Refresh as RefreshIcon } from "@mui/icons-material";
|
|
27
|
-
import {
|
|
28
|
-
Avatar,
|
|
29
|
-
CardHeader,
|
|
30
|
-
Chip as Chip2
|
|
31
|
-
} from "@mui/material";
|
|
16
|
+
import { Avatar, CardHeader, Chip as Chip2 } from "@mui/material";
|
|
32
17
|
import { FlexRow } from "@xylabs/react-flexbox";
|
|
33
|
-
import { isDefined as isDefined3 } from "@xylabs/
|
|
18
|
+
import { isDefined as isDefined3 } from "@xylabs/sdk-js";
|
|
19
|
+
import React9 from "react";
|
|
34
20
|
|
|
35
21
|
// src/contexts/EmbedPluginContext/Context.ts
|
|
36
22
|
import { createContextEx } from "@xylabs/react-shared";
|
|
@@ -38,611 +24,555 @@ var EmbedPluginContext = createContextEx();
|
|
|
38
24
|
|
|
39
25
|
// src/contexts/EmbedPluginContext/Provider.tsx
|
|
40
26
|
import { useResetState } from "@xylabs/react-hooks";
|
|
41
|
-
import
|
|
42
|
-
var EmbedPluginProvider = ({
|
|
43
|
-
children,
|
|
44
|
-
refreshTitle,
|
|
45
|
-
timestampLabel,
|
|
46
|
-
hideElementsConfig,
|
|
47
|
-
plugins,
|
|
48
|
-
embedPluginConfig
|
|
49
|
-
}) => {
|
|
27
|
+
import React2 from "react";
|
|
28
|
+
var EmbedPluginProvider = /* @__PURE__ */ __name(({ children, refreshTitle, timestampLabel, hideElementsConfig, plugins, embedPluginConfig }) => {
|
|
50
29
|
const [activePlugin, setActivePlugin] = useResetState(plugins ? plugins[0] : void 0);
|
|
51
|
-
return /* @__PURE__ */
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
setActivePlugin,
|
|
61
|
-
timestampLabel
|
|
62
|
-
},
|
|
63
|
-
children
|
|
30
|
+
return /* @__PURE__ */ React2.createElement(EmbedPluginContext, {
|
|
31
|
+
value: {
|
|
32
|
+
activePlugin,
|
|
33
|
+
embedPluginConfig,
|
|
34
|
+
hideElementsConfig,
|
|
35
|
+
provided: true,
|
|
36
|
+
refreshTitle,
|
|
37
|
+
setActivePlugin,
|
|
38
|
+
timestampLabel
|
|
64
39
|
}
|
|
65
|
-
);
|
|
66
|
-
};
|
|
40
|
+
}, children);
|
|
41
|
+
}, "EmbedPluginProvider");
|
|
67
42
|
|
|
68
43
|
// src/contexts/EmbedPluginContext/use.ts
|
|
69
44
|
import { useContextEx } from "@xylabs/react-shared";
|
|
70
|
-
var useEmbedPluginState = () => useContextEx(EmbedPluginContext, "EmbedPlugin", true);
|
|
45
|
+
var useEmbedPluginState = /* @__PURE__ */ __name(() => useContextEx(EmbedPluginContext, "EmbedPlugin", true), "useEmbedPluginState");
|
|
71
46
|
|
|
72
47
|
// src/contexts/PluginPropsContext/context.ts
|
|
73
48
|
import { createContextEx as createContextEx2 } from "@xylabs/react-shared";
|
|
74
49
|
var PluginPropsContext = createContextEx2();
|
|
75
50
|
|
|
76
51
|
// src/contexts/PluginPropsContext/Provider.tsx
|
|
77
|
-
import {
|
|
78
|
-
|
|
79
|
-
useMemo,
|
|
80
|
-
useState
|
|
81
|
-
} from "react";
|
|
82
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
83
|
-
var PluginPropsProvider = ({ children, pluginProps: pluginPropsProp }) => {
|
|
52
|
+
import React3, { useEffect, useMemo, useState } from "react";
|
|
53
|
+
var PluginPropsProvider = /* @__PURE__ */ __name(({ children, pluginProps: pluginPropsProp }) => {
|
|
84
54
|
const [pluginProps, setPluginProps] = useState(pluginPropsProp);
|
|
85
55
|
useEffect(() => {
|
|
86
56
|
setPluginProps(pluginPropsProp);
|
|
87
|
-
}, [
|
|
57
|
+
}, [
|
|
58
|
+
pluginPropsProp
|
|
59
|
+
]);
|
|
88
60
|
const value = useMemo(() => ({
|
|
89
61
|
pluginProps,
|
|
90
62
|
provided: true
|
|
91
|
-
}), [
|
|
92
|
-
|
|
93
|
-
|
|
63
|
+
}), [
|
|
64
|
+
pluginProps
|
|
65
|
+
]);
|
|
66
|
+
return /* @__PURE__ */ React3.createElement(PluginPropsContext, {
|
|
67
|
+
value
|
|
68
|
+
}, children);
|
|
69
|
+
}, "PluginPropsProvider");
|
|
94
70
|
|
|
95
71
|
// src/contexts/PluginPropsContext/use.ts
|
|
96
72
|
import { useContextEx as useContextEx2 } from "@xylabs/react-shared";
|
|
97
|
-
var usePluginProps = (required = false) => useContextEx2(PluginPropsContext, "PluginProps", required);
|
|
73
|
+
var usePluginProps = /* @__PURE__ */ __name((required = false) => useContextEx2(PluginPropsContext, "PluginProps", required), "usePluginProps");
|
|
98
74
|
|
|
99
75
|
// src/contexts/RefreshPayloadContext/Provider.tsx
|
|
100
|
-
import { useState as useState2 } from "react";
|
|
76
|
+
import React4, { useState as useState2 } from "react";
|
|
101
77
|
|
|
102
78
|
// src/contexts/RefreshPayloadContext/Context.ts
|
|
103
79
|
import { createContextEx as createContextEx3 } from "@xylabs/react-shared";
|
|
104
80
|
var RefreshPayloadContext = createContextEx3();
|
|
105
81
|
|
|
106
82
|
// src/contexts/RefreshPayloadContext/Provider.tsx
|
|
107
|
-
|
|
108
|
-
var RefreshPayloadProvider = ({
|
|
109
|
-
children,
|
|
110
|
-
onRefresh,
|
|
111
|
-
refreshPayload
|
|
112
|
-
}) => {
|
|
83
|
+
var RefreshPayloadProvider = /* @__PURE__ */ __name(({ children, onRefresh, refreshPayload }) => {
|
|
113
84
|
const [localRefreshPayload, setLocalRefreshPayload] = useState2(refreshPayload);
|
|
114
|
-
return /* @__PURE__ */
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
refreshPayload: localRefreshPayload,
|
|
121
|
-
setRefreshPayload: setLocalRefreshPayload
|
|
122
|
-
},
|
|
123
|
-
children
|
|
85
|
+
return /* @__PURE__ */ React4.createElement(RefreshPayloadContext, {
|
|
86
|
+
value: {
|
|
87
|
+
onRefresh,
|
|
88
|
+
provided: true,
|
|
89
|
+
refreshPayload: localRefreshPayload,
|
|
90
|
+
setRefreshPayload: setLocalRefreshPayload
|
|
124
91
|
}
|
|
125
|
-
);
|
|
126
|
-
};
|
|
92
|
+
}, children);
|
|
93
|
+
}, "RefreshPayloadProvider");
|
|
127
94
|
|
|
128
95
|
// src/contexts/RefreshPayloadContext/use.ts
|
|
129
96
|
import { useContextEx as useContextEx3 } from "@xylabs/react-shared";
|
|
130
|
-
var useRefreshPayload = () => useContextEx3(RefreshPayloadContext, "RefreshPayload", true);
|
|
97
|
+
var useRefreshPayload = /* @__PURE__ */ __name(() => useContextEx3(RefreshPayloadContext, "RefreshPayload", true), "useRefreshPayload");
|
|
131
98
|
|
|
132
99
|
// src/contexts/ResolvePayloadContext/Context.ts
|
|
133
100
|
import { createContextEx as createContextEx4 } from "@xylabs/react-shared";
|
|
134
101
|
var ResolvePayloadContext = createContextEx4();
|
|
135
102
|
|
|
136
103
|
// src/contexts/ResolvePayloadContext/Provider.tsx
|
|
137
|
-
import { delay } from "@xylabs/delay";
|
|
138
104
|
import { useAsyncEffect } from "@xylabs/react-async-effect";
|
|
139
|
-
import { isDefined } from "@xylabs/
|
|
105
|
+
import { delay, isDefined } from "@xylabs/sdk-js";
|
|
140
106
|
import { Huri } from "@xyo-network/huri";
|
|
141
107
|
import { ModuleErrorSchema } from "@xyo-network/payload-model";
|
|
142
|
-
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
143
|
-
|
|
144
|
-
var ResolvePayloadProvider = ({ children, huriPayload }) => {
|
|
108
|
+
import React5, { useEffect as useEffect2, useState as useState3 } from "react";
|
|
109
|
+
var ResolvePayloadProvider = /* @__PURE__ */ __name(({ children, huriPayload }) => {
|
|
145
110
|
const [payload, setPayload] = useState3();
|
|
146
111
|
const [huri, setHuri] = useState3();
|
|
147
|
-
const {
|
|
148
|
-
refreshPayload,
|
|
149
|
-
setRefreshPayload,
|
|
150
|
-
onRefresh
|
|
151
|
-
} = useRefreshPayload();
|
|
112
|
+
const { refreshPayload, setRefreshPayload, onRefresh } = useRefreshPayload();
|
|
152
113
|
useEffect2(() => {
|
|
153
114
|
typeof huriPayload === "string" ? setHuri(huriPayload) : void 0;
|
|
154
115
|
if (typeof huriPayload === "object") {
|
|
155
116
|
setPayload(huriPayload);
|
|
156
117
|
setRefreshPayload?.(true);
|
|
157
118
|
}
|
|
158
|
-
}, [
|
|
119
|
+
}, [
|
|
120
|
+
huriPayload,
|
|
121
|
+
setRefreshPayload
|
|
122
|
+
]);
|
|
159
123
|
const [notFound, setNotFound] = useState3();
|
|
160
124
|
const [huriError, setHuriError] = useState3();
|
|
161
|
-
useAsyncEffect(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
setRefreshPayload?.(true);
|
|
172
|
-
}
|
|
173
|
-
} catch (e) {
|
|
174
|
-
const error = e;
|
|
175
|
-
setHuriError({
|
|
176
|
-
message: error.message,
|
|
177
|
-
schema: ModuleErrorSchema,
|
|
178
|
-
$sources: []
|
|
179
|
-
});
|
|
125
|
+
useAsyncEffect(async (mounted) => {
|
|
126
|
+
if (isDefined(huri) && !refreshPayload) {
|
|
127
|
+
try {
|
|
128
|
+
const huriInstance = new Huri(huri);
|
|
129
|
+
const result = await huriInstance.fetch();
|
|
130
|
+
await delay(500);
|
|
131
|
+
if (mounted()) {
|
|
132
|
+
setNotFound(result === null);
|
|
133
|
+
setPayload(result);
|
|
134
|
+
setRefreshPayload?.(true);
|
|
180
135
|
}
|
|
136
|
+
} catch (e) {
|
|
137
|
+
const error = e;
|
|
138
|
+
setHuriError({
|
|
139
|
+
message: error.message,
|
|
140
|
+
schema: ModuleErrorSchema,
|
|
141
|
+
$sources: []
|
|
142
|
+
});
|
|
181
143
|
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
144
|
+
}
|
|
145
|
+
}, [
|
|
146
|
+
huri,
|
|
147
|
+
payload,
|
|
148
|
+
refreshPayload,
|
|
149
|
+
setRefreshPayload
|
|
150
|
+
]);
|
|
151
|
+
const refreshHuri = /* @__PURE__ */ __name(() => {
|
|
186
152
|
onRefresh?.();
|
|
187
153
|
if (isDefined(huri)) {
|
|
188
154
|
setRefreshPayload?.(false);
|
|
189
155
|
}
|
|
190
|
-
};
|
|
191
|
-
return /* @__PURE__ */
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
refreshHuri,
|
|
201
|
-
setPayload
|
|
202
|
-
},
|
|
203
|
-
children
|
|
156
|
+
}, "refreshHuri");
|
|
157
|
+
return /* @__PURE__ */ React5.createElement(ResolvePayloadContext, {
|
|
158
|
+
value: {
|
|
159
|
+
huri,
|
|
160
|
+
huriError,
|
|
161
|
+
notFound,
|
|
162
|
+
payload,
|
|
163
|
+
provided: true,
|
|
164
|
+
refreshHuri,
|
|
165
|
+
setPayload
|
|
204
166
|
}
|
|
205
|
-
);
|
|
206
|
-
};
|
|
167
|
+
}, children);
|
|
168
|
+
}, "ResolvePayloadProvider");
|
|
207
169
|
|
|
208
170
|
// src/contexts/ResolvePayloadContext/use.ts
|
|
209
171
|
import { useContextEx as useContextEx4 } from "@xylabs/react-shared";
|
|
210
|
-
var useResolvePayload = () => useContextEx4(ResolvePayloadContext, "ResolvePayload", true);
|
|
172
|
+
var useResolvePayload = /* @__PURE__ */ __name(() => useContextEx4(ResolvePayloadContext, "ResolvePayload", true), "useResolvePayload");
|
|
211
173
|
|
|
212
174
|
// src/contexts/ValidatePayloadContext/Provider.tsx
|
|
213
175
|
import { Chip } from "@mui/material";
|
|
214
176
|
import { useAsyncEffect as useAsyncEffect2 } from "@xylabs/react-async-effect";
|
|
215
177
|
import { SchemaCache } from "@xyo-network/schema-cache";
|
|
216
|
-
import { useState as useState4 } from "react";
|
|
178
|
+
import React6, { useState as useState4 } from "react";
|
|
217
179
|
|
|
218
180
|
// src/contexts/ValidatePayloadContext/Context.ts
|
|
219
181
|
import { createContextEx as createContextEx5 } from "@xylabs/react-shared";
|
|
220
182
|
var ValidatePayloadContext = createContextEx5();
|
|
221
183
|
|
|
222
184
|
// src/contexts/ValidatePayloadContext/Provider.tsx
|
|
223
|
-
|
|
224
|
-
var ValidatePayloadProvider = ({ children, enabled = false }) => {
|
|
185
|
+
var ValidatePayloadProvider = /* @__PURE__ */ __name(({ children, enabled = false }) => {
|
|
225
186
|
const { payload } = useResolvePayload();
|
|
226
187
|
const [initialized, setInitialized] = useState4(false);
|
|
227
188
|
const [valid, setValid] = useState4();
|
|
228
|
-
useAsyncEffect2(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const validator = SchemaCache.instance.validators[possibleKnownSchema];
|
|
235
|
-
setValid(validator?.(payload));
|
|
236
|
-
}
|
|
237
|
-
setInitialized(true);
|
|
189
|
+
useAsyncEffect2(async () => {
|
|
190
|
+
if (payload && enabled) {
|
|
191
|
+
await SchemaCache.instance.get(payload.schema);
|
|
192
|
+
const possibleKnownSchema = payload.schema;
|
|
193
|
+
if (SchemaCache.instance.validators[possibleKnownSchema]) {
|
|
194
|
+
const validator = SchemaCache.instance.validators[possibleKnownSchema];
|
|
238
195
|
}
|
|
239
|
-
|
|
240
|
-
[payload, enabled]
|
|
241
|
-
);
|
|
242
|
-
return /* @__PURE__ */ jsx6(
|
|
243
|
-
ValidatePayloadContext,
|
|
244
|
-
{
|
|
245
|
-
value: {
|
|
246
|
-
enabled,
|
|
247
|
-
provided: true,
|
|
248
|
-
schema: payload?.schema,
|
|
249
|
-
validPayload: valid
|
|
250
|
-
},
|
|
251
|
-
children: enabled ? /* @__PURE__ */ jsx6(Fragment, { children: initialized ? children : /* @__PURE__ */ jsx6(Chip, { label: "Validating Payload..." }) }) : children
|
|
196
|
+
setInitialized(true);
|
|
252
197
|
}
|
|
253
|
-
|
|
254
|
-
|
|
198
|
+
}, [
|
|
199
|
+
payload,
|
|
200
|
+
enabled
|
|
201
|
+
]);
|
|
202
|
+
return /* @__PURE__ */ React6.createElement(ValidatePayloadContext, {
|
|
203
|
+
value: {
|
|
204
|
+
enabled,
|
|
205
|
+
provided: true,
|
|
206
|
+
schema: payload?.schema,
|
|
207
|
+
validPayload: valid
|
|
208
|
+
}
|
|
209
|
+
}, enabled ? /* @__PURE__ */ React6.createElement(React6.Fragment, null, initialized ? children : /* @__PURE__ */ React6.createElement(Chip, {
|
|
210
|
+
label: "Validating Payload..."
|
|
211
|
+
})) : children);
|
|
212
|
+
}, "ValidatePayloadProvider");
|
|
255
213
|
|
|
256
214
|
// src/contexts/ValidatePayloadContext/use.ts
|
|
257
215
|
import { useContextEx as useContextEx5 } from "@xylabs/react-shared";
|
|
258
|
-
var useValidatePayload = () => useContextEx5(ValidatePayloadContext, "ValidateSchema", true);
|
|
216
|
+
var useValidatePayload = /* @__PURE__ */ __name(() => useContextEx5(ValidatePayloadContext, "ValidateSchema", true), "useValidatePayload");
|
|
259
217
|
|
|
260
218
|
// src/components/embed-card/menu/EmbedMenu.tsx
|
|
261
219
|
import { MoreVert as MoreVertIcon } from "@mui/icons-material";
|
|
262
220
|
import { IconButton, Menu } from "@mui/material";
|
|
263
|
-
import { useState as useState5 } from "react";
|
|
221
|
+
import React8, { useState as useState5 } from "react";
|
|
264
222
|
|
|
265
223
|
// src/components/embed-card/menu/JsonMenuItem.tsx
|
|
266
224
|
import { OpenInNew as OpenInNewIcon } from "@mui/icons-material";
|
|
267
|
-
import {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
} from "@mui/material";
|
|
272
|
-
import { isDefined as isDefined2 } from "@xylabs/typeof";
|
|
273
|
-
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
274
|
-
var JsonMenuItem = (props) => {
|
|
225
|
+
import { ListItemIcon, ListItemText, MenuItem } from "@mui/material";
|
|
226
|
+
import { isDefined as isDefined2 } from "@xylabs/sdk-js";
|
|
227
|
+
import React7 from "react";
|
|
228
|
+
var JsonMenuItem = /* @__PURE__ */ __name((props) => {
|
|
275
229
|
const { huri } = useResolvePayload();
|
|
276
|
-
return /* @__PURE__ */
|
|
277
|
-
|
|
278
|
-
/* @__PURE__ */
|
|
279
|
-
|
|
280
|
-
}
|
|
230
|
+
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, isDefined2(huri) ? /* @__PURE__ */ React7.createElement(MenuItem, {
|
|
231
|
+
title: "Source Payload JSON",
|
|
232
|
+
onClick: /* @__PURE__ */ __name(() => window.open(huri, "_blank"), "onClick"),
|
|
233
|
+
...props
|
|
234
|
+
}, /* @__PURE__ */ React7.createElement(ListItemText, {
|
|
235
|
+
sx: {
|
|
236
|
+
mr: 1
|
|
237
|
+
}
|
|
238
|
+
}, "JSON"), /* @__PURE__ */ React7.createElement(ListItemIcon, {
|
|
239
|
+
sx: {
|
|
240
|
+
justifyContent: "end"
|
|
241
|
+
}
|
|
242
|
+
}, /* @__PURE__ */ React7.createElement(OpenInNewIcon, {
|
|
243
|
+
fontSize: "small"
|
|
244
|
+
}))) : null);
|
|
245
|
+
}, "JsonMenuItem");
|
|
281
246
|
|
|
282
247
|
// src/components/embed-card/menu/EmbedMenu.tsx
|
|
283
|
-
|
|
284
|
-
var EmbedMenu = (props) => {
|
|
248
|
+
var EmbedMenu = /* @__PURE__ */ __name((props) => {
|
|
285
249
|
const [anchorEl, setAnchorEl] = useState5(null);
|
|
286
250
|
const open = Boolean(anchorEl);
|
|
287
|
-
const handleClick = (event) => {
|
|
251
|
+
const handleClick = /* @__PURE__ */ __name((event) => {
|
|
288
252
|
setAnchorEl(event.currentTarget);
|
|
289
|
-
};
|
|
290
|
-
const handleClose = () => {
|
|
253
|
+
}, "handleClick");
|
|
254
|
+
const handleClose = /* @__PURE__ */ __name(() => {
|
|
291
255
|
setAnchorEl(null);
|
|
292
|
-
};
|
|
293
|
-
return /* @__PURE__ */
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
256
|
+
}, "handleClose");
|
|
257
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(IconButton, {
|
|
258
|
+
onClick: handleClick,
|
|
259
|
+
...props
|
|
260
|
+
}, /* @__PURE__ */ React8.createElement(MoreVertIcon, null)), /* @__PURE__ */ React8.createElement(Menu, {
|
|
261
|
+
anchorEl,
|
|
262
|
+
open,
|
|
263
|
+
onClose: handleClose,
|
|
264
|
+
slotProps: {
|
|
265
|
+
paper: {
|
|
266
|
+
variant: "elevation"
|
|
267
|
+
},
|
|
268
|
+
list: {
|
|
269
|
+
dense: true
|
|
306
270
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
};
|
|
271
|
+
}
|
|
272
|
+
}, /* @__PURE__ */ React8.createElement(JsonMenuItem, null)));
|
|
273
|
+
}, "EmbedMenu");
|
|
310
274
|
|
|
311
275
|
// src/components/embed-card/card/EmbedCardHeader.tsx
|
|
312
|
-
|
|
313
|
-
var EmbedCardHeader = () => {
|
|
276
|
+
var EmbedCardHeader = /* @__PURE__ */ __name(() => {
|
|
314
277
|
const { refreshHuri, huri } = useResolvePayload();
|
|
315
|
-
const {
|
|
316
|
-
|
|
317
|
-
timestampLabel,
|
|
318
|
-
hideElementsConfig
|
|
319
|
-
} = useEmbedPluginState();
|
|
320
|
-
const {
|
|
321
|
-
hideAvatar,
|
|
322
|
-
hideTitle,
|
|
323
|
-
hideRefreshButton,
|
|
324
|
-
hideTimestamp,
|
|
325
|
-
hideCardActions
|
|
326
|
-
} = hideElementsConfig ?? {};
|
|
278
|
+
const { activePlugin, timestampLabel, hideElementsConfig } = useEmbedPluginState();
|
|
279
|
+
const { hideAvatar, hideTitle, hideRefreshButton, hideTimestamp, hideCardActions } = hideElementsConfig ?? {};
|
|
327
280
|
const timestamp = Date.now();
|
|
328
|
-
return /* @__PURE__ */
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
281
|
+
return /* @__PURE__ */ React9.createElement(CardHeader, {
|
|
282
|
+
sx: {
|
|
283
|
+
flexWrap: "wrap",
|
|
284
|
+
rowGap: 1
|
|
285
|
+
},
|
|
286
|
+
avatar: hideAvatar ? /* @__PURE__ */ React9.createElement(React9.Fragment, null) : /* @__PURE__ */ React9.createElement(Avatar, {
|
|
287
|
+
sx: {
|
|
288
|
+
bgcolor: /* @__PURE__ */ __name((theme) => theme.vars.palette.primary.main, "bgcolor")
|
|
289
|
+
},
|
|
290
|
+
"aria-label": activePlugin?.name
|
|
291
|
+
}, activePlugin?.name?.charAt(0)),
|
|
292
|
+
action: /* @__PURE__ */ React9.createElement(FlexRow, {
|
|
293
|
+
flexWrap: "wrap",
|
|
294
|
+
columnGap: 0.5
|
|
295
|
+
}, isDefined3(timestamp) && !Number.isNaN(timestamp) ? hideTimestamp && hideRefreshButton ? "" : /* @__PURE__ */ React9.createElement(Chip2, {
|
|
296
|
+
avatar: hideRefreshButton ? /* @__PURE__ */ React9.createElement(React9.Fragment, null) : /* @__PURE__ */ React9.createElement(RefreshIcon, null),
|
|
297
|
+
clickable: hideRefreshButton ? false : true,
|
|
298
|
+
onClick: refreshHuri,
|
|
299
|
+
label: hideTimestamp ? "" : `${timestampLabel} ${new Date(timestamp).toLocaleString()}`
|
|
300
|
+
}) : null, hideCardActions || huri === void 0 ? null : /* @__PURE__ */ React9.createElement(EmbedMenu, null)),
|
|
301
|
+
title: hideTitle ? "" : activePlugin?.name
|
|
302
|
+
});
|
|
303
|
+
}, "EmbedCardHeader");
|
|
349
304
|
|
|
350
305
|
// src/components/embed-card/card/EmbedPluginCard.tsx
|
|
351
306
|
import { CardContent } from "@mui/material";
|
|
352
307
|
import { FlexGrowRow } from "@xylabs/react-flexbox";
|
|
353
|
-
import { isTruthy } from "@xylabs/
|
|
308
|
+
import { isTruthy } from "@xylabs/sdk-js";
|
|
354
309
|
import { useListMode as useListMode2 } from "@xyo-network/react-shared";
|
|
310
|
+
import React13 from "react";
|
|
355
311
|
|
|
356
312
|
// src/components/controls/EmbedFormControl.tsx
|
|
357
313
|
import { FormControl, InputLabel } from "@mui/material";
|
|
358
|
-
import
|
|
359
|
-
var EmbedFormControl = ({
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
children
|
|
363
|
-
|
|
364
|
-
}) => {
|
|
365
|
-
return /* @__PURE__ */ jsxs5(FormControl, { ...props, children: [
|
|
366
|
-
/* @__PURE__ */ jsx10(InputLabel, { id: formId, children: formLabel }),
|
|
367
|
-
children
|
|
368
|
-
] });
|
|
369
|
-
};
|
|
314
|
+
import React10 from "react";
|
|
315
|
+
var EmbedFormControl = /* @__PURE__ */ __name(({ formId, formLabel, children, ...props }) => {
|
|
316
|
+
return /* @__PURE__ */ React10.createElement(FormControl, props, /* @__PURE__ */ React10.createElement(InputLabel, {
|
|
317
|
+
id: formId
|
|
318
|
+
}, formLabel), children);
|
|
319
|
+
}, "EmbedFormControl");
|
|
370
320
|
|
|
371
321
|
// src/components/controls/ListModeSelect.tsx
|
|
372
322
|
import { MenuItem as MenuItem2 } from "@mui/material";
|
|
373
323
|
import { SelectEx } from "@xylabs/react-select";
|
|
374
324
|
import { useListMode } from "@xyo-network/react-shared";
|
|
375
|
-
import
|
|
325
|
+
import React11 from "react";
|
|
376
326
|
var listModeSelectId = "listmode-select-id";
|
|
377
327
|
var listModeSelectLabel = "List Mode";
|
|
378
|
-
var ListModeSelect = (props) => {
|
|
328
|
+
var ListModeSelect = /* @__PURE__ */ __name((props) => {
|
|
379
329
|
const { listMode, setListMode } = useListMode();
|
|
380
|
-
return /* @__PURE__ */
|
|
381
|
-
|
|
382
|
-
{
|
|
383
|
-
value
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
330
|
+
return /* @__PURE__ */ React11.createElement(SelectEx, {
|
|
331
|
+
value: listMode ?? "default",
|
|
332
|
+
onChange: /* @__PURE__ */ __name((event) => {
|
|
333
|
+
setListMode?.(event.target.value);
|
|
334
|
+
}, "onChange"),
|
|
335
|
+
...props
|
|
336
|
+
}, /* @__PURE__ */ React11.createElement(MenuItem2, {
|
|
337
|
+
key: "default",
|
|
338
|
+
value: "default"
|
|
339
|
+
}, "Default"), /* @__PURE__ */ React11.createElement(MenuItem2, {
|
|
340
|
+
key: "table",
|
|
341
|
+
value: "table"
|
|
342
|
+
}, "Table"), /* @__PURE__ */ React11.createElement(MenuItem2, {
|
|
343
|
+
key: "grid",
|
|
344
|
+
value: "grid"
|
|
345
|
+
}, "Grid"));
|
|
346
|
+
}, "ListModeSelect");
|
|
347
|
+
var ListModeSelectFormControl = /* @__PURE__ */ __name((props) => {
|
|
348
|
+
return /* @__PURE__ */ React11.createElement(EmbedFormControl, {
|
|
349
|
+
formId: listModeSelectId,
|
|
350
|
+
formLabel: listModeSelectLabel
|
|
351
|
+
}, /* @__PURE__ */ React11.createElement(ListModeSelect, {
|
|
352
|
+
size: "small",
|
|
353
|
+
label: listModeSelectLabel,
|
|
354
|
+
labelId: listModeSelectId,
|
|
355
|
+
...props
|
|
356
|
+
}));
|
|
357
|
+
}, "ListModeSelectFormControl");
|
|
399
358
|
|
|
400
359
|
// src/components/controls/RenderSelect.tsx
|
|
401
360
|
import { MenuItem as MenuItem3 } from "@mui/material";
|
|
402
361
|
import { SelectEx as SelectEx2 } from "@xylabs/react-select";
|
|
403
|
-
import
|
|
362
|
+
import React12 from "react";
|
|
404
363
|
var renderSelectId = "render-select-id";
|
|
405
364
|
var renderSelectLabel = "Renderer";
|
|
406
|
-
var EmbedRenderSelect = (props) => {
|
|
407
|
-
const {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
|
|
365
|
+
var EmbedRenderSelect = /* @__PURE__ */ __name((props) => {
|
|
366
|
+
const { activePlugin, setActivePlugin, plugins } = useEmbedPluginState();
|
|
367
|
+
return /* @__PURE__ */ React12.createElement(EmbedFormControl, {
|
|
368
|
+
formId: renderSelectId,
|
|
369
|
+
formLabel: renderSelectLabel
|
|
370
|
+
}, /* @__PURE__ */ React12.createElement(SelectEx2, {
|
|
371
|
+
size: "small",
|
|
372
|
+
value: activePlugin?.name,
|
|
373
|
+
...props
|
|
374
|
+
}, plugins?.map((plugin) => /* @__PURE__ */ React12.createElement(MenuItem3, {
|
|
375
|
+
value: plugin.name,
|
|
376
|
+
key: plugin.name,
|
|
377
|
+
onClick: /* @__PURE__ */ __name(() => setActivePlugin?.(plugin), "onClick")
|
|
378
|
+
}, plugin.name))));
|
|
379
|
+
}, "EmbedRenderSelect");
|
|
414
380
|
|
|
415
381
|
// src/components/embed-card/card/EmbedPluginCard.tsx
|
|
416
|
-
|
|
417
|
-
var EmbedPluginCard = ({ ...props }) => {
|
|
382
|
+
var EmbedPluginCard = /* @__PURE__ */ __name(({ ...props }) => {
|
|
418
383
|
const { payload } = useResolvePayload();
|
|
419
|
-
const {
|
|
420
|
-
activePlugin: ActivePlugin,
|
|
421
|
-
plugins,
|
|
422
|
-
hideElementsConfig
|
|
423
|
-
} = useEmbedPluginState();
|
|
384
|
+
const { activePlugin: ActivePlugin, plugins, hideElementsConfig } = useEmbedPluginState();
|
|
424
385
|
const { listMode } = useListMode2();
|
|
425
386
|
const { pluginProps } = usePluginProps();
|
|
426
387
|
const supportsListMode = isTruthy(ActivePlugin?.components?.box?.listModes?.length) ? true : false;
|
|
427
|
-
return /* @__PURE__ */
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}
|
|
388
|
+
return /* @__PURE__ */ React13.createElement(BusyCard, props, hideElementsConfig?.hideCardHeader ? null : /* @__PURE__ */ React13.createElement(EmbedCardHeader, null), plugins && plugins.length > 0 || supportsListMode ? /* @__PURE__ */ React13.createElement(FlexGrowRow, {
|
|
389
|
+
columnGap: 2,
|
|
390
|
+
rowGap: 2,
|
|
391
|
+
flexWrap: "wrap",
|
|
392
|
+
pb: 1
|
|
393
|
+
}, plugins && plugins.length > 1 ? /* @__PURE__ */ React13.createElement(EmbedRenderSelect, null) : null, supportsListMode ? /* @__PURE__ */ React13.createElement(ListModeSelectFormControl, null) : null) : null, /* @__PURE__ */ React13.createElement(CardContent, {
|
|
394
|
+
sx: {
|
|
395
|
+
height: "100%"
|
|
396
|
+
}
|
|
397
|
+
}, ActivePlugin ? /* @__PURE__ */ React13.createElement(ActivePlugin.components.box.detailsBox, {
|
|
398
|
+
payload,
|
|
399
|
+
...pluginProps,
|
|
400
|
+
...supportsListMode && {
|
|
401
|
+
listMode
|
|
402
|
+
}
|
|
403
|
+
}) : null));
|
|
404
|
+
}, "EmbedPluginCard");
|
|
436
405
|
|
|
437
406
|
// src/components/embed-card/EmbedPluginCard.tsx
|
|
438
407
|
import { useTheme } from "@mui/material";
|
|
408
|
+
import React20 from "react";
|
|
439
409
|
|
|
440
410
|
// src/components/EmbedPlugin.tsx
|
|
441
411
|
import { ErrorBoundary } from "@xylabs/react-error";
|
|
442
412
|
import { ListModeProvider } from "@xyo-network/react-shared";
|
|
413
|
+
import React17 from "react";
|
|
443
414
|
|
|
444
415
|
// src/components/EmbedResolver.tsx
|
|
445
416
|
import { LoadResult } from "@xyo-network/react-shared";
|
|
446
|
-
import
|
|
447
|
-
var EmbedResolver = ({ children }) => {
|
|
448
|
-
const {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
};
|
|
417
|
+
import React14 from "react";
|
|
418
|
+
var EmbedResolver = /* @__PURE__ */ __name(({ children }) => {
|
|
419
|
+
const { payload, notFound, huriError } = useResolvePayload();
|
|
420
|
+
return /* @__PURE__ */ React14.createElement(LoadResult, {
|
|
421
|
+
searchResult: payload,
|
|
422
|
+
notFound: !!notFound,
|
|
423
|
+
error: !!huriError
|
|
424
|
+
}, children);
|
|
425
|
+
}, "EmbedResolver");
|
|
455
426
|
|
|
456
427
|
// src/components/validation-alerts/ValidatePayload.tsx
|
|
457
428
|
import { Alert } from "@mui/material";
|
|
458
|
-
import
|
|
459
|
-
var ValidatePayloadAlert = ({ children, ...props }) => {
|
|
460
|
-
const {
|
|
461
|
-
validPayload,
|
|
462
|
-
enabled,
|
|
463
|
-
schema
|
|
464
|
-
} = useValidatePayload();
|
|
429
|
+
import React15 from "react";
|
|
430
|
+
var ValidatePayloadAlert = /* @__PURE__ */ __name(({ children, ...props }) => {
|
|
431
|
+
const { validPayload, enabled, schema } = useValidatePayload();
|
|
465
432
|
if (enabled && validPayload === false) {
|
|
466
|
-
return /* @__PURE__ */
|
|
467
|
-
|
|
468
|
-
" ",
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
"but failed to validate."
|
|
472
|
-
] });
|
|
433
|
+
return /* @__PURE__ */ React15.createElement(Alert, {
|
|
434
|
+
severity: "error",
|
|
435
|
+
title: "Invalid Payload!",
|
|
436
|
+
...props
|
|
437
|
+
}, "Payload schema claimed to be", " ", schema, " ", "but failed to validate.");
|
|
473
438
|
}
|
|
474
|
-
return /* @__PURE__ */
|
|
475
|
-
};
|
|
439
|
+
return /* @__PURE__ */ React15.createElement(React15.Fragment, null, children);
|
|
440
|
+
}, "ValidatePayloadAlert");
|
|
476
441
|
|
|
477
442
|
// src/components/validation-alerts/ValidatePlugins.tsx
|
|
478
443
|
import { Alert as Alert2, AlertTitle } from "@mui/material";
|
|
479
|
-
import
|
|
480
|
-
var ValidatePluginsAlert = ({ children, ...props }) => {
|
|
444
|
+
import React16 from "react";
|
|
445
|
+
var ValidatePluginsAlert = /* @__PURE__ */ __name(({ children, ...props }) => {
|
|
481
446
|
const { payload } = useResolvePayload();
|
|
482
447
|
const { plugins } = useEmbedPluginState();
|
|
483
448
|
if (payload && plugins?.length === 0) {
|
|
484
|
-
return /* @__PURE__ */
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
449
|
+
return /* @__PURE__ */ React16.createElement(Alert2, {
|
|
450
|
+
severity: "warning",
|
|
451
|
+
...props
|
|
452
|
+
}, /* @__PURE__ */ React16.createElement(AlertTitle, null, "Missing plugins!"), "Payload found but no plugins were present.");
|
|
488
453
|
}
|
|
489
|
-
return /* @__PURE__ */
|
|
490
|
-
};
|
|
454
|
+
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, children);
|
|
455
|
+
}, "ValidatePluginsAlert");
|
|
491
456
|
|
|
492
457
|
// src/components/EmbedPlugin.tsx
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}) => {
|
|
522
|
-
return /* @__PURE__ */ jsx17(RefreshPayloadProvider, { onRefresh, children: /* @__PURE__ */ jsx17(ResolvePayloadProvider, { huriPayload, children: /* @__PURE__ */ jsx17(EmbedResolver, { children }) }) });
|
|
523
|
-
};
|
|
524
|
-
var WithValidators = ({ children, validateSchema }) => {
|
|
525
|
-
return /* @__PURE__ */ jsx17(ValidatePayloadProvider, { enabled: validateSchema, children: /* @__PURE__ */ jsx17(ValidatePluginsAlert, { children: /* @__PURE__ */ jsx17(ValidatePayloadAlert, { children }) }) });
|
|
526
|
-
};
|
|
458
|
+
var EmbedPluginInner = /* @__PURE__ */ __name(({ validateSchema, plugins, huriPayload, refreshTitle = "", timestampLabel = "Data From", hideElementsConfig, embedPluginConfig, onRefresh, children }) => {
|
|
459
|
+
return /* @__PURE__ */ React17.createElement(ErrorBoundary, null, /* @__PURE__ */ React17.createElement(EmbedPluginProvider, {
|
|
460
|
+
refreshTitle,
|
|
461
|
+
timestampLabel,
|
|
462
|
+
hideElementsConfig,
|
|
463
|
+
plugins,
|
|
464
|
+
embedPluginConfig
|
|
465
|
+
}, /* @__PURE__ */ React17.createElement(WithResolvers, {
|
|
466
|
+
onRefresh,
|
|
467
|
+
huriPayload
|
|
468
|
+
}, /* @__PURE__ */ React17.createElement(WithValidators, {
|
|
469
|
+
validateSchema
|
|
470
|
+
}, /* @__PURE__ */ React17.createElement(ListModeProvider, {
|
|
471
|
+
defaultListMode: embedPluginConfig?.listMode
|
|
472
|
+
}, children)))));
|
|
473
|
+
}, "EmbedPluginInner");
|
|
474
|
+
var WithResolvers = /* @__PURE__ */ __name(({ children, onRefresh, huriPayload }) => {
|
|
475
|
+
return /* @__PURE__ */ React17.createElement(RefreshPayloadProvider, {
|
|
476
|
+
onRefresh
|
|
477
|
+
}, /* @__PURE__ */ React17.createElement(ResolvePayloadProvider, {
|
|
478
|
+
huriPayload
|
|
479
|
+
}, /* @__PURE__ */ React17.createElement(EmbedResolver, null, children)));
|
|
480
|
+
}, "WithResolvers");
|
|
481
|
+
var WithValidators = /* @__PURE__ */ __name(({ children, validateSchema }) => {
|
|
482
|
+
return /* @__PURE__ */ React17.createElement(ValidatePayloadProvider, {
|
|
483
|
+
enabled: validateSchema
|
|
484
|
+
}, /* @__PURE__ */ React17.createElement(ValidatePluginsAlert, null, /* @__PURE__ */ React17.createElement(ValidatePayloadAlert, null, children)));
|
|
485
|
+
}, "WithValidators");
|
|
527
486
|
|
|
528
487
|
// src/components/embed-card/error-handling/EmbedCardApiErrorRenderer.tsx
|
|
529
488
|
import { ErrorAlert, ErrorRender } from "@xylabs/react-error";
|
|
489
|
+
import React19 from "react";
|
|
530
490
|
|
|
531
491
|
// src/components/embed-card/error-handling/EmbedErrorCard.tsx
|
|
532
|
-
import {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
Typography
|
|
538
|
-
} from "@mui/material";
|
|
539
|
-
import { isDefined as isDefined4 } from "@xylabs/typeof";
|
|
540
|
-
import { Fragment as Fragment7, jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
541
|
-
var EmbedErrorCard = (props) => {
|
|
542
|
-
const {
|
|
543
|
-
alertProps,
|
|
544
|
-
error,
|
|
545
|
-
scope,
|
|
546
|
-
hideErrorDetails = true,
|
|
547
|
-
children,
|
|
548
|
-
...cardProps
|
|
549
|
-
} = props;
|
|
492
|
+
import { Alert as Alert3, AlertTitle as AlertTitle2, Card as Card2, CardContent as CardContent2, Typography } from "@mui/material";
|
|
493
|
+
import { isDefined as isDefined4 } from "@xylabs/sdk-js";
|
|
494
|
+
import React18 from "react";
|
|
495
|
+
var EmbedErrorCard = /* @__PURE__ */ __name((props) => {
|
|
496
|
+
const { alertProps, error, scope, hideErrorDetails = true, children, ...cardProps } = props;
|
|
550
497
|
const errorProps = {
|
|
551
498
|
alertProps,
|
|
552
499
|
error,
|
|
553
500
|
hideErrorDetails,
|
|
554
501
|
scope
|
|
555
502
|
};
|
|
556
|
-
return /* @__PURE__ */
|
|
557
|
-
};
|
|
558
|
-
var DefaultErrorAlert = ({
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
] }) : /* @__PURE__ */ jsx18(Typography, { variant: "caption", fontSize: "small", children: "Error Loading Plugin" })
|
|
574
|
-
] });
|
|
575
|
-
};
|
|
503
|
+
return /* @__PURE__ */ React18.createElement(Card2, cardProps, /* @__PURE__ */ React18.createElement(CardContent2, null, children ?? /* @__PURE__ */ React18.createElement(DefaultErrorAlert, errorProps)));
|
|
504
|
+
}, "EmbedErrorCard");
|
|
505
|
+
var DefaultErrorAlert = /* @__PURE__ */ __name(({ alertProps, scope, hideErrorDetails, error }) => {
|
|
506
|
+
return /* @__PURE__ */ React18.createElement(Alert3, {
|
|
507
|
+
severity: "error",
|
|
508
|
+
...alertProps
|
|
509
|
+
}, /* @__PURE__ */ React18.createElement(AlertTitle2, null, "Whoops! Something went wrong"), isDefined4(scope) ? /* @__PURE__ */ React18.createElement(Typography, {
|
|
510
|
+
variant: "caption"
|
|
511
|
+
}, "Scope:", scope) : null, !hideErrorDetails && error ? /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(Typography, {
|
|
512
|
+
variant: "caption"
|
|
513
|
+
}, "Error: "), /* @__PURE__ */ React18.createElement(Typography, {
|
|
514
|
+
variant: "caption"
|
|
515
|
+
}, error?.message)) : /* @__PURE__ */ React18.createElement(Typography, {
|
|
516
|
+
variant: "caption",
|
|
517
|
+
fontSize: "small"
|
|
518
|
+
}, "Error Loading Plugin"));
|
|
519
|
+
}, "DefaultErrorAlert");
|
|
576
520
|
|
|
577
521
|
// src/components/embed-card/error-handling/EmbedCardApiErrorRenderer.tsx
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
};
|
|
522
|
+
var EmbedCardApiErrorRenderer = /* @__PURE__ */ __name(({ xyoError, children, ...props }) => {
|
|
523
|
+
return /* @__PURE__ */ React19.createElement(ErrorRender, {
|
|
524
|
+
error: xyoError,
|
|
525
|
+
noReAuth: true,
|
|
526
|
+
noErrorDisplay: true,
|
|
527
|
+
customError: /* @__PURE__ */ React19.createElement(CustomApiErrorCard, {
|
|
528
|
+
xyoError,
|
|
529
|
+
...props
|
|
530
|
+
})
|
|
531
|
+
}, children);
|
|
532
|
+
}, "EmbedCardApiErrorRenderer");
|
|
533
|
+
var CustomApiErrorCard = /* @__PURE__ */ __name(({ xyoError, ...props }) => {
|
|
534
|
+
return /* @__PURE__ */ React19.createElement(EmbedErrorCard, props, /* @__PURE__ */ React19.createElement(ErrorAlert, {
|
|
535
|
+
error: xyoError
|
|
536
|
+
}));
|
|
537
|
+
}, "CustomApiErrorCard");
|
|
589
538
|
|
|
590
539
|
// src/components/embed-card/EmbedPluginCard.tsx
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
validateSchema,
|
|
595
|
-
plugins = [],
|
|
596
|
-
huriPayload,
|
|
597
|
-
refreshTitle = "",
|
|
598
|
-
timestampLabel = "Data From",
|
|
599
|
-
hideElementsConfig,
|
|
540
|
+
var ApiEmbedPluginCard = /* @__PURE__ */ __name(({ children, ...props }) => {
|
|
541
|
+
const { validateSchema, plugins = [], huriPayload, refreshTitle = "", timestampLabel = "Data From", hideElementsConfig, embedPluginConfig, onRefresh, ...busyCardProps } = props;
|
|
542
|
+
return /* @__PURE__ */ React20.createElement(EmbedPluginInner, {
|
|
600
543
|
embedPluginConfig,
|
|
544
|
+
hideElementsConfig,
|
|
545
|
+
huriPayload,
|
|
601
546
|
onRefresh,
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
hideElementsConfig,
|
|
610
|
-
huriPayload,
|
|
611
|
-
onRefresh,
|
|
612
|
-
plugins,
|
|
613
|
-
refreshTitle,
|
|
614
|
-
timestampLabel,
|
|
615
|
-
validateSchema
|
|
616
|
-
},
|
|
617
|
-
children: [
|
|
618
|
-
/* @__PURE__ */ jsx20(EmbedPluginCardInner, { ...busyCardProps }),
|
|
619
|
-
children
|
|
620
|
-
]
|
|
621
|
-
}
|
|
622
|
-
);
|
|
623
|
-
};
|
|
624
|
-
var EmbedPluginCardInner = (props) => {
|
|
547
|
+
plugins,
|
|
548
|
+
refreshTitle,
|
|
549
|
+
timestampLabel,
|
|
550
|
+
validateSchema
|
|
551
|
+
}, /* @__PURE__ */ React20.createElement(EmbedPluginCardInner, busyCardProps), children);
|
|
552
|
+
}, "ApiEmbedPluginCard");
|
|
553
|
+
var EmbedPluginCardInner = /* @__PURE__ */ __name((props) => {
|
|
625
554
|
const { payload, huriError } = useResolvePayload();
|
|
626
555
|
const { refreshPayload } = useRefreshPayload();
|
|
627
556
|
const theme = useTheme();
|
|
628
|
-
return /* @__PURE__ */
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
};
|
|
557
|
+
return /* @__PURE__ */ React20.createElement(EmbedCardApiErrorRenderer, {
|
|
558
|
+
xyoError: huriError
|
|
559
|
+
}, /* @__PURE__ */ React20.createElement(EmbedPluginCard, {
|
|
560
|
+
elevation: 3,
|
|
561
|
+
variant: "elevation",
|
|
562
|
+
busy: Boolean(!refreshPayload && payload),
|
|
563
|
+
busyVariantProps: {
|
|
564
|
+
style: {
|
|
565
|
+
alignItems: "start",
|
|
566
|
+
paddingTop: theme.spacing(2),
|
|
567
|
+
zIndex: 2
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
sx: {
|
|
571
|
+
position: "relative"
|
|
572
|
+
},
|
|
573
|
+
...props
|
|
574
|
+
}));
|
|
575
|
+
}, "EmbedPluginCardInner");
|
|
646
576
|
export {
|
|
647
577
|
ApiEmbedPluginCard,
|
|
648
578
|
BusyCard,
|