@smallwebco/tinypivot-react 1.0.34 → 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 CHANGED
@@ -147,10 +147,23 @@ function useExcelGrid(options) {
147
147
  const filteredRowCount = table.getFilteredRowModel().rows.length;
148
148
  const totalRowCount = data.length;
149
149
  const activeFilters = (0, import_react.useMemo)(() => {
150
- return columnFilters.map((f) => ({
151
- column: f.id,
152
- values: f.value
153
- }));
150
+ return columnFilters.map((f) => {
151
+ const filterValue = f.value;
152
+ if (filterValue && (0, import_tinypivot_core.isNumericRange)(filterValue)) {
153
+ return {
154
+ column: f.id,
155
+ type: "range",
156
+ range: filterValue,
157
+ values: []
158
+ };
159
+ }
160
+ return {
161
+ column: f.id,
162
+ type: "values",
163
+ values: Array.isArray(filterValue) ? filterValue : [],
164
+ range: null
165
+ };
166
+ });
154
167
  }, [columnFilters]);
155
168
  const hasActiveFilter = (0, import_react.useCallback)(
156
169
  (columnId) => {
@@ -2160,13 +2173,24 @@ function PivotSkeleton({
2160
2173
  const filterTooltipDetails = (0, import_react9.useMemo)(() => {
2161
2174
  if (!activeFilters || activeFilters.length === 0) return [];
2162
2175
  return activeFilters.map((f) => {
2176
+ if (f.isRange && f.displayText) {
2177
+ return {
2178
+ column: f.column,
2179
+ displayText: f.displayText,
2180
+ isRange: true,
2181
+ values: [],
2182
+ remaining: 0
2183
+ };
2184
+ }
2185
+ const values = f.values || [];
2163
2186
  const maxDisplay = 5;
2164
- const displayValues = f.values.slice(0, maxDisplay);
2165
- const remaining = f.values.length - maxDisplay;
2187
+ const displayValues = values.slice(0, maxDisplay);
2188
+ const remaining = values.length - maxDisplay;
2166
2189
  return {
2167
2190
  column: f.column,
2168
2191
  values: displayValues,
2169
- remaining: remaining > 0 ? remaining : 0
2192
+ remaining: remaining > 0 ? remaining : 0,
2193
+ isRange: false
2170
2194
  };
2171
2195
  });
2172
2196
  }, [activeFilters]);
@@ -2338,14 +2362,14 @@ function PivotSkeleton({
2338
2362
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "vpg-tooltip-header", children: "Active Filters" }),
2339
2363
  filterTooltipDetails.map((filter) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "vpg-tooltip-filter", children: [
2340
2364
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "vpg-tooltip-column", children: filter.column }),
2341
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "vpg-tooltip-values", children: [
2365
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "vpg-tooltip-values", children: filter.isRange ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "vpg-tooltip-value vpg-range-value", children: filter.displayText }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
2342
2366
  filter.values.map((val, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "vpg-tooltip-value", children: val }, idx)),
2343
2367
  filter.remaining > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "vpg-tooltip-more", children: [
2344
2368
  "+",
2345
2369
  filter.remaining,
2346
2370
  " more"
2347
2371
  ] })
2348
- ] })
2372
+ ] }) })
2349
2373
  ] }, filter.column)),
2350
2374
  filteredRowCount !== void 0 && totalRowCount !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "vpg-tooltip-summary", children: [
2351
2375
  "Showing ",
@@ -2766,11 +2790,25 @@ function DataGrid({
2766
2790
  } = usePivotTable(filteredDataForPivot);
2767
2791
  const activeFilterInfo = (0, import_react10.useMemo)(() => {
2768
2792
  if (activeFilters.length === 0) return null;
2769
- return activeFilters.map((f) => ({
2770
- column: f.column,
2771
- valueCount: f.values?.length || 0,
2772
- values: f.values || []
2773
- }));
2793
+ return activeFilters.map((f) => {
2794
+ if (f.type === "range" && f.range) {
2795
+ const parts = [];
2796
+ if (f.range.min !== null) parts.push(`\u2265 ${f.range.min}`);
2797
+ if (f.range.max !== null) parts.push(`\u2264 ${f.range.max}`);
2798
+ return {
2799
+ column: f.column,
2800
+ valueCount: 1,
2801
+ displayText: parts.join(" and "),
2802
+ isRange: true
2803
+ };
2804
+ }
2805
+ return {
2806
+ column: f.column,
2807
+ valueCount: f.values?.length || 0,
2808
+ values: f.values || [],
2809
+ isRange: false
2810
+ };
2811
+ });
2774
2812
  }, [activeFilters]);
2775
2813
  const rows = (0, import_react10.useMemo)(() => table.getFilteredRowModel().rows, [table, columnFilters]);
2776
2814
  const searchFilteredData = (0, import_react10.useMemo)(() => {