@idds/js 1.0.58 → 1.0.60
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/index.iife.js +39 -39
- package/dist/index.js +39 -39
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -978,7 +978,7 @@ var InaUI = (() => {
|
|
|
978
978
|
upload: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"></path><polyline points="16 6 12 2 8 6"></polyline><line x1="12" y1="2" x2="12" y2="16"></line></svg>`,
|
|
979
979
|
file: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>`,
|
|
980
980
|
trash: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>`,
|
|
981
|
-
check: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="
|
|
981
|
+
check: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" size="20" class="tabler-icon tabler-icon-circle-check"><path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path><path d="M9 12l2 2l4 -4"></path></svg>`,
|
|
982
982
|
error: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line></svg>`,
|
|
983
983
|
loader: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="${PREFIX}-file-upload__file-icon--spinning"><path d="M21 12a9 9 0 1 1-6.219-8.56"></path></svg>`
|
|
984
984
|
};
|
|
@@ -998,18 +998,10 @@ var InaUI = (() => {
|
|
|
998
998
|
filesContainer.className = `${PREFIX}-file-upload__files`;
|
|
999
999
|
container.appendChild(filesContainer);
|
|
1000
1000
|
}
|
|
1001
|
-
let errorsContainer = container.querySelector(
|
|
1002
|
-
`.${PREFIX}-file-upload__errors`
|
|
1003
|
-
);
|
|
1004
|
-
if (!errorsContainer) {
|
|
1005
|
-
errorsContainer = document.createElement("div");
|
|
1006
|
-
errorsContainer.className = `${PREFIX}-file-upload__errors`;
|
|
1007
|
-
container.appendChild(errorsContainer);
|
|
1008
|
-
}
|
|
1009
1001
|
if (!input || !dropzone) return;
|
|
1010
1002
|
const maxFiles = parseInt(container.getAttribute("data-max-files")) || 0;
|
|
1011
1003
|
const maxSize = parseInt(container.getAttribute("data-max-size")) || 0;
|
|
1012
|
-
const allowedExtensions = (container.getAttribute("data-allowed-extensions") || "").split(",").filter(Boolean);
|
|
1004
|
+
const allowedExtensions = (container.getAttribute("data-allowed-extensions") || "").toLowerCase().split(",").map((ext) => ext.trim()).filter(Boolean);
|
|
1013
1005
|
const multiple = input.hasAttribute("multiple");
|
|
1014
1006
|
let uploadedFiles = [];
|
|
1015
1007
|
const formatFileSize = (bytes) => {
|
|
@@ -1023,7 +1015,7 @@ var InaUI = (() => {
|
|
|
1023
1015
|
const validateFile = (file) => {
|
|
1024
1016
|
if (allowedExtensions.length > 0) {
|
|
1025
1017
|
const ext = file.name.split(".").pop().toLowerCase();
|
|
1026
|
-
if (!allowedExtensions.includes(ext
|
|
1018
|
+
if (!allowedExtensions.includes(ext)) {
|
|
1027
1019
|
return {
|
|
1028
1020
|
valid: false,
|
|
1029
1021
|
error: `Ekstensi file harus: ${allowedExtensions.join(", ")}`
|
|
@@ -1040,7 +1032,11 @@ var InaUI = (() => {
|
|
|
1040
1032
|
};
|
|
1041
1033
|
const renderFiles = () => {
|
|
1042
1034
|
filesContainer.innerHTML = "";
|
|
1043
|
-
|
|
1035
|
+
if (uploadedFiles.length > 0) {
|
|
1036
|
+
filesContainer.style.display = "flex";
|
|
1037
|
+
} else {
|
|
1038
|
+
filesContainer.style.display = "none";
|
|
1039
|
+
}
|
|
1044
1040
|
uploadedFiles.forEach((f, index) => {
|
|
1045
1041
|
const fileEl = document.createElement("div");
|
|
1046
1042
|
fileEl.className = `${PREFIX}-file-upload__file`;
|
|
@@ -1085,59 +1081,63 @@ var InaUI = (() => {
|
|
|
1085
1081
|
});
|
|
1086
1082
|
};
|
|
1087
1083
|
const addFiles = (newFiles) => {
|
|
1088
|
-
const
|
|
1089
|
-
const errors = [];
|
|
1084
|
+
const addedFiles = [];
|
|
1090
1085
|
Array.from(newFiles).forEach((file) => {
|
|
1091
1086
|
const validation = validateFile(file);
|
|
1092
1087
|
if (!validation.valid) {
|
|
1093
|
-
|
|
1088
|
+
addedFiles.push({
|
|
1089
|
+
file,
|
|
1090
|
+
status: "error",
|
|
1091
|
+
error: validation.error,
|
|
1092
|
+
id: generateId()
|
|
1093
|
+
});
|
|
1094
1094
|
} else {
|
|
1095
|
-
|
|
1095
|
+
addedFiles.push({
|
|
1096
1096
|
file,
|
|
1097
1097
|
status: "idle",
|
|
1098
|
-
// In vanilla we might simulate upload or just set success immediately
|
|
1099
1098
|
id: generateId()
|
|
1100
1099
|
});
|
|
1101
1100
|
}
|
|
1102
1101
|
});
|
|
1102
|
+
const existingValidCount = uploadedFiles.filter(
|
|
1103
|
+
(f) => f.status !== "error"
|
|
1104
|
+
).length;
|
|
1105
|
+
const newValidCount = addedFiles.filter(
|
|
1106
|
+
(f) => f.status !== "error"
|
|
1107
|
+
).length;
|
|
1103
1108
|
if (multiple && maxFiles > 0) {
|
|
1104
|
-
if (
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1109
|
+
if (existingValidCount + newValidCount > maxFiles) {
|
|
1110
|
+
let validFiles = addedFiles.filter((f) => f.status !== "error");
|
|
1111
|
+
let errorFiles = addedFiles.filter((f) => f.status === "error");
|
|
1112
|
+
const spaceLeft = maxFiles - existingValidCount;
|
|
1113
|
+
if (spaceLeft < validFiles.length) {
|
|
1114
|
+
validFiles = validFiles.slice(0, spaceLeft);
|
|
1110
1115
|
}
|
|
1116
|
+
const limitedAddedFiles = [...errorFiles, ...validFiles];
|
|
1111
1117
|
}
|
|
1112
1118
|
}
|
|
1113
1119
|
if (!multiple) {
|
|
1114
|
-
uploadedFiles =
|
|
1120
|
+
uploadedFiles = addedFiles.slice(0, 1);
|
|
1115
1121
|
} else {
|
|
1116
|
-
uploadedFiles = [...uploadedFiles, ...
|
|
1122
|
+
uploadedFiles = [...uploadedFiles, ...addedFiles];
|
|
1117
1123
|
}
|
|
1118
|
-
errorsContainer.innerHTML = "";
|
|
1119
|
-
errors.forEach((err) => {
|
|
1120
|
-
const errEl = document.createElement("div");
|
|
1121
|
-
errEl.className = `${PREFIX}-file-upload__error-message`;
|
|
1122
|
-
errEl.textContent = `${err.file.name}: ${err.error}`;
|
|
1123
|
-
errorsContainer.appendChild(errEl);
|
|
1124
|
-
});
|
|
1125
1124
|
renderFiles();
|
|
1126
1125
|
container.dispatchEvent(
|
|
1127
1126
|
new CustomEvent("file-upload:change", {
|
|
1128
1127
|
detail: {
|
|
1129
1128
|
files: uploadedFiles.map((f) => f.file),
|
|
1130
|
-
errors
|
|
1129
|
+
errors: uploadedFiles.filter((f) => f.status === "error").map((f) => ({ file: f.file, error: f.error }))
|
|
1131
1130
|
},
|
|
1132
1131
|
bubbles: true
|
|
1133
1132
|
})
|
|
1134
1133
|
);
|
|
1135
|
-
|
|
1134
|
+
const filesToUpload = uploadedFiles.filter((f) => f.status === "idle");
|
|
1135
|
+
filesToUpload.forEach((f) => {
|
|
1136
1136
|
f.status = "uploading";
|
|
1137
1137
|
});
|
|
1138
1138
|
renderFiles();
|
|
1139
1139
|
setTimeout(() => {
|
|
1140
|
-
|
|
1140
|
+
filesToUpload.forEach((f) => {
|
|
1141
1141
|
f.status = "success";
|
|
1142
1142
|
});
|
|
1143
1143
|
renderFiles();
|
|
@@ -1184,7 +1184,7 @@ var InaUI = (() => {
|
|
|
1184
1184
|
|
|
1185
1185
|
// src/js/components/stateful/single-file-upload.js
|
|
1186
1186
|
var ICONS2 = {
|
|
1187
|
-
upload: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"></path><
|
|
1187
|
+
upload: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" size="24" class="tabler-icon tabler-icon-upload"><path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"></path><path d="M7 9l5 -5l5 5"></path><path d="M12 4l0 12"></path></svg>`,
|
|
1188
1188
|
trash: `<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>`,
|
|
1189
1189
|
file: `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>`,
|
|
1190
1190
|
pdf: `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><path d="M10 13a1 1 0 0 0-1 1v4"></path><path d="M10 13h1a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-1"></path><path d="M14 13h1a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-1v-2"></path><path d="M14 15h2"></path></svg>`,
|
|
@@ -1208,9 +1208,9 @@ var InaUI = (() => {
|
|
|
1208
1208
|
`.${PREFIX}-single-file-upload__description`
|
|
1209
1209
|
);
|
|
1210
1210
|
const initialTitle = titleEl ? titleEl.textContent : "Unggah File";
|
|
1211
|
-
const initialDescription = descriptionEl ? descriptionEl.textContent : "";
|
|
1211
|
+
const initialDescription = descriptionEl ? descriptionEl.textContent : "Unggah atau seret dan lepas ke sini";
|
|
1212
1212
|
const maxSize = parseInt(container.getAttribute("data-max-size")) || 0;
|
|
1213
|
-
const allowedExtensions = (container.getAttribute("data-allowed-extensions") || "").split(",").filter(Boolean);
|
|
1213
|
+
const allowedExtensions = (container.getAttribute("data-allowed-extensions") || "").toLowerCase().split(",").map((ext) => ext.trim()).filter(Boolean);
|
|
1214
1214
|
let status = "idle";
|
|
1215
1215
|
let currentFile = null;
|
|
1216
1216
|
let progress = 0;
|
|
@@ -1278,7 +1278,7 @@ var InaUI = (() => {
|
|
|
1278
1278
|
return;
|
|
1279
1279
|
}
|
|
1280
1280
|
if (allowedExtensions.length > 0) {
|
|
1281
|
-
const ext = file.name.split(".").pop();
|
|
1281
|
+
const ext = file.name.split(".").pop().toLowerCase();
|
|
1282
1282
|
if (!allowedExtensions.includes(ext)) {
|
|
1283
1283
|
alert("Invalid file extension.");
|
|
1284
1284
|
return;
|
package/dist/index.js
CHANGED
|
@@ -981,7 +981,7 @@ var ICONS = {
|
|
|
981
981
|
upload: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"></path><polyline points="16 6 12 2 8 6"></polyline><line x1="12" y1="2" x2="12" y2="16"></line></svg>`,
|
|
982
982
|
file: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>`,
|
|
983
983
|
trash: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>`,
|
|
984
|
-
check: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="
|
|
984
|
+
check: `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" size="20" class="tabler-icon tabler-icon-circle-check"><path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path><path d="M9 12l2 2l4 -4"></path></svg>`,
|
|
985
985
|
error: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line></svg>`,
|
|
986
986
|
loader: `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="${PREFIX}-file-upload__file-icon--spinning"><path d="M21 12a9 9 0 1 1-6.219-8.56"></path></svg>`
|
|
987
987
|
};
|
|
@@ -1001,18 +1001,10 @@ function initFileUpload(rootSelector = `.${PREFIX}-file-upload`) {
|
|
|
1001
1001
|
filesContainer.className = `${PREFIX}-file-upload__files`;
|
|
1002
1002
|
container.appendChild(filesContainer);
|
|
1003
1003
|
}
|
|
1004
|
-
let errorsContainer = container.querySelector(
|
|
1005
|
-
`.${PREFIX}-file-upload__errors`
|
|
1006
|
-
);
|
|
1007
|
-
if (!errorsContainer) {
|
|
1008
|
-
errorsContainer = document.createElement("div");
|
|
1009
|
-
errorsContainer.className = `${PREFIX}-file-upload__errors`;
|
|
1010
|
-
container.appendChild(errorsContainer);
|
|
1011
|
-
}
|
|
1012
1004
|
if (!input || !dropzone) return;
|
|
1013
1005
|
const maxFiles = parseInt(container.getAttribute("data-max-files")) || 0;
|
|
1014
1006
|
const maxSize = parseInt(container.getAttribute("data-max-size")) || 0;
|
|
1015
|
-
const allowedExtensions = (container.getAttribute("data-allowed-extensions") || "").split(",").filter(Boolean);
|
|
1007
|
+
const allowedExtensions = (container.getAttribute("data-allowed-extensions") || "").toLowerCase().split(",").map((ext) => ext.trim()).filter(Boolean);
|
|
1016
1008
|
const multiple = input.hasAttribute("multiple");
|
|
1017
1009
|
let uploadedFiles = [];
|
|
1018
1010
|
const formatFileSize = (bytes) => {
|
|
@@ -1026,7 +1018,7 @@ function initFileUpload(rootSelector = `.${PREFIX}-file-upload`) {
|
|
|
1026
1018
|
const validateFile = (file) => {
|
|
1027
1019
|
if (allowedExtensions.length > 0) {
|
|
1028
1020
|
const ext = file.name.split(".").pop().toLowerCase();
|
|
1029
|
-
if (!allowedExtensions.includes(ext
|
|
1021
|
+
if (!allowedExtensions.includes(ext)) {
|
|
1030
1022
|
return {
|
|
1031
1023
|
valid: false,
|
|
1032
1024
|
error: `Ekstensi file harus: ${allowedExtensions.join(", ")}`
|
|
@@ -1043,7 +1035,11 @@ function initFileUpload(rootSelector = `.${PREFIX}-file-upload`) {
|
|
|
1043
1035
|
};
|
|
1044
1036
|
const renderFiles = () => {
|
|
1045
1037
|
filesContainer.innerHTML = "";
|
|
1046
|
-
|
|
1038
|
+
if (uploadedFiles.length > 0) {
|
|
1039
|
+
filesContainer.style.display = "flex";
|
|
1040
|
+
} else {
|
|
1041
|
+
filesContainer.style.display = "none";
|
|
1042
|
+
}
|
|
1047
1043
|
uploadedFiles.forEach((f, index) => {
|
|
1048
1044
|
const fileEl = document.createElement("div");
|
|
1049
1045
|
fileEl.className = `${PREFIX}-file-upload__file`;
|
|
@@ -1088,59 +1084,63 @@ function initFileUpload(rootSelector = `.${PREFIX}-file-upload`) {
|
|
|
1088
1084
|
});
|
|
1089
1085
|
};
|
|
1090
1086
|
const addFiles = (newFiles) => {
|
|
1091
|
-
const
|
|
1092
|
-
const errors = [];
|
|
1087
|
+
const addedFiles = [];
|
|
1093
1088
|
Array.from(newFiles).forEach((file) => {
|
|
1094
1089
|
const validation = validateFile(file);
|
|
1095
1090
|
if (!validation.valid) {
|
|
1096
|
-
|
|
1091
|
+
addedFiles.push({
|
|
1092
|
+
file,
|
|
1093
|
+
status: "error",
|
|
1094
|
+
error: validation.error,
|
|
1095
|
+
id: generateId()
|
|
1096
|
+
});
|
|
1097
1097
|
} else {
|
|
1098
|
-
|
|
1098
|
+
addedFiles.push({
|
|
1099
1099
|
file,
|
|
1100
1100
|
status: "idle",
|
|
1101
|
-
// In vanilla we might simulate upload or just set success immediately
|
|
1102
1101
|
id: generateId()
|
|
1103
1102
|
});
|
|
1104
1103
|
}
|
|
1105
1104
|
});
|
|
1105
|
+
const existingValidCount = uploadedFiles.filter(
|
|
1106
|
+
(f) => f.status !== "error"
|
|
1107
|
+
).length;
|
|
1108
|
+
const newValidCount = addedFiles.filter(
|
|
1109
|
+
(f) => f.status !== "error"
|
|
1110
|
+
).length;
|
|
1106
1111
|
if (multiple && maxFiles > 0) {
|
|
1107
|
-
if (
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1112
|
+
if (existingValidCount + newValidCount > maxFiles) {
|
|
1113
|
+
let validFiles = addedFiles.filter((f) => f.status !== "error");
|
|
1114
|
+
let errorFiles = addedFiles.filter((f) => f.status === "error");
|
|
1115
|
+
const spaceLeft = maxFiles - existingValidCount;
|
|
1116
|
+
if (spaceLeft < validFiles.length) {
|
|
1117
|
+
validFiles = validFiles.slice(0, spaceLeft);
|
|
1113
1118
|
}
|
|
1119
|
+
const limitedAddedFiles = [...errorFiles, ...validFiles];
|
|
1114
1120
|
}
|
|
1115
1121
|
}
|
|
1116
1122
|
if (!multiple) {
|
|
1117
|
-
uploadedFiles =
|
|
1123
|
+
uploadedFiles = addedFiles.slice(0, 1);
|
|
1118
1124
|
} else {
|
|
1119
|
-
uploadedFiles = [...uploadedFiles, ...
|
|
1125
|
+
uploadedFiles = [...uploadedFiles, ...addedFiles];
|
|
1120
1126
|
}
|
|
1121
|
-
errorsContainer.innerHTML = "";
|
|
1122
|
-
errors.forEach((err) => {
|
|
1123
|
-
const errEl = document.createElement("div");
|
|
1124
|
-
errEl.className = `${PREFIX}-file-upload__error-message`;
|
|
1125
|
-
errEl.textContent = `${err.file.name}: ${err.error}`;
|
|
1126
|
-
errorsContainer.appendChild(errEl);
|
|
1127
|
-
});
|
|
1128
1127
|
renderFiles();
|
|
1129
1128
|
container.dispatchEvent(
|
|
1130
1129
|
new CustomEvent("file-upload:change", {
|
|
1131
1130
|
detail: {
|
|
1132
1131
|
files: uploadedFiles.map((f) => f.file),
|
|
1133
|
-
errors
|
|
1132
|
+
errors: uploadedFiles.filter((f) => f.status === "error").map((f) => ({ file: f.file, error: f.error }))
|
|
1134
1133
|
},
|
|
1135
1134
|
bubbles: true
|
|
1136
1135
|
})
|
|
1137
1136
|
);
|
|
1138
|
-
|
|
1137
|
+
const filesToUpload = uploadedFiles.filter((f) => f.status === "idle");
|
|
1138
|
+
filesToUpload.forEach((f) => {
|
|
1139
1139
|
f.status = "uploading";
|
|
1140
1140
|
});
|
|
1141
1141
|
renderFiles();
|
|
1142
1142
|
setTimeout(() => {
|
|
1143
|
-
|
|
1143
|
+
filesToUpload.forEach((f) => {
|
|
1144
1144
|
f.status = "success";
|
|
1145
1145
|
});
|
|
1146
1146
|
renderFiles();
|
|
@@ -1187,7 +1187,7 @@ function initFileUpload(rootSelector = `.${PREFIX}-file-upload`) {
|
|
|
1187
1187
|
|
|
1188
1188
|
// src/js/components/stateful/single-file-upload.js
|
|
1189
1189
|
var ICONS2 = {
|
|
1190
|
-
upload: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"></path><
|
|
1190
|
+
upload: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" size="24" class="tabler-icon tabler-icon-upload"><path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"></path><path d="M7 9l5 -5l5 5"></path><path d="M12 4l0 12"></path></svg>`,
|
|
1191
1191
|
trash: `<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>`,
|
|
1192
1192
|
file: `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>`,
|
|
1193
1193
|
pdf: `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><path d="M10 13a1 1 0 0 0-1 1v4"></path><path d="M10 13h1a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-1"></path><path d="M14 13h1a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-1v-2"></path><path d="M14 15h2"></path></svg>`,
|
|
@@ -1211,9 +1211,9 @@ function initSingleFileUpload(rootSelector = `.${PREFIX}-single-file-upload`) {
|
|
|
1211
1211
|
`.${PREFIX}-single-file-upload__description`
|
|
1212
1212
|
);
|
|
1213
1213
|
const initialTitle = titleEl ? titleEl.textContent : "Unggah File";
|
|
1214
|
-
const initialDescription = descriptionEl ? descriptionEl.textContent : "";
|
|
1214
|
+
const initialDescription = descriptionEl ? descriptionEl.textContent : "Unggah atau seret dan lepas ke sini";
|
|
1215
1215
|
const maxSize = parseInt(container.getAttribute("data-max-size")) || 0;
|
|
1216
|
-
const allowedExtensions = (container.getAttribute("data-allowed-extensions") || "").split(",").filter(Boolean);
|
|
1216
|
+
const allowedExtensions = (container.getAttribute("data-allowed-extensions") || "").toLowerCase().split(",").map((ext) => ext.trim()).filter(Boolean);
|
|
1217
1217
|
let status = "idle";
|
|
1218
1218
|
let currentFile = null;
|
|
1219
1219
|
let progress = 0;
|
|
@@ -1281,7 +1281,7 @@ function initSingleFileUpload(rootSelector = `.${PREFIX}-single-file-upload`) {
|
|
|
1281
1281
|
return;
|
|
1282
1282
|
}
|
|
1283
1283
|
if (allowedExtensions.length > 0) {
|
|
1284
|
-
const ext = file.name.split(".").pop();
|
|
1284
|
+
const ext = file.name.split(".").pop().toLowerCase();
|
|
1285
1285
|
if (!allowedExtensions.includes(ext)) {
|
|
1286
1286
|
alert("Invalid file extension.");
|
|
1287
1287
|
return;
|