@opentiny/tiny-robot 0.3.0-alpha.1 → 0.3.0-alpha.10

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/index.js CHANGED
@@ -1,84 +1,203 @@
1
- import { Bubble as s, BubbleList as t, BubbleProvider as n } from "./bubble/index.js";
2
- import { BubbleChainMessageRenderer as E, BubbleMarkdownMessageRenderer as j, BubbleMessageClassRenderer as q } from "./bubble/index.js";
3
- import i from "./container/index.js";
4
- import a from "./conversations/index.js";
5
- import m from "./dropdown-menu/index.js";
6
- import p from "./feedback/index.js";
7
- import u from "./history/index.js";
8
- import l from "./icon-button/index.js";
9
- import { Prompt as T, Prompts as b } from "./prompts/index.js";
10
- import f from "./question/index.js";
11
- import g from "./sender/index.js";
12
- import c from "./welcome/index.js";
13
- import d from "./suggestion/index.js";
14
- import B from "./suggestion-popover/index.js";
15
- import P, { SuggestionPillButton as S } from "./suggestion-pills/index.js";
16
- const v = [
17
- s,
18
- t,
19
- n,
20
- i,
21
- a,
22
- m,
23
- p,
24
- u,
25
- l,
1
+ import T from "./attachments/index.js";
2
+ import { Bubble as E, BubbleList as x } from "./bubble/index.js";
3
+ import S from "./container/index.js";
4
+ import L from "./conversations/index.js";
5
+ import y from "./drag-overlay/index.js";
6
+ import O from "./dropdown-menu/index.js";
7
+ import C from "./feedback/index.js";
8
+ import P from "./history/index.js";
9
+ import j from "./icon-button/index.js";
10
+ import { Prompt as B, Prompts as H } from "./prompts/index.js";
11
+ import b from "./sender/index.js";
12
+ import w, { SuggestionPillButton as A } from "./suggestion-pills/index.js";
13
+ import R from "./suggestion-popover/index.js";
14
+ import W from "./welcome/index.js";
15
+ var d = /* @__PURE__ */ ((e) => (e.FileTypeNotAllowed = "file-type-not-allowed", e.FileSizeExceeded = "file-size-exceeded", e.FileCountExceeded = "file-count-exceeded", e))(d || {});
16
+ function $(e, r) {
17
+ if (!r) return !0;
18
+ const o = r.split(",").map((t) => t.trim());
19
+ return o.includes("*") ? !0 : o.some((t) => {
20
+ if (t.startsWith("."))
21
+ return e.name.toLowerCase().endsWith(t.toLowerCase());
22
+ if (t.includes("/*")) {
23
+ const a = t.split("/")[0];
24
+ return e.type.startsWith(a + "/");
25
+ } else
26
+ return e.type === t;
27
+ });
28
+ }
29
+ function _(e, r) {
30
+ return e.size <= r;
31
+ }
32
+ function M(e, r) {
33
+ return e.length <= r;
34
+ }
35
+ function k(e, r) {
36
+ const { accept: o, multiple: t, maxSize: a, maxFiles: l } = r, n = [], s = [];
37
+ if (!M(e, l))
38
+ return {
39
+ acceptedFiles: n,
40
+ rejectedFiles: Array.from(e),
41
+ rejectionReason: {
42
+ code: d.FileCountExceeded,
43
+ message: `文件数量不能超过 ${l} 个`
44
+ }
45
+ };
46
+ if (e.forEach((i) => {
47
+ $(i, o) && _(i, a) ? n.push(i) : s.push(i);
48
+ }), !t && n.length > 1)
49
+ return {
50
+ acceptedFiles: [],
51
+ rejectedFiles: n,
52
+ rejectionReason: {
53
+ code: d.FileCountExceeded,
54
+ message: "只允许上传一个文件"
55
+ }
56
+ };
57
+ if (s.length > 0) {
58
+ const i = s.some((u) => !_(u, a)), p = i ? d.FileSizeExceeded : d.FileTypeNotAllowed, c = i ? `文件大小不能超过 ${a / 1024 / 1024}MB` : `文件类型不匹配 (accept: ${o})`;
59
+ return {
60
+ acceptedFiles: n,
61
+ rejectedFiles: s,
62
+ rejectionReason: { code: p, message: c }
63
+ };
64
+ }
65
+ return { acceptedFiles: n, rejectedFiles: s, rejectionReason: null };
66
+ }
67
+ function g(e) {
68
+ return {
69
+ accept: e.accept || "*",
70
+ multiple: e.multiple ?? !0,
71
+ maxSize: e.maxSize || 1024 * 1024 * 10,
72
+ maxFiles: e.maxFiles || 3,
73
+ onDrop: e.onDrop,
74
+ onError: e.onError,
75
+ disabled: e.disabled || !1
76
+ };
77
+ }
78
+ const oe = {
79
+ /**
80
+ * 挂载指令
81
+ * @param el 元素
82
+ * @param binding 绑定
83
+ */
84
+ mounted(e, r) {
85
+ let o = 0;
86
+ const { disabled: t, onDraggingChange: a } = r.value;
87
+ e.__vDropzoneOptions__ = g(r.value);
88
+ const l = {
89
+ /**
90
+ * 拖拽进入
91
+ */
92
+ handleDragEnter: () => {
93
+ t || (o++, o === 1 && a(!0, e));
94
+ },
95
+ /**
96
+ * 拖拽覆盖
97
+ * @param e 事件
98
+ */
99
+ handleDragOver: (n) => {
100
+ t || n.preventDefault();
101
+ },
102
+ /**
103
+ * 拖拽离开
104
+ */
105
+ handleDragLeave: () => {
106
+ t || (o--, o === 0 && a(!1, null));
107
+ },
108
+ /**
109
+ * 拖拽放下
110
+ * @param e 事件
111
+ */
112
+ handleDrop: (n) => {
113
+ var m;
114
+ if (t) return;
115
+ n.preventDefault(), o = 0, a(!1, null);
116
+ const s = (m = n.dataTransfer) == null ? void 0 : m.files, { onDrop: i, onError: p, accept: c, multiple: u, maxSize: D, maxFiles: h } = e.__vDropzoneOptions__;
117
+ if (s && s.length > 0) {
118
+ const F = Array.from(s), { acceptedFiles: f, rejectedFiles: z, rejectionReason: v } = k(F, {
119
+ accept: c,
120
+ multiple: u,
121
+ maxSize: D,
122
+ maxFiles: h
123
+ });
124
+ v && p({ files: z, ...v }), f.length > 0 && i(f);
125
+ }
126
+ }
127
+ };
128
+ e.__vDropzoneHandlers__ = l, e.addEventListener("dragenter", l.handleDragEnter), e.addEventListener("dragover", l.handleDragOver), e.addEventListener("dragleave", l.handleDragLeave), e.addEventListener("drop", l.handleDrop);
129
+ },
130
+ updated(e, r) {
131
+ e.__vDropzoneOptions__ && (e.__vDropzoneOptions__ = g(r.value));
132
+ },
133
+ /**
134
+ * 卸载指令
135
+ * @param el 元素
136
+ */
137
+ unmounted(e) {
138
+ e.__vDropzoneHandlers__ && (e.removeEventListener("dragenter", e.__vDropzoneHandlers__.handleDragEnter), e.removeEventListener("dragover", e.__vDropzoneHandlers__.handleDragOver), e.removeEventListener("dragleave", e.__vDropzoneHandlers__.handleDragLeave), e.removeEventListener("drop", e.__vDropzoneHandlers__.handleDrop), delete e.__vDropzoneHandlers__), delete e.__vDropzoneOptions__;
139
+ }
140
+ }, I = [
26
141
  T,
27
- b,
28
- f,
29
- g,
30
- c,
31
- d,
32
- B,
142
+ E,
143
+ x,
144
+ S,
145
+ L,
146
+ y,
147
+ O,
148
+ C,
33
149
  P,
34
- S
35
- ], L = {
36
- install(o) {
37
- v.forEach((r) => {
38
- const e = r.name.replace(/^Tiny/, "").replace(/^Tr/, "");
39
- o.component(`Tr${e}`, r);
150
+ j,
151
+ B,
152
+ H,
153
+ b,
154
+ w,
155
+ A,
156
+ R,
157
+ W
158
+ ], ne = {
159
+ install(e) {
160
+ I.forEach((r) => {
161
+ const o = r.name.replace(/^Tiny/, "").replace(/^Tr/, "");
162
+ e.component(`Tr${o}`, r);
40
163
  });
41
164
  }
42
165
  };
43
166
  export {
44
- s as Bubble,
45
- E as BubbleChainMessageRenderer,
46
- t as BubbleList,
47
- j as BubbleMarkdownMessageRenderer,
48
- q as BubbleMessageClassRenderer,
49
- n as BubbleProvider,
50
- i as Container,
51
- a as Conversations,
52
- m as DropdownMenu,
53
- p as Feedback,
54
- u as History,
55
- l as IconButton,
56
- T as Prompt,
57
- b as Prompts,
58
- f as Question,
59
- g as Sender,
60
- d as Suggestion,
61
- S as SuggestionPillButton,
62
- P as SuggestionPills,
63
- B as SuggestionPopover,
64
- s as TrBubble,
65
- t as TrBubbleList,
66
- n as TrBubbleProvider,
67
- i as TrContainer,
68
- a as TrConversations,
69
- m as TrDropdownMenu,
70
- p as TrFeedback,
71
- u as TrHistory,
72
- l as TrIconButton,
73
- T as TrPrompt,
74
- b as TrPrompts,
75
- f as TrQuestion,
76
- g as TrSender,
77
- d as TrSuggestion,
78
- S as TrSuggestionPillButton,
79
- P as TrSuggestionPills,
80
- B as TrSuggestionPopover,
81
- c as TrWelcome,
82
- c as Welcome,
83
- L as default
167
+ T as Attachments,
168
+ E as Bubble,
169
+ x as BubbleList,
170
+ S as Container,
171
+ L as Conversations,
172
+ y as DragOverlay,
173
+ O as DropdownMenu,
174
+ C as Feedback,
175
+ P as History,
176
+ j as IconButton,
177
+ B as Prompt,
178
+ H as Prompts,
179
+ b as Sender,
180
+ A as SuggestionPillButton,
181
+ w as SuggestionPills,
182
+ R as SuggestionPopover,
183
+ T as TrAttachments,
184
+ E as TrBubble,
185
+ x as TrBubbleList,
186
+ S as TrContainer,
187
+ L as TrConversations,
188
+ y as TrDragOverlay,
189
+ O as TrDropdownMenu,
190
+ C as TrFeedback,
191
+ P as TrHistory,
192
+ j as TrIconButton,
193
+ B as TrPrompt,
194
+ H as TrPrompts,
195
+ b as TrSender,
196
+ A as TrSuggestionPillButton,
197
+ w as TrSuggestionPills,
198
+ R as TrSuggestionPopover,
199
+ W as TrWelcome,
200
+ W as Welcome,
201
+ ne as default,
202
+ oe as vDropzone
84
203
  };