@api-components/api-type-document 4.2.31 → 4.2.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@api-components/api-type-document",
|
|
3
3
|
"description": "A documentation table for type (resource) properties. Works with AMF data model",
|
|
4
|
-
"version": "4.2.
|
|
4
|
+
"version": "4.2.33",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"module": "index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@advanced-rest-client/arc-marked": "^1.1.0",
|
|
29
29
|
"@advanced-rest-client/markdown-styles": "^3.1.4",
|
|
30
30
|
"@anypoint-web-components/anypoint-button": "^1.2.3",
|
|
31
|
-
"@api-components/amf-helper-mixin": "^4.5.
|
|
31
|
+
"@api-components/amf-helper-mixin": "^4.5.29",
|
|
32
32
|
"@api-components/api-annotation-document": "^4.1.0",
|
|
33
33
|
"@api-components/api-resource-example-document": "^4.3.3",
|
|
34
34
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
package/src/ApiTypeDocument.js
CHANGED
|
@@ -671,6 +671,19 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
671
671
|
this._hasExamples = value;
|
|
672
672
|
}
|
|
673
673
|
|
|
674
|
+
/**
|
|
675
|
+
* Return the type mappings
|
|
676
|
+
*/
|
|
677
|
+
_typesMappings(item) {
|
|
678
|
+
const itemName = this._getValue(item, this._getAmfKey(this.ns.w3.shacl.name));
|
|
679
|
+
const typeTarget = this._getValue(this.type, this._getAmfKey(this.ns.aml.vocabularies.shapes.discriminator));
|
|
680
|
+
let type;
|
|
681
|
+
if (itemName && typeTarget && itemName === typeTarget) {
|
|
682
|
+
type = this.type;
|
|
683
|
+
}
|
|
684
|
+
return type;
|
|
685
|
+
}
|
|
686
|
+
|
|
674
687
|
/**
|
|
675
688
|
* @return {TemplateResult[]|string} Templates for object properties
|
|
676
689
|
*/
|
|
@@ -691,6 +704,7 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
691
704
|
?graph="${this.graph}"
|
|
692
705
|
.mediaType="${this.mediaType}"
|
|
693
706
|
?renderReadOnly="${this.renderReadOnly}"
|
|
707
|
+
.discriminatorMapping="${this._typesMappings(item)}"
|
|
694
708
|
></property-shape-document>`
|
|
695
709
|
);
|
|
696
710
|
}
|
|
@@ -143,6 +143,11 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
143
143
|
* @attribute
|
|
144
144
|
*/
|
|
145
145
|
deprecated: boolean
|
|
146
|
+
/**
|
|
147
|
+
* List type mappings
|
|
148
|
+
* @attribute
|
|
149
|
+
*/
|
|
150
|
+
discriminatorMapping: any;
|
|
146
151
|
|
|
147
152
|
get complexToggleLabel(): string;
|
|
148
153
|
|
|
@@ -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}"
|
package/src/ShapeStyles.js
CHANGED
|
@@ -163,4 +163,14 @@ export default css`
|
|
|
163
163
|
border-radius: var(--api-type-document-deprecated-warning-border-radius, 3px);
|
|
164
164
|
display: inline-flex;
|
|
165
165
|
}
|
|
166
|
+
.types-mappings-container {
|
|
167
|
+
margin-top: -10px;
|
|
168
|
+
}
|
|
169
|
+
.types-mappings-item {
|
|
170
|
+
cursor: pointer;
|
|
171
|
+
color: var(--link-color, #0277bd);
|
|
172
|
+
}
|
|
173
|
+
.types-mappings-item:hover {
|
|
174
|
+
text-decoration: underline;
|
|
175
|
+
}
|
|
166
176
|
`;
|