Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web-types): add support for VDataTable pattern slots #15694

Merged
merged 1 commit into from
Sep 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion packages/api-generator/src/export.js
Original file line number Diff line number Diff line change
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