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