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.js CHANGED
@@ -3806,11 +3806,14 @@ const SearchInput$1 = props => {
3806
3806
  position = 'left',
3807
3807
  iconColor = '#212121',
3808
3808
  onTyping = () => {},
3809
+ onClear = () => {},
3810
+ clearTrigger,
3809
3811
  className
3810
3812
  } = props;
3811
3813
 
3812
3814
  // Use internal state for uncontrolled mode
3813
3815
  const [internalValue, setInternalValue] = React$1.useState(defaultValue);
3816
+ const previousValueRef = React$1.useRef(defaultValue);
3814
3817
 
3815
3818
  // Determine if component is controlled
3816
3819
  const isControlled = controlledValue !== undefined;
@@ -3822,12 +3825,33 @@ const SearchInput$1 = props => {
3822
3825
  setInternalValue(defaultValue);
3823
3826
  }
3824
3827
  }, [defaultValue, isControlled]);
3828
+
3829
+ // Clear the input when clearTrigger changes (external clear trigger)
3830
+ React$1.useEffect(() => {
3831
+ if (clearTrigger !== undefined) {
3832
+ setInternalValue('');
3833
+ }
3834
+ }, [clearTrigger]);
3825
3835
  const handleInputChange = e => {
3836
+ const newValue = e.target.value;
3837
+
3838
+ // Detect native clear button click (value was non-empty, now empty, via input event)
3839
+ if (previousValueRef.current && newValue === '') {
3840
+ onClear();
3841
+ }
3842
+ previousValueRef.current = newValue;
3826
3843
  if (!isControlled) {
3827
- setInternalValue(e.target.value);
3844
+ setInternalValue(newValue);
3828
3845
  }
3829
3846
  onTyping(e);
3830
3847
  };
3848
+
3849
+ // Handle the 'search' event which fires when native clear button is clicked
3850
+ const handleSearch = e => {
3851
+ if (e.target.value === '') {
3852
+ onClear();
3853
+ }
3854
+ };
3831
3855
  return /*#__PURE__*/React__default["default"].createElement(TextFieldContainer, {
3832
3856
  className: className,
3833
3857
  width: width
@@ -3842,6 +3866,7 @@ const SearchInput$1 = props => {
3842
3866
  height: height,
3843
3867
  placeholder: placeholder,
3844
3868
  onChange: handleInputChange,
3869
+ onSearch: handleSearch,
3845
3870
  position: position
3846
3871
  }));
3847
3872
  };
@@ -37724,8 +37749,16 @@ const SearchInput = styled__default["default"].input`
37724
37749
  }
37725
37750
  `;
37726
37751
  const ListWrapper = styled__default["default"].div`
37727
- max-height: ${props => props.maxHeight || 'unset'};
37728
- overflow-y: auto;
37752
+ max-height: ${props => {
37753
+ const maxH = parseInt(props.maxHeight) || 400;
37754
+ const actualH = (props.actualHeight || maxH) + 16;
37755
+ return actualH < maxH ? `${actualH}px` : props.maxHeight;
37756
+ }};
37757
+ overflow-y: ${props => {
37758
+ const maxH = parseInt(props.maxHeight) || 400;
37759
+ const actualH = (props.actualHeight || maxH) + 16;
37760
+ return actualH < maxH ? 'hidden' : 'auto';
37761
+ }};
37729
37762
  position: relative;
37730
37763
  `;
37731
37764
  const CheckboxGroup = styled__default["default"].div`
@@ -37770,6 +37803,7 @@ const CheckboxLabel = styled__default["default"].label`
37770
37803
  color: #212121;
37771
37804
  cursor: pointer;
37772
37805
  flex-shrink: 0;
37806
+ box-sizing: border-box;
37773
37807
 
37774
37808
  &:hover {
37775
37809
  background-color: #E6F0F0;
@@ -37842,7 +37876,7 @@ const FilterPop = props => {
37842
37876
  selectedAttributes: propSelectedAttributes = {},
37843
37877
  showSearch = true,
37844
37878
  searchPlaceholder = "Search...",
37845
- itemHeight = 32,
37879
+ itemHeight = 40,
37846
37880
  overscan = 5,
37847
37881
  hasActiveFilter = false // NEW: Indicates if this column has an active filter
37848
37882
  } = props;
@@ -37931,16 +37965,18 @@ const FilterPop = props => {
37931
37965
  offsetY
37932
37966
  } = React$1.useMemo(() => {
37933
37967
  const containerHeight = parseInt(maxHeight) || 400;
37934
- const startIndex = Math.max(0, Math.floor(scrollTop / itemHeight) - overscan);
37935
- const endIndex = Math.min(sortedList.length, Math.ceil((scrollTop + containerHeight) / itemHeight) + overscan);
37968
+ const gap = 8;
37969
+ const itemWithGap = itemHeight + gap;
37970
+ const startIndex = Math.max(0, Math.floor(scrollTop / itemWithGap) - overscan);
37971
+ const endIndex = Math.min(sortedList.length, Math.ceil((scrollTop + containerHeight) / itemWithGap) + overscan);
37936
37972
  const visible = sortedList.slice(startIndex, endIndex).map((item, idx) => ({
37937
37973
  ...item,
37938
37974
  index: startIndex + idx
37939
37975
  }));
37940
37976
  return {
37941
37977
  visibleItems: visible,
37942
- totalHeight: (sortedList.length + 1) * (itemHeight + 8),
37943
- offsetY: startIndex * itemHeight
37978
+ totalHeight: sortedList.length * itemHeight + Math.max(0, sortedList.length - 1) * gap,
37979
+ offsetY: startIndex * itemWithGap
37944
37980
  };
37945
37981
  }, [sortedList, scrollTop, itemHeight, overscan, maxHeight]);
37946
37982
  const areAllNonAllItemsSelected = function () {
@@ -38140,7 +38176,8 @@ const FilterPop = props => {
38140
38176
  }), /*#__PURE__*/React__default["default"].createElement(ListWrapper, {
38141
38177
  ref: scrollContainerRef,
38142
38178
  onScroll: handleScroll,
38143
- maxHeight: maxHeight
38179
+ maxHeight: maxHeight,
38180
+ actualHeight: totalHeight
38144
38181
  }, sortedList.length === 1 ? /*#__PURE__*/React__default["default"].createElement(NoResultsMessage, null, "No items match your search") : /*#__PURE__*/React__default["default"].createElement("div", {
38145
38182
  style: {
38146
38183
  height: `${totalHeight}px`,
@@ -40992,10 +41029,12 @@ const TableHeader = ({
40992
41029
  const debouncedFilterState = useDebounce(filterState, debounceDelay);
40993
41030
  const iconRefs = React$1.useRef({});
40994
41031
  const popupRef = React$1.useRef(null);
41032
+ const prevResetKeyRef = React$1.useRef(resetFiltersKey);
40995
41033
 
40996
- // Reset internal state when resetFiltersKey changes
41034
+ // Reset internal state when resetFiltersKey changes (not when columns change)
40997
41035
  React$1.useEffect(() => {
40998
- if (resetFiltersKey > 0) {
41036
+ // Only run reset when resetFiltersKey actually changed
41037
+ if (resetFiltersKey !== prevResetKeyRef.current && resetFiltersKey > 0) {
40999
41038
  const resetSelections = {};
41000
41039
  columns.forEach(column => {
41001
41040
  if (column.filter && column.filterOptions) {
@@ -41017,6 +41056,7 @@ const TableHeader = ({
41017
41056
  setVisibleFilterPopWrapper(null);
41018
41057
  setVisibleSortPopWrapper(null);
41019
41058
  }
41059
+ prevResetKeyRef.current = resetFiltersKey;
41020
41060
  }, [resetFiltersKey, columns]);
41021
41061
 
41022
41062
  // Track if we've already initialized from saved state