@@ -11,10 +11,10 @@ import {
11
11
import { MultiCompBuilder , sameTypeMap , withDefault } from "comps/generators" ;
12
12
import { migrateOldData } from "comps/generators/simpleGenerators" ;
13
13
import { NameGenerator } from "comps/utils" ;
14
- import { fromRecord , Node } from "lowcoder-core" ;
14
+ import { changeValueAction , fromRecord , multiChangeAction , Node } from "lowcoder-core" ;
15
15
import { nodeIsRecord } from "lowcoder-core" ;
16
16
import _ from "lodash" ;
17
- import { ReactNode } from "react" ;
17
+ import { ReactNode , useContext , useEffect } from "react" ;
18
18
import { lastValueIfEqual } from "util/objectUtils" ;
19
19
import {
20
20
CompTree ,
@@ -27,6 +27,9 @@ import { SimpleContainerComp } from "../containerBase/simpleContainerComp";
27
27
import { ContainerBodyChildComp } from "./containerBodyChildComp" ;
28
28
import { trans } from "i18n" ;
29
29
import { ControlNode } from "lowcoder-design" ;
30
+ import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext" ;
31
+ import { CompTypeContext } from "@lowcoder-ee/comps/utils/compTypeContext" ;
32
+ import { setInitialCompStyles } from "@lowcoder-ee/comps/utils/themeUtil" ;
30
33
31
34
const childrenMap = {
32
35
header : SimpleContainerComp ,
@@ -40,15 +43,32 @@ const childrenMap = {
40
43
showFooter : BoolControl ,
41
44
autoHeight : AutoHeightControl ,
42
45
scrollbars : withDefault ( BoolControl , false ) ,
43
- style : withDefault ( styleControl ( ContainerStyle ) , { borderWidth :'1px' } ) ,
44
- headerStyle : styleControl ( ContainerHeaderStyle ) ,
45
- bodyStyle : styleControl ( ContainerBodyStyle ) ,
46
- footerStyle : styleControl ( ContainerFooterStyle ) ,
46
+ style : withDefault ( styleControl ( ContainerStyle , 'style' ) , { borderWidth :'1px' } ) ,
47
+ headerStyle : styleControl ( ContainerHeaderStyle , 'headerStyle' ) ,
48
+ bodyStyle : styleControl ( ContainerBodyStyle , 'bodyStyle' ) ,
49
+ footerStyle : styleControl ( ContainerFooterStyle , 'footerStyle' ) ,
47
50
} ;
48
51
49
52
// Compatible with old style data 2022-8-15
50
53
const TriContainerBaseComp = migrateOldData (
51
54
new MultiCompBuilder ( childrenMap , ( props , dispatch ) => {
55
+ const theme = useContext ( ThemeContext ) ;
56
+ const compType = useContext ( CompTypeContext ) ;
57
+ const compTheme = theme ?. theme ?. components ?. [ compType ] ;
58
+ // Filter style props from children props
59
+ const styleProps : Record < string , any > = { } ;
60
+ [ 'style' , 'headerStyle' , 'bodyStyle' , 'footerStyle' ] . forEach ( ( key : string ) => {
61
+ styleProps [ key ] = ( props as any ) [ key ] ;
62
+ } ) ;
63
+ // Update comp styles with combination of default style and comp theme style
64
+ useEffect ( ( ) => {
65
+ setInitialCompStyles ( {
66
+ dispatch,
67
+ compTheme,
68
+ styleProps,
69
+ } ) ;
70
+ } , [ ] ) ;
71
+
52
72
return { ...props , dispatch } ;
53
73
} ) . build ( ) ,
54
74
fixOldStyleData
0 commit comments