@mittwald/flow-remote-react-renderer 0.2.0-alpha.59 → 0.2.0-alpha.590
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/js/RemoteRenderer.mjs +11 -11
- package/dist/js/RemoteRenderer.mjs.map +1 -1
- package/dist/js/core/src/file.mjs +17 -0
- package/dist/js/core/src/file.mjs.map +1 -0
- package/dist/js/index.mjs +1 -4
- package/dist/js/index.mjs.map +1 -1
- package/dist/js/remote-react-renderer/src/RemoteRendererBrowser.mjs +131 -0
- package/dist/js/remote-react-renderer/src/RemoteRendererBrowser.mjs.map +1 -0
- package/dist/js/remote-react-renderer/src/auto-generated/index.mjs +312 -0
- package/dist/js/remote-react-renderer/src/auto-generated/index.mjs.map +1 -0
- package/dist/js/remote-react-renderer/src/components/Form.mjs +37 -0
- package/dist/js/remote-react-renderer/src/components/Form.mjs.map +1 -0
- package/dist/js/remote-react-renderer/src/components/NotificationRenderController.mjs +25 -0
- package/dist/js/remote-react-renderer/src/components/NotificationRenderController.mjs.map +1 -0
- package/dist/js/remote-react-renderer/src/components/SlotRootWrapper.mjs +10 -0
- package/dist/js/remote-react-renderer/src/components/SlotRootWrapper.mjs.map +1 -0
- package/dist/js/remote-react-renderer/src/components/lib/prepareFormData.mjs +29 -0
- package/dist/js/remote-react-renderer/src/components/lib/prepareFormData.mjs.map +1 -0
- package/dist/js/remote-react-renderer/src/components.mjs +54 -0
- package/dist/js/remote-react-renderer/src/components.mjs.map +1 -0
- package/dist/js/remote-react-renderer/src/hooks/useControllableSuspenseTrigger.mjs +30 -0
- package/dist/js/remote-react-renderer/src/hooks/useControllableSuspenseTrigger.mjs.map +1 -0
- package/dist/js/remote-react-renderer/src/hooks/useMergedComponents.mjs +24 -0
- package/dist/js/remote-react-renderer/src/hooks/useMergedComponents.mjs.map +1 -0
- package/dist/js/remote-react-renderer/src/hooks/useUpdateHostPathnameOnRemote.mjs +17 -0
- package/dist/js/remote-react-renderer/src/hooks/useUpdateHostPathnameOnRemote.mjs.map +1 -0
- package/dist/js/remote-react-renderer/src/integrations/react-hook-form/Form.mjs +16 -0
- package/dist/js/remote-react-renderer/src/integrations/react-hook-form/Form.mjs.map +1 -0
- package/dist/js/remote-react-renderer/src/lib/createFlowRemoteComponentRenderer.mjs +47 -0
- package/dist/js/remote-react-renderer/src/lib/createFlowRemoteComponentRenderer.mjs.map +1 -0
- package/dist/js/remote-react-renderer/src/lib/elementFactory.mjs +23 -0
- package/dist/js/remote-react-renderer/src/lib/elementFactory.mjs.map +1 -0
- package/dist/js/{lib → remote-react-renderer/src/lib}/mapAttributeToReactProperty.mjs +4 -4
- package/dist/js/remote-react-renderer/src/lib/mapAttributeToReactProperty.mjs.map +1 -0
- package/dist/js/remote-react-renderer/src/lib/propClassifiers.mjs +7 -0
- package/dist/js/remote-react-renderer/src/lib/propClassifiers.mjs.map +1 -0
- package/dist/types/RemoteRenderer.d.ts +2 -2
- package/dist/types/RemoteRenderer.d.ts.map +1 -1
- package/dist/types/RemoteRendererBrowser.d.ts +18 -0
- package/dist/types/RemoteRendererBrowser.d.ts.map +1 -0
- package/dist/types/auto-generated/index.d.ts +119 -99
- package/dist/types/auto-generated/index.d.ts.map +1 -1
- package/dist/types/components/Form.d.ts +8 -2
- package/dist/types/components/Form.d.ts.map +1 -1
- package/dist/types/components/NotificationRenderController.d.ts +4 -0
- package/dist/types/components/NotificationRenderController.d.ts.map +1 -0
- package/dist/types/components/SlotRootWrapper.d.ts +4 -0
- package/dist/types/components/SlotRootWrapper.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +3 -0
- package/dist/types/components/index.d.ts.map +1 -0
- package/dist/types/components/lib/prepareFormData.d.ts +2 -0
- package/dist/types/components/lib/prepareFormData.d.ts.map +1 -0
- package/dist/types/components.d.ts +135 -105
- package/dist/types/components.d.ts.map +1 -1
- package/dist/types/hooks/useControllableSuspenseTrigger.d.ts +5 -0
- package/dist/types/hooks/useControllableSuspenseTrigger.d.ts.map +1 -0
- package/dist/types/hooks/useMergedComponents.d.ts +5 -0
- package/dist/types/hooks/useMergedComponents.d.ts.map +1 -0
- package/dist/types/hooks/useUpdateHostPathnameOnRemote.d.ts +4 -0
- package/dist/types/hooks/useUpdateHostPathnameOnRemote.d.ts.map +1 -0
- package/dist/types/integrations/react-hook-form/Form.d.ts +13 -0
- package/dist/types/integrations/react-hook-form/Form.d.ts.map +1 -0
- package/dist/types/lib/createFlowRemoteComponentRenderer.d.ts +2 -2
- package/dist/types/lib/createFlowRemoteComponentRenderer.d.ts.map +1 -1
- package/dist/types/lib/elementFactory.d.ts +4 -1
- package/dist/types/lib/elementFactory.d.ts.map +1 -1
- package/dist/types/lib/mapAttributeToReactProperty.d.ts.map +1 -1
- package/dist/types/lib/propClassifiers.d.ts +0 -2
- package/dist/types/lib/propClassifiers.d.ts.map +1 -1
- package/dist/types/lib/types.d.ts +1 -1
- package/dist/types/lib/types.d.ts.map +1 -1
- package/package.json +26 -23
- package/dist/js/RemoteRendererClient.mjs +0 -55
- package/dist/js/RemoteRendererClient.mjs.map +0 -1
- package/dist/js/auto-generated/index.mjs +0 -112
- package/dist/js/auto-generated/index.mjs.map +0 -1
- package/dist/js/components/Form.mjs +0 -22
- package/dist/js/components/Form.mjs.map +0 -1
- package/dist/js/components/lib/getFormDataObject.mjs +0 -7
- package/dist/js/components/lib/getFormDataObject.mjs.map +0 -1
- package/dist/js/components.mjs +0 -26
- package/dist/js/components.mjs.map +0 -1
- package/dist/js/hooks/useIsMounted.mjs +0 -14
- package/dist/js/hooks/useIsMounted.mjs.map +0 -1
- package/dist/js/lib/createFlowRemoteComponentRenderer.mjs +0 -36
- package/dist/js/lib/createFlowRemoteComponentRenderer.mjs.map +0 -1
- package/dist/js/lib/elementFactory.mjs +0 -19
- package/dist/js/lib/elementFactory.mjs.map +0 -1
- package/dist/js/lib/mapAttributeToReactProperty.mjs.map +0 -1
- package/dist/js/lib/propClassifiers.mjs +0 -13
- package/dist/js/lib/propClassifiers.mjs.map +0 -1
- package/dist/types/RemoteRendererClient.d.ts +0 -11
- package/dist/types/RemoteRendererClient.d.ts.map +0 -1
- package/dist/types/components/lib/getFormDataObject.d.ts +0 -2
- package/dist/types/components/lib/getFormDataObject.d.ts.map +0 -1
- package/dist/types/lib/stringChildrenExtractor.d.ts +0 -3
- package/dist/types/lib/stringChildrenExtractor.d.ts.map +0 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import 'react';
|
|
5
|
+
import { prepareFormData } from './lib/prepareFormData.mjs';
|
|
6
|
+
|
|
7
|
+
const Form = (props) => {
|
|
8
|
+
const {
|
|
9
|
+
action: onActionFromProps,
|
|
10
|
+
onSubmit: onSubmitFromProps,
|
|
11
|
+
ref,
|
|
12
|
+
...rest
|
|
13
|
+
} = props;
|
|
14
|
+
const onSubmit = async (event) => {
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
const resolvedData = await prepareFormData(
|
|
17
|
+
new FormData(event.currentTarget)
|
|
18
|
+
);
|
|
19
|
+
await onSubmitFromProps?.(resolvedData);
|
|
20
|
+
};
|
|
21
|
+
const onAction = async (formData) => {
|
|
22
|
+
const resolvedFormData = await prepareFormData(formData);
|
|
23
|
+
await onActionFromProps?.(resolvedFormData);
|
|
24
|
+
};
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
"form",
|
|
27
|
+
{
|
|
28
|
+
...rest,
|
|
29
|
+
ref,
|
|
30
|
+
action: onActionFromProps ? onAction : void 0,
|
|
31
|
+
onSubmit: onSubmitFromProps ? onSubmit : void 0
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { Form };
|
|
37
|
+
//# sourceMappingURL=Form.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.mjs","sources":["../../../../../src/components/Form.tsx"],"sourcesContent":["import {\n type FC,\n type FormEvent,\n type PropsWithChildren,\n type Ref,\n} from \"react\";\nimport { prepareFormData } from \"@/components/lib/prepareFormData\";\n\ntype FormProps = {\n action?: (data: FormData) => void | Promise<void>;\n onSubmit?: (data: FormData) => void | Promise<void>;\n ref?: Ref<HTMLFormElement>;\n} & PropsWithChildren;\n\nexport const Form: FC<FormProps> = (props) => {\n const {\n action: onActionFromProps,\n onSubmit: onSubmitFromProps,\n ref,\n ...rest\n } = props;\n\n const onSubmit = async (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n const resolvedData = await prepareFormData(\n new FormData(event.currentTarget),\n );\n await onSubmitFromProps?.(resolvedData);\n };\n\n const onAction = async (formData: FormData) => {\n const resolvedFormData = await prepareFormData(formData);\n await onActionFromProps?.(resolvedFormData);\n };\n\n return (\n <form\n {...rest}\n ref={ref}\n action={onActionFromProps ? onAction : undefined}\n onSubmit={onSubmitFromProps ? onSubmit : undefined}\n />\n );\n};\n"],"names":[],"mappings":";;;;AAcO,MAAM,IAAA,GAAsB,CAAC,KAAA,KAAU;AAC5C,EAAA,MAAM;AAAA,IACJ,MAAA,EAAQ,iBAAA;AAAA,IACR,QAAA,EAAU,iBAAA;AAAA,IACV,GAAA;AAAA,IACA,GAAG;AAAA,GACL,GAAI,KAAA;AAEJ,EAAA,MAAM,QAAA,GAAW,OAAO,KAAA,KAAsC;AAC5D,IAAA,KAAA,CAAM,cAAA,EAAe;AACrB,IAAA,MAAM,eAAe,MAAM,eAAA;AAAA,MACzB,IAAI,QAAA,CAAS,KAAA,CAAM,aAAa;AAAA,KAClC;AACA,IAAA,MAAM,oBAAoB,YAAY,CAAA;AAAA,EACxC,CAAA;AAEA,EAAA,MAAM,QAAA,GAAW,OAAO,QAAA,KAAuB;AAC7C,IAAA,MAAM,gBAAA,GAAmB,MAAM,eAAA,CAAgB,QAAQ,CAAA;AACvD,IAAA,MAAM,oBAAoB,gBAAgB,CAAA;AAAA,EAC5C,CAAA;AAEA,EAAA,uBACE,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,GAAA;AAAA,MACA,MAAA,EAAQ,oBAAoB,QAAA,GAAW,MAAA;AAAA,MACvC,QAAA,EAAU,oBAAoB,QAAA,GAAW;AAAA;AAAA,GAC3C;AAEJ;;;;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useNotificationController, Notification } from '@mittwald/flow-react-components';
|
|
5
|
+
import { useRef, useEffect } from 'react';
|
|
6
|
+
|
|
7
|
+
const NotificationRenderController = (props) => {
|
|
8
|
+
const notifications = useNotificationController();
|
|
9
|
+
const isAdded = useRef(false);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (isAdded.current) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const id = notifications.add(/* @__PURE__ */ jsx(Notification, { ...props }));
|
|
15
|
+
isAdded.current = true;
|
|
16
|
+
return () => {
|
|
17
|
+
notifications.remove(id);
|
|
18
|
+
isAdded.current = false;
|
|
19
|
+
};
|
|
20
|
+
}, [notifications]);
|
|
21
|
+
return null;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { NotificationRenderController };
|
|
25
|
+
//# sourceMappingURL=NotificationRenderController.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationRenderController.mjs","sources":["../../../../../src/components/NotificationRenderController.tsx"],"sourcesContent":["import {\n useNotificationController,\n type NotificationProps,\n Notification,\n} from \"@mittwald/flow-react-components\";\nimport { useEffect, useRef, type FC } from \"react\";\n\nexport const NotificationRenderController: FC<NotificationProps> = (props) => {\n const notifications = useNotificationController();\n const isAdded = useRef(false);\n\n useEffect(() => {\n if (isAdded.current) {\n return;\n }\n\n const id = notifications.add(<Notification {...props} />);\n isAdded.current = true;\n\n return () => {\n notifications.remove(id);\n isAdded.current = false;\n };\n }, [notifications]);\n\n return null;\n};\n"],"names":[],"mappings":";;;;AAOO,MAAM,4BAAA,GAAsD,CAAC,KAAA,KAAU;AAC5E,EAAA,MAAM,gBAAgB,yBAAA,EAA0B;AAChD,EAAA,MAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AAE5B,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,QAAQ,OAAA,EAAS;AACnB,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,KAAK,aAAA,CAAc,GAAA,qBAAK,YAAA,EAAA,EAAc,GAAG,OAAO,CAAE,CAAA;AACxD,IAAA,OAAA,CAAQ,OAAA,GAAU,IAAA;AAElB,IAAA,OAAO,MAAM;AACX,MAAA,aAAA,CAAc,OAAO,EAAE,CAAA;AACvB,MAAA,OAAA,CAAQ,OAAA,GAAU,KAAA;AAAA,IACpB,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,aAAa,CAAC,CAAA;AAElB,EAAA,OAAO,IAAA;AACT;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import React, { createElement } from 'react';
|
|
4
|
+
|
|
5
|
+
const SlotRootWrapper = (props) => {
|
|
6
|
+
return createElement(React.Fragment, {}, props.children);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { SlotRootWrapper, SlotRootWrapper as default };
|
|
10
|
+
//# sourceMappingURL=SlotRootWrapper.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlotRootWrapper.mjs","sources":["../../../../../src/components/SlotRootWrapper.ts"],"sourcesContent":["import React, { createElement, type FC, type PropsWithChildren } from \"react\";\n\nexport const SlotRootWrapper: FC<PropsWithChildren> = (props) => {\n return createElement(React.Fragment, {}, props.children);\n};\n\nexport default SlotRootWrapper;\n"],"names":[],"mappings":";;AAEO,MAAM,eAAA,GAAyC,CAAC,KAAA,KAAU;AAC/D,EAAA,OAAO,cAAc,KAAA,CAAM,QAAA,EAAU,EAAC,EAAG,MAAM,QAAQ,CAAA;AACzD;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import { addAwaitedArrayBuffer } from '../../../../core/src/file.mjs';
|
|
4
|
+
|
|
5
|
+
const prepareFormData = async (formData) => {
|
|
6
|
+
for (const [fieldName] of formData) {
|
|
7
|
+
const fieldValues = formData.getAll(fieldName);
|
|
8
|
+
if (fieldValues.every((v) => v instanceof File)) {
|
|
9
|
+
formData.delete(fieldName);
|
|
10
|
+
}
|
|
11
|
+
for (let value of fieldValues) {
|
|
12
|
+
if (value instanceof File) {
|
|
13
|
+
if (!value.name || value.size <= 0) {
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
value = await addAwaitedArrayBuffer(value);
|
|
17
|
+
if (formData.has(fieldName)) {
|
|
18
|
+
formData.append(fieldName, value);
|
|
19
|
+
} else {
|
|
20
|
+
formData.set(fieldName, value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return formData;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { prepareFormData };
|
|
29
|
+
//# sourceMappingURL=prepareFormData.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareFormData.mjs","sources":["../../../../../../src/components/lib/prepareFormData.ts"],"sourcesContent":["import { addAwaitedArrayBuffer } from \"@mittwald/flow-core\";\n\nexport const prepareFormData = async (\n formData: FormData,\n): Promise<FormData> => {\n for (const [fieldName] of formData) {\n const fieldValues = formData.getAll(fieldName);\n\n if (fieldValues.every((v) => v instanceof File)) {\n formData.delete(fieldName);\n }\n\n for (let value of fieldValues) {\n if (value instanceof File) {\n if (!value.name || value.size <= 0) {\n break;\n }\n\n value = await addAwaitedArrayBuffer(value);\n if (formData.has(fieldName)) {\n formData.append(fieldName, value);\n } else {\n formData.set(fieldName, value);\n }\n }\n }\n }\n\n return formData;\n};\n"],"names":[],"mappings":";;AAEO,MAAM,eAAA,GAAkB,OAC7B,QAAA,KACsB;AACtB,EAAA,KAAA,MAAW,CAAC,SAAS,CAAA,IAAK,QAAA,EAAU;AAClC,IAAA,MAAM,WAAA,GAAc,QAAA,CAAS,MAAA,CAAO,SAAS,CAAA;AAE7C,IAAA,IAAI,YAAY,KAAA,CAAM,CAAC,CAAA,KAAM,CAAA,YAAa,IAAI,CAAA,EAAG;AAC/C,MAAA,QAAA,CAAS,OAAO,SAAS,CAAA;AAAA,IAC3B;AAEA,IAAA,KAAA,IAAS,SAAS,WAAA,EAAa;AAC7B,MAAA,IAAI,iBAAiB,IAAA,EAAM;AACzB,QAAA,IAAI,CAAC,KAAA,CAAM,IAAA,IAAQ,KAAA,CAAM,QAAQ,CAAA,EAAG;AAClC,UAAA;AAAA,QACF;AAEA,QAAA,KAAA,GAAQ,MAAM,sBAAsB,KAAK,CAAA;AACzC,QAAA,IAAI,QAAA,CAAS,GAAA,CAAI,SAAS,CAAA,EAAG;AAC3B,UAAA,QAAA,CAAS,MAAA,CAAO,WAAW,KAAK,CAAA;AAAA,QAClC,CAAA,MAAO;AACL,UAAA,QAAA,CAAS,GAAA,CAAI,WAAW,KAAK,CAAA;AAAA,QAC/B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,QAAA;AACT;;;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import { createFlowRemoteComponentRenderer } from './lib/createFlowRemoteComponentRenderer.mjs';
|
|
4
|
+
import { elementFactory } from './lib/elementFactory.mjs';
|
|
5
|
+
import { createRemoteComponentRenderer } from '@mittwald/remote-dom-react/host';
|
|
6
|
+
import { flowComponents } from './auto-generated/index.mjs';
|
|
7
|
+
import { Form as Form$1 } from './components/Form.mjs';
|
|
8
|
+
import { SlotRootWrapper } from './components/SlotRootWrapper.mjs';
|
|
9
|
+
import { Form } from './integrations/react-hook-form/Form.mjs';
|
|
10
|
+
import { NotificationRenderController } from './components/NotificationRenderController.mjs';
|
|
11
|
+
|
|
12
|
+
const htmlComponentsMap = {
|
|
13
|
+
svg: createRemoteComponentRenderer(elementFactory("svg")),
|
|
14
|
+
circle: createRemoteComponentRenderer(elementFactory("circle")),
|
|
15
|
+
g: createRemoteComponentRenderer(elementFactory("g")),
|
|
16
|
+
path: createRemoteComponentRenderer(elementFactory("path")),
|
|
17
|
+
strong: createRemoteComponentRenderer(elementFactory("strong")),
|
|
18
|
+
s: createRemoteComponentRenderer(elementFactory("s")),
|
|
19
|
+
ul: createRemoteComponentRenderer(elementFactory("ul")),
|
|
20
|
+
ol: createRemoteComponentRenderer(elementFactory("ol")),
|
|
21
|
+
li: createRemoteComponentRenderer(elementFactory("li")),
|
|
22
|
+
small: createRemoteComponentRenderer(elementFactory("small")),
|
|
23
|
+
br: createRemoteComponentRenderer(
|
|
24
|
+
elementFactory("br", { isVoidElement: true })
|
|
25
|
+
)
|
|
26
|
+
};
|
|
27
|
+
const skippedComponentsMap = {
|
|
28
|
+
script: () => null
|
|
29
|
+
};
|
|
30
|
+
const flowComponentsMap = {
|
|
31
|
+
"flr-form": createFlowRemoteComponentRenderer("Form", Form$1),
|
|
32
|
+
"flr-rhf-form": createFlowRemoteComponentRenderer("RhfForm", Form),
|
|
33
|
+
"flr-slot-root-wrapper": createFlowRemoteComponentRenderer(
|
|
34
|
+
"SlotRootWrapper",
|
|
35
|
+
SlotRootWrapper
|
|
36
|
+
),
|
|
37
|
+
"flr-notification": createFlowRemoteComponentRenderer(
|
|
38
|
+
"Notification",
|
|
39
|
+
NotificationRenderController
|
|
40
|
+
),
|
|
41
|
+
"flr-clear-props-context-content": createFlowRemoteComponentRenderer(
|
|
42
|
+
"ClearPropsContextContent",
|
|
43
|
+
SlotRootWrapper
|
|
44
|
+
)
|
|
45
|
+
};
|
|
46
|
+
const components = {
|
|
47
|
+
...htmlComponentsMap,
|
|
48
|
+
...skippedComponentsMap,
|
|
49
|
+
...flowComponents,
|
|
50
|
+
...flowComponentsMap
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { components };
|
|
54
|
+
//# sourceMappingURL=components.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.mjs","sources":["../../../../src/components.ts"],"sourcesContent":["import { createFlowRemoteComponentRenderer } from \"@/lib/createFlowRemoteComponentRenderer\";\nimport { elementFactory } from \"@/lib/elementFactory\";\nimport { createRemoteComponentRenderer } from \"@mittwald/remote-dom-react/host\";\nimport autoGenerated from \"./auto-generated\";\nimport { Form, SlotRootWrapper } from \"@/components/\";\nimport { Form as RhfForm } from \"@/integrations/react-hook-form/Form\";\nimport { NotificationRenderController } from \"@/components/NotificationRenderController\";\n\nconst htmlComponentsMap = {\n svg: createRemoteComponentRenderer(elementFactory(\"svg\")),\n circle: createRemoteComponentRenderer(elementFactory(\"circle\")),\n g: createRemoteComponentRenderer(elementFactory(\"g\")),\n path: createRemoteComponentRenderer(elementFactory(\"path\")),\n strong: createRemoteComponentRenderer(elementFactory(\"strong\")),\n s: createRemoteComponentRenderer(elementFactory(\"s\")),\n ul: createRemoteComponentRenderer(elementFactory(\"ul\")),\n ol: createRemoteComponentRenderer(elementFactory(\"ol\")),\n li: createRemoteComponentRenderer(elementFactory(\"li\")),\n small: createRemoteComponentRenderer(elementFactory(\"small\")),\n br: createRemoteComponentRenderer(\n elementFactory(\"br\", { isVoidElement: true }),\n ),\n} as const;\n\n/**\n * Components that are allowed to be used remotely but should not be rendered on\n * the host.\n */\nconst skippedComponentsMap = {\n script: () => null,\n} as const;\n\nconst flowComponentsMap = {\n \"flr-form\": createFlowRemoteComponentRenderer(\"Form\", Form),\n \"flr-rhf-form\": createFlowRemoteComponentRenderer(\"RhfForm\", RhfForm),\n \"flr-slot-root-wrapper\": createFlowRemoteComponentRenderer(\n \"SlotRootWrapper\",\n SlotRootWrapper,\n ),\n \"flr-notification\": createFlowRemoteComponentRenderer(\n \"Notification\",\n NotificationRenderController,\n ),\n \"flr-clear-props-context-content\": createFlowRemoteComponentRenderer(\n \"ClearPropsContextContent\",\n SlotRootWrapper,\n ),\n};\n\nexport const components = {\n ...htmlComponentsMap,\n ...skippedComponentsMap,\n ...autoGenerated,\n ...flowComponentsMap,\n};\n"],"names":["Form","RhfForm","autoGenerated"],"mappings":";;;;;;;;;AAQA,MAAM,iBAAA,GAAoB;AAAA,EACxB,GAAA,EAAK,6BAAA,CAA8B,cAAA,CAAe,KAAK,CAAC,CAAA;AAAA,EACxD,MAAA,EAAQ,6BAAA,CAA8B,cAAA,CAAe,QAAQ,CAAC,CAAA;AAAA,EAC9D,CAAA,EAAG,6BAAA,CAA8B,cAAA,CAAe,GAAG,CAAC,CAAA;AAAA,EACpD,IAAA,EAAM,6BAAA,CAA8B,cAAA,CAAe,MAAM,CAAC,CAAA;AAAA,EAC1D,MAAA,EAAQ,6BAAA,CAA8B,cAAA,CAAe,QAAQ,CAAC,CAAA;AAAA,EAC9D,CAAA,EAAG,6BAAA,CAA8B,cAAA,CAAe,GAAG,CAAC,CAAA;AAAA,EACpD,EAAA,EAAI,6BAAA,CAA8B,cAAA,CAAe,IAAI,CAAC,CAAA;AAAA,EACtD,EAAA,EAAI,6BAAA,CAA8B,cAAA,CAAe,IAAI,CAAC,CAAA;AAAA,EACtD,EAAA,EAAI,6BAAA,CAA8B,cAAA,CAAe,IAAI,CAAC,CAAA;AAAA,EACtD,KAAA,EAAO,6BAAA,CAA8B,cAAA,CAAe,OAAO,CAAC,CAAA;AAAA,EAC5D,EAAA,EAAI,6BAAA;AAAA,IACF,cAAA,CAAe,IAAA,EAAM,EAAE,aAAA,EAAe,MAAM;AAAA;AAEhD,CAAA;AAMA,MAAM,oBAAA,GAAuB;AAAA,EAC3B,QAAQ,MAAM;AAChB,CAAA;AAEA,MAAM,iBAAA,GAAoB;AAAA,EACxB,UAAA,EAAY,iCAAA,CAAkC,MAAA,EAAQA,MAAI,CAAA;AAAA,EAC1D,cAAA,EAAgB,iCAAA,CAAkC,SAAA,EAAWC,IAAO,CAAA;AAAA,EACpE,uBAAA,EAAyB,iCAAA;AAAA,IACvB,iBAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA,kBAAA,EAAoB,iCAAA;AAAA,IAClB,cAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA,iCAAA,EAAmC,iCAAA;AAAA,IACjC,0BAAA;AAAA,IACA;AAAA;AAEJ,CAAA;AAEO,MAAM,UAAA,GAAa;AAAA,EACxB,GAAG,iBAAA;AAAA,EACH,GAAG,oBAAA;AAAA,EACH,GAAGC,cAAA;AAAA,EACH,GAAG;AACL;;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import { usePromise } from '@mittwald/react-use-promise';
|
|
4
|
+
import { useId, useRef, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
const useControllableSuspenseTrigger = () => {
|
|
7
|
+
const localId = useId();
|
|
8
|
+
const promise = useRef(null);
|
|
9
|
+
const [startedCount, setStartedCount] = useState(0);
|
|
10
|
+
usePromise(
|
|
11
|
+
(promise2) => promise2,
|
|
12
|
+
promise.current ? [promise.current.promise] : null,
|
|
13
|
+
{
|
|
14
|
+
keepValueWhileLoading: false,
|
|
15
|
+
loaderId: localId + startedCount
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
return {
|
|
19
|
+
start: () => {
|
|
20
|
+
promise.current = Promise.withResolvers();
|
|
21
|
+
setStartedCount((c) => c + 1);
|
|
22
|
+
},
|
|
23
|
+
stop: () => {
|
|
24
|
+
promise.current?.resolve();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { useControllableSuspenseTrigger };
|
|
30
|
+
//# sourceMappingURL=useControllableSuspenseTrigger.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useControllableSuspenseTrigger.mjs","sources":["../../../../../src/hooks/useControllableSuspenseTrigger.ts"],"sourcesContent":["import { usePromise } from \"@mittwald/react-use-promise\";\nimport { useId, useRef, useState } from \"react\";\n\nexport const useControllableSuspenseTrigger = () => {\n const localId = useId();\n const promise = useRef<PromiseWithResolvers<void>>(null);\n const [startedCount, setStartedCount] = useState(0);\n\n usePromise(\n (promise: Promise<void>) => promise,\n promise.current ? [promise.current.promise] : null,\n {\n keepValueWhileLoading: false,\n loaderId: localId + startedCount,\n },\n );\n\n return {\n start: () => {\n promise.current = Promise.withResolvers<void>();\n setStartedCount((c) => c + 1);\n },\n stop: () => {\n promise.current?.resolve();\n },\n };\n};\n"],"names":["promise"],"mappings":";;;AAGO,MAAM,iCAAiC,MAAM;AAClD,EAAA,MAAM,UAAU,KAAA,EAAM;AACtB,EAAA,MAAM,OAAA,GAAU,OAAmC,IAAI,CAAA;AACvD,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,SAAS,CAAC,CAAA;AAElD,EAAA,UAAA;AAAA,IACE,CAACA,QAAAA,KAA2BA,QAAAA;AAAA,IAC5B,QAAQ,OAAA,GAAU,CAAC,OAAA,CAAQ,OAAA,CAAQ,OAAO,CAAA,GAAI,IAAA;AAAA,IAC9C;AAAA,MACE,qBAAA,EAAuB,KAAA;AAAA,MACvB,UAAU,OAAA,GAAU;AAAA;AACtB,GACF;AAEA,EAAA,OAAO;AAAA,IACL,OAAO,MAAM;AACX,MAAA,OAAA,CAAQ,OAAA,GAAU,QAAQ,aAAA,EAAoB;AAC9C,MAAA,eAAA,CAAgB,CAAC,CAAA,KAAM,CAAA,GAAI,CAAC,CAAA;AAAA,IAC9B,CAAA;AAAA,IACA,MAAM,MAAM;AACV,MAAA,OAAA,CAAQ,SAAS,OAAA,EAAQ;AAAA,IAC3B;AAAA,GACF;AACF;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import { components } from '../components.mjs';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { reduce } from 'remeda';
|
|
6
|
+
|
|
7
|
+
const useMergedComponents = (integrations) => useMemo(
|
|
8
|
+
() => new Map(
|
|
9
|
+
Object.entries(
|
|
10
|
+
reduce(
|
|
11
|
+
[...integrations, components],
|
|
12
|
+
(merged, current) => ({
|
|
13
|
+
...merged,
|
|
14
|
+
...current
|
|
15
|
+
}),
|
|
16
|
+
{}
|
|
17
|
+
)
|
|
18
|
+
)
|
|
19
|
+
),
|
|
20
|
+
[...integrations]
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export { useMergedComponents };
|
|
24
|
+
//# sourceMappingURL=useMergedComponents.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMergedComponents.mjs","sources":["../../../../../src/hooks/useMergedComponents.ts"],"sourcesContent":["import { components } from \"@/components\";\nimport type { RemoteComponentsMap } from \"@/lib/types\";\nimport type { RemoteComponentRendererProps } from \"@mittwald/remote-dom-react/host\";\nimport { type ComponentType, useMemo } from \"react\";\nimport { reduce } from \"remeda\";\n\nexport const useMergedComponents = (\n integrations: RemoteComponentsMap<never>[],\n) =>\n useMemo(\n () =>\n new Map<string, ComponentType<RemoteComponentRendererProps>>(\n Object.entries(\n reduce(\n [...integrations, components],\n (merged, current) => ({\n ...merged,\n ...current,\n }),\n {},\n ),\n ),\n ),\n [...integrations],\n );\n"],"names":[],"mappings":";;;;AAMO,MAAM,mBAAA,GAAsB,CACjC,YAAA,KAEA,OAAA;AAAA,EACE,MACE,IAAI,GAAA;AAAA,IACF,MAAA,CAAO,OAAA;AAAA,MACL,MAAA;AAAA,QACE,CAAC,GAAG,YAAA,EAAc,UAAU,CAAA;AAAA,QAC5B,CAAC,QAAQ,OAAA,MAAa;AAAA,UACpB,GAAG,MAAA;AAAA,UACH,GAAG;AAAA,SACL,CAAA;AAAA,QACA;AAAC;AACH;AACF,GACF;AAAA,EACF,CAAC,GAAG,YAAY;AAClB;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import '@mittwald/flow-remote-core';
|
|
4
|
+
import { useLayoutEffect } from 'react';
|
|
5
|
+
|
|
6
|
+
const useUpdateHostPathnameOnRemote = (hostPathname, connection) => {
|
|
7
|
+
useLayoutEffect(() => {
|
|
8
|
+
if (hostPathname === void 0 || !connection) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const { updateHostPathname } = connection;
|
|
12
|
+
updateHostPathname(hostPathname);
|
|
13
|
+
}, [hostPathname, connection]);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { useUpdateHostPathnameOnRemote };
|
|
17
|
+
//# sourceMappingURL=useUpdateHostPathnameOnRemote.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUpdateHostPathnameOnRemote.mjs","sources":["../../../../../src/hooks/useUpdateHostPathnameOnRemote.ts"],"sourcesContent":["import { type HostToRemoteConnection } from \"@mittwald/flow-remote-core\";\nimport { useLayoutEffect } from \"react\";\n\n/** Updates the host pathname in the remote connection. */\nexport const useUpdateHostPathnameOnRemote = (\n hostPathname?: string,\n connection?: HostToRemoteConnection,\n) => {\n useLayoutEffect(() => {\n if (hostPathname === undefined || !connection) {\n return;\n }\n\n const { updateHostPathname } = connection;\n updateHostPathname(hostPathname);\n }, [hostPathname, connection]);\n};\n"],"names":[],"mappings":";;;AAIO,MAAM,6BAAA,GAAgC,CAC3C,YAAA,EACA,UAAA,KACG;AACH,EAAA,eAAA,CAAgB,MAAM;AACpB,IAAA,IAAI,YAAA,KAAiB,MAAA,IAAa,CAAC,UAAA,EAAY;AAC7C,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,EAAE,oBAAmB,GAAI,UAAA;AAC/B,IAAA,kBAAA,CAAmB,YAAY,CAAA;AAAA,EACjC,CAAA,EAAG,CAAC,YAAA,EAAc,UAAU,CAAC,CAAA;AAC/B;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import 'react';
|
|
5
|
+
|
|
6
|
+
const Form = (props) => {
|
|
7
|
+
const { onSubmit: onSubmitFromProps, ref, ...rest } = props;
|
|
8
|
+
const onSubmit = async (event) => {
|
|
9
|
+
event.preventDefault();
|
|
10
|
+
await onSubmitFromProps?.();
|
|
11
|
+
};
|
|
12
|
+
return /* @__PURE__ */ jsx("form", { ...rest, ref, onSubmit });
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { Form };
|
|
16
|
+
//# sourceMappingURL=Form.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.mjs","sources":["../../../../../../src/integrations/react-hook-form/Form.tsx"],"sourcesContent":["import {\n type FC,\n type FormEvent,\n type PropsWithChildren,\n type Ref,\n} from \"react\";\n\ntype FormProps = {\n onSubmit?: () => void | Promise<void>;\n ref?: Ref<HTMLFormElement>;\n} & PropsWithChildren;\n\n/**\n * ReactHookForm won't send the data over onSubmit, the form state is\n * transferred over onChange. To avoid sending unnecessary data, this RemoteForm\n * sends only the onSubmit without any formData.\n */\nexport const Form: FC<FormProps> = (props) => {\n const { onSubmit: onSubmitFromProps, ref, ...rest } = props;\n\n const onSubmit = async (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n await onSubmitFromProps?.();\n };\n\n return <form {...rest} ref={ref} onSubmit={onSubmit} />;\n};\n"],"names":[],"mappings":";;;AAiBO,MAAM,IAAA,GAAsB,CAAC,KAAA,KAAU;AAC5C,EAAA,MAAM,EAAE,QAAA,EAAU,iBAAA,EAAmB,GAAA,EAAK,GAAG,MAAK,GAAI,KAAA;AAEtD,EAAA,MAAM,QAAA,GAAW,OAAO,KAAA,KAAsC;AAC5D,IAAA,KAAA,CAAM,cAAA,EAAe;AACrB,IAAA,MAAM,iBAAA,IAAoB;AAAA,EAC5B,CAAA;AAEA,EAAA,uBAAO,GAAA,CAAC,MAAA,EAAA,EAAM,GAAG,IAAA,EAAM,KAAU,QAAA,EAAoB,CAAA;AACvD;;;;"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { isStyleProp, isReactSuspendedStyle } from './propClassifiers.mjs';
|
|
5
|
+
import { createRemoteComponentRenderer } from '@mittwald/remote-dom-react/host';
|
|
6
|
+
import { FlowRemoteElement } from '@mittwald/flow-remote-elements';
|
|
7
|
+
import { Version } from '@mittwald/flow-remote-core';
|
|
8
|
+
import 'react';
|
|
9
|
+
import { mapValues } from 'remeda';
|
|
10
|
+
|
|
11
|
+
const mapProperty = (val, key) => {
|
|
12
|
+
if (isStyleProp(key)) {
|
|
13
|
+
if (isReactSuspendedStyle(val)) {
|
|
14
|
+
return {
|
|
15
|
+
display: "none"
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
return val;
|
|
21
|
+
};
|
|
22
|
+
const createFlowRemoteComponentRenderer = (name, Component) => {
|
|
23
|
+
function HostComponent(props) {
|
|
24
|
+
const hostComponentProps = mapValues(
|
|
25
|
+
props,
|
|
26
|
+
(v, k) => mapProperty(v, k)
|
|
27
|
+
);
|
|
28
|
+
const {
|
|
29
|
+
[FlowRemoteElement.versionPropertyName]: version = Version.v1,
|
|
30
|
+
[FlowRemoteElement.initializationPropertyName]: initialized = false,
|
|
31
|
+
...restProps
|
|
32
|
+
} = hostComponentProps;
|
|
33
|
+
if (version >= Version.v3) {
|
|
34
|
+
if (!initialized) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return /* @__PURE__ */ jsx(Component, { ...restProps });
|
|
39
|
+
}
|
|
40
|
+
HostComponent.displayName = `FlowRemoteRenderer(${name})`;
|
|
41
|
+
return createRemoteComponentRenderer(HostComponent, {
|
|
42
|
+
name: `RemoteRenderer(${name})`
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { createFlowRemoteComponentRenderer };
|
|
47
|
+
//# sourceMappingURL=createFlowRemoteComponentRenderer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFlowRemoteComponentRenderer.mjs","sources":["../../../../../src/lib/createFlowRemoteComponentRenderer.tsx"],"sourcesContent":["import { isReactSuspendedStyle, isStyleProp } from \"@/lib/propClassifiers\";\nimport type { RemoteComponentRendererProps } from \"@mittwald/remote-dom-react/host\";\nimport { createRemoteComponentRenderer } from \"@mittwald/remote-dom-react/host\";\nimport { FlowRemoteElement } from \"@mittwald/flow-remote-elements\";\nimport type { FlowRemoteElementMetaData } from \"@mittwald/flow-remote-elements\";\nimport { Version } from \"@mittwald/flow-remote-core\";\nimport { type ComponentType } from \"react\";\nimport { mapValues } from \"remeda\";\n\nconst mapProperty = (val: unknown, key: string) => {\n if (isStyleProp(key)) {\n if (isReactSuspendedStyle(val)) {\n return {\n display: \"none\",\n };\n }\n return {};\n }\n return val;\n};\n\nexport const createFlowRemoteComponentRenderer = <P extends object>(\n name: string,\n Component: ComponentType<P>,\n): ComponentType<RemoteComponentRendererProps> => {\n function HostComponent(props: P & FlowRemoteElementMetaData) {\n const hostComponentProps = mapValues(props, (v, k) =>\n mapProperty(v, k),\n ) as P & FlowRemoteElementMetaData;\n\n const {\n [FlowRemoteElement.versionPropertyName]: version = Version.v1,\n [FlowRemoteElement.initializationPropertyName]: initialized = false,\n ...restProps\n } = hostComponentProps;\n\n if (version >= Version.v3) {\n // \"initialized\" handling introduced in version 3\n if (!initialized) {\n return null;\n }\n }\n\n return <Component {...(restProps as P)} />;\n }\n HostComponent.displayName = `FlowRemoteRenderer(${name})`;\n return createRemoteComponentRenderer(HostComponent, {\n name: `RemoteRenderer(${name})`,\n });\n};\n"],"names":[],"mappings":";;;;;;;;AASA,MAAM,WAAA,GAAc,CAAC,GAAA,EAAc,GAAA,KAAgB;AACjD,EAAA,IAAI,WAAA,CAAY,GAAG,CAAA,EAAG;AACpB,IAAA,IAAI,qBAAA,CAAsB,GAAG,CAAA,EAAG;AAC9B,MAAA,OAAO;AAAA,QACL,OAAA,EAAS;AAAA,OACX;AAAA,IACF;AACA,IAAA,OAAO,EAAC;AAAA,EACV;AACA,EAAA,OAAO,GAAA;AACT,CAAA;AAEO,MAAM,iCAAA,GAAoC,CAC/C,IAAA,EACA,SAAA,KACgD;AAChD,EAAA,SAAS,cAAc,KAAA,EAAsC;AAC3D,IAAA,MAAM,kBAAA,GAAqB,SAAA;AAAA,MAAU,KAAA;AAAA,MAAO,CAAC,CAAA,EAAG,CAAA,KAC9C,WAAA,CAAY,GAAG,CAAC;AAAA,KAClB;AAEA,IAAA,MAAM;AAAA,MACJ,CAAC,iBAAA,CAAkB,mBAAmB,GAAG,UAAU,OAAA,CAAQ,EAAA;AAAA,MAC3D,CAAC,iBAAA,CAAkB,0BAA0B,GAAG,WAAA,GAAc,KAAA;AAAA,MAC9D,GAAG;AAAA,KACL,GAAI,kBAAA;AAEJ,IAAA,IAAI,OAAA,IAAW,QAAQ,EAAA,EAAI;AAEzB,MAAA,IAAI,CAAC,WAAA,EAAa;AAChB,QAAA,OAAO,IAAA;AAAA,MACT;AAAA,IACF;AAEA,IAAA,uBAAO,GAAA,CAAC,SAAA,EAAA,EAAW,GAAI,SAAA,EAAiB,CAAA;AAAA,EAC1C;AACA,EAAA,aAAA,CAAc,WAAA,GAAc,sBAAsB,IAAI,CAAA,CAAA,CAAA;AACtD,EAAA,OAAO,8BAA8B,aAAA,EAAe;AAAA,IAClD,IAAA,EAAM,kBAAkB,IAAI,CAAA,CAAA;AAAA,GAC7B,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import { mapAttributeToReactProperty } from './mapAttributeToReactProperty.mjs';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { createElement } from 'react';
|
|
6
|
+
import { mapKeys } from 'remeda';
|
|
7
|
+
|
|
8
|
+
const elementFactory = (element, options = {}) => (props) => {
|
|
9
|
+
const result = { ...props };
|
|
10
|
+
const { isVoidElement = false } = options;
|
|
11
|
+
if (isVoidElement) {
|
|
12
|
+
delete result["children"];
|
|
13
|
+
}
|
|
14
|
+
result["className"] = clsx(
|
|
15
|
+
"className" in result && String(result["className"]),
|
|
16
|
+
"class" in result && String(result["class"])
|
|
17
|
+
);
|
|
18
|
+
delete result["class"];
|
|
19
|
+
return createElement(element, mapKeys(result, mapAttributeToReactProperty));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { elementFactory };
|
|
23
|
+
//# sourceMappingURL=elementFactory.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elementFactory.mjs","sources":["../../../../../src/lib/elementFactory.ts"],"sourcesContent":["import { mapAttributeToReactProperty } from \"@/lib/mapAttributeToReactProperty\";\nimport clsx from \"clsx\";\nimport { createElement } from \"react\";\nimport { mapKeys } from \"remeda\";\n\ntype ElementTagNameMap = HTMLElementTagNameMap &\n Pick<\n SVGElementTagNameMap,\n Exclude<keyof SVGElementTagNameMap, keyof HTMLElementTagNameMap>\n >;\n\ninterface Options {\n isVoidElement?: boolean;\n}\n\nexport const elementFactory =\n <E extends keyof ElementTagNameMap>(element: E, options: Options = {}) =>\n (props: Record<string, unknown>) => {\n const result = { ...props };\n const { isVoidElement = false } = options;\n\n if (isVoidElement) {\n delete result[\"children\"];\n }\n\n // merge className and class\n result[\"className\"] = clsx(\n \"className\" in result && String(result[\"className\"]),\n \"class\" in result && String(result[\"class\"]),\n );\n\n delete result[\"class\"];\n\n return createElement(element, mapKeys(result, mapAttributeToReactProperty));\n };\n"],"names":[],"mappings":";;;;;AAeO,MAAM,iBACX,CAAoC,OAAA,EAAY,UAAmB,EAAC,KACpE,CAAC,KAAA,KAAmC;AAClC,EAAA,MAAM,MAAA,GAAS,EAAE,GAAG,KAAA,EAAM;AAC1B,EAAA,MAAM,EAAE,aAAA,GAAgB,KAAA,EAAM,GAAI,OAAA;AAElC,EAAA,IAAI,aAAA,EAAe;AACjB,IAAA,OAAO,OAAO,UAAU,CAAA;AAAA,EAC1B;AAGA,EAAA,MAAA,CAAO,WAAW,CAAA,GAAI,IAAA;AAAA,IACpB,WAAA,IAAe,MAAA,IAAU,MAAA,CAAO,MAAA,CAAO,WAAW,CAAC,CAAA;AAAA,IACnD,OAAA,IAAW,MAAA,IAAU,MAAA,CAAO,MAAA,CAAO,OAAO,CAAC;AAAA,GAC7C;AAEA,EAAA,OAAO,OAAO,OAAO,CAAA;AAErB,EAAA,OAAO,aAAA,CAAc,OAAA,EAAS,OAAA,CAAQ,MAAA,EAAQ,2BAA2B,CAAC,CAAA;AAC5E;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import { toCamelCase } from
|
|
3
|
+
import { toCamelCase } from 'remeda';
|
|
4
|
+
|
|
4
5
|
const keepWhenStartsWith = ["aria-", "data-"];
|
|
5
6
|
const mapAttributeToReactProperty = (key) => {
|
|
6
7
|
if (keepWhenStartsWith.some((prefix) => key.startsWith(prefix))) {
|
|
@@ -8,7 +9,6 @@ const mapAttributeToReactProperty = (key) => {
|
|
|
8
9
|
}
|
|
9
10
|
return toCamelCase(key);
|
|
10
11
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
12
|
+
|
|
13
|
+
export { mapAttributeToReactProperty };
|
|
14
14
|
//# sourceMappingURL=mapAttributeToReactProperty.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapAttributeToReactProperty.mjs","sources":["../../../../../src/lib/mapAttributeToReactProperty.ts"],"sourcesContent":["import { toCamelCase } from \"remeda\";\n\nconst keepWhenStartsWith = [\"aria-\", \"data-\"];\n\nexport const mapAttributeToReactProperty = (key: string) => {\n if (keepWhenStartsWith.some((prefix) => key.startsWith(prefix))) {\n return key;\n }\n\n return toCamelCase(key);\n};\n"],"names":[],"mappings":";;AAEA,MAAM,kBAAA,GAAqB,CAAC,OAAA,EAAS,OAAO,CAAA;AAErC,MAAM,2BAAA,GAA8B,CAAC,GAAA,KAAgB;AAC1D,EAAA,IAAI,kBAAA,CAAmB,KAAK,CAAC,MAAA,KAAW,IAAI,UAAA,CAAW,MAAM,CAAC,CAAA,EAAG;AAC/D,IAAA,OAAO,GAAA;AAAA,EACT;AAEA,EAAA,OAAO,YAAY,GAAG,CAAA;AACxB;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propClassifiers.mjs","sources":["../../../../../src/lib/propClassifiers.ts"],"sourcesContent":["export const isStyleProp = (name: string): boolean => name === \"style\";\n\nexport const isReactSuspendedStyle = (value: unknown): boolean =>\n value === \"display: none !important;\";\n"],"names":[],"mappings":"AAAO,MAAM,WAAA,GAAc,CAAC,IAAA,KAA0B,IAAA,KAAS;AAExD,MAAM,qBAAA,GAAwB,CAAC,KAAA,KACpC,KAAA,KAAU;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { RemoteRendererBrowserProps } from './RemoteRendererBrowser';
|
|
1
2
|
import { FC } from 'react';
|
|
2
|
-
|
|
3
|
-
export declare const RemoteRenderer: FC<RemoteRendererProps>;
|
|
3
|
+
export declare const RemoteRenderer: FC<RemoteRendererBrowserProps>;
|
|
4
4
|
export default RemoteRenderer;
|
|
5
5
|
//# sourceMappingURL=RemoteRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteRenderer.d.ts","sourceRoot":"","sources":["../../src/RemoteRenderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"RemoteRenderer.d.ts","sourceRoot":"","sources":["../../src/RemoteRenderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAc,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAMvC,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,0BAA0B,CAMzD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RemoteComponentsMap } from './lib/types';
|
|
2
|
+
import { ExtBridgeConnectionApi } from '@mittwald/ext-bridge';
|
|
3
|
+
import { NavigationState } from '@mittwald/flow-remote-core';
|
|
4
|
+
import { RemoteReceiver } from '@mittwald/remote-dom-react/host';
|
|
5
|
+
import { FC } from 'react';
|
|
6
|
+
export interface RemoteRendererBrowserProps {
|
|
7
|
+
integrations?: RemoteComponentsMap<never>[];
|
|
8
|
+
src?: string;
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
onNavigationStateChanged?: (state: NavigationState) => void;
|
|
11
|
+
hostPathname?: string;
|
|
12
|
+
extBridgeImplementation?: ExtBridgeConnectionApi;
|
|
13
|
+
/** Internal use only */
|
|
14
|
+
__remoteReceiver?: RemoteReceiver;
|
|
15
|
+
}
|
|
16
|
+
export declare const RemoteRendererBrowser: FC<RemoteRendererBrowserProps>;
|
|
17
|
+
export default RemoteRendererBrowser;
|
|
18
|
+
//# sourceMappingURL=RemoteRendererBrowser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RemoteRendererBrowser.d.ts","sourceRoot":"","sources":["../../src/RemoteRendererBrowser.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,cAAc,EAEf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAsB,KAAK,EAAE,EAA6B,MAAM,OAAO,CAAC;AAE/E,MAAM,WAAW,0BAA0B;IACzC,YAAY,CAAC,EAAE,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC5D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,sBAAsB,CAAC;IACjD,wBAAwB;IACxB,gBAAgB,CAAC,EAAE,cAAc,CAAC;CACnC;AAWD,eAAO,MAAM,qBAAqB,EAAE,EAAE,CAAC,0BAA0B,CA2HhE,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|