From 83f338fbd08da1986493b05c4f172226a3f4c4d5 Mon Sep 17 00:00:00 2001 From: Shivam Agarwal Date: Wed, 16 Jul 2025 12:15:04 +0530 Subject: [PATCH 1/7] creating a custom upload file --- .../.content.xml | 2 +- .../.content.xml | 2 +- .../form/customfileupload/.content.xml | 3 + .../form/customfileupload/v1/.content.xml | 5 + .../v1/customfileupload/.content.xml | 8 + .../clientlibs/site/.content.xml | 6 + .../customfileupload/clientlibs/site/js.txt | 19 ++ .../clientlibs/site/js/fileinputview.js | 140 +++++++++ .../clientlibs/site/js/fileinputwidget.js | 269 ++++++++++++++++++ 9 files changed, 452 insertions(+), 2 deletions(-) create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/.content.xml create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/.content.xml create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/.content.xml create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/.content.xml create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js.txt create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputview.js create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-all-xfa/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-all-xfa/.content.xml index 3bf1de3a89..89969144f0 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-all-xfa/.content.xml +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-all-xfa/.content.xml @@ -5,4 +5,4 @@ cssProcessor="[default:none,min:none]" jsProcessor="[default:none,min:none]" categories="[core.forms.components.runtime.all.xfa]" - embed="[core.forms.components.runtime.base.xfa,core.forms.components.container.v2.runtime,core.forms.components.datePicker.v1.runtime,core.forms.components.textinput.v1.runtime,core.forms.components.numberinput.v1.runtime,core.forms.components.panelcontainer.v1.runtime,core.forms.components.radiobutton.v1.runtime,core.forms.components.text.v1.runtime,core.forms.components.checkboxgroup.v1.runtime,core.forms.components.button.v1.runtime,core.forms.components.image.v1.runtime,core.forms.components.dropdown.v1.runtime,core.forms.components.fileinput.v3.runtime,core.forms.components.accordion.v1.runtime,core.forms.components.tabs.v1.runtime,core.forms.components.wizard.v1.runtime,core.forms.components.verticaltabs.v1.runtime,core.forms.components.recaptcha.v1.runtime,core.forms.components.checkbox.v1.runtime,core.forms.components.fragment.v1.runtime,core.forms.components.switch.v1.runtime,core.forms.components.termsandconditions.v1.runtime, core.forms.components.hcaptcha.v1.runtime,core.forms.components.review.v1.runtime, core.forms.components.turnstile.v1.runtime]"/> + embed="[core.forms.components.runtime.base.xfa,core.forms.components.container.v2.runtime,core.forms.components.datePicker.v1.runtime,core.forms.components.textinput.v1.runtime,core.forms.components.numberinput.v1.runtime,core.forms.components.panelcontainer.v1.runtime,core.forms.components.radiobutton.v1.runtime,core.forms.components.text.v1.runtime,core.forms.components.checkboxgroup.v1.runtime,core.forms.components.button.v1.runtime,core.forms.components.image.v1.runtime,core.forms.components.dropdown.v1.runtime,core.forms.components.fileinput.v3.runtime,core.forms.components.accordion.v1.runtime,core.forms.components.tabs.v1.runtime,core.forms.components.wizard.v1.runtime,core.forms.components.verticaltabs.v1.runtime,core.forms.components.recaptcha.v1.runtime,core.forms.components.checkbox.v1.runtime,core.forms.components.fragment.v1.runtime,core.forms.components.switch.v1.runtime,core.forms.components.termsandconditions.v1.runtime, core.forms.components.hcaptcha.v1.runtime,core.forms.components.review.v1.runtime, core.forms.components.turnstile.v1.runtime, core.forms.components.customfileupload.v1.runtime]"/> diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-all/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-all/.content.xml index 0ef50cf14f..d0d8c106f2 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-all/.content.xml +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/af-clientlibs/core-forms-components-runtime-all/.content.xml @@ -5,4 +5,4 @@ cssProcessor="[default:none,min:none]" jsProcessor="[default:none,min:none]" categories="[core.forms.components.runtime.all]" - embed="[core.forms.components.runtime.base,core.forms.components.container.v2.runtime,core.forms.components.datePicker.v1.runtime,core.forms.components.textinput.v1.runtime,core.forms.components.numberinput.v1.runtime,core.forms.components.panelcontainer.v1.runtime,core.forms.components.radiobutton.v1.runtime,core.forms.components.text.v1.runtime,core.forms.components.checkboxgroup.v1.runtime,core.forms.components.button.v1.runtime,core.forms.components.image.v1.runtime,core.forms.components.dropdown.v1.runtime,core.forms.components.fileinput.v3.runtime,core.forms.components.accordion.v1.runtime,core.forms.components.tabs.v1.runtime,core.forms.components.wizard.v1.runtime,core.forms.components.verticaltabs.v1.runtime,core.forms.components.recaptcha.v1.runtime,core.forms.components.checkbox.v1.runtime,core.forms.components.fragment.v1.runtime,core.forms.components.switch.v1.runtime,core.forms.components.termsandconditions.v1.runtime, core.forms.components.hcaptcha.v1.runtime,core.forms.components.review.v1.runtime, core.forms.components.turnstile.v1.runtime]"/> + embed="[core.forms.components.runtime.base,core.forms.components.container.v2.runtime,core.forms.components.datePicker.v1.runtime,core.forms.components.textinput.v1.runtime,core.forms.components.numberinput.v1.runtime,core.forms.components.panelcontainer.v1.runtime,core.forms.components.radiobutton.v1.runtime,core.forms.components.text.v1.runtime,core.forms.components.checkboxgroup.v1.runtime,core.forms.components.button.v1.runtime,core.forms.components.image.v1.runtime,core.forms.components.dropdown.v1.runtime,core.forms.components.fileinput.v3.runtime,core.forms.components.accordion.v1.runtime,core.forms.components.tabs.v1.runtime,core.forms.components.wizard.v1.runtime,core.forms.components.verticaltabs.v1.runtime,core.forms.components.recaptcha.v1.runtime,core.forms.components.checkbox.v1.runtime,core.forms.components.fragment.v1.runtime,core.forms.components.switch.v1.runtime,core.forms.components.termsandconditions.v1.runtime, core.forms.components.hcaptcha.v1.runtime,core.forms.components.review.v1.runtime, core.forms.components.turnstile.v1.runtime, core.forms.components.customfileupload.v1.runtime]"/> diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/.content.xml new file mode 100644 index 0000000000..3d0c31ab4d --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/.content.xml new file mode 100644 index 0000000000..1437899b31 --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/.content.xml @@ -0,0 +1,5 @@ + + + + diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/.content.xml new file mode 100644 index 0000000000..2a99c0ebaa --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/.content.xml @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/.content.xml b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/.content.xml new file mode 100644 index 0000000000..9ccf799a9f --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/.content.xml @@ -0,0 +1,6 @@ + + diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js.txt b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js.txt new file mode 100644 index 0000000000..22ed485080 --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js.txt @@ -0,0 +1,19 @@ +############################################################################### +# Copyright 2025 Adobe +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +############################################################################### + +#base=js +fileinputwidget.js +fileinputview.js \ No newline at end of file diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputview.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputview.js new file mode 100644 index 0000000000..facb6b181a --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputview.js @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright 2023 Adobe + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ +(function() { + + "use strict"; + class FileInputV3 extends FormView.FormFileInput { + + static NS = FormView.Constants.NS; + /** + * Each FormField has a data attribute class that is prefixed along with the global namespace to + * distinguish between them. If a component wants to put a data-attribute X, the attribute in HTML would be + * data-{NS}-{IS}-x="" + * @type {string} + */ + static IS = "adaptiveFormFileInput"; + static bemBlock = 'cmp-adaptiveform-fileinput' + static selectors = { + self: "[data-" + this.NS + '-is="' + this.IS + '"]', + widget: `.${FileInputV3.bemBlock}__widget`, + label: `.${FileInputV3.bemBlock}__label`, + description: `.${FileInputV3.bemBlock}__longdescription`, + qm: `.${FileInputV3.bemBlock}__questionmark`, + errorDiv: `.${FileInputV3.bemBlock}__errormessage`, + tooltipDiv: `.${FileInputV3.bemBlock}__shortdescription`, + fileListDiv : `.${FileInputV3.bemBlock}__filelist`, + attachButtonLabel : `.${FileInputV3.bemBlock}__widgetlabel`, + dragArea: `.${FileInputV3.bemBlock}__dragarea` + }; + + constructor(params) { + super(params); + } + widgetFields = { + widget: this.getWidget(), + fileListDiv: this.getFileListDiv(), + model: () => this._model, + dragArea: this.getDragArea() + }; + + getWidget() { + return this.element.querySelector(FileInputV3.selectors.widget); + } + + getDragArea() { + return this.element.querySelector(FileInputV3.selectors.dragArea); + } + + getDescription() { + return this.element.querySelector(FileInputV3.selectors.description); + } + + getLabel() { + return this.element.querySelector(FileInputV3.selectors.label); + } + + getErrorDiv() { + return this.element.querySelector(FileInputV3.selectors.errorDiv); + } + + getTooltipDiv() { + return this.element.querySelector(FileInputV3.selectors.tooltipDiv); + } + + getQuestionMarkDiv() { + return this.element.querySelector(FileInputV3.selectors.qm); + } + + getFileListDiv() { + return this.element.querySelector(FileInputV3.selectors.fileListDiv); + } + + getAttachButtonLabel() { + return this.element.querySelector(FileInputV3.selectors.attachButtonLabel); + } + + updateEnabled(enabled, state) { + if (this.widget) { + this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_ENABLED, enabled); + const isDisabled = !enabled || state.readOnly; + if (isDisabled) { + this.widget.setAttribute("disabled", "disabled"); + } else { + this.widget.removeAttribute("disabled"); + } + } + } + + updateValue(value) { + if (this.widgetObject == null) { + this.widgetObject = new FileInputWidget(this.widgetFields); + } + this.widgetObject.setValue(value); + super.updateEmptyStatus(); + } + + setModel(model) { + super.setModel(model); + if (this.widgetObject == null) { + this.widgetObject = new FileInputWidget(this.widgetFields); + } + this.getAttachButtonLabel().addEventListener('focus', () => { + this.setActive(); + }) + this.getAttachButtonLabel().addEventListener('blur', () => { + this.setInactive(); + }) + } + + syncWidget() { + let widgetElement = this.getWidget ? this.getWidget() : null; + if (widgetElement) { + widgetElement.id = this.getId() + "__widget"; + const closestElement = widgetElement?.previousElementSibling; + if (closestElement && closestElement.tagName.toLowerCase() === 'label') { + closestElement.setAttribute('for', this.getId() + "__widget"); + } else { + this.getAttachButtonLabel().removeAttribute('for'); + } + } + } + } + + FormView.Utils.setupField(({element, formContainer}) => { + return new FileInputV3({element, formContainer}) + }, FileInputV3.selectors.self); + +})(); diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js new file mode 100644 index 0000000000..f1c9ceac4e --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js @@ -0,0 +1,269 @@ +/******************************************************************************* + * Copyright 2025 Adobe + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +/** + * This class is responsible for interacting with the file input widget. It implements the file preview, + * file list, handling invalid file size, file name, file mime type functionality + */ + +if (typeof window.FileInputWidget !== 'undefined') { + window.FileInputWidget = class extends FormView.FormFileInputWidget { + + constructor(params) { + super(params); + } + + attachEventHandlers(widget, dragArea, model) { + super.attachEventHandlers(widget, dragArea, model) + const customBtn = dragArea?.querySelector(".cmp-adaptiveform-fileinput__widgetlabel") + customBtn?.addEventListener("click", () => { + widget.click(); + }); + customBtn?.addEventListener('keydown', function(event) { + // Check if the Enter key is pressed + if (event.key === 'Enter' || event.keyCode === 13) { + // Trigger the click event of the file input + widget.click(); + } + }); + } + + fileItem(fileName, fileSize, comment, fileUrl) { + let self = this; + let id = `${Date.now() + '_' + Math.floor(Math.random() * 10000)}_file_size` + let fileItem = document.createElement('li'); + fileItem.setAttribute("class", "cmp-adaptiveform-fileinput__fileitem"); + let fileNameDom = document.createElement('a'); + let fileSizeDom = document.createElement('span'); + + fileSizeDom.setAttribute('class', "cmp-adaptiveform-fileinput__filesize"); + fileSizeDom.setAttribute('id', id); + fileSizeDom.textContent = this.formatBytes(fileSize); + + fileNameDom.setAttribute('tabindex', '0'); + fileNameDom.setAttribute('class', "cmp-adaptiveform-fileinput__filename"); + fileNameDom.setAttribute('aria-describedBY', id); + fileNameDom.textContent = fileName; + fileNameDom.addEventListener('keypress', function(e) { + if (e.keyCode === 13 || e.charCode === 32) { + e.target.click(); + } + }); + fileNameDom.addEventListener('click', function(e) { + self.handleFilePreview(e); + }); + fileItem.appendChild(fileNameDom); + if(fileUrl != null){ + fileNameDom.dataset.key = fileUrl; + } + let fileEndContainer = document.createElement('span'); + let fileClose = document.createElement('button'); + fileEndContainer.setAttribute('class', "cmp-adaptiveform-fileinput__fileendcontainer"); + fileClose.setAttribute('tabindex', '0'); + fileClose.setAttribute('class', "cmp-adaptiveform-fileinput__filedelete"); + fileClose.setAttribute('aria-label', FormView.LanguageUtils.getTranslatedString(this.lang, "FileCloseAccessText") + fileName); + fileClose.textContent = "x"; + fileClose.addEventListener('keypress', function(e) { + if (e.keyCode === 13 || e.charCode === 32) { + e.target.click(); + } + }); + fileClose.addEventListener('click', function(e) { + self.handleClick(e); + }); + fileEndContainer.appendChild(fileSizeDom); + fileEndContainer.appendChild(fileClose); + fileItem.appendChild(fileEndContainer); + return fileItem; + } + + handleChange(filesUploaded) { + if (!this.isFileUpdate) { + let currFileName = '', + inValidSizefileNames = '', + inValidNamefileNames = '', + inValidMimeTypefileNames = '', + self = this, + files = filesUploaded; + // Initially set the invalid flag to false + let isInvalidSize = false, + isInvalidFileName = false, + isInvalidMimeType = false; + //this.resetIfNotMultiSelect(); + if (typeof files !== "undefined") { + let invalidFilesIndexes = []; + let validFileNames = []; + Array.from(files).forEach(function (file, fileIndex) { + let isCurrentInvalidFileSize = false, + isCurrentInvalidFileName = false, + isCurrentInvalidMimeType = false; + currFileName = file.name.split("\\").pop(); + // Now size is in MB + let size = file.size / 1024 / 1024; + // check if file size limit is within limits + if ((size > parseFloat(this.options.maxFileSize))) { + isInvalidSize = isCurrentInvalidFileSize = true; + inValidSizefileNames = currFileName + "," + inValidSizefileNames; + } else if (!FileInputWidget.isValid(currFileName)) { + // check if file names are valid (ie) there are no control characters in file names + isInvalidFileName = isCurrentInvalidFileName = true; + inValidNamefileNames = currFileName + "," + inValidNamefileNames; + } else { + let isMatch = false; + let extension = currFileName.split('.').pop(); + let mimeType = (file.type) ? file.type : self.extensionToMimeTypeMap[extension]; + if (mimeType != undefined && mimeType.trim().length > 0) { + isMatch = this.regexMimeTypeList.some(function (rx) { + return rx.test(mimeType); + }); + } + if (!isMatch) { + isInvalidMimeType = isCurrentInvalidMimeType = true; + inValidMimeTypefileNames = currFileName + "," + inValidMimeTypefileNames; + } + } + + // if the file is not invalid, show it and push it to internal array + if (!isCurrentInvalidFileSize && !isCurrentInvalidFileName && !isCurrentInvalidMimeType) { + // We'll update this.values with the complete URL later + validFileNames.push(currFileName); + if(this.isMultiSelect()) { + this.fileArr.push(file); + } else { + this.fileArr = [file]; + } + } else { + invalidFilesIndexes.push(fileIndex); + } + }, this); + + // Handle file upload for valid files + if (validFileNames.length > 0) { + // Upload file and get URL + let fileUrl = this.uploadFile(files); + if (this.isMultiSelect()) { + Array.from(files).forEach(function (file, fileIndex) { + let completeUrl = fileUrl + "/" + file.name; + this.values.push(completeUrl); + }, this); + } else { + let completeUrl = fileUrl + "/" + files[0].name; + this.values = [completeUrl]; + } + } + + if (invalidFilesIndexes.length > 0 && this.widget !== null) { + this.deleteFilesFromInputDom(invalidFilesIndexes); + } + } + + // set the new model value. + this.model.value = this.fileArr; + //this.model.validate(); + + if (isInvalidSize) { + this.showInvalidMessage(inValidSizefileNames.substring(0, inValidSizefileNames.lastIndexOf(',')), this.invalidFeature.SIZE); + } else if (isInvalidFileName) { + this.showInvalidMessage(inValidNamefileNames.substring(0, inValidNamefileNames.lastIndexOf(',')), this.invalidFeature.NAME); + } else if (isInvalidMimeType) { + this.showInvalidMessage(inValidMimeTypefileNames.substring(0, inValidMimeTypefileNames.lastIndexOf(',')), this.invalidFeature.MIMETYPE); + } + } + this.widget.value = null; + } + + uploadFile (filesObject) { + let s3UploadUrl = "/services/s3/presign", // URL for getting S3 presigned URL + multiple = this.isMultiSelect(); // Check if multiple files can be uploaded; + + let self = this; + if (multiple) { + let uploadPromises = []; + Array.from(filesObject).forEach(function (file, fileIndex) { + uploadPromises.push(self.uploadFileToS3(file, s3UploadUrl, file.name)); + }, this); + + // Wait for all files to upload + Promise.all(uploadPromises).then(function(results) { + console.log("fileuploaded successfully"); + //self.handleMultipleFileUpload(results); + }).catch(function(error) { + console.error("Error uploading files:", error); + //self.$element.trigger("adobeFileUploader.fileUploadFailed"); + }); + } else { + this.uploadFileToS3(filesObject[0], s3UploadUrl, filesObject[0].name).then(function(result) { + console.log("fileuploaded successfully"); + }).catch(function(error) { + console.error("Error uploading file:", error); + // self.$element.trigger("adobeFileUploader.fileUploadFailed"); + }); + } + return s3UploadUrl; + } + + // Helper method to handle file upload to S3 + uploadFileToS3(file, presignEndpoint, fileName) { + // Return a resolved promise with a sample URL + // This is just for testing - replace with actual implementation + return new Promise((resolve) => { + // Simulate network delay + setTimeout(() => { + // For testing: construct a sample URL using the fileName + const sampleUrl = presignEndpoint + "/" + fileName; + + // Return an object with url and other metadata + resolve({ + success: true, + url: sampleUrl, + fileName: fileName, + fileSize: file.size, + fileType: file.type, + lastModified: file.lastModified + }); + }, 500); // 500ms delay to simulate network request + }); + + /* Real implementation would look like this: + return fetch(presignEndpoint, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + fileName: fileName, + contentType: file.type + }) + }) + .then(response => response.json()) + .then(presignedData => { + return fetch(presignedData.url, { + method: 'PUT', + body: file, + headers: presignedData.headers || {} + }); + }) + .then(() => { + return { + success: true, + url: this.fileUrl, + fileName: fileName + }; + }); + */ + } + } +} \ No newline at end of file From e9b4997fd91481dcf93d3b93835abf3ab8811668 Mon Sep 17 00:00:00 2001 From: Shivam Agarwal Date: Thu, 17 Jul 2025 14:32:03 +0530 Subject: [PATCH 2/7] updating payload to send url instead of file --- .../clientlibs/site/js/fileinputwidget.js | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js index f1c9ceac4e..df6d77664e 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js @@ -105,7 +105,7 @@ if (typeof window.FileInputWidget !== 'undefined') { //this.resetIfNotMultiSelect(); if (typeof files !== "undefined") { let invalidFilesIndexes = []; - let validFileNames = []; + let validFiles = []; Array.from(files).forEach(function (file, fileIndex) { let isCurrentInvalidFileSize = false, isCurrentInvalidFileName = false, @@ -139,29 +139,26 @@ if (typeof window.FileInputWidget !== 'undefined') { // if the file is not invalid, show it and push it to internal array if (!isCurrentInvalidFileSize && !isCurrentInvalidFileName && !isCurrentInvalidMimeType) { // We'll update this.values with the complete URL later - validFileNames.push(currFileName); - if(this.isMultiSelect()) { - this.fileArr.push(file); - } else { - this.fileArr = [file]; - } + validFiles.push(file); } else { invalidFilesIndexes.push(fileIndex); } }, this); // Handle file upload for valid files - if (validFileNames.length > 0) { + if (validFiles.length > 0) { // Upload file and get URL - let fileUrl = this.uploadFile(files); + let fileUrl = this.uploadFile(validFiles); if (this.isMultiSelect()) { - Array.from(files).forEach(function (file, fileIndex) { + Array.from(validFiles).forEach(function (file, fileIndex) { let completeUrl = fileUrl + "/" + file.name; - this.values.push(completeUrl); + this.fileArr.push(completeUrl); + this.values.push(file.name); }, this); } else { let completeUrl = fileUrl + "/" + files[0].name; - this.values = [completeUrl]; + this.values = [validFiles[0].name]; + this.fileArr = [completeUrl]; } } From 5e4cc08debe6185d8ad8da72c53d833ba0a1a544 Mon Sep 17 00:00:00 2001 From: Shivam Agarwal Date: Fri, 18 Jul 2025 12:47:30 +0530 Subject: [PATCH 3/7] resolving file error --- .../clientlibs/site/js/fileinputwidget.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js index df6d77664e..530371c3d2 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js @@ -97,6 +97,7 @@ if (typeof window.FileInputWidget !== 'undefined') { inValidNamefileNames = '', inValidMimeTypefileNames = '', self = this, + uris = [], files = filesUploaded; // Initially set the invalid flag to false let isInvalidSize = false, @@ -152,13 +153,15 @@ if (typeof window.FileInputWidget !== 'undefined') { if (this.isMultiSelect()) { Array.from(validFiles).forEach(function (file, fileIndex) { let completeUrl = fileUrl + "/" + file.name; + uris.push(completeUrl); this.fileArr.push(completeUrl); - this.values.push(file.name); + this.values.push(completeUrl); }, this); } else { - let completeUrl = fileUrl + "/" + files[0].name; - this.values = [validFiles[0].name]; + let completeUrl = fileUrl + "/" + validFiles[0].name; + this.values = [completeUrl]; this.fileArr = [completeUrl]; + uris.push(completeUrl); } } @@ -169,7 +172,10 @@ if (typeof window.FileInputWidget !== 'undefined') { // set the new model value. this.model.value = this.fileArr; - //this.model.validate(); + + Array.from(uris).forEach(function (uri, fileIndex) { + this.fileList.querySelectorAll('.cmp-adaptiveform-fileinput__filename')[fileIndex].dataset.key = uri; + }, this); if (isInvalidSize) { this.showInvalidMessage(inValidSizefileNames.substring(0, inValidSizefileNames.lastIndexOf(',')), this.invalidFeature.SIZE); From 3a1ef8fda2402bc11fc89dd72ad519fb2bd31e2a Mon Sep 17 00:00:00 2001 From: Shivam Agarwal Date: Fri, 18 Jul 2025 13:12:02 +0530 Subject: [PATCH 4/7] hiding file size --- .../v1/customfileupload/clientlibs/site/js/fileinputwidget.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js index 530371c3d2..c1f7c4d03c 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js @@ -175,6 +175,7 @@ if (typeof window.FileInputWidget !== 'undefined') { Array.from(uris).forEach(function (uri, fileIndex) { this.fileList.querySelectorAll('.cmp-adaptiveform-fileinput__filename')[fileIndex].dataset.key = uri; + this.fileList.querySelectorAll('.cmp-adaptiveform-fileinput__filesize')[fileIndex].hidden = true; }, this); if (isInvalidSize) { From 20e410a2b72482fbb236de138041de545afeca5e Mon Sep 17 00:00:00 2001 From: Shivam Agarwal Date: Fri, 18 Jul 2025 15:38:32 +0530 Subject: [PATCH 5/7] handling new component changes --- .../clientlibs/site/js/fileinputview.js | 8 +-- .../clientlibs/site/js/fileinputwidget.js | 4 +- .../v1/customfileupload/customfileupload.html | 68 ++++++++++++++++++ ui.frontend/src/index.js | 4 +- ui.frontend/src/view/FormCustomFileInput.js | 71 +++++++++++++++++++ ui.frontend/src/view/index.js | 3 +- 6 files changed, 149 insertions(+), 9 deletions(-) create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/customfileupload.html create mode 100644 ui.frontend/src/view/FormCustomFileInput.js diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputview.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputview.js index facb6b181a..a5585a019f 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputview.js +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputview.js @@ -16,7 +16,7 @@ (function() { "use strict"; - class FileInputV3 extends FormView.FormFileInput { + class FileInputV3 extends FormView.FormCustomFileInput { static NS = FormView.Constants.NS; /** @@ -25,7 +25,7 @@ * data-{NS}-{IS}-x="" * @type {string} */ - static IS = "adaptiveFormFileInput"; + static IS = "adaptiveFormCustomFileInput"; static bemBlock = 'cmp-adaptiveform-fileinput' static selectors = { self: "[data-" + this.NS + '-is="' + this.IS + '"]', @@ -100,7 +100,7 @@ updateValue(value) { if (this.widgetObject == null) { - this.widgetObject = new FileInputWidget(this.widgetFields); + this.widgetObject = new CustomFileInputWidget(this.widgetFields); } this.widgetObject.setValue(value); super.updateEmptyStatus(); @@ -109,7 +109,7 @@ setModel(model) { super.setModel(model); if (this.widgetObject == null) { - this.widgetObject = new FileInputWidget(this.widgetFields); + this.widgetObject = new CustomFileInputWidget(this.widgetFields); } this.getAttachButtonLabel().addEventListener('focus', () => { this.setActive(); diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js index c1f7c4d03c..e49f8ccc40 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js @@ -19,8 +19,8 @@ * file list, handling invalid file size, file name, file mime type functionality */ -if (typeof window.FileInputWidget !== 'undefined') { - window.FileInputWidget = class extends FormView.FormFileInputWidget { +if (typeof window.CustomFileInputWidget === 'undefined') { + window.CustomFileInputWidget = class extends FormView.FormFileInputWidget { constructor(params) { super(params); diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/customfileupload.html b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/customfileupload.html new file mode 100644 index 0000000000..b7c77dfca6 --- /dev/null +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/customfileupload.html @@ -0,0 +1,68 @@ + + + + + +
+
+
+
+
+
+
+
+
+
${file.dragDropText @context='html'}
+ + +
+
    +
    +
    +
    +
    +
    +
    + + + + diff --git a/ui.frontend/src/index.js b/ui.frontend/src/index.js index 8ac52985ff..e787e0afbb 100644 --- a/ui.frontend/src/index.js +++ b/ui.frontend/src/index.js @@ -16,7 +16,7 @@ import Utils from "./utils.js"; import LanguageUtils from "./LanguageUtils.js"; import {createFormInstance, FileObject, extractFileInfo, readAttachments, Click, Change, Submit, Save, Blur, AddItem, RemoveItem, CustomEvent, UIChange} from "@aemforms/af-core"; -import {FormField, FormContainer, FormFieldBase, FormPanel, FormTabs, FormFileInput, FormOptionFieldBase, FormCheckBox, FormFileInputWidgetBase, FormFileInputWidget} from "./view/index.js"; +import {FormField, FormContainer, FormFieldBase, FormPanel, FormTabs, FormFileInput, FormCustomFileInput, FormOptionFieldBase, FormCheckBox, FormFileInputWidgetBase, FormFileInputWidget} from "./view/index.js"; import {Constants} from "./constants.js"; import GuideBridge from "./GuideBridge.js"; import HTTPAPILayer from "./HTTPAPILayer.js"; @@ -79,4 +79,4 @@ const FileAttachmentUtils = { */ -export {createFormInstance, FormTabs, FormField, FormFieldBase, FormPanel, FormContainer, Constants, Utils, Actions, HTTPAPILayer, FileAttachmentUtils, Formatters, LanguageUtils, FunctionRuntime, FormCheckBox, FormOptionFieldBase, FormFileInput, FormFileInputWidgetBase, customFunctions, FormFileInputWidget}; +export {createFormInstance, FormTabs, FormField, FormFieldBase, FormPanel, FormContainer, Constants, Utils, Actions, HTTPAPILayer, FileAttachmentUtils, Formatters, LanguageUtils, FunctionRuntime, FormCheckBox, FormOptionFieldBase, FormFileInput, FormCustomFileInput, FormFileInputWidgetBase, customFunctions, FormFileInputWidget}; diff --git a/ui.frontend/src/view/FormCustomFileInput.js b/ui.frontend/src/view/FormCustomFileInput.js new file mode 100644 index 0000000000..267af47c35 --- /dev/null +++ b/ui.frontend/src/view/FormCustomFileInput.js @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright 2025 Adobe + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +import FormFieldBase from "./FormFieldBase.js"; + +/** + * Class representing components based on FileInput. + * @extends module:FormView~FormFileInput + */ +class FormCustomFileInput extends FormFieldBase { + + constructor(params) { + super(params); + } + + setModel(model) { + super.setModel(model); + if (this.widgetObject == null) { + this.widgetObject = new CustomFileInputWidget(this.widgetFields); + } + } + + updateValue(value) { + if (this.widgetObject == null) { + this.widgetObject = new CustomFileInputWidget(this.widgetFields); + } + this.widgetObject.setValue(value); + super.updateEmptyStatus(); + } + + syncWidget() { + let widgetElement = this.getWidget ? this.getWidget() : null; + if (widgetElement) { + widgetElement.id = this.getId() + "__widget"; + this.getAttachButtonLabel().setAttribute('for', this.getId() + "__widget"); + } + } + + /* + We are overriding the syncLabel method of the FormFieldBase class because for all components, + we pass the widgetId in 'for' attribute. However, for the file input component, + we already have a widget, so we should not pass the widgetId twice + */ + syncLabel() { + let labelElement = typeof this.getLabel === 'function' ? this.getLabel() : null; + if (labelElement) { + labelElement.setAttribute('for', this.getId()); + } + } + + syncMarkupWithModel() { + super.syncMarkupWithModel(); + this.syncWidget(); + this.syncLabel(); + } +} + +export default FormCustomFileInput; \ No newline at end of file diff --git a/ui.frontend/src/view/index.js b/ui.frontend/src/view/index.js index f350d4cf61..d163727a3f 100644 --- a/ui.frontend/src/view/index.js +++ b/ui.frontend/src/view/index.js @@ -20,9 +20,10 @@ import FormPanel from "./FormPanel.js"; import FormTabs from "./FormTabs.js"; import FormCheckBox from "./FormCheckBox.js"; import FormFileInput from "./FormFileInput.js"; +import FormCustomFileInput from "./FormCustomFileInput.js"; import FormFileInputWidgetBase from "./FormFileInputWidgetBase.js"; import FormOptionFieldBase from "./FormOptionFieldBase"; import FormFileInputWidget from "./FormFileInputWidget.js"; -export {FormField, FormContainer, FormFieldBase, FormPanel, FormTabs, FormCheckBox, FormOptionFieldBase, FormFileInput, FormFileInputWidgetBase, FormFileInputWidget } +export {FormField, FormContainer, FormFieldBase, FormPanel, FormTabs, FormCheckBox, FormOptionFieldBase, FormFileInput, FormCustomFileInput, FormFileInputWidgetBase, FormFileInputWidget } From 674d8d1781e19a23a2b76c1f3adadfe892d04866 Mon Sep 17 00:00:00 2001 From: Shivam Agarwal Date: Mon, 21 Jul 2025 14:28:00 +0530 Subject: [PATCH 6/7] handling new component changes fix --- .../clientlibs/site/js/fileinputview.js | 15 +++- ui.frontend/src/index.js | 4 +- ui.frontend/src/view/FormCustomFileInput.js | 71 ------------------- ui.frontend/src/view/index.js | 3 +- 4 files changed, 17 insertions(+), 76 deletions(-) delete mode 100644 ui.frontend/src/view/FormCustomFileInput.js diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputview.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputview.js index a5585a019f..3afe972702 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputview.js +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputview.js @@ -16,7 +16,7 @@ (function() { "use strict"; - class FileInputV3 extends FormView.FormCustomFileInput { + class FileInputV3 extends FormView.FormFieldBase { static NS = FormView.Constants.NS; /** @@ -131,6 +131,19 @@ } } } + + syncLabel() { + let labelElement = typeof this.getLabel === 'function' ? this.getLabel() : null; + if (labelElement) { + labelElement.setAttribute('for', this.getId()); + } + } + + syncMarkupWithModel() { + super.syncMarkupWithModel(); + this.syncWidget(); + this.syncLabel(); + } } FormView.Utils.setupField(({element, formContainer}) => { diff --git a/ui.frontend/src/index.js b/ui.frontend/src/index.js index e787e0afbb..8ac52985ff 100644 --- a/ui.frontend/src/index.js +++ b/ui.frontend/src/index.js @@ -16,7 +16,7 @@ import Utils from "./utils.js"; import LanguageUtils from "./LanguageUtils.js"; import {createFormInstance, FileObject, extractFileInfo, readAttachments, Click, Change, Submit, Save, Blur, AddItem, RemoveItem, CustomEvent, UIChange} from "@aemforms/af-core"; -import {FormField, FormContainer, FormFieldBase, FormPanel, FormTabs, FormFileInput, FormCustomFileInput, FormOptionFieldBase, FormCheckBox, FormFileInputWidgetBase, FormFileInputWidget} from "./view/index.js"; +import {FormField, FormContainer, FormFieldBase, FormPanel, FormTabs, FormFileInput, FormOptionFieldBase, FormCheckBox, FormFileInputWidgetBase, FormFileInputWidget} from "./view/index.js"; import {Constants} from "./constants.js"; import GuideBridge from "./GuideBridge.js"; import HTTPAPILayer from "./HTTPAPILayer.js"; @@ -79,4 +79,4 @@ const FileAttachmentUtils = { */ -export {createFormInstance, FormTabs, FormField, FormFieldBase, FormPanel, FormContainer, Constants, Utils, Actions, HTTPAPILayer, FileAttachmentUtils, Formatters, LanguageUtils, FunctionRuntime, FormCheckBox, FormOptionFieldBase, FormFileInput, FormCustomFileInput, FormFileInputWidgetBase, customFunctions, FormFileInputWidget}; +export {createFormInstance, FormTabs, FormField, FormFieldBase, FormPanel, FormContainer, Constants, Utils, Actions, HTTPAPILayer, FileAttachmentUtils, Formatters, LanguageUtils, FunctionRuntime, FormCheckBox, FormOptionFieldBase, FormFileInput, FormFileInputWidgetBase, customFunctions, FormFileInputWidget}; diff --git a/ui.frontend/src/view/FormCustomFileInput.js b/ui.frontend/src/view/FormCustomFileInput.js deleted file mode 100644 index 267af47c35..0000000000 --- a/ui.frontend/src/view/FormCustomFileInput.js +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright 2025 Adobe - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -import FormFieldBase from "./FormFieldBase.js"; - -/** - * Class representing components based on FileInput. - * @extends module:FormView~FormFileInput - */ -class FormCustomFileInput extends FormFieldBase { - - constructor(params) { - super(params); - } - - setModel(model) { - super.setModel(model); - if (this.widgetObject == null) { - this.widgetObject = new CustomFileInputWidget(this.widgetFields); - } - } - - updateValue(value) { - if (this.widgetObject == null) { - this.widgetObject = new CustomFileInputWidget(this.widgetFields); - } - this.widgetObject.setValue(value); - super.updateEmptyStatus(); - } - - syncWidget() { - let widgetElement = this.getWidget ? this.getWidget() : null; - if (widgetElement) { - widgetElement.id = this.getId() + "__widget"; - this.getAttachButtonLabel().setAttribute('for', this.getId() + "__widget"); - } - } - - /* - We are overriding the syncLabel method of the FormFieldBase class because for all components, - we pass the widgetId in 'for' attribute. However, for the file input component, - we already have a widget, so we should not pass the widgetId twice - */ - syncLabel() { - let labelElement = typeof this.getLabel === 'function' ? this.getLabel() : null; - if (labelElement) { - labelElement.setAttribute('for', this.getId()); - } - } - - syncMarkupWithModel() { - super.syncMarkupWithModel(); - this.syncWidget(); - this.syncLabel(); - } -} - -export default FormCustomFileInput; \ No newline at end of file diff --git a/ui.frontend/src/view/index.js b/ui.frontend/src/view/index.js index d163727a3f..f350d4cf61 100644 --- a/ui.frontend/src/view/index.js +++ b/ui.frontend/src/view/index.js @@ -20,10 +20,9 @@ import FormPanel from "./FormPanel.js"; import FormTabs from "./FormTabs.js"; import FormCheckBox from "./FormCheckBox.js"; import FormFileInput from "./FormFileInput.js"; -import FormCustomFileInput from "./FormCustomFileInput.js"; import FormFileInputWidgetBase from "./FormFileInputWidgetBase.js"; import FormOptionFieldBase from "./FormOptionFieldBase"; import FormFileInputWidget from "./FormFileInputWidget.js"; -export {FormField, FormContainer, FormFieldBase, FormPanel, FormTabs, FormCheckBox, FormOptionFieldBase, FormFileInput, FormCustomFileInput, FormFileInputWidgetBase, FormFileInputWidget } +export {FormField, FormContainer, FormFieldBase, FormPanel, FormTabs, FormCheckBox, FormOptionFieldBase, FormFileInput, FormFileInputWidgetBase, FormFileInputWidget } From ac458ea500ae3d4acc00494226b6e15e5c42e4d7 Mon Sep 17 00:00:00 2001 From: Shivam Agarwal Date: Mon, 21 Jul 2025 15:02:46 +0530 Subject: [PATCH 7/7] file size should be hidden --- .../v1/customfileupload/clientlibs/site/js/fileinputwidget.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js index e49f8ccc40..d97bd08707 100644 --- a/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js +++ b/ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/customfileupload/v1/customfileupload/clientlibs/site/js/fileinputwidget.js @@ -51,6 +51,7 @@ if (typeof window.CustomFileInputWidget === 'undefined') { fileSizeDom.setAttribute('class', "cmp-adaptiveform-fileinput__filesize"); fileSizeDom.setAttribute('id', id); + fileSizeDom.setAttribute('hidden', true); fileSizeDom.textContent = this.formatBytes(fileSize); fileNameDom.setAttribute('tabindex', '0');