@opentiny/tiny-robot 0.3.0-alpha.4 → 0.3.0-alpha.5

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,41 +1,103 @@
1
- import { defineComponent as q, useSlots as J, computed as a, createElementBlock as m, openBlock as r, normalizeClass as y, renderSlot as H, createBlock as x, resolveDynamicComponent as R, createCommentVNode as S, toDisplayString as oe, mergeModels as O, useModel as ne, ref as d, watch as F, nextTick as N, createElementVNode as $, Fragment as D, renderList as z, isVNode as G, createVNode as K, Transition as le, withCtx as se, unref as re } from "vue";
2
- import { K as ae } from "../tiny-robot-svgs.js";
3
- import { c as ie, d as j, w as ce, o as ue, e as fe } from "../index2.js";
4
- import { u as de } from "../useSlotRefs.js";
5
- import { _ as Q } from "../_plugin-vue_export-helper.js";
6
- const me = { key: 0 }, pe = /* @__PURE__ */ q({
1
+ import { defineComponent as H, useSlots as Z, computed as w, createElementBlock as k, openBlock as u, normalizeClass as P, renderSlot as b, createBlock as h, resolveDynamicComponent as j, createCommentVNode as R, toDisplayString as x, unref as _, mergeProps as E, createSlots as ee, withCtx as A, createVNode as W, renderList as $, normalizeStyle as te, mergeModels as F, useModel as oe, ref as S, watch as G, nextTick as V, createElementVNode as z, Fragment as N, Transition as ne } from "vue";
2
+ import { K as le } from "../tiny-robot-svgs.js";
3
+ import { b as se, w as ie, o as re } from "../index2.js";
4
+ import ae from "../dropdown-menu/index.js";
5
+ import ue from "../suggestion-popover/index.js";
6
+ import { _ as q } from "../_plugin-vue_export-helper.js";
7
+ const ce = { key: 0 }, me = /* @__PURE__ */ H({
7
8
  __name: "PillButton",
8
9
  props: {
9
10
  item: {}
10
11
  },
11
- setup(i) {
12
- const h = i, _ = J(), p = a(() => {
13
- var t;
14
- return !!(_.icon || (t = h.item) != null && t.icon);
15
- }), k = a(() => {
16
- var t;
17
- return !!(_.default || (t = h.item) != null && t.text);
18
- }), I = a(() => p.value && !k.value);
19
- return (t, u) => (r(), m("button", {
20
- class: y(["tr-suggestion-pills__item", { "only-icon": I.value }])
12
+ setup(p) {
13
+ const y = p, n = Z(), t = w(() => {
14
+ var o;
15
+ return !!(n.icon || (o = y.item) != null && o.icon);
16
+ }), l = w(() => {
17
+ var o;
18
+ return !!(n.default || (o = y.item) != null && o.text);
19
+ }), v = w(() => t.value && !l.value);
20
+ return (o, C) => (u(), k("button", {
21
+ class: P(["tr-suggestion-pills__item", { "only-icon": v.value }])
21
22
  }, [
22
- H(t.$slots, "icon", {}, () => {
23
+ b(o.$slots, "icon", {}, () => {
23
24
  var c;
24
25
  return [
25
- (r(), x(R((c = t.item) == null ? void 0 : c.icon), { class: "tr-suggestion-pills__item_icon" }))
26
+ (u(), h(j((c = o.item) == null ? void 0 : c.icon), { class: "tr-suggestion-pills__item_icon" }))
26
27
  ];
27
28
  }, !0),
28
- H(t.$slots, "default", {}, () => {
29
+ b(o.$slots, "default", {}, () => {
29
30
  var c;
30
31
  return [
31
- (c = t.item) != null && c.text ? (r(), m("span", me, oe(t.item.text), 1)) : S("", !0)
32
+ (c = o.item) != null && c.text ? (u(), k("span", ce, x(o.item.text), 1)) : R("", !0)
32
33
  ];
33
34
  }, !0)
34
35
  ], 2));
35
36
  }
36
- }), g = /* @__PURE__ */ Q(pe, [["__scopeId", "data-v-5c433c31"]]), ve = { class: "tr-suggestion-pills__more-wrapper" }, ge = /* @__PURE__ */ q({
37
+ }), f = /* @__PURE__ */ q(me, [["__scopeId", "data-v-5c433c31"]]), K = /* @__PURE__ */ H({
38
+ __name: "PillButtonWrapper",
39
+ props: {
40
+ item: {},
41
+ style: {}
42
+ },
43
+ emits: ["click", "mouseenter"],
44
+ setup(p, { emit: y }) {
45
+ const n = y;
46
+ return (t, l) => {
47
+ var v, o, C, c, B, g, d, M, I;
48
+ return ((v = t.item.action) == null ? void 0 : v.type) === "popover" ? (u(), h(_(ue), E({
49
+ key: 0,
50
+ style: t.style
51
+ }, t.item.action.props, {
52
+ onItemClick: (o = t.item.action.events) == null ? void 0 : o.itemClick,
53
+ onGroupClick: (C = t.item.action.events) == null ? void 0 : C.groupClick,
54
+ onOpen: (c = t.item.action.events) == null ? void 0 : c.open,
55
+ onClose: (B = t.item.action.events) == null ? void 0 : B.close,
56
+ onClickOutside: (g = t.item.action.events) == null ? void 0 : g.clickOutside
57
+ }), ee({
58
+ default: A(() => [
59
+ W(f, {
60
+ item: t.item,
61
+ onClick: l[0] || (l[0] = (r) => n("click", r)),
62
+ onMouseenter: l[1] || (l[1] = (r) => n("mouseenter", r))
63
+ }, null, 8, ["item"])
64
+ ]),
65
+ _: 2
66
+ }, [
67
+ $(t.item.action.slots, (r, O) => ({
68
+ name: O,
69
+ fn: A(() => [
70
+ (u(), h(j(r)))
71
+ ])
72
+ }))
73
+ ]), 1040, ["style", "onItemClick", "onGroupClick", "onOpen", "onClose", "onClickOutside"])) : ((d = t.item.action) == null ? void 0 : d.type) === "menu" ? (u(), h(_(ae), E({
74
+ key: 1,
75
+ style: t.style
76
+ }, t.item.action.props, {
77
+ onItemClick: (M = t.item.action.events) == null ? void 0 : M.itemClick,
78
+ onClickOutside: (I = t.item.action.events) == null ? void 0 : I.clickOutside
79
+ }), {
80
+ trigger: A(() => [
81
+ W(f, {
82
+ item: t.item,
83
+ onClick: l[2] || (l[2] = (r) => n("click", r)),
84
+ onMouseenter: l[3] || (l[3] = (r) => n("mouseenter", r))
85
+ }, null, 8, ["item"])
86
+ ]),
87
+ _: 1
88
+ }, 16, ["style", "onItemClick", "onClickOutside"])) : (u(), h(f, {
89
+ key: 2,
90
+ item: t.item,
91
+ style: te(t.style),
92
+ onClick: l[4] || (l[4] = (r) => n("click", r)),
93
+ onMouseenter: l[5] || (l[5] = (r) => n("mouseenter", r))
94
+ }, null, 8, ["item", "style"]));
95
+ };
96
+ }
97
+ }), pe = { class: "tr-suggestion-pills__more-wrapper" }, de = /* @__PURE__ */ H({
37
98
  __name: "index",
38
- props: /* @__PURE__ */ O({
99
+ props: /* @__PURE__ */ F({
100
+ items: {},
39
101
  showAll: { type: Boolean },
40
102
  showAllButtonOn: { default: "hover" },
41
103
  overflowMode: { default: "expand" },
@@ -44,125 +106,146 @@ const me = { key: 0 }, pe = /* @__PURE__ */ q({
44
106
  showAll: { type: Boolean, default: !1 },
45
107
  showAllModifiers: {}
46
108
  }),
47
- emits: /* @__PURE__ */ O(["click-outside"], ["update:showAll"]),
48
- setup(i, { expose: h, emit: _ }) {
49
- const p = i, k = J(), I = _, { vnodes: t } = de(k.default, !0), u = ne(i, "showAll"), c = d(null), f = d(null), b = d(null), { width: M } = ie(f), A = d(0), B = a(() => p.overflowMode === "expand" && M.value < A.value), v = d(-1), U = a(() => B.value && u.value ? t.value.slice(0, v.value) : t.value), W = a(() => B.value && u.value ? t.value.slice(v.value).map((e, o) => ({
50
- vnode: e,
51
- index: o + v.value
52
- })) : []), C = d([]), T = d([]), E = a(() => C.value.map((e) => j(e)).filter((e) => e instanceof Element)), X = a(() => T.value.map((e) => j(e)).filter((e) => e instanceof Element)), P = () => {
53
- const e = f.value, o = b.value;
54
- return Array.from((e == null ? void 0 : e.children) || []).concat(Array.from((o == null ? void 0 : o.children) || []));
55
- }, V = () => {
56
- N(() => {
57
- const e = f.value;
109
+ emits: /* @__PURE__ */ F(["item-click", "click-outside"], ["update:showAll"]),
110
+ setup(p, { emit: y }) {
111
+ const n = p, t = y, l = oe(p, "showAll"), v = S(null), o = S(null), C = S(null), { width: c } = se(o), B = S(0), g = w(() => n.overflowMode === "expand" && c.value < B.value), d = S(-1), M = w(() => {
112
+ var e;
113
+ return g.value && l.value ? ((e = n.items) == null ? void 0 : e.slice(0, d.value)) || [] : n.items || [];
114
+ }), I = w(() => {
115
+ var e;
116
+ return g.value && l.value ? ((e = n.items) == null ? void 0 : e.slice(d.value)) || [] : [];
117
+ }), r = () => {
118
+ const e = o.value, s = C.value;
119
+ return Array.from((e == null ? void 0 : e.children) || []).concat(Array.from((s == null ? void 0 : s.children) || []));
120
+ }, O = () => {
121
+ V(() => {
122
+ const e = o.value;
58
123
  if (!e)
59
124
  return;
60
- const o = P(), n = parseFloat(getComputedStyle(e).rowGap) || 0;
61
- v.value = -1;
62
- let l = 0;
63
- for (let s = 0; s < o.length; s++)
64
- if (l += o[s].offsetWidth, s > 0 && (l += n), l > e.clientWidth) {
65
- v.value = s;
125
+ const s = r(), i = parseFloat(getComputedStyle(e).rowGap) || 0;
126
+ let m = 0;
127
+ for (let a = 0; a < s.length; a++) {
128
+ if (m += s[a].offsetWidth, a > 0 && (m += i), m > e.clientWidth) {
129
+ d.value = a;
66
130
  break;
67
131
  }
132
+ a === s.length - 1 && (d.value = -1);
133
+ }
68
134
  });
69
135
  };
70
- F(
71
- t,
136
+ G(
137
+ () => {
138
+ var e;
139
+ return [n.items, (e = n.items) == null ? void 0 : e.length];
140
+ },
72
141
  () => {
73
- N(() => {
74
- if (!f.value)
142
+ V(() => {
143
+ if (!o.value)
75
144
  return;
76
- const e = P(), o = parseFloat(getComputedStyle(f.value).rowGap) || 0;
77
- A.value = e.reduce((n, l, s) => n + l.offsetWidth + (s > 0 ? o : 0), 0);
145
+ const e = r(), s = parseFloat(getComputedStyle(o.value).rowGap) || 0;
146
+ B.value = e.reduce((i, m, a) => i + m.offsetWidth + (a > 0 ? s : 0), 0);
78
147
  });
79
148
  },
80
149
  { immediate: !0 }
81
- ), F(t, V), ce(M, V, { debounce: 100 });
82
- const Y = () => {
83
- u.value = !u.value;
150
+ ), G(() => {
151
+ var e;
152
+ return [n.items, (e = n.items) == null ? void 0 : e.length];
153
+ }, O), ie(
154
+ c,
155
+ (e) => {
156
+ e > 0 && O();
157
+ },
158
+ { debounce: 100 }
159
+ );
160
+ const J = (e, s, i) => {
161
+ if (g.value && i >= d.value) {
162
+ e.stopPropagation(), L();
163
+ return;
164
+ }
165
+ t("item-click", s);
166
+ }, L = () => {
167
+ l.value = !l.value;
84
168
  };
85
- ue(c, (e) => {
86
- u.value && I("click-outside", e);
169
+ re(v, (e) => {
170
+ l.value && t("click-outside", e);
87
171
  });
88
- const Z = (e) => {
89
- const o = f.value;
90
- if (!o)
172
+ const Q = (e) => {
173
+ const s = o.value;
174
+ if (!s)
91
175
  return;
92
- const n = e.offsetLeft, l = n + e.offsetWidth, s = o.scrollLeft, L = o.clientWidth, ee = n < s, te = l > s + L;
93
- ee ? o.scrollTo({
94
- left: n,
176
+ const i = e.offsetLeft, m = i + e.offsetWidth, a = s.scrollLeft, D = s.clientWidth, X = i < a, Y = m > a + D;
177
+ X ? s.scrollTo({
178
+ left: i,
95
179
  behavior: "smooth"
96
- }) : te && o.scrollTo({
97
- left: l - L,
180
+ }) : Y && s.scrollTo({
181
+ left: m - D,
98
182
  behavior: "smooth"
99
183
  });
184
+ }, U = (e) => {
185
+ n.autoScrollOnHover && e.currentTarget && Q(e.currentTarget);
100
186
  };
101
- return fe(E, "mouseenter", (e) => {
102
- p.autoScrollOnHover && e.currentTarget && Z(e.currentTarget);
103
- }), h({
104
- children: a(() => E.value.concat(X.value))
105
- }), (e, o) => (r(), m("div", {
187
+ return (e, s) => (u(), k("div", {
106
188
  class: "tr-suggestion-pills__wrapper",
107
189
  ref_key: "containerWrapperRef",
108
- ref: c
190
+ ref: v
109
191
  }, [
110
- $("div", {
111
- class: y(["tr-suggestion-pills__container", { "overflow-scroll": p.overflowMode === "scroll" }]),
192
+ z("div", {
193
+ class: P(["tr-suggestion-pills__container", { "overflow-scroll": n.overflowMode === "scroll" }]),
112
194
  ref_key: "containerRef",
113
- ref: f
195
+ ref: o
114
196
  }, [
115
- (r(!0), m(D, null, z(U.value, (n, l) => (r(), x(R(n), {
116
- key: G(n) ? n.key : l,
117
- ref_for: !0,
118
- ref_key: "staticMaybeItemRefs",
119
- ref: C
120
- }))), 128))
197
+ b(e.$slots, "default", {}, () => [
198
+ (u(!0), k(N, null, $(M.value, (i, m) => (u(), h(_(K), {
199
+ key: i.id,
200
+ item: i,
201
+ onClick: (a) => J(a, i, m),
202
+ onMouseenter: s[0] || (s[0] = (a) => U(a))
203
+ }, null, 8, ["item", "onClick"]))), 128))
204
+ ], !0)
121
205
  ], 2),
122
- $("div", ve, [
123
- K(le, { name: "tr-suggestion-pills__more" }, {
124
- default: se(() => [
125
- W.value.length ? (r(), m("div", {
206
+ z("div", pe, [
207
+ W(ne, { name: "tr-suggestion-pills__more" }, {
208
+ default: A(() => [
209
+ I.value.length ? (u(), k("div", {
126
210
  key: 0,
127
211
  class: "tr-suggestion-pills__more",
128
212
  ref_key: "floatingItemsRef",
129
- ref: b
213
+ ref: C
130
214
  }, [
131
- (r(!0), m(D, null, z(W.value, ({ vnode: n, index: l }) => (r(), x(R(n), {
132
- key: G(n) ? n.key : l,
133
- ref_for: !0,
134
- ref_key: "floatingMaybeItemRefs",
135
- ref: T
136
- }))), 128))
137
- ], 512)) : S("", !0)
215
+ (u(!0), k(N, null, $(I.value, (i) => (u(), h(_(K), {
216
+ key: i.id,
217
+ item: i,
218
+ onClick: (m) => t("item-click", i)
219
+ }, null, 8, ["item", "onClick"]))), 128))
220
+ ], 512)) : R("", !0)
138
221
  ]),
139
222
  _: 1
140
223
  })
141
224
  ]),
142
- B.value ? (r(), m("button", {
225
+ g.value ? (u(), k("button", {
143
226
  key: 0,
144
- class: y(["tr-suggestion-pills__expand", { "show-on-hover": p.showAllButtonOn === "hover" }]),
145
- onClick: Y
227
+ class: P(["tr-suggestion-pills__expand", { "show-on-hover": n.showAllButtonOn === "hover" }]),
228
+ onClick: L
146
229
  }, [
147
- K(re(ae), {
148
- class: y(["tr-suggestion-pills__expand-icon", { rotate: u.value }])
230
+ W(_(le), {
231
+ class: P(["tr-suggestion-pills__expand-icon", { rotate: l.value }])
149
232
  }, null, 8, ["class"])
150
- ], 2)) : S("", !0)
233
+ ], 2)) : R("", !0)
151
234
  ], 512));
152
235
  }
153
- }), w = /* @__PURE__ */ Q(ge, [["__scopeId", "data-v-ffbab62d"]]);
154
- w.name = "TrSuggestionPills";
155
- const he = function(i) {
156
- i.component(w.name, w);
236
+ }), T = /* @__PURE__ */ q(de, [["__scopeId", "data-v-5137af87"]]);
237
+ T.name = "TrSuggestionPills";
238
+ const fe = function(p) {
239
+ p.component(T.name, T);
157
240
  };
158
- w.install = he;
159
- g.name = "TrSuggestionPillButton";
160
- const _e = function(i) {
161
- i.component(g.name, g);
241
+ T.install = fe;
242
+ f.name = "TrSuggestionPillButton";
243
+ const ve = function(p) {
244
+ p.component(f.name, f);
162
245
  };
163
- g.install = _e;
164
- const xe = g;
246
+ f.install = ve;
247
+ const Be = f;
165
248
  export {
166
- xe as SuggestionPillButton,
167
- w as default
249
+ Be as SuggestionPillButton,
250
+ T as default
168
251
  };