140 lines
4.8 KiB
JavaScript
140 lines
4.8 KiB
JavaScript
|
import { resolveDirective as _resolveDirective, createVNode as _createVNode } from "vue";
|
||
|
// Styles
|
||
|
import "./VBanner.css";
|
||
|
|
||
|
// Components
|
||
|
import { VBannerActions } from "./VBannerActions.mjs";
|
||
|
import { VBannerText } from "./VBannerText.mjs";
|
||
|
import { VAvatar } from "../VAvatar/index.mjs";
|
||
|
import { VDefaultsProvider } from "../VDefaultsProvider/index.mjs"; // Composables
|
||
|
import { makeBorderProps, useBorder } from "../../composables/border.mjs";
|
||
|
import { useBackgroundColor } from "../../composables/color.mjs";
|
||
|
import { makeComponentProps } from "../../composables/component.mjs";
|
||
|
import { provideDefaults } from "../../composables/defaults.mjs";
|
||
|
import { makeDensityProps, useDensity } from "../../composables/density.mjs";
|
||
|
import { makeDimensionProps, useDimension } from "../../composables/dimensions.mjs";
|
||
|
import { makeDisplayProps, useDisplay } from "../../composables/display.mjs";
|
||
|
import { makeElevationProps, useElevation } from "../../composables/elevation.mjs";
|
||
|
import { IconValue } from "../../composables/icons.mjs";
|
||
|
import { makeLocationProps, useLocation } from "../../composables/location.mjs";
|
||
|
import { makePositionProps, usePosition } from "../../composables/position.mjs";
|
||
|
import { makeRoundedProps, useRounded } from "../../composables/rounded.mjs";
|
||
|
import { makeTagProps } from "../../composables/tag.mjs";
|
||
|
import { makeThemeProps, provideTheme } from "../../composables/theme.mjs"; // Utilities
|
||
|
import { toRef } from 'vue';
|
||
|
import { genericComponent, propsFactory, useRender } from "../../util/index.mjs"; // Types
|
||
|
export const makeVBannerProps = propsFactory({
|
||
|
avatar: String,
|
||
|
bgColor: String,
|
||
|
color: String,
|
||
|
icon: IconValue,
|
||
|
lines: String,
|
||
|
stacked: Boolean,
|
||
|
sticky: Boolean,
|
||
|
text: String,
|
||
|
...makeBorderProps(),
|
||
|
...makeComponentProps(),
|
||
|
...makeDensityProps(),
|
||
|
...makeDimensionProps(),
|
||
|
...makeDisplayProps(),
|
||
|
...makeElevationProps(),
|
||
|
...makeLocationProps(),
|
||
|
...makePositionProps(),
|
||
|
...makeRoundedProps(),
|
||
|
...makeTagProps(),
|
||
|
...makeThemeProps()
|
||
|
}, 'VBanner');
|
||
|
export const VBanner = genericComponent()({
|
||
|
name: 'VBanner',
|
||
|
props: makeVBannerProps(),
|
||
|
setup(props, _ref) {
|
||
|
let {
|
||
|
slots
|
||
|
} = _ref;
|
||
|
const {
|
||
|
backgroundColorClasses,
|
||
|
backgroundColorStyles
|
||
|
} = useBackgroundColor(props, 'bgColor');
|
||
|
const {
|
||
|
borderClasses
|
||
|
} = useBorder(props);
|
||
|
const {
|
||
|
densityClasses
|
||
|
} = useDensity(props);
|
||
|
const {
|
||
|
displayClasses,
|
||
|
mobile
|
||
|
} = useDisplay(props);
|
||
|
const {
|
||
|
dimensionStyles
|
||
|
} = useDimension(props);
|
||
|
const {
|
||
|
elevationClasses
|
||
|
} = useElevation(props);
|
||
|
const {
|
||
|
locationStyles
|
||
|
} = useLocation(props);
|
||
|
const {
|
||
|
positionClasses
|
||
|
} = usePosition(props);
|
||
|
const {
|
||
|
roundedClasses
|
||
|
} = useRounded(props);
|
||
|
const {
|
||
|
themeClasses
|
||
|
} = provideTheme(props);
|
||
|
const color = toRef(props, 'color');
|
||
|
const density = toRef(props, 'density');
|
||
|
provideDefaults({
|
||
|
VBannerActions: {
|
||
|
color,
|
||
|
density
|
||
|
}
|
||
|
});
|
||
|
useRender(() => {
|
||
|
const hasText = !!(props.text || slots.text);
|
||
|
const hasPrependMedia = !!(props.avatar || props.icon);
|
||
|
const hasPrepend = !!(hasPrependMedia || slots.prepend);
|
||
|
return _createVNode(props.tag, {
|
||
|
"class": ['v-banner', {
|
||
|
'v-banner--stacked': props.stacked || mobile.value,
|
||
|
'v-banner--sticky': props.sticky,
|
||
|
[`v-banner--${props.lines}-line`]: !!props.lines
|
||
|
}, themeClasses.value, backgroundColorClasses.value, borderClasses.value, densityClasses.value, displayClasses.value, elevationClasses.value, positionClasses.value, roundedClasses.value, props.class],
|
||
|
"style": [backgroundColorStyles.value, dimensionStyles.value, locationStyles.value, props.style],
|
||
|
"role": "banner"
|
||
|
}, {
|
||
|
default: () => [hasPrepend && _createVNode("div", {
|
||
|
"key": "prepend",
|
||
|
"class": "v-banner__prepend"
|
||
|
}, [!slots.prepend ? _createVNode(VAvatar, {
|
||
|
"key": "prepend-avatar",
|
||
|
"color": color.value,
|
||
|
"density": density.value,
|
||
|
"icon": props.icon,
|
||
|
"image": props.avatar
|
||
|
}, null) : _createVNode(VDefaultsProvider, {
|
||
|
"key": "prepend-defaults",
|
||
|
"disabled": !hasPrependMedia,
|
||
|
"defaults": {
|
||
|
VAvatar: {
|
||
|
color: color.value,
|
||
|
density: density.value,
|
||
|
icon: props.icon,
|
||
|
image: props.avatar
|
||
|
}
|
||
|
}
|
||
|
}, slots.prepend)]), _createVNode("div", {
|
||
|
"class": "v-banner__content"
|
||
|
}, [hasText && _createVNode(VBannerText, {
|
||
|
"key": "text"
|
||
|
}, {
|
||
|
default: () => [slots.text?.() ?? props.text]
|
||
|
}), slots.default?.()]), slots.actions && _createVNode(VBannerActions, {
|
||
|
"key": "actions"
|
||
|
}, slots.actions)]
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
//# sourceMappingURL=VBanner.mjs.map
|