wj-elements 0.3.6 → 0.3.7
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/localize.js
CHANGED
|
@@ -34,11 +34,26 @@ class LocalizerDefault {
|
|
|
34
34
|
if (!langMap) return key;
|
|
35
35
|
return langMap ? langMap[key] || key : key;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Translates a key and interpolates placeholders in the format {placeholder}.
|
|
39
|
+
* Missing params are kept as-is so untranslated placeholders stay visible.
|
|
40
|
+
* @param {string} key The translation key.
|
|
41
|
+
* @param {object} [params] Key-value map used for interpolation. Defaults to an empty object.
|
|
42
|
+
* @returns {string} Localized string with interpolated params.
|
|
43
|
+
*/
|
|
44
|
+
translateWithParams(key, params = {}) {
|
|
45
|
+
const translated = this.translate(key);
|
|
46
|
+
if (typeof translated !== "string") return translated;
|
|
47
|
+
return translated.replace(/\{([^{}]+)\}/g, (match, token) => {
|
|
48
|
+
const value = params[token.trim()];
|
|
49
|
+
return value === void 0 || value === null ? match : String(value);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
37
52
|
/**
|
|
38
53
|
* Translates a key into a localized string based on the provided count and pluralization type.
|
|
39
54
|
* @param {string} key The base translation key to be used for fetching the localized string.
|
|
40
|
-
* @param {number} [count
|
|
41
|
-
* @param {string} [type
|
|
55
|
+
* @param {number} [count] The count value used to determine the pluralization form. Defaults to 0.
|
|
56
|
+
* @param {string} [type] The type of pluralization to use, such as 'cardinal' or 'ordinal'. Defaults to 'cardinal'.
|
|
42
57
|
* @returns {string} The translated string, adapted to the pluralization rules and count.
|
|
43
58
|
*/
|
|
44
59
|
translatePlural(key, count = 0, type = "cardinal") {
|
package/dist/localize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localize.js","sources":["../packages/localize/localize.js","../packages/utils/localize.js"],"sourcesContent":["// export const translations = new Map();\n\nexport class LocalizerDefault {\n constructor(element) {\n this.element = element;\n\n this.lang = this.element?.lang || document.documentElement?.lang || 'en-GB';\n this.dir = this.element?.dir || document.documentElement?.dir || 'ltr';\n this.currentLang = 'en-GB';\n\n this.setLanguage();\n }\n\n get languages() {\n return window.translations;\n }\n\n // Nastavenie aktuálneho jazyka\n setLanguage() {\n if (this.languages?.has(this.lang)) {\n this.currentLang = this.lang;\n } else {\n console.error(`Language \"${this.lang}\" not loaded.`);\n }\n }\n\n convertLangCode = (lang) => lang.replace(\"-\", \"_\").replace(/_([a-z]{2})$/, (_, code) => `_${code.toUpperCase()}`);\n\n /**\n * Translates a given translation key based on the currently selected language.\n * @param {string} key The key representing the text to be translated.\n * @returns {string} The translated text if available; otherwise, returns the original key.\n */\n translate(key) {\n const langMap = this.languages?.get(this.currentLang);\n if (!langMap) return key;\n return langMap ? langMap[key] || key : key;\n }\n\n /**\n * Translates a key into a localized string based on the provided count and pluralization type.\n * @param {string} key The base translation key to be used for fetching the localized string.\n * @param {number} [count
|
|
1
|
+
{"version":3,"file":"localize.js","sources":["../packages/localize/localize.js","../packages/utils/localize.js"],"sourcesContent":["// export const translations = new Map();\n\nexport class LocalizerDefault {\n constructor(element) {\n this.element = element;\n\n this.lang = this.element?.lang || document.documentElement?.lang || 'en-GB';\n this.dir = this.element?.dir || document.documentElement?.dir || 'ltr';\n this.currentLang = 'en-GB';\n\n this.setLanguage();\n }\n\n get languages() {\n return window.translations;\n }\n\n // Nastavenie aktuálneho jazyka\n setLanguage() {\n if (this.languages?.has(this.lang)) {\n this.currentLang = this.lang;\n } else {\n console.error(`Language \"${this.lang}\" not loaded.`);\n }\n }\n\n convertLangCode = (lang) => lang.replace(\"-\", \"_\").replace(/_([a-z]{2})$/, (_, code) => `_${code.toUpperCase()}`);\n\n /**\n * Translates a given translation key based on the currently selected language.\n * @param {string} key The key representing the text to be translated.\n * @returns {string} The translated text if available; otherwise, returns the original key.\n */\n translate(key) {\n const langMap = this.languages?.get(this.currentLang);\n if (!langMap) return key;\n return langMap ? langMap[key] || key : key;\n }\n\n /**\n * Translates a key and interpolates placeholders in the format {placeholder}.\n * Missing params are kept as-is so untranslated placeholders stay visible.\n * @param {string} key The translation key.\n * @param {object} [params] Key-value map used for interpolation. Defaults to an empty object.\n * @returns {string} Localized string with interpolated params.\n */\n translateWithParams(key, params = {}) {\n const translated = this.translate(key);\n\n if (typeof translated !== 'string') return translated;\n\n return translated.replace(/\\{([^{}]+)\\}/g, (match, token) => {\n const value = params[token.trim()];\n return value === undefined || value === null ? match : String(value);\n });\n }\n\n /**\n * Translates a key into a localized string based on the provided count and pluralization type.\n * @param {string} key The base translation key to be used for fetching the localized string.\n * @param {number} [count] The count value used to determine the pluralization form. Defaults to 0.\n * @param {string} [type] The type of pluralization to use, such as 'cardinal' or 'ordinal'. Defaults to 'cardinal'.\n * @returns {string} The translated string, adapted to the pluralization rules and count.\n */\n translatePlural(key, count = 0, type = 'cardinal') {\n const plural = new Intl.PluralRules(this.currentLang, { type });\n const k = `${key}.${plural.select(count)}`;\n const t = this.translate(k);\n if (t !== k) return t;\n return this.translate(`${key}.other`);\n }\n\n /**\n * Formats a number according to the specified locale and formatting options.\n * @param {number} number The numeric value to format.\n * @param {object} options An object containing formatting options for the number.\n * @returns {string} The formatted number as a string.\n */\n formatNumber(number, options) {\n return new Intl.NumberFormat(this.currentLang, options).format(number);\n }\n\n /**\n * Formats a given date based on the specified options and the current language setting.\n * @param {string|Date|number} date The date to format. Can be a Date object, a timestamp, or a date string.\n * @param {object} options The formatting options to customize the output, as supported by Intl.DateTimeFormat.\n * @returns {string} The formatted date string based on the specified options and current language.\n */\n formatDate(date, options) {\n return new Intl.DateTimeFormat(this.currentLang, options).format(new Date(date));\n }\n\n /**\n * Formats a relative time string based on a given language, value, unit, and formatting options.\n * @param {string} lang The language to use for formatting. Defaults to `this.currentLang` if not provided.\n * @param {number} value The numerical value to format, representing the time difference.\n * @param {string} [unit] The unit of time to use (e.g., \"second\", \"minute\", \"hour\", \"day\", \"week\", \"month\", \"year\").\n * @param {object} [options] An object containing formatting options, such as the style for the numeric representation.\n * @returns {string} The formatted relative time string in the specified language.\n */\n relativeTime(lang, value = 0, unit = 'day', options = { numeric: 'auto' }) {\n lang = lang || this.currentLang;\n return new Intl.RelativeTimeFormat(lang, options).format(value, unit);\n }\n}\n\nexport function registerTranslation(...translation) {\n translation.forEach((t) => {\n if (!t.code) {\n console.error(\"Translation object is missing 'code' property:\", t);\n return;\n }\n\n const code = t.code.toLowerCase();\n if (window.translations.has(code)) {\n window.translations.set(code, { ...window.translations.get(code), ...t });\n } else {\n window.translations.set(code, t);\n }\n });\n}\n","import { LocalizerDefault, registerTranslation } from '../localize/localize.js';\n\nexport class Localizer extends LocalizerDefault {\n constructor(element) {\n super(element);\n }\n static registerTranslation(...translation) {\n registerTranslation(...translation);\n }\n}\n"],"names":[],"mappings":";;;AAEO,MAAM,iBAAiB;AAAA,EAC1B,YAAY,SAAS;AAuBrB,2CAAkB,CAAC,SAAS,KAAK,QAAQ,KAAK,GAAG,EAAE,QAAQ,gBAAgB,CAAC,GAAG,SAAS,IAAI,KAAK,YAAW,CAAE,EAAE;AA1BpH;AAIQ,SAAK,UAAU;AAEf,SAAK,SAAO,UAAK,YAAL,mBAAc,WAAQ,cAAS,oBAAT,mBAA0B,SAAQ;AACpE,SAAK,QAAM,UAAK,YAAL,mBAAc,UAAO,cAAS,oBAAT,mBAA0B,QAAO;AACjE,SAAK,cAAc;AAEnB,SAAK,YAAW;AAAA,EACpB;AAAA,EAEA,IAAI,YAAY;AACZ,WAAO,OAAO;AAAA,EAClB;AAAA;AAAA,EAGA,cAAc;AAlBlB;AAmBQ,SAAI,UAAK,cAAL,mBAAgB,IAAI,KAAK,OAAO;AAChC,WAAK,cAAc,KAAK;AAAA,IAC5B,OAAO;AACH,cAAQ,MAAM,aAAa,KAAK,IAAI,eAAe;AAAA,IACvD;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,UAAU,KAAK;AAjCnB;AAkCQ,UAAM,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WAAO,QAAQ,KAAK;AACpB,WAAO,IAAI,KAAK,mBAAmB,MAAM,OAAO,EAAE,OAAO,OAAO,IAAI;AAAA,EACxE;AACJ;AAEO,SAAS,uBAAuB,aAAa;AAChD,cAAY,QAAQ,CAAC,MAAM;AACvB,QAAI,CAAC,EAAE,MAAM;AACT,cAAQ,MAAM,kDAAkD,CAAC;AACjE;AAAA,IACJ;AAEA,UAAM,OAAO,EAAE,KAAK,YAAW;AAC/B,QAAI,OAAO,aAAa,IAAI,IAAI,GAAG;AAC/B,aAAO,aAAa,IAAI,MAAM,EAAE,GAAG,OAAO,aAAa,IAAI,IAAI,GAAG,GAAG,EAAC,CAAE;AAAA,IAC5E,OAAO;AACH,aAAO,aAAa,IAAI,MAAM,CAAC;AAAA,IACnC;AAAA,EACJ,CAAC;AACL;ACtHO,MAAM,kBAAkB,iBAAiB;AAAA,EAC5C,YAAY,SAAS;AACjB,UAAM,OAAO;AAAA,EACjB;AAAA,EACA,OAAO,uBAAuB,aAAa;AACvC,wBAAoB,GAAG,WAAW;AAAA,EACtC;AACJ;"}
|
|
@@ -14,11 +14,19 @@ export class LocalizerDefault {
|
|
|
14
14
|
* @returns {string} The translated text if available; otherwise, returns the original key.
|
|
15
15
|
*/
|
|
16
16
|
translate(key: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Translates a key and interpolates placeholders in the format {placeholder}.
|
|
19
|
+
* Missing params are kept as-is so untranslated placeholders stay visible.
|
|
20
|
+
* @param {string} key The translation key.
|
|
21
|
+
* @param {object} [params] Key-value map used for interpolation. Defaults to an empty object.
|
|
22
|
+
* @returns {string} Localized string with interpolated params.
|
|
23
|
+
*/
|
|
24
|
+
translateWithParams(key: string, params?: object): string;
|
|
17
25
|
/**
|
|
18
26
|
* Translates a key into a localized string based on the provided count and pluralization type.
|
|
19
27
|
* @param {string} key The base translation key to be used for fetching the localized string.
|
|
20
|
-
* @param {number} [count
|
|
21
|
-
* @param {string} [type
|
|
28
|
+
* @param {number} [count] The count value used to determine the pluralization form. Defaults to 0.
|
|
29
|
+
* @param {string} [type] The type of pluralization to use, such as 'cardinal' or 'ordinal'. Defaults to 'cardinal'.
|
|
22
30
|
* @returns {string} The translated string, adapted to the pluralization rules and count.
|
|
23
31
|
*/
|
|
24
32
|
translatePlural(key: string, count?: number, type?: string): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Retrieves the icon name for a given file type.
|
|
3
|
-
* @param {string} type The file
|
|
3
|
+
* @param {string} type The file extension, MIME subtype or category (e.g., "pdf", "vnd.ms-excel", "folder").
|
|
4
4
|
* @returns {string} The name of the icon associated with the file type.
|
|
5
5
|
* @example
|
|
6
6
|
* getFileTypeIcon('pdf'); // Returns the icon name for PDF files.
|
package/dist/wje-file-upload.js
CHANGED
|
@@ -37,11 +37,31 @@ function fileType() {
|
|
|
37
37
|
name: "file-type-txt"
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
|
-
type: [
|
|
40
|
+
type: [
|
|
41
|
+
"doc",
|
|
42
|
+
"docx",
|
|
43
|
+
"msword",
|
|
44
|
+
"vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
45
|
+
"vnd.ms-word.document.macroenabled.12",
|
|
46
|
+
"vnd.openxmlformats-officedocument.wordprocessingml.template",
|
|
47
|
+
"vnd.ms-word.template.macroenabled.12",
|
|
48
|
+
"vnd.oasis.opendocument.text"
|
|
49
|
+
],
|
|
41
50
|
name: "file-type-doc"
|
|
42
51
|
},
|
|
43
52
|
{
|
|
44
|
-
type: [
|
|
53
|
+
type: [
|
|
54
|
+
"xls",
|
|
55
|
+
"xlsx",
|
|
56
|
+
"vnd.ms-excel",
|
|
57
|
+
"vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
58
|
+
"vnd.ms-excel.sheet.macroenabled.12",
|
|
59
|
+
"vnd.openxmlformats-officedocument.spreadsheetml.template",
|
|
60
|
+
"vnd.ms-excel.template.macroenabled.12",
|
|
61
|
+
"vnd.ms-excel.addin.macroenabled.12",
|
|
62
|
+
"vnd.ms-excel.sheet.binary.macroenabled.12",
|
|
63
|
+
"vnd.oasis.opendocument.spreadsheet"
|
|
64
|
+
],
|
|
45
65
|
name: "file-type-xls"
|
|
46
66
|
},
|
|
47
67
|
{
|
|
@@ -49,13 +69,28 @@ function fileType() {
|
|
|
49
69
|
name: "file-type-pdf"
|
|
50
70
|
},
|
|
51
71
|
{
|
|
52
|
-
type: [
|
|
72
|
+
type: [
|
|
73
|
+
"ppt",
|
|
74
|
+
"pptx",
|
|
75
|
+
"odp",
|
|
76
|
+
"vnd.ms-powerpoint",
|
|
77
|
+
"vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
78
|
+
"vnd.ms-powerpoint.presentation.macroenabled.12",
|
|
79
|
+
"vnd.openxmlformats-officedocument.presentationml.slideshow",
|
|
80
|
+
"vnd.ms-powerpoint.slideshow.macroenabled.12",
|
|
81
|
+
"vnd.openxmlformats-officedocument.presentationml.template",
|
|
82
|
+
"vnd.ms-powerpoint.template.macroenabled.12",
|
|
83
|
+
"vnd.oasis.opendocument.presentation"
|
|
84
|
+
],
|
|
53
85
|
name: "file-type-ppt"
|
|
54
86
|
}
|
|
55
87
|
];
|
|
56
88
|
}
|
|
57
89
|
function getFileTypeIcon(type) {
|
|
58
90
|
let searchType;
|
|
91
|
+
if (!type) {
|
|
92
|
+
return searchType;
|
|
93
|
+
}
|
|
59
94
|
if (type.toLowerCase() !== "folder") {
|
|
60
95
|
fileType().forEach((i) => {
|
|
61
96
|
if (i.type.includes(type.toLowerCase())) {
|
|
@@ -547,11 +582,13 @@ class FileUpload extends WJElement {
|
|
|
547
582
|
*/
|
|
548
583
|
createPreview(file, reader) {
|
|
549
584
|
let preview = document.createElement("wje-file-upload-item");
|
|
585
|
+
let fileType2 = file.type ? file.type.split("/")[1] : file.name.split(".").pop();
|
|
586
|
+
let icon = getFileTypeIcon(fileType2) || "file";
|
|
550
587
|
preview.setAttribute("slot", "item");
|
|
551
588
|
preview.setAttribute("name", file.name);
|
|
552
589
|
preview.setAttribute("size", file.size);
|
|
553
590
|
preview.setAttribute("uploaded", "0");
|
|
554
|
-
preview.innerHTML = `<wje-icon slot="img" name="${
|
|
591
|
+
preview.innerHTML = `<wje-icon slot="img" name="${icon}" size="large"></wje-icon>`;
|
|
555
592
|
preview.data = file;
|
|
556
593
|
return preview;
|
|
557
594
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-file-upload.js","sources":["../packages/wje-file-upload/service/service.js","../packages/wje-file-upload/file-upload.element.js","../packages/wje-file-upload/file-upload.js"],"sourcesContent":["/**\n * Returns a list of file type categories and their corresponding icon names.\n * @returns {Array<object>} An array of objects representing file type categories.\n * Each object contains the following properties:\n * - `type` {Array<string>} A list of file extensions associated with the category.\n * - `name` {string} The name of the icon representing the category.\n * @example\n * const types = fileType();\n * console.log(types);\n * // [\n * // { type: [\"jpg\", \"jpeg\", \"png\", \"gif\", \"bpm\", \"tiff\", \"svg\"], name: \"photo\" },\n * // { type: [\"zip\", \"rar\", \"cab\", \"jar\", \"tar\", \"gzip\", \"uue\", \"bz2\", \"scorm\", \"war\"], name: \"file-type-zip\" },\n * // ...\n * // ]\n */\nfunction fileType() {\n return [\n {\n type: ['jpg', 'jpeg', 'png', 'gif', 'bpm', 'tiff', 'svg'],\n name: 'photo',\n },\n {\n type: ['zip', 'rar', 'cab', 'jar', 'tar', 'gzip', 'uue', 'bz2', 'scorm', 'war'],\n name: 'file-type-zip',\n },\n {\n type: ['mov', 'mp4', 'avi', 'flv'],\n name: 'video',\n },\n {\n type: ['m4a', 'mp3', 'wav'],\n name: 'audio',\n },\n {\n type: ['html', 'html'],\n name: 'file-type-html',\n },\n {\n type: ['css'],\n name: 'code',\n },\n {\n type: ['txt'],\n name: 'file-type-txt',\n },\n {\n type: ['doc', 'docx'],\n name: 'file-type-doc',\n },\n {\n type: ['xls', 'xlsx'],\n name: 'file-type-xls',\n },\n {\n type: ['pdf'],\n name: 'file-type-pdf',\n },\n {\n type: ['ppt', 'pptx', 'odp'],\n name: 'file-type-ppt',\n },\n ];\n}\n\n/**\n * Retrieves the icon name for a given file type.\n * @param {string} type The file type or category (e.g., \"pdf\", \"image\", \"folder\").\n * @returns {string} The name of the icon associated with the file type.\n * @example\n * getFileTypeIcon('pdf'); // Returns the icon name for PDF files.\n * getFileTypeIcon('folder'); // Returns 'folder'.\n */\nexport function getFileTypeIcon(type) {\n let searchType;\n if (type.toLowerCase() !== 'folder') {\n fileType().forEach((i) => {\n if (i.type.includes(type.toLowerCase())) {\n searchType = i.name;\n }\n });\n } else {\n searchType = 'folder';\n }\n\n return searchType;\n}\n\n/**\n * Returns a function for uploading files either in chunks or as a whole file, based on the provided options.\n * @param {string} url The URL to which the file will be uploaded.\n * @param {number} [chunkSize] The size of each chunk in bytes when uploading in chunks (default is 1MB).\n * @param {boolean} [wholeFile] Whether to upload the file as a whole. If `true`, the entire file is uploaded at once.\n * @returns {Function} A function that takes a file and a preview element as arguments and uploads the file.\n * @example\n * // Upload a file in chunks\n * const uploadInChunks = upload('/upload', 1024 * 512); // 512KB chunks\n * uploadInChunks(file, previewElement);\n * @example\n * // Upload a whole file\n * const uploadWhole = upload('/upload', undefined, true);\n * uploadWhole(file, previewElement);\n */\nexport function upload(url, chunkSize = 1024 * 1024, wholeFile = false) {\n if (wholeFile) {\n return (file, preview) => uploadWholeFile(url, file, preview);\n }\n return (file, preview) => uploadFileInChunks(url, file, preview, chunkSize);\n}\n\n/**\n * Uploads a file in chunks to a specified URL, allowing for progress tracking and resuming in case of errors.\n * @param {string} url The URL to which the file chunks will be uploaded.\n * @param {File} file The file to be uploaded in chunks.\n * @param {HTMLElement} preview The element used to display upload progress.\n * @param {number} [chunkSize] The size of each chunk in bytes (default is 1MB).\n * @returns {Promise<object>} Resolves with the response of the last chunk uploaded, parsed as JSON.\n * @throws {Error} - Throws an error if a chunk fails to upload.\n */\nexport async function uploadFileInChunks(url, file, preview, chunkSize = 1024 * 1024) {\n let offset = 0;\n const totalChunks = Math.ceil(file.size / chunkSize);\n const partResponses = [];\n\n while (offset < file.size) {\n const chunk = file.slice(offset, offset + chunkSize);\n\n // Creating a custom ReadableStream to track progress of the current chunk\n const stream = new ReadableStream({\n start(controller) {\n const reader = chunk.stream().getReader();\n let uploadedBytes = 0;\n\n reader.read().then(function process({ done, value }) {\n if (done) {\n controller.close();\n return Promise.resolve();\n }\n\n // Track progress\n uploadedBytes += value.byteLength;\n const percentComplete = ((offset + uploadedBytes) / file.size) * 100;\n preview.setAttribute('uploaded', offset + uploadedBytes);\n\n // Enqueue chunk data into the stream\n controller.enqueue(value);\n\n // Read the next chunk\n return reader.read().then(process);\n });\n },\n });\n\n const formData = new FormData();\n formData.append('file', new Blob([stream])); // Send the current stream (chunk)\n formData.append('chunkIndex', Math.floor(offset / chunkSize)); // Send chunk index\n formData.append('totalChunks', totalChunks); // Send total chunks\n formData.append('fileName', file.name); // Send file name\n\n try {\n // Send the current chunk via Fetch\n const response = await fetch(url, {\n method: 'POST',\n body: formData,\n });\n\n if (!response.ok) {\n throw new Error(`Failed to upload chunk ${Math.floor(offset / chunkSize) + 1}: ${response.statusText}`);\n }\n\n partResponses.push(response);\n } catch (error) {\n console.error('Error uploading chunk:', error);\n break;\n }\n\n // Move to the next chunk\n offset += chunkSize;\n }\n\n const response = await partResponses.at(-1).json();\n\n return {\n data: response,\n file,\n };\n}\n\n/**\n * Uploads a file to a specified URL using a `POST` request and updates the preview element with the uploaded file size.\n * @param {string} url The URL to which the file will be uploaded.\n * @param {File} file The file to be uploaded.\n * @param {HTMLElement} preview The element that displays the upload preview. It will be updated with the file size.\n * @returns {Promise<{data: object, file: File}>} - A promise that resolves with the server response and the uploaded file.\n * @throws {Error} - Logs an error to the console if the request fails.\n */\nexport function uploadWholeFile(url, file, preview) {\n const formData = new FormData();\n formData.append('file', file);\n\n //use fetch\n return fetch(url, {\n method: 'POST',\n body: formData,\n })\n .then((response) => response.json())\n .then((data) => {\n preview.setAttribute('uploaded', file.size);\n return {\n data,\n file,\n };\n })\n .catch((error) => {\n console.error('Error:', error);\n });\n}\n","import { Localizer } from '../utils/localize.js';\nimport { default as WJElement, event } from '../wje-element/element.js';\nimport Button from '../wje-button/button.js';\nimport { isValidFileType } from '../utils/utils.js';\nimport { getFileTypeIcon, upload } from './service/service.js';\n\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary FileUpload is a custom web component for uploading files.\n * It extends from WJElement and provides functionalities for file upload.\n * @documentation https://elements.webjet.sk/components/file-upload\n * @status stable\n * @augments WJElement\n * @slot - This is a default/unnamed slot.\n * @csspart native - The native file upload part.\n * @csspart file-list - The file list part.\n * @csspart upload-button - The label part.\n * @event change - Fires when the file input changes.\n * @event drop - Fires when a file is dropped into the component.\n * @attribute {string} accepted-types - The accepted file types for upload.\n * @attribute {number} chunk-size - The chunk size for file upload.\n * @attribute {number} max-file-size - The maximum file size for upload.\n * @attribute {string} upload-url - The URL to set as the upload URL.\n * @attribute {boolean} auto-process-files - The auto process files attribute.\n * @attribute {boolean} no-upload-button - The no upload button attribute.\n * @tag wje-file-upload\n */\nexport default class FileUpload extends WJElement {\n /**\n * Constructor for FileUpload.\n * Initializes a new instance of the Localizer.\n */\n constructor() {\n super();\n this.localizer = new Localizer(this);\n this._uploadedFiles = [];\n this._queuedFiles = [];\n }\n\n /**\n * Dependencies for the FileUpload component.\n * @type {object}\n */\n dependencies = {\n 'wje-button': Button,\n };\n\n /**\n * Setter for acceptedTypes attribute.\n * @param {string} value The accepted file types for upload.\n */\n set acceptedTypes(value) {\n this.setAttribute('accepted-types', value);\n }\n\n /**\n * Getter for acceptedTypes attribute.\n * @returns {string} The accepted file types for upload.\n */\n get acceptedTypes() {\n const accepted = this.getAttribute('accepted-types');\n return this.hasAttribute('accepted-types') ? accepted : 'image/*';\n }\n\n /**\n * Setter for chunkSize attribute.\n * @param {number} value The chunk size for file upload.\n */\n set chunkSize(value) {\n this.setAttribute('chunk-size', value);\n }\n\n /**\n * Getter for chunkSize attribute.\n * @returns {number} The chunk size for file upload.\n */\n get chunkSize() {\n const chunk = this.getAttribute('chunk-size');\n return this.hasAttribute('chunk-size') ? chunk : 1024 * 1024;\n }\n\n /**\n * Setter for maxFileSize attribute.\n * @param {number} value The maximum file size for upload.\n */\n set maxFileSize(value) {\n this.setAttribute('max-file-size', value);\n }\n\n /**\n * Getter for maxFileSize attribute.\n * @returns {number} The maximum file size for upload.\n */\n get maxFileSize() {\n const fileSize = this.getAttribute('max-file-size');\n return this.hasAttribute('max-file-size') ? fileSize * 1024 * 1024 : 1024 * 1024;\n }\n\n /**\n * Setter for label attribute.\n * @param {string} value The URL to set as the upload URL.\n */\n set uploadUrl(value) {\n this.setAttribute('upload-url', value);\n }\n\n /**\n * Gets the upload URL for the file upload element.\n * @returns {string} The upload URL for the file upload element.\n */\n get uploadUrl() {\n return this.getAttribute('upload-url') ?? '/upload';\n }\n\n /**\n * Sets the autoProcessFiles attribute.\n * @param value\n */\n set autoProcessFiles(value) {\n this.setAttribute('auto-process-files', value);\n }\n\n /**\n * Gets the autoProcessFiles attribute.\n * @returns {any|boolean}\n */\n get autoProcessFiles() {\n return JSON.parse(this.getAttribute('auto-process-files')) ?? true;\n }\n\n /**\n * Sets the noUploadButton attribute.\n * @param value\n */\n set noUploadButton(value) {\n this.setAttribute('no-upload-button', value);\n }\n\n /**\n * Gets the noUploadButton attribute.\n * @returns {boolean}\n */\n get noUploadButton() {\n return this.hasAttribute('no-upload-button');\n }\n\n /**\n * Sets the uploaded files.\n * @param value\n */\n set uploadedFiles(value) {\n this._uploadedFiles = value;\n }\n\n /**\n * Return the uploaded files.\n * @returns {[]}\n */\n get uploadedFiles() {\n return this._uploadedFiles;\n }\n\n /**\n * Sets the to-chunk attribute.\n * @param value\n */\n set toChunk(value) {\n this.setAttribute('to-chunk', value);\n }\n\n /**\n * Gets the to-chunk attribute.\n * @returns {boolean}\n */\n get toChunk() {\n return this.hasAttribute('to-chunk');\n }\n\n /**\n * Sets the maximum number of files that can be uploaded or managed.\n * Assigns the specified value to the 'max-files' attribute.\n * @param {number} value The maximum allowable number of files.\n */\n set maxFiles(value) {\n this.setAttribute('max-files', value);\n }\n\n /**\n * Sets the label attribute for the upload button.\n * @param {string} value\n */\n set label(value) {\n this.setAttribute('label', value);\n }\n\n /**\n * Gets the label attribute for the upload button.\n * @returns {string}\n */\n get label() {\n return this.getAttribute('label') || '';\n }\n\n /**\n * Retrieves the maximum number of files allowed from the `max-files` attribute.\n * If the attribute is not set or is invalid, defaults to 0.\n * @returns {number} The maximum number of files allowed.\n */\n get maxFiles() {\n return parseInt(this.getAttribute('max-files')) || 10;\n }\n\n className = 'FileUpload';\n\n /**\n * Getter for cssStyleSheet.\n * @returns {string} The CSS styles for the component.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for observedAttributes.\n * @returns {Array} An empty array as no attributes are observed.\n */\n static get observedAttributes() {\n return ['label'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n if (name === 'label' && this.button) {\n const nextLabel = this.label || this.localizer.translate('wj.file.upload.button');\n this.button.innerText = nextLabel;\n this.button.setAttribute('aria-label', nextLabel);\n }\n }\n\n /**\n * Method to setup attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.setAriaState({\n role: 'group',\n });\n }\n\n beforeDraw() {\n this.uploadFunction = upload(this.uploadUrl, this.chunkSize, !this.toChunk);\n }\n\n /**\n * Method to draw the component on the screen.\n * @returns {DocumentFragment} The fragment containing the component.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native-file-upload');\n native.setAttribute('part', 'native');\n\n let label = document.createElement('div');\n label.setAttribute('part', 'file-label');\n label.classList.add('file-label');\n\n let fileList = document.createElement('slot');\n fileList.setAttribute('name', 'item');\n fileList.setAttribute('part', 'items');\n fileList.classList.add('file-list');\n\n let slot = document.createElement('slot');\n label.appendChild(slot);\n\n let fileInput = document.createElement('input');\n fileInput.setAttribute('type', 'file');\n fileInput.setAttribute('multiple', '');\n fileInput.setAttribute('style', 'display:none;');\n fileInput.setAttribute('aria-hidden', 'true');\n\n if (!this.noUploadButton) {\n let button = document.createElement('wje-button');\n button.innerText = this.label || this.localizer.translate('wj.file.upload.button');\n button.setAttribute('part', 'upload-button');\n button.setAttribute('aria-label', button.innerText);\n\n label.appendChild(button);\n\n this.button = button;\n }\n\n native.appendChild(fileInput);\n native.appendChild(label);\n native.appendChild(fileList);\n\n fragment.appendChild(native);\n\n this.native = native;\n this.fileList = fileList;\n this.fileInput = fileInput;\n\n return fragment;\n }\n\n /**\n * Method to perform actions after the component is drawn.\n */\n afterDraw() {\n this.button?.addEventListener('click', () => {\n this.fileInput.click();\n });\n\n this.fileInput.addEventListener('change', this.handleInputChange);\n this.native.addEventListener('drop', this.handleDrop);\n\n let dragEventCounter = 0;\n\n this.native.addEventListener('dragenter', (e) => {handleInputChange\n e.preventDefault();\n\n if (dragEventCounter === 0) {\n this.native.classList.add('highlight');\n }\n\n dragEventCounter += 1;\n });\n\n this.native.addEventListener('dragover', (e) => {\n e.preventDefault();\n\n if (dragEventCounter === 0) {\n dragEventCounter = 1;\n }\n });\n\n this.native.addEventListener('dragleave', (e) => {\n e.preventDefault();\n\n dragEventCounter -= 1;\n\n if (dragEventCounter <= 0) {\n dragEventCounter = 0;\n this.native.classList.remove('highlight');\n }\n });\n\n this.native.addEventListener('drop', (e) => {\n event.preventDefault();\n\n dragEventCounter = 0;\n this.native.classList.remove('highlight');\n });\n\n this.addEventListener('wje-file-upload-item:remove', (e) => {\n const file = e.detail;\n\n if (!(file instanceof File)) {\n return;\n }\n\n let count = this.uploadedFiles.length;\n\n this.uploadedFiles = this.uploadedFiles.filter((entry) => {\n return entry?.file?.lastModified !== file.lastModified;\n });\n\n if(count !== this.uploadedFiles.length)\n event.dispatchCustomEvent(this, 'wje-file-upload:file-removed', file);\n });\n }\n\n /**\n * Method to handle form submission.\n * @param {Event} e The form submission event.\n */\n handleSubmit(e) {\n e.preventDefault();\n\n this.addFilesToQueue(this.fileInput.files);\n }\n\n /**\n * Method to handle file drop event.\n * @param {Event} e The file drop event object.\n */\n handleDrop = (e) => {\n const fileList = e.dataTransfer.files;\n\n this.resetFormState();\n\n this.addFilesToQueue(fileList);\n };\n\n /**\n * Method to handle file input change event.\n * @param {Event} e The file input change event object.\n */\n handleInputChange = (e) => {\n const files = Array.from(e.target.files);\n\n event.dispatchCustomEvent(this, 'wje-file-upload:files-selected', files);\n\n this.resetFormState();\n\n try {\n this.handleSubmit(e);\n } catch (err) {\n console.error(err);\n }\n };\n\n /**\n * Method to add files to the queue.\n * @param files\n */\n addFilesToQueue(files) {\n const currentCount = (Array.isArray(this.uploadedFiles) ? this.uploadedFiles.length : 0) + (Array.isArray(this._queuedFiles) ? this._queuedFiles.length : 0);\n const newTotal = currentCount + files.length;\n\n if (this.maxFiles && newTotal > this.maxFiles) {\n const detail = {\n code: 'MAX-FILES-EXCEEDED',\n files,\n maxFiles: this.maxFiles,\n currentCount,\n attemptedToAdd: files.length,\n allowedRemaining: Math.max(this.maxFiles - currentCount, 0),\n };\n\n event.dispatchCustomEvent(this, 'wje-file-upload:error', detail);\n\n return;\n }\n\n this._queuedFiles = [...(this._queuedFiles || []), ...files];\n\n event.dispatchCustomEvent(this, 'wje-file-upload:files-added', files);\n\n this.onAddedFiles?.();\n\n if (this.autoProcessFiles) {\n this.uploadFiles();\n }\n\n this.fileInput.value = '';\n }\n\n /**\n * Method to upload files.\n */\n uploadFiles() {\n if (this._queuedFiles.length === 0) {\n return;\n }\n\n const uploadPromises = this._queuedFiles.map((file) => this.createUploadPromise(file));\n uploadPromises\n .reduce((prev, curr) => {\n return prev.then(() => {\n return curr;\n });\n }, Promise.resolve())\n .then(() => {\n event.dispatchCustomEvent(this, 'wje-file-upload:files-uploaded', this.uploadedFiles);\n\n this.onAllFilesUploaded?.();\n this._queuedFiles = [];\n }).catch((err) => {\n this._queuedFiles = this._queuedFiles.filter((file) => file !== err.file);\n\n event.dispatchCustomEvent(this,'wje-file-upload:error', err);\n });\n }\n\n /**\n * Method to create an upload promise.\n * @param file\n * @returns {Promise<unknown>}\n */\n createUploadPromise = (file) => {\n return new Promise((resolve, reject) => {\n this.assertFilesValid(file);\n let preview;\n\n let reader = new FileReader();\n reader.onload = () => {\n event.dispatchCustomEvent(this, 'wje-file-upload:started', file);\n\n this.onUploadStarted?.(file);\n\n preview = this.createPreview(file, reader);\n this.appendChild(preview);\n\n this.uploadFunction(file, preview).then((res) => {\n res.item = preview;\n\n event.dispatchCustomEvent(this, 'wje-file-upload:file-uploaded', res);\n\n this.onUploadedFileComplete?.(res);\n\n this.uploadedFiles.push(res);\n\n resolve(res);\n });\n };\n\n reader.readAsDataURL(file);\n });\n };\n\n /**\n * Method to create a preview for the file.\n * @param {File} file The file for which the preview is to be created.\n * @param {FileReader} reader The FileReader instance to read the file.\n * @returns {HTMLElement} The created preview.\n */\n createPreview(file, reader) {\n let preview = document.createElement('wje-file-upload-item');\n preview.setAttribute('slot', 'item');\n preview.setAttribute('name', file.name);\n preview.setAttribute('size', file.size);\n preview.setAttribute('uploaded', '0');\n preview.innerHTML = `<wje-icon slot=\"img\" name=\"${getFileTypeIcon(file.type.split('/')[1])}\" size=\"large\"></wje-icon>`;\n preview.data = file;\n\n return preview;\n }\n\n /**\n * Method to create a thumbnail for the file.\n * @param {File} file The file for which the thumbnail is to be created.\n * @param {FileReader} reader The FileReader instance to read the file.\n * @returns {HTMLElement} The created thumbnail.\n */\n createThumbnail(file, reader) {\n let img = document.createElement('img');\n img.setAttribute('src', reader.result);\n\n return img;\n }\n\n /**\n * Method to validate the files.\n * @param {File} file The file to be validated.\n * TODO: alowed types a size limit by malo byt cez attributy\n */\n assertFilesValid(file) {\n const { name: fileName, size: fileSize } = file;\n\n if (!isValidFileType(file, this.acceptedTypes)) {\n const err = new Error('');\n err.code = 'INVALID-FILE-TYPE';\n err.file = file;\n err.acceptedTypes = this.acceptedTypes;\n\n throw err;\n }\n\n if (fileSize > this.maxFileSize) {\n const err = new Error('');\n err.code = 'FILE-TOO-LARGE';\n err.file = file;\n err.maxFileSize = this.maxFileSize;\n\n throw err;\n }\n }\n\n /**\n * Method to reset the form state.\n */\n resetFormState() {\n this.fileList.textContent = '';\n }\n}\n","import FileUpload from './file-upload.element.js';\n\nexport default FileUpload;\n\nFileUpload.define('wje-file-upload', FileUpload);\n"],"names":["response","_a"],"mappings":";;;;;;;;AAeA,SAAS,WAAW;AAChB,SAAO;AAAA,IACH;AAAA,MACI,MAAM,CAAC,OAAO,QAAQ,OAAO,OAAO,OAAO,QAAQ,KAAK;AAAA,MACxD,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,SAAS,KAAK;AAAA,MAC9E,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,OAAO,OAAO,OAAO,KAAK;AAAA,MACjC,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,OAAO,OAAO,KAAK;AAAA,MAC1B,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,QAAQ,MAAM;AAAA,MACrB,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,KAAK;AAAA,MACZ,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,KAAK;AAAA,MACZ,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,OAAO,MAAM;AAAA,MACpB,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,OAAO,MAAM;AAAA,MACpB,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,KAAK;AAAA,MACZ,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,OAAO,QAAQ,KAAK;AAAA,M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EvB,YAAM;AAAA,IACV;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAiB;AACb,SAAK,SAAS,cAAc;AAAA,EAChC;AACJ;AC7jBA,WAAW,OAAO,mBAAmB,UAAU;"}
|
|
1
|
+
{"version":3,"file":"wje-file-upload.js","sources":["../packages/wje-file-upload/service/service.js","../packages/wje-file-upload/file-upload.element.js","../packages/wje-file-upload/file-upload.js"],"sourcesContent":["/**\n * Returns a list of file type categories and their corresponding icon names.\n * @returns {Array<object>} An array of objects representing file type categories.\n * Each object contains the following properties:\n * - `type` {Array<string>} A list of file extensions and MIME subtypes associated with the category.\n * - `name` {string} The name of the icon representing the category.\n * @example\n * const types = fileType();\n * console.log(types);\n * // [\n * // { type: [\"jpg\", \"jpeg\", \"png\", \"gif\", \"bpm\", \"tiff\", \"svg\"], name: \"photo\" },\n * // { type: [\"zip\", \"rar\", \"cab\", \"jar\", \"tar\", \"gzip\", \"uue\", \"bz2\", \"scorm\", \"war\"], name: \"file-type-zip\" },\n * // ...\n * // ]\n */\nfunction fileType() {\n return [\n {\n type: ['jpg', 'jpeg', 'png', 'gif', 'bpm', 'tiff', 'svg'],\n name: 'photo',\n },\n {\n type: ['zip', 'rar', 'cab', 'jar', 'tar', 'gzip', 'uue', 'bz2', 'scorm', 'war'],\n name: 'file-type-zip',\n },\n {\n type: ['mov', 'mp4', 'avi', 'flv'],\n name: 'video',\n },\n {\n type: ['m4a', 'mp3', 'wav'],\n name: 'audio',\n },\n {\n type: ['html', 'html'],\n name: 'file-type-html',\n },\n {\n type: ['css'],\n name: 'code',\n },\n {\n type: ['txt'],\n name: 'file-type-txt',\n },\n {\n type: [\n 'doc',\n 'docx',\n 'msword',\n 'vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'vnd.ms-word.document.macroenabled.12',\n 'vnd.openxmlformats-officedocument.wordprocessingml.template',\n 'vnd.ms-word.template.macroenabled.12',\n 'vnd.oasis.opendocument.text',\n ],\n name: 'file-type-doc',\n },\n {\n type: [\n 'xls',\n 'xlsx',\n 'vnd.ms-excel',\n 'vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'vnd.ms-excel.sheet.macroenabled.12',\n 'vnd.openxmlformats-officedocument.spreadsheetml.template',\n 'vnd.ms-excel.template.macroenabled.12',\n 'vnd.ms-excel.addin.macroenabled.12',\n 'vnd.ms-excel.sheet.binary.macroenabled.12',\n 'vnd.oasis.opendocument.spreadsheet',\n ],\n name: 'file-type-xls',\n },\n {\n type: ['pdf'],\n name: 'file-type-pdf',\n },\n {\n type: [\n 'ppt',\n 'pptx',\n 'odp',\n 'vnd.ms-powerpoint',\n 'vnd.openxmlformats-officedocument.presentationml.presentation',\n 'vnd.ms-powerpoint.presentation.macroenabled.12',\n 'vnd.openxmlformats-officedocument.presentationml.slideshow',\n 'vnd.ms-powerpoint.slideshow.macroenabled.12',\n 'vnd.openxmlformats-officedocument.presentationml.template',\n 'vnd.ms-powerpoint.template.macroenabled.12',\n 'vnd.oasis.opendocument.presentation',\n ],\n name: 'file-type-ppt',\n },\n ];\n}\n\n/**\n * Retrieves the icon name for a given file type.\n * @param {string} type The file extension, MIME subtype or category (e.g., \"pdf\", \"vnd.ms-excel\", \"folder\").\n * @returns {string} The name of the icon associated with the file type.\n * @example\n * getFileTypeIcon('pdf'); // Returns the icon name for PDF files.\n * getFileTypeIcon('folder'); // Returns 'folder'.\n */\nexport function getFileTypeIcon(type) {\n let searchType;\n if (!type) {\n return searchType;\n }\n\n if (type.toLowerCase() !== 'folder') {\n fileType().forEach((i) => {\n if (i.type.includes(type.toLowerCase())) {\n searchType = i.name;\n }\n });\n } else {\n searchType = 'folder';\n }\n\n return searchType;\n}\n\n/**\n * Returns a function for uploading files either in chunks or as a whole file, based on the provided options.\n * @param {string} url The URL to which the file will be uploaded.\n * @param {number} [chunkSize] The size of each chunk in bytes when uploading in chunks (default is 1MB).\n * @param {boolean} [wholeFile] Whether to upload the file as a whole. If `true`, the entire file is uploaded at once.\n * @returns {Function} A function that takes a file and a preview element as arguments and uploads the file.\n * @example\n * // Upload a file in chunks\n * const uploadInChunks = upload('/upload', 1024 * 512); // 512KB chunks\n * uploadInChunks(file, previewElement);\n * @example\n * // Upload a whole file\n * const uploadWhole = upload('/upload', undefined, true);\n * uploadWhole(file, previewElement);\n */\nexport function upload(url, chunkSize = 1024 * 1024, wholeFile = false) {\n if (wholeFile) {\n return (file, preview) => uploadWholeFile(url, file, preview);\n }\n return (file, preview) => uploadFileInChunks(url, file, preview, chunkSize);\n}\n\n/**\n * Uploads a file in chunks to a specified URL, allowing for progress tracking and resuming in case of errors.\n * @param {string} url The URL to which the file chunks will be uploaded.\n * @param {File} file The file to be uploaded in chunks.\n * @param {HTMLElement} preview The element used to display upload progress.\n * @param {number} [chunkSize] The size of each chunk in bytes (default is 1MB).\n * @returns {Promise<object>} Resolves with the response of the last chunk uploaded, parsed as JSON.\n * @throws {Error} - Throws an error if a chunk fails to upload.\n */\nexport async function uploadFileInChunks(url, file, preview, chunkSize = 1024 * 1024) {\n let offset = 0;\n const totalChunks = Math.ceil(file.size / chunkSize);\n const partResponses = [];\n\n while (offset < file.size) {\n const chunk = file.slice(offset, offset + chunkSize);\n\n // Creating a custom ReadableStream to track progress of the current chunk\n const stream = new ReadableStream({\n start(controller) {\n const reader = chunk.stream().getReader();\n let uploadedBytes = 0;\n\n reader.read().then(function process({ done, value }) {\n if (done) {\n controller.close();\n return Promise.resolve();\n }\n\n // Track progress\n uploadedBytes += value.byteLength;\n const percentComplete = ((offset + uploadedBytes) / file.size) * 100;\n preview.setAttribute('uploaded', offset + uploadedBytes);\n\n // Enqueue chunk data into the stream\n controller.enqueue(value);\n\n // Read the next chunk\n return reader.read().then(process);\n });\n },\n });\n\n const formData = new FormData();\n formData.append('file', new Blob([stream])); // Send the current stream (chunk)\n formData.append('chunkIndex', Math.floor(offset / chunkSize)); // Send chunk index\n formData.append('totalChunks', totalChunks); // Send total chunks\n formData.append('fileName', file.name); // Send file name\n\n try {\n // Send the current chunk via Fetch\n const response = await fetch(url, {\n method: 'POST',\n body: formData,\n });\n\n if (!response.ok) {\n throw new Error(`Failed to upload chunk ${Math.floor(offset / chunkSize) + 1}: ${response.statusText}`);\n }\n\n partResponses.push(response);\n } catch (error) {\n console.error('Error uploading chunk:', error);\n break;\n }\n\n // Move to the next chunk\n offset += chunkSize;\n }\n\n const response = await partResponses.at(-1).json();\n\n return {\n data: response,\n file,\n };\n}\n\n/**\n * Uploads a file to a specified URL using a `POST` request and updates the preview element with the uploaded file size.\n * @param {string} url The URL to which the file will be uploaded.\n * @param {File} file The file to be uploaded.\n * @param {HTMLElement} preview The element that displays the upload preview. It will be updated with the file size.\n * @returns {Promise<{data: object, file: File}>} - A promise that resolves with the server response and the uploaded file.\n * @throws {Error} - Logs an error to the console if the request fails.\n */\nexport function uploadWholeFile(url, file, preview) {\n const formData = new FormData();\n formData.append('file', file);\n\n //use fetch\n return fetch(url, {\n method: 'POST',\n body: formData,\n })\n .then((response) => response.json())\n .then((data) => {\n preview.setAttribute('uploaded', file.size);\n return {\n data,\n file,\n };\n })\n .catch((error) => {\n console.error('Error:', error);\n });\n}\n","import { Localizer } from '../utils/localize.js';\nimport { default as WJElement, event } from '../wje-element/element.js';\nimport Button from '../wje-button/button.js';\nimport { isValidFileType } from '../utils/utils.js';\nimport { getFileTypeIcon, upload } from './service/service.js';\n\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary FileUpload is a custom web component for uploading files.\n * It extends from WJElement and provides functionalities for file upload.\n * @documentation https://elements.webjet.sk/components/file-upload\n * @status stable\n * @augments WJElement\n * @slot - This is a default/unnamed slot.\n * @csspart native - The native file upload part.\n * @csspart file-list - The file list part.\n * @csspart upload-button - The label part.\n * @event change - Fires when the file input changes.\n * @event drop - Fires when a file is dropped into the component.\n * @attribute {string} accepted-types - The accepted file types for upload.\n * @attribute {number} chunk-size - The chunk size for file upload.\n * @attribute {number} max-file-size - The maximum file size for upload.\n * @attribute {string} upload-url - The URL to set as the upload URL.\n * @attribute {boolean} auto-process-files - The auto process files attribute.\n * @attribute {boolean} no-upload-button - The no upload button attribute.\n * @tag wje-file-upload\n */\nexport default class FileUpload extends WJElement {\n /**\n * Constructor for FileUpload.\n * Initializes a new instance of the Localizer.\n */\n constructor() {\n super();\n this.localizer = new Localizer(this);\n this._uploadedFiles = [];\n this._queuedFiles = [];\n }\n\n /**\n * Dependencies for the FileUpload component.\n * @type {object}\n */\n dependencies = {\n 'wje-button': Button,\n };\n\n /**\n * Setter for acceptedTypes attribute.\n * @param {string} value The accepted file types for upload.\n */\n set acceptedTypes(value) {\n this.setAttribute('accepted-types', value);\n }\n\n /**\n * Getter for acceptedTypes attribute.\n * @returns {string} The accepted file types for upload.\n */\n get acceptedTypes() {\n const accepted = this.getAttribute('accepted-types');\n return this.hasAttribute('accepted-types') ? accepted : 'image/*';\n }\n\n /**\n * Setter for chunkSize attribute.\n * @param {number} value The chunk size for file upload.\n */\n set chunkSize(value) {\n this.setAttribute('chunk-size', value);\n }\n\n /**\n * Getter for chunkSize attribute.\n * @returns {number} The chunk size for file upload.\n */\n get chunkSize() {\n const chunk = this.getAttribute('chunk-size');\n return this.hasAttribute('chunk-size') ? chunk : 1024 * 1024;\n }\n\n /**\n * Setter for maxFileSize attribute.\n * @param {number} value The maximum file size for upload.\n */\n set maxFileSize(value) {\n this.setAttribute('max-file-size', value);\n }\n\n /**\n * Getter for maxFileSize attribute.\n * @returns {number} The maximum file size for upload.\n */\n get maxFileSize() {\n const fileSize = this.getAttribute('max-file-size');\n return this.hasAttribute('max-file-size') ? fileSize * 1024 * 1024 : 1024 * 1024;\n }\n\n /**\n * Setter for label attribute.\n * @param {string} value The URL to set as the upload URL.\n */\n set uploadUrl(value) {\n this.setAttribute('upload-url', value);\n }\n\n /**\n * Gets the upload URL for the file upload element.\n * @returns {string} The upload URL for the file upload element.\n */\n get uploadUrl() {\n return this.getAttribute('upload-url') ?? '/upload';\n }\n\n /**\n * Sets the autoProcessFiles attribute.\n * @param value\n */\n set autoProcessFiles(value) {\n this.setAttribute('auto-process-files', value);\n }\n\n /**\n * Gets the autoProcessFiles attribute.\n * @returns {any|boolean}\n */\n get autoProcessFiles() {\n return JSON.parse(this.getAttribute('auto-process-files')) ?? true;\n }\n\n /**\n * Sets the noUploadButton attribute.\n * @param value\n */\n set noUploadButton(value) {\n this.setAttribute('no-upload-button', value);\n }\n\n /**\n * Gets the noUploadButton attribute.\n * @returns {boolean}\n */\n get noUploadButton() {\n return this.hasAttribute('no-upload-button');\n }\n\n /**\n * Sets the uploaded files.\n * @param value\n */\n set uploadedFiles(value) {\n this._uploadedFiles = value;\n }\n\n /**\n * Return the uploaded files.\n * @returns {[]}\n */\n get uploadedFiles() {\n return this._uploadedFiles;\n }\n\n /**\n * Sets the to-chunk attribute.\n * @param value\n */\n set toChunk(value) {\n this.setAttribute('to-chunk', value);\n }\n\n /**\n * Gets the to-chunk attribute.\n * @returns {boolean}\n */\n get toChunk() {\n return this.hasAttribute('to-chunk');\n }\n\n /**\n * Sets the maximum number of files that can be uploaded or managed.\n * Assigns the specified value to the 'max-files' attribute.\n * @param {number} value The maximum allowable number of files.\n */\n set maxFiles(value) {\n this.setAttribute('max-files', value);\n }\n\n /**\n * Sets the label attribute for the upload button.\n * @param {string} value\n */\n set label(value) {\n this.setAttribute('label', value);\n }\n\n /**\n * Gets the label attribute for the upload button.\n * @returns {string}\n */\n get label() {\n return this.getAttribute('label') || '';\n }\n\n /**\n * Retrieves the maximum number of files allowed from the `max-files` attribute.\n * If the attribute is not set or is invalid, defaults to 0.\n * @returns {number} The maximum number of files allowed.\n */\n get maxFiles() {\n return parseInt(this.getAttribute('max-files')) || 10;\n }\n\n className = 'FileUpload';\n\n /**\n * Getter for cssStyleSheet.\n * @returns {string} The CSS styles for the component.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for observedAttributes.\n * @returns {Array} An empty array as no attributes are observed.\n */\n static get observedAttributes() {\n return ['label'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n if (name === 'label' && this.button) {\n const nextLabel = this.label || this.localizer.translate('wj.file.upload.button');\n this.button.innerText = nextLabel;\n this.button.setAttribute('aria-label', nextLabel);\n }\n }\n\n /**\n * Method to setup attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.setAriaState({\n role: 'group',\n });\n }\n\n beforeDraw() {\n this.uploadFunction = upload(this.uploadUrl, this.chunkSize, !this.toChunk);\n }\n\n /**\n * Method to draw the component on the screen.\n * @returns {DocumentFragment} The fragment containing the component.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native-file-upload');\n native.setAttribute('part', 'native');\n\n let label = document.createElement('div');\n label.setAttribute('part', 'file-label');\n label.classList.add('file-label');\n\n let fileList = document.createElement('slot');\n fileList.setAttribute('name', 'item');\n fileList.setAttribute('part', 'items');\n fileList.classList.add('file-list');\n\n let slot = document.createElement('slot');\n label.appendChild(slot);\n\n let fileInput = document.createElement('input');\n fileInput.setAttribute('type', 'file');\n fileInput.setAttribute('multiple', '');\n fileInput.setAttribute('style', 'display:none;');\n fileInput.setAttribute('aria-hidden', 'true');\n\n if (!this.noUploadButton) {\n let button = document.createElement('wje-button');\n button.innerText = this.label || this.localizer.translate('wj.file.upload.button');\n button.setAttribute('part', 'upload-button');\n button.setAttribute('aria-label', button.innerText);\n\n label.appendChild(button);\n\n this.button = button;\n }\n\n native.appendChild(fileInput);\n native.appendChild(label);\n native.appendChild(fileList);\n\n fragment.appendChild(native);\n\n this.native = native;\n this.fileList = fileList;\n this.fileInput = fileInput;\n\n return fragment;\n }\n\n /**\n * Method to perform actions after the component is drawn.\n */\n afterDraw() {\n this.button?.addEventListener('click', () => {\n this.fileInput.click();\n });\n\n this.fileInput.addEventListener('change', this.handleInputChange);\n this.native.addEventListener('drop', this.handleDrop);\n\n let dragEventCounter = 0;\n\n this.native.addEventListener('dragenter', (e) => {handleInputChange\n e.preventDefault();\n\n if (dragEventCounter === 0) {\n this.native.classList.add('highlight');\n }\n\n dragEventCounter += 1;\n });\n\n this.native.addEventListener('dragover', (e) => {\n e.preventDefault();\n\n if (dragEventCounter === 0) {\n dragEventCounter = 1;\n }\n });\n\n this.native.addEventListener('dragleave', (e) => {\n e.preventDefault();\n\n dragEventCounter -= 1;\n\n if (dragEventCounter <= 0) {\n dragEventCounter = 0;\n this.native.classList.remove('highlight');\n }\n });\n\n this.native.addEventListener('drop', (e) => {\n event.preventDefault();\n\n dragEventCounter = 0;\n this.native.classList.remove('highlight');\n });\n\n this.addEventListener('wje-file-upload-item:remove', (e) => {\n const file = e.detail;\n\n if (!(file instanceof File)) {\n return;\n }\n\n let count = this.uploadedFiles.length;\n\n this.uploadedFiles = this.uploadedFiles.filter((entry) => {\n return entry?.file?.lastModified !== file.lastModified;\n });\n\n if(count !== this.uploadedFiles.length)\n event.dispatchCustomEvent(this, 'wje-file-upload:file-removed', file);\n });\n }\n\n /**\n * Method to handle form submission.\n * @param {Event} e The form submission event.\n */\n handleSubmit(e) {\n e.preventDefault();\n\n this.addFilesToQueue(this.fileInput.files);\n }\n\n /**\n * Method to handle file drop event.\n * @param {Event} e The file drop event object.\n */\n handleDrop = (e) => {\n const fileList = e.dataTransfer.files;\n\n this.resetFormState();\n\n this.addFilesToQueue(fileList);\n };\n\n /**\n * Method to handle file input change event.\n * @param {Event} e The file input change event object.\n */\n handleInputChange = (e) => {\n const files = Array.from(e.target.files);\n\n event.dispatchCustomEvent(this, 'wje-file-upload:files-selected', files);\n\n this.resetFormState();\n\n try {\n this.handleSubmit(e);\n } catch (err) {\n console.error(err);\n }\n };\n\n /**\n * Method to add files to the queue.\n * @param files\n */\n addFilesToQueue(files) {\n const currentCount = (Array.isArray(this.uploadedFiles) ? this.uploadedFiles.length : 0) + (Array.isArray(this._queuedFiles) ? this._queuedFiles.length : 0);\n const newTotal = currentCount + files.length;\n\n if (this.maxFiles && newTotal > this.maxFiles) {\n const detail = {\n code: 'MAX-FILES-EXCEEDED',\n files,\n maxFiles: this.maxFiles,\n currentCount,\n attemptedToAdd: files.length,\n allowedRemaining: Math.max(this.maxFiles - currentCount, 0),\n };\n\n event.dispatchCustomEvent(this, 'wje-file-upload:error', detail);\n\n return;\n }\n\n this._queuedFiles = [...(this._queuedFiles || []), ...files];\n\n event.dispatchCustomEvent(this, 'wje-file-upload:files-added', files);\n\n this.onAddedFiles?.();\n\n if (this.autoProcessFiles) {\n this.uploadFiles();\n }\n\n this.fileInput.value = '';\n }\n\n /**\n * Method to upload files.\n */\n uploadFiles() {\n if (this._queuedFiles.length === 0) {\n return;\n }\n\n const uploadPromises = this._queuedFiles.map((file) => this.createUploadPromise(file));\n uploadPromises\n .reduce((prev, curr) => {\n return prev.then(() => {\n return curr;\n });\n }, Promise.resolve())\n .then(() => {\n event.dispatchCustomEvent(this, 'wje-file-upload:files-uploaded', this.uploadedFiles);\n\n this.onAllFilesUploaded?.();\n this._queuedFiles = [];\n }).catch((err) => {\n this._queuedFiles = this._queuedFiles.filter((file) => file !== err.file);\n\n event.dispatchCustomEvent(this,'wje-file-upload:error', err);\n });\n }\n\n /**\n * Method to create an upload promise.\n * @param file\n * @returns {Promise<unknown>}\n */\n createUploadPromise = (file) => {\n return new Promise((resolve, reject) => {\n this.assertFilesValid(file);\n let preview;\n\n let reader = new FileReader();\n reader.onload = () => {\n event.dispatchCustomEvent(this, 'wje-file-upload:started', file);\n\n this.onUploadStarted?.(file);\n\n preview = this.createPreview(file, reader);\n this.appendChild(preview);\n\n this.uploadFunction(file, preview).then((res) => {\n res.item = preview;\n\n event.dispatchCustomEvent(this, 'wje-file-upload:file-uploaded', res);\n\n this.onUploadedFileComplete?.(res);\n\n this.uploadedFiles.push(res);\n\n resolve(res);\n });\n };\n\n reader.readAsDataURL(file);\n });\n };\n\n /**\n * Method to create a preview for the file.\n * @param {File} file The file for which the preview is to be created.\n * @param {FileReader} reader The FileReader instance to read the file.\n * @returns {HTMLElement} The created preview.\n */\n createPreview(file, reader) {\n let preview = document.createElement('wje-file-upload-item');\n let fileType = file.type ? file.type.split('/')[1] : file.name.split('.').pop();\n let icon = getFileTypeIcon(fileType) || 'file';\n\n preview.setAttribute('slot', 'item');\n preview.setAttribute('name', file.name);\n preview.setAttribute('size', file.size);\n preview.setAttribute('uploaded', '0');\n preview.innerHTML = `<wje-icon slot=\"img\" name=\"${icon}\" size=\"large\"></wje-icon>`;\n preview.data = file;\n\n return preview;\n }\n\n /**\n * Method to create a thumbnail for the file.\n * @param {File} file The file for which the thumbnail is to be created.\n * @param {FileReader} reader The FileReader instance to read the file.\n * @returns {HTMLElement} The created thumbnail.\n */\n createThumbnail(file, reader) {\n let img = document.createElement('img');\n img.setAttribute('src', reader.result);\n\n return img;\n }\n\n /**\n * Method to validate the files.\n * @param {File} file The file to be validated.\n * TODO: alowed types a size limit by malo byt cez attributy\n */\n assertFilesValid(file) {\n const { name: fileName, size: fileSize } = file;\n\n if (!isValidFileType(file, this.acceptedTypes)) {\n const err = new Error('');\n err.code = 'INVALID-FILE-TYPE';\n err.file = file;\n err.acceptedTypes = this.acceptedTypes;\n\n throw err;\n }\n\n if (fileSize > this.maxFileSize) {\n const err = new Error('');\n err.code = 'FILE-TOO-LARGE';\n err.file = file;\n err.maxFileSize = this.maxFileSize;\n\n throw err;\n }\n }\n\n /**\n * Method to reset the form state.\n */\n resetFormState() {\n this.fileList.textContent = '';\n }\n}\n","import FileUpload from './file-upload.element.js';\n\nexport default FileUpload;\n\nFileUpload.define('wje-file-upload', FileUpload);\n"],"names":["response","_a","fileType"],"mappings":";;;;;;;;AAeA,SAAS,WAAW;AAChB,SAAO;AAAA,IACH;AAAA,MACI,MAAM,CAAC,OAAO,QAAQ,OAAO,OAAO,OAAO,QAAQ,KAAK;AAAA,MACxD,MAAM;AAAA,IAClB;AAAA,IACQ;AAAA,MACI,MAAM,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,SAAS,KAAK;AAAA,MAC9E,MAAM;A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;AChkBA,WAAW,OAAO,mBAAmB,UAAU;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wj-elements",
|
|
3
3
|
"description": "WebJET Elements is a modern set of user interface tools harnessing the power of web components designed to simplify web application development.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.7",
|
|
5
5
|
"homepage": "https://github.com/lencys/wj-elements",
|
|
6
6
|
"author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
|
|
7
7
|
"license": "MIT",
|