@cardinali-studio/adminkit 2.2.50 → 2.2.52

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/app/app.css CHANGED
@@ -2493,8 +2493,7 @@ body:has(.uk) .pane-body { padding-bottom: 190px; }
2493
2493
  .dl-email-recipient{padding:4px 0 0 30px}
2494
2494
 
2495
2495
  /* Transfer composer. The options occupy their own column only when opened. */
2496
- .dl-compose-grid { grid-template-columns: minmax(0, 31rem); }
2497
- .dl-compose-grid.is-expanded { grid-template-columns: minmax(0, 31rem) minmax(16rem, 1fr); }
2496
+ .dl-compose-grid { grid-template-columns: minmax(0, 0.78fr) minmax(0, 1.22fr); }
2498
2497
  .dl-compose-grid [hidden] { display: none; }
2499
2498
  .dl-options-head, .dl-compose-actions, .dl-selection { display: flex; align-items: center; gap: .75rem; }
2500
2499
  .dl-options-head { justify-content: space-between; }
@@ -2510,10 +2509,6 @@ body:has(.uk) .pane-body { padding-bottom: 190px; }
2510
2509
  .dl-selection .ak-btn { margin-left: auto; }
2511
2510
  .dl-compose-grid .dl-cover-head { flex-direction: column; align-items: start; }
2512
2511
  .dl-compose-grid .dl-cover-actions { justify-content: start; }
2513
- .dl-work:has(.dl-compose-grid) { container-type: inline-size; }
2514
- @container (max-width: 43rem) {
2515
- .dl-compose-grid.is-expanded { grid-template-columns: minmax(0,1fr); }
2516
- }
2517
2512
  @media (max-width: 700px) {
2518
2513
  .dl-compose-grid .dl-pick { grid-template-columns: repeat(2,minmax(0,1fr)); }
2519
2514
  }
@@ -2521,9 +2516,6 @@ body:has(.uk) .pane-body { padding-bottom: 190px; }
2521
2516
  .dl-default-covers { display: flex; flex-wrap: wrap; gap: 1rem; padding: 0; list-style: none; }
2522
2517
  .dl-default-covers li { display: grid; gap: .4rem; }
2523
2518
  .dl-default-covers img { width: 7rem; aspect-ratio: 3/2; object-fit: cover; border-radius: var(--ak-radius); }
2524
- .dl-compose-grid.has-background { position: relative; isolation: isolate; padding: clamp(12px,2vw,28px); border-radius: var(--ak-radius); overflow: clip; }
2525
- .dl-compose-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; object-fit: cover; }
2526
- .dl-compose-grid.has-background .dl-side { background: var(--ak-panel); border-radius: var(--ak-radius); padding: 12px; }
2527
2519
  .dl-selected-list { flex-basis: 100%; }
2528
2520
  .dl-selected-list summary { cursor: pointer; }
2529
2521
  .dl-selected-list ul { padding: 0; list-style: none; max-height: 12rem; overflow: auto; }
@@ -2543,6 +2535,65 @@ body:has(.uk) .pane-body { padding-bottom: 190px; }
2543
2535
  .dl-settings-shortcut { display: grid; place-items: center; width: 42px; height: 42px; background: transparent; color: var(--ak-ink-quiet); border: 1px solid transparent; border-radius: var(--ak-radius); cursor: pointer; }
2544
2536
  .dl-settings-shortcut:hover, .dl-settings-shortcut[aria-current] { color: var(--ak-accent); border-color: var(--ak-line); }
2545
2537
  .dl-settings-shortcut svg { width: 18px; height: 18px; }
2546
- @container (min-width: 43.01rem) {
2547
- .dl-compose-grid.is-expanded .dl-side { max-height: min(42rem, 80svh); overflow-y: auto; scrollbar-gutter: stable; }
2538
+
2539
+ .dl-work.dl-transfer-canvas {
2540
+ --dl-paper: #edf2f7;
2541
+ --dl-caption: #1a2835;
2542
+ box-sizing: border-box;
2543
+ container-type: inline-size;
2544
+ background: var(--dl-paper);
2545
+ border-radius: 18px;
2546
+ padding: clamp(14px, 2.4vw, 36px);
2547
+ align-content: start;
2548
+ }
2549
+ :root .dl-work.dl-transfer-canvas > .dl-work-head {
2550
+ position: static;
2551
+ margin: 0;
2552
+ padding: 0;
2553
+ background: transparent;
2554
+ flex-wrap: wrap;
2555
+ color: var(--dl-caption);
2556
+ }
2557
+ .dl-transfer-canvas .dl-work-actions { flex-wrap: wrap; }
2558
+ .dl-transfer-canvas .dl-work-actions .ak-btn:not(.ak-btn-primary) { background: var(--ak-panel); }
2559
+ .dl-transfer-canvas .dl-compose-grid {
2560
+ grid-template-columns: minmax(17rem, .79fr) minmax(0, 1.45fr);
2561
+ column-gap: clamp(16px, 3cqi, 42px);
2562
+ }
2563
+ .dl-transfer-canvas .dl-main { grid-area: 1 / 1; }
2564
+ .dl-transfer-canvas .dl-compose-card, .dl-transfer-canvas .dl-link {
2565
+ box-shadow: 0 7px 25px rgb(26 40 53 / .12);
2566
+ }
2567
+ .dl-artwork {
2568
+ grid-area: 1 / 2;
2569
+ min-width: 0;
2570
+ margin: clamp(16px, 6cqi, 88px) 0 0;
2571
+ display: grid;
2572
+ gap: 12px;
2573
+ color: var(--dl-caption);
2574
+ }
2575
+ .dl-artwork-images { display: flex; justify-content: center; align-items: center; gap: 8px; }
2576
+ .dl-artwork-images img { flex: 1 1 0; min-width: 0; width: 100%; max-height: min(58svh, 36rem); object-fit: contain; }
2577
+ .dl-artwork figcaption { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; overflow-wrap: anywhere; }
2578
+ .dl-artwork figcaption:empty { display: none; }
2579
+ .dl-artwork-title { display: grid; gap: .3rem; min-width: 0; }
2580
+ .dl-artwork-title strong { font: 500 clamp(20px, 3cqi, 36px)/1.1 Georgia, serif; }
2581
+ .dl-artwork-title span, .dl-artwork figcaption p { font: 400 .875rem/1.45 var(--ak-font); }
2582
+ .dl-artwork figcaption p { margin: 0; max-width: 34ch; white-space: pre-line; }
2583
+ .dl-artwork-tools, .dl-artwork-tools [role=group] { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
2584
+ .dl-artwork-tools { justify-content: space-between; }
2585
+ .dl-artwork-tools button { background: transparent; color: inherit; border: 1px solid #acbac6; border-radius: 99px; padding: 0 .85rem; min-height: 36px; font: 500 .8rem/1 var(--ak-font); cursor: pointer; }
2586
+ .dl-artwork-tools button:hover { background: #fff; }
2587
+ .dl-artwork-tools button:disabled { opacity: .5; cursor: default; }
2588
+ .dl-artwork-tools [role=group] { font: 500 .75rem var(--ak-font); }
2589
+ .dl-artwork-tools [role=group] button { font-size: 1.2rem; }
2590
+ .dl-transfer-canvas .dl-side { grid-area: 1 / 2; z-index: 1; padding: 16px; border-radius: var(--ak-radius); background: var(--ak-panel); box-shadow: 0 6px 24px rgb(26 40 53 / .15); }
2591
+ .dl-compose-grid.is-expanded .dl-artwork { display: none; }
2592
+ @container (max-width: 688px) {
2593
+ .dl-transfer-canvas .dl-compose-grid { grid-template-columns: minmax(0,1fr); gap: 16px; }
2594
+ .dl-transfer-canvas .dl-main, .dl-transfer-canvas .dl-side { grid-area: auto; }
2595
+ .dl-artwork { grid-area: 1 / 1; margin: 0; }
2596
+ .dl-artwork-images img { max-height: 32svh; }
2597
+ .dl-artwork figcaption { flex-wrap: wrap; gap: .45rem; }
2598
+ .dl-artwork-tools button { min-height: 44px; }
2548
2599
  }
@@ -997,10 +997,10 @@ export function deliverySelectionName(files) {
997
997
  export async function uploadDeliveryHeroObject(deliveryId, packageId, file) {
998
998
  const variant = await makeHeroVariant(file);
999
999
  const signed = await postJson({
1000
- action: "heroPresign", id: deliveryId, packageId,
1000
+ action: "heroPresign", id: deliveryId, packageId, contentType: variant.blob.type,
1001
1001
  });
1002
1002
  const response = await fetch(signed.url, {
1003
- method: "PUT", body: variant.blob, headers: { "Content-Type": "image/webp" },
1003
+ method: "PUT", body: variant.blob, headers: { "Content-Type": variant.blob.type },
1004
1004
  });
1005
1005
  if (!response.ok)
1006
1006
  throw new Error(`Copertina non caricata (${response.status}). Riprova.`);
@@ -1015,10 +1015,24 @@ async function makeHeroVariant(file) {
1015
1015
  const bitmap = await createImageBitmap(file, { imageOrientation: "from-image" });
1016
1016
  try {
1017
1017
  const size = fit(bitmap.width, bitmap.height, 2560);
1018
- return {
1019
- blob: await drawImageBlob(bitmap, size.width, size.height, .82),
1020
- width: size.width, height: size.height,
1021
- };
1018
+ const canvas = document.createElement("canvas");
1019
+ canvas.width = size.width;
1020
+ canvas.height = size.height;
1021
+ const context = canvas.getContext("2d");
1022
+ if (!context)
1023
+ throw new Error("Impossibile preparare la copertina.");
1024
+ context.drawImage(bitmap, 0, 0, size.width, size.height);
1025
+ const encode = (type) => new Promise(resolve => canvas.toBlob(resolve, type, .82));
1026
+ // Safari can return a PNG when asked for WebP. Preserve alpha for transparent sources.
1027
+ let blob = await encode("image/webp");
1028
+ if (blob?.type !== "image/webp") {
1029
+ const fallback = /\.jpe?g$/i.test(file.name) ? "image/jpeg" : "image/png";
1030
+ if (blob?.type !== fallback)
1031
+ blob = await encode(fallback);
1032
+ if (blob?.type !== fallback)
1033
+ throw new Error("Impossibile preparare la copertina.");
1034
+ }
1035
+ return { blob, ...size };
1022
1036
  }
1023
1037
  finally {
1024
1038
  bitmap.close();
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { DeliveryRecipientPreview } from "./DeliveryRecipientPreview";
2
3
  import { DeliveryEmailConfiguration, DeliveryEmail, saveTransferEmailPreferences } from "./DeliveryEmail";
3
- import { useEffect, useRef, useState } from "react";
4
+ import { useEffect, useMemo, useRef, useState } from "react";
4
5
  import { assertUploadCoordinatorSelection, prepareUploadSession, validateNewUploadNegotiation } from '../lib/delivery-upload-coordinator.js';
5
6
  import { deliveryProgressPercent, deliveryRelativeName, deliverySelectionName, deliverySourceFingerprint, uploadDeliveryHeroObject, preflightDeliverySelection, } from "../lib/delivery-upload";
6
7
  import { isBusy, startUpload, uploadFor, useUploadCompletions, useUploads, } from "../lib/upload-queue";
@@ -30,7 +31,8 @@ export function DeliveriesTotal({ rows }) {
30
31
  const bytes = rows.reduce((sum, row) => sum + (row.storedBytes || 0), 0);
31
32
  return (_jsxs("p", { className: "dl-total", children: [rows.length, " transfer \u00B7 ", formatBytes(bytes)] }));
32
33
  }
33
- export function DeliveryWorkspace({ delivery: fromServer, defaultHeroes = [], busy, onAction, onRefresh, onReload, onRead, onDeleted, onOpen, onSelected, }) {
34
+ const emptyCovers = [];
35
+ export function DeliveryWorkspace({ delivery: fromServer, defaultHeroes = emptyCovers, busy, onAction, onRefresh, onReload, onRead, onDeleted, onOpen, onSelected, }) {
34
36
  /* Il transfer «corrente» può venire dal server (l'ho aperto dall'elenco) o essere nato qui
35
37
  dentro al primo file rilasciato. Nel secondo caso resta in questo stato finché non si
36
38
  ricarica l'elenco. */
@@ -56,14 +58,11 @@ export function DeliveryWorkspace({ delivery: fromServer, defaultHeroes = [], bu
56
58
  const [selection, setSelection] = useState([]);
57
59
  const [coverFiles, setCoverFiles] = useState([]);
58
60
  const [preparing, setPreparing] = useState(false);
59
- const [coverPreview, setCoverPreview] = useState("");
60
- useEffect(() => {
61
- const url = coverFiles[0] ? URL.createObjectURL(coverFiles[0]) : "";
62
- setCoverPreview(url);
63
- return () => { if (url)
64
- URL.revokeObjectURL(url); };
65
- }, [coverFiles]);
66
- const background = coverPreview || heroes[0]?.previewUrl || defaultHeroes[0];
61
+ const previewCovers = useMemo(() => {
62
+ if (coverFiles.length)
63
+ return coverFiles;
64
+ return heroes.length ? heroes.map(hero => hero.previewUrl).filter(Boolean) : defaultHeroes;
65
+ }, [coverFiles, heroes, defaultHeroes]);
67
66
  const quickFields = useRef(null);
68
67
  const fileInputs = useRef(null);
69
68
  const optionsTitle = useRef(null);
@@ -121,7 +120,7 @@ export function DeliveryWorkspace({ delivery: fromServer, defaultHeroes = [], bu
121
120
  const job = delivery ? uploadFor(delivery.id, jobs) : undefined;
122
121
  const uploading = isBusy(job) || preparing;
123
122
  const heroesDirty = !sameHeroes(heroes, heroesClean);
124
- const dirty = !same(draft, clean) || heroesDirty || emailDirty;
123
+ const dirty = !same(draft, clean) || heroesDirty || coverFiles.length > 0 || emailDirty;
125
124
  const photos = packages.filter(pkg => pkg.state === "ready").flatMap((pkg) => [...pkg.images, ...(moreImages[pkg.id]?.images || [])].map((image) => ({ pkg, image })));
126
125
  async function loadMoreImages() {
127
126
  if (loadingImages || !delivery)
@@ -251,19 +250,8 @@ export function DeliveryWorkspace({ delivery: fromServer, defaultHeroes = [], bu
251
250
  options.webFormat = created.package.webFormat || "webp";
252
251
  }
253
252
  }
254
- if (coverFiles.length || heroesDirty) {
255
- const nextHeroes = coverFiles.length ? [] : heroes;
256
- for (const file of coverFiles) {
257
- const uploaded = await uploadDeliveryHeroObject(target.id, packageId, file);
258
- nextHeroes.push({ ...uploaded, previewUrl: "" });
259
- }
260
- target = (await onAction({
261
- action: "commitHeroes", id: target.id, version: target.version, heroes: nextHeroes,
262
- }, { reload: false })).delivery;
263
- setHeroes(target.heroes);
264
- setHeroesClean(target.heroes);
265
- setCoverFiles([]);
266
- }
253
+ if (coverFiles.length || heroesDirty)
254
+ target = await commitCovers(target, packageId);
267
255
  // Metadata, link and cover are already saved, including when adding a
268
256
  // package to an existing transfer. The next detail read can adopt its version.
269
257
  const savedDraft = { ...draft, title, duration: "keep" };
@@ -336,15 +324,37 @@ export function DeliveryWorkspace({ delivery: fromServer, defaultHeroes = [], bu
336
324
  input.click();
337
325
  };
338
326
  /* ---- salvataggio: uno solo, che fa tutto ------------------------------------------- */
327
+ async function commitCovers(target, packageId) {
328
+ const chosen = coverFiles.length ? [] : [...heroes];
329
+ if (coverFiles.length && !packageId)
330
+ return target;
331
+ for (const file of coverFiles) {
332
+ const uploaded = await uploadDeliveryHeroObject(target.id, packageId, file);
333
+ chosen.push({ ...uploaded, previewUrl: "" });
334
+ }
335
+ const { delivery: updated } = await onAction({
336
+ action: "commitHeroes", id: target.id, version: target.version, heroes: chosen,
337
+ }, { reload: false });
338
+ setCoverFiles([]);
339
+ setHeroes(updated.heroes);
340
+ setHeroesClean(updated.heroes);
341
+ return updated;
342
+ }
339
343
  const save = async () => {
340
344
  if (!delivery || !quickFields.current?.reportValidity())
341
345
  return;
342
346
  setSaving(true);
343
347
  setFailure(null);
344
348
  setNotice(null);
349
+ let savedRevision;
345
350
  try {
351
+ let target = editingSnapshot.current ?? delivery;
352
+ if (coverFiles.length || !sameHeroes(heroes, heroesClean)) {
353
+ target = await commitCovers(target, packages.find(pkg => pkg.state === "ready")?.id);
354
+ savedRevision = target;
355
+ }
346
356
  const updated = (await onAction({
347
- action: "update", id: delivery.id, version: editingSnapshot.current?.version ?? delivery.version, title: draft.title.trim() || delivery.title,
357
+ action: "update", id: delivery.id, version: target.version, title: draft.title.trim() || delivery.title,
348
358
  clientName: draft.clientName, description: draft.description,
349
359
  licenseNotes: draft.licenseNotes, ctaEnabled: draft.ctaEnabled,
350
360
  ctaLabel: draft.ctaLabel, ctaUrl: draft.ctaUrl, syncPackageLabel: true,
@@ -353,9 +363,7 @@ export function DeliveryWorkspace({ delivery: fromServer, defaultHeroes = [], bu
353
363
  filesExpiresAt: draft.duration === "keep"
354
364
  ? delivery.filesExpiresAt : expiryFrom(draft.duration),
355
365
  }, { reload: false })).delivery;
356
- if (!sameHeroes(heroes, heroesClean)) {
357
- await onAction({ action: "commitHeroes", id: delivery.id, version: updated.version, heroes }, { reload: false });
358
- }
366
+ savedRevision = updated;
359
367
  if (link) {
360
368
  if ((link.pin || "") !== draft.pin) {
361
369
  await onAction({
@@ -375,11 +383,12 @@ export function DeliveryWorkspace({ delivery: fromServer, defaultHeroes = [], bu
375
383
  }
376
384
  setClean({ ...draft, duration: "keep" });
377
385
  setDraft((current) => ({ ...current, duration: "keep" }));
378
- setHeroesClean(heroes);
379
- setNotice(link ? "Salvato" : "Link pronto: ora puoi mandarlo");
386
+ setNotice(coverFiles.length && !ready ? "Le copertine saranno salvate con il primo caricamento." : link ? "Salvato" : "Link pronto: ora puoi mandarlo");
380
387
  await refreshAll(updated.id);
381
388
  }
382
389
  catch (error) {
390
+ if (savedRevision)
391
+ editingSnapshot.current = savedRevision;
383
392
  setFailure(errorText(error));
384
393
  }
385
394
  finally {
@@ -388,7 +397,9 @@ export function DeliveryWorkspace({ delivery: fromServer, defaultHeroes = [], bu
388
397
  };
389
398
  /* ---- copertina --------------------------------------------------------------------- */
390
399
  const toggleCover = (packageId, index, previewUrl) => {
391
- setHeroes((current) => {
400
+ setCoverFiles([]);
401
+ setHeroes((previous) => {
402
+ const current = coverFiles.length ? [] : previous;
392
403
  const has = current.some((item) => item.type === "package" && item.packageId === packageId && item.index === index);
393
404
  if (has) {
394
405
  return current.filter((item) => !(item.type === "package" && item.packageId === packageId && item.index === index));
@@ -398,38 +409,19 @@ export function DeliveryWorkspace({ delivery: fromServer, defaultHeroes = [], bu
398
409
  return [...current, { type: "package", packageId, index, previewUrl }];
399
410
  });
400
411
  };
401
- const uploadCovers = async (event) => {
412
+ const selectCovers = (event) => {
402
413
  const input = event.currentTarget;
403
414
  const files = Array.from(input.files || []);
415
+ input.value = "";
404
416
  if (!files.length)
405
417
  return;
406
418
  if (files.length > 8 || files.some(file => !/\.(jpe?g|png|webp)$/i.test(file.name))) {
407
419
  setFailure("Scegli fino a otto immagini JPEG, PNG o WebP.");
408
420
  return;
409
421
  }
410
- const pkg = packages.find(item => item.state === "ready");
411
- if (!pkg || !delivery) {
412
- setCoverFiles(files);
413
- setFailure(null);
414
- return;
415
- }
416
- setSaving(true);
422
+ setCoverFiles(files);
417
423
  setFailure(null);
418
- try {
419
- const added = [];
420
- for (const file of files) {
421
- const uploaded = await uploadDeliveryHeroObject(delivery.id, pkg.id, file);
422
- added.push({ ...uploaded, previewUrl: "" });
423
- }
424
- setHeroes(added);
425
- }
426
- catch (error) {
427
- setFailure(errorText(error));
428
- }
429
- finally {
430
- setSaving(false);
431
- input.value = "";
432
- }
424
+ setAdvanced(false);
433
425
  };
434
426
  /* ---- azioni di servizio ------------------------------------------------------------ */
435
427
  const run = async (payload, done) => {
@@ -498,13 +490,13 @@ export function DeliveryWorkspace({ delivery: fromServer, defaultHeroes = [], bu
498
490
  setSaving(false);
499
491
  }
500
492
  }, children: "Accorcia link" }))] }), accessEdited && _jsx("p", { className: "dl-link-stats", role: "status", children: "Salva le modifiche di accesso o scadenza prima di condividere." }), _jsx("p", { className: "dl-link-stats", children: linkStory(link) }), _jsx("div", { ref: setActivityTarget, className: "dl-link-email" }), link.pin && (_jsxs("p", { className: "dl-link-stats", children: ["Codice di accesso ", _jsx("strong", { children: link.pin }), " \u00B7 Incluso nel messaggio."] }))] })) : null;
501
- return (_jsxs("div", { className: "dl-work", children: [_jsxs("header", { className: "dl-work-head", children: [_jsxs("div", { className: "dl-work-title", children: [state && _jsx("span", { className: "dl-pill is-" + state.kind, children: state.label }), _jsx("h2", { children: draft.title.trim() || (delivery ? delivery.title : "Nuovo transfer") })] }), _jsxs("div", { className: "dl-work-actions", children: [link && (_jsx("a", { className: "ak-btn", href: link.url, target: "_blank", rel: "noreferrer", children: "Guarda come lo vede il cliente" })), link && (_jsx("button", { className: "ak-btn ak-btn-primary", disabled: !dirty || saving || busy || uploading, onClick: () => void save(), children: saving ? "Salvo…" : "Salva" }))] })] }), (failure || notice) && (_jsxs("p", { role: failure ? "alert" : "status", className: failure ? "ak-error dl-feedback" : "dl-feedback is-ok", children: [failure || notice, _jsx("button", { type: "button", "aria-label": "Chiudi", onClick: () => { setFailure(null); setNotice(null); }, children: "\u00D7" })] })), _jsxs("div", { className: "dl-grid dl-compose-grid" + (advanced ? " is-expanded" : "") + (background ? " has-background" : ""), children: [background && _jsx("img", { className: "dl-compose-backdrop", src: background, alt: "" }), _jsxs("div", { className: "dl-main", children: [ready && sharingCard, _jsxs("div", { className: "dl-compose-card", children: [_jsxs("section", { className: "dl-card dl-upload-card", "aria-labelledby": "dl-files-heading", children: [_jsxs("div", { className: "dl-section-head", children: [_jsx("h3", { id: "dl-files-heading", children: "File da consegnare" }), _jsx("p", { children: "Fino a 150 GB per caricamento." })] }), _jsxs("div", { className: "dl-pick", children: [_jsxs("button", { className: "dl-pick-tile", disabled: uploading, onClick: () => choose(false), children: [_jsx(FileIcon, {}), "Aggiungi file"] }), _jsxs("button", { className: "dl-pick-tile", disabled: uploading, onClick: () => choose(true), children: [_jsx(FolderIcon, {}), "Aggiungi una cartella"] }), _jsx("div", { ref: fileInputs, hidden: true })] }), _jsx(DropArea, { disabled: uploading, resuming: !!resumeRef.current, onFiles: addFiles, onError: (error) => setFailure(errorText(error)) }), !!selection.length && _jsxs("div", { className: "dl-selection", "aria-live": "polite", children: [_jsx("strong", { children: selection.length === 1 ? deliveryRelativeName(selection[0]) : selection.length + " file selezionati" }), _jsx("span", { children: formatBytes(selection.reduce((sum, file) => sum + file.size, 0)) }), _jsx("button", { type: "button", className: "ak-btn ak-btn-quiet", disabled: uploading, onClick: () => {
493
+ return (_jsxs("div", { className: "dl-work dl-transfer-canvas", children: [_jsx("input", { ref: coverRef, "data-transfer-cover-input": true, type: "file", accept: "image/jpeg,image/png,image/webp", multiple: true, hidden: true, onChange: selectCovers }), _jsxs("header", { className: "dl-work-head", children: [_jsxs("div", { className: "dl-work-title", children: [state && _jsx("span", { className: "dl-pill is-" + state.kind, children: state.label }), _jsx("h2", { children: delivery ? draft.title.trim() || delivery.title : "Nuovo transfer" })] }), _jsxs("div", { className: "dl-work-actions", children: [link && (_jsx("a", { className: "ak-btn", href: link.url, target: "_blank", rel: "noreferrer", children: "Apri pagina pubblica" })), link && (_jsx("button", { className: "ak-btn ak-btn-primary", disabled: !dirty || saving || busy || uploading, onClick: () => void save(), children: saving ? "Salvo…" : "Salva" }))] })] }), (failure || notice) && (_jsxs("p", { role: failure ? "alert" : "status", className: failure ? "ak-error dl-feedback" : "dl-feedback is-ok", children: [failure || notice, _jsx("button", { type: "button", "aria-label": "Chiudi", onClick: () => { setFailure(null); setNotice(null); }, children: "\u00D7" })] })), _jsxs("div", { className: "dl-grid dl-compose-grid" + (advanced ? " is-expanded" : ""), children: [_jsxs("div", { className: "dl-main", children: [ready && sharingCard, _jsxs("div", { className: "dl-compose-card", children: [_jsxs("section", { className: "dl-card dl-upload-card", "aria-labelledby": "dl-files-heading", children: [_jsxs("div", { className: "dl-section-head", children: [_jsx("h3", { id: "dl-files-heading", children: "File da consegnare" }), _jsx("p", { children: "Fino a 150 GB per caricamento." })] }), _jsxs("div", { className: "dl-pick", children: [_jsxs("button", { className: "dl-pick-tile", disabled: uploading, onClick: () => choose(false), children: [_jsx(FileIcon, {}), "Aggiungi file"] }), _jsxs("button", { className: "dl-pick-tile", disabled: uploading, onClick: () => choose(true), children: [_jsx(FolderIcon, {}), "Aggiungi una cartella"] }), _jsx("div", { ref: fileInputs, hidden: true })] }), _jsx(DropArea, { disabled: uploading, resuming: !!resumeRef.current, onFiles: addFiles, onError: (error) => setFailure(errorText(error)) }), !!selection.length && _jsxs("div", { className: "dl-selection", "aria-live": "polite", children: [_jsx("strong", { children: selection.length === 1 ? deliveryRelativeName(selection[0]) : selection.length + " file selezionati" }), _jsx("span", { children: formatBytes(selection.reduce((sum, file) => sum + file.size, 0)) }), _jsx("button", { type: "button", className: "ak-btn ak-btn-quiet", disabled: uploading, onClick: () => {
502
494
  setSelection([]);
503
495
  fileInputs.current?.replaceChildren();
504
496
  }, children: "Svuota selezione" }), selection.length > 1 && _jsxs("details", { className: "dl-selected-list", children: [_jsx("summary", { children: "Mostra file" }), _jsx("ul", { children: selection.slice(0, filesShown).map((file, index) => _jsxs("li", { children: [_jsx("span", { children: deliveryRelativeName(file) }), _jsx("button", { className: "ak-btn", type: "button", disabled: uploading, "aria-label": `Rimuovi ${deliveryRelativeName(file)}`, onClick: () => setSelection(files => files.filter((_, i) => i !== index)), children: "\u00D7" })] }, index)) }), filesShown < selection.length && _jsx("button", { className: "ak-btn", type: "button", onClick: () => setFilesShown(count => count + 50), children: "Mostra altri file" })] })] }), job && isBusy(job) && _jsx(Progress, { job: job }), !!packages.length && (_jsx("ul", { className: "dl-files", children: packages.map((pkg) => (_jsxs("li", { className: "dl-file is-" + pkg.state + (confirmPackage === pkg.id ? " is-confirming" : ""), children: [_jsx("span", { className: "dl-file-icon", "aria-hidden": "true", children: pkg.state === "ready" ? "✓" : "…" }), _jsx(PackageContents, { pkg: pkg, confirming: confirmPackage === pkg.id, job: job?.id === pkg.id ? job : undefined, onAction: onAction }), confirmPackage === pkg.id ? (_jsx(_Fragment, { children: _jsxs("span", { className: "dl-file-actions", children: [_jsx("button", { className: "ak-btn", onClick: () => setConfirmPackage(null), children: "Annulla" }), _jsx("button", { className: "ak-btn dl-danger-btn", disabled: uploading, onClick: () => {
505
497
  setConfirmPackage(null);
506
498
  void run({ action: "deletePackage", id: delivery?.id, packageId: pkg.id }, "File rimossi");
507
- }, children: "S\u00EC, rimuovi" })] }) })) : (_jsx(_Fragment, { children: _jsxs("span", { className: "dl-file-actions", children: [pkg.state !== "ready" && !(job?.id === pkg.id && isBusy(job)) && (_jsx("button", { className: "ak-btn", disabled: uploading, onClick: () => { resumeRef.current = pkg; setSelection([]); setNotice(resumeHint); }, children: "Riprendi" })), !(job?.id === pkg.id && isBusy(job)) && (_jsx("button", { className: "ak-btn ak-btn-quiet", disabled: uploading, onClick: () => setConfirmPackage(pkg.id), children: "Rimuovi" }))] }) }))] }, pkg.id))) }))] }), _jsxs("form", { ref: quickFields, className: "dl-card dl-about dl-quick-fields", onSubmit: event => { event.preventDefault(); void beginUpload(selection, resumeRef.current); }, children: [_jsx(DeliveryEmail, { id: delivery?.id, value: emailPreferences, onChange: setEmailPreferences, busy: saving || uploading, unsaved: dirty, activityTarget: activityTarget, canResend: ready, hydratePreferences: !!fromServer, onState: p => { setEmailPreferences(p); setEmailClean(p); } }), _jsx(Field, { label: "Titolo", children: _jsx("input", { disabled: uploading || saving, value: draft.title, placeholder: selection.length ? deliverySelectionName(selection) : "Titolo del transfer", onChange: (e) => change({ title: e.target.value }) }) }), _jsx(Field, { label: "Messaggio", wide: true, children: _jsx("textarea", { disabled: uploading || saving, rows: 3, value: draft.description, onChange: (e) => change({ description: e.target.value }) }) }), _jsxs("div", { className: "dl-compose-actions", children: [_jsx("button", { ref: toggleRef, type: "button", className: "ak-btn dl-options-toggle", "aria-label": "Opzioni del transfer", title: "Opzioni del transfer", "aria-expanded": advanced, "aria-controls": "dl-options", onClick: () => setAdvanced(open => !open), children: "\u2022\u2022\u2022" }), _jsx("button", { className: "ak-btn ak-btn-primary", type: "submit", disabled: !selection.length || uploading || saving || busy, children: preparing ? "Caricamento in corso…" : resumeRef.current ? "Riprendi caricamento" : "Trasferisci" })] })] })] }), !ready && sharingCard, !link && delivery && !uploading && (_jsx("button", { className: "ak-btn", disabled: saving || busy, onClick: () => void save(), children: "Ottieni il link" }))] }), _jsxs("aside", { className: "dl-side", id: "dl-options", "aria-label": "Opzioni del transfer", hidden: !advanced, children: [_jsxs("div", { className: "dl-options-head", children: [_jsx("h3", { tabIndex: -1, ref: optionsTitle, children: "Opzioni del transfer" }), _jsx("button", { type: "button", className: "ak-btn", "aria-label": "Chiudi opzioni", onClick: () => { setAdvanced(false); toggleRef.current?.focus(); }, children: "\u00D7" })] }), _jsxs("fieldset", { className: "dl-option-fields", disabled: uploading || saving, children: [_jsxs(Group, { title: "Opzioni di consegna", note: packages.length
499
+ }, children: "S\u00EC, rimuovi" })] }) })) : (_jsx(_Fragment, { children: _jsxs("span", { className: "dl-file-actions", children: [pkg.state !== "ready" && !(job?.id === pkg.id && isBusy(job)) && (_jsx("button", { className: "ak-btn", disabled: uploading, onClick: () => { resumeRef.current = pkg; setSelection([]); setNotice(resumeHint); }, children: "Riprendi" })), !(job?.id === pkg.id && isBusy(job)) && (_jsx("button", { className: "ak-btn ak-btn-quiet", disabled: uploading, onClick: () => setConfirmPackage(pkg.id), children: "Rimuovi" }))] }) }))] }, pkg.id))) }))] }), _jsxs("form", { ref: quickFields, className: "dl-card dl-about dl-quick-fields", onSubmit: event => { event.preventDefault(); void beginUpload(selection, resumeRef.current); }, children: [_jsx(DeliveryEmail, { id: delivery?.id, value: emailPreferences, onChange: setEmailPreferences, busy: saving || uploading, unsaved: dirty, activityTarget: activityTarget, canResend: ready, hydratePreferences: !!fromServer, onState: p => { setEmailPreferences(p); setEmailClean(p); } }), _jsx(Field, { label: "Titolo", children: _jsx("input", { disabled: uploading || saving, value: draft.title, placeholder: selection.length ? deliverySelectionName(selection) : "Titolo del transfer", onChange: (e) => change({ title: e.target.value }) }) }), _jsx(Field, { label: "Messaggio", wide: true, children: _jsx("textarea", { disabled: uploading || saving, rows: 3, value: draft.description, onChange: (e) => change({ description: e.target.value }) }) }), _jsxs("div", { className: "dl-compose-actions", children: [_jsx("button", { ref: toggleRef, type: "button", className: "ak-btn dl-options-toggle", "aria-label": "Opzioni del transfer", title: "Opzioni del transfer", "aria-expanded": advanced, "aria-controls": "dl-options", onClick: () => setAdvanced(open => !open), children: "\u2022\u2022\u2022" }), _jsx("button", { className: "ak-btn ak-btn-primary", type: "submit", disabled: !selection.length || uploading || saving || busy, children: preparing ? "Caricamento in corso…" : resumeRef.current ? "Riprendi caricamento" : "Trasferisci" })] })] })] }), !ready && sharingCard, !link && delivery && !uploading && (_jsx("button", { className: "ak-btn", disabled: saving || busy, onClick: () => void save(), children: "Ottieni il link" }))] }), _jsx(DeliveryRecipientPreview, { title: draft.title.trim() || (selection.length ? deliverySelectionName(selection) : delivery?.title) || "", clientName: draft.clientName.trim(), message: draft.description, covers: previewCovers, disabled: saving || uploading || preparing, onChoose: () => coverRef.current?.click() }), _jsxs("aside", { className: "dl-side", id: "dl-options", "aria-label": "Opzioni del transfer", hidden: !advanced, children: [_jsxs("div", { className: "dl-options-head", children: [_jsx("h3", { tabIndex: -1, ref: optionsTitle, children: "Opzioni del transfer" }), _jsx("button", { type: "button", className: "ak-btn", "aria-label": "Chiudi opzioni", onClick: () => { setAdvanced(false); toggleRef.current?.focus(); }, children: "\u00D7" })] }), _jsxs("fieldset", { className: "dl-option-fields", disabled: uploading || saving, children: [_jsxs(Group, { title: "Opzioni di consegna", note: packages.length
508
500
  ? "Le opzioni dei file caricati sono bloccate. Per cambiarle, rimuovi e ricarica i file."
509
501
  : "Puoi cambiare queste opzioni prima di premere Trasferisci.", children: [_jsxs("label", { className: "dl-check", children: [_jsx("input", { type: "checkbox", checked: draft.gallery, disabled: !!packages.length, onChange: (e) => change({ gallery: e.target.checked }) }), _jsxs("span", { children: [_jsx("strong", { children: "Galleria" }), _jsx("small", { children: "Mostra le foto in anteprima sulla pagina del transfer." })] })] }), _jsxs("label", { className: "dl-check", children: [_jsx("input", { type: "checkbox", checked: draft.light, disabled: !!packages.length, onChange: (e) => change({ light: e.target.checked, webFormat: jpegEnabled ? draft.webFormat : "webp" }) }), _jsxs("span", { children: [_jsx("strong", { children: "Aggiungi conversione in bassa risoluzione" }), _jsx("small", { children: "Chi scarica pu\u00F2 scegliere foto pi\u00F9 leggere per web e social, fino a 2048 px sul lato lungo." })] })] }), draft.light && (_jsxs("label", { className: "dl-field", children: [_jsx("span", { children: "Formato della conversione" }), _jsxs("select", { className: "dl-select", "aria-label": "Formato della conversione", value: draft.webFormat, disabled: !!packages.length || uploading, onChange: (e) => change({ webFormat: e.target.value === "jpg" ? "jpg" : "webp" }), children: [_jsx("option", { value: "webp", children: "WebP \u2014 file pi\u00F9 piccoli" }), _jsx("option", { value: "jpg", disabled: !jpegEnabled && draft.webFormat !== "jpg", children: "JPG \u2014 massima compatibilit\u00E0" })] }), _jsxs("small", { children: ["2048 px sul lato lungo, senza ingrandire le foto pi\u00F9 piccole. Qualit\u00E0 ", draft.webFormat === "jpg" ? "82%" : "80%", "."] })] }))] }), _jsx(Group, { title: "Cliente", children: _jsx(Field, { label: "Destinatario", hint: "Nome del cliente o dell\u2019azienda. Facoltativo.", children: _jsx("input", { value: draft.clientName, placeholder: "Es. Azienda Rossi", onChange: (e) => change({ clientName: e.target.value }) }) }) }), _jsxs(Group, { title: "Chi pu\u00F2 aprirlo", children: [_jsxs("label", { className: "dl-radio", children: [_jsx("input", { type: "radio", name: "dl-access", checked: !draft.pin, onChange: () => change({ pin: "" }) }), _jsxs("span", { children: [_jsx("strong", { children: "Chiunque abbia il link" }), _jsx("small", { children: "Chi riceve il link pu\u00F2 aprire il transfer e condividerlo." })] })] }), _jsxs("label", { className: "dl-radio", children: [_jsx("input", { type: "radio", name: "dl-access", checked: !!draft.pin, onChange: () => change({ pin: draft.pin || makeCode() }) }), _jsxs("span", { children: [_jsx("strong", { children: "Link e codice di accesso" }), _jsx("small", { children: "Condividi il codice con il destinatario. Dopo 10 tentativi errati, l\u2019accesso \u00E8 sospeso per un\u2019ora." })] })] }), !!draft.pin && (_jsxs("div", { className: "dl-code", children: [_jsx("input", { "aria-label": "Codice di accesso", value: draft.pin, spellCheck: false, onChange: (e) => change({ pin: e.target.value.toUpperCase() }) }), _jsx("button", { className: "ak-btn", onClick: () => change({ pin: makeCode() }), children: "Rigenera" })] }))] }), downloadLabelsEnabled && (_jsxs(Group, { title: "Testi dei pulsanti di download", note: "Lascia vuoto per usare il testo predefinito. Puoi cambiarli anche dopo l\u2019invio, senza ricaricare i file.", children: [delivery?.status !== "archived" && (_jsx(Field, { label: "Pulsante degli originali", children: _jsx("input", { value: draft.downloadOriginalsLabel, maxLength: 80, placeholder: "Scarica i file", onChange: (e) => change({ downloadOriginalsLabel: e.target.value }) }) })), (packages.length ? packages.some(pkg => pkg.webEnabled) : draft.light) && (_jsx(Field, { label: "Pulsante della versione leggera", children: _jsx("input", { value: draft.downloadWebLabel, maxLength: 80, placeholder: "Versione leggera", onChange: (e) => change({ downloadWebLabel: e.target.value }) }) }))] })), _jsxs(Group, { title: "Scadenza", children: [_jsxs("select", { "aria-label": "Scadenza", className: "dl-select", value: draft.duration, onChange: (e) => change({ duration: e.target.value }), children: [delivery && _jsx("option", { value: "keep", children: delivery.filesExpiresAt
510
502
  ? `Fino al ${formatDate(delivery.filesExpiresAt)}`
@@ -512,12 +504,11 @@ export function DeliveryWorkspace({ delivery: fromServer, defaultHeroes = [], bu
512
504
  ? `Dopo il ${formatDate(expiry)} il link continua ad aprirsi, ma i file non si scaricano più.`
513
505
  : "I file restano finché non li togli tu." })] }), _jsxs(Group, { title: "Alla fine della pagina", children: [_jsxs("label", { className: "dl-check", children: [_jsx("input", { type: "checkbox", checked: draft.ctaEnabled, onChange: (e) => change({ ctaEnabled: e.target.checked }) }), _jsxs("span", { children: [_jsx("strong", { children: "Chiedi una recensione" }), _jsx("small", { children: "Un pulsante in fondo, dopo le fotografie." })] })] }), draft.ctaEnabled && (_jsxs(_Fragment, { children: [_jsx(Field, { label: "Testo del pulsante", children: _jsx("input", { value: draft.ctaLabel, onChange: (e) => change({ ctaLabel: e.target.value }) }) }), _jsx(Field, { label: "Indirizzo", hint: "Il link alla tua pagina delle recensioni.", children: _jsx("input", { type: "url", value: draft.ctaUrl, placeholder: "https://\u2026", onChange: (e) => change({ ctaUrl: e.target.value }) }) })] })), _jsx(Field, { label: "Note d'uso", hint: "Cosa pu\u00F2 farci il cliente. Appaiono in fondo alla pagina.", children: _jsx("textarea", { rows: 3, value: draft.licenseNotes, onChange: (e) => change({ licenseNotes: e.target.value }) }) })] }), _jsxs("details", { className: "dl-unavailable", children: [_jsx("summary", { children: "Funzioni aggiuntive non attive" }), _jsxs("div", { children: [" ", _jsxs(Group, { title: "Richiedi pagamento", children: [_jsx("span", { className: "dl-payment-status", children: "Chiedi di attivare la funzione" }), _jsxs("label", { className: "dl-check dl-payment-disabled", children: [_jsx("input", { type: "checkbox", checked: false, disabled: true, "aria-describedby": "dl-payment-description" }), _jsxs("span", { children: [_jsx("strong", { children: "Sblocca gallery e download al saldo" }), _jsx("small", { id: "dl-payment-description", children: "Potrai impostare l\u2019importo da incassare per questa consegna. Il cliente pagher\u00E0 una sola volta per sbloccare la galleria e scaricare i file." })] })] }), _jsx("p", { className: "dl-note", children: "Questa opzione non \u00E8 ancora disponibile: il transfer non richiede pagamenti e segue le impostazioni di accesso qui sopra." })] }), _jsxs(Group, { title: "Selezione del cliente", children: [_jsx("span", { className: "dl-payment-status", children: "Chiedi di attivare la funzione" }), _jsxs("label", { className: "dl-check dl-payment-disabled", children: [_jsx("input", { type: "checkbox", checked: false, disabled: true, "aria-describedby": "dl-selection-description" }), _jsxs("span", { children: [_jsx("strong", { children: "Consenti al cliente di scegliere le foto" }), _jsx("small", { id: "dl-selection-description", children: "Il cliente potr\u00E0 indicare nella galleria quali foto entrano nella sua selezione." })] })] }), _jsx("p", { className: "dl-note", children: "Questa opzione non \u00E8 ancora disponibile: al momento il cliente pu\u00F2 consultare la galleria, se abilitata, ma non salvare una selezione." })] })] })] }), _jsxs("section", { className: "dl-card dl-cover", children: [_jsxs("div", { className: "dl-cover-head", children: [_jsxs("div", { children: [_jsx("span", { className: "dl-step", children: "Copertina" }), _jsxs("p", { children: ["Fino a otto sfondi per la pagina del destinatario.", " ", coverFiles.length ? coverFiles.map(file => file.name).join(", ") : heroes.length
514
506
  ? `Ne hai scelte ${heroes.length}.`
515
- : "Nessuna scelta: si userà quella predefinita."] }), _jsx("p", { role: "status", children: !delivery ? "Puoi scegliere uno sfondo per questo transfer prima di inviarlo." : heroesDirty
507
+ : "Nessuna scelta: si userà quella predefinita."] }), _jsx("p", { role: "status", children: !delivery ? "Puoi scegliere uno sfondo per questo transfer prima di inviarlo." : heroesDirty || coverFiles.length > 0
516
508
  ? "Scelta non ancora salvata: premi Salva modifiche per mostrarla al cliente."
517
509
  : heroes.length
518
510
  ? "Copertine salvate. Una sola immagine resta fissa; più immagini compongono la sequenza."
519
- : "Scegli le copertine qui: la galleria sotto nella pagina del cliente è separata." })] }), _jsxs("div", { className: "dl-cover-actions", children: [!!photos.length && (_jsx("button", { className: "ak-btn", onClick: () => setPreviewAttempt(value => value + 1), title: "Riprova a caricare le miniature senza cambiare le copertine selezionate", children: "Ricarica anteprime" })), delivery && _jsx("button", { className: "ak-btn ak-btn-primary", disabled: !dirty || saving || busy || uploading, onClick: () => void save(), children: saving ? "Salvo…" : "Salva modifiche" }), _jsx("button", { className: "ak-btn", disabled: saving || uploading, onClick: () => { if (coverRef.current)
520
- coverRef.current.value = ""; coverRef.current?.click(); }, children: "Carica un'immagine" }), (!!heroes.length || !!coverFiles.length) && (_jsx("button", { className: "ak-btn ak-btn-quiet", disabled: saving, onClick: () => { setHeroes([]); setCoverFiles([]); }, children: "Usa quella predefinita" })), _jsx("input", { ref: coverRef, type: "file", accept: "image/jpeg,image/png,image/webp", multiple: true, hidden: true, onChange: (event) => void uploadCovers(event) })] })] }), packages.some(pkg => (moreImages[pkg.id] ? moreImages[pkg.id].nextCursor : pkg.nextCursor) != null) && (_jsx("button", { className: "ak-btn", disabled: loadingImages, onClick: () => void loadMoreImages(), children: loadingImages ? "Caricamento…" : "Mostra altre foto" })), photos.length ? (_jsx("div", { className: "dl-cover-grid", children: photos.map(({ pkg, image }) => {
511
+ : "Scegli le copertine qui: la galleria sotto nella pagina del cliente è separata." })] }), _jsxs("div", { className: "dl-cover-actions", children: [!!photos.length && (_jsx("button", { className: "ak-btn", onClick: () => setPreviewAttempt(value => value + 1), title: "Riprova a caricare le miniature senza cambiare le copertine selezionate", children: "Ricarica anteprime" })), delivery && _jsx("button", { className: "ak-btn ak-btn-primary", disabled: !dirty || saving || busy || uploading, onClick: () => void save(), children: saving ? "Salvo…" : "Salva modifiche" }), _jsx("button", { className: "ak-btn", disabled: saving || uploading, onClick: () => coverRef.current?.click(), children: "Carica un'immagine" }), (!!heroes.length || !!coverFiles.length) && (_jsx("button", { className: "ak-btn ak-btn-quiet", disabled: saving, onClick: () => { setHeroes([]); setCoverFiles([]); }, children: "Usa quella predefinita" }))] })] }), packages.some(pkg => (moreImages[pkg.id] ? moreImages[pkg.id].nextCursor : pkg.nextCursor) != null) && (_jsx("button", { className: "ak-btn", disabled: loadingImages, onClick: () => void loadMoreImages(), children: loadingImages ? "Caricamento…" : "Mostra altre foto" })), photos.length ? (_jsx("div", { className: "dl-cover-grid", children: photos.map(({ pkg, image }) => {
521
512
  const chosen = heroes.some((item) => item.type === "package" && item.packageId === pkg.id && item.index === image.index);
522
513
  return (_jsxs("button", { type: "button", className: chosen ? "is-chosen" : "", disabled: saving, "aria-pressed": chosen, onClick: () => toggleCover(pkg.id, image.index, image.previewUrl), children: [_jsx("img", { src: previewAttempt ? `${image.previewUrl}&previewRetry=${previewAttempt}` : image.previewUrl, alt: image.name, width: image.width, height: image.height, loading: "lazy" }), chosen && _jsx("em", { "aria-hidden": "true", children: "\u2713" })] }, `${pkg.id}-${image.index}`));
523
514
  }) })) : ready ? (_jsx("p", { className: "dl-note dl-cover-empty", children: heroes.some((item) => item.type === "object")
@@ -0,0 +1,10 @@
1
+ interface Props {
2
+ title: string;
3
+ clientName: string;
4
+ message: string;
5
+ covers: (string | File)[];
6
+ onChoose: () => void;
7
+ disabled: boolean;
8
+ }
9
+ export declare function DeliveryRecipientPreview(props: Props): import("react").JSX.Element;
10
+ export {};
@@ -0,0 +1,56 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ // Keep file previews local to the editor, including covers awaiting their first save.
4
+ function usePreviewCovers(sources) {
5
+ const [images, setImages] = useState([]);
6
+ useEffect(() => {
7
+ const localUrls = [];
8
+ const loaded = sources.map(() => null);
9
+ setImages([]);
10
+ const probes = sources.map((source, i) => {
11
+ const image = new Image();
12
+ const url = typeof source === "string" ? source : URL.createObjectURL(source);
13
+ if (typeof source !== "string")
14
+ localUrls.push(url);
15
+ image.onload = () => {
16
+ loaded[i] = { src: url, portrait: image.naturalHeight > image.naturalWidth };
17
+ setImages([...loaded]);
18
+ };
19
+ image.src = url;
20
+ return image;
21
+ });
22
+ return () => {
23
+ for (const image of probes)
24
+ image.onload = null;
25
+ for (const url of localUrls)
26
+ URL.revokeObjectURL(url);
27
+ };
28
+ }, [sources]);
29
+ return images.filter((image) => image !== null);
30
+ }
31
+ export function DeliveryRecipientPreview(props) {
32
+ const figure = useRef(null);
33
+ const [pairPortraits, setPairPortraits] = useState(false);
34
+ const [page, setPage] = useState(0);
35
+ const covers = usePreviewCovers(props.covers);
36
+ useEffect(() => {
37
+ const canvas = figure.current?.closest(".dl-transfer-canvas");
38
+ if (!canvas)
39
+ return;
40
+ const observer = new ResizeObserver(([entry]) => setPairPortraits(entry.contentRect.width > 688));
41
+ observer.observe(canvas);
42
+ return () => observer.disconnect();
43
+ }, []);
44
+ useEffect(() => { setPage(0); }, [pairPortraits, props.covers]);
45
+ const groups = [];
46
+ for (let i = 0; i < covers.length; i++) {
47
+ const group = [covers[i]];
48
+ if (pairPortraits && covers[i].portrait && covers[i + 1]?.portrait)
49
+ group.push(covers[++i]);
50
+ groups.push(group);
51
+ }
52
+ const current = Math.min(page, Math.max(0, groups.length - 1));
53
+ const group = groups[current] ?? [];
54
+ const chooseLabel = group.length ? "Cambia copertina" : "Scegli una copertina";
55
+ return _jsxs("figure", { className: "dl-artwork", ref: figure, "aria-label": "Copertina del transfer", children: [group.length > 0 && _jsx("div", { className: "dl-artwork-images", children: group.map(cover => _jsx("img", { src: cover.src, alt: "" }, cover.src)) }), _jsxs("figcaption", { children: [(props.clientName || props.title) && _jsxs("div", { className: "dl-artwork-title", children: [_jsx("strong", { children: props.clientName || props.title }), props.clientName && props.title && _jsx("span", { children: props.title })] }), props.message && _jsx("p", { children: props.message })] }), _jsxs("div", { className: "dl-artwork-tools", children: [_jsx("button", { type: "button", disabled: props.disabled, onClick: props.onChoose, children: chooseLabel }), groups.length > 1 && _jsxs("div", { role: "group", "aria-label": "Sequenza delle copertine", children: [_jsx("button", { type: "button", "aria-label": "Vista precedente", onClick: () => setPage((current + groups.length - 1) % groups.length), children: "\u2039" }), _jsxs("span", { "aria-live": "polite", children: [current + 1, " / ", groups.length] }), _jsx("button", { type: "button", "aria-label": "Vista successiva", onClick: () => setPage((current + 1) % groups.length), children: "\u203A" })] })] })] });
56
+ }
@@ -0,0 +1,15 @@
1
+ // Covers created by earlier clients always have a WebP key.
2
+ export function heroExtension(contentType = "image/webp") {
3
+ switch (contentType) {
4
+ case "image/webp": return "webp";
5
+ case "image/jpeg": return "jpg";
6
+ case "image/png": return "png";
7
+ default: throw Object.assign(new Error("Scegli una copertina JPEG, PNG o WebP."), { status: 400, retryable: false });
8
+ }
9
+ }
10
+
11
+ export function heroContentType(key) {
12
+ if (key.endsWith(".png")) return "image/png";
13
+ if (key.endsWith(".jpg")) return "image/jpeg";
14
+ return "image/webp";
15
+ }
@@ -1,3 +1,4 @@
1
+ import { heroContentType } from "../../_shared/delivery-hero-format.js";
1
2
  /* Derivata hero dedicata: oggetto piccolo B2, mai l'originale fotografico. */
2
3
  import { b2Get } from "../../_shared/b2.js";
3
4
 
@@ -11,7 +12,7 @@ export async function onRequestGet({ request, env }) {
11
12
  const upstream = await b2Get(env, hero.object_key);
12
13
  if (!upstream.ok) return new Response("Not found", { status: upstream.status });
13
14
  const headers = new Headers({
14
- "Content-Type": "image/webp",
15
+ "Content-Type": heroContentType(hero.object_key),
15
16
  "Cache-Control": "private, max-age=3600",
16
17
  "X-Content-Type-Options": "nosniff",
17
18
  });
@@ -1,3 +1,4 @@
1
+ import { heroExtension } from "../../_shared/delivery-hero-format.js";
1
2
  import { requestDiagnostics, technicalDiagnostic } from "../../_shared/diagnostics.js";
2
3
  import packageInfo from "../../../../package.json" with { type: "json" };
3
4
  /* Controllo multipart Backblaze B2.
@@ -75,7 +76,7 @@ async function heroPresign(env, body) {
75
76
  if (!pkg) throw invalid("pacchetto per la hero non trovato o scaduto");
76
77
  assertUploadSessionInvocation(env, pkg);
77
78
  const heroId = crypto.randomUUID();
78
- const key = b2ObjectKey(pkg.storage_prefix, `heroes/${heroId}.webp`);
79
+ const key = b2ObjectKey(pkg.storage_prefix, `heroes/${heroId}.${heroExtension(body.contentType)}`);
79
80
  const now = new Date().toISOString();
80
81
  await env.DB.prepare(`
81
82
  INSERT INTO delivery_hero_objects
@@ -1,3 +1,4 @@
1
+ import { heroContentType } from "../_shared/delivery-hero-format.js";
1
2
  import { bundleIdentity, bundleResponse, downloadSources } from "../_shared/delivery-download-bundle.js";
2
3
  import {processDeliveryEmails} from "../_shared/delivery-email.js";
3
4
  /* Consegna pubblica: /c/<token>.
@@ -528,7 +529,7 @@ async function hero(env, access, id) {
528
529
  const upstream = await b2Get(env, selected.objectKey);
529
530
  if (!upstream.ok) return new Response("Not found", { status: upstream.status });
530
531
  const headers = new Headers({
531
- "Content-Type": "image/webp",
532
+ "Content-Type": heroContentType(selected.objectKey),
532
533
  "Cache-Control": "private, max-age=86400",
533
534
  "X-Content-Type-Options": "nosniff",
534
535
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cardinali-studio/adminkit",
3
- "version": "2.2.50",
3
+ "version": "2.2.52",
4
4
  "type": "module",
5
5
  "description": "Motore riusabile di un pannello di amministrazione per siti Hugo su Cloudflare Pages: codec del front matter guidato dallo schema, form React, libreria media su R2. NIENTE di specifico di un sito qui dentro.",
6
6
  "license": "0BSD",