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 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, NConfigProvider as oe, NGlobalStyle as ae, NEl as re, NMessageProvider as le, NNotificationProvider as ie, NModalProvider as se, NDialogProvider as ce } from "naive-ui";
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 ue() {
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 = fe(f, p, v, w);
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 y(t) {
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 && v(l);
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 v(t) {
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 g(t, e) {
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 && v(e), a && window.removeEventListener("popstate", a);
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 _(t = 300) {
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", y), D = null, n?.clear && n.clear();
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", y), D = { on: f, ononce: g, onclose: b, onClose: V, off: v, emit: p, register: m, call: L, close: _, destroy: u, getWindow: w, getMode: F, getParent: h, sendFile: r, onReceiveFile: c, manageFiles: d }, D;
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 de() {
135
- return ue();
134
+ function we() {
135
+ return fe();
136
136
  }
137
- function fe(n, i, s, N) {
138
- const w = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Set(), F = 1e4, y = 6e4;
139
- let f = null, v = !1, g = [];
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 (v) return;
142
- v = !0;
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 > y && w.delete(r);
147
+ u - c.lastActive > g && w.delete(r);
148
148
  w.size === 0 && (clearInterval(f), f = null);
149
149
  }, F));
150
150
  };
151
- g.push(n("__FILE_TRANSFER_START__", (u) => {
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
- })), g.push(n("__FILE_TRANSFER_CHUNK__", ({ id: u, index: r, data: c }) => {
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
- })), g.push(n("__FILE_TRANSFER_END__", async ({ id: u }) => {
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
- })), g.push(n("__FILE_TRANSFER_ERROR__", ({ id: u }) => {
174
+ })), y.push(n("__FILE_TRANSFER_ERROR__", ({ id: u }) => {
175
175
  w.delete(u);
176
176
  }));
177
177
  }, m = () => {
178
- v && (g.forEach((_) => s(_)), g = [], v = !1, f && (clearInterval(f), f = null), w.clear());
178
+ _ && (y.forEach((v) => s(v)), y = [], _ = !1, f && (clearInterval(f), f = null), w.clear());
179
179
  };
180
- async function L(_, u = null, r = 1024 * 1024) {
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 = _.name || "blob", e = _.type, a = _.size, l = Math.ceil(a / r);
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 _.slice(P, C).arrayBuffer();
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 _ != "function" ? () => {
205
- } : (h.add(_), p(), () => {
206
- h.delete(_), h.size === 0 && m();
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(_ = 3e4, u = 1e4) {
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 > _ && r.delete(a);
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 we = de();
261
- function _e() {
262
- return we;
260
+ const _e = we();
261
+ function me() {
262
+ return _e;
263
263
  }
264
- const he = /* @__PURE__ */ K({
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), y = _e(), f = k(() => h.value === "dark" ? te : ne), v = H({});
274
- y.on("onTheme", (m) => {
275
- h.value = m.name, v.value = m.overrides, N("theme", {
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: y,
277
+ view: g,
278
278
  theme_style: f,
279
279
  theme_name: k(() => h.value),
280
- theme_overrides: k(() => v.value)
280
+ theme_overrides: k(() => _.value)
281
281
  });
282
282
  });
283
- const g = K({
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
- v.value = JSON.parse(m);
300
+ _.value = JSON.parse(m);
301
301
  } catch {
302
302
  }
303
303
  F.value = !1;
304
304
  }
305
305
  return Q(() => {
306
- y.getParent() ? y.call("getTheme", null, 500).then((m) => {
307
- h.value = m.name, v.value = m.overrides, F.value = !1;
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: y,
312
+ view: g,
313
313
  theme_style: f,
314
314
  theme_name: k(() => h.value),
315
- theme_overrides: k(() => v.value)
315
+ theme_overrides: k(() => _.value)
316
316
  });
317
- }), (m, L) => F.value ? W("", !0) : (G(), U(E(oe), {
317
+ }), (m, L) => F.value ? W("", !0) : (G(), U(E(re), {
318
318
  key: 0,
319
319
  theme: f.value,
320
- "theme-overrides": v.value,
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(ae), { key: 0 })) : W("", !0),
327
- S(E(re), null, {
326
+ w.value == "window" ? (G(), U(E(le), { key: 0 })) : W("", !0),
327
+ S(E(ie), null, {
328
328
  default: A(() => [
329
- S(E(le), null, {
329
+ S(E(se), null, {
330
330
  default: A(() => [
331
- S(E(ie), null, {
331
+ S(E(ce), null, {
332
332
  default: A(() => [
333
- S(E(se), null, {
333
+ S(E(ue), null, {
334
334
  default: A(() => [
335
- S(E(ce), null, {
335
+ S(E(de), null, {
336
336
  default: A(() => [
337
- S(E(g)),
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
- he as NViewProvider
360
+ ge as NViewProvider
361
361
  };