Skip to content

Commit

Permalink
fix(web-types): add support for VDataTable pattern slots (#15694)
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrtomiak committed Sep 6, 2022
1 parent 464529a commit ac45c98
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion packages/api-generator/src/export.js
Expand Up @@ -49,10 +49,46 @@ const createWebTypesApi = () => {
const getDocUrl = (cmp, heading = null) => `https://www.vuetifyjs.com/api/${cmp}${heading ? `#${heading}` : ''}`

const createTag = component => {
const createTagSlotPattern = slot => {
const patternIndex = slot.name.indexOf('<name>')
if (patternIndex < 0) { return {} }

let itemName
const slotPrefix = slot.name.substring(0, patternIndex)
if (slotPrefix === 'header.') {
// VDataTable header.<name>
itemName = 'header column'
} else if (slotPrefix === 'item.') {
// VDataTable item.<name>
itemName = 'column'
} else {
// Fallback
itemName = 'item'
}

const itemsPath = itemName.replace(' ', '-') + 's'
return {
pattern: {
items: itemsPath,
template: [
slotPrefix,
'#item:' + itemName,
],
},
[itemsPath]: {
name: itemName[0].toUpperCase() + itemName.substring(1),
pattern: {
regex: '.+',
},
'doc-hide-pattern': true,
},
}
}

const createTagSlot = slot => {
return {
name: slot.name,
pattern: undefined,
...createTagSlotPattern(slot),
description: slot.description.en || '',
'doc-url': getDocUrl(component.name, 'slots'),
'vue-properties': slot.props && Object.keys(slot.props).map(key => createTypedEntity(key, slot.props[key])),
Expand Down

0 comments on commit ac45c98

Please sign in to comment.