pixel-sharan 1.13.71 → 1.13.75
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/StyleGuide/ColorPalette/colorPaletteList.js +10 -0
- package/lib/StyleGuide/ColorPalette/colorPaletteList.js.map +1 -1
- package/lib/_virtual/index10.js +2 -2
- package/lib/_virtual/index11.js +2 -2
- package/lib/_virtual/index9.js +2 -2
- package/lib/components/Charts/DashboardDonutChart/DashboardDonutChart.js +28 -3
- package/lib/components/Charts/DashboardDonutChart/DashboardDonutChart.js.map +1 -1
- package/lib/components/Drawer/Drawer.js +1 -1
- package/lib/components/Drawer/Drawer.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.js +141 -217
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducer.js.map +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.js +25 -13
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.js.map +1 -1
- package/lib/components/Input/Input.js +5 -2
- package/lib/components/Input/Input.js.map +1 -1
- package/lib/components/Input/types.d.ts +4 -0
- package/lib/components/MachineInputField/MachineInputField.js +1 -1
- package/lib/components/MachineInputField/MachineInputField.js.map +1 -1
- package/lib/components/MachineInputField/types.d.ts +1 -1
- package/lib/components/SequentialConnectingBranch/components/Branches/Branches.js +2 -2
- package/lib/components/SequentialConnectingBranch/components/Branches/Branches.js.map +1 -1
- package/lib/index.cjs +203 -239
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/node_modules/js-beautify/js/src/css/beautifier.js +1 -1
- package/lib/node_modules/js-beautify/js/src/css/index.js +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/tokenizer.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/tokenizer.js +1 -1
- package/lib/styles.css +1 -1
- package/lib/styles.css.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
@@ -1988,7 +1988,7 @@ const Drawer = ({
|
|
1988
1988
|
const handleKeyDown = e => {
|
1989
1989
|
if (e.key === 'Enter' && isOpen && primaryButtonProps?.onClick && !primaryButtonProps.disabled) {
|
1990
1990
|
const activeElement = document.activeElement;
|
1991
|
-
if (activeElement && activeElement.tagName === 'INPUT') {
|
1991
|
+
if (activeElement && activeElement.tagName === 'INPUT' && ['ff-add-module-input', 'ff-search-input'].includes(activeElement.className)) {
|
1992
1992
|
return;
|
1993
1993
|
}
|
1994
1994
|
primaryButtonProps.onClick();
|
@@ -3559,6 +3559,7 @@ const Input$1 = /*#__PURE__*/React.forwardRef(({
|
|
3559
3559
|
placeholder = 'Enter input',
|
3560
3560
|
value = type === 'number' ? 0 : '',
|
3561
3561
|
helperText = '',
|
3562
|
+
isHelperTextRequired = false,
|
3562
3563
|
error,
|
3563
3564
|
noBorder,
|
3564
3565
|
className = '',
|
@@ -3804,11 +3805,13 @@ const Input$1 = /*#__PURE__*/React.forwardRef(({
|
|
3804
3805
|
}), reserveHelperTextSpace && jsxRuntime.jsx("span", {
|
3805
3806
|
className: classNames('ff-input-message', {
|
3806
3807
|
'ff-input-message--space': !!reserveHelperTextSpace,
|
3808
|
+
'ff-input-message--showHelperText': !!isHelperTextRequired,
|
3807
3809
|
'ff-input-message--danger': (displayErrorImmediately || touched) && !!error
|
3808
3810
|
}),
|
3809
|
-
children: (displayErrorImmediately || touched) && error ? helperText : ''
|
3810
|
-
}), !reserveHelperTextSpace && (displayErrorImmediately || touched) && helperText && error && jsxRuntime.jsx("span", {
|
3811
|
+
children: (displayErrorImmediately || touched) && (error || isHelperTextRequired) ? helperText : ''
|
3812
|
+
}), !reserveHelperTextSpace && (displayErrorImmediately || touched) && helperText && (error || isHelperTextRequired) && jsxRuntime.jsx("span", {
|
3811
3813
|
className: classNames('ff-input-message', {
|
3814
|
+
'ff-input-message--showHelperText': !!isHelperTextRequired,
|
3812
3815
|
'ff-input-message--danger': !!error
|
3813
3816
|
}),
|
3814
3817
|
children: helperText
|
@@ -31421,6 +31424,31 @@ const DashboardDonutChart = ({
|
|
31421
31424
|
document.body.removeChild(svgContainer);
|
31422
31425
|
return `${truncatedText}...`;
|
31423
31426
|
};
|
31427
|
+
const getCenterText = () => {
|
31428
|
+
if (legendType === 'tableLegend' && hoveredItemIndex !== null) {
|
31429
|
+
const hoveredItem = chartValues.find(item => item.originalIndex === hoveredItemIndex);
|
31430
|
+
return total === 0 ? '0%' : `${Math.round((hoveredItem?.value || 0) / total * 100)}%`;
|
31431
|
+
}
|
31432
|
+
if (legendType === 'memoryLegend') {
|
31433
|
+
return `${totalMemory}`;
|
31434
|
+
}
|
31435
|
+
if (isOnClick && hoveredItemIndex !== null) {
|
31436
|
+
const hoveredItem = chartValues.find(item => item.originalIndex === hoveredItemIndex);
|
31437
|
+
return `${hoveredItem?.value}`;
|
31438
|
+
}
|
31439
|
+
return `${legendType === 'tableLegend' ? `${chartValues.length}` : Number.isInteger(total) ? total : total?.toFixed(2)} ${showUnit && unit ? unit.toUpperCase() : ''}`;
|
31440
|
+
};
|
31441
|
+
const getSubLabelText = () => {
|
31442
|
+
if (legendType === 'tableLegend' && hoveredItemIndex !== null) {
|
31443
|
+
const hoveredItem = chartValues.find(item => item.originalIndex === hoveredItemIndex);
|
31444
|
+
return truncateChartText(hoveredItem?.key || '');
|
31445
|
+
}
|
31446
|
+
if (isOnClick && hoveredItemIndex !== null) {
|
31447
|
+
const hoveredItem = chartValues.find(item => item.originalIndex === hoveredItemIndex);
|
31448
|
+
return truncateChartText(hoveredItem?.key || '');
|
31449
|
+
}
|
31450
|
+
return truncateChartText(legendDetailsType);
|
31451
|
+
};
|
31424
31452
|
return jsxRuntime.jsxs("div", {
|
31425
31453
|
className: classNames('ff-dashboard-donut-chart-section', {
|
31426
31454
|
'ff-dashboard-donut-chart-section-table-legend': legendType === 'tableLegend',
|
@@ -31472,7 +31500,7 @@ const DashboardDonutChart = ({
|
|
31472
31500
|
style: {
|
31473
31501
|
fontSize: `${labelFontSize}px`
|
31474
31502
|
},
|
31475
|
-
children: wrapText(
|
31503
|
+
children: wrapText(getCenterText(), LABEL_MAX_WIDTH, labelFontSize).map((line, index) => jsxRuntime.jsx("tspan", {
|
31476
31504
|
x: "0",
|
31477
31505
|
dy: index === 0 ? 0 : labelFontSize,
|
31478
31506
|
children: selectedItemIndex !== null && chartValues.find(item => item.originalIndex === selectedItemIndex) ? index === 0 ? chartValues.find(item => item.originalIndex === selectedItemIndex)?.value : null : apiDataLabel ? apiDataLabel : line
|
@@ -31485,11 +31513,11 @@ const DashboardDonutChart = ({
|
|
31485
31513
|
style: {
|
31486
31514
|
fontSize: `${subLabelFontSize}px`
|
31487
31515
|
},
|
31488
|
-
children: wrapText(
|
31516
|
+
children: wrapText(getSubLabelText(), LABEL_MAX_WIDTH, subLabelFontSize).map((line, index) => jsxRuntime.jsx("tspan", {
|
31489
31517
|
x: "0",
|
31490
31518
|
dy: index === 0 ? 0 : subLabelFontSize,
|
31491
31519
|
fill: selectedItemIndex !== null && chartValues.find(item => item.originalIndex === selectedItemIndex)?.color || hoveredItemIndex !== null && isOnClick && chartValues.find(item => item.originalIndex === hoveredItemIndex)?.color || '',
|
31492
|
-
children:
|
31520
|
+
children: line
|
31493
31521
|
}, index))
|
31494
31522
|
})]
|
31495
31523
|
})]
|
@@ -34411,7 +34439,7 @@ const IconRadioGroup = ({
|
|
34411
34439
|
};
|
34412
34440
|
|
34413
34441
|
const MachineInputField = ({
|
34414
|
-
width = '',
|
34442
|
+
width = '100%',
|
34415
34443
|
options = [],
|
34416
34444
|
runCount = 0,
|
34417
34445
|
className = '',
|
@@ -34569,9 +34597,9 @@ const Branches = ({
|
|
34569
34597
|
const showMiddleArrow = index => machineInstances.length - 1 !== index && machineColumnCount > 1;
|
34570
34598
|
const getGridTemplateColumnStyle = () => {
|
34571
34599
|
if (machineColumnCount === 1) {
|
34572
|
-
return `24px
|
34600
|
+
return `24px auto 24px`;
|
34573
34601
|
}
|
34574
|
-
return `24px
|
34602
|
+
return `24px minmax(180px, auto) repeat(${machineColumnCount - 1}, 40px minmax(180px, auto)) 24px`;
|
34575
34603
|
};
|
34576
34604
|
const getMachineLabelOptionList = (type = '', machineInstance) => {
|
34577
34605
|
const {
|
@@ -37663,6 +37691,16 @@ const clearCell = cell => {
|
|
37663
37691
|
style: cell?.style
|
37664
37692
|
};
|
37665
37693
|
};
|
37694
|
+
const clearEditCell = cell => {
|
37695
|
+
if (!canClearCell(cell) || cell?.inputType?.type === 'file') {
|
37696
|
+
return cell;
|
37697
|
+
}
|
37698
|
+
return {
|
37699
|
+
...cell,
|
37700
|
+
value: typeof cell?.value === 'string' ? cell.value.slice(0, -1) : cell?.value,
|
37701
|
+
style: cell?.style
|
37702
|
+
};
|
37703
|
+
};
|
37666
37704
|
const nextLine = cell => {
|
37667
37705
|
if (!cell) return undefined;
|
37668
37706
|
return {
|
@@ -37697,24 +37735,26 @@ function clearEditMode(state) {
|
|
37697
37735
|
if (!state.active) {
|
37698
37736
|
return state;
|
37699
37737
|
}
|
37700
|
-
|
37701
|
-
|
37702
|
-
|
37703
|
-
|
37704
|
-
const
|
37705
|
-
|
37738
|
+
if (state.mode === 'view') {
|
37739
|
+
const resultState = clear(state);
|
37740
|
+
return resultState;
|
37741
|
+
} else {
|
37742
|
+
const changes = [];
|
37743
|
+
let newData = state.model.data;
|
37744
|
+
const cell = get$1(state.active, state.model.data);
|
37745
|
+
const clearedCell = clearEditCell(cell);
|
37706
37746
|
changes.push({
|
37707
37747
|
prevCell: cell || null,
|
37708
37748
|
nextCell: clearedCell || null
|
37709
37749
|
});
|
37710
|
-
newData = set$1(
|
37750
|
+
newData = set$1(state.active, clearedCell, newData);
|
37751
|
+
return {
|
37752
|
+
...state,
|
37753
|
+
mode: 'edit',
|
37754
|
+
model: new Model(createFormulaParser, newData),
|
37755
|
+
...commit(changes)
|
37756
|
+
};
|
37711
37757
|
}
|
37712
|
-
return {
|
37713
|
-
...state,
|
37714
|
-
mode: 'edit',
|
37715
|
-
model: new Model(createFormulaParser, newData),
|
37716
|
-
...commit(changes)
|
37717
|
-
};
|
37718
37758
|
}
|
37719
37759
|
function enterFunctionality(state) {
|
37720
37760
|
if (!state.active) {
|
@@ -40604,118 +40644,158 @@ const ActiveCell = props => {
|
|
40604
40644
|
const [allOption, setAllOption] = React__namespace.useState();
|
40605
40645
|
const [selectedFiles, setSelectedFiles] = React__namespace.useState([]);
|
40606
40646
|
const handleFilesChange = async (newFiles, selected, actionType) => {
|
40607
|
-
if (
|
40608
|
-
|
40609
|
-
|
40610
|
-
|
40611
|
-
|
40612
|
-
|
40613
|
-
|
40614
|
-
|
40615
|
-
|
40616
|
-
|
40617
|
-
|
40618
|
-
|
40619
|
-
|
40620
|
-
|
40621
|
-
|
40622
|
-
|
40623
|
-
|
40624
|
-
|
40625
|
-
|
40626
|
-
|
40627
|
-
|
40628
|
-
|
40629
|
-
|
40630
|
-
|
40631
|
-
}
|
40632
|
-
console.log('nonDuplicateFiles:', nonDuplicateFiles);
|
40633
|
-
// Upload files with better error handling
|
40634
|
-
const uploadPromises = nonDuplicateFiles.map(async file => {
|
40635
|
-
try {
|
40636
|
-
console.log(`Starting upload for file: ${file.name}`);
|
40637
|
-
const response = await props?.attachmentAction?.addAttachment(file);
|
40638
|
-
console.log(`Raw response for ${file.name}:`, response, typeof response);
|
40639
|
-
// Check if response is falsy or empty
|
40640
|
-
if (!response || typeof response === 'string' && response.trim().length === 0) {
|
40641
|
-
console.error(`Empty or null response for ${file.name}`);
|
40642
|
-
return null;
|
40647
|
+
if (actionType === 'ADD' && cell?.inputType?.type === 'file') {
|
40648
|
+
const parsedFiles = !checkEmpty(cell.value) ? JSON.parse(cell.value) : [];
|
40649
|
+
// Combine selected and newFiles, ensuring selected is an array
|
40650
|
+
const allFiles = [...(selected || []), ...newFiles];
|
40651
|
+
// Check total file count (existing + all files)
|
40652
|
+
const totalFiles = parsedFiles.length + allFiles.length;
|
40653
|
+
if (totalFiles > 5) {
|
40654
|
+
toast.info('Cannot upload more than 5 files.');
|
40655
|
+
return;
|
40656
|
+
}
|
40657
|
+
if (props.attachmentAction?.addAttachment) {
|
40658
|
+
try {
|
40659
|
+
let successCount = 0;
|
40660
|
+
let failureCount = 0;
|
40661
|
+
let duplicateCount = 0;
|
40662
|
+
// Filter out duplicate files (check against parsedFiles and within allFiles)
|
40663
|
+
const uniqueFiles = allFiles.filter((file, index, self) => {
|
40664
|
+
// Check against existing parsedFiles
|
40665
|
+
const isDuplicateInParsed = parsedFiles.some(existing => existing?.name.split('*')[0] === file?.name);
|
40666
|
+
// Check for duplicates within allFiles (keep first occurrence)
|
40667
|
+
const isDuplicateInSelf = self.findIndex(f => f.name === file.name) !== index;
|
40668
|
+
if (isDuplicateInParsed || isDuplicateInSelf) {
|
40669
|
+
duplicateCount++;
|
40670
|
+
return false;
|
40643
40671
|
}
|
40644
|
-
|
40645
|
-
|
40646
|
-
|
40647
|
-
|
40648
|
-
|
40649
|
-
|
40650
|
-
|
40651
|
-
|
40652
|
-
|
40672
|
+
return true;
|
40673
|
+
});
|
40674
|
+
if (uniqueFiles.length === 0) {
|
40675
|
+
if (duplicateCount > 0) {
|
40676
|
+
toast.warning(`Duplicate attachments not allowed within the same row`);
|
40677
|
+
}
|
40678
|
+
return;
|
40679
|
+
}
|
40680
|
+
// Upload files with error handling
|
40681
|
+
const uploadPromises = uniqueFiles.map(async file => {
|
40682
|
+
try {
|
40683
|
+
const response = await props?.attachmentAction?.addAttachment(file);
|
40684
|
+
// Check for invalid response
|
40685
|
+
if (!response || typeof response === 'string' && response.trim().length === 0) {
|
40686
|
+
return {
|
40687
|
+
file,
|
40688
|
+
status: 'failed',
|
40689
|
+
reason: 'no response'
|
40690
|
+
};
|
40691
|
+
}
|
40692
|
+
// Handle string responses
|
40693
|
+
if (typeof response === 'string') {
|
40694
|
+
try {
|
40695
|
+
const parsedResponse = JSON.parse(response);
|
40696
|
+
// Check for response code 400
|
40697
|
+
if (parsedResponse.responseCode === 400) {
|
40698
|
+
return {
|
40699
|
+
file,
|
40700
|
+
status: 'failed',
|
40701
|
+
reason: 'invalid file'
|
40702
|
+
};
|
40703
|
+
}
|
40704
|
+
// Validate parsed response structure
|
40705
|
+
if (parsedResponse && parsedResponse.id && parsedResponse.name) {
|
40706
|
+
return {
|
40707
|
+
file,
|
40708
|
+
status: 'success',
|
40709
|
+
data: parsedResponse
|
40710
|
+
};
|
40711
|
+
} else {
|
40712
|
+
return {
|
40713
|
+
file,
|
40714
|
+
status: 'failed',
|
40715
|
+
reason: 'invalid response'
|
40716
|
+
};
|
40717
|
+
}
|
40718
|
+
} catch (parseError) {
|
40719
|
+
return {
|
40720
|
+
file,
|
40721
|
+
status: 'failed',
|
40722
|
+
reason: 'parse error'
|
40723
|
+
};
|
40724
|
+
}
|
40725
|
+
}
|
40726
|
+
// Handle object responses
|
40727
|
+
if (typeof response === 'object' && response !== null) {
|
40728
|
+
const typedResponse = response;
|
40729
|
+
if (typedResponse?.id && typedResponse?.name) {
|
40730
|
+
return {
|
40731
|
+
file,
|
40732
|
+
status: 'success',
|
40733
|
+
data: typedResponse
|
40734
|
+
};
|
40653
40735
|
} else {
|
40654
|
-
|
40655
|
-
|
40736
|
+
return {
|
40737
|
+
file,
|
40738
|
+
status: 'failed',
|
40739
|
+
reason: 'invalid response'
|
40740
|
+
};
|
40656
40741
|
}
|
40657
|
-
} catch (parseError) {
|
40658
|
-
console.error(`JSON parse failed for ${file.name}:`, parseError, 'Raw response:', response);
|
40659
|
-
return null;
|
40660
40742
|
}
|
40743
|
+
return {
|
40744
|
+
file,
|
40745
|
+
status: 'failed',
|
40746
|
+
reason: 'unknown'
|
40747
|
+
};
|
40748
|
+
} catch (error) {
|
40749
|
+
console.error(`Upload failed for ${file.name}:`, error);
|
40750
|
+
return {
|
40751
|
+
file,
|
40752
|
+
status: 'failed',
|
40753
|
+
reason: 'upload error'
|
40754
|
+
};
|
40661
40755
|
}
|
40662
|
-
|
40663
|
-
|
40664
|
-
|
40665
|
-
|
40666
|
-
|
40667
|
-
|
40668
|
-
|
40756
|
+
});
|
40757
|
+
const results = await Promise.allSettled(uploadPromises);
|
40758
|
+
results.forEach(result => {
|
40759
|
+
if (result.status === 'fulfilled' && result.value) {
|
40760
|
+
const {
|
40761
|
+
status,
|
40762
|
+
data
|
40763
|
+
} = result.value;
|
40764
|
+
if (status === 'success' && data) {
|
40765
|
+
parsedFiles.push(data);
|
40766
|
+
successCount++;
|
40767
|
+
} else if (result.value.reason === 'invalid file') {
|
40768
|
+
failureCount++;
|
40669
40769
|
} else {
|
40670
|
-
|
40671
|
-
return null;
|
40770
|
+
failureCount++;
|
40672
40771
|
}
|
40772
|
+
} else {
|
40773
|
+
failureCount++;
|
40673
40774
|
}
|
40674
|
-
|
40675
|
-
|
40676
|
-
|
40677
|
-
|
40678
|
-
|
40775
|
+
});
|
40776
|
+
// Update cell value
|
40777
|
+
const newValue = parsedFiles.length > 0 ? JSON.stringify(parsedFiles) : '';
|
40778
|
+
handleChange({
|
40779
|
+
...cell,
|
40780
|
+
value: newValue,
|
40781
|
+
style: cell?.style,
|
40782
|
+
inputType: cell?.inputType
|
40783
|
+
});
|
40784
|
+
setSelectedFiles(parsedFiles.map(file => new File([new Blob()], file.name)));
|
40785
|
+
// Show toast messages
|
40786
|
+
if (duplicateCount > 0) {
|
40787
|
+
toast.warning(`Duplicate attachments not allowed within the same row`);
|
40679
40788
|
}
|
40680
|
-
|
40681
|
-
|
40682
|
-
console.log('Promise.allSettled results:', results);
|
40683
|
-
results.forEach((result, index) => {
|
40684
|
-
const fileName = nonDuplicateFiles[index]?.name;
|
40685
|
-
console.log(`Processing result for ${fileName}:`, result);
|
40686
|
-
if (result.status === 'fulfilled' && result.value && result.value.id && result.value.name) {
|
40687
|
-
parsedFiles.push(result.value);
|
40688
|
-
successCount++;
|
40689
|
-
console.log(`Successfully added ${fileName} to parsedFiles`);
|
40690
|
-
} else {
|
40691
|
-
console.error(`Failed to process file ${fileName}:`, result);
|
40692
|
-
failureCount++;
|
40789
|
+
if (successCount > 0) {
|
40790
|
+
toast.success(`${successCount} file${successCount > 1 ? 's' : ''} uploaded successfully.`);
|
40693
40791
|
}
|
40694
|
-
|
40695
|
-
|
40696
|
-
|
40697
|
-
|
40698
|
-
|
40699
|
-
|
40700
|
-
value: newValue,
|
40701
|
-
style: cell?.style,
|
40702
|
-
inputType: cell?.inputType
|
40703
|
-
});
|
40704
|
-
setSelectedFiles(parsedFiles.map(file => new File([new Blob()], file.name)));
|
40705
|
-
// Show appropriate toast messages
|
40706
|
-
if (duplicateCount > 0) {
|
40707
|
-
toast.warning(`Duplicate attachments not allowed within the same row`);
|
40708
|
-
}
|
40709
|
-
if (successCount > 0 && failureCount === 0) {
|
40710
|
-
toast.success(`${successCount} file${successCount > 1 ? 's' : ''} uploaded successfully.`);
|
40711
|
-
} else if (successCount > 0 && failureCount > 0) {
|
40712
|
-
toast.info(`${successCount} file${successCount > 1 ? 's' : ''} uploaded successfully. ${failureCount} file${failureCount > 1 ? 's' : ''} failed.`);
|
40713
|
-
} else if (failureCount > 0) {
|
40714
|
-
toast.error(`${failureCount} unsupported ${failureCount > 1 ? 'files' : 'file'}. Please check the file formats.`);
|
40792
|
+
if (failureCount > 0) {
|
40793
|
+
toast.info(`${failureCount} unsupported ${failureCount > 1 ? 'files' : 'file'}. Please check the file formats.`);
|
40794
|
+
}
|
40795
|
+
} catch (error) {
|
40796
|
+
console.error('Attachment operation failed:', error);
|
40797
|
+
toast.error('Attachment operation failed');
|
40715
40798
|
}
|
40716
|
-
} catch (error) {
|
40717
|
-
console.error('Attachment operation failed:', error);
|
40718
|
-
toast.error('Attachment operation failed');
|
40719
40799
|
}
|
40720
40800
|
} else if (actionType === 'DELETE' && cell?.inputType?.type === 'file') {
|
40721
40801
|
try {
|
@@ -40727,7 +40807,6 @@ const ActiveCell = props => {
|
|
40727
40807
|
if (index !== -1 && fileId && props.attachmentAction?.deleteAttachment) {
|
40728
40808
|
try {
|
40729
40809
|
const response = await props.attachmentAction.deleteAttachment(fileId);
|
40730
|
-
console.log(`Delete response for ${file.name}:`, response);
|
40731
40810
|
if (response) {
|
40732
40811
|
updatedFileDetails.splice(index, 1);
|
40733
40812
|
handleChange({
|
@@ -40737,7 +40816,6 @@ const ActiveCell = props => {
|
|
40737
40816
|
inputType: cell?.inputType
|
40738
40817
|
});
|
40739
40818
|
setSelectedFiles(prevSelectedFiles => [...prevSelectedFiles.filter(f => f.name !== file.name)]);
|
40740
|
-
console.log(`Successfully deleted ${file.name}`);
|
40741
40819
|
} else {
|
40742
40820
|
console.error(`Delete failed for ${file.name}: No response`);
|
40743
40821
|
}
|
@@ -40752,120 +40830,6 @@ const ActiveCell = props => {
|
|
40752
40830
|
}
|
40753
40831
|
}
|
40754
40832
|
};
|
40755
|
-
// const handleFilesChange = async (
|
40756
|
-
// newFiles: File[],
|
40757
|
-
// selected?: File[],
|
40758
|
-
// actionType?: string
|
40759
|
-
// ) => {
|
40760
|
-
// if (newFiles.length > 5) {
|
40761
|
-
// toast.info('Cannot upload more than 5 files.');
|
40762
|
-
// return;
|
40763
|
-
// }
|
40764
|
-
// if (props.attachmentAction?.addAttachment && selected && actionType === 'ADD' && cell?.inputType?.type === 'file') {
|
40765
|
-
// try {
|
40766
|
-
// const parsedFiles: Types.AttachmentApi[] = !checkEmpty(cell.value) ? JSON.parse(cell.value) : [];
|
40767
|
-
// let successCount = 0;
|
40768
|
-
// let failureCount = 0;
|
40769
|
-
// let duplicateCount = 0;
|
40770
|
-
// // Filter out duplicate files
|
40771
|
-
// const nonDuplicateFiles = selected.filter((file) => {
|
40772
|
-
// const isDuplicate = parsedFiles.some(
|
40773
|
-
// (existing) => existing?.name.split('*')[0] === file?.name
|
40774
|
-
// );
|
40775
|
-
// if (isDuplicate) {
|
40776
|
-
// duplicateCount++;
|
40777
|
-
// }
|
40778
|
-
// return !isDuplicate;
|
40779
|
-
// });
|
40780
|
-
// if (nonDuplicateFiles.length === 0) {
|
40781
|
-
// if (duplicateCount > 0) {
|
40782
|
-
// toast.warning(`Duplicate attachments not allowed within the same row`);
|
40783
|
-
// }
|
40784
|
-
// return;
|
40785
|
-
// }
|
40786
|
-
// // Upload files
|
40787
|
-
// const uploadPromises = nonDuplicateFiles?.map(async (file) => {
|
40788
|
-
// try {
|
40789
|
-
// const response = await props?.attachmentAction?.addAttachment(file);
|
40790
|
-
// console.log(`Raw response for ${file.name}:`, response); // Debug log
|
40791
|
-
// if (response && typeof response === 'string' && !checkEmpty(response)) {
|
40792
|
-
// const parsedResponse = JSON.parse(response);
|
40793
|
-
// console.log(`Parsed response for ${file.name}:`, parsedResponse); // Debug log
|
40794
|
-
// if (parsedResponse && parsedResponse.id && parsedResponse.name) {
|
40795
|
-
// return parsedResponse;
|
40796
|
-
// }
|
40797
|
-
// console.error(`Invalid response format for ${file.name}:`, parsedResponse);
|
40798
|
-
// return null;
|
40799
|
-
// }
|
40800
|
-
// console.error(`Invalid or empty response for ${file.name}:`, response);
|
40801
|
-
// return null;
|
40802
|
-
// } catch (error) {
|
40803
|
-
// console.error(`Upload failed for ${file.name}:`, error);
|
40804
|
-
// return null;
|
40805
|
-
// }
|
40806
|
-
// });
|
40807
|
-
// const results = await Promise.allSettled(uploadPromises);
|
40808
|
-
// console.log('res',results);
|
40809
|
-
// results.forEach((result, index) => {
|
40810
|
-
// if (result.status === 'fulfilled' && result.value && result.value.id && result.value.name) {
|
40811
|
-
// parsedFiles.push(result.value as Types.AttachmentApi);
|
40812
|
-
// successCount++;
|
40813
|
-
// } else {
|
40814
|
-
// console.error(`Failed to process file ${nonDuplicateFiles[index]?.name}:`, result);
|
40815
|
-
// failureCount++;
|
40816
|
-
// }
|
40817
|
-
// });
|
40818
|
-
// // Update cell value
|
40819
|
-
// handleChange({
|
40820
|
-
// ...cell,
|
40821
|
-
// value: JSON.stringify(parsedFiles),
|
40822
|
-
// style: cell?.style,
|
40823
|
-
// inputType: cell?.inputType,
|
40824
|
-
// });
|
40825
|
-
// setSelectedFiles(parsedFiles.map((file) => new File([new Blob()], file.name)));
|
40826
|
-
// // Original toast messages
|
40827
|
-
// if (duplicateCount > 0) {
|
40828
|
-
// toast.warning(`Duplicate attachments not allowed within the same row`);
|
40829
|
-
// } else if (successCount > 0 && failureCount === 0) {
|
40830
|
-
// toast.success(`file${successCount > 1 ? 's' : ''} uploaded successfully.`);
|
40831
|
-
// } else if (failureCount > 0) {
|
40832
|
-
// toast.info(`${failureCount} unsupported ${failureCount > 1 ? 'files' : 'file'}. Please check the file formats.`);
|
40833
|
-
// }
|
40834
|
-
// } catch (error) {
|
40835
|
-
// console.error('Attachment operation failed:', error);
|
40836
|
-
// toast.error('Attachment operation failed');
|
40837
|
-
// }
|
40838
|
-
// } else if (actionType === 'DELETE' && cell?.inputType?.type === 'file') {
|
40839
|
-
// try {
|
40840
|
-
// const parsedValue = cell && JSON.parse(cell.value);
|
40841
|
-
// const updatedFileDetails = [...parsedValue];
|
40842
|
-
// for (const file of selected || []) {
|
40843
|
-
// const index = updatedFileDetails.findIndex(
|
40844
|
-
// (originalFile: Types.AttachmentApi) => originalFile.name === file.name
|
40845
|
-
// );
|
40846
|
-
// const fileId = updatedFileDetails[index]?.id;
|
40847
|
-
// if (index !== -1 && fileId && props.attachmentAction?.deleteAttachment) {
|
40848
|
-
// const response = await props.attachmentAction.deleteAttachment(fileId);
|
40849
|
-
// if (response) {
|
40850
|
-
// updatedFileDetails.splice(index, 1);
|
40851
|
-
// handleChange({
|
40852
|
-
// ...cell,
|
40853
|
-
// value: !checkEmpty(updatedFileDetails) ? JSON.stringify(updatedFileDetails) : '',
|
40854
|
-
// style: cell?.style,
|
40855
|
-
// inputType: cell?.inputType,
|
40856
|
-
// });
|
40857
|
-
// setSelectedFiles((prevSelectedFiles) => [
|
40858
|
-
// ...prevSelectedFiles.filter((f) => f.name !== file.name),
|
40859
|
-
// ]);
|
40860
|
-
// }
|
40861
|
-
// }
|
40862
|
-
// }
|
40863
|
-
// } catch (error) {
|
40864
|
-
// toast.error('Attachment operation failed');
|
40865
|
-
// console.error('Attachment failed:', error);
|
40866
|
-
// }
|
40867
|
-
// }
|
40868
|
-
// };
|
40869
40833
|
const handleClick = e => {
|
40870
40834
|
const selectedList = e.target.innerText;
|
40871
40835
|
if (selectedList) {
|