Skip to content

Commit ac45c98

Browse files
authored
fix(web-types): add support for VDataTable pattern slots (#15694)
1 parent 464529a commit ac45c98

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

Diff for: packages/api-generator/src/export.js

+37-1
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,46 @@ const createWebTypesApi = () => {
4949
const getDocUrl = (cmp, heading = null) => `https://www.vuetifyjs.com/api/${cmp}${heading ? `#${heading}` : ''}`
5050

5151
const createTag = component => {
52+
const createTagSlotPattern = slot => {
53+
const patternIndex = slot.name.indexOf('<name>')
54+
if (patternIndex < 0) { return {} }
55+
56+
let itemName
57+
const slotPrefix = slot.name.substring(0, patternIndex)
58+
if (slotPrefix === 'header.') {
59+
// VDataTable header.<name>
60+
itemName = 'header column'
61+
} else if (slotPrefix === 'item.') {
62+
// VDataTable item.<name>
63+
itemName = 'column'
64+
} else {
65+
// Fallback
66+
itemName = 'item'
67+
}
68+
69+
const itemsPath = itemName.replace(' ', '-') + 's'
70+
return {
71+
pattern: {
72+
items: itemsPath,
73+
template: [
74+
slotPrefix,
75+
'#item:' + itemName,
76+
],
77+
},
78+
[itemsPath]: {
79+
name: itemName[0].toUpperCase() + itemName.substring(1),
80+
pattern: {
81+
regex: '.+',
82+
},
83+
'doc-hide-pattern': true,
84+
},
85+
}
86+
}
87+
5288
const createTagSlot = slot => {
5389
return {
5490
name: slot.name,
55-
pattern: undefined,
91+
...createTagSlotPattern(slot),
5692
description: slot.description.en || '',
5793
'doc-url': getDocUrl(component.name, 'slots'),
5894
'vue-properties': slot.props && Object.keys(slot.props).map(key => createTypedEntity(key, slot.props[key])),

0 commit comments

Comments
 (0)