@xyo-network/react-embed 2.77.0 → 2.77.2

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 +8 -8
@@ -1,496 +1,2 @@
1
- // src/components/embed-card/card/BusyCard.tsx
2
- import { Card } from "@mui/material";
3
- import { useBusyTiming } from "@xylabs/react-flexbox";
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
- }) => {
17
- const internalBusy = useBusyTiming(busy, busyMinimum);
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
- };
24
-
25
- // src/components/embed-card/card/EmbedCardHeader.tsx
26
- import { Refresh as RefreshIcon } from "@mui/icons-material";
27
- import { Avatar, CardHeader, Chip as Chip2 } from "@mui/material";
28
- import { FlexRow } from "@xylabs/react-flexbox";
29
-
30
- // src/contexts/EmbedPluginContext/Context.tsx
31
- import { createContextEx } from "@xyo-network/react-shared";
32
- var EmbedPluginContext = createContextEx();
33
-
34
- // src/contexts/EmbedPluginContext/Provider.tsx
35
- import { useEffect, useState } from "react";
36
- import { jsx as jsx2 } from "react/jsx-runtime";
37
- var EmbedPluginProvider = ({
38
- children,
39
- refreshTitle,
40
- timestampLabel,
41
- hideElementsConfig,
42
- plugins,
43
- embedPluginConfig
44
- }) => {
45
- const [activePlugin, setActivePlugin] = useState(plugins ? plugins[0] : void 0);
46
- useEffect(() => {
47
- setActivePlugin(plugins ? plugins[0] : void 0);
48
- }, [plugins]);
49
- return /* @__PURE__ */ jsx2(
50
- EmbedPluginContext.Provider,
51
- {
52
- value: {
53
- activePlugin,
54
- embedPluginConfig,
55
- hideElementsConfig,
56
- provided: true,
57
- refreshTitle,
58
- setActivePlugin,
59
- timestampLabel
60
- },
61
- children
62
- }
63
- );
64
- };
65
-
66
- // src/contexts/EmbedPluginContext/use.tsx
67
- import { useContextEx } from "@xyo-network/react-shared";
68
- var useEmbedPluginState = () => useContextEx(EmbedPluginContext, "EmbedPlugin", true);
69
-
70
- // src/contexts/RefreshPayloadContext/Provider.tsx
71
- import { useState as useState2 } from "react";
72
-
73
- // src/contexts/RefreshPayloadContext/Context.tsx
74
- import { createContextEx as createContextEx2 } from "@xyo-network/react-shared";
75
- var RefreshPayloadContext = createContextEx2();
76
-
77
- // src/contexts/RefreshPayloadContext/Provider.tsx
78
- import { jsx as jsx3 } from "react/jsx-runtime";
79
- var RefreshPayloadProvider = ({ children, onRefresh, refreshPayload }) => {
80
- const [localRefreshPayload, setRefreshPayload] = useState2(refreshPayload);
81
- return /* @__PURE__ */ jsx3(RefreshPayloadContext.Provider, { value: { onRefresh, provided: true, refreshPayload: localRefreshPayload, setRefreshPayload }, children });
82
- };
83
-
84
- // src/contexts/RefreshPayloadContext/use.tsx
85
- import { useContextEx as useContextEx2 } from "@xyo-network/react-shared";
86
- var useRefreshPayload = () => useContextEx2(RefreshPayloadContext, "RefreshPayload", true);
87
-
88
- // src/contexts/ResolvePayloadContext/Context.ts
89
- import { createContextEx as createContextEx3 } from "@xyo-network/react-shared";
90
- var ResolvePayloadContext = createContextEx3();
91
-
92
- // src/contexts/ResolvePayloadContext/Provider.tsx
93
- import { delay } from "@xylabs/delay";
94
- import { useAsyncEffect } from "@xylabs/react-async-effect";
95
- import { Huri } from "@xyo-network/huri";
96
- import { ModuleErrorSchema } from "@xyo-network/payload-model";
97
- import { useEffect as useEffect2, useState as useState3 } from "react";
98
- import { jsx as jsx4 } from "react/jsx-runtime";
99
- var ResolvePayloadProvider = ({ children, huriPayload }) => {
100
- const [payload, setPayload] = useState3();
101
- const [huri, setHuri] = useState3();
102
- const { refreshPayload, setRefreshPayload, onRefresh } = useRefreshPayload();
103
- useEffect2(() => {
104
- typeof huriPayload === "string" ? setHuri(huriPayload) : void 0;
105
- if (typeof huriPayload === "object") {
106
- setPayload(huriPayload);
107
- setRefreshPayload == null ? void 0 : setRefreshPayload(true);
108
- }
109
- }, [huriPayload, setRefreshPayload]);
110
- const [notFound, setNotFound] = useState3();
111
- const [huriError, setHuriError] = useState3();
112
- useAsyncEffect(
113
- // eslint-disable-next-line react-hooks/exhaustive-deps
114
- async (mounted) => {
115
- if (huri && !refreshPayload) {
116
- try {
117
- const huriInstance = new Huri(huri);
118
- const result = await huriInstance.fetch();
119
- await delay(500);
120
- if (mounted()) {
121
- setNotFound(result === null);
122
- setPayload(result);
123
- setRefreshPayload == null ? void 0 : setRefreshPayload(true);
124
- }
125
- } catch (e) {
126
- const error = e;
127
- setHuriError({ message: error.message, schema: ModuleErrorSchema, sources: [] });
128
- }
129
- }
130
- },
131
- [huri, payload, refreshPayload, setRefreshPayload]
132
- );
133
- const refreshHuri = () => {
134
- onRefresh == null ? void 0 : onRefresh();
135
- if (huri) {
136
- setRefreshPayload == null ? void 0 : setRefreshPayload(false);
137
- }
138
- };
139
- return /* @__PURE__ */ jsx4(ResolvePayloadContext.Provider, { value: { huri, huriError, notFound, payload, provided: true, refreshHuri, setPayload }, children });
140
- };
141
-
142
- // src/contexts/ResolvePayloadContext/use.tsx
143
- import { useContextEx as useContextEx3 } from "@xyo-network/react-shared";
144
- var useResolvePayload = () => useContextEx3(ResolvePayloadContext, "ResolvePayload", true);
145
-
146
- // src/contexts/ValidatePayloadContext/Provider.tsx
147
- import { Chip } from "@mui/material";
148
- import { useAsyncEffect as useAsyncEffect2 } from "@xylabs/react-async-effect";
149
- import { SchemaCache } from "@xyo-network/schema-cache";
150
- import { useState as useState4 } from "react";
151
-
152
- // src/contexts/ValidatePayloadContext/Context.ts
153
- import { createContextEx as createContextEx4 } from "@xyo-network/react-shared";
154
- var ValidatePayloadContext = createContextEx4();
155
-
156
- // src/contexts/ValidatePayloadContext/Provider.tsx
157
- import { Fragment, jsx as jsx5 } from "react/jsx-runtime";
158
- var ValidatePayloadProvider = ({ children, enabled = false }) => {
159
- const { payload } = useResolvePayload();
160
- const [initialized, setInitialized] = useState4(false);
161
- const [valid, setValid] = useState4();
162
- useAsyncEffect2(
163
- // eslint-disable-next-line react-hooks/exhaustive-deps
164
- async () => {
165
- if (payload && enabled) {
166
- await SchemaCache.instance.get(payload.schema);
167
- const possibleKnownSchema = payload.schema;
168
- if (SchemaCache.instance.validators[possibleKnownSchema]) {
169
- const validator = SchemaCache.instance.validators[possibleKnownSchema];
170
- setValid(validator == null ? void 0 : validator(payload));
171
- }
172
- setInitialized(true);
173
- }
174
- },
175
- [payload, enabled]
176
- );
177
- return /* @__PURE__ */ jsx5(ValidatePayloadContext.Provider, { value: { enabled, provided: true, schema: payload == null ? void 0 : payload.schema, validPayload: valid }, children: enabled ? /* @__PURE__ */ jsx5(Fragment, { children: initialized ? children : /* @__PURE__ */ jsx5(Chip, { label: "Validating Payload..." }) }) : children });
178
- };
179
-
180
- // src/contexts/ValidatePayloadContext/use.tsx
181
- import { useContextEx as useContextEx4 } from "@xyo-network/react-shared";
182
- var useValidatePayload = () => useContextEx4(ValidatePayloadContext, "ValidateSchema", true);
183
-
184
- // src/components/embed-card/menu/EmbedMenu.tsx
185
- import { MoreVert as MoreVertIcon } from "@mui/icons-material";
186
- import { IconButton, Menu } from "@mui/material";
187
- import { useState as useState5 } from "react";
188
-
189
- // src/components/embed-card/menu/JsonMenuItem.tsx
190
- import { OpenInNew as OpenInNewIcon } from "@mui/icons-material";
191
- import { ListItemIcon, ListItemText, MenuItem } from "@mui/material";
192
- import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
193
- var JsonMenuItem = (props) => {
194
- const { huri } = useResolvePayload();
195
- return /* @__PURE__ */ jsx6(Fragment2, { children: huri ? /* @__PURE__ */ jsxs2(MenuItem, { title: "Source Payload JSON", onClick: () => window.open(huri, "_blank"), ...props, children: [
196
- /* @__PURE__ */ jsx6(ListItemText, { sx: { mr: 1 }, children: "JSON" }),
197
- /* @__PURE__ */ jsx6(ListItemIcon, { sx: { justifyContent: "end" }, children: /* @__PURE__ */ jsx6(OpenInNewIcon, { fontSize: "small" }) })
198
- ] }) : null });
199
- };
200
-
201
- // src/components/embed-card/menu/EmbedMenu.tsx
202
- import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
203
- var EmbedMenu = (props) => {
204
- const [anchorEl, setAnchorEl] = useState5(null);
205
- const open = Boolean(anchorEl);
206
- const handleClick = (event) => {
207
- setAnchorEl(event.currentTarget);
208
- };
209
- const handleClose = () => {
210
- setAnchorEl(null);
211
- };
212
- return /* @__PURE__ */ jsxs3(Fragment3, { children: [
213
- /* @__PURE__ */ jsx7(IconButton, { onClick: handleClick, ...props, children: /* @__PURE__ */ jsx7(MoreVertIcon, {}) }),
214
- /* @__PURE__ */ jsx7(Menu, { anchorEl, open, onClose: handleClose, PaperProps: { variant: "elevation" }, MenuListProps: { dense: true }, children: /* @__PURE__ */ jsx7(JsonMenuItem, {}) })
215
- ] });
216
- };
217
-
218
- // src/components/embed-card/card/EmbedCardHeader.tsx
219
- import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
220
- var EmbedCardHeader = () => {
221
- var _a;
222
- const { refreshHuri, huri } = useResolvePayload();
223
- const { activePlugin, timestampLabel, hideElementsConfig } = useEmbedPluginState();
224
- const { hideAvatar, hideTitle, hideRefreshButton, hideTimestamp, hideCardActions } = hideElementsConfig ?? {};
225
- const timestamp = Date.now();
226
- return /* @__PURE__ */ jsx8(
227
- CardHeader,
228
- {
229
- sx: { flexWrap: "wrap", rowGap: 1 },
230
- avatar: hideAvatar ? /* @__PURE__ */ jsx8(Fragment4, {}) : /* @__PURE__ */ jsx8(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) }),
231
- action: /* @__PURE__ */ jsxs4(FlexRow, { flexWrap: "wrap", columnGap: 0.5, children: [
232
- timestamp ? hideTimestamp && hideRefreshButton ? "" : /* @__PURE__ */ jsx8(
233
- Chip2,
234
- {
235
- avatar: hideRefreshButton ? /* @__PURE__ */ jsx8(Fragment4, {}) : /* @__PURE__ */ jsx8(RefreshIcon, {}),
236
- clickable: hideRefreshButton ? false : true,
237
- onClick: refreshHuri,
238
- label: hideTimestamp ? "" : `${timestampLabel} ${new Date(timestamp).toLocaleString()}`
239
- }
240
- ) : null,
241
- hideCardActions || huri === void 0 ? null : /* @__PURE__ */ jsx8(EmbedMenu, {})
242
- ] }),
243
- title: hideTitle ? "" : activePlugin == null ? void 0 : activePlugin.name
244
- }
245
- );
246
- };
247
-
248
- // src/components/embed-card/card/EmbedPluginCard.tsx
249
- import { CardContent } from "@mui/material";
250
- import { FlexGrowRow } from "@xylabs/react-flexbox";
251
- import { useListMode as useListMode2 } from "@xyo-network/react-shared";
252
-
253
- // src/components/controls/EmbedFormControl.tsx
254
- import { FormControl, InputLabel } from "@mui/material";
255
- import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
256
- var EmbedFormControl = ({ formId, formLabel, children, ...props }) => {
257
- return /* @__PURE__ */ jsxs5(FormControl, { ...props, children: [
258
- /* @__PURE__ */ jsx9(InputLabel, { id: formId, children: formLabel }),
259
- children
260
- ] });
261
- };
262
-
263
- // src/components/controls/ListModeSelect.tsx
264
- import { MenuItem as MenuItem2 } from "@mui/material";
265
- import { SelectEx } from "@xylabs/react-select";
266
- import { useListMode } from "@xyo-network/react-shared";
267
- import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
268
- var listModeSelectId = "listmode-select-id";
269
- var listModeSelectLabel = "List Mode";
270
- var ListModeSelect = (props) => {
271
- const { listMode, setListMode } = useListMode();
272
- return /* @__PURE__ */ jsxs6(
273
- SelectEx,
274
- {
275
- value: listMode ?? "default",
276
- onChange: (event) => {
277
- setListMode == null ? void 0 : setListMode(event.target.value);
278
- },
279
- ...props,
280
- children: [
281
- /* @__PURE__ */ jsx10(MenuItem2, { value: "default", children: "Default" }, "default"),
282
- /* @__PURE__ */ jsx10(MenuItem2, { value: "table", children: "Table" }, "table"),
283
- /* @__PURE__ */ jsx10(MenuItem2, { value: "grid", children: "Grid" }, "grid")
284
- ]
285
- }
286
- );
287
- };
288
- var ListModeSelectFormControl = (props) => {
289
- return /* @__PURE__ */ jsx10(EmbedFormControl, { formId: listModeSelectId, formLabel: listModeSelectLabel, children: /* @__PURE__ */ jsx10(ListModeSelect, { size: "small", label: listModeSelectLabel, labelId: listModeSelectId, ...props }) });
290
- };
291
-
292
- // src/components/controls/RenderSelect.tsx
293
- import { MenuItem as MenuItem3 } from "@mui/material";
294
- import { SelectEx as SelectEx2 } from "@xylabs/react-select";
295
- import { jsx as jsx11 } from "react/jsx-runtime";
296
- var renderSelectId = "render-select-id";
297
- var renderSelectLabel = "Renderer";
298
- var EmbedRenderSelect = (props) => {
299
- const { activePlugin, setActivePlugin, plugins } = useEmbedPluginState();
300
- return /* @__PURE__ */ jsx11(EmbedFormControl, { formId: renderSelectId, formLabel: renderSelectLabel, children: /* @__PURE__ */ jsx11(SelectEx2, { size: "small", value: activePlugin == null ? void 0 : activePlugin.name, ...props, children: plugins == null ? void 0 : plugins.map((plugin) => /* @__PURE__ */ jsx11(MenuItem3, { value: plugin.name, onClick: () => setActivePlugin == null ? void 0 : setActivePlugin(plugin), children: plugin.name }, plugin.name)) }) });
301
- };
302
-
303
- // src/components/embed-card/card/EmbedPluginCard.tsx
304
- import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
305
- var EmbedPluginCard = ({ ...props }) => {
306
- var _a, _b, _c;
307
- const { payload } = useResolvePayload();
308
- const { activePlugin: ActivePlugin, plugins, hideElementsConfig } = useEmbedPluginState();
309
- const { listMode } = useListMode2();
310
- 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;
311
- return /* @__PURE__ */ jsxs7(BusyCard, { ...props, children: [
312
- (hideElementsConfig == null ? void 0 : hideElementsConfig.hideCardHeader) ? null : /* @__PURE__ */ jsx12(EmbedCardHeader, {}),
313
- plugins && plugins.length > 0 || supportsListMode ? /* @__PURE__ */ jsxs7(FlexGrowRow, { columnGap: 2, rowGap: 2, flexWrap: "wrap", pb: 1, children: [
314
- plugins && plugins.length > 1 ? /* @__PURE__ */ jsx12(EmbedRenderSelect, {}) : null,
315
- supportsListMode ? /* @__PURE__ */ jsx12(ListModeSelectFormControl, {}) : null
316
- ] }) : null,
317
- /* @__PURE__ */ jsx12(CardContent, { sx: { height: "100%" }, children: ActivePlugin ? /* @__PURE__ */ jsx12(ActivePlugin.components.box.detailsBox, { payload, ...supportsListMode && { listMode } }) : null })
318
- ] });
319
- };
320
-
321
- // src/components/embed-card/EmbedPluginCard.tsx
322
- import { useTheme } from "@mui/material";
323
-
324
- // src/components/EmbedPlugin.tsx
325
- import { ErrorBoundary, ListModeProvider } from "@xyo-network/react-shared";
326
-
327
- // src/components/EmbedResolver.tsx
328
- import { LoadResult } from "@xyo-network/react-shared";
329
- import { jsx as jsx13 } from "react/jsx-runtime";
330
- var EmbedResolver = ({ children }) => {
331
- const { payload, notFound, huriError } = useResolvePayload();
332
- return /* @__PURE__ */ jsx13(LoadResult, { searchResult: payload, notFound: !!notFound, error: !!huriError, children });
333
- };
334
-
335
- // src/components/validation-alerts/ValidatePayload.tsx
336
- import { Alert } from "@mui/material";
337
- import { Fragment as Fragment5, jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
338
- var ValidatePayloadAlert = ({ children, ...props }) => {
339
- const { validPayload, enabled, schema } = useValidatePayload();
340
- if (enabled && validPayload === false) {
341
- return /* @__PURE__ */ jsxs8(Alert, { severity: "error", title: "Invalid Payload!", ...props, children: [
342
- "Payload schema claimed to be ",
343
- schema,
344
- " but failed to validate."
345
- ] });
346
- }
347
- return /* @__PURE__ */ jsx14(Fragment5, { children });
348
- };
349
-
350
- // src/components/validation-alerts/ValidatePlugins.tsx
351
- import { Alert as Alert2, AlertTitle } from "@mui/material";
352
- import { Fragment as Fragment6, jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
353
- var ValidatePluginsAlert = ({ children, ...props }) => {
354
- const { payload } = useResolvePayload();
355
- const { plugins } = useEmbedPluginState();
356
- if (payload && (plugins == null ? void 0 : plugins.length) === 0) {
357
- return /* @__PURE__ */ jsxs9(Alert2, { severity: "warning", ...props, children: [
358
- /* @__PURE__ */ jsx15(AlertTitle, { children: "Missing plugins!" }),
359
- "Payload found but no plugins were present."
360
- ] });
361
- }
362
- return /* @__PURE__ */ jsx15(Fragment6, { children });
363
- };
364
-
365
- // src/components/EmbedPlugin.tsx
366
- import { jsx as jsx16 } from "react/jsx-runtime";
367
- var EmbedPluginInner = ({
368
- validateSchema,
369
- plugins = [],
370
- huriPayload,
371
- refreshTitle = "",
372
- timestampLabel = "Data From",
373
- hideElementsConfig,
374
- embedPluginConfig,
375
- onRefresh,
376
- children
377
- }) => {
378
- return /* @__PURE__ */ jsx16(ErrorBoundary, { children: /* @__PURE__ */ jsx16(
379
- EmbedPluginProvider,
380
- {
381
- refreshTitle,
382
- timestampLabel,
383
- hideElementsConfig,
384
- plugins,
385
- embedPluginConfig,
386
- children: /* @__PURE__ */ jsx16(WithResolvers, { onRefresh, huriPayload, children: /* @__PURE__ */ jsx16(WithValidators, { validateSchema, children: /* @__PURE__ */ jsx16(ListModeProvider, { defaultListMode: embedPluginConfig == null ? void 0 : embedPluginConfig.listMode, children }) }) })
387
- }
388
- ) });
389
- };
390
- var WithResolvers = ({ children, onRefresh, huriPayload }) => {
391
- return /* @__PURE__ */ jsx16(RefreshPayloadProvider, { onRefresh, children: /* @__PURE__ */ jsx16(ResolvePayloadProvider, { huriPayload, children: /* @__PURE__ */ jsx16(EmbedResolver, { children }) }) });
392
- };
393
- var WithValidators = ({ children, validateSchema }) => {
394
- return /* @__PURE__ */ jsx16(ValidatePayloadProvider, { enabled: validateSchema, children: /* @__PURE__ */ jsx16(ValidatePluginsAlert, { children: /* @__PURE__ */ jsx16(ValidatePayloadAlert, { children }) }) });
395
- };
396
-
397
- // src/components/embed-card/error-handling/EmbedCardApiErrorRenderer.tsx
398
- import { ErrorAlert, ErrorRender } from "@xyo-network/react-error";
399
-
400
- // src/components/embed-card/error-handling/EmbedErrorCard.tsx
401
- import { Alert as Alert3, AlertTitle as AlertTitle2, Card as Card2, CardContent as CardContent2, Typography } from "@mui/material";
402
- import { Fragment as Fragment7, jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
403
- var EmbedErrorCard = (props) => {
404
- const { alertProps, error, hideErrorDetails = true, children, ...cardProps } = props;
405
- const errorProps = { alertProps, error, hideErrorDetails };
406
- return /* @__PURE__ */ jsx17(Card2, { ...cardProps, children: /* @__PURE__ */ jsx17(CardContent2, { children: children ?? /* @__PURE__ */ jsx17(DefaultErrorAlert, { ...errorProps }) }) });
407
- };
408
- var DefaultErrorAlert = ({ alertProps, hideErrorDetails, error }) => {
409
- return /* @__PURE__ */ jsxs10(Alert3, { severity: "error", ...alertProps, children: [
410
- /* @__PURE__ */ jsx17(AlertTitle2, { children: "Whoops! Something went wrong" }),
411
- !hideErrorDetails && error ? /* @__PURE__ */ jsxs10(Fragment7, { children: [
412
- /* @__PURE__ */ jsx17(Typography, { variant: "caption", children: "Error: " }),
413
- /* @__PURE__ */ jsx17(Typography, { variant: "caption", children: error == null ? void 0 : error.message })
414
- ] }) : /* @__PURE__ */ jsx17(Typography, { variant: "caption", fontSize: "small", children: "Error Loading Plugin" })
415
- ] });
416
- };
417
-
418
- // src/components/embed-card/error-handling/EmbedCardApiErrorRenderer.tsx
419
- import { jsx as jsx18 } from "react/jsx-runtime";
420
- var EmbedCardApiErrorRenderer = ({ xyoError, children, ...props }) => {
421
- return /* @__PURE__ */ jsx18(ErrorRender, { error: xyoError, noReAuth: true, noErrorDisplay: true, customError: /* @__PURE__ */ jsx18(CustomApiErrorCard, { xyoError, ...props }), children });
422
- };
423
- var CustomApiErrorCard = ({ xyoError, ...props }) => {
424
- return /* @__PURE__ */ jsx18(EmbedErrorCard, { ...props, children: /* @__PURE__ */ jsx18(ErrorAlert, { error: xyoError }) });
425
- };
426
-
427
- // src/components/embed-card/EmbedPluginCard.tsx
428
- import { jsx as jsx19, jsxs as jsxs11 } from "react/jsx-runtime";
429
- var ApiEmbedPluginCard = ({ children, ...props }) => {
430
- const {
431
- validateSchema,
432
- plugins = [],
433
- huriPayload,
434
- refreshTitle = "",
435
- timestampLabel = "Data From",
436
- hideElementsConfig,
437
- embedPluginConfig,
438
- onRefresh,
439
- ...busyCardProps
440
- } = props;
441
- return /* @__PURE__ */ jsxs11(
442
- EmbedPluginInner,
443
- {
444
- ...{
445
- embedPluginConfig,
446
- hideElementsConfig,
447
- huriPayload,
448
- onRefresh,
449
- plugins,
450
- refreshTitle,
451
- timestampLabel,
452
- validateSchema
453
- },
454
- children: [
455
- /* @__PURE__ */ jsx19(EmbedPluginCardInner, { ...busyCardProps }),
456
- children
457
- ]
458
- }
459
- );
460
- };
461
- var EmbedPluginCardInner = (props) => {
462
- const { payload, huriError } = useResolvePayload();
463
- const { refreshPayload } = useRefreshPayload();
464
- const theme = useTheme();
465
- return /* @__PURE__ */ jsx19(EmbedCardApiErrorRenderer, { xyoError: huriError, children: /* @__PURE__ */ jsx19(
466
- EmbedPluginCard,
467
- {
468
- elevation: 3,
469
- variant: "elevation",
470
- busy: Boolean(!refreshPayload && payload),
471
- busyVariantProps: { style: { alignItems: "start", paddingTop: theme.spacing(2), zIndex: 2 } },
472
- sx: { position: "relative" },
473
- ...props
474
- }
475
- ) });
476
- };
477
- export {
478
- ApiEmbedPluginCard,
479
- BusyCard,
480
- EmbedCardHeader,
481
- EmbedPluginCard as EmbedPlugin,
482
- EmbedPluginCard,
483
- EmbedPluginCardInner,
484
- EmbedPluginContext,
485
- EmbedPluginInner,
486
- EmbedPluginProvider,
487
- RefreshPayloadProvider,
488
- ResolvePayloadContext,
489
- ResolvePayloadProvider,
490
- ValidatePayloadProvider,
491
- useEmbedPluginState,
492
- useRefreshPayload,
493
- useResolvePayload,
494
- useValidatePayload
495
- };
1
+ import{Card as ur}from"@mui/material";import{useBusyTiming as Pr}from"@xylabs/react-flexbox";import{BusyCircularProgress as cr,BusyLinearProgress as fr}from"@xylabs/react-shared";import{jsx as z,jsxs as Cr}from"react/jsx-runtime";var G=({busy:o,busyMinimum:e=500,busyVariant:r="circular",busyVariantProps:t,children:a,...i})=>{let n=Pr(o,e);return Cr(ur,{...i,children:[a,r==="circular"&&n?z(cr,{...t}):null,r==="linear"&&n?z(fr,{...t}):null]})};import{Refresh as Yr}from"@mui/icons-material";import{Avatar as Zr,CardHeader as jr,Chip as re}from"@mui/material";import{FlexRow as ee}from"@xylabs/react-flexbox";import{createContextEx as hr}from"@xyo-network/react-shared";var y=hr();import{useEffect as Er,useState as yr}from"react";import{jsx as br}from"react/jsx-runtime";var N=({children:o,refreshTitle:e,timestampLabel:r,hideElementsConfig:t,plugins:a,embedPluginConfig:i})=>{let[n,l]=yr(a?a[0]:void 0);return Er(()=>{l(a?a[0]:void 0)},[a]),br(y.Provider,{value:{activePlugin:n,embedPluginConfig:i,hideElementsConfig:t,provided:!0,refreshTitle:e,setActivePlugin:l,timestampLabel:r},children:o})};import{useContextEx as vr}from"@xyo-network/react-shared";var u=()=>vr(y,"EmbedPlugin",!0);import{useState as xr}from"react";import{createContextEx as Rr}from"@xyo-network/react-shared";var b=Rr();import{jsx as gr}from"react/jsx-runtime";var O=({children:o,onRefresh:e,refreshPayload:r})=>{let[t,a]=xr(r);return gr(b.Provider,{value:{onRefresh:e,provided:!0,refreshPayload:t,setRefreshPayload:a},children:o})};import{useContextEx as Sr}from"@xyo-network/react-shared";var v=()=>Sr(b,"RefreshPayload",!0);import{createContextEx as Mr}from"@xyo-network/react-shared";var R=Mr();import{delay as Fr}from"@xylabs/delay";import{useAsyncEffect as Ir}from"@xylabs/react-async-effect";import{Huri as Ar}from"@xyo-network/huri";import{ModuleErrorSchema as Br}from"@xyo-network/payload-model";import{useEffect as Lr,useState as x}from"react";import{jsx as Wr}from"react/jsx-runtime";var J=({children:o,huriPayload:e})=>{let[r,t]=x(),[a,i]=x(),{refreshPayload:n,setRefreshPayload:l,onRefresh:s}=v();Lr(()=>{typeof e=="string"&&i(e),typeof e=="object"&&(t(e),l==null||l(!0))},[e,l]);let[p,f]=x(),[E,A]=x();Ir(async pr=>{if(a&&!n)try{let B=await new Ar(a).fetch();await Fr(500),pr()&&(f(B===null),t(B),l==null||l(!0))}catch(D){A({message:D.message,schema:Br,sources:[]})}},[a,r,n,l]);let mr=()=>{s==null||s(),a&&(l==null||l(!1))};return Wr(R.Provider,{value:{huri:a,huriError:E,notFound:p,payload:r,provided:!0,refreshHuri:mr,setPayload:t},children:o})};import{useContextEx as Vr}from"@xyo-network/react-shared";var d=()=>Vr(R,"ResolvePayload",!0);import{Chip as Tr}from"@mui/material";import{useAsyncEffect as kr}from"@xylabs/react-async-effect";import{SchemaCache as L}from"@xyo-network/schema-cache";import{useState as $}from"react";import{createContextEx as wr}from"@xyo-network/react-shared";var g=wr();import{Fragment as Hr,jsx as W}from"react/jsx-runtime";var K=({children:o,enabled:e=!1})=>{let{payload:r}=d(),[t,a]=$(!1),[i,n]=$();return kr(async()=>{if(r&&e){await L.instance.get(r.schema);let l=r.schema;if(L.instance.validators[l]){let s=L.instance.validators[l];n(s==null?void 0:s(r))}a(!0)}},[r,e]),W(g.Provider,{value:{enabled:e,provided:!0,schema:r==null?void 0:r.schema,validPayload:i},children:e?W(Hr,{children:t?o:W(Tr,{label:"Validating Payload..."})}):o})};import{useContextEx as Dr}from"@xyo-network/react-shared";var _=()=>Dr(g,"ValidateSchema",!0);import{MoreVert as Kr}from"@mui/icons-material";import{IconButton as _r,Menu as qr}from"@mui/material";import{useState as Qr}from"react";import{OpenInNew as zr}from"@mui/icons-material";import{ListItemIcon as Gr,ListItemText as Nr,MenuItem as Or}from"@mui/material";import{Fragment as $r,jsx as S,jsxs as Jr}from"react/jsx-runtime";var q=o=>{let{huri:e}=d();return S($r,{children:e?Jr(Or,{title:"Source Payload JSON",onClick:()=>window.open(e,"_blank"),...o,children:[S(Nr,{sx:{mr:1},children:"JSON"}),S(Gr,{sx:{justifyContent:"end"},children:S(zr,{fontSize:"small"})})]}):null})};import{Fragment as Ur,jsx as M,jsxs as Xr}from"react/jsx-runtime";var Q=o=>{let[e,r]=Qr(null),t=!!e,a=n=>{r(n.currentTarget)},i=()=>{r(null)};return Xr(Ur,{children:[M(_r,{onClick:a,...o,children:M(Kr,{})}),M(qr,{anchorEl:e,open:t,onClose:i,PaperProps:{variant:"elevation"},MenuListProps:{dense:!0},children:M(q,{})})]})};import{Fragment as U,jsx as P,jsxs as oe}from"react/jsx-runtime";var X=()=>{var E;let{refreshHuri:o,huri:e}=d(),{activePlugin:r,timestampLabel:t,hideElementsConfig:a}=u(),{hideAvatar:i,hideTitle:n,hideRefreshButton:l,hideTimestamp:s,hideCardActions:p}=a??{},f=Date.now();return P(jr,{sx:{flexWrap:"wrap",rowGap:1},avatar:i?P(U,{}):P(Zr,{sx:{bgcolor:A=>A.palette.primary.main},"aria-label":r==null?void 0:r.name,children:(E=r==null?void 0:r.name)==null?void 0:E.charAt(0)}),action:oe(ee,{flexWrap:"wrap",columnGap:.5,children:[f?s&&l?"":P(re,{avatar:l?P(U,{}):P(Yr,{}),clickable:!l,onClick:o,label:s?"":`${t} ${new Date(f).toLocaleString()}`}):null,p||e===void 0?null:P(Q,{})]}),title:n?"":r==null?void 0:r.name})};import{CardContent as fe}from"@mui/material";import{FlexGrowRow as Ce}from"@xylabs/react-flexbox";import{useListMode as he}from"@xyo-network/react-shared";import{FormControl as te,InputLabel as ae}from"@mui/material";import{jsx as le,jsxs as ne}from"react/jsx-runtime";var F=({formId:o,formLabel:e,children:r,...t})=>ne(te,{...t,children:[le(ae,{id:o,children:e}),r]});import{MenuItem as V}from"@mui/material";import{SelectEx as ie}from"@xylabs/react-select";import{useListMode as se}from"@xyo-network/react-shared";import{jsx as C,jsxs as me}from"react/jsx-runtime";var Y="listmode-select-id",Z="List Mode",de=o=>{let{listMode:e,setListMode:r}=se();return me(ie,{value:e??"default",onChange:t=>{r==null||r(t.target.value)},...o,children:[C(V,{value:"default",children:"Default"},"default"),C(V,{value:"table",children:"Table"},"table"),C(V,{value:"grid",children:"Grid"},"grid")]})},j=o=>C(F,{formId:Y,formLabel:Z,children:C(de,{size:"small",label:Z,labelId:Y,...o})});import{MenuItem as pe}from"@mui/material";import{SelectEx as ue}from"@xylabs/react-select";import{jsx as w}from"react/jsx-runtime";var Pe="render-select-id",ce="Renderer",rr=o=>{let{activePlugin:e,setActivePlugin:r,plugins:t}=u();return w(F,{formId:Pe,formLabel:ce,children:w(ue,{size:"small",value:e==null?void 0:e.name,...o,children:t==null?void 0:t.map(a=>w(pe,{value:a.name,onClick:()=>r==null?void 0:r(a),children:a.name},a.name))})})};import{jsx as h,jsxs as er}from"react/jsx-runtime";var T=({...o})=>{var l,s,p;let{payload:e}=d(),{activePlugin:r,plugins:t,hideElementsConfig:a}=u(),{listMode:i}=he(),n=((p=(s=(l=r==null?void 0:r.components)==null?void 0:l.box)==null?void 0:s.listModes)==null?void 0:p.length)??!1;return er(G,{...o,children:[a!=null&&a.hideCardHeader?null:h(X,{}),t&&t.length>0||n?er(Ce,{columnGap:2,rowGap:2,flexWrap:"wrap",pb:1,children:[t&&t.length>1?h(rr,{}):null,n?h(j,{}):null]}):null,h(fe,{sx:{height:"100%"},children:r?h(r.components.box.detailsBox,{payload:e,...n&&{listMode:i}}):null})]})};import{useTheme as Ne}from"@mui/material";import{ErrorBoundary as Ie,ListModeProvider as Ae}from"@xyo-network/react-shared";import{LoadResult as Ee}from"@xyo-network/react-shared";import{jsx as ye}from"react/jsx-runtime";var or=({children:o})=>{let{payload:e,notFound:r,huriError:t}=d();return ye(Ee,{searchResult:e,notFound:!!r,error:!!t,children:o})};import{Alert as be}from"@mui/material";import{Fragment as Re,jsx as xe,jsxs as ve}from"react/jsx-runtime";var tr=({children:o,...e})=>{let{validPayload:r,enabled:t,schema:a}=_();return t&&r===!1?ve(be,{severity:"error",title:"Invalid Payload!",...e,children:["Payload schema claimed to be ",a," but failed to validate."]}):xe(Re,{children:o})};import{Alert as ge,AlertTitle as Se}from"@mui/material";import{Fragment as Fe,jsx as ar,jsxs as Me}from"react/jsx-runtime";var lr=({children:o,...e})=>{let{payload:r}=d(),{plugins:t}=u();return r&&(t==null?void 0:t.length)===0?Me(ge,{severity:"warning",...e,children:[ar(Se,{children:"Missing plugins!"}),"Payload found but no plugins were present."]}):ar(Fe,{children:o})};import{jsx as m}from"react/jsx-runtime";var nr=({validateSchema:o,plugins:e=[],huriPayload:r,refreshTitle:t="",timestampLabel:a="Data From",hideElementsConfig:i,embedPluginConfig:n,onRefresh:l,children:s})=>m(Ie,{children:m(N,{refreshTitle:t,timestampLabel:a,hideElementsConfig:i,plugins:e,embedPluginConfig:n,children:m(Be,{onRefresh:l,huriPayload:r,children:m(Le,{validateSchema:o,children:m(Ae,{defaultListMode:n==null?void 0:n.listMode,children:s})})})})}),Be=({children:o,onRefresh:e,huriPayload:r})=>m(O,{onRefresh:e,children:m(J,{huriPayload:r,children:m(or,{children:o})})}),Le=({children:o,validateSchema:e})=>m(K,{enabled:e,children:m(lr,{children:m(tr,{children:o})})});import{ErrorAlert as De,ErrorRender as ze}from"@xyo-network/react-error";import{Alert as We,AlertTitle as Ve,Card as we,CardContent as Te,Typography as k}from"@mui/material";import{Fragment as He,jsx as c,jsxs as ir}from"react/jsx-runtime";var sr=o=>{let{alertProps:e,error:r,hideErrorDetails:t=!0,children:a,...i}=o;return c(we,{...i,children:c(Te,{children:a??c(ke,{...{alertProps:e,error:r,hideErrorDetails:t}})})})},ke=({alertProps:o,hideErrorDetails:e,error:r})=>ir(We,{severity:"error",...o,children:[c(Ve,{children:"Whoops! Something went wrong"}),!e&&r?ir(He,{children:[c(k,{variant:"caption",children:"Error: "}),c(k,{variant:"caption",children:r==null?void 0:r.message})]}):c(k,{variant:"caption",fontSize:"small",children:"Error Loading Plugin"})]});import{jsx as I}from"react/jsx-runtime";var dr=({xyoError:o,children:e,...r})=>I(ze,{error:o,noReAuth:!0,noErrorDisplay:!0,customError:I(Ge,{xyoError:o,...r}),children:e}),Ge=({xyoError:o,...e})=>I(sr,{...e,children:I(De,{error:o})});import{jsx as H,jsxs as Je}from"react/jsx-runtime";var Fa=({children:o,...e})=>{let{validateSchema:r,plugins:t=[],huriPayload:a,refreshTitle:i="",timestampLabel:n="Data From",hideElementsConfig:l,embedPluginConfig:s,onRefresh:p,...f}=e;return Je(nr,{embedPluginConfig:s,hideElementsConfig:l,huriPayload:a,onRefresh:p,plugins:t,refreshTitle:i,timestampLabel:n,validateSchema:r,children:[H(Oe,{...f}),o]})},Oe=o=>{let{payload:e,huriError:r}=d(),{refreshPayload:t}=v(),a=Ne();return H(dr,{xyoError:r,children:H(T,{elevation:3,variant:"elevation",busy:!!(!t&&e),busyVariantProps:{style:{alignItems:"start",paddingTop:a.spacing(2),zIndex:2}},sx:{position:"relative"},...o})})};export{Fa as ApiEmbedPluginCard,G as BusyCard,X as EmbedCardHeader,T as EmbedPlugin,T as EmbedPluginCard,Oe as EmbedPluginCardInner,y as EmbedPluginContext,nr as EmbedPluginInner,N as EmbedPluginProvider,O as RefreshPayloadProvider,R as ResolvePayloadContext,J as ResolvePayloadProvider,K as ValidatePayloadProvider,u as useEmbedPluginState,v as useRefreshPayload,d as useResolvePayload,_ as useValidatePayload};
496
2
  //# sourceMappingURL=index.js.map