@widergy/energy-ui 3.142.2 → 3.143.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [3.143.0](https://github.com/widergy/energy-ui/compare/v3.142.2...v3.143.0) (2026-04-15)
2
+
3
+
4
+ ### Features
5
+
6
+ * [BRILLA-339] persist file name and xls download ([#774](https://github.com/widergy/energy-ui/issues/774)) ([d2486f3](https://github.com/widergy/energy-ui/commit/d2486f3f475299954245b051defaa527c1c1e0c1))
7
+
1
8
  ## [3.142.2](https://github.com/widergy/energy-ui/compare/v3.142.1...v3.142.2) (2026-04-15)
2
9
 
3
10
 
@@ -76,7 +76,7 @@ const AttachmentListContainer = _ref => {
76
76
  const loadPreview = file => new Promise((resolve, reject) => {
77
77
  const reader = new FileReader();
78
78
  reader.onload = e => {
79
- if ((0, _utils.hasPreview)(file)) {
79
+ if ((0, _utils.hasPreview)(file) || (0, _utils.isDownloadable)(file)) {
80
80
  resolve({
81
81
  src: e.target.result,
82
82
  file
@@ -190,7 +190,9 @@ const AttachmentListContainer = _ref => {
190
190
  const imageUrl = Array.isArray(input.value) ? ((_input$value$index = input.value[index]) === null || _input$value$index === void 0 ? void 0 : _input$value$index.url) || ((_formattedImages$inde = formattedImages[index]) === null || _formattedImages$inde === void 0 ? void 0 : _formattedImages$inde.url) : input.value;
191
191
  (0, _utils.getBlobFromUrl)(imageUrl, async response => {
192
192
  if (response) {
193
- const newFile = new File([response], (0, _utils.getDefaultAttachment)(response.type.substring(response.type.indexOf('/') + 1), index + 1), {
193
+ var _input$value$index2, _formattedImages$inde2;
194
+ const itemName = Array.isArray(input.value) ? ((_input$value$index2 = input.value[index]) === null || _input$value$index2 === void 0 ? void 0 : _input$value$index2.name) || ((_formattedImages$inde2 = formattedImages[index]) === null || _formattedImages$inde2 === void 0 ? void 0 : _formattedImages$inde2.name) : null;
195
+ const newFile = new File([response], itemName || (0, _utils.getDefaultAttachment)(response.type.substring(response.type.indexOf('/') + 1), index + 1), {
194
196
  type: response.type
195
197
  });
196
198
  loadDefaultValues(index + 1, [...accumulatedFiles, newFile]);
@@ -112,9 +112,9 @@ const AttachmentList = _ref => {
112
112
  },
113
113
  size: "small",
114
114
  variant: "text"
115
- }), (0, _utils.isPDF)(previewItem) && previewItem.src && /*#__PURE__*/_react.default.createElement(_UTButton.default, {
115
+ }), (0, _utils.isDownloadable)(previewItem) && previewItem.src && /*#__PURE__*/_react.default.createElement(_UTButton.default, {
116
116
  Icon: "IconDownload",
117
- onClick: () => (0, _downloadjs.default)(previewItem.src, previewItem.name, 'application/pdf'),
117
+ onClick: () => (0, _downloadjs.default)(previewItem.src, previewItem.name, previewItem.type),
118
118
  size: "small",
119
119
  variant: "text"
120
120
  }), /*#__PURE__*/_react.default.createElement(_UTButton.default, {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.pdfAspectRatioValidation = exports.isVideo = exports.isValidFile = exports.isPDF = exports.isNewFile = exports.isImage = exports.isHTML = exports.isAudio = exports.hasPreview = exports.getSizeInMB = exports.getNotRepeatedFiles = exports.getDefaultAttachment = exports.getBlobFromUrl = exports.getAvailableFileTypesLabel = void 0;
6
+ exports.pdfAspectRatioValidation = exports.isXLSX = exports.isXLS = exports.isVideo = exports.isValidFile = exports.isPDF = exports.isNewFile = exports.isImage = exports.isHTML = exports.isDownloadable = exports.isCSV = exports.isAudio = exports.hasPreview = exports.getSizeInMB = exports.getNotRepeatedFiles = exports.getDefaultAttachment = exports.getBlobFromUrl = exports.getAvailableFileTypesLabel = void 0;
7
7
  var _files = require("@widergy/web-utils/lib/constants/files");
8
8
  var _constants = require("./constants");
9
9
  if (window['pdfjs-dist/build/pdf']) window['pdfjs-dist/build/pdf'].GlobalWorkerOptions.workerSrc = "//cdnjs.cloudflare.com/ajax/libs/pdf.js/".concat(window['pdfjs-dist/build/pdf'].version, "/pdf.worker.js");
@@ -49,6 +49,14 @@ const isVideo = file => _files.inputFiles.video.validType.includes(file === null
49
49
  exports.isVideo = isVideo;
50
50
  const isHTML = file => _files.inputFiles.html.validType.includes(file === null || file === void 0 ? void 0 : file.type);
51
51
  exports.isHTML = isHTML;
52
+ const isCSV = file => _files.inputFiles.csv.validType.includes(file === null || file === void 0 ? void 0 : file.type);
53
+ exports.isCSV = isCSV;
54
+ const isXLS = file => _files.inputFiles.xls.validType.includes(file === null || file === void 0 ? void 0 : file.type);
55
+ exports.isXLS = isXLS;
56
+ const isXLSX = file => _files.inputFiles.xlsx.validType.includes(file === null || file === void 0 ? void 0 : file.type);
57
+ exports.isXLSX = isXLSX;
58
+ const isDownloadable = file => isPDF(file) || isCSV(file) || isXLS(file) || isXLSX(file);
59
+ exports.isDownloadable = isDownloadable;
52
60
  const hasPreview = file => isImage(file) || isAudio(file) || isVideo(file) || isPDF(file);
53
61
  exports.hasPreview = hasPreview;
54
62
  const isValidFile = file => hasPreview(file) || isPDF(file) || isHTML(file);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/energy-ui",
3
- "version": "3.142.2",
3
+ "version": "3.143.0",
4
4
  "description": "Widergy Web Components",
5
5
  "author": "widergy",
6
6
  "license": "MIT",