@bunnyapp/components 1.6.0-beta.8 → 1.6.0-beta.9

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/cjs/index.js CHANGED
@@ -22643,6 +22643,24 @@ const getFeatureUsage = async ({ subscriptionChargeId, token, apiHost, }) => {
22643
22643
  throw new Error('No data found');
22644
22644
  };
22645
22645
 
22646
+ var utc$2 = {exports: {}};
22647
+
22648
+ var utc$1 = utc$2.exports;
22649
+
22650
+ var hasRequiredUtc;
22651
+
22652
+ function requireUtc () {
22653
+ if (hasRequiredUtc) return utc$2.exports;
22654
+ hasRequiredUtc = 1;
22655
+ (function (module, exports) {
22656
+ !function(t,i){module.exports=i();}(utc$1,(function(){var t="minute",i=/[+-]\d\d(?::?\d\d)?/g,e=/([+-]|\d\d)/g;return function(s,f,n){var u=f.prototype;n.utc=function(t){var i={date:t,utc:!0,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:!0});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var r=u.parse;u.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),r.call(this,t);};var o=u.init;u.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds();}else o.call(this);};var a=u.utcOffset;u.utcOffset=function(s,f){var n=this.$utils().u;if(n(s))return this.$u?0:n(this.$offset)?a.call(this):this.$offset;if("string"==typeof s&&(s=function(t){void 0===t&&(t="");var s=t.match(i);if(!s)return null;var f=(""+s[0]).match(e)||["-",0,0],n=f[0],u=60*+f[1]+ +f[2];return 0===u?0:"+"===n?u:-u}(s),null===s))return this;var u=Math.abs(s)<=16?60*s:s;if(0===u)return this.utc(f);var r=this.clone();if(f)return r.$offset=u,r.$u=!1,r;var o=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return (r=this.local().add(u+o,t)).$offset=u,r.$x.$localOffset=o,r};var h=u.format;u.format=function(t){var i=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,i)},u.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},u.isUTC=function(){return !!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var l=u.toDate;u.toDate=function(t){return "s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():l.call(this)};var c=u.diff;u.diff=function(t,i,e){if(t&&this.$u===t.$u)return c.call(this,t,i,e);var s=this.local(),f=n(t).local();return c.call(s,f,i,e)};}}));
22657
+ } (utc$2));
22658
+ return utc$2.exports;
22659
+ }
22660
+
22661
+ var utcExports = requireUtc();
22662
+ var utc = /*@__PURE__*/getDefaultExportFromCjs(utcExports);
22663
+
22646
22664
  const StyledModal = defaultStyled(antd.Modal) `
22647
22665
  z-index: 2000;
22648
22666
 
@@ -22675,74 +22693,103 @@ const HeaderModalWrapper = (props) => {
22675
22693
  };
22676
22694
 
22677
22695
  const { isPlural } = pkg;
22696
+ dayjs.extend(utc);
22678
22697
  const getDateFormat = (dataInterval) => {
22679
22698
  return dataInterval === common.DataInterval.DAILY
22680
- ? "MMM DD"
22699
+ ? 'MMM DD'
22681
22700
  : dataInterval === common.DataInterval.MONTHLY
22682
- ? "MMM"
22701
+ ? 'MMM'
22683
22702
  : dataInterval === common.DataInterval.QUARTERLY
22684
- ? "MMM"
22703
+ ? 'MMM'
22685
22704
  : dataInterval === common.DataInterval.SEMIANNUALLY
22686
- ? "MMM"
22687
- : "YYYY";
22705
+ ? 'MMM'
22706
+ : 'YYYY';
22688
22707
  };
22689
- const FeatureUsageGraph = ({ charge, featureUsage, }) => {
22708
+ const USAGE_ROW_HEIGHT = 20;
22709
+ const FeatureUsageGraph = ({ charge, featureUsage, useAreaChart = false, }) => {
22690
22710
  var _a;
22691
22711
  // State
22692
- const [isModalOpen, setIsModalOpen] = react.useState(false);
22693
- const dataFormat = getDateFormat(featureUsage.dataInterval);
22694
- const chargeFeatureName = ((_a = charge.feature) === null || _a === void 0 ? void 0 : _a.name) || "";
22712
+ const [open, setOpen] = react.useState(false);
22713
+ const chargeFeatureName = ((_a = charge.feature) === null || _a === void 0 ? void 0 : _a.name) || '';
22695
22714
  const featureName = isPlural(chargeFeatureName)
22696
22715
  ? chargeFeatureName
22697
22716
  : pkg(chargeFeatureName);
22698
- const basicViewData = featureUsage.data.map((data) => ({
22699
- label: dayjs(data.periodStart).format(dataFormat) +
22700
- " - " +
22701
- dayjs(data.periodEnd).format(dataFormat),
22702
- [featureName]: data.intervalsTotal,
22703
- }));
22704
- const detailedViewData = featureUsage.data.flatMap((data) => {
22705
- return data.intervals.map((interval) => ({
22706
- label: dayjs(interval.intervalStart).format(dataFormat),
22717
+ if (!featureUsage)
22718
+ return null;
22719
+ const dataFormat = getDateFormat(featureUsage.dataInterval);
22720
+ // Use individual intervals instead of grouped periods
22721
+ const basicViewData = featureUsage.data.flatMap(data => {
22722
+ return data.intervals.map(interval => ({
22723
+ label: dayjs.utc(interval.intervalStart).format(dataFormat),
22707
22724
  [featureName]: interval.intervalUsage,
22708
22725
  }));
22709
22726
  });
22710
- if (!basicViewData.some((d) => {
22727
+ const detailedViewData = basicViewData;
22728
+ if (!basicViewData.some(d => {
22711
22729
  const usage = d[featureName];
22712
- if (typeof usage === "number") {
22730
+ if (typeof usage === 'number') {
22713
22731
  return usage > 0;
22714
22732
  }
22715
22733
  return false;
22716
22734
  }))
22717
- return jsxRuntime.jsx("div", { children: "no usage" });
22718
- return (jsxRuntime.jsxs("div", { onClick: () => {
22719
- setIsModalOpen(true);
22720
- }, children: [jsxRuntime.jsx("div", { style: {
22721
- height: "36px",
22722
- }, children: jsxRuntime.jsx(FeatureBarChart, { data: basicViewData, featureName: featureName, height: 36, width: 120 }) }), jsxRuntime.jsx(HeaderModalWrapper, { footer: null, open: isModalOpen, onCancel: (e) => {
22723
- e.stopPropagation();
22724
- setIsModalOpen(false);
22725
- }, title: `Usage for period ${dayjs(charge.startDate).format("MMM DD, YYYY")} - ${dayjs(charge.endDate).format("MMM DD, YYYY")}`, children: jsxRuntime.jsx("div", { className: "bunny-py-4 bunny-px-6 bunny-overflow-visible", children: jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: 200, children: jsxRuntime.jsx(FeatureBarChart, { data: detailedViewData, displayXAxis: true, featureName: featureName }) }) }) })] }));
22735
+ return 'no usage';
22736
+ return (jsxRuntime.jsxs("div", { className: "bunny-cursor-pointer", onClick: e => {
22737
+ e === null || e === void 0 ? void 0 : e.stopPropagation();
22738
+ }, children: [jsxRuntime.jsx("div", { onClick: () => setOpen(true), style: {
22739
+ height: USAGE_ROW_HEIGHT,
22740
+ }, children: jsxRuntime.jsx(FeatureBarChart, { data: basicViewData, featureName: featureName, height: USAGE_ROW_HEIGHT, width: 120, useAreaChart: useAreaChart }) }), jsxRuntime.jsx(HeaderModalWrapper, { footer: null, onCancel: () => {
22741
+ setOpen(false);
22742
+ }, open: open, title: `Usage for period ${dayjs.utc(charge.startDate).format('MMM DD, YYYY')} - ${dayjs
22743
+ .utc(charge.endDate)
22744
+ .format('MMM DD, YYYY')}`, children: jsxRuntime.jsx("div", { className: "bunny-py-4 bunny-px-6", onClick: e => e.stopPropagation(), children: jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: 200, children: jsxRuntime.jsx(FeatureBarChart, { data: detailedViewData, displayXAxis: true, featureName: featureName }) }) }) })] }));
22726
22745
  };
22727
- const FeatureBarChart = ({ data, displayXAxis, featureName, height, width, }) => {
22728
- // Context
22729
- const { brandColor } = react.useContext(BrandContext);
22730
- return (jsxRuntime.jsxs(StyledBarChart, { width: width, height: height, data: data, children: [jsxRuntime.jsx(recharts.XAxis, { className: "bunny-text-xs", dataKey: "label", ...(displayXAxis
22746
+ const FeatureBarChart = ({ data, displayXAxis, featureName, height, width, useAreaChart, }) => {
22747
+ const BLUE_300 = '#93c5fd';
22748
+ if (useAreaChart) {
22749
+ return (jsxRuntime.jsxs(StyledAreaChart, { data: data, height: height, style: { overflow: 'visible' }, width: width, margin: { top: 0, right: 0, left: 0, bottom: 0 }, children: [jsxRuntime.jsx(recharts.XAxis, { className: "bunny-text-xs", dataKey: "label", interval: "equidistantPreserveStart", axisLine: false, ...(displayXAxis
22750
+ ? {}
22751
+ : {
22752
+ tickFormatter: () => '',
22753
+ tickLine: false,
22754
+ }), style: {
22755
+ fill: common.SLATE_500,
22756
+ }, height: displayXAxis ? undefined : 1 }), jsxRuntime.jsx(recharts.Tooltip, { cursor: { fill: common.SLATE_200 }, ...(displayXAxis
22757
+ ? {}
22758
+ : {
22759
+ position: { y: -62 },
22760
+ }), wrapperStyle: { zIndex: 1000 }, content: ({ payload, label }) => {
22761
+ var _a, _b;
22762
+ const usage = (_b = (_a = payload === null || payload === void 0 ? void 0 : payload[0]) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.toLocaleString();
22763
+ return (jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-rounded bunny-bg-white bunny-p-2 bunny-shadow bunny-gap-1", children: [jsxRuntime.jsx("div", { className: "bunny-text-left bunny-text-sm bunny-font-medium", children: label }), jsxRuntime.jsxs("div", { className: "bunny-text-left bunny-flex bunny-items-center bunny-text-sm", children: [jsxRuntime.jsxs("span", { children: [featureName, ": "] }), jsxRuntime.jsxs("span", { children: ["\u00A0", usage] })] })] }));
22764
+ } }), jsxRuntime.jsx(recharts.Area, { type: "monotone", dataKey: featureName, stroke: BLUE_300, fill: BLUE_300, fillOpacity: 0.6 })] }));
22765
+ }
22766
+ return (jsxRuntime.jsxs(StyledBarChart, { data: data, height: height, style: { overflow: 'visible' }, width: width, margin: { top: 0, right: 0, left: 0, bottom: 0 }, children: [jsxRuntime.jsx(recharts.XAxis, { className: "bunny-text-xs", dataKey: "label", interval: "equidistantPreserveStart", ...(displayXAxis
22731
22767
  ? {}
22732
22768
  : {
22733
- tickFormatter: () => "",
22769
+ tickFormatter: () => '',
22734
22770
  tickLine: false,
22735
- }), height: displayXAxis ? undefined : 1, interval: "equidistantPreserveStart", style: {
22771
+ }), style: {
22736
22772
  fill: common.SLATE_500,
22737
- } }), jsxRuntime.jsx(recharts.Tooltip, { cursor: { fill: common.SLATE_200 }, ...(displayXAxis
22773
+ }, height: displayXAxis ? undefined : 1 }), jsxRuntime.jsx(recharts.Tooltip, { cursor: { fill: common.SLATE_200 }, ...(displayXAxis
22738
22774
  ? {}
22739
22775
  : {
22740
22776
  position: { y: -62 },
22741
- }) }), jsxRuntime.jsx(recharts.Bar, { dataKey: featureName, fill: brandColor, activeBar: jsxRuntime.jsx(recharts.Rectangle, { fill: brandColor }) })] }));
22777
+ }), wrapperStyle: { zIndex: 1000 }, content: ({ payload, label }) => {
22778
+ var _a, _b;
22779
+ const usage = (_b = (_a = payload === null || payload === void 0 ? void 0 : payload[0]) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.toLocaleString();
22780
+ return (jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-rounded bunny-bg-white bunny-p-2 bunny-shadow bunny-gap-1", children: [jsxRuntime.jsx("div", { className: "bunny-text-left bunny-text-sm bunny-font-medium", children: label }), jsxRuntime.jsxs("div", { className: "bunny-text-left bunny-flex bunny-items-center bunny-text-sm", children: [jsxRuntime.jsxs("span", { children: [featureName, ": "] }), jsxRuntime.jsxs("span", { children: ["\u00A0", usage] })] })] }));
22781
+ } }), jsxRuntime.jsx(recharts.Bar, { activeBar: jsxRuntime.jsx(recharts.Rectangle, { fill: BLUE_300 }), dataKey: featureName, fill: BLUE_300 })] }));
22742
22782
  };
22743
22783
  const StyledBarChart = defaultStyled(recharts.BarChart) `
22744
22784
  .recharts-surface {
22745
22785
  overflow: visible;
22786
+ outline: none;
22787
+ }
22788
+ `;
22789
+ const StyledAreaChart = defaultStyled(recharts.AreaChart) `
22790
+ .recharts-surface {
22791
+ overflow: visible;
22792
+ outline: none;
22746
22793
  }
22747
22794
  `;
22748
22795
 
@@ -23221,7 +23268,7 @@ const SubscriptionCardDesktopRow = ({ charge, chargeIndex, subscription, }) => {
23221
23268
  return (jsxRuntime.jsxs("div", { className: "bunny-contents", children: [(isRampFirstRow || !isRamp) && (jsxRuntime.jsx(SubscriptionsListCell, { gridColumn: isRamp ? '1/-1' : '1', children: jsxRuntime.jsx("div", { className: `bunny-flex bunny-items-center bunny-gap-2 ${isDiscount ? 'bunny-pl-4' : ''}`, children: jsxRuntime.jsx("div", { children: isRampFirstRow || (!isRamp && !dontShowChargeName) ? charge.name : '' }) }) })), jsxRuntime.jsx(SubscriptionsListCell, { gridColumn: 2, children: jsxRuntime.jsx("div", { children: chargePeriod }) }), jsxRuntime.jsx(SubscriptionsListCell, { right: true, children: charge.kind === common.QuoteChangeKind.DISCOUNT
23222
23269
  ? ''
23223
23270
  : charge.chargeType === common.ChargeType.USAGE
23224
- ? data && jsxRuntime.jsx(FeatureUsageGraph, { charge: charge, featureUsage: data })
23271
+ ? data && jsxRuntime.jsx(FeatureUsageGraph, { charge: charge, featureUsage: data, useAreaChart: true })
23225
23272
  : charge.isAmendment
23226
23273
  ? `+${(_b = charge.quantity) === null || _b === void 0 ? void 0 : _b.toLocaleString()}`
23227
23274
  : (_c = charge.quantity) === null || _c === void 0 ? void 0 : _c.toLocaleString() }), jsxRuntime.jsx(SubscriptionsListCell, { right: true, children: jsxRuntime.jsx(SubscriptionChargeUnitPrice, { charge: charge, currencyId: subscription.currencyId }) }), jsxRuntime.jsx(SubscriptionsListCell, { right: true, children: jsxRuntime.jsx(SubscriptionChargeTotal, { charge: charge, subscription: subscription }) })] }));
package/dist/esm/index.js CHANGED
@@ -15,7 +15,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
15
15
  import { useElements, useStripe, PaymentElement, Elements } from '@stripe/react-stripe-js';
16
16
  import { loadStripe } from '@stripe/stripe-js/pure/index.js';
17
17
  import { print } from 'graphql';
18
- import { BarChart, ResponsiveContainer, XAxis, Tooltip as Tooltip$1, Bar, Rectangle } from 'recharts';
18
+ import { BarChart, AreaChart, ResponsiveContainer, XAxis, Tooltip as Tooltip$1, Area, Bar, Rectangle } from 'recharts';
19
19
  import { omit } from 'lodash-es';
20
20
  import pkg from 'pluralize';
21
21
 
@@ -22641,6 +22641,24 @@ const getFeatureUsage = async ({ subscriptionChargeId, token, apiHost, }) => {
22641
22641
  throw new Error('No data found');
22642
22642
  };
22643
22643
 
22644
+ var utc$2 = {exports: {}};
22645
+
22646
+ var utc$1 = utc$2.exports;
22647
+
22648
+ var hasRequiredUtc;
22649
+
22650
+ function requireUtc () {
22651
+ if (hasRequiredUtc) return utc$2.exports;
22652
+ hasRequiredUtc = 1;
22653
+ (function (module, exports) {
22654
+ !function(t,i){module.exports=i();}(utc$1,(function(){var t="minute",i=/[+-]\d\d(?::?\d\d)?/g,e=/([+-]|\d\d)/g;return function(s,f,n){var u=f.prototype;n.utc=function(t){var i={date:t,utc:!0,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:!0});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var r=u.parse;u.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),r.call(this,t);};var o=u.init;u.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds();}else o.call(this);};var a=u.utcOffset;u.utcOffset=function(s,f){var n=this.$utils().u;if(n(s))return this.$u?0:n(this.$offset)?a.call(this):this.$offset;if("string"==typeof s&&(s=function(t){void 0===t&&(t="");var s=t.match(i);if(!s)return null;var f=(""+s[0]).match(e)||["-",0,0],n=f[0],u=60*+f[1]+ +f[2];return 0===u?0:"+"===n?u:-u}(s),null===s))return this;var u=Math.abs(s)<=16?60*s:s;if(0===u)return this.utc(f);var r=this.clone();if(f)return r.$offset=u,r.$u=!1,r;var o=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return (r=this.local().add(u+o,t)).$offset=u,r.$x.$localOffset=o,r};var h=u.format;u.format=function(t){var i=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,i)},u.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},u.isUTC=function(){return !!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var l=u.toDate;u.toDate=function(t){return "s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():l.call(this)};var c=u.diff;u.diff=function(t,i,e){if(t&&this.$u===t.$u)return c.call(this,t,i,e);var s=this.local(),f=n(t).local();return c.call(s,f,i,e)};}}));
22655
+ } (utc$2));
22656
+ return utc$2.exports;
22657
+ }
22658
+
22659
+ var utcExports = requireUtc();
22660
+ var utc = /*@__PURE__*/getDefaultExportFromCjs(utcExports);
22661
+
22644
22662
  const StyledModal = defaultStyled(Modal) `
22645
22663
  z-index: 2000;
22646
22664
 
@@ -22673,74 +22691,103 @@ const HeaderModalWrapper = (props) => {
22673
22691
  };
22674
22692
 
22675
22693
  const { isPlural } = pkg;
22694
+ dayjs.extend(utc);
22676
22695
  const getDateFormat = (dataInterval) => {
22677
22696
  return dataInterval === DataInterval.DAILY
22678
- ? "MMM DD"
22697
+ ? 'MMM DD'
22679
22698
  : dataInterval === DataInterval.MONTHLY
22680
- ? "MMM"
22699
+ ? 'MMM'
22681
22700
  : dataInterval === DataInterval.QUARTERLY
22682
- ? "MMM"
22701
+ ? 'MMM'
22683
22702
  : dataInterval === DataInterval.SEMIANNUALLY
22684
- ? "MMM"
22685
- : "YYYY";
22703
+ ? 'MMM'
22704
+ : 'YYYY';
22686
22705
  };
22687
- const FeatureUsageGraph = ({ charge, featureUsage, }) => {
22706
+ const USAGE_ROW_HEIGHT = 20;
22707
+ const FeatureUsageGraph = ({ charge, featureUsage, useAreaChart = false, }) => {
22688
22708
  var _a;
22689
22709
  // State
22690
- const [isModalOpen, setIsModalOpen] = useState(false);
22691
- const dataFormat = getDateFormat(featureUsage.dataInterval);
22692
- const chargeFeatureName = ((_a = charge.feature) === null || _a === void 0 ? void 0 : _a.name) || "";
22710
+ const [open, setOpen] = useState(false);
22711
+ const chargeFeatureName = ((_a = charge.feature) === null || _a === void 0 ? void 0 : _a.name) || '';
22693
22712
  const featureName = isPlural(chargeFeatureName)
22694
22713
  ? chargeFeatureName
22695
22714
  : pkg(chargeFeatureName);
22696
- const basicViewData = featureUsage.data.map((data) => ({
22697
- label: dayjs(data.periodStart).format(dataFormat) +
22698
- " - " +
22699
- dayjs(data.periodEnd).format(dataFormat),
22700
- [featureName]: data.intervalsTotal,
22701
- }));
22702
- const detailedViewData = featureUsage.data.flatMap((data) => {
22703
- return data.intervals.map((interval) => ({
22704
- label: dayjs(interval.intervalStart).format(dataFormat),
22715
+ if (!featureUsage)
22716
+ return null;
22717
+ const dataFormat = getDateFormat(featureUsage.dataInterval);
22718
+ // Use individual intervals instead of grouped periods
22719
+ const basicViewData = featureUsage.data.flatMap(data => {
22720
+ return data.intervals.map(interval => ({
22721
+ label: dayjs.utc(interval.intervalStart).format(dataFormat),
22705
22722
  [featureName]: interval.intervalUsage,
22706
22723
  }));
22707
22724
  });
22708
- if (!basicViewData.some((d) => {
22725
+ const detailedViewData = basicViewData;
22726
+ if (!basicViewData.some(d => {
22709
22727
  const usage = d[featureName];
22710
- if (typeof usage === "number") {
22728
+ if (typeof usage === 'number') {
22711
22729
  return usage > 0;
22712
22730
  }
22713
22731
  return false;
22714
22732
  }))
22715
- return jsx("div", { children: "no usage" });
22716
- return (jsxs("div", { onClick: () => {
22717
- setIsModalOpen(true);
22718
- }, children: [jsx("div", { style: {
22719
- height: "36px",
22720
- }, children: jsx(FeatureBarChart, { data: basicViewData, featureName: featureName, height: 36, width: 120 }) }), jsx(HeaderModalWrapper, { footer: null, open: isModalOpen, onCancel: (e) => {
22721
- e.stopPropagation();
22722
- setIsModalOpen(false);
22723
- }, title: `Usage for period ${dayjs(charge.startDate).format("MMM DD, YYYY")} - ${dayjs(charge.endDate).format("MMM DD, YYYY")}`, children: jsx("div", { className: "bunny-py-4 bunny-px-6 bunny-overflow-visible", children: jsx(ResponsiveContainer, { width: "100%", height: 200, children: jsx(FeatureBarChart, { data: detailedViewData, displayXAxis: true, featureName: featureName }) }) }) })] }));
22733
+ return 'no usage';
22734
+ return (jsxs("div", { className: "bunny-cursor-pointer", onClick: e => {
22735
+ e === null || e === void 0 ? void 0 : e.stopPropagation();
22736
+ }, children: [jsx("div", { onClick: () => setOpen(true), style: {
22737
+ height: USAGE_ROW_HEIGHT,
22738
+ }, children: jsx(FeatureBarChart, { data: basicViewData, featureName: featureName, height: USAGE_ROW_HEIGHT, width: 120, useAreaChart: useAreaChart }) }), jsx(HeaderModalWrapper, { footer: null, onCancel: () => {
22739
+ setOpen(false);
22740
+ }, open: open, title: `Usage for period ${dayjs.utc(charge.startDate).format('MMM DD, YYYY')} - ${dayjs
22741
+ .utc(charge.endDate)
22742
+ .format('MMM DD, YYYY')}`, children: jsx("div", { className: "bunny-py-4 bunny-px-6", onClick: e => e.stopPropagation(), children: jsx(ResponsiveContainer, { width: "100%", height: 200, children: jsx(FeatureBarChart, { data: detailedViewData, displayXAxis: true, featureName: featureName }) }) }) })] }));
22724
22743
  };
22725
- const FeatureBarChart = ({ data, displayXAxis, featureName, height, width, }) => {
22726
- // Context
22727
- const { brandColor } = useContext(BrandContext);
22728
- return (jsxs(StyledBarChart, { width: width, height: height, data: data, children: [jsx(XAxis, { className: "bunny-text-xs", dataKey: "label", ...(displayXAxis
22744
+ const FeatureBarChart = ({ data, displayXAxis, featureName, height, width, useAreaChart, }) => {
22745
+ const BLUE_300 = '#93c5fd';
22746
+ if (useAreaChart) {
22747
+ return (jsxs(StyledAreaChart, { data: data, height: height, style: { overflow: 'visible' }, width: width, margin: { top: 0, right: 0, left: 0, bottom: 0 }, children: [jsx(XAxis, { className: "bunny-text-xs", dataKey: "label", interval: "equidistantPreserveStart", axisLine: false, ...(displayXAxis
22748
+ ? {}
22749
+ : {
22750
+ tickFormatter: () => '',
22751
+ tickLine: false,
22752
+ }), style: {
22753
+ fill: SLATE_500,
22754
+ }, height: displayXAxis ? undefined : 1 }), jsx(Tooltip$1, { cursor: { fill: SLATE_200 }, ...(displayXAxis
22755
+ ? {}
22756
+ : {
22757
+ position: { y: -62 },
22758
+ }), wrapperStyle: { zIndex: 1000 }, content: ({ payload, label }) => {
22759
+ var _a, _b;
22760
+ const usage = (_b = (_a = payload === null || payload === void 0 ? void 0 : payload[0]) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.toLocaleString();
22761
+ return (jsxs("div", { className: "bunny-flex bunny-flex-col bunny-rounded bunny-bg-white bunny-p-2 bunny-shadow bunny-gap-1", children: [jsx("div", { className: "bunny-text-left bunny-text-sm bunny-font-medium", children: label }), jsxs("div", { className: "bunny-text-left bunny-flex bunny-items-center bunny-text-sm", children: [jsxs("span", { children: [featureName, ": "] }), jsxs("span", { children: ["\u00A0", usage] })] })] }));
22762
+ } }), jsx(Area, { type: "monotone", dataKey: featureName, stroke: BLUE_300, fill: BLUE_300, fillOpacity: 0.6 })] }));
22763
+ }
22764
+ return (jsxs(StyledBarChart, { data: data, height: height, style: { overflow: 'visible' }, width: width, margin: { top: 0, right: 0, left: 0, bottom: 0 }, children: [jsx(XAxis, { className: "bunny-text-xs", dataKey: "label", interval: "equidistantPreserveStart", ...(displayXAxis
22729
22765
  ? {}
22730
22766
  : {
22731
- tickFormatter: () => "",
22767
+ tickFormatter: () => '',
22732
22768
  tickLine: false,
22733
- }), height: displayXAxis ? undefined : 1, interval: "equidistantPreserveStart", style: {
22769
+ }), style: {
22734
22770
  fill: SLATE_500,
22735
- } }), jsx(Tooltip$1, { cursor: { fill: SLATE_200 }, ...(displayXAxis
22771
+ }, height: displayXAxis ? undefined : 1 }), jsx(Tooltip$1, { cursor: { fill: SLATE_200 }, ...(displayXAxis
22736
22772
  ? {}
22737
22773
  : {
22738
22774
  position: { y: -62 },
22739
- }) }), jsx(Bar, { dataKey: featureName, fill: brandColor, activeBar: jsx(Rectangle, { fill: brandColor }) })] }));
22775
+ }), wrapperStyle: { zIndex: 1000 }, content: ({ payload, label }) => {
22776
+ var _a, _b;
22777
+ const usage = (_b = (_a = payload === null || payload === void 0 ? void 0 : payload[0]) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.toLocaleString();
22778
+ return (jsxs("div", { className: "bunny-flex bunny-flex-col bunny-rounded bunny-bg-white bunny-p-2 bunny-shadow bunny-gap-1", children: [jsx("div", { className: "bunny-text-left bunny-text-sm bunny-font-medium", children: label }), jsxs("div", { className: "bunny-text-left bunny-flex bunny-items-center bunny-text-sm", children: [jsxs("span", { children: [featureName, ": "] }), jsxs("span", { children: ["\u00A0", usage] })] })] }));
22779
+ } }), jsx(Bar, { activeBar: jsx(Rectangle, { fill: BLUE_300 }), dataKey: featureName, fill: BLUE_300 })] }));
22740
22780
  };
22741
22781
  const StyledBarChart = defaultStyled(BarChart) `
22742
22782
  .recharts-surface {
22743
22783
  overflow: visible;
22784
+ outline: none;
22785
+ }
22786
+ `;
22787
+ const StyledAreaChart = defaultStyled(AreaChart) `
22788
+ .recharts-surface {
22789
+ overflow: visible;
22790
+ outline: none;
22744
22791
  }
22745
22792
  `;
22746
22793
 
@@ -23219,7 +23266,7 @@ const SubscriptionCardDesktopRow = ({ charge, chargeIndex, subscription, }) => {
23219
23266
  return (jsxs("div", { className: "bunny-contents", children: [(isRampFirstRow || !isRamp) && (jsx(SubscriptionsListCell, { gridColumn: isRamp ? '1/-1' : '1', children: jsx("div", { className: `bunny-flex bunny-items-center bunny-gap-2 ${isDiscount ? 'bunny-pl-4' : ''}`, children: jsx("div", { children: isRampFirstRow || (!isRamp && !dontShowChargeName) ? charge.name : '' }) }) })), jsx(SubscriptionsListCell, { gridColumn: 2, children: jsx("div", { children: chargePeriod }) }), jsx(SubscriptionsListCell, { right: true, children: charge.kind === QuoteChangeKind.DISCOUNT
23220
23267
  ? ''
23221
23268
  : charge.chargeType === ChargeType.USAGE
23222
- ? data && jsx(FeatureUsageGraph, { charge: charge, featureUsage: data })
23269
+ ? data && jsx(FeatureUsageGraph, { charge: charge, featureUsage: data, useAreaChart: true })
23223
23270
  : charge.isAmendment
23224
23271
  ? `+${(_b = charge.quantity) === null || _b === void 0 ? void 0 : _b.toLocaleString()}`
23225
23272
  : (_c = charge.quantity) === null || _c === void 0 ? void 0 : _c.toLocaleString() }), jsx(SubscriptionsListCell, { right: true, children: jsx(SubscriptionChargeUnitPrice, { charge: charge, currencyId: subscription.currencyId }) }), jsx(SubscriptionsListCell, { right: true, children: jsx(SubscriptionChargeTotal, { charge: charge, subscription: subscription }) })] }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunnyapp/components",
3
- "version": "1.6.0-beta.8",
3
+ "version": "1.6.0-beta.9",
4
4
  "description": "Components from the Bunny portal to embed Bunny UI functionality into your application.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -65,7 +65,7 @@
65
65
  "rollup-plugin-peer-deps-external": "^2.2.4",
66
66
  "rollup-plugin-postcss": "^4.0.2",
67
67
  "storybook": "^8.6.14",
68
- "tailwindcss": "^4.1.17",
68
+ "tailwindcss": "^3.4.18",
69
69
  "typescript": "^5.9.3",
70
70
  "vite": "^6.4.1"
71
71
  },
@@ -86,13 +86,13 @@
86
86
  "graphql-request": "^6.1.0",
87
87
  "interweave": "^13.1.0",
88
88
  "less": "^4.2.0",
89
+ "rimraf": "^6.1.0",
89
90
  "lodash-es": "^4.17.21",
90
91
  "pluralize": "^8.0.0",
91
92
  "react": "^18.3.1",
92
93
  "react-dom": "^18.3.1",
93
94
  "recharts": "^2.15.0",
94
95
  "recoil": "^0.7.7",
95
- "rimraf": "^6.1.0",
96
96
  "styled-components": "^6.1.13"
97
97
  },
98
98
  "msw": {