vue3-layer 1.0.18 → 2.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.
- package/README.md +63 -24
- package/dist/components/S3Layer.vue.d.ts +57 -0
- package/dist/components/S3Layer.vue.d.ts.map +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/layui.d.ts +11 -0
- package/dist/layui.d.ts.map +1 -0
- package/dist/types.d.ts +90 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/vue3-layer.css +2 -0
- package/dist/vue3-layer.js +186 -0
- package/dist/vue3-layer.umd.cjs +1 -0
- package/package.json +54 -33
- package/dist/demo.html +0 -10
- package/dist/img/icon-ext.ba81b24c.png +0 -0
- package/dist/img/icon.551539f8.png +0 -0
- package/dist/img/loading-0.a72011cc.gif +0 -0
- package/dist/s3Layer.common.js +0 -15232
- package/dist/s3Layer.css +0 -1
- package/dist/s3Layer.umd.js +0 -15242
- package/dist/s3Layer.umd.min.js +0 -29
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -17
- package/src/App.vue +0 -38
- package/src/assets/logo.png +0 -0
- package/src/components/index.js +0 -2
- package/src/components/s3-layer.vue +0 -110
- package/src/main.js +0 -4
- package/src/vue3-layer.d.ts +0 -2
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { Teleport as e, computed as t, createBlock as n, createCommentVNode as r, defineComponent as i, nextTick as a, onBeforeUnmount as o, onMounted as s, openBlock as c, ref as l, renderSlot as u, shallowRef as d, useAttrs as f, useSlots as p, watch as m } from "vue";
|
|
2
|
+
import "layui";
|
|
3
|
+
//#region src/layui.ts
|
|
4
|
+
function h() {
|
|
5
|
+
let e = globalThis;
|
|
6
|
+
if (e.layui?.layer) return e.layui;
|
|
7
|
+
if (e.layer) return { layer: e.layer };
|
|
8
|
+
}
|
|
9
|
+
function g() {
|
|
10
|
+
let e = h();
|
|
11
|
+
if (!e?.layer) throw Error("layui layer is not available. Make sure this code runs in a browser environment.");
|
|
12
|
+
return e;
|
|
13
|
+
}
|
|
14
|
+
function _() {
|
|
15
|
+
return g();
|
|
16
|
+
}
|
|
17
|
+
function v() {
|
|
18
|
+
return g().layer;
|
|
19
|
+
}
|
|
20
|
+
var y = new Proxy({}, {
|
|
21
|
+
get(e, t) {
|
|
22
|
+
return g()[t];
|
|
23
|
+
},
|
|
24
|
+
set(e, t, n) {
|
|
25
|
+
return g()[t] = n, !0;
|
|
26
|
+
}
|
|
27
|
+
}), b = new Proxy({}, {
|
|
28
|
+
get(e, t) {
|
|
29
|
+
let n = v(), r = n[t];
|
|
30
|
+
return typeof r == "function" ? r.bind(n) : r;
|
|
31
|
+
},
|
|
32
|
+
set(e, t, n) {
|
|
33
|
+
return v()[t] = n, !0;
|
|
34
|
+
}
|
|
35
|
+
}), x = /* @__PURE__ */ i({
|
|
36
|
+
name: "S3Layer",
|
|
37
|
+
inheritAttrs: !1,
|
|
38
|
+
__name: "S3Layer",
|
|
39
|
+
props: {
|
|
40
|
+
modelValue: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: !1
|
|
43
|
+
},
|
|
44
|
+
options: { default: () => ({}) }
|
|
45
|
+
},
|
|
46
|
+
emits: [
|
|
47
|
+
"update:modelValue",
|
|
48
|
+
"success",
|
|
49
|
+
"yes",
|
|
50
|
+
"cancel",
|
|
51
|
+
"beforeEnd",
|
|
52
|
+
"end",
|
|
53
|
+
"moveEnd",
|
|
54
|
+
"resizing",
|
|
55
|
+
"full",
|
|
56
|
+
"min",
|
|
57
|
+
"restore"
|
|
58
|
+
],
|
|
59
|
+
setup(i, { expose: h, emit: g }) {
|
|
60
|
+
let _ = i, y = g, b = f(), x = p(), S = l(), C = d(), w = d(), T = l(!1), E = t(() => !!x.default), D = 0;
|
|
61
|
+
function O(e) {
|
|
62
|
+
let t = e.slice(2);
|
|
63
|
+
return t.charAt(0).toLowerCase() + t.slice(1);
|
|
64
|
+
}
|
|
65
|
+
function k() {
|
|
66
|
+
let e = {};
|
|
67
|
+
return Object.entries(b).forEach(([t, n]) => {
|
|
68
|
+
if (!(t === "class" || t === "style")) {
|
|
69
|
+
if (/^on[A-Z]/.test(t) && typeof n == "function") {
|
|
70
|
+
e[O(t)] = n;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
e[t] = n;
|
|
74
|
+
}
|
|
75
|
+
}), e;
|
|
76
|
+
}
|
|
77
|
+
function A(e) {
|
|
78
|
+
let t = b.class, n = b.style;
|
|
79
|
+
t && (typeof e.addClass == "function" ? e.addClass(String(t)) : e.classList.add(...String(t).split(/\s+/).filter(Boolean))), n && (typeof e.css == "function" ? e.css(n) : typeof n == "string" ? e.setAttribute("style", `${e.getAttribute("style") || ""};${n}`) : typeof n == "object" && Object.assign(e.style, n));
|
|
80
|
+
}
|
|
81
|
+
function j() {
|
|
82
|
+
S.value = void 0, C.value = void 0, w.value = void 0, T.value = !1;
|
|
83
|
+
}
|
|
84
|
+
function M() {
|
|
85
|
+
S.value !== void 0 && v().close(S.value);
|
|
86
|
+
}
|
|
87
|
+
function N(e, t, n) {
|
|
88
|
+
if (T.value) return;
|
|
89
|
+
y("beforeEnd", t, n);
|
|
90
|
+
let r = e.beforeEnd?.(t, n);
|
|
91
|
+
return r && typeof r.then == "function" ? (r.then((e) => {
|
|
92
|
+
e === !1 || S.value !== t || (T.value = !0, v().close(t));
|
|
93
|
+
}).catch(() => void 0), !1) : r;
|
|
94
|
+
}
|
|
95
|
+
async function P() {
|
|
96
|
+
if (S.value !== void 0 || typeof window > "u") return;
|
|
97
|
+
let e = v(), t = E.value ? `s3-layer-teleport-${Date.now()}-${D++}` : void 0, n = k(), r = _.options || {}, i = {
|
|
98
|
+
title: "信息",
|
|
99
|
+
...n,
|
|
100
|
+
...r
|
|
101
|
+
};
|
|
102
|
+
t && (i.type = 1, i.content = `<div id="${t}" class="s3-layer__teleport"></div>`);
|
|
103
|
+
let { success: o, yes: s, cancel: c, beforeEnd: l, end: u, moveEnd: d, resizing: f, full: p, min: m, restore: h, ...g } = i;
|
|
104
|
+
S.value = e.open({
|
|
105
|
+
...g,
|
|
106
|
+
success(e, n) {
|
|
107
|
+
if (C.value = e, t) {
|
|
108
|
+
let e = document.getElementById(t);
|
|
109
|
+
e && (w.value = e);
|
|
110
|
+
}
|
|
111
|
+
A(e), o?.(e, n), window.dispatchEvent(new Event("resize")), y("success", e, n);
|
|
112
|
+
},
|
|
113
|
+
yes(t, n) {
|
|
114
|
+
s?.(t, n), y("yes", t, n), s || e.close(t);
|
|
115
|
+
},
|
|
116
|
+
cancel(e, t) {
|
|
117
|
+
let n = c?.(e, t);
|
|
118
|
+
return y("cancel", e, t), n;
|
|
119
|
+
},
|
|
120
|
+
beforeEnd(e, t) {
|
|
121
|
+
return N({
|
|
122
|
+
...i,
|
|
123
|
+
beforeEnd: l
|
|
124
|
+
}, e, t);
|
|
125
|
+
},
|
|
126
|
+
end() {
|
|
127
|
+
u?.(), y("update:modelValue", !1), y("end"), j();
|
|
128
|
+
},
|
|
129
|
+
moveEnd(e) {
|
|
130
|
+
d?.(e), y("moveEnd", e);
|
|
131
|
+
},
|
|
132
|
+
resizing(e) {
|
|
133
|
+
f?.(e), y("resizing", e);
|
|
134
|
+
},
|
|
135
|
+
full(e, t) {
|
|
136
|
+
p?.(e, t), y("full", e, t);
|
|
137
|
+
},
|
|
138
|
+
min(e, t) {
|
|
139
|
+
m?.(e, t), y("min", e, t);
|
|
140
|
+
},
|
|
141
|
+
restore(e, t) {
|
|
142
|
+
h?.(e, t), y("restore", e, t);
|
|
143
|
+
}
|
|
144
|
+
}), await a();
|
|
145
|
+
}
|
|
146
|
+
m(() => _.modelValue, (e) => {
|
|
147
|
+
e ? P() : M();
|
|
148
|
+
}), s(() => {
|
|
149
|
+
_.modelValue && P();
|
|
150
|
+
}), o(() => {
|
|
151
|
+
M(), j();
|
|
152
|
+
});
|
|
153
|
+
function F() {
|
|
154
|
+
return S.value;
|
|
155
|
+
}
|
|
156
|
+
function I(e) {
|
|
157
|
+
S.value !== void 0 && v().style(S.value, e);
|
|
158
|
+
}
|
|
159
|
+
function L(e) {
|
|
160
|
+
S.value !== void 0 && v().title(e, S.value);
|
|
161
|
+
}
|
|
162
|
+
function R() {
|
|
163
|
+
S.value !== void 0 && v().full(S.value);
|
|
164
|
+
}
|
|
165
|
+
function z() {
|
|
166
|
+
S.value !== void 0 && v().min(S.value);
|
|
167
|
+
}
|
|
168
|
+
function B() {
|
|
169
|
+
S.value !== void 0 && v().restore(S.value);
|
|
170
|
+
}
|
|
171
|
+
return h({
|
|
172
|
+
getIndex: F,
|
|
173
|
+
close: M,
|
|
174
|
+
style: I,
|
|
175
|
+
title: L,
|
|
176
|
+
full: R,
|
|
177
|
+
min: z,
|
|
178
|
+
restore: B
|
|
179
|
+
}), (t, i) => w.value ? (c(), n(e, {
|
|
180
|
+
key: 0,
|
|
181
|
+
to: w.value
|
|
182
|
+
}, [u(t.$slots, "default")], 8, ["to"])) : r("", !0);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
//#endregion
|
|
186
|
+
export { x as S3Layer, x as s3Layer, v as getLayer, _ as getLayui, b as layer, y as layui };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("vue"),require("layui")):typeof define==`function`&&define.amd?define([`exports`,`vue`,`layui`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.Vue3Layer={},e.Vue,e.layui))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function r(){let e=globalThis;if(e.layui?.layer)return e.layui;if(e.layer)return{layer:e.layer}}function i(){let e=r();if(!e?.layer)throw Error(`layui layer is not available. Make sure this code runs in a browser environment.`);return e}function a(){return i()}function o(){return i().layer}var s=new Proxy({},{get(e,t){return i()[t]},set(e,t,n){return i()[t]=n,!0}}),c=new Proxy({},{get(e,t){let n=o(),r=n[t];return typeof r==`function`?r.bind(n):r},set(e,t,n){return o()[t]=n,!0}}),l=(0,t.defineComponent)({name:`S3Layer`,inheritAttrs:!1,__name:`S3Layer`,props:{modelValue:{type:Boolean,default:!1},options:{default:()=>({})}},emits:[`update:modelValue`,`success`,`yes`,`cancel`,`beforeEnd`,`end`,`moveEnd`,`resizing`,`full`,`min`,`restore`],setup(e,{expose:n,emit:r}){let i=e,a=r,s=(0,t.useAttrs)(),c=(0,t.useSlots)(),l=(0,t.ref)(),u=(0,t.shallowRef)(),d=(0,t.shallowRef)(),f=(0,t.ref)(!1),p=(0,t.computed)(()=>!!c.default),m=0;function h(e){let t=e.slice(2);return t.charAt(0).toLowerCase()+t.slice(1)}function g(){let e={};return Object.entries(s).forEach(([t,n])=>{if(!(t===`class`||t===`style`)){if(/^on[A-Z]/.test(t)&&typeof n==`function`){e[h(t)]=n;return}e[t]=n}}),e}function _(e){let t=s.class,n=s.style;t&&(typeof e.addClass==`function`?e.addClass(String(t)):e.classList.add(...String(t).split(/\s+/).filter(Boolean))),n&&(typeof e.css==`function`?e.css(n):typeof n==`string`?e.setAttribute(`style`,`${e.getAttribute(`style`)||``};${n}`):typeof n==`object`&&Object.assign(e.style,n))}function v(){l.value=void 0,u.value=void 0,d.value=void 0,f.value=!1}function y(){l.value!==void 0&&o().close(l.value)}function b(e,t,n){if(f.value)return;a(`beforeEnd`,t,n);let r=e.beforeEnd?.(t,n);return r&&typeof r.then==`function`?(r.then(e=>{e===!1||l.value!==t||(f.value=!0,o().close(t))}).catch(()=>void 0),!1):r}async function x(){if(l.value!==void 0||typeof window>`u`)return;let e=o(),n=p.value?`s3-layer-teleport-${Date.now()}-${m++}`:void 0,r=g(),s=i.options||{},c={title:`信息`,...r,...s};n&&(c.type=1,c.content=`<div id="${n}" class="s3-layer__teleport"></div>`);let{success:f,yes:h,cancel:y,beforeEnd:x,end:S,moveEnd:C,resizing:w,full:T,min:E,restore:D,...O}=c;l.value=e.open({...O,success(e,t){if(u.value=e,n){let e=document.getElementById(n);e&&(d.value=e)}_(e),f?.(e,t),window.dispatchEvent(new Event(`resize`)),a(`success`,e,t)},yes(t,n){h?.(t,n),a(`yes`,t,n),h||e.close(t)},cancel(e,t){let n=y?.(e,t);return a(`cancel`,e,t),n},beforeEnd(e,t){return b({...c,beforeEnd:x},e,t)},end(){S?.(),a(`update:modelValue`,!1),a(`end`),v()},moveEnd(e){C?.(e),a(`moveEnd`,e)},resizing(e){w?.(e),a(`resizing`,e)},full(e,t){T?.(e,t),a(`full`,e,t)},min(e,t){E?.(e,t),a(`min`,e,t)},restore(e,t){D?.(e,t),a(`restore`,e,t)}}),await(0,t.nextTick)()}(0,t.watch)(()=>i.modelValue,e=>{e?x():y()}),(0,t.onMounted)(()=>{i.modelValue&&x()}),(0,t.onBeforeUnmount)(()=>{y(),v()});function S(){return l.value}function C(e){l.value!==void 0&&o().style(l.value,e)}function w(e){l.value!==void 0&&o().title(e,l.value)}function T(){l.value!==void 0&&o().full(l.value)}function E(){l.value!==void 0&&o().min(l.value)}function D(){l.value!==void 0&&o().restore(l.value)}return n({getIndex:S,close:y,style:C,title:w,full:T,min:E,restore:D}),(e,n)=>d.value?((0,t.openBlock)(),(0,t.createBlock)(t.Teleport,{key:0,to:d.value},[(0,t.renderSlot)(e.$slots,`default`)],8,[`to`])):(0,t.createCommentVNode)(``,!0)}});e.S3Layer=l,e.s3Layer=l,e.getLayer=o,e.getLayui=a,e.layer=c,e.layui=s});
|
package/package.json
CHANGED
|
@@ -1,52 +1,73 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue3-layer",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "基于 Vue 3 和 layui layer 的 Web 通用弹出层组件",
|
|
5
5
|
"author": "legad",
|
|
6
|
-
"description": "基于 vue3 的Web 通用弹出层组件",
|
|
7
6
|
"keywords": [
|
|
8
7
|
"vue-layer",
|
|
9
8
|
"vue-modal",
|
|
10
9
|
"vue-dialog",
|
|
11
10
|
"vue3-modal",
|
|
12
11
|
"vue3-dialog",
|
|
13
|
-
"vue3-layer"
|
|
12
|
+
"vue3-layer",
|
|
13
|
+
"layui",
|
|
14
|
+
"layer"
|
|
14
15
|
],
|
|
15
16
|
"homepage": "https://github.com/liicos/vue3-layer",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "dist/vue3-layer.umd.cjs",
|
|
20
|
+
"module": "dist/vue3-layer.js",
|
|
21
|
+
"types": "dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/vue3-layer.js",
|
|
26
|
+
"require": "./dist/vue3-layer.umd.cjs"
|
|
27
|
+
},
|
|
28
|
+
"./style.css": "./dist/vue3-layer.css",
|
|
29
|
+
"./vue3-layer.css": "./dist/vue3-layer.css"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"sideEffects": [
|
|
35
|
+
"**/*.css",
|
|
36
|
+
"**/*.vue"
|
|
37
|
+
],
|
|
16
38
|
"scripts": {
|
|
17
|
-
"
|
|
18
|
-
"build": "vue-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
39
|
+
"dev": "vite",
|
|
40
|
+
"build": "vue-tsc -p tsconfig.build.json --noEmit && vite build",
|
|
41
|
+
"typecheck": "vue-tsc -p tsconfig.build.json --noEmit",
|
|
42
|
+
"lint": "eslint .",
|
|
43
|
+
"preview": "vite preview",
|
|
44
|
+
"docs:dev": "vitepress dev docs",
|
|
45
|
+
"docs:build": "vitepress build docs",
|
|
46
|
+
"docs:preview": "vitepress preview docs"
|
|
21
47
|
},
|
|
22
48
|
"dependencies": {
|
|
23
|
-
"
|
|
24
|
-
"jquery": "^3.6.0",
|
|
25
|
-
"layer-src": "^3.5.1",
|
|
26
|
-
"nanoid": "^3.1.30"
|
|
49
|
+
"layui": "^2.13.7"
|
|
27
50
|
},
|
|
28
51
|
"peerDependencies": {
|
|
29
|
-
"vue": "
|
|
52
|
+
"vue": ">=3.5.0 <4"
|
|
30
53
|
},
|
|
31
54
|
"devDependencies": {
|
|
32
|
-
"
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@vue/
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"eslint
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
],
|
|
51
|
-
"types": "src/vue3-layer.d.ts"
|
|
55
|
+
"@eslint/js": "^10.0.1",
|
|
56
|
+
"@types/node": "^24.10.1",
|
|
57
|
+
"@types/layui": "^2.13.0",
|
|
58
|
+
"@vitejs/plugin-vue": "^6.0.7",
|
|
59
|
+
"@vue/test-utils": "^2.4.10",
|
|
60
|
+
"eslint": "^10.4.1",
|
|
61
|
+
"eslint-plugin-vue": "^10.9.1",
|
|
62
|
+
"jsdom": "^29.1.1",
|
|
63
|
+
"prettier": "^3.8.3",
|
|
64
|
+
"typescript": "^6.0.3",
|
|
65
|
+
"typescript-eslint": "^8.60.1",
|
|
66
|
+
"vite": "^8.0.16",
|
|
67
|
+
"vite-plugin-dts": "^5.0.2",
|
|
68
|
+
"vitepress": "^1.6.4",
|
|
69
|
+
"vitest": "^4.1.8",
|
|
70
|
+
"vue": "^3.5.35",
|
|
71
|
+
"vue-tsc": "^3.3.3"
|
|
72
|
+
}
|
|
52
73
|
}
|
package/dist/demo.html
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|