123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- import { mergeProps as _mergeProps, resolveDirective as _resolveDirective, createVNode as _createVNode } from "vue";
- // Styles
- import "./VSnackbar.css";
- // Components
- import { VDefaultsProvider } from "../VDefaultsProvider/index.mjs";
- import { VOverlay } from "../VOverlay/index.mjs";
- import { makeVOverlayProps } from "../VOverlay/VOverlay.mjs"; // Composables
- import { forwardRefs } from "../../composables/forwardRefs.mjs";
- import { makeLocationProps, useLocation } from "../../composables/location.mjs";
- import { makePositionProps, usePosition } from "../../composables/position.mjs";
- import { useProxiedModel } from "../../composables/proxiedModel.mjs";
- import { makeRoundedProps, useRounded } from "../../composables/rounded.mjs";
- import { useScopeId } from "../../composables/scopeId.mjs";
- import { makeThemeProps, provideTheme } from "../../composables/theme.mjs";
- import { genOverlays, makeVariantProps, useVariant } from "../../composables/variant.mjs"; // Utilities
- import { mergeProps, onMounted, ref, watch } from 'vue';
- import { genericComponent, omit, propsFactory, useRender } from "../../util/index.mjs";
- export const makeVSnackbarProps = propsFactory({
- multiLine: Boolean,
- timeout: {
- type: [Number, String],
- default: 5000
- },
- vertical: Boolean,
- ...makeLocationProps({
- location: 'bottom'
- }),
- ...makePositionProps(),
- ...makeRoundedProps(),
- ...makeVariantProps(),
- ...makeThemeProps(),
- ...omit(makeVOverlayProps({
- transition: 'v-snackbar-transition'
- }), ['persistent', 'noClickAnimation', 'scrim', 'scrollStrategy'])
- }, 'VSnackbar');
- export const VSnackbar = genericComponent()({
- name: 'VSnackbar',
- props: makeVSnackbarProps(),
- emits: {
- 'update:modelValue': v => true
- },
- setup(props, _ref) {
- let {
- slots
- } = _ref;
- const isActive = useProxiedModel(props, 'modelValue');
- const {
- locationStyles
- } = useLocation(props);
- const {
- positionClasses
- } = usePosition(props);
- const {
- scopeId
- } = useScopeId();
- const {
- themeClasses
- } = provideTheme(props);
- const {
- colorClasses,
- colorStyles,
- variantClasses
- } = useVariant(props);
- const {
- roundedClasses
- } = useRounded(props);
- const overlay = ref();
- watch(isActive, startTimeout);
- watch(() => props.timeout, startTimeout);
- onMounted(() => {
- if (isActive.value) startTimeout();
- });
- let activeTimeout = -1;
- function startTimeout() {
- window.clearTimeout(activeTimeout);
- const timeout = Number(props.timeout);
- if (!isActive.value || timeout === -1) return;
- activeTimeout = window.setTimeout(() => {
- isActive.value = false;
- }, timeout);
- }
- function onPointerenter() {
- window.clearTimeout(activeTimeout);
- }
- useRender(() => {
- const [overlayProps] = VOverlay.filterProps(props);
- return _createVNode(VOverlay, _mergeProps({
- "ref": overlay,
- "class": ['v-snackbar', {
- 'v-snackbar--active': isActive.value,
- 'v-snackbar--multi-line': props.multiLine && !props.vertical,
- 'v-snackbar--vertical': props.vertical
- }, positionClasses.value, props.class],
- "style": props.style
- }, overlayProps, {
- "modelValue": isActive.value,
- "onUpdate:modelValue": $event => isActive.value = $event,
- "contentProps": mergeProps({
- class: ['v-snackbar__wrapper', themeClasses.value, colorClasses.value, roundedClasses.value, variantClasses.value],
- style: [locationStyles.value, colorStyles.value],
- onPointerenter,
- onPointerleave: startTimeout
- }, overlayProps.contentProps),
- "persistent": true,
- "noClickAnimation": true,
- "scrim": false,
- "scrollStrategy": "none",
- "_disableGlobalStack": true
- }, scopeId), {
- default: () => [genOverlays(false, 'v-snackbar'), slots.default && _createVNode("div", {
- "class": "v-snackbar__content",
- "role": "status",
- "aria-live": "polite"
- }, [slots.default()]), slots.actions && _createVNode(VDefaultsProvider, {
- "defaults": {
- VBtn: {
- variant: 'text',
- ripple: false
- }
- }
- }, {
- default: () => [_createVNode("div", {
- "class": "v-snackbar__actions"
- }, [slots.actions()])]
- })],
- activator: slots.activator
- });
- });
- return forwardRefs({}, overlay);
- }
- });
- //# sourceMappingURL=VSnackbar.mjs.map
|