File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
packages/dataviews/src/components/dataform/stories Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -435,3 +435,53 @@ export const Validation = {
435
435
required : true ,
436
436
} ,
437
437
} ;
438
+
439
+ const DataFormVisibilityComponent = ( ) => {
440
+ type Post = {
441
+ name : string ;
442
+ email : string ;
443
+ isActive : boolean ;
444
+ } ;
445
+ const [ data , setData ] = useState ( {
446
+ name : '' ,
447
+ email : '' ,
448
+ isActive : true ,
449
+ } ) ;
450
+
451
+ const _fields = [
452
+ { id : 'isActive' , label : 'Is module active?' , type : 'boolean' } ,
453
+ {
454
+ id : 'name' ,
455
+ label : 'Name' ,
456
+ type : 'text' ,
457
+ isVisible : ( post ) => post . isActive === true ,
458
+ } ,
459
+ {
460
+ id : 'email' ,
461
+ label : 'Email' ,
462
+ type : 'email' ,
463
+ isVisible : ( post ) => post . isActive === true ,
464
+ } ,
465
+ ] satisfies Field < Post > [ ] ;
466
+ const form = {
467
+ fields : [ 'isActive' , 'name' , 'email' ] ,
468
+ } ;
469
+ return (
470
+ < DataForm < Post >
471
+ data = { data }
472
+ fields = { _fields }
473
+ form = { form }
474
+ onChange = { ( edits ) =>
475
+ setData ( ( prev ) => ( {
476
+ ...prev ,
477
+ ...edits ,
478
+ } ) )
479
+ }
480
+ />
481
+ ) ;
482
+ } ;
483
+
484
+ export const Visibility = {
485
+ title : 'DataForm/Visibility' ,
486
+ render : DataFormVisibilityComponent ,
487
+ } ;
You can’t perform that action at this time.
0 commit comments