@mieweb/ui 0.9.0-dev.4 → 0.9.0-dev.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/{chunk-DG6LIEUJ.js → chunk-22CYDCXA.js} +13 -1183
- package/dist/chunk-22CYDCXA.js.map +1 -0
- package/dist/chunk-3SD7PDCV.js +1878 -0
- package/dist/chunk-3SD7PDCV.js.map +1 -0
- package/dist/{chunk-USZ3VEPE.js → chunk-NORSXAXL.js} +853 -779
- package/dist/chunk-NORSXAXL.js.map +1 -0
- package/dist/{chunk-Z3RYJWSV.cjs → chunk-PY7XAG4D.cjs} +3 -4
- package/dist/chunk-PY7XAG4D.cjs.map +1 -0
- package/dist/chunk-T6PTKWM6.cjs +1912 -0
- package/dist/chunk-T6PTKWM6.cjs.map +1 -0
- package/dist/{chunk-DH7I5HMK.cjs → chunk-WIAQQNFU.cjs} +12 -1184
- package/dist/chunk-WIAQQNFU.cjs.map +1 -0
- package/dist/{chunk-XEZCHQHB.js → chunk-X5YM3KXY.js} +3 -4
- package/dist/chunk-X5YM3KXY.js.map +1 -0
- package/dist/{chunk-3MHG4HYB.cjs → chunk-XCNDZNY7.cjs} +855 -780
- package/dist/chunk-XCNDZNY7.cjs.map +1 -0
- package/dist/components/SuperChat/index.cjs +8 -8
- package/dist/components/SuperChat/index.d.cts +4 -4
- package/dist/components/SuperChat/index.d.ts +4 -4
- package/dist/components/SuperChat/index.js +2 -2
- package/dist/components/SuperChat/plugins/index.cjs +10 -3
- package/dist/components/SuperChat/plugins/index.cjs.map +1 -1
- package/dist/components/SuperChat/plugins/index.d.cts +3 -3
- package/dist/components/SuperChat/plugins/index.d.ts +3 -3
- package/dist/components/SuperChat/plugins/index.js +9 -2
- package/dist/components/SuperChat/plugins/index.js.map +1 -1
- package/dist/index.cjs +171 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +471 -410
- package/dist/index.d.ts +471 -410
- package/dist/index.js +95 -41
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind-preset.cjs +4 -4
- package/dist/tailwind-preset.js +1 -1
- package/dist/{types-DZDroUW8.d.cts → types-B97JNRNQ.d.cts} +1 -1
- package/dist/{types-B2RLmdVd.d.cts → types-CnPEwzlp.d.cts} +6 -2
- package/dist/{types-B2RLmdVd.d.ts → types-CnPEwzlp.d.ts} +6 -2
- package/dist/{types-9vK_YdEb.d.ts → types-gZXrfLj6.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-3MHG4HYB.cjs.map +0 -1
- package/dist/chunk-5VXRKOPR.cjs +0 -735
- package/dist/chunk-5VXRKOPR.cjs.map +0 -1
- package/dist/chunk-DG6LIEUJ.js.map +0 -1
- package/dist/chunk-DH7I5HMK.cjs.map +0 -1
- package/dist/chunk-IF3X2WZP.js +0 -705
- package/dist/chunk-IF3X2WZP.js.map +0 -1
- package/dist/chunk-USZ3VEPE.js.map +0 -1
- package/dist/chunk-XEZCHQHB.js.map +0 -1
- package/dist/chunk-Z3RYJWSV.cjs.map +0 -1
package/dist/chunk-5VXRKOPR.cjs
DELETED
|
@@ -1,735 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkS5RVSXDV_cjs = require('./chunk-S5RVSXDV.cjs');
|
|
4
|
-
var chunkAOHJILLU_cjs = require('./chunk-AOHJILLU.cjs');
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
-
var reactDom = require('react-dom');
|
|
8
|
-
|
|
9
|
-
function _interopNamespace(e) {
|
|
10
|
-
if (e && e.__esModule) return e;
|
|
11
|
-
var n = Object.create(null);
|
|
12
|
-
if (e) {
|
|
13
|
-
Object.keys(e).forEach(function (k) {
|
|
14
|
-
if (k !== 'default') {
|
|
15
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () { return e[k]; }
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
n.default = e;
|
|
24
|
-
return Object.freeze(n);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
|
-
|
|
29
|
-
function getFileType(mimeType) {
|
|
30
|
-
if (mimeType.startsWith("image/")) return "image";
|
|
31
|
-
if (mimeType.startsWith("video/")) return "video";
|
|
32
|
-
if (mimeType.startsWith("audio/")) return "audio";
|
|
33
|
-
if (mimeType.includes("pdf") || mimeType.includes("document") || mimeType.includes("text")) {
|
|
34
|
-
return "document";
|
|
35
|
-
}
|
|
36
|
-
return "file";
|
|
37
|
-
}
|
|
38
|
-
function formatFileSize(bytes) {
|
|
39
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
40
|
-
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
41
|
-
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
42
|
-
}
|
|
43
|
-
function validateFile(file, acceptedTypes, maxSize) {
|
|
44
|
-
if (acceptedTypes && acceptedTypes.length > 0) {
|
|
45
|
-
const isAccepted = acceptedTypes.some((type) => {
|
|
46
|
-
if (type.startsWith(".")) {
|
|
47
|
-
return file.name.toLowerCase().endsWith(type.toLowerCase());
|
|
48
|
-
}
|
|
49
|
-
if (type.endsWith("/*")) {
|
|
50
|
-
return file.type.startsWith(type.replace("/*", "/"));
|
|
51
|
-
}
|
|
52
|
-
return file.type === type;
|
|
53
|
-
});
|
|
54
|
-
if (!isAccepted) {
|
|
55
|
-
return { valid: false, error: "File type not supported" };
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (maxSize && file.size > maxSize) {
|
|
59
|
-
return {
|
|
60
|
-
valid: false,
|
|
61
|
-
error: `File too large (max ${formatFileSize(maxSize)})`
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
return { valid: true };
|
|
65
|
-
}
|
|
66
|
-
function generateAttachmentId() {
|
|
67
|
-
return `attachment-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
68
|
-
}
|
|
69
|
-
function AttachmentPreviewItem({
|
|
70
|
-
attachment,
|
|
71
|
-
onRemove,
|
|
72
|
-
onRetry,
|
|
73
|
-
disabled = false,
|
|
74
|
-
className
|
|
75
|
-
}) {
|
|
76
|
-
const { file, previewUrl, type, state, progress } = attachment;
|
|
77
|
-
const isImage = type === "image";
|
|
78
|
-
const isVideo = type === "video";
|
|
79
|
-
const isUploading = state === "uploading";
|
|
80
|
-
const isFailed = state === "failed";
|
|
81
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
82
|
-
"div",
|
|
83
|
-
{
|
|
84
|
-
className: chunkS5RVSXDV_cjs.cn(
|
|
85
|
-
"group relative overflow-hidden rounded-lg",
|
|
86
|
-
"bg-neutral-100 dark:bg-neutral-800",
|
|
87
|
-
"border border-neutral-200 dark:border-neutral-700",
|
|
88
|
-
isFailed && "border-red-500",
|
|
89
|
-
className
|
|
90
|
-
),
|
|
91
|
-
children: [
|
|
92
|
-
(isImage || isVideo) && previewUrl ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative h-20 w-20", children: [
|
|
93
|
-
isVideo ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
94
|
-
"video",
|
|
95
|
-
{
|
|
96
|
-
src: previewUrl,
|
|
97
|
-
"aria-label": file.name,
|
|
98
|
-
muted: true,
|
|
99
|
-
playsInline: true,
|
|
100
|
-
preload: "metadata",
|
|
101
|
-
className: chunkS5RVSXDV_cjs.cn(
|
|
102
|
-
"h-full w-full object-cover",
|
|
103
|
-
(isUploading || isFailed) && "opacity-50"
|
|
104
|
-
)
|
|
105
|
-
}
|
|
106
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
107
|
-
"img",
|
|
108
|
-
{
|
|
109
|
-
src: previewUrl,
|
|
110
|
-
alt: file.name,
|
|
111
|
-
className: chunkS5RVSXDV_cjs.cn(
|
|
112
|
-
"h-full w-full object-cover",
|
|
113
|
-
(isUploading || isFailed) && "opacity-50"
|
|
114
|
-
)
|
|
115
|
-
}
|
|
116
|
-
),
|
|
117
|
-
isVideo && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
118
|
-
"svg",
|
|
119
|
-
{
|
|
120
|
-
"aria-hidden": "true",
|
|
121
|
-
className: "h-6 w-6 text-white drop-shadow",
|
|
122
|
-
fill: "currentColor",
|
|
123
|
-
viewBox: "0 0 24 24",
|
|
124
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 5v14l11-7z" })
|
|
125
|
-
}
|
|
126
|
-
) })
|
|
127
|
-
] }) : (
|
|
128
|
-
/* File preview */
|
|
129
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-20 w-20 flex-col items-center justify-center p-2", children: [
|
|
130
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
131
|
-
"svg",
|
|
132
|
-
{
|
|
133
|
-
"aria-hidden": "true",
|
|
134
|
-
className: "h-8 w-8 text-neutral-500",
|
|
135
|
-
fill: "none",
|
|
136
|
-
viewBox: "0 0 24 24",
|
|
137
|
-
stroke: "currentColor",
|
|
138
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
139
|
-
"path",
|
|
140
|
-
{
|
|
141
|
-
strokeLinecap: "round",
|
|
142
|
-
strokeLinejoin: "round",
|
|
143
|
-
strokeWidth: 2,
|
|
144
|
-
d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
|
|
145
|
-
}
|
|
146
|
-
)
|
|
147
|
-
}
|
|
148
|
-
),
|
|
149
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "mt-1 max-w-full truncate px-1 text-xs text-neutral-600 dark:text-neutral-400", children: file.name.split(".").pop()?.toUpperCase() })
|
|
150
|
-
] })
|
|
151
|
-
),
|
|
152
|
-
isUploading && progress !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-black/50", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center text-white", children: [
|
|
153
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
154
|
-
"svg",
|
|
155
|
-
{
|
|
156
|
-
"aria-hidden": "true",
|
|
157
|
-
className: "mx-auto h-6 w-6 animate-spin",
|
|
158
|
-
fill: "none",
|
|
159
|
-
viewBox: "0 0 24 24",
|
|
160
|
-
children: [
|
|
161
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
162
|
-
"circle",
|
|
163
|
-
{
|
|
164
|
-
className: "opacity-25",
|
|
165
|
-
cx: "12",
|
|
166
|
-
cy: "12",
|
|
167
|
-
r: "10",
|
|
168
|
-
stroke: "currentColor",
|
|
169
|
-
strokeWidth: "4"
|
|
170
|
-
}
|
|
171
|
-
),
|
|
172
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
173
|
-
"path",
|
|
174
|
-
{
|
|
175
|
-
className: "opacity-75",
|
|
176
|
-
fill: "currentColor",
|
|
177
|
-
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
|
|
178
|
-
}
|
|
179
|
-
)
|
|
180
|
-
]
|
|
181
|
-
}
|
|
182
|
-
),
|
|
183
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "mt-1 text-xs", children: [
|
|
184
|
-
progress,
|
|
185
|
-
"%"
|
|
186
|
-
] })
|
|
187
|
-
] }) }),
|
|
188
|
-
isFailed && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-black/50", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
189
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
190
|
-
"svg",
|
|
191
|
-
{
|
|
192
|
-
"aria-hidden": "true",
|
|
193
|
-
className: "mx-auto h-6 w-6 text-red-400",
|
|
194
|
-
fill: "none",
|
|
195
|
-
viewBox: "0 0 24 24",
|
|
196
|
-
stroke: "currentColor",
|
|
197
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
198
|
-
"path",
|
|
199
|
-
{
|
|
200
|
-
strokeLinecap: "round",
|
|
201
|
-
strokeLinejoin: "round",
|
|
202
|
-
strokeWidth: 2,
|
|
203
|
-
d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
|
|
204
|
-
}
|
|
205
|
-
)
|
|
206
|
-
}
|
|
207
|
-
),
|
|
208
|
-
onRetry && /* @__PURE__ */ jsxRuntime.jsx(
|
|
209
|
-
"button",
|
|
210
|
-
{
|
|
211
|
-
type: "button",
|
|
212
|
-
onClick: onRetry,
|
|
213
|
-
disabled,
|
|
214
|
-
className: "mt-1 text-xs text-white underline hover:no-underline disabled:no-underline disabled:opacity-50",
|
|
215
|
-
children: "Retry"
|
|
216
|
-
}
|
|
217
|
-
)
|
|
218
|
-
] }) }),
|
|
219
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
220
|
-
"button",
|
|
221
|
-
{
|
|
222
|
-
type: "button",
|
|
223
|
-
onClick: onRemove,
|
|
224
|
-
disabled,
|
|
225
|
-
className: chunkS5RVSXDV_cjs.cn(
|
|
226
|
-
"absolute -end-1 -top-1 z-10",
|
|
227
|
-
"rounded-full p-1",
|
|
228
|
-
"bg-neutral-900 text-white",
|
|
229
|
-
"opacity-0 group-hover:opacity-100",
|
|
230
|
-
"focus:ring-primary-500 focus:opacity-100 focus:ring-2 focus:outline-none",
|
|
231
|
-
"transition-opacity",
|
|
232
|
-
"disabled:cursor-not-allowed disabled:group-hover:opacity-0"
|
|
233
|
-
),
|
|
234
|
-
"aria-label": `Remove ${file.name}`,
|
|
235
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
236
|
-
"svg",
|
|
237
|
-
{
|
|
238
|
-
"aria-hidden": "true",
|
|
239
|
-
className: "h-3 w-3",
|
|
240
|
-
fill: "none",
|
|
241
|
-
viewBox: "0 0 24 24",
|
|
242
|
-
stroke: "currentColor",
|
|
243
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
244
|
-
"path",
|
|
245
|
-
{
|
|
246
|
-
strokeLinecap: "round",
|
|
247
|
-
strokeLinejoin: "round",
|
|
248
|
-
strokeWidth: 2,
|
|
249
|
-
d: "M6 18L18 6M6 6l12 12"
|
|
250
|
-
}
|
|
251
|
-
)
|
|
252
|
-
}
|
|
253
|
-
)
|
|
254
|
-
}
|
|
255
|
-
),
|
|
256
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
257
|
-
"div",
|
|
258
|
-
{
|
|
259
|
-
className: chunkS5RVSXDV_cjs.cn(
|
|
260
|
-
"absolute start-0 end-0 bottom-0",
|
|
261
|
-
"bg-black/70 px-1 py-0.5",
|
|
262
|
-
"opacity-0 group-hover:opacity-100",
|
|
263
|
-
"transition-opacity"
|
|
264
|
-
),
|
|
265
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "truncate text-xs text-white", children: file.name })
|
|
266
|
-
}
|
|
267
|
-
)
|
|
268
|
-
]
|
|
269
|
-
}
|
|
270
|
-
);
|
|
271
|
-
}
|
|
272
|
-
AttachmentPreviewItem.displayName = "AttachmentPreviewItem";
|
|
273
|
-
var AttachmentPicker = React__namespace.forwardRef(
|
|
274
|
-
({
|
|
275
|
-
onFilesSelected,
|
|
276
|
-
acceptedTypes = ["image/*", "video/*", ".pdf", ".doc", ".docx"],
|
|
277
|
-
maxFileSize = 25 * 1024 * 1024,
|
|
278
|
-
// 25MB
|
|
279
|
-
maxFiles = 10,
|
|
280
|
-
multiple = true,
|
|
281
|
-
disabled = false,
|
|
282
|
-
onError,
|
|
283
|
-
className,
|
|
284
|
-
children
|
|
285
|
-
}, ref) => {
|
|
286
|
-
const inputRef = React__namespace.useRef(null);
|
|
287
|
-
React__namespace.useImperativeHandle(ref, () => inputRef.current);
|
|
288
|
-
const handleClick = () => {
|
|
289
|
-
inputRef.current?.click();
|
|
290
|
-
};
|
|
291
|
-
const handleChange = (event) => {
|
|
292
|
-
const files = Array.from(event.target.files || []);
|
|
293
|
-
if (files.length === 0) return;
|
|
294
|
-
const validFiles = [];
|
|
295
|
-
for (const file of files.slice(0, maxFiles)) {
|
|
296
|
-
const validation = validateFile(file, acceptedTypes, maxFileSize);
|
|
297
|
-
if (validation.valid) {
|
|
298
|
-
validFiles.push(file);
|
|
299
|
-
} else if (onError) {
|
|
300
|
-
onError(`${file.name}: ${validation.error}`);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
if (files.length > maxFiles && onError) {
|
|
304
|
-
onError(`Maximum ${maxFiles} files allowed`);
|
|
305
|
-
}
|
|
306
|
-
if (validFiles.length > 0) {
|
|
307
|
-
onFilesSelected(validFiles);
|
|
308
|
-
}
|
|
309
|
-
event.target.value = "";
|
|
310
|
-
};
|
|
311
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
312
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
313
|
-
"input",
|
|
314
|
-
{
|
|
315
|
-
ref: inputRef,
|
|
316
|
-
type: "file",
|
|
317
|
-
accept: acceptedTypes.join(","),
|
|
318
|
-
multiple,
|
|
319
|
-
onChange: handleChange,
|
|
320
|
-
disabled,
|
|
321
|
-
className: "sr-only",
|
|
322
|
-
"aria-label": "Select files to attach"
|
|
323
|
-
}
|
|
324
|
-
),
|
|
325
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
326
|
-
"button",
|
|
327
|
-
{
|
|
328
|
-
type: "button",
|
|
329
|
-
onClick: handleClick,
|
|
330
|
-
disabled,
|
|
331
|
-
"data-slot": "attachment-picker-button",
|
|
332
|
-
className: chunkS5RVSXDV_cjs.cn(
|
|
333
|
-
"inline-flex items-center justify-center",
|
|
334
|
-
"rounded-full p-2",
|
|
335
|
-
"text-neutral-500 hover:text-neutral-700",
|
|
336
|
-
"dark:text-neutral-400 dark:hover:text-neutral-200",
|
|
337
|
-
"hover:bg-neutral-100 dark:hover:bg-neutral-800",
|
|
338
|
-
"focus:ring-primary-500 focus:ring-2 focus:outline-none",
|
|
339
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
340
|
-
"transition-colors",
|
|
341
|
-
className
|
|
342
|
-
),
|
|
343
|
-
"aria-label": "Attach files",
|
|
344
|
-
children: children || /* @__PURE__ */ jsxRuntime.jsx(
|
|
345
|
-
"svg",
|
|
346
|
-
{
|
|
347
|
-
"aria-hidden": "true",
|
|
348
|
-
className: "h-5 w-5",
|
|
349
|
-
fill: "none",
|
|
350
|
-
viewBox: "0 0 24 24",
|
|
351
|
-
stroke: "currentColor",
|
|
352
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
353
|
-
"path",
|
|
354
|
-
{
|
|
355
|
-
strokeLinecap: "round",
|
|
356
|
-
strokeLinejoin: "round",
|
|
357
|
-
strokeWidth: 2,
|
|
358
|
-
d: "M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"
|
|
359
|
-
}
|
|
360
|
-
)
|
|
361
|
-
}
|
|
362
|
-
)
|
|
363
|
-
}
|
|
364
|
-
)
|
|
365
|
-
] });
|
|
366
|
-
}
|
|
367
|
-
);
|
|
368
|
-
AttachmentPicker.displayName = "AttachmentPicker";
|
|
369
|
-
function DragDropZone({
|
|
370
|
-
onFilesDropped,
|
|
371
|
-
acceptedTypes,
|
|
372
|
-
maxFileSize,
|
|
373
|
-
maxFiles = 10,
|
|
374
|
-
disabled = false,
|
|
375
|
-
onError,
|
|
376
|
-
overlayLabel = "Drop files here",
|
|
377
|
-
children,
|
|
378
|
-
className
|
|
379
|
-
}) {
|
|
380
|
-
const [isDragging, setIsDragging] = React__namespace.useState(false);
|
|
381
|
-
const dragCounterRef = React__namespace.useRef(0);
|
|
382
|
-
const handleDragEnter = (event) => {
|
|
383
|
-
event.preventDefault();
|
|
384
|
-
event.stopPropagation();
|
|
385
|
-
if (disabled) return;
|
|
386
|
-
dragCounterRef.current++;
|
|
387
|
-
if (event.dataTransfer.items && event.dataTransfer.items.length > 0) {
|
|
388
|
-
setIsDragging(true);
|
|
389
|
-
}
|
|
390
|
-
};
|
|
391
|
-
const handleDragLeave = (event) => {
|
|
392
|
-
event.preventDefault();
|
|
393
|
-
event.stopPropagation();
|
|
394
|
-
if (disabled) return;
|
|
395
|
-
dragCounterRef.current--;
|
|
396
|
-
if (dragCounterRef.current === 0) {
|
|
397
|
-
setIsDragging(false);
|
|
398
|
-
}
|
|
399
|
-
};
|
|
400
|
-
const handleDragOver = (event) => {
|
|
401
|
-
event.preventDefault();
|
|
402
|
-
event.stopPropagation();
|
|
403
|
-
};
|
|
404
|
-
const handleDrop = (event) => {
|
|
405
|
-
event.preventDefault();
|
|
406
|
-
event.stopPropagation();
|
|
407
|
-
if (disabled) return;
|
|
408
|
-
setIsDragging(false);
|
|
409
|
-
dragCounterRef.current = 0;
|
|
410
|
-
const files = Array.from(event.dataTransfer.files);
|
|
411
|
-
if (files.length === 0) return;
|
|
412
|
-
const validFiles = [];
|
|
413
|
-
for (const file of files.slice(0, maxFiles)) {
|
|
414
|
-
const validation = validateFile(file, acceptedTypes, maxFileSize);
|
|
415
|
-
if (validation.valid) {
|
|
416
|
-
validFiles.push(file);
|
|
417
|
-
} else if (onError) {
|
|
418
|
-
onError(`${file.name}: ${validation.error}`);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
if (files.length > maxFiles && onError) {
|
|
422
|
-
onError(`Maximum ${maxFiles} files allowed`);
|
|
423
|
-
}
|
|
424
|
-
if (validFiles.length > 0) {
|
|
425
|
-
onFilesDropped(validFiles);
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
429
|
-
"div",
|
|
430
|
-
{
|
|
431
|
-
onDragEnter: handleDragEnter,
|
|
432
|
-
onDragLeave: handleDragLeave,
|
|
433
|
-
onDragOver: handleDragOver,
|
|
434
|
-
onDrop: handleDrop,
|
|
435
|
-
className: chunkS5RVSXDV_cjs.cn("relative", className),
|
|
436
|
-
children: [
|
|
437
|
-
children,
|
|
438
|
-
isDragging && /* @__PURE__ */ jsxRuntime.jsx(
|
|
439
|
-
"div",
|
|
440
|
-
{
|
|
441
|
-
className: chunkS5RVSXDV_cjs.cn(
|
|
442
|
-
"absolute inset-0 z-50",
|
|
443
|
-
"flex items-center justify-center",
|
|
444
|
-
"bg-primary-50/90 dark:bg-primary-900/90",
|
|
445
|
-
"border-primary-500 border-2 border-dashed",
|
|
446
|
-
"rounded-lg"
|
|
447
|
-
),
|
|
448
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
449
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
450
|
-
"svg",
|
|
451
|
-
{
|
|
452
|
-
"aria-hidden": "true",
|
|
453
|
-
className: "text-primary-800 mx-auto h-12 w-12",
|
|
454
|
-
fill: "none",
|
|
455
|
-
viewBox: "0 0 24 24",
|
|
456
|
-
stroke: "currentColor",
|
|
457
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
458
|
-
"path",
|
|
459
|
-
{
|
|
460
|
-
strokeLinecap: "round",
|
|
461
|
-
strokeLinejoin: "round",
|
|
462
|
-
strokeWidth: 2,
|
|
463
|
-
d: "M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"
|
|
464
|
-
}
|
|
465
|
-
)
|
|
466
|
-
}
|
|
467
|
-
),
|
|
468
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-primary-700 dark:text-primary-300 mt-2 text-sm font-medium", children: overlayLabel })
|
|
469
|
-
] })
|
|
470
|
-
}
|
|
471
|
-
)
|
|
472
|
-
]
|
|
473
|
-
}
|
|
474
|
-
);
|
|
475
|
-
}
|
|
476
|
-
DragDropZone.displayName = "DragDropZone";
|
|
477
|
-
function CameraButton({
|
|
478
|
-
onCapture,
|
|
479
|
-
useFrontCamera = false,
|
|
480
|
-
disabled = false,
|
|
481
|
-
className
|
|
482
|
-
}) {
|
|
483
|
-
const inputRef = React__namespace.useRef(null);
|
|
484
|
-
const handleClick = () => {
|
|
485
|
-
inputRef.current?.click();
|
|
486
|
-
};
|
|
487
|
-
const handleChange = (event) => {
|
|
488
|
-
const file = event.target.files?.[0];
|
|
489
|
-
if (file) {
|
|
490
|
-
onCapture(file);
|
|
491
|
-
}
|
|
492
|
-
event.target.value = "";
|
|
493
|
-
};
|
|
494
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
495
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
496
|
-
"input",
|
|
497
|
-
{
|
|
498
|
-
ref: inputRef,
|
|
499
|
-
type: "file",
|
|
500
|
-
accept: "image/*",
|
|
501
|
-
capture: useFrontCamera ? "user" : "environment",
|
|
502
|
-
onChange: handleChange,
|
|
503
|
-
disabled,
|
|
504
|
-
className: "sr-only",
|
|
505
|
-
"aria-label": "Take a photo"
|
|
506
|
-
}
|
|
507
|
-
),
|
|
508
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
509
|
-
"button",
|
|
510
|
-
{
|
|
511
|
-
type: "button",
|
|
512
|
-
onClick: handleClick,
|
|
513
|
-
disabled,
|
|
514
|
-
className: chunkS5RVSXDV_cjs.cn(
|
|
515
|
-
"inline-flex items-center justify-center",
|
|
516
|
-
"rounded-full p-2",
|
|
517
|
-
"text-neutral-500 hover:text-neutral-700",
|
|
518
|
-
"dark:text-neutral-400 dark:hover:text-neutral-200",
|
|
519
|
-
"hover:bg-neutral-100 dark:hover:bg-neutral-800",
|
|
520
|
-
"focus:ring-primary-500 focus:ring-2 focus:outline-none",
|
|
521
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
522
|
-
"transition-colors",
|
|
523
|
-
className
|
|
524
|
-
),
|
|
525
|
-
"aria-label": "Take a photo",
|
|
526
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
527
|
-
"svg",
|
|
528
|
-
{
|
|
529
|
-
"aria-hidden": "true",
|
|
530
|
-
className: "h-5 w-5",
|
|
531
|
-
fill: "none",
|
|
532
|
-
viewBox: "0 0 24 24",
|
|
533
|
-
stroke: "currentColor",
|
|
534
|
-
children: [
|
|
535
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
536
|
-
"path",
|
|
537
|
-
{
|
|
538
|
-
strokeLinecap: "round",
|
|
539
|
-
strokeLinejoin: "round",
|
|
540
|
-
strokeWidth: 2,
|
|
541
|
-
d: "M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z"
|
|
542
|
-
}
|
|
543
|
-
),
|
|
544
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
545
|
-
"path",
|
|
546
|
-
{
|
|
547
|
-
strokeLinecap: "round",
|
|
548
|
-
strokeLinejoin: "round",
|
|
549
|
-
strokeWidth: 2,
|
|
550
|
-
d: "M15 13a3 3 0 11-6 0 3 3 0 016 0z"
|
|
551
|
-
}
|
|
552
|
-
)
|
|
553
|
-
]
|
|
554
|
-
}
|
|
555
|
-
)
|
|
556
|
-
}
|
|
557
|
-
)
|
|
558
|
-
] });
|
|
559
|
-
}
|
|
560
|
-
CameraButton.displayName = "CameraButton";
|
|
561
|
-
function activeMentionQuery(value, caret) {
|
|
562
|
-
const upToCaret = value.slice(0, caret);
|
|
563
|
-
const match = /(^|\s)@([^\s@]*)$/.exec(upToCaret);
|
|
564
|
-
if (!match) return null;
|
|
565
|
-
const query = match[2];
|
|
566
|
-
return { query, start: caret - query.length - 1 };
|
|
567
|
-
}
|
|
568
|
-
function useMentionAutocomplete({
|
|
569
|
-
options,
|
|
570
|
-
value,
|
|
571
|
-
setValue,
|
|
572
|
-
textareaRef
|
|
573
|
-
}) {
|
|
574
|
-
const enabled = !!options && options.length > 0;
|
|
575
|
-
const [mention, setMention] = React__namespace.useState(null);
|
|
576
|
-
const [highlight, setHighlight] = React__namespace.useState(0);
|
|
577
|
-
const listId = React__namespace.useId();
|
|
578
|
-
const optionId = React__namespace.useCallback(
|
|
579
|
-
(index) => `${listId}-option-${index}`,
|
|
580
|
-
[listId]
|
|
581
|
-
);
|
|
582
|
-
const suggestions = React__namespace.useMemo(() => {
|
|
583
|
-
if (!mention || !options) return [];
|
|
584
|
-
const q = mention.query.toLowerCase();
|
|
585
|
-
return options.filter((o) => o.label.toLowerCase().includes(q));
|
|
586
|
-
}, [mention, options]);
|
|
587
|
-
const menuOpen = enabled && mention !== null && suggestions.length > 0;
|
|
588
|
-
const {
|
|
589
|
-
anchorRef,
|
|
590
|
-
floatingRef,
|
|
591
|
-
style: menuStyle
|
|
592
|
-
} = chunkAOHJILLU_cjs.useAnchoredPosition({
|
|
593
|
-
open: menuOpen,
|
|
594
|
-
placement: "top-start",
|
|
595
|
-
maxHeight: 224
|
|
596
|
-
});
|
|
597
|
-
const clampedHighlight = menuOpen ? Math.min(highlight, suggestions.length - 1) : -1;
|
|
598
|
-
const activeOptionId = menuOpen ? optionId(clampedHighlight) : void 0;
|
|
599
|
-
const sync = React__namespace.useCallback(
|
|
600
|
-
(nextValue, caret) => {
|
|
601
|
-
if (!enabled) return;
|
|
602
|
-
setMention(activeMentionQuery(nextValue, caret));
|
|
603
|
-
setHighlight(0);
|
|
604
|
-
},
|
|
605
|
-
[enabled]
|
|
606
|
-
);
|
|
607
|
-
const insert = (option) => {
|
|
608
|
-
if (!mention) return;
|
|
609
|
-
const insertValue = option.value ?? option.label.split(" ")[0];
|
|
610
|
-
const before = value.slice(0, mention.start);
|
|
611
|
-
const after = value.slice(mention.start + 1 + mention.query.length);
|
|
612
|
-
const insertText = `@${insertValue} `;
|
|
613
|
-
setValue(before + insertText + after);
|
|
614
|
-
setMention(null);
|
|
615
|
-
const caret = before.length + insertText.length;
|
|
616
|
-
requestAnimationFrame(() => {
|
|
617
|
-
const el = textareaRef.current;
|
|
618
|
-
if (el) {
|
|
619
|
-
el.focus();
|
|
620
|
-
el.setSelectionRange(caret, caret);
|
|
621
|
-
}
|
|
622
|
-
});
|
|
623
|
-
};
|
|
624
|
-
const handleKeyDown = (event) => {
|
|
625
|
-
if (!menuOpen) return false;
|
|
626
|
-
if (event.key === "ArrowDown") {
|
|
627
|
-
event.preventDefault();
|
|
628
|
-
setHighlight(
|
|
629
|
-
(h) => (Math.min(h, suggestions.length - 1) + 1) % suggestions.length
|
|
630
|
-
);
|
|
631
|
-
return true;
|
|
632
|
-
}
|
|
633
|
-
if (event.key === "ArrowUp") {
|
|
634
|
-
event.preventDefault();
|
|
635
|
-
setHighlight(
|
|
636
|
-
(h) => (Math.min(h, suggestions.length - 1) - 1 + suggestions.length) % suggestions.length
|
|
637
|
-
);
|
|
638
|
-
return true;
|
|
639
|
-
}
|
|
640
|
-
if (event.key === "Enter" || event.key === "Tab") {
|
|
641
|
-
event.preventDefault();
|
|
642
|
-
const chosen = suggestions[clampedHighlight];
|
|
643
|
-
if (chosen) insert(chosen);
|
|
644
|
-
return true;
|
|
645
|
-
}
|
|
646
|
-
if (event.key === "Escape") {
|
|
647
|
-
event.preventDefault();
|
|
648
|
-
setMention(null);
|
|
649
|
-
return true;
|
|
650
|
-
}
|
|
651
|
-
return false;
|
|
652
|
-
};
|
|
653
|
-
const inputProps = enabled ? {
|
|
654
|
-
"aria-controls": menuOpen ? listId : void 0,
|
|
655
|
-
"aria-activedescendant": activeOptionId,
|
|
656
|
-
"aria-autocomplete": "list"
|
|
657
|
-
} : {};
|
|
658
|
-
return {
|
|
659
|
-
enabled,
|
|
660
|
-
menuOpen,
|
|
661
|
-
suggestions,
|
|
662
|
-
highlight: clampedHighlight,
|
|
663
|
-
listId,
|
|
664
|
-
optionId,
|
|
665
|
-
anchorRef,
|
|
666
|
-
floatingRef,
|
|
667
|
-
menuStyle,
|
|
668
|
-
sync,
|
|
669
|
-
insert,
|
|
670
|
-
setHighlight,
|
|
671
|
-
handleKeyDown,
|
|
672
|
-
inputProps
|
|
673
|
-
};
|
|
674
|
-
}
|
|
675
|
-
function MentionMenu({
|
|
676
|
-
mention,
|
|
677
|
-
label = "Mention",
|
|
678
|
-
dataSlot = "composer-mention-list"
|
|
679
|
-
}) {
|
|
680
|
-
if (!mention.menuOpen) return null;
|
|
681
|
-
return reactDom.createPortal(
|
|
682
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
683
|
-
"ul",
|
|
684
|
-
{
|
|
685
|
-
ref: mention.floatingRef,
|
|
686
|
-
style: mention.menuStyle,
|
|
687
|
-
id: mention.listId,
|
|
688
|
-
role: "listbox",
|
|
689
|
-
"aria-label": label,
|
|
690
|
-
"data-slot": dataSlot,
|
|
691
|
-
className: "w-64 overflow-y-auto rounded-lg border border-neutral-200 bg-white py-1 shadow-lg dark:border-neutral-700 dark:bg-neutral-800",
|
|
692
|
-
children: mention.suggestions.map((option, i) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
693
|
-
"button",
|
|
694
|
-
{
|
|
695
|
-
type: "button",
|
|
696
|
-
id: mention.optionId(i),
|
|
697
|
-
role: "option",
|
|
698
|
-
"aria-selected": i === mention.highlight,
|
|
699
|
-
onMouseDown: (e) => {
|
|
700
|
-
e.preventDefault();
|
|
701
|
-
mention.insert(option);
|
|
702
|
-
},
|
|
703
|
-
onMouseEnter: () => mention.setHighlight(i),
|
|
704
|
-
className: chunkS5RVSXDV_cjs.cn(
|
|
705
|
-
"flex w-full items-center gap-2 px-3 py-1.5 text-start text-sm",
|
|
706
|
-
i === mention.highlight ? "bg-primary-100 text-primary-900 dark:bg-primary-900/40 dark:text-primary-100" : "text-neutral-700 dark:text-neutral-200"
|
|
707
|
-
),
|
|
708
|
-
children: [
|
|
709
|
-
option.icon,
|
|
710
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "min-w-0 flex-1 truncate", children: [
|
|
711
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: option.label }),
|
|
712
|
-
option.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ms-1 text-xs text-neutral-400", children: option.description })
|
|
713
|
-
] }),
|
|
714
|
-
option.meta && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-neutral-400", children: option.meta })
|
|
715
|
-
]
|
|
716
|
-
}
|
|
717
|
-
) }, option.id))
|
|
718
|
-
}
|
|
719
|
-
),
|
|
720
|
-
document.body
|
|
721
|
-
);
|
|
722
|
-
}
|
|
723
|
-
MentionMenu.displayName = "MentionMenu";
|
|
724
|
-
|
|
725
|
-
exports.AttachmentPicker = AttachmentPicker;
|
|
726
|
-
exports.AttachmentPreviewItem = AttachmentPreviewItem;
|
|
727
|
-
exports.CameraButton = CameraButton;
|
|
728
|
-
exports.DragDropZone = DragDropZone;
|
|
729
|
-
exports.MentionMenu = MentionMenu;
|
|
730
|
-
exports.generateAttachmentId = generateAttachmentId;
|
|
731
|
-
exports.getFileType = getFileType;
|
|
732
|
-
exports.useMentionAutocomplete = useMentionAutocomplete;
|
|
733
|
-
exports.validateFile = validateFile;
|
|
734
|
-
//# sourceMappingURL=chunk-5VXRKOPR.cjs.map
|
|
735
|
-
//# sourceMappingURL=chunk-5VXRKOPR.cjs.map
|