@5minds/node-red-dashboard-2-processcube-dynamic-form 1.0.25-poc-for-using-dynamic-ui-from-app-sdk-825bfc-m2n7fwvk → 1.0.25-poc-for-using-dynamic-ui-from-app-sdk-bac204-m2onni3p

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.
@@ -0,0 +1,20 @@
1
+ import { DynamicUi } from '@5minds/processcube_app_sdk/client';
2
+ import '@5minds/processcube_app_sdk/client/components/DynamicUi/DynamicUi.css';
3
+ import React, { useState } from 'react';
4
+
5
+ export default function UIDynamicForm(props) {
6
+ const [usertask, setUsertask] = useState(undefined)
7
+ props.socket.on('widget-load:' + props.id, (msg) => {
8
+ setUsertask(msg.payload.userTask)
9
+ })
10
+ props.socket.on('msg-input:' + props.id, (msg) => {
11
+ setUsertask(msg.payload.userTask)
12
+ })
13
+
14
+ if (!usertask) {
15
+ return <h1>no task to show</h1>
16
+ }
17
+
18
+ return <DynamicUi task={usertask as any} onSubmit={() => console.log("submit...") as any} />;
19
+ }
20
+
@@ -0,0 +1,40 @@
1
+ <template>
2
+ <div ref="reactRoot"></div>
3
+ </template>
4
+
5
+ <script>
6
+ import { defineComponent, onMounted, ref, inject } from 'vue';
7
+ import React from 'react';
8
+ import { createRoot } from 'react-dom/client';
9
+ import UIDynamicForm from './UIDynamicForm.tsx';
10
+
11
+ export default defineComponent({
12
+ name: 'UIDynamicForm',
13
+ inject: ['$socket'],
14
+ props: {
15
+ /* do not remove entries from this - Dashboard's Layout Manager's will pass this data to your component */
16
+ id: { type: String, required: true },
17
+ props: { type: Object, default: () => ({}) },
18
+ state: {
19
+ type: Object,
20
+ default: () => ({ enabled: false, visible: false }),
21
+ },
22
+ },
23
+ setup(props) {
24
+ const reactRoot = ref(null);
25
+
26
+ const socket = inject('$socket');
27
+
28
+ onMounted(() => {
29
+ const root = createRoot(reactRoot.value);
30
+ root.render(React.createElement(UIDynamicForm, {...props, socket}));
31
+ });
32
+ return {
33
+ reactRoot,
34
+ };
35
+ },
36
+ });
37
+ </script>
38
+
39
+ <style>
40
+ </style>
@@ -1,5 +0,0 @@
1
- import React from "react"
2
-
3
- export default function UIDynamicForm() {
4
- return <h1 className="reactclass">amk qn2 yeah yeah</h1>
5
- }
@@ -1,29 +0,0 @@
1
- <template>
2
- <div ref="reactRoot"></div>
3
- </template>
4
-
5
- <script>
6
- import { defineComponent, onMounted, ref } from 'vue';
7
- import React from 'react';
8
- import { createRoot } from 'react-dom/client';
9
- import UIDynamicForm from './UIDynamicForm.jsx';
10
-
11
- export default defineComponent({
12
- name: 'UIDynamicForm',
13
- setup() {
14
- const reactRoot = ref(null);
15
-
16
- onMounted(() => {
17
- const root = createRoot(reactRoot.value);
18
- root.render(React.createElement(UIDynamicForm));
19
- });
20
-
21
- return {
22
- reactRoot,
23
- };
24
- },
25
- });
26
- </script>
27
-
28
- <style>
29
- </style>