2024-09-13 14:23:04 +00:00
< template >
2024-09-20 11:57:01 +00:00
< DocSectionText v-bind ="$attrs" >
< p >
Some sections may not be visible due to the availability of the particular feature . Section names that start with the < i > pc < / i > prefix indicate that the element is a PrimeVue component not a DOM element . Visit the
< PrimeVueNuxtLink to = "/passthrough/#pcprefix" > pass - through < / PrimeVueNuxtLink > documentation for more information .
< / p >
< / DocSectionText >
2024-09-16 08:24:54 +00:00
< div ref = "container" class = "doc-ptviewerwrapper card" >
2024-09-16 10:18:28 +00:00
< div id = "doc-ptviewer" class = "doc-ptviewer" >
2024-09-13 14:23:04 +00:00
< slot / >
< / div >
2024-09-16 08:24:54 +00:00
< div class = "doc-ptoptions" >
2024-09-13 14:23:04 +00:00
< template v-if ="docs[0].data" >
< template v-for ="doc of docs" :key="doc.key" >
2024-09-16 08:24:54 +00:00
< div v-for ="item of handleData(doc.data)" :key="item.value" class="doc-ptoption" @mouseenter="enterSection(item, doc.key)" @mouseleave="leaveSection" >
2024-09-17 10:20:40 +00:00
< span class = "doc-ptoption-text" >
{ { item . label } }
2024-09-23 07:05:21 +00:00
{ { findComponentName ( item . label , doc ) } }
2024-09-17 10:20:40 +00:00
< / span >
2024-09-13 14:23:04 +00:00
< / div >
< / template >
< / template >
< / div >
< / div >
< / template >
< script >
import { addClass , find , removeClass } from '@primeuix/utils/dom' ;
2024-09-23 07:05:21 +00:00
import { defaultOptions } from '@primevue/core/config' ;
2024-09-13 14:23:04 +00:00
export default {
props : [ 'docs' ] ,
data ( ) {
return {
hoveredElements : [ ]
} ;
} ,
methods : {
2024-09-23 07:05:21 +00:00
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 ;
} ,
2024-09-13 14:23:04 +00:00
enterSection ( item , componentName ) {
2024-09-16 10:18:28 +00:00
let selector ,
cmpName = componentName ;
2024-09-13 14:23:04 +00:00
2024-09-16 10:18:28 +00:00
if ( componentName === 'ConfirmDialog' ) cmpName = 'Dialog' ;
2024-09-17 09:09:24 +00:00
else if ( componentName === 'ScrollTop' ) cmpName = 'Button' ;
2024-09-19 07:36:09 +00:00
else if ( componentName === 'Galleria' ) cmpName = 'GalleriaContent' ;
2024-09-16 10:18:28 +00:00
2024-09-19 12:26:58 +00:00
if ( componentName === 'InputMask' ) selector = ` [data-pc-extend="inputtext"][data-pc-section="root"] ` ;
else if ( item . label === 'root' ) selector = ` [data-pc-name=" ${ cmpName . toLowerCase ( ) } "] ` ;
2024-09-13 14:23:04 +00:00
else if ( item . label . startsWith ( 'pc' ) ) selector = ` [data-pc-name=" ${ item . label . toLowerCase ( ) } "] ` ;
else selector = ` [data-pc-section=" ${ item . label . toLowerCase ( ) } "] ` ;
this . hoveredElements = find ( this . $refs . container , selector ) ;
2024-09-16 10:18:28 +00:00
if ( this . hoveredElements . length === 0 ) this . hoveredElements = find ( document . querySelector ( 'body' ) , selector ) ; //TODO:
2024-09-16 08:24:54 +00:00
this . hoveredElements ? . forEach ( ( el ) => {
2024-09-17 10:20:40 +00:00
addClass ( el , '!ring !ring-blue-500 !z-10' ) ;
2024-09-13 14:23:04 +00:00
} ) ;
} ,
leaveSection ( ) {
this . hoveredElements . forEach ( ( el ) => {
2024-09-17 10:20:40 +00:00
removeClass ( el , '!ring !ring-blue-500 !z-10' ) ;
2024-09-13 14:23:04 +00:00
} ) ;
this . hoveredElements = [ ] ;
} ,
handleData ( doc ) {
2024-09-18 07:59:38 +00:00
return doc . filter ( ( item ) => item . label !== 'hooks' && item . label !== 'transition' && ! item . label . includes ( 'hidden' ) ) ;
2024-09-13 14:23:04 +00:00
}
}
} ;
< / script >