trotl-table 1.0.21 → 1.0.22
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.cjs.js +43 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +43 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -9844,9 +9844,50 @@ function TableInner({
|
|
|
9844
9844
|
return normalizeData(isGrouped ? localData : [], isGrouped ? [] : localData);
|
|
9845
9845
|
}, [localData, isGrouped]);
|
|
9846
9846
|
const filterRows = React.useCallback(rows => {
|
|
9847
|
-
|
|
9847
|
+
// Check for date-related URL params first
|
|
9848
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
9849
|
+
const dateParams = ['startDate', 'endDate', 'date'];
|
|
9850
|
+
let dateFiltered = rows;
|
|
9851
|
+
for (const paramKey of dateParams) {
|
|
9852
|
+
const paramValue = urlParams.get(paramKey);
|
|
9853
|
+
if (!paramValue) continue;
|
|
9854
|
+
|
|
9855
|
+
// Check if it's a range (contains ~)
|
|
9856
|
+
if (paramValue.includes('~')) {
|
|
9857
|
+
const [startTs, endTs] = paramValue.split('~').map(Number);
|
|
9858
|
+
if (isNaN(startTs) || isNaN(endTs)) continue;
|
|
9859
|
+
dateFiltered = dateFiltered.filter(row => {
|
|
9860
|
+
// Check if any date field in the row falls within the range
|
|
9861
|
+
const itemStartDate = row.startDate ? new Date(row.startDate).getTime() : null;
|
|
9862
|
+
const itemEndDate = row.endDate ? new Date(row.endDate).getTime() : null;
|
|
9863
|
+
const itemDate = row.date ? new Date(row.date).getTime() : null;
|
|
9864
|
+
|
|
9865
|
+
// Match if any date field overlaps with the range
|
|
9866
|
+
return itemStartDate && itemStartDate >= startTs && itemStartDate <= endTs || itemEndDate && itemEndDate >= startTs && itemEndDate <= endTs || itemDate && itemDate >= startTs && itemDate <= endTs ||
|
|
9867
|
+
// Check if event spans the entire range
|
|
9868
|
+
itemStartDate && itemEndDate && itemStartDate <= startTs && itemEndDate >= endTs;
|
|
9869
|
+
});
|
|
9870
|
+
} else {
|
|
9871
|
+
// Single timestamp
|
|
9872
|
+
const timestamp = Number(paramValue);
|
|
9873
|
+
if (isNaN(timestamp)) continue;
|
|
9874
|
+
dateFiltered = dateFiltered.filter(row => {
|
|
9875
|
+
const itemStartDate = row.startDate ? new Date(row.startDate).getTime() : null;
|
|
9876
|
+
const itemEndDate = row.endDate ? new Date(row.endDate).getTime() : null;
|
|
9877
|
+
const itemDate = row.date ? new Date(row.date).getTime() : null;
|
|
9878
|
+
|
|
9879
|
+
// Match if the timestamp falls within the event's date range or matches the date
|
|
9880
|
+
return itemDate && Math.abs(itemDate - timestamp) < 86400000 ||
|
|
9881
|
+
// Same day (within 24h)
|
|
9882
|
+
itemStartDate && itemEndDate && itemStartDate <= timestamp && itemEndDate >= timestamp || itemStartDate && Math.abs(itemStartDate - timestamp) < 86400000 || itemEndDate && Math.abs(itemEndDate - timestamp) < 86400000;
|
|
9883
|
+
});
|
|
9884
|
+
}
|
|
9885
|
+
}
|
|
9886
|
+
|
|
9887
|
+
// Then apply text search filter
|
|
9888
|
+
if (!searchTerm) return dateFiltered;
|
|
9848
9889
|
const query = searchTerm.toLowerCase();
|
|
9849
|
-
return
|
|
9890
|
+
return dateFiltered.filter(row => columns.some(col => {
|
|
9850
9891
|
const val = row[col.accessor];
|
|
9851
9892
|
if (val == null) return false;
|
|
9852
9893
|
return String(val).toLowerCase().includes(query);
|