@optiaxiom/proteus 0.2.9 → 0.2.10

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.
@@ -1,5 +1,5 @@
1
- @layer optiaxiom._1fgw1dd;
2
- @layer optiaxiom._1fgw1dd {
1
+ @layer optiaxiom._13gldnk;
2
+ @layer optiaxiom._13gldnk {
3
3
  .ProteusChart__jmlqij1 {
4
4
  border-radius: 16px;
5
5
  }
@@ -1,5 +1,5 @@
1
- @layer optiaxiom._1fgw1dd;
2
- @layer optiaxiom._1fgw1dd {
1
+ @layer optiaxiom._13gldnk;
2
+ @layer optiaxiom._13gldnk {
3
3
  .ProteusChartTooltipContent__1gsvq810 {
4
4
  min-width: 128px;
5
5
  position: absolute;
@@ -1,5 +1,5 @@
1
- @layer optiaxiom._1fgw1dd;
2
- @layer optiaxiom._1fgw1dd {
1
+ @layer optiaxiom._13gldnk;
2
+ @layer optiaxiom._13gldnk {
3
3
  .ProteusDocumentShell__vpuvfj1 {
4
4
  margin: -4px;
5
5
  }
@@ -1,5 +1,5 @@
1
- @layer optiaxiom._1fgw1dd;
2
- @layer optiaxiom._1fgw1dd {
1
+ @layer optiaxiom._13gldnk;
2
+ @layer optiaxiom._13gldnk {
3
3
  .ProteusImageCarousel__1t6qej70 {
4
4
  outline: none;
5
5
  user-select: none;
@@ -1,5 +1,5 @@
1
- @layer optiaxiom._1fgw1dd;
2
- @layer optiaxiom._1fgw1dd {
1
+ @layer optiaxiom._13gldnk;
2
+ @layer optiaxiom._13gldnk {
3
3
  .ProteusQuestion__8f590p0 {
4
4
  outline: none;
5
5
  }
package/dist/esm/index.js CHANGED
@@ -5,6 +5,7 @@ export { ProteusDataTable } from './proteus-data-table/ProteusDataTable.js';
5
5
  export { ProteusDocumentRenderer } from './proteus-document/ProteusDocumentRenderer.js';
6
6
  export { ProteusDocumentShell } from './proteus-document/ProteusDocumentShell.js';
7
7
  export { safeParseDocument } from './proteus-document/schemas.js';
8
+ export { ProteusFederated } from './proteus-federated/ProteusFederated.js';
8
9
  export { ProteusFileUpload } from './proteus-file-upload/ProteusFileUpload.js';
9
10
  export { ProteusImage } from './proteus-image/ProteusImage.js';
10
11
  export { ProteusImageCarousel } from './proteus-image-carousel/ProteusImageCarousel.js';
@@ -1,4 +1,4 @@
1
- import './../assets/src/proteus-chart/ProteusChart.css.ts.vanilla-BO0-TwP_.css';
1
+ import './../assets/src/proteus-chart/ProteusChart.css.ts.vanilla-9aXajeqc.css';
2
2
  import { recipe } from '@optiaxiom/react/css-runtime';
3
3
 
4
4
  var chart = recipe({base:[{border:'1',borderColor:'border.tertiary',fontSize:'sm',p:'16'},'ProteusChart__jmlqij1','ProteusChart__jmlqij0']});
@@ -1,4 +1,4 @@
1
- import './../assets/src/proteus-chart/ProteusChartTooltipContent.css.ts.vanilla-ETMXhILd.css';
1
+ import './../assets/src/proteus-chart/ProteusChartTooltipContent.css.ts.vanilla-BvKLAJt6.css';
2
2
  import { recipe } from '@optiaxiom/react/css-runtime';
3
3
 
4
4
  var tooltip = recipe({base:[{bg:'bg.default',border:'1',borderColor:'border.secondary',display:'grid',fontSize:'sm',gap:'6',pointerEvents:'none',px:'8',py:'10',rounded:'lg',shadow:'lg',transition:'all',z:'popover'},'ProteusChartTooltipContent__1gsvq810']});
@@ -1,4 +1,4 @@
1
- import './../assets/src/proteus-document/ProteusDocumentShell.css.ts.vanilla-CDxANCyw.css';
1
+ import './../assets/src/proteus-document/ProteusDocumentShell.css.ts.vanilla-DKjJk3n9.css';
2
2
  import { recipe } from '@optiaxiom/react/css-runtime';
3
3
 
4
4
  var body = recipe({base:[{flexDirection:'column',gap:'16'},'ProteusDocumentShell__vpuvfj0'],variants:{truncate:{false:{},true:[{maxH:'sm',overflow:'auto',p:'4'},'ProteusDocumentShell__vpuvfj1']}}});
@@ -11,6 +11,7 @@ import { useProteusDocumentContext } from '../proteus-document/ProteusDocumentCo
11
11
  import { useProteusDocumentPathContext } from '../proteus-document/ProteusDocumentPathContext.js';
12
12
  import { resolveProteusProp } from '../proteus-document/resolveProteusProp.js';
13
13
  import { safeParseElement } from '../proteus-document/schemas.js';
14
+ import { ProteusFederated } from '../proteus-federated/ProteusFederated.js';
14
15
  import { ProteusFileUpload } from '../proteus-file-upload/ProteusFileUpload.js';
15
16
  import { ProteusImageCarousel } from '../proteus-image-carousel/ProteusImageCarousel.js';
16
17
  import { ProteusImage } from '../proteus-image/ProteusImage.js';
@@ -96,6 +97,13 @@ const ProteusElement = ({
96
97
  ...resolve(element)
97
98
  }
98
99
  );
100
+ case "Federated":
101
+ return /* @__PURE__ */ jsx(
102
+ ProteusFederated,
103
+ {
104
+ ...resolve(element)
105
+ }
106
+ );
99
107
  case "Field":
100
108
  return /* @__PURE__ */ jsx(Field, { ...resolve(element) });
101
109
  case "FileUpload":
@@ -0,0 +1,58 @@
1
+ "use client";
2
+ import { jsx, Fragment } from 'react/jsx-runtime';
3
+ import { registerRemotes, loadRemote, getInstance, init } from '@module-federation/enhanced/runtime';
4
+ import { useId, useState, useEffect, Suspense } from 'react';
5
+ import { useProteusDocumentContext } from '../proteus-document/ProteusDocumentContext.js';
6
+
7
+ function ProteusFederated({
8
+ entry,
9
+ exposeKey = ".",
10
+ fallback
11
+ }) {
12
+ const { data, onEvent } = useProteusDocumentContext(
13
+ "@optiaxiom/proteus/ProteusFederated"
14
+ );
15
+ const id = useId();
16
+ const name = `proteus_${id.replace(/[^a-zA-Z0-9]/g, "_")}`;
17
+ const [Component, setComponent] = useState(null);
18
+ const [error, setError] = useState(false);
19
+ useEffect(() => {
20
+ if (!entry) {
21
+ setError(true);
22
+ return;
23
+ }
24
+ let cancelled = false;
25
+ ensureInstance();
26
+ registerRemotes([{ entry, name, type: "esm" }], { force: false });
27
+ const modulePath = exposeKey === "." ? "" : exposeKey.replace(/^\.\//, "");
28
+ const remoteId = modulePath ? `${name}/${modulePath}` : name;
29
+ loadRemote(remoteId).then((mod) => {
30
+ if (!cancelled && mod) {
31
+ setComponent(() => mod.default);
32
+ } else if (!cancelled) {
33
+ setError(true);
34
+ }
35
+ }).catch(() => {
36
+ if (!cancelled)
37
+ setError(true);
38
+ });
39
+ return () => {
40
+ cancelled = true;
41
+ };
42
+ }, [entry, exposeKey, name]);
43
+ if (error) {
44
+ return fallback ? /* @__PURE__ */ jsx(Fragment, { children: fallback }) : null;
45
+ }
46
+ if (!Component) {
47
+ return null;
48
+ }
49
+ return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(Component, { data, onEvent }) });
50
+ }
51
+ function ensureInstance() {
52
+ if (!getInstance()) {
53
+ init({ name: "proteus-federated", remotes: [] });
54
+ }
55
+ }
56
+ ProteusFederated.displayName = "@optiaxiom/proteus/ProteusFederated";
57
+
58
+ export { ProteusFederated };
@@ -1,4 +1,4 @@
1
- import './../assets/src/proteus-image-carousel/ProteusImageCarousel.css.ts.vanilla-CVLALefb.css';
1
+ import './../assets/src/proteus-image-carousel/ProteusImageCarousel.css.ts.vanilla-CVsqKi1-.css';
2
2
  import { recipe } from '@optiaxiom/react/css-runtime';
3
3
 
4
4
  var carousel = recipe({base:[{flexDirection:'column',gap:'12'},'ProteusImageCarousel__1t6qej70']});
@@ -1,4 +1,4 @@
1
- import './../assets/src/proteus-question/ProteusQuestion.css.ts.vanilla-DKDk8HIF.css';
1
+ import './../assets/src/proteus-question/ProteusQuestion.css.ts.vanilla-DAuhHkyp.css';
2
2
  import { recipe } from '@optiaxiom/react/css-runtime';
3
3
 
4
4
  var addon = recipe({base:[{display:'grid',fontWeight:'500',placeItems:'center',rounded:'lg',size:'md',transition:'colors'},'ProteusQuestion__8f590p3'],variants:{cursor:{pointer:{cursor:'pointer'}}}});
@@ -2731,6 +2731,9 @@ var definitions = {
2731
2731
  {
2732
2732
  $ref: "#/definitions/ProteusDataTable"
2733
2733
  },
2734
+ {
2735
+ $ref: "#/definitions/ProteusFederated"
2736
+ },
2734
2737
  {
2735
2738
  $ref: "#/definitions/ProteusField"
2736
2739
  },
@@ -4948,6 +4951,38 @@ var definitions = {
4948
4951
  ],
4949
4952
  type: "object"
4950
4953
  },
4954
+ ProteusFederated: {
4955
+ additionalProperties: false,
4956
+ examples: [
4957
+ {
4958
+ $type: "Federated",
4959
+ entry: "https://widgets.example.com/remoteEntry.js"
4960
+ }
4961
+ ],
4962
+ properties: {
4963
+ $type: {
4964
+ "const": "Federated"
4965
+ },
4966
+ entry: {
4967
+ description: "URL to the remote application's remoteEntry.js or mf-manifest.json",
4968
+ type: "string"
4969
+ },
4970
+ exposeKey: {
4971
+ "default": ".",
4972
+ description: "The key from the remote's ModuleFederationPlugin exposes config (e.g. './App'). Defaults to '.' (root export)",
4973
+ type: "string"
4974
+ },
4975
+ fallback: {
4976
+ $ref: "#/definitions/ProteusNode",
4977
+ description: "Content rendered when the federated component fails to load"
4978
+ }
4979
+ },
4980
+ required: [
4981
+ "$type",
4982
+ "entry"
4983
+ ],
4984
+ type: "object"
4985
+ },
4951
4986
  ProteusField: {
4952
4987
  additionalProperties: false,
4953
4988
  examples: [
@@ -2719,6 +2719,9 @@ var definitions = {
2719
2719
  {
2720
2720
  $ref: "#/definitions/ProteusDataTable"
2721
2721
  },
2722
+ {
2723
+ $ref: "#/definitions/ProteusFederated"
2724
+ },
2722
2725
  {
2723
2726
  $ref: "#/definitions/ProteusField"
2724
2727
  },
@@ -4915,6 +4918,37 @@ var definitions = {
4915
4918
  ],
4916
4919
  type: "object"
4917
4920
  },
4921
+ ProteusFederated: {
4922
+ examples: [
4923
+ {
4924
+ $type: "Federated",
4925
+ entry: "https://widgets.example.com/remoteEntry.js"
4926
+ }
4927
+ ],
4928
+ properties: {
4929
+ $type: {
4930
+ "const": "Federated"
4931
+ },
4932
+ entry: {
4933
+ description: "URL to the remote application's remoteEntry.js or mf-manifest.json",
4934
+ type: "string"
4935
+ },
4936
+ exposeKey: {
4937
+ "default": ".",
4938
+ description: "The key from the remote's ModuleFederationPlugin exposes config (e.g. './App'). Defaults to '.' (root export)",
4939
+ type: "string"
4940
+ },
4941
+ fallback: {
4942
+ $ref: "#/definitions/ProteusNode",
4943
+ description: "Content rendered when the federated component fails to load"
4944
+ }
4945
+ },
4946
+ required: [
4947
+ "$type",
4948
+ "entry"
4949
+ ],
4950
+ type: "object"
4951
+ },
4918
4952
  ProteusField: {
4919
4953
  examples: [
4920
4954
  {
package/dist/index.d.ts CHANGED
@@ -77,6 +77,25 @@ declare const ProteusDataTable: {
77
77
  displayName: string;
78
78
  };
79
79
 
80
+ type ProteusFederatedProps = {
81
+ /**
82
+ * URL to the remote's remoteEntry.js or mf-manifest.json
83
+ */
84
+ entry: string;
85
+ /**
86
+ * The key from the remote's ModuleFederationPlugin exposes config (e.g. './App'). Defaults to '.' (root export)
87
+ */
88
+ exposeKey?: string;
89
+ /**
90
+ * Content rendered when the federated component fails to load
91
+ */
92
+ fallback?: ReactNode;
93
+ };
94
+ declare function ProteusFederated({ entry, exposeKey, fallback, }: ProteusFederatedProps): react_jsx_runtime.JSX.Element | null;
95
+ declare namespace ProteusFederated {
96
+ var displayName: string;
97
+ }
98
+
80
99
  type ProteusFileUploadProps = {
81
100
  /**
82
101
  * File types to accept; array of MIME types or extensions.
@@ -400,5 +419,5 @@ declare namespace ProteusTextarea {
400
419
 
401
420
  declare function useProteusValue(element: ProteusValueProps): any;
402
421
 
403
- export { ProteusAction, ProteusBridge, ProteusChart, ProteusDataTable, ProteusDocumentRenderer, ProteusDocumentShell, ProteusFileUpload, ProteusImage, ProteusImageCarousel, ProteusInput, ProteusMap, ProteusSelect, ProteusShow, ProteusTextarea, safeParseDocument, useProteusValue };
422
+ export { ProteusAction, ProteusBridge, ProteusChart, ProteusDataTable, ProteusDocumentRenderer, ProteusDocumentShell, ProteusFederated, ProteusFileUpload, ProteusImage, ProteusImageCarousel, ProteusInput, ProteusMap, ProteusSelect, ProteusShow, ProteusTextarea, safeParseDocument, useProteusValue };
404
423
  export type { ProteusDocumentRendererProps, ProteusDocumentShellProps, ProteusFileUploadProps, StructuredMessage, UploadFile };