@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/index.js
CHANGED
|
@@ -169,6 +169,72 @@ function ProgressBar({ progress, className = "", style }) {
|
|
|
169
169
|
}
|
|
170
170
|
);
|
|
171
171
|
}
|
|
172
|
+
var FORMATS = [
|
|
173
|
+
{ value: "webp", label: "WebP", hint: "Melhor custo-benef\xEDcio" },
|
|
174
|
+
{ value: "avif", label: "AVIF", hint: "M\xE1xima compress\xE3o" },
|
|
175
|
+
{ value: "jpeg", label: "JPEG", hint: "Compatibilidade universal" },
|
|
176
|
+
{ value: "png", label: "PNG", hint: "Sem perda" }
|
|
177
|
+
];
|
|
178
|
+
function ImageOptions({ value, onChange, style }) {
|
|
179
|
+
const fmt = value.format ?? "webp";
|
|
180
|
+
const optimize = value.optimize ?? true;
|
|
181
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 10, ...style }, children: [
|
|
182
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
183
|
+
/* @__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" }),
|
|
184
|
+
/* @__PURE__ */ jsx("div", { style: { display: "flex", gap: 6, flexWrap: "wrap" }, children: FORMATS.map((f) => /* @__PURE__ */ jsx(
|
|
185
|
+
"button",
|
|
186
|
+
{
|
|
187
|
+
type: "button",
|
|
188
|
+
onClick: () => onChange({ ...value, format: f.value }),
|
|
189
|
+
title: f.hint,
|
|
190
|
+
style: {
|
|
191
|
+
padding: "4px 12px",
|
|
192
|
+
borderRadius: 6,
|
|
193
|
+
border: `1px solid ${fmt === f.value ? "var(--silo-accent, #6366f1)" : "var(--silo-border, #e2e8f0)"}`,
|
|
194
|
+
background: fmt === f.value ? "var(--silo-accent, #6366f1)" : "transparent",
|
|
195
|
+
color: fmt === f.value ? "#fff" : "var(--silo-text, #0f172a)",
|
|
196
|
+
fontSize: 12,
|
|
197
|
+
fontWeight: 600,
|
|
198
|
+
cursor: "pointer"
|
|
199
|
+
},
|
|
200
|
+
children: f.label
|
|
201
|
+
},
|
|
202
|
+
f.value
|
|
203
|
+
)) })
|
|
204
|
+
] }),
|
|
205
|
+
/* @__PURE__ */ jsxs("label", { style: { display: "flex", alignItems: "center", gap: 8, cursor: "pointer", userSelect: "none" }, children: [
|
|
206
|
+
/* @__PURE__ */ jsx(
|
|
207
|
+
"span",
|
|
208
|
+
{
|
|
209
|
+
onClick: () => onChange({ ...value, optimize: !optimize }),
|
|
210
|
+
style: {
|
|
211
|
+
width: 36,
|
|
212
|
+
height: 20,
|
|
213
|
+
borderRadius: 10,
|
|
214
|
+
background: optimize ? "var(--silo-accent, #6366f1)" : "var(--silo-border, #e2e8f0)",
|
|
215
|
+
position: "relative",
|
|
216
|
+
flexShrink: 0,
|
|
217
|
+
transition: "background 0.15s",
|
|
218
|
+
cursor: "pointer"
|
|
219
|
+
},
|
|
220
|
+
children: /* @__PURE__ */ jsx("span", { style: {
|
|
221
|
+
position: "absolute",
|
|
222
|
+
top: 2,
|
|
223
|
+
left: optimize ? 18 : 2,
|
|
224
|
+
width: 16,
|
|
225
|
+
height: 16,
|
|
226
|
+
borderRadius: "50%",
|
|
227
|
+
background: "#fff",
|
|
228
|
+
transition: "left 0.15s",
|
|
229
|
+
boxShadow: "0 1px 3px rgba(0,0,0,0.2)"
|
|
230
|
+
} })
|
|
231
|
+
}
|
|
232
|
+
),
|
|
233
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 12, color: "var(--silo-text, #0f172a)", fontWeight: 500 }, children: "Otimizar tamanho" }),
|
|
234
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 11, color: "var(--silo-text-muted, #94a3b8)" }, children: optimize ? "Qualidade 85 \u2014 menor tamanho" : "Qualidade m\xE1xima" })
|
|
235
|
+
] })
|
|
236
|
+
] });
|
|
237
|
+
}
|
|
172
238
|
|
|
173
239
|
// src/utils/format.ts
|
|
174
240
|
function formatBytes(bytes) {
|
|
@@ -200,6 +266,7 @@ function ImageUploader({
|
|
|
200
266
|
maxSize,
|
|
201
267
|
accept = "image/*",
|
|
202
268
|
showPreview = true,
|
|
269
|
+
showImageOptions = false,
|
|
203
270
|
image,
|
|
204
271
|
theme,
|
|
205
272
|
renderIcon,
|
|
@@ -210,23 +277,33 @@ function ImageUploader({
|
|
|
210
277
|
}) {
|
|
211
278
|
const { state, upload, pause, resume, abort, reset } = useMultipartUpload(bucket);
|
|
212
279
|
const [preview, setPreview] = useState(null);
|
|
280
|
+
const [imageOpts, setImageOpts] = useState(image ?? { format: "webp", optimize: true });
|
|
281
|
+
const [stagedFile, setStagedFile] = useState(null);
|
|
213
282
|
const t = resolveTheme(theme);
|
|
214
283
|
const vars = themeToVars(t);
|
|
215
|
-
const
|
|
216
|
-
const file = files[0];
|
|
217
|
-
if (!file) return;
|
|
284
|
+
const doUpload = useCallback(async (file, opts) => {
|
|
218
285
|
if (showPreview) setPreview(URL.createObjectURL(file));
|
|
219
286
|
try {
|
|
220
287
|
const result = await upload(file, {
|
|
221
288
|
...bucket !== void 0 && { bucket },
|
|
222
289
|
visibility,
|
|
223
|
-
|
|
290
|
+
image: opts
|
|
224
291
|
});
|
|
225
292
|
if (result) onUpload?.(result);
|
|
226
293
|
} catch (err) {
|
|
227
294
|
onError?.(err instanceof Error ? err : new Error(String(err)));
|
|
228
295
|
}
|
|
229
|
-
}, [upload, bucket, visibility,
|
|
296
|
+
}, [upload, bucket, visibility, onUpload, onError, showPreview]);
|
|
297
|
+
const handleFiles = useCallback(async (files) => {
|
|
298
|
+
const file = files[0];
|
|
299
|
+
if (!file) return;
|
|
300
|
+
if (showImageOptions) {
|
|
301
|
+
setStagedFile(file);
|
|
302
|
+
if (showPreview) setPreview(URL.createObjectURL(file));
|
|
303
|
+
} else {
|
|
304
|
+
await doUpload(file, image ?? imageOpts);
|
|
305
|
+
}
|
|
306
|
+
}, [showImageOptions, image, imageOpts, doUpload, showPreview]);
|
|
230
307
|
const containerStyle = {
|
|
231
308
|
...vars,
|
|
232
309
|
display: "flex",
|
|
@@ -268,6 +345,41 @@ function ImageUploader({
|
|
|
268
345
|
] })
|
|
269
346
|
}
|
|
270
347
|
),
|
|
348
|
+
showImageOptions && stagedFile && !isUploading && state.status !== "done" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
349
|
+
/* @__PURE__ */ jsx(
|
|
350
|
+
ImageOptions,
|
|
351
|
+
{
|
|
352
|
+
value: imageOpts,
|
|
353
|
+
onChange: setImageOpts,
|
|
354
|
+
style: { padding: "12px 14px", borderRadius: 8, border: "1px solid var(--silo-border, #e2e8f0)", background: "var(--silo-bg-hover, #f8fafc)" }
|
|
355
|
+
}
|
|
356
|
+
),
|
|
357
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 8 }, children: [
|
|
358
|
+
/* @__PURE__ */ jsx(
|
|
359
|
+
"button",
|
|
360
|
+
{
|
|
361
|
+
onClick: () => {
|
|
362
|
+
setStagedFile(null);
|
|
363
|
+
setPreview(null);
|
|
364
|
+
},
|
|
365
|
+
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" },
|
|
366
|
+
children: "Cancelar"
|
|
367
|
+
}
|
|
368
|
+
),
|
|
369
|
+
/* @__PURE__ */ jsx(
|
|
370
|
+
"button",
|
|
371
|
+
{
|
|
372
|
+
onClick: () => {
|
|
373
|
+
const f = stagedFile;
|
|
374
|
+
setStagedFile(null);
|
|
375
|
+
void doUpload(f, imageOpts);
|
|
376
|
+
},
|
|
377
|
+
style: { flex: 1, padding: "8px", borderRadius: 6, border: "none", background: "var(--silo-accent, #6366f1)", color: "#fff", fontSize: 13, fontWeight: 600, cursor: "pointer" },
|
|
378
|
+
children: "Enviar imagem"
|
|
379
|
+
}
|
|
380
|
+
)
|
|
381
|
+
] })
|
|
382
|
+
] }),
|
|
271
383
|
isUploading && /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: renderProgress ? renderProgress(progress) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
272
384
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", fontSize: "13px", color: "var(--silo-text-muted)" }, children: [
|
|
273
385
|
/* @__PURE__ */ jsx("span", { children: state.status === "completing" ? "Finalizando\u2026" : state.status === "preparing" ? "Preparando\u2026" : `Parte ${state.part} de ${state.totalParts}` }),
|
|
@@ -308,6 +420,132 @@ function ImageUploader({
|
|
|
308
420
|
] })
|
|
309
421
|
] });
|
|
310
422
|
}
|
|
423
|
+
var CODECS = [
|
|
424
|
+
{ value: "h264", label: "H.264", hint: "Compatibilidade m\xE1xima" },
|
|
425
|
+
{ value: "h265", label: "H.265", hint: "Melhor compress\xE3o" },
|
|
426
|
+
{ value: "av1", label: "AV1", hint: "Futuro \u2014 menor tamanho" },
|
|
427
|
+
{ value: "vp9", label: "VP9", hint: "Open source" }
|
|
428
|
+
];
|
|
429
|
+
var RESOLUTIONS = ["360", "480", "720", "1080", "1440", "2160"];
|
|
430
|
+
var RESOLUTION_LABELS = {
|
|
431
|
+
"360": "360p",
|
|
432
|
+
"480": "480p",
|
|
433
|
+
"720": "720p",
|
|
434
|
+
"1080": "1080p",
|
|
435
|
+
"1440": "1440p",
|
|
436
|
+
"2160": "4K"
|
|
437
|
+
};
|
|
438
|
+
function VideoOptions({ value, onChange, style }) {
|
|
439
|
+
const codec = value.codec ?? "h264";
|
|
440
|
+
const transcoding = value.transcoding ?? "auto";
|
|
441
|
+
const isAuto = transcoding === "auto";
|
|
442
|
+
const selectedRes = isAuto ? [] : transcoding;
|
|
443
|
+
function toggleRes(r) {
|
|
444
|
+
if (isAuto) {
|
|
445
|
+
onChange({ ...value, transcoding: [r] });
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
const next = selectedRes.includes(r) ? selectedRes.filter((x) => x !== r) : [...selectedRes, r];
|
|
449
|
+
onChange({ ...value, transcoding: next.length === 0 ? "auto" : next });
|
|
450
|
+
}
|
|
451
|
+
function toggleFeature(key) {
|
|
452
|
+
onChange({ ...value, [key]: !value[key] });
|
|
453
|
+
}
|
|
454
|
+
const btn = (active) => ({
|
|
455
|
+
padding: "4px 10px",
|
|
456
|
+
borderRadius: 6,
|
|
457
|
+
border: `1px solid ${active ? "var(--silo-accent, #6366f1)" : "var(--silo-border, #e2e8f0)"}`,
|
|
458
|
+
background: active ? "var(--silo-accent, #6366f1)" : "transparent",
|
|
459
|
+
color: active ? "#fff" : "var(--silo-text, #0f172a)",
|
|
460
|
+
fontSize: 12,
|
|
461
|
+
fontWeight: 600,
|
|
462
|
+
cursor: "pointer"
|
|
463
|
+
});
|
|
464
|
+
const toggle = (on) => ({
|
|
465
|
+
display: "inline-flex",
|
|
466
|
+
alignItems: "center",
|
|
467
|
+
gap: 6,
|
|
468
|
+
cursor: "pointer",
|
|
469
|
+
userSelect: "none",
|
|
470
|
+
fontSize: 12,
|
|
471
|
+
color: "var(--silo-text, #0f172a)",
|
|
472
|
+
fontWeight: 500
|
|
473
|
+
});
|
|
474
|
+
function Toggle({ checked, onToggle, label }) {
|
|
475
|
+
return /* @__PURE__ */ jsxs("label", { style: toggle(), onClick: onToggle, children: [
|
|
476
|
+
/* @__PURE__ */ jsx("span", { style: {
|
|
477
|
+
width: 32,
|
|
478
|
+
height: 18,
|
|
479
|
+
borderRadius: 9,
|
|
480
|
+
flexShrink: 0,
|
|
481
|
+
background: checked ? "var(--silo-accent, #6366f1)" : "var(--silo-border, #e2e8f0)",
|
|
482
|
+
position: "relative",
|
|
483
|
+
transition: "background 0.15s",
|
|
484
|
+
cursor: "pointer"
|
|
485
|
+
}, children: /* @__PURE__ */ jsx("span", { style: {
|
|
486
|
+
position: "absolute",
|
|
487
|
+
top: 2,
|
|
488
|
+
left: checked ? 16 : 2,
|
|
489
|
+
width: 14,
|
|
490
|
+
height: 14,
|
|
491
|
+
borderRadius: "50%",
|
|
492
|
+
background: "#fff",
|
|
493
|
+
transition: "left 0.15s",
|
|
494
|
+
boxShadow: "0 1px 3px rgba(0,0,0,0.2)"
|
|
495
|
+
} }) }),
|
|
496
|
+
label
|
|
497
|
+
] });
|
|
498
|
+
}
|
|
499
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 12, ...style }, children: [
|
|
500
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
501
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 11, fontWeight: 700, color: "var(--silo-text-muted, #64748b)", letterSpacing: "0.05em", textTransform: "uppercase", marginBottom: 6 }, children: "Codec" }),
|
|
502
|
+
/* @__PURE__ */ jsx("div", { style: { display: "flex", gap: 6, flexWrap: "wrap" }, children: CODECS.map((c) => /* @__PURE__ */ jsx(
|
|
503
|
+
"button",
|
|
504
|
+
{
|
|
505
|
+
type: "button",
|
|
506
|
+
title: c.hint,
|
|
507
|
+
onClick: () => onChange({ ...value, codec: c.value }),
|
|
508
|
+
style: btn(codec === c.value),
|
|
509
|
+
children: c.label
|
|
510
|
+
},
|
|
511
|
+
c.value
|
|
512
|
+
)) })
|
|
513
|
+
] }),
|
|
514
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
515
|
+
/* @__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" }),
|
|
516
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 6, flexWrap: "wrap" }, children: [
|
|
517
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => onChange({ ...value, transcoding: "auto" }), style: btn(isAuto), children: "Auto" }),
|
|
518
|
+
RESOLUTIONS.map((r) => /* @__PURE__ */ jsx(
|
|
519
|
+
"button",
|
|
520
|
+
{
|
|
521
|
+
type: "button",
|
|
522
|
+
onClick: () => toggleRes(r),
|
|
523
|
+
style: btn(!isAuto && selectedRes.includes(r)),
|
|
524
|
+
children: RESOLUTION_LABELS[r]
|
|
525
|
+
},
|
|
526
|
+
r
|
|
527
|
+
))
|
|
528
|
+
] })
|
|
529
|
+
] }),
|
|
530
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
531
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: 11, fontWeight: 700, color: "var(--silo-text-muted, #64748b)", letterSpacing: "0.05em", textTransform: "uppercase", marginBottom: 8 }, children: "Recursos" }),
|
|
532
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
|
|
533
|
+
/* @__PURE__ */ jsx(Toggle, { checked: value.thumbnails ?? true, onToggle: () => toggleFeature("thumbnails"), label: "Gerar thumbnails" }),
|
|
534
|
+
/* @__PURE__ */ jsx(Toggle, { checked: value.storyboard ?? false, onToggle: () => toggleFeature("storyboard"), label: "Gerar storyboard" }),
|
|
535
|
+
/* @__PURE__ */ jsx(Toggle, { checked: value.autoCaptions ?? false, onToggle: () => toggleFeature("autoCaptions"), label: "Legendas autom\xE1ticas (IA)" }),
|
|
536
|
+
/* @__PURE__ */ jsx(Toggle, { checked: value.separateAudio ?? false, onToggle: () => toggleFeature("separateAudio"), label: "Separar faixa de \xE1udio" })
|
|
537
|
+
] })
|
|
538
|
+
] })
|
|
539
|
+
] });
|
|
540
|
+
}
|
|
541
|
+
var DEFAULT_VIDEO_OPTS = {
|
|
542
|
+
thumbnails: true,
|
|
543
|
+
storyboard: false,
|
|
544
|
+
autoCaptions: false,
|
|
545
|
+
separateAudio: false,
|
|
546
|
+
codec: "h264",
|
|
547
|
+
transcoding: "auto"
|
|
548
|
+
};
|
|
311
549
|
function VideoUploader({
|
|
312
550
|
bucket,
|
|
313
551
|
expiresIn,
|
|
@@ -320,6 +558,7 @@ function VideoUploader({
|
|
|
320
558
|
maxSize,
|
|
321
559
|
accept = "video/*",
|
|
322
560
|
showPreview = true,
|
|
561
|
+
showVideoOptions = false,
|
|
323
562
|
video,
|
|
324
563
|
theme,
|
|
325
564
|
renderIcon,
|
|
@@ -330,23 +569,33 @@ function VideoUploader({
|
|
|
330
569
|
}) {
|
|
331
570
|
const { state, upload, pause, resume, abort, reset } = useMultipartUpload(bucket);
|
|
332
571
|
const [preview, setPreview] = useState(null);
|
|
572
|
+
const [videoOpts, setVideoOpts] = useState(video ?? DEFAULT_VIDEO_OPTS);
|
|
573
|
+
const [stagedFile, setStagedFile] = useState(null);
|
|
333
574
|
const t = resolveTheme(theme);
|
|
334
575
|
const vars = themeToVars(t);
|
|
335
|
-
const
|
|
336
|
-
const file = files[0];
|
|
337
|
-
if (!file) return;
|
|
576
|
+
const doUpload = useCallback(async (file, opts) => {
|
|
338
577
|
if (showPreview) setPreview(URL.createObjectURL(file));
|
|
339
578
|
try {
|
|
340
579
|
const result = await upload(file, {
|
|
341
580
|
...bucket !== void 0 && { bucket },
|
|
342
581
|
visibility,
|
|
343
|
-
|
|
582
|
+
video: opts
|
|
344
583
|
});
|
|
345
584
|
if (result) onUpload?.(result);
|
|
346
585
|
} catch (err) {
|
|
347
586
|
onError?.(err instanceof Error ? err : new Error(String(err)));
|
|
348
587
|
}
|
|
349
|
-
}, [upload, bucket, visibility,
|
|
588
|
+
}, [upload, bucket, visibility, onUpload, onError, showPreview]);
|
|
589
|
+
const handleFiles = useCallback(async (files) => {
|
|
590
|
+
const file = files[0];
|
|
591
|
+
if (!file) return;
|
|
592
|
+
if (showVideoOptions) {
|
|
593
|
+
setStagedFile(file);
|
|
594
|
+
if (showPreview) setPreview(URL.createObjectURL(file));
|
|
595
|
+
} else {
|
|
596
|
+
await doUpload(file, video ?? videoOpts);
|
|
597
|
+
}
|
|
598
|
+
}, [showVideoOptions, video, videoOpts, doUpload, showPreview]);
|
|
350
599
|
const containerStyle = {
|
|
351
600
|
...vars,
|
|
352
601
|
display: "flex",
|
|
@@ -388,6 +637,41 @@ function VideoUploader({
|
|
|
388
637
|
] })
|
|
389
638
|
}
|
|
390
639
|
),
|
|
640
|
+
showVideoOptions && stagedFile && !isUploading && state.status !== "done" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
641
|
+
/* @__PURE__ */ jsx(
|
|
642
|
+
VideoOptions,
|
|
643
|
+
{
|
|
644
|
+
value: videoOpts,
|
|
645
|
+
onChange: setVideoOpts,
|
|
646
|
+
style: { padding: "12px 14px", borderRadius: 8, border: "1px solid var(--silo-border, #e2e8f0)", background: "var(--silo-bg-hover, #f8fafc)" }
|
|
647
|
+
}
|
|
648
|
+
),
|
|
649
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 8 }, children: [
|
|
650
|
+
/* @__PURE__ */ jsx(
|
|
651
|
+
"button",
|
|
652
|
+
{
|
|
653
|
+
onClick: () => {
|
|
654
|
+
setStagedFile(null);
|
|
655
|
+
setPreview(null);
|
|
656
|
+
},
|
|
657
|
+
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" },
|
|
658
|
+
children: "Cancelar"
|
|
659
|
+
}
|
|
660
|
+
),
|
|
661
|
+
/* @__PURE__ */ jsx(
|
|
662
|
+
"button",
|
|
663
|
+
{
|
|
664
|
+
onClick: () => {
|
|
665
|
+
const f = stagedFile;
|
|
666
|
+
setStagedFile(null);
|
|
667
|
+
void doUpload(f, videoOpts);
|
|
668
|
+
},
|
|
669
|
+
style: { flex: 1, padding: "8px", borderRadius: 6, border: "none", background: "var(--silo-accent, #6366f1)", color: "#fff", fontSize: 13, fontWeight: 600, cursor: "pointer" },
|
|
670
|
+
children: "Enviar v\xEDdeo"
|
|
671
|
+
}
|
|
672
|
+
)
|
|
673
|
+
] })
|
|
674
|
+
] }),
|
|
391
675
|
isUploading && /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: renderProgress ? renderProgress(progress) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
392
676
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", fontSize: "13px", color: "var(--silo-text-muted)" }, children: [
|
|
393
677
|
/* @__PURE__ */ jsx("span", { children: state.status === "completing" ? "Finalizando\u2026" : state.status === "preparing" ? "Preparando\u2026" : `Parte ${state.part} de ${state.totalParts}` }),
|
|
@@ -403,7 +687,14 @@ function VideoUploader({
|
|
|
403
687
|
/* @__PURE__ */ jsx("span", { style: { fontSize: "12px", color: "var(--silo-text-muted)" }, children: "O processamento inicia ap\xF3s o upload" })
|
|
404
688
|
] }) }),
|
|
405
689
|
isPaused && /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
406
|
-
/* @__PURE__ */ jsx(
|
|
690
|
+
/* @__PURE__ */ jsx(
|
|
691
|
+
"button",
|
|
692
|
+
{
|
|
693
|
+
onClick: () => resume({ ...bucket !== void 0 && { bucket }, visibility, video: showVideoOptions ? videoOpts : video ?? videoOpts }),
|
|
694
|
+
style: { flex: 1, padding: "8px", borderRadius: "6px", border: "none", backgroundColor: "#10b981", color: "#fff", fontSize: "13px", fontWeight: 600, cursor: "pointer" },
|
|
695
|
+
children: "Retomar upload"
|
|
696
|
+
}
|
|
697
|
+
),
|
|
407
698
|
/* @__PURE__ */ jsx("button", { onClick: () => {
|
|
408
699
|
abort();
|
|
409
700
|
setPreview(null);
|
|
@@ -426,6 +717,14 @@ function VideoUploader({
|
|
|
426
717
|
] })
|
|
427
718
|
] });
|
|
428
719
|
}
|
|
720
|
+
var DEFAULT_VIDEO_OPTS2 = {
|
|
721
|
+
thumbnails: true,
|
|
722
|
+
storyboard: false,
|
|
723
|
+
autoCaptions: false,
|
|
724
|
+
separateAudio: false,
|
|
725
|
+
codec: "h264",
|
|
726
|
+
transcoding: "auto"
|
|
727
|
+
};
|
|
429
728
|
function FileUploader({
|
|
430
729
|
bucket,
|
|
431
730
|
visibility = "private",
|
|
@@ -439,6 +738,8 @@ function FileUploader({
|
|
|
439
738
|
accept,
|
|
440
739
|
multiple = false,
|
|
441
740
|
allowRename = false,
|
|
741
|
+
showImageOptions = false,
|
|
742
|
+
showVideoOptions = false,
|
|
442
743
|
image,
|
|
443
744
|
video,
|
|
444
745
|
theme,
|
|
@@ -461,6 +762,8 @@ function FileUploader({
|
|
|
461
762
|
};
|
|
462
763
|
const single = useMultipartUpload(bucket);
|
|
463
764
|
const batch = useBatchUpload();
|
|
765
|
+
const [imageOpts, setImageOpts] = useState(image ?? { format: "webp", optimize: true });
|
|
766
|
+
const [videoOpts, setVideoOpts] = useState(video ?? DEFAULT_VIDEO_OPTS2);
|
|
464
767
|
const [staged, setStaged] = useState(null);
|
|
465
768
|
const [renames, setRenames] = useState(/* @__PURE__ */ new Map());
|
|
466
769
|
const [editingIndex, setEditingIndex] = useState(null);
|
|
@@ -484,9 +787,11 @@ function FileUploader({
|
|
|
484
787
|
setEditingIndex(null);
|
|
485
788
|
}
|
|
486
789
|
const doUpload = useCallback(async (files) => {
|
|
790
|
+
const effectiveImage = showImageOptions ? imageOpts : image ?? imageOpts;
|
|
791
|
+
const effectiveVideo = showVideoOptions ? videoOpts : video ?? videoOpts;
|
|
487
792
|
if (multiple && files.length > 1) {
|
|
488
793
|
try {
|
|
489
|
-
const opts = { ...bucket !== void 0 && { bucket }, visibility,
|
|
794
|
+
const opts = { ...bucket !== void 0 && { bucket }, visibility, image: effectiveImage, video: effectiveVideo };
|
|
490
795
|
const results = await batch.upload(files, opts);
|
|
491
796
|
onBatchUpload?.(results);
|
|
492
797
|
results.forEach((r) => onUpload?.(r));
|
|
@@ -497,7 +802,7 @@ function FileUploader({
|
|
|
497
802
|
const file = files[0];
|
|
498
803
|
if (!file) return;
|
|
499
804
|
try {
|
|
500
|
-
const opts = { ...bucket !== void 0 && { bucket }, visibility,
|
|
805
|
+
const opts = { ...bucket !== void 0 && { bucket }, visibility, image: effectiveImage, video: effectiveVideo };
|
|
501
806
|
const result = await single.upload(file, opts);
|
|
502
807
|
if (result) onUpload?.(result);
|
|
503
808
|
} catch (err) {
|
|
@@ -506,7 +811,8 @@ function FileUploader({
|
|
|
506
811
|
}
|
|
507
812
|
}, [single, batch, multiple, bucket, visibility, image, video, onUpload, onBatchUpload, onError]);
|
|
508
813
|
const handleFiles = useCallback(async (files) => {
|
|
509
|
-
|
|
814
|
+
const needsStaging = allowRename || showImageOptions && files.some((f) => f.type.startsWith("image/")) || showVideoOptions && files.some((f) => f.type.startsWith("video/"));
|
|
815
|
+
if (needsStaging) {
|
|
510
816
|
setStaged(files);
|
|
511
817
|
setRenames(/* @__PURE__ */ new Map());
|
|
512
818
|
} else {
|
|
@@ -616,6 +922,22 @@ function FileUploader({
|
|
|
616
922
|
}
|
|
617
923
|
)
|
|
618
924
|
] }, i)),
|
|
925
|
+
showImageOptions && staged.some((f) => f.type.startsWith("image/")) && /* @__PURE__ */ jsx(
|
|
926
|
+
ImageOptions,
|
|
927
|
+
{
|
|
928
|
+
value: imageOpts,
|
|
929
|
+
onChange: setImageOpts,
|
|
930
|
+
style: { padding: "12px 14px", borderRadius: 8, border: "1px solid var(--silo-border)", background: "var(--silo-bg-hover, #f8fafc)", marginTop: 4 }
|
|
931
|
+
}
|
|
932
|
+
),
|
|
933
|
+
showVideoOptions && staged.some((f) => f.type.startsWith("video/")) && /* @__PURE__ */ jsx(
|
|
934
|
+
VideoOptions,
|
|
935
|
+
{
|
|
936
|
+
value: videoOpts,
|
|
937
|
+
onChange: setVideoOpts,
|
|
938
|
+
style: { padding: "12px 14px", borderRadius: 8, border: "1px solid var(--silo-border)", background: "var(--silo-bg-hover, #f8fafc)", marginTop: 4 }
|
|
939
|
+
}
|
|
940
|
+
),
|
|
619
941
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px", marginTop: "4px" }, children: [
|
|
620
942
|
/* @__PURE__ */ jsx(
|
|
621
943
|
"button",
|
|
@@ -2354,6 +2676,6 @@ var metaGrid = {
|
|
|
2354
2676
|
alignItems: "baseline"
|
|
2355
2677
|
};
|
|
2356
2678
|
|
|
2357
|
-
export { Avatar, Background, DropZone, FileCard, FileIcon, FilePreview, FileUploader, ImageUploader, MediaUploader, ProgressBar, Source, Sources, Storyboard, StoryboardFrame, Subtitle, Subtitles, Thumbnail, Video, VideoPlayer, VideoUploader, defaultTheme, resolveTheme };
|
|
2679
|
+
export { Avatar, Background, DropZone, FileCard, FileIcon, FilePreview, FileUploader, ImageOptions, ImageUploader, MediaUploader, ProgressBar, Source, Sources, Storyboard, StoryboardFrame, Subtitle, Subtitles, Thumbnail, Video, VideoOptions, VideoPlayer, VideoUploader, defaultTheme, resolveTheme };
|
|
2358
2680
|
//# sourceMappingURL=index.js.map
|
|
2359
2681
|
//# sourceMappingURL=index.js.map
|