@smallwebco/tinypivot-react 1.0.35 → 1.0.36
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 +52 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +52 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -96,7 +96,9 @@ declare function PivotConfig({ availableFields, rowFields, columnFields, valueFi
|
|
|
96
96
|
interface ActiveFilter {
|
|
97
97
|
column: string;
|
|
98
98
|
valueCount: number;
|
|
99
|
-
values
|
|
99
|
+
values?: string[];
|
|
100
|
+
displayText?: string;
|
|
101
|
+
isRange?: boolean;
|
|
100
102
|
}
|
|
101
103
|
interface PivotSkeletonProps {
|
|
102
104
|
rowFields: string[];
|
|
@@ -144,10 +146,17 @@ declare function useExcelGrid<T extends Record<string, unknown>>(options: ExcelG
|
|
|
144
146
|
setGlobalFilter: react.Dispatch<react.SetStateAction<string>>;
|
|
145
147
|
filteredRowCount: number;
|
|
146
148
|
totalRowCount: number;
|
|
147
|
-
activeFilters: {
|
|
149
|
+
activeFilters: ({
|
|
148
150
|
column: string;
|
|
151
|
+
type: "range";
|
|
152
|
+
range: NumericRange;
|
|
149
153
|
values: string[];
|
|
150
|
-
}
|
|
154
|
+
} | {
|
|
155
|
+
column: string;
|
|
156
|
+
type: "values";
|
|
157
|
+
values: string[];
|
|
158
|
+
range: NumericRange | null;
|
|
159
|
+
})[];
|
|
151
160
|
getColumnStats: (columnKey: string) => ColumnStats;
|
|
152
161
|
clearStatsCache: () => void;
|
|
153
162
|
hasActiveFilter: (columnId: string) => boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -96,7 +96,9 @@ declare function PivotConfig({ availableFields, rowFields, columnFields, valueFi
|
|
|
96
96
|
interface ActiveFilter {
|
|
97
97
|
column: string;
|
|
98
98
|
valueCount: number;
|
|
99
|
-
values
|
|
99
|
+
values?: string[];
|
|
100
|
+
displayText?: string;
|
|
101
|
+
isRange?: boolean;
|
|
100
102
|
}
|
|
101
103
|
interface PivotSkeletonProps {
|
|
102
104
|
rowFields: string[];
|
|
@@ -144,10 +146,17 @@ declare function useExcelGrid<T extends Record<string, unknown>>(options: ExcelG
|
|
|
144
146
|
setGlobalFilter: react.Dispatch<react.SetStateAction<string>>;
|
|
145
147
|
filteredRowCount: number;
|
|
146
148
|
totalRowCount: number;
|
|
147
|
-
activeFilters: {
|
|
149
|
+
activeFilters: ({
|
|
148
150
|
column: string;
|
|
151
|
+
type: "range";
|
|
152
|
+
range: NumericRange;
|
|
149
153
|
values: string[];
|
|
150
|
-
}
|
|
154
|
+
} | {
|
|
155
|
+
column: string;
|
|
156
|
+
type: "values";
|
|
157
|
+
values: string[];
|
|
158
|
+
range: NumericRange | null;
|
|
159
|
+
})[];
|
|
151
160
|
getColumnStats: (columnKey: string) => ColumnStats;
|
|
152
161
|
clearStatsCache: () => void;
|
|
153
162
|
hasActiveFilter: (columnId: string) => boolean;
|
package/dist/index.js
CHANGED
|
@@ -106,10 +106,23 @@ function useExcelGrid(options) {
|
|
|
106
106
|
const filteredRowCount = table.getFilteredRowModel().rows.length;
|
|
107
107
|
const totalRowCount = data.length;
|
|
108
108
|
const activeFilters = useMemo(() => {
|
|
109
|
-
return columnFilters.map((f) =>
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
return columnFilters.map((f) => {
|
|
110
|
+
const filterValue = f.value;
|
|
111
|
+
if (filterValue && isNumericRange(filterValue)) {
|
|
112
|
+
return {
|
|
113
|
+
column: f.id,
|
|
114
|
+
type: "range",
|
|
115
|
+
range: filterValue,
|
|
116
|
+
values: []
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
column: f.id,
|
|
121
|
+
type: "values",
|
|
122
|
+
values: Array.isArray(filterValue) ? filterValue : [],
|
|
123
|
+
range: null
|
|
124
|
+
};
|
|
125
|
+
});
|
|
113
126
|
}, [columnFilters]);
|
|
114
127
|
const hasActiveFilter = useCallback(
|
|
115
128
|
(columnId) => {
|
|
@@ -2145,13 +2158,24 @@ function PivotSkeleton({
|
|
|
2145
2158
|
const filterTooltipDetails = useMemo9(() => {
|
|
2146
2159
|
if (!activeFilters || activeFilters.length === 0) return [];
|
|
2147
2160
|
return activeFilters.map((f) => {
|
|
2161
|
+
if (f.isRange && f.displayText) {
|
|
2162
|
+
return {
|
|
2163
|
+
column: f.column,
|
|
2164
|
+
displayText: f.displayText,
|
|
2165
|
+
isRange: true,
|
|
2166
|
+
values: [],
|
|
2167
|
+
remaining: 0
|
|
2168
|
+
};
|
|
2169
|
+
}
|
|
2170
|
+
const values = f.values || [];
|
|
2148
2171
|
const maxDisplay = 5;
|
|
2149
|
-
const displayValues =
|
|
2150
|
-
const remaining =
|
|
2172
|
+
const displayValues = values.slice(0, maxDisplay);
|
|
2173
|
+
const remaining = values.length - maxDisplay;
|
|
2151
2174
|
return {
|
|
2152
2175
|
column: f.column,
|
|
2153
2176
|
values: displayValues,
|
|
2154
|
-
remaining: remaining > 0 ? remaining : 0
|
|
2177
|
+
remaining: remaining > 0 ? remaining : 0,
|
|
2178
|
+
isRange: false
|
|
2155
2179
|
};
|
|
2156
2180
|
});
|
|
2157
2181
|
}, [activeFilters]);
|
|
@@ -2323,14 +2347,14 @@ function PivotSkeleton({
|
|
|
2323
2347
|
/* @__PURE__ */ jsx5("div", { className: "vpg-tooltip-header", children: "Active Filters" }),
|
|
2324
2348
|
filterTooltipDetails.map((filter) => /* @__PURE__ */ jsxs5("div", { className: "vpg-tooltip-filter", children: [
|
|
2325
2349
|
/* @__PURE__ */ jsx5("div", { className: "vpg-tooltip-column", children: filter.column }),
|
|
2326
|
-
/* @__PURE__ */
|
|
2350
|
+
/* @__PURE__ */ jsx5("div", { className: "vpg-tooltip-values", children: filter.isRange ? /* @__PURE__ */ jsx5("span", { className: "vpg-tooltip-value vpg-range-value", children: filter.displayText }) : /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
2327
2351
|
filter.values.map((val, idx) => /* @__PURE__ */ jsx5("span", { className: "vpg-tooltip-value", children: val }, idx)),
|
|
2328
2352
|
filter.remaining > 0 && /* @__PURE__ */ jsxs5("span", { className: "vpg-tooltip-more", children: [
|
|
2329
2353
|
"+",
|
|
2330
2354
|
filter.remaining,
|
|
2331
2355
|
" more"
|
|
2332
2356
|
] })
|
|
2333
|
-
] })
|
|
2357
|
+
] }) })
|
|
2334
2358
|
] }, filter.column)),
|
|
2335
2359
|
filteredRowCount !== void 0 && totalRowCount !== void 0 && /* @__PURE__ */ jsxs5("div", { className: "vpg-tooltip-summary", children: [
|
|
2336
2360
|
"Showing ",
|
|
@@ -2751,11 +2775,25 @@ function DataGrid({
|
|
|
2751
2775
|
} = usePivotTable(filteredDataForPivot);
|
|
2752
2776
|
const activeFilterInfo = useMemo10(() => {
|
|
2753
2777
|
if (activeFilters.length === 0) return null;
|
|
2754
|
-
return activeFilters.map((f) =>
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2778
|
+
return activeFilters.map((f) => {
|
|
2779
|
+
if (f.type === "range" && f.range) {
|
|
2780
|
+
const parts = [];
|
|
2781
|
+
if (f.range.min !== null) parts.push(`\u2265 ${f.range.min}`);
|
|
2782
|
+
if (f.range.max !== null) parts.push(`\u2264 ${f.range.max}`);
|
|
2783
|
+
return {
|
|
2784
|
+
column: f.column,
|
|
2785
|
+
valueCount: 1,
|
|
2786
|
+
displayText: parts.join(" and "),
|
|
2787
|
+
isRange: true
|
|
2788
|
+
};
|
|
2789
|
+
}
|
|
2790
|
+
return {
|
|
2791
|
+
column: f.column,
|
|
2792
|
+
valueCount: f.values?.length || 0,
|
|
2793
|
+
values: f.values || [],
|
|
2794
|
+
isRange: false
|
|
2795
|
+
};
|
|
2796
|
+
});
|
|
2759
2797
|
}, [activeFilters]);
|
|
2760
2798
|
const rows = useMemo10(() => table.getFilteredRowModel().rows, [table, columnFilters]);
|
|
2761
2799
|
const searchFilteredData = useMemo10(() => {
|