@api-components/api-type-document 4.2.17 → 4.2.19

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.17",
4
+ "version": "4.2.19",
5
5
  "license": "Apache-2.0",
6
6
  "main": "index.js",
7
7
  "module": "index.js",
@@ -652,6 +652,25 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
652
652
  );
653
653
  }
654
654
 
655
+ _arrayPropertyTemplate(label, value, title) {
656
+ return html`
657
+ <div class="property-attribute" part="property-attribute">
658
+ <span class="attribute-label" part="attribute-label">${label}</span>
659
+ <span class="attribute-value" part="attribute-value" title=${title}>${value}</span>
660
+ </div>
661
+ `
662
+ }
663
+
664
+ _arrayPropertiesTemplate() {
665
+ const minCount = this._getValue(this._resolvedType, this.ns.w3.shacl.minCount)
666
+ const maxCount = this._getValue(this._resolvedType, this.ns.w3.shacl.maxCount)
667
+
668
+ return html`
669
+ ${minCount !== undefined ? this._arrayPropertyTemplate('Minimum array length:', minCount, 'Minimum amount of items in array') : ''}
670
+ ${maxCount !== undefined ? this._arrayPropertyTemplate('Maximum array length:', maxCount, 'Maximum amount of items in array') : ''}
671
+ `
672
+ }
673
+
655
674
  /**
656
675
  * @return {TemplateResult} Templates for object properties
657
676
  */
@@ -688,15 +707,19 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
688
707
  : ''}
689
708
  `
690
709
  );
691
- if (!this.hasParentType) {
692
- return html`
710
+
711
+ return html`
712
+ ${!this.hasParentType ?
713
+ html`
693
714
  <span>Array of:</span>
694
715
  <div class="array-children">
695
716
  ${documents}
696
- </div>
697
- `;
698
- }
699
- return html`${documents}`;
717
+ </div>`
718
+ : html`${documents}`
719
+ }
720
+
721
+ ${this._arrayPropertiesTemplate()}
722
+ `;
700
723
  }
701
724
 
702
725
  /**
@@ -303,6 +303,25 @@ export class PropertyRangeDocument extends PropertyDocumentMixin(LitElement) {
303
303
  </div>`;
304
304
  }
305
305
 
306
+ _arrayPropertiesTemplate() {
307
+ const { range } = this;
308
+
309
+ return html` ${this._hasProperty(range, this.ns.w3.shacl.minCount)
310
+ ? this._listItemTemplate(
311
+ 'Minimum array length',
312
+ 'Minimum amount of items in array',
313
+ this.ns.w3.shacl.minCount
314
+ )
315
+ : ''}
316
+ ${this._hasProperty(range, this.ns.w3.shacl.maxCount)
317
+ ? this._listItemTemplate(
318
+ 'Maximum array length',
319
+ 'Maximum amount of items in array',
320
+ this.ns.w3.shacl.maxCount
321
+ )
322
+ : ''}`;
323
+ }
324
+
306
325
  /**
307
326
  * @return {TemplateResult|string} Template for the element.
308
327
  */
@@ -355,6 +374,7 @@ export class PropertyRangeDocument extends PropertyDocumentMixin(LitElement) {
355
374
  ? this._filePropertiesTemplate()
356
375
  : this._nonFilePropertiesTemplate()}
357
376
  ${this.isEnum ? this._enumTemplate() : ''}
377
+ ${this.isArray ? this._arrayPropertiesTemplate() : ''}
358
378
 
359
379
  <section class="examples" ?hidden="${!this._hasExamples}">
360
380
  <api-resource-example-document
package/src/TypeStyles.js CHANGED
@@ -85,4 +85,15 @@ export default css`
85
85
  .union-type-selector {
86
86
  margin: 12px 0;
87
87
  }
88
+
89
+ .property-attribute {
90
+ margin: 4px 0;
91
+ padding: 0;
92
+ color: var(--api-type-document-type-attribute-color, #616161);
93
+ }
94
+
95
+ .attribute-label {
96
+ font-weight: var(--api-type-document-property-range-attribute-label-font-weight, 500);
97
+ margin-right: 12px;
98
+ }
88
99
  `;