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