@genexus/genexus-ide-ui 1.1.1 → 1.1.3

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.
Files changed (48) hide show
  1. package/dist/cjs/genexus-ide-ui.cjs.js +1 -1
  2. package/dist/cjs/gx-ide-file-item.cjs.entry.js +110 -0
  3. package/dist/cjs/gx-ide-file-item.cjs.entry.js.map +1 -0
  4. package/dist/cjs/gx-ide-file-uploader.cjs.entry.js +399 -0
  5. package/dist/cjs/gx-ide-file-uploader.cjs.entry.js.map +1 -0
  6. package/dist/cjs/loader.cjs.js +1 -1
  7. package/dist/collection/collection-manifest.json +2 -0
  8. package/dist/collection/components/file-uploader/file-item/file-item.css +97 -0
  9. package/dist/collection/components/file-uploader/file-item/file-item.js +246 -0
  10. package/dist/collection/components/file-uploader/file-item/file-item.js.map +1 -0
  11. package/dist/collection/components/file-uploader/file-uploader.css +678 -0
  12. package/dist/collection/components/file-uploader/file-uploader.js +750 -0
  13. package/dist/collection/components/file-uploader/file-uploader.js.map +1 -0
  14. package/dist/collection/components/file-uploader/gx-ide-assets/file-uploader/langs/file-uploader.lang.en.json +36 -0
  15. package/dist/collection/components/file-uploader/gx-ide-assets/file-uploader/langs/file-uploader.lang.ja.json +36 -0
  16. package/dist/collection/components/file-uploader/gx-ide-assets/file-uploader/langs/file-uploader.lang.zh.json +36 -0
  17. package/dist/collection/components/file-uploader/types.js +2 -0
  18. package/dist/collection/components/file-uploader/types.js.map +1 -0
  19. package/dist/collection/testing/locale.e2e.js +4 -1
  20. package/dist/collection/testing/locale.e2e.js.map +1 -1
  21. package/dist/components/file-item.js +130 -0
  22. package/dist/components/file-item.js.map +1 -0
  23. package/dist/components/gx-ide-file-item.d.ts +11 -0
  24. package/dist/components/gx-ide-file-item.js +8 -0
  25. package/dist/components/gx-ide-file-item.js.map +1 -0
  26. package/dist/components/gx-ide-file-uploader.d.ts +11 -0
  27. package/dist/components/gx-ide-file-uploader.js +438 -0
  28. package/dist/components/gx-ide-file-uploader.js.map +1 -0
  29. package/dist/esm/genexus-ide-ui.js +1 -1
  30. package/dist/esm/gx-ide-file-item.entry.js +106 -0
  31. package/dist/esm/gx-ide-file-item.entry.js.map +1 -0
  32. package/dist/esm/gx-ide-file-uploader.entry.js +395 -0
  33. package/dist/esm/gx-ide-file-uploader.entry.js.map +1 -0
  34. package/dist/esm/loader.js +1 -1
  35. package/dist/genexus-ide-ui/genexus-ide-ui.esm.js +1 -1
  36. package/dist/genexus-ide-ui/genexus-ide-ui.esm.js.map +1 -1
  37. package/dist/genexus-ide-ui/gx-ide-assets/file-uploader/langs/file-uploader.lang.en.json +36 -0
  38. package/dist/genexus-ide-ui/gx-ide-assets/file-uploader/langs/file-uploader.lang.ja.json +36 -0
  39. package/dist/genexus-ide-ui/gx-ide-assets/file-uploader/langs/file-uploader.lang.zh.json +36 -0
  40. package/dist/genexus-ide-ui/p-961cd6c2.entry.js +475 -0
  41. package/dist/genexus-ide-ui/p-961cd6c2.entry.js.map +1 -0
  42. package/dist/genexus-ide-ui/p-ef5dfd35.entry.js +157 -0
  43. package/dist/genexus-ide-ui/p-ef5dfd35.entry.js.map +1 -0
  44. package/dist/types/components/file-uploader/file-item/file-item.d.ts +31 -0
  45. package/dist/types/components/file-uploader/file-uploader.d.ts +51 -0
  46. package/dist/types/components/file-uploader/types.d.ts +31 -0
  47. package/dist/types/components.d.ts +247 -0
  48. package/package.json +1 -1
@@ -0,0 +1,750 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f)
3
+ throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
5
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
6
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
7
+ };
8
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9
+ if (kind === "m")
10
+ throw new TypeError("Private method is not writable");
11
+ if (kind === "a" && !f)
12
+ throw new TypeError("Private accessor was defined without a setter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
14
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
15
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
+ };
17
+ var _FileUploader_instances, _FileUploader__componentLocale, _FileUploader_fileInputEl, _FileUploader_dragCounter, _FileUploader_generateId, _FileUploader_isValidFile, _FileUploader_getValidFiles, _FileUploader_handleDragEnter, _FileUploader_handleDragLeave, _FileUploader_handleDragOver, _FileUploader_handleDrop, _FileUploader_handleFileSelect, _FileUploader_handleFileInput, _FileUploader_handleFiles, _FileUploader_handleNameChange, _FileUploader_handleFileCancel, _FileUploader_handleConfirm, _FileUploader_handleCancel;
18
+ /* eslint-disable @stencil-community/own-methods-must-be-private */
19
+ /* eslint-disable @stencil-community/own-props-must-be-private */
20
+ /* STENCIL IMPORTS */
21
+ import { Host, h } from "@stencil/core";
22
+ import { getIconPath } from "@genexus/mercury";
23
+ import { Locale } from "../../common/locale";
24
+ const PLUS_ICON = getIconPath({
25
+ category: "gemini-tools",
26
+ name: "add",
27
+ colorType: "primary"
28
+ });
29
+ const CSS_BUNDLES = [
30
+ "resets/box-sizing",
31
+ "components/button",
32
+ "components/icon",
33
+ "components/list-box",
34
+ "components/edit",
35
+ "utils/typography",
36
+ "utils/spacing",
37
+ "utils/form",
38
+ "utils/layout",
39
+ "utils/elevation",
40
+ "chameleon/scrollbar"
41
+ ];
42
+ export class FileUploader {
43
+ constructor() {
44
+ _FileUploader_instances.add(this);
45
+ _FileUploader__componentLocale.set(this, void 0);
46
+ _FileUploader_fileInputEl.set(this, void 0);
47
+ _FileUploader_dragCounter.set(this, 0);
48
+ /** Generates a unique ID for file identification */
49
+ _FileUploader_generateId.set(this, () => {
50
+ return Math.random().toString(36).substr(2, 9);
51
+ });
52
+ /** Handles drag enter event */
53
+ _FileUploader_handleDragEnter.set(this, (e) => {
54
+ var _a;
55
+ e.preventDefault();
56
+ e.stopPropagation();
57
+ __classPrivateFieldSet(this, _FileUploader_dragCounter, (_a = __classPrivateFieldGet(this, _FileUploader_dragCounter, "f"), _a++, _a), "f");
58
+ this.isDragging = true;
59
+ });
60
+ /** Handles drag leave event */
61
+ _FileUploader_handleDragLeave.set(this, (e) => {
62
+ var _a;
63
+ e.preventDefault();
64
+ e.stopPropagation();
65
+ __classPrivateFieldSet(this, _FileUploader_dragCounter, (_a = __classPrivateFieldGet(this, _FileUploader_dragCounter, "f"), _a--, _a), "f");
66
+ if (__classPrivateFieldGet(this, _FileUploader_dragCounter, "f") === 0) {
67
+ this.isDragging = false;
68
+ }
69
+ });
70
+ /** Handles drag over event */
71
+ _FileUploader_handleDragOver.set(this, (e) => {
72
+ e.preventDefault();
73
+ e.stopPropagation();
74
+ });
75
+ /** Handles drop event */
76
+ _FileUploader_handleDrop.set(this, (e) => {
77
+ var _a;
78
+ e.preventDefault();
79
+ e.stopPropagation();
80
+ this.isDragging = false;
81
+ __classPrivateFieldSet(this, _FileUploader_dragCounter, 0, "f");
82
+ const files = (_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.files;
83
+ if (files) {
84
+ __classPrivateFieldGet(this, _FileUploader_handleFiles, "f").call(this, files);
85
+ }
86
+ });
87
+ /** Triggers file input click */
88
+ _FileUploader_handleFileSelect.set(this, () => {
89
+ var _a;
90
+ (_a = __classPrivateFieldGet(this, _FileUploader_fileInputEl, "f")) === null || _a === void 0 ? void 0 : _a.click();
91
+ });
92
+ /** Handles file input change event */
93
+ _FileUploader_handleFileInput.set(this, (e) => {
94
+ const files = e.target.files;
95
+ if (files) {
96
+ __classPrivateFieldGet(this, _FileUploader_handleFiles, "f").call(this, files);
97
+ }
98
+ });
99
+ /** Processes files and starts upload */
100
+ _FileUploader_handleFiles.set(this, (files) => {
101
+ const validFiles = __classPrivateFieldGet(this, _FileUploader_instances, "m", _FileUploader_getValidFiles).call(this, files);
102
+ validFiles.forEach(async (file) => {
103
+ var _a, _b;
104
+ const id = __classPrivateFieldGet(this, _FileUploader_generateId, "f").call(this);
105
+ const fileState = {
106
+ id,
107
+ name: file.name,
108
+ file,
109
+ pending: true,
110
+ progress: 0
111
+ };
112
+ if (!this.multiple) {
113
+ this.fileStates.clear();
114
+ }
115
+ this.fileStates = new Map(this.fileStates.set(id, fileState));
116
+ if (this.uploadFunction) {
117
+ try {
118
+ const uploadPromise = this.uploadFunction(file, progress => {
119
+ const state = this.fileStates.get(id);
120
+ if (state) {
121
+ const updatedState = Object.assign(Object.assign({}, state), { progress: progress, pending: progress < 100 });
122
+ this.fileStates = new Map(this.fileStates.set(id, updatedState));
123
+ }
124
+ });
125
+ // Store the upload promise/object for potential cancellation
126
+ const stateWithPromise = Object.assign(Object.assign({}, this.fileStates.get(id)), { uploadPromise });
127
+ this.fileStates = new Map(this.fileStates.set(id, stateWithPromise));
128
+ const result = await uploadPromise;
129
+ console.log("Upload result:", { id, result });
130
+ const state = this.fileStates.get(id);
131
+ if (state) {
132
+ if (result.success && result.remoteId) {
133
+ const updatedState = Object.assign(Object.assign({}, state), { remoteId: result.remoteId, pending: false, progress: 100 });
134
+ this.fileStates = new Map(this.fileStates.set(id, updatedState));
135
+ console.log("File uploaded successfully:", updatedState);
136
+ await ((_a = this.fileUploadedCallback) === null || _a === void 0 ? void 0 : _a.call(this, {
137
+ name: state.name,
138
+ originalName: state.file.name,
139
+ remoteId: result.remoteId
140
+ }));
141
+ }
142
+ else {
143
+ const updatedState = Object.assign(Object.assign({}, state), { error: ((_b = result.errors) === null || _b === void 0 ? void 0 : _b.upload) || "Upload failed", pending: false });
144
+ this.fileStates = new Map(this.fileStates.set(id, updatedState));
145
+ console.log("File upload failed:", updatedState);
146
+ }
147
+ }
148
+ }
149
+ catch (error) {
150
+ const state = this.fileStates.get(id);
151
+ if (state) {
152
+ const updatedState = Object.assign(Object.assign({}, state), { error: error instanceof Error
153
+ ? error.message
154
+ : "Unknown error occurred", pending: false });
155
+ this.fileStates = new Map(this.fileStates.set(id, updatedState));
156
+ console.log("File upload error:", updatedState);
157
+ }
158
+ }
159
+ }
160
+ });
161
+ if (__classPrivateFieldGet(this, _FileUploader_fileInputEl, "f")) {
162
+ __classPrivateFieldGet(this, _FileUploader_fileInputEl, "f").value = "";
163
+ }
164
+ });
165
+ /** Handles file name change */
166
+ _FileUploader_handleNameChange.set(this, async (event) => {
167
+ var _a;
168
+ const { id, name } = event.detail;
169
+ const file = this.fileStates.get(id);
170
+ if (file) {
171
+ const updatedFile = Object.assign(Object.assign({}, file), { name: name.trim(), isEditing: false });
172
+ this.fileStates = new Map(this.fileStates.set(id, updatedFile));
173
+ await ((_a = this.fileRenamedCallback) === null || _a === void 0 ? void 0 : _a.call(this, { fileId: id, newName: name.trim() }));
174
+ }
175
+ });
176
+ /** Handles individual file cancellation or deletion */
177
+ _FileUploader_handleFileCancel.set(this, async (event) => {
178
+ var _a, _b, _c, _d;
179
+ const id = event.detail;
180
+ const state = this.fileStates.get(id);
181
+ if (state) {
182
+ try {
183
+ if (state.pending) {
184
+ // Cancel upload in progress
185
+ if (state.uploadPromise &&
186
+ typeof state.uploadPromise.cancel === "function") {
187
+ state.uploadPromise.cancel();
188
+ }
189
+ else if (this.cancelUploadFunction) {
190
+ await this.cancelUploadFunction(id);
191
+ }
192
+ await ((_a = this.uploadCancelledCallback) === null || _a === void 0 ? void 0 : _a.call(this, id));
193
+ this.fileStates.delete(id);
194
+ this.fileStates = new Map(this.fileStates);
195
+ }
196
+ else {
197
+ const fileToDelete = {
198
+ name: state.name,
199
+ originalName: state.file.name,
200
+ remoteId: state.remoteId
201
+ };
202
+ const shouldDelete = await ((_b = this.onBeforeDelete) === null || _b === void 0 ? void 0 : _b.call(this, fileToDelete));
203
+ if (shouldDelete) {
204
+ await ((_c = this.fileDeletedCallback) === null || _c === void 0 ? void 0 : _c.call(this, fileToDelete));
205
+ this.fileStates.delete(id);
206
+ this.fileStates = new Map(this.fileStates);
207
+ }
208
+ }
209
+ }
210
+ catch (error) {
211
+ await ((_d = this.fileDeletionErrorCallback) === null || _d === void 0 ? void 0 : _d.call(this, {
212
+ fileName: state.name,
213
+ error: error instanceof Error ? error.message : "Unknown error occurred"
214
+ }));
215
+ }
216
+ }
217
+ });
218
+ /** Handles dialog confirmation */
219
+ _FileUploader_handleConfirm.set(this, async () => {
220
+ var _a;
221
+ // Verificar si hay subidas en progreso
222
+ const hasPendingUploads = Array.from(this.fileStates.values()).some(file => file.pending);
223
+ if (hasPendingUploads) {
224
+ return; // No permitir confirmar si hay subidas en progreso
225
+ }
226
+ // Obtener todos los archivos que están completamente subidos
227
+ const uploadedFiles = Array.from(this.fileStates.values())
228
+ .filter(file => {
229
+ const isValid = !file.pending && file.remoteId && !file.error;
230
+ console.log("File validation:", {
231
+ id: file.id,
232
+ name: file.name,
233
+ pending: file.pending,
234
+ remoteId: file.remoteId,
235
+ error: file.error,
236
+ isValid
237
+ });
238
+ return isValid;
239
+ })
240
+ .map(file => ({
241
+ name: file.name,
242
+ originalName: file.file.name,
243
+ remoteId: file.remoteId
244
+ }));
245
+ console.log("Files to be confirmed:", uploadedFiles);
246
+ if (uploadedFiles.length > 0) {
247
+ await ((_a = this.dialogConfirmedCallback) === null || _a === void 0 ? void 0 : _a.call(this, uploadedFiles));
248
+ }
249
+ // Clear file states
250
+ this.fileStates.clear();
251
+ this.fileStates = new Map();
252
+ // Reset file input
253
+ if (__classPrivateFieldGet(this, _FileUploader_fileInputEl, "f")) {
254
+ __classPrivateFieldGet(this, _FileUploader_fileInputEl, "f").value = "";
255
+ }
256
+ });
257
+ /** Handles dialog cancellation */
258
+ _FileUploader_handleCancel.set(this, async () => {
259
+ var _a, _b, _c;
260
+ try {
261
+ // Cancelamos todas las subidas en progreso
262
+ for (const [id, state] of this.fileStates.entries()) {
263
+ if (state.pending && this.cancelUploadFunction) {
264
+ try {
265
+ await this.cancelUploadFunction(id);
266
+ await ((_a = this.uploadCancelledCallback) === null || _a === void 0 ? void 0 : _a.call(this, id));
267
+ }
268
+ catch (error) {
269
+ // Error handling for upload cancellation
270
+ }
271
+ }
272
+ }
273
+ // Limpiamos todos los estados
274
+ this.fileStates.clear();
275
+ this.fileStates = new Map();
276
+ if (__classPrivateFieldGet(this, _FileUploader_fileInputEl, "f")) {
277
+ __classPrivateFieldGet(this, _FileUploader_fileInputEl, "f").value = "";
278
+ }
279
+ await ((_b = this.dialogCanceledCallback) === null || _b === void 0 ? void 0 : _b.call(this));
280
+ }
281
+ catch (error) {
282
+ this.fileStates.clear();
283
+ this.fileStates = new Map();
284
+ await ((_c = this.dialogCanceledCallback) === null || _c === void 0 ? void 0 : _c.call(this));
285
+ }
286
+ });
287
+ this.types = [];
288
+ this.multiple = false;
289
+ this.canEditName = false;
290
+ this.label = undefined;
291
+ this.uploadFunction = undefined;
292
+ this.cancelUploadFunction = undefined;
293
+ this.fileUploadedCallback = undefined;
294
+ this.dialogCanceledCallback = undefined;
295
+ this.dialogConfirmedCallback = undefined;
296
+ this.uploadCancelledCallback = undefined;
297
+ this.fileRenamedCallback = undefined;
298
+ this.fileValidationErrorCallback = undefined;
299
+ this.fileDeletionErrorCallback = undefined;
300
+ this.fileDeletedCallback = undefined;
301
+ this.onBeforeDelete = undefined;
302
+ this.fileStates = new Map();
303
+ this.isDragging = false;
304
+ }
305
+ /** Initializes component with locale strings */
306
+ async componentWillLoad() {
307
+ __classPrivateFieldSet(this, _FileUploader__componentLocale, await Locale.getComponentStrings(this.el), "f");
308
+ }
309
+ /** Clears the current file selection */
310
+ async clear() {
311
+ var _a;
312
+ for (const [id, state] of this.fileStates.entries()) {
313
+ if (state.pending && this.cancelUploadFunction) {
314
+ try {
315
+ await this.cancelUploadFunction(id);
316
+ await ((_a = this.uploadCancelledCallback) === null || _a === void 0 ? void 0 : _a.call(this, id));
317
+ }
318
+ catch (error) {
319
+ // Error handling for upload cancellation
320
+ }
321
+ }
322
+ }
323
+ this.fileStates.clear();
324
+ }
325
+ render() {
326
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
327
+ return (h(Host, { class: "widget" }, h("ch-theme", { model: CSS_BUNDLES }), h("input", { type: "file", class: "hidden-input", multiple: this.multiple, accept: (_a = this.types) === null || _a === void 0 ? void 0 : _a.map(type => (type.startsWith(".") ? type : `.${type}`)).join(","), onChange: __classPrivateFieldGet(this, _FileUploader_handleFileInput, "f"), ref: el => (__classPrivateFieldSet(this, _FileUploader_fileInputEl, el, "f")), "aria-hidden": "true", tabIndex: -1, style: { display: "none" } }), h("div", { class: "file-uploader-dialog" }, h("div", { class: "dialog-content" }, this.isDragging || this.fileStates.size === 0 ? (h("div", { class: {
328
+ "file-uploader__drop-zone": true,
329
+ "file-uploader__drop-zone--dragging": this.isDragging
330
+ }, onDragEnter: __classPrivateFieldGet(this, _FileUploader_handleDragEnter, "f"), onDragLeave: __classPrivateFieldGet(this, _FileUploader_handleDragLeave, "f"), onDragOver: __classPrivateFieldGet(this, _FileUploader_handleDragOver, "f"), onDrop: __classPrivateFieldGet(this, _FileUploader_handleDrop, "f") }, h("button", { class: "button-tertiary button-icon-and-text", type: "button", onClick: __classPrivateFieldGet(this, _FileUploader_handleFileSelect, "f") }, h("ch-image", { class: "icon-md", src: PLUS_ICON }), h("label", { class: "label" }, this.multiple
331
+ ? (_b = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _b === void 0 ? void 0 : _b.header.uploadButtonMultiple
332
+ : (_c = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _c === void 0 ? void 0 : _c.header.uploadButtonSingle)), h("div", { class: "text-container" }, h("div", { class: "label-primary-row" }, h("label", { class: "label" }, this.label || ((_d = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _d === void 0 ? void 0 : _d.header.orText)), h("label", { class: "label" }, (_e = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _e === void 0 ? void 0 : _e.header.dragAndDrop)), h("span", { class: "caption" }, this.types && this.types.length > 0
333
+ ? (_f = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _f === void 0 ? void 0 : _f.header.acceptedFiles.replace("{0}", this.types.join(", "))
334
+ : (_g = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _g === void 0 ? void 0 : _g.header.allFilesAccepted)))) : (h("div", { class: "file-uploader__list" }, h("div", { class: "file-uploader__list-header spacing-body-block-end" }, h("div", { class: "file-uploader__list-title-container" }, h("label", { class: "label" }, this.label ||
335
+ ((_h = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _h === void 0 ? void 0 : _h.fileList.attachedFiles)), h("span", { class: "caption" }, (_j = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _j === void 0 ? void 0 : _j.fileList.filesCount.replace("{0}", this.fileStates.size.toString()))), this.multiple && (h("button", { class: "button-tertiary button-icon-and-text", type: "button", onClick: __classPrivateFieldGet(this, _FileUploader_handleFileSelect, "f") }, h("ch-image", { class: "icon-md", src: PLUS_ICON }), h("label", { class: "label" }, this.multiple
336
+ ? (_k = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _k === void 0 ? void 0 : _k.header.uploadButtonMultiple
337
+ : (_l = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _l === void 0 ? void 0 : _l.header.uploadButtonSingle)))), h("div", { class: "file-uploader__list-content scrollable" }, Array.from(this.fileStates.values()).map(file => (h("gx-ide-file-item", { key: file.id, file: file, editable: this.canEditName, onFileNameChange: __classPrivateFieldGet(this, _FileUploader_handleNameChange, "f"), onFileDelete: __classPrivateFieldGet(this, _FileUploader_handleFileCancel, "f"), onFileCancel: __classPrivateFieldGet(this, _FileUploader_handleFileCancel, "f") }))))))), h("div", { class: "dialog-footer control-footer control-footer-with-border" }, h("div", { class: "buttons-spacer" }, h("button", { class: "button-secondary", type: "button", onClick: __classPrivateFieldGet(this, _FileUploader_handleCancel, "f") }, (_m = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _m === void 0 ? void 0 : _m.buttons.cancel), h("button", { class: "button-primary", type: "button", onClick: __classPrivateFieldGet(this, _FileUploader_handleConfirm, "f"), disabled: this.fileStates.size === 0 ||
338
+ Array.from(this.fileStates.values()).some(file => file.pending) }, (_o = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _o === void 0 ? void 0 : _o.buttons.confirm))))));
339
+ }
340
+ static get is() { return "gx-ide-file-uploader"; }
341
+ static get encapsulation() { return "shadow"; }
342
+ static get originalStyleUrls() {
343
+ return {
344
+ "$": ["file-uploader.scss"]
345
+ };
346
+ }
347
+ static get styleUrls() {
348
+ return {
349
+ "$": ["file-uploader.css"]
350
+ };
351
+ }
352
+ static get assetsDirs() { return ["gx-ide-assets/file-uploader"]; }
353
+ static get properties() {
354
+ return {
355
+ "types": {
356
+ "type": "unknown",
357
+ "mutable": false,
358
+ "complexType": {
359
+ "original": "string[]",
360
+ "resolved": "string[]",
361
+ "references": {}
362
+ },
363
+ "required": false,
364
+ "optional": true,
365
+ "docs": {
366
+ "tags": [],
367
+ "text": "Allowed file types/extensions (e.g. ['.jpg', '.png', 'image/*', 'application/pdf'])"
368
+ },
369
+ "defaultValue": "[]"
370
+ },
371
+ "multiple": {
372
+ "type": "boolean",
373
+ "mutable": false,
374
+ "complexType": {
375
+ "original": "boolean",
376
+ "resolved": "boolean",
377
+ "references": {}
378
+ },
379
+ "required": false,
380
+ "optional": false,
381
+ "docs": {
382
+ "tags": [],
383
+ "text": "Whether multiple files can be selected"
384
+ },
385
+ "attribute": "multiple",
386
+ "reflect": false,
387
+ "defaultValue": "false"
388
+ },
389
+ "canEditName": {
390
+ "type": "boolean",
391
+ "mutable": false,
392
+ "complexType": {
393
+ "original": "boolean",
394
+ "resolved": "boolean",
395
+ "references": {}
396
+ },
397
+ "required": false,
398
+ "optional": false,
399
+ "docs": {
400
+ "tags": [],
401
+ "text": "Whether file names can be edited"
402
+ },
403
+ "attribute": "can-edit-name",
404
+ "reflect": false,
405
+ "defaultValue": "false"
406
+ },
407
+ "label": {
408
+ "type": "string",
409
+ "mutable": false,
410
+ "complexType": {
411
+ "original": "string",
412
+ "resolved": "string",
413
+ "references": {}
414
+ },
415
+ "required": false,
416
+ "optional": true,
417
+ "docs": {
418
+ "tags": [],
419
+ "text": "Label to display in the uploader dialog"
420
+ },
421
+ "attribute": "label",
422
+ "reflect": false
423
+ },
424
+ "uploadFunction": {
425
+ "type": "unknown",
426
+ "mutable": false,
427
+ "complexType": {
428
+ "original": "(\n file: File,\n progressCallback: (progress: number) => void\n ) => Promise<UploadResult>",
429
+ "resolved": "(file: File, progressCallback: (progress: number) => void) => Promise<UploadResult>",
430
+ "references": {
431
+ "File": {
432
+ "location": "global",
433
+ "id": "global::File"
434
+ },
435
+ "Promise": {
436
+ "location": "global",
437
+ "id": "global::Promise"
438
+ },
439
+ "UploadResult": {
440
+ "location": "import",
441
+ "path": "./types",
442
+ "id": "src/components/file-uploader/types.ts::UploadResult"
443
+ }
444
+ }
445
+ },
446
+ "required": true,
447
+ "optional": false,
448
+ "docs": {
449
+ "tags": [],
450
+ "text": "Function to handle file upload"
451
+ }
452
+ },
453
+ "cancelUploadFunction": {
454
+ "type": "unknown",
455
+ "mutable": false,
456
+ "complexType": {
457
+ "original": "(fileId: string) => Promise<void>",
458
+ "resolved": "(fileId: string) => Promise<void>",
459
+ "references": {
460
+ "Promise": {
461
+ "location": "global",
462
+ "id": "global::Promise"
463
+ }
464
+ }
465
+ },
466
+ "required": false,
467
+ "optional": true,
468
+ "docs": {
469
+ "tags": [],
470
+ "text": "Function to cancel file upload"
471
+ }
472
+ },
473
+ "fileUploadedCallback": {
474
+ "type": "unknown",
475
+ "mutable": false,
476
+ "complexType": {
477
+ "original": "(file: UploadedFile) => Promise<void>",
478
+ "resolved": "(file: UploadedFile) => Promise<void>",
479
+ "references": {
480
+ "UploadedFile": {
481
+ "location": "import",
482
+ "path": "./types",
483
+ "id": "src/components/file-uploader/types.ts::UploadedFile"
484
+ },
485
+ "Promise": {
486
+ "location": "global",
487
+ "id": "global::Promise"
488
+ }
489
+ }
490
+ },
491
+ "required": false,
492
+ "optional": true,
493
+ "docs": {
494
+ "tags": [],
495
+ "text": "Callback when a file is uploaded successfully"
496
+ }
497
+ },
498
+ "dialogCanceledCallback": {
499
+ "type": "unknown",
500
+ "mutable": false,
501
+ "complexType": {
502
+ "original": "() => Promise<void>",
503
+ "resolved": "() => Promise<void>",
504
+ "references": {
505
+ "Promise": {
506
+ "location": "global",
507
+ "id": "global::Promise"
508
+ }
509
+ }
510
+ },
511
+ "required": false,
512
+ "optional": true,
513
+ "docs": {
514
+ "tags": [],
515
+ "text": "Callback when the dialog is canceled"
516
+ }
517
+ },
518
+ "dialogConfirmedCallback": {
519
+ "type": "unknown",
520
+ "mutable": false,
521
+ "complexType": {
522
+ "original": "(\n files: UploadedFile[]\n ) => Promise<void>",
523
+ "resolved": "(files: UploadedFile[]) => Promise<void>",
524
+ "references": {
525
+ "UploadedFile": {
526
+ "location": "import",
527
+ "path": "./types",
528
+ "id": "src/components/file-uploader/types.ts::UploadedFile"
529
+ },
530
+ "Promise": {
531
+ "location": "global",
532
+ "id": "global::Promise"
533
+ }
534
+ }
535
+ },
536
+ "required": false,
537
+ "optional": true,
538
+ "docs": {
539
+ "tags": [],
540
+ "text": "Callback when the dialog is confirmed with files"
541
+ }
542
+ },
543
+ "uploadCancelledCallback": {
544
+ "type": "unknown",
545
+ "mutable": false,
546
+ "complexType": {
547
+ "original": "(fileId: string) => Promise<void>",
548
+ "resolved": "(fileId: string) => Promise<void>",
549
+ "references": {
550
+ "Promise": {
551
+ "location": "global",
552
+ "id": "global::Promise"
553
+ }
554
+ }
555
+ },
556
+ "required": false,
557
+ "optional": true,
558
+ "docs": {
559
+ "tags": [],
560
+ "text": "Callback when upload is cancelled"
561
+ }
562
+ },
563
+ "fileRenamedCallback": {
564
+ "type": "unknown",
565
+ "mutable": false,
566
+ "complexType": {
567
+ "original": "(data: {\n fileId: string;\n newName: string;\n }) => Promise<void>",
568
+ "resolved": "(data: { fileId: string; newName: string; }) => Promise<void>",
569
+ "references": {
570
+ "Promise": {
571
+ "location": "global",
572
+ "id": "global::Promise"
573
+ }
574
+ }
575
+ },
576
+ "required": false,
577
+ "optional": true,
578
+ "docs": {
579
+ "tags": [],
580
+ "text": "Callback when file is renamed"
581
+ }
582
+ },
583
+ "fileValidationErrorCallback": {
584
+ "type": "unknown",
585
+ "mutable": false,
586
+ "complexType": {
587
+ "original": "(data: {\n fileName: string;\n error: string;\n }) => Promise<void>",
588
+ "resolved": "(data: { fileName: string; error: string; }) => Promise<void>",
589
+ "references": {
590
+ "Promise": {
591
+ "location": "global",
592
+ "id": "global::Promise"
593
+ }
594
+ }
595
+ },
596
+ "required": false,
597
+ "optional": true,
598
+ "docs": {
599
+ "tags": [],
600
+ "text": "Callback when a file validation error occurs"
601
+ }
602
+ },
603
+ "fileDeletionErrorCallback": {
604
+ "type": "unknown",
605
+ "mutable": false,
606
+ "complexType": {
607
+ "original": "(data: {\n fileName: string;\n error: string;\n }) => Promise<void>",
608
+ "resolved": "(data: { fileName: string; error: string; }) => Promise<void>",
609
+ "references": {
610
+ "Promise": {
611
+ "location": "global",
612
+ "id": "global::Promise"
613
+ }
614
+ }
615
+ },
616
+ "required": false,
617
+ "optional": true,
618
+ "docs": {
619
+ "tags": [],
620
+ "text": "Callback when a file deletion error occurs"
621
+ }
622
+ },
623
+ "fileDeletedCallback": {
624
+ "type": "unknown",
625
+ "mutable": false,
626
+ "complexType": {
627
+ "original": "(file: UploadedFile) => Promise<void>",
628
+ "resolved": "(file: UploadedFile) => Promise<void>",
629
+ "references": {
630
+ "UploadedFile": {
631
+ "location": "import",
632
+ "path": "./types",
633
+ "id": "src/components/file-uploader/types.ts::UploadedFile"
634
+ },
635
+ "Promise": {
636
+ "location": "global",
637
+ "id": "global::Promise"
638
+ }
639
+ }
640
+ },
641
+ "required": false,
642
+ "optional": true,
643
+ "docs": {
644
+ "tags": [],
645
+ "text": "Callback when a file is deleted"
646
+ }
647
+ },
648
+ "onBeforeDelete": {
649
+ "type": "unknown",
650
+ "mutable": false,
651
+ "complexType": {
652
+ "original": "(file: UploadedFile) => Promise<boolean>",
653
+ "resolved": "(file: UploadedFile) => Promise<boolean>",
654
+ "references": {
655
+ "UploadedFile": {
656
+ "location": "import",
657
+ "path": "./types",
658
+ "id": "src/components/file-uploader/types.ts::UploadedFile"
659
+ },
660
+ "Promise": {
661
+ "location": "global",
662
+ "id": "global::Promise"
663
+ }
664
+ }
665
+ },
666
+ "required": false,
667
+ "optional": true,
668
+ "docs": {
669
+ "tags": [],
670
+ "text": "Callback before deleting a file to get confirmation"
671
+ }
672
+ }
673
+ };
674
+ }
675
+ static get states() {
676
+ return {
677
+ "fileStates": {},
678
+ "isDragging": {}
679
+ };
680
+ }
681
+ static get methods() {
682
+ return {
683
+ "clear": {
684
+ "complexType": {
685
+ "signature": "() => Promise<void>",
686
+ "parameters": [],
687
+ "references": {
688
+ "Promise": {
689
+ "location": "global",
690
+ "id": "global::Promise"
691
+ }
692
+ },
693
+ "return": "Promise<void>"
694
+ },
695
+ "docs": {
696
+ "text": "Clears the current file selection",
697
+ "tags": []
698
+ }
699
+ }
700
+ };
701
+ }
702
+ static get elementRef() { return "el"; }
703
+ }
704
+ _FileUploader__componentLocale = new WeakMap(), _FileUploader_fileInputEl = new WeakMap(), _FileUploader_dragCounter = new WeakMap(), _FileUploader_generateId = new WeakMap(), _FileUploader_handleDragEnter = new WeakMap(), _FileUploader_handleDragLeave = new WeakMap(), _FileUploader_handleDragOver = new WeakMap(), _FileUploader_handleDrop = new WeakMap(), _FileUploader_handleFileSelect = new WeakMap(), _FileUploader_handleFileInput = new WeakMap(), _FileUploader_handleFiles = new WeakMap(), _FileUploader_handleNameChange = new WeakMap(), _FileUploader_handleFileCancel = new WeakMap(), _FileUploader_handleConfirm = new WeakMap(), _FileUploader_handleCancel = new WeakMap(), _FileUploader_instances = new WeakSet(), _FileUploader_isValidFile = function _FileUploader_isValidFile(file) {
705
+ var _a, _b;
706
+ // If no types specified, accept any file
707
+ if (!this.types || this.types.length === 0) {
708
+ return { isValid: true };
709
+ }
710
+ for (const type of this.types) {
711
+ // Handle wildcards like 'image/*'
712
+ if (type.includes("/*")) {
713
+ const baseType = type.split("/")[0];
714
+ if (file.type.startsWith(baseType)) {
715
+ return { isValid: true };
716
+ }
717
+ }
718
+ // Handle extensions like '.jpg'
719
+ else if (type.startsWith(".")) {
720
+ if (file.name.toLowerCase().endsWith(type.toLowerCase())) {
721
+ return { isValid: true };
722
+ }
723
+ }
724
+ // Handle specific MIME types
725
+ else if (file.type === type || file.type === `application/${type}`) {
726
+ return { isValid: true };
727
+ }
728
+ }
729
+ return {
730
+ isValid: false,
731
+ error: ((_b = (_a = __classPrivateFieldGet(this, _FileUploader__componentLocale, "f")) === null || _a === void 0 ? void 0 : _a.errors) === null || _b === void 0 ? void 0 : _b.invalidFileType) || "Invalid file type"
732
+ };
733
+ }, _FileUploader_getValidFiles = function _FileUploader_getValidFiles(files) {
734
+ const validFiles = [];
735
+ Array.from(files).forEach(file => {
736
+ var _a;
737
+ const validation = __classPrivateFieldGet(this, _FileUploader_instances, "m", _FileUploader_isValidFile).call(this, file);
738
+ if (validation.isValid) {
739
+ validFiles.push(file);
740
+ }
741
+ else {
742
+ (_a = this.fileValidationErrorCallback) === null || _a === void 0 ? void 0 : _a.call(this, {
743
+ fileName: file.name,
744
+ error: validation.error
745
+ });
746
+ }
747
+ });
748
+ return validFiles;
749
+ };
750
+ //# sourceMappingURL=file-uploader.js.map