sag_components 2.0.0-beta276 → 2.0.0-beta277
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 +139 -48
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +139 -48
- package/dist/index.js.map +1 -1
- package/dist/types/components/ItemManagerPanel/ItemManagerPanel.stories.d.ts +31 -0
- package/dist/types/components/Table/TableHeader.d.ts +2 -1
- package/package.json +2 -1
package/dist/index.esm.js
CHANGED
|
@@ -36110,15 +36110,19 @@ const ToggleInput = styled.input`
|
|
|
36110
36110
|
const ToggleSlider = styled.span`
|
|
36111
36111
|
display: block;
|
|
36112
36112
|
position: relative;
|
|
36113
|
-
background: ${
|
|
36114
|
-
|
|
36115
|
-
|
|
36116
|
-
|
|
36113
|
+
background: ${_ref => {
|
|
36114
|
+
let {
|
|
36115
|
+
checked,
|
|
36116
|
+
disabled
|
|
36117
|
+
} = _ref;
|
|
36118
|
+
return checked ? "#006d6a" : disabled ? "#B1B1B1" : "#D0D0D0";
|
|
36119
|
+
}};
|
|
36117
36120
|
border-radius: 999px;
|
|
36118
36121
|
transition: background 0.2s;
|
|
36119
|
-
${
|
|
36120
|
-
|
|
36121
|
-
|
|
36122
|
+
${_ref2 => {
|
|
36123
|
+
let {
|
|
36124
|
+
size
|
|
36125
|
+
} = _ref2;
|
|
36122
36126
|
switch (size) {
|
|
36123
36127
|
case "s":
|
|
36124
36128
|
return css`width: 40px; height: 20px;`;
|
|
@@ -36134,14 +36138,18 @@ const ToggleSlider = styled.span`
|
|
|
36134
36138
|
left: 3px;
|
|
36135
36139
|
top: 50%;
|
|
36136
36140
|
transform: translateY(-50%);
|
|
36137
|
-
background: ${
|
|
36138
|
-
|
|
36139
|
-
|
|
36141
|
+
background: ${_ref3 => {
|
|
36142
|
+
let {
|
|
36143
|
+
disabled
|
|
36144
|
+
} = _ref3;
|
|
36145
|
+
return disabled ? "#D0D0D0" : "#fff";
|
|
36146
|
+
}};
|
|
36140
36147
|
border-radius: 50%;
|
|
36141
36148
|
transition: left 0.2s, width 0.2s, height 0.2s;
|
|
36142
|
-
${
|
|
36143
|
-
|
|
36144
|
-
|
|
36149
|
+
${_ref4 => {
|
|
36150
|
+
let {
|
|
36151
|
+
size
|
|
36152
|
+
} = _ref4;
|
|
36145
36153
|
switch (size) {
|
|
36146
36154
|
case "s":
|
|
36147
36155
|
return css`width: 14px; height: 14px;`;
|
|
@@ -36151,10 +36159,11 @@ const ToggleSlider = styled.span`
|
|
|
36151
36159
|
return css`width: 20px; height: 20px;`;
|
|
36152
36160
|
}
|
|
36153
36161
|
}}
|
|
36154
|
-
left: ${
|
|
36155
|
-
|
|
36156
|
-
|
|
36157
|
-
|
|
36162
|
+
left: ${_ref5 => {
|
|
36163
|
+
let {
|
|
36164
|
+
checked,
|
|
36165
|
+
size
|
|
36166
|
+
} = _ref5;
|
|
36158
36167
|
if (!checked) return "3px";
|
|
36159
36168
|
switch (size) {
|
|
36160
36169
|
case "s":
|
|
@@ -36168,9 +36177,9 @@ const ToggleSlider = styled.span`
|
|
|
36168
36177
|
}
|
|
36169
36178
|
`;
|
|
36170
36179
|
|
|
36171
|
-
/**
|
|
36172
|
-
* ToggleSwitch component for on/off states.
|
|
36173
|
-
* Supports small/large sizes and disabled state.
|
|
36180
|
+
/**
|
|
36181
|
+
* ToggleSwitch component for on/off states.
|
|
36182
|
+
* Supports small/large sizes and disabled state.
|
|
36174
36183
|
*/
|
|
36175
36184
|
function ToggleSwitch(_ref) {
|
|
36176
36185
|
let {
|
|
@@ -40839,7 +40848,21 @@ const SortIcon = ({
|
|
|
40839
40848
|
}));
|
|
40840
40849
|
};
|
|
40841
40850
|
|
|
40842
|
-
// TableHeader.jsx
|
|
40851
|
+
// TableHeader.jsx - Updated with debounce
|
|
40852
|
+
|
|
40853
|
+
// Inline debounce hook
|
|
40854
|
+
const useDebounce = (value, delay = 1500) => {
|
|
40855
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
40856
|
+
useEffect(() => {
|
|
40857
|
+
const handler = setTimeout(() => {
|
|
40858
|
+
setDebouncedValue(value);
|
|
40859
|
+
}, delay);
|
|
40860
|
+
return () => {
|
|
40861
|
+
clearTimeout(handler);
|
|
40862
|
+
};
|
|
40863
|
+
}, [value, delay]);
|
|
40864
|
+
return debouncedValue;
|
|
40865
|
+
};
|
|
40843
40866
|
const TableHeader = ({
|
|
40844
40867
|
columns,
|
|
40845
40868
|
onSort,
|
|
@@ -40850,7 +40873,8 @@ const TableHeader = ({
|
|
|
40850
40873
|
expandable = false,
|
|
40851
40874
|
onHeaderCheckboxClick = () => {},
|
|
40852
40875
|
headerCheckboxStates = {},
|
|
40853
|
-
resetFiltersKey = 0
|
|
40876
|
+
resetFiltersKey = 0,
|
|
40877
|
+
debounceDelay = 500 // NEW: Add debounce delay prop (default 500ms)
|
|
40854
40878
|
}) => {
|
|
40855
40879
|
const [focusedFilter, setFocusedFilter] = useState(null);
|
|
40856
40880
|
const [focusedSort, setFocusedSort] = useState(null);
|
|
@@ -40860,17 +40884,21 @@ const TableHeader = ({
|
|
|
40860
40884
|
top: 0,
|
|
40861
40885
|
left: 0
|
|
40862
40886
|
});
|
|
40887
|
+
|
|
40888
|
+
// Internal state that updates immediately (for UI responsiveness)
|
|
40863
40889
|
const [filterState, setFilterState] = useState({});
|
|
40864
40890
|
const [filterSelections, setFilterSelections] = useState({});
|
|
40865
40891
|
const [activeSortColumn, setActiveSortColumn] = useState(null);
|
|
40866
40892
|
const [activeSortValue, setActiveSortValue] = useState(null);
|
|
40893
|
+
|
|
40894
|
+
// Debounced values (these will be passed to parent after delay)
|
|
40895
|
+
const debouncedFilterState = useDebounce(filterState, debounceDelay);
|
|
40867
40896
|
const iconRefs = useRef({});
|
|
40868
40897
|
const popupRef = useRef(null);
|
|
40869
40898
|
|
|
40870
|
-
//
|
|
40899
|
+
// Reset internal state when resetFiltersKey changes
|
|
40871
40900
|
useEffect(() => {
|
|
40872
40901
|
if (resetFiltersKey > 0) {
|
|
40873
|
-
// Reset filter selections to default (all selected)
|
|
40874
40902
|
const resetSelections = {};
|
|
40875
40903
|
columns.forEach(column => {
|
|
40876
40904
|
if (column.filter && column.filterOptions) {
|
|
@@ -40886,15 +40914,9 @@ const TableHeader = ({
|
|
|
40886
40914
|
}
|
|
40887
40915
|
});
|
|
40888
40916
|
setFilterSelections(resetSelections);
|
|
40889
|
-
|
|
40890
|
-
// Reset filter state
|
|
40891
40917
|
setFilterState({});
|
|
40892
|
-
|
|
40893
|
-
// Reset sort state
|
|
40894
40918
|
setActiveSortColumn(null);
|
|
40895
40919
|
setActiveSortValue(null);
|
|
40896
|
-
|
|
40897
|
-
// Close any open popups
|
|
40898
40920
|
setVisibleFilterPopWrapper(null);
|
|
40899
40921
|
setVisibleSortPopWrapper(null);
|
|
40900
40922
|
}
|
|
@@ -40937,6 +40959,14 @@ const TableHeader = ({
|
|
|
40937
40959
|
return hasChanges ? newSelections : prevSelections;
|
|
40938
40960
|
});
|
|
40939
40961
|
}, [columns]);
|
|
40962
|
+
|
|
40963
|
+
// 🎯 KEY CHANGE: Use debounced value to trigger parent callback
|
|
40964
|
+
useEffect(() => {
|
|
40965
|
+
// Only call onFilter if there's actual filter data
|
|
40966
|
+
if (Object.keys(debouncedFilterState).length > 0) {
|
|
40967
|
+
onFilter(debouncedFilterState);
|
|
40968
|
+
}
|
|
40969
|
+
}, [debouncedFilterState, onFilter]);
|
|
40940
40970
|
const isFilterInDefaultState = columnKey => {
|
|
40941
40971
|
const filterData = filterState[columnKey];
|
|
40942
40972
|
if (!filterData) {
|
|
@@ -41029,11 +41059,6 @@ const TableHeader = ({
|
|
|
41029
41059
|
setVisibleSortPopWrapper(prevKey => prevKey === key ? null : key);
|
|
41030
41060
|
setVisibleFilterPopWrapper(null);
|
|
41031
41061
|
};
|
|
41032
|
-
useEffect(() => {
|
|
41033
|
-
if (Object.keys(filterState).length > 0) {
|
|
41034
|
-
onFilter(filterState);
|
|
41035
|
-
}
|
|
41036
|
-
}, [filterState]);
|
|
41037
41062
|
const handleFilter = key => {
|
|
41038
41063
|
const iconElement = iconRefs.current[`filter-${key}`];
|
|
41039
41064
|
if (iconElement) {
|
|
@@ -41063,6 +41088,9 @@ const TableHeader = ({
|
|
|
41063
41088
|
onSort(columnKey, null);
|
|
41064
41089
|
}
|
|
41065
41090
|
};
|
|
41091
|
+
|
|
41092
|
+
// 🎯 Filter changes update immediately in UI (filterState)
|
|
41093
|
+
// But parent callback is triggered only after debounce
|
|
41066
41094
|
const handleFilterSelectionChange = (columnKey, selectionData) => {
|
|
41067
41095
|
setFilterSelections(prev => {
|
|
41068
41096
|
const updated = {
|
|
@@ -41071,6 +41099,8 @@ const TableHeader = ({
|
|
|
41071
41099
|
};
|
|
41072
41100
|
return updated;
|
|
41073
41101
|
});
|
|
41102
|
+
|
|
41103
|
+
// Update internal state immediately for responsive UI
|
|
41074
41104
|
setFilterState(prev => ({
|
|
41075
41105
|
...prev,
|
|
41076
41106
|
[columnKey]: selectionData.filterData
|
|
@@ -41207,6 +41237,7 @@ const TableHeader = ({
|
|
|
41207
41237
|
placeholder: column.key === 'EventCode' ? 'Enter Event ID' : 'Search..',
|
|
41208
41238
|
fieldHeight: "40px",
|
|
41209
41239
|
onTyping: value => {
|
|
41240
|
+
// Update internal state immediately
|
|
41210
41241
|
setFilterState(prev => ({
|
|
41211
41242
|
...prev,
|
|
41212
41243
|
[key]: value
|
|
@@ -41241,6 +41272,7 @@ const TableHeader = ({
|
|
|
41241
41272
|
fields: currentFilterState.fields
|
|
41242
41273
|
} : null,
|
|
41243
41274
|
onApply: data => {
|
|
41275
|
+
// Update internal state immediately
|
|
41244
41276
|
setFilterState(prev => ({
|
|
41245
41277
|
...prev,
|
|
41246
41278
|
[key]: data
|
|
@@ -47564,25 +47596,52 @@ styled.span`
|
|
|
47564
47596
|
font-weight: 600;
|
|
47565
47597
|
`;
|
|
47566
47598
|
|
|
47599
|
+
let FixedSizeList = null;
|
|
47600
|
+
try {
|
|
47601
|
+
FixedSizeList = require('react-window').FixedSizeList;
|
|
47602
|
+
} catch (e) {
|
|
47603
|
+
console.error('react-window not found:', e);
|
|
47604
|
+
}
|
|
47605
|
+
const VENDOR_ITEM_HEIGHT = 72;
|
|
47567
47606
|
const NewItemList = ({
|
|
47568
47607
|
onBack,
|
|
47569
47608
|
onVendorClick,
|
|
47570
47609
|
itemAndPackage
|
|
47571
47610
|
}) => {
|
|
47572
|
-
const [
|
|
47611
|
+
const [debouncedSearch, setDebouncedSearch] = useState("");
|
|
47573
47612
|
const [headerHeight, setHeaderHeight] = useState(0);
|
|
47574
47613
|
const headerRef = useRef(null);
|
|
47614
|
+
const searchInputRef = useRef(null);
|
|
47615
|
+
const timerRef = useRef(null);
|
|
47575
47616
|
useEffect(() => {
|
|
47576
47617
|
if (headerRef.current) {
|
|
47577
47618
|
setHeaderHeight(headerRef.current.offsetHeight);
|
|
47578
47619
|
}
|
|
47579
47620
|
}, []);
|
|
47580
|
-
const
|
|
47581
|
-
|
|
47582
|
-
|
|
47583
|
-
|
|
47584
|
-
|
|
47585
|
-
|
|
47621
|
+
const handleSearchChange = e => {
|
|
47622
|
+
const value = e.target.value;
|
|
47623
|
+
if (timerRef.current) {
|
|
47624
|
+
clearTimeout(timerRef.current);
|
|
47625
|
+
}
|
|
47626
|
+
timerRef.current = setTimeout(() => {
|
|
47627
|
+
setDebouncedSearch(value);
|
|
47628
|
+
}, 100);
|
|
47629
|
+
};
|
|
47630
|
+
const filteredItems = useMemo(() => {
|
|
47631
|
+
if (!debouncedSearch) return itemAndPackage;
|
|
47632
|
+
const searchLower = debouncedSearch.toLowerCase();
|
|
47633
|
+
const results = [];
|
|
47634
|
+
const startsWithResults = [];
|
|
47635
|
+
for (let i = 0; i < itemAndPackage.length; i++) {
|
|
47636
|
+
const nameLower = itemAndPackage[i].name.toLowerCase();
|
|
47637
|
+
if (nameLower.startsWith(searchLower)) {
|
|
47638
|
+
startsWithResults.push(itemAndPackage[i]);
|
|
47639
|
+
} else if (nameLower.includes(searchLower)) {
|
|
47640
|
+
results.push(itemAndPackage[i]);
|
|
47641
|
+
}
|
|
47642
|
+
}
|
|
47643
|
+
return [...startsWithResults, ...results];
|
|
47644
|
+
}, [debouncedSearch, itemAndPackage]);
|
|
47586
47645
|
const highlightMatch = (text, query) => {
|
|
47587
47646
|
if (!query) return text;
|
|
47588
47647
|
const regex = new RegExp(`(${query})`, "ig");
|
|
@@ -47592,18 +47651,51 @@ const NewItemList = ({
|
|
|
47592
47651
|
};
|
|
47593
47652
|
const hasValidStatus = pkg => pkg.hasOwnProperty("status") && pkg.status != null && pkg.status !== undefined && pkg.status !== "";
|
|
47594
47653
|
const draftPackages = pkg => pkg.status === 1;
|
|
47654
|
+
const VendorRow = ({
|
|
47655
|
+
index,
|
|
47656
|
+
style
|
|
47657
|
+
}) => {
|
|
47658
|
+
const item = filteredItems[index];
|
|
47659
|
+
let packagesLength = 0;
|
|
47660
|
+
let sentPackagesLength = 0;
|
|
47661
|
+
if (item.packages !== null) {
|
|
47662
|
+
packagesLength = item.packages.length;
|
|
47663
|
+
sentPackagesLength = item.packages.filter(pkg => hasValidStatus(pkg) && !draftPackages(pkg)).length;
|
|
47664
|
+
}
|
|
47665
|
+
return /*#__PURE__*/React$1.createElement("div", {
|
|
47666
|
+
style: style
|
|
47667
|
+
}, /*#__PURE__*/React$1.createElement(VendorItem, {
|
|
47668
|
+
onClick: e => {
|
|
47669
|
+
if (onVendorClick) {
|
|
47670
|
+
onVendorClick(item);
|
|
47671
|
+
}
|
|
47672
|
+
}
|
|
47673
|
+
}, /*#__PURE__*/React$1.createElement(VendorNameAndPackagesContainer, null, /*#__PURE__*/React$1.createElement(VendorName$1, null, highlightMatch(item.name, debouncedSearch.toLowerCase())), packagesLength > 0 && /*#__PURE__*/React$1.createElement(VendorPackages, null, (() => {
|
|
47674
|
+
const noPackagesSent = sentPackagesLength === 0;
|
|
47675
|
+
if (noPackagesSent) {
|
|
47676
|
+
return `0/${packagesLength} Packages Sent`;
|
|
47677
|
+
} else {
|
|
47678
|
+
return `${sentPackagesLength}/${packagesLength} Packages Sent`;
|
|
47679
|
+
}
|
|
47680
|
+
})())), /*#__PURE__*/React$1.createElement(VendorChevron, null, /*#__PURE__*/React$1.createElement(ArrowRightFullIcon, null))));
|
|
47681
|
+
};
|
|
47595
47682
|
return /*#__PURE__*/React$1.createElement(VendorSelectionContainer, null, /*#__PURE__*/React$1.createElement(VendorHeader$1, {
|
|
47596
47683
|
ref: headerRef
|
|
47597
47684
|
}, /*#__PURE__*/React$1.createElement(VendorRoute, null, /*#__PURE__*/React$1.createElement(VendorBackButton, {
|
|
47598
47685
|
onClick: onBack
|
|
47599
47686
|
}, /*#__PURE__*/React$1.createElement(ArrowLeftIcon, null)), /*#__PURE__*/React$1.createElement(VendorBackTitle, null, "Selected Vendors")), /*#__PURE__*/React$1.createElement(VendorSelectionTitle, null, "Add New Vendor"), /*#__PURE__*/React$1.createElement(VendorSearch, {
|
|
47687
|
+
ref: searchInputRef,
|
|
47600
47688
|
type: "search",
|
|
47601
47689
|
placeholder: "Search",
|
|
47602
|
-
|
|
47603
|
-
|
|
47604
|
-
}), /*#__PURE__*/React$1.createElement(VendorSearchResult, null, search !== "" ? `${filteredItems.length === 0 ? "No" : filteredItems.length} Vendors Found` : " ")), /*#__PURE__*/React$1.createElement(VendorListWrapper$1, {
|
|
47690
|
+
onChange: handleSearchChange
|
|
47691
|
+
}), /*#__PURE__*/React$1.createElement(VendorSearchResult, null, debouncedSearch !== "" ? `${filteredItems.length === 0 ? "No" : filteredItems.length} Vendors Found` : " ")), /*#__PURE__*/React$1.createElement(VendorListWrapper$1, {
|
|
47605
47692
|
headerHeight: headerHeight
|
|
47606
|
-
}, /*#__PURE__*/React$1.createElement(
|
|
47693
|
+
}, FixedSizeList ? /*#__PURE__*/React$1.createElement(FixedSizeList, {
|
|
47694
|
+
height: window.innerHeight - headerHeight - 48,
|
|
47695
|
+
itemCount: filteredItems.length,
|
|
47696
|
+
itemSize: VENDOR_ITEM_HEIGHT,
|
|
47697
|
+
width: "100%"
|
|
47698
|
+
}, VendorRow) : /*#__PURE__*/React$1.createElement(VendorList$1, null, filteredItems.map((item, idx) => {
|
|
47607
47699
|
let packagesLength = 0;
|
|
47608
47700
|
let sentPackagesLength = 0;
|
|
47609
47701
|
if (item.packages !== null) {
|
|
@@ -47613,12 +47705,11 @@ const NewItemList = ({
|
|
|
47613
47705
|
return /*#__PURE__*/React$1.createElement(VendorItem, {
|
|
47614
47706
|
key: idx,
|
|
47615
47707
|
onClick: e => {
|
|
47616
|
-
// Always call onVendorClick - it will handle the conversion from null to []
|
|
47617
47708
|
if (onVendorClick) {
|
|
47618
47709
|
onVendorClick(item);
|
|
47619
47710
|
}
|
|
47620
47711
|
}
|
|
47621
|
-
}, /*#__PURE__*/React$1.createElement(VendorNameAndPackagesContainer, null, /*#__PURE__*/React$1.createElement(VendorName$1, null, highlightMatch(item.name,
|
|
47712
|
+
}, /*#__PURE__*/React$1.createElement(VendorNameAndPackagesContainer, null, /*#__PURE__*/React$1.createElement(VendorName$1, null, highlightMatch(item.name, debouncedSearch.toLowerCase())), packagesLength > 0 && /*#__PURE__*/React$1.createElement(VendorPackages, null, (() => {
|
|
47622
47713
|
const noPackagesSent = sentPackagesLength === 0;
|
|
47623
47714
|
if (noPackagesSent) {
|
|
47624
47715
|
return `0/${packagesLength} Packages Sent`;
|