pixel-sharan 1.13.83 → 1.13.86
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/lib/_virtual/index10.js +2 -2
- package/lib/_virtual/index9.js +2 -2
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.js +189 -206
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.js.map +1 -1
- package/lib/index.cjs +191 -208
- package/lib/index.cjs.map +1 -1
- package/lib/node_modules/js-beautify/js/src/html/beautifier.js +1 -1
- package/lib/node_modules/js-beautify/js/src/html/index.js +1 -1
- package/lib/node_modules/js-beautify/js/src/html/options.js +1 -1
- package/lib/node_modules/js-beautify/js/src/javascript/beautifier.js +1 -1
- package/lib/node_modules/js-beautify/js/src/javascript/index.js +1 -1
- package/lib/node_modules/js-beautify/js/src/javascript/options.js +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
@@ -40644,252 +40644,235 @@ const ActiveCell = props => {
|
|
40644
40644
|
const [allOption, setAllOption] = React__namespace.useState();
|
40645
40645
|
const [selectedFiles, setSelectedFiles] = React__namespace.useState([]);
|
40646
40646
|
const handleFilesChange = async (newFiles, selected, actionType) => {
|
40647
|
-
|
40648
|
-
|
40649
|
-
|
40650
|
-
|
40651
|
-
if (cell?.value) {
|
40652
|
-
existingFiles = JSON.parse(cell.value);
|
40653
|
-
}
|
40654
|
-
} catch (error) {
|
40655
|
-
console.error('Error parsing cell.value:', error);
|
40656
|
-
}
|
40657
|
-
// Deduplicate within newFiles and against existingFiles
|
40658
|
-
let duplicateCount = 0;
|
40659
|
-
const uniqueFiles = newFiles.filter((file, index, self) => {
|
40660
|
-
const baseName = file.name.split('*')[0];
|
40661
|
-
// Check for duplicates within newFiles
|
40662
|
-
const isDuplicateInSelf = self.findIndex(f => f.name.split('*')[0] === baseName) !== index;
|
40663
|
-
// Check for duplicates in existingFiles
|
40664
|
-
const isDuplicateInExisting = existingFiles.some(existingFile => existingFile.name.split('*')[0] === baseName);
|
40665
|
-
if (isDuplicateInSelf || isDuplicateInExisting) {
|
40666
|
-
duplicateCount++;
|
40667
|
-
return false;
|
40668
|
-
}
|
40669
|
-
return true;
|
40670
|
-
});
|
40671
|
-
// Check total file count (existing + new)
|
40672
|
-
if (existingFiles.length + uniqueFiles.length > 5) {
|
40673
|
-
toast.info('Cannot upload more than 5 files.');
|
40674
|
-
return;
|
40675
|
-
}
|
40676
|
-
if (props.attachmentAction?.addAttachment && uniqueFiles.length > 0) {
|
40647
|
+
try {
|
40648
|
+
if (actionType === 'ADD' && cell?.inputType?.type === 'file') {
|
40649
|
+
// Parse existing cell.value
|
40650
|
+
let existingFiles = [];
|
40677
40651
|
try {
|
40678
|
-
|
40679
|
-
|
40680
|
-
|
40681
|
-
|
40682
|
-
|
40683
|
-
|
40684
|
-
|
40685
|
-
|
40686
|
-
|
40687
|
-
|
40688
|
-
|
40689
|
-
|
40690
|
-
|
40691
|
-
|
40692
|
-
|
40693
|
-
|
40694
|
-
|
40695
|
-
|
40696
|
-
|
40697
|
-
|
40698
|
-
|
40699
|
-
|
40700
|
-
|
40701
|
-
|
40702
|
-
|
40703
|
-
|
40704
|
-
|
40705
|
-
|
40706
|
-
|
40707
|
-
|
40708
|
-
|
40709
|
-
|
40710
|
-
|
40711
|
-
|
40712
|
-
|
40652
|
+
if (cell?.value) {
|
40653
|
+
existingFiles = JSON.parse(cell.value);
|
40654
|
+
}
|
40655
|
+
} catch (error) {
|
40656
|
+
console.error('Error parsing cell.value:', error);
|
40657
|
+
}
|
40658
|
+
// Deduplicate within newFiles and against existingFiles
|
40659
|
+
let duplicateCount = 0;
|
40660
|
+
const uniqueFiles = newFiles.filter((file, index, self) => {
|
40661
|
+
const baseName = file.name.split('*')[0];
|
40662
|
+
const isDuplicateInSelf = self.findIndex(f => f.name.split('*')[0] === baseName) !== index;
|
40663
|
+
const isDuplicateInExisting = existingFiles.some(existingFile => existingFile.name.split('*')[0] === baseName);
|
40664
|
+
if (isDuplicateInSelf || isDuplicateInExisting) {
|
40665
|
+
duplicateCount++;
|
40666
|
+
return false;
|
40667
|
+
}
|
40668
|
+
return true;
|
40669
|
+
});
|
40670
|
+
// Check total file count
|
40671
|
+
if (existingFiles.length + uniqueFiles.length > 5) {
|
40672
|
+
toast.info('Cannot upload more than 5 files.');
|
40673
|
+
return;
|
40674
|
+
}
|
40675
|
+
if (props.attachmentAction?.addAttachment && uniqueFiles.length > 0) {
|
40676
|
+
try {
|
40677
|
+
let successCount = 0;
|
40678
|
+
let failureCount = 0;
|
40679
|
+
const processedFiles = [...existingFiles];
|
40680
|
+
if (duplicateCount > 0) {
|
40681
|
+
toast.warning('Duplicate attachments not allowed within the same row');
|
40682
|
+
}
|
40683
|
+
const uploadPromises = uniqueFiles.map(async file => {
|
40684
|
+
try {
|
40685
|
+
if (file.name.includes('*')) {
|
40686
|
+
return {
|
40687
|
+
file,
|
40688
|
+
status: 'existing',
|
40689
|
+
data: {
|
40690
|
+
name: file.name
|
40691
|
+
}
|
40692
|
+
};
|
40693
|
+
}
|
40694
|
+
const response = await props?.attachmentAction?.addAttachment(file);
|
40695
|
+
if (!response || typeof response === 'string' && response.trim().length === 0) {
|
40696
|
+
return {
|
40697
|
+
file,
|
40698
|
+
status: 'failed',
|
40699
|
+
reason: 'no response'
|
40700
|
+
};
|
40701
|
+
}
|
40702
|
+
if (typeof response === 'string') {
|
40703
|
+
try {
|
40704
|
+
const parsedResponse = JSON.parse(response);
|
40705
|
+
if (parsedResponse.responseCode === 400) {
|
40706
|
+
return {
|
40707
|
+
file,
|
40708
|
+
status: 'failed',
|
40709
|
+
reason: 'invalid file'
|
40710
|
+
};
|
40711
|
+
}
|
40712
|
+
if (parsedResponse?.id && parsedResponse?.name) {
|
40713
|
+
return {
|
40714
|
+
file,
|
40715
|
+
status: 'success',
|
40716
|
+
data: parsedResponse
|
40717
|
+
};
|
40718
|
+
} else {
|
40719
|
+
console.error(`Invalid response structure for ${file.name}:`, parsedResponse);
|
40720
|
+
return {
|
40721
|
+
file,
|
40722
|
+
status: 'failed',
|
40723
|
+
reason: 'invalid response'
|
40724
|
+
};
|
40725
|
+
}
|
40726
|
+
} catch (error) {
|
40727
|
+
console.error(`Parse error for ${file.name}:`, error);
|
40713
40728
|
return {
|
40714
40729
|
file,
|
40715
40730
|
status: 'failed',
|
40716
|
-
reason: '
|
40731
|
+
reason: 'parse error'
|
40717
40732
|
};
|
40718
40733
|
}
|
40719
|
-
|
40720
|
-
|
40734
|
+
}
|
40735
|
+
if (typeof response === 'object' && response !== null) {
|
40736
|
+
const typedResponse = response;
|
40737
|
+
if (typedResponse?.id && typedResponse?.name) {
|
40721
40738
|
return {
|
40722
40739
|
file,
|
40723
40740
|
status: 'success',
|
40724
|
-
data:
|
40741
|
+
data: typedResponse
|
40725
40742
|
};
|
40726
40743
|
} else {
|
40744
|
+
console.error(`Invalid response structure for ${file.name}:`, response);
|
40727
40745
|
return {
|
40728
40746
|
file,
|
40729
40747
|
status: 'failed',
|
40730
40748
|
reason: 'invalid response'
|
40731
40749
|
};
|
40732
40750
|
}
|
40733
|
-
} catch (error) {
|
40734
|
-
console.error(`Parse error for ${file.name}:`, error);
|
40735
|
-
return {
|
40736
|
-
file,
|
40737
|
-
status: 'failed',
|
40738
|
-
reason: 'parse error'
|
40739
|
-
};
|
40740
40751
|
}
|
40752
|
+
console.error(`Unknown response for ${file.name}:`, response);
|
40753
|
+
return {
|
40754
|
+
file,
|
40755
|
+
status: 'failed',
|
40756
|
+
reason: 'unknown'
|
40757
|
+
};
|
40758
|
+
} catch (error) {
|
40759
|
+
console.error(`Upload failed for ${file.name}:`, error);
|
40760
|
+
return {
|
40761
|
+
file,
|
40762
|
+
status: 'failed',
|
40763
|
+
reason: 'upload error'
|
40764
|
+
};
|
40741
40765
|
}
|
40742
|
-
|
40743
|
-
|
40744
|
-
|
40745
|
-
|
40746
|
-
|
40747
|
-
|
40748
|
-
|
40749
|
-
|
40750
|
-
|
40766
|
+
});
|
40767
|
+
const results = await Promise.allSettled(uploadPromises);
|
40768
|
+
results.forEach(result => {
|
40769
|
+
if (result.status === 'fulfilled' && result.value) {
|
40770
|
+
const {
|
40771
|
+
status,
|
40772
|
+
data
|
40773
|
+
} = result.value;
|
40774
|
+
if (status === 'success' && data?.id && data?.name) {
|
40775
|
+
processedFiles.push(data);
|
40776
|
+
successCount++;
|
40777
|
+
} else if (status === 'existing' && data?.name) {
|
40778
|
+
processedFiles.push(data);
|
40751
40779
|
} else {
|
40752
|
-
|
40753
|
-
file,
|
40754
|
-
status: 'failed',
|
40755
|
-
reason: 'invalid response'
|
40756
|
-
};
|
40780
|
+
failureCount++;
|
40757
40781
|
}
|
40758
|
-
}
|
40759
|
-
return {
|
40760
|
-
file,
|
40761
|
-
status: 'failed',
|
40762
|
-
reason: 'unknown'
|
40763
|
-
};
|
40764
|
-
} catch (error) {
|
40765
|
-
console.error(`Upload failed for ${file.name}:`, error);
|
40766
|
-
return {
|
40767
|
-
file,
|
40768
|
-
status: 'failed',
|
40769
|
-
reason: 'upload error'
|
40770
|
-
};
|
40771
|
-
}
|
40772
|
-
});
|
40773
|
-
const results = await Promise.allSettled(uploadPromises);
|
40774
|
-
results.forEach(result => {
|
40775
|
-
if (result.status === 'fulfilled' && result.value) {
|
40776
|
-
const {
|
40777
|
-
status,
|
40778
|
-
data
|
40779
|
-
} = result.value;
|
40780
|
-
if (status === 'success' && data?.id && data?.name) {
|
40781
|
-
processedFiles.push(data);
|
40782
|
-
successCount++;
|
40783
|
-
} else if (status === 'existing' && data?.name) {
|
40784
|
-
processedFiles.push(data);
|
40785
|
-
} else if (result.value.reason === 'invalid file') {
|
40786
|
-
failureCount++;
|
40787
40782
|
} else {
|
40788
40783
|
failureCount++;
|
40789
40784
|
}
|
40790
|
-
} else {
|
40791
|
-
failureCount++;
|
40792
|
-
}
|
40793
|
-
});
|
40794
|
-
// Update cell value only if new valid files were added
|
40795
|
-
if (successCount > 0 || processedFiles.length > existingFiles.length) {
|
40796
|
-
const newValue = processedFiles.length > 0 ? JSON.stringify(processedFiles) : '';
|
40797
|
-
handleChange({
|
40798
|
-
...cell,
|
40799
|
-
value: newValue,
|
40800
|
-
style: cell?.style,
|
40801
|
-
inputType: cell?.inputType
|
40802
40785
|
});
|
40803
|
-
|
40804
|
-
|
40805
|
-
|
40806
|
-
|
40807
|
-
|
40808
|
-
|
40809
|
-
|
40810
|
-
|
40786
|
+
if (successCount > 0 || processedFiles.length > existingFiles.length) {
|
40787
|
+
const newValue = processedFiles.length > 0 ? JSON.stringify(processedFiles) : '';
|
40788
|
+
handleChange({
|
40789
|
+
...cell,
|
40790
|
+
value: newValue,
|
40791
|
+
style: cell?.style,
|
40792
|
+
inputType: cell?.inputType
|
40793
|
+
});
|
40794
|
+
setSelectedFiles(processedFiles.map(file => new File([new Blob()], file.name)));
|
40795
|
+
}
|
40796
|
+
if (successCount > 0) {
|
40797
|
+
toast.success(`${successCount} file${successCount > 1 ? 's' : ''} uploaded successfully`);
|
40798
|
+
}
|
40799
|
+
if (failureCount > 0) {
|
40800
|
+
toast.info(`${failureCount} unsupported ${failureCount > 1 ? 'files' : 'file'}.`);
|
40801
|
+
}
|
40802
|
+
} catch (error) {
|
40803
|
+
console.error('Upload operation failed:', error);
|
40804
|
+
toast.error('Operation failed');
|
40811
40805
|
}
|
40812
|
-
}
|
40813
|
-
|
40814
|
-
toast.error('Operation failed');
|
40806
|
+
} else if (duplicateCount > 0) {
|
40807
|
+
toast.warning('Duplicate attachments not allowed within the same row');
|
40815
40808
|
}
|
40816
|
-
} else if (
|
40817
|
-
|
40818
|
-
|
40819
|
-
|
40820
|
-
|
40821
|
-
|
40822
|
-
|
40823
|
-
|
40824
|
-
|
40825
|
-
|
40826
|
-
|
40827
|
-
|
40828
|
-
|
40829
|
-
|
40830
|
-
|
40831
|
-
|
40832
|
-
|
40833
|
-
|
40834
|
-
|
40835
|
-
|
40836
|
-
|
40837
|
-
|
40838
|
-
try {
|
40839
|
-
const response = await props.attachmentAction.deleteAttachment(fileId);
|
40840
|
-
console.log(`Delete response for ${file.name}:`, response); // Debug log
|
40841
|
-
if (response && (response === 'SUCCESS' || typeof response === 'object' && ('status' in response && response.status === 200 || Object.keys(response).length > 0))) {
|
40842
|
-
updatedFileDetails.splice(index, 1);
|
40843
|
-
console.log(`After splice for ${file.name}:`, updatedFileDetails); // Debug log
|
40844
|
-
deletedCount++;
|
40845
|
-
console.log(`Deleted ${file.name} successfully`); // Debug log
|
40846
|
-
} else {
|
40847
|
-
console.error(`Delete failed for ${file.name}: Invalid response`, response);
|
40809
|
+
} else if (actionType === 'DELETE' && cell?.inputType?.type === 'file') {
|
40810
|
+
try {
|
40811
|
+
const parsedValue = cell && JSON.parse(cell.value);
|
40812
|
+
let updatedFileDetails = [...parsedValue];
|
40813
|
+
let deletedCount = 0;
|
40814
|
+
for (const file of selected || []) {
|
40815
|
+
const index = updatedFileDetails.findIndex(originalFile => originalFile.name.split('*')[0] === file.name.split('*')[0]);
|
40816
|
+
const fileId = updatedFileDetails[index]?.id;
|
40817
|
+
if (index !== -1 && fileId && props.attachmentAction?.deleteAttachment) {
|
40818
|
+
try {
|
40819
|
+
const response = await props.attachmentAction.deleteAttachment(fileId);
|
40820
|
+
// Check for valid response
|
40821
|
+
if (response === 'SUCCESS' || typeof response === 'object' && response !== null && ('status' in response && response.status === 'SUCCESS' || 'responseCode' in response && response.responseCode === 200)) {
|
40822
|
+
updatedFileDetails.splice(index, 1);
|
40823
|
+
deletedCount++;
|
40824
|
+
} else {
|
40825
|
+
console.error(`Delete failed for ${file.name}: Invalid response`, response);
|
40826
|
+
toast.warning('Failed to delete file: Invalid server response');
|
40827
|
+
}
|
40828
|
+
} catch (deleteError) {
|
40829
|
+
console.error(`Delete error for ${file.name}:`, deleteError);
|
40830
|
+
toast.error('Error deleting file');
|
40848
40831
|
}
|
40849
|
-
}
|
40850
|
-
console.error(`
|
40832
|
+
} else {
|
40833
|
+
console.error(`Cannot delete ${file.name}: Invalid fileId or no match`, {
|
40834
|
+
index,
|
40835
|
+
fileId,
|
40836
|
+
hasDeleteAttachment: !!props.attachmentAction?.deleteAttachment
|
40837
|
+
}); // Debug log
|
40838
|
+
toast.error('Failed to delete file: Invalid file data');
|
40851
40839
|
}
|
40852
|
-
}
|
40853
|
-
|
40854
|
-
|
40855
|
-
|
40856
|
-
hasDeleteAttachment: !!props.attachmentAction?.deleteAttachment
|
40857
|
-
}); // Debug log
|
40858
|
-
}
|
40859
|
-
}
|
40860
|
-
if (deletedCount > 0) {
|
40861
|
-
const newValue = updatedFileDetails.length > 0 ? JSON.stringify(updatedFileDetails) : '';
|
40862
|
-
console.log('Updated cell.value:', newValue); // Debug log
|
40863
|
-
handleChange({
|
40864
|
-
...cell,
|
40865
|
-
value: newValue,
|
40866
|
-
style: cell?.style,
|
40867
|
-
inputType: cell?.inputType
|
40868
|
-
});
|
40869
|
-
setSelectedFiles(updatedFileDetails.map(file => new File([new Blob()], file.name)));
|
40870
|
-
console.log('Updated selectedFiles:', updatedFileDetails); // Debug log
|
40871
|
-
toast.success(`${deletedCount} file${deletedCount > 1 ? 's' : ''} deleted successfully`);
|
40872
|
-
} else if (selected?.length) {
|
40873
|
-
console.log('No files deleted, retaining original state'); // Debug log
|
40874
|
-
const validFiles = updatedFileDetails.filter(file => file.id && file.name);
|
40875
|
-
if (validFiles.length < updatedFileDetails.length) {
|
40876
|
-
const newValue = validFiles.length > 0 ? JSON.stringify(validFiles) : '';
|
40877
|
-
console.log('Cleaning invalid files, new cell.value:', newValue); // Debug log
|
40840
|
+
}
|
40841
|
+
// Update cell value and selected files
|
40842
|
+
if (deletedCount > 0) {
|
40843
|
+
const newValue = updatedFileDetails.length > 0 ? JSON.stringify(updatedFileDetails) : '';
|
40878
40844
|
handleChange({
|
40879
40845
|
...cell,
|
40880
40846
|
value: newValue,
|
40881
40847
|
style: cell?.style,
|
40882
40848
|
inputType: cell?.inputType
|
40883
40849
|
});
|
40884
|
-
setSelectedFiles(
|
40885
|
-
|
40850
|
+
setSelectedFiles(updatedFileDetails.map(file => new File([new Blob()], file.name)));
|
40851
|
+
toast.success(`${deletedCount} file${deletedCount > 1 ? 's' : ''} deleted successfully`);
|
40852
|
+
} else if (selected?.length) {
|
40853
|
+
const validFiles = updatedFileDetails.filter(file => file.id && file.name);
|
40854
|
+
if (validFiles.length < updatedFileDetails.length) {
|
40855
|
+
const newValue = validFiles.length > 0 ? JSON.stringify(validFiles) : '';
|
40856
|
+
handleChange({
|
40857
|
+
...cell,
|
40858
|
+
value: newValue,
|
40859
|
+
style: cell?.style,
|
40860
|
+
inputType: cell?.inputType
|
40861
|
+
});
|
40862
|
+
setSelectedFiles(validFiles.map(file => new File([new Blob()], file.name)));
|
40863
|
+
toast.error('Failed to delete file(s). Invalid file data detected.');
|
40864
|
+
} else {
|
40865
|
+
toast.error('Failed to delete file(s). No valid files removed.');
|
40866
|
+
}
|
40886
40867
|
}
|
40887
|
-
|
40868
|
+
} catch (error) {
|
40869
|
+
console.error('Delete operation failed:', error);
|
40870
|
+
toast.error('Delete operation failed');
|
40888
40871
|
}
|
40889
|
-
} catch (error) {
|
40890
|
-
console.error('Delete operation failed:', error);
|
40891
|
-
toast.error('Delete operation failed');
|
40892
40872
|
}
|
40873
|
+
} catch (error) {
|
40874
|
+
console.error('handleFilesChange error:', error);
|
40875
|
+
toast.error('Operation failed');
|
40893
40876
|
}
|
40894
40877
|
};
|
40895
40878
|
const handleClick = e => {
|