reka-ui
Version:
Vue port for Radix UI Primitives.
146 lines (143 loc) • 4.74 kB
JavaScript
const require_rolldown_runtime = require('../rolldown-runtime.cjs');
const require_shared_useForwardExpose = require('../shared/useForwardExpose.cjs');
const require_Presence_Presence = require('../Presence/Presence.cjs');
const require_Toast_ToastRootImpl = require('./ToastRootImpl.cjs');
const vue = require_rolldown_runtime.__toESM(require("vue"));
const __vueuse_core = require_rolldown_runtime.__toESM(require("@vueuse/core"));
//#region src/Toast/ToastRoot.vue?vue&type=script&setup=true&lang.ts
var ToastRoot_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
__name: "ToastRoot",
props: {
defaultOpen: {
type: Boolean,
required: false,
default: true
},
forceMount: {
type: Boolean,
required: false
},
type: {
type: String,
required: false,
default: "foreground"
},
open: {
type: Boolean,
required: false,
default: void 0
},
duration: {
type: Number,
required: false
},
asChild: {
type: Boolean,
required: false
},
as: {
type: null,
required: false,
default: "li"
}
},
emits: [
"escapeKeyDown",
"pause",
"resume",
"swipeStart",
"swipeMove",
"swipeCancel",
"swipeEnd",
"update:open"
],
setup(__props, { emit: __emit }) {
const props = __props;
const emits = __emit;
const { forwardRef } = require_shared_useForwardExpose.useForwardExpose();
const open = (0, __vueuse_core.useVModel)(props, "open", emits, {
defaultValue: props.defaultOpen,
passive: props.open === void 0
});
return (_ctx, _cache) => {
return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(require_Presence_Presence.Presence_default), { present: _ctx.forceMount || (0, vue.unref)(open) }, {
default: (0, vue.withCtx)(() => [(0, vue.createVNode)(require_Toast_ToastRootImpl.ToastRootImpl_default, (0, vue.mergeProps)({
ref: (0, vue.unref)(forwardRef),
open: (0, vue.unref)(open),
type: _ctx.type,
as: _ctx.as,
"as-child": _ctx.asChild,
duration: _ctx.duration
}, _ctx.$attrs, {
onClose: _cache[0] || (_cache[0] = ($event) => open.value = false),
onPause: _cache[1] || (_cache[1] = ($event) => emits("pause")),
onResume: _cache[2] || (_cache[2] = ($event) => emits("resume")),
onEscapeKeyDown: _cache[3] || (_cache[3] = ($event) => emits("escapeKeyDown", $event)),
onSwipeStart: _cache[4] || (_cache[4] = (event) => {
emits("swipeStart", event);
if (!event.defaultPrevented) event.currentTarget.setAttribute("data-swipe", "start");
}),
onSwipeMove: _cache[5] || (_cache[5] = (event) => {
emits("swipeMove", event);
if (!event.defaultPrevented) {
const { x, y } = event.detail.delta;
const target = event.currentTarget;
target.setAttribute("data-swipe", "move");
target.style.setProperty("--reka-toast-swipe-move-x", `${x}px`);
target.style.setProperty("--reka-toast-swipe-move-y", `${y}px`);
}
}),
onSwipeCancel: _cache[6] || (_cache[6] = (event) => {
emits("swipeCancel", event);
if (!event.defaultPrevented) {
const target = event.currentTarget;
target.setAttribute("data-swipe", "cancel");
target.style.removeProperty("--reka-toast-swipe-move-x");
target.style.removeProperty("--reka-toast-swipe-move-y");
target.style.removeProperty("--reka-toast-swipe-end-x");
target.style.removeProperty("--reka-toast-swipe-end-y");
}
}),
onSwipeEnd: _cache[7] || (_cache[7] = (event) => {
emits("swipeEnd", event);
if (!event.defaultPrevented) {
const { x, y } = event.detail.delta;
const target = event.currentTarget;
target.setAttribute("data-swipe", "end");
target.style.removeProperty("--reka-toast-swipe-move-x");
target.style.removeProperty("--reka-toast-swipe-move-y");
target.style.setProperty("--reka-toast-swipe-end-x", `${x}px`);
target.style.setProperty("--reka-toast-swipe-end-y", `${y}px`);
open.value = false;
}
})
}), {
default: (0, vue.withCtx)(({ remaining, duration: _duration }) => [(0, vue.renderSlot)(_ctx.$slots, "default", {
remaining,
duration: _duration,
open: (0, vue.unref)(open)
})]),
_: 3
}, 16, [
"open",
"type",
"as",
"as-child",
"duration"
])]),
_: 3
}, 8, ["present"]);
};
}
});
//#endregion
//#region src/Toast/ToastRoot.vue
var ToastRoot_default = ToastRoot_vue_vue_type_script_setup_true_lang_default;
//#endregion
Object.defineProperty(exports, 'ToastRoot_default', {
enumerable: true,
get: function () {
return ToastRoot_default;
}
});
//# sourceMappingURL=ToastRoot.cjs.map