esoftplay 0.0.141-u → 0.0.141-v
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/modules/lib/compose.tsx +60 -27
- package/package.json +1 -1
package/modules/lib/compose.tsx
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// withHooks
|
|
2
|
+
import { LibNavigationRoutes } from 'esoftplay';
|
|
3
|
+
import { LibNavigation } from 'esoftplay/cache/lib/navigation/import';
|
|
2
4
|
import { LibObject } from 'esoftplay/cache/lib/object/import';
|
|
5
|
+
import { LibUtils } from 'esoftplay/cache/lib/utils/import';
|
|
3
6
|
import { EspRouterInterface } from 'esoftplay/cache/routers';
|
|
4
7
|
import esp from 'esoftplay/esp';
|
|
5
8
|
import useGlobalState from 'esoftplay/global';
|
|
@@ -14,31 +17,7 @@ export interface RNTypes extends EspRouterInterface {
|
|
|
14
17
|
// "TextInput": typeof TextInput,
|
|
15
18
|
}
|
|
16
19
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const action: any = {
|
|
20
|
-
"navigate": (args: any[]) => esp.mod("lib/navigation").navigate(args[0], args[1]),
|
|
21
|
-
"replace": (args: any[]) => esp.mod("lib/navigation").replace(args[0], args[1]),
|
|
22
|
-
"back": (args: any[]) => esp.mod("lib/navigation").back(),
|
|
23
|
-
"copy": (args: any[]) => {
|
|
24
|
-
esp.mod("lib/utils").copyToClipboard(JSON.stringify(args))
|
|
25
|
-
esp.modProp("lib/toast").show(args + " copied!")
|
|
26
|
-
},
|
|
27
|
-
"curl": (args: any[]) => {
|
|
28
|
-
let post = args?.[1]
|
|
29
|
-
try {
|
|
30
|
-
post = JSON.parse(args?.[1])
|
|
31
|
-
} catch (error) {
|
|
32
|
-
post = args?.[1]
|
|
33
|
-
}
|
|
34
|
-
post = Object.assign({}, post, form.get())
|
|
35
|
-
new (esp.mod('lib/curl'))(args[0], post, (res, msg) => {
|
|
36
|
-
esp.modProp("lib/toast").show(msg)
|
|
37
|
-
}, (err) => {
|
|
38
|
-
esp.modProp("lib/toast").show(err.message)
|
|
39
|
-
}, 1)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
20
|
+
const formState = useGlobalState({})
|
|
42
21
|
|
|
43
22
|
function buildUIFromJSON(json: any): ReactElement {
|
|
44
23
|
const { component, props } = json;
|
|
@@ -80,14 +59,14 @@ function buildUIFromJSON(json: any): ReactElement {
|
|
|
80
59
|
const [type, postkey] = cleanForm.split('.')
|
|
81
60
|
if (type == 'input') {
|
|
82
61
|
_props[key] = (input: string) => {
|
|
83
|
-
|
|
62
|
+
formState.set(LibObject.set(formState.get(), input)(postkey))
|
|
84
63
|
}
|
|
85
64
|
}
|
|
86
65
|
if (type == 'select') {
|
|
87
66
|
console.log(type, postkey, key)
|
|
88
67
|
const [_key, _value] = postkey.split(":")
|
|
89
68
|
_props[key] = () => {
|
|
90
|
-
|
|
69
|
+
formState.set(LibObject.set(formState.get(), _value)(_key))
|
|
91
70
|
}
|
|
92
71
|
}
|
|
93
72
|
} else {
|
|
@@ -109,6 +88,60 @@ export default function m({ schema }: { schema: any }): ReactElement {
|
|
|
109
88
|
return buildUIFromJSON(schema)
|
|
110
89
|
}
|
|
111
90
|
|
|
91
|
+
const action: any = {
|
|
92
|
+
"navigate": (args: any[]) => esp.mod("lib/navigation").navigate(args[0], args[1]),
|
|
93
|
+
"replace": (args: any[]) => esp.mod("lib/navigation").replace(args[0], args[1]),
|
|
94
|
+
"back": (args: any[]) => esp.mod("lib/navigation").back(),
|
|
95
|
+
"copy": (args: any[]) => {
|
|
96
|
+
esp.mod("lib/utils").copyToClipboard(JSON.stringify(args))
|
|
97
|
+
esp.modProp("lib/toast").show(args + " copied!")
|
|
98
|
+
},
|
|
99
|
+
"curl": (args: any[]) => {
|
|
100
|
+
esp.mod("lib/progress").show("Please Wait..")
|
|
101
|
+
let post = args?.[1]
|
|
102
|
+
try {
|
|
103
|
+
post = JSON.parse(args?.[1])
|
|
104
|
+
} catch (error) {
|
|
105
|
+
post = args?.[1]
|
|
106
|
+
}
|
|
107
|
+
post = Object.assign({}, post, formState.get())
|
|
108
|
+
new (esp.mod('lib/curl'))(args[0], post, (res, msg) => {
|
|
109
|
+
esp.modProp("lib/toast").show(msg)
|
|
110
|
+
esp.mod("lib/progress").hide()
|
|
111
|
+
}, (err) => {
|
|
112
|
+
esp.modProp("lib/toast").show(err.message)
|
|
113
|
+
esp.mod("lib/progress").hide()
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export const forms = {
|
|
119
|
+
select: (postKey: string, value: string) => `#form.select.${postKey}:${value}`,
|
|
120
|
+
input: (postKey: string) => `#form.input.${postKey}`,
|
|
121
|
+
}
|
|
122
|
+
export const actions = {
|
|
123
|
+
navigate: (module: LibNavigationRoutes, params: any) => {
|
|
124
|
+
LibNavigation.navigate(module, params)
|
|
125
|
+
},
|
|
126
|
+
replace: (module: LibNavigationRoutes, params: any) => {
|
|
127
|
+
LibNavigation.replace(module, params)
|
|
128
|
+
},
|
|
129
|
+
back: () => {
|
|
130
|
+
LibNavigation.back()
|
|
131
|
+
},
|
|
132
|
+
copy: (args: string) => {
|
|
133
|
+
LibUtils.copyToClipboard(args)
|
|
134
|
+
esp.modProp("lib/toast").show(args + " copied!")
|
|
135
|
+
},
|
|
136
|
+
curl: (uri: string, post?: any) => {
|
|
137
|
+
new (esp.mod('lib/curl'))(uri, post, (res, msg) => {
|
|
138
|
+
esp.modProp("lib/toast").show(msg)
|
|
139
|
+
}, (err) => {
|
|
140
|
+
esp.modProp("lib/toast").show(err.message)
|
|
141
|
+
}, 1)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
112
145
|
export function build<T extends keyof RNTypes>(cmpn: T, props: React.ComponentProps<RNTypes[T]>): any {
|
|
113
146
|
let obj: any = {};
|
|
114
147
|
obj.component = cmpn;
|