Skip to content

Commit efa905a

Browse files
author
FalkWolsky
committed
Updated Component Plugin Demo
1 parent 885d0dc commit efa905a

File tree

130 files changed

+688
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+688
-164
lines changed

client/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.2.0
1+
dev
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
/node_modules
21
*.tgz
2+
/node_modules
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 10 additions & 0 deletions

client/packages/lowcoder-plugin-demo/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CompIDE } from "lowcoder-sdk";
33
import { name, version, lowcoder } from "./package.json";
44
import compMap from "./src/index";
55

6-
import "../lowcoder-sdk/dist/style.css";
6+
import "lowcoder-sdk/dist/style.css";
77

88
function CompDevApp() {
99
return (
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"helloWorldCompName": "Hello World"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"helloWorldCompName": "你好,世界"
3+
}
Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,29 @@
11
{
22
"name": "lowcoder-plugin-demo",
3-
"version": "0.0.4",
3+
"version": "0.0.1",
44
"type": "module",
55
"license": "MIT",
66
"dependencies": {
7-
"lowcoder-core": "^0.0.1",
8-
"lowcoder-design": "^0.0.1",
7+
"@types/react": "17",
8+
"@types/react-dom": "17",
9+
"lowcoder-dev-utils": "^0.0.6",
10+
"lowcoder-sdk": "^2.1.9",
911
"react": "17",
10-
"react-dom": "17"
11-
},
12-
"publishConfig": {
13-
"registry": "https://registry.npmjs.com"
12+
"react-dom": "17",
13+
"typescript": "5.3.3",
14+
"vite": "^5.0.6"
1415
},
1516
"lowcoder": {
1617
"description": "",
1718
"comps": {
1819
"hello_world": {
19-
"name": "Hello World",
20-
"icon": "./icons/demo-icon.png"
21-
},
22-
"counter": {
23-
"name": "Counter",
24-
"icon": "./icons/demo-icon.png"
20+
"name": "__i18n_helloWorldCompName__",
21+
"icon": "./icons/demo-icon.svg"
2522
}
2623
}
2724
},
2825
"scripts": {
2926
"start": "vite",
3027
"build": "lowcoder-cli build"
31-
},
32-
"devDependencies": {
33-
"@types/react": "17",
34-
"@types/react-dom": "17",
35-
"lowcoder-cli": "workspace:^",
36-
"lowcoder-sdk": "workspace:^",
37-
"typescript": "4.8.4",
38-
"vite": "^4.5.1"
3928
}
4029
}

client/packages/lowcoder-plugin-demo/src/CounterComp.tsx

Lines changed: 0 additions & 81 deletions
This file was deleted.
Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,82 @@
11
import {
2+
antd,
23
UICompBuilder,
3-
stringExposingStateControl,
4+
numberExposingStateControl,
45
Section,
6+
withDefault,
57
withExposingConfigs,
8+
NumberControl,
69
NameConfig,
10+
eventHandlerControl,
11+
withMethodExposing,
712
} from "lowcoder-sdk";
813

9-
import styles from "./style.module.css";
14+
import styles from "./styles.module.css";
15+
16+
const { Button } = antd;
1017

1118
const childrenMap = {
12-
text: stringExposingStateControl("text", "world"),
19+
value: numberExposingStateControl("value", 10),
20+
step: withDefault(NumberControl, 1),
21+
onEvent: eventHandlerControl([
22+
{
23+
label: "onChange",
24+
value: "change",
25+
description: "",
26+
},
27+
]),
1328
};
1429

1530
const HelloWorldCompBase = new UICompBuilder(childrenMap, (props: any) => {
16-
const text = props.text.value;
17-
return <div className={styles.wrapper}>Hello {text}</div>;
31+
const currentValue = props.value.value;
32+
return (
33+
<div className={styles.wrapper}>
34+
<Button
35+
onClick={() => {
36+
props.value.onChange(currentValue - props.step);
37+
props.onEvent("change");
38+
}}
39+
>
40+
-
41+
</Button>
42+
<span style={{ padding: "0 8px" }}>{currentValue}</span>
43+
<Button
44+
onClick={() => {
45+
props.value.onChange(currentValue + props.step);
46+
props.onEvent("change");
47+
}}
48+
>
49+
+
50+
</Button>
51+
</div>
52+
);
1853
})
1954
.setPropertyViewFn((children: any) => {
20-
return <Section name="Basic">{children.text.propertyView({ label: "Text" })}</Section>;
55+
return (
56+
<>
57+
<Section name="Basic">
58+
{children.value.propertyView({ label: "Initial Value" })}
59+
{children.step.propertyView({ label: "Step" })}
60+
</Section>
61+
<Section name="Interaction">{children.onEvent.propertyView()}</Section>
62+
</>
63+
);
2164
})
2265
.build();
2366

24-
export default withExposingConfigs(HelloWorldCompBase, [new NameConfig("text", "")]);
67+
const HelloWorldCompTemp = withMethodExposing(HelloWorldCompBase, [
68+
{
69+
method: {
70+
name: "random",
71+
params: [],
72+
},
73+
execute(comp: any) {
74+
comp.children.value.getView().onChange(Math.floor(Math.random() * 100));
75+
},
76+
},
77+
]);
78+
79+
export default withExposingConfigs(HelloWorldCompTemp, [
80+
new NameConfig("value", ""),
81+
new NameConfig("step", ""),
82+
]);
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import CounterComp from "./CounterComp";
21
import HelloWorldComp from "./HelloWorldComp";
32

43
export default {
54
hello_world: HelloWorldComp,
6-
counter: CounterComp,
75
};
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
.wrapper {
2-
color: red;
2+
padding: 5px;
33
display: flex;
44
justify-content: center;
55
align-items: center;
66
height: 100%;
77
border: 1px solid #dddddd;
88
background-color: white;
9-
padding: 8px 0;
109
}

client/packages/lowcoder-plugin-demo/tsconfig.json

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,7 @@
1616
"isolatedModules": true,
1717
"noEmit": true,
1818
"jsx": "react-jsx",
19-
"baseUrl": "src",
20-
"paths": {
21-
"lowcoder-sdk": [
22-
"../../lowcoder/src/index.sdk.ts",
23-
"../node_modules/lowcoder-sdk/src/lowcoder/index.sdk.ts"
24-
],
25-
"*": [
26-
"*",
27-
"../../lowcoder/src/*",
28-
"../../lowcoder-sdk/src/*",
29-
"../node_modules/lowcoder-sdk/src/lowcoder/*"
30-
]
31-
}
19+
"baseUrl": "src"
3220
},
3321
"include": ["src", "index.tsx"]
3422
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy