2023-02-28 08:29:30 +00:00
|
|
|
<template>
|
2023-03-06 10:59:56 +00:00
|
|
|
<DocSectionText :id="id" :label="label" :level="componentLevel">
|
|
|
|
{{ description || null }}
|
|
|
|
<p v-if="relatedProp" class="inline-block">
|
2023-03-06 13:43:19 +00:00
|
|
|
See <NuxtLink :to="setRelatedPropPath(relatedProp)" class="doc-option-link"> {{ relatedPropValue(relatedProp) }} </NuxtLink>
|
2023-03-06 10:59:56 +00:00
|
|
|
</p>
|
|
|
|
</DocSectionText>
|
2023-02-28 08:29:30 +00:00
|
|
|
|
2023-03-06 10:59:56 +00:00
|
|
|
<div v-if="!data[0].data" class="doc-tablewrapper mt-3">
|
|
|
|
<table class="doc-table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th v-for="header in Object.keys(data[0])" :key="header">
|
|
|
|
<template v-if="header !== 'readonly' && header !== 'optional' && header !== 'deprecated'">
|
|
|
|
{{ header }}
|
|
|
|
</template>
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr v-for="prop in data" :key="prop">
|
2023-09-20 17:52:07 +00:00
|
|
|
<td
|
|
|
|
v-for="[k, v] in Object.entries(prop)"
|
|
|
|
:key="k"
|
|
|
|
:class="{ 'doc-option-type': k === 'type' || k === 'options', 'doc-option-default': k === 'defaultValue' }"
|
|
|
|
:style="{ 'max-width': k === 'default' || k === 'returnType' ? '200px' : undefined }"
|
|
|
|
>
|
2023-03-06 10:59:56 +00:00
|
|
|
<template v-if="k !== 'readonly' && k !== 'optional' && k !== 'deprecated'">
|
2023-03-27 10:48:54 +00:00
|
|
|
<span v-if="k === 'name'" :id="id + '.' + v" class="doc-option-name" :class="{ 'line-through cursor-pointer': !!prop.deprecated }" :title="prop.deprecated">
|
2023-09-20 17:52:07 +00:00
|
|
|
{{ v }}<NuxtLink :to="`/${$router.currentRoute.value.name}/#${id}.${v}`" :class="['doc-option-link', optionLinkClass]"> <i class="pi pi-link"></i> </NuxtLink>
|
2023-03-06 10:59:56 +00:00
|
|
|
</span>
|
2023-09-20 17:52:07 +00:00
|
|
|
|
2023-03-06 10:59:56 +00:00
|
|
|
<template v-else-if="k === 'type'">
|
|
|
|
<template v-for="(value, i) in getType(v)" :key="value">
|
2023-09-20 17:52:07 +00:00
|
|
|
{{ i !== 0 ? ' | ' : '' }}<NuxtLink v-if="isLinkType(value)" :to="setLinkPath(value)" :class="['doc-option-link', optionLinkClass]">{{ value }}</NuxtLink
|
2023-03-06 21:50:56 +00:00
|
|
|
><span v-else>{{ value }}</span>
|
2023-03-04 13:43:35 +00:00
|
|
|
</template>
|
2023-03-06 10:59:56 +00:00
|
|
|
</template>
|
2023-02-28 08:29:30 +00:00
|
|
|
|
2023-08-10 09:07:31 +00:00
|
|
|
<template v-else-if="k === 'options'">
|
|
|
|
<template v-for="val in v" :key="val.name">
|
|
|
|
<div class="doc-option-type-options-container">
|
|
|
|
{{ val.name }}: <span class="doc-option-type-options">{{ val.type }}</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
2023-03-06 10:59:56 +00:00
|
|
|
<template v-else-if="k === 'parameters'">
|
2023-09-20 17:52:07 +00:00
|
|
|
<span v-if="v.name" :class="{ 'font-medium text-600': label === 'Slots' }"> {{ v.name }} : </span>
|
2023-03-06 10:59:56 +00:00
|
|
|
<template v-for="(value, i) in getType(v.type)" :key="value">
|
2023-09-20 17:52:07 +00:00
|
|
|
{{ i !== 0 ? ' | ' : '' }}<NuxtLink v-if="isLinkType(value)" :to="setLinkPath(value)" :class="['doc-option-link', optionLinkClass]"> {{ value }} </NuxtLink>
|
2023-03-06 21:50:56 +00:00
|
|
|
<span v-else v-html="value"> </span>
|
2023-03-06 10:59:56 +00:00
|
|
|
</template>
|
2023-02-28 08:29:30 +00:00
|
|
|
</template>
|
2023-03-06 10:59:56 +00:00
|
|
|
|
2023-09-20 17:52:07 +00:00
|
|
|
<div v-else-if="(k === 'default' && v !== '') || k === 'returnType'" :id="id + '.' + k" :class="['doc-option-props', optionPropClass]">
|
2023-03-06 10:59:56 +00:00
|
|
|
{{ v }}
|
2023-09-20 17:52:07 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<span v-else :id="id + '.' + k"> {{ v }} </span>
|
2023-03-06 10:59:56 +00:00
|
|
|
</template>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<template v-if="data[0].data && data[0].data.length > 0">
|
|
|
|
<template v-for="childData in data" :key="childData">
|
|
|
|
<DocApiTable :id="childData.id" :data="childData.data" :label="childData.label" :description="childData.description" :relatedProp="childData.relatedProp" :level="3" />
|
2023-02-28 08:29:30 +00:00
|
|
|
</template>
|
2023-03-06 10:59:56 +00:00
|
|
|
</template>
|
2023-02-28 08:29:30 +00:00
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
id: {
|
|
|
|
type: String
|
|
|
|
},
|
|
|
|
label: {
|
|
|
|
type: String
|
|
|
|
},
|
|
|
|
data: {
|
|
|
|
type: Array,
|
|
|
|
default: () => []
|
|
|
|
},
|
|
|
|
description: {
|
|
|
|
type: String
|
|
|
|
},
|
|
|
|
relatedProp: {
|
|
|
|
type: String
|
2023-03-04 13:43:35 +00:00
|
|
|
},
|
|
|
|
level: {
|
|
|
|
type: Number,
|
|
|
|
default: 1
|
2023-02-28 08:29:30 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2023-03-04 13:43:35 +00:00
|
|
|
getType(value) {
|
2023-03-06 21:50:56 +00:00
|
|
|
if (this.label === 'Slots') {
|
|
|
|
return value?.split('|');
|
|
|
|
}
|
2023-03-04 13:43:35 +00:00
|
|
|
|
2023-03-06 21:50:56 +00:00
|
|
|
return value?.split('|').map((item) => {
|
|
|
|
return item.replace(/(\[|\]|<|>).*$/gm, '').trim();
|
2023-03-04 13:43:35 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
isLinkType(value) {
|
2023-03-06 10:59:56 +00:00
|
|
|
if (this.label === 'Slots') return false;
|
2023-03-12 11:06:00 +00:00
|
|
|
const validValues = ['confirmationoptions', 'toastmessageoptions'];
|
2023-03-06 10:59:56 +00:00
|
|
|
|
2023-03-12 11:06:00 +00:00
|
|
|
return value.toLowerCase().includes(this.id.split('.')[1]) || validValues.includes(value.toLowerCase());
|
2023-02-28 08:29:30 +00:00
|
|
|
},
|
2023-03-06 10:59:56 +00:00
|
|
|
setLinkPath(value, type) {
|
2023-02-28 08:29:30 +00:00
|
|
|
const currentRoute = this.$router.currentRoute.value.name;
|
2023-03-12 11:06:00 +00:00
|
|
|
let componentName = this.id.split('.')[1];
|
2023-03-06 10:59:56 +00:00
|
|
|
|
2023-03-12 11:06:00 +00:00
|
|
|
const validValues = ['menuitem', 'confirmationoptions'];
|
|
|
|
let definationType = type ? type : value.includes('Type') ? 'types' : value.includes('Event') ? 'events' : validValues.includes(value.toLowerCase()) ? 'options' : 'interfaces';
|
2023-03-07 22:49:05 +00:00
|
|
|
|
2023-03-12 11:06:00 +00:00
|
|
|
if (componentName.includes('toast')) {
|
|
|
|
componentName = 'toast';
|
|
|
|
}
|
2023-03-06 10:59:56 +00:00
|
|
|
|
2023-03-12 11:06:00 +00:00
|
|
|
return definationType === 'options' ? `/${currentRoute}/#api.${definationType}.${value}` : `/${currentRoute}/#api.${componentName}.${definationType}.${value}`;
|
2023-03-06 10:59:56 +00:00
|
|
|
},
|
2023-03-06 13:43:19 +00:00
|
|
|
relatedPropValue(value) {
|
|
|
|
return this.findRelatedProps(value).secondPart;
|
|
|
|
},
|
2023-03-06 10:59:56 +00:00
|
|
|
setRelatedPropPath(value) {
|
2023-03-06 13:43:19 +00:00
|
|
|
let { firstPart, secondPart } = this.findRelatedProps(value);
|
|
|
|
|
|
|
|
const docName = this.$route.name;
|
|
|
|
|
|
|
|
firstPart = firstPart.toLowerCase().replace(docName, '');
|
|
|
|
|
|
|
|
return this.setLinkPath(secondPart, firstPart);
|
|
|
|
},
|
|
|
|
findRelatedProps(value) {
|
2023-03-06 10:59:56 +00:00
|
|
|
let firstPart = '';
|
|
|
|
let secondPart = '';
|
|
|
|
|
|
|
|
if (value.includes('.')) {
|
|
|
|
const parts = value.split('.');
|
|
|
|
|
|
|
|
firstPart = parts[0].trim();
|
|
|
|
secondPart = parts[1].trim();
|
|
|
|
} else if (value.includes('[')) {
|
|
|
|
const start = value.indexOf("['") + 2;
|
|
|
|
const end = value.indexOf("']");
|
|
|
|
|
|
|
|
firstPart = value.slice(0, start - 2).trim();
|
|
|
|
secondPart = value.slice(start, end).trim();
|
|
|
|
}
|
|
|
|
|
2023-03-06 13:43:19 +00:00
|
|
|
return { firstPart, secondPart };
|
2023-02-28 08:29:30 +00:00
|
|
|
}
|
2023-03-04 13:43:35 +00:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
componentLevel() {
|
|
|
|
if (this.label === 'Interfaces' || this.label === 'Events') {
|
|
|
|
return 2;
|
|
|
|
} else if (this.level === 3) {
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.data[0].data ? 1 : 2;
|
2023-09-20 17:52:07 +00:00
|
|
|
},
|
|
|
|
optionLinkClass() {
|
|
|
|
return this.$appState.darkTheme ? 'text-primary-400' : 'text-primary-600';
|
|
|
|
},
|
|
|
|
optionPropClass() {
|
|
|
|
return this.$appState.darkTheme ? 'border-bluegray-800 bg-bluegray-800' : 'border-bluegray-100 bg-bluegray-50';
|
2023-03-04 13:43:35 +00:00
|
|
|
}
|
2023-02-28 08:29:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|