@@ -16,6 +16,7 @@ import {
1616 RecordType ,
1717 NameGenerator ,
1818 JSONValue ,
19+ CompActionTypes ,
1920} from "lowcoder-sdk" ;
2021import React from "react" ;
2122
@@ -28,7 +29,8 @@ type JSONValue = typeof JSONValue;
2829const ContextSlotControl = withSelectedMultiContext ( SlotControl ) ;
2930
3031const ContainerView = React . memo ( ( props : ContainerBaseProps ) => {
31- return < InnerGrid { ...props } emptyRows = { 15 } autoHeight /> ;
32+ console . log ( 'card grid -> ' , props ) ;
33+ return < InnerGrid { ...props } emptyRows = { 8 } autoHeight /> ;
3234} ) ;
3335
3436const CardView = React . memo ( ( props : { containerProps : ConstructorToView < typeof SimpleContainerComp > } ) => {
@@ -47,13 +49,28 @@ const CardView = React.memo((props: { containerProps: ConstructorToView<typeof S
4749 // containerPadding={[2, 2]}
4850 />
4951 ) ;
50- } ) ;
52+ } , ( prev , next ) => JSON . stringify ( prev . containerProps ) === JSON . stringify ( next . containerProps ) ) ;
53+
54+ const cardTemplate = ( props : {
55+ data : Record < string , string > ,
56+ index : number ,
57+ cardView : any ,
58+ } ) => {
59+ const slotControl = props . cardView . getView ( ) (
60+ {
61+ currentRow : props . data ,
62+ currentIndex : props . index ,
63+ currentOriginalIndex : props . index ,
64+ } ,
65+ String ( props . index )
66+ ) ;
67+ const containerProps = slotControl . children . container . getView ( ) ;
68+ return < CardView key = { `view-${ props . index } ` } containerProps = { containerProps } />
69+ } ;
5170
5271let CardViewControlTmp = ( function ( ) {
53- // const label = trans("table.expandable");
5472 return new ControlItemCompBuilder (
5573 {
56- // expandable: BoolControl,
5774 cardView : ContextSlotControl ,
5875 } ,
5976 ( ) => ( { cardViewConfig : { } , cardModalView : null } )
@@ -65,7 +82,7 @@ let CardViewControlTmp = (function () {
6582 { children . cardView
6683 . getSelectedComp ( )
6784 . getComp ( )
68- . propertyView ( { buttonText : "Customize" } )
85+ . propertyView ( { buttonText : "Customize Card View " } )
6986 }
7087 </ >
7188 ) ;
@@ -78,16 +95,12 @@ export class CardViewControl extends CardViewControlTmp {
7895 const selectedContainer = this . children . cardView . getSelectedComp ( ) ;
7996 return {
8097 cardTemplate : ( data : Record < string , string > , index : number ) => {
81- const slotControl = this . children . cardView . getView ( ) (
82- {
83- currentRow : data ,
84- currentIndex : index ,
85- currentOriginalIndex : index ,
86- } ,
87- String ( index )
88- ) ;
89- const containerProps = slotControl . children . container . getView ( ) ;
90- return < CardView key = { index } containerProps = { containerProps } /> ;
98+ const cardView = this . children . cardView ;
99+ return cardTemplate ( {
100+ data,
101+ index,
102+ cardView,
103+ } ) ;
91104 } ,
92105 cardModalView : selectedContainer . getView ( ) ,
93106 } ;
@@ -105,6 +118,8 @@ export class CardViewControl extends CardViewControlTmp {
105118 }
106119
107120 reduce ( action : any ) {
121+ if ( action . type === CompActionTypes . CHANGE_VALUE && action . path [ action . path . length - 1 ] === 'positionParams' ) return this ;
122+
108123 const comp = super . reduce ( action ) ;
109124 // console.info("CardViewControl reduce. action: ", action, "\nthis: ", this, "\ncomp: ", comp);
110125 return comp ;
0 commit comments