@opentiny/tiny-robot 0.2.13 → 0.3.0-alpha.1

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,201 @@
1
- import { defineComponent as H, useSlots as Z, computed as w, createElementBlock as k, openBlock as a, 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 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 { f 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({
8
8
  __name: "PillButton",
9
9
  props: {
10
10
  item: {}
11
11
  },
12
- setup(p) {
13
- const y = p, n = Z(), t = w(() => {
12
+ setup(u) {
13
+ const g = u, l = H(), e = k(() => {
14
14
  var o;
15
- return !!(n.icon || (o = y.item) != null && o.icon);
16
- }), l = w(() => {
15
+ return !!(l.icon || (o = g.item) != null && o.icon);
16
+ }), r = k(() => {
17
17
  var o;
18
- return !!(n.default || (o = y.item) != null && o.text);
19
- }), v = w(() => t.value && !l.value);
20
- return (o, C) => (a(), k("button", {
21
- class: P(["tr-suggestion-pills__item", { "only-icon": v.value }])
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 }])
22
22
  }, [
23
- b(o.$slots, "icon", {}, () => {
24
- var c;
23
+ $(o.$slots, "icon", {}, () => {
24
+ var i;
25
25
  return [
26
- (a(), h(j((c = o.item) == null ? void 0 : c.icon), { class: "tr-suggestion-pills__item_icon" }))
26
+ (n(), v(N((i = o.item) == null ? void 0 : i.icon), { class: "tr-suggestion-pills__item_icon" }))
27
27
  ];
28
28
  }, !0),
29
- b(o.$slots, "default", {}, () => {
30
- var c;
29
+ $(o.$slots, "default", {}, () => {
30
+ var i;
31
31
  return [
32
- (c = o.item) != null && c.text ? (a(), k("span", ce, x(o.item.text), 1)) : R("", !0)
32
+ (i = o.item) != null && i.text ? (n(), f("span", oe, j(o.item.text), 1)) : b("", !0)
33
33
  ];
34
34
  }, !0)
35
35
  ], 2));
36
36
  }
37
- }), f = /* @__PURE__ */ q(me, [["__scopeId", "data-v-5c113fe1"]]), K = /* @__PURE__ */ H({
37
+ }), d = /* @__PURE__ */ V(ne, [["__scopeId", "data-v-5c113fe1"]]), L = /* @__PURE__ */ T({
38
38
  __name: "PillButtonWrapper",
39
39
  props: {
40
40
  item: {},
41
41
  style: {}
42
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" ? (a(), h(_(ue), E({
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({
49
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))
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))
63
60
  }, null, 8, ["item"])
64
61
  ]),
65
62
  _: 2
66
63
  }, [
67
- $(t.item.action.slots, (r, O) => ({
68
- name: O,
69
- fn: A(() => [
70
- (a(), h(j(r)))
64
+ M(e.item.action.slots, (a, C) => ({
65
+ name: C,
66
+ fn: B(() => [
67
+ (n(), v(N(a)))
71
68
  ])
72
69
  }))
73
- ]), 1040, ["style", "onItemClick", "onGroupClick", "onOpen", "onClose", "onClickOutside"])) : ((d = t.item.action) == null ? void 0 : d.type) === "menu" ? (a(), h(_(ae), E({
70
+ ]), 1040, ["style", "onItemClick", "onGroupClick", "onClose"])) : ((p = e.item.action) == null ? void 0 : p.type) === "menu" ? (n(), v(h(ee), D({
74
71
  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
72
+ style: e.style
73
+ }, e.item.action.props, {
74
+ onItemClick: (y = e.item.action.events) == null ? void 0 : y.itemClick
79
75
  }), {
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))
76
+ default: B(() => [
77
+ I(d, {
78
+ item: e.item,
79
+ onClick: r[1] || (r[1] = (a) => l("click", a, e.item))
85
80
  }, null, 8, ["item"])
86
81
  ]),
87
82
  _: 1
88
- }, 16, ["style", "onItemClick", "onClickOutside"])) : (a(), h(f, {
83
+ }, 16, ["style", "onItemClick"])) : (n(), v(d, {
89
84
  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))
85
+ item: e.item,
86
+ style: O(e.style),
87
+ onClick: r[2] || (r[2] = (a) => l("click", a, e.item))
94
88
  }, null, 8, ["item", "style"]));
95
89
  };
96
90
  }
97
- }), pe = { class: "tr-suggestion-pills__more-wrapper" }, de = /* @__PURE__ */ H({
91
+ }), le = { class: "tr-suggestion-pills__more-wrapper" }, ie = {
92
+ key: 0,
93
+ class: "tr-suggestion-pills__more"
94
+ }, se = /* @__PURE__ */ T({
98
95
  __name: "index",
99
- props: /* @__PURE__ */ F({
96
+ props: /* @__PURE__ */ E({
100
97
  items: {},
101
98
  showAll: { type: Boolean },
102
- showAllButtonOn: { default: "hover" },
103
- overflowMode: { default: "expand" },
104
- autoScrollOnHover: { type: Boolean }
99
+ showAllButtonOn: { default: "hover" }
105
100
  }, {
106
101
  showAll: { type: Boolean, default: !1 },
107
102
  showAllModifiers: {}
108
103
  }),
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)
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)
124
113
  return;
125
- const s = r(), i = parseFloat(getComputedStyle(e).rowGap) || 0;
126
- let m = 0;
127
- for (let u = 0; u < s.length; u++) {
128
- if (m += s[u].offsetWidth, u > 0 && (m += i), m > e.clientWidth) {
129
- d.value = u;
130
- break;
131
- }
132
- u === s.length - 1 && (d.value = -1);
133
- }
114
+ const _ = Array.from(t.children);
115
+ c.value = _.findIndex((s) => s.offsetLeft + s.offsetWidth > t.clientWidth);
134
116
  });
135
117
  };
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.map((i) => i.offsetWidth).reduce((i, m) => i + m + s);
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();
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();
157
125
  },
158
126
  { debounce: 100 }
159
127
  );
160
- const J = (e, s, i) => {
161
- if (g.value && i >= d.value) {
162
- e.stopPropagation(), L();
128
+ const G = (t, _, s) => {
129
+ if (i.value && s >= c.value) {
130
+ t.stopPropagation(), W();
163
131
  return;
164
132
  }
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, u = s.scrollLeft, D = s.clientWidth, X = i < u, Y = m > u + 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);
133
+ e("item-click", _);
134
+ }, W = () => {
135
+ p.value = !p.value;
186
136
  };
187
- return (e, s) => (a(), k("div", {
137
+ return x(r, (t) => {
138
+ e("click-outside", t);
139
+ }), (t, _) => (n(), f("div", {
188
140
  class: "tr-suggestion-pills__wrapper",
189
141
  ref_key: "containerWrapperRef",
190
- ref: v
142
+ ref: r
191
143
  }, [
192
- z("div", {
193
- class: P(["tr-suggestion-pills__container", { "overflow-scroll": n.overflowMode === "scroll" }]),
144
+ R("div", {
145
+ class: "tr-suggestion-pills__container",
194
146
  ref_key: "containerRef",
195
- ref: o
147
+ ref: m
196
148
  }, [
197
- b(e.$slots, "default", {}, () => [
198
- (a(!0), k(N, null, $(M.value, (i, m) => (a(), h(_(K), {
199
- key: i.id,
200
- item: i,
201
- onClick: (u) => J(u, i, m),
202
- onMouseenter: s[0] || (s[0] = (u) => U(u))
203
- }, null, 8, ["item", "onClick"]))), 128))
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))
204
159
  ], !0)
205
- ], 2),
206
- z("div", pe, [
207
- W(ne, { name: "tr-suggestion-pills__more" }, {
208
- default: A(() => [
209
- I.value.length ? (a(), k("div", {
210
- key: 0,
211
- class: "tr-suggestion-pills__more",
212
- ref_key: "floatingItemsRef",
213
- ref: C
214
- }, [
215
- (a(!0), k(N, null, $(I.value, (i) => (a(), h(_(K), {
216
- key: i.id,
217
- item: i,
218
- onClick: (m) => t("item-click", i)
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)
219
169
  }, null, 8, ["item", "onClick"]))), 128))
220
- ], 512)) : R("", !0)
170
+ ])) : b("", !0)
221
171
  ]),
222
172
  _: 1
223
173
  })
224
174
  ]),
225
- g.value ? (a(), k("button", {
175
+ i.value ? (n(), f("button", {
226
176
  key: 0,
227
- class: P(["tr-suggestion-pills__expand", { "show-on-hover": n.showAllButtonOn === "hover" }]),
228
- onClick: L
177
+ class: A(["tr-suggestion-pills__expand", { "show-on-hover": l.showAllButtonOn === "hover" }]),
178
+ onClick: W
229
179
  }, [
230
- W(_(le), {
231
- class: P(["tr-suggestion-pills__expand-icon", { rotate: l.value }])
180
+ I(h(X), {
181
+ class: A(["tr-suggestion-pills__expand-icon", { rotate: p.value }])
232
182
  }, null, 8, ["class"])
233
- ], 2)) : R("", !0)
183
+ ], 2)) : b("", !0)
234
184
  ], 512));
235
185
  }
236
- }), T = /* @__PURE__ */ q(de, [["__scopeId", "data-v-68ee26f5"]]);
237
- T.name = "TrSuggestionPills";
238
- const fe = function(p) {
239
- p.component(T.name, T);
186
+ }), S = /* @__PURE__ */ V(se, [["__scopeId", "data-v-43d06a90"]]);
187
+ S.name = "TrSuggestionPills";
188
+ const re = function(u) {
189
+ u.component(S.name, S);
240
190
  };
241
- T.install = fe;
242
- f.name = "TrSuggestionPillButton";
243
- const ve = function(p) {
244
- p.component(f.name, f);
191
+ S.install = re;
192
+ d.name = "TrSuggestionPillButton";
193
+ const ae = function(u) {
194
+ u.component(d.name, d);
245
195
  };
246
- f.install = ve;
247
- const Be = f;
196
+ d.install = ae;
197
+ const ve = d;
248
198
  export {
249
- Be as SuggestionPillButton,
250
- T as default
199
+ ve as SuggestionPillButton,
200
+ S as default
251
201
  };