@opentiny/tiny-robot 0.2.0-alpha.6 → 0.2.0-alpha.8

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,120 +1,180 @@
1
- import { defineComponent as T, useSlots as N, computed as d, createElementBlock as a, openBlock as n, normalizeClass as R, renderSlot as v, createBlock as c, resolveDynamicComponent as V, createCommentVNode as z, toDisplayString as E, useCssVars as F, ref as L, Fragment as $, renderList as b, unref as i, mergeProps as x, createSlots as M, withCtx as C, createVNode as D } from "vue";
2
- import { d as j } from "../index3.js";
3
- import q from "../dropdown-menu/index.js";
4
- import A from "../suggestion-popover/index.js";
5
- import { _ as w } from "../_plugin-vue_export-helper.js";
6
- const H = { key: 0 }, J = /* @__PURE__ */ T({
1
+ import { defineComponent as b, useSlots as L, computed as f, createElementBlock as d, openBlock as n, normalizeClass as R, renderSlot as B, createBlock as c, resolveDynamicComponent as z, createCommentVNode as S, toDisplayString as U, unref as g, mergeProps as T, createSlots as F, withCtx as w, createVNode as $, renderList as P, mergeModels as D, useCssVars as H, ref as V, useModel as j, watch as q, createElementVNode as W, Fragment as E, Transition as J, nextTick as O } from "vue";
2
+ import { K as Q, U as X } from "../tiny-robot-svgs.js";
3
+ import { b as Y, w as Z } from "../index2.js";
4
+ import x from "../dropdown-menu/index.js";
5
+ import ee from "../suggestion-popover/index.js";
6
+ import { _ as G } from "../_plugin-vue_export-helper.js";
7
+ const te = { key: 0 }, ne = /* @__PURE__ */ b({
7
8
  __name: "PillButton",
8
9
  props: {
9
10
  item: {}
10
11
  },
11
- setup(s) {
12
- const u = s, p = N(), r = d(() => {
13
- var e;
14
- return !!(p.icon || (e = u.item) != null && e.icon);
15
- }), m = d(() => {
16
- var e;
17
- return !!(p.default || (e = u.item) != null && e.text);
18
- }), k = d(() => r.value && !m.value);
19
- return (e, g) => (n(), a("button", {
20
- class: R(["tr-suggestion-pills__item", { "only-icon": k.value }])
12
+ setup(a) {
13
+ const k = a, s = L(), e = f(() => {
14
+ var t;
15
+ return !!(s.icon || (t = k.item) != null && t.icon);
16
+ }), i = f(() => {
17
+ var t;
18
+ return !!(s.default || (t = k.item) != null && t.text);
19
+ }), p = f(() => e.value && !i.value);
20
+ return (t, u) => (n(), d("button", {
21
+ class: R(["tr-suggestion-pills__item", { "only-icon": p.value }])
21
22
  }, [
22
- v(e.$slots, "icon", {}, () => {
23
- var l;
23
+ B(t.$slots, "icon", {}, () => {
24
+ var o;
24
25
  return [
25
- (n(), c(V((l = e.item) == null ? void 0 : l.icon), { class: "tr-suggestion-pills__item_icon" }))
26
+ (n(), c(z((o = t.item) == null ? void 0 : o.icon), { class: "tr-suggestion-pills__item_icon" }))
26
27
  ];
27
28
  }, !0),
28
- v(e.$slots, "default", {}, () => {
29
- var l;
29
+ B(t.$slots, "default", {}, () => {
30
+ var o;
30
31
  return [
31
- (l = e.item) != null && l.text ? (n(), a("span", H, E(e.item.text), 1)) : z("", !0)
32
+ (o = t.item) != null && o.text ? (n(), d("span", te, U(t.item.text), 1)) : S("", !0)
32
33
  ];
33
34
  }, !0)
34
35
  ], 2));
35
36
  }
36
- }), o = /* @__PURE__ */ w(J, [["__scopeId", "data-v-8df2df8c"]]), K = /* @__PURE__ */ T({
37
- __name: "index",
37
+ }), m = /* @__PURE__ */ G(ne, [["__scopeId", "data-v-5c113fe1"]]), N = /* @__PURE__ */ b({
38
+ __name: "PillButtonWrapper",
38
39
  props: {
39
- items: {}
40
+ item: {}
40
41
  },
41
- emits: ["item-click"],
42
- setup(s, { emit: u }) {
43
- F((g) => ({
44
- 31203585: e.value
42
+ emits: ["click"],
43
+ setup(a, { emit: k }) {
44
+ const s = k;
45
+ return (e, i) => {
46
+ var p, t, u, o, h, _;
47
+ return ((p = e.item.action) == null ? void 0 : p.type) === "popover" ? (n(), c(g(ee), T({ key: 0 }, e.item.action.props, {
48
+ onItemClick: (t = e.item.action.events) == null ? void 0 : t.itemClick,
49
+ onGroupClick: (u = e.item.action.events) == null ? void 0 : u.groupClick,
50
+ onClose: (o = e.item.action.events) == null ? void 0 : o.close
51
+ }), F({
52
+ default: w(() => [
53
+ $(m, {
54
+ item: e.item,
55
+ onClick: i[0] || (i[0] = (v) => s("click", e.item))
56
+ }, null, 8, ["item"])
57
+ ]),
58
+ _: 2
59
+ }, [
60
+ P(e.item.action.slots, (v, C) => ({
61
+ name: C,
62
+ fn: w(() => [
63
+ (n(), c(z(v)))
64
+ ])
65
+ }))
66
+ ]), 1040, ["onItemClick", "onGroupClick", "onClose"])) : ((h = e.item.action) == null ? void 0 : h.type) === "menu" ? (n(), c(g(x), T({ key: 1 }, e.item.action.props, {
67
+ onItemClick: (_ = e.item.action.events) == null ? void 0 : _.itemClick
68
+ }), {
69
+ default: w(() => [
70
+ $(m, {
71
+ item: e.item,
72
+ onClick: i[1] || (i[1] = (v) => s("click", e.item))
73
+ }, null, 8, ["item"])
74
+ ]),
75
+ _: 1
76
+ }, 16, ["onItemClick"])) : (n(), c(m, {
77
+ key: 2,
78
+ item: e.item,
79
+ onClick: i[2] || (i[2] = (v) => s("click", e.item))
80
+ }, null, 8, ["item"]));
81
+ };
82
+ }
83
+ }), oe = { class: "tr-suggestion-pills__wrapper" }, ie = { class: "tr-suggestion-pills__more-wrapper" }, le = {
84
+ key: 0,
85
+ class: "tr-suggestion-pills__more"
86
+ }, se = /* @__PURE__ */ b({
87
+ __name: "index",
88
+ props: /* @__PURE__ */ D({
89
+ items: {},
90
+ showAll: { type: Boolean }
91
+ }, {
92
+ showAll: { type: Boolean, default: !1 },
93
+ showAllModifiers: {}
94
+ }),
95
+ emits: /* @__PURE__ */ D(["item-click"], ["update:showAll"]),
96
+ setup(a, { emit: k }) {
97
+ H((l) => ({
98
+ "8cd74b6e": v.value
45
99
  }));
46
- const p = s, r = u, m = L(null), { arrivedState: k } = j(m), e = d(() => k.left ? "linear-gradient(to right, black 95%, transparent)" : k.right ? "linear-gradient(to left, black 95%, transparent)" : "linear-gradient(to right, transparent, black 5%, black 95%, transparent)");
47
- return (g, l) => (n(), a("div", {
48
- class: "tr-suggestion-pills__container",
49
- ref_key: "containerRef",
50
- ref: m
51
- }, [
52
- v(g.$slots, "default", {}, () => [
53
- (n(!0), a($, null, b(p.items, (t) => {
54
- var y, h, S, B, I, P;
55
- return n(), a($, {
56
- key: t.id
57
- }, [
58
- ((y = t.action) == null ? void 0 : y.type) === "popover" ? (n(), c(i(A), x({
59
- key: 0,
60
- class: "shrink",
61
- ref_for: !0
62
- }, t.action.props, {
63
- onItemClick: (h = t.action.events) == null ? void 0 : h.itemClick,
64
- onGroupClick: (S = t.action.events) == null ? void 0 : S.groupClick,
65
- onClose: (B = t.action.events) == null ? void 0 : B.close
66
- }), M({
67
- default: C(() => [
68
- D(i(o), {
69
- item: t,
70
- onClick: (f) => r("item-click", t)
71
- }, null, 8, ["item", "onClick"])
72
- ]),
73
- _: 2
74
- }, [
75
- b(t.action.slots, (f, G) => ({
76
- name: G,
77
- fn: C(() => [
78
- (n(), c(V(f)))
79
- ])
80
- }))
81
- ]), 1040, ["onItemClick", "onGroupClick", "onClose"])) : ((I = t.action) == null ? void 0 : I.type) === "menu" ? (n(), c(i(q), x({
82
- key: 1,
83
- class: "shrink",
84
- ref_for: !0
85
- }, t.action.props, {
86
- onItemClick: (P = t.action.events) == null ? void 0 : P.itemClick
87
- }), {
88
- default: C(() => [
89
- D(i(o), {
90
- item: t,
91
- onClick: (f) => r("item-click", t)
92
- }, null, 8, ["item", "onClick"])
93
- ]),
94
- _: 2
95
- }, 1040, ["onItemClick"])) : (n(), c(i(o), {
96
- key: 2,
97
- item: t,
98
- onClick: (f) => r("item-click", t)
99
- }, null, 8, ["item", "onClick"]))
100
- ], 64);
101
- }), 128))
102
- ], !0)
103
- ], 512));
100
+ const s = a, e = k, i = V(null), { width: p } = Y(i), t = V(-1), u = f(() => t.value !== -1), o = j(a, "showAll"), h = f(() => !u.value || !o.value ? s.items || [] : (s.items || []).slice(0, t.value)), _ = f(() => !u.value || !o.value ? [] : (s.items || []).slice(t.value)), v = f(() => p.value < i.value.scrollWidth ? "linear-gradient(to right, black 90%, transparent)" : "unset"), C = () => {
101
+ O(() => {
102
+ const l = i.value;
103
+ if (!l)
104
+ return;
105
+ const y = Array.from(l.children);
106
+ t.value = y.findIndex((r) => r.offsetLeft + r.offsetWidth > l.clientWidth);
107
+ });
108
+ };
109
+ q(() => {
110
+ var l;
111
+ return [s.items, (l = s.items) == null ? void 0 : l.length];
112
+ }, C), Z(
113
+ p,
114
+ (l) => {
115
+ l > 0 && C();
116
+ },
117
+ { debounce: 100 }
118
+ );
119
+ const K = (l, y) => {
120
+ if (u.value && y >= t.value) {
121
+ A();
122
+ return;
123
+ }
124
+ e("item-click", l);
125
+ }, A = () => {
126
+ o.value = !o.value;
127
+ };
128
+ return (l, y) => (n(), d("div", oe, [
129
+ W("div", {
130
+ class: "tr-suggestion-pills__container",
131
+ ref_key: "containerRef",
132
+ ref: i
133
+ }, [
134
+ B(l.$slots, "default", {}, () => [
135
+ (n(!0), d(E, null, P(h.value, (r, M) => (n(), c(g(N), {
136
+ key: r.id,
137
+ item: r,
138
+ onClick: (ce) => K(r, M)
139
+ }, null, 8, ["item", "onClick"]))), 128))
140
+ ], !0)
141
+ ], 512),
142
+ W("div", ie, [
143
+ $(J, { name: "tr-suggestion-pills__more" }, {
144
+ default: w(() => [
145
+ _.value.length ? (n(), d("div", le, [
146
+ (n(!0), d(E, null, P(_.value, (r) => (n(), c(g(N), {
147
+ key: r.id,
148
+ item: r,
149
+ onClick: (M) => e("item-click", r)
150
+ }, null, 8, ["item", "onClick"]))), 128))
151
+ ])) : S("", !0)
152
+ ]),
153
+ _: 1
154
+ })
155
+ ]),
156
+ u.value ? (n(), d("button", {
157
+ key: 0,
158
+ class: "tr-suggestion-pills__expand",
159
+ onClick: A
160
+ }, [
161
+ o.value ? (n(), c(g(X), { key: 1 })) : (n(), c(g(Q), { key: 0 }))
162
+ ])) : S("", !0)
163
+ ]));
104
164
  }
105
- }), _ = /* @__PURE__ */ w(K, [["__scopeId", "data-v-9c74797b"]]);
106
- _.name = "TrSuggestionPills";
107
- const O = function(s) {
108
- s.component(_.name, _);
165
+ }), I = /* @__PURE__ */ G(se, [["__scopeId", "data-v-e03676ad"]]);
166
+ I.name = "TrSuggestionPills";
167
+ const re = function(a) {
168
+ a.component(I.name, I);
109
169
  };
110
- _.install = O;
111
- o.name = "TrSuggestionPillButton";
112
- const Q = function(s) {
113
- s.component(o.name, o);
170
+ I.install = re;
171
+ m.name = "TrSuggestionPillButton";
172
+ const ae = function(a) {
173
+ a.component(m.name, m);
114
174
  };
115
- o.install = Q;
116
- const tt = o;
175
+ m.install = ae;
176
+ const ve = m;
117
177
  export {
118
- tt as SuggestionPillButton,
119
- _ as default
178
+ ve as SuggestionPillButton,
179
+ I as default
120
180
  };