@opentiny/tiny-robot 0.2.0-alpha.5 → 0.2.0-alpha.7

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