Skip to content

Commit 8a0475f

Browse files
committed
update sdk version to 0.0.32
1 parent 149ed67 commit 8a0475f

File tree

7 files changed

+64
-10
lines changed

7 files changed

+64
-10
lines changed
Binary file not shown.
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dependencies": {
1212
"history": "^5.3.0",
1313
"less": "^4.1.3",
14-
"openblocks-sdk": "^0.0.31",
14+
"openblocks-sdk": "^0.0.32",
1515
"react": "17",
1616
"react-dom": "17",
1717
"react-router": "^6.4.3",

src/App.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const demos = [
3636
title: "Use offline application dsl",
3737
dsl: formDsl,
3838
isModule: true,
39+
initialMethodName: "setNameFieldValue",
40+
initialMethodParams: JSON.stringify(["Tom"]),
3941
},
4042
];
4143

@@ -73,17 +75,19 @@ const routes: RouteObject[] = [
7375
{
7476
path: "/",
7577
element: <Root />,
76-
children: demos.map((i) => ({
78+
children: demos.map((i, idx) => ({
7779
path: titleToPath(i.title),
7880
element: i.isModule ? (
7981
<ModuleDemo
82+
key={idx}
8083
appId={i.appId || ""}
8184
appDsl={i.dsl}
8285
initialModuleInputs={i.initialInputs}
8386
initialMethodName={i.initialMethodName || ""}
87+
initialMethodParams={i.initialMethodParams}
8488
/>
8589
) : (
86-
<AppDemo appId={i.appId || ""} appDsl={i.dsl} />
90+
<AppDemo key={idx} appId={i.appId || ""} appDsl={i.dsl} />
8791
),
8892
})),
8993
},

src/ModuleDemo.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ interface IProps {
66
appDsl?: any;
77
initialModuleInputs: any;
88
initialMethodName: string;
9+
initialMethodParams?: string;
910
}
1011

1112
export function ModuleDemo(props: IProps) {
1213
const inputRef = useRef<HTMLTextAreaElement>(null);
1314
const methodInputRef = useRef<HTMLInputElement>(null);
15+
const methodParamsInputRef = useRef<HTMLInputElement>(null);
1416
const instanceRef = useRef<AppViewInstance<any, any>>(null);
1517
const [inputs, setInputs] = useState<any>(props.initialModuleInputs);
1618
const [outputs, setOutputs] = useState<any>({});
@@ -29,10 +31,21 @@ export function ModuleDemo(props: IProps) {
2931

3032
const handleInvokeMethod = () => {
3133
const methodName = methodInputRef.current?.value;
34+
const paramsJson = methodParamsInputRef.current?.value;
35+
3236
if (!methodName) {
3337
return;
3438
}
35-
instanceRef.current?.invokeMethod(methodName);
39+
40+
let params = [];
41+
if (paramsJson) {
42+
try {
43+
params = JSON.parse(paramsJson);
44+
} catch {
45+
params = [];
46+
}
47+
}
48+
instanceRef.current?.invokeMethod(methodName, params);
3649
};
3750

3851
return (
@@ -61,10 +74,17 @@ export function ModuleDemo(props: IProps) {
6174
<div>
6275
<strong>invoke method</strong>
6376
<input
77+
style={{ marginBottom: 8 }}
6478
ref={methodInputRef}
6579
defaultValue={props.initialMethodName}
6680
placeholder="input module method name"
6781
/>
82+
<span>json array of params, like: ["param1", "param2"]</span>
83+
<input
84+
ref={methodParamsInputRef}
85+
defaultValue={props.initialMethodParams}
86+
placeholder="method params"
87+
/>
6888
<button onClick={handleInvokeMethod}>invoke</button>
6989
</div>
7090
<div>

src/dsl/form.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,37 @@
1717
}
1818
]
1919
},
20-
"methods": [],
20+
"methods": [
21+
{
22+
"name": "setNameFieldValue",
23+
"action": {
24+
"compType": "executeComp",
25+
"comp": {
26+
"name": "input1",
27+
"methodName": "setValue",
28+
"params": [
29+
{
30+
"compType": "string",
31+
"comp": "{{nameFieldValue}}",
32+
"name": "value"
33+
}
34+
]
35+
},
36+
"condition": "",
37+
"slowdown": "debounce",
38+
"delay": ""
39+
},
40+
"params": [
41+
{
42+
"name": "nameFieldValue",
43+
"description": "",
44+
"type": "JSONValue",
45+
"defaultValue": { "compType": "JSONValue", "comp": "" },
46+
"test": { "compType": "JSONValue", "comp": "" }
47+
}
48+
]
49+
}
50+
],
2151
"events": {
2252
"list": [{ "name": "onSubmit", "description": "" }],
2353
"enableEventTestMessage": true

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ __metadata:
555555
"@vitejs/plugin-react": ^2.2.0
556556
history: ^5.3.0
557557
less: ^4.1.3
558-
openblocks-sdk: ^0.0.31
558+
openblocks-sdk: ^0.0.32
559559
react: 17
560560
react-dom: 17
561561
react-router: ^6.4.3
@@ -1685,13 +1685,13 @@ __metadata:
16851685
languageName: node
16861686
linkType: hard
16871687

1688-
"openblocks-sdk@npm:^0.0.31":
1689-
version: 0.0.31
1690-
resolution: "openblocks-sdk@npm:0.0.31::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Fopenblocks-sdk%2F-%2Fopenblocks-sdk-0.0.31.tgz"
1688+
"openblocks-sdk@npm:^0.0.32":
1689+
version: 0.0.32
1690+
resolution: "openblocks-sdk@npm:0.0.32::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Fopenblocks-sdk%2F-%2Fopenblocks-sdk-0.0.32.tgz"
16911691
peerDependencies:
16921692
react: ^17
16931693
react-dom: ^17
1694-
checksum: 3b72c14d730e0d09ebe3903d32b2b53a5c4e042b633d6ee6d2c3c0f93d317b60ba2000651f251bfae6f149c8724c74e190239e20bcf19524b2748d8a9378c087
1694+
checksum: 12103100c8a80b72c33ff412d804f17c36f4a74600da29321d9f65dc1205338956a8fe2f4e6a6841ff64c6d00b3991d5306b99d315b08a17a35f688bb927be89
16951695
languageName: node
16961696
linkType: hard
16971697

0 commit comments

Comments
 (0)