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