naive-ui-x 0.0.6 → 0.0.7
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/dist/es/index.js +62 -62
- package/dist/js/naive-ui.esm.js +6468 -6463
- package/dist/js/naive-ui.js +186 -186
- package/package.json +7 -8
package/dist/es/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defineComponent as K, computed as k, ref as H, onMounted as Q, openBlock as G, createBlock as U, unref as E, withCtx as A, createCommentVNode as W, createVNode as S, renderSlot as X } from "vue";
|
|
2
|
-
import { dateZhCN as Y, zhCN as ee, darkTheme as te, lightTheme as ne, useNotification as J, useMessage as Z,
|
|
2
|
+
import { dateZhCN as Y, zhCN as ee, darkTheme as te, lightTheme as ne, useNotification as J, useMessage as Z, useDialog as oe, useModal as ae, NConfigProvider as re, NGlobalStyle as le, NEl as ie, NMessageProvider as se, NNotificationProvider as ce, NModalProvider as ue, NDialogProvider as de } from "naive-ui";
|
|
3
3
|
const x = "iframe", M = "window";
|
|
4
4
|
let D = null;
|
|
5
|
-
function
|
|
5
|
+
function fe() {
|
|
6
6
|
if (D)
|
|
7
7
|
return D;
|
|
8
8
|
const n = /* @__PURE__ */ new Map();
|
|
@@ -13,7 +13,7 @@ function ue() {
|
|
|
13
13
|
windowInstance: window.parent,
|
|
14
14
|
mode: x
|
|
15
15
|
};
|
|
16
|
-
const N =
|
|
16
|
+
const N = ve(f, p, _, w);
|
|
17
17
|
function w() {
|
|
18
18
|
return i;
|
|
19
19
|
}
|
|
@@ -23,12 +23,12 @@ function ue() {
|
|
|
23
23
|
function F(t = !1) {
|
|
24
24
|
return t && (!i || i === window.self) ? null : s;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function g(t) {
|
|
27
27
|
if (t?.source !== i)
|
|
28
28
|
return;
|
|
29
29
|
const { event: e, data: a } = t.data;
|
|
30
30
|
e && n.has(e) && n.get(e).forEach((l) => {
|
|
31
|
-
l.once &&
|
|
31
|
+
l.once && _(l);
|
|
32
32
|
try {
|
|
33
33
|
l.callback(a);
|
|
34
34
|
} catch {
|
|
@@ -40,7 +40,7 @@ function ue() {
|
|
|
40
40
|
const l = { event: t, callback: e, once: a };
|
|
41
41
|
return n.get(t).push(l), l;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function _(t) {
|
|
44
44
|
if (typeof t == "string")
|
|
45
45
|
return n.has(t) ? (n.delete(t), !0) : !1;
|
|
46
46
|
if (n.has(t.event)) {
|
|
@@ -50,7 +50,7 @@ function ue() {
|
|
|
50
50
|
}
|
|
51
51
|
return !1;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function y(t, e) {
|
|
54
54
|
return f(t, e, !0);
|
|
55
55
|
}
|
|
56
56
|
function p(t, e = null) {
|
|
@@ -111,54 +111,54 @@ function ue() {
|
|
|
111
111
|
} catch {
|
|
112
112
|
}
|
|
113
113
|
}, a = function() {
|
|
114
|
-
s === M && window.history.length === 2 && (window.history.pushState({}, "", ""),
|
|
114
|
+
s === M && window.history.length === 2 && (window.history.pushState({}, "", ""), v());
|
|
115
115
|
}, window.history.pushState({}, "", ""), window.addEventListener("popstate", a), window.addEventListener("beforeunload", e)), s === x && (e = m("close", t)), () => {
|
|
116
|
-
s === M && e && window.removeEventListener("beforeunload", e), s === x && e &&
|
|
116
|
+
s === M && e && window.removeEventListener("beforeunload", e), s === x && e && _(e), a && window.removeEventListener("popstate", a);
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
function V(t) {
|
|
120
120
|
return b(t);
|
|
121
121
|
}
|
|
122
122
|
let R = null;
|
|
123
|
-
function
|
|
123
|
+
function v(t = 300) {
|
|
124
124
|
R && (clearTimeout(R), R = null), R = setTimeout(() => {
|
|
125
125
|
s === M && window.close(), s === x && p("onClose"), R = null;
|
|
126
126
|
}, t);
|
|
127
127
|
}
|
|
128
128
|
function u() {
|
|
129
|
-
N.destroy(), window.removeEventListener("message",
|
|
129
|
+
N.destroy(), window.removeEventListener("message", g), D = null, n?.clear && n.clear();
|
|
130
130
|
}
|
|
131
131
|
const { sendFile: r, onReceiveFile: c, manageFiles: d } = N;
|
|
132
|
-
return window.addEventListener("message",
|
|
132
|
+
return window.addEventListener("message", g), D = { on: f, ononce: y, onclose: b, onClose: V, off: _, emit: p, register: m, call: L, close: v, destroy: u, getWindow: w, getMode: F, getParent: h, sendFile: r, onReceiveFile: c, manageFiles: d }, D;
|
|
133
133
|
}
|
|
134
|
-
function
|
|
135
|
-
return
|
|
134
|
+
function we() {
|
|
135
|
+
return fe();
|
|
136
136
|
}
|
|
137
|
-
function
|
|
138
|
-
const w = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Set(), F = 1e4,
|
|
139
|
-
let f = null,
|
|
137
|
+
function ve(n, i, s, N) {
|
|
138
|
+
const w = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Set(), F = 1e4, g = 6e4;
|
|
139
|
+
let f = null, _ = !1, y = [];
|
|
140
140
|
const p = () => {
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
const
|
|
141
|
+
if (_) return;
|
|
142
|
+
_ = !0;
|
|
143
|
+
const v = () => {
|
|
144
144
|
f || (f = setInterval(() => {
|
|
145
145
|
const u = Date.now();
|
|
146
146
|
for (const [r, c] of w)
|
|
147
|
-
u - c.lastActive >
|
|
147
|
+
u - c.lastActive > g && w.delete(r);
|
|
148
148
|
w.size === 0 && (clearInterval(f), f = null);
|
|
149
149
|
}, F));
|
|
150
150
|
};
|
|
151
|
-
|
|
151
|
+
y.push(n("__FILE_TRANSFER_START__", (u) => {
|
|
152
152
|
w.set(u.id, {
|
|
153
153
|
chunks: new Array(u.totalChunks),
|
|
154
154
|
received: 0,
|
|
155
155
|
metadata: u,
|
|
156
156
|
lastActive: Date.now()
|
|
157
|
-
}),
|
|
158
|
-
})),
|
|
157
|
+
}), v();
|
|
158
|
+
})), y.push(n("__FILE_TRANSFER_CHUNK__", ({ id: u, index: r, data: c }) => {
|
|
159
159
|
const d = w.get(u);
|
|
160
160
|
d && (d.chunks[r] = c, d.received++, d.lastActive = Date.now());
|
|
161
|
-
})),
|
|
161
|
+
})), y.push(n("__FILE_TRANSFER_END__", async ({ id: u }) => {
|
|
162
162
|
const r = w.get(u);
|
|
163
163
|
if (r && r.received === r.metadata.totalChunks)
|
|
164
164
|
try {
|
|
@@ -171,21 +171,21 @@ function fe(n, i, s, N) {
|
|
|
171
171
|
} finally {
|
|
172
172
|
w.delete(u);
|
|
173
173
|
}
|
|
174
|
-
})),
|
|
174
|
+
})), y.push(n("__FILE_TRANSFER_ERROR__", ({ id: u }) => {
|
|
175
175
|
w.delete(u);
|
|
176
176
|
}));
|
|
177
177
|
}, m = () => {
|
|
178
|
-
|
|
178
|
+
_ && (y.forEach((v) => s(v)), y = [], _ = !1, f && (clearInterval(f), f = null), w.clear());
|
|
179
179
|
};
|
|
180
|
-
async function L(
|
|
180
|
+
async function L(v, u = null, r = 1024 * 1024) {
|
|
181
181
|
const c = N();
|
|
182
182
|
if (!c || c === window)
|
|
183
183
|
return Promise.reject("No window instance");
|
|
184
|
-
const d = Math.random().toString(36).substring(2) + Date.now(), t =
|
|
184
|
+
const d = Math.random().toString(36).substring(2) + Date.now(), t = v.name || "blob", e = v.type, a = v.size, l = Math.ceil(a / r);
|
|
185
185
|
i("__FILE_TRANSFER_START__", { id: d, name: t, type: e, size: a, totalChunks: l });
|
|
186
186
|
try {
|
|
187
187
|
for (let o = 0; o < l; o++) {
|
|
188
|
-
const P = o * r, C = Math.min(P + r, a), I = await
|
|
188
|
+
const P = o * r, C = Math.min(P + r, a), I = await v.slice(P, C).arrayBuffer();
|
|
189
189
|
if (c.postMessage({
|
|
190
190
|
event: "__FILE_TRANSFER_CHUNK__",
|
|
191
191
|
data: { id: d, index: o, data: I }
|
|
@@ -200,20 +200,20 @@ function fe(n, i, s, N) {
|
|
|
200
200
|
throw i("__FILE_TRANSFER_ERROR__", { id: d, error: o.message || o.toString() }), o;
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
function b(
|
|
204
|
-
return typeof
|
|
205
|
-
} : (h.add(
|
|
206
|
-
h.delete(
|
|
203
|
+
function b(v) {
|
|
204
|
+
return typeof v != "function" ? () => {
|
|
205
|
+
} : (h.add(v), p(), () => {
|
|
206
|
+
h.delete(v), h.size === 0 && m();
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
|
-
function V(
|
|
209
|
+
function V(v = 3e4, u = 1e4) {
|
|
210
210
|
const r = /* @__PURE__ */ new Map();
|
|
211
211
|
let c = null;
|
|
212
212
|
const d = () => {
|
|
213
213
|
c || (c = setInterval(() => {
|
|
214
214
|
const e = Date.now();
|
|
215
215
|
for (const [a, l] of r)
|
|
216
|
-
e - l.timestamp >
|
|
216
|
+
e - l.timestamp > v && r.delete(a);
|
|
217
217
|
r.size === 0 && (clearInterval(c), c = null);
|
|
218
218
|
}, u));
|
|
219
219
|
}, t = b((e, a) => {
|
|
@@ -257,11 +257,11 @@ function T(n) {
|
|
|
257
257
|
}
|
|
258
258
|
return i;
|
|
259
259
|
}
|
|
260
|
-
const
|
|
261
|
-
function
|
|
262
|
-
return
|
|
260
|
+
const _e = we();
|
|
261
|
+
function me() {
|
|
262
|
+
return _e;
|
|
263
263
|
}
|
|
264
|
-
const
|
|
264
|
+
const ge = /* @__PURE__ */ K({
|
|
265
265
|
__name: "n-view-provider",
|
|
266
266
|
props: {
|
|
267
267
|
locale: { default: ee },
|
|
@@ -270,20 +270,20 @@ const he = /* @__PURE__ */ K({
|
|
|
270
270
|
},
|
|
271
271
|
emits: ["init", "theme"],
|
|
272
272
|
setup(n, { emit: i }) {
|
|
273
|
-
const s = n, N = i, w = k(() => window.opener ? "window" : "iframe"), h = H("light"), F = H(!0),
|
|
274
|
-
|
|
275
|
-
h.value = m.name,
|
|
273
|
+
const s = n, N = i, w = k(() => window.opener ? "window" : "iframe"), h = H("light"), F = H(!0), g = me(), f = k(() => h.value === "dark" ? te : ne), _ = H({});
|
|
274
|
+
g.on("onTheme", (m) => {
|
|
275
|
+
h.value = m.name, _.value = m.overrides, N("theme", {
|
|
276
276
|
mode: w,
|
|
277
|
-
view:
|
|
277
|
+
view: g,
|
|
278
278
|
theme_style: f,
|
|
279
279
|
theme_name: k(() => h.value),
|
|
280
|
-
theme_overrides: k(() =>
|
|
280
|
+
theme_overrides: k(() => _.value)
|
|
281
281
|
});
|
|
282
282
|
});
|
|
283
|
-
const
|
|
283
|
+
const y = K({
|
|
284
284
|
name: "NPreViewProvider",
|
|
285
285
|
setup() {
|
|
286
|
-
return window.naive ? (window.naive.message = Z(), window.naive.notification = J()) : window.naive = {
|
|
286
|
+
return window.naive ? (window.naive.message = Z(), window.naive.notification = J(), window.naive.dialog = oe(), window.naive.modal = ae()) : window.naive = {
|
|
287
287
|
message: Z(),
|
|
288
288
|
notification: J()
|
|
289
289
|
}, {};
|
|
@@ -297,44 +297,44 @@ const he = /* @__PURE__ */ K({
|
|
|
297
297
|
let m = window.localStorage.getItem("themeOverrides");
|
|
298
298
|
if (m)
|
|
299
299
|
try {
|
|
300
|
-
|
|
300
|
+
_.value = JSON.parse(m);
|
|
301
301
|
} catch {
|
|
302
302
|
}
|
|
303
303
|
F.value = !1;
|
|
304
304
|
}
|
|
305
305
|
return Q(() => {
|
|
306
|
-
|
|
307
|
-
h.value = m.name,
|
|
306
|
+
g.getParent() ? g.call("getTheme", null, 500).then((m) => {
|
|
307
|
+
h.value = m.name, _.value = m.overrides, F.value = !1;
|
|
308
308
|
}).catch((m) => {
|
|
309
309
|
p();
|
|
310
310
|
}) : p(), N("init", {
|
|
311
311
|
mode: w,
|
|
312
|
-
view:
|
|
312
|
+
view: g,
|
|
313
313
|
theme_style: f,
|
|
314
314
|
theme_name: k(() => h.value),
|
|
315
|
-
theme_overrides: k(() =>
|
|
315
|
+
theme_overrides: k(() => _.value)
|
|
316
316
|
});
|
|
317
|
-
}), (m, L) => F.value ? W("", !0) : (G(), U(E(
|
|
317
|
+
}), (m, L) => F.value ? W("", !0) : (G(), U(E(re), {
|
|
318
318
|
key: 0,
|
|
319
319
|
theme: f.value,
|
|
320
|
-
"theme-overrides":
|
|
320
|
+
"theme-overrides": _.value,
|
|
321
321
|
locale: s.locale,
|
|
322
322
|
"date-locale": s.dateLocale,
|
|
323
323
|
breakpoints: s.breakpoints
|
|
324
324
|
}, {
|
|
325
325
|
default: A(() => [
|
|
326
|
-
w.value == "window" ? (G(), U(E(
|
|
327
|
-
S(E(
|
|
326
|
+
w.value == "window" ? (G(), U(E(le), { key: 0 })) : W("", !0),
|
|
327
|
+
S(E(ie), null, {
|
|
328
328
|
default: A(() => [
|
|
329
|
-
S(E(
|
|
329
|
+
S(E(se), null, {
|
|
330
330
|
default: A(() => [
|
|
331
|
-
S(E(
|
|
331
|
+
S(E(ce), null, {
|
|
332
332
|
default: A(() => [
|
|
333
|
-
S(E(
|
|
333
|
+
S(E(ue), null, {
|
|
334
334
|
default: A(() => [
|
|
335
|
-
S(E(
|
|
335
|
+
S(E(de), null, {
|
|
336
336
|
default: A(() => [
|
|
337
|
-
S(E(
|
|
337
|
+
S(E(y)),
|
|
338
338
|
X(m.$slots, "default")
|
|
339
339
|
]),
|
|
340
340
|
_: 3
|
|
@@ -357,5 +357,5 @@ const he = /* @__PURE__ */ K({
|
|
|
357
357
|
}
|
|
358
358
|
});
|
|
359
359
|
export {
|
|
360
|
-
|
|
360
|
+
ge as NViewProvider
|
|
361
361
|
};
|