slide-popup-vue3 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,73 @@
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".fade-enter-active,.fade-leave-active{transition:opacity .3s ease-in}.fade-enter-from,.fade-leave-to{opacity:0}.slide-top-enter-active,.slide-top-leave-active{transition:all .3s ease}.slide-top-enter-from,.slide-top-leave-to{transform:translateY(-100%)}.slide-bottom-enter-active,.slide-bottom-leave-active{transition:all .3s ease}.slide-bottom-enter-from,.slide-bottom-leave-to{transform:translateY(100%)}.slide-right-enter-active,.slide-right-leave-active{transition:all .3s ease}.slide-right-enter-from,.slide-right-leave-to{transform:translate(100%)}.slide-left-enter-active,.slide-left-leave-active{transition:all .3s ease}.slide-left-enter-from,.slide-left-leave-to{transform:translate(-100%)}.popup-mask{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000004d;z-index:1000}.popup-content{position:fixed;z-index:1001;background:#fff}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
+ import { computed as g, openBlock as o, createElementBlock as l, createVNode as i, Transition as p, withCtx as u, normalizeClass as y, createCommentVNode as c, normalizeStyle as C, renderSlot as V } from "vue";
3
+ const a = {
4
+ __name: "SlidePopup",
5
+ props: {
6
+ modelValue: {
7
+ type: Boolean,
8
+ default: !1
9
+ },
10
+ position: {
11
+ type: String,
12
+ default: "bottom",
13
+ validator: (t) => ["top", "bottom", "left", "right"].includes(t)
14
+ },
15
+ closeOnClickMask: {
16
+ type: Boolean,
17
+ default: !0
18
+ }
19
+ },
20
+ emits: ["update:modelValue", "close"],
21
+ setup(t, { emit: m }) {
22
+ const s = t, n = m, d = g(() => {
23
+ const e = {
24
+ top: { width: "100%", top: 0, left: 0 },
25
+ bottom: { width: "100%", bottom: 0, left: 0 },
26
+ left: { height: "100%", left: 0, bottom: 0 },
27
+ right: { height: "100%", right: 0, bottom: 0 }
28
+ };
29
+ return e[s.position] || e.bottom;
30
+ }), r = (e) => {
31
+ const h = e.target.closest('[data-popup-mask="true"]');
32
+ s.closeOnClickMask && h && (console.log("点击了遮罩层"), f());
33
+ }, f = () => {
34
+ n("update:modelValue", !1), n("close");
35
+ };
36
+ return (e, k) => (o(), l("div", {
37
+ class: "popup",
38
+ onClickCapture: r
39
+ }, [
40
+ i(p, { name: "fade" }, {
41
+ default: u(() => [
42
+ t.modelValue ? (o(), l("div", {
43
+ key: 0,
44
+ class: y(["popup-mask", { "popup-mask_active": t.modelValue }]),
45
+ "data-popup-mask": "true"
46
+ }, null, 2)) : c("", !0)
47
+ ]),
48
+ _: 1
49
+ }),
50
+ i(p, {
51
+ name: "slide-" + t.position
52
+ }, {
53
+ default: u(() => [
54
+ t.modelValue ? (o(), l("div", {
55
+ key: 0,
56
+ class: "popup-content",
57
+ style: C(d.value)
58
+ }, [
59
+ V(e.$slots, "default")
60
+ ], 4)) : c("", !0)
61
+ ]),
62
+ _: 3
63
+ }, 8, ["name"])
64
+ ], 32));
65
+ }
66
+ };
67
+ a.install = function(t) {
68
+ t.component(a.name, a);
69
+ };
70
+ export {
71
+ a as SlidePopup,
72
+ a as default
73
+ };
@@ -0,0 +1,2 @@
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".fade-enter-active,.fade-leave-active{transition:opacity .3s ease-in}.fade-enter-from,.fade-leave-to{opacity:0}.slide-top-enter-active,.slide-top-leave-active{transition:all .3s ease}.slide-top-enter-from,.slide-top-leave-to{transform:translateY(-100%)}.slide-bottom-enter-active,.slide-bottom-leave-active{transition:all .3s ease}.slide-bottom-enter-from,.slide-bottom-leave-to{transform:translateY(100%)}.slide-right-enter-active,.slide-right-leave-active{transition:all .3s ease}.slide-right-enter-from,.slide-right-leave-to{transform:translate(100%)}.slide-left-enter-active,.slide-left-leave-active{transition:all .3s ease}.slide-left-enter-from,.slide-left-leave-to{transform:translate(-100%)}.popup-mask{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000004d;z-index:1000}.popup-content{position:fixed;z-index:1001;background:#fff}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
+ (function(o,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(o=typeof globalThis<"u"?globalThis:o||self,e(o.SlidePopup={},o.Vue))})(this,function(o,e){"use strict";const n={__name:"SlidePopup",props:{modelValue:{type:Boolean,default:!1},position:{type:String,default:"bottom",validator:t=>["top","bottom","left","right"].includes(t)},closeOnClickMask:{type:Boolean,default:!0}},emits:["update:modelValue","close"],setup(t,{emit:s}){const a=t,i=s,c=e.computed(()=>{const l={top:{width:"100%",top:0,left:0},bottom:{width:"100%",bottom:0,left:0},left:{height:"100%",left:0,bottom:0},right:{height:"100%",right:0,bottom:0}};return l[a.position]||l.bottom}),d=l=>{const u=l.target.closest('[data-popup-mask="true"]');a.closeOnClickMask&&u&&(console.log("点击了遮罩层"),p())},p=()=>{i("update:modelValue",!1),i("close")};return(l,m)=>(e.openBlock(),e.createElementBlock("div",{class:"popup",onClickCapture:d},[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[t.modelValue?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["popup-mask",{"popup-mask_active":t.modelValue}]),"data-popup-mask":"true"},null,2)):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.Transition,{name:"slide-"+t.position},{default:e.withCtx(()=>[t.modelValue?(e.openBlock(),e.createElementBlock("div",{key:0,class:"popup-content",style:e.normalizeStyle(c.value)},[e.renderSlot(l.$slots,"default")],4)):e.createCommentVNode("",!0)]),_:3},8,["name"])],32))}};n.install=function(t){t.component(n.name,n)},o.SlidePopup=n,o.default=n,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "slide-popup-vue3",
3
+ "version": "1.0.0",
4
+ "description": "一个Vue3的抽屉式弹出层组件",
5
+ "license": "ISC",
6
+ "author": "sun-weitao",
7
+ "type": "module",
8
+ "main": "dist/slide-popup.umd.js",
9
+ "module": "dist/slide-popup.es.js",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/slide-popup.es.js",
13
+ "require": "./dist/slide-popup.umd.js"
14
+ }
15
+ },
16
+ "unpkg": "dist/slide-popup.umd.js",
17
+ "jsdelivr": "dist/slide-popup.umd.js",
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "keywords": [
22
+ "vue",
23
+ "vue3",
24
+ "popup",
25
+ "drawer",
26
+ "slide",
27
+ "modal"
28
+ ],
29
+ "peerDependencies": {
30
+ "vue": ">=3.0.0"
31
+ },
32
+ "peerDependenciesMeta": {
33
+ "vue": {
34
+ "optional": true
35
+ }
36
+ },
37
+ "scripts": {
38
+ "build": "vite build",
39
+ "prepublishOnly": "npm run build",
40
+ "test": "echo \"Error: no test specified\" && exit 1"
41
+ },
42
+ "devDependencies": {
43
+ "@vitejs/plugin-vue": "^5.0.0",
44
+ "sass": "^1.103.1",
45
+ "vite": "^5.0.0",
46
+ "vite-plugin-css-injected-by-js": "^5.0.2",
47
+ "vue": "^3.4.0"
48
+ }
49
+ }