Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0ee8c56

Browse files
committed
Merge branch 'feat/chat-component' of github.com:iamfaran/lowcoder into feat/chat-component
2 parents3fc3517 +cd079e6 commit0ee8c56

File tree

5 files changed

+158
-61
lines changed

5 files changed

+158
-61
lines changed
Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
// client/packages/lowcoder/src/comps/comps/chatComp/chatCompTypes.ts
2-
3-
// ============================================================================
4-
// CLEAN CHATCOMP TYPES - SIMPLIFIED AND FOCUSED
5-
// ============================================================================
6-
7-
exporttypeChatCompProps={
8-
// Storage
9-
tableName:string;
10-
11-
// Message Handler
12-
handlerType:"query"|"n8n";
13-
chatQuery:string;// Only used when handlerType === "query"
14-
modelHost:string;// Only used when handlerType === "n8n"
15-
systemPrompt:string;
16-
streaming:boolean;
17-
18-
// UI
19-
placeholder:string;
20-
21-
// Exposed Variables
22-
currentMessage:string;// Read-only exposed variable
23-
};
24-
25-
// Legacy export for backwards compatibility (if needed)
26-
exporttypeChatCompLegacyProps=ChatCompProps;
1+
2+
// ============================================================================
3+
// CLEAN CHATCOMP TYPES - SIMPLIFIED AND FOCUSED
4+
// ============================================================================
5+
6+
exporttypeChatCompProps={
7+
// Storage
8+
tableName:string;
9+
10+
// Message Handler
11+
handlerType:"query"|"n8n";
12+
chatQuery:string;// Only used when handlerType === "query"
13+
modelHost:string;// Only used when handlerType === "n8n"
14+
systemPrompt:string;
15+
streaming:boolean;
16+
17+
// UI
18+
placeholder:string;
19+
20+
// Exposed Variables
21+
currentMessage:string;// Read-only exposed variable
22+
};
23+
24+
// Legacy export for backwards compatibility (if needed)
25+
exporttypeChatCompLegacyProps=ChatCompProps;

‎client/packages/lowcoder/src/comps/comps/chatComp/components/ChatCoreMain.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,5 @@ export function ChatCoreMain({
267267
</ChatContainer>
268268
</AssistantRuntimeProvider>
269269
);
270-
}
270+
}
271+

‎client/packages/lowcoder/src/comps/comps/preLoadComp/actions/componentConfiguration.ts‎

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import{message}from"antd";
22
import{ActionConfig,ActionExecuteParams}from"../types";
3+
import{getEditorComponentInfo}from"../utils";
34

45
exportconstconfigureComponentAction:ActionConfig={
56
key:'configure-components',
@@ -19,10 +20,40 @@ export const configureComponentAction: ActionConfig = {
1920
}
2021
},
2122
execute:async(params:ActionExecuteParams)=>{
22-
const{ selectedEditorComponent, actionValue}=params;
23+
const{ selectedEditorComponent,actionValue:name, actionValue, actionPayload, editorState}=params;
24+
constotherProps=actionPayload;
25+
// const { name, ...otherProps } = actionPayload;
2326

2427
try{
25-
constconfig=JSON.parse(actionValue);
28+
constcomponentInfo=getEditorComponentInfo(editorState,name);
29+
30+
if(!componentInfo){
31+
message.error(`Component "${selectedEditorComponent}" not found`);
32+
return;
33+
}
34+
35+
const{componentKey:parentKey, items}=componentInfo;
36+
37+
if(!parentKey){
38+
message.error(`Parent component "${selectedEditorComponent}" not found in layout`);
39+
return;
40+
}
41+
42+
constparentItem=items[parentKey];
43+
if(!parentItem){
44+
message.error(`Parent component "${selectedEditorComponent}" not found in items`);
45+
return;
46+
}
47+
48+
constitemComp=parentItem.children.comp;
49+
constitemData=itemComp.toJsonValue();
50+
constconfig={
51+
...itemData,
52+
...otherProps
53+
};
54+
itemComp.dispatchChangeValueAction(config);
55+
56+
debugger;
2657
console.log('Configuring component:',selectedEditorComponent,'with config:',config);
2758
message.info(`Configure action for component "${selectedEditorComponent}"`);
2859

‎client/packages/lowcoder/src/comps/comps/preLoadComp/actions/componentManagement.ts‎

Lines changed: 97 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
deleteCompAction
1414
}from"lowcoder-core";
1515
import{getEditorComponentInfo}from"../utils";
16+
import{getPromiseAfterDispatch}from"@lowcoder-ee/util/promiseUtils";
17+
import{hookCompCategory,HookCompType}from"@lowcoder-ee/comps/hooks/hookCompTypes";
1618

1719
exportconstaddComponentAction:ActionConfig={
1820
key:'add-components',
@@ -21,14 +23,30 @@ export const addComponentAction: ActionConfig = {
2123
requiresComponentSelection:true,
2224
requiresInput:false,
2325
execute:async(params:ActionExecuteParams)=>{
24-
const{ selectedComponent, editorState}=params;
25-
26+
const{ selectedComponent, editorState, actionPayload}=params;
27+
const{component_name:name, layout, action_parameters}=actionPayload;
28+
2629
if(!selectedComponent||!editorState){
2730
message.error('Component and editor state are required');
2831
return;
2932
}
3033

3134
try{
35+
if(hookCompCategory(selectedComponent)==="ui"){
36+
constcompName=Boolean(name) ?name :editorState.getNameGenerator().genItemName(selectedComponent);
37+
editorState
38+
.getHooksComp()
39+
.dispatch(
40+
wrapActionExtraInfo(
41+
editorState
42+
.getHooksComp()
43+
.pushAction({name:compName,compType:selectedComponentasHookCompType}),
44+
{compInfos:[{compName:compName,compType:selectedComponent,type:"add"}]}
45+
)
46+
);
47+
return;
48+
}
49+
3250
constuiComp=editorState.getUIComp();
3351
constcontainer=uiComp.getComp();
3452

@@ -43,31 +61,33 @@ export const addComponentAction: ActionConfig = {
4361
return;
4462
}
4563

64+
letcompName=name;
4665
constnameGenerator=editorState.getNameGenerator();
4766
constcompInfo=parseCompType(selectedComponent);
48-
constcompName=nameGenerator.genItemName(compInfo.compName);
67+
if(!compName){
68+
compName=nameGenerator.genItemName(compInfo.compName);
69+
}
4970
constkey=genRandomKey();
5071

5172
constmanifest=uiCompRegistry[selectedComponent];
5273
letdefaultDataFn=undefined;
5374

54-
if(manifest?.lazyLoad){
55-
const{ defaultDataFnName, defaultDataFnPath}=manifest;
56-
if(defaultDataFnName&&defaultDataFnPath){
57-
constmodule=awaitimport(`../../../${defaultDataFnPath}.tsx`);
58-
defaultDataFn=module[defaultDataFnName];
59-
}
60-
}elseif(!compInfo.isRemote){
75+
if(!compInfo.isRemote){
6176
defaultDataFn=manifest?.defaultDataFn;
6277
}
6378

79+
letcompDefaultValue=defaultDataFn ?defaultDataFn(compName,nameGenerator,editorState) :undefined;
80+
constcompInitialValue={
81+
...(compDefaultValueasany||{}),
82+
...action_parameters,
83+
}
6484
constwidgetValue:GridItemDataType={
6585
compType:selectedComponent,
6686
name:compName,
67-
comp:defaultDataFn ?defaultDataFn(compName,nameGenerator,editorState) :undefined,
87+
comp:compInitialValue,
6888
};
6989

70-
constcurrentLayout=simpleContainer.children.layout.getView();
90+
constcurrentLayout=uiComp.children.comp.children.layout.getView();
7191
constlayoutInfo=manifest?.layoutInfo||defaultLayout(selectedComponentasUICompType);
7292

7393
letitemPos=0;
@@ -83,9 +103,11 @@ export const addComponentAction: ActionConfig = {
83103
h:layoutInfo.h||5,
84104
pos:itemPos,
85105
isDragging:false,
106+
...(layout||{}),
86107
};
87108

88-
simpleContainer.dispatch(
109+
awaitgetPromiseAfterDispatch(
110+
uiComp.children.comp.dispatch,
89111
wrapActionExtraInfo(
90112
multiChangeAction({
91113
layout:changeValueAction({
@@ -95,8 +117,23 @@ export const addComponentAction: ActionConfig = {
95117
items:addMapChildAction(key,widgetValue),
96118
}),
97119
{compInfos:[{compName:compName,compType:selectedComponent,type:"add"}]}
98-
)
120+
),
121+
{
122+
autoHandleAfterReduce:true,
123+
}
99124
);
125+
// simpleContainer.dispatch(
126+
// wrapActionExtraInfo(
127+
// multiChangeAction({
128+
// layout: changeValueAction({
129+
// ...currentLayout,
130+
// [key]: layoutItem,
131+
// }, true),
132+
// items: addMapChildAction(key, widgetValue),
133+
// }),
134+
// { compInfos: [{ compName: compName, compType: selectedComponent, type: "add" }]}
135+
// )
136+
// );
100137

101138
editorState.setSelectedCompNames(newSet([compName]),"addComp");
102139

@@ -116,28 +153,32 @@ export const nestComponentAction: ActionConfig = {
116153
requiresInput:false,
117154
isNested:true,
118155
execute:async(params:ActionExecuteParams)=>{
119-
const{ selectedEditorComponent, selectedNestComponent, editorState}=params;
120-
156+
// const { selectedEditorComponent, selectedNestComponent, editorState, actionPayload } = params;
157+
const{ editorState, actionPayload,selectedComponent:selectedNestComponent}=params;
158+
const{component_name:name, layout,parent_component_name:selectedEditorComponent, action_parameters}=actionPayload;
159+
// const { name, layout, target: selectedEditorComponent, ...otherProps } = actionPayload;
160+
121161
if(!selectedEditorComponent||!selectedNestComponent||!editorState){
122162
message.error('Parent component, child component, and editor state are required');
123163
return;
124164
}
125165

126-
constparentComponentInfo=getEditorComponentInfo(editorState,selectedEditorComponent);
166+
const[editorComponent, ...childComponents]=selectedEditorComponent.split('.');
167+
constparentItem=editorState.getUICompByName(editorComponent);//getEditorComponentInfo(editorState, editorComponent);
127168

128-
if(!parentComponentInfo){
129-
message.error(`Parent component "${selectedEditorComponent}" not found`);
130-
return;
131-
}
169+
//if (!parentComponentInfo) {
170+
// message.error(`Parent component "${selectedEditorComponent}" not found`);
171+
// return;
172+
//}
132173

133-
const{componentKey:parentKey, items}=parentComponentInfo;
174+
//const { componentKey: parentKey, items } = parentComponentInfo;
134175

135-
if(!parentKey){
136-
message.error(`Parent component "${selectedEditorComponent}" not found in layout`);
137-
return;
138-
}
176+
//if (!parentKey) {
177+
// message.error(`Parent component "${selectedEditorComponent}" not found in layout`);
178+
// return;
179+
//}
139180

140-
constparentItem=items[parentKey];
181+
//const parentItem = items[parentKey];
141182
if(!parentItem){
142183
message.error(`Parent component "${selectedEditorComponent}" not found in items`);
143184
return;
@@ -153,10 +194,15 @@ export const nestComponentAction: ActionConfig = {
153194
}
154195

155196
try{
156-
197+
letcompName=name;
157198
constnameGenerator=editorState.getNameGenerator();
158199
constcompInfo=parseCompType(selectedNestComponent);
159-
constcompName=nameGenerator.genItemName(compInfo.compName);
200+
if(!compName){
201+
compName=nameGenerator.genItemName(compInfo.compName);
202+
}
203+
// const nameGenerator = editorState.getNameGenerator();
204+
// const compInfo = parseCompType(selectedNestComponent);
205+
// const compName = nameGenerator.genItemName(compInfo.compName);
160206
constkey=genRandomKey();
161207

162208
constmanifest=uiCompRegistry[selectedNestComponent];
@@ -172,15 +218,33 @@ export const nestComponentAction: ActionConfig = {
172218
defaultDataFn=manifest?.defaultDataFn;
173219
}
174220

221+
letcompDefaultValue=defaultDataFn ?defaultDataFn(compName,nameGenerator,editorState) :undefined;
222+
constcompInitialValue={
223+
...(compDefaultValueasany||{}),
224+
...action_parameters,
225+
}
226+
175227
constwidgetValue:GridItemDataType={
176228
compType:selectedNestComponent,
177229
name:compName,
178-
comp:defaultDataFn ?defaultDataFn(compName,nameGenerator,editorState) :undefined,
230+
comp:compInitialValue,
179231
};
180232

181233
constparentContainer=parentItem.children.comp;
182-
183-
constrealContainer=parentContainer.realSimpleContainer();
234+
letoriginalContainer=parentContainer;
235+
for(constchildComponentofchildComponents){
236+
originalContainer=originalContainer.children[childComponent];
237+
}
238+
if(originalContainer?.children?.[0]?.children?.view){
239+
originalContainer=originalContainer?.children?.[0]?.children?.view;
240+
}
241+
242+
if(!originalContainer){
243+
message.error(`Container "${selectedEditorComponent}" cannot accept nested components`);
244+
return;
245+
}
246+
247+
constrealContainer=originalContainer.realSimpleContainer();
184248
if(!realContainer){
185249
message.error(`Container "${selectedEditorComponent}" cannot accept nested components`);
186250
return;
@@ -202,6 +266,7 @@ export const nestComponentAction: ActionConfig = {
202266
h:layoutInfo.h||5,
203267
pos:itemPos,
204268
isDragging:false,
269+
...(layout||{}),
205270
};
206271

207272
realContainer.dispatch(

‎client/packages/lowcoder/src/comps/comps/preLoadComp/types.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface ActionConfig {
4444
exportinterfaceActionExecuteParams{
4545
actionKey:string;
4646
actionValue:string;
47+
actionPayload?:any;
4748
selectedComponent:string|null;
4849
selectedEditorComponent:string|null;
4950
selectedNestComponent:string|null;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp