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

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,177 +1,180 @@
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({
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({
8
8
  __name: "PillButton",
9
9
  props: {
10
10
  item: {}
11
11
  },
12
12
  setup(a) {
13
- const v = a, s = R(), e = k(() => {
13
+ const k = a, s = L(), e = f(() => {
14
14
  var t;
15
- return !!(s.icon || (t = v.item) != null && t.icon);
16
- }), o = k(() => {
15
+ return !!(s.icon || (t = k.item) != null && t.icon);
16
+ }), i = f(() => {
17
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 }])
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 }])
22
22
  }, [
23
23
  B(t.$slots, "icon", {}, () => {
24
- var i;
24
+ var o;
25
25
  return [
26
- (n(), u(G((i = t.item) == null ? void 0 : i.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" }))
27
27
  ];
28
28
  }, !0),
29
29
  B(t.$slots, "default", {}, () => {
30
- var i;
30
+ var o;
31
31
  return [
32
- (i = t.item) != null && i.text ? (n(), f("span", oe, F(t.item.text), 1)) : S("", !0)
32
+ (o = t.item) != null && o.text ? (n(), d("span", te, U(t.item.text), 1)) : S("", !0)
33
33
  ];
34
34
  }, !0)
35
35
  ], 2));
36
36
  }
37
- }), p = /* @__PURE__ */ K(ie, [["__scopeId", "data-v-bb357728"]]), z = /* @__PURE__ */ b({
37
+ }), m = /* @__PURE__ */ G(ne, [["__scopeId", "data-v-5c113fe1"]]), N = /* @__PURE__ */ b({
38
38
  __name: "PillButtonWrapper",
39
39
  props: {
40
40
  item: {}
41
41
  },
42
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, {
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
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, {
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
54
  item: e.item,
55
- onClick: o[0] || (o[0] = (d) => s("click", e.item))
55
+ onClick: i[0] || (i[0] = (v) => s("click", e.item))
56
56
  }, null, 8, ["item"])
57
57
  ]),
58
58
  _: 2
59
59
  }, [
60
- P(e.item.action.slots, (d, I) => ({
61
- name: I,
62
- fn: y(() => [
63
- (n(), u(G(d)))
60
+ P(e.item.action.slots, (v, C) => ({
61
+ name: C,
62
+ fn: w(() => [
63
+ (n(), c(z(v)))
64
64
  ])
65
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
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
68
  }), {
69
- default: y(() => [
70
- $(p, {
69
+ default: w(() => [
70
+ $(m, {
71
71
  item: e.item,
72
- onClick: o[1] || (o[1] = (d) => s("click", e.item))
72
+ onClick: i[1] || (i[1] = (v) => s("click", e.item))
73
73
  }, null, 8, ["item"])
74
74
  ]),
75
75
  _: 1
76
- }, 16, ["onItemClick"])) : (n(), u(p, {
76
+ }, 16, ["onItemClick"])) : (n(), c(m, {
77
77
  key: 2,
78
78
  item: e.item,
79
- onClick: o[2] || (o[2] = (d) => s("click", e.item))
79
+ onClick: i[2] || (i[2] = (v) => s("click", e.item))
80
80
  }, null, 8, ["item"]));
81
81
  };
82
82
  }
83
- }), se = { class: "tr-suggestion-pills__wrapper" }, le = { class: "tr-suggestion-pills__more-wrapper" }, re = {
83
+ }), oe = { class: "tr-suggestion-pills__wrapper" }, ie = { class: "tr-suggestion-pills__more-wrapper" }, le = {
84
84
  key: 0,
85
85
  class: "tr-suggestion-pills__more"
86
- }, ae = /* @__PURE__ */ b({
86
+ }, se = /* @__PURE__ */ b({
87
87
  __name: "index",
88
- props: /* @__PURE__ */ V({
88
+ props: /* @__PURE__ */ D({
89
89
  items: {},
90
90
  showAll: { type: Boolean }
91
91
  }, {
92
92
  showAll: { type: Boolean, default: !1 },
93
93
  showAllModifiers: {}
94
94
  }),
95
- emits: /* @__PURE__ */ V(["item-click"], ["update:showAll"]),
96
- setup(a, { emit: v }) {
97
- j((l) => ({
98
- "2bdfa5e6": I.value
95
+ emits: /* @__PURE__ */ D(["item-click"], ["update:showAll"]),
96
+ setup(a, { emit: k }) {
97
+ H((l) => ({
98
+ "8cd74b6e": v.value
99
99
  }));
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;
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
103
  if (!l)
104
104
  return;
105
- const h = Array.from(l.children);
106
- c.value = h.findIndex((r) => r.offsetLeft + r.offsetWidth > l.clientWidth);
105
+ const y = Array.from(l.children);
106
+ t.value = y.findIndex((r) => r.offsetLeft + r.offsetWidth > l.clientWidth);
107
107
  });
108
108
  };
109
- J(() => s.items, A), ee(
110
- g,
109
+ q(() => {
110
+ var l;
111
+ return [s.items, (l = s.items) == null ? void 0 : l.length];
112
+ }, C), Z(
113
+ p,
111
114
  (l) => {
112
- l > 0 && A();
115
+ l > 0 && C();
113
116
  },
114
117
  { debounce: 100 }
115
118
  );
116
- const L = (l, h) => {
117
- if (i.value && h >= c.value) {
118
- M();
119
+ const K = (l, y) => {
120
+ if (u.value && y >= t.value) {
121
+ A();
119
122
  return;
120
123
  }
121
124
  e("item-click", l);
122
- }, M = () => {
123
- m.value = !m.value;
125
+ }, A = () => {
126
+ o.value = !o.value;
124
127
  };
125
- return (l, h) => (n(), f("div", se, [
126
- N("div", {
128
+ return (l, y) => (n(), d("div", oe, [
129
+ W("div", {
127
130
  class: "tr-suggestion-pills__container",
128
131
  ref_key: "containerRef",
129
- ref: o
132
+ ref: i
130
133
  }, [
131
134
  B(l.$slots, "default", {}, () => [
132
- (n(!0), f(W, null, P(C.value, (r, T) => (n(), u(_(z), {
135
+ (n(!0), d(E, null, P(h.value, (r, M) => (n(), c(g(N), {
133
136
  key: r.id,
134
137
  item: r,
135
- onClick: (me) => L(r, T)
138
+ onClick: (ce) => K(r, M)
136
139
  }, null, 8, ["item", "onClick"]))), 128))
137
140
  ], !0)
138
141
  ], 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), {
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), {
144
147
  key: r.id,
145
148
  item: r,
146
- onClick: (T) => e("item-click", r)
149
+ onClick: (M) => e("item-click", r)
147
150
  }, null, 8, ["item", "onClick"]))), 128))
148
151
  ])) : S("", !0)
149
152
  ]),
150
153
  _: 1
151
154
  })
152
155
  ]),
153
- i.value ? (n(), f("button", {
156
+ u.value ? (n(), d("button", {
154
157
  key: 0,
155
158
  class: "tr-suggestion-pills__expand",
156
- onClick: M
159
+ onClick: A
157
160
  }, [
158
- m.value ? (n(), u(_(Y), { key: 1 })) : (n(), u(_(X), { key: 0 }))
161
+ o.value ? (n(), c(g(X), { key: 1 })) : (n(), c(g(Q), { key: 0 }))
159
162
  ])) : S("", !0)
160
163
  ]));
161
164
  }
162
- }), w = /* @__PURE__ */ K(ae, [["__scopeId", "data-v-74f54ee4"]]);
163
- w.name = "TrSuggestionPills";
164
- const ce = function(a) {
165
- a.component(w.name, w);
165
+ }), I = /* @__PURE__ */ G(se, [["__scopeId", "data-v-e03676ad"]]);
166
+ I.name = "TrSuggestionPills";
167
+ const re = function(a) {
168
+ a.component(I.name, I);
166
169
  };
167
- w.install = ce;
168
- p.name = "TrSuggestionPillButton";
169
- const ue = function(a) {
170
- a.component(p.name, p);
170
+ I.install = re;
171
+ m.name = "TrSuggestionPillButton";
172
+ const ae = function(a) {
173
+ a.component(m.name, m);
171
174
  };
172
- p.install = ue;
173
- const _e = p;
175
+ m.install = ae;
176
+ const ve = m;
174
177
  export {
175
- _e as SuggestionPillButton,
176
- w as default
178
+ ve as SuggestionPillButton,
179
+ I as default
177
180
  };