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

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/index5.js ADDED
@@ -0,0 +1,301 @@
1
+ import { ref as _, onMounted as ne, onBeforeUnmount as oe, defineComponent as P, createElementBlock as a, openBlock as r, createElementVNode as w, createVNode as T, 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, d as ve, c as ge, b as ye } from "./index4.js";
5
+ import { t as O } from "./utils.js";
6
+ const D = _(!1);
7
+ let b = 0, $;
8
+ function _e() {
9
+ const s = window.matchMedia("(hover: none) and (pointer: coarse)"), m = () => {
10
+ D.value = s.matches;
11
+ };
12
+ m(), s.addEventListener("change", m);
13
+ const t = (c) => {
14
+ D.value = c.pointerType !== "mouse";
15
+ };
16
+ return window.addEventListener("pointerdown", t, !0), () => {
17
+ s.removeEventListener("change", m), window.removeEventListener("pointerdown", t, !0);
18
+ };
19
+ }
20
+ function he() {
21
+ $ == null || $(), $ = void 0;
22
+ }
23
+ function Ce() {
24
+ return typeof window > "u" ? {
25
+ isTouchDevice: D
26
+ } : (ne(() => {
27
+ b++, b === 1 && ($ = _e());
28
+ }), oe(() => {
29
+ b = Math.max(0, b - 1), b === 0 && he();
30
+ }), {
31
+ isTouchDevice: D
32
+ });
33
+ }
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
+ T(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;
66
+ },
67
+ {
68
+ ignore: [t]
69
+ }
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));
94
+ }
95
+ }), Me = /* @__PURE__ */ z(xe, [["__scopeId", "data-v-89fdb41c"]]), be = ({
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 = "";
117
+ };
118
+ return (s === "confirm" || s === "cancel") && Z(
119
+ h,
120
+ () => {
121
+ s === "confirm" ? R() : k();
122
+ },
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
133
+ };
134
+ }, X = Symbol("NO_GROUP"), Te = {
135
+ key: 0,
136
+ class: "tr-history__group-title"
137
+ }, $e = { 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
+ } = be({
169
+ renameControlOnClickOutside: t.renameControlOnClickOutside,
170
+ onItemTitleChange: (i, e) => {
171
+ c("item-title-change", i, e);
172
+ }
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;
178
+ }
179
+ g.value = i.currentTarget, u.value = e;
180
+ } else
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));
185
+ };
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", Te, B(f.group), 1)) : G("", !0),
195
+ w("div", $e, [
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
+ T(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
+ T(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
+ T(n(pe))
272
+ ], 10, Se)
273
+ ])
274
+ ], 10, Ge))), 128))
275
+ ])
276
+ ]))), 128)),
277
+ q(T(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));
290
+ }
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
+ });
298
+ export {
299
+ N as H,
300
+ Ce as u
301
+ };
package/dist/index6.js ADDED
@@ -0,0 +1,161 @@
1
+ import { onMounted as U, nextTick as B, h as C, defineComponent as _, render as R, onBeforeUnmount as D, Teleport as W, computed as h, ref as E, createBlock as F, openBlock as g, Transition as j, normalizeProps as q, guardReactiveProps as L, withCtx as Z, createElementBlock as G, createCommentVNode as J, renderSlot as K, useSlots as Q, watch as X, useAttrs as Y, resolveDynamicComponent as ee, unref as S, mergeProps as k, createVNode as te } from "vue";
2
+ import { a as oe, d as re, c as ne } from "./index4.js";
3
+ import { t as u } from "./utils.js";
4
+ import { _ as N } from "./_plugin-vue_export-helper.js";
5
+ import { u as se } from "./useSlotRefs.js";
6
+ const pe = _({
7
+ setup: (r) => () => C(W, r.propsFactory(), r.vnodeFactory()),
8
+ props: ["propsFactory", "vnodeFactory"]
9
+ });
10
+ function ae(r, n) {
11
+ let e = null, t = null, s = !1;
12
+ U(() => {
13
+ B(() => {
14
+ s || (t = document.createElement("div"), e = C(pe, { propsFactory: r, vnodeFactory: n }), R(e, t));
15
+ });
16
+ }), D(() => {
17
+ s = !0, B(() => {
18
+ t && (R(null, t), t.remove(), e = null, t = null);
19
+ });
20
+ });
21
+ }
22
+ function ce(r, n) {
23
+ return h(() => {
24
+ var v;
25
+ if (n instanceof HTMLElement)
26
+ return n;
27
+ const e = n, t = oe(r), s = (v = t == null ? void 0 : t.getRootNode) == null ? void 0 : v.call(t), i = s instanceof ShadowRoot, d = i ? s : document.body;
28
+ if (e) {
29
+ if (!i && e === "body")
30
+ return document.body;
31
+ const f = d.querySelector(e);
32
+ if (f instanceof Node) return f;
33
+ }
34
+ return d;
35
+ });
36
+ }
37
+ const ie = /* @__PURE__ */ _({
38
+ __name: "Popper",
39
+ props: {
40
+ show: { type: Boolean },
41
+ transitionProps: {}
42
+ },
43
+ setup(r, { expose: n }) {
44
+ const e = E(null);
45
+ return n({
46
+ popperRef: e
47
+ }), (t, s) => (g(), F(j, q(L(r.transitionProps)), {
48
+ default: Z(() => [
49
+ r.show ? (g(), G("div", {
50
+ key: 0,
51
+ class: "tr-base-popper",
52
+ ref_key: "popperRef",
53
+ ref: e
54
+ }, [
55
+ K(t.$slots, "default", {}, void 0, !0)
56
+ ], 512)) : J("", !0)
57
+ ]),
58
+ _: 3
59
+ }, 16));
60
+ }
61
+ }), le = /* @__PURE__ */ N(ie, [["__scopeId", "data-v-25c13ab7"]]), ue = /* @__PURE__ */ _({
62
+ inheritAttrs: !1,
63
+ __name: "index",
64
+ props: {
65
+ appendTo: {},
66
+ offset: {},
67
+ placement: {
68
+ default: "top-center"
69
+ },
70
+ preventOverflow: {
71
+ type: Boolean
72
+ },
73
+ show: {
74
+ type: Boolean
75
+ },
76
+ transitionProps: {},
77
+ triggerEvents: {}
78
+ },
79
+ setup(r, {
80
+ expose: n
81
+ }) {
82
+ const e = r, t = Q(), {
83
+ vnodes: s,
84
+ ref: i,
85
+ setRef: d
86
+ } = se(t.trigger), v = (o = {}) => {
87
+ const p = {};
88
+ for (const [c, a] of Object.entries(o))
89
+ /^on[A-Z]/.test(c) && typeof a == "function" && (p[c] = a);
90
+ return p;
91
+ }, f = E(null), b = h(() => {
92
+ var o;
93
+ return ((o = f.value) == null ? void 0 : o.popperRef) || null;
94
+ }), m = h(() => {
95
+ var o, p;
96
+ return typeof e.offset == "number" ? {
97
+ mainAxis: e.offset,
98
+ crossAxis: 0
99
+ } : {
100
+ mainAxis: ((o = e.offset) == null ? void 0 : o.mainAxis) ?? 0,
101
+ crossAxis: ((p = e.offset) == null ? void 0 : p.crossAxis) ?? 0
102
+ };
103
+ }), {
104
+ top: $,
105
+ bottom: O,
106
+ left: w,
107
+ right: V,
108
+ width: z,
109
+ update: A
110
+ } = re(i), {
111
+ width: x,
112
+ height: P
113
+ } = ne(b, void 0, {
114
+ box: "border-box"
115
+ }), H = h(() => {
116
+ const {
117
+ placement: o,
118
+ preventOverflow: p
119
+ } = e, c = {}, a = (l, y) => {
120
+ if (!p) {
121
+ c[l] = y;
122
+ return;
123
+ }
124
+ const T = u(l === "top" ? P.value : x.value);
125
+ l === "top" ? c[l] = `clamp(var(--tr-base-popper-min-top), ${y}, calc(var(--tr-base-popper-max-bottom) - ${T}))` : l === "left" && (c[l] = `clamp(var(--tr-base-popper-min-left), ${y}, calc(var(--tr-base-popper-max-right) - ${T}))`);
126
+ };
127
+ return o.includes("top") && a("top", u($.value - P.value - m.value.mainAxis)), o.includes("bottom") && a("top", u(O.value + m.value.mainAxis)), o.includes("left") && a("left", u(w.value + m.value.crossAxis)), o.includes("right") && a("left", u(V.value - x.value + m.value.crossAxis)), o.includes("center") && a("left", u(w.value + z.value / 2 - x.value / 2 + m.value.crossAxis)), c;
128
+ });
129
+ X(() => e.show, (o) => {
130
+ o && A();
131
+ }, {
132
+ flush: "post"
133
+ });
134
+ const I = ce(i, e.appendTo), M = Y();
135
+ return ae(() => ({
136
+ to: I.value
137
+ }), () => te(le, k({
138
+ ref: f,
139
+ show: e.show,
140
+ transitionProps: e.transitionProps,
141
+ style: H.value
142
+ }, M), {
143
+ default: () => {
144
+ var o;
145
+ return [(o = t.content) == null ? void 0 : o.call(t)];
146
+ }
147
+ })), n({
148
+ triggerRef: i,
149
+ popperRef: b,
150
+ update: A
151
+ }), (o, p) => (g(), F(ee(S(s)[0]), k({
152
+ ref: S(d)
153
+ }, v(e.triggerEvents)), null, 16));
154
+ }
155
+ }), fe = /* @__PURE__ */ N(ue, [["__scopeId", "data-v-f1e25842"]]);
156
+ fe.name = "TrBasePopper";
157
+ export {
158
+ fe as B,
159
+ ae as c,
160
+ ce as u
161
+ };
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as g, ref as b, useModel as k, watch as O, onUnmounted as R, createElementBlock as _, openBlock as v, createElementVNode as t, withDirectives as c, vModelText as f, createVNode as y, unref as D, createCommentVNode as $ } from "vue";
2
2
  import { TinyRadioGroup as E } from "@opentiny/vue";
3
- import { e as L } from "../index3.js";
3
+ import { e as L } from "../index4.js";
4
4
  import { _ as T } from "../_plugin-vue_export-helper.js";
5
5
  const M = { class: "form-editor__container" }, S = { class: "form-editor__item" }, F = { class: "form-editor__item" }, I = { class: "form-editor__item" }, N = { class: "form-editor__item" }, H = { class: "form-editor__item" }, w = { class: "form-editor__item" }, A = ["src"], C = "https://res.hc-cdn.com/tinyui-design/1.1.0.20250526191525/home/images/tiny-ng.svg", P = /* @__PURE__ */ g({
6
6
  __name: "FormEditor",
@@ -3,7 +3,7 @@ import { TinyPopconfirm as ve, TinySwitch as X, TinyTabs as fe, TinyTabItem as Y
3
3
  import { IconArrowRight as ke, IconArrowDown as be, IconDelete as Te, IconClose as oe, IconEmptySearch as Ce, IconPlus as Pe, IconSearch as ee } from "@opentiny/tiny-robot-svgs";
4
4
  import { _ as z } from "../_plugin-vue_export-helper.js";
5
5
  import { _ as we } from "../no-data.js";
6
- import { o as xe } from "../index3.js";
6
+ import { o as xe } from "../index4.js";
7
7
  import Se from "../mcp-add-form/index.js";
8
8
  const $e = { class: "plugin-card__main" }, Be = ["src"], Ve = { class: "plugin-card__content" }, Ae = { class: "plugin-card__info" }, Fe = { class: "plugin-card__name" }, Me = {
9
9
  key: 0,