@ammarkhalidfarooq/dashboard-package 0.6.70 → 0.6.72

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
@@ -2162,6 +2162,21 @@ var DonorGeographyPanel = function DonorGeographyPanel(_ref9) {
2162
2162
  })
2163
2163
  });
2164
2164
  };
2165
+ var formatDonationTypeCategory = function formatDonationTypeCategory(label, slotWidth) {
2166
+ var str = String(label !== null && label !== void 0 ? label : "").trim();
2167
+ if (!str) return "";
2168
+ var monthRange = str.match(/^([A-Za-z]{3})-([A-Za-z]{3})(?:\s+\d{2,4})?$/);
2169
+ if (monthRange) {
2170
+ var full = "".concat(monthRange[1], "-").concat(monthRange[2]);
2171
+ var mini = "".concat(monthRange[1][0], "-").concat(monthRange[2][0]);
2172
+ var fullWidth = full.length * 3.1;
2173
+ return fullWidth <= slotWidth - 2 ? full : mini;
2174
+ }
2175
+ var noYear = str.replace(/\s+['']?\d{2,4}$/, "").trim();
2176
+ var maxChars = Math.max(3, Math.floor(slotWidth / 3.1));
2177
+ if (noYear.length <= maxChars) return noYear;
2178
+ return "".concat(noYear.slice(0, Math.max(1, maxChars - 1)), "\u2026");
2179
+ };
2165
2180
  var DonationTypeBarSvg = function DonationTypeBarSvg(_ref0) {
2166
2181
  var _ref0$categories = _ref0.categories,
2167
2182
  categories = _ref0$categories === void 0 ? [] : _ref0$categories,
@@ -2178,13 +2193,15 @@ var DonationTypeBarSvg = function DonationTypeBarSvg(_ref0) {
2178
2193
  var padL = 30;
2179
2194
  var padR = 2;
2180
2195
  var padT = 14;
2181
- var padB = 18;
2196
+ var padB = 20;
2182
2197
  var chartW = width - padL - padR;
2183
2198
  var chartH = height - padT - padB;
2184
2199
  var allVals = [].concat(_toConsumableArray(recurring), _toConsumableArray(oneTime));
2185
2200
  var maxVal = Math.max.apply(Math, _toConsumableArray(allVals).concat([0])) || 1;
2186
2201
  var n = categories.length;
2187
2202
  var yTicks = [0, maxVal / 2, maxVal];
2203
+ var groupW = n > 0 ? chartW / n : chartW;
2204
+ var labelFontSize = n > 3 ? 5 : 5.5;
2188
2205
  if (!n) {
2189
2206
  return /*#__PURE__*/jsxRuntime.jsxs("svg", {
2190
2207
  width: "100%",
@@ -2209,7 +2226,6 @@ var DonationTypeBarSvg = function DonationTypeBarSvg(_ref0) {
2209
2226
  })]
2210
2227
  });
2211
2228
  }
2212
- var groupW = chartW / n;
2213
2229
  var barW = Math.min(groupW * 0.3, 12);
2214
2230
  var baseY = padT + chartH;
2215
2231
  return /*#__PURE__*/jsxRuntime.jsxs("svg", {
@@ -2219,7 +2235,19 @@ var DonationTypeBarSvg = function DonationTypeBarSvg(_ref0) {
2219
2235
  style: {
2220
2236
  display: "block"
2221
2237
  },
2222
- children: [yTicks.map(function (tick, i) {
2238
+ children: [/*#__PURE__*/jsxRuntime.jsx("defs", {
2239
+ children: categories.map(function (_, i) {
2240
+ return /*#__PURE__*/jsxRuntime.jsx("clipPath", {
2241
+ id: "donation-type-cat-clip-".concat(i),
2242
+ children: /*#__PURE__*/jsxRuntime.jsx("rect", {
2243
+ x: padL + i * groupW,
2244
+ y: baseY + 2,
2245
+ width: groupW,
2246
+ height: padB - 2
2247
+ })
2248
+ }, "clip-".concat(i));
2249
+ })
2250
+ }), yTicks.map(function (tick, i) {
2223
2251
  var y = padT + chartH - tick / maxVal * chartH;
2224
2252
  return /*#__PURE__*/jsxRuntime.jsxs("g", {
2225
2253
  children: [/*#__PURE__*/jsxRuntime.jsx("line", {
@@ -2283,11 +2311,12 @@ var DonationTypeBarSvg = function DonationTypeBarSvg(_ref0) {
2283
2311
  })]
2284
2312
  }), /*#__PURE__*/jsxRuntime.jsx("text", {
2285
2313
  x: groupX,
2286
- y: height - 4,
2314
+ y: height - 5,
2287
2315
  textAnchor: "middle",
2288
- fontSize: 7.5,
2316
+ fontSize: labelFontSize,
2289
2317
  fill: "rgba(0,0,0,0.4)",
2290
- children: cat
2318
+ clipPath: "url(#donation-type-cat-clip-".concat(i, ")"),
2319
+ children: formatDonationTypeCategory(cat, groupW)
2291
2320
  })]
2292
2321
  }, "bar-".concat(i));
2293
2322
  })]
@@ -2846,6 +2875,23 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref14, ref) {
2846
2875
  emerald: "#10B981",
2847
2876
  cyan: "#06B6D4"
2848
2877
  };
2878
+ var revenueLegend = [{
2879
+ label: "Paid Ads",
2880
+ color: C.indigo
2881
+ }, {
2882
+ label: "Organic",
2883
+ color: C.emerald
2884
+ }, {
2885
+ label: "Email",
2886
+ color: C.cyan
2887
+ }];
2888
+ var revenueTrendText = mainChart.trend || "";
2889
+ var revenueTrendColor = getTrendColor(revenueTrendText, {
2890
+ up: "#054835ff",
2891
+ down: "#EF4444"
2892
+ });
2893
+ var revenueTrendBadgeBg = revenueTrendColor === "#EF4444" ? "#fee2e2" : "#8df3be9a";
2894
+ var revenueTrendArrow = getTrendArrow(revenueTrendText);
2849
2895
  var headerProps = {
2850
2896
  dateLabel: dateLabel,
2851
2897
  generatedLabel: generatedLabel,
@@ -2945,77 +2991,90 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref14, ref) {
2945
2991
  display: "flex",
2946
2992
  justifyContent: "space-between",
2947
2993
  alignItems: "flex-start",
2948
- marginBottom: 6
2994
+ marginBottom: 8
2949
2995
  },
2950
2996
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
2951
2997
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
2952
2998
  style: {
2953
2999
  fontSize: 13,
2954
3000
  fontWeight: 700,
2955
- color: "#111827"
3001
+ color: "#111827",
3002
+ lineHeight: 1.15
2956
3003
  },
2957
3004
  children: "Total revenue trend"
2958
3005
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
2959
3006
  style: {
2960
3007
  fontSize: 9.5,
2961
- color: "#9CA3AF",
2962
- marginTop: 1
3008
+ color: "rgba(0, 0, 0, 0.4)",
3009
+ marginTop: 2,
3010
+ lineHeight: 1.15
2963
3011
  },
2964
3012
  children: ["Last ", daysLabel, " \xB7 daily aggregation"]
2965
- })]
2966
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
2967
- style: {
2968
- textAlign: "right"
2969
- },
2970
- children: [/*#__PURE__*/jsxRuntime.jsx("span", {
2971
- style: {
2972
- fontSize: 15,
2973
- fontWeight: 800,
2974
- color: "#111827"
2975
- },
2976
- children: kpi$(totalRaised)
2977
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
2978
- style: {
2979
- marginLeft: 8,
2980
- fontSize: 10.5
2981
- },
2982
- children: /*#__PURE__*/jsxRuntime.jsx(TrendText, {
2983
- children: mainChart.trend
2984
- })
2985
- })]
2986
- })]
2987
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
2988
- style: {
2989
- display: "flex",
2990
- gap: 14,
2991
- marginBottom: 6
2992
- },
2993
- children: [["Email", C.cyan], ["Organic", C.emerald], ["Paid Ads", C.indigo]].map(function (_ref15) {
2994
- var _ref16 = _slicedToArray(_ref15, 2),
2995
- name = _ref16[0],
2996
- color = _ref16[1];
2997
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
3013
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
2998
3014
  style: {
2999
3015
  display: "flex",
3000
3016
  alignItems: "center",
3001
- gap: 5
3017
+ gap: 6,
3018
+ marginTop: 8
3002
3019
  },
3003
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
3020
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
3004
3021
  style: {
3005
- width: 20,
3006
- height: 2.5,
3007
- background: color,
3008
- borderRadius: 2
3009
- }
3010
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
3022
+ fontSize: 22,
3023
+ fontWeight: 700,
3024
+ color: "#111827"
3025
+ },
3026
+ children: kpi$(totalRaised)
3027
+ }), revenueTrendText && /*#__PURE__*/jsxRuntime.jsxs("span", {
3011
3028
  style: {
3029
+ display: "inline-flex",
3030
+ alignItems: "center",
3031
+ gap: 3,
3032
+ background: revenueTrendBadgeBg,
3033
+ color: revenueTrendColor,
3034
+ padding: "2px 8px",
3035
+ borderRadius: 100,
3012
3036
  fontSize: 9.5,
3013
- color: "#6B7280"
3037
+ fontWeight: 600
3014
3038
  },
3015
- children: name
3039
+ children: [revenueTrendArrow && /*#__PURE__*/jsxRuntime.jsx("span", {
3040
+ children: revenueTrendArrow
3041
+ }), revenueTrendText]
3016
3042
  })]
3017
- }, name);
3018
- })
3043
+ })]
3044
+ }), revSeries.length > 0 && /*#__PURE__*/jsxRuntime.jsx("div", {
3045
+ style: {
3046
+ display: "flex",
3047
+ gap: 10,
3048
+ alignItems: "center",
3049
+ flexShrink: 0,
3050
+ paddingTop: 2
3051
+ },
3052
+ children: revenueLegend.map(function (leg) {
3053
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
3054
+ style: {
3055
+ display: "flex",
3056
+ alignItems: "center",
3057
+ gap: 4
3058
+ },
3059
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
3060
+ style: {
3061
+ width: 8,
3062
+ height: 8,
3063
+ borderRadius: "50%",
3064
+ background: leg.color,
3065
+ flexShrink: 0
3066
+ }
3067
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
3068
+ style: {
3069
+ fontSize: 9.5,
3070
+ color: "rgba(0, 0, 0, 0.6)",
3071
+ fontWeight: 500
3072
+ },
3073
+ children: leg.label
3074
+ })]
3075
+ }, leg.label);
3076
+ })
3077
+ })]
3019
3078
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
3020
3079
  style: {
3021
3080
  width: "100%",
@@ -3350,10 +3409,10 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref14, ref) {
3350
3409
  display: "flex",
3351
3410
  gap: 12
3352
3411
  },
3353
- children: [["Avg/day", d$((ob === null || ob === void 0 ? void 0 : ob.averagePerDay) || 0)], ["Peak day", d$((ob === null || ob === void 0 || (_ob$peakDay = ob.peakDay) === null || _ob$peakDay === void 0 ? void 0 : _ob$peakDay.amount) || 0)], ["Orders", formatNumber((ob === null || ob === void 0 ? void 0 : ob.totalOrders) || 0)]].map(function (_ref17) {
3354
- var _ref18 = _slicedToArray(_ref17, 2),
3355
- l = _ref18[0],
3356
- v = _ref18[1];
3412
+ children: [["Avg/day", d$((ob === null || ob === void 0 ? void 0 : ob.averagePerDay) || 0)], ["Peak day", d$((ob === null || ob === void 0 || (_ob$peakDay = ob.peakDay) === null || _ob$peakDay === void 0 ? void 0 : _ob$peakDay.amount) || 0)], ["Orders", formatNumber((ob === null || ob === void 0 ? void 0 : ob.totalOrders) || 0)]].map(function (_ref15) {
3413
+ var _ref16 = _slicedToArray(_ref15, 2),
3414
+ l = _ref16[0],
3415
+ v = _ref16[1];
3357
3416
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
3358
3417
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
3359
3418
  style: {
@@ -3426,10 +3485,10 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref14, ref) {
3426
3485
  display: "flex",
3427
3486
  gap: 12
3428
3487
  },
3429
- children: [["Referrers", formatNumber((refCard === null || refCard === void 0 ? void 0 : refCard.totalReferrers) || 0)], ["Avg gift", d$((refCard === null || refCard === void 0 ? void 0 : refCard.averageGift) || 0)], ["Conv. rate", pct((refCard === null || refCard === void 0 ? void 0 : refCard.conversionRate) || 0, 1)]].map(function (_ref19) {
3430
- var _ref20 = _slicedToArray(_ref19, 2),
3431
- l = _ref20[0],
3432
- v = _ref20[1];
3488
+ children: [["Referrers", formatNumber((refCard === null || refCard === void 0 ? void 0 : refCard.totalReferrers) || 0)], ["Avg gift", d$((refCard === null || refCard === void 0 ? void 0 : refCard.averageGift) || 0)], ["Conv. rate", pct((refCard === null || refCard === void 0 ? void 0 : refCard.conversionRate) || 0, 1)]].map(function (_ref17) {
3489
+ var _ref18 = _slicedToArray(_ref17, 2),
3490
+ l = _ref18[0],
3491
+ v = _ref18[1];
3433
3492
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
3434
3493
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
3435
3494
  style: {