@awell-health/ui-library 0.1.151 → 0.1.152

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.js CHANGED
@@ -51455,11 +51455,34 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
51455
51455
  }
51456
51456
  };
51457
51457
 
51458
+ var isAcceptedMimeType = function (contentType, acceptedFileTypes) {
51459
+ var normalizedContentType = (contentType !== null && contentType !== void 0 ? contentType : '').trim().toLowerCase();
51460
+ if (normalizedContentType === '')
51461
+ return false;
51462
+ return acceptedFileTypes.some(function (accepted) {
51463
+ var normalized = (accepted !== null && accepted !== void 0 ? accepted : '').trim().toLowerCase();
51464
+ if (normalized === '')
51465
+ return false;
51466
+ if (normalized === '*' || normalized === '*/*')
51467
+ return true;
51468
+ if (normalized === normalizedContentType)
51469
+ return true;
51470
+ if (normalized.endsWith('/*')) {
51471
+ var prefix = normalized.slice(0, normalized.indexOf('/') + 1);
51472
+ return normalizedContentType.startsWith(prefix);
51473
+ }
51474
+ return false;
51475
+ });
51476
+ };
51477
+
51458
51478
  var areAttachmentsValid = function (_a) {
51459
51479
  var attachmentsValue = _a.attachmentsValue,required = _a.required,acceptedFileTypes = _a.acceptedFileTypes;
51460
51480
  var parseAttachments = function (val) {
51461
51481
  try {
51462
- return JSON.parse(val);
51482
+ var parsed = JSON.parse(val);
51483
+ if (lodash.exports.isNil(parsed))
51484
+ return [];
51485
+ return Array.isArray(parsed) ? parsed : [parsed];
51463
51486
  }
51464
51487
  catch (error) {
51465
51488
  return [];
@@ -51467,9 +51490,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
51467
51490
  };
51468
51491
  var attachments = parseAttachments(attachmentsValue);
51469
51492
  if (required) {
51470
- return !lodash.exports.isNil(attachments) && attachments.length > 0;
51493
+ return attachments.length > 0;
51471
51494
  }
51472
- return attachments.every(function (attachment) {var _a;return acceptedFileTypes.includes((_a = attachment.contentType) !== null && _a !== void 0 ? _a : '');});
51495
+ return attachments.every(function (attachment) {var _a;return isAcceptedMimeType((_a = attachment.contentType) !== null && _a !== void 0 ? _a : '', acceptedFileTypes);});
51473
51496
  };
51474
51497
 
51475
51498
  var classes$9 = {"file_input_field_container":"awell__FileInputField_file_input_field_container","error_message":"awell__FileInputField_error_message","file_upload_wrapper":"awell__FileInputField_file_upload_wrapper","file_list_wrapper":"awell__FileInputField_file_list_wrapper","btn-square":"awell__FileInputField_btn-square"};
@@ -51619,10 +51642,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
51619
51642
  if (lodash.exports.isNil(attachment) || lodash.exports.isNil(attachment.contentType)) {
51620
51643
  return !required;
51621
51644
  }
51622
- if (acceptedFileTypes.includes('*') || acceptedFileTypes.includes('*/*')) {
51623
- return true;
51624
- }
51625
- return acceptedFileTypes.includes(attachment.contentType);
51645
+ return isAcceptedMimeType(attachment.contentType, acceptedFileTypes);
51626
51646
  };
51627
51647
 
51628
51648
  var AUTO_PROGRESS_DELAY = 850;
@@ -0,0 +1 @@
1
+ export declare const isAcceptedMimeType: (contentType: string, acceptedFileTypes: string[]) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awell-health/ui-library",
3
- "version": "0.1.151",
3
+ "version": "0.1.152",
4
4
  "description": "UI components to integrate with Awell Health",
5
5
  "repository": {
6
6
  "type": "git",