@ammarkhalidfarooq/dashboard-package 0.6.71 → 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
  })]