@marianmeres/stuic 3.184.0 → 3.186.0
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/components/Input/FieldSingleAsset.svelte +33 -9
- package/dist/components/Input/FieldSingleAsset.svelte.d.ts +8 -0
- package/dist/components/Input/README.md +1 -0
- package/dist/components/Input/field-single-asset-i18n-sk.js +5 -0
- package/dist/components/Input/field-single-asset-i18n.d.ts +5 -0
- package/dist/components/Input/field-single-asset-i18n.js +5 -0
- package/package.json +1 -1
|
@@ -177,6 +177,14 @@
|
|
|
177
177
|
placeholder?: THC;
|
|
178
178
|
/** Hide the "Preview" action (the `AssetsPreview` lightbox). */
|
|
179
179
|
noPreview?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Never show the asset's `name` to the user — the tile's filename line, the
|
|
182
|
+
* lightbox caption, the "… removed" / "… uploaded" announcements and toasts all
|
|
183
|
+
* fall back to name-less wording (`replace_file_short`, `removed_short`, ...).
|
|
184
|
+
* For stores that hand back a content-hash filename, which carries no meaning
|
|
185
|
+
* worth reading. The type / size line (`metaText`) is unaffected.
|
|
186
|
+
*/
|
|
187
|
+
noFilename?: boolean;
|
|
180
188
|
/** Hide the lightbox's Download button. */
|
|
181
189
|
noDownload?: boolean;
|
|
182
190
|
/** See `AssetsPreview.onDownload`: replaces the default download of `url.original`. */
|
|
@@ -288,6 +296,7 @@
|
|
|
288
296
|
placeholder,
|
|
289
297
|
noPreview = false,
|
|
290
298
|
noDownload = false,
|
|
299
|
+
noFilename = false,
|
|
291
300
|
onDownload,
|
|
292
301
|
onChange,
|
|
293
302
|
}: Props = $props();
|
|
@@ -356,9 +365,13 @@
|
|
|
356
365
|
let tileActionText = $derived(
|
|
357
366
|
canUpload
|
|
358
367
|
? shown
|
|
359
|
-
?
|
|
368
|
+
? noFilename
|
|
369
|
+
? t("replace_file_short")
|
|
370
|
+
: t("replace_file", { name: shown.name })
|
|
360
371
|
: t("pick_file")
|
|
361
|
-
:
|
|
372
|
+
: noFilename
|
|
373
|
+
? ""
|
|
374
|
+
: (shown?.name ?? "")
|
|
362
375
|
);
|
|
363
376
|
let metaText = $derived.by(() => {
|
|
364
377
|
if (!shown) return "";
|
|
@@ -540,7 +553,7 @@
|
|
|
540
553
|
assetsPreview?.close?.();
|
|
541
554
|
pending = { asset: optimistic, file, progress: 0, error: null };
|
|
542
555
|
const seq = ++uploadSeq;
|
|
543
|
-
announce(t("uploading", { name: file.name }));
|
|
556
|
+
announce(noFilename ? t("uploading_short") : t("uploading", { name: file.name }));
|
|
544
557
|
|
|
545
558
|
const onProgress = (p: number) => {
|
|
546
559
|
if (seq === uploadSeq && pending && !pending.error) {
|
|
@@ -564,14 +577,20 @@
|
|
|
564
577
|
}
|
|
565
578
|
pending = null;
|
|
566
579
|
commit(uploaded);
|
|
567
|
-
announce(
|
|
580
|
+
announce(
|
|
581
|
+
noFilename
|
|
582
|
+
? t("uploaded_short")
|
|
583
|
+
: t("uploaded", { name: uploaded.name ?? file.name })
|
|
584
|
+
);
|
|
568
585
|
})
|
|
569
586
|
.catch((e) => {
|
|
570
587
|
if (seq !== uploadSeq) return;
|
|
571
588
|
const error = `${e?.message ?? e}`;
|
|
572
589
|
clog.error(error);
|
|
573
590
|
if (pending) pending.error = error;
|
|
574
|
-
const msg =
|
|
591
|
+
const msg = noFilename
|
|
592
|
+
? t("upload_failed_error", { error })
|
|
593
|
+
: t("upload_failed_named", { name: file.name, error });
|
|
575
594
|
announce(msg);
|
|
576
595
|
// the consumer may own the report (a quota panel it already renders):
|
|
577
596
|
// `false` skips only the toast, the tile's Retry / Discard stay
|
|
@@ -609,7 +628,7 @@
|
|
|
609
628
|
}
|
|
610
629
|
assetsPreview?.close?.();
|
|
611
630
|
commit(null);
|
|
612
|
-
announce(t("removed", { name: current.name }));
|
|
631
|
+
announce(noFilename ? t("removed_short") : t("removed", { name: current.name }));
|
|
613
632
|
if (undoTtl > 0) {
|
|
614
633
|
removed = current;
|
|
615
634
|
undoTimer = setTimeout(() => clear_removed(), undoTtl);
|
|
@@ -622,7 +641,7 @@
|
|
|
622
641
|
if (!back) return;
|
|
623
642
|
clear_removed();
|
|
624
643
|
commit(back);
|
|
625
|
-
announce(t("restored", { name: back.name }));
|
|
644
|
+
announce(noFilename ? t("restored_short") : t("restored", { name: back.name }));
|
|
626
645
|
focus_tile();
|
|
627
646
|
}
|
|
628
647
|
|
|
@@ -823,13 +842,17 @@
|
|
|
823
842
|
{#if isLoading}
|
|
824
843
|
<Skeleton variant="text" lines={2} width="60%" />
|
|
825
844
|
{:else if shown}
|
|
826
|
-
|
|
845
|
+
{#if !noFilename}
|
|
846
|
+
<div class="truncate font-medium" title={shown.name}>{shown.name}</div>
|
|
847
|
+
{/if}
|
|
827
848
|
{#if metaText}
|
|
828
849
|
<div class="text-xs stuic-field-single-asset-meta">{metaText}</div>
|
|
829
850
|
{/if}
|
|
830
851
|
{:else if undoOffer}
|
|
831
852
|
<div class="stuic-field-single-asset-meta">
|
|
832
|
-
<span>
|
|
853
|
+
<span>
|
|
854
|
+
{noFilename ? t("removed_short") : t("removed", { name: undoOffer.name })}
|
|
855
|
+
</span>
|
|
833
856
|
<button type="button" class="stuic-field-single-asset-undo" onclick={undo}>
|
|
834
857
|
{@html iconUndo({ size: 14 })}
|
|
835
858
|
<span>{t("undo")}</span>
|
|
@@ -925,6 +948,7 @@
|
|
|
925
948
|
noPrevNext
|
|
926
949
|
noDots
|
|
927
950
|
noCurrentOfTotal
|
|
951
|
+
noName={noFilename}
|
|
928
952
|
{noDownload}
|
|
929
953
|
onDelete={(_, _index, controls) => {
|
|
930
954
|
controls.close();
|
|
@@ -133,6 +133,14 @@ export interface Props extends InputWrapClassProps, Record<string, any> {
|
|
|
133
133
|
placeholder?: THC;
|
|
134
134
|
/** Hide the "Preview" action (the `AssetsPreview` lightbox). */
|
|
135
135
|
noPreview?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Never show the asset's `name` to the user — the tile's filename line, the
|
|
138
|
+
* lightbox caption, the "… removed" / "… uploaded" announcements and toasts all
|
|
139
|
+
* fall back to name-less wording (`replace_file_short`, `removed_short`, ...).
|
|
140
|
+
* For stores that hand back a content-hash filename, which carries no meaning
|
|
141
|
+
* worth reading. The type / size line (`metaText`) is unaffected.
|
|
142
|
+
*/
|
|
143
|
+
noFilename?: boolean;
|
|
136
144
|
/** Hide the lightbox's Download button. */
|
|
137
145
|
noDownload?: boolean;
|
|
138
146
|
/** See `AssetsPreview.onDownload`: replaces the default download of `url.original`. */
|
|
@@ -937,6 +937,7 @@ a dialog and resolves with the cropped file.
|
|
|
937
937
|
| `size` | `"sm" \| "md" \| "lg" \| string` | `"md"` | Tile height: preset or CSS length |
|
|
938
938
|
| `placeholder` | `THC` | - | Empty-tile content (e.g. an `Avatar` with initials) |
|
|
939
939
|
| `noPreview`, `noDownload` | `boolean` | `false` | Hide the Preview action / the lightbox's Download |
|
|
940
|
+
| `noFilename` | `boolean` | `false` | Never show the asset's name (hash filenames); name-less wording instead |
|
|
940
941
|
| `onDownload` | `(asset) => void \| Promise<void>` | - | Replaces the lightbox's default download (auth-gated bytes) |
|
|
941
942
|
| `onChange` | `(asset \| null) => void` | - | After every user-driven change of `value` |
|
|
942
943
|
| `parseValue`, `serializeValue` | see Value | JSON | Custom `value` shape |
|
|
@@ -21,12 +21,15 @@ export const FIELD_SINGLE_ASSET_MESSAGES_SK = {
|
|
|
21
21
|
field_req_att: "Toto pole vyžaduje pozornosť. Skontrolujte ho a skúste to znova.",
|
|
22
22
|
pick_file: "Vybrať súbor",
|
|
23
23
|
replace_file: "Nahradiť {{name}}",
|
|
24
|
+
replace_file_short: "Nahradiť súbor",
|
|
24
25
|
empty_hint: "Presuňte sem súbor alebo kliknite a vyberte ho",
|
|
25
26
|
remove: "Odstrániť",
|
|
26
27
|
removing_short: "Odstraňuje sa…",
|
|
27
28
|
removed: "Súbor {{name}} bol odstránený",
|
|
29
|
+
removed_short: "Súbor bol odstránený",
|
|
28
30
|
undo: "Vrátiť späť",
|
|
29
31
|
restored: "Súbor {{name}} bol obnovený",
|
|
32
|
+
restored_short: "Súbor bol obnovený",
|
|
30
33
|
preview: "Náhľad",
|
|
31
34
|
retry: "Skúsiť nahrať znova",
|
|
32
35
|
discard: "Zahodiť",
|
|
@@ -35,8 +38,10 @@ export const FIELD_SINGLE_ASSET_MESSAGES_SK = {
|
|
|
35
38
|
uploading_short: "Nahráva sa…",
|
|
36
39
|
uploading_progress: "Nahráva sa… {{percent}} %",
|
|
37
40
|
uploaded: "Súbor {{name}} bol nahraný",
|
|
41
|
+
uploaded_short: "Súbor bol nahraný",
|
|
38
42
|
upload_failed: "Nahrávanie zlyhalo",
|
|
39
43
|
upload_failed_named: "Nahrávanie súboru {{name}} zlyhalo: {{error}}",
|
|
44
|
+
upload_failed_error: "Nahrávanie zlyhalo: {{error}}",
|
|
40
45
|
invalid_type: "Tento typ súboru nie je podporovaný. Povolené: „{{accept}}“.",
|
|
41
46
|
too_large: "Súbor je príliš veľký ({{size}}). Maximum je {{max}}.",
|
|
42
47
|
single_only: "Sem je možné umiestniť iba jeden súbor. Presuňte alebo prilepte jeden súbor.",
|
|
@@ -10,12 +10,15 @@ export declare const FIELD_SINGLE_ASSET_MESSAGES_EN: {
|
|
|
10
10
|
field_req_att: string;
|
|
11
11
|
pick_file: string;
|
|
12
12
|
replace_file: string;
|
|
13
|
+
replace_file_short: string;
|
|
13
14
|
empty_hint: string;
|
|
14
15
|
remove: string;
|
|
15
16
|
removing_short: string;
|
|
16
17
|
removed: string;
|
|
18
|
+
removed_short: string;
|
|
17
19
|
undo: string;
|
|
18
20
|
restored: string;
|
|
21
|
+
restored_short: string;
|
|
19
22
|
preview: string;
|
|
20
23
|
retry: string;
|
|
21
24
|
discard: string;
|
|
@@ -24,8 +27,10 @@ export declare const FIELD_SINGLE_ASSET_MESSAGES_EN: {
|
|
|
24
27
|
uploading_short: string;
|
|
25
28
|
uploading_progress: string;
|
|
26
29
|
uploaded: string;
|
|
30
|
+
uploaded_short: string;
|
|
27
31
|
upload_failed: string;
|
|
28
32
|
upload_failed_named: string;
|
|
33
|
+
upload_failed_error: string;
|
|
29
34
|
invalid_type: string;
|
|
30
35
|
too_large: string;
|
|
31
36
|
single_only: string;
|
|
@@ -11,12 +11,15 @@ export const FIELD_SINGLE_ASSET_MESSAGES_EN = {
|
|
|
11
11
|
field_req_att: "This field requires attention. Please review and try again.",
|
|
12
12
|
pick_file: "Choose a file",
|
|
13
13
|
replace_file: "Replace {{name}}",
|
|
14
|
+
replace_file_short: "Replace file",
|
|
14
15
|
empty_hint: "Drop a file here or click to browse",
|
|
15
16
|
remove: "Remove",
|
|
16
17
|
removing_short: "Removing…",
|
|
17
18
|
removed: "{{name}} removed",
|
|
19
|
+
removed_short: "File removed",
|
|
18
20
|
undo: "Undo",
|
|
19
21
|
restored: "{{name}} restored",
|
|
22
|
+
restored_short: "File restored",
|
|
20
23
|
preview: "Preview",
|
|
21
24
|
retry: "Retry upload",
|
|
22
25
|
discard: "Discard",
|
|
@@ -25,8 +28,10 @@ export const FIELD_SINGLE_ASSET_MESSAGES_EN = {
|
|
|
25
28
|
uploading_short: "Uploading…",
|
|
26
29
|
uploading_progress: "Uploading… {{percent}}%",
|
|
27
30
|
uploaded: "{{name}} uploaded",
|
|
31
|
+
uploaded_short: "File uploaded",
|
|
28
32
|
upload_failed: "Upload failed",
|
|
29
33
|
upload_failed_named: "Upload of {{name}} failed: {{error}}",
|
|
34
|
+
upload_failed_error: "Upload failed: {{error}}",
|
|
30
35
|
invalid_type: 'This file type is not supported. Allowed: "{{accept}}".',
|
|
31
36
|
too_large: "The file is too large ({{size}}). The maximum is {{max}}.",
|
|
32
37
|
single_only: "Only one file can be placed here. Drop or paste a single file.",
|