@star-ng/ui 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +148 -2
- package/fesm2022/star-ng-ui-accordion.mjs +376 -0
- package/fesm2022/star-ng-ui-accordion.mjs.map +1 -0
- package/fesm2022/star-ng-ui-autocomplete.mjs +782 -0
- package/fesm2022/star-ng-ui-autocomplete.mjs.map +1 -0
- package/fesm2022/star-ng-ui-avatar.mjs +154 -0
- package/fesm2022/star-ng-ui-avatar.mjs.map +1 -0
- package/fesm2022/star-ng-ui-badge.mjs +153 -0
- package/fesm2022/star-ng-ui-badge.mjs.map +1 -0
- package/fesm2022/star-ng-ui-breadcrumb.mjs +199 -0
- package/fesm2022/star-ng-ui-breadcrumb.mjs.map +1 -0
- package/fesm2022/star-ng-ui-button.mjs +282 -0
- package/fesm2022/star-ng-ui-button.mjs.map +1 -0
- package/fesm2022/star-ng-ui-card.mjs +112 -0
- package/fesm2022/star-ng-ui-card.mjs.map +1 -0
- package/fesm2022/star-ng-ui-chart.mjs +1904 -0
- package/fesm2022/star-ng-ui-chart.mjs.map +1 -0
- package/fesm2022/star-ng-ui-checkbox.mjs +345 -0
- package/fesm2022/star-ng-ui-checkbox.mjs.map +1 -0
- package/fesm2022/star-ng-ui-core.mjs +392 -0
- package/fesm2022/star-ng-ui-core.mjs.map +1 -0
- package/fesm2022/star-ng-ui-data-display.mjs +1556 -0
- package/fesm2022/star-ng-ui-data-display.mjs.map +1 -0
- package/fesm2022/star-ng-ui-date-picker.mjs +2786 -0
- package/fesm2022/star-ng-ui-date-picker.mjs.map +1 -0
- package/fesm2022/star-ng-ui-dialog.mjs +948 -0
- package/fesm2022/star-ng-ui-dialog.mjs.map +1 -0
- package/fesm2022/star-ng-ui-drawer.mjs +158 -0
- package/fesm2022/star-ng-ui-drawer.mjs.map +1 -0
- package/fesm2022/star-ng-ui-editor.mjs +416 -0
- package/fesm2022/star-ng-ui-editor.mjs.map +1 -0
- package/fesm2022/star-ng-ui-field.mjs +378 -0
- package/fesm2022/star-ng-ui-field.mjs.map +1 -0
- package/fesm2022/star-ng-ui-file-upload.mjs +762 -0
- package/fesm2022/star-ng-ui-file-upload.mjs.map +1 -0
- package/fesm2022/star-ng-ui-i18n-de.mjs +179 -0
- package/fesm2022/star-ng-ui-i18n-de.mjs.map +1 -0
- package/fesm2022/star-ng-ui-i18n-es.mjs +179 -0
- package/fesm2022/star-ng-ui-i18n-es.mjs.map +1 -0
- package/fesm2022/star-ng-ui-input-group.mjs +188 -0
- package/fesm2022/star-ng-ui-input-group.mjs.map +1 -0
- package/fesm2022/star-ng-ui-input-mask.mjs +434 -0
- package/fesm2022/star-ng-ui-input-mask.mjs.map +1 -0
- package/fesm2022/star-ng-ui-input-number.mjs +691 -0
- package/fesm2022/star-ng-ui-input-number.mjs.map +1 -0
- package/fesm2022/star-ng-ui-input-otp.mjs +343 -0
- package/fesm2022/star-ng-ui-input-otp.mjs.map +1 -0
- package/fesm2022/star-ng-ui-input-tags.mjs +616 -0
- package/fesm2022/star-ng-ui-input-tags.mjs.map +1 -0
- package/fesm2022/star-ng-ui-knob.mjs +514 -0
- package/fesm2022/star-ng-ui-knob.mjs.map +1 -0
- package/fesm2022/star-ng-ui-layout.mjs +608 -0
- package/fesm2022/star-ng-ui-layout.mjs.map +1 -0
- package/fesm2022/star-ng-ui-listbox.mjs +978 -0
- package/fesm2022/star-ng-ui-listbox.mjs.map +1 -0
- package/fesm2022/star-ng-ui-media.mjs +833 -0
- package/fesm2022/star-ng-ui-media.mjs.map +1 -0
- package/fesm2022/star-ng-ui-menu.mjs +1840 -0
- package/fesm2022/star-ng-ui-menu.mjs.map +1 -0
- package/fesm2022/star-ng-ui-message.mjs +191 -0
- package/fesm2022/star-ng-ui-message.mjs.map +1 -0
- package/fesm2022/star-ng-ui-paginator.mjs +387 -0
- package/fesm2022/star-ng-ui-paginator.mjs.map +1 -0
- package/fesm2022/star-ng-ui-panel.mjs +324 -0
- package/fesm2022/star-ng-ui-panel.mjs.map +1 -0
- package/fesm2022/star-ng-ui-password.mjs +517 -0
- package/fesm2022/star-ng-ui-password.mjs.map +1 -0
- package/fesm2022/star-ng-ui-popover.mjs +241 -0
- package/fesm2022/star-ng-ui-popover.mjs.map +1 -0
- package/fesm2022/star-ng-ui-progress-bar.mjs +183 -0
- package/fesm2022/star-ng-ui-progress-bar.mjs.map +1 -0
- package/fesm2022/star-ng-ui-radio.mjs +411 -0
- package/fesm2022/star-ng-ui-radio.mjs.map +1 -0
- package/fesm2022/star-ng-ui-rating.mjs +211 -0
- package/fesm2022/star-ng-ui-rating.mjs.map +1 -0
- package/fesm2022/star-ng-ui-select-button.mjs +613 -0
- package/fesm2022/star-ng-ui-select-button.mjs.map +1 -0
- package/fesm2022/star-ng-ui-select.mjs +2523 -0
- package/fesm2022/star-ng-ui-select.mjs.map +1 -0
- package/fesm2022/star-ng-ui-skeleton.mjs +160 -0
- package/fesm2022/star-ng-ui-skeleton.mjs.map +1 -0
- package/fesm2022/star-ng-ui-slider.mjs +552 -0
- package/fesm2022/star-ng-ui-slider.mjs.map +1 -0
- package/fesm2022/star-ng-ui-spinner.mjs +148 -0
- package/fesm2022/star-ng-ui-spinner.mjs.map +1 -0
- package/fesm2022/star-ng-ui-stepper.mjs +360 -0
- package/fesm2022/star-ng-ui-stepper.mjs.map +1 -0
- package/fesm2022/star-ng-ui-table.mjs +3477 -0
- package/fesm2022/star-ng-ui-table.mjs.map +1 -0
- package/fesm2022/star-ng-ui-tabs.mjs +464 -0
- package/fesm2022/star-ng-ui-tabs.mjs.map +1 -0
- package/fesm2022/star-ng-ui-tag.mjs +129 -0
- package/fesm2022/star-ng-ui-tag.mjs.map +1 -0
- package/fesm2022/star-ng-ui-theme-switch.mjs +105 -0
- package/fesm2022/star-ng-ui-theme-switch.mjs.map +1 -0
- package/fesm2022/star-ng-ui-theme.mjs +98 -0
- package/fesm2022/star-ng-ui-theme.mjs.map +1 -0
- package/fesm2022/star-ng-ui-toast.mjs +298 -0
- package/fesm2022/star-ng-ui-toast.mjs.map +1 -0
- package/fesm2022/star-ng-ui-toggle-switch.mjs +316 -0
- package/fesm2022/star-ng-ui-toggle-switch.mjs.map +1 -0
- package/fesm2022/star-ng-ui-tooltip.mjs +297 -0
- package/fesm2022/star-ng-ui-tooltip.mjs.map +1 -0
- package/fesm2022/star-ng-ui-transloco.mjs +40 -0
- package/fesm2022/star-ng-ui-transloco.mjs.map +1 -0
- package/fesm2022/star-ng-ui-tree.mjs +1446 -0
- package/fesm2022/star-ng-ui-tree.mjs.map +1 -0
- package/fesm2022/star-ng-ui-utility.mjs +2134 -0
- package/fesm2022/star-ng-ui-utility.mjs.map +1 -0
- package/fesm2022/star-ng-ui.mjs +51 -0
- package/package.json +281 -3
- package/styles/_base.scss +70 -0
- package/styles/_shared.scss +2 -0
- package/styles/_tokens.scss +190 -0
- package/styles/controls/_accordion.scss +75 -0
- package/styles/controls/_autocomplete.scss +44 -0
- package/styles/controls/_avatar.scss +39 -0
- package/styles/controls/_breadcrumb.scss +45 -0
- package/styles/controls/_button.scss +137 -0
- package/styles/controls/_card.scss +38 -0
- package/styles/controls/_chart.scss +214 -0
- package/styles/controls/_chip.scss +51 -0
- package/styles/controls/_choice.scss +153 -0
- package/styles/controls/_data-display.scss +118 -0
- package/styles/controls/_date-picker.scss +300 -0
- package/styles/controls/_dialog.scss +123 -0
- package/styles/controls/_drawer.scss +118 -0
- package/styles/controls/_editor.scss +74 -0
- package/styles/controls/_field.scss +92 -0
- package/styles/controls/_file-upload.scss +136 -0
- package/styles/controls/_input-group.scss +104 -0
- package/styles/controls/_input-mask.scss +46 -0
- package/styles/controls/_input-number.scss +125 -0
- package/styles/controls/_knob.scss +76 -0
- package/styles/controls/_layout.scss +182 -0
- package/styles/controls/_listbox.scss +38 -0
- package/styles/controls/_media.scss +222 -0
- package/styles/controls/_menu.scss +254 -0
- package/styles/controls/_message.scss +48 -0
- package/styles/controls/_org-chart.scss +128 -0
- package/styles/controls/_paginator.scss +59 -0
- package/styles/controls/_panel.scss +83 -0
- package/styles/controls/_popover.scss +40 -0
- package/styles/controls/_progress-bar.scss +74 -0
- package/styles/controls/_select-button.scss +61 -0
- package/styles/controls/_select.scss +216 -0
- package/styles/controls/_skeleton.scss +43 -0
- package/styles/controls/_slider.scss +163 -0
- package/styles/controls/_spinner.scss +34 -0
- package/styles/controls/_stepper.scss +109 -0
- package/styles/controls/_table.scss +523 -0
- package/styles/controls/_tabs.scss +93 -0
- package/styles/controls/_tag.scss +84 -0
- package/styles/controls/_toast.scss +141 -0
- package/styles/controls/_tooltip.scss +14 -0
- package/styles/controls/_tree.scss +113 -0
- package/styles/controls/_utility.scss +654 -0
- package/styles/star-ng.css +5803 -0
- package/styles/star-ng.min.css +1 -0
- package/styles/star-ng.scss +50 -0
- package/theme/star-theme-first-paint.js +1 -0
- package/types/star-ng-ui-accordion.d.ts +82 -0
- package/types/star-ng-ui-autocomplete.d.ts +171 -0
- package/types/star-ng-ui-avatar.d.ts +43 -0
- package/types/star-ng-ui-badge.d.ts +46 -0
- package/types/star-ng-ui-breadcrumb.d.ts +39 -0
- package/types/star-ng-ui-button.d.ts +79 -0
- package/types/star-ng-ui-card.d.ts +29 -0
- package/types/star-ng-ui-chart.d.ts +337 -0
- package/types/star-ng-ui-checkbox.d.ts +92 -0
- package/types/star-ng-ui-core.d.ts +310 -0
- package/types/star-ng-ui-data-display.d.ts +339 -0
- package/types/star-ng-ui-date-picker.d.ts +701 -0
- package/types/star-ng-ui-dialog.d.ts +254 -0
- package/types/star-ng-ui-drawer.d.ts +29 -0
- package/types/star-ng-ui-editor.d.ts +96 -0
- package/types/star-ng-ui-field.d.ts +146 -0
- package/types/star-ng-ui-file-upload.d.ts +192 -0
- package/types/star-ng-ui-i18n-de.d.ts +7 -0
- package/types/star-ng-ui-i18n-es.d.ts +7 -0
- package/types/star-ng-ui-input-group.d.ts +58 -0
- package/types/star-ng-ui-input-mask.d.ts +126 -0
- package/types/star-ng-ui-input-number.d.ts +193 -0
- package/types/star-ng-ui-input-otp.d.ts +86 -0
- package/types/star-ng-ui-input-tags.d.ts +159 -0
- package/types/star-ng-ui-knob.d.ts +121 -0
- package/types/star-ng-ui-layout.d.ts +154 -0
- package/types/star-ng-ui-listbox.d.ts +197 -0
- package/types/star-ng-ui-media.d.ts +161 -0
- package/types/star-ng-ui-menu.d.ts +332 -0
- package/types/star-ng-ui-message.d.ts +52 -0
- package/types/star-ng-ui-paginator.d.ts +85 -0
- package/types/star-ng-ui-panel.d.ts +65 -0
- package/types/star-ng-ui-password.d.ts +129 -0
- package/types/star-ng-ui-popover.d.ts +57 -0
- package/types/star-ng-ui-progress-bar.d.ts +49 -0
- package/types/star-ng-ui-radio.d.ts +116 -0
- package/types/star-ng-ui-rating.d.ts +52 -0
- package/types/star-ng-ui-select-button.d.ts +169 -0
- package/types/star-ng-ui-select.d.ts +540 -0
- package/types/star-ng-ui-skeleton.d.ts +47 -0
- package/types/star-ng-ui-slider.d.ts +145 -0
- package/types/star-ng-ui-spinner.d.ts +29 -0
- package/types/star-ng-ui-stepper.d.ts +89 -0
- package/types/star-ng-ui-table.d.ts +829 -0
- package/types/star-ng-ui-tabs.d.ts +109 -0
- package/types/star-ng-ui-tag.d.ts +35 -0
- package/types/star-ng-ui-theme-switch.d.ts +36 -0
- package/types/star-ng-ui-theme.d.ts +95 -0
- package/types/star-ng-ui-toast.d.ts +84 -0
- package/types/star-ng-ui-toggle-switch.d.ts +81 -0
- package/types/star-ng-ui-tooltip.d.ts +66 -0
- package/types/star-ng-ui-transloco.d.ts +14 -0
- package/types/star-ng-ui-tree.d.ts +310 -0
- package/types/star-ng-ui-utility.d.ts +533 -0
- package/types/star-ng-ui.d.ts +51 -0
|
@@ -0,0 +1,762 @@
|
|
|
1
|
+
import { _IdGenerator } from "@angular/cdk/a11y";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, booleanAttribute, computed, inject, input, model, output, signal, viewChild } from "@angular/core";
|
|
4
|
+
import { STAR_UI_TEXT } from "@star-ng/ui/core";
|
|
5
|
+
import { HttpEventType } from "@angular/common/http";
|
|
6
|
+
import { catchError, filter, map, of } from "rxjs";
|
|
7
|
+
function formatFileSize(bytes, locale) {
|
|
8
|
+
const units = [
|
|
9
|
+
"byte",
|
|
10
|
+
"kilobyte",
|
|
11
|
+
"megabyte",
|
|
12
|
+
"gigabyte"
|
|
13
|
+
];
|
|
14
|
+
let value = bytes;
|
|
15
|
+
let unit = 0;
|
|
16
|
+
while (value >= 1024 && unit < units.length - 1) {
|
|
17
|
+
value /= 1024;
|
|
18
|
+
unit++;
|
|
19
|
+
}
|
|
20
|
+
return new Intl.NumberFormat(locale, {
|
|
21
|
+
style: "unit",
|
|
22
|
+
unit: units[unit],
|
|
23
|
+
unitDisplay: "short",
|
|
24
|
+
maximumFractionDigits: unit === 0 ? 0 : 1
|
|
25
|
+
}).format(value);
|
|
26
|
+
}
|
|
27
|
+
function fileMatchesAccept(file, accept) {
|
|
28
|
+
if (!accept.trim()) return true;
|
|
29
|
+
const name = file.name.toLowerCase();
|
|
30
|
+
const type = file.type.toLowerCase();
|
|
31
|
+
return accept.split(",").map((rule) => rule.trim().toLowerCase()).some((rule) => rule.startsWith(".") ? name.endsWith(rule) : rule.endsWith("/*") ? type.startsWith(rule.slice(0, -1)) : type === rule);
|
|
32
|
+
}
|
|
33
|
+
var StarFileUpload = class StarFileUpload {
|
|
34
|
+
text = inject(STAR_UI_TEXT);
|
|
35
|
+
ids = inject(_IdGenerator);
|
|
36
|
+
constructor() {
|
|
37
|
+
inject(DestroyRef).onDestroy(() => {
|
|
38
|
+
for (const url of this.thumbnailUrls.values()) URL.revokeObjectURL(url);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
value = model([], ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
|
|
42
|
+
accept = input("", ...ngDevMode ? [{ debugName: "accept" }] : /* istanbul ignore next */ []);
|
|
43
|
+
multiple = input(false, {
|
|
44
|
+
...ngDevMode ? { debugName: "multiple" } : /* istanbul ignore next */ {},
|
|
45
|
+
transform: booleanAttribute
|
|
46
|
+
});
|
|
47
|
+
maxFileSize = input(0, ...ngDevMode ? [{ debugName: "maxFileSize" }] : /* istanbul ignore next */ []);
|
|
48
|
+
fileLimit = input(0, ...ngDevMode ? [{ debugName: "fileLimit" }] : /* istanbul ignore next */ []);
|
|
49
|
+
locale = input(void 0, ...ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []);
|
|
50
|
+
fileStatus = input(null, ...ngDevMode ? [{ debugName: "fileStatus" }] : /* istanbul ignore next */ []);
|
|
51
|
+
reorderable = input(false, {
|
|
52
|
+
...ngDevMode ? { debugName: "reorderable" } : /* istanbul ignore next */ {},
|
|
53
|
+
transform: booleanAttribute
|
|
54
|
+
});
|
|
55
|
+
thumbnails = input(false, {
|
|
56
|
+
...ngDevMode ? { debugName: "thumbnails" } : /* istanbul ignore next */ {},
|
|
57
|
+
transform: booleanAttribute
|
|
58
|
+
});
|
|
59
|
+
disabled = input(false, {
|
|
60
|
+
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
61
|
+
transform: booleanAttribute
|
|
62
|
+
});
|
|
63
|
+
readonly = input(false, {
|
|
64
|
+
...ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {},
|
|
65
|
+
transform: booleanAttribute
|
|
66
|
+
});
|
|
67
|
+
invalid = input(false, {
|
|
68
|
+
...ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {},
|
|
69
|
+
transform: booleanAttribute
|
|
70
|
+
});
|
|
71
|
+
touched = input(false, {
|
|
72
|
+
...ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {},
|
|
73
|
+
transform: booleanAttribute
|
|
74
|
+
});
|
|
75
|
+
touch = output();
|
|
76
|
+
selected = output();
|
|
77
|
+
rejectedChange = output();
|
|
78
|
+
inputId = this.ids.getId("star-upload-");
|
|
79
|
+
hintId = this.ids.getId("star-upload-hint-");
|
|
80
|
+
dragging = signal(false, ...ngDevMode ? [{ debugName: "dragging" }] : /* istanbul ignore next */ []);
|
|
81
|
+
rejected = signal([], ...ngDevMode ? [{ debugName: "rejected" }] : /* istanbul ignore next */ []);
|
|
82
|
+
dropIndex = signal(null, ...ngDevMode ? [{ debugName: "dropIndex" }] : /* istanbul ignore next */ []);
|
|
83
|
+
dragIndex = null;
|
|
84
|
+
canReorder = computed(() => this.reorderable() && !this.disabled() && !this.readonly() && this.value().length > 1, ...ngDevMode ? [{ debugName: "canReorder" }] : /* istanbul ignore next */ []);
|
|
85
|
+
input = viewChild.required("input", ...ngDevMode ? [{ debugName: "input" }] : /* istanbul ignore next */ []);
|
|
86
|
+
hint = computed(() => {
|
|
87
|
+
const parts = [];
|
|
88
|
+
if (this.accept()) parts.push(this.accept().split(",").join(", "));
|
|
89
|
+
if (this.maxFileSize()) parts.push(this.text.fileMaxSize(formatFileSize(this.maxFileSize(), this.locale())));
|
|
90
|
+
if (this.fileLimit()) parts.push(this.text.fileUpTo(this.fileLimit()));
|
|
91
|
+
return parts.join(" · ");
|
|
92
|
+
}, ...ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []);
|
|
93
|
+
statusOf(file) {
|
|
94
|
+
return this.fileStatus()?.(file) ?? null;
|
|
95
|
+
}
|
|
96
|
+
percent(status) {
|
|
97
|
+
return Math.round(Math.min(100, Math.max(0, status?.progress ?? 0)));
|
|
98
|
+
}
|
|
99
|
+
move(from, to) {
|
|
100
|
+
const files = [...this.value()];
|
|
101
|
+
if (from === to || from < 0 || to < 0 || from >= files.length || to >= files.length) return;
|
|
102
|
+
files.splice(to, 0, ...files.splice(from, 1));
|
|
103
|
+
this.value.set(files);
|
|
104
|
+
}
|
|
105
|
+
onFileDragStart(index, event) {
|
|
106
|
+
if (!this.canReorder()) return;
|
|
107
|
+
this.dragIndex = index;
|
|
108
|
+
event.dataTransfer?.setData("text/plain", String(index));
|
|
109
|
+
if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
|
|
110
|
+
}
|
|
111
|
+
onFileDragOver(index, event) {
|
|
112
|
+
if (this.dragIndex === null || this.dragIndex === index) return;
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
this.dropIndex.set(index);
|
|
115
|
+
}
|
|
116
|
+
onFileDrop(index, event) {
|
|
117
|
+
if (this.dragIndex === null) return;
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
event.stopPropagation();
|
|
120
|
+
this.move(this.dragIndex, index);
|
|
121
|
+
this.endFileDrag();
|
|
122
|
+
}
|
|
123
|
+
endFileDrag() {
|
|
124
|
+
this.dragIndex = null;
|
|
125
|
+
this.dropIndex.set(null);
|
|
126
|
+
}
|
|
127
|
+
size(file) {
|
|
128
|
+
return formatFileSize(file.size, this.locale());
|
|
129
|
+
}
|
|
130
|
+
rejectionText(item) {
|
|
131
|
+
switch (item.reason) {
|
|
132
|
+
case "type": return this.text.fileTypeNotAllowed(item.file.name);
|
|
133
|
+
case "size": return this.text.fileTooLarge(item.file.name, formatFileSize(this.maxFileSize(), this.locale()));
|
|
134
|
+
default: return this.text.fileLimitReached(this.fileLimit());
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
onDrag(event, over) {
|
|
138
|
+
if (this.disabled() || this.readonly()) return;
|
|
139
|
+
event.preventDefault();
|
|
140
|
+
this.dragging.set(over);
|
|
141
|
+
}
|
|
142
|
+
onDrop(event) {
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
this.dragging.set(false);
|
|
145
|
+
if (this.disabled() || this.readonly() || this.dragIndex !== null) return;
|
|
146
|
+
this.add([...event.dataTransfer?.files ?? []]);
|
|
147
|
+
}
|
|
148
|
+
onPicked(input) {
|
|
149
|
+
this.add([...input.files ?? []]);
|
|
150
|
+
input.value = "";
|
|
151
|
+
}
|
|
152
|
+
add(files) {
|
|
153
|
+
const accepted = [];
|
|
154
|
+
const rejected = [];
|
|
155
|
+
const current = this.multiple() ? this.value() : [];
|
|
156
|
+
const limit = this.multiple() ? this.fileLimit() : 1;
|
|
157
|
+
for (const file of this.multiple() ? files : files.slice(0, 1)) if (!fileMatchesAccept(file, this.accept())) rejected.push({
|
|
158
|
+
file,
|
|
159
|
+
reason: "type"
|
|
160
|
+
});
|
|
161
|
+
else if (this.maxFileSize() && file.size > this.maxFileSize()) rejected.push({
|
|
162
|
+
file,
|
|
163
|
+
reason: "size"
|
|
164
|
+
});
|
|
165
|
+
else if (limit && current.length + accepted.length >= limit) rejected.push({
|
|
166
|
+
file,
|
|
167
|
+
reason: "limit"
|
|
168
|
+
});
|
|
169
|
+
else accepted.push(file);
|
|
170
|
+
this.rejected.set(rejected);
|
|
171
|
+
if (rejected.length) this.rejectedChange.emit(rejected);
|
|
172
|
+
if (accepted.length) {
|
|
173
|
+
this.value.set([...current, ...accepted]);
|
|
174
|
+
this.selected.emit(accepted);
|
|
175
|
+
}
|
|
176
|
+
this.touch.emit();
|
|
177
|
+
}
|
|
178
|
+
remove(file) {
|
|
179
|
+
this.value.update((files) => files.filter((f) => f !== file));
|
|
180
|
+
this.rejected.set([]);
|
|
181
|
+
this.releaseThumbnail(file);
|
|
182
|
+
}
|
|
183
|
+
thumbnailUrls = /* @__PURE__ */ new Map();
|
|
184
|
+
thumbnailOf(file) {
|
|
185
|
+
if (!this.thumbnails() || !file.type.startsWith("image/")) return null;
|
|
186
|
+
let url = this.thumbnailUrls.get(file);
|
|
187
|
+
if (!url && typeof URL.createObjectURL === "function") {
|
|
188
|
+
url = URL.createObjectURL(file);
|
|
189
|
+
this.thumbnailUrls.set(file, url);
|
|
190
|
+
}
|
|
191
|
+
return url ?? null;
|
|
192
|
+
}
|
|
193
|
+
releaseThumbnail(file) {
|
|
194
|
+
const url = this.thumbnailUrls.get(file);
|
|
195
|
+
if (!url) return;
|
|
196
|
+
URL.revokeObjectURL(url);
|
|
197
|
+
this.thumbnailUrls.delete(file);
|
|
198
|
+
}
|
|
199
|
+
onPaste(event) {
|
|
200
|
+
const files = [...event.clipboardData?.files ?? []];
|
|
201
|
+
if (!files.length || this.disabled() || this.readonly()) return;
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
this.add(files);
|
|
204
|
+
}
|
|
205
|
+
focus() {
|
|
206
|
+
this.input().nativeElement.focus();
|
|
207
|
+
}
|
|
208
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
209
|
+
minVersion: "12.0.0",
|
|
210
|
+
version: "22.2.6",
|
|
211
|
+
ngImport: i0,
|
|
212
|
+
type: StarFileUpload,
|
|
213
|
+
deps: [],
|
|
214
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
215
|
+
});
|
|
216
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
217
|
+
minVersion: "17.0.0",
|
|
218
|
+
version: "22.2.6",
|
|
219
|
+
type: StarFileUpload,
|
|
220
|
+
isStandalone: true,
|
|
221
|
+
selector: "star-file-upload",
|
|
222
|
+
inputs: {
|
|
223
|
+
value: {
|
|
224
|
+
classPropertyName: "value",
|
|
225
|
+
publicName: "value",
|
|
226
|
+
isSignal: true,
|
|
227
|
+
isRequired: false,
|
|
228
|
+
transformFunction: null
|
|
229
|
+
},
|
|
230
|
+
accept: {
|
|
231
|
+
classPropertyName: "accept",
|
|
232
|
+
publicName: "accept",
|
|
233
|
+
isSignal: true,
|
|
234
|
+
isRequired: false,
|
|
235
|
+
transformFunction: null
|
|
236
|
+
},
|
|
237
|
+
multiple: {
|
|
238
|
+
classPropertyName: "multiple",
|
|
239
|
+
publicName: "multiple",
|
|
240
|
+
isSignal: true,
|
|
241
|
+
isRequired: false,
|
|
242
|
+
transformFunction: null
|
|
243
|
+
},
|
|
244
|
+
maxFileSize: {
|
|
245
|
+
classPropertyName: "maxFileSize",
|
|
246
|
+
publicName: "maxFileSize",
|
|
247
|
+
isSignal: true,
|
|
248
|
+
isRequired: false,
|
|
249
|
+
transformFunction: null
|
|
250
|
+
},
|
|
251
|
+
fileLimit: {
|
|
252
|
+
classPropertyName: "fileLimit",
|
|
253
|
+
publicName: "fileLimit",
|
|
254
|
+
isSignal: true,
|
|
255
|
+
isRequired: false,
|
|
256
|
+
transformFunction: null
|
|
257
|
+
},
|
|
258
|
+
locale: {
|
|
259
|
+
classPropertyName: "locale",
|
|
260
|
+
publicName: "locale",
|
|
261
|
+
isSignal: true,
|
|
262
|
+
isRequired: false,
|
|
263
|
+
transformFunction: null
|
|
264
|
+
},
|
|
265
|
+
fileStatus: {
|
|
266
|
+
classPropertyName: "fileStatus",
|
|
267
|
+
publicName: "fileStatus",
|
|
268
|
+
isSignal: true,
|
|
269
|
+
isRequired: false,
|
|
270
|
+
transformFunction: null
|
|
271
|
+
},
|
|
272
|
+
reorderable: {
|
|
273
|
+
classPropertyName: "reorderable",
|
|
274
|
+
publicName: "reorderable",
|
|
275
|
+
isSignal: true,
|
|
276
|
+
isRequired: false,
|
|
277
|
+
transformFunction: null
|
|
278
|
+
},
|
|
279
|
+
thumbnails: {
|
|
280
|
+
classPropertyName: "thumbnails",
|
|
281
|
+
publicName: "thumbnails",
|
|
282
|
+
isSignal: true,
|
|
283
|
+
isRequired: false,
|
|
284
|
+
transformFunction: null
|
|
285
|
+
},
|
|
286
|
+
disabled: {
|
|
287
|
+
classPropertyName: "disabled",
|
|
288
|
+
publicName: "disabled",
|
|
289
|
+
isSignal: true,
|
|
290
|
+
isRequired: false,
|
|
291
|
+
transformFunction: null
|
|
292
|
+
},
|
|
293
|
+
readonly: {
|
|
294
|
+
classPropertyName: "readonly",
|
|
295
|
+
publicName: "readonly",
|
|
296
|
+
isSignal: true,
|
|
297
|
+
isRequired: false,
|
|
298
|
+
transformFunction: null
|
|
299
|
+
},
|
|
300
|
+
invalid: {
|
|
301
|
+
classPropertyName: "invalid",
|
|
302
|
+
publicName: "invalid",
|
|
303
|
+
isSignal: true,
|
|
304
|
+
isRequired: false,
|
|
305
|
+
transformFunction: null
|
|
306
|
+
},
|
|
307
|
+
touched: {
|
|
308
|
+
classPropertyName: "touched",
|
|
309
|
+
publicName: "touched",
|
|
310
|
+
isSignal: true,
|
|
311
|
+
isRequired: false,
|
|
312
|
+
transformFunction: null
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
outputs: {
|
|
316
|
+
value: "valueChange",
|
|
317
|
+
touch: "touch",
|
|
318
|
+
selected: "selected",
|
|
319
|
+
rejectedChange: "rejectedChange"
|
|
320
|
+
},
|
|
321
|
+
host: {
|
|
322
|
+
listeners: { "paste": "onPaste($event)" },
|
|
323
|
+
properties: {
|
|
324
|
+
"class.star-upload--dragging": "dragging()",
|
|
325
|
+
"class.star-upload--disabled": "disabled()",
|
|
326
|
+
"class.star-upload--invalid": "invalid() && touched()"
|
|
327
|
+
},
|
|
328
|
+
classAttribute: "star-upload"
|
|
329
|
+
},
|
|
330
|
+
viewQueries: [{
|
|
331
|
+
propertyName: "input",
|
|
332
|
+
first: true,
|
|
333
|
+
predicate: ["input"],
|
|
334
|
+
descendants: true,
|
|
335
|
+
isSignal: true
|
|
336
|
+
}],
|
|
337
|
+
ngImport: i0,
|
|
338
|
+
template: `
|
|
339
|
+
<div
|
|
340
|
+
class="star-upload__zone"
|
|
341
|
+
(dragenter)="onDrag($event, true)"
|
|
342
|
+
(dragover)="onDrag($event, true)"
|
|
343
|
+
(dragleave)="onDrag($event, false)"
|
|
344
|
+
(drop)="onDrop($event)"
|
|
345
|
+
>
|
|
346
|
+
<i class="ph-bold ph-cloud-arrow-up star-upload__icon" aria-hidden="true"></i>
|
|
347
|
+
<p class="star-upload__lead">{{ text.dropFiles }}</p>
|
|
348
|
+
<label class="star-btn star-btn--secondary star-btn--sm star-upload__choose" [for]="inputId">
|
|
349
|
+
{{ text.chooseFiles }}
|
|
350
|
+
</label>
|
|
351
|
+
<input
|
|
352
|
+
#input
|
|
353
|
+
type="file"
|
|
354
|
+
class="star-sr-only"
|
|
355
|
+
[id]="inputId"
|
|
356
|
+
[attr.accept]="accept() || null"
|
|
357
|
+
[multiple]="multiple()"
|
|
358
|
+
[disabled]="disabled() || readonly()"
|
|
359
|
+
[attr.aria-describedby]="hintId"
|
|
360
|
+
(change)="onPicked(input)"
|
|
361
|
+
(blur)="touch.emit()"
|
|
362
|
+
/>
|
|
363
|
+
@if (hint()) {
|
|
364
|
+
<p class="star-upload__hint" [id]="hintId">{{ hint() }}</p>
|
|
365
|
+
}
|
|
366
|
+
</div>
|
|
367
|
+
|
|
368
|
+
@if (value().length) {
|
|
369
|
+
<ul class="star-upload__list" [attr.aria-label]="text.chooseFiles">
|
|
370
|
+
@for (file of value(); track file; let i = $index; let first = $first; let last = $last) {
|
|
371
|
+
@let status = statusOf(file);
|
|
372
|
+
<li
|
|
373
|
+
class="star-upload__file"
|
|
374
|
+
[class.star-upload__file--error]="status?.state === 'error'"
|
|
375
|
+
[class.star-upload__file--drop]="dropIndex() === i"
|
|
376
|
+
[attr.draggable]="canReorder() ? 'true' : null"
|
|
377
|
+
(dragstart)="onFileDragStart(i, $event)"
|
|
378
|
+
(dragover)="onFileDragOver(i, $event)"
|
|
379
|
+
(drop)="onFileDrop(i, $event)"
|
|
380
|
+
(dragend)="endFileDrag()"
|
|
381
|
+
>
|
|
382
|
+
@if (status?.state === 'done') {
|
|
383
|
+
<i class="ph-fill ph-check-circle star-upload__state--done" aria-hidden="true"></i>
|
|
384
|
+
} @else if (status?.state === 'error') {
|
|
385
|
+
<i class="ph-fill ph-warning-circle star-upload__state--error" aria-hidden="true"></i>
|
|
386
|
+
} @else if (thumbnailOf(file); as thumbnail) {
|
|
387
|
+
<img class="star-upload__thumb" alt="" [src]="thumbnail" />
|
|
388
|
+
} @else {
|
|
389
|
+
<i class="ph-bold ph-file star-upload__file-icon" aria-hidden="true"></i>
|
|
390
|
+
}
|
|
391
|
+
<span class="star-upload__main">
|
|
392
|
+
<span class="star-upload__name">{{ file.name }}</span>
|
|
393
|
+
@if (status?.state === 'uploading') {
|
|
394
|
+
<span
|
|
395
|
+
class="star-upload__progress"
|
|
396
|
+
role="progressbar"
|
|
397
|
+
aria-valuemin="0"
|
|
398
|
+
aria-valuemax="100"
|
|
399
|
+
[attr.aria-valuenow]="percent(status)"
|
|
400
|
+
[attr.aria-label]="text.uploadingFile(file.name)"
|
|
401
|
+
>
|
|
402
|
+
<span class="star-upload__progress-bar" [style.width.%]="percent(status)"></span>
|
|
403
|
+
</span>
|
|
404
|
+
} @else if (status?.state === 'error' && status?.message) {
|
|
405
|
+
<span class="star-upload__message">{{ status?.message }}</span>
|
|
406
|
+
} @else if (status?.state === 'done') {
|
|
407
|
+
<span class="star-sr-only">{{ text.uploaded }}</span>
|
|
408
|
+
}
|
|
409
|
+
</span>
|
|
410
|
+
@if (status?.state === 'uploading') {
|
|
411
|
+
<span class="star-upload__size">{{ percent(status) }}%</span>
|
|
412
|
+
} @else {
|
|
413
|
+
<span class="star-upload__size">{{ size(file) }}</span>
|
|
414
|
+
}
|
|
415
|
+
@if (canReorder()) {
|
|
416
|
+
<button
|
|
417
|
+
type="button"
|
|
418
|
+
class="star-select__icon-btn"
|
|
419
|
+
[disabled]="first"
|
|
420
|
+
[attr.aria-label]="text.moveUp + ': ' + file.name"
|
|
421
|
+
(click)="move(i, i - 1)"
|
|
422
|
+
>
|
|
423
|
+
<i class="ph-bold ph-arrow-up" aria-hidden="true"></i>
|
|
424
|
+
</button>
|
|
425
|
+
<button
|
|
426
|
+
type="button"
|
|
427
|
+
class="star-select__icon-btn"
|
|
428
|
+
[disabled]="last"
|
|
429
|
+
[attr.aria-label]="text.moveDown + ': ' + file.name"
|
|
430
|
+
(click)="move(i, i + 1)"
|
|
431
|
+
>
|
|
432
|
+
<i class="ph-bold ph-arrow-down" aria-hidden="true"></i>
|
|
433
|
+
</button>
|
|
434
|
+
}
|
|
435
|
+
@if (!disabled() && !readonly()) {
|
|
436
|
+
<button
|
|
437
|
+
type="button"
|
|
438
|
+
class="star-select__icon-btn"
|
|
439
|
+
[attr.aria-label]="text.removeItem(file.name)"
|
|
440
|
+
(click)="remove(file)"
|
|
441
|
+
>
|
|
442
|
+
<i class="ph-bold ph-x" aria-hidden="true"></i>
|
|
443
|
+
</button>
|
|
444
|
+
}
|
|
445
|
+
</li>
|
|
446
|
+
}
|
|
447
|
+
</ul>
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
@if (rejected().length) {
|
|
451
|
+
<div role="alert">
|
|
452
|
+
<ul class="star-upload__errors">
|
|
453
|
+
@for (item of rejected(); track $index) {
|
|
454
|
+
<li>{{ rejectionText(item) }}</li>
|
|
455
|
+
}
|
|
456
|
+
</ul>
|
|
457
|
+
</div>
|
|
458
|
+
}
|
|
459
|
+
`,
|
|
460
|
+
isInline: true,
|
|
461
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
462
|
+
});
|
|
463
|
+
};
|
|
464
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
465
|
+
minVersion: "12.0.0",
|
|
466
|
+
version: "22.2.6",
|
|
467
|
+
ngImport: i0,
|
|
468
|
+
type: StarFileUpload,
|
|
469
|
+
decorators: [{
|
|
470
|
+
type: Component,
|
|
471
|
+
args: [{
|
|
472
|
+
selector: "star-file-upload",
|
|
473
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
474
|
+
host: {
|
|
475
|
+
class: "star-upload",
|
|
476
|
+
"[class.star-upload--dragging]": "dragging()",
|
|
477
|
+
"[class.star-upload--disabled]": "disabled()",
|
|
478
|
+
"[class.star-upload--invalid]": "invalid() && touched()",
|
|
479
|
+
"(paste)": "onPaste($event)"
|
|
480
|
+
},
|
|
481
|
+
template: `
|
|
482
|
+
<div
|
|
483
|
+
class="star-upload__zone"
|
|
484
|
+
(dragenter)="onDrag($event, true)"
|
|
485
|
+
(dragover)="onDrag($event, true)"
|
|
486
|
+
(dragleave)="onDrag($event, false)"
|
|
487
|
+
(drop)="onDrop($event)"
|
|
488
|
+
>
|
|
489
|
+
<i class="ph-bold ph-cloud-arrow-up star-upload__icon" aria-hidden="true"></i>
|
|
490
|
+
<p class="star-upload__lead">{{ text.dropFiles }}</p>
|
|
491
|
+
<label class="star-btn star-btn--secondary star-btn--sm star-upload__choose" [for]="inputId">
|
|
492
|
+
{{ text.chooseFiles }}
|
|
493
|
+
</label>
|
|
494
|
+
<input
|
|
495
|
+
#input
|
|
496
|
+
type="file"
|
|
497
|
+
class="star-sr-only"
|
|
498
|
+
[id]="inputId"
|
|
499
|
+
[attr.accept]="accept() || null"
|
|
500
|
+
[multiple]="multiple()"
|
|
501
|
+
[disabled]="disabled() || readonly()"
|
|
502
|
+
[attr.aria-describedby]="hintId"
|
|
503
|
+
(change)="onPicked(input)"
|
|
504
|
+
(blur)="touch.emit()"
|
|
505
|
+
/>
|
|
506
|
+
@if (hint()) {
|
|
507
|
+
<p class="star-upload__hint" [id]="hintId">{{ hint() }}</p>
|
|
508
|
+
}
|
|
509
|
+
</div>
|
|
510
|
+
|
|
511
|
+
@if (value().length) {
|
|
512
|
+
<ul class="star-upload__list" [attr.aria-label]="text.chooseFiles">
|
|
513
|
+
@for (file of value(); track file; let i = $index; let first = $first; let last = $last) {
|
|
514
|
+
@let status = statusOf(file);
|
|
515
|
+
<li
|
|
516
|
+
class="star-upload__file"
|
|
517
|
+
[class.star-upload__file--error]="status?.state === 'error'"
|
|
518
|
+
[class.star-upload__file--drop]="dropIndex() === i"
|
|
519
|
+
[attr.draggable]="canReorder() ? 'true' : null"
|
|
520
|
+
(dragstart)="onFileDragStart(i, $event)"
|
|
521
|
+
(dragover)="onFileDragOver(i, $event)"
|
|
522
|
+
(drop)="onFileDrop(i, $event)"
|
|
523
|
+
(dragend)="endFileDrag()"
|
|
524
|
+
>
|
|
525
|
+
@if (status?.state === 'done') {
|
|
526
|
+
<i class="ph-fill ph-check-circle star-upload__state--done" aria-hidden="true"></i>
|
|
527
|
+
} @else if (status?.state === 'error') {
|
|
528
|
+
<i class="ph-fill ph-warning-circle star-upload__state--error" aria-hidden="true"></i>
|
|
529
|
+
} @else if (thumbnailOf(file); as thumbnail) {
|
|
530
|
+
<img class="star-upload__thumb" alt="" [src]="thumbnail" />
|
|
531
|
+
} @else {
|
|
532
|
+
<i class="ph-bold ph-file star-upload__file-icon" aria-hidden="true"></i>
|
|
533
|
+
}
|
|
534
|
+
<span class="star-upload__main">
|
|
535
|
+
<span class="star-upload__name">{{ file.name }}</span>
|
|
536
|
+
@if (status?.state === 'uploading') {
|
|
537
|
+
<span
|
|
538
|
+
class="star-upload__progress"
|
|
539
|
+
role="progressbar"
|
|
540
|
+
aria-valuemin="0"
|
|
541
|
+
aria-valuemax="100"
|
|
542
|
+
[attr.aria-valuenow]="percent(status)"
|
|
543
|
+
[attr.aria-label]="text.uploadingFile(file.name)"
|
|
544
|
+
>
|
|
545
|
+
<span class="star-upload__progress-bar" [style.width.%]="percent(status)"></span>
|
|
546
|
+
</span>
|
|
547
|
+
} @else if (status?.state === 'error' && status?.message) {
|
|
548
|
+
<span class="star-upload__message">{{ status?.message }}</span>
|
|
549
|
+
} @else if (status?.state === 'done') {
|
|
550
|
+
<span class="star-sr-only">{{ text.uploaded }}</span>
|
|
551
|
+
}
|
|
552
|
+
</span>
|
|
553
|
+
@if (status?.state === 'uploading') {
|
|
554
|
+
<span class="star-upload__size">{{ percent(status) }}%</span>
|
|
555
|
+
} @else {
|
|
556
|
+
<span class="star-upload__size">{{ size(file) }}</span>
|
|
557
|
+
}
|
|
558
|
+
@if (canReorder()) {
|
|
559
|
+
<button
|
|
560
|
+
type="button"
|
|
561
|
+
class="star-select__icon-btn"
|
|
562
|
+
[disabled]="first"
|
|
563
|
+
[attr.aria-label]="text.moveUp + ': ' + file.name"
|
|
564
|
+
(click)="move(i, i - 1)"
|
|
565
|
+
>
|
|
566
|
+
<i class="ph-bold ph-arrow-up" aria-hidden="true"></i>
|
|
567
|
+
</button>
|
|
568
|
+
<button
|
|
569
|
+
type="button"
|
|
570
|
+
class="star-select__icon-btn"
|
|
571
|
+
[disabled]="last"
|
|
572
|
+
[attr.aria-label]="text.moveDown + ': ' + file.name"
|
|
573
|
+
(click)="move(i, i + 1)"
|
|
574
|
+
>
|
|
575
|
+
<i class="ph-bold ph-arrow-down" aria-hidden="true"></i>
|
|
576
|
+
</button>
|
|
577
|
+
}
|
|
578
|
+
@if (!disabled() && !readonly()) {
|
|
579
|
+
<button
|
|
580
|
+
type="button"
|
|
581
|
+
class="star-select__icon-btn"
|
|
582
|
+
[attr.aria-label]="text.removeItem(file.name)"
|
|
583
|
+
(click)="remove(file)"
|
|
584
|
+
>
|
|
585
|
+
<i class="ph-bold ph-x" aria-hidden="true"></i>
|
|
586
|
+
</button>
|
|
587
|
+
}
|
|
588
|
+
</li>
|
|
589
|
+
}
|
|
590
|
+
</ul>
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
@if (rejected().length) {
|
|
594
|
+
<div role="alert">
|
|
595
|
+
<ul class="star-upload__errors">
|
|
596
|
+
@for (item of rejected(); track $index) {
|
|
597
|
+
<li>{{ rejectionText(item) }}</li>
|
|
598
|
+
}
|
|
599
|
+
</ul>
|
|
600
|
+
</div>
|
|
601
|
+
}
|
|
602
|
+
`
|
|
603
|
+
}]
|
|
604
|
+
}],
|
|
605
|
+
ctorParameters: () => [],
|
|
606
|
+
propDecorators: {
|
|
607
|
+
value: [{
|
|
608
|
+
type: i0.Input,
|
|
609
|
+
args: [{
|
|
610
|
+
isSignal: true,
|
|
611
|
+
alias: "value",
|
|
612
|
+
required: false
|
|
613
|
+
}]
|
|
614
|
+
}, {
|
|
615
|
+
type: i0.Output,
|
|
616
|
+
args: ["valueChange"]
|
|
617
|
+
}],
|
|
618
|
+
accept: [{
|
|
619
|
+
type: i0.Input,
|
|
620
|
+
args: [{
|
|
621
|
+
isSignal: true,
|
|
622
|
+
alias: "accept",
|
|
623
|
+
required: false
|
|
624
|
+
}]
|
|
625
|
+
}],
|
|
626
|
+
multiple: [{
|
|
627
|
+
type: i0.Input,
|
|
628
|
+
args: [{
|
|
629
|
+
isSignal: true,
|
|
630
|
+
alias: "multiple",
|
|
631
|
+
required: false
|
|
632
|
+
}]
|
|
633
|
+
}],
|
|
634
|
+
maxFileSize: [{
|
|
635
|
+
type: i0.Input,
|
|
636
|
+
args: [{
|
|
637
|
+
isSignal: true,
|
|
638
|
+
alias: "maxFileSize",
|
|
639
|
+
required: false
|
|
640
|
+
}]
|
|
641
|
+
}],
|
|
642
|
+
fileLimit: [{
|
|
643
|
+
type: i0.Input,
|
|
644
|
+
args: [{
|
|
645
|
+
isSignal: true,
|
|
646
|
+
alias: "fileLimit",
|
|
647
|
+
required: false
|
|
648
|
+
}]
|
|
649
|
+
}],
|
|
650
|
+
locale: [{
|
|
651
|
+
type: i0.Input,
|
|
652
|
+
args: [{
|
|
653
|
+
isSignal: true,
|
|
654
|
+
alias: "locale",
|
|
655
|
+
required: false
|
|
656
|
+
}]
|
|
657
|
+
}],
|
|
658
|
+
fileStatus: [{
|
|
659
|
+
type: i0.Input,
|
|
660
|
+
args: [{
|
|
661
|
+
isSignal: true,
|
|
662
|
+
alias: "fileStatus",
|
|
663
|
+
required: false
|
|
664
|
+
}]
|
|
665
|
+
}],
|
|
666
|
+
reorderable: [{
|
|
667
|
+
type: i0.Input,
|
|
668
|
+
args: [{
|
|
669
|
+
isSignal: true,
|
|
670
|
+
alias: "reorderable",
|
|
671
|
+
required: false
|
|
672
|
+
}]
|
|
673
|
+
}],
|
|
674
|
+
thumbnails: [{
|
|
675
|
+
type: i0.Input,
|
|
676
|
+
args: [{
|
|
677
|
+
isSignal: true,
|
|
678
|
+
alias: "thumbnails",
|
|
679
|
+
required: false
|
|
680
|
+
}]
|
|
681
|
+
}],
|
|
682
|
+
disabled: [{
|
|
683
|
+
type: i0.Input,
|
|
684
|
+
args: [{
|
|
685
|
+
isSignal: true,
|
|
686
|
+
alias: "disabled",
|
|
687
|
+
required: false
|
|
688
|
+
}]
|
|
689
|
+
}],
|
|
690
|
+
readonly: [{
|
|
691
|
+
type: i0.Input,
|
|
692
|
+
args: [{
|
|
693
|
+
isSignal: true,
|
|
694
|
+
alias: "readonly",
|
|
695
|
+
required: false
|
|
696
|
+
}]
|
|
697
|
+
}],
|
|
698
|
+
invalid: [{
|
|
699
|
+
type: i0.Input,
|
|
700
|
+
args: [{
|
|
701
|
+
isSignal: true,
|
|
702
|
+
alias: "invalid",
|
|
703
|
+
required: false
|
|
704
|
+
}]
|
|
705
|
+
}],
|
|
706
|
+
touched: [{
|
|
707
|
+
type: i0.Input,
|
|
708
|
+
args: [{
|
|
709
|
+
isSignal: true,
|
|
710
|
+
alias: "touched",
|
|
711
|
+
required: false
|
|
712
|
+
}]
|
|
713
|
+
}],
|
|
714
|
+
touch: [{
|
|
715
|
+
type: i0.Output,
|
|
716
|
+
args: ["touch"]
|
|
717
|
+
}],
|
|
718
|
+
selected: [{
|
|
719
|
+
type: i0.Output,
|
|
720
|
+
args: ["selected"]
|
|
721
|
+
}],
|
|
722
|
+
rejectedChange: [{
|
|
723
|
+
type: i0.Output,
|
|
724
|
+
args: ["rejectedChange"]
|
|
725
|
+
}],
|
|
726
|
+
input: [{
|
|
727
|
+
type: i0.ViewChild,
|
|
728
|
+
args: ["input", { isSignal: true }]
|
|
729
|
+
}]
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
function toUploadStatus(errorMessage = defaultErrorMessage) {
|
|
733
|
+
return (events) => events.pipe(map((event) => {
|
|
734
|
+
switch (event.type) {
|
|
735
|
+
case HttpEventType.Sent: return {
|
|
736
|
+
state: "uploading",
|
|
737
|
+
progress: 0
|
|
738
|
+
};
|
|
739
|
+
case HttpEventType.UploadProgress: return {
|
|
740
|
+
state: "uploading",
|
|
741
|
+
progress: event.total ? 100 * event.loaded / event.total : 0
|
|
742
|
+
};
|
|
743
|
+
case HttpEventType.Response: return {
|
|
744
|
+
state: "done",
|
|
745
|
+
progress: 100,
|
|
746
|
+
response: event.body ?? void 0
|
|
747
|
+
};
|
|
748
|
+
default: return null;
|
|
749
|
+
}
|
|
750
|
+
}), filter((status) => status !== null), catchError((error) => of({
|
|
751
|
+
state: "error",
|
|
752
|
+
message: errorMessage(error)
|
|
753
|
+
})));
|
|
754
|
+
}
|
|
755
|
+
function defaultErrorMessage(error) {
|
|
756
|
+
const status = error ?? {};
|
|
757
|
+
if (status.status) return `${status.status} ${status.statusText ?? ""}`.trim();
|
|
758
|
+
return error instanceof Error ? error.message : String(error);
|
|
759
|
+
}
|
|
760
|
+
export { StarFileUpload, fileMatchesAccept, formatFileSize, toUploadStatus };
|
|
761
|
+
|
|
762
|
+
//# sourceMappingURL=star-ng-ui-file-upload.mjs.map
|