@cardinali-studio/adminkit 2.2.50 → 2.2.51

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,8 @@ 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); }
2497
+ .dl-compose-companion { display: grid; gap: 14px; min-width: 0; }
2498
2498
  .dl-compose-grid [hidden] { display: none; }
2499
2499
  .dl-options-head, .dl-compose-actions, .dl-selection { display: flex; align-items: center; gap: .75rem; }
2500
2500
  .dl-options-head { justify-content: space-between; }
@@ -2512,7 +2512,9 @@ body:has(.uk) .pane-body { padding-bottom: 190px; }
2512
2512
  .dl-compose-grid .dl-cover-actions { justify-content: start; }
2513
2513
  .dl-work:has(.dl-compose-grid) { container-type: inline-size; }
2514
2514
  @container (max-width: 43rem) {
2515
- .dl-compose-grid.is-expanded { grid-template-columns: minmax(0,1fr); }
2515
+ .dl-compose-grid { grid-template-columns: minmax(0,1fr); }
2516
+ .dl-compose-companion { display: contents; }
2517
+ .dl-recipient { order: -1; }
2516
2518
  }
2517
2519
  @media (max-width: 700px) {
2518
2520
  .dl-compose-grid .dl-pick { grid-template-columns: repeat(2,minmax(0,1fr)); }
@@ -2521,9 +2523,6 @@ body:has(.uk) .pane-body { padding-bottom: 190px; }
2521
2523
  .dl-default-covers { display: flex; flex-wrap: wrap; gap: 1rem; padding: 0; list-style: none; }
2522
2524
  .dl-default-covers li { display: grid; gap: .4rem; }
2523
2525
  .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
2526
  .dl-selected-list { flex-basis: 100%; }
2528
2527
  .dl-selected-list summary { cursor: pointer; }
2529
2528
  .dl-selected-list ul { padding: 0; list-style: none; max-height: 12rem; overflow: auto; }
@@ -2546,3 +2545,47 @@ body:has(.uk) .pane-body { padding-bottom: 190px; }
2546
2545
  @container (min-width: 43.01rem) {
2547
2546
  .dl-compose-grid.is-expanded .dl-side { max-height: min(42rem, 80svh); overflow-y: auto; scrollbar-gutter: stable; }
2548
2547
  }
2548
+
2549
+ /* A miniature of the first recipient screen, separate from the authoring controls. */
2550
+ .dl-recipient { min-width: 0; overflow: hidden; border: 1px solid var(--ak-line); border-radius: var(--ak-radius); background: var(--ak-panel); }
2551
+ .dl-recipient-tools { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; padding: .65rem .85rem; }
2552
+ .dl-recipient-tools h3 { margin: 0; font: 600 .9rem/1.3 var(--ak-font); color: var(--ak-ink); }
2553
+ .dl-preview-devices, .dl-preview-pager { display: flex; align-items: center; gap: .2rem; }
2554
+ .dl-preview-devices { padding: .15rem; border: 1px solid var(--ak-line); border-radius: .6rem; }
2555
+ .dl-preview-devices button, .dl-preview-pager button { border: 0; border-radius: .4rem; background: transparent; color: var(--ak-ink-quiet); cursor: pointer; font: 500 .75rem/1 var(--ak-font); }
2556
+ .dl-preview-devices button { min-height: 30px; padding: .35rem .65rem; }
2557
+ .dl-preview-devices button[aria-pressed=true] { color: var(--ak-ink); background: var(--ak-bg); box-shadow: inset 0 0 0 1px var(--ak-line); }
2558
+ .dl-preview-surround { padding: .7rem; background: var(--ak-bg); }
2559
+ .dl-preview-page { container-type: inline-size; position: relative; width: 100%; aspect-ratio: 16/10; margin: auto; overflow: auto; border-radius: .35rem; background: #f3f2ec; color: #15140e; color-scheme: light; font-family: var(--ak-font); }
2560
+ .dl-preview-page.is-phone { width: min(100%, 13rem); aspect-ratio: 390/680; }
2561
+ .dl-preview-sheet { position: relative; display: grid; min-height: 100%; }
2562
+ .dl-preview-page.with-covers .dl-preview-sheet { grid-template-columns: 30% minmax(0,1fr); }
2563
+ .dl-preview-menu { position: absolute; z-index: 1; top: 2.2cqw; left: 50%; transform: translateX(-50%); padding: .35em .9em; border: 1px solid #d5d3c9; border-radius: 2em; background: #f3f2ece6; font-size: clamp(8px,1.3cqw,12px); }
2564
+ .dl-preview-info { display: flex; flex-direction: column; align-items: flex-start; gap: 1.1cqw; min-width: 0; overflow-wrap: anywhere; padding: 8cqw 2.2cqw 3cqw; font-size: clamp(9px,1.4cqw,13px); line-height: 1.4; }
2565
+ .dl-preview-page:not(.with-covers) .dl-preview-info { width: min(100%, 44ch); }
2566
+ .dl-preview-kicker, .dl-preview-expiry { color: #635f54; font: 500 clamp(8px,1cqw,10px)/1.35 ui-monospace, monospace; text-transform: uppercase; letter-spacing: .045em; }
2567
+ .dl-preview-title, .dl-preview-work { line-height: 1.05; letter-spacing: -.045em; }
2568
+ .dl-preview-title { font-size: clamp(17px,3.8cqw,32px); }
2569
+ .dl-preview-work { font-size: 1.4em; font-weight: 600; }
2570
+ .dl-preview-info p { margin: 0; white-space: pre-line; color: #514e49; }
2571
+ .dl-preview-download, .dl-preview-gate { display: grid; justify-items: start; gap: .4em; }
2572
+ .dl-preview-download small { font-size: .95em; color: #625e53; }
2573
+ .dl-preview-button, .dl-preview-final { max-width: 100%; padding: .65em 1em; border-radius: 2em; font-weight: 600; }
2574
+ .dl-preview-button { color: #fff; background: #15140e; }
2575
+ .dl-preview-final { background: white; margin-top: auto; }
2576
+ .dl-preview-stage { display: flex; align-self: stretch; min-width: 0; gap: 1cqw; padding: 2cqw; }
2577
+ .dl-preview-stage img { flex: 1 1 0; width: 0; min-width: 0; height: 58.5cqw; object-fit: contain; align-self: center; }
2578
+ .dl-preview-page.is-phone .dl-preview-sheet { display: flex; flex-direction: column; }
2579
+ .dl-preview-page.is-phone .dl-preview-menu { top: 4cqw; right: 4cqw; left: auto; transform: none; }
2580
+ .dl-preview-page.is-phone .dl-preview-info { gap: 2.5cqw; padding: 18cqw 5cqw 5cqw; }
2581
+ .dl-preview-page.is-phone .dl-preview-title { font-size: clamp(18px,8cqw,26px); }
2582
+ .dl-preview-page.is-phone .dl-preview-stage { flex: 1; padding: 2cqw 5cqw 5cqw; }
2583
+ .dl-preview-page.is-phone .dl-preview-stage img { height: 86cqw; }
2584
+ .dl-preview-pager { justify-content: center; gap: .6rem; padding: .2rem; font-size: .75rem; font-variant-numeric: tabular-nums; }
2585
+ .dl-preview-pager button { min-width: 36px; min-height: 32px; font-size: 1.4rem; }
2586
+ .dl-preview-devices button:focus-visible, .dl-preview-pager button:focus-visible { outline: 2px solid var(--ak-accent); outline-offset: 1px; }
2587
+
2588
+ .dl-preview-gate > div { display: flex; align-items: center; gap: .45em; flex-wrap: wrap; }
2589
+ .dl-preview-code { border: 1px solid #c9c6bb; border-radius: 2em; padding: .5em 1.2em; background: white; }
2590
+ .dl-preview-gate button { border: 0; font: inherit; cursor: pointer; }
2591
+ .dl-preview-relock { margin: .4rem .7rem; }
@@ -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,7 +409,7 @@ 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 || []);
404
415
  if (!files.length)
@@ -407,29 +418,9 @@ export function DeliveryWorkspace({ delivery: fromServer, defaultHeroes = [], bu
407
418
  setFailure("Scegli fino a otto immagini JPEG, PNG o WebP.");
408
419
  return;
409
420
  }
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);
421
+ setCoverFiles(files);
417
422
  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
- }
423
+ input.value = "";
433
424
  };
434
425
  /* ---- azioni di servizio ------------------------------------------------------------ */
435
426
  const run = async (payload, done) => {
@@ -484,6 +475,9 @@ export function DeliveryWorkspace({ delivery: fromServer, defaultHeroes = [], bu
484
475
  const state = delivery ? transferState(delivery) : null;
485
476
  const expiry = draft.duration === "keep"
486
477
  ? delivery?.filesExpiresAt || null : expiryFrom(draft.duration);
478
+ const filesExpired = !!expiry && Date.parse(expiry) < Date.now();
479
+ const archived = delivery?.status === "archived";
480
+ const previewFileCount = filesExpired ? 0 : selection.length + packages.reduce((sum, pkg) => sum + (pkg.state === "ready" && (!archived || pkg.webEnabled) ? pkg.fileCount : 0), 0);
487
481
  const accessEdited = !!link && (draft.pin !== (link.pin || "") || draft.duration !== clean.duration);
488
482
  const sharingPaused = accessEdited || saving;
489
483
  const shareMessage = delivery && link ? messageFor(delivery, link) : "";
@@ -498,31 +492,31 @@ export function DeliveryWorkspace({ delivery: fromServer, defaultHeroes = [], bu
498
492
  setSaving(false);
499
493
  }
500
494
  }, 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: () => {
495
+ 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: "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
496
  setSelection([]);
503
497
  fileInputs.current?.replaceChildren();
504
498
  }, 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
499
  setConfirmPackage(null);
506
500
  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
508
- ? "Le opzioni dei file caricati sono bloccate. Per cambiarle, rimuovi e ricarica i file."
509
- : "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
- ? `Fino al ${formatDate(delivery.filesExpiresAt)}`
511
- : "Per sempre" }), _jsx("option", { value: "7", children: "7 giorni" }), _jsx("option", { value: "30", children: "30 giorni" }), _jsx("option", { value: "60", children: "60 giorni" }), _jsx("option", { value: "180", children: "6 mesi" }), _jsx("option", { value: "365", children: "1 anno" }), _jsx("option", { value: "forever", children: "Per sempre" })] }), _jsx("p", { className: "dl-note", children: expiry
512
- ? `Dopo il ${formatDate(expiry)} il link continua ad aprirsi, ma i file non si scaricano più.`
513
- : "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
- ? `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
516
- ? "Scelta non ancora salvata: premi Salva modifiche per mostrarla al cliente."
517
- : heroes.length
518
- ? "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 }) => {
521
- const chosen = heroes.some((item) => item.type === "package" && item.packageId === pkg.id && item.index === image.index);
522
- 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
- }) })) : ready ? (_jsx("p", { className: "dl-note dl-cover-empty", children: heroes.some((item) => item.type === "object")
524
- ? `${heroes.length} immagini caricate a mano.`
525
- : "Questo transfer non ha anteprime da cui scegliere: carica un'immagine, oppure resta quella predefinita." })) : null] }), !!delivery && (_jsxs("section", { className: "dl-danger", children: [_jsxs("div", { children: [_jsx("button", { className: "ak-btn ak-btn-quiet", disabled: busy, onClick: () => void duplicate(), children: "Usa come modello" }), delivery.status === "active" && (_jsx("button", { className: "ak-btn ak-btn-quiet", disabled: busy, onClick: () => void run({ action: "archive", id: delivery.id }, "Originali tolti: recuperabili per sette giorni"), children: "Libera spazio: togli gli originali" }))] }), confirmDelete ? (_jsxs("div", { className: "dl-confirm", children: [_jsxs("p", { children: ["Elimino ", _jsx("strong", { children: delivery.title }), photos.length ? ` (${countPhotos(packages)} file, ${formatBytes(delivery.storedBytes)})` : "", "? Il link smette subito di funzionare. La rimozione dei file e degli upload residui viene completata in background. Non si torna indietro."] }), _jsx("button", { className: "ak-btn", onClick: () => setConfirmDelete(false), children: "Annulla" }), _jsx("button", { className: "ak-btn dl-danger-btn", onClick: () => void remove(), children: "S\u00EC, elimina" })] })) : (_jsx("button", { className: "ak-btn ak-btn-quiet", onClick: () => setConfirmDelete(true), children: "Elimina il transfer" }))] }))] })] })] })] }));
501
+ }, 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("div", { className: "dl-compose-companion", children: [_jsx(DeliveryRecipientPreview, { title: draft.title.trim() || (selection.length ? deliverySelectionName(selection) : delivery?.title) || "Titolo del transfer", clientName: draft.clientName.trim(), message: draft.description, covers: previewCovers, locked: !!draft.pin, fileCount: previewFileCount, downloadLabel: archived ? draft.downloadWebLabel || "Scarica versione leggera" : draft.downloadOriginalsLabel || (previewFileCount === 1 ? "Scarica il file" : "Scarica tutti i file"), expiryLabel: expiry ? `${filesExpired ? "File scaduti il" : "Scaricabili fino al"} ${formatDate(expiry)}` : "", notice: filesExpired ? "I file di questa consegna sono scaduti." : archived ? "Gli originali sono stati archiviati." : "", finalLabel: draft.ctaEnabled && draft.ctaUrl ? draft.ctaLabel || "Lascia una recensione" : "" }), _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
502
+ ? "Le opzioni dei file caricati sono bloccate. Per cambiarle, rimuovi e ricarica i file."
503
+ : "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
504
+ ? `Fino al ${formatDate(delivery.filesExpiresAt)}`
505
+ : "Per sempre" }), _jsx("option", { value: "7", children: "7 giorni" }), _jsx("option", { value: "30", children: "30 giorni" }), _jsx("option", { value: "60", children: "60 giorni" }), _jsx("option", { value: "180", children: "6 mesi" }), _jsx("option", { value: "365", children: "1 anno" }), _jsx("option", { value: "forever", children: "Per sempre" })] }), _jsx("p", { className: "dl-note", children: expiry
506
+ ? `Dopo il ${formatDate(expiry)} il link continua ad aprirsi, ma i file non si scaricano più.`
507
+ : "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
508
+ ? `Ne hai scelte ${heroes.length}.`
509
+ : "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
510
+ ? "Scelta non ancora salvata: premi Salva modifiche per mostrarla al cliente."
511
+ : heroes.length
512
+ ? "Copertine salvate. Una sola immagine resta fissa; più immagini compongono la sequenza."
513
+ : "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)
514
+ 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: selectCovers })] })] }), 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 }) => {
515
+ const chosen = heroes.some((item) => item.type === "package" && item.packageId === pkg.id && item.index === image.index);
516
+ 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}`));
517
+ }) })) : ready ? (_jsx("p", { className: "dl-note dl-cover-empty", children: heroes.some((item) => item.type === "object")
518
+ ? `${heroes.length} immagini caricate a mano.`
519
+ : "Questo transfer non ha anteprime da cui scegliere: carica un'immagine, oppure resta quella predefinita." })) : null] }), !!delivery && (_jsxs("section", { className: "dl-danger", children: [_jsxs("div", { children: [_jsx("button", { className: "ak-btn ak-btn-quiet", disabled: busy, onClick: () => void duplicate(), children: "Usa come modello" }), delivery.status === "active" && (_jsx("button", { className: "ak-btn ak-btn-quiet", disabled: busy, onClick: () => void run({ action: "archive", id: delivery.id }, "Originali tolti: recuperabili per sette giorni"), children: "Libera spazio: togli gli originali" }))] }), confirmDelete ? (_jsxs("div", { className: "dl-confirm", children: [_jsxs("p", { children: ["Elimino ", _jsx("strong", { children: delivery.title }), photos.length ? ` (${countPhotos(packages)} file, ${formatBytes(delivery.storedBytes)})` : "", "? Il link smette subito di funzionare. La rimozione dei file e degli upload residui viene completata in background. Non si torna indietro."] }), _jsx("button", { className: "ak-btn", onClick: () => setConfirmDelete(false), children: "Annulla" }), _jsx("button", { className: "ak-btn dl-danger-btn", onClick: () => void remove(), children: "S\u00EC, elimina" })] })) : (_jsx("button", { className: "ak-btn ak-btn-quiet", onClick: () => setConfirmDelete(true), children: "Elimina il transfer" }))] }))] })] })] })] })] }));
526
520
  }
527
521
  /* ============================================================================================
528
522
  Impostazioni
@@ -0,0 +1,14 @@
1
+ interface Props {
2
+ title: string;
3
+ clientName: string;
4
+ message: string;
5
+ covers: (string | File)[];
6
+ locked: boolean;
7
+ fileCount: number;
8
+ downloadLabel: string;
9
+ expiryLabel: string;
10
+ notice: string;
11
+ finalLabel: string;
12
+ }
13
+ export declare function DeliveryRecipientPreview(props: Props): import("react").JSX.Element;
14
+ export {};
@@ -0,0 +1,49 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, 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 [phone, setPhone] = useState(() => window.matchMedia("(max-width: 760px)").matches);
33
+ const [page, setPage] = useState(0);
34
+ const [showUnlocked, setShowUnlocked] = useState(false);
35
+ const locked = props.locked && !showUnlocked;
36
+ useEffect(() => { setShowUnlocked(false); }, [props.locked]);
37
+ const covers = usePreviewCovers(props.covers);
38
+ useEffect(() => { setPage(0); }, [phone, props.covers]);
39
+ const groups = [];
40
+ for (let i = 0; i < covers.length; i++) {
41
+ const group = [covers[i]];
42
+ if (!phone && covers[i].portrait && covers[i + 1]?.portrait)
43
+ group.push(covers[++i]);
44
+ groups.push(group);
45
+ }
46
+ const current = Math.min(page, Math.max(0, groups.length - 1));
47
+ const group = locked ? [] : groups[current] ?? [];
48
+ return _jsxs("section", { className: "dl-recipient", "aria-label": "Anteprima destinatario", children: [_jsxs("header", { className: "dl-recipient-tools", children: [_jsx("h3", { children: "Anteprima destinatario" }), _jsxs("div", { className: "dl-preview-devices", role: "group", "aria-label": "Formato anteprima", children: [_jsx("button", { type: "button", "aria-pressed": !phone, onClick: () => setPhone(false), children: "Desktop" }), _jsx("button", { type: "button", "aria-pressed": phone, onClick: () => setPhone(true), children: "Mobile" })] })] }), _jsx("div", { className: "dl-preview-surround", children: _jsx("div", { className: "dl-preview-page" + (phone ? " is-phone" : "") + (group.length ? " with-covers" : ""), children: _jsxs("div", { className: "dl-preview-sheet", children: [_jsx("span", { className: "dl-preview-menu", "aria-hidden": "true", children: "menu" }), _jsxs("div", { className: "dl-preview-info", children: [_jsx("span", { className: "dl-preview-kicker", children: "Consegna file" }), _jsx("strong", { className: "dl-preview-title", children: props.clientName || props.title }), props.clientName && _jsx("span", { className: "dl-preview-work", children: props.title }), locked ? _jsxs("div", { className: "dl-preview-gate", children: [_jsx("span", { children: "Codice di accesso" }), _jsxs("div", { children: [_jsx("span", { className: "dl-preview-code", "aria-hidden": "true", children: "\u2022\u2022\u2022\u2022" }), _jsx("button", { type: "button", className: "dl-preview-button", "aria-label": "Simula lo sblocco nell\u2019anteprima", onClick: () => setShowUnlocked(true), children: "Entra" })] })] }) : _jsxs(_Fragment, { children: [props.message && _jsx("p", { className: "dl-preview-message", children: props.message }), props.notice && _jsx("p", { children: props.notice }), props.fileCount > 0 && _jsxs("div", { className: "dl-preview-download", children: [_jsxs("small", { children: [props.fileCount, " file \u00B7 ZIP"] }), _jsx("span", { className: "dl-preview-button", children: props.downloadLabel })] })] }), props.expiryLabel && _jsx("small", { className: "dl-preview-expiry", children: props.expiryLabel }), !locked && props.finalLabel && _jsx("span", { className: "dl-preview-final", children: props.finalLabel })] }), group.length > 0 && _jsx("div", { className: "dl-preview-stage", children: group.map((cover, i) => _jsx("img", { src: cover.src, alt: "" }, i)) })] }) }) }), props.locked && showUnlocked && _jsx("button", { className: "ak-btn dl-preview-relock", type: "button", onClick: () => setShowUnlocked(false), children: "Rivedi la richiesta del codice" }), !locked && groups.length > 1 && _jsxs("div", { className: "dl-preview-pager", 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" })] })] });
49
+ }
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.51",
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",