Skip to content

Commit d5d9873

Browse files
committed
init chat component
1 parent 48d6d7b commit d5d9873

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { StringControl } from "comps/controls/codeControl";
2+
import { UICompBuilder, withDefault } from "comps/generators";
3+
import { NameConfig, withExposingConfigs } from "comps/generators/withExposing";
4+
import { Section, sectionNames } from "lowcoder-design";
5+
import { trans } from "i18n";
6+
import React from "react";
7+
8+
// Simple children map with just basic properties
9+
const childrenMap = {
10+
text: withDefault(StringControl, "Chat Component Placeholder"),
11+
};
12+
13+
// Basic view - just a simple div for now
14+
const ChatView = React.memo((props: any) => {
15+
return (
16+
<div
17+
style={{
18+
height: "100%",
19+
border: "1px solid #ccc",
20+
padding: "16px",
21+
borderRadius: "4px",
22+
}}
23+
>
24+
{props.text}
25+
</div>
26+
);
27+
});
28+
29+
// Basic property view
30+
const ChatPropertyView = React.memo((props: any) => {
31+
return (
32+
<Section name={sectionNames.basic}>
33+
{props.children.text.propertyView({
34+
label: "Text",
35+
})}
36+
</Section>
37+
);
38+
});
39+
40+
// Build the component
41+
const ChatTmpComp = new UICompBuilder(childrenMap, (props) => (
42+
<ChatView {...props} />
43+
))
44+
.setPropertyViewFn((children) => <ChatPropertyView children={children} />)
45+
.build();
46+
47+
// Export the component
48+
export const ChatComp = withExposingConfigs(ChatTmpComp, [
49+
new NameConfig("text", "Chat component text"),
50+
]);

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ import { DrawerComp } from "./hooks/drawerComp";
193193
import { ModalComp } from "./hooks/modalComp";
194194
import { defaultCollapsibleContainerData } from "./comps/containerComp/collapsibleContainerComp";
195195
import { ContainerComp as FloatTextContainerComp } from "./comps/containerComp/textContainerComp";
196+
import { ChatComp } from "./comps/chatComp";
196197

197198
type Registry = {
198199
[key in UICompType]?: UICompManifest;
@@ -1669,6 +1670,19 @@ export var uiCompMap: Registry = {
16691670
h: 20,
16701671
},
16711672
},
1673+
chat: {
1674+
name: "Chat",
1675+
enName: "Chat",
1676+
description: "Chat Component",
1677+
categories: ["collaboration"],
1678+
icon: CommentCompIcon, // Use existing icon for now
1679+
keywords: "chat,conversation",
1680+
comp: ChatComp,
1681+
layoutInfo: {
1682+
w: 12,
1683+
h: 20,
1684+
},
1685+
},
16721686

16731687
// Integration
16741688

client/packages/lowcoder/src/comps/uiCompRegistry.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export type UICompType =
169169
| "columnLayout"
170170
| "ganttChart"
171171
| "kanban"
172+
| "chat" // Added by Faran
172173
;
173174

174175

client/packages/lowcoder/src/pages/editor/editorConstants.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,4 +306,5 @@ export const CompStateIcon: {
306306
sunburstChart: <MemoizedIcon Icon={SunburstChartCompIconSmall} />,
307307
themeriverChart: <MemoizedIcon Icon={ThemeriverChartCompIconSmall} />,
308308
basicChart: <MemoizedIcon Icon={ChartCompIconSmall} />,
309+
chat: <MemoizedIcon Icon={CommentCompIconSmall} />,
309310
} as const;

0 commit comments

Comments
 (0)