4
0
mirror of https://github.com/AzuraCast/AzuraCast.git synced 2024-06-14 05:06:37 +00:00
AzuraCast/frontend/vue/components/Form/BFormFieldset.vue
2023-01-06 19:55:08 -06:00

50 lines
1.1 KiB
Vue

<script>
/* TODO Options API */
export default {
name: 'BFormFieldset',
methods: {
getSlot(name, scope = {}) {
let slot = this.$slots[name]
return typeof slot === 'function' ? slot(scope) : slot
}
},
render(h) {
const legendSlot = this.getSlot('label');
const descriptionSlot = this.getSlot('description');
let header = h();
if (legendSlot) {
const description = descriptionSlot
? h('p', {}, [descriptionSlot])
: h();
const legend = h('legend', {}, [legendSlot]);
header = h(
'div',
{
staticClass: 'fieldset-legend'
},
[
legend,
description
]
);
}
return h(
'fieldset',
{
staticClass: 'form-group'
},
[
header,
this.getSlot('default') || h()
]
)
}
}
</script>