@opentiny/tiny-robot 0.2.12 → 0.2.14

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.
@@ -1,18 +1,42 @@
1
- import { computed as a, defineComponent as j, useSlots as F, Fragment as x, ref as R, watch as E, nextTick as U, createElementBlock as S, openBlock as d, createVNode as W, renderList as Z, createBlock as V, resolveDynamicComponent as q, mergeProps as k, Transition as J, normalizeProps as K, guardReactiveProps as Q, withCtx as X, createCommentVNode as Y, Teleport as ee, unref as te, createElementVNode as oe, renderSlot as re } from "vue";
2
- import { d as ne, e as se, b as ae } from "../index2.js";
3
- import { t as l } from "../utils.js";
4
- import { _ as ie } from "../_plugin-vue_export-helper.js";
5
- function le(m, w) {
6
- return a(() => {
7
- var c;
8
- const o = ne(m), i = (c = o == null ? void 0 : o.getRootNode) == null ? void 0 : c.call(o);
9
- return i instanceof ShadowRoot ? i : document.body;
1
+ import { computed as u, Fragment as R, ref as N, watch as k, defineComponent as j, useSlots as G, createElementBlock as E, openBlock as y, createVNode as I, renderList as F, unref as b, createBlock as S, resolveDynamicComponent as U, mergeProps as B, isVNode as W, Transition as Z, normalizeProps as q, guardReactiveProps as J, withCtx as K, createCommentVNode as Q, Teleport as X, createElementVNode as Y, renderSlot as ee } from "vue";
2
+ import { d as te, e as oe, b as re } from "../index2.js";
3
+ import { t as m } from "../utils.js";
4
+ import { _ as ne } from "../_plugin-vue_export-helper.js";
5
+ function se(f, g) {
6
+ const t = u(() => {
7
+ const e = (f == null ? void 0 : f()) || [], a = e.find((d) => d.type === R);
8
+ return a && Array.isArray(a.children) ? a.children : e;
9
+ }), p = u(() => g ? t.value.length : 1), v = u(() => t.value.slice(0, p.value)), c = N([]), s = (e) => e && typeof e == "object" && "$el" in e || e instanceof HTMLElement || e instanceof SVGElement ? e : (console.warn("el must be an HTMLElement or SVGElement or Vue component instance. el:", e), null), x = (e) => {
10
+ c.value[0] = s(e);
11
+ }, A = (e, a) => {
12
+ c.value[a] = s(e);
13
+ };
14
+ return k(
15
+ p,
16
+ (e) => {
17
+ c.value.length = e;
18
+ },
19
+ { flush: "post" }
20
+ ), {
21
+ vnodes: v,
22
+ ref: u(() => c.value.at(0)),
23
+ refs: c,
24
+ setRef: x,
25
+ setRefs: A
26
+ };
27
+ }
28
+ function ae(f, g) {
29
+ return u(() => {
30
+ var s;
31
+ const t = te(f), p = (s = t == null ? void 0 : t.getRootNode) == null ? void 0 : s.call(t);
32
+ return p instanceof ShadowRoot ? p : document.body;
10
33
  });
11
34
  }
12
- const ce = /* @__PURE__ */ j({
35
+ const le = /* @__PURE__ */ j({
13
36
  inheritAttrs: !1,
14
37
  __name: "index",
15
38
  props: {
39
+ appendTo: {},
16
40
  offset: {},
17
41
  placement: { default: "top-center" },
18
42
  preventOverflow: { type: Boolean },
@@ -21,87 +45,78 @@ const ce = /* @__PURE__ */ j({
21
45
  transitionProps: {},
22
46
  triggerEvents: {}
23
47
  },
24
- setup(m, { expose: w }) {
25
- const o = m, i = F(), v = a(() => {
26
- var r;
27
- const e = (r = i.trigger) == null ? void 0 : r.call(i), t = e ? Array.isArray(e) ? e : [e] : [];
28
- return t[0].type === x && Array.isArray(t[0].children) ? t[0].children : t;
29
- }), g = a(() => o.renderAllTriggers ? v.value.length : 1), c = a(() => v.value.slice(0, g.value)), p = R([]), h = a(() => p.value.at(0)), B = (e) => e != null && e.$el || e instanceof HTMLElement || e instanceof SVGElement ? e : (console.warn("trigger must be an HTMLElement or SVGElement or Vue component instance"), null), $ = (e, t) => {
30
- p.value[t] = B(e);
31
- };
32
- E(
33
- g,
34
- (e) => {
35
- p.value.length = e;
36
- },
37
- { flush: "post" }
38
- );
39
- function N(e = {}, t) {
40
- const r = {};
41
- for (const [n, s] of Object.entries(e))
42
- /^on[A-Z]/.test(n) && typeof s == "function" && (r[n] = (...f) => s(...f, t));
43
- return r;
48
+ setup(f, { expose: g }) {
49
+ const t = f, p = G(), {
50
+ vnodes: v,
51
+ refs: c,
52
+ ref: s,
53
+ setRefs: x
54
+ } = se(p.trigger, t.renderAllTriggers);
55
+ function A(o = {}, l) {
56
+ const n = {};
57
+ for (const [r, i] of Object.entries(o))
58
+ /^on[A-Z]/.test(r) && typeof i == "function" && (n[r] = (...h) => i(...h, l));
59
+ return n;
44
60
  }
45
- const P = a(
46
- () => c.value.map((e, t) => N(o.triggerEvents, t))
47
- ), y = R(null), u = a(() => {
48
- var e, t;
49
- return typeof o.offset == "number" ? { mainAxis: o.offset, crossAxis: 0 } : {
50
- mainAxis: ((e = o.offset) == null ? void 0 : e.mainAxis) ?? 0,
51
- crossAxis: ((t = o.offset) == null ? void 0 : t.crossAxis) ?? 0
61
+ const e = u(
62
+ () => v.value.map((o, l) => A(t.triggerEvents, l))
63
+ ), a = N(null), d = u(() => {
64
+ var o, l;
65
+ return typeof t.offset == "number" ? { mainAxis: t.offset, crossAxis: 0 } : {
66
+ mainAxis: ((o = t.offset) == null ? void 0 : o.mainAxis) ?? 0,
67
+ crossAxis: ((l = t.offset) == null ? void 0 : l.crossAxis) ?? 0
52
68
  };
53
- }), { top: O, bottom: C, left: b, right: H, width: L, update: M } = se(h), { width: T, height: A } = ae(y, void 0, { box: "border-box" }), z = a(() => {
54
- const { placement: e, preventOverflow: t } = o, r = {}, n = (s, f) => {
55
- if (!t) {
56
- r[s] = f;
69
+ }), { top: $, bottom: P, left: T, right: O, width: C, update: H } = oe(s), { width: _, height: w } = re(a, void 0, { box: "border-box" }), M = u(() => {
70
+ const { placement: o, preventOverflow: l } = t, n = {}, r = (i, h) => {
71
+ if (!l) {
72
+ n[i] = h;
57
73
  return;
58
74
  }
59
- const _ = s === "top" || s === "bottom", G = _ ? "100dvh" : "100dvw", I = l(_ ? A.value : T.value);
60
- r[s] = `clamp(0px, ${f}, calc(${G} - ${I}))`;
75
+ const V = i === "top" || i === "bottom", D = V ? "100dvh" : "100dvw", L = m(V ? w.value : _.value);
76
+ n[i] = `clamp(0px, ${h}, calc(${D} - ${L}))`;
61
77
  };
62
- return e.includes("top") && n("top", l(O.value - A.value - u.value.mainAxis)), e.includes("bottom") && n("bottom", `calc(100% - ${l(C.value + A.value + u.value.mainAxis)})`), e.includes("left") && n("left", l(b.value + u.value.crossAxis)), e.includes("right") && n("right", `calc(100% - ${l(H.value + u.value.crossAxis)})`), e.includes("center") && n("left", l(b.value + L.value / 2 - T.value / 2 + u.value.crossAxis)), r;
78
+ return o.includes("top") && r("top", m($.value - w.value - d.value.mainAxis)), o.includes("bottom") && r("bottom", `calc(100% - ${m(P.value + w.value + d.value.mainAxis)})`), o.includes("left") && r("left", m(T.value + d.value.crossAxis)), o.includes("right") && r("right", `calc(100% - ${m(O.value + d.value.crossAxis)})`), o.includes("center") && r("left", m(T.value + C.value / 2 - _.value / 2 + d.value.crossAxis)), n;
63
79
  });
64
- E(
65
- () => o.show,
66
- (e) => {
67
- e && U(() => {
68
- M();
69
- });
70
- }
80
+ k(
81
+ () => t.show,
82
+ (o) => {
83
+ o && H();
84
+ },
85
+ { flush: "post" }
71
86
  );
72
- const D = le(h);
73
- return w({
74
- triggerRef: h,
75
- triggerRefs: p,
76
- popperRef: y
77
- }), (e, t) => (d(), S(x, null, [
78
- (d(!0), S(x, null, Z(c.value, (r, n) => (d(), V(q(r), k({
79
- key: r.key ?? n,
87
+ const z = ae(s);
88
+ return g({
89
+ triggerRef: s,
90
+ triggerRefs: c,
91
+ popperRef: a
92
+ }), (o, l) => (y(), E(R, null, [
93
+ (y(!0), E(R, null, F(b(v), (n, r) => (y(), S(U(n), B({
94
+ key: W(n) ? n.key : r,
80
95
  ref_for: !0,
81
- ref: (s) => $(s, n)
82
- }, { ref_for: !0 }, P.value[n]), null, 16))), 128)),
83
- W(J, K(Q(e.transitionProps)), {
84
- default: X(() => [
85
- e.show ? (d(), V(ee, {
96
+ ref: (i) => b(x)(i, r)
97
+ }, { ref_for: !0 }, e.value[r]), null, 16))), 128)),
98
+ I(Z, q(J(o.transitionProps)), {
99
+ default: K(() => [
100
+ o.show ? (y(), S(X, {
86
101
  key: 0,
87
- to: te(D)
102
+ to: t.appendTo || b(z)
88
103
  }, [
89
- oe("div", k({
104
+ Y("div", B({
90
105
  class: "tr-base-popper",
91
106
  ref_key: "popperRef",
92
- ref: y,
93
- style: z.value
94
- }, e.$attrs), [
95
- re(e.$slots, "content", {}, void 0, !0)
107
+ ref: a,
108
+ style: M.value
109
+ }, o.$attrs), [
110
+ ee(o.$slots, "content", {}, void 0, !0)
96
111
  ], 16)
97
- ], 8, ["to"])) : Y("", !0)
112
+ ], 8, ["to"])) : Q("", !0)
98
113
  ]),
99
114
  _: 3
100
115
  }, 16)
101
116
  ], 64));
102
117
  }
103
- }), ue = /* @__PURE__ */ ie(ce, [["__scopeId", "data-v-21605fe2"]]);
104
- ue.name = "TrBasePopper";
118
+ }), ie = /* @__PURE__ */ ne(le, [["__scopeId", "data-v-335d147d"]]);
119
+ ie.name = "TrBasePopper";
105
120
  export {
106
- ue as default
121
+ ie as default
107
122
  };
@@ -1,45 +1,46 @@
1
- import { defineComponent as C, ref as g, computed as n, watch as R, createBlock as E, openBlock as a, unref as x, withCtx as v, createElementVNode as B, createElementBlock as _, Fragment as D, renderList as M, toDisplayString as H, renderSlot as L } from "vue";
2
- import { o as P, c as k, d as T } from "../index2.js";
1
+ import { defineComponent as C, ref as g, computed as n, watch as R, createBlock as E, openBlock as a, unref as x, withCtx as v, createElementVNode as B, createElementBlock as _, Fragment as T, renderList as D, toDisplayString as M, renderSlot as H } from "vue";
2
+ import { o as L, c as k, d as P } from "../index2.js";
3
3
  import b from "../base-popper/index.js";
4
4
  import { _ as I } from "../_plugin-vue_export-helper.js";
5
5
  const S = { class: "tr-dropdown-menu__list" }, $ = ["onClick"], F = /* @__PURE__ */ C({
6
6
  __name: "index",
7
7
  props: {
8
+ appendTo: {},
8
9
  items: {},
9
10
  show: { type: Boolean },
10
11
  trigger: { default: "click" }
11
12
  },
12
13
  emits: ["item-click", "click-outside"],
13
14
  setup(l, { emit: w }) {
14
- const t = l, c = w, u = g(!1), r = n({
15
- get: () => t.trigger === "manual" ? t.show : u.value,
15
+ const t = l, c = w, p = g(!1), r = n({
16
+ get: () => t.trigger === "manual" ? t.show : p.value,
16
17
  set: (e) => {
17
- t.trigger !== "manual" && (u.value = e);
18
+ t.trigger !== "manual" && (p.value = e);
18
19
  }
19
- }), i = g(null), d = n(() => {
20
+ }), i = g(null), u = n(() => {
20
21
  var e;
21
22
  return (e = i.value) == null ? void 0 : e.triggerRef;
22
- }), p = n(() => {
23
+ }), d = n(() => {
23
24
  var e;
24
25
  return (e = i.value) == null ? void 0 : e.popperRef;
25
26
  });
26
27
  if (t.trigger === "click" || t.trigger === "manual")
27
- P(
28
- p,
28
+ L(
29
+ d,
29
30
  (e) => {
30
31
  c("click-outside", e), r.value = !1;
31
32
  },
32
- { ignore: [d] }
33
+ { ignore: [u] }
33
34
  );
34
35
  else if (t.trigger === "hover") {
35
36
  const e = k(
36
- n(() => T(d.value)),
37
+ n(() => P(u.value)),
37
38
  { delayEnter: 100, delayLeave: 300 }
38
- ), f = k(p, { delayEnter: 100, delayLeave: 300 });
39
+ ), m = k(d, { delayEnter: 100, delayLeave: 300 });
39
40
  R(
40
- () => [e.value, f.value],
41
- ([o, m]) => {
42
- r.value = o || m;
41
+ () => [e.value, m.value],
42
+ ([o, f]) => {
43
+ r.value = o || f;
43
44
  }
44
45
  );
45
46
  }
@@ -48,33 +49,34 @@ const S = { class: "tr-dropdown-menu__list" }, $ = ["onClick"], F = /* @__PURE__
48
49
  }, y = (e) => {
49
50
  r.value = !1, c("item-click", e);
50
51
  };
51
- return (e, f) => (a(), E(x(b), {
52
+ return (e, m) => (a(), E(x(b), {
52
53
  show: r.value,
53
54
  class: "tr-dropdown-menu",
54
55
  ref_key: "basePopperRef",
55
56
  ref: i,
56
57
  placement: "top-left",
58
+ "append-to": t.appendTo,
57
59
  offset: 8,
58
60
  "transition-props": { name: "tr-dropdown-menu" },
59
61
  "prevent-overflow": !0,
60
62
  "trigger-events": { onClick: h }
61
63
  }, {
62
64
  trigger: v(() => [
63
- L(e.$slots, "trigger", {}, void 0, !0)
65
+ H(e.$slots, "trigger", {}, void 0, !0)
64
66
  ]),
65
67
  content: v(() => [
66
68
  B("ul", S, [
67
- (a(!0), _(D, null, M(t.items, (o) => (a(), _("li", {
69
+ (a(!0), _(T, null, D(t.items, (o) => (a(), _("li", {
68
70
  class: "tr-dropdown-menu__list-item",
69
71
  key: o.id,
70
- onClick: (m) => y(o)
71
- }, H(o.text), 9, $))), 128))
72
+ onClick: (f) => y(o)
73
+ }, M(o.text), 9, $))), 128))
72
74
  ])
73
75
  ]),
74
76
  _: 3
75
- }, 8, ["show", "trigger-events"]));
77
+ }, 8, ["show", "append-to", "trigger-events"]));
76
78
  }
77
- }), s = /* @__PURE__ */ I(F, [["__scopeId", "data-v-f8df9a66"]]);
79
+ }), s = /* @__PURE__ */ I(F, [["__scopeId", "data-v-ea33ed82"]]);
78
80
  s.name = "TrDropdownMenu";
79
81
  const N = function(l) {
80
82
  l.component(s.name, s);