@soei/flyweight 0.3.10 → 0.3.12

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/Flyweight.js CHANGED
@@ -1,27 +1,27 @@
1
- import { runer as T, merge as B, isArray as nt, each as H, picker as O, isEmpty as ot, isSimplyType as J, isString as _t } from "@soei/util";
2
- import { openBlock as z, createElementBlock as M, normalizeClass as ht, normalizeStyle as I, createElementVNode as P, Fragment as at, renderList as ct, renderSlot as m, mergeProps as U, createCommentVNode as ut, createTextVNode as dt, toDisplayString as D, createBlock as xt, resolveDynamicComponent as vt, normalizeProps as St, guardReactiveProps as $t, withCtx as zt } from "vue";
3
- import { runer as p, each as K } from "@soei/tools";
1
+ import { runer as T, merge as C, isArray as ht, each as W, picker as O, isEmpty as at, isSimplyType as K, isString as xt } from "@soei/util";
2
+ import { openBlock as N, createElementBlock as M, normalizeClass as dt, normalizeStyle as P, createElementVNode as B, Fragment as ct, renderList as ut, renderSlot as g, mergeProps as I, createCommentVNode as ft, createTextVNode as pt, toDisplayString as D, createBlock as St, resolveDynamicComponent as $t, withCtx as Nt } from "vue";
3
+ import { runer as p, isNil as zt, each as Q } from "@soei/tools";
4
4
  import kt from "@soei/picker";
5
- let Nt = /(\d+|[+\-\*/]|%)/g, Q = {
5
+ let Tt = /(\d+|[+\-\*/]|%)/g, Z = {
6
6
  "+": (t, e) => t + e,
7
7
  "-": (t, e) => t - e,
8
8
  "*": (t, e) => t * e,
9
9
  "/": (t, e) => t / e,
10
10
  "%": (t, e, i) => parseFloat(t) / 100 * i
11
- }, Z = (t, e) => {
11
+ }, tt = (t, e) => {
12
12
  let i;
13
- if (i = T("match", t, Nt)) {
13
+ if (i = T("match", t, Tt)) {
14
14
  let r = i.length, n, l = 0, s, h = [];
15
15
  for (; r--; )
16
- l = i.shift(), l in Q ? (n && h.push(n), l === "%" && (h.length = 2), s = l) : +l && h.push(+l), h.length == 2 && (h.push(e), n = Q[s].apply(null, h), h.length = 0);
16
+ l = i.shift(), l in Z ? (n && h.push(n), l === "%" && (h.length = 2), s = l) : +l && h.push(+l), h.length == 2 && (h.push(e), n = Z[s].apply(null, h), h.length = 0);
17
17
  +n || (n = +h.pop()), t = n >> 0;
18
18
  }
19
19
  return t;
20
- }, tt = {}, _ = (t, e) => (t + "").replace(
20
+ }, et = {}, _ = (t, e) => (t + "").replace(
21
21
  /\w+\((.*)\)/g,
22
22
  "$1"
23
23
  ).replace(
24
- tt[e] || (tt[e] = new RegExp("(?=\\s+|^)(\\d+)(?:\\.\\d{1,})?(?!(?:\\.)*\\d|%|\\w)", "g")),
24
+ et[e] || (et[e] = new RegExp("(?=\\s+|^)(\\d+)(?:\\.\\d{1,})?(?!(?:\\.)*\\d|%|\\w)", "g")),
25
25
  "$1px"
26
26
  );
27
27
  const j = (t, e) => {
@@ -30,10 +30,10 @@ const j = (t, e) => {
30
30
  i[r] = n;
31
31
  return i;
32
32
  };
33
- let et = (t) => t == null || t == null, Tt = (...t) => {
33
+ let it = (t) => t == null || t == null, Mt = (...t) => {
34
34
  console.info("::::FLYWEIGHT", ...t);
35
35
  };
36
- const Mt = {
36
+ const Et = {
37
37
  name: "Flyweight",
38
38
  props: {
39
39
  flys: {
@@ -97,7 +97,7 @@ const Mt = {
97
97
  },
98
98
  style() {
99
99
  var t = this.w, e = this.h, i = this.Size, r = {};
100
- return B(r, {
100
+ return C(r, {
101
101
  "--width": _(this.realW),
102
102
  "--height": _(this.realH),
103
103
  "--flyweight-content": _(i)
@@ -156,7 +156,7 @@ const Mt = {
156
156
  this.rebuild(), this.$emit("resize");
157
157
  }).observe(this.flyweight);
158
158
  } catch (t) {
159
- Tt(t);
159
+ Mt(t);
160
160
  }
161
161
  this.scrollx = T("hasAttribute", this.flyweight, "scroll-x"), this.BoxRule = /* this.scrollx ? 'clientHeight=>width,clientWidth=>height' : */
162
162
  "clientHeight=>height,clientWidth=>width", this.direction = this.scrollx ? "scrollLeft" : "scrollTop";
@@ -164,9 +164,9 @@ const Mt = {
164
164
  methods: {
165
165
  exec: _,
166
166
  trigger(t, e) {
167
- nt(t) || (t = t && e ? [[t, e]] : []), t.length && this.lazyrun(() => {
168
- H(t, (i, r) => {
169
- this.$emit(r[0], et(r[1]) ? !0 : r[1]);
167
+ ht(t) || (t = t && e ? [[t, e]] : []), t.length && this.lazyrun(() => {
168
+ W(t, (i, r) => {
169
+ this.$emit(r[0], it(r[1]) ? !0 : r[1]);
170
170
  });
171
171
  });
172
172
  },
@@ -177,11 +177,11 @@ const Mt = {
177
177
  setview(t) {
178
178
  T([this.cheackflys, (e) => {
179
179
  e = e || {};
180
- let i = e.index || H(this.flys, (r, n, l, s) => {
180
+ let i = e.index || W(this.flys, (r, n, l, s) => {
181
181
  if (n[l] == s)
182
182
  return r;
183
183
  }, e.picker, e.id);
184
- et(i) || this.setindex(i);
184
+ it(i) || this.setindex(i);
185
185
  }], this, t);
186
186
  },
187
187
  setindex(t) {
@@ -207,24 +207,24 @@ const Mt = {
207
207
  /* 显示区域第一行的索引 */
208
208
  index: i / this.expand >> 0
209
209
  };
210
- B(r, this.space), t.from || e.push(["onscroll", r]);
210
+ C(r, this.space), t.from || e.push(["onscroll", r]);
211
211
  let n = !1;
212
- H(
212
+ W(
213
213
  this.flyweights,
214
- (l, s, h, o, u, c, d, f, a) => {
215
- if (h = l / u >> 0, f = h + o * /* 偏移量, 如果超出顶部 + 1轮,排列到列队后, 否则保持在当前*/
216
- (+(h < c % o) + (c / o >> 0)), a = f * u + l % u, a >= this.count) {
214
+ (l, s, h, o, d, c, u, f, a) => {
215
+ if (h = l / d >> 0, f = h + o * /* 偏移量, 如果超出顶部 + 1轮,排列到列队后, 否则保持在当前*/
216
+ (+(h < c % o) + (c / o >> 0)), a = f * d + l % d, a >= this.count) {
217
217
  n || (e.push(["onend"]), n = !0);
218
218
  return;
219
219
  }
220
220
  s.index = f, s.i = a, s.data = this.flys[a];
221
- let x = [
221
+ let v = [
222
222
  /* top */
223
223
  f * this.expand + s.x,
224
224
  /* left */
225
225
  s.space
226
226
  ];
227
- d && x.reverse(), s.top = x[0], s.left = x[1];
227
+ u && v.reverse(), s.top = v[0], s.left = v[1];
228
228
  },
229
229
  null,
230
230
  this.row,
@@ -244,65 +244,65 @@ const Mt = {
244
244
  this.count = t;
245
245
  let i = this.scrollx, r = this.flyweight, n = O(r, this.BoxRule);
246
246
  this.$nextTick(() => {
247
- let l = /true/.test(this.auto), [s, h] = this.offset, o = n.width, u = n.height, c = (Z(this.width, o) || o) + s, d = Z(this.height, u) + h, f = [o / c >> 0 || 1, u / d >> 0 || 1];
247
+ let l = /true/.test(this.auto), [s, h] = this.offset, o = n.width, d = n.height, c = (tt(this.width, o) || o) + s, u = tt(this.height, d) + h, f = [o / c >> 0 || 1, d / u >> 0 || 1];
248
248
  i && f.reverse();
249
- let [a, x] = f, v = this.padding, L, S = 0, g, y;
250
- i ? (g = c, c -= s, y = (b) => (
249
+ let [a, v] = f, x = this.padding, E, S = 0, y, w;
250
+ i ? (y = c, c -= s, w = ($) => (
251
251
  /* 计算top偏移量 */
252
- b * (d - h) + (b + 1) * h
253
- )) : (l ? (c = (o - s * (a + 2 * v - 1)) / a, L = !v * s, S = v * s) : (L = 0, S = (o % c + s * a) / (a + 1) >> 0, c -= s), y = (b) => b * (c + L) + (b + 1) * S, g = d), this.row = x + 2, this.column = a, this.realH = d - h, this.realW = c, this.expand = g, this.Size = Math.ceil(t / a) * g;
254
- let $ = Math.min(t, a * this.row), w = $ - 1, k;
255
- for (; $-- > 0; )
256
- k = w - $, this.$set(e, k, {
252
+ $ * (u - h) + ($ + 1) * h
253
+ )) : (l ? (c = (o - s * (a + 2 * x - 1)) / a, E = !x * s, S = x * s) : (E = 0, S = (o % c + s * a) / (a + 1) >> 0, c -= s), w = ($) => $ * (c + E) + ($ + 1) * S, y = u), this.row = v + 2, this.column = a, this.realH = u - h, this.realW = c, this.expand = y, this.Size = Math.ceil(t / a) * y;
254
+ let b = Math.min(t, a * this.row), m = b - 1, z;
255
+ for (; b-- > 0; )
256
+ z = m - b, this.$set(e, z, {
257
257
  x: s,
258
258
  y: h,
259
259
  width: c,
260
- height: d - h,
261
- space: y(k % a),
260
+ height: u - h,
261
+ space: w(z % a),
262
262
  data: {}
263
263
  });
264
- e.length = w + 1;
265
- let N = [];
266
- u / g > w / a && N.push(["onend"]), this.flyweight && (this.flyweight[this.direction] = 0), this.$nextTick(() => {
264
+ e.length = m + 1;
265
+ let k = [];
266
+ d / y > m / a && k.push(["onend"]), this.flyweight && (this.flyweight[this.direction] = 0), this.$nextTick(() => {
267
267
  this.setindex(this.selectIndex || 0), this.scroll();
268
- }), N.push(["update:space", {
269
- row: (w / a >> 0) + 1,
268
+ }), k.push(["update:space", {
269
+ row: (m / a >> 0) + 1,
270
270
  column: a,
271
271
  showrow: this.row,
272
272
  showcolumn: this.column
273
- }]), this.trigger(N);
273
+ }]), this.trigger(k);
274
274
  });
275
275
  }
276
276
  }
277
- }, Lt = { class: "flyweight-all" };
278
- function Et(t, e, i, r, n, l) {
279
- return z(), M("div", {
277
+ }, Ht = { class: "flyweight-all" };
278
+ function Lt(t, e, i, r, n, l) {
279
+ return N(), M("div", {
280
280
  ref: "flyweight",
281
- class: ht(["flyweight", {
281
+ class: dt(["flyweight", {
282
282
  "flyweight-active": n.actice
283
283
  }]),
284
- style: I(l.style),
284
+ style: P(l.style),
285
285
  onScroll: e[0] || (e[0] = (...s) => l.scroll && l.scroll(...s))
286
286
  }, [
287
- P("div", Lt, [
288
- (z(!0), M(at, null, ct(n.flyweights, (s, h) => (z(), M("div", {
287
+ B("div", Ht, [
288
+ (N(!0), M(ct, null, ut(n.flyweights, (s, h) => (N(), M("div", {
289
289
  key: h,
290
- style: I({
290
+ style: P({
291
291
  top: s.top + "px",
292
292
  left: s.left + "px"
293
293
  })
294
294
  }, [
295
- m(t.$slots, "default", U({ ref_for: !0 }, s), void 0, !0)
295
+ g(t.$slots, "default", I({ ref_for: !0 }, s), void 0, !0)
296
296
  ], 4))), 128))
297
297
  ]),
298
- n.flyweights.length ? m(t.$slots, "end", { key: 0 }, void 0, !0) : ut("", !0)
298
+ n.flyweights.length ? g(t.$slots, "end", { key: 0 }, void 0, !0) : ft("", !0)
299
299
  ], 38);
300
300
  }
301
- const Ht = /* @__PURE__ */ j(Mt, [["render", Et], ["__scopeId", "data-v-35b94e9b"]]);
301
+ const Wt = /* @__PURE__ */ j(Et, [["render", Lt], ["__scopeId", "data-v-35b94e9b"]]);
302
302
  function G(t, e) {
303
303
  return e && (t = t.replace(/[a-z]/g, "")), t.toLowerCase();
304
304
  }
305
- let ft = {
305
+ let gt = {
306
306
  close: {
307
307
  handler(t) {
308
308
  this.change(t);
@@ -315,7 +315,7 @@ let ft = {
315
315
  },
316
316
  deep: !0
317
317
  }
318
- }, Pt = [
318
+ }, Bt = [
319
319
  "BackGround",
320
320
  "BordeR",
321
321
  "Height",
@@ -324,17 +324,17 @@ let ft = {
324
324
  "Right",
325
325
  "Bottom",
326
326
  "Left"
327
- ], pt = {};
328
- H(
329
- Pt,
327
+ ], yt = {};
328
+ W(
329
+ Bt,
330
330
  (t, e, i) => {
331
- t = G(e), pt["--" + G(e, !0)] = t, i[t] = function() {
331
+ t = G(e), yt["--" + G(e, !0)] = t, i[t] = function() {
332
332
  this.trigger++;
333
333
  };
334
334
  },
335
- ft
335
+ gt
336
336
  );
337
- const Wt = {
337
+ const Ct = {
338
338
  name: "Card",
339
339
  // inheritAttrs: false,
340
340
  props: {
@@ -393,14 +393,14 @@ const Wt = {
393
393
  return this.tr();
394
394
  }
395
395
  },
396
- watch: ft,
396
+ watch: gt,
397
397
  methods: {
398
398
  exec: _,
399
- isEmpty: ot,
400
- isSimplyType: J,
399
+ isEmpty: at,
400
+ isSimplyType: K,
401
401
  tr() {
402
402
  let t = {};
403
- return this.margin(this.offset), H(pt, (e, i) => {
403
+ return this.margin(this.offset), W(yt, (e, i) => {
404
404
  this.css(t, e, i);
405
405
  }), t;
406
406
  },
@@ -410,16 +410,16 @@ const Wt = {
410
410
  !r || this.default[i] == r || (t[e] = _(r));
411
411
  },
412
412
  change(t) {
413
- J(t) || (this.closecss = O(
413
+ K(t) || (this.closecss = O(
414
414
  t,
415
415
  "color=>--s-card-close-color,size=>--s-close-width,bold=>--s-close-height,*"
416
416
  ));
417
417
  },
418
418
  margin(t) {
419
- B(
419
+ C(
420
420
  this,
421
421
  O(
422
- _t(t) ? t.split(/\s*(?:,|\s+)\s*/) : t,
422
+ xt(t) ? t.split(/\s*(?:,|\s+)\s*/) : t,
423
423
  "0=>top,1|0=>right,2|0=>bottom,3|1|0=>left",
424
424
  !0
425
425
  ),
@@ -430,42 +430,45 @@ const Wt = {
430
430
  mounted() {
431
431
  this.change(this.close);
432
432
  }
433
- }, At = { class: "card-title" }, Ct = ["title"], Rt = { class: "card-content" };
434
- function Bt(t, e, i, r, n, l) {
435
- return z(), M("div", {
433
+ }, Rt = { class: "card-title" }, At = ["title"], Ot = { class: "card-content" };
434
+ function Pt(t, e, i, r, n, l) {
435
+ return N(), M("div", {
436
436
  class: "card",
437
437
  key: n.trigger,
438
- style: I(l.isEmpty(l.style) ? l.tr() : l.style)
438
+ style: P(l.isEmpty(l.style) ? l.tr() : l.style)
439
439
  }, [
440
- m(t.$slots, "default", {}, () => [
441
- m(t.$slots, "title", {}, () => {
440
+ g(t.$slots, "default", {}, () => [
441
+ g(t.$slots, "title", {}, () => {
442
442
  var s;
443
443
  return [
444
- P("div", At, [
445
- dt(D(i.show || i.title) + " ", 1),
446
- P("div", {
447
- class: ht(["card-close", { hide: l.isSimplyType(i.close) ? !i.close : !1 }]),
448
- style: I(n.closecss),
444
+ B("div", Rt, [
445
+ pt(D(i.show || i.title) + " ", 1),
446
+ B("div", {
447
+ class: dt(["card-close", { hide: l.isSimplyType(i.close) ? !i.close : !1 }]),
448
+ style: P(n.closecss),
449
449
  onClick: e[0] || (e[0] = (h) => t.$emit("close")),
450
450
  title: (s = i.close) == null ? void 0 : s.tips
451
- }, null, 14, Ct)
451
+ }, null, 14, At)
452
452
  ])
453
453
  ];
454
454
  }, !0),
455
- m(t.$slots, "content", {}, () => [
456
- P("div", Rt, [
457
- m(t.$slots, "inner", {}, void 0, !0)
455
+ g(t.$slots, "content", {}, () => [
456
+ B("div", Ot, [
457
+ g(t.$slots, "inner", {}, void 0, !0)
458
458
  ])
459
459
  ], !0)
460
460
  ], !0)
461
461
  ], 4);
462
462
  }
463
- const Ot = /* @__PURE__ */ j(Wt, [["render", Bt], ["__scopeId", "data-v-2008eeb3"]]), It = {
463
+ const It = /* @__PURE__ */ j(Ct, [["render", Pt], ["__scopeId", "data-v-2008eeb3"]]), jt = {
464
464
  name: "Stream",
465
465
  computed: {
466
+ component() {
467
+ return this.$refs.component;
468
+ },
466
469
  column() {
467
470
  let { columns: t, T: e } = this, i = t || e;
468
- return ot(i) ? [] : nt(i) ? i : [i];
471
+ return at(i) ? [] : ht(i) ? i : [i];
469
472
  }
470
473
  },
471
474
  props: {
@@ -478,10 +481,6 @@ const Ot = /* @__PURE__ */ j(Wt, [["render", Bt], ["__scopeId", "data-v-2008eeb3
478
481
  type: String,
479
482
  default: "div"
480
483
  },
481
- data: {
482
- type: Array,
483
- default: () => []
484
- },
485
484
  columns: {
486
485
  type: [Object, Array],
487
486
  default: () => null
@@ -491,32 +490,35 @@ const Ot = /* @__PURE__ */ j(Wt, [["render", Bt], ["__scopeId", "data-v-2008eeb3
491
490
  default: () => null
492
491
  }
493
492
  },
493
+ mounted() {
494
+ this.$.vnode.ref && C(this, { ...this.component });
495
+ },
494
496
  methods: {
495
- trigger(t) {
497
+ __trigger(t) {
496
498
  let e = t[this.bridge] || t.type;
497
499
  return (this.$slots || this.$scopedSlots)[e] ? e : "default";
498
500
  }
499
501
  }
500
502
  };
501
- function jt(t, e, i, r, n, l) {
502
- return z(), xt(vt(i.type), St($t(t.$attrs)), {
503
- default: zt(() => [
504
- (z(!0), M(at, null, ct(l.column, (s) => m(t.$slots, l.trigger(s), U({
503
+ function Ft(t, e, i, r, n, l) {
504
+ return N(), St($t(i.type), I({ ref: "component" }, t.$attrs), {
505
+ default: Nt(() => [
506
+ (N(!0), M(ct, null, ut(l.column, (s) => g(t.$slots, l.__trigger(s), I({
505
507
  key: s.type
506
508
  }, { ref_for: !0 }, s))), 128))
507
509
  ]),
508
510
  _: 3
509
511
  }, 16);
510
512
  }
511
- const Ft = /* @__PURE__ */ j(It, [["render", jt]]), it = /(?:\,|\|{2})/, C = "px", st = "";
512
- let gt = document.documentElement, rt, lt = ["s-left", "s-top", "s-right", "s-bottom"], Dt = { left: 0, top: 1, right: 2, bottom: 3 };
513
- const V = [];
514
- var Gt = kt(
513
+ const Dt = /* @__PURE__ */ j(jt, [["render", Ft]]), st = /(?:\,|\|{2})/, rt = "px", lt = "";
514
+ let mt = document.documentElement, nt, ot = ["s-left", "s-top", "s-right", "s-bottom"], Gt = { left: 0, top: 1, right: 2, bottom: 3 };
515
+ const U = [];
516
+ var Ut = kt(
515
517
  window,
516
518
  "Reflect.defineProperty|Object.defineProperty=>Proxy"
517
519
  ).Proxy;
518
- let X = {}, yt = null;
519
- Gt(X, "delay", {
520
+ let V = {}, wt = null;
521
+ Ut(V, "delay", {
520
522
  /**
521
523
  * 获取延迟时间值
522
524
  * @returns {number} 返回当前实例的延迟时间属性值
@@ -525,77 +527,75 @@ Gt(X, "delay", {
525
527
  return this._delay;
526
528
  },
527
529
  set(t) {
528
- yt = Ut(() => {
529
- p(V);
530
+ wt = Vt(() => {
531
+ p(U);
530
532
  }, t), this._delay = t;
531
533
  }
532
534
  });
533
- X.delay = 60;
534
- function Ut(t, e) {
535
+ V.delay = 60;
536
+ function Vt(t, e) {
535
537
  let i = 0;
536
538
  return function() {
537
539
  const r = Date.now();
538
540
  r - i >= e && (i = r, p(t, this, arguments));
539
541
  };
540
542
  }
541
- const R = () => {
542
- yt();
543
+ const A = () => {
544
+ wt();
543
545
  };
544
- function Vt(t) {
545
- V.push(t);
546
+ function qt(t) {
547
+ U.push(t);
546
548
  }
547
- const E = new ResizeObserver(R);
548
- E.observe(gt);
549
- function mt(t) {
550
- t.onresize || (V.push([mt, null, t]), t.onresize = !0);
551
- var e = gt, i = e.clientHeight, r = t.offset || 15, n = t.target, l = t.room, s = t.index, h = t.position, o = n.getBoundingClientRect(), u = l.offsetHeight + r, c = l.offsetWidth + r, d = "3,0,2,1".split(it), f, a = (o.height == rt ? o.bottom - o.top : o.height) >> 0, x = (o.width == rt ? o.right - o.left : o.width) >> 0, v = e.clientWidth - c, L = i - u, S = [
549
+ const L = new ResizeObserver(A);
550
+ L.observe(mt);
551
+ function bt(t) {
552
+ t.onresize || (U.push([bt, null, t]), t.onresize = !0);
553
+ var e = mt, i = e.clientHeight, r = zt(t.offset) ? 15 : t.offset, n = t.target, l = t.room, s = t.index, h = t.position, o = n.getBoundingClientRect(), d = l.offsetHeight + r, c = l.offsetWidth + r, u = "3,0,2,1".split(st), f, a = (o.height == nt ? o.bottom - o.top : o.height) >> 0, v = (o.width == nt ? o.right - o.left : o.width) >> 0, x = e.clientWidth - c, E = i - d, S = [
552
554
  /* left: 0 */
553
555
  o.left - c,
554
556
  /* top: 1 */
555
- o.top - u,
557
+ o.top - d,
556
558
  /* right: 2 */
557
- v - o.right,
559
+ x - o.right,
558
560
  /* bottom: 3 */
559
- L - o.bottom
561
+ E - o.bottom
560
562
  ];
561
- h && (K(
562
- h.split(it),
563
- function(wt, A, F, bt) {
564
- bt.push(F[A]);
563
+ h && (Q(
564
+ h.split(st),
565
+ function(_t, R, F, vt) {
566
+ vt.push(F[R]);
565
567
  },
566
- Dt,
568
+ Gt,
567
569
  f = []
568
- ), d.unshift.apply(d, f)), s = K(
569
- d,
570
- function(wt, A, F) {
571
- if (F[A] > 0)
572
- return A;
570
+ ), u.unshift.apply(u, f)), s = Q(
571
+ u,
572
+ function(_t, R, F) {
573
+ if (F[R] > 0)
574
+ return R;
573
575
  },
574
576
  S
575
577
  );
576
- var g = 0, y = 0, $ = 0;
578
+ var y = 0, w = 0, b = 0;
577
579
  if (s != null) {
578
- var w = s == 0 || s == 2, k = s == 3 || s == 1;
579
- g = k ? Math.min(o.left, v) : s == 2 ? o.right + r : S[0], u -= r * +w;
580
- var N = Math.max(o.top, 0), b = Math.min(
580
+ var m = s == 0 || s == 2, z = s == 3 || s == 1;
581
+ y = z ? Math.min(o.left, x) : s == 2 ? o.right + r : S[0], d -= r * +m;
582
+ var k = Math.max(o.top, 0), $ = Math.min(
581
583
  o.bottom,
582
584
  i
583
- ), Y = (b - u + Math.min(i - u, N)) / 2;
584
- y = Math.max(
585
- w ? Y : s == 3 ? o.top + a + r : Math.min(Y, S[1]),
585
+ ), q = ($ - d + Math.min(i - d, k)) / 2;
586
+ w = Math.max(
587
+ m ? q : s == 3 ? o.top + a + r : Math.min(q, S[1]),
586
588
  0
587
- ), k && o.left > v && ($ = o.left - g - r + x / 2);
589
+ ), z && o.left > x && (b = o.left - y - r + v / 2);
588
590
  }
589
- let q = l.classList, W = t.css;
590
- q.remove(...lt), q.add(lt[s]), t.index = s, W.left = g + C, W.top = y + C, W["--tips-position-top"] = w ? Math.max(
591
- r,
592
- Math.min(
593
- /* 底边距 */
594
- (Math.min(y + u, b) + Math.max(y, N)) / 2 - y + r / 2,
595
- /* 容器高度 - offset / 2 */
596
- u - 0.5 * r
597
- )
598
- ) + C : st, W["--tips-position-left"] = $ ? Math.min($, c - 3 * r) + C : st;
591
+ let X = l.classList, H = t.css;
592
+ X.remove(...ot), X.add(ot[s]), t.index = s, H.left = y + rt, H.top = w + rt;
593
+ let Y = H["--tips-arrow-top"] = m ? Math.min(
594
+ /* 底边距 */
595
+ Math.max(w, k) - w,
596
+ d - r
597
+ ) : lt, J = c - 3 * r;
598
+ H["--tips-arrow"] = b > J - 10 || m && (Y + (d > 50 ? 15 : 0) > d || !Y) ? "hidden" : "visible", H["--tips-arrow-left"] = b ? Math.min(b, J) : lt;
599
599
  }
600
600
  const Xt = {
601
601
  name: "Tips",
@@ -653,6 +653,11 @@ const Xt = {
653
653
  delay: {
654
654
  type: [String, Number],
655
655
  default: 10
656
+ },
657
+ /* 显示箭头 */
658
+ borderRadius: {
659
+ type: [String, Number],
660
+ default: 10
656
661
  }
657
662
  },
658
663
  watch: {
@@ -683,7 +688,7 @@ const Xt = {
683
688
  },
684
689
  /* 初始化 */
685
690
  init() {
686
- this.$el.nodeName != "#comment" && mt({
691
+ this.$el.nodeName != "#comment" && bt({
687
692
  onresize: !1,
688
693
  /* 监控的目标 */
689
694
  target: this.$el.parentNode,
@@ -694,58 +699,60 @@ const Xt = {
694
699
  /* CSS样式集合 */
695
700
  css: this.css,
696
701
  /* 偏移量 */
697
- offset: +this.offset
702
+ offset: +this.offset >> 0
698
703
  });
699
704
  },
700
705
  scrollListener() {
701
706
  this.static || this.parent((t, e, i) => {
702
- e ? p(t.addEventListener, t, "scroll", R) : (p(E.observe, E, t), (t.offsetHeight < t.scrollHeight || t.offsetWidth < t.scrollWidth) && (i = this.attr(t, "-tips-scroll"), i || (p(t.addEventListener, t, "scroll", R), this.attr(t, "-tips-scroll", "true"))));
707
+ e ? p(t.addEventListener, t, "scroll", A) : (p(L.observe, L, t), (t.offsetHeight < t.scrollHeight || t.offsetWidth < t.scrollWidth) && (i = this.attr(t, "-tips-scroll"), i || (p(t.addEventListener, t, "scroll", A), this.attr(t, "-tips-scroll", "true"))));
703
708
  });
704
709
  }
705
710
  },
706
711
  mounted() {
707
- B(
712
+ C(
708
713
  this.css,
709
714
  O(
710
715
  this.$props,
711
- "color=>--tips-color,background=>--tips-background-color,border=>--tips-border-width,fontSize=>--tips-font-size"
716
+ "color=>--tips-color,background=>--tips-background-color,border=>--tips-border-width,fontSize=>--tips-font-size,borderRadius=>--tips-border-radius"
712
717
  )
713
- ), this.init(), X.delay = +this.delay, Vt((t) => {
718
+ ), this.css["--arrow-size"] = Math.sqrt(2 * Math.pow((this.border || 3) * 2 + 2, 2)) / 2 >> 0, this.init(), V.delay = +this.delay, qt((t) => {
714
719
  this.scrollListener();
715
720
  }), this.scrollListener();
716
721
  },
717
722
  unmounted() {
718
723
  this.parent(function(t, e) {
719
- p(t.removeEventListener, t, "scroll", R), p(t.removeAttribute, t, "-tips-scroll", void 0), e || p(E.unobserve, E, t);
724
+ p(t.removeEventListener, t, "scroll", A), p(t.removeAttribute, t, "-tips-scroll", void 0), e || p(L.unobserve, L, t);
720
725
  });
721
726
  }
722
- }, Yt = ["static"], qt = { class: "tips-title" };
723
- function Jt(t, e, i, r, n, l) {
724
- return i.visible ? (z(), M("div", U({
727
+ }, Yt = ["static"], Jt = { class: "tips-title" };
728
+ function Kt(t, e, i, r, n, l) {
729
+ return i.visible ? (N(), M("div", I({
725
730
  key: 0,
726
731
  class: "tips",
727
732
  style: i.static ? null : n.css,
728
733
  static: i.static ? "" : null
729
734
  }, t.$attrs), [
730
- m(t.$slots, "title", {}, () => [
731
- P("div", qt, D(i.title), 1)
732
- ], !0),
733
- m(t.$slots, "content", {}, () => [
734
- dt(D(i.content), 1)
735
+ g(t.$slots, "default", {}, () => [
736
+ g(t.$slots, "title", {}, () => [
737
+ B("div", Jt, D(i.title), 1)
738
+ ], !0),
739
+ g(t.$slots, "content", {}, () => [
740
+ pt(D(i.content), 1)
741
+ ], !0)
735
742
  ], !0)
736
- ], 16, Yt)) : ut("", !0);
743
+ ], 16, Yt)) : ft("", !0);
737
744
  }
738
- const Kt = /* @__PURE__ */ j(Xt, [["render", Jt], ["__scopeId", "data-v-b1c3381c"]]), Qt = [Ht, Ot, Ft, Kt], se = {
745
+ const Qt = /* @__PURE__ */ j(Xt, [["render", Kt], ["__scopeId", "data-v-8c83dee3"]]), Zt = [Wt, It, Dt, Qt], re = {
739
746
  install(t) {
740
- Qt.forEach((e) => {
747
+ Zt.forEach((e) => {
741
748
  t.component("S" + e.name, e), t.component(e.name + "S", e);
742
749
  });
743
750
  }
744
751
  };
745
752
  export {
746
- Ot as Card,
747
- Ht as Flyweight,
748
- Ft as Stream,
749
- Kt as Tips,
750
- se as default
753
+ It as Card,
754
+ Wt as Flyweight,
755
+ Dt as Stream,
756
+ Qt as Tips,
757
+ re as default
751
758
  };
package/README.md CHANGED
@@ -6,6 +6,26 @@
6
6
 
7
7
  [![安装](https://img.shields.io/badge/-@soei-ae8aff?style=flat-square)![NPM Downloads by package author](https://img.shields.io/npm-stat/dw/soeiz?style=flat-square)](https://npmjs.com/package/@soei/flyweight)
8
8
 
9
+ ```html
10
+ <!-- 版本 0.3.12 优化 和 部分代码优化-->
11
+ <Card [space|space="around|evenly"|nothing]
12
+ ...
13
+ />
14
+ ```
15
+
16
+ ```html
17
+ <!-- 版本 0.3.11 新增属Tips -->
18
+ <!-- arrow: 显示箭头 -->
19
+ <!-- [notice|warn|simply]: 内置样式, 不喜欢可以background="..." color="..." -->
20
+ <Tips
21
+ class="notice|warn|simply|arrow|animate"
22
+ ...
23
+ />
24
+ <Tips >
25
+ .....
26
+ </Tips>
27
+ ```
28
+
9
29
  ```html
10
30
  <!-- 版本 0.3.9 新增属Tips -->
11
31
  <Tips