PTViewer improvements

pull/6462/head
tugcekucukoglu 2024-09-23 10:05:21 +03:00
parent d4c21053ec
commit db654f9502
1 changed files with 34 additions and 1 deletions

View File

@ -15,7 +15,7 @@
<div v-for="item of handleData(doc.data)" :key="item.value" class="doc-ptoption" @mouseenter="enterSection(item, doc.key)" @mouseleave="leaveSection"> <div v-for="item of handleData(doc.data)" :key="item.value" class="doc-ptoption" @mouseenter="enterSection(item, doc.key)" @mouseleave="leaveSection">
<span class="doc-ptoption-text"> <span class="doc-ptoption-text">
{{ item.label }} {{ item.label }}
<template v-if="docs.length > 1">| {{ doc.key }}</template> {{ findComponentName(item.label, doc) }}
</span> </span>
</div> </div>
</template> </template>
@ -26,6 +26,7 @@
<script> <script>
import { addClass, find, removeClass } from '@primeuix/utils/dom'; import { addClass, find, removeClass } from '@primeuix/utils/dom';
import { defaultOptions } from '@primevue/core/config';
export default { export default {
props: ['docs'], props: ['docs'],
@ -35,6 +36,38 @@ export default {
}; };
}, },
methods: { methods: {
findComponentName(label, doc) {
let text = '';
if (this.docs.length > 1) {
text += `| ${doc.key}`;
}
if (label.includes('pc')) {
let reservedNames = ['Decrement', 'File', 'Increment', 'JumpToPage', 'Maximize', 'Node', 'Option', 'Prev', 'Remove', 'RowPerPage', 'Source', 'Target', 'MoveAllTo', 'MoveAll', 'MoveTop', 'MoveTo']; // the order of this list is important!
let whiteList = [...reservedNames, ...Object.keys(defaultOptions.locale), ...Object.keys(defaultOptions.locale.aria)];
let elemName = label.replace('pc', '');
if (elemName.includes('FilterContainer')) elemName = elemName.replace('FilterContainer', 'IconField');
else if (elemName.includes('FilterIconContainer')) elemName = elemName.replace('FilterIconContainer', 'InputIcon');
else if (elemName.includes('Filter')) elemName = elemName.replace('Filter', 'InputText');
if (elemName.includes('Action')) elemName = elemName.replace('Action', 'Button');
if (elemName.includes('Dropdown')) elemName = elemName.replace('Dropdown', 'Select');
for (const word of whiteList) {
if (elemName.toLowerCase().includes(word.toLowerCase())) {
const regex = new RegExp(word, 'gi');
elemName = elemName.replace(regex, '');
}
}
text += ` | ${elemName}`;
}
return text;
},
enterSection(item, componentName) { enterSection(item, componentName) {
let selector, let selector,
cmpName = componentName; cmpName = componentName;