@@ -159,6 +159,10 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
159
159
* Determines if shape's range is deprecated
160
160
*/
161
161
deprecated : { type : Boolean , reflect : true } ,
162
+ /**
163
+ * Used for discriminator types mappings
164
+ */
165
+ discriminatorMapping : { type : Object } ,
162
166
} ;
163
167
}
164
168
@@ -247,6 +251,7 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
247
251
this . narrow = false ;
248
252
this . renderReadOnly = false ;
249
253
this . deprecated = false ;
254
+ this . discriminatorMapping = undefined ;
250
255
}
251
256
252
257
connectedCallback ( ) {
@@ -936,6 +941,42 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
936
941
return ''
937
942
}
938
943
944
+ _navigateItem ( e ) {
945
+ e . preventDefault ( ) ;
946
+ const data = e . composedPath ( ) [ 0 ] . dataset ;
947
+ if ( ! data . id || ! data . shapeType ) {
948
+ return ;
949
+ }
950
+ const ev = new CustomEvent ( "api-navigation-selection-changed" , {
951
+ bubbles : true ,
952
+ composed : true ,
953
+ detail : {
954
+ selected : data . id ,
955
+ type : data . shapeType ,
956
+ } ,
957
+ } ) ;
958
+ this . dispatchEvent ( ev ) ;
959
+ }
960
+
961
+ _keydownNavigateItem ( e ) {
962
+ if ( e . key === "Enter" ) {
963
+ this . _navigateItem ( e ) ;
964
+ }
965
+ }
966
+
967
+ _typesMappingsTemplate ( ) {
968
+ const mappings = this . _getValueArray ( this . discriminatorMapping , this . _getAmfKey ( this . ns . aml . vocabularies . shapes . discriminatorValueMapping ) ) ;
969
+ if ( ! mappings ) return html `` ;
970
+
971
+ return html `< ul class ="types-mappings-container ">
972
+ ${ mappings . map ( ( mapping ) => {
973
+ const name = this . _getValue ( mapping , this . _getAmfKey ( this . ns . aml . vocabularies . shapes . discriminatorValue ) ) ;
974
+ const target = this . _getLinkValue ( mapping , this . _getAmfKey ( this . ns . aml . vocabularies . shapes . discriminatorValueTarget ) ) ;
975
+ return html `< li class ="types-mappings-item " data-id ="${ target } " data-shape-type ="type " @click ="${ this . _navigateItem } " @keydown ="${ this . _keydownNavigateItem } "> ${ name } </ li > ` ;
976
+ } ) }
977
+ </ ul > ` ;
978
+ }
979
+
939
980
/**
940
981
* @return {TemplateResult } Main render function.
941
982
*/
@@ -975,6 +1016,7 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
975
1016
${ this . _getTypeAliasesAvroTemplate ( ) }
976
1017
${ this . _deprecatedWarningTemplate ( ) }
977
1018
${ this . _descriptionTemplate ( ) }
1019
+ ${ this . _typesMappingsTemplate ( ) }
978
1020
< property-range-document
979
1021
.amf ="${ this . amf } "
980
1022
.shape ="${ this . shape } "
0 commit comments