@xyo-network/react-embed 2.77.0-rc.1 → 2.77.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. package/dist/browser/components/embed-card/EmbedPluginCard.d.cts +0 -1
  2. package/dist/browser/components/embed-card/EmbedPluginCard.d.cts.map +1 -1
  3. package/dist/browser/components/embed-card/EmbedPluginCard.d.mts +0 -1
  4. package/dist/browser/components/embed-card/EmbedPluginCard.d.mts.map +1 -1
  5. package/dist/browser/components/embed-card/EmbedPluginCard.d.ts +0 -1
  6. package/dist/browser/components/embed-card/EmbedPluginCard.d.ts.map +1 -1
  7. package/dist/browser/contexts/EmbedPluginContext/Provider.d.cts +0 -1
  8. package/dist/browser/contexts/EmbedPluginContext/Provider.d.cts.map +1 -1
  9. package/dist/browser/contexts/EmbedPluginContext/Provider.d.mts +0 -1
  10. package/dist/browser/contexts/EmbedPluginContext/Provider.d.mts.map +1 -1
  11. package/dist/browser/contexts/EmbedPluginContext/Provider.d.ts +0 -1
  12. package/dist/browser/contexts/EmbedPluginContext/Provider.d.ts.map +1 -1
  13. package/dist/browser/contexts/EmbedPluginContext/State.d.cts +0 -5
  14. package/dist/browser/contexts/EmbedPluginContext/State.d.cts.map +1 -1
  15. package/dist/browser/contexts/EmbedPluginContext/State.d.mts +0 -5
  16. package/dist/browser/contexts/EmbedPluginContext/State.d.mts.map +1 -1
  17. package/dist/browser/contexts/EmbedPluginContext/State.d.ts +0 -5
  18. package/dist/browser/contexts/EmbedPluginContext/State.d.ts.map +1 -1
  19. package/dist/browser/index.cjs +1 -513
  20. package/dist/browser/index.cjs.map +1 -1
  21. package/dist/browser/index.js +1 -493
  22. package/dist/browser/index.js.map +1 -1
  23. package/dist/browser/types/EmbedPluginProps.d.cts +0 -1
  24. package/dist/browser/types/EmbedPluginProps.d.cts.map +1 -1
  25. package/dist/browser/types/EmbedPluginProps.d.mts +0 -1
  26. package/dist/browser/types/EmbedPluginProps.d.mts.map +1 -1
  27. package/dist/browser/types/EmbedPluginProps.d.ts +0 -1
  28. package/dist/browser/types/EmbedPluginProps.d.ts.map +1 -1
  29. package/dist/neutral/components/embed-card/EmbedPluginCard.d.cts +0 -1
  30. package/dist/neutral/components/embed-card/EmbedPluginCard.d.cts.map +1 -1
  31. package/dist/neutral/components/embed-card/EmbedPluginCard.d.mts +0 -1
  32. package/dist/neutral/components/embed-card/EmbedPluginCard.d.mts.map +1 -1
  33. package/dist/neutral/components/embed-card/EmbedPluginCard.d.ts +0 -1
  34. package/dist/neutral/components/embed-card/EmbedPluginCard.d.ts.map +1 -1
  35. package/dist/neutral/contexts/EmbedPluginContext/Provider.d.cts +0 -1
  36. package/dist/neutral/contexts/EmbedPluginContext/Provider.d.cts.map +1 -1
  37. package/dist/neutral/contexts/EmbedPluginContext/Provider.d.mts +0 -1
  38. package/dist/neutral/contexts/EmbedPluginContext/Provider.d.mts.map +1 -1
  39. package/dist/neutral/contexts/EmbedPluginContext/Provider.d.ts +0 -1
  40. package/dist/neutral/contexts/EmbedPluginContext/Provider.d.ts.map +1 -1
  41. package/dist/neutral/contexts/EmbedPluginContext/State.d.cts +0 -5
  42. package/dist/neutral/contexts/EmbedPluginContext/State.d.cts.map +1 -1
  43. package/dist/neutral/contexts/EmbedPluginContext/State.d.mts +0 -5
  44. package/dist/neutral/contexts/EmbedPluginContext/State.d.mts.map +1 -1
  45. package/dist/neutral/contexts/EmbedPluginContext/State.d.ts +0 -5
  46. package/dist/neutral/contexts/EmbedPluginContext/State.d.ts.map +1 -1
  47. package/dist/neutral/index.cjs +1 -513
  48. package/dist/neutral/index.cjs.map +1 -1
  49. package/dist/neutral/index.js +1 -493
  50. package/dist/neutral/index.js.map +1 -1
  51. package/dist/neutral/types/EmbedPluginProps.d.cts +0 -1
  52. package/dist/neutral/types/EmbedPluginProps.d.cts.map +1 -1
  53. package/dist/neutral/types/EmbedPluginProps.d.mts +0 -1
  54. package/dist/neutral/types/EmbedPluginProps.d.mts.map +1 -1
  55. package/dist/neutral/types/EmbedPluginProps.d.ts +0 -1
  56. package/dist/neutral/types/EmbedPluginProps.d.ts.map +1 -1
  57. package/dist/node/components/embed-card/EmbedPluginCard.d.cts +0 -1
  58. package/dist/node/components/embed-card/EmbedPluginCard.d.cts.map +1 -1
  59. package/dist/node/components/embed-card/EmbedPluginCard.d.mts +0 -1
  60. package/dist/node/components/embed-card/EmbedPluginCard.d.mts.map +1 -1
  61. package/dist/node/components/embed-card/EmbedPluginCard.d.ts +0 -1
  62. package/dist/node/components/embed-card/EmbedPluginCard.d.ts.map +1 -1
  63. package/dist/node/contexts/EmbedPluginContext/Provider.d.cts +0 -1
  64. package/dist/node/contexts/EmbedPluginContext/Provider.d.cts.map +1 -1
  65. package/dist/node/contexts/EmbedPluginContext/Provider.d.mts +0 -1
  66. package/dist/node/contexts/EmbedPluginContext/Provider.d.mts.map +1 -1
  67. package/dist/node/contexts/EmbedPluginContext/Provider.d.ts +0 -1
  68. package/dist/node/contexts/EmbedPluginContext/Provider.d.ts.map +1 -1
  69. package/dist/node/contexts/EmbedPluginContext/State.d.cts +0 -5
  70. package/dist/node/contexts/EmbedPluginContext/State.d.cts.map +1 -1
  71. package/dist/node/contexts/EmbedPluginContext/State.d.mts +0 -5
  72. package/dist/node/contexts/EmbedPluginContext/State.d.mts.map +1 -1
  73. package/dist/node/contexts/EmbedPluginContext/State.d.ts +0 -5
  74. package/dist/node/contexts/EmbedPluginContext/State.d.ts.map +1 -1
  75. package/dist/node/index.cjs +1 -535
  76. package/dist/node/index.cjs.map +1 -1
  77. package/dist/node/index.js +1 -495
  78. package/dist/node/index.js.map +1 -1
  79. package/dist/node/types/EmbedPluginProps.d.cts +0 -1
  80. package/dist/node/types/EmbedPluginProps.d.cts.map +1 -1
  81. package/dist/node/types/EmbedPluginProps.d.mts +0 -1
  82. package/dist/node/types/EmbedPluginProps.d.mts.map +1 -1
  83. package/dist/node/types/EmbedPluginProps.d.ts +0 -1
  84. package/dist/node/types/EmbedPluginProps.d.ts.map +1 -1
  85. package/package.json +15 -16
@@ -1,536 +1,2 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- ApiEmbedPluginCard: () => ApiEmbedPluginCard,
24
- BusyCard: () => BusyCard,
25
- EmbedCardHeader: () => EmbedCardHeader,
26
- EmbedPlugin: () => EmbedPluginCard,
27
- EmbedPluginCard: () => EmbedPluginCard,
28
- EmbedPluginCardInner: () => EmbedPluginCardInner,
29
- EmbedPluginContext: () => EmbedPluginContext,
30
- EmbedPluginInner: () => EmbedPluginInner,
31
- EmbedPluginProvider: () => EmbedPluginProvider,
32
- RefreshPayloadProvider: () => RefreshPayloadProvider,
33
- ResolvePayloadContext: () => ResolvePayloadContext,
34
- ResolvePayloadProvider: () => ResolvePayloadProvider,
35
- ValidatePayloadProvider: () => ValidatePayloadProvider,
36
- useEmbedPluginState: () => useEmbedPluginState,
37
- useRefreshPayload: () => useRefreshPayload,
38
- useResolvePayload: () => useResolvePayload,
39
- useValidatePayload: () => useValidatePayload
40
- });
41
- module.exports = __toCommonJS(src_exports);
42
-
43
- // src/components/embed-card/card/BusyCard.tsx
44
- var import_material = require("@mui/material");
45
- var import_react_flexbox = require("@xylabs/react-flexbox");
46
- var import_react_shared = require("@xylabs/react-shared");
47
- var import_jsx_runtime = require("react/jsx-runtime");
48
- var BusyCard = ({
49
- busy,
50
- busyMinimum = 500,
51
- busyVariant = "circular",
52
- busyVariantProps,
53
- children,
54
- ...props
55
- }) => {
56
- const internalBusy = (0, import_react_flexbox.useBusyTiming)(busy, busyMinimum);
57
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.Card, { ...props, children: [
58
- children,
59
- busyVariant === "circular" && internalBusy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_shared.BusyCircularProgress, { ...busyVariantProps }) : null,
60
- busyVariant === "linear" && internalBusy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_shared.BusyLinearProgress, { ...busyVariantProps }) : null
61
- ] });
62
- };
63
-
64
- // src/components/embed-card/card/EmbedCardHeader.tsx
65
- var import_icons_material3 = require("@mui/icons-material");
66
- var import_material5 = require("@mui/material");
67
- var import_react_flexbox2 = require("@xylabs/react-flexbox");
68
-
69
- // src/contexts/EmbedPluginContext/Context.tsx
70
- var import_react_shared2 = require("@xyo-network/react-shared");
71
- var EmbedPluginContext = (0, import_react_shared2.createContextEx)();
72
-
73
- // src/contexts/EmbedPluginContext/Provider.tsx
74
- var import_react = require("react");
75
- var import_jsx_runtime2 = require("react/jsx-runtime");
76
- var EmbedPluginProvider = ({
77
- children,
78
- refreshTitle,
79
- timestampLabel,
80
- hideElementsConfig,
81
- plugins,
82
- embedPluginConfig
83
- }) => {
84
- const [activePlugin, setActivePlugin] = (0, import_react.useState)(plugins ? plugins[0] : void 0);
85
- (0, import_react.useEffect)(() => {
86
- setActivePlugin(plugins ? plugins[0] : void 0);
87
- }, [plugins]);
88
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
89
- EmbedPluginContext.Provider,
90
- {
91
- value: {
92
- activePlugin,
93
- embedPluginConfig,
94
- hideElementsConfig,
95
- provided: true,
96
- refreshTitle,
97
- setActivePlugin,
98
- timestampLabel
99
- },
100
- children
101
- }
102
- );
103
- };
104
-
105
- // src/contexts/EmbedPluginContext/use.tsx
106
- var import_react_shared3 = require("@xyo-network/react-shared");
107
- var useEmbedPluginState = () => (0, import_react_shared3.useContextEx)(EmbedPluginContext, "EmbedPlugin", true);
108
-
109
- // src/contexts/RefreshPayloadContext/Provider.tsx
110
- var import_react2 = require("react");
111
-
112
- // src/contexts/RefreshPayloadContext/Context.tsx
113
- var import_react_shared4 = require("@xyo-network/react-shared");
114
- var RefreshPayloadContext = (0, import_react_shared4.createContextEx)();
115
-
116
- // src/contexts/RefreshPayloadContext/Provider.tsx
117
- var import_jsx_runtime3 = require("react/jsx-runtime");
118
- var RefreshPayloadProvider = ({ children, onRefresh, refreshPayload }) => {
119
- const [localRefreshPayload, setRefreshPayload] = (0, import_react2.useState)(refreshPayload);
120
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RefreshPayloadContext.Provider, { value: { onRefresh, provided: true, refreshPayload: localRefreshPayload, setRefreshPayload }, children });
121
- };
122
-
123
- // src/contexts/RefreshPayloadContext/use.tsx
124
- var import_react_shared5 = require("@xyo-network/react-shared");
125
- var useRefreshPayload = () => (0, import_react_shared5.useContextEx)(RefreshPayloadContext, "RefreshPayload", true);
126
-
127
- // src/contexts/ResolvePayloadContext/Context.ts
128
- var import_react_shared6 = require("@xyo-network/react-shared");
129
- var ResolvePayloadContext = (0, import_react_shared6.createContextEx)();
130
-
131
- // src/contexts/ResolvePayloadContext/Provider.tsx
132
- var import_delay = require("@xylabs/delay");
133
- var import_react_async_effect = require("@xylabs/react-async-effect");
134
- var import_huri = require("@xyo-network/huri");
135
- var import_payload_model = require("@xyo-network/payload-model");
136
- var import_react3 = require("react");
137
- var import_jsx_runtime4 = require("react/jsx-runtime");
138
- var ResolvePayloadProvider = ({ children, huriPayload }) => {
139
- const [payload, setPayload] = (0, import_react3.useState)();
140
- const [huri, setHuri] = (0, import_react3.useState)();
141
- const { refreshPayload, setRefreshPayload, onRefresh } = useRefreshPayload();
142
- (0, import_react3.useEffect)(() => {
143
- typeof huriPayload === "string" ? setHuri(huriPayload) : void 0;
144
- if (typeof huriPayload === "object") {
145
- setPayload(huriPayload);
146
- setRefreshPayload == null ? void 0 : setRefreshPayload(true);
147
- }
148
- }, [huriPayload, setRefreshPayload]);
149
- const [notFound, setNotFound] = (0, import_react3.useState)();
150
- const [huriError, setHuriError] = (0, import_react3.useState)();
151
- (0, import_react_async_effect.useAsyncEffect)(
152
- // eslint-disable-next-line react-hooks/exhaustive-deps
153
- async (mounted) => {
154
- if (huri && !refreshPayload) {
155
- try {
156
- const huriInstance = new import_huri.Huri(huri);
157
- const result = await huriInstance.fetch();
158
- await (0, import_delay.delay)(500);
159
- if (mounted()) {
160
- setNotFound(result === null);
161
- setPayload(result);
162
- setRefreshPayload == null ? void 0 : setRefreshPayload(true);
163
- }
164
- } catch (e) {
165
- const error = e;
166
- setHuriError({ message: error.message, schema: import_payload_model.ModuleErrorSchema, sources: [] });
167
- }
168
- }
169
- },
170
- [huri, payload, refreshPayload, setRefreshPayload]
171
- );
172
- const refreshHuri = () => {
173
- onRefresh == null ? void 0 : onRefresh();
174
- if (huri) {
175
- setRefreshPayload == null ? void 0 : setRefreshPayload(false);
176
- }
177
- };
178
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ResolvePayloadContext.Provider, { value: { huri, huriError, notFound, payload, provided: true, refreshHuri, setPayload }, children });
179
- };
180
-
181
- // src/contexts/ResolvePayloadContext/use.tsx
182
- var import_react_shared7 = require("@xyo-network/react-shared");
183
- var useResolvePayload = () => (0, import_react_shared7.useContextEx)(ResolvePayloadContext, "ResolvePayload", true);
184
-
185
- // src/contexts/ValidatePayloadContext/Provider.tsx
186
- var import_material2 = require("@mui/material");
187
- var import_react_async_effect2 = require("@xylabs/react-async-effect");
188
- var import_schema_cache = require("@xyo-network/schema-cache");
189
- var import_react4 = require("react");
190
-
191
- // src/contexts/ValidatePayloadContext/Context.ts
192
- var import_react_shared8 = require("@xyo-network/react-shared");
193
- var ValidatePayloadContext = (0, import_react_shared8.createContextEx)();
194
-
195
- // src/contexts/ValidatePayloadContext/Provider.tsx
196
- var import_jsx_runtime5 = require("react/jsx-runtime");
197
- var ValidatePayloadProvider = ({ children, enabled = false }) => {
198
- const { payload } = useResolvePayload();
199
- const [initialized, setInitialized] = (0, import_react4.useState)(false);
200
- const [valid, setValid] = (0, import_react4.useState)();
201
- (0, import_react_async_effect2.useAsyncEffect)(
202
- // eslint-disable-next-line react-hooks/exhaustive-deps
203
- async () => {
204
- if (payload && enabled) {
205
- await import_schema_cache.SchemaCache.instance.get(payload.schema);
206
- const possibleKnownSchema = payload.schema;
207
- if (import_schema_cache.SchemaCache.instance.validators[possibleKnownSchema]) {
208
- const validator = import_schema_cache.SchemaCache.instance.validators[possibleKnownSchema];
209
- setValid(validator == null ? void 0 : validator(payload));
210
- }
211
- setInitialized(true);
212
- }
213
- },
214
- [payload, enabled]
215
- );
216
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ValidatePayloadContext.Provider, { value: { enabled, provided: true, schema: payload == null ? void 0 : payload.schema, validPayload: valid }, children: enabled ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: initialized ? children : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_material2.Chip, { label: "Validating Payload..." }) }) : children });
217
- };
218
-
219
- // src/contexts/ValidatePayloadContext/use.tsx
220
- var import_react_shared9 = require("@xyo-network/react-shared");
221
- var useValidatePayload = () => (0, import_react_shared9.useContextEx)(ValidatePayloadContext, "ValidateSchema", true);
222
-
223
- // src/components/embed-card/menu/EmbedMenu.tsx
224
- var import_icons_material2 = require("@mui/icons-material");
225
- var import_material4 = require("@mui/material");
226
- var import_react5 = require("react");
227
-
228
- // src/components/embed-card/menu/JsonMenuItem.tsx
229
- var import_icons_material = require("@mui/icons-material");
230
- var import_material3 = require("@mui/material");
231
- var import_jsx_runtime6 = require("react/jsx-runtime");
232
- var JsonMenuItem = (props) => {
233
- const { huri } = useResolvePayload();
234
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: huri ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material3.MenuItem, { title: "Source Payload JSON", onClick: () => window.open(huri, "_blank"), ...props, children: [
235
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material3.ListItemText, { sx: { mr: 1 }, children: "JSON" }),
236
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material3.ListItemIcon, { sx: { justifyContent: "end" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons_material.OpenInNew, { fontSize: "small" }) })
237
- ] }) : null });
238
- };
239
-
240
- // src/components/embed-card/menu/EmbedMenu.tsx
241
- var import_jsx_runtime7 = require("react/jsx-runtime");
242
- var EmbedMenu = (props) => {
243
- const [anchorEl, setAnchorEl] = (0, import_react5.useState)(null);
244
- const open = Boolean(anchorEl);
245
- const handleClick = (event) => {
246
- setAnchorEl(event.currentTarget);
247
- };
248
- const handleClose = () => {
249
- setAnchorEl(null);
250
- };
251
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
252
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_material4.IconButton, { onClick: handleClick, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons_material2.MoreVert, {}) }),
253
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_material4.Menu, { anchorEl, open, onClose: handleClose, PaperProps: { variant: "elevation" }, MenuListProps: { dense: true }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(JsonMenuItem, {}) })
254
- ] });
255
- };
256
-
257
- // src/components/embed-card/card/EmbedCardHeader.tsx
258
- var import_jsx_runtime8 = require("react/jsx-runtime");
259
- var EmbedCardHeader = () => {
260
- var _a;
261
- const { refreshHuri, huri } = useResolvePayload();
262
- const { activePlugin, timestampLabel, hideElementsConfig } = useEmbedPluginState();
263
- const { hideAvatar, hideTitle, hideRefreshButton, hideTimestamp, hideCardActions } = hideElementsConfig ?? {};
264
- const timestamp = Date.now();
265
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
266
- import_material5.CardHeader,
267
- {
268
- sx: { flexWrap: "wrap", rowGap: 1 },
269
- avatar: hideAvatar ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material5.Avatar, { sx: { bgcolor: (theme) => theme.palette.primary.main }, "aria-label": activePlugin == null ? void 0 : activePlugin.name, children: (_a = activePlugin == null ? void 0 : activePlugin.name) == null ? void 0 : _a.charAt(0) }),
270
- action: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_flexbox2.FlexRow, { flexWrap: "wrap", columnGap: 0.5, children: [
271
- timestamp ? hideTimestamp && hideRefreshButton ? "" : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
272
- import_material5.Chip,
273
- {
274
- avatar: hideRefreshButton ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons_material3.Refresh, {}),
275
- clickable: hideRefreshButton ? false : true,
276
- onClick: refreshHuri,
277
- label: hideTimestamp ? "" : `${timestampLabel} ${new Date(timestamp).toLocaleString()}`
278
- }
279
- ) : null,
280
- hideCardActions || huri === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(EmbedMenu, {})
281
- ] }),
282
- title: hideTitle ? "" : activePlugin == null ? void 0 : activePlugin.name
283
- }
284
- );
285
- };
286
-
287
- // src/components/embed-card/card/EmbedPluginCard.tsx
288
- var import_material9 = require("@mui/material");
289
- var import_react_flexbox3 = require("@xylabs/react-flexbox");
290
- var import_react_shared11 = require("@xyo-network/react-shared");
291
-
292
- // src/components/controls/EmbedFormControl.tsx
293
- var import_material6 = require("@mui/material");
294
- var import_jsx_runtime9 = require("react/jsx-runtime");
295
- var EmbedFormControl = ({ formId, formLabel, children, ...props }) => {
296
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_material6.FormControl, { ...props, children: [
297
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_material6.InputLabel, { id: formId, children: formLabel }),
298
- children
299
- ] });
300
- };
301
-
302
- // src/components/controls/ListModeSelect.tsx
303
- var import_material7 = require("@mui/material");
304
- var import_react_select = require("@xylabs/react-select");
305
- var import_react_shared10 = require("@xyo-network/react-shared");
306
- var import_jsx_runtime10 = require("react/jsx-runtime");
307
- var listModeSelectId = "listmode-select-id";
308
- var listModeSelectLabel = "List Mode";
309
- var ListModeSelect = (props) => {
310
- const { listMode, setListMode } = (0, import_react_shared10.useListMode)();
311
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
312
- import_react_select.SelectEx,
313
- {
314
- value: listMode ?? "default",
315
- onChange: (event) => {
316
- setListMode == null ? void 0 : setListMode(event.target.value);
317
- },
318
- ...props,
319
- children: [
320
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_material7.MenuItem, { value: "default", children: "Default" }, "default"),
321
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_material7.MenuItem, { value: "table", children: "Table" }, "table"),
322
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_material7.MenuItem, { value: "grid", children: "Grid" }, "grid")
323
- ]
324
- }
325
- );
326
- };
327
- var ListModeSelectFormControl = (props) => {
328
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(EmbedFormControl, { formId: listModeSelectId, formLabel: listModeSelectLabel, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ListModeSelect, { size: "small", label: listModeSelectLabel, labelId: listModeSelectId, ...props }) });
329
- };
330
-
331
- // src/components/controls/RenderSelect.tsx
332
- var import_material8 = require("@mui/material");
333
- var import_react_select2 = require("@xylabs/react-select");
334
- var import_jsx_runtime11 = require("react/jsx-runtime");
335
- var renderSelectId = "render-select-id";
336
- var renderSelectLabel = "Renderer";
337
- var EmbedRenderSelect = (props) => {
338
- const { activePlugin, setActivePlugin, plugins } = useEmbedPluginState();
339
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(EmbedFormControl, { formId: renderSelectId, formLabel: renderSelectLabel, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_select2.SelectEx, { size: "small", value: activePlugin == null ? void 0 : activePlugin.name, ...props, children: plugins == null ? void 0 : plugins.map((plugin) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_material8.MenuItem, { value: plugin.name, onClick: () => setActivePlugin == null ? void 0 : setActivePlugin(plugin), children: plugin.name }, plugin.name)) }) });
340
- };
341
-
342
- // src/components/embed-card/card/EmbedPluginCard.tsx
343
- var import_jsx_runtime12 = require("react/jsx-runtime");
344
- var EmbedPluginCard = ({ ...props }) => {
345
- var _a, _b, _c;
346
- const { payload } = useResolvePayload();
347
- const { activePlugin: ActivePlugin, plugins, hideElementsConfig } = useEmbedPluginState();
348
- const { listMode } = (0, import_react_shared11.useListMode)();
349
- const supportsListMode = ((_c = (_b = (_a = ActivePlugin == null ? void 0 : ActivePlugin.components) == null ? void 0 : _a.box) == null ? void 0 : _b.listModes) == null ? void 0 : _c.length) ?? 0 > 1;
350
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(BusyCard, { ...props, children: [
351
- (hideElementsConfig == null ? void 0 : hideElementsConfig.hideCardHeader) ? null : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(EmbedCardHeader, {}),
352
- plugins && plugins.length > 0 || supportsListMode ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_flexbox3.FlexGrowRow, { columnGap: 2, rowGap: 2, flexWrap: "wrap", pb: 1, children: [
353
- plugins && plugins.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(EmbedRenderSelect, {}) : null,
354
- supportsListMode ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ListModeSelectFormControl, {}) : null
355
- ] }) : null,
356
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_material9.CardContent, { sx: { height: "100%" }, children: ActivePlugin ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ActivePlugin.components.box.detailsBox, { payload, ...supportsListMode && { listMode } }) : null })
357
- ] });
358
- };
359
-
360
- // src/components/embed-card/EmbedPluginCard.tsx
361
- var import_material13 = require("@mui/material");
362
-
363
- // src/components/EmbedPlugin.tsx
364
- var import_react_shared13 = require("@xyo-network/react-shared");
365
-
366
- // src/components/EmbedResolver.tsx
367
- var import_react_shared12 = require("@xyo-network/react-shared");
368
- var import_jsx_runtime13 = require("react/jsx-runtime");
369
- var EmbedResolver = ({ children }) => {
370
- const { payload, notFound, huriError } = useResolvePayload();
371
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_shared12.LoadResult, { searchResult: payload, notFound: !!notFound, error: !!huriError, children });
372
- };
373
-
374
- // src/components/validation-alerts/ValidatePayload.tsx
375
- var import_material10 = require("@mui/material");
376
- var import_jsx_runtime14 = require("react/jsx-runtime");
377
- var ValidatePayloadAlert = ({ children, ...props }) => {
378
- const { validPayload, enabled, schema } = useValidatePayload();
379
- if (enabled && validPayload === false) {
380
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material10.Alert, { severity: "error", title: "Invalid Payload!", ...props, children: [
381
- "Payload schema claimed to be ",
382
- schema,
383
- " but failed to validate."
384
- ] });
385
- }
386
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children });
387
- };
388
-
389
- // src/components/validation-alerts/ValidatePlugins.tsx
390
- var import_material11 = require("@mui/material");
391
- var import_jsx_runtime15 = require("react/jsx-runtime");
392
- var ValidatePluginsAlert = ({ children, ...props }) => {
393
- const { payload } = useResolvePayload();
394
- const { plugins } = useEmbedPluginState();
395
- if (payload && (plugins == null ? void 0 : plugins.length) === 0) {
396
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_material11.Alert, { severity: "warning", ...props, children: [
397
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_material11.AlertTitle, { children: "Missing plugins!" }),
398
- "Payload found but no plugins were present."
399
- ] });
400
- }
401
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children });
402
- };
403
-
404
- // src/components/EmbedPlugin.tsx
405
- var import_jsx_runtime16 = require("react/jsx-runtime");
406
- var EmbedPluginInner = ({
407
- validateSchema,
408
- plugins = [],
409
- huriPayload,
410
- refreshTitle = "",
411
- timestampLabel = "Data From",
412
- hideElementsConfig,
413
- embedPluginConfig,
414
- onRefresh,
415
- children
416
- }) => {
417
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_shared13.ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
418
- EmbedPluginProvider,
419
- {
420
- refreshTitle,
421
- timestampLabel,
422
- hideElementsConfig,
423
- plugins,
424
- embedPluginConfig,
425
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(WithResolvers, { onRefresh, huriPayload, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(WithValidators, { validateSchema, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_shared13.ListModeProvider, { defaultListMode: embedPluginConfig == null ? void 0 : embedPluginConfig.listMode, children }) }) })
426
- }
427
- ) });
428
- };
429
- var WithResolvers = ({ children, onRefresh, huriPayload }) => {
430
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(RefreshPayloadProvider, { onRefresh, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ResolvePayloadProvider, { huriPayload, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(EmbedResolver, { children }) }) });
431
- };
432
- var WithValidators = ({ children, validateSchema }) => {
433
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ValidatePayloadProvider, { enabled: validateSchema, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ValidatePluginsAlert, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ValidatePayloadAlert, { children }) }) });
434
- };
435
-
436
- // src/components/embed-card/error-handling/EmbedCardApiErrorRenderer.tsx
437
- var import_react_error = require("@xyo-network/react-error");
438
-
439
- // src/components/embed-card/error-handling/EmbedErrorCard.tsx
440
- var import_material12 = require("@mui/material");
441
- var import_jsx_runtime17 = require("react/jsx-runtime");
442
- var EmbedErrorCard = (props) => {
443
- const { alertProps, error, hideErrorDetails = true, children, ...cardProps } = props;
444
- const errorProps = { alertProps, error, hideErrorDetails };
445
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material12.Card, { ...cardProps, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material12.CardContent, { children: children ?? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(DefaultErrorAlert, { ...errorProps }) }) });
446
- };
447
- var DefaultErrorAlert = ({ alertProps, hideErrorDetails, error }) => {
448
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_material12.Alert, { severity: "error", ...alertProps, children: [
449
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material12.AlertTitle, { children: "Whoops! Something went wrong" }),
450
- !hideErrorDetails && error ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
451
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material12.Typography, { variant: "caption", children: "Error: " }),
452
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material12.Typography, { variant: "caption", children: error == null ? void 0 : error.message })
453
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material12.Typography, { variant: "caption", fontSize: "small", children: "Error Loading Plugin" })
454
- ] });
455
- };
456
-
457
- // src/components/embed-card/error-handling/EmbedCardApiErrorRenderer.tsx
458
- var import_jsx_runtime18 = require("react/jsx-runtime");
459
- var EmbedCardApiErrorRenderer = ({ xyoError, children, ...props }) => {
460
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_error.ErrorRender, { error: xyoError, noReAuth: true, noErrorDisplay: true, customError: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CustomApiErrorCard, { xyoError, ...props }), children });
461
- };
462
- var CustomApiErrorCard = ({ xyoError, ...props }) => {
463
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(EmbedErrorCard, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_error.ErrorAlert, { error: xyoError }) });
464
- };
465
-
466
- // src/components/embed-card/EmbedPluginCard.tsx
467
- var import_jsx_runtime19 = require("react/jsx-runtime");
468
- var ApiEmbedPluginCard = ({ children, ...props }) => {
469
- const {
470
- validateSchema,
471
- plugins = [],
472
- huriPayload,
473
- refreshTitle = "",
474
- timestampLabel = "Data From",
475
- hideElementsConfig,
476
- embedPluginConfig,
477
- onRefresh,
478
- ...busyCardProps
479
- } = props;
480
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
481
- EmbedPluginInner,
482
- {
483
- ...{
484
- embedPluginConfig,
485
- hideElementsConfig,
486
- huriPayload,
487
- onRefresh,
488
- plugins,
489
- refreshTitle,
490
- timestampLabel,
491
- validateSchema
492
- },
493
- children: [
494
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EmbedPluginCardInner, { ...busyCardProps }),
495
- children
496
- ]
497
- }
498
- );
499
- };
500
- var EmbedPluginCardInner = (props) => {
501
- const { payload, huriError } = useResolvePayload();
502
- const { refreshPayload } = useRefreshPayload();
503
- const theme = (0, import_material13.useTheme)();
504
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EmbedCardApiErrorRenderer, { xyoError: huriError, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
505
- EmbedPluginCard,
506
- {
507
- elevation: 3,
508
- variant: "elevation",
509
- busy: Boolean(!refreshPayload && payload),
510
- busyVariantProps: { style: { alignItems: "start", paddingTop: theme.spacing(2), zIndex: 2 } },
511
- sx: { position: "relative" },
512
- ...props
513
- }
514
- ) });
515
- };
516
- // Annotate the CommonJS export names for ESM import in node:
517
- 0 && (module.exports = {
518
- ApiEmbedPluginCard,
519
- BusyCard,
520
- EmbedCardHeader,
521
- EmbedPlugin,
522
- EmbedPluginCard,
523
- EmbedPluginCardInner,
524
- EmbedPluginContext,
525
- EmbedPluginInner,
526
- EmbedPluginProvider,
527
- RefreshPayloadProvider,
528
- ResolvePayloadContext,
529
- ResolvePayloadProvider,
530
- ValidatePayloadProvider,
531
- useEmbedPluginState,
532
- useRefreshPayload,
533
- useResolvePayload,
534
- useValidatePayload
535
- });
1
+ "use strict";var Y=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ne=Object.prototype.hasOwnProperty;var ie=(o,e)=>{for(var r in e)Y(o,r,{get:e[r],enumerable:!0})},se=(o,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of le(e))!ne.call(o,a)&&a!==r&&Y(o,a,{get:()=>e[a],enumerable:!(t=ae(e,a))||t.enumerable});return o};var de=o=>se(Y({},"__esModule",{value:!0}),o);var Ee={};ie(Ee,{ApiEmbedPluginCard:()=>he,BusyCard:()=>Z,EmbedCardHeader:()=>lr,EmbedPlugin:()=>K,EmbedPluginCard:()=>K,EmbedPluginCardInner:()=>ee,EmbedPluginContext:()=>A,EmbedPluginInner:()=>nr,EmbedPluginProvider:()=>j,RefreshPayloadProvider:()=>rr,ResolvePayloadContext:()=>L,ResolvePayloadProvider:()=>er,ValidatePayloadProvider:()=>tr,useEmbedPluginState:()=>c,useRefreshPayload:()=>B,useResolvePayload:()=>d,useValidatePayload:()=>ar});module.exports=de(Ee);var sr=require("@mui/material"),dr=require("@xylabs/react-flexbox"),w=require("@xylabs/react-shared"),I=require("react/jsx-runtime"),Z=({busy:o,busyMinimum:e=500,busyVariant:r="circular",busyVariantProps:t,children:a,...i})=>{let n=(0,dr.useBusyTiming)(o,e);return(0,I.jsxs)(sr.Card,{...i,children:[a,r==="circular"&&n?(0,I.jsx)(w.BusyCircularProgress,{...t}):null,r==="linear"&&n?(0,I.jsx)(w.BusyLinearProgress,{...t}):null]})};var Vr=require("@mui/icons-material"),S=require("@mui/material"),wr=require("@xylabs/react-flexbox");var mr=require("@xyo-network/react-shared"),A=(0,mr.createContextEx)();var T=require("react");var pr=require("react/jsx-runtime"),j=({children:o,refreshTitle:e,timestampLabel:r,hideElementsConfig:t,plugins:a,embedPluginConfig:i})=>{let[n,l]=(0,T.useState)(a?a[0]:void 0);return(0,T.useEffect)(()=>{l(a?a[0]:void 0)},[a]),(0,pr.jsx)(A.Provider,{value:{activePlugin:n,embedPluginConfig:i,hideElementsConfig:t,provided:!0,refreshTitle:e,setActivePlugin:l,timestampLabel:r},children:o})};var ur=require("@xyo-network/react-shared");var c=()=>(0,ur.useContextEx)(A,"EmbedPlugin",!0);var cr=require("react");var Pr=require("@xyo-network/react-shared"),k=(0,Pr.createContextEx)();var fr=require("react/jsx-runtime"),rr=({children:o,onRefresh:e,refreshPayload:r})=>{let[t,a]=(0,cr.useState)(r);return(0,fr.jsx)(k.Provider,{value:{onRefresh:e,provided:!0,refreshPayload:t,setRefreshPayload:a},children:o})};var Cr=require("@xyo-network/react-shared");var B=()=>(0,Cr.useContextEx)(k,"RefreshPayload",!0);var hr=require("@xyo-network/react-shared"),L=(0,hr.createContextEx)();var Er=require("@xylabs/delay"),yr=require("@xylabs/react-async-effect"),br=require("@xyo-network/huri"),vr=require("@xyo-network/payload-model"),b=require("react");var Rr=require("react/jsx-runtime"),er=({children:o,huriPayload:e})=>{let[r,t]=(0,b.useState)(),[a,i]=(0,b.useState)(),{refreshPayload:n,setRefreshPayload:l,onRefresh:s}=B();(0,b.useEffect)(()=>{typeof e=="string"&&i(e),typeof e=="object"&&(t(e),l==null||l(!0))},[e,l]);let[E,R]=(0,b.useState)(),[V,U]=(0,b.useState)();(0,yr.useAsyncEffect)(async te=>{if(a&&!n)try{let X=await new br.Huri(a).fetch();await(0,Er.delay)(500),te()&&(R(X===null),t(X),l==null||l(!0))}catch(ir){U({message:ir.message,schema:vr.ModuleErrorSchema,sources:[]})}},[a,r,n,l]);let oe=()=>{s==null||s(),a&&(l==null||l(!1))};return(0,Rr.jsx)(L.Provider,{value:{huri:a,huriError:V,notFound:E,payload:r,provided:!0,refreshHuri:oe,setPayload:t},children:o})};var xr=require("@xyo-network/react-shared");var d=()=>(0,xr.useContextEx)(L,"ResolvePayload",!0);var Sr=require("@mui/material"),Mr=require("@xylabs/react-async-effect"),D=require("@xyo-network/schema-cache"),or=require("react");var gr=require("@xyo-network/react-shared"),H=(0,gr.createContextEx)();var x=require("react/jsx-runtime"),tr=({children:o,enabled:e=!1})=>{let{payload:r}=d(),[t,a]=(0,or.useState)(!1),[i,n]=(0,or.useState)();return(0,Mr.useAsyncEffect)(async()=>{if(r&&e){await D.SchemaCache.instance.get(r.schema);let l=r.schema;if(D.SchemaCache.instance.validators[l]){let s=D.SchemaCache.instance.validators[l];n(s==null?void 0:s(r))}a(!0)}},[r,e]),(0,x.jsx)(H.Provider,{value:{enabled:e,provided:!0,schema:r==null?void 0:r.schema,validPayload:i},children:e?(0,x.jsx)(x.Fragment,{children:t?o:(0,x.jsx)(Sr.Chip,{label:"Validating Payload..."})}):o})};var Fr=require("@xyo-network/react-shared");var ar=()=>(0,Fr.useContextEx)(H,"ValidateSchema",!0);var Br=require("@mui/icons-material"),z=require("@mui/material"),Lr=require("react");var Ir=require("@mui/icons-material"),g=require("@mui/material");var f=require("react/jsx-runtime"),Ar=o=>{let{huri:e}=d();return(0,f.jsx)(f.Fragment,{children:e?(0,f.jsxs)(g.MenuItem,{title:"Source Payload JSON",onClick:()=>window.open(e,"_blank"),...o,children:[(0,f.jsx)(g.ListItemText,{sx:{mr:1},children:"JSON"}),(0,f.jsx)(g.ListItemIcon,{sx:{justifyContent:"end"},children:(0,f.jsx)(Ir.OpenInNew,{fontSize:"small"})})]}):null})};var C=require("react/jsx-runtime"),Wr=o=>{let[e,r]=(0,Lr.useState)(null),t=!!e,a=n=>{r(n.currentTarget)},i=()=>{r(null)};return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(z.IconButton,{onClick:a,...o,children:(0,C.jsx)(Br.MoreVert,{})}),(0,C.jsx)(z.Menu,{anchorEl:e,open:t,onClose:i,PaperProps:{variant:"elevation"},MenuListProps:{dense:!0},children:(0,C.jsx)(Ar,{})})]})};var m=require("react/jsx-runtime"),lr=()=>{var V;let{refreshHuri:o,huri:e}=d(),{activePlugin:r,timestampLabel:t,hideElementsConfig:a}=c(),{hideAvatar:i,hideTitle:n,hideRefreshButton:l,hideTimestamp:s,hideCardActions:E}=a??{},R=Date.now();return(0,m.jsx)(S.CardHeader,{sx:{flexWrap:"wrap",rowGap:1},avatar:i?(0,m.jsx)(m.Fragment,{}):(0,m.jsx)(S.Avatar,{sx:{bgcolor:U=>U.palette.primary.main},"aria-label":r==null?void 0:r.name,children:(V=r==null?void 0:r.name)==null?void 0:V.charAt(0)}),action:(0,m.jsxs)(wr.FlexRow,{flexWrap:"wrap",columnGap:.5,children:[R?s&&l?"":(0,m.jsx)(S.Chip,{avatar:l?(0,m.jsx)(m.Fragment,{}):(0,m.jsx)(Vr.Refresh,{}),clickable:!l,onClick:o,label:s?"":`${t} ${new Date(R).toLocaleString()}`}):null,E||e===void 0?null:(0,m.jsx)(Wr,{})]}),title:n?"":r==null?void 0:r.name})};var Jr=require("@mui/material"),$r=require("@xylabs/react-flexbox"),Kr=require("@xyo-network/react-shared");var G=require("@mui/material"),O=require("react/jsx-runtime"),N=({formId:o,formLabel:e,children:r,...t})=>(0,O.jsxs)(G.FormControl,{...t,children:[(0,O.jsx)(G.InputLabel,{id:o,children:e}),r]});var J=require("@mui/material"),Hr=require("@xylabs/react-select"),Dr=require("@xyo-network/react-shared");var y=require("react/jsx-runtime"),Tr="listmode-select-id",kr="List Mode",me=o=>{let{listMode:e,setListMode:r}=(0,Dr.useListMode)();return(0,y.jsxs)(Hr.SelectEx,{value:e??"default",onChange:t=>{r==null||r(t.target.value)},...o,children:[(0,y.jsx)(J.MenuItem,{value:"default",children:"Default"},"default"),(0,y.jsx)(J.MenuItem,{value:"table",children:"Table"},"table"),(0,y.jsx)(J.MenuItem,{value:"grid",children:"Grid"},"grid")]})},zr=o=>(0,y.jsx)(N,{formId:Tr,formLabel:kr,children:(0,y.jsx)(me,{size:"small",label:kr,labelId:Tr,...o})});var Gr=require("@mui/material"),Nr=require("@xylabs/react-select");var $=require("react/jsx-runtime"),pe="render-select-id",ue="Renderer",Or=o=>{let{activePlugin:e,setActivePlugin:r,plugins:t}=c();return(0,$.jsx)(N,{formId:pe,formLabel:ue,children:(0,$.jsx)(Nr.SelectEx,{size:"small",value:e==null?void 0:e.name,...o,children:t==null?void 0:t.map(a=>(0,$.jsx)(Gr.MenuItem,{value:a.name,onClick:()=>r==null?void 0:r(a),children:a.name},a.name))})})};var h=require("react/jsx-runtime"),K=({...o})=>{var l,s,E;let{payload:e}=d(),{activePlugin:r,plugins:t,hideElementsConfig:a}=c(),{listMode:i}=(0,Kr.useListMode)(),n=((E=(s=(l=r==null?void 0:r.components)==null?void 0:l.box)==null?void 0:s.listModes)==null?void 0:E.length)??!1;return(0,h.jsxs)(Z,{...o,children:[a!=null&&a.hideCardHeader?null:(0,h.jsx)(lr,{}),t&&t.length>0||n?(0,h.jsxs)($r.FlexGrowRow,{columnGap:2,rowGap:2,flexWrap:"wrap",pb:1,children:[t&&t.length>1?(0,h.jsx)(Or,{}):null,n?(0,h.jsx)(zr,{}):null]}):null,(0,h.jsx)(Jr.CardContent,{sx:{height:"100%"},children:r?(0,h.jsx)(r.components.box.detailsBox,{payload:e,...n&&{listMode:i}}):null})]})};var re=require("@mui/material");var q=require("@xyo-network/react-shared");var _r=require("@xyo-network/react-shared");var Qr=require("react/jsx-runtime"),qr=({children:o})=>{let{payload:e,notFound:r,huriError:t}=d();return(0,Qr.jsx)(_r.LoadResult,{searchResult:e,notFound:!!r,error:!!t,children:o})};var Ur=require("@mui/material");var M=require("react/jsx-runtime"),Xr=({children:o,...e})=>{let{validPayload:r,enabled:t,schema:a}=ar();return t&&r===!1?(0,M.jsxs)(Ur.Alert,{severity:"error",title:"Invalid Payload!",...e,children:["Payload schema claimed to be ",a," but failed to validate."]}):(0,M.jsx)(M.Fragment,{children:o})};var _=require("@mui/material");var v=require("react/jsx-runtime"),Yr=({children:o,...e})=>{let{payload:r}=d(),{plugins:t}=c();return r&&(t==null?void 0:t.length)===0?(0,v.jsxs)(_.Alert,{severity:"warning",...e,children:[(0,v.jsx)(_.AlertTitle,{children:"Missing plugins!"}),"Payload found but no plugins were present."]}):(0,v.jsx)(v.Fragment,{children:o})};var u=require("react/jsx-runtime"),nr=({validateSchema:o,plugins:e=[],huriPayload:r,refreshTitle:t="",timestampLabel:a="Data From",hideElementsConfig:i,embedPluginConfig:n,onRefresh:l,children:s})=>(0,u.jsx)(q.ErrorBoundary,{children:(0,u.jsx)(j,{refreshTitle:t,timestampLabel:a,hideElementsConfig:i,plugins:e,embedPluginConfig:n,children:(0,u.jsx)(Pe,{onRefresh:l,huriPayload:r,children:(0,u.jsx)(ce,{validateSchema:o,children:(0,u.jsx)(q.ListModeProvider,{defaultListMode:n==null?void 0:n.listMode,children:s})})})})}),Pe=({children:o,onRefresh:e,huriPayload:r})=>(0,u.jsx)(rr,{onRefresh:e,children:(0,u.jsx)(er,{huriPayload:r,children:(0,u.jsx)(qr,{children:o})})}),ce=({children:o,validateSchema:e})=>(0,u.jsx)(tr,{enabled:e,children:(0,u.jsx)(Yr,{children:(0,u.jsx)(Xr,{children:o})})});var Q=require("@xyo-network/react-error");var P=require("@mui/material"),p=require("react/jsx-runtime"),Zr=o=>{let{alertProps:e,error:r,hideErrorDetails:t=!0,children:a,...i}=o;return(0,p.jsx)(P.Card,{...i,children:(0,p.jsx)(P.CardContent,{children:a??(0,p.jsx)(fe,{...{alertProps:e,error:r,hideErrorDetails:t}})})})},fe=({alertProps:o,hideErrorDetails:e,error:r})=>(0,p.jsxs)(P.Alert,{severity:"error",...o,children:[(0,p.jsx)(P.AlertTitle,{children:"Whoops! Something went wrong"}),!e&&r?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(P.Typography,{variant:"caption",children:"Error: "}),(0,p.jsx)(P.Typography,{variant:"caption",children:r==null?void 0:r.message})]}):(0,p.jsx)(P.Typography,{variant:"caption",fontSize:"small",children:"Error Loading Plugin"})]});var W=require("react/jsx-runtime"),jr=({xyoError:o,children:e,...r})=>(0,W.jsx)(Q.ErrorRender,{error:o,noReAuth:!0,noErrorDisplay:!0,customError:(0,W.jsx)(Ce,{xyoError:o,...r}),children:e}),Ce=({xyoError:o,...e})=>(0,W.jsx)(Zr,{...e,children:(0,W.jsx)(Q.ErrorAlert,{error:o})});var F=require("react/jsx-runtime"),he=({children:o,...e})=>{let{validateSchema:r,plugins:t=[],huriPayload:a,refreshTitle:i="",timestampLabel:n="Data From",hideElementsConfig:l,embedPluginConfig:s,onRefresh:E,...R}=e;return(0,F.jsxs)(nr,{embedPluginConfig:s,hideElementsConfig:l,huriPayload:a,onRefresh:E,plugins:t,refreshTitle:i,timestampLabel:n,validateSchema:r,children:[(0,F.jsx)(ee,{...R}),o]})},ee=o=>{let{payload:e,huriError:r}=d(),{refreshPayload:t}=B(),a=(0,re.useTheme)();return(0,F.jsx)(jr,{xyoError:r,children:(0,F.jsx)(K,{elevation:3,variant:"elevation",busy:!!(!t&&e),busyVariantProps:{style:{alignItems:"start",paddingTop:a.spacing(2),zIndex:2}},sx:{position:"relative"},...o})})};0&&(module.exports={ApiEmbedPluginCard,BusyCard,EmbedCardHeader,EmbedPlugin,EmbedPluginCard,EmbedPluginCardInner,EmbedPluginContext,EmbedPluginInner,EmbedPluginProvider,RefreshPayloadProvider,ResolvePayloadContext,ResolvePayloadProvider,ValidatePayloadProvider,useEmbedPluginState,useRefreshPayload,useResolvePayload,useValidatePayload});
536
2
  //# sourceMappingURL=index.cjs.map