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

Commitb0f8e67

Browse files
listView doesn't expose component updates for child components
1 parent11c6dcd commitb0f8e67

File tree

16 files changed

+141
-52
lines changed

16 files changed

+141
-52
lines changed

‎client/packages/lowcoder/src/comps/comps/listViewComp/listView.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ export function ListView(props: Props) {
176176
return<divkey={itemIdx}style={{flex:"auto"}}></div>;
177177
}
178178
constcontainerProps=containerFn(
179-
{[itemIndexName]:itemIdx,[itemDataName]:getCurrentItemParams(data,itemIdx)},
179+
{
180+
[itemIndexName]:itemIdx,
181+
[itemDataName]:getCurrentItemParams(data,itemIdx)
182+
},
180183
String(itemIdx)
181184
).getView();
182185
constunMountFn=()=>{

‎client/packages/lowcoder/src/comps/comps/listViewComp/listViewComp.tsx‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
}from"comps/controls/codeControl";
88
import{styleControl}from"comps/controls/styleControl";
99
import{ListViewStyle}from"comps/controls/styleControlConstants";
10-
import{UICompBuilder,withDefault,withPropertyViewFn,withViewFn}from"comps/generators";
10+
import{UICompBuilder,stateComp,valueComp,withDefault,withPropertyViewFn,withViewFn}from"comps/generators";
1111
import{
1212
CompDepsConfig,
1313
depsConfig,
@@ -80,10 +80,10 @@ export class ListViewImplComp extends ListViewTmpComp implements IContainer {
8080
}
8181
overridereduce(action:CompAction): this{
8282
// console.info("listView reduce. action: ", action);
83-
8483
letcomp=reduceInContext({inEventContext:true},()=>super.reduce(action));
84+
8585
if(action.type===CompActionTypes.UPDATE_NODES_V2){
86-
const{ itemCount}=getData(comp.children.noOfRows.getView());
86+
const{ itemCount}=getData(comp.children.noOfRows.getView());
8787
constpagination=comp.children.pagination.getView();
8888
consttotal=pagination.total||itemCount;
8989
constoffset=(pagination.current-1)*pagination.pageSize;
@@ -171,6 +171,12 @@ export const ListViewComp = withExposingConfigs(ListViewPropertyComp, [
171171
returndata;
172172
},
173173
}),
174+
// new CompDepsConfig(
175+
// "index",
176+
// (comp) => ({index: comp.children.itemIndexName.node() }),
177+
// (input) => input.index.value,
178+
// "index", // trans("listView.itemsDesc")
179+
// ),
174180
NameConfigHidden,
175181
]);
176182

@@ -232,7 +238,7 @@ export function defaultListViewData(compName: string, nameGenerator: NameGenerat
232238
compType:"rating",
233239
name:nameGenerator.genItemName("rating"),
234240
comp:{
235-
value:"{{currentItem.rate / 2}}",
241+
defaultValue:"{{currentItem.rate / 2}}",
236242
max:"5",
237243
label:{
238244
text:"",

‎client/packages/lowcoder/src/comps/comps/ratingComp.tsx‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { migrateOldData } from "comps/generators/simpleGenerators";
1515
import{disabledPropertyView,hiddenPropertyView}from"comps/utils/propertyUtils";
1616
import{trans}from"i18n";
1717

18-
import{useContext}from"react";
18+
import{useContext,useEffect,useRef}from"react";
1919
import{EditorContext}from"comps/editorState";
2020

2121
constEventOptions=[changeEvent]asconst;
@@ -36,6 +36,7 @@ function fixOldData(oldData: any) {
3636

3737
constRatingBasicComp=(function(){
3838
constchildrenMap={
39+
defaultValue:numberExposingStateControl("defaultValue"),
3940
value:numberExposingStateControl("value"),
4041
max:withDefault(NumberControl,"5"),
4142
label:LabelControl,
@@ -46,6 +47,21 @@ const RatingBasicComp = (function () {
4647
...formDataChildren,
4748
};
4849
returnnewUICompBuilder(childrenMap,(props)=>{
50+
constdefaultValue={ ...props.defaultValue}.value;
51+
constvalue={ ...props.value}.value;
52+
constchangeRef=useRef(false)
53+
54+
useEffect(()=>{
55+
props.value.onChange(defaultValue);
56+
},[defaultValue]);
57+
58+
useEffect(()=>{
59+
if(!changeRef.current)return;
60+
61+
props.onEvent("change");
62+
changeRef.current=false;
63+
},[value]);
64+
4965
returnprops.label({
5066
style:props.style,
5167
children:(
@@ -54,7 +70,7 @@ const RatingBasicComp = (function () {
5470
value={props.value.value}
5571
onChange={(e)=>{
5672
props.value.onChange(e);
57-
props.onEvent("change");
73+
changeRef.current=true;
5874
}}
5975
allowHalf={props.allowHalf}
6076
disabled={props.disabled}
@@ -67,7 +83,7 @@ const RatingBasicComp = (function () {
6783
return(
6884
<>
6985
<Sectionname={sectionNames.basic}>
70-
{children.value.propertyView({label:trans("prop.defaultValue")})}
86+
{children.defaultValue.propertyView({label:trans("prop.defaultValue")})}
7187
{children.max.propertyView({
7288
label:trans("rating.max"),
7389
})}

‎client/packages/lowcoder/src/comps/comps/selectInputComp/checkboxComp.tsx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ const CheckboxGroup = styled(AntdCheckboxGroup)<{
102102

103103
constCheckboxBasicComp=(function(){
104104
constchildrenMap={
105-
value:arrayStringExposingStateControl("value",["1"]),
105+
defaultValue:arrayStringExposingStateControl("defaultValue"),
106+
value:arrayStringExposingStateControl("value"),
106107
label:LabelControl,
107108
disabled:BoolCodeControl,
108109
onEvent:ChangeEventHandlerControl,
@@ -115,7 +116,10 @@ const CheckboxBasicComp = (function () {
115116
...formDataChildren,
116117
};
117118
returnnewUICompBuilder(childrenMap,(props)=>{
118-
const[validateState,handleValidate]=useSelectInputValidate(props);
119+
const[
120+
validateState,
121+
handleChange,
122+
]=useSelectInputValidate(props);
119123
returnprops.label({
120124
required:props.required,
121125
style:props.style,
@@ -134,9 +138,7 @@ const CheckboxBasicComp = (function () {
134138
disabled:option.disabled,
135139
}))}
136140
onChange={(values)=>{
137-
handleValidate(valuesasstring[]);
138-
props.value.onChange(valuesasstring[]);
139-
props.onEvent("change");
141+
handleChange(valuesasstring[]);
140142
}}
141143
/>
142144
),

‎client/packages/lowcoder/src/comps/comps/selectInputComp/multiSelectComp.tsx‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,24 @@ import { SelectInputInvalidConfig, useSelectInputValidate } from "./selectInputC
1414

1515
import{PaddingControl}from"../../controls/paddingControl";
1616
import{MarginControl}from"../../controls/marginControl";
17+
import{useEffect,useRef}from"react";
1718

1819
constMultiSelectBasicComp=(function(){
1920
constchildrenMap={
2021
...SelectChildrenMap,
21-
value:arrayStringExposingStateControl("value",["1","2"]),
22+
defaultValue:arrayStringExposingStateControl("defaultValue",["1","2"]),
23+
value:arrayStringExposingStateControl("value"),
2224
style:styleControl(MultiSelectStyle),
2325
margin:MarginControl,
2426
padding:PaddingControl,
2527
};
2628
returnnewUICompBuilder(childrenMap,(props,dispatch)=>{
2729
constvalueSet=newSet<any>(props.options.map((o)=>o.value));// Filter illegal default values entered by the user
28-
const[validateState,handleValidate]=useSelectInputValidate(props);
30+
const[
31+
validateState,
32+
handleChange,
33+
]=useSelectInputValidate(props);
34+
2935
returnprops.label({
3036
required:props.required,
3137
style:props.style,
@@ -34,11 +40,7 @@ const MultiSelectBasicComp = (function () {
3440
{...props}
3541
mode={"multiple"}
3642
value={props.value.value.filter?.((v)=>valueSet.has(v))}
37-
onChange={(value)=>{
38-
handleValidate(value);
39-
props.value.onChange(value);
40-
props.onEvent("change");
41-
}}
43+
onChange={handleChange}
4244
dispatch={dispatch}
4345
/>
4446
),

‎client/packages/lowcoder/src/comps/comps/selectInputComp/radioComp.tsx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ const Radio = styled(AntdRadioGroup)<{
8383

8484
constRadioBasicComp=(function(){
8585
returnnewUICompBuilder(RadioChildrenMap,(props)=>{
86-
const[validateState,handleValidate]=useSelectInputValidate(props);
86+
const[
87+
validateState,
88+
handleChange,
89+
]=useSelectInputValidate(props);
8790
returnprops.label({
8891
required:props.required,
8992
style:props.style,
@@ -95,9 +98,7 @@ const RadioBasicComp = (function () {
9598
$style={props.style}
9699
$layout={props.layout}
97100
onChange={(e)=>{
98-
handleValidate(e.target.value);
99-
props.value.onChange(e.target.value);
100-
props.onEvent("change");
101+
handleChange(e.target.value);
101102
}}
102103
options={props.options
103104
.filter((option)=>option.value!==undefined&&!option.hidden)

‎client/packages/lowcoder/src/comps/comps/selectInputComp/radioCompConstants.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const RadioLayoutOptions = [
3030
]asconst;
3131

3232
exportconstRadioChildrenMap={
33+
defaultValue:stringExposingStateControl("value"),
3334
value:stringExposingStateControl("value"),
3435
label:LabelControl,
3536
disabled:BoolCodeControl,
@@ -46,6 +47,9 @@ export const RadioChildrenMap = {
4647
exportconstRadioPropertyView=(
4748
children:RecordConstructorToComp<
4849
typeofRadioChildrenMap&{hidden:typeofBoolCodeControl}&{
50+
defaultValue:
51+
|ReturnType<typeofstringExposingStateControl>
52+
|ReturnType<typeofarrayStringExposingStateControl>;
4953
value:
5054
|ReturnType<typeofstringExposingStateControl>
5155
|ReturnType<typeofarrayStringExposingStateControl>;
@@ -55,7 +59,7 @@ export const RadioPropertyView = (
5559
<>
5660
<Sectionname={sectionNames.basic}>
5761
{children.options.propertyView({})}
58-
{children.value.propertyView({label:trans("prop.defaultValue")})}
62+
{children.defaultValue.propertyView({label:trans("prop.defaultValue")})}
5963
</Section>
6064

6165
{["logic","both"].includes(useContext(EditorContext).editorModeStatus)&&(

‎client/packages/lowcoder/src/comps/comps/selectInputComp/segmentedControl.tsx‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const Segmented = styled(AntdSegmented)<{ $style: SegmentStyleType }>`
6262
`;
6363

6464
constSegmentChildrenMap={
65+
defaultValue:stringExposingStateControl("value"),
6566
value:stringExposingStateControl("value"),
6667
label:LabelControl,
6768
disabled:BoolCodeControl,
@@ -76,7 +77,11 @@ const SegmentChildrenMap = {
7677

7778
constSegmentedControlBasicComp=(function(){
7879
returnnewUICompBuilder(SegmentChildrenMap,(props)=>{
79-
const[validateState,handleValidate]=useSelectInputValidate(props);
80+
const[
81+
validateState,
82+
handleValidate,
83+
handleChange,
84+
]=useSelectInputValidate(props);
8085
returnprops.label({
8186
required:props.required,
8287
style:props.style,
@@ -88,9 +93,7 @@ const SegmentedControlBasicComp = (function () {
8893
value={props.value.value}
8994
$style={props.style}
9095
onChange={(value)=>{
91-
handleValidate(value.toString());
92-
props.value.onChange(value.toString());
93-
props.onEvent("change");
96+
handleChange(value.toString());
9497
}}
9598
options={props.options
9699
.filter((option)=>option.value!==undefined&&!option.hidden)
@@ -109,7 +112,7 @@ const SegmentedControlBasicComp = (function () {
109112
<>
110113
<Sectionname={sectionNames.basic}>
111114
{children.options.propertyView({})}
112-
{children.value.propertyView({label:trans("prop.defaultValue")})}
115+
{children.defaultValue.propertyView({label:trans("prop.defaultValue")})}
113116
</Section>
114117

115118
{["logic","both"].includes(useContext(EditorContext).editorModeStatus)&&(

‎client/packages/lowcoder/src/comps/comps/selectInputComp/selectComp.tsx‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,29 @@ import { RecordConstructorToView } from "lowcoder-core";
2121
constSelectBasicComp=(function(){
2222
constchildrenMap={
2323
...SelectChildrenMap,
24+
defaultValue:stringExposingStateControl("defaultValue"),
2425
value:stringExposingStateControl("value"),
2526
style:styleControl(SelectStyle),
2627
};
2728
returnnewUICompBuilder(childrenMap,(props,dispatch)=>{
28-
const[validateState,handleValidate]=useSelectInputValidate(props);
29+
const[
30+
validateState,
31+
handleChange,
32+
]=useSelectInputValidate(props);
2933

3034
constpropsRef=useRef<RecordConstructorToView<typeofchildrenMap>>(props);
3135
propsRef.current=props;
3236

3337
constvalueSet=newSet<any>(props.options.map((o)=>o.value));// Filter illegal default values entered by the user
38+
3439
returnprops.label({
3540
required:props.required,
3641
style:props.style,
3742
children:(
3843
<SelectUIView
3944
{...props}
4045
value={valueSet.has(props.value.value) ?props.value.value :undefined}
41-
onChange={(value)=>{
42-
props.value.onChange(value??"").then(()=>{
43-
propsRef.current.onEvent("change");
44-
handleValidate(value??"");
45-
});
46-
}}
46+
onChange={handleChange}
4747
dispatch={dispatch}
4848
/>
4949
),

‎client/packages/lowcoder/src/comps/comps/selectInputComp/selectCompConstants.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,15 @@ export const SelectPropertyView = (
265265
hidden:typeofBoolCodeControl;
266266
}
267267
>&{
268+
defaultValue:{propertyView:(params:ControlParams)=>ControlNode};
268269
value:{propertyView:(params:ControlParams)=>ControlNode};
269270
style:{getPropertyView:()=>ControlNode};
270271
}
271272
)=>(
272273
<>
273274
<Sectionname={sectionNames.basic}>
274275
{children.options.propertyView({})}
275-
{children.value.propertyView({label:trans("prop.defaultValue")})}
276+
{children.defaultValue.propertyView({label:trans("prop.defaultValue")})}
276277
{placeholderPropertyView(children)}
277278
</Section>
278279

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp