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