vuetify
Version:
Vue Material Component Framework
89 lines • 3.58 kB
JavaScript
import { createElementVNode as _createElementVNode, createVNode as _createVNode, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, withDirectives as _withDirectives } from "vue";
// Components
import { VExpansionPanelSymbol } from "./shared.js";
import { VDefaultsProvider } from "../VDefaultsProvider/index.js";
import { VIcon } from "../VIcon/index.js"; // Composables
import { useBackgroundColor } from "../../composables/color.js";
import { makeComponentProps } from "../../composables/component.js";
import { makeDimensionProps, useDimension } from "../../composables/dimensions.js";
import { IconValue } from "../../composables/icons.js"; // Directives
import vRipple from "../../directives/ripple/index.js"; // Utilities
import { computed, inject, toRef } from 'vue';
import { genericComponent, propsFactory, useRender } from "../../util/index.js"; // Types
export const makeVExpansionPanelTitleProps = propsFactory({
color: String,
expandIcon: {
type: IconValue,
default: '$expand'
},
collapseIcon: {
type: IconValue,
default: '$collapse'
},
hideActions: Boolean,
focusable: Boolean,
static: Boolean,
ripple: {
type: [Boolean, Object],
default: false
},
readonly: Boolean,
...makeComponentProps(),
...makeDimensionProps()
}, 'VExpansionPanelTitle');
export const VExpansionPanelTitle = genericComponent()({
name: 'VExpansionPanelTitle',
directives: {
vRipple
},
props: makeVExpansionPanelTitleProps(),
setup(props, _ref) {
let {
slots
} = _ref;
const expansionPanel = inject(VExpansionPanelSymbol);
if (!expansionPanel) throw new Error('[Vuetify] v-expansion-panel-title needs to be placed inside v-expansion-panel');
const {
backgroundColorClasses,
backgroundColorStyles
} = useBackgroundColor(() => props.color);
const {
dimensionStyles
} = useDimension(props);
const slotProps = computed(() => ({
collapseIcon: props.collapseIcon,
disabled: expansionPanel.disabled.value,
expanded: expansionPanel.isSelected.value,
expandIcon: props.expandIcon,
readonly: props.readonly
}));
const icon = toRef(() => expansionPanel.isSelected.value ? props.collapseIcon : props.expandIcon);
useRender(() => _withDirectives(_createElementVNode("button", {
"class": _normalizeClass(['v-expansion-panel-title', {
'v-expansion-panel-title--active': expansionPanel.isSelected.value,
'v-expansion-panel-title--focusable': props.focusable,
'v-expansion-panel-title--static': props.static
}, backgroundColorClasses.value, props.class]),
"style": _normalizeStyle([backgroundColorStyles.value, dimensionStyles.value, props.style]),
"type": "button",
"tabindex": expansionPanel.disabled.value ? -1 : undefined,
"disabled": expansionPanel.disabled.value,
"aria-expanded": expansionPanel.isSelected.value,
"onClick": !props.readonly ? expansionPanel.toggle : undefined
}, [_createElementVNode("span", {
"class": "v-expansion-panel-title__overlay"
}, null), slots.default?.(slotProps.value), !props.hideActions && _createVNode(VDefaultsProvider, {
"defaults": {
VIcon: {
icon: icon.value
}
}
}, {
default: () => [_createElementVNode("span", {
"class": "v-expansion-panel-title__icon"
}, [slots.actions?.(slotProps.value) ?? _createVNode(VIcon, null, null)])]
})]), [[vRipple, props.ripple]]));
return {};
}
});
//# sourceMappingURL=VExpansionPanelTitle.js.map