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

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,177 @@
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 J, useSlots as K, computed as a, createElementBlock as m, openBlock as r, normalizeClass as w, renderSlot as H, createBlock as S, resolveDynamicComponent as b, createCommentVNode as A, 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 U, createVNode as j, Transition as se, withCtx as re, unref as ae } from "vue";
2
+ import { IconArrowUp as ie } from "@opentiny/tiny-robot-svgs";
3
+ import { e as ce, b as q, f as ue, o as fe, g as de } from "../index2.js";
4
+ import { u as me } from "../useSlotRefs.js";
5
+ import { _ as Q } 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(u) {
13
- const g = u, l = H(), e = k(() => {
11
+ setup(i) {
12
+ const v = i, _ = K(), p = a(() => {
14
13
  var o;
15
- return !!(l.icon || (o = g.item) != null && o.icon);
16
- }), r = k(() => {
14
+ return !!(_.icon || (o = v.item) != null && o.icon);
15
+ }), I = a(() => {
17
16
  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 }])
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
- $(o.$slots, "icon", {}, () => {
24
- var i;
22
+ H(o.$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(), S(b((c = o.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(o.$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 = o.item) != null && c.text ? (r(), m("span", pe, ne(o.item.text), 1)) : A("", !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
+ }), h = /* @__PURE__ */ Q(ge, [["__scopeId", "data-v-5c433c31"]]), he = { class: "tr-suggestion-pills__more-wrapper" }, ve = /* @__PURE__ */ J({
95
37
  __name: "index",
96
- props: /* @__PURE__ */ E({
97
- items: {},
38
+ props: /* @__PURE__ */ N({
98
39
  showAll: { type: Boolean },
99
- showAllButtonOn: { default: "hover" }
40
+ showAllButtonOn: { default: "hover" },
41
+ overflowMode: { default: "expand" },
42
+ autoScrollOn: {}
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__ */ N(["click-outside"], ["update:showAll"]),
48
+ setup(i, { expose: v, emit: _ }) {
49
+ const p = i, I = K(), x = _, { vnodes: o } = me(I.default, !0), u = le(i, "showAll"), c = d(null), f = d(null), M = 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 = M.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)
113
59
  return;
114
- const _ = Array.from(t.children);
115
- c.value = _.findIndex((s) => s.offsetLeft + s.offsetWidth > t.clientWidth);
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
+ }
116
68
  });
117
69
  };
118
- K(() => {
119
- var t;
120
- return [l.items, (t = l.items) == null ? void 0 : t.length];
121
- }, C), Z(
70
+ R(
122
71
  o,
123
- (t) => {
124
- t > 0 && C();
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
+ });
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
+ ), 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)
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 = 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
+ });
136
100
  };
137
- return x(r, (t) => {
138
- e("click-outside", t);
139
- }), (t, _) => (n(), f("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", {
140
115
  class: "tr-suggestion-pills__wrapper",
141
116
  ref_key: "containerWrapperRef",
142
- ref: r
117
+ ref: c
143
118
  }, [
144
- R("div", {
145
- class: "tr-suggestion-pills__container",
119
+ D("div", {
120
+ class: w(["tr-suggestion-pills__container", { "overflow-scroll": p.overflowMode === "scroll" }]),
146
121
  ref_key: "containerRef",
147
- ref: m
122
+ ref: f
148
123
  }, [
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)
124
+ (r(!0), m(z, null, G(X.value, (n, l) => (r(), S(b(n), {
125
+ key: U(n) ? n.key : l,
126
+ ref_for: !0,
127
+ ref_key: "staticMaybeItemRefs",
128
+ ref: E
129
+ }))), 128))
130
+ ], 2),
131
+ D("div", he, [
132
+ j(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: M
139
+ }, [
140
+ (r(!0), m(z, null, G(T.value, ({ vnode: n, index: l }) => (r(), S(b(n), {
141
+ key: U(n) ? n.key : l,
142
+ ref_for: !0,
143
+ ref_key: "floatingMaybeItemRefs",
144
+ ref: P
145
+ }))), 128))
146
+ ], 512)) : A("", !0)
171
147
  ]),
172
148
  _: 1
173
149
  })
174
150
  ]),
175
- i.value ? (n(), f("button", {
151
+ B.value ? (r(), m("button", {
176
152
  key: 0,
177
- class: A(["tr-suggestion-pills__expand", { "show-on-hover": l.showAllButtonOn === "hover" }]),
178
- onClick: W
153
+ class: w(["tr-suggestion-pills__expand", { "show-on-hover": p.showAllButtonOn === "hover" }]),
154
+ onClick: Z
179
155
  }, [
180
- I(h(X), {
181
- class: A(["tr-suggestion-pills__expand-icon", { rotate: p.value }])
156
+ j(ae(ie), {
157
+ class: w(["tr-suggestion-pills__expand-icon", { rotate: u.value }])
182
158
  }, null, 8, ["class"])
183
- ], 2)) : b("", !0)
159
+ ], 2)) : A("", !0)
184
160
  ], 512));
185
161
  }
186
- }), S = /* @__PURE__ */ V(se, [["__scopeId", "data-v-43d06a90"]]);
187
- S.name = "TrSuggestionPills";
188
- const re = function(u) {
189
- u.component(S.name, S);
162
+ }), k = /* @__PURE__ */ Q(ve, [["__scopeId", "data-v-ebbd7a00"]]);
163
+ k.name = "TrSuggestionPills";
164
+ const _e = function(i) {
165
+ i.component(k.name, k);
190
166
  };
191
- S.install = re;
192
- d.name = "TrSuggestionPillButton";
193
- const ae = function(u) {
194
- u.component(d.name, d);
167
+ k.install = _e;
168
+ h.name = "TrSuggestionPillButton";
169
+ const ye = function(i) {
170
+ i.component(h.name, h);
195
171
  };
196
- d.install = ae;
197
- const ve = d;
172
+ h.install = ye;
173
+ const Re = h;
198
174
  export {
199
- ve as SuggestionPillButton,
200
- S as default
175
+ Re as SuggestionPillButton,
176
+ k as default
201
177
  };