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