@opentiny/tiny-robot 0.3.1-alpha.4 → 0.3.1

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.
package/dist/index3.js CHANGED
@@ -1,710 +1,301 @@
1
- import { onMounted as re, nextTick as he, watch as k, getCurrentScope as me, onScopeDispose as ge, getCurrentInstance as j, isRef as ie, toValue as w, hasInjectionContext as le, inject as we, toRefs as be, customRef as ye, shallowRef as y, computed as P, reactive as Z, unref as Oe, watchEffect as se, ref as Se, readonly as Te } from "vue";
2
- function z(e) {
3
- return me() ? (ge(e), !0) : !1;
4
- }
5
- // @__NO_SIDE_EFFECTS__
6
- function ee() {
7
- const e = /* @__PURE__ */ new Set(), t = (i) => {
8
- e.delete(i);
9
- };
10
- return {
11
- on: (i) => {
12
- e.add(i);
13
- const a = () => t(i);
14
- return z(a), {
15
- off: a
16
- };
17
- },
18
- off: t,
19
- trigger: (...i) => Promise.all(Array.from(e).map((a) => a(...i))),
20
- clear: () => {
21
- e.clear();
22
- }
23
- };
24
- }
25
- const B = /* @__PURE__ */ new WeakMap(), Ee = /* @__NO_SIDE_EFFECTS__ */ (...e) => {
26
- var t;
27
- const o = e[0], n = (t = j()) == null ? void 0 : t.proxy;
28
- if (n == null && !le())
29
- throw new Error("injectLocal must be called in setup");
30
- return n && B.has(n) && o in B.get(n) ? B.get(n)[o] : we(...e);
31
- }, $ = typeof window < "u" && typeof document < "u";
32
- typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
33
- const xe = (e) => e != null, We = Object.prototype.toString, Me = (e) => We.call(e) === "[object Object]", W = () => {
34
- }, Ie = (e, t) => Object.prototype.hasOwnProperty.call(e, t), Pe = /* @__PURE__ */ Ae();
35
- function Ae() {
36
- var e, t;
37
- return $ && ((e = window == null ? void 0 : window.navigator) == null ? void 0 : e.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((t = window == null ? void 0 : window.navigator) == null ? void 0 : t.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window == null ? void 0 : window.navigator.userAgent));
38
- }
39
- function Y(e, t) {
40
- function o(...n) {
41
- return new Promise((u, i) => {
42
- Promise.resolve(e(() => t.apply(this, n), { fn: t, thisArg: this, args: n })).then(u).catch(i);
43
- });
44
- }
45
- return o;
46
- }
47
- const Fe = (e) => e();
48
- function ue(e, t = {}) {
49
- let o, n, u = W;
50
- const i = (s) => {
51
- clearTimeout(s), u(), u = W;
1
+ import { ref as _, onMounted as ne, onBeforeUnmount as oe, defineComponent as P, createElementBlock as a, openBlock as r, createElementVNode as w, createVNode as $, unref as n, toDisplayString as B, mergeModels as W, useModel as j, computed as I, normalizeStyle as ie, Fragment as S, renderList as V, createBlock as H, resolveDynamicComponent as Y, nextTick as se, normalizeClass as U, withDirectives as q, createCommentVNode as G, renderSlot as A, withKeys as F, withModifiers as J, isRef as le, vModelText as re, vShow as ae } from "vue";
2
+ import { IconEmptySearch as ue, IconEditPen as ce, IconDelete as de, IconCheck as me, IconClose as fe, IconMenu2 as pe } from "@opentiny/tiny-robot-svgs";
3
+ import { _ as z } from "./_plugin-vue_export-helper.js";
4
+ import { o as Z, c as ve, e as ge, d as ye } from "./index4.js";
5
+ import { t as O } from "./utils.js";
6
+ const D = _(!1);
7
+ let T = 0, b;
8
+ function _e() {
9
+ const s = window.matchMedia("(hover: none) and (pointer: coarse)"), m = () => {
10
+ D.value = s.matches;
52
11
  };
53
- let a;
54
- return (s) => {
55
- const d = w(e), v = w(t.maxWait);
56
- return o && i(o), d <= 0 || v !== void 0 && v <= 0 ? (n && (i(n), n = void 0), Promise.resolve(s())) : new Promise((l, c) => {
57
- u = t.rejectOnCancel ? c : l, a = s, v && !n && (n = setTimeout(() => {
58
- o && i(o), n = void 0, l(a());
59
- }, v)), o = setTimeout(() => {
60
- n && i(n), n = void 0, l(s());
61
- }, d);
62
- });
63
- };
64
- }
65
- function ce(...e) {
66
- let t = 0, o, n = !0, u = W, i, a, r, s, d;
67
- !ie(e[0]) && typeof e[0] == "object" ? { delay: a, trailing: r = !0, leading: s = !0, rejectOnCancel: d = !1 } = e[0] : [a, r = !0, s = !0, d = !1] = e;
68
- const v = () => {
69
- o && (clearTimeout(o), o = void 0, u(), u = W);
12
+ m(), s.addEventListener("change", m);
13
+ const t = (c) => {
14
+ D.value = c.pointerType !== "mouse";
70
15
  };
71
- return (c) => {
72
- const p = w(a), h = Date.now() - t, O = () => i = c();
73
- return v(), p <= 0 ? (t = Date.now(), O()) : (h > p && (s || !n) ? (t = Date.now(), O()) : r && (i = new Promise((f, m) => {
74
- u = d ? m : f, o = setTimeout(() => {
75
- t = Date.now(), n = !0, f(O()), v();
76
- }, Math.max(0, p - h));
77
- })), !s && !o && (o = setTimeout(() => n = !0, p)), n = !1, i);
16
+ return window.addEventListener("pointerdown", t, !0), () => {
17
+ s.removeEventListener("change", m), window.removeEventListener("pointerdown", t, !0);
78
18
  };
79
19
  }
80
- function te(e) {
81
- return e.endsWith("rem") ? Number.parseFloat(e) * 16 : Number.parseFloat(e);
20
+ function he() {
21
+ b == null || b(), b = void 0;
82
22
  }
83
- function _e(e, t, o = !1) {
84
- return t.reduce((n, u) => (u in e && (!o || e[u] !== void 0) && (n[u] = e[u]), n), {});
85
- }
86
- function C(e) {
87
- return Array.isArray(e) ? e : [e];
88
- }
89
- function Le(e) {
90
- return j();
91
- }
92
- // @__NO_SIDE_EFFECTS__
93
- function ke(e, t = 200, o = {}) {
94
- return Y(
95
- ue(t, o),
96
- e
97
- );
98
- }
99
- // @__NO_SIDE_EFFECTS__
100
- function De(e, t = 200, o = !1, n = !0, u = !1) {
101
- return Y(
102
- ce(t, o, n, u),
103
- e
104
- );
105
- }
106
- function ae(e, t, o = {}) {
107
- const {
108
- eventFilter: n = Fe,
109
- ...u
110
- } = o;
111
- return k(
112
- e,
113
- Y(
114
- n,
115
- t
116
- ),
117
- u
118
- );
23
+ function Ce() {
24
+ return typeof window > "u" ? {
25
+ isTouchDevice: D
26
+ } : (ne(() => {
27
+ T++, T === 1 && (b = _e());
28
+ }), oe(() => {
29
+ T = Math.max(0, T - 1), T === 0 && he();
30
+ }), {
31
+ isTouchDevice: D
32
+ });
119
33
  }
120
- function Re(e, t = {}) {
121
- if (!ie(e))
122
- return be(e);
123
- const o = Array.isArray(e.value) ? Array.from({ length: e.value.length }) : {};
124
- for (const n in e.value)
125
- o[n] = ye(() => ({
126
- get() {
127
- return e.value[n];
34
+ const ke = { class: "tr-history__empty" }, Le = { class: "tr-history__empty-icon" }, Ee = { class: "tr-history__empty-text" }, we = /* @__PURE__ */ P({
35
+ __name: "Empty",
36
+ props: {
37
+ text: { default: "暂无内容" }
38
+ },
39
+ setup(s) {
40
+ const m = s;
41
+ return (t, c) => (r(), a("div", ke, [
42
+ w("span", Le, [
43
+ $(n(ue))
44
+ ]),
45
+ w("span", Ee, B(m.text), 1)
46
+ ]));
47
+ }
48
+ }), Re = /* @__PURE__ */ z(we, [["__scopeId", "data-v-d0340c39"]]), Ie = ["onClick"], Q = 4, xe = /* @__PURE__ */ P({
49
+ __name: "MenuList",
50
+ props: /* @__PURE__ */ W({
51
+ items: {},
52
+ menuListGap: { default: 8 }
53
+ }, {
54
+ trigger: { default: null },
55
+ triggerModifiers: {},
56
+ data: { default: null },
57
+ dataModifiers: {}
58
+ }),
59
+ emits: /* @__PURE__ */ W(["item-click"], ["update:trigger", "update:data"]),
60
+ setup(s, { emit: m }) {
61
+ const t = j(s, "trigger"), c = j(s, "data"), h = s, C = m, E = _(null);
62
+ Z(
63
+ E,
64
+ () => {
65
+ t.value = null, c.value = null;
128
66
  },
129
- set(u) {
130
- var i;
131
- if ((i = w(t.replaceRef)) != null ? i : !0)
132
- if (Array.isArray(e.value)) {
133
- const r = [...e.value];
134
- r[n] = u, e.value = r;
135
- } else {
136
- const r = { ...e.value, [n]: u };
137
- Object.setPrototypeOf(r, Object.getPrototypeOf(e.value)), e.value = r;
138
- }
139
- else
140
- e.value[n] = u;
67
+ {
68
+ ignore: [t]
141
69
  }
142
- }));
143
- return o;
144
- }
145
- function N(e, t = !0, o) {
146
- Le() ? re(e, o) : t ? e() : he(e);
147
- }
148
- function Xe(e, t, o = {}) {
149
- const {
150
- debounce: n = 0,
151
- maxWait: u = void 0,
152
- ...i
153
- } = o;
154
- return ae(
155
- e,
156
- t,
157
- {
158
- ...i,
159
- eventFilter: ue(n, { maxWait: u })
160
- }
161
- );
162
- }
163
- function Ce(e, t, o) {
164
- return k(
165
- e,
166
- t,
167
- {
168
- ...o,
169
- immediate: !0
170
- }
171
- );
172
- }
173
- function Qe(e, t, o = {}) {
174
- const {
175
- throttle: n = 0,
176
- trailing: u = !0,
177
- leading: i = !0,
178
- ...a
179
- } = o;
180
- return ae(
181
- e,
182
- t,
183
- {
184
- ...a,
185
- eventFilter: ce(n, u, i)
186
- }
187
- );
188
- }
189
- const A = $ ? window : void 0, Ve = $ ? window.document : void 0;
190
- function S(e) {
191
- var t;
192
- const o = w(e);
193
- return (t = o == null ? void 0 : o.$el) != null ? t : o;
194
- }
195
- function M(...e) {
196
- const t = [], o = () => {
197
- t.forEach((r) => r()), t.length = 0;
198
- }, n = (r, s, d, v) => (r.addEventListener(s, d, v), () => r.removeEventListener(s, d, v)), u = P(() => {
199
- const r = C(w(e[0])).filter((s) => s != null);
200
- return r.every((s) => typeof s != "string") ? r : void 0;
201
- }), i = Ce(
202
- () => {
203
- var r, s;
204
- return [
205
- (s = (r = u.value) == null ? void 0 : r.map((d) => S(d))) != null ? s : [A].filter((d) => d != null),
206
- C(w(u.value ? e[1] : e[0])),
207
- C(Oe(u.value ? e[2] : e[1])),
208
- // @ts-expect-error - TypeScript gets the correct types, but somehow still complains
209
- w(u.value ? e[3] : e[2])
210
- ];
211
- },
212
- ([r, s, d, v]) => {
213
- if (o(), !(r != null && r.length) || !(s != null && s.length) || !(d != null && d.length))
214
- return;
215
- const l = Me(v) ? { ...v } : v;
216
- t.push(
217
- ...r.flatMap(
218
- (c) => s.flatMap(
219
- (p) => d.map((h) => n(c, p, h, l))
220
- )
221
- )
222
- );
223
- },
224
- { flush: "post" }
225
- ), a = () => {
226
- i(), o();
227
- };
228
- return z(o), a;
229
- }
230
- let ne = !1;
231
- function Ue(e, t, o = {}) {
232
- const { window: n = A, ignore: u = [], capture: i = !0, detectIframe: a = !1, controls: r = !1 } = o;
233
- if (!n)
234
- return r ? { stop: W, cancel: W, trigger: W } : W;
235
- if (Pe && !ne) {
236
- ne = !0;
237
- const f = { passive: !0 };
238
- Array.from(n.document.body.children).forEach((m) => m.addEventListener("click", W, f)), n.document.documentElement.addEventListener("click", W, f);
239
- }
240
- let s = !0;
241
- const d = (f) => w(u).some((m) => {
242
- if (typeof m == "string")
243
- return Array.from(n.document.querySelectorAll(m)).some((b) => b === f.target || f.composedPath().includes(b));
244
- {
245
- const b = S(m);
246
- return b && (f.target === b || f.composedPath().includes(b));
247
- }
248
- });
249
- function v(f) {
250
- const m = w(f);
251
- return m && m.$.subTree.shapeFlag === 16;
252
- }
253
- function l(f, m) {
254
- const b = w(f), T = b.$.subTree && b.$.subTree.children;
255
- return T == null || !Array.isArray(T) ? !1 : T.some((E) => E.el === m.target || m.composedPath().includes(E.el));
70
+ );
71
+ const { top: p, bottom: x, left: y } = ve(t), { width: M, height: k } = ge(E, void 0, { box: "border-box" }), { height: R } = ye(), o = I(() => {
72
+ const L = {
73
+ left: `min(${O(y.value)}, calc(100% - ${O(M.value + Q)}))`
74
+ }, g = x.value + h.menuListGap;
75
+ return g + k.value + Q > R.value ? L.bottom = `calc(100% - ${O(p.value - h.menuListGap)})` : L.top = O(g), L;
76
+ }), v = (L) => {
77
+ C("item-click", L), t.value = null, c.value = null;
78
+ };
79
+ return (L, g) => (r(), a("ul", {
80
+ class: "tr-history__menu-list",
81
+ ref_key: "menuRef",
82
+ ref: E,
83
+ style: ie(o.value)
84
+ }, [
85
+ (r(!0), a(S, null, V(h.items, (u) => (r(), a("li", {
86
+ class: "tr-history__menu-list__item",
87
+ key: u.id,
88
+ onClick: (K) => v(u)
89
+ }, [
90
+ (r(), H(Y(u.icon))),
91
+ w("span", null, B(u.text), 1)
92
+ ], 8, Ie))), 128))
93
+ ], 4));
256
94
  }
257
- const c = (f) => {
258
- const m = S(e);
259
- if (f.target != null && !(!(m instanceof Element) && v(e) && l(e, f)) && !(!m || m === f.target || f.composedPath().includes(m))) {
260
- if ("detail" in f && f.detail === 0 && (s = !d(f)), !s) {
261
- s = !0;
262
- return;
263
- }
264
- t(f);
265
- }
95
+ }), Me = /* @__PURE__ */ z(xe, [["__scopeId", "data-v-89fdb41c"]]), Te = ({
96
+ renameControlOnClickOutside: s,
97
+ onItemTitleChange: m
98
+ }) => {
99
+ const t = _(void 0), c = _(null), h = I(() => {
100
+ var o;
101
+ return (o = c.value) == null ? void 0 : o.at(0);
102
+ }), C = _(null), E = I(() => {
103
+ var o;
104
+ return (o = C.value) == null ? void 0 : o.at(0);
105
+ }), p = _(null), x = I(() => {
106
+ var o;
107
+ return (o = p.value) == null ? void 0 : o.at(0);
108
+ }), y = _(""), M = (o) => {
109
+ t.value = o, y.value = o.title, se(() => {
110
+ const v = h.value;
111
+ v && (v.focus(), v.select());
112
+ });
113
+ }, k = () => {
114
+ t.value = void 0, y.value = "";
115
+ }, R = () => {
116
+ t.value && m(y.value, t.value), t.value = void 0, y.value = "";
266
117
  };
267
- let p = !1;
268
- const h = [
269
- M(n, "click", (f) => {
270
- p || (p = !0, setTimeout(() => {
271
- p = !1;
272
- }, 0), c(f));
273
- }, { passive: !0, capture: i }),
274
- M(n, "pointerdown", (f) => {
275
- const m = S(e);
276
- s = !d(f) && !!(m && !f.composedPath().includes(m));
277
- }, { passive: !0 }),
278
- a && M(n, "blur", (f) => {
279
- setTimeout(() => {
280
- var m;
281
- const b = S(e);
282
- ((m = n.document.activeElement) == null ? void 0 : m.tagName) === "IFRAME" && !(b != null && b.contains(n.document.activeElement)) && t(f);
283
- }, 0);
284
- }, { passive: !0 })
285
- ].filter(Boolean), O = () => h.forEach((f) => f());
286
- return r ? {
287
- stop: O,
288
- cancel: () => {
289
- s = !1;
290
- },
291
- trigger: (f) => {
292
- s = !0, c(f), s = !1;
293
- }
294
- } : O;
295
- }
296
- // @__NO_SIDE_EFFECTS__
297
- function He() {
298
- const e = y(!1), t = j();
299
- return t && re(() => {
300
- e.value = !0;
301
- }, t), e;
302
- }
303
- // @__NO_SIDE_EFFECTS__
304
- function G(e) {
305
- const t = /* @__PURE__ */ He();
306
- return P(() => (t.value, !!e()));
307
- }
308
- function fe(e, t, o = {}) {
309
- const { window: n = A, ...u } = o;
310
- let i;
311
- const a = /* @__PURE__ */ G(() => n && "MutationObserver" in n), r = () => {
312
- i && (i.disconnect(), i = void 0);
313
- }, s = P(() => {
314
- const c = w(e), p = C(c).map(S).filter(xe);
315
- return new Set(p);
316
- }), d = k(
317
- s,
318
- (c) => {
319
- r(), a.value && c.size && (i = new MutationObserver(t), c.forEach((p) => i.observe(p, u)));
118
+ return (s === "confirm" || s === "cancel") && Z(
119
+ h,
120
+ () => {
121
+ s === "confirm" ? R() : k();
320
122
  },
321
- { immediate: !0, flush: "post" }
322
- ), v = () => i == null ? void 0 : i.takeRecords(), l = () => {
323
- d(), r();
324
- };
325
- return z(l), {
326
- isSupported: a,
327
- stop: l,
328
- takeRecords: v
329
- };
330
- }
331
- const ze = Symbol("vueuse-ssr-width");
332
- // @__NO_SIDE_EFFECTS__
333
- function Ne() {
334
- const e = le() ? /* @__PURE__ */ Ee(ze, null) : null;
335
- return typeof e == "number" ? e : void 0;
336
- }
337
- function Be(e, t = {}) {
338
- const { window: o = A, ssrWidth: n = /* @__PURE__ */ Ne() } = t, u = /* @__PURE__ */ G(() => o && "matchMedia" in o && typeof o.matchMedia == "function"), i = y(typeof n == "number"), a = y(), r = y(!1), s = (d) => {
339
- r.value = d.matches;
123
+ { ignore: [E, x] }
124
+ ), {
125
+ editingItem: t,
126
+ editorRefList: c,
127
+ editorConfirmRefList: C,
128
+ editorCancelRefList: p,
129
+ editorValue: y,
130
+ handleEdit: M,
131
+ handleEditCancel: k,
132
+ handleEditConfirm: R
340
133
  };
341
- return se(() => {
342
- if (i.value) {
343
- i.value = !u.value;
344
- const d = w(e).split(",");
345
- r.value = d.some((v) => {
346
- const l = v.includes("not all"), c = v.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), p = v.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
347
- let h = !!(c || p);
348
- return c && h && (h = n >= te(c[1])), p && h && (h = n <= te(p[1])), l ? !h : h;
349
- });
350
- return;
351
- }
352
- u.value && (a.value = o.matchMedia(w(e)), r.value = a.value.matches);
353
- }), M(a, "change", s, { passive: !0 }), P(() => r.value);
354
- }
355
- function de(e, t, o = {}) {
356
- const { window: n = A, ...u } = o;
357
- let i;
358
- const a = /* @__PURE__ */ G(() => n && "ResizeObserver" in n), r = () => {
359
- i && (i.disconnect(), i = void 0);
360
- }, s = P(() => {
361
- const l = w(e);
362
- return Array.isArray(l) ? l.map((c) => S(c)) : [S(l)];
363
- }), d = k(
364
- s,
365
- (l) => {
366
- if (r(), a.value && n) {
367
- i = new ResizeObserver(t);
368
- for (const c of l)
369
- c && i.observe(c, u);
134
+ }, X = Symbol("NO_GROUP"), $e = {
135
+ key: 0,
136
+ class: "tr-history__group-title"
137
+ }, be = { class: "tr-history__group-items" }, Ge = ["onClick"], Oe = ["title"], Se = ["onClick"], Be = /* @__PURE__ */ P({
138
+ __name: "index",
139
+ props: {
140
+ data: {},
141
+ selected: {},
142
+ showRenameControls: { type: Boolean, default: !1 },
143
+ renameControlOnClickOutside: { default: "confirm" },
144
+ menuItems: { default: () => [
145
+ { id: "rename", text: "重命名", icon: ce },
146
+ { id: "delete", text: "删除", icon: de }
147
+ ] },
148
+ menuListGap: { default: 8 }
149
+ },
150
+ emits: ["item-click", "item-title-change", "item-action"],
151
+ setup(s, { emit: m }) {
152
+ const t = s, c = m, h = (i) => {
153
+ var f;
154
+ const e = typeof ((f = i[0]) == null ? void 0 : f.group);
155
+ return e === "string" || e === "symbol";
156
+ }, C = I(() => {
157
+ const i = t.data;
158
+ return h(i) ? i : [{ group: X, items: i }];
159
+ }), E = I(() => C.value.length === 0 || C.value.every((i) => i.items.length === 0)), {
160
+ editingItem: p,
161
+ editorRefList: x,
162
+ editorConfirmRefList: y,
163
+ editorCancelRefList: M,
164
+ editorValue: k,
165
+ handleEdit: R,
166
+ handleEditCancel: o,
167
+ handleEditConfirm: v
168
+ } = Te({
169
+ renameControlOnClickOutside: t.renameControlOnClickOutside,
170
+ onItemTitleChange: (i, e) => {
171
+ c("item-title-change", i, e);
370
172
  }
371
- },
372
- { immediate: !0, flush: "post" }
373
- ), v = () => {
374
- r(), d();
375
- };
376
- return z(v), {
377
- isSupported: a,
378
- stop: v
379
- };
380
- }
381
- function qe(e, t = {}) {
382
- const {
383
- reset: o = !0,
384
- windowResize: n = !0,
385
- windowScroll: u = !0,
386
- immediate: i = !0,
387
- updateTiming: a = "sync"
388
- } = t, r = y(0), s = y(0), d = y(0), v = y(0), l = y(0), c = y(0), p = y(0), h = y(0);
389
- function O() {
390
- const m = S(e);
391
- if (!m) {
392
- o && (r.value = 0, s.value = 0, d.value = 0, v.value = 0, l.value = 0, c.value = 0, p.value = 0, h.value = 0);
393
- return;
394
- }
395
- const b = m.getBoundingClientRect();
396
- r.value = b.height, s.value = b.bottom, d.value = b.left, v.value = b.right, l.value = b.top, c.value = b.width, p.value = b.x, h.value = b.y;
397
- }
398
- function f() {
399
- a === "sync" ? O() : a === "next-frame" && requestAnimationFrame(() => O());
400
- }
401
- return de(e, f), k(() => S(e), (m) => !m && f()), fe(e, f, {
402
- attributeFilter: ["style", "class"]
403
- }), u && M("scroll", f, { capture: !0, passive: !0 }), n && M("resize", f, { passive: !0 }), N(() => {
404
- i && f();
405
- }), {
406
- height: r,
407
- bottom: s,
408
- left: d,
409
- right: v,
410
- top: l,
411
- width: c,
412
- x: p,
413
- y: h,
414
- update: f
415
- };
416
- }
417
- function Je(e, t = { width: 0, height: 0 }, o = {}) {
418
- const { window: n = A, box: u = "content-box" } = o, i = P(() => {
419
- var l, c;
420
- return (c = (l = S(e)) == null ? void 0 : l.namespaceURI) == null ? void 0 : c.includes("svg");
421
- }), a = y(t.width), r = y(t.height), { stop: s } = de(
422
- e,
423
- ([l]) => {
424
- const c = u === "border-box" ? l.borderBoxSize : u === "content-box" ? l.contentBoxSize : l.devicePixelContentBoxSize;
425
- if (n && i.value) {
426
- const p = S(e);
427
- if (p) {
428
- const h = p.getBoundingClientRect();
429
- a.value = h.width, r.value = h.height;
173
+ }), { isTouchDevice: L } = Ce(), g = _(null), u = _(null), K = (i, e) => {
174
+ if (i.currentTarget instanceof HTMLButtonElement) {
175
+ if (u.value === e) {
176
+ g.value = null, u.value = null;
177
+ return;
430
178
  }
431
- } else if (c) {
432
- const p = C(c);
433
- a.value = p.reduce((h, { inlineSize: O }) => h + O, 0), r.value = p.reduce((h, { blockSize: O }) => h + O, 0);
179
+ g.value = i.currentTarget, u.value = e;
434
180
  } else
435
- a.value = l.contentRect.width, r.value = l.contentRect.height;
436
- },
437
- o
438
- );
439
- N(() => {
440
- const l = S(e);
441
- l && (a.value = "offsetWidth" in l ? l.offsetWidth : t.width, r.value = "offsetHeight" in l ? l.offsetHeight : t.height);
442
- });
443
- const d = k(
444
- () => S(e),
445
- (l) => {
446
- a.value = l ? t.width : 0, r.value = l ? t.height : 0;
447
- }
448
- );
449
- function v() {
450
- s(), d();
451
- }
452
- return {
453
- width: a,
454
- height: r,
455
- stop: v
456
- };
457
- }
458
- const je = {
459
- multiple: !0,
460
- accept: "*",
461
- reset: !1,
462
- directory: !1
463
- };
464
- function $e(e) {
465
- if (!e)
466
- return null;
467
- if (e instanceof FileList)
468
- return e;
469
- const t = new DataTransfer();
470
- for (const o of e)
471
- t.items.add(o);
472
- return t.files;
473
- }
474
- function Ke(e = {}) {
475
- const {
476
- document: t = Ve
477
- } = e, o = Se($e(e.initialFiles)), { on: n, trigger: u } = /* @__PURE__ */ ee(), { on: i, trigger: a } = /* @__PURE__ */ ee(), r = P(() => {
478
- var l;
479
- const c = (l = S(e.input)) != null ? l : t ? t.createElement("input") : void 0;
480
- return c && (c.type = "file", c.onchange = (p) => {
481
- const h = p.target;
482
- o.value = h.files, u(o.value);
483
- }, c.oncancel = () => {
484
- a();
485
- }), c;
486
- }), s = () => {
487
- o.value = null, r.value && r.value.value && (r.value.value = "", u(null));
488
- }, d = (l) => {
489
- const c = r.value;
490
- c && (c.multiple = w(l.multiple), c.accept = w(l.accept), c.webkitdirectory = w(l.directory), Ie(l, "capture") && (c.capture = w(l.capture)));
491
- }, v = (l) => {
492
- const c = r.value;
493
- if (!c)
494
- return;
495
- const p = {
496
- ...je,
497
- ...e,
498
- ...l
181
+ g.value = null, u.value = null;
182
+ }, ee = (i) => {
183
+ const e = u.value;
184
+ e && (i.id === "rename" && R(e), c("item-action", i, e));
499
185
  };
500
- d(p), w(p.reset) && s(), c.click();
501
- };
502
- return se(() => {
503
- d(e);
504
- }), {
505
- files: Te(o),
506
- open: v,
507
- reset: s,
508
- onCancel: i,
509
- onChange: n
510
- };
511
- }
512
- const oe = 1;
513
- function Ze(e, t = {}) {
514
- const {
515
- throttle: o = 0,
516
- idle: n = 200,
517
- onStop: u = W,
518
- onScroll: i = W,
519
- offset: a = {
520
- left: 0,
521
- right: 0,
522
- top: 0,
523
- bottom: 0
524
- },
525
- observe: r = {
526
- mutation: !1
527
- },
528
- eventListenerOptions: s = {
529
- capture: !1,
530
- passive: !0
531
- },
532
- behavior: d = "auto",
533
- window: v = A,
534
- onError: l = (g) => {
535
- console.error(g);
536
- }
537
- } = t, c = typeof r == "boolean" ? {
538
- mutation: r
539
- } : r, p = y(0), h = y(0), O = P({
540
- get() {
541
- return p.value;
542
- },
543
- set(g) {
544
- m(g, void 0);
545
- }
546
- }), f = P({
547
- get() {
548
- return h.value;
549
- },
550
- set(g) {
551
- m(void 0, g);
552
- }
553
- });
554
- function m(g, _) {
555
- var x, D, R, H;
556
- if (!v)
557
- return;
558
- const I = w(e);
559
- if (!I)
560
- return;
561
- (R = I instanceof Document ? v.document.body : I) == null || R.scrollTo({
562
- top: (x = w(_)) != null ? x : f.value,
563
- left: (D = w(g)) != null ? D : O.value,
564
- behavior: w(d)
565
- });
566
- const F = ((H = I == null ? void 0 : I.document) == null ? void 0 : H.documentElement) || (I == null ? void 0 : I.documentElement) || I;
567
- O != null && (p.value = F.scrollLeft), f != null && (h.value = F.scrollTop);
568
- }
569
- const b = y(!1), T = Z({
570
- left: !0,
571
- right: !1,
572
- top: !0,
573
- bottom: !1
574
- }), E = Z({
575
- left: !1,
576
- right: !1,
577
- top: !1,
578
- bottom: !1
579
- }), X = (g) => {
580
- b.value && (b.value = !1, E.left = !1, E.right = !1, E.top = !1, E.bottom = !1, u(g));
581
- }, pe = /* @__PURE__ */ ke(X, o + n), V = (g) => {
582
- var _;
583
- if (!v)
584
- return;
585
- const x = ((_ = g == null ? void 0 : g.document) == null ? void 0 : _.documentElement) || (g == null ? void 0 : g.documentElement) || S(g), { display: D, flexDirection: R, direction: H } = getComputedStyle(x), I = H === "rtl" ? -1 : 1, F = x.scrollLeft;
586
- E.left = F < p.value, E.right = F > p.value;
587
- const U = Math.abs(F * I) <= (a.left || 0), q = Math.abs(F * I) + x.clientWidth >= x.scrollWidth - (a.right || 0) - oe;
588
- D === "flex" && R === "row-reverse" ? (T.left = q, T.right = U) : (T.left = U, T.right = q), p.value = F;
589
- let L = x.scrollTop;
590
- g === v.document && !L && (L = v.document.body.scrollTop), E.top = L < h.value, E.bottom = L > h.value;
591
- const J = Math.abs(L) <= (a.top || 0), K = Math.abs(L) + x.clientHeight >= x.scrollHeight - (a.bottom || 0) - oe;
592
- D === "flex" && R === "column-reverse" ? (T.top = K, T.bottom = J) : (T.top = J, T.bottom = K), h.value = L;
593
- }, Q = (g) => {
594
- var _;
595
- if (!v)
596
- return;
597
- const x = (_ = g.target.documentElement) != null ? _ : g.target;
598
- V(x), b.value = !0, pe(g), i(g);
599
- };
600
- return M(
601
- e,
602
- "scroll",
603
- o ? /* @__PURE__ */ De(Q, o, !0, !1) : Q,
604
- s
605
- ), N(() => {
606
- try {
607
- const g = w(e);
608
- if (!g)
609
- return;
610
- V(g);
611
- } catch (g) {
612
- l(g);
613
- }
614
- }), c != null && c.mutation && e != null && e !== v && e !== document && fe(
615
- e,
616
- () => {
617
- const g = w(e);
618
- g && V(g);
619
- },
620
- {
621
- attributes: !0,
622
- childList: !0,
623
- subtree: !0
624
- }
625
- ), M(
626
- e,
627
- "scrollend",
628
- X,
629
- s
630
- ), {
631
- x: O,
632
- y: f,
633
- isScrolling: b,
634
- arrivedState: T,
635
- directions: E,
636
- measure() {
637
- const g = w(e);
638
- v && g && V(g);
639
- }
640
- };
641
- }
642
- const ve = {
643
- x: 0,
644
- y: 0,
645
- pointerId: 0,
646
- pressure: 0,
647
- tiltX: 0,
648
- tiltY: 0,
649
- width: 0,
650
- height: 0,
651
- twist: 0,
652
- pointerType: null
653
- }, Ye = /* @__PURE__ */ Object.keys(ve);
654
- function et(e = {}) {
655
- const {
656
- target: t = A
657
- } = e, o = y(!1), n = y(e.initialValue || {});
658
- Object.assign(n.value, ve, n.value);
659
- const u = (i) => {
660
- o.value = !0, !(e.pointerTypes && !e.pointerTypes.includes(i.pointerType)) && (n.value = _e(i, Ye, !1));
661
- };
662
- if (t) {
663
- const i = { passive: !0 };
664
- M(t, ["pointerdown", "pointermove", "pointerup"], u, i), M(t, "pointerleave", () => o.value = !1, i);
186
+ return (i, e) => (r(), a("div", {
187
+ class: U(["tr-history", { "touch-device": n(L) }])
188
+ }, [
189
+ E.value ? (r(), H(Re, { key: 1 })) : (r(), a(S, { key: 0 }, [
190
+ (r(!0), a(S, null, V(C.value, (f) => (r(), a("div", {
191
+ class: "tr-history__group",
192
+ key: f.group
193
+ }, [
194
+ f.group !== n(X) ? (r(), a("div", $e, B(f.group), 1)) : G("", !0),
195
+ w("div", be, [
196
+ (r(!0), a(S, null, V(f.items, (l, te) => (r(), a("div", {
197
+ class: U(["tr-history__item", {
198
+ selected: l.id && l.id === t.selected,
199
+ editing: n(p) === l,
200
+ active: u.value === l
201
+ }]),
202
+ key: l.id || te,
203
+ onClick: (d) => c("item-click", l)
204
+ }, [
205
+ A(i.$slots, "item-prefix", { item: l }, void 0, !0),
206
+ l.icon ? (r(), H(Y(l.icon), { key: 0 })) : G("", !0),
207
+ n(p) === l ? q((r(), a("input", {
208
+ key: 1,
209
+ class: "tr-history__item-editor",
210
+ type: "text",
211
+ onClick: e[0] || (e[0] = J(() => {
212
+ }, ["stop"])),
213
+ ref_for: !0,
214
+ ref_key: "editorRefList",
215
+ ref: x,
216
+ "onUpdate:modelValue": e[1] || (e[1] = (d) => le(k) ? k.value = d : null),
217
+ onKeydown: [
218
+ e[2] || (e[2] = F(
219
+ //@ts-ignore
220
+ (...d) => n(v) && n(v)(...d),
221
+ ["enter"]
222
+ )),
223
+ e[3] || (e[3] = F(
224
+ //@ts-ignore
225
+ (...d) => n(o) && n(o)(...d),
226
+ ["escape"]
227
+ ))
228
+ ]
229
+ }, null, 544)), [
230
+ [re, n(k)]
231
+ ]) : A(i.$slots, "item-title", {
232
+ key: 2,
233
+ item: l
234
+ }, () => [
235
+ w("span", {
236
+ class: "text",
237
+ title: l.title
238
+ }, B(l.title), 9, Oe)
239
+ ], !0),
240
+ w("span", {
241
+ class: "tr-history__item-actions",
242
+ onClick: e[6] || (e[6] = J(() => {
243
+ }, ["stop"]))
244
+ }, [
245
+ t.showRenameControls && n(p) === l ? (r(), a("button", {
246
+ key: 0,
247
+ class: "editor-confirm",
248
+ ref_for: !0,
249
+ ref_key: "editorConfirmRefList",
250
+ ref: y,
251
+ onClick: e[4] || (e[4] = //@ts-ignore
252
+ (...d) => n(v) && n(v)(...d))
253
+ }, [
254
+ $(n(me))
255
+ ], 512)) : G("", !0),
256
+ t.showRenameControls && n(p) === l ? (r(), a("button", {
257
+ key: 1,
258
+ class: "editor-cancel",
259
+ ref_for: !0,
260
+ ref_key: "editorCancelRefList",
261
+ ref: M,
262
+ onClick: e[5] || (e[5] = //@ts-ignore
263
+ (...d) => n(o) && n(o)(...d))
264
+ }, [
265
+ $(n(fe))
266
+ ], 512)) : G("", !0),
267
+ w("button", {
268
+ class: U(["menu", { hidden: n(p) === l }]),
269
+ onClick: (d) => K(d, l)
270
+ }, [
271
+ $(n(pe))
272
+ ], 10, Se)
273
+ ])
274
+ ], 10, Ge))), 128))
275
+ ])
276
+ ]))), 128)),
277
+ q($(Me, {
278
+ trigger: g.value,
279
+ "onUpdate:trigger": e[7] || (e[7] = (f) => g.value = f),
280
+ data: u.value,
281
+ "onUpdate:data": e[8] || (e[8] = (f) => u.value = f),
282
+ items: t.menuItems,
283
+ "menu-list-gap": t.menuListGap,
284
+ onItemClick: ee
285
+ }, null, 8, ["trigger", "data", "items", "menu-list-gap"]), [
286
+ [ae, g.value]
287
+ ])
288
+ ], 64))
289
+ ], 2));
665
290
  }
666
- return {
667
- ...Re(n),
668
- isInside: o
669
- };
670
- }
671
- // @__NO_SIDE_EFFECTS__
672
- function tt(e = {}) {
673
- const {
674
- window: t = A,
675
- initialWidth: o = Number.POSITIVE_INFINITY,
676
- initialHeight: n = Number.POSITIVE_INFINITY,
677
- listenOrientation: u = !0,
678
- includeScrollbar: i = !0,
679
- type: a = "inner"
680
- } = e, r = y(o), s = y(n), d = () => {
681
- if (t)
682
- if (a === "outer")
683
- r.value = t.outerWidth, s.value = t.outerHeight;
684
- else if (a === "visual" && t.visualViewport) {
685
- const { width: l, height: c, scale: p } = t.visualViewport;
686
- r.value = Math.round(l * p), s.value = Math.round(c * p);
687
- } else i ? (r.value = t.innerWidth, s.value = t.innerHeight) : (r.value = t.document.documentElement.clientWidth, s.value = t.document.documentElement.clientHeight);
688
- };
689
- d(), N(d);
690
- const v = { passive: !0 };
691
- if (M("resize", d, v), t && a === "visual" && t.visualViewport && M(t.visualViewport, "resize", d, v), u) {
692
- const l = Be("(orientation: portrait)");
693
- k(l, () => d());
694
- }
695
- return { width: r, height: s };
696
- }
291
+ }), N = /* @__PURE__ */ z(Be, [["__scopeId", "data-v-97a7e8a2"]]), De = function(s) {
292
+ s.component(N.name, N);
293
+ };
294
+ Object.assign(N, {
295
+ name: "TrHistory",
296
+ install: De
297
+ });
697
298
  export {
698
- qe as a,
699
- S as b,
700
- tt as c,
701
- Je as d,
702
- Ke as e,
703
- Xe as f,
704
- M as g,
705
- Be as h,
706
- et as i,
707
- Ue as o,
708
- Ze as u,
709
- Qe as w
299
+ N as H,
300
+ Ce as u
710
301
  };