@opentiny/tiny-robot 0.3.0-alpha.15 → 0.3.0-alpha.16

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