@ammarkhalidfarooq/dashboard-package 0.6.35 → 0.6.37

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.es.js CHANGED
@@ -8,49 +8,6 @@ import Box$1 from '@mui/material/Box';
8
8
  import Typography$1 from '@mui/material/Typography';
9
9
  import ReactApexChart from 'react-apexcharts';
10
10
 
11
- var theme = createTheme({
12
- cssVariables: true,
13
- // Enable CSS variables for better SSR support
14
- typography: {
15
- fontFamily: ["var(--font-league-spartan)", "var(--font-noto-sans-arabic)",
16
- // Added as a fallback for Arabic text
17
- "-apple-system", "BlinkMacSystemFont", "Segoe UI", "Roboto", "Helvetica Neue", "Arial", "sans-serif", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"].join(",")
18
- },
19
- palette: {
20
- primary: {
21
- main: "#6363E6",
22
- mainLight: "#F7F7FF",
23
- light: "#FFFFFF",
24
- gray: "#A1A1A8",
25
- lightGreen: "#E1FBF2",
26
- green: "#0CAB72",
27
- red: "#E61D1D",
28
- lightRed: "#FFEDED",
29
- lightGray: "#E9E9EB",
30
- darkGray: "#606062",
31
- dark: "#090909"
32
- },
33
- text: {
34
- primary: "#666666"
35
- },
36
- secondary: {
37
- main: "#E0C2FF",
38
- light: "#F5EBFF",
39
- // dark: will be calculated from palette.secondary.main,
40
- contrastText: "#47008F"
41
- },
42
- white: {
43
- main: "#FFFFFF",
44
- light: "#F8F8F8"
45
- },
46
- gradients: {
47
- primary: "linear-gradient(90deg, #6363E6 0.05%, #59C9F9 99.96%)",
48
- secondary: "linear-gradient(180deg, #E9E9FF 0%, #C9EEFF 100%)"
49
- // You can add more gradients if needed
50
- }
51
- }
52
- });
53
-
54
11
  function _arrayLikeToArray(r, a) {
55
12
  (null == a || a > r.length) && (a = r.length);
56
13
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
@@ -297,6 +254,49 @@ function _unsupportedIterableToArray(r, a) {
297
254
  }
298
255
  }
299
256
 
257
+ var theme = createTheme({
258
+ cssVariables: true,
259
+ // Enable CSS variables for better SSR support
260
+ typography: {
261
+ fontFamily: ["var(--font-league-spartan)", "var(--font-noto-sans-arabic)",
262
+ // Added as a fallback for Arabic text
263
+ "-apple-system", "BlinkMacSystemFont", "Segoe UI", "Roboto", "Helvetica Neue", "Arial", "sans-serif", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"].join(",")
264
+ },
265
+ palette: {
266
+ primary: {
267
+ main: "#6363E6",
268
+ mainLight: "#F7F7FF",
269
+ light: "#FFFFFF",
270
+ gray: "#A1A1A8",
271
+ lightGreen: "#E1FBF2",
272
+ green: "#0CAB72",
273
+ red: "#E61D1D",
274
+ lightRed: "#FFEDED",
275
+ lightGray: "#E9E9EB",
276
+ darkGray: "#606062",
277
+ dark: "#090909"
278
+ },
279
+ text: {
280
+ primary: "#666666"
281
+ },
282
+ secondary: {
283
+ main: "#E0C2FF",
284
+ light: "#F5EBFF",
285
+ // dark: will be calculated from palette.secondary.main,
286
+ contrastText: "#47008F"
287
+ },
288
+ white: {
289
+ main: "#FFFFFF",
290
+ light: "#F8F8F8"
291
+ },
292
+ gradients: {
293
+ primary: "linear-gradient(90deg, #6363E6 0.05%, #59C9F9 99.96%)",
294
+ secondary: "linear-gradient(180deg, #E9E9FF 0%, #C9EEFF 100%)"
295
+ // You can add more gradients if needed
296
+ }
297
+ }
298
+ });
299
+
300
300
  var MetricSelector = function MetricSelector(_ref) {
301
301
  var metric = _ref.metric,
302
302
  onMetricChange = _ref.onMetricChange,
@@ -932,7 +932,12 @@ var Dashboard = function Dashboard(_ref) {
932
932
  numberOfDays = _ref$numberOfDays === void 0 ? 1 : _ref$numberOfDays,
933
933
  _ref$activeFilters = _ref.activeFilters,
934
934
  activeFilters = _ref$activeFilters === void 0 ? [] : _ref$activeFilters;
935
- console.log("activeFilters chart", activeFilters);
935
+ console.log("[Dashboard] activeFilters prop:", {
936
+ value: activeFilters,
937
+ type: _typeof(activeFilters),
938
+ isArray: Array.isArray(activeFilters),
939
+ length: Array.isArray(activeFilters) ? activeFilters.length : undefined
940
+ });
936
941
  return /*#__PURE__*/jsx(ThemeProvider, {
937
942
  theme: theme,
938
943
  children: /*#__PURE__*/jsx(Suspense, {
@@ -2192,10 +2197,22 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref1, ref) {
2192
2197
  minute: "2-digit"
2193
2198
  }) + " GMT";
2194
2199
  var dateLabel = dateName;
2195
- var normalizeFiltersText = function normalizeFiltersText(filtersInput) {
2200
+ var _normalizeFiltersText = function normalizeFiltersText(filtersInput) {
2201
+ if (typeof filtersInput === "string") {
2202
+ var str = filtersInput.trim();
2203
+ if (!str) return "";
2204
+ if (str.startsWith("[") || str.startsWith("{")) {
2205
+ try {
2206
+ return _normalizeFiltersText(JSON.parse(str));
2207
+ } catch (_) {
2208
+ // Keep raw text if not valid JSON.
2209
+ }
2210
+ }
2211
+ return str;
2212
+ }
2196
2213
  if (Array.isArray(filtersInput)) {
2197
2214
  var fromObjects = filtersInput.filter(function (item) {
2198
- return item && item.value !== undefined && item.value !== null && "".concat(item.value).trim();
2215
+ return item && _typeof(item) === "object" && item.value !== undefined && item.value !== null && "".concat(item.value).trim();
2199
2216
  }).map(function (item) {
2200
2217
  return "".concat(item.label || item.id || "Filter", ": ").concat(item.value);
2201
2218
  }).join(" | ").trim();
@@ -2205,13 +2222,24 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref1, ref) {
2205
2222
  }).filter(Boolean).join(" | ").trim();
2206
2223
  if (fromStrings) return fromStrings;
2207
2224
  }
2208
- if (typeof filtersInput === "string") {
2209
- var str = filtersInput.trim();
2210
- if (str) return str;
2225
+ if (filtersInput && _typeof(filtersInput) === "object") {
2226
+ if (Array.isArray(filtersInput.activeFilters) || typeof filtersInput.activeFilters === "string") {
2227
+ return _normalizeFiltersText(filtersInput.activeFilters);
2228
+ }
2229
+ if (filtersInput.value !== undefined && filtersInput.value !== null && "".concat(filtersInput.value).trim()) {
2230
+ return "".concat(filtersInput.label || filtersInput.id || "Filter", ": ").concat(filtersInput.value).trim();
2231
+ }
2211
2232
  }
2212
2233
  return "";
2213
2234
  };
2214
- var formattedActiveFilters = normalizeFiltersText(activeFilters);
2235
+ var formattedActiveFilters = _normalizeFiltersText(activeFilters);
2236
+ console.log("[ExportPdfLayout] activeFilters prop received:", {
2237
+ value: activeFilters,
2238
+ type: _typeof(activeFilters),
2239
+ isArray: Array.isArray(activeFilters),
2240
+ length: Array.isArray(activeFilters) ? activeFilters.length : undefined
2241
+ });
2242
+ console.log("[ExportPdfLayout] formattedActiveFilters:", formattedActiveFilters);
2215
2243
  var report = buildReportData(apiData, dateName);
2216
2244
  var hero = report.hero,
2217
2245
  metrics = report.metrics,
@@ -3191,7 +3219,19 @@ var NewOverview = function NewOverview(_ref) {
3191
3219
  _useState6 = _slicedToArray(_useState5, 2),
3192
3220
  showExportLayout = _useState6[0],
3193
3221
  setShowExportLayout = _useState6[1];
3222
+ var _useState7 = useState([]),
3223
+ _useState8 = _slicedToArray(_useState7, 2),
3224
+ exportFiltersSnapshot = _useState8[0],
3225
+ setExportFiltersSnapshot = _useState8[1];
3194
3226
  var exportLayoutRef = useRef(null);
3227
+ useEffect(function () {
3228
+ console.log("[NewOverview] activeFilters prop changed:", {
3229
+ value: activeFilters,
3230
+ type: _typeof(activeFilters),
3231
+ isArray: Array.isArray(activeFilters),
3232
+ length: Array.isArray(activeFilters) ? activeFilters.length : undefined
3233
+ });
3234
+ }, [activeFilters]);
3195
3235
  useEffect(function () {
3196
3236
  if (activeSectionProp) {
3197
3237
  var capitalized = activeSectionProp.charAt(0).toUpperCase() + activeSectionProp.slice(1).toLowerCase();
@@ -3201,8 +3241,26 @@ var NewOverview = function NewOverview(_ref) {
3201
3241
 
3202
3242
  // Step 1 – mount the off-screen export layout whenever the trigger fires
3203
3243
  useEffect(function () {
3204
- if (exportTrigger > 0) setShowExportLayout(true);
3205
- }, [exportTrigger]);
3244
+ if (exportTrigger > 0) {
3245
+ console.log("[NewOverview] exportTrigger received:", exportTrigger);
3246
+ console.log("[NewOverview] snapshotting filters for export:", {
3247
+ value: activeFilters,
3248
+ type: _typeof(activeFilters),
3249
+ isArray: Array.isArray(activeFilters),
3250
+ length: Array.isArray(activeFilters) ? activeFilters.length : undefined
3251
+ });
3252
+ setExportFiltersSnapshot(activeFilters);
3253
+ setShowExportLayout(true);
3254
+ }
3255
+ }, [exportTrigger, activeFilters]);
3256
+ useEffect(function () {
3257
+ console.log("[NewOverview] exportFiltersSnapshot updated:", {
3258
+ value: exportFiltersSnapshot,
3259
+ type: _typeof(exportFiltersSnapshot),
3260
+ isArray: Array.isArray(exportFiltersSnapshot),
3261
+ length: Array.isArray(exportFiltersSnapshot) ? exportFiltersSnapshot.length : undefined
3262
+ });
3263
+ }, [exportFiltersSnapshot]);
3206
3264
 
3207
3265
  // Step 2 – once the layout is in the DOM, capture each page and build the PDF
3208
3266
  useEffect(function () {
@@ -3214,6 +3272,8 @@ var NewOverview = function NewOverview(_ref) {
3214
3272
  while (1) switch (_context.p = _context.n) {
3215
3273
  case 0:
3216
3274
  _context.p = 0;
3275
+ console.log("[NewOverview] starting PDF export with snapshot:", exportFiltersSnapshot);
3276
+ // Allow SVG layout to paint before capture
3217
3277
  _context.n = 1;
3218
3278
  return new Promise(function (r) {
3219
3279
  return requestAnimationFrame(function () {
@@ -3237,6 +3297,7 @@ var NewOverview = function NewOverview(_ref) {
3237
3297
  _context.n = 4;
3238
3298
  return exportReportPdf(container, "DashboardOverview_report_".concat(safeDate, ".pdf"));
3239
3299
  case 4:
3300
+ console.log("[NewOverview] PDF export completed");
3240
3301
  _context.n = 6;
3241
3302
  break;
3242
3303
  case 5:
@@ -3257,7 +3318,7 @@ var NewOverview = function NewOverview(_ref) {
3257
3318
  };
3258
3319
  }();
3259
3320
  doPdfExport();
3260
- }, [showExportLayout]);
3321
+ }, [showExportLayout, exportFiltersSnapshot]);
3261
3322
  var currentData = metric === "Revenue" ? revenueData : donationsData;
3262
3323
  var oneTimeData = (apiData === null || apiData === void 0 ? void 0 : apiData.oneTimeDonations) || [];
3263
3324
  var oneTimeValues = oneTimeData.length > 0 ? oneTimeData.map(function (item) {
@@ -3481,7 +3542,7 @@ var NewOverview = function NewOverview(_ref) {
3481
3542
  apiData: apiData,
3482
3543
  dateName: dateName,
3483
3544
  numberOfDays: numberOfDays,
3484
- activeFilters: activeFilters
3545
+ activeFilters: exportFiltersSnapshot
3485
3546
  })
3486
3547
  })]
3487
3548
  });