@anjuna/docs
Version:
Anjuna Documentation Web Components
63 lines (62 loc) • 2.12 kB
JavaScript
import { h } from "@stencil/core";
const keys = ['inputs', 'outputs', 'props', 'events', 'methods'];
export class Api {
hasApi() {
if (!this.doc) {
return false;
}
for (const k of keys) {
if (this.doc[k] && this.doc[k].length > 0) {
return true;
}
}
}
angular() {
return [
this.doc.inputs ? this.doc.inputs.map(i => h("ad-input-def", { input: i })) : undefined,
this.doc.outputs ? this.doc.outputs.map(i => h("ad-output-def", { output: i })) : undefined,
this.doc.props ? this.doc.props.map(i => h("ad-prop-def", { prop: i })) : undefined
];
}
stencil() {
return [
this.doc.props ? this.doc.props.map(i => h("ad-prop-def", { prop: i })) : undefined,
this.doc.events ? this.doc.events.map(i => h("ad-event-def", { event: i })) : undefined,
];
}
render() {
if (!this.hasApi()) {
return undefined;
}
const isAngular = !this.doc.tag;
return (h("article", { id: "api", class: "api" },
h("h2", null, "API"),
isAngular ? this.angular() : this.stencil(),
this.doc.methods ? this.doc.methods.map(i => h("ad-method-def", { method: i })) : undefined));
}
static get is() { return "ad-api"; }
static get encapsulation() { return "scoped"; }
static get originalStyleUrls() { return {
"$": ["api.scss"]
}; }
static get styleUrls() { return {
"$": ["api.css"]
}; }
static get properties() { return {
"doc": {
"type": "unknown",
"mutable": false,
"complexType": {
"original": "{[key: string]: any}",
"resolved": "{ [key: string]: any; }",
"references": {}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": ""
}
}
}; }
}