Skip to content

Commit d1d9b92

Browse files
committed
refactor component structure
1 parent d5d9873 commit d1d9b92

File tree

6 files changed

+66
-50
lines changed

6 files changed

+66
-50
lines changed

client/packages/lowcoder/src/comps/comps/chatComp.tsx

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// client/packages/lowcoder/src/comps/comps/chatComp/chatComp.tsx
2+
import { UICompBuilder } from "comps/generators";
3+
import { NameConfig, withExposingConfigs } from "comps/generators/withExposing";
4+
import { chatChildrenMap } from "./chatCompTypes";
5+
import { ChatView } from "./chatView";
6+
import { ChatPropertyView } from "./chatPropertyView";
7+
8+
// Build the component
9+
const ChatTmpComp = new UICompBuilder(
10+
chatChildrenMap,
11+
(props) => <ChatView {...props} />
12+
)
13+
.setPropertyViewFn((children) => <ChatPropertyView children={children} />)
14+
.build();
15+
16+
// Export the component
17+
export const ChatComp = withExposingConfigs(ChatTmpComp, [
18+
new NameConfig("text", "Chat component text"),
19+
]);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// client/packages/lowcoder/src/comps/comps/chatComp/chatCompTypes.ts
2+
import { StringControl } from "comps/controls/codeControl";
3+
import { withDefault } from "comps/generators";
4+
5+
export const chatChildrenMap = {
6+
text: withDefault(StringControl, "Chat Component Placeholder"),
7+
};
8+
9+
export type ChatCompProps = {
10+
text: string;
11+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// client/packages/lowcoder/src/comps/comps/chatComp/chatPropertyView.tsx
2+
import React from "react";
3+
import { Section, sectionNames } from "lowcoder-design";
4+
5+
export const ChatPropertyView = React.memo((props: any) => {
6+
return (
7+
<Section name={sectionNames.basic}>
8+
{props.children.text.propertyView({
9+
label: "Text"
10+
})}
11+
</Section>
12+
);
13+
});
14+
15+
ChatPropertyView.displayName = 'ChatPropertyView';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// client/packages/lowcoder/src/comps/comps/chatComp/chatView.tsx
2+
import React from "react";
3+
import { ChatCompProps } from "./chatCompTypes";
4+
5+
export const ChatView = React.memo((props: ChatCompProps) => {
6+
return (
7+
<div style={{
8+
height: '100%',
9+
border: '1px solid #ccc',
10+
padding: '16px',
11+
borderRadius: '4px'
12+
}}>
13+
{props.text}
14+
</div>
15+
);
16+
});
17+
18+
ChatView.displayName = 'ChatView';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// client/packages/lowcoder/src/comps/comps/chatComp/index.ts
2+
export { ChatComp } from "./chatComp";
3+
export type { ChatCompProps } from "./chatCompTypes";

0 commit comments

Comments
 (0)