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

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,168 @@
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({
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({
8
7
  __name: "PillButton",
9
8
  props: {
10
9
  item: {}
11
10
  },
12
- setup(u) {
13
- const g = u, l = H(), e = k(() => {
14
- var o;
15
- return !!(l.icon || (o = g.item) != null && o.icon);
16
- }), r = k(() => {
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 }])
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 }])
22
21
  }, [
23
- $(o.$slots, "icon", {}, () => {
24
- var i;
22
+ H(t.$slots, "icon", {}, () => {
23
+ var c;
25
24
  return [
26
- (n(), v(N((i = o.item) == null ? void 0 : i.icon), { class: "tr-suggestion-pills__item_icon" }))
25
+ (r(), x(R((c = t.item) == null ? void 0 : c.icon), { class: "tr-suggestion-pills__item_icon" }))
27
26
  ];
28
27
  }, !0),
29
- $(o.$slots, "default", {}, () => {
30
- var i;
28
+ H(t.$slots, "default", {}, () => {
29
+ var c;
31
30
  return [
32
- (i = o.item) != null && i.text ? (n(), f("span", oe, j(o.item.text), 1)) : b("", !0)
31
+ (c = t.item) != null && c.text ? (r(), m("span", me, oe(t.item.text), 1)) : S("", !0)
33
32
  ];
34
33
  }, !0)
35
34
  ], 2));
36
35
  }
37
- }), d = /* @__PURE__ */ V(ne, [["__scopeId", "data-v-5c113fe1"]]), L = /* @__PURE__ */ T({
38
- __name: "PillButtonWrapper",
39
- props: {
40
- item: {},
41
- style: {}
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({
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))
60
- }, null, 8, ["item"])
61
- ]),
62
- _: 2
63
- }, [
64
- M(e.item.action.slots, (a, C) => ({
65
- name: C,
66
- fn: B(() => [
67
- (n(), v(N(a)))
68
- ])
69
- }))
70
- ]), 1040, ["style", "onItemClick", "onGroupClick", "onClose"])) : ((p = e.item.action) == null ? void 0 : p.type) === "menu" ? (n(), v(h(ee), D({
71
- key: 1,
72
- style: e.style
73
- }, e.item.action.props, {
74
- onItemClick: (y = e.item.action.events) == null ? void 0 : y.itemClick
75
- }), {
76
- default: B(() => [
77
- I(d, {
78
- item: e.item,
79
- onClick: r[1] || (r[1] = (a) => l("click", a, e.item))
80
- }, null, 8, ["item"])
81
- ]),
82
- _: 1
83
- }, 16, ["style", "onItemClick"])) : (n(), v(d, {
84
- key: 2,
85
- item: e.item,
86
- style: O(e.style),
87
- onClick: r[2] || (r[2] = (a) => l("click", a, e.item))
88
- }, null, 8, ["item", "style"]));
89
- };
90
- }
91
- }), le = { class: "tr-suggestion-pills__more-wrapper" }, ie = {
92
- key: 0,
93
- class: "tr-suggestion-pills__more"
94
- }, se = /* @__PURE__ */ T({
36
+ }), g = /* @__PURE__ */ Q(pe, [["__scopeId", "data-v-5c433c31"]]), ve = { class: "tr-suggestion-pills__more-wrapper" }, ge = /* @__PURE__ */ q({
95
37
  __name: "index",
96
- props: /* @__PURE__ */ E({
97
- items: {},
38
+ props: /* @__PURE__ */ O({
98
39
  showAll: { type: Boolean },
99
- showAllButtonOn: { default: "hover" }
40
+ showAllButtonOn: { default: "hover" },
41
+ overflowMode: { default: "expand" },
42
+ autoScrollOnHover: { type: Boolean }
100
43
  }, {
101
44
  showAll: { type: Boolean, default: !1 },
102
45
  showAllModifiers: {}
103
46
  }),
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)
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;
58
+ if (!e)
113
59
  return;
114
- const _ = Array.from(t.children);
115
- c.value = _.findIndex((s) => s.offsetLeft + s.offsetWidth > t.clientWidth);
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;
66
+ break;
67
+ }
116
68
  });
117
69
  };
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();
70
+ F(
71
+ t,
72
+ () => {
73
+ N(() => {
74
+ if (!f.value)
75
+ 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);
78
+ });
125
79
  },
126
- { debounce: 100 }
127
- );
128
- const G = (t, _, s) => {
129
- if (i.value && s >= c.value) {
130
- t.stopPropagation(), W();
80
+ { immediate: !0 }
81
+ ), F(t, V), ce(M, V, { debounce: 100 });
82
+ const Y = () => {
83
+ u.value = !u.value;
84
+ };
85
+ ue(c, (e) => {
86
+ u.value && I("click-outside", e);
87
+ });
88
+ const Z = (e) => {
89
+ const o = f.value;
90
+ if (!o)
131
91
  return;
132
- }
133
- e("item-click", _);
134
- }, W = () => {
135
- p.value = !p.value;
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,
95
+ behavior: "smooth"
96
+ }) : te && o.scrollTo({
97
+ left: l - L,
98
+ behavior: "smooth"
99
+ });
136
100
  };
137
- return x(r, (t) => {
138
- e("click-outside", t);
139
- }), (t, _) => (n(), f("div", {
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", {
140
106
  class: "tr-suggestion-pills__wrapper",
141
107
  ref_key: "containerWrapperRef",
142
- ref: r
108
+ ref: c
143
109
  }, [
144
- R("div", {
145
- class: "tr-suggestion-pills__container",
110
+ $("div", {
111
+ class: y(["tr-suggestion-pills__container", { "overflow-scroll": p.overflowMode === "scroll" }]),
146
112
  ref_key: "containerRef",
147
- ref: m
113
+ ref: f
148
114
  }, [
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))
159
- ], !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)
169
- }, null, 8, ["item", "onClick"]))), 128))
170
- ])) : b("", !0)
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))
121
+ ], 2),
122
+ $("div", ve, [
123
+ K(le, { name: "tr-suggestion-pills__more" }, {
124
+ default: se(() => [
125
+ W.value.length ? (r(), m("div", {
126
+ key: 0,
127
+ class: "tr-suggestion-pills__more",
128
+ ref_key: "floatingItemsRef",
129
+ ref: b
130
+ }, [
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)
171
138
  ]),
172
139
  _: 1
173
140
  })
174
141
  ]),
175
- i.value ? (n(), f("button", {
142
+ B.value ? (r(), m("button", {
176
143
  key: 0,
177
- class: A(["tr-suggestion-pills__expand", { "show-on-hover": l.showAllButtonOn === "hover" }]),
178
- onClick: W
144
+ class: y(["tr-suggestion-pills__expand", { "show-on-hover": p.showAllButtonOn === "hover" }]),
145
+ onClick: Y
179
146
  }, [
180
- I(h(X), {
181
- class: A(["tr-suggestion-pills__expand-icon", { rotate: p.value }])
147
+ K(re(ae), {
148
+ class: y(["tr-suggestion-pills__expand-icon", { rotate: u.value }])
182
149
  }, null, 8, ["class"])
183
- ], 2)) : b("", !0)
150
+ ], 2)) : S("", !0)
184
151
  ], 512));
185
152
  }
186
- }), S = /* @__PURE__ */ V(se, [["__scopeId", "data-v-43d06a90"]]);
187
- S.name = "TrSuggestionPills";
188
- const re = function(u) {
189
- u.component(S.name, S);
153
+ }), w = /* @__PURE__ */ Q(ge, [["__scopeId", "data-v-ffbab62d"]]);
154
+ w.name = "TrSuggestionPills";
155
+ const he = function(i) {
156
+ i.component(w.name, w);
190
157
  };
191
- S.install = re;
192
- d.name = "TrSuggestionPillButton";
193
- const ae = function(u) {
194
- u.component(d.name, d);
158
+ w.install = he;
159
+ g.name = "TrSuggestionPillButton";
160
+ const _e = function(i) {
161
+ i.component(g.name, g);
195
162
  };
196
- d.install = ae;
197
- const ve = d;
163
+ g.install = _e;
164
+ const xe = g;
198
165
  export {
199
- ve as SuggestionPillButton,
200
- S as default
166
+ xe as SuggestionPillButton,
167
+ w as default
201
168
  };