@bnsights/bbsf-controls 1.0.194-beta.19-9 → 1.0.194-beta.19-11

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.
@@ -7177,6 +7177,14 @@ class FileUploadComponent {
7177
7177
  this.acceptedTypeArray = this.acceptedTypeArray.filter((value) => value.trim() != '');
7178
7178
  // Rebuild acceptedType string for HTML accept attribute (properly formatted)
7179
7179
  this.acceptedType = this.acceptedTypeArray.join(',');
7180
+ // Add file extension support for custom MIME types that browsers don't recognize
7181
+ // For application/BN (License files), also add .bn extension to accept attribute
7182
+ const hasLicenseType = this.acceptedTypeArray.some(acceptedType => {
7183
+ return acceptedType.toLowerCase().trim() === 'application/bn';
7184
+ });
7185
+ if (hasLicenseType) {
7186
+ this.acceptedType = this.acceptedType + ',.bn';
7187
+ }
7180
7188
  // Process each accepted MIME type to build tooltip display names
7181
7189
  for (let index = 0; index < this.acceptedTypeArray.length; index++) {
7182
7190
  const element = this.acceptedTypeArray[index].trim();
@@ -7458,7 +7466,7 @@ class FileUploadComponent {
7458
7466
  }
7459
7467
  if (this.options.fileUploadAcceptsTypes != null &&
7460
7468
  this.options.fileUploadAcceptsTypes.length > 0 &&
7461
- !this.isFileTypeAccepted(fileType)) {
7469
+ !this.isFileTypeAccepted(fileType, file.name)) {
7462
7470
  // Remove only the file that violates the file type restriction
7463
7471
  this.uploader.queue = this.uploader.queue.filter(queueItem => queueItem.file.name !== file.name);
7464
7472
  hasValidationError = true;
@@ -7708,17 +7716,38 @@ class FileUploadComponent {
7708
7716
  }
7709
7717
  }
7710
7718
  }
7711
- isFileTypeAccepted(fileType) {
7719
+ isFileTypeAccepted(fileType, fileName) {
7712
7720
  if (!this.acceptedTypeArray || this.acceptedTypeArray.length === 0) {
7713
7721
  return true; // No restrictions
7714
7722
  }
7715
7723
  // Normalize the file type for comparison
7716
- const normalizedFileType = fileType.toLowerCase().trim();
7724
+ const normalizedFileType = fileType ? fileType.toLowerCase().trim() : '';
7717
7725
  // Check against all accepted types (case-insensitive and trimmed)
7718
- return this.acceptedTypeArray.some(acceptedType => {
7726
+ const isMimeTypeAccepted = this.acceptedTypeArray.some(acceptedType => {
7719
7727
  const normalizedAcceptedType = acceptedType.toLowerCase().trim();
7720
7728
  return normalizedAcceptedType === normalizedFileType;
7721
7729
  });
7730
+ // If MIME type matches, return true
7731
+ if (isMimeTypeAccepted) {
7732
+ return true;
7733
+ }
7734
+ // Handle custom MIME types that browsers don't recognize
7735
+ // For application/BN (License files), check file extension
7736
+ const hasLicenseType = this.acceptedTypeArray.some(acceptedType => {
7737
+ return acceptedType.toLowerCase().trim() === 'application/bn';
7738
+ });
7739
+ if (hasLicenseType && fileName) {
7740
+ const lastDotIndex = fileName.lastIndexOf('.');
7741
+ if (lastDotIndex !== -1) {
7742
+ const fileExtension = fileName.toLowerCase().substring(lastDotIndex);
7743
+ if (fileExtension === '.bn') {
7744
+ // Accept .bn files regardless of MIME type since browsers assign
7745
+ // application/octet-stream or empty type to unknown file types
7746
+ return true;
7747
+ }
7748
+ }
7749
+ }
7750
+ return false;
7722
7751
  }
7723
7752
  setValuePreservingErrors(value, preserveErrors) {
7724
7753
  // Capture current duplicate errors before setValue clears them