@geekapps/silo-elements-nextjs 0.1.3 → 0.1.5
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/FileUploader.d.ts +1 -1
- package/dist/FileUploader.js +218 -3
- package/dist/FileUploader.js.map +1 -1
- package/dist/ImageUploader.d.ts +1 -1
- package/dist/ImageUploader.js +117 -5
- package/dist/ImageUploader.js.map +1 -1
- package/dist/MediaUploader.js +336 -14
- package/dist/MediaUploader.js.map +1 -1
- package/dist/VideoUploader.d.ts +1 -1
- package/dist/VideoUploader.js +185 -6
- package/dist/VideoUploader.js.map +1 -1
- package/dist/index.d.ts +17 -2
- package/dist/index.js +337 -15
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +10 -2
- package/package.json +1 -1
package/dist/MediaUploader.js
CHANGED
|
@@ -164,6 +164,72 @@ function ProgressBar({ progress, className = "", style }) {
|
|
|
164
164
|
}
|
|
165
165
|
);
|
|
166
166
|
}
|
|
167
|
+
var FORMATS = [
|
|
168
|
+
{ value: "webp", label: "WebP", hint: "Melhor custo-benef\xEDcio" },
|
|
169
|
+
{ value: "avif", label: "AVIF", hint: "M\xE1xima compress\xE3o" },
|
|
170
|
+
{ value: "jpeg", label: "JPEG", hint: "Compatibilidade universal" },
|
|
171
|
+
{ value: "png", label: "PNG", hint: "Sem perda" }
|
|
172
|
+
];
|
|
173
|
+
function ImageOptions({ value, onChange, style }) {
|
|
174
|
+
const fmt = value.format ?? "webp";
|
|
175
|
+
const optimize = value.optimize ?? true;
|
|
176
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 10, ...style }, children: [
|
|
177
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
178
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 11, fontWeight: 700, color: "var(--silo-text-muted, #64748b)", letterSpacing: "0.05em", textTransform: "uppercase", marginBottom: 6 }, children: "Formato de sa\xEDda" }),
|
|
179
|
+
/* @__PURE__ */ jsx("div", { style: { display: "flex", gap: 6, flexWrap: "wrap" }, children: FORMATS.map((f) => /* @__PURE__ */ jsx(
|
|
180
|
+
"button",
|
|
181
|
+
{
|
|
182
|
+
type: "button",
|
|
183
|
+
onClick: () => onChange({ ...value, format: f.value }),
|
|
184
|
+
title: f.hint,
|
|
185
|
+
style: {
|
|
186
|
+
padding: "4px 12px",
|
|
187
|
+
borderRadius: 6,
|
|
188
|
+
border: `1px solid ${fmt === f.value ? "var(--silo-accent, #6366f1)" : "var(--silo-border, #e2e8f0)"}`,
|
|
189
|
+
background: fmt === f.value ? "var(--silo-accent, #6366f1)" : "transparent",
|
|
190
|
+
color: fmt === f.value ? "#fff" : "var(--silo-text, #0f172a)",
|
|
191
|
+
fontSize: 12,
|
|
192
|
+
fontWeight: 600,
|
|
193
|
+
cursor: "pointer"
|
|
194
|
+
},
|
|
195
|
+
children: f.label
|
|
196
|
+
},
|
|
197
|
+
f.value
|
|
198
|
+
)) })
|
|
199
|
+
] }),
|
|
200
|
+
/* @__PURE__ */ jsxs("label", { style: { display: "flex", alignItems: "center", gap: 8, cursor: "pointer", userSelect: "none" }, children: [
|
|
201
|
+
/* @__PURE__ */ jsx(
|
|
202
|
+
"span",
|
|
203
|
+
{
|
|
204
|
+
onClick: () => onChange({ ...value, optimize: !optimize }),
|
|
205
|
+
style: {
|
|
206
|
+
width: 36,
|
|
207
|
+
height: 20,
|
|
208
|
+
borderRadius: 10,
|
|
209
|
+
background: optimize ? "var(--silo-accent, #6366f1)" : "var(--silo-border, #e2e8f0)",
|
|
210
|
+
position: "relative",
|
|
211
|
+
flexShrink: 0,
|
|
212
|
+
transition: "background 0.15s",
|
|
213
|
+
cursor: "pointer"
|
|
214
|
+
},
|
|
215
|
+
children: /* @__PURE__ */ jsx("span", { style: {
|
|
216
|
+
position: "absolute",
|
|
217
|
+
top: 2,
|
|
218
|
+
left: optimize ? 18 : 2,
|
|
219
|
+
width: 16,
|
|
220
|
+
height: 16,
|
|
221
|
+
borderRadius: "50%",
|
|
222
|
+
background: "#fff",
|
|
223
|
+
transition: "left 0.15s",
|
|
224
|
+
boxShadow: "0 1px 3px rgba(0,0,0,0.2)"
|
|
225
|
+
} })
|
|
226
|
+
}
|
|
227
|
+
),
|
|
228
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 12, color: "var(--silo-text, #0f172a)", fontWeight: 500 }, children: "Otimizar tamanho" }),
|
|
229
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 11, color: "var(--silo-text-muted, #94a3b8)" }, children: optimize ? "Qualidade 85 \u2014 menor tamanho" : "Qualidade m\xE1xima" })
|
|
230
|
+
] })
|
|
231
|
+
] });
|
|
232
|
+
}
|
|
167
233
|
|
|
168
234
|
// src/utils/format.ts
|
|
169
235
|
function formatBytes(bytes) {
|
|
@@ -195,6 +261,7 @@ function ImageUploader({
|
|
|
195
261
|
maxSize,
|
|
196
262
|
accept = "image/*",
|
|
197
263
|
showPreview = true,
|
|
264
|
+
showImageOptions = false,
|
|
198
265
|
image,
|
|
199
266
|
theme,
|
|
200
267
|
renderIcon,
|
|
@@ -205,23 +272,33 @@ function ImageUploader({
|
|
|
205
272
|
}) {
|
|
206
273
|
const { state, upload, pause, resume, abort, reset } = useMultipartUpload(bucket);
|
|
207
274
|
const [preview, setPreview] = useState(null);
|
|
275
|
+
const [imageOpts, setImageOpts] = useState(image ?? { format: "webp", optimize: true });
|
|
276
|
+
const [stagedFile, setStagedFile] = useState(null);
|
|
208
277
|
const t = resolveTheme(theme);
|
|
209
278
|
const vars = themeToVars(t);
|
|
210
|
-
const
|
|
211
|
-
const file = files[0];
|
|
212
|
-
if (!file) return;
|
|
279
|
+
const doUpload = useCallback(async (file, opts) => {
|
|
213
280
|
if (showPreview) setPreview(URL.createObjectURL(file));
|
|
214
281
|
try {
|
|
215
282
|
const result = await upload(file, {
|
|
216
283
|
...bucket !== void 0 && { bucket },
|
|
217
284
|
visibility,
|
|
218
|
-
|
|
285
|
+
image: opts
|
|
219
286
|
});
|
|
220
287
|
if (result) onUpload?.(result);
|
|
221
288
|
} catch (err) {
|
|
222
289
|
onError?.(err instanceof Error ? err : new Error(String(err)));
|
|
223
290
|
}
|
|
224
|
-
}, [upload, bucket, visibility,
|
|
291
|
+
}, [upload, bucket, visibility, onUpload, onError, showPreview]);
|
|
292
|
+
const handleFiles = useCallback(async (files) => {
|
|
293
|
+
const file = files[0];
|
|
294
|
+
if (!file) return;
|
|
295
|
+
if (showImageOptions) {
|
|
296
|
+
setStagedFile(file);
|
|
297
|
+
if (showPreview) setPreview(URL.createObjectURL(file));
|
|
298
|
+
} else {
|
|
299
|
+
await doUpload(file, image ?? imageOpts);
|
|
300
|
+
}
|
|
301
|
+
}, [showImageOptions, image, imageOpts, doUpload, showPreview]);
|
|
225
302
|
const containerStyle = {
|
|
226
303
|
...vars,
|
|
227
304
|
display: "flex",
|
|
@@ -263,6 +340,41 @@ function ImageUploader({
|
|
|
263
340
|
] })
|
|
264
341
|
}
|
|
265
342
|
),
|
|
343
|
+
showImageOptions && stagedFile && !isUploading && state.status !== "done" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
344
|
+
/* @__PURE__ */ jsx(
|
|
345
|
+
ImageOptions,
|
|
346
|
+
{
|
|
347
|
+
value: imageOpts,
|
|
348
|
+
onChange: setImageOpts,
|
|
349
|
+
style: { padding: "12px 14px", borderRadius: 8, border: "1px solid var(--silo-border, #e2e8f0)", background: "var(--silo-bg-hover, #f8fafc)" }
|
|
350
|
+
}
|
|
351
|
+
),
|
|
352
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 8 }, children: [
|
|
353
|
+
/* @__PURE__ */ jsx(
|
|
354
|
+
"button",
|
|
355
|
+
{
|
|
356
|
+
onClick: () => {
|
|
357
|
+
setStagedFile(null);
|
|
358
|
+
setPreview(null);
|
|
359
|
+
},
|
|
360
|
+
style: { padding: "8px 14px", borderRadius: 6, border: "1px solid var(--silo-border, #e2e8f0)", background: "transparent", color: "var(--silo-text-muted, #94a3b8)", fontSize: 13, fontWeight: 600, cursor: "pointer" },
|
|
361
|
+
children: "Cancelar"
|
|
362
|
+
}
|
|
363
|
+
),
|
|
364
|
+
/* @__PURE__ */ jsx(
|
|
365
|
+
"button",
|
|
366
|
+
{
|
|
367
|
+
onClick: () => {
|
|
368
|
+
const f = stagedFile;
|
|
369
|
+
setStagedFile(null);
|
|
370
|
+
void doUpload(f, imageOpts);
|
|
371
|
+
},
|
|
372
|
+
style: { flex: 1, padding: "8px", borderRadius: 6, border: "none", background: "var(--silo-accent, #6366f1)", color: "#fff", fontSize: 13, fontWeight: 600, cursor: "pointer" },
|
|
373
|
+
children: "Enviar imagem"
|
|
374
|
+
}
|
|
375
|
+
)
|
|
376
|
+
] })
|
|
377
|
+
] }),
|
|
266
378
|
isUploading && /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: renderProgress ? renderProgress(progress) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
267
379
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", fontSize: "13px", color: "var(--silo-text-muted)" }, children: [
|
|
268
380
|
/* @__PURE__ */ jsx("span", { children: state.status === "completing" ? "Finalizando\u2026" : state.status === "preparing" ? "Preparando\u2026" : `Parte ${state.part} de ${state.totalParts}` }),
|
|
@@ -303,6 +415,132 @@ function ImageUploader({
|
|
|
303
415
|
] })
|
|
304
416
|
] });
|
|
305
417
|
}
|
|
418
|
+
var CODECS = [
|
|
419
|
+
{ value: "h264", label: "H.264", hint: "Compatibilidade m\xE1xima" },
|
|
420
|
+
{ value: "h265", label: "H.265", hint: "Melhor compress\xE3o" },
|
|
421
|
+
{ value: "av1", label: "AV1", hint: "Futuro \u2014 menor tamanho" },
|
|
422
|
+
{ value: "vp9", label: "VP9", hint: "Open source" }
|
|
423
|
+
];
|
|
424
|
+
var RESOLUTIONS = ["360", "480", "720", "1080", "1440", "2160"];
|
|
425
|
+
var RESOLUTION_LABELS = {
|
|
426
|
+
"360": "360p",
|
|
427
|
+
"480": "480p",
|
|
428
|
+
"720": "720p",
|
|
429
|
+
"1080": "1080p",
|
|
430
|
+
"1440": "1440p",
|
|
431
|
+
"2160": "4K"
|
|
432
|
+
};
|
|
433
|
+
function VideoOptions({ value, onChange, style }) {
|
|
434
|
+
const codec = value.codec ?? "h264";
|
|
435
|
+
const transcoding = value.transcoding ?? "auto";
|
|
436
|
+
const isAuto = transcoding === "auto";
|
|
437
|
+
const selectedRes = isAuto ? [] : transcoding;
|
|
438
|
+
function toggleRes(r) {
|
|
439
|
+
if (isAuto) {
|
|
440
|
+
onChange({ ...value, transcoding: [r] });
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
const next = selectedRes.includes(r) ? selectedRes.filter((x) => x !== r) : [...selectedRes, r];
|
|
444
|
+
onChange({ ...value, transcoding: next.length === 0 ? "auto" : next });
|
|
445
|
+
}
|
|
446
|
+
function toggleFeature(key) {
|
|
447
|
+
onChange({ ...value, [key]: !value[key] });
|
|
448
|
+
}
|
|
449
|
+
const btn = (active) => ({
|
|
450
|
+
padding: "4px 10px",
|
|
451
|
+
borderRadius: 6,
|
|
452
|
+
border: `1px solid ${active ? "var(--silo-accent, #6366f1)" : "var(--silo-border, #e2e8f0)"}`,
|
|
453
|
+
background: active ? "var(--silo-accent, #6366f1)" : "transparent",
|
|
454
|
+
color: active ? "#fff" : "var(--silo-text, #0f172a)",
|
|
455
|
+
fontSize: 12,
|
|
456
|
+
fontWeight: 600,
|
|
457
|
+
cursor: "pointer"
|
|
458
|
+
});
|
|
459
|
+
const toggle = (on) => ({
|
|
460
|
+
display: "inline-flex",
|
|
461
|
+
alignItems: "center",
|
|
462
|
+
gap: 6,
|
|
463
|
+
cursor: "pointer",
|
|
464
|
+
userSelect: "none",
|
|
465
|
+
fontSize: 12,
|
|
466
|
+
color: "var(--silo-text, #0f172a)",
|
|
467
|
+
fontWeight: 500
|
|
468
|
+
});
|
|
469
|
+
function Toggle({ checked, onToggle, label }) {
|
|
470
|
+
return /* @__PURE__ */ jsxs("label", { style: toggle(), onClick: onToggle, children: [
|
|
471
|
+
/* @__PURE__ */ jsx("span", { style: {
|
|
472
|
+
width: 32,
|
|
473
|
+
height: 18,
|
|
474
|
+
borderRadius: 9,
|
|
475
|
+
flexShrink: 0,
|
|
476
|
+
background: checked ? "var(--silo-accent, #6366f1)" : "var(--silo-border, #e2e8f0)",
|
|
477
|
+
position: "relative",
|
|
478
|
+
transition: "background 0.15s",
|
|
479
|
+
cursor: "pointer"
|
|
480
|
+
}, children: /* @__PURE__ */ jsx("span", { style: {
|
|
481
|
+
position: "absolute",
|
|
482
|
+
top: 2,
|
|
483
|
+
left: checked ? 16 : 2,
|
|
484
|
+
width: 14,
|
|
485
|
+
height: 14,
|
|
486
|
+
borderRadius: "50%",
|
|
487
|
+
background: "#fff",
|
|
488
|
+
transition: "left 0.15s",
|
|
489
|
+
boxShadow: "0 1px 3px rgba(0,0,0,0.2)"
|
|
490
|
+
} }) }),
|
|
491
|
+
label
|
|
492
|
+
] });
|
|
493
|
+
}
|
|
494
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 12, ...style }, children: [
|
|
495
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
496
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 11, fontWeight: 700, color: "var(--silo-text-muted, #64748b)", letterSpacing: "0.05em", textTransform: "uppercase", marginBottom: 6 }, children: "Codec" }),
|
|
497
|
+
/* @__PURE__ */ jsx("div", { style: { display: "flex", gap: 6, flexWrap: "wrap" }, children: CODECS.map((c) => /* @__PURE__ */ jsx(
|
|
498
|
+
"button",
|
|
499
|
+
{
|
|
500
|
+
type: "button",
|
|
501
|
+
title: c.hint,
|
|
502
|
+
onClick: () => onChange({ ...value, codec: c.value }),
|
|
503
|
+
style: btn(codec === c.value),
|
|
504
|
+
children: c.label
|
|
505
|
+
},
|
|
506
|
+
c.value
|
|
507
|
+
)) })
|
|
508
|
+
] }),
|
|
509
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
510
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 11, fontWeight: 700, color: "var(--silo-text-muted, #64748b)", letterSpacing: "0.05em", textTransform: "uppercase", marginBottom: 6 }, children: "Resolu\xE7\xF5es" }),
|
|
511
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 6, flexWrap: "wrap" }, children: [
|
|
512
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => onChange({ ...value, transcoding: "auto" }), style: btn(isAuto), children: "Auto" }),
|
|
513
|
+
RESOLUTIONS.map((r) => /* @__PURE__ */ jsx(
|
|
514
|
+
"button",
|
|
515
|
+
{
|
|
516
|
+
type: "button",
|
|
517
|
+
onClick: () => toggleRes(r),
|
|
518
|
+
style: btn(!isAuto && selectedRes.includes(r)),
|
|
519
|
+
children: RESOLUTION_LABELS[r]
|
|
520
|
+
},
|
|
521
|
+
r
|
|
522
|
+
))
|
|
523
|
+
] })
|
|
524
|
+
] }),
|
|
525
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
526
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 11, fontWeight: 700, color: "var(--silo-text-muted, #64748b)", letterSpacing: "0.05em", textTransform: "uppercase", marginBottom: 8 }, children: "Recursos" }),
|
|
527
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
|
|
528
|
+
/* @__PURE__ */ jsx(Toggle, { checked: value.thumbnails ?? true, onToggle: () => toggleFeature("thumbnails"), label: "Gerar thumbnails" }),
|
|
529
|
+
/* @__PURE__ */ jsx(Toggle, { checked: value.storyboard ?? false, onToggle: () => toggleFeature("storyboard"), label: "Gerar storyboard" }),
|
|
530
|
+
/* @__PURE__ */ jsx(Toggle, { checked: value.autoCaptions ?? false, onToggle: () => toggleFeature("autoCaptions"), label: "Legendas autom\xE1ticas (IA)" }),
|
|
531
|
+
/* @__PURE__ */ jsx(Toggle, { checked: value.separateAudio ?? false, onToggle: () => toggleFeature("separateAudio"), label: "Separar faixa de \xE1udio" })
|
|
532
|
+
] })
|
|
533
|
+
] })
|
|
534
|
+
] });
|
|
535
|
+
}
|
|
536
|
+
var DEFAULT_VIDEO_OPTS = {
|
|
537
|
+
thumbnails: true,
|
|
538
|
+
storyboard: false,
|
|
539
|
+
autoCaptions: false,
|
|
540
|
+
separateAudio: false,
|
|
541
|
+
codec: "h264",
|
|
542
|
+
transcoding: "auto"
|
|
543
|
+
};
|
|
306
544
|
function VideoUploader({
|
|
307
545
|
bucket,
|
|
308
546
|
expiresIn,
|
|
@@ -315,6 +553,7 @@ function VideoUploader({
|
|
|
315
553
|
maxSize,
|
|
316
554
|
accept = "video/*",
|
|
317
555
|
showPreview = true,
|
|
556
|
+
showVideoOptions = false,
|
|
318
557
|
video,
|
|
319
558
|
theme,
|
|
320
559
|
renderIcon,
|
|
@@ -325,23 +564,33 @@ function VideoUploader({
|
|
|
325
564
|
}) {
|
|
326
565
|
const { state, upload, pause, resume, abort, reset } = useMultipartUpload(bucket);
|
|
327
566
|
const [preview, setPreview] = useState(null);
|
|
567
|
+
const [videoOpts, setVideoOpts] = useState(video ?? DEFAULT_VIDEO_OPTS);
|
|
568
|
+
const [stagedFile, setStagedFile] = useState(null);
|
|
328
569
|
const t = resolveTheme(theme);
|
|
329
570
|
const vars = themeToVars(t);
|
|
330
|
-
const
|
|
331
|
-
const file = files[0];
|
|
332
|
-
if (!file) return;
|
|
571
|
+
const doUpload = useCallback(async (file, opts) => {
|
|
333
572
|
if (showPreview) setPreview(URL.createObjectURL(file));
|
|
334
573
|
try {
|
|
335
574
|
const result = await upload(file, {
|
|
336
575
|
...bucket !== void 0 && { bucket },
|
|
337
576
|
visibility,
|
|
338
|
-
|
|
577
|
+
video: opts
|
|
339
578
|
});
|
|
340
579
|
if (result) onUpload?.(result);
|
|
341
580
|
} catch (err) {
|
|
342
581
|
onError?.(err instanceof Error ? err : new Error(String(err)));
|
|
343
582
|
}
|
|
344
|
-
}, [upload, bucket, visibility,
|
|
583
|
+
}, [upload, bucket, visibility, onUpload, onError, showPreview]);
|
|
584
|
+
const handleFiles = useCallback(async (files) => {
|
|
585
|
+
const file = files[0];
|
|
586
|
+
if (!file) return;
|
|
587
|
+
if (showVideoOptions) {
|
|
588
|
+
setStagedFile(file);
|
|
589
|
+
if (showPreview) setPreview(URL.createObjectURL(file));
|
|
590
|
+
} else {
|
|
591
|
+
await doUpload(file, video ?? videoOpts);
|
|
592
|
+
}
|
|
593
|
+
}, [showVideoOptions, video, videoOpts, doUpload, showPreview]);
|
|
345
594
|
const containerStyle = {
|
|
346
595
|
...vars,
|
|
347
596
|
display: "flex",
|
|
@@ -383,6 +632,41 @@ function VideoUploader({
|
|
|
383
632
|
] })
|
|
384
633
|
}
|
|
385
634
|
),
|
|
635
|
+
showVideoOptions && stagedFile && !isUploading && state.status !== "done" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
636
|
+
/* @__PURE__ */ jsx(
|
|
637
|
+
VideoOptions,
|
|
638
|
+
{
|
|
639
|
+
value: videoOpts,
|
|
640
|
+
onChange: setVideoOpts,
|
|
641
|
+
style: { padding: "12px 14px", borderRadius: 8, border: "1px solid var(--silo-border, #e2e8f0)", background: "var(--silo-bg-hover, #f8fafc)" }
|
|
642
|
+
}
|
|
643
|
+
),
|
|
644
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 8 }, children: [
|
|
645
|
+
/* @__PURE__ */ jsx(
|
|
646
|
+
"button",
|
|
647
|
+
{
|
|
648
|
+
onClick: () => {
|
|
649
|
+
setStagedFile(null);
|
|
650
|
+
setPreview(null);
|
|
651
|
+
},
|
|
652
|
+
style: { padding: "8px 14px", borderRadius: 6, border: "1px solid var(--silo-border, #e2e8f0)", background: "transparent", color: "var(--silo-text-muted, #94a3b8)", fontSize: 13, fontWeight: 600, cursor: "pointer" },
|
|
653
|
+
children: "Cancelar"
|
|
654
|
+
}
|
|
655
|
+
),
|
|
656
|
+
/* @__PURE__ */ jsx(
|
|
657
|
+
"button",
|
|
658
|
+
{
|
|
659
|
+
onClick: () => {
|
|
660
|
+
const f = stagedFile;
|
|
661
|
+
setStagedFile(null);
|
|
662
|
+
void doUpload(f, videoOpts);
|
|
663
|
+
},
|
|
664
|
+
style: { flex: 1, padding: "8px", borderRadius: 6, border: "none", background: "var(--silo-accent, #6366f1)", color: "#fff", fontSize: 13, fontWeight: 600, cursor: "pointer" },
|
|
665
|
+
children: "Enviar v\xEDdeo"
|
|
666
|
+
}
|
|
667
|
+
)
|
|
668
|
+
] })
|
|
669
|
+
] }),
|
|
386
670
|
isUploading && /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: renderProgress ? renderProgress(progress) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
387
671
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", fontSize: "13px", color: "var(--silo-text-muted)" }, children: [
|
|
388
672
|
/* @__PURE__ */ jsx("span", { children: state.status === "completing" ? "Finalizando\u2026" : state.status === "preparing" ? "Preparando\u2026" : `Parte ${state.part} de ${state.totalParts}` }),
|
|
@@ -398,7 +682,14 @@ function VideoUploader({
|
|
|
398
682
|
/* @__PURE__ */ jsx("span", { style: { fontSize: "12px", color: "var(--silo-text-muted)" }, children: "O processamento inicia ap\xF3s o upload" })
|
|
399
683
|
] }) }),
|
|
400
684
|
isPaused && /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
401
|
-
/* @__PURE__ */ jsx(
|
|
685
|
+
/* @__PURE__ */ jsx(
|
|
686
|
+
"button",
|
|
687
|
+
{
|
|
688
|
+
onClick: () => resume({ ...bucket !== void 0 && { bucket }, visibility, video: showVideoOptions ? videoOpts : video ?? videoOpts }),
|
|
689
|
+
style: { flex: 1, padding: "8px", borderRadius: "6px", border: "none", backgroundColor: "#10b981", color: "#fff", fontSize: "13px", fontWeight: 600, cursor: "pointer" },
|
|
690
|
+
children: "Retomar upload"
|
|
691
|
+
}
|
|
692
|
+
),
|
|
402
693
|
/* @__PURE__ */ jsx("button", { onClick: () => {
|
|
403
694
|
abort();
|
|
404
695
|
setPreview(null);
|
|
@@ -421,6 +712,14 @@ function VideoUploader({
|
|
|
421
712
|
] })
|
|
422
713
|
] });
|
|
423
714
|
}
|
|
715
|
+
var DEFAULT_VIDEO_OPTS2 = {
|
|
716
|
+
thumbnails: true,
|
|
717
|
+
storyboard: false,
|
|
718
|
+
autoCaptions: false,
|
|
719
|
+
separateAudio: false,
|
|
720
|
+
codec: "h264",
|
|
721
|
+
transcoding: "auto"
|
|
722
|
+
};
|
|
424
723
|
function FileUploader({
|
|
425
724
|
bucket,
|
|
426
725
|
visibility = "private",
|
|
@@ -434,6 +733,8 @@ function FileUploader({
|
|
|
434
733
|
accept,
|
|
435
734
|
multiple = false,
|
|
436
735
|
allowRename = false,
|
|
736
|
+
showImageOptions = false,
|
|
737
|
+
showVideoOptions = false,
|
|
437
738
|
image,
|
|
438
739
|
video,
|
|
439
740
|
theme,
|
|
@@ -456,6 +757,8 @@ function FileUploader({
|
|
|
456
757
|
};
|
|
457
758
|
const single = useMultipartUpload(bucket);
|
|
458
759
|
const batch = useBatchUpload();
|
|
760
|
+
const [imageOpts, setImageOpts] = useState(image ?? { format: "webp", optimize: true });
|
|
761
|
+
const [videoOpts, setVideoOpts] = useState(video ?? DEFAULT_VIDEO_OPTS2);
|
|
459
762
|
const [staged, setStaged] = useState(null);
|
|
460
763
|
const [renames, setRenames] = useState(/* @__PURE__ */ new Map());
|
|
461
764
|
const [editingIndex, setEditingIndex] = useState(null);
|
|
@@ -479,9 +782,11 @@ function FileUploader({
|
|
|
479
782
|
setEditingIndex(null);
|
|
480
783
|
}
|
|
481
784
|
const doUpload = useCallback(async (files) => {
|
|
785
|
+
const effectiveImage = showImageOptions ? imageOpts : image ?? imageOpts;
|
|
786
|
+
const effectiveVideo = showVideoOptions ? videoOpts : video ?? videoOpts;
|
|
482
787
|
if (multiple && files.length > 1) {
|
|
483
788
|
try {
|
|
484
|
-
const opts = { ...bucket !== void 0 && { bucket }, visibility,
|
|
789
|
+
const opts = { ...bucket !== void 0 && { bucket }, visibility, image: effectiveImage, video: effectiveVideo };
|
|
485
790
|
const results = await batch.upload(files, opts);
|
|
486
791
|
onBatchUpload?.(results);
|
|
487
792
|
results.forEach((r) => onUpload?.(r));
|
|
@@ -492,7 +797,7 @@ function FileUploader({
|
|
|
492
797
|
const file = files[0];
|
|
493
798
|
if (!file) return;
|
|
494
799
|
try {
|
|
495
|
-
const opts = { ...bucket !== void 0 && { bucket }, visibility,
|
|
800
|
+
const opts = { ...bucket !== void 0 && { bucket }, visibility, image: effectiveImage, video: effectiveVideo };
|
|
496
801
|
const result = await single.upload(file, opts);
|
|
497
802
|
if (result) onUpload?.(result);
|
|
498
803
|
} catch (err) {
|
|
@@ -501,7 +806,8 @@ function FileUploader({
|
|
|
501
806
|
}
|
|
502
807
|
}, [single, batch, multiple, bucket, visibility, image, video, onUpload, onBatchUpload, onError]);
|
|
503
808
|
const handleFiles = useCallback(async (files) => {
|
|
504
|
-
|
|
809
|
+
const needsStaging = allowRename || showImageOptions && files.some((f) => f.type.startsWith("image/")) || showVideoOptions && files.some((f) => f.type.startsWith("video/"));
|
|
810
|
+
if (needsStaging) {
|
|
505
811
|
setStaged(files);
|
|
506
812
|
setRenames(/* @__PURE__ */ new Map());
|
|
507
813
|
} else {
|
|
@@ -611,6 +917,22 @@ function FileUploader({
|
|
|
611
917
|
}
|
|
612
918
|
)
|
|
613
919
|
] }, i)),
|
|
920
|
+
showImageOptions && staged.some((f) => f.type.startsWith("image/")) && /* @__PURE__ */ jsx(
|
|
921
|
+
ImageOptions,
|
|
922
|
+
{
|
|
923
|
+
value: imageOpts,
|
|
924
|
+
onChange: setImageOpts,
|
|
925
|
+
style: { padding: "12px 14px", borderRadius: 8, border: "1px solid var(--silo-border)", background: "var(--silo-bg-hover, #f8fafc)", marginTop: 4 }
|
|
926
|
+
}
|
|
927
|
+
),
|
|
928
|
+
showVideoOptions && staged.some((f) => f.type.startsWith("video/")) && /* @__PURE__ */ jsx(
|
|
929
|
+
VideoOptions,
|
|
930
|
+
{
|
|
931
|
+
value: videoOpts,
|
|
932
|
+
onChange: setVideoOpts,
|
|
933
|
+
style: { padding: "12px 14px", borderRadius: 8, border: "1px solid var(--silo-border)", background: "var(--silo-bg-hover, #f8fafc)", marginTop: 4 }
|
|
934
|
+
}
|
|
935
|
+
),
|
|
614
936
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px", marginTop: "4px" }, children: [
|
|
615
937
|
/* @__PURE__ */ jsx(
|
|
616
938
|
"button",
|