@@ -39,7 +39,7 @@ import {
39
39
import {
40
40
$dataSourceVariables ,
41
41
$dataSources ,
42
- $registeredComponentPropsMetas ,
42
+ $registeredComponentMetas ,
43
43
$variableValuesByInstanceSelector ,
44
44
} from "~/shared/nano-states" ;
45
45
import type { BindingVariant } from "~/builder/shared/binding-popover" ;
@@ -455,62 +455,60 @@ const attributeToMeta = (attribute: Attribute): PropMeta => {
455
455
} ;
456
456
457
457
export const $selectedInstancePropsMetas = computed (
458
- [ $selectedInstance , $registeredComponentPropsMetas , $instanceTags ] ,
459
- ( instance , componentPropsMetas , instanceTags ) : Map < string , PropMeta > => {
458
+ [ $selectedInstance , $registeredComponentMetas , $instanceTags ] ,
459
+ ( instance , metas , instanceTags ) : Map < string , PropMeta > => {
460
460
if ( instance === undefined ) {
461
461
return new Map ( ) ;
462
462
}
463
- const propsMetas = componentPropsMetas . get ( instance . component ) ?. props ?? { } ;
463
+ const meta = metas . get ( instance . component ) ;
464
464
const tag = instanceTags . get ( instance . id ) ;
465
- const metas = new Map < Prop [ "name" ] , PropMeta > ( ) ;
465
+ const propsMetas = new Map < Prop [ "name" ] , PropMeta > ( ) ;
466
466
// add html attributes only when instance has tag
467
467
if ( tag ) {
468
468
for ( const attribute of [ ...ariaAttributes ] . reverse ( ) ) {
469
- metas . set ( attribute . name , attributeToMeta ( attribute ) ) ;
469
+ propsMetas . set ( attribute . name , attributeToMeta ( attribute ) ) ;
470
470
}
471
471
if ( attributesByTag [ "*" ] ) {
472
472
for ( const attribute of [ ...attributesByTag [ "*" ] ] . reverse ( ) ) {
473
- metas . set ( attribute . name , attributeToMeta ( attribute ) ) ;
473
+ propsMetas . set ( attribute . name , attributeToMeta ( attribute ) ) ;
474
474
}
475
475
}
476
476
if ( attributesByTag [ tag ] ) {
477
477
for ( const attribute of [ ...attributesByTag [ tag ] ] . reverse ( ) ) {
478
- metas . set ( attribute . name , attributeToMeta ( attribute ) ) ;
478
+ propsMetas . set ( attribute . name , attributeToMeta ( attribute ) ) ;
479
479
}
480
480
}
481
481
}
482
- for ( const [ name , propMeta ] of Object . entries ( propsMetas ) . reverse ( ) ) {
482
+ for ( const [ name , propMeta ] of Object . entries (
483
+ meta ?. props ?? { }
484
+ ) . reverse ( ) ) {
483
485
// when component property has the same name as html attribute in react
484
486
// override to deduplicate similar properties
485
487
// for example component can have own "className" and html has "class"
486
488
const htmlName = reactPropsToStandardAttributes [ name ] ;
487
489
if ( htmlName ) {
488
- metas . delete ( htmlName ) ;
490
+ propsMetas . delete ( htmlName ) ;
489
491
}
490
- metas . set ( name , propMeta ) ;
492
+ propsMetas . set ( name , propMeta ) ;
491
493
}
492
- metas . set ( showAttribute , showAttributeMeta ) ;
494
+ propsMetas . set ( showAttribute , showAttributeMeta ) ;
493
495
// ui should render in the following order
494
496
// 1. system properties
495
497
// 2. component properties
496
498
// 3. specific tag attributes
497
499
// 4. global html attributes
498
500
// 5. aria attributes
499
- return new Map ( Array . from ( metas . entries ( ) ) . reverse ( ) ) ;
501
+ return new Map ( Array . from ( propsMetas . entries ( ) ) . reverse ( ) ) ;
500
502
}
501
503
) ;
502
504
503
505
export const $selectedInstanceInitialPropNames = computed (
504
- [
505
- $selectedInstance ,
506
- $registeredComponentPropsMetas ,
507
- $selectedInstancePropsMetas ,
508
- ] ,
509
- ( selectedInstance , componentPropsMetas , instancePropsMetas ) => {
506
+ [ $selectedInstance , $registeredComponentMetas , $selectedInstancePropsMetas ] ,
507
+ ( selectedInstance , metas , instancePropsMetas ) => {
510
508
const initialPropNames = new Set < string > ( ) ;
511
509
if ( selectedInstance ) {
512
510
const initialProps =
513
- componentPropsMetas . get ( selectedInstance . component ) ?. initialProps ?? [ ] ;
511
+ metas . get ( selectedInstance . component ) ?. initialProps ?? [ ] ;
514
512
for ( const propName of initialProps ) {
515
513
// className -> class
516
514
if ( instancePropsMetas . has ( reactPropsToStandardAttributes [ propName ] ) ) {
0 commit comments