@widergy/energy-ui 3.119.1 → 3.119.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [3.119.3](https://github.com/widergy/energy-ui/compare/v3.119.2...v3.119.3) (2025-11-12)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * [BRILLA-58] handle attachment list preview files ([#718](https://github.com/widergy/energy-ui/issues/718)) ([74b31d0](https://github.com/widergy/energy-ui/commit/74b31d019685dc558b40845dab75a180b943505e))
7
+
8
+ ## [3.119.2](https://github.com/widergy/energy-ui/compare/v3.119.1...v3.119.2) (2025-11-07)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add hideheader to utactioncard ([#719](https://github.com/widergy/energy-ui/issues/719)) ([7f0b7ca](https://github.com/widergy/energy-ui/commit/7f0b7ca9c0ad521d5a8b83a9c5d0d6c7bd8f7a7c))
14
+
1
15
  ## [3.119.1](https://github.com/widergy/energy-ui/compare/v3.119.0...v3.119.1) (2025-11-07)
2
16
 
3
17
 
@@ -15,6 +15,7 @@
15
15
  | `descriptionProps` | `shape({ colorTheme: string, variant: string })` | | Props to customize the description's style. |
16
16
  | `headerActions` | `arrayOf(shape({ Icon: oneOfType([elementType, string]), iconProps: string, id: oneOfType([number, string]), label: string, loading: bool, onClick: func }))` | | List of actions available in the header section. |
17
17
  | `headerActionsProps` | `shape({ alignment: oneOf(['center', 'end', 'start']), buttonGroupProps: shape({ colorTheme: string, shape: string }), variant: oneOf(['default', 'buttonGroup']) })` | | Props to configure header actions alignment, button group, etc. |
18
+ | `hideHeader` | `bool` | `false` | Hides the header section of the card. |
18
19
  | `mainAction` | `func` | | Main action function for the card. |
19
20
  | `size` | `oneOf(['medium', 'small'])` | `'medium'` | Size of the card, either small or medium. |
20
21
  | `status` | `string` | | Status text to be displayed. |
@@ -32,6 +32,7 @@ const UTActionCard = _ref => {
32
32
  headerActionsProps = {
33
33
  variant: _constants.HEADER_ACTIONS_VARIANTS.DEFAULT
34
34
  },
35
+ hideHeader = false,
35
36
  mainAction,
36
37
  size = _constants.SIZES.MEDIUM,
37
38
  status,
@@ -59,7 +60,7 @@ const UTActionCard = _ref => {
59
60
  "data-testid": backgroundDataTestId
60
61
  }), /*#__PURE__*/_react.default.createElement("div", {
61
62
  className: "".concat(_stylesModule.default.headerAndChildrenContainer, " ").concat(classNames.headerAndChildrenContainer)
62
- }, /*#__PURE__*/_react.default.createElement(_Header.default, {
63
+ }, !hideHeader && /*#__PURE__*/_react.default.createElement(_Header.default, {
63
64
  adornment,
64
65
  classNames,
65
66
  description,
@@ -76,7 +77,7 @@ const UTActionCard = _ref => {
76
77
  title,
77
78
  titleProps
78
79
  }), children && /*#__PURE__*/_react.default.createElement("div", {
79
- className: "".concat(withBodyPadding ? _stylesModule.default["bodyPadding-".concat(size)] : _stylesModule.default["withoutBodyPadding-".concat(size)])
80
+ className: "".concat(hideHeader ? _stylesModule.default.withoutHeader : '', " ").concat(withBodyPadding ? _stylesModule.default["bodyPadding-".concat(size)] : _stylesModule.default["withoutBodyPadding-".concat(size)])
80
81
  }, children))), !(0, _object.objectIsEmpty)(additionalMessage) && /*#__PURE__*/_react.default.createElement(_AdditionalMessage.default, _extends({}, additionalMessage, {
81
82
  size: size
82
83
  })), !(0, _array.isEmpty)(bottomActions) && /*#__PURE__*/_react.default.createElement(_BottomActions.default, {
@@ -136,6 +137,7 @@ UTActionCard.propTypes = {
136
137
  }),
137
138
  variant: (0, _propTypes.oneOf)([_constants.HEADER_ACTIONS_VARIANTS.DEFAULT, _constants.HEADER_ACTIONS_VARIANTS.BUTTON_GROUP])
138
139
  }),
140
+ hideHeader: _propTypes.bool,
139
141
  mainAction: _propTypes.func,
140
142
  size: (0, _propTypes.oneOf)([_constants.SIZES.MEDIUM, _constants.SIZES.SMALL]),
141
143
  status: _propTypes.string,
@@ -77,3 +77,7 @@ $default-shadow-gray-bottom-1: 0px 3px 6px rgba(24, 44, 73, 0.1);
77
77
  .withoutBodyPadding-medium {
78
78
  padding-bottom: 24px;
79
79
  }
80
+
81
+ .withoutHeader {
82
+ padding-top: 24px;
83
+ }
@@ -3,11 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.previewPropType = exports.UPLOAD_FILE = exports.SIZE_ERROR_TEXT = exports.MB_LABEL = exports.MAX_SIZE_FILE_LABEL = exports.MAX_FILES_ERROR = exports.INDICATIONS = exports.FORMAT_FILE_LABEL = exports.FORMAT_ERROR_TEXT = exports.DEFAULT_UPLOADING_TEXT = exports.DEFAULT_MAX_FILES = exports.DEFAULT_ATTACHMENT_NAME = exports.ASPECT_RATIO_ERROR_TEXT = void 0;
6
+ exports.previewPropType = exports.UPLOAD_FILE = exports.SIZE_ERROR_TEXT = exports.PREVIEW_TYPES = exports.MB_LABEL = exports.MAX_SIZE_FILE_LABEL = exports.MAX_FILES_ERROR = exports.INDICATIONS = exports.FORMAT_FILE_LABEL = exports.FORMAT_ERROR_TEXT = exports.FILE_NOT_FOUND_ERROR_TEXT = exports.DEFAULT_UPLOADING_TEXT = exports.DEFAULT_MAX_FILES = exports.DEFAULT_ATTACHMENT_NAME = exports.ASPECT_RATIO_ERROR_TEXT = void 0;
7
7
  var _propTypes = require("prop-types");
8
8
  const FORMAT_ERROR_TEXT = exports.FORMAT_ERROR_TEXT = 'El formato no es compatible';
9
9
  const SIZE_ERROR_TEXT = exports.SIZE_ERROR_TEXT = 'El archivo supera los ';
10
10
  const ASPECT_RATIO_ERROR_TEXT = exports.ASPECT_RATIO_ERROR_TEXT = 'El formato de archivo es inválido. (Válidos:';
11
+ const FILE_NOT_FOUND_ERROR_TEXT = exports.FILE_NOT_FOUND_ERROR_TEXT = 'Hubo un error al cargar el archivo';
11
12
  const DEFAULT_UPLOADING_TEXT = exports.DEFAULT_UPLOADING_TEXT = 'Cargando...';
12
13
  const DEFAULT_ATTACHMENT_NAME = exports.DEFAULT_ATTACHMENT_NAME = 'Adjunto';
13
14
  const FORMAT_FILE_LABEL = exports.FORMAT_FILE_LABEL = 'Debe tener formato: ';
@@ -17,6 +18,10 @@ const INDICATIONS = exports.INDICATIONS = 'Arrastra y suelta o';
17
18
  const MB_LABEL = exports.MB_LABEL = 'MB';
18
19
  const MAX_FILES_ERROR = exports.MAX_FILES_ERROR = 'Se ha excedido el límite máximo de archivos permitidos ';
19
20
  const DEFAULT_MAX_FILES = exports.DEFAULT_MAX_FILES = 1;
21
+ const PREVIEW_TYPES = exports.PREVIEW_TYPES = {
22
+ ERROR: 'error',
23
+ LOADING: 'loading'
24
+ };
20
25
  const previewPropType = exports.previewPropType = (0, _propTypes.shape)({
21
26
  audio: _propTypes.object,
22
27
  image: _propTypes.object,
@@ -17,7 +17,7 @@ var _layout = _interopRequireDefault(require("./layout"));
17
17
  var _utils = require("./utils");
18
18
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
19
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
20
- const AttachmentContainer = _ref => {
20
+ const AttachmentListContainer = _ref => {
21
21
  var _field$configuration, _field$configuration2, _field$configuration3, _field$configuration4, _input$value;
22
22
  let {
23
23
  acceptedFileTypes: defaultAcceptedFileTypes,
@@ -31,7 +31,7 @@ const AttachmentContainer = _ref => {
31
31
  disableResize,
32
32
  errorClassname,
33
33
  field,
34
- fieldTypes,
34
+ fieldTypes = [],
35
35
  icon,
36
36
  input,
37
37
  loadingTextClassname,
@@ -69,7 +69,6 @@ const AttachmentContainer = _ref => {
69
69
  setErrorText(dynamicData ? "".concat(errorMessage, "(").concat(dynamicData, ")") : errorMessage);
70
70
  };
71
71
  const buildPreviews = async files => {
72
- const prevPreviews = preview !== null && preview !== void 0 ? preview : [];
73
72
  const loadPreview = file => new Promise((resolve, reject) => {
74
73
  const reader = new FileReader();
75
74
  reader.onload = e => {
@@ -106,9 +105,10 @@ const AttachmentContainer = _ref => {
106
105
  onClick: () => removePreviewItem(file.name)
107
106
  });
108
107
  });
109
- setPreview((0, _utils.getNotRepeatedFiles)([...prevPreviews, ...previewItems]));
108
+ setPreview(currentPreviews => (0, _utils.getNotRepeatedFiles)([...(currentPreviews || []).filter(item => item.type !== 'loading'), ...previewItems]));
110
109
  } catch (e) {
111
- onFailValidation(e);
110
+ setPreview(currentPreviews => (currentPreviews || []).filter(item => item.type !== 'loading'));
111
+ onFailValidation(e === null || e === void 0 ? void 0 : e.message);
112
112
  }
113
113
  };
114
114
  const onChange = async ev => {
@@ -169,7 +169,7 @@ const AttachmentContainer = _ref => {
169
169
  await processFiles(0);
170
170
  };
171
171
  const loadDefaultValues = async function () {
172
- var _input$value$index;
172
+ var _input$value$index, _formattedImages$inde;
173
173
  let index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
174
174
  let accumulatedFiles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
175
175
  const length = Array.isArray(input.value) ? input.value.length : 1;
@@ -182,7 +182,8 @@ const AttachmentContainer = _ref => {
182
182
  buildPreviews(accumulatedFiles);
183
183
  return;
184
184
  }
185
- const imageUrl = Array.isArray(input.value) ? (_input$value$index = input.value[index]) === null || _input$value$index === void 0 ? void 0 : _input$value$index.url : input.value;
185
+ const formattedImages = Array.isArray(input.value) ? input.value.flatMap(obj => Object.values(obj)[0]) : input.value;
186
+ 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;
186
187
  (0, _utils.getBlobFromUrl)(imageUrl, async response => {
187
188
  if (response) {
188
189
  const newFile = new File([response], (0, _utils.getDefaultAttachment)(response.type.substring(response.type.indexOf('/') + 1), index + 1), {
@@ -190,13 +191,37 @@ const AttachmentContainer = _ref => {
190
191
  });
191
192
  loadDefaultValues(index + 1, [...accumulatedFiles, newFile]);
192
193
  } else {
194
+ setPreview(currentPreviews => {
195
+ let foundLoading = false;
196
+ return currentPreviews.map(previewElement => {
197
+ if (!foundLoading && previewElement.type === _constants.PREVIEW_TYPES.LOADING) {
198
+ foundLoading = true;
199
+ return {
200
+ ...previewElement,
201
+ type: _constants.PREVIEW_TYPES.ERROR
202
+ };
203
+ }
204
+ return previewElement;
205
+ });
206
+ });
193
207
  loadDefaultValues(index + 1, accumulatedFiles);
194
208
  }
195
209
  });
196
210
  };
197
211
  (0, _react.useEffect)(() => {
198
- if (!(0, _isEmpty.default)(updatedFiles)) buildPreviews(updatedFiles);else if (!(0, _isEmpty.default)(input.value)) buildPreviews(input.value.files);
199
- if (Array.isArray(input.value) && !(0, _isEmpty.default)(input.value) || input.value && typeof input.value === 'string') loadDefaultValues();
212
+ var _input$value3;
213
+ if (!(0, _isEmpty.default)(updatedFiles)) buildPreviews(updatedFiles);else if (!(0, _isEmpty.default)((_input$value3 = input.value) === null || _input$value3 === void 0 ? void 0 : _input$value3.files)) buildPreviews(input.value.files);
214
+ if (Array.isArray(input.value) && !(0, _isEmpty.default)(input.value) || input.value && typeof input.value === 'string') {
215
+ if ((0, _isEmpty.default)(preview)) {
216
+ const length = Array.isArray(input.value) ? input.value.length : 1;
217
+ setPreview(Array.from({
218
+ length
219
+ }, () => ({
220
+ type: _constants.PREVIEW_TYPES.LOADING
221
+ })));
222
+ }
223
+ loadDefaultValues();
224
+ }
200
225
  }, [input]);
201
226
  return /*#__PURE__*/_react.default.createElement(_layout.default, {
202
227
  acceptedFileTypes: acceptedFileTypes,
@@ -220,7 +245,7 @@ const AttachmentContainer = _ref => {
220
245
  previewDataTestId: previewDataTestId
221
246
  });
222
247
  };
223
- AttachmentContainer.propTypes = {
248
+ AttachmentListContainer.propTypes = {
224
249
  acceptedFileTypes: _propTypes.string,
225
250
  allowedPDFUploadSizes: (0, _propTypes.arrayOf)((0, _propTypes.shape)({
226
251
  name: _propTypes.string,
@@ -256,4 +281,4 @@ AttachmentContainer.propTypes = {
256
281
  }),
257
282
  sanitize: _propTypes.func
258
283
  };
259
- var _default = exports.default = (0, _WithTheme.default)(_theme.retrieveStyle)(AttachmentContainer);
284
+ var _default = exports.default = (0, _WithTheme.default)(_theme.retrieveStyle)(AttachmentListContainer);
@@ -10,6 +10,7 @@ var _files = require("@widergy/web-utils/lib/constants/files");
10
10
  var _lodash = require("lodash");
11
11
  var _UTLabel = _interopRequireDefault(require("../UTLabel"));
12
12
  var _UTButton = _interopRequireDefault(require("../UTButton"));
13
+ var _UTIcon = _interopRequireDefault(require("../UTIcon"));
13
14
  var _constants = require("./constants");
14
15
  var _Preview = _interopRequireDefault(require("./components/Preview"));
15
16
  var _utils = require("./utils");
@@ -107,7 +108,7 @@ PlayIcon.defaultProps = {
107
108
  fill: "#0e59a3",
108
109
  xmlns: "http://www.w3.org/2000/svg"
109
110
  };
110
- const Attachment = _ref => {
111
+ const AttachmentList = _ref => {
111
112
  let {
112
113
  acceptedFileTypes,
113
114
  classes,
@@ -116,7 +117,7 @@ const Attachment = _ref => {
116
117
  disabled,
117
118
  error,
118
119
  errorText,
119
- fieldTypes,
120
+ fieldTypes = [],
120
121
  fileInputRef,
121
122
  helpText,
122
123
  maxFileSize,
@@ -142,7 +143,21 @@ const Attachment = _ref => {
142
143
  }, !previewIsEmpty && preview.map(previewItem => /*#__PURE__*/_react.default.createElement("div", {
143
144
  className: "".concat(_stylesModule.default.previewContainer, " ").concat(classes.previewContainer),
144
145
  "data-testid": previewDataTestId
145
- }, previewItem.src ? /*#__PURE__*/_react.default.createElement(_Preview.default, {
146
+ }, previewItem.type === _constants.PREVIEW_TYPES.LOADING ? /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_UTIcon.default, {
147
+ name: "IconLoader",
148
+ className: _stylesModule.default.loaderIcon
149
+ }), /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
150
+ className: _stylesModule.default.loadingText,
151
+ colorTheme: "gray",
152
+ variant: "small"
153
+ }, _constants.DEFAULT_UPLOADING_TEXT), /*#__PURE__*/_react.default.createElement("div", null)) : previewItem.type === _constants.PREVIEW_TYPES.ERROR ? /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_UTIcon.default, {
154
+ name: "IconX",
155
+ colorTheme: "error"
156
+ }), /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
157
+ className: _stylesModule.default.errorText,
158
+ colorTheme: "error",
159
+ variant: "small"
160
+ }, _constants.FILE_NOT_FOUND_ERROR_TEXT), /*#__PURE__*/_react.default.createElement("div", null)) : /*#__PURE__*/_react.default.createElement(_react.Fragment, null, previewItem.src ? /*#__PURE__*/_react.default.createElement(_Preview.default, {
146
161
  classes: classes,
147
162
  preview: previewItem,
148
163
  previewProps: preview.previewProps,
@@ -181,7 +196,7 @@ const Attachment = _ref => {
181
196
  onClick: previewItem.onClick,
182
197
  size: "small",
183
198
  variant: "text"
184
- }))), previewIsEmpty && /*#__PURE__*/_react.default.createElement(FilesIcon, {
199
+ })))), previewIsEmpty && /*#__PURE__*/_react.default.createElement(FilesIcon, {
185
200
  className: "".concat(_stylesModule.default.filesIcon, " ").concat(classes.filesIcon)
186
201
  }), /*#__PURE__*/_react.default.createElement("div", {
187
202
  className: "".concat(_stylesModule.default.labelAndInputContainer, " ").concat(!previewIsEmpty && _stylesModule.default.positionRelative)
@@ -226,7 +241,7 @@ const Attachment = _ref => {
226
241
  closePreviewModal: closePreviewModal
227
242
  }));
228
243
  };
229
- Attachment.propTypes = {
244
+ AttachmentList.propTypes = {
230
245
  acceptedFileTypes: _propTypes.string,
231
246
  classes: (0, _propTypes.objectOf)(_propTypes.string),
232
247
  dataTestId: _propTypes.string,
@@ -242,12 +257,12 @@ Attachment.propTypes = {
242
257
  maxFileSize: _propTypes.number,
243
258
  maxFiles: _propTypes.number,
244
259
  onChange: _propTypes.func,
245
- preview: (0, _propTypes.shape)({
260
+ preview: (0, _propTypes.arrayOf)((0, _propTypes.shape)({
246
261
  src: _propTypes.string,
247
262
  type: _propTypes.string
248
- }),
263
+ })),
249
264
  previewDataTestId: _propTypes.string,
250
265
  previewProps: _constants.previewPropType,
251
266
  RemoveIcon: _propTypes.elementType
252
267
  };
253
- var _default = exports.default = Attachment;
268
+ var _default = exports.default = AttachmentList;
@@ -54,15 +54,19 @@ $box-shadow: #e4e6eae5;
54
54
  align-items: center;
55
55
  border-radius: 5px;
56
56
  box-shadow: 0px 3px 6px $box-shadow;
57
+ box-sizing: border-box;
57
58
  cursor: initial;
58
59
  display: flex;
59
60
  flex-direction: row;
60
61
  grid-gap: 16px;
61
62
  justify-content: space-between;
62
- margin: 16px 16px 0;
63
63
  padding: 16px;
64
- width: calc(100% - 32px);
64
+ width: 100%;
65
65
  z-index: 5;
66
+
67
+ &:first-child {
68
+ margin-top: 16px;
69
+ }
66
70
  }
67
71
 
68
72
  .positionRelative {
@@ -70,7 +74,6 @@ $box-shadow: #e4e6eae5;
70
74
  }
71
75
 
72
76
  .fileContainer {
73
- display: flex;
74
77
  display: flex;
75
78
  flex: 1;
76
79
  flex-direction: column;
@@ -88,3 +91,21 @@ $box-shadow: #e4e6eae5;
88
91
  grid-gap: 8px;
89
92
  margin-top: 12px;
90
93
  }
94
+
95
+ @keyframes rotate {
96
+ from {
97
+ transform: rotate(0deg);
98
+ }
99
+ to {
100
+ transform: rotate(360deg);
101
+ }
102
+ }
103
+
104
+ .loaderIcon {
105
+ animation: rotate 2s linear infinite;
106
+ }
107
+
108
+ .loadingText,
109
+ .errorText {
110
+ flex: 1 1;
111
+ }
@@ -1,5 +1,5 @@
1
1
  .container {
2
- align-items: start;
2
+ align-items: flex-start;
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  gap: 10px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/energy-ui",
3
- "version": "3.119.1",
3
+ "version": "3.119.3",
4
4
  "description": "Widergy Web Components",
5
5
  "author": "widergy",
6
6
  "license": "MIT",