@optiaxiom/proteus 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/_virtual/_openai-shim-script.js +3 -2
- package/dist/esm/assets/src/proteus-chart/{ProteusChart.css.ts.vanilla-BeRNNwBj.css → ProteusChart.css.ts.vanilla-yGx8JdKz.css} +2 -2
- package/dist/esm/assets/src/proteus-chart/{ProteusChartTooltipContent.css.ts.vanilla-Df_IhL_i.css → ProteusChartTooltipContent.css.ts.vanilla-HapBe2oo.css} +2 -2
- package/dist/esm/assets/src/proteus-document/{ProteusDocumentShell.css.ts.vanilla-CyMtrn1n.css → ProteusDocumentShell.css.ts.vanilla-BPytQ9pT.css} +2 -2
- package/dist/esm/assets/src/proteus-image-carousel/{ProteusImageCarousel.css.ts.vanilla-Dbf7yRF1.css → ProteusImageCarousel.css.ts.vanilla-DnlXoyv1.css} +2 -2
- package/dist/esm/assets/src/proteus-question/{ProteusQuestion.css.ts.vanilla-cmHZWqNR.css → ProteusQuestion.css.ts.vanilla-CpDgoW0l.css} +2 -2
- package/dist/esm/hooks/useEffectEvent.js +11 -10
- package/dist/esm/hooks/useObserveValue.js +24 -30
- package/dist/esm/icons/IconAngleLeft.js +13 -19
- package/dist/esm/icons/IconAngleRight.js +13 -19
- package/dist/esm/icons/IconX.js +10 -18
- package/dist/esm/icons/withIcon.js +17 -28
- package/dist/esm/index.js +22 -17
- package/dist/esm/proteus-action/ProteusAction.js +44 -39
- package/dist/esm/proteus-bridge/ProteusBridge.js +71 -85
- package/dist/esm/proteus-card-link/ProteusCardLink.js +24 -37
- package/dist/esm/proteus-chart/ProteusChart-css.js +14 -5
- package/dist/esm/proteus-chart/ProteusChart.js +86 -84
- package/dist/esm/proteus-chart/ProteusChartContext.js +3 -3
- package/dist/esm/proteus-chart/ProteusChartTooltipContent-css.js +23 -6
- package/dist/esm/proteus-chart/ProteusChartTooltipContent.js +52 -66
- package/dist/esm/proteus-data-table/ProteusDataTable.js +28 -29
- package/dist/esm/proteus-date-input/ProteusDateInput.js +23 -0
- package/dist/esm/proteus-document/ProteusDocumentContext.js +4 -3
- package/dist/esm/proteus-document/ProteusDocumentPathContext.js +6 -5
- package/dist/esm/proteus-document/ProteusDocumentRenderer.js +25 -33
- package/dist/esm/proteus-document/ProteusDocumentShell-css.js +32 -6
- package/dist/esm/proteus-document/ProteusDocumentShell.js +226 -219
- package/dist/esm/proteus-document/getProteusValue.js +28 -42
- package/dist/esm/proteus-document/resolveProteusProp.js +31 -49
- package/dist/esm/proteus-document/resolveProteusValue.js +73 -136
- package/dist/esm/proteus-document/schemas.js +42 -45
- package/dist/esm/proteus-document/useResolveProteusValues.js +10 -16
- package/dist/esm/proteus-element/ProteusElement.js +114 -180
- package/dist/esm/proteus-federated/ProteusFederated.js +51 -52
- package/dist/esm/proteus-file-icon/ProteusFileIcon.js +29 -38
- package/dist/esm/proteus-file-upload/ProteusFileUpload.js +107 -133
- package/dist/esm/proteus-image/ProteusImage.js +99 -106
- package/dist/esm/proteus-image/downloadFile.js +3 -2
- package/dist/esm/proteus-image-carousel/ProteusImageCarousel-css.js +49 -11
- package/dist/esm/proteus-image-carousel/ProteusImageCarousel.js +151 -163
- package/dist/esm/proteus-input/ProteusInput.js +19 -27
- package/dist/esm/proteus-length/ProteusLength.js +10 -0
- package/dist/esm/proteus-map/ProteusMap.js +18 -31
- package/dist/esm/proteus-map-index/ProteusMapIndex.js +11 -0
- package/dist/esm/proteus-pill-menu/ProteusPillMenu.js +65 -0
- package/dist/esm/proteus-pill-menu/useInputValueChangeInteraction.js +36 -0
- package/dist/esm/proteus-question/ProteusQuestion-css.js +40 -8
- package/dist/esm/proteus-question/ProteusQuestion.js +324 -400
- package/dist/esm/proteus-select/ProteusSelect.js +25 -40
- package/dist/esm/proteus-show/ProteusShow.js +10 -18
- package/dist/esm/proteus-switch/ProteusSwitch.js +33 -36
- package/dist/esm/proteus-textarea/ProteusTextarea.js +18 -27
- package/dist/esm/proteus-value/ProteusValue.js +4 -4
- package/dist/esm/schema/public-schema.js +4537 -0
- package/dist/esm/schema/runtime-schema.js +4460 -0
- package/dist/esm/spec.js +5 -1
- package/dist/esm/use-proteus-value/useProteusValue.js +8 -12
- package/dist/index.d.ts +516 -347
- package/dist/spec.d.ts +5 -9952
- package/package.json +4 -4
- package/dist/esm/icons/IconCalendar.js +0 -20
- package/dist/esm/schema/public-schema.json.js +0 -9026
- package/dist/esm/schema/runtime-schema.json.js +0 -8959
|
@@ -1,186 +1,120 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
|
|
2
|
+
import { useProteusDocumentContext } from "../proteus-document/ProteusDocumentContext.js";
|
|
3
|
+
import { useProteusDocumentPathContext } from "../proteus-document/ProteusDocumentPathContext.js";
|
|
4
|
+
import { ProteusAction } from "../proteus-action/ProteusAction.js";
|
|
5
|
+
import { ProteusBridge } from "../proteus-bridge/ProteusBridge.js";
|
|
6
|
+
import { ProteusDataTable } from "../proteus-data-table/ProteusDataTable.js";
|
|
7
|
+
import { ProteusDateInput } from "../proteus-date-input/ProteusDateInput.js";
|
|
8
|
+
import { ProteusCardLink } from "../proteus-card-link/ProteusCardLink.js";
|
|
9
|
+
import { resolveProteusProp } from "../proteus-document/resolveProteusProp.js";
|
|
10
|
+
import { safeParseElement } from "../proteus-document/schemas.js";
|
|
11
|
+
import { ProteusFederated } from "../proteus-federated/ProteusFederated.js";
|
|
12
|
+
import { ProteusFileIcon } from "../proteus-file-icon/ProteusFileIcon.js";
|
|
13
|
+
import { ProteusFileUpload } from "../proteus-file-upload/ProteusFileUpload.js";
|
|
14
|
+
import { ProteusImage } from "../proteus-image/ProteusImage.js";
|
|
15
|
+
import { ProteusImageCarousel } from "../proteus-image-carousel/ProteusImageCarousel.js";
|
|
16
|
+
import { ProteusInput } from "../proteus-input/ProteusInput.js";
|
|
17
|
+
import { ProteusLength } from "../proteus-length/ProteusLength.js";
|
|
18
|
+
import { ProteusMapIndex } from "../proteus-map-index/ProteusMapIndex.js";
|
|
19
|
+
import { ProteusMap } from "../proteus-map/ProteusMap.js";
|
|
20
|
+
import { ProteusPillMenu } from "../proteus-pill-menu/ProteusPillMenu.js";
|
|
21
|
+
import { ProteusQuestion } from "../proteus-question/ProteusQuestion.js";
|
|
22
|
+
import { ProteusSelect } from "../proteus-select/ProteusSelect.js";
|
|
23
|
+
import { ProteusShow } from "../proteus-show/ProteusShow.js";
|
|
24
|
+
import { ProteusSwitch } from "../proteus-switch/ProteusSwitch.js";
|
|
25
|
+
import { ProteusTextarea } from "../proteus-textarea/ProteusTextarea.js";
|
|
26
|
+
import { ProteusValue } from "../proteus-value/ProteusValue.js";
|
|
27
|
+
import { Alert, Avatar, AvatarGroup, Badge, Box, Card, CardHeader, Disclosure, DisclosureContent, DisclosureTrigger, Field, Group, Heading, Link, SelectContent, SelectTrigger, Separator, Text } from "@optiaxiom/react";
|
|
28
|
+
import { Suspense, lazy } from "react";
|
|
29
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
30
|
+
import { Range, Time } from "@optiaxiom/react/unstable";
|
|
31
|
+
//#region src/proteus-element/ProteusElement.tsx
|
|
29
32
|
const ProteusChart = lazy(async () => {
|
|
30
|
-
|
|
31
|
-
default: (await import('../proteus-chart/ProteusChart.js')).ProteusChart
|
|
32
|
-
};
|
|
33
|
+
return { default: (await import("../proteus-chart/ProteusChart.js")).ProteusChart };
|
|
33
34
|
});
|
|
34
|
-
const ProteusElement = ({
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return /* @__PURE__ */ jsx(Group, { ...resolve(element) });
|
|
117
|
-
case "Heading":
|
|
118
|
-
return /* @__PURE__ */ jsx(Heading, { ...resolve(element) });
|
|
119
|
-
case "IconCalendar":
|
|
120
|
-
return /* @__PURE__ */ jsx(Box, { asChild: true, ...resolve(element), children: /* @__PURE__ */ jsx(IconCalendar, {}) });
|
|
121
|
-
case "Image":
|
|
122
|
-
return /* @__PURE__ */ jsx(ProteusImage, { ...resolve(element) });
|
|
123
|
-
case "ImageCarousel":
|
|
124
|
-
return /* @__PURE__ */ jsx(
|
|
125
|
-
ProteusImageCarousel,
|
|
126
|
-
{
|
|
127
|
-
...resolve(element)
|
|
128
|
-
}
|
|
129
|
-
);
|
|
130
|
-
case "Input":
|
|
131
|
-
return /* @__PURE__ */ jsx(ProteusInput, { ...resolve(element) });
|
|
132
|
-
case "Link":
|
|
133
|
-
return /* @__PURE__ */ jsx(Link, { target: "_blank", ...resolve(element) });
|
|
134
|
-
case "Map":
|
|
135
|
-
return /* @__PURE__ */ jsx(
|
|
136
|
-
ProteusMap,
|
|
137
|
-
{
|
|
138
|
-
...resolve(element)
|
|
139
|
-
}
|
|
140
|
-
);
|
|
141
|
-
case "Question":
|
|
142
|
-
return /* @__PURE__ */ jsx(ProteusQuestion, { ...resolve(element) });
|
|
143
|
-
case "Range":
|
|
144
|
-
return /* @__PURE__ */ jsx(Range, { ...resolve(element) });
|
|
145
|
-
case "Select":
|
|
146
|
-
return /* @__PURE__ */ jsx(ProteusSelect, { ...resolve(element) });
|
|
147
|
-
case "SelectContent":
|
|
148
|
-
return /* @__PURE__ */ jsx(SelectContent, { ...resolve(element) });
|
|
149
|
-
case "SelectTrigger":
|
|
150
|
-
return /* @__PURE__ */ jsx(SelectTrigger, { ...resolve(element) });
|
|
151
|
-
case "Separator":
|
|
152
|
-
return /* @__PURE__ */ jsx(Separator, { ...resolve(element) });
|
|
153
|
-
case "Show":
|
|
154
|
-
return /* @__PURE__ */ jsx(
|
|
155
|
-
ProteusShow,
|
|
156
|
-
{
|
|
157
|
-
...resolve(element)
|
|
158
|
-
}
|
|
159
|
-
);
|
|
160
|
-
case "Switch":
|
|
161
|
-
return /* @__PURE__ */ jsx(ProteusSwitch, { ...resolve(element) });
|
|
162
|
-
case "Text":
|
|
163
|
-
return /* @__PURE__ */ jsx(Text, { ...resolve(element) });
|
|
164
|
-
case "Textarea":
|
|
165
|
-
return /* @__PURE__ */ jsx(ProteusTextarea, { ...resolve(element) });
|
|
166
|
-
case "Time":
|
|
167
|
-
return /* @__PURE__ */ jsx(
|
|
168
|
-
Time,
|
|
169
|
-
{
|
|
170
|
-
...resolve(element)
|
|
171
|
-
}
|
|
172
|
-
);
|
|
173
|
-
case "Value":
|
|
174
|
-
return /* @__PURE__ */ jsx(
|
|
175
|
-
ProteusValue,
|
|
176
|
-
{
|
|
177
|
-
...element
|
|
178
|
-
}
|
|
179
|
-
);
|
|
180
|
-
default:
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
35
|
+
const ProteusElement = ({ element: elementProp }) => {
|
|
36
|
+
const { data, icons, strict } = useProteusDocumentContext("@optiaxiom/proteus/ProteusElement");
|
|
37
|
+
const { mapIndices, path: parentPath } = useProteusDocumentPathContext("@optiaxiom/proteus/ProteusElement");
|
|
38
|
+
if (!elementProp) return null;
|
|
39
|
+
else if (typeof elementProp === "string" || typeof elementProp === "number") return elementProp;
|
|
40
|
+
else if (Array.isArray(elementProp)) return /* @__PURE__ */ jsx(Fragment, { children: elementProp.map((element, index) => /* @__PURE__ */ jsx(ProteusElement, { element }, index)) });
|
|
41
|
+
const result = safeParseElement(elementProp);
|
|
42
|
+
if (!result.success) {
|
|
43
|
+
if (strict) throw new Error(`Invalid element: ${result.error.join("\n")}`);
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const element = result.data;
|
|
47
|
+
const resolve = (obj) => {
|
|
48
|
+
const { $type: _$type, ...rest } = obj;
|
|
49
|
+
const resolved = {};
|
|
50
|
+
for (const [key, value] of Object.entries(rest)) resolved[key] = resolveProteusProp(value, data, parentPath, mapIndices);
|
|
51
|
+
return resolved;
|
|
52
|
+
};
|
|
53
|
+
switch (element.$type) {
|
|
54
|
+
case "Action": return /* @__PURE__ */ jsx(ProteusAction, { ...resolve(element) });
|
|
55
|
+
case "Alert": return /* @__PURE__ */ jsx(Alert, { ...resolve(element) });
|
|
56
|
+
case "Avatar": return /* @__PURE__ */ jsx(Avatar, { ...resolve(element) });
|
|
57
|
+
case "AvatarGroup": return /* @__PURE__ */ jsx(AvatarGroup, { ...resolve(element) });
|
|
58
|
+
case "Badge": return /* @__PURE__ */ jsx(Badge, { ...resolve(element) });
|
|
59
|
+
case "Bridge": return /* @__PURE__ */ jsx(ProteusBridge, { ...resolve(element) });
|
|
60
|
+
case "Button": return /* @__PURE__ */ jsx(ProteusAction, { ...resolve(element) });
|
|
61
|
+
case "Card": return /* @__PURE__ */ jsx(Card, { ...resolve(element) });
|
|
62
|
+
case "CardHeader": return /* @__PURE__ */ jsx(CardHeader, { ...resolve(element) });
|
|
63
|
+
case "CardLink": return /* @__PURE__ */ jsx(ProteusCardLink, { ...resolve(element) });
|
|
64
|
+
case "Chart": return /* @__PURE__ */ jsx(Suspense, {
|
|
65
|
+
fallback: null,
|
|
66
|
+
children: /* @__PURE__ */ jsx(ProteusChart, { ...resolve(element) })
|
|
67
|
+
});
|
|
68
|
+
case "DataTable": return /* @__PURE__ */ jsx(ProteusDataTable, { ...resolve(element) });
|
|
69
|
+
case "DateInput": return /* @__PURE__ */ jsx(ProteusDateInput, { ...resolve(element) });
|
|
70
|
+
case "Disclosure": return /* @__PURE__ */ jsx(Disclosure, { ...resolve(element) });
|
|
71
|
+
case "DisclosureContent": return /* @__PURE__ */ jsx(DisclosureContent, { ...resolve(element) });
|
|
72
|
+
case "DisclosureTrigger": return /* @__PURE__ */ jsx(DisclosureTrigger, { ...resolve(element) });
|
|
73
|
+
case "Federated": return /* @__PURE__ */ jsx(ProteusFederated, { ...resolve(element) });
|
|
74
|
+
case "Field": return /* @__PURE__ */ jsx(Field, { ...resolve(element) });
|
|
75
|
+
case "FileIcon": return /* @__PURE__ */ jsx(ProteusFileIcon, { ...resolve(element) });
|
|
76
|
+
case "FileUpload": return /* @__PURE__ */ jsx(ProteusFileUpload, { ...resolve(element) });
|
|
77
|
+
case "Group": return /* @__PURE__ */ jsx(Group, { ...resolve(element) });
|
|
78
|
+
case "Heading": return /* @__PURE__ */ jsx(Heading, { ...resolve(element) });
|
|
79
|
+
case "Icon": {
|
|
80
|
+
const { filled, name, ...rest } = resolve(element);
|
|
81
|
+
const IconComp = icons?.[name];
|
|
82
|
+
if (!IconComp) {
|
|
83
|
+
if (strict) throw new Error(`Icon "${name}" not registered. Pass it via the \`icons\` prop on ProteusDocumentRenderer.`);
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
87
|
+
asChild: true,
|
|
88
|
+
...rest,
|
|
89
|
+
children: /* @__PURE__ */ jsx(IconComp, { filled })
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
case "Image": return /* @__PURE__ */ jsx(ProteusImage, { ...resolve(element) });
|
|
93
|
+
case "ImageCarousel": return /* @__PURE__ */ jsx(ProteusImageCarousel, { ...resolve(element) });
|
|
94
|
+
case "Input": return /* @__PURE__ */ jsx(ProteusInput, { ...resolve(element) });
|
|
95
|
+
case "Length": return /* @__PURE__ */ jsx(ProteusLength, { ...resolve(element) });
|
|
96
|
+
case "Link": return /* @__PURE__ */ jsx(Link, {
|
|
97
|
+
target: "_blank",
|
|
98
|
+
...resolve(element)
|
|
99
|
+
});
|
|
100
|
+
case "Map": return /* @__PURE__ */ jsx(ProteusMap, { ...resolve(element) });
|
|
101
|
+
case "MapIndex": return /* @__PURE__ */ jsx(ProteusMapIndex, { ...resolve(element) });
|
|
102
|
+
case "PillMenu": return /* @__PURE__ */ jsx(ProteusPillMenu, { ...resolve(element) });
|
|
103
|
+
case "Question": return /* @__PURE__ */ jsx(ProteusQuestion, { ...resolve(element) });
|
|
104
|
+
case "Range": return /* @__PURE__ */ jsx(Range, { ...resolve(element) });
|
|
105
|
+
case "Select": return /* @__PURE__ */ jsx(ProteusSelect, { ...resolve(element) });
|
|
106
|
+
case "SelectContent": return /* @__PURE__ */ jsx(SelectContent, { ...resolve(element) });
|
|
107
|
+
case "SelectTrigger": return /* @__PURE__ */ jsx(SelectTrigger, { ...resolve(element) });
|
|
108
|
+
case "Separator": return /* @__PURE__ */ jsx(Separator, { ...resolve(element) });
|
|
109
|
+
case "Show": return /* @__PURE__ */ jsx(ProteusShow, { ...resolve(element) });
|
|
110
|
+
case "Switch": return /* @__PURE__ */ jsx(ProteusSwitch, { ...resolve(element) });
|
|
111
|
+
case "Text": return /* @__PURE__ */ jsx(Text, { ...resolve(element) });
|
|
112
|
+
case "Textarea": return /* @__PURE__ */ jsx(ProteusTextarea, { ...resolve(element) });
|
|
113
|
+
case "Time": return /* @__PURE__ */ jsx(Time, { ...resolve(element) });
|
|
114
|
+
case "Value": return /* @__PURE__ */ jsx(ProteusValue, { ...element });
|
|
115
|
+
default: return null;
|
|
116
|
+
}
|
|
183
117
|
};
|
|
184
118
|
ProteusElement.displayName = "@optiaxiom/proteus/ProteusElement";
|
|
185
|
-
|
|
119
|
+
//#endregion
|
|
186
120
|
export { ProteusElement };
|
|
@@ -1,58 +1,57 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
function ProteusFederated({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(Component, { data, onEvent }) });
|
|
2
|
+
import { useProteusDocumentContext } from "../proteus-document/ProteusDocumentContext.js";
|
|
3
|
+
import { Suspense, useEffect, useId, useState } from "react";
|
|
4
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
5
|
+
import { getInstance, init, loadRemote, registerRemotes } from "@module-federation/enhanced/runtime";
|
|
6
|
+
//#region src/proteus-federated/ProteusFederated.tsx
|
|
7
|
+
function ProteusFederated({ entry, exposeKey = ".", fallback }) {
|
|
8
|
+
const { data, onEvent } = useProteusDocumentContext("@optiaxiom/proteus/ProteusFederated");
|
|
9
|
+
const name = `proteus_${useId().replace(/[^a-zA-Z0-9]/g, "_")}`;
|
|
10
|
+
const [Component, setComponent] = useState(null);
|
|
11
|
+
const [error, setError] = useState(false);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!entry) {
|
|
14
|
+
setError(true);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
let cancelled = false;
|
|
18
|
+
ensureInstance();
|
|
19
|
+
registerRemotes([{
|
|
20
|
+
entry,
|
|
21
|
+
name,
|
|
22
|
+
type: "esm"
|
|
23
|
+
}], { force: false });
|
|
24
|
+
const modulePath = exposeKey === "." ? "" : exposeKey.replace(/^\.\//, "");
|
|
25
|
+
loadRemote(modulePath ? `${name}/${modulePath}` : name).then((mod) => {
|
|
26
|
+
if (!cancelled && mod) setComponent(() => mod.default);
|
|
27
|
+
else if (!cancelled) setError(true);
|
|
28
|
+
}).catch(() => {
|
|
29
|
+
if (!cancelled) setError(true);
|
|
30
|
+
});
|
|
31
|
+
return () => {
|
|
32
|
+
cancelled = true;
|
|
33
|
+
};
|
|
34
|
+
}, [
|
|
35
|
+
entry,
|
|
36
|
+
exposeKey,
|
|
37
|
+
name
|
|
38
|
+
]);
|
|
39
|
+
if (error) return fallback ? /* @__PURE__ */ jsx(Fragment, { children: fallback }) : null;
|
|
40
|
+
if (!Component) return null;
|
|
41
|
+
return /* @__PURE__ */ jsx(Suspense, {
|
|
42
|
+
fallback: null,
|
|
43
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
44
|
+
data,
|
|
45
|
+
onEvent
|
|
46
|
+
})
|
|
47
|
+
});
|
|
50
48
|
}
|
|
51
49
|
function ensureInstance() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
if (!getInstance()) init({
|
|
51
|
+
name: "proteus-federated",
|
|
52
|
+
remotes: []
|
|
53
|
+
});
|
|
55
54
|
}
|
|
56
55
|
ProteusFederated.displayName = "@optiaxiom/proteus/ProteusFederated";
|
|
57
|
-
|
|
56
|
+
//#endregion
|
|
58
57
|
export { ProteusFederated };
|
|
@@ -1,47 +1,38 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { Box } from "@optiaxiom/react";
|
|
3
|
+
import "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { IconCode, IconFile, IconFileImage, IconFileLines, IconFileVideo, IconFileZipper, IconMusic, IconPresentationScreen, IconTableLayout } from "@optiaxiom/icons";
|
|
6
|
+
//#region src/proteus-file-icon/ProteusFileIcon.tsx
|
|
6
7
|
const mimeIconMap = [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
IconCode
|
|
17
|
-
],
|
|
18
|
-
[/^text\/|word|rtf/, IconFileLines]
|
|
8
|
+
[/^image\//, IconFileImage],
|
|
9
|
+
[/^video\//, IconFileVideo],
|
|
10
|
+
[/^audio\//, IconMusic],
|
|
11
|
+
[/presentation|powerpoint|keynote|slides/, IconPresentationScreen],
|
|
12
|
+
[/spreadsheet|excel|csv|tab-separated-values|tsv|parquet/, IconTableLayout],
|
|
13
|
+
[/zip|tar|compress|archive|x-7z|x-rar/, IconFileZipper],
|
|
14
|
+
[/pdf|wordprocessing|opendocument\.text/, IconFileLines],
|
|
15
|
+
[/json|xml|yaml|javascript|typescript|html|css|x-sh|x-python|code|script/, IconCode],
|
|
16
|
+
[/^text\/|word|rtf/, IconFileLines]
|
|
19
17
|
];
|
|
20
18
|
function ProteusFileIcon({ mimeType, ...props }) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
children: /* @__PURE__ */ jsx(Icon, {})
|
|
32
|
-
}
|
|
33
|
-
);
|
|
19
|
+
const Icon = getIconForMimeType(mimeType);
|
|
20
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
21
|
+
asChild: true,
|
|
22
|
+
bg: "bg.secondary",
|
|
23
|
+
color: "fg.tertiary",
|
|
24
|
+
p: "8",
|
|
25
|
+
rounded: "md",
|
|
26
|
+
...props,
|
|
27
|
+
children: /* @__PURE__ */ jsx(Icon, {})
|
|
28
|
+
});
|
|
34
29
|
}
|
|
35
30
|
function getIconForMimeType(mimeType) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return IconFile;
|
|
31
|
+
if (mimeType) {
|
|
32
|
+
for (const [pattern, Icon] of mimeIconMap) if (pattern.test(mimeType)) return Icon;
|
|
33
|
+
}
|
|
34
|
+
return IconFile;
|
|
44
35
|
}
|
|
45
36
|
ProteusFileIcon.displayName = "@optiaxiom/proteus/ProteusFileIcon";
|
|
46
|
-
|
|
37
|
+
//#endregion
|
|
47
38
|
export { ProteusFileIcon };
|