@@ -14,7 +14,8 @@ export default class PanelComponent extends NestedComponent {
14
14
input : false ,
15
15
tableView : false ,
16
16
dataGridLabel : false ,
17
- persistent : false
17
+ persistent : false ,
18
+ lazyLoad : false
18
19
} , ...extend ) ;
19
20
}
20
21
@@ -31,6 +32,7 @@ export default class PanelComponent extends NestedComponent {
31
32
32
33
constructor ( component , options , data ) {
33
34
super ( component , options , data ) ;
35
+ this . lazyLoaded = false ;
34
36
}
35
37
36
38
get defaultSchema ( ) {
@@ -60,6 +62,48 @@ export default class PanelComponent extends NestedComponent {
60
62
}
61
63
}
62
64
65
+ checkValidity ( data , dirty ) {
66
+ // Make sure to toggle the collapsed state before checking validity.
67
+ if (
68
+ dirty &&
69
+ this . component . lazyLoad &&
70
+ this . component . collapsible &&
71
+ this . collapsed &&
72
+ ! this . lazyLoaded
73
+ ) {
74
+ this . lazyLoaded = true ;
75
+ this . addComponents ( ) ;
76
+ }
77
+
78
+ return super . checkValidity ( data , dirty ) ;
79
+ }
80
+
81
+ addComponents ( element , data , options , state ) {
82
+ // If they are lazy loading, then only add the components if they toggle the collapsed state.
83
+ if (
84
+ this . component . lazyLoad &&
85
+ this . component . collapsible &&
86
+ this . collapsed &&
87
+ ! this . lazyLoaded
88
+ ) {
89
+ return ;
90
+ }
91
+ return super . addComponents ( element , data , options , state ) ;
92
+ }
93
+
94
+ toggleCollapse ( ) {
95
+ super . toggleCollapse ( ) ;
96
+ if (
97
+ this . component . lazyLoad &&
98
+ this . component . collapsible &&
99
+ ! this . collapsed &&
100
+ ! this . lazyLoaded
101
+ ) {
102
+ this . lazyLoaded = true ;
103
+ this . addComponents ( ) ;
104
+ }
105
+ }
106
+
63
107
build ( state ) {
64
108
this . component . theme = this . component . theme || 'default' ;
65
109
let panelClass = 'mb-2 card border ' ;
0 commit comments