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

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