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