sag_components 2.0.0-beta305 → 2.0.0-beta306
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
CHANGED
|
@@ -3796,11 +3796,14 @@ const SearchInput$1 = props => {
|
|
|
3796
3796
|
position = 'left',
|
|
3797
3797
|
iconColor = '#212121',
|
|
3798
3798
|
onTyping = () => {},
|
|
3799
|
+
onClear = () => {},
|
|
3800
|
+
clearTrigger,
|
|
3799
3801
|
className
|
|
3800
3802
|
} = props;
|
|
3801
3803
|
|
|
3802
3804
|
// Use internal state for uncontrolled mode
|
|
3803
3805
|
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
3806
|
+
const previousValueRef = useRef(defaultValue);
|
|
3804
3807
|
|
|
3805
3808
|
// Determine if component is controlled
|
|
3806
3809
|
const isControlled = controlledValue !== undefined;
|
|
@@ -3812,12 +3815,33 @@ const SearchInput$1 = props => {
|
|
|
3812
3815
|
setInternalValue(defaultValue);
|
|
3813
3816
|
}
|
|
3814
3817
|
}, [defaultValue, isControlled]);
|
|
3818
|
+
|
|
3819
|
+
// Clear the input when clearTrigger changes (external clear trigger)
|
|
3820
|
+
useEffect(() => {
|
|
3821
|
+
if (clearTrigger !== undefined) {
|
|
3822
|
+
setInternalValue('');
|
|
3823
|
+
}
|
|
3824
|
+
}, [clearTrigger]);
|
|
3815
3825
|
const handleInputChange = e => {
|
|
3826
|
+
const newValue = e.target.value;
|
|
3827
|
+
|
|
3828
|
+
// Detect native clear button click (value was non-empty, now empty, via input event)
|
|
3829
|
+
if (previousValueRef.current && newValue === '') {
|
|
3830
|
+
onClear();
|
|
3831
|
+
}
|
|
3832
|
+
previousValueRef.current = newValue;
|
|
3816
3833
|
if (!isControlled) {
|
|
3817
|
-
setInternalValue(
|
|
3834
|
+
setInternalValue(newValue);
|
|
3818
3835
|
}
|
|
3819
3836
|
onTyping(e);
|
|
3820
3837
|
};
|
|
3838
|
+
|
|
3839
|
+
// Handle the 'search' event which fires when native clear button is clicked
|
|
3840
|
+
const handleSearch = e => {
|
|
3841
|
+
if (e.target.value === '') {
|
|
3842
|
+
onClear();
|
|
3843
|
+
}
|
|
3844
|
+
};
|
|
3821
3845
|
return /*#__PURE__*/React$1.createElement(TextFieldContainer, {
|
|
3822
3846
|
className: className,
|
|
3823
3847
|
width: width
|
|
@@ -3832,6 +3856,7 @@ const SearchInput$1 = props => {
|
|
|
3832
3856
|
height: height,
|
|
3833
3857
|
placeholder: placeholder,
|
|
3834
3858
|
onChange: handleInputChange,
|
|
3859
|
+
onSearch: handleSearch,
|
|
3835
3860
|
position: position
|
|
3836
3861
|
}));
|
|
3837
3862
|
};
|
|
@@ -37714,8 +37739,16 @@ const SearchInput = styled.input`
|
|
|
37714
37739
|
}
|
|
37715
37740
|
`;
|
|
37716
37741
|
const ListWrapper = styled.div`
|
|
37717
|
-
max-height: ${props =>
|
|
37718
|
-
|
|
37742
|
+
max-height: ${props => {
|
|
37743
|
+
const maxH = parseInt(props.maxHeight) || 400;
|
|
37744
|
+
const actualH = (props.actualHeight || maxH) + 16;
|
|
37745
|
+
return actualH < maxH ? `${actualH}px` : props.maxHeight;
|
|
37746
|
+
}};
|
|
37747
|
+
overflow-y: ${props => {
|
|
37748
|
+
const maxH = parseInt(props.maxHeight) || 400;
|
|
37749
|
+
const actualH = (props.actualHeight || maxH) + 16;
|
|
37750
|
+
return actualH < maxH ? 'hidden' : 'auto';
|
|
37751
|
+
}};
|
|
37719
37752
|
position: relative;
|
|
37720
37753
|
`;
|
|
37721
37754
|
const CheckboxGroup = styled.div`
|
|
@@ -37760,6 +37793,7 @@ const CheckboxLabel = styled.label`
|
|
|
37760
37793
|
color: #212121;
|
|
37761
37794
|
cursor: pointer;
|
|
37762
37795
|
flex-shrink: 0;
|
|
37796
|
+
box-sizing: border-box;
|
|
37763
37797
|
|
|
37764
37798
|
&:hover {
|
|
37765
37799
|
background-color: #E6F0F0;
|
|
@@ -37832,7 +37866,7 @@ const FilterPop = props => {
|
|
|
37832
37866
|
selectedAttributes: propSelectedAttributes = {},
|
|
37833
37867
|
showSearch = true,
|
|
37834
37868
|
searchPlaceholder = "Search...",
|
|
37835
|
-
itemHeight =
|
|
37869
|
+
itemHeight = 40,
|
|
37836
37870
|
overscan = 5,
|
|
37837
37871
|
hasActiveFilter = false // NEW: Indicates if this column has an active filter
|
|
37838
37872
|
} = props;
|
|
@@ -37921,16 +37955,18 @@ const FilterPop = props => {
|
|
|
37921
37955
|
offsetY
|
|
37922
37956
|
} = useMemo(() => {
|
|
37923
37957
|
const containerHeight = parseInt(maxHeight) || 400;
|
|
37924
|
-
const
|
|
37925
|
-
const
|
|
37958
|
+
const gap = 8;
|
|
37959
|
+
const itemWithGap = itemHeight + gap;
|
|
37960
|
+
const startIndex = Math.max(0, Math.floor(scrollTop / itemWithGap) - overscan);
|
|
37961
|
+
const endIndex = Math.min(sortedList.length, Math.ceil((scrollTop + containerHeight) / itemWithGap) + overscan);
|
|
37926
37962
|
const visible = sortedList.slice(startIndex, endIndex).map((item, idx) => ({
|
|
37927
37963
|
...item,
|
|
37928
37964
|
index: startIndex + idx
|
|
37929
37965
|
}));
|
|
37930
37966
|
return {
|
|
37931
37967
|
visibleItems: visible,
|
|
37932
|
-
totalHeight:
|
|
37933
|
-
offsetY: startIndex *
|
|
37968
|
+
totalHeight: sortedList.length * itemHeight + Math.max(0, sortedList.length - 1) * gap,
|
|
37969
|
+
offsetY: startIndex * itemWithGap
|
|
37934
37970
|
};
|
|
37935
37971
|
}, [sortedList, scrollTop, itemHeight, overscan, maxHeight]);
|
|
37936
37972
|
const areAllNonAllItemsSelected = function () {
|
|
@@ -38130,7 +38166,8 @@ const FilterPop = props => {
|
|
|
38130
38166
|
}), /*#__PURE__*/React$1.createElement(ListWrapper, {
|
|
38131
38167
|
ref: scrollContainerRef,
|
|
38132
38168
|
onScroll: handleScroll,
|
|
38133
|
-
maxHeight: maxHeight
|
|
38169
|
+
maxHeight: maxHeight,
|
|
38170
|
+
actualHeight: totalHeight
|
|
38134
38171
|
}, sortedList.length === 1 ? /*#__PURE__*/React$1.createElement(NoResultsMessage, null, "No items match your search") : /*#__PURE__*/React$1.createElement("div", {
|
|
38135
38172
|
style: {
|
|
38136
38173
|
height: `${totalHeight}px`,
|
|
@@ -40982,10 +41019,12 @@ const TableHeader = ({
|
|
|
40982
41019
|
const debouncedFilterState = useDebounce(filterState, debounceDelay);
|
|
40983
41020
|
const iconRefs = useRef({});
|
|
40984
41021
|
const popupRef = useRef(null);
|
|
41022
|
+
const prevResetKeyRef = useRef(resetFiltersKey);
|
|
40985
41023
|
|
|
40986
|
-
// Reset internal state when resetFiltersKey changes
|
|
41024
|
+
// Reset internal state when resetFiltersKey changes (not when columns change)
|
|
40987
41025
|
useEffect(() => {
|
|
40988
|
-
|
|
41026
|
+
// Only run reset when resetFiltersKey actually changed
|
|
41027
|
+
if (resetFiltersKey !== prevResetKeyRef.current && resetFiltersKey > 0) {
|
|
40989
41028
|
const resetSelections = {};
|
|
40990
41029
|
columns.forEach(column => {
|
|
40991
41030
|
if (column.filter && column.filterOptions) {
|
|
@@ -41007,6 +41046,7 @@ const TableHeader = ({
|
|
|
41007
41046
|
setVisibleFilterPopWrapper(null);
|
|
41008
41047
|
setVisibleSortPopWrapper(null);
|
|
41009
41048
|
}
|
|
41049
|
+
prevResetKeyRef.current = resetFiltersKey;
|
|
41010
41050
|
}, [resetFiltersKey, columns]);
|
|
41011
41051
|
|
|
41012
41052
|
// Track if we've already initialized from saved state
|