@ammarkhalidfarooq/dashboard-package 0.6.35 → 0.6.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.js CHANGED
@@ -934,7 +934,6 @@ 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);
938
937
  return /*#__PURE__*/jsxRuntime.jsx(material.ThemeProvider, {
939
938
  theme: theme,
940
939
  children: /*#__PURE__*/jsxRuntime.jsx(React.Suspense, {
@@ -2194,10 +2193,22 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref1, ref) {
2194
2193
  minute: "2-digit"
2195
2194
  }) + " GMT";
2196
2195
  var dateLabel = dateName;
2197
- var normalizeFiltersText = function normalizeFiltersText(filtersInput) {
2196
+ var _normalizeFiltersText = function normalizeFiltersText(filtersInput) {
2197
+ if (typeof filtersInput === "string") {
2198
+ var str = filtersInput.trim();
2199
+ if (!str) return "";
2200
+ if (str.startsWith("[") || str.startsWith("{")) {
2201
+ try {
2202
+ return _normalizeFiltersText(JSON.parse(str));
2203
+ } catch (_) {
2204
+ // Keep raw text if not valid JSON.
2205
+ }
2206
+ }
2207
+ return str;
2208
+ }
2198
2209
  if (Array.isArray(filtersInput)) {
2199
2210
  var fromObjects = filtersInput.filter(function (item) {
2200
- return item && item.value !== undefined && item.value !== null && "".concat(item.value).trim();
2211
+ return item && _typeof(item) === "object" && item.value !== undefined && item.value !== null && "".concat(item.value).trim();
2201
2212
  }).map(function (item) {
2202
2213
  return "".concat(item.label || item.id || "Filter", ": ").concat(item.value);
2203
2214
  }).join(" | ").trim();
@@ -2207,13 +2218,17 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref1, ref) {
2207
2218
  }).filter(Boolean).join(" | ").trim();
2208
2219
  if (fromStrings) return fromStrings;
2209
2220
  }
2210
- if (typeof filtersInput === "string") {
2211
- var str = filtersInput.trim();
2212
- if (str) return str;
2221
+ if (filtersInput && _typeof(filtersInput) === "object") {
2222
+ if (Array.isArray(filtersInput.activeFilters) || typeof filtersInput.activeFilters === "string") {
2223
+ return _normalizeFiltersText(filtersInput.activeFilters);
2224
+ }
2225
+ if (filtersInput.value !== undefined && filtersInput.value !== null && "".concat(filtersInput.value).trim()) {
2226
+ return "".concat(filtersInput.label || filtersInput.id || "Filter", ": ").concat(filtersInput.value).trim();
2227
+ }
2213
2228
  }
2214
2229
  return "";
2215
2230
  };
2216
- var formattedActiveFilters = normalizeFiltersText(activeFilters);
2231
+ var formattedActiveFilters = _normalizeFiltersText(activeFilters);
2217
2232
  var report = buildReportData(apiData, dateName);
2218
2233
  var hero = report.hero,
2219
2234
  metrics = report.metrics,
@@ -3193,6 +3208,10 @@ var NewOverview = function NewOverview(_ref) {
3193
3208
  _useState6 = _slicedToArray(_useState5, 2),
3194
3209
  showExportLayout = _useState6[0],
3195
3210
  setShowExportLayout = _useState6[1];
3211
+ var _useState7 = React.useState([]),
3212
+ _useState8 = _slicedToArray(_useState7, 2),
3213
+ exportFiltersSnapshot = _useState8[0],
3214
+ setExportFiltersSnapshot = _useState8[1];
3196
3215
  var exportLayoutRef = React.useRef(null);
3197
3216
  React.useEffect(function () {
3198
3217
  if (activeSectionProp) {
@@ -3203,8 +3222,11 @@ var NewOverview = function NewOverview(_ref) {
3203
3222
 
3204
3223
  // Step 1 – mount the off-screen export layout whenever the trigger fires
3205
3224
  React.useEffect(function () {
3206
- if (exportTrigger > 0) setShowExportLayout(true);
3207
- }, [exportTrigger]);
3225
+ if (exportTrigger > 0) {
3226
+ setExportFiltersSnapshot(activeFilters);
3227
+ setShowExportLayout(true);
3228
+ }
3229
+ }, [exportTrigger, activeFilters]);
3208
3230
 
3209
3231
  // Step 2 – once the layout is in the DOM, capture each page and build the PDF
3210
3232
  React.useEffect(function () {
@@ -3483,7 +3505,7 @@ var NewOverview = function NewOverview(_ref) {
3483
3505
  apiData: apiData,
3484
3506
  dateName: dateName,
3485
3507
  numberOfDays: numberOfDays,
3486
- activeFilters: activeFilters
3508
+ activeFilters: exportFiltersSnapshot
3487
3509
  })
3488
3510
  })]
3489
3511
  });