@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,494 +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?.(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?.(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?.();
135
- if (huri) {
136
- 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?.(payload));
171
- }
172
- setInitialized(true);
173
- }
174
- },
175
- [payload, enabled]
176
- );
177
- return /* @__PURE__ */ jsx5(ValidatePayloadContext.Provider, { value: { enabled, provided: true, schema: 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
- const { refreshHuri, huri } = useResolvePayload();
222
- const { activePlugin, timestampLabel, hideElementsConfig } = useEmbedPluginState();
223
- const { hideAvatar, hideTitle, hideRefreshButton, hideTimestamp, hideCardActions } = hideElementsConfig ?? {};
224
- const timestamp = Date.now();
225
- return /* @__PURE__ */ jsx8(
226
- CardHeader,
227
- {
228
- sx: { flexWrap: "wrap", rowGap: 1 },
229
- avatar: hideAvatar ? /* @__PURE__ */ jsx8(Fragment4, {}) : /* @__PURE__ */ jsx8(Avatar, { sx: { bgcolor: (theme) => theme.palette.primary.main }, "aria-label": activePlugin?.name, children: activePlugin?.name?.charAt(0) }),
230
- action: /* @__PURE__ */ jsxs4(FlexRow, { flexWrap: "wrap", columnGap: 0.5, children: [
231
- timestamp ? hideTimestamp && hideRefreshButton ? "" : /* @__PURE__ */ jsx8(
232
- Chip2,
233
- {
234
- avatar: hideRefreshButton ? /* @__PURE__ */ jsx8(Fragment4, {}) : /* @__PURE__ */ jsx8(RefreshIcon, {}),
235
- clickable: hideRefreshButton ? false : true,
236
- onClick: refreshHuri,
237
- label: hideTimestamp ? "" : `${timestampLabel} ${new Date(timestamp).toLocaleString()}`
238
- }
239
- ) : null,
240
- hideCardActions || huri === void 0 ? null : /* @__PURE__ */ jsx8(EmbedMenu, {})
241
- ] }),
242
- title: hideTitle ? "" : activePlugin?.name
243
- }
244
- );
245
- };
246
-
247
- // src/components/embed-card/card/EmbedPluginCard.tsx
248
- import { CardContent } from "@mui/material";
249
- import { FlexGrowRow } from "@xylabs/react-flexbox";
250
- import { useListMode as useListMode2 } from "@xyo-network/react-shared";
251
-
252
- // src/components/controls/EmbedFormControl.tsx
253
- import { FormControl, InputLabel } from "@mui/material";
254
- import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
255
- var EmbedFormControl = ({ formId, formLabel, children, ...props }) => {
256
- return /* @__PURE__ */ jsxs5(FormControl, { ...props, children: [
257
- /* @__PURE__ */ jsx9(InputLabel, { id: formId, children: formLabel }),
258
- children
259
- ] });
260
- };
261
-
262
- // src/components/controls/ListModeSelect.tsx
263
- import { MenuItem as MenuItem2 } from "@mui/material";
264
- import { SelectEx } from "@xylabs/react-select";
265
- import { useListMode } from "@xyo-network/react-shared";
266
- import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
267
- var listModeSelectId = "listmode-select-id";
268
- var listModeSelectLabel = "List Mode";
269
- var ListModeSelect = (props) => {
270
- const { listMode, setListMode } = useListMode();
271
- return /* @__PURE__ */ jsxs6(
272
- SelectEx,
273
- {
274
- value: listMode ?? "default",
275
- onChange: (event) => {
276
- setListMode?.(event.target.value);
277
- },
278
- ...props,
279
- children: [
280
- /* @__PURE__ */ jsx10(MenuItem2, { value: "default", children: "Default" }, "default"),
281
- /* @__PURE__ */ jsx10(MenuItem2, { value: "table", children: "Table" }, "table"),
282
- /* @__PURE__ */ jsx10(MenuItem2, { value: "grid", children: "Grid" }, "grid")
283
- ]
284
- }
285
- );
286
- };
287
- var ListModeSelectFormControl = (props) => {
288
- return /* @__PURE__ */ jsx10(EmbedFormControl, { formId: listModeSelectId, formLabel: listModeSelectLabel, children: /* @__PURE__ */ jsx10(ListModeSelect, { size: "small", label: listModeSelectLabel, labelId: listModeSelectId, ...props }) });
289
- };
290
-
291
- // src/components/controls/RenderSelect.tsx
292
- import { MenuItem as MenuItem3 } from "@mui/material";
293
- import { SelectEx as SelectEx2 } from "@xylabs/react-select";
294
- import { jsx as jsx11 } from "react/jsx-runtime";
295
- var renderSelectId = "render-select-id";
296
- var renderSelectLabel = "Renderer";
297
- var EmbedRenderSelect = (props) => {
298
- const { activePlugin, setActivePlugin, plugins } = useEmbedPluginState();
299
- return /* @__PURE__ */ jsx11(EmbedFormControl, { formId: renderSelectId, formLabel: renderSelectLabel, children: /* @__PURE__ */ jsx11(SelectEx2, { size: "small", value: activePlugin?.name, ...props, children: plugins?.map((plugin) => /* @__PURE__ */ jsx11(MenuItem3, { value: plugin.name, onClick: () => setActivePlugin?.(plugin), children: plugin.name }, plugin.name)) }) });
300
- };
301
-
302
- // src/components/embed-card/card/EmbedPluginCard.tsx
303
- import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
304
- var EmbedPluginCard = ({ ...props }) => {
305
- const { payload } = useResolvePayload();
306
- const { activePlugin: ActivePlugin, plugins, hideElementsConfig } = useEmbedPluginState();
307
- const { listMode } = useListMode2();
308
- const supportsListMode = ActivePlugin?.components?.box?.listModes?.length ?? 0 > 1;
309
- return /* @__PURE__ */ jsxs7(BusyCard, { ...props, children: [
310
- hideElementsConfig?.hideCardHeader ? null : /* @__PURE__ */ jsx12(EmbedCardHeader, {}),
311
- plugins && plugins.length > 0 || supportsListMode ? /* @__PURE__ */ jsxs7(FlexGrowRow, { columnGap: 2, rowGap: 2, flexWrap: "wrap", pb: 1, children: [
312
- plugins && plugins.length > 1 ? /* @__PURE__ */ jsx12(EmbedRenderSelect, {}) : null,
313
- supportsListMode ? /* @__PURE__ */ jsx12(ListModeSelectFormControl, {}) : null
314
- ] }) : null,
315
- /* @__PURE__ */ jsx12(CardContent, { sx: { height: "100%" }, children: ActivePlugin ? /* @__PURE__ */ jsx12(ActivePlugin.components.box.detailsBox, { payload, ...supportsListMode && { listMode } }) : null })
316
- ] });
317
- };
318
-
319
- // src/components/embed-card/EmbedPluginCard.tsx
320
- import { useTheme } from "@mui/material";
321
-
322
- // src/components/EmbedPlugin.tsx
323
- import { ErrorBoundary, ListModeProvider } from "@xyo-network/react-shared";
324
-
325
- // src/components/EmbedResolver.tsx
326
- import { LoadResult } from "@xyo-network/react-shared";
327
- import { jsx as jsx13 } from "react/jsx-runtime";
328
- var EmbedResolver = ({ children }) => {
329
- const { payload, notFound, huriError } = useResolvePayload();
330
- return /* @__PURE__ */ jsx13(LoadResult, { searchResult: payload, notFound: !!notFound, error: !!huriError, children });
331
- };
332
-
333
- // src/components/validation-alerts/ValidatePayload.tsx
334
- import { Alert } from "@mui/material";
335
- import { Fragment as Fragment5, jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
336
- var ValidatePayloadAlert = ({ children, ...props }) => {
337
- const { validPayload, enabled, schema } = useValidatePayload();
338
- if (enabled && validPayload === false) {
339
- return /* @__PURE__ */ jsxs8(Alert, { severity: "error", title: "Invalid Payload!", ...props, children: [
340
- "Payload schema claimed to be ",
341
- schema,
342
- " but failed to validate."
343
- ] });
344
- }
345
- return /* @__PURE__ */ jsx14(Fragment5, { children });
346
- };
347
-
348
- // src/components/validation-alerts/ValidatePlugins.tsx
349
- import { Alert as Alert2, AlertTitle } from "@mui/material";
350
- import { Fragment as Fragment6, jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
351
- var ValidatePluginsAlert = ({ children, ...props }) => {
352
- const { payload } = useResolvePayload();
353
- const { plugins } = useEmbedPluginState();
354
- if (payload && plugins?.length === 0) {
355
- return /* @__PURE__ */ jsxs9(Alert2, { severity: "warning", ...props, children: [
356
- /* @__PURE__ */ jsx15(AlertTitle, { children: "Missing plugins!" }),
357
- "Payload found but no plugins were present."
358
- ] });
359
- }
360
- return /* @__PURE__ */ jsx15(Fragment6, { children });
361
- };
362
-
363
- // src/components/EmbedPlugin.tsx
364
- import { jsx as jsx16 } from "react/jsx-runtime";
365
- var EmbedPluginInner = ({
366
- validateSchema,
367
- plugins = [],
368
- huriPayload,
369
- refreshTitle = "",
370
- timestampLabel = "Data From",
371
- hideElementsConfig,
372
- embedPluginConfig,
373
- onRefresh,
374
- children
375
- }) => {
376
- return /* @__PURE__ */ jsx16(ErrorBoundary, { children: /* @__PURE__ */ jsx16(
377
- EmbedPluginProvider,
378
- {
379
- refreshTitle,
380
- timestampLabel,
381
- hideElementsConfig,
382
- plugins,
383
- embedPluginConfig,
384
- children: /* @__PURE__ */ jsx16(WithResolvers, { onRefresh, huriPayload, children: /* @__PURE__ */ jsx16(WithValidators, { validateSchema, children: /* @__PURE__ */ jsx16(ListModeProvider, { defaultListMode: embedPluginConfig?.listMode, children }) }) })
385
- }
386
- ) });
387
- };
388
- var WithResolvers = ({ children, onRefresh, huriPayload }) => {
389
- return /* @__PURE__ */ jsx16(RefreshPayloadProvider, { onRefresh, children: /* @__PURE__ */ jsx16(ResolvePayloadProvider, { huriPayload, children: /* @__PURE__ */ jsx16(EmbedResolver, { children }) }) });
390
- };
391
- var WithValidators = ({ children, validateSchema }) => {
392
- return /* @__PURE__ */ jsx16(ValidatePayloadProvider, { enabled: validateSchema, children: /* @__PURE__ */ jsx16(ValidatePluginsAlert, { children: /* @__PURE__ */ jsx16(ValidatePayloadAlert, { children }) }) });
393
- };
394
-
395
- // src/components/embed-card/error-handling/EmbedCardApiErrorRenderer.tsx
396
- import { ErrorAlert, ErrorRender } from "@xyo-network/react-error";
397
-
398
- // src/components/embed-card/error-handling/EmbedErrorCard.tsx
399
- import { Alert as Alert3, AlertTitle as AlertTitle2, Card as Card2, CardContent as CardContent2, Typography } from "@mui/material";
400
- import { Fragment as Fragment7, jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
401
- var EmbedErrorCard = (props) => {
402
- const { alertProps, error, hideErrorDetails = true, children, ...cardProps } = props;
403
- const errorProps = { alertProps, error, hideErrorDetails };
404
- return /* @__PURE__ */ jsx17(Card2, { ...cardProps, children: /* @__PURE__ */ jsx17(CardContent2, { children: children ?? /* @__PURE__ */ jsx17(DefaultErrorAlert, { ...errorProps }) }) });
405
- };
406
- var DefaultErrorAlert = ({ alertProps, hideErrorDetails, error }) => {
407
- return /* @__PURE__ */ jsxs10(Alert3, { severity: "error", ...alertProps, children: [
408
- /* @__PURE__ */ jsx17(AlertTitle2, { children: "Whoops! Something went wrong" }),
409
- !hideErrorDetails && error ? /* @__PURE__ */ jsxs10(Fragment7, { children: [
410
- /* @__PURE__ */ jsx17(Typography, { variant: "caption", children: "Error: " }),
411
- /* @__PURE__ */ jsx17(Typography, { variant: "caption", children: error?.message })
412
- ] }) : /* @__PURE__ */ jsx17(Typography, { variant: "caption", fontSize: "small", children: "Error Loading Plugin" })
413
- ] });
414
- };
415
-
416
- // src/components/embed-card/error-handling/EmbedCardApiErrorRenderer.tsx
417
- import { jsx as jsx18 } from "react/jsx-runtime";
418
- var EmbedCardApiErrorRenderer = ({ xyoError, children, ...props }) => {
419
- return /* @__PURE__ */ jsx18(ErrorRender, { error: xyoError, noReAuth: true, noErrorDisplay: true, customError: /* @__PURE__ */ jsx18(CustomApiErrorCard, { xyoError, ...props }), children });
420
- };
421
- var CustomApiErrorCard = ({ xyoError, ...props }) => {
422
- return /* @__PURE__ */ jsx18(EmbedErrorCard, { ...props, children: /* @__PURE__ */ jsx18(ErrorAlert, { error: xyoError }) });
423
- };
424
-
425
- // src/components/embed-card/EmbedPluginCard.tsx
426
- import { jsx as jsx19, jsxs as jsxs11 } from "react/jsx-runtime";
427
- var ApiEmbedPluginCard = ({ children, ...props }) => {
428
- const {
429
- validateSchema,
430
- plugins = [],
431
- huriPayload,
432
- refreshTitle = "",
433
- timestampLabel = "Data From",
434
- hideElementsConfig,
435
- embedPluginConfig,
436
- onRefresh,
437
- ...busyCardProps
438
- } = props;
439
- return /* @__PURE__ */ jsxs11(
440
- EmbedPluginInner,
441
- {
442
- ...{
443
- embedPluginConfig,
444
- hideElementsConfig,
445
- huriPayload,
446
- onRefresh,
447
- plugins,
448
- refreshTitle,
449
- timestampLabel,
450
- validateSchema
451
- },
452
- children: [
453
- /* @__PURE__ */ jsx19(EmbedPluginCardInner, { ...busyCardProps }),
454
- children
455
- ]
456
- }
457
- );
458
- };
459
- var EmbedPluginCardInner = (props) => {
460
- const { payload, huriError } = useResolvePayload();
461
- const { refreshPayload } = useRefreshPayload();
462
- const theme = useTheme();
463
- return /* @__PURE__ */ jsx19(EmbedCardApiErrorRenderer, { xyoError: huriError, children: /* @__PURE__ */ jsx19(
464
- EmbedPluginCard,
465
- {
466
- elevation: 3,
467
- variant: "elevation",
468
- busy: Boolean(!refreshPayload && payload),
469
- busyVariantProps: { style: { alignItems: "start", paddingTop: theme.spacing(2), zIndex: 2 } },
470
- sx: { position: "relative" },
471
- ...props
472
- }
473
- ) });
474
- };
475
- export {
476
- ApiEmbedPluginCard,
477
- BusyCard,
478
- EmbedCardHeader,
479
- EmbedPluginCard as EmbedPlugin,
480
- EmbedPluginCard,
481
- EmbedPluginCardInner,
482
- EmbedPluginContext,
483
- EmbedPluginInner,
484
- EmbedPluginProvider,
485
- RefreshPayloadProvider,
486
- ResolvePayloadContext,
487
- ResolvePayloadProvider,
488
- ValidatePayloadProvider,
489
- useEmbedPluginState,
490
- useRefreshPayload,
491
- useResolvePayload,
492
- useValidatePayload
493
- };
1
+ import{Card as ue}from"@mui/material";import{useBusyTiming as Pe}from"@xylabs/react-flexbox";import{BusyCircularProgress as ce,BusyLinearProgress as fe}from"@xylabs/react-shared";import{jsx as D,jsxs as Ce}from"react/jsx-runtime";var z=({busy:o,busyMinimum:e=500,busyVariant:r="circular",busyVariantProps:t,children:a,...l})=>{let i=Pe(o,e);return Ce(ue,{...l,children:[a,r==="circular"&&i?D(ce,{...t}):null,r==="linear"&&i?D(fe,{...t}):null]})};import{Refresh as Ye}from"@mui/icons-material";import{Avatar as Ze,CardHeader as je,Chip as er}from"@mui/material";import{FlexRow as rr}from"@xylabs/react-flexbox";import{createContextEx as he}from"@xyo-network/react-shared";var y=he();import{useEffect as ye,useState as Ee}from"react";import{jsx as ve}from"react/jsx-runtime";var G=({children:o,refreshTitle:e,timestampLabel:r,hideElementsConfig:t,plugins:a,embedPluginConfig:l})=>{let[i,n]=Ee(a?a[0]:void 0);return ye(()=>{n(a?a[0]:void 0)},[a]),ve(y.Provider,{value:{activePlugin:i,embedPluginConfig:l,hideElementsConfig:t,provided:!0,refreshTitle:e,setActivePlugin:n,timestampLabel:r},children:o})};import{useContextEx as be}from"@xyo-network/react-shared";var p=()=>be(y,"EmbedPlugin",!0);import{useState as ge}from"react";import{createContextEx as Re}from"@xyo-network/react-shared";var E=Re();import{jsx as xe}from"react/jsx-runtime";var N=({children:o,onRefresh:e,refreshPayload:r})=>{let[t,a]=ge(r);return xe(E.Provider,{value:{onRefresh:e,provided:!0,refreshPayload:t,setRefreshPayload:a},children:o})};import{useContextEx as Me}from"@xyo-network/react-shared";var v=()=>Me(E,"RefreshPayload",!0);import{createContextEx as Se}from"@xyo-network/react-shared";var b=Se();import{delay as Fe}from"@xylabs/delay";import{useAsyncEffect as Ae}from"@xylabs/react-async-effect";import{Huri as Ie}from"@xyo-network/huri";import{ModuleErrorSchema as Le}from"@xyo-network/payload-model";import{useEffect as Be,useState as R}from"react";import{jsx as We}from"react/jsx-runtime";var O=({children:o,huriPayload:e})=>{let[r,t]=R(),[a,l]=R(),{refreshPayload:i,setRefreshPayload:n,onRefresh:m}=v();Be(()=>{typeof e=="string"&&l(e),typeof e=="object"&&(t(e),n?.(!0))},[e,n]);let[f,c]=R(),[A,de]=R();Ae(async pe=>{if(a&&!i)try{let I=await new Ie(a).fetch();await Fe(500),pe()&&(c(I===null),t(I),n?.(!0))}catch(H){de({message:H.message,schema:Le,sources:[]})}},[a,r,i,n]);let me=()=>{m?.(),a&&n?.(!1)};return We(b.Provider,{value:{huri:a,huriError:A,notFound:f,payload:r,provided:!0,refreshHuri:me,setPayload:t},children:o})};import{useContextEx as Ve}from"@xyo-network/react-shared";var s=()=>Ve(b,"ResolvePayload",!0);import{Chip as Te}from"@mui/material";import{useAsyncEffect as ke}from"@xylabs/react-async-effect";import{SchemaCache as L}from"@xyo-network/schema-cache";import{useState as J}from"react";import{createContextEx as we}from"@xyo-network/react-shared";var g=we();import{Fragment as He,jsx as B}from"react/jsx-runtime";var $=({children:o,enabled:e=!1})=>{let{payload:r}=s(),[t,a]=J(!1),[l,i]=J();return ke(async()=>{if(r&&e){await L.instance.get(r.schema);let n=r.schema;if(L.instance.validators[n]){let m=L.instance.validators[n];i(m?.(r))}a(!0)}},[r,e]),B(g.Provider,{value:{enabled:e,provided:!0,schema:r?.schema,validPayload:l},children:e?B(He,{children:t?o:B(Te,{label:"Validating Payload..."})}):o})};import{useContextEx as De}from"@xyo-network/react-shared";var K=()=>De(g,"ValidateSchema",!0);import{MoreVert as Ke}from"@mui/icons-material";import{IconButton as _e,Menu as qe}from"@mui/material";import{useState as Qe}from"react";import{OpenInNew as ze}from"@mui/icons-material";import{ListItemIcon as Ge,ListItemText as Ne,MenuItem as Oe}from"@mui/material";import{Fragment as $e,jsx as x,jsxs as Je}from"react/jsx-runtime";var _=o=>{let{huri:e}=s();return x($e,{children:e?Je(Oe,{title:"Source Payload JSON",onClick:()=>window.open(e,"_blank"),...o,children:[x(Ne,{sx:{mr:1},children:"JSON"}),x(Ge,{sx:{justifyContent:"end"},children:x(ze,{fontSize:"small"})})]}):null})};import{Fragment as Ue,jsx as M,jsxs as Xe}from"react/jsx-runtime";var q=o=>{let[e,r]=Qe(null),t=!!e,a=i=>{r(i.currentTarget)},l=()=>{r(null)};return Xe(Ue,{children:[M(_e,{onClick:a,...o,children:M(Ke,{})}),M(qe,{anchorEl:e,open:t,onClose:l,PaperProps:{variant:"elevation"},MenuListProps:{dense:!0},children:M(_,{})})]})};import{Fragment as Q,jsx as u,jsxs as or}from"react/jsx-runtime";var U=()=>{let{refreshHuri:o,huri:e}=s(),{activePlugin:r,timestampLabel:t,hideElementsConfig:a}=p(),{hideAvatar:l,hideTitle:i,hideRefreshButton:n,hideTimestamp:m,hideCardActions:f}=a??{},c=Date.now();return u(je,{sx:{flexWrap:"wrap",rowGap:1},avatar:l?u(Q,{}):u(Ze,{sx:{bgcolor:A=>A.palette.primary.main},"aria-label":r?.name,children:r?.name?.charAt(0)}),action:or(rr,{flexWrap:"wrap",columnGap:.5,children:[c?m&&n?"":u(er,{avatar:n?u(Q,{}):u(Ye,{}),clickable:!n,onClick:o,label:m?"":`${t} ${new Date(c).toLocaleString()}`}):null,f||e===void 0?null:u(q,{})]}),title:i?"":r?.name})};import{CardContent as fr}from"@mui/material";import{FlexGrowRow as Cr}from"@xylabs/react-flexbox";import{useListMode as hr}from"@xyo-network/react-shared";import{FormControl as tr,InputLabel as ar}from"@mui/material";import{jsx as ir,jsxs as lr}from"react/jsx-runtime";var S=({formId:o,formLabel:e,children:r,...t})=>lr(tr,{...t,children:[ir(ar,{id:o,children:e}),r]});import{MenuItem as W}from"@mui/material";import{SelectEx as nr}from"@xylabs/react-select";import{useListMode as sr}from"@xyo-network/react-shared";import{jsx as C,jsxs as mr}from"react/jsx-runtime";var X="listmode-select-id",Y="List Mode",dr=o=>{let{listMode:e,setListMode:r}=sr();return mr(nr,{value:e??"default",onChange:t=>{r?.(t.target.value)},...o,children:[C(W,{value:"default",children:"Default"},"default"),C(W,{value:"table",children:"Table"},"table"),C(W,{value:"grid",children:"Grid"},"grid")]})},Z=o=>C(S,{formId:X,formLabel:Y,children:C(dr,{size:"small",label:Y,labelId:X,...o})});import{MenuItem as pr}from"@mui/material";import{SelectEx as ur}from"@xylabs/react-select";import{jsx as V}from"react/jsx-runtime";var Pr="render-select-id",cr="Renderer",j=o=>{let{activePlugin:e,setActivePlugin:r,plugins:t}=p();return V(S,{formId:Pr,formLabel:cr,children:V(ur,{size:"small",value:e?.name,...o,children:t?.map(a=>V(pr,{value:a.name,onClick:()=>r?.(a),children:a.name},a.name))})})};import{jsx as h,jsxs as ee}from"react/jsx-runtime";var w=({...o})=>{let{payload:e}=s(),{activePlugin:r,plugins:t,hideElementsConfig:a}=p(),{listMode:l}=hr(),i=r?.components?.box?.listModes?.length??!1;return ee(z,{...o,children:[a?.hideCardHeader?null:h(U,{}),t&&t.length>0||i?ee(Cr,{columnGap:2,rowGap:2,flexWrap:"wrap",pb:1,children:[t&&t.length>1?h(j,{}):null,i?h(Z,{}):null]}):null,h(fr,{sx:{height:"100%"},children:r?h(r.components.box.detailsBox,{payload:e,...i&&{listMode:l}}):null})]})};import{useTheme as Nr}from"@mui/material";import{ErrorBoundary as Ar,ListModeProvider as Ir}from"@xyo-network/react-shared";import{LoadResult as yr}from"@xyo-network/react-shared";import{jsx as Er}from"react/jsx-runtime";var re=({children:o})=>{let{payload:e,notFound:r,huriError:t}=s();return Er(yr,{searchResult:e,notFound:!!r,error:!!t,children:o})};import{Alert as vr}from"@mui/material";import{Fragment as Rr,jsx as gr,jsxs as br}from"react/jsx-runtime";var oe=({children:o,...e})=>{let{validPayload:r,enabled:t,schema:a}=K();return t&&r===!1?br(vr,{severity:"error",title:"Invalid Payload!",...e,children:["Payload schema claimed to be ",a," but failed to validate."]}):gr(Rr,{children:o})};import{Alert as xr,AlertTitle as Mr}from"@mui/material";import{Fragment as Fr,jsx as te,jsxs as Sr}from"react/jsx-runtime";var ae=({children:o,...e})=>{let{payload:r}=s(),{plugins:t}=p();return r&&t?.length===0?Sr(xr,{severity:"warning",...e,children:[te(Mr,{children:"Missing plugins!"}),"Payload found but no plugins were present."]}):te(Fr,{children:o})};import{jsx as d}from"react/jsx-runtime";var ie=({validateSchema:o,plugins:e=[],huriPayload:r,refreshTitle:t="",timestampLabel:a="Data From",hideElementsConfig:l,embedPluginConfig:i,onRefresh:n,children:m})=>d(Ar,{children:d(G,{refreshTitle:t,timestampLabel:a,hideElementsConfig:l,plugins:e,embedPluginConfig:i,children:d(Lr,{onRefresh:n,huriPayload:r,children:d(Br,{validateSchema:o,children:d(Ir,{defaultListMode:i?.listMode,children:m})})})})}),Lr=({children:o,onRefresh:e,huriPayload:r})=>d(N,{onRefresh:e,children:d(O,{huriPayload:r,children:d(re,{children:o})})}),Br=({children:o,validateSchema:e})=>d($,{enabled:e,children:d(ae,{children:d(oe,{children:o})})});import{ErrorAlert as Dr,ErrorRender as zr}from"@xyo-network/react-error";import{Alert as Wr,AlertTitle as Vr,Card as wr,CardContent as Tr,Typography as T}from"@mui/material";import{Fragment as Hr,jsx as P,jsxs as le}from"react/jsx-runtime";var ne=o=>{let{alertProps:e,error:r,hideErrorDetails:t=!0,children:a,...l}=o;return P(wr,{...l,children:P(Tr,{children:a??P(kr,{...{alertProps:e,error:r,hideErrorDetails:t}})})})},kr=({alertProps:o,hideErrorDetails:e,error:r})=>le(Wr,{severity:"error",...o,children:[P(Vr,{children:"Whoops! Something went wrong"}),!e&&r?le(Hr,{children:[P(T,{variant:"caption",children:"Error: "}),P(T,{variant:"caption",children:r?.message})]}):P(T,{variant:"caption",fontSize:"small",children:"Error Loading Plugin"})]});import{jsx as F}from"react/jsx-runtime";var se=({xyoError:o,children:e,...r})=>F(zr,{error:o,noReAuth:!0,noErrorDisplay:!0,customError:F(Gr,{xyoError:o,...r}),children:e}),Gr=({xyoError:o,...e})=>F(ne,{...e,children:F(Dr,{error:o})});import{jsx as k,jsxs as Jr}from"react/jsx-runtime";var Fa=({children:o,...e})=>{let{validateSchema:r,plugins:t=[],huriPayload:a,refreshTitle:l="",timestampLabel:i="Data From",hideElementsConfig:n,embedPluginConfig:m,onRefresh:f,...c}=e;return Jr(ie,{embedPluginConfig:m,hideElementsConfig:n,huriPayload:a,onRefresh:f,plugins:t,refreshTitle:l,timestampLabel:i,validateSchema:r,children:[k(Or,{...c}),o]})},Or=o=>{let{payload:e,huriError:r}=s(),{refreshPayload:t}=v(),a=Nr();return k(se,{xyoError:r,children:k(w,{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,z as BusyCard,U as EmbedCardHeader,w as EmbedPlugin,w as EmbedPluginCard,Or as EmbedPluginCardInner,y as EmbedPluginContext,ie as EmbedPluginInner,G as EmbedPluginProvider,N as RefreshPayloadProvider,b as ResolvePayloadContext,O as ResolvePayloadProvider,$ as ValidatePayloadProvider,p as useEmbedPluginState,v as useRefreshPayload,s as useResolvePayload,K as useValidatePayload};
494
2
  //# sourceMappingURL=index.js.map