sag_components 2.0.0-beta292 → 2.0.0-beta294
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.esm.js +187 -92
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +187 -92
- package/dist/index.js.map +1 -1
- package/dist/types/components/OverlayDropdown/OverlayDropdown.stories.d.ts +7 -7
- package/dist/types/components/Table/DropMenus/Dropdown.d.ts +7 -3
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -42574,6 +42574,7 @@ const Dropdown = ({
|
|
|
42574
42574
|
isOpen,
|
|
42575
42575
|
options,
|
|
42576
42576
|
selectedValue,
|
|
42577
|
+
// Can now be an array for multi-select
|
|
42577
42578
|
displayText,
|
|
42578
42579
|
onToggle,
|
|
42579
42580
|
onOptionSelect,
|
|
@@ -42583,16 +42584,79 @@ const Dropdown = ({
|
|
|
42583
42584
|
selectedColor,
|
|
42584
42585
|
dropdownOptionsWidth,
|
|
42585
42586
|
dropdownOptionsAlignment = 'right',
|
|
42586
|
-
placeholder = 'Select...'
|
|
42587
|
+
placeholder = 'Select...',
|
|
42588
|
+
multiSelect = true,
|
|
42589
|
+
// New prop to enable/disable multi-select
|
|
42590
|
+
showSelectAll = true // New prop to show/hide "Select All" option
|
|
42587
42591
|
}) => {
|
|
42588
42592
|
const [isDropdownHovered, setIsDropdownHovered] = useState(false);
|
|
42589
42593
|
|
|
42594
|
+
// Normalize selectedValue to always be an array for consistency
|
|
42595
|
+
const selectedValues = Array.isArray(selectedValue) ? selectedValue : selectedValue ? [selectedValue] : [];
|
|
42596
|
+
|
|
42590
42597
|
// Reset dropdown hover state when dropdown closes
|
|
42591
42598
|
useEffect(() => {
|
|
42592
42599
|
if (!isOpen) {
|
|
42593
42600
|
setIsDropdownHovered(false);
|
|
42594
42601
|
}
|
|
42595
42602
|
}, [isOpen]);
|
|
42603
|
+
|
|
42604
|
+
// Check if an option is selected
|
|
42605
|
+
const isOptionSelected = optionValue => {
|
|
42606
|
+
return selectedValues.includes(optionValue);
|
|
42607
|
+
};
|
|
42608
|
+
|
|
42609
|
+
// Check if all options are selected
|
|
42610
|
+
const areAllSelected = () => {
|
|
42611
|
+
return options.length > 0 && options.every(option => isOptionSelected(option.value));
|
|
42612
|
+
};
|
|
42613
|
+
|
|
42614
|
+
// Handle option click
|
|
42615
|
+
const handleOptionClick = (option, e) => {
|
|
42616
|
+
e.stopPropagation();
|
|
42617
|
+
if (!multiSelect) {
|
|
42618
|
+
// Single select mode - close dropdown after selection
|
|
42619
|
+
onOptionSelect(option, e);
|
|
42620
|
+
return;
|
|
42621
|
+
}
|
|
42622
|
+
|
|
42623
|
+
// Multi-select mode - keep dropdown open
|
|
42624
|
+
onOptionSelect(option, e);
|
|
42625
|
+
};
|
|
42626
|
+
|
|
42627
|
+
// Handle "Select All" click
|
|
42628
|
+
const handleSelectAllClick = e => {
|
|
42629
|
+
e.stopPropagation();
|
|
42630
|
+
if (areAllSelected()) {
|
|
42631
|
+
// Deselect all
|
|
42632
|
+
onOptionSelect({
|
|
42633
|
+
value: 'none',
|
|
42634
|
+
label: 'Deselect All',
|
|
42635
|
+
isSelectAll: true
|
|
42636
|
+
}, e);
|
|
42637
|
+
} else {
|
|
42638
|
+
// Select all
|
|
42639
|
+
onOptionSelect({
|
|
42640
|
+
value: 'all',
|
|
42641
|
+
label: 'Select All',
|
|
42642
|
+
isSelectAll: true
|
|
42643
|
+
}, e);
|
|
42644
|
+
}
|
|
42645
|
+
};
|
|
42646
|
+
|
|
42647
|
+
// Generate display text based on selections
|
|
42648
|
+
const getDisplayText = () => {
|
|
42649
|
+
if (selectedValues.length === 0) {
|
|
42650
|
+
return placeholder;
|
|
42651
|
+
}
|
|
42652
|
+
|
|
42653
|
+
// if (selectedValues.length === 1) {
|
|
42654
|
+
// const selectedOption = options.find(opt => opt.value === selectedValues[0]);
|
|
42655
|
+
// return selectedOption ? selectedOption.label : displayText;
|
|
42656
|
+
// }
|
|
42657
|
+
|
|
42658
|
+
return `${selectedValues.map(val => options.find(opt => opt.value === val).label).join(', ')}`;
|
|
42659
|
+
};
|
|
42596
42660
|
return /*#__PURE__*/React$1.createElement(DropdownContainer$1, {
|
|
42597
42661
|
onMouseEnter: () => setIsDropdownHovered(true),
|
|
42598
42662
|
onMouseLeave: () => setIsDropdownHovered(false)
|
|
@@ -42602,7 +42666,7 @@ const Dropdown = ({
|
|
|
42602
42666
|
$isRowFocused: isRowFocused,
|
|
42603
42667
|
$isRowHovered: isRowHovered,
|
|
42604
42668
|
$selectedColor: selectedColor
|
|
42605
|
-
}, /*#__PURE__*/React$1.createElement("span", null, displayText), /*#__PURE__*/React$1.createElement(DropdownIcon, {
|
|
42669
|
+
}, /*#__PURE__*/React$1.createElement("span", null, displayText || getDisplayText()), /*#__PURE__*/React$1.createElement(DropdownIcon, {
|
|
42606
42670
|
$isOpen: isOpen,
|
|
42607
42671
|
$isRowFocused: isRowFocused,
|
|
42608
42672
|
$isRowHovered: isRowHovered,
|
|
@@ -42615,11 +42679,22 @@ const Dropdown = ({
|
|
|
42615
42679
|
$maxDropdownHeight: maxDropdownHeight,
|
|
42616
42680
|
$dropdownOptionsWidth: dropdownOptionsWidth,
|
|
42617
42681
|
$dropdownOptionsAlignment: dropdownOptionsAlignment
|
|
42618
|
-
}, options.
|
|
42682
|
+
}, multiSelect && showSelectAll && options.length > 0 && /*#__PURE__*/React$1.createElement(DropdownOption, {
|
|
42683
|
+
onClick: handleSelectAllClick,
|
|
42684
|
+
$isSelected: areAllSelected(),
|
|
42685
|
+
style: {
|
|
42686
|
+
borderBottom: '1px solid #E5E7EB',
|
|
42687
|
+
fontWeight: '500'
|
|
42688
|
+
}
|
|
42689
|
+
}, /*#__PURE__*/React$1.createElement("span", null, areAllSelected() ? 'Deselect All' : 'Select All'), areAllSelected() && /*#__PURE__*/React$1.createElement(OkIcon, {
|
|
42690
|
+
width: "24",
|
|
42691
|
+
height: "24",
|
|
42692
|
+
color: "#066768"
|
|
42693
|
+
})), options.map((option, index) => /*#__PURE__*/React$1.createElement(DropdownOption, {
|
|
42619
42694
|
key: index,
|
|
42620
|
-
onClick: e =>
|
|
42621
|
-
$isSelected: option.value
|
|
42622
|
-
}, /*#__PURE__*/React$1.createElement("span", null, option.label), option.value
|
|
42695
|
+
onClick: e => handleOptionClick(option, e),
|
|
42696
|
+
$isSelected: isOptionSelected(option.value)
|
|
42697
|
+
}, /*#__PURE__*/React$1.createElement("span", null, option.label), isOptionSelected(option.value) && /*#__PURE__*/React$1.createElement(OkIcon, {
|
|
42623
42698
|
width: "24",
|
|
42624
42699
|
height: "24",
|
|
42625
42700
|
color: "#066768"
|
|
@@ -42631,8 +42706,8 @@ Dropdown.propTypes = {
|
|
|
42631
42706
|
value: PropTypes.string.isRequired,
|
|
42632
42707
|
label: PropTypes.string.isRequired
|
|
42633
42708
|
})).isRequired,
|
|
42634
|
-
selectedValue: PropTypes.string,
|
|
42635
|
-
displayText: PropTypes.string
|
|
42709
|
+
selectedValue: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
|
|
42710
|
+
displayText: PropTypes.string,
|
|
42636
42711
|
onToggle: PropTypes.func.isRequired,
|
|
42637
42712
|
onOptionSelect: PropTypes.func.isRequired,
|
|
42638
42713
|
maxDropdownHeight: PropTypes.string,
|
|
@@ -42641,7 +42716,9 @@ Dropdown.propTypes = {
|
|
|
42641
42716
|
selectedColor: PropTypes.string,
|
|
42642
42717
|
dropdownOptionsWidth: PropTypes.string,
|
|
42643
42718
|
dropdownOptionsAlignment: PropTypes.oneOf(['left', 'right']),
|
|
42644
|
-
placeholder: PropTypes.string
|
|
42719
|
+
placeholder: PropTypes.string,
|
|
42720
|
+
multiSelect: PropTypes.bool,
|
|
42721
|
+
showSelectAll: PropTypes.bool
|
|
42645
42722
|
};
|
|
42646
42723
|
|
|
42647
42724
|
const HeroIcon = ({
|
|
@@ -42797,44 +42874,31 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
42797
42874
|
isEditMode = false,
|
|
42798
42875
|
editRowIndex = -1
|
|
42799
42876
|
}, ref) => {
|
|
42800
|
-
// MOVE ALL VALIDATION TO THE VERY TOP BEFORE ANY HOOKS
|
|
42801
42877
|
if (!Array.isArray(data) || !Array.isArray(columns)) {
|
|
42802
42878
|
console.warn("TableBody: Invalid data or columns prop");
|
|
42803
42879
|
return null;
|
|
42804
42880
|
}
|
|
42805
|
-
|
|
42806
|
-
// NOW ALL THE HOOKS CAN BE CALLED SAFELY
|
|
42807
42881
|
const [hoveredRowIndex, setHoveredRowIndex] = useState(null);
|
|
42808
42882
|
const [focusedRowIndex, setFocusedRowIndex] = useState(null);
|
|
42809
42883
|
const [isCommentModalOpen, setIsCommentModalOpen] = useState(false);
|
|
42810
42884
|
const [currentCommentRow, setCurrentCommentRow] = useState(null);
|
|
42811
42885
|
const [openDropdowns, setOpenDropdowns] = useState({});
|
|
42812
|
-
|
|
42813
|
-
// TextArea logic states
|
|
42814
42886
|
const [commentText, setCommentText] = useState("");
|
|
42815
42887
|
const [isFocused, setIsFocused] = useState(false);
|
|
42816
42888
|
const [hasUserInteracted, setHasUserInteracted] = useState(false);
|
|
42817
42889
|
const [hasInitialValue, setHasInitialValue] = useState(false);
|
|
42818
|
-
|
|
42819
|
-
// Shimmer state - manage shimmer effect at the top level
|
|
42820
42890
|
const [shimmerRowIndex, setShimmerRowIndex] = useState(-1);
|
|
42821
42891
|
const [shimmerStartTime, setShimmerStartTime] = useState(null);
|
|
42822
|
-
|
|
42823
|
-
// Helper function to get nested values from objects (e.g., "status.PackageStatusDescription")
|
|
42824
42892
|
const getNestedValue = (obj, path) => {
|
|
42825
42893
|
if (!path || typeof path !== 'string') return undefined;
|
|
42826
42894
|
return path.split('.').reduce((current, key) => {
|
|
42827
42895
|
return current && current[key] !== undefined ? current[key] : undefined;
|
|
42828
42896
|
}, obj);
|
|
42829
42897
|
};
|
|
42830
|
-
|
|
42831
|
-
// Handle shimmer effect changes
|
|
42832
42898
|
useEffect(() => {
|
|
42833
42899
|
if (indexToShimmer >= 0) {
|
|
42834
42900
|
setShimmerRowIndex(indexToShimmer);
|
|
42835
42901
|
setShimmerStartTime(Date.now());
|
|
42836
|
-
|
|
42837
|
-
// Auto-stop shimmer after 5 seconds
|
|
42838
42902
|
const timeout = setTimeout(() => {
|
|
42839
42903
|
setShimmerRowIndex(-1);
|
|
42840
42904
|
setShimmerStartTime(null);
|
|
@@ -42845,8 +42909,6 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
42845
42909
|
setShimmerStartTime(null);
|
|
42846
42910
|
}
|
|
42847
42911
|
}, [indexToShimmer]);
|
|
42848
|
-
|
|
42849
|
-
// Expose methods to parent component via ref
|
|
42850
42912
|
useImperativeHandle(ref, () => ({
|
|
42851
42913
|
clearFocus: () => {
|
|
42852
42914
|
setFocusedRowIndex(null);
|
|
@@ -42882,8 +42944,6 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
42882
42944
|
setFocusedRowIndex(changeFocusIndex);
|
|
42883
42945
|
}
|
|
42884
42946
|
}, [changeFocusIndex]);
|
|
42885
|
-
|
|
42886
|
-
// Close all dropdowns when clicking outside
|
|
42887
42947
|
useEffect(() => {
|
|
42888
42948
|
const handleClickOutside = () => {
|
|
42889
42949
|
setOpenDropdowns({});
|
|
@@ -42893,8 +42953,6 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
42893
42953
|
document.removeEventListener("click", handleClickOutside);
|
|
42894
42954
|
};
|
|
42895
42955
|
}, []);
|
|
42896
|
-
|
|
42897
|
-
// HANDLE SPECIAL CASE: EMPTY DATA AFTER ALL HOOKS
|
|
42898
42956
|
if (data.length === 0) {
|
|
42899
42957
|
return /*#__PURE__*/React$1.createElement(StyledTableBody, {
|
|
42900
42958
|
ref: ref
|
|
@@ -42902,8 +42960,6 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
42902
42960
|
colSpan: columns.length
|
|
42903
42961
|
}, "No data available")));
|
|
42904
42962
|
}
|
|
42905
|
-
|
|
42906
|
-
// Handle row click for focus state
|
|
42907
42963
|
const handleRowClick = (row, rowIndex) => {
|
|
42908
42964
|
if (isEditMode && editRowIndex !== -1) {
|
|
42909
42965
|
return;
|
|
@@ -42913,8 +42969,6 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
42913
42969
|
onRowClick(row, rowIndex);
|
|
42914
42970
|
}
|
|
42915
42971
|
};
|
|
42916
|
-
|
|
42917
|
-
// TextArea handlers
|
|
42918
42972
|
const handleTextChange = e => {
|
|
42919
42973
|
const text = e.target.value;
|
|
42920
42974
|
if (text.length <= commentTextLimit) {
|
|
@@ -42930,16 +42984,12 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
42930
42984
|
const handleBlur = () => {
|
|
42931
42985
|
setIsFocused(false);
|
|
42932
42986
|
};
|
|
42933
|
-
|
|
42934
|
-
// Handle comment save
|
|
42935
42987
|
const handleCommentSave = () => {
|
|
42936
42988
|
if (currentCommentRow !== null) {
|
|
42937
42989
|
onCommentSave(currentCommentRow, commentText);
|
|
42938
42990
|
}
|
|
42939
42991
|
handleCommentModalClose();
|
|
42940
42992
|
};
|
|
42941
|
-
|
|
42942
|
-
// Handle comment modal close
|
|
42943
42993
|
const handleCommentModalClose = () => {
|
|
42944
42994
|
setCommentText("");
|
|
42945
42995
|
setHasUserInteracted(false);
|
|
@@ -42947,17 +42997,12 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
42947
42997
|
setCurrentCommentRow(null);
|
|
42948
42998
|
setIsCommentModalOpen(false);
|
|
42949
42999
|
};
|
|
42950
|
-
|
|
42951
|
-
// Determine if save button should be enabled
|
|
42952
43000
|
const isSaveEnabled = hasUserInteracted && (commentText.length > 0 || hasInitialValue);
|
|
42953
|
-
|
|
42954
|
-
// Helper function to format tag text
|
|
42955
43001
|
const formatTagText = tag => {
|
|
42956
43002
|
if (typeof tag !== "string") return String(tag || "");
|
|
42957
43003
|
return tag.replace(/-/g, " ").replace(/\b\w/g, l => l.toUpperCase());
|
|
42958
43004
|
};
|
|
42959
43005
|
const formatValue = (value, column, row, rowIndex) => {
|
|
42960
|
-
// Add safety checks at the start
|
|
42961
43006
|
if (!column) {
|
|
42962
43007
|
console.warn('formatValue called with null/undefined column');
|
|
42963
43008
|
return "";
|
|
@@ -42966,8 +43011,6 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
42966
43011
|
if ((value === null || value === undefined) && column?.fieldType?.toLowerCase() !== "comments" && column?.fieldType?.toLowerCase() !== "editable") {
|
|
42967
43012
|
return "";
|
|
42968
43013
|
}
|
|
42969
|
-
|
|
42970
|
-
// Find the tooltip text for the current value - can be used for different fieldTypes
|
|
42971
43014
|
const getTooltipText = value => {
|
|
42972
43015
|
try {
|
|
42973
43016
|
if (column?.tooltipText && Array.isArray(column.tooltipText)) {
|
|
@@ -43020,8 +43063,6 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
43020
43063
|
} else {
|
|
43021
43064
|
formattedDate = String(value || "");
|
|
43022
43065
|
}
|
|
43023
|
-
|
|
43024
|
-
// Check if this column should check for expiration
|
|
43025
43066
|
if (column.checkExpiration !== false && value && isDateExpired(value)) {
|
|
43026
43067
|
return /*#__PURE__*/React$1.createElement("span", {
|
|
43027
43068
|
style: {
|
|
@@ -43091,15 +43132,12 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
43091
43132
|
}
|
|
43092
43133
|
case "dotindicator":
|
|
43093
43134
|
try {
|
|
43094
|
-
// Check if value is an object with show and color properties
|
|
43095
43135
|
if (!value || typeof value !== 'object') return null;
|
|
43096
43136
|
const {
|
|
43097
43137
|
show,
|
|
43098
43138
|
color,
|
|
43099
43139
|
tooltip
|
|
43100
43140
|
} = value;
|
|
43101
|
-
|
|
43102
|
-
// Only show the dot if show is true
|
|
43103
43141
|
if (!show) return null;
|
|
43104
43142
|
return /*#__PURE__*/React$1.createElement(DotIndicatorWrapper, {
|
|
43105
43143
|
ref: el => {
|
|
@@ -43179,7 +43217,6 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
43179
43217
|
}
|
|
43180
43218
|
};
|
|
43181
43219
|
const tooltipText = getTooltipText(value);
|
|
43182
|
-
// Handle array values (like PackageStatusName)
|
|
43183
43220
|
const processedValue = Array.isArray(value) ? value[0] : value;
|
|
43184
43221
|
const lowerValue = String(processedValue || "").toLowerCase();
|
|
43185
43222
|
if (lowerValue === "empty") {
|
|
@@ -43392,12 +43429,24 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
43392
43429
|
const dropdownOptionsWidth = column.dropdownOptionsWidth;
|
|
43393
43430
|
const dropdownOptionsAlignment = column.dropdownOptionsAlignment || "right";
|
|
43394
43431
|
const placeholder = column.placeholder || "Select...";
|
|
43395
|
-
const
|
|
43396
|
-
const
|
|
43432
|
+
const isMultiSelect = column.multiSelect !== false;
|
|
43433
|
+
const showSelectAll = column.showSelectAll !== false;
|
|
43434
|
+
const normalizedValue = Array.isArray(value) ? value : value ? [value] : [];
|
|
43435
|
+
let displayText;
|
|
43436
|
+
if (normalizedValue.length === 0) {
|
|
43437
|
+
displayText = placeholder;
|
|
43438
|
+
} else if (normalizedValue.length === dropdownOptions.length && dropdownOptions.length > 0) {
|
|
43439
|
+
displayText = 'All Selected';
|
|
43440
|
+
} else if (normalizedValue.length === 1) {
|
|
43441
|
+
const selectedOption = dropdownOptions.find(opt => opt.value === normalizedValue[0]);
|
|
43442
|
+
displayText = selectedOption ? selectedOption.label : placeholder;
|
|
43443
|
+
} else {
|
|
43444
|
+
displayText = `${normalizedValue.map(val => dropdownOptions.find(opt => opt.value === val).label).join(', ')}`;
|
|
43445
|
+
}
|
|
43397
43446
|
return /*#__PURE__*/React$1.createElement(Dropdown, {
|
|
43398
43447
|
isOpen: isOpen,
|
|
43399
43448
|
options: dropdownOptions,
|
|
43400
|
-
selectedValue:
|
|
43449
|
+
selectedValue: normalizedValue,
|
|
43401
43450
|
displayText: displayText,
|
|
43402
43451
|
onToggle: e => handleDropdownClick(rowIndex, column.key, e),
|
|
43403
43452
|
onOptionSelect: (option, e) => handleDropdownOptionClick(row, rowIndex, column.key, option, e),
|
|
@@ -43407,7 +43456,9 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
43407
43456
|
placeholder: placeholder,
|
|
43408
43457
|
isRowFocused: focusedRowIndex === rowIndex,
|
|
43409
43458
|
isRowHovered: hoveredRowIndex === rowIndex,
|
|
43410
|
-
selectedColor: selectedColor
|
|
43459
|
+
selectedColor: selectedColor,
|
|
43460
|
+
multiSelect: isMultiSelect,
|
|
43461
|
+
showSelectAll: showSelectAll
|
|
43411
43462
|
});
|
|
43412
43463
|
} catch (e) {
|
|
43413
43464
|
console.warn('Error formatting dropdown:', e);
|
|
@@ -43416,8 +43467,6 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
43416
43467
|
case "checkbox":
|
|
43417
43468
|
try {
|
|
43418
43469
|
const isChecked = Boolean(value);
|
|
43419
|
-
// Check if this specific checkbox should be disabled
|
|
43420
|
-
// Format: checkboxDisabled_{columnKey} or checkboxDisabled (for backward compatibility)
|
|
43421
43470
|
const isDisabled = row[`checkboxDisabled_${column.key}`] === true || column.key && row[`checkboxDisabled_${column.key}`] === true;
|
|
43422
43471
|
return /*#__PURE__*/React$1.createElement("div", {
|
|
43423
43472
|
style: {
|
|
@@ -43470,8 +43519,6 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
43470
43519
|
const shouldShowTooltip = (element, content) => {
|
|
43471
43520
|
return element && element.scrollWidth > element.clientWidth;
|
|
43472
43521
|
};
|
|
43473
|
-
|
|
43474
|
-
// Handle expand click
|
|
43475
43522
|
const handleExpandClick = (row, rowIndex, event) => {
|
|
43476
43523
|
event.stopPropagation();
|
|
43477
43524
|
if (onExpandRow) {
|
|
@@ -43479,8 +43526,6 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
43479
43526
|
onExpandRow(row, rowIndex, expandStatus);
|
|
43480
43527
|
}
|
|
43481
43528
|
};
|
|
43482
|
-
|
|
43483
|
-
// Handle checkbox click
|
|
43484
43529
|
const handleCheckboxClick = (row, columnKey, event) => {
|
|
43485
43530
|
event.stopPropagation();
|
|
43486
43531
|
const currentValue = row[columnKey];
|
|
@@ -43497,8 +43542,6 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
43497
43542
|
});
|
|
43498
43543
|
}
|
|
43499
43544
|
};
|
|
43500
|
-
|
|
43501
|
-
// Handle dropdown click
|
|
43502
43545
|
const handleDropdownClick = (rowIndex, columnKey, event) => {
|
|
43503
43546
|
event.stopPropagation();
|
|
43504
43547
|
const dropdownKey = `${rowIndex}-${columnKey}`;
|
|
@@ -43507,17 +43550,66 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
43507
43550
|
[dropdownKey]: !prev[dropdownKey]
|
|
43508
43551
|
}));
|
|
43509
43552
|
};
|
|
43510
|
-
|
|
43511
|
-
// Handle dropdown option selection
|
|
43512
43553
|
const handleDropdownOptionClick = (row, rowIndex, columnKey, selectedOption, event) => {
|
|
43513
43554
|
event.stopPropagation();
|
|
43555
|
+
const column = columns.find(col => col.key === columnKey);
|
|
43556
|
+
const isMultiSelect = column?.multiSelect !== false;
|
|
43557
|
+
if (selectedOption.isSelectAll) {
|
|
43558
|
+
const dropdownKey = `${rowIndex}-${columnKey}`;
|
|
43559
|
+
if (selectedOption.value === 'all') {
|
|
43560
|
+
const allValues = column.dropdownOptions.map(opt => opt.value);
|
|
43561
|
+
if (onDropdownSelected) {
|
|
43562
|
+
onDropdownSelected(row, {
|
|
43563
|
+
value: allValues,
|
|
43564
|
+
label: 'All Selected',
|
|
43565
|
+
isSelectAll: true
|
|
43566
|
+
}, columnKey);
|
|
43567
|
+
}
|
|
43568
|
+
} else {
|
|
43569
|
+
if (onDropdownSelected) {
|
|
43570
|
+
onDropdownSelected(row, {
|
|
43571
|
+
value: [],
|
|
43572
|
+
label: 'None Selected',
|
|
43573
|
+
isSelectAll: true
|
|
43574
|
+
}, columnKey);
|
|
43575
|
+
}
|
|
43576
|
+
}
|
|
43577
|
+
if (isMultiSelect) {
|
|
43578
|
+
setOpenDropdowns(prev => ({
|
|
43579
|
+
...prev,
|
|
43580
|
+
[dropdownKey]: true
|
|
43581
|
+
}));
|
|
43582
|
+
} else {
|
|
43583
|
+
setOpenDropdowns(prev => ({
|
|
43584
|
+
...prev,
|
|
43585
|
+
[dropdownKey]: false
|
|
43586
|
+
}));
|
|
43587
|
+
}
|
|
43588
|
+
return;
|
|
43589
|
+
}
|
|
43514
43590
|
const dropdownKey = `${rowIndex}-${columnKey}`;
|
|
43515
|
-
|
|
43516
|
-
|
|
43517
|
-
[
|
|
43518
|
-
|
|
43519
|
-
|
|
43520
|
-
|
|
43591
|
+
if (isMultiSelect) {
|
|
43592
|
+
const currentValues = Array.isArray(row[columnKey]) ? row[columnKey] : row[columnKey] ? [row[columnKey]] : [];
|
|
43593
|
+
const newValues = currentValues.includes(selectedOption.value) ? currentValues.filter(v => v !== selectedOption.value) : [...currentValues, selectedOption.value];
|
|
43594
|
+
if (onDropdownSelected) {
|
|
43595
|
+
onDropdownSelected(row, {
|
|
43596
|
+
...selectedOption,
|
|
43597
|
+
value: newValues,
|
|
43598
|
+
selectedValues: newValues
|
|
43599
|
+
}, columnKey);
|
|
43600
|
+
}
|
|
43601
|
+
setOpenDropdowns(prev => ({
|
|
43602
|
+
...prev,
|
|
43603
|
+
[dropdownKey]: true
|
|
43604
|
+
}));
|
|
43605
|
+
} else {
|
|
43606
|
+
setOpenDropdowns(prev => ({
|
|
43607
|
+
...prev,
|
|
43608
|
+
[dropdownKey]: false
|
|
43609
|
+
}));
|
|
43610
|
+
if (onDropdownSelected) {
|
|
43611
|
+
onDropdownSelected(row, selectedOption, columnKey);
|
|
43612
|
+
}
|
|
43521
43613
|
}
|
|
43522
43614
|
};
|
|
43523
43615
|
const handleEditableClick = (row, columnKey, currentValue, rowIndex) => {
|
|
@@ -43530,15 +43622,13 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
43530
43622
|
});
|
|
43531
43623
|
}
|
|
43532
43624
|
};
|
|
43533
|
-
|
|
43534
|
-
// Helper function to check if date is expired (past current date)
|
|
43535
43625
|
const isDateExpired = dateString => {
|
|
43536
43626
|
if (!dateString) return false;
|
|
43537
43627
|
try {
|
|
43538
43628
|
const date = new Date(dateString);
|
|
43539
43629
|
if (isNaN(date.getTime())) return false;
|
|
43540
43630
|
const today = new Date();
|
|
43541
|
-
today.setHours(0, 0, 0, 0);
|
|
43631
|
+
today.setHours(0, 0, 0, 0);
|
|
43542
43632
|
date.setHours(0, 0, 0, 0);
|
|
43543
43633
|
return date < today;
|
|
43544
43634
|
} catch (error) {
|
|
@@ -43548,7 +43638,6 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
43548
43638
|
return /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement(StyledTableBody, {
|
|
43549
43639
|
ref: ref
|
|
43550
43640
|
}, data.map((row, rowIndex) => {
|
|
43551
|
-
// Skip invalid rows
|
|
43552
43641
|
if (!row || typeof row !== 'object') {
|
|
43553
43642
|
console.warn(`Invalid row at index ${rowIndex}:`, row);
|
|
43554
43643
|
return null;
|
|
@@ -43592,18 +43681,13 @@ const TableBody = /*#__PURE__*/forwardRef(({
|
|
|
43592
43681
|
}
|
|
43593
43682
|
let value, formattedValue;
|
|
43594
43683
|
try {
|
|
43595
|
-
// Support nested keys like "status.PackageStatusDescription"
|
|
43596
43684
|
value = column.key.includes('.') ? getNestedValue(row, column.key) : row[column.key];
|
|
43597
43685
|
formattedValue = formatValue(value, column, row, rowIndex) || "";
|
|
43598
43686
|
} catch (e) {
|
|
43599
43687
|
console.error("Error formatting value:", e);
|
|
43600
43688
|
formattedValue = "";
|
|
43601
43689
|
}
|
|
43602
|
-
|
|
43603
|
-
// Check if this is a text-based field for shimmer rendering
|
|
43604
43690
|
const isTextBasedField = column.fieldType?.toLowerCase() === "text" || column.fieldType?.toLowerCase() === "currency" || column.fieldType?.toLowerCase() === "number" || column.fieldType?.toLowerCase() === "percentage" || column.fieldType?.toLowerCase() === "date" || !column.fieldType;
|
|
43605
|
-
|
|
43606
|
-
// Determine if shimmer should be applied
|
|
43607
43691
|
const shouldShimmer = isTextBasedField && rowIndex === shimmerRowIndex && shimmerStartTime !== null;
|
|
43608
43692
|
return /*#__PURE__*/React$1.createElement(TableCell, {
|
|
43609
43693
|
key: `${column.key}-${rowIndex}`,
|
|
@@ -58126,13 +58210,34 @@ const OverlayDropdown = _ref => {
|
|
|
58126
58210
|
}, ["Template Offer", "Last defined by you"].includes(group.overlayName) && /*#__PURE__*/React$1.createElement(SectionTitle, null, group.overlayName), group.items.map(item => {
|
|
58127
58211
|
const isDigitalCoupon = group.templateType === 3 && editableDigitalCoupon;
|
|
58128
58212
|
const hasAppliedCoupons = appliedCouponsCount > 0;
|
|
58129
|
-
const penColor = isDigitalCoupon && hasAppliedCoupons ? "#FF8C00" : item.value === value ? "#fff" : "#212121";
|
|
58130
|
-
|
|
58131
|
-
// Update label to show count for digital coupons
|
|
58132
58213
|
let displayText = item.label;
|
|
58133
58214
|
if (isDigitalCoupon && appliedCouponsCount > 0) {
|
|
58134
58215
|
displayText = `Digital Coupon/s (${appliedCouponsCount})`;
|
|
58135
58216
|
}
|
|
58217
|
+
let iconToShow = null;
|
|
58218
|
+
if (group.templateType === 2) {
|
|
58219
|
+
iconToShow = /*#__PURE__*/React$1.createElement(ChervronRightIcon, {
|
|
58220
|
+
fill: item.value === value ? "#fff" : "#212121"
|
|
58221
|
+
});
|
|
58222
|
+
} else if (isDigitalCoupon) {
|
|
58223
|
+
if (hasAppliedCoupons) {
|
|
58224
|
+
iconToShow = /*#__PURE__*/React$1.createElement(PenIcon, {
|
|
58225
|
+
color: item.value === value ? "#fff" : "#212121",
|
|
58226
|
+
width: "16",
|
|
58227
|
+
height: "16"
|
|
58228
|
+
});
|
|
58229
|
+
} else {
|
|
58230
|
+
iconToShow = /*#__PURE__*/React$1.createElement(ChervronRightIcon, {
|
|
58231
|
+
fill: item.value === value ? "#fff" : "#212121"
|
|
58232
|
+
});
|
|
58233
|
+
}
|
|
58234
|
+
} else if (item.value === value) {
|
|
58235
|
+
iconToShow = /*#__PURE__*/React$1.createElement(OkIcon, {
|
|
58236
|
+
width: "22px",
|
|
58237
|
+
height: "22px",
|
|
58238
|
+
color: "#fff"
|
|
58239
|
+
});
|
|
58240
|
+
}
|
|
58136
58241
|
return /*#__PURE__*/React$1.createElement(DropdownItem, {
|
|
58137
58242
|
key: item.value,
|
|
58138
58243
|
selected: item.value === value,
|
|
@@ -58171,17 +58276,7 @@ const OverlayDropdown = _ref => {
|
|
|
58171
58276
|
}, /*#__PURE__*/React$1.createElement(TruncatedText, {
|
|
58172
58277
|
onMouseEnter: () => setHoveredText(displayText),
|
|
58173
58278
|
onMouseLeave: () => setHoveredText(null)
|
|
58174
|
-
}, displayText),
|
|
58175
|
-
fill: item.value === value ? "#fff" : "#212121"
|
|
58176
|
-
}) : isDigitalCoupon ? /*#__PURE__*/React$1.createElement(PenIcon, {
|
|
58177
|
-
color: penColor,
|
|
58178
|
-
width: "16",
|
|
58179
|
-
height: "16"
|
|
58180
|
-
}) : item.value === value && /*#__PURE__*/React$1.createElement(OkIcon, {
|
|
58181
|
-
width: "22px",
|
|
58182
|
-
height: "22px",
|
|
58183
|
-
color: "#fff"
|
|
58184
|
-
}));
|
|
58279
|
+
}, displayText), iconToShow);
|
|
58185
58280
|
})))), templateDialog && /*#__PURE__*/React$1.createElement(OverlayTemplateDialog, {
|
|
58186
58281
|
open: true,
|
|
58187
58282
|
onClose: () => setTemplateDialog(null),
|