@servicetitan/marketing-ui 5.9.0 → 5.11.0
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/components/ads/ads-stat.js +21 -10
- package/dist/components/ads/ads-stat.js.map +1 -1
- package/dist/components/charts/funnel-chart/components/funnel-chart.js +118 -6
- package/dist/components/charts/funnel-chart/components/funnel-chart.js.map +1 -1
- package/dist/components/charts/funnel-chart/components/funnel-chart.module.less.d.ts +9 -0
- package/dist/components/charts/funnel-chart/components/funnel-svg.js +62 -12
- package/dist/components/charts/funnel-chart/components/funnel-svg.js.map +1 -1
- package/dist/components/charts/funnel-chart/index.js +1 -0
- package/dist/components/charts/funnel-chart/index.js.map +1 -1
- package/dist/components/charts/funnel-chart/utils/const.js +1 -0
- package/dist/components/charts/funnel-chart/utils/const.js.map +1 -1
- package/dist/components/charts/funnel-chart/utils/interface.js +2 -1
- package/dist/components/charts/funnel-chart/utils/interface.js.map +1 -1
- package/dist/components/charts/line-chart/components/body.js +105 -16
- package/dist/components/charts/line-chart/components/body.js.map +1 -1
- package/dist/components/charts/line-chart/components/body.module.less.d.ts +4 -0
- package/dist/components/charts/line-chart/components/container.js +12 -4
- package/dist/components/charts/line-chart/components/container.js.map +1 -1
- package/dist/components/charts/line-chart/components/hover-popover.js +56 -13
- package/dist/components/charts/line-chart/components/hover-popover.js.map +1 -1
- package/dist/components/charts/line-chart/components/hover-popover.module.less.d.ts +5 -0
- package/dist/components/charts/line-chart/components/sidebar.js +35 -5
- package/dist/components/charts/line-chart/components/sidebar.js.map +1 -1
- package/dist/components/charts/line-chart/components/sidebar.module.less.d.ts +13 -0
- package/dist/components/charts/line-chart/components/stuff.js +73 -32
- package/dist/components/charts/line-chart/components/stuff.js.map +1 -1
- package/dist/components/charts/line-chart/components/stuff.module.less.d.ts +6 -0
- package/dist/components/charts/line-chart/components/svg-bars.js +58 -26
- package/dist/components/charts/line-chart/components/svg-bars.js.map +1 -1
- package/dist/components/charts/line-chart/components/svg-body.js +52 -11
- package/dist/components/charts/line-chart/components/svg-body.js.map +1 -1
- package/dist/components/charts/line-chart/components/svg-lines.js +46 -27
- package/dist/components/charts/line-chart/components/svg-lines.js.map +1 -1
- package/dist/components/charts/line-chart/components/svg.module.less.d.ts +5 -0
- package/dist/components/charts/line-chart/index.js +1 -0
- package/dist/components/charts/line-chart/index.js.map +1 -1
- package/dist/components/charts/line-chart/stores/line-chart.store.js +98 -137
- package/dist/components/charts/line-chart/stores/line-chart.store.js.map +1 -1
- package/dist/components/charts/line-chart/stores/svg.store.js +66 -108
- package/dist/components/charts/line-chart/stores/svg.store.js.map +1 -1
- package/dist/components/charts/line-chart/utils/const.js +8 -7
- package/dist/components/charts/line-chart/utils/const.js.map +1 -1
- package/dist/components/charts/line-chart/utils/formatters.js +13 -11
- package/dist/components/charts/line-chart/utils/formatters.js.map +1 -1
- package/dist/components/charts/line-chart/utils/interfaces.js +2 -1
- package/dist/components/charts/line-chart/utils/interfaces.js.map +1 -1
- package/dist/components/charts/line-chart/utils/internal-interfaces.js +2 -1
- package/dist/components/charts/line-chart/utils/internal-interfaces.js.map +1 -1
- package/dist/components/charts/line-chart/utils/key.js +2 -1
- package/dist/components/charts/line-chart/utils/key.js.map +1 -1
- package/dist/components/charts/line-chart/utils/labels.js +50 -46
- package/dist/components/charts/line-chart/utils/labels.js.map +1 -1
- package/dist/components/charts/pie-chart/components/pie-chart.js +60 -6
- package/dist/components/charts/pie-chart/components/pie-chart.js.map +1 -1
- package/dist/components/charts/pie-chart/components/pie-chart.module.less.d.ts +3 -0
- package/dist/components/charts/pie-chart/components/pie.js +176 -39
- package/dist/components/charts/pie-chart/components/pie.js.map +1 -1
- package/dist/components/charts/pie-chart/index.js +2 -0
- package/dist/components/charts/pie-chart/index.js.map +1 -1
- package/dist/components/charts/pie-chart/utils/const.js +55 -39
- package/dist/components/charts/pie-chart/utils/const.js.map +1 -1
- package/dist/components/charts/pie-chart/utils/interface.js +2 -1
- package/dist/components/charts/pie-chart/utils/interface.js.map +1 -1
- package/dist/components/image-cropper/image-cropper.js +74 -88
- package/dist/components/image-cropper/image-cropper.js.map +1 -1
- package/dist/components/stat/stat-card.js +68 -22
- package/dist/components/stat/stat-card.js.map +1 -1
- package/dist/components/stat/stat-card.module.less.d.ts +5 -0
- package/dist/components/stat/stat-extended-card.js +76 -4
- package/dist/components/stat/stat-extended-card.js.map +1 -1
- package/dist/components/ui/action-button/action-button.js +33 -7
- package/dist/components/ui/action-button/action-button.js.map +1 -1
- package/dist/components/ui/action-button/action-button.module.less.d.ts +9 -0
- package/dist/components/ui/action-button/index.js +1 -0
- package/dist/components/ui/action-button/index.js.map +1 -1
- package/dist/components/ui/centered-spinner/centered-spinner.js +20 -2
- package/dist/components/ui/centered-spinner/centered-spinner.js.map +1 -1
- package/dist/components/ui/date-range-picker/date-range-picker.js +71 -35
- package/dist/components/ui/date-range-picker/date-range-picker.js.map +1 -1
- package/dist/components/ui/date-range-picker/date-range-picker.module.less.d.ts +4 -0
- package/dist/components/ui/disabled-button.js +12 -3
- package/dist/components/ui/disabled-button.js.map +1 -1
- package/dist/components/ui/label-with-hint/label-with-hint.js +23 -1
- package/dist/components/ui/label-with-hint/label-with-hint.js.map +1 -1
- package/dist/components/ui/line-text/index.js +1 -0
- package/dist/components/ui/line-text/index.js.map +1 -1
- package/dist/components/ui/line-text/line-text.js +71 -12
- package/dist/components/ui/line-text/line-text.js.map +1 -1
- package/dist/components/ui/line-text/line-text.module.less.d.ts +6 -0
- package/dist/components/ui/title-popover/index.js +1 -0
- package/dist/components/ui/title-popover/index.js.map +1 -1
- package/dist/components/ui/title-popover/title-popover.js +78 -69
- package/dist/components/ui/title-popover/title-popover.js.map +1 -1
- package/dist/components/ui/title-popover/title-popover.module.less.d.ts +3 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/ads-texts.js +2 -1
- package/dist/utils/ads-texts.js.map +1 -1
- package/dist/utils/date/date-range-picker-options.js +90 -68
- package/dist/utils/date/date-range-picker-options.js.map +1 -1
- package/dist/utils/date/date-range-picker-state.js +42 -43
- package/dist/utils/date/date-range-picker-state.js.map +1 -1
- package/dist/utils/date/date-tenant.js +4 -6
- package/dist/utils/date/date-tenant.js.map +1 -1
- package/dist/utils/date/date.js +5 -9
- package/dist/utils/date/date.js.map +1 -1
- package/dist/utils/date/index.js +1 -0
- package/dist/utils/date/index.js.map +1 -1
- package/dist/utils/format-big-numbers.js +11 -6
- package/dist/utils/format-big-numbers.js.map +1 -1
- package/dist/utils/formatters.js +8 -7
- package/dist/utils/formatters.js.map +1 -1
- package/dist/utils/helpers.js +9 -12
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/marketing-parner-handlers.js +9 -12
- package/dist/utils/marketing-parner-handlers.js.map +1 -1
- package/dist/utils/string-case.js +1 -0
- package/dist/utils/string-case.js.map +1 -1
- package/dist/utils/use-client-rect.js +19 -19
- package/dist/utils/use-client-rect.js.map +1 -1
- package/dist/utils/use-target-range-store.js +7 -6
- package/dist/utils/use-target-range-store.js.map +1 -1
- package/package.json +11 -11
- package/dist/components/charts/funnel-chart/funnel-chart.stories.js +0 -76
- package/dist/components/charts/funnel-chart/funnel-chart.stories.js.map +0 -1
- package/dist/components/charts/line-chart/line-chart.stories.js +0 -225
- package/dist/components/charts/line-chart/line-chart.stories.js.map +0 -1
- package/dist/components/charts/pie-chart/pie-chart.stories.js +0 -22
- package/dist/components/charts/pie-chart/pie-chart.stories.js.map +0 -1
- package/dist/components/image-cropper/image-cropper.stories.js +0 -39
- package/dist/components/image-cropper/image-cropper.stories.js.map +0 -1
- package/dist/components/stat/stat-cards.stories.js +0 -16
- package/dist/components/stat/stat-cards.stories.js.map +0 -1
- package/dist/components/stat/stat-extended-card.stories.js +0 -12
- package/dist/components/stat/stat-extended-card.stories.js.map +0 -1
- package/dist/components/ui/action-button/action-button.stories.js +0 -11
- package/dist/components/ui/action-button/action-button.stories.js.map +0 -1
- package/dist/components/ui/centered-spinner/centered-spinner.stories.js +0 -12
- package/dist/components/ui/centered-spinner/centered-spinner.stories.js.map +0 -1
- package/dist/components/ui/date-range-picker/date-range-picker.stories.js +0 -18
- package/dist/components/ui/date-range-picker/date-range-picker.stories.js.map +0 -1
- package/dist/components/ui/label-with-hint/label-with-hint.stories.js +0 -12
- package/dist/components/ui/label-with-hint/label-with-hint.stories.js.map +0 -1
- package/dist/components/ui/line-text/line-text-body.stories.js +0 -11
- package/dist/components/ui/line-text/line-text-body.stories.js.map +0 -1
- package/dist/components/ui/line-text/line-text-head.stories.js +0 -11
- package/dist/components/ui/line-text/line-text-head.stories.js.map +0 -1
- package/dist/components/ui/title-popover/title-popover.stories.js +0 -17
- package/dist/components/ui/title-popover/title-popover.stories.js.map +0 -1
- package/dist/utils/__tests__/format-big-numbers.test.js +0 -16
- package/dist/utils/__tests__/format-big-numbers.test.js.map +0 -1
- package/dist/utils/__tests__/formatters.test.js +0 -45
- package/dist/utils/__tests__/formatters.test.js.map +0 -1
- package/dist/utils/__tests__/helpers.test.js +0 -31
- package/dist/utils/__tests__/helpers.test.js.map +0 -1
- package/dist/utils/__tests__/string-case.test.js +0 -20
- package/dist/utils/__tests__/string-case.test.js.map +0 -1
- package/dist/utils/date/__mocks__/date-mock.js +0 -19
- package/dist/utils/date/__mocks__/date-mock.js.map +0 -1
- package/dist/utils/date/__tests__/date-range-picker.test.js +0 -93
- package/dist/utils/date/__tests__/date-range-picker.test.js.map +0 -1
- package/dist/utils/date/__tests__/date-tenant.test.js +0 -29
- package/dist/utils/date/__tests__/date-tenant.test.js.map +0 -1
|
@@ -3,16 +3,27 @@ import { StatCard } from '../stat/stat-card';
|
|
|
3
3
|
import { StatExtendedCard } from '../stat/stat-extended-card';
|
|
4
4
|
import { adsStatDescriptions } from '../../utils/ads-texts';
|
|
5
5
|
import { camelCaseToTitleCase } from '../../utils/string-case';
|
|
6
|
-
export const AdsPerformanceStatCard = props
|
|
7
|
-
var
|
|
8
|
-
const titleText = (
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
export const AdsPerformanceStatCard = (props)=>{
|
|
7
|
+
var _props_title;
|
|
8
|
+
const titleText = (_props_title = props.title) !== null && _props_title !== void 0 ? _props_title : camelCaseToTitleCase(props.stat);
|
|
9
|
+
var _props_description;
|
|
10
|
+
const hintText = (_props_description = props.description) !== null && _props_description !== void 0 ? _props_description : adsStatDescriptions[props.stat];
|
|
11
|
+
return /*#__PURE__*/ _jsx(StatCard, {
|
|
12
|
+
...props,
|
|
13
|
+
title: titleText,
|
|
14
|
+
description: hintText
|
|
15
|
+
});
|
|
11
16
|
};
|
|
12
|
-
export const AdsPerformanceStatExtendedCard = props
|
|
13
|
-
var
|
|
14
|
-
const titleText = (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
export const AdsPerformanceStatExtendedCard = (props)=>{
|
|
18
|
+
var _props_title;
|
|
19
|
+
const titleText = (_props_title = props.title) !== null && _props_title !== void 0 ? _props_title : camelCaseToTitleCase(props.stat);
|
|
20
|
+
var _props_description;
|
|
21
|
+
const hintText = (_props_description = props.description) !== null && _props_description !== void 0 ? _props_description : adsStatDescriptions[props.stat];
|
|
22
|
+
return /*#__PURE__*/ _jsx(StatExtendedCard, {
|
|
23
|
+
...props,
|
|
24
|
+
title: titleText,
|
|
25
|
+
description: hintText
|
|
26
|
+
});
|
|
17
27
|
};
|
|
28
|
+
|
|
18
29
|
//# sourceMappingURL=ads-stat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ads/ads-stat.tsx"],"sourcesContent":["import { FC } from 'react';\nimport { StatCard, StatCardProps } from '../stat/stat-card';\nimport { StatExtendedCard, StatExtendedCardProps } from '../stat/stat-extended-card';\nimport { adsStatDescriptions, AdsStatType } from '../../utils/ads-texts';\nimport { camelCaseToTitleCase } from '../../utils/string-case';\n\nexport interface AdsPerformanceStatProps extends Omit<StatCardProps, 'title'> {\n stat: AdsStatType;\n title?: string;\n}\n\nexport const AdsPerformanceStatCard: FC<AdsPerformanceStatProps> = props => {\n const titleText = props.title ?? camelCaseToTitleCase(props.stat);\n const hintText = props.description ?? adsStatDescriptions[props.stat];\n\n return <StatCard {...props} title={titleText} description={hintText} />;\n};\n\nexport interface AdsPerformanceStatExtendedProps extends Omit<StatExtendedCardProps, 'title'> {\n stat: AdsStatType;\n title?: string;\n title2: string;\n}\n\nexport const AdsPerformanceStatExtendedCard: FC<AdsPerformanceStatExtendedProps> = props => {\n const titleText = props.title ?? camelCaseToTitleCase(props.stat);\n const hintText = props.description ?? adsStatDescriptions[props.stat];\n\n return <StatExtendedCard {...props} title={titleText} description={hintText} />;\n};\n"],"names":["StatCard","StatExtendedCard","adsStatDescriptions","camelCaseToTitleCase","AdsPerformanceStatCard","props","titleText","title","stat","hintText","description","AdsPerformanceStatExtendedCard"],"mappings":";AACA,SAASA,QAAQ,QAAuB,oBAAoB;AAC5D,SAASC,gBAAgB,QAA+B,6BAA6B;AACrF,SAASC,mBAAmB,QAAqB,wBAAwB;AACzE,SAASC,oBAAoB,QAAQ,0BAA0B;AAO/D,OAAO,MAAMC,yBAAsDC,CAAAA;QAC7CA;IAAlB,MAAMC,YAAYD,CAAAA,eAAAA,MAAME,KAAK,cAAXF,0BAAAA,eAAeF,qBAAqBE,MAAMG,IAAI;QAC/CH;IAAjB,MAAMI,WAAWJ,CAAAA,qBAAAA,MAAMK,WAAW,cAAjBL,gCAAAA,qBAAqBH,mBAAmB,CAACG,MAAMG,IAAI,CAAC;IAErE,qBAAO,KAACR;QAAU,GAAGK,KAAK;QAAEE,OAAOD;QAAWI,aAAaD;;AAC/D,EAAE;AAQF,OAAO,MAAME,iCAAsEN,CAAAA;QAC7DA;IAAlB,MAAMC,YAAYD,CAAAA,eAAAA,MAAME,KAAK,cAAXF,0BAAAA,eAAeF,qBAAqBE,MAAMG,IAAI;QAC/CH;IAAjB,MAAMI,WAAWJ,CAAAA,qBAAAA,MAAMK,WAAW,cAAjBL,gCAAAA,qBAAqBH,mBAAmB,CAACG,MAAMG,IAAI,CAAC;IAErE,qBAAO,KAACP;QAAkB,GAAGI,KAAK;QAAEE,OAAOD;QAAWI,aAAaD;;AACvE,EAAE"}
|
|
@@ -1,18 +1,130 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useState } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import { BodyText, Eyebrow, Headline, Icon, Mask, Popover, Stack, StatusLight, Tooltip
|
|
4
|
+
import { BodyText, Eyebrow, Headline, Icon, Mask, Popover, Stack, StatusLight, Tooltip } from '@servicetitan/design-system';
|
|
5
5
|
import { tokens } from '@servicetitan/tokens/core';
|
|
6
6
|
import { formatValue } from '../../../../utils/formatters';
|
|
7
7
|
import { StatDiff } from '../../../stat/stat-card';
|
|
8
8
|
import { defaultBottomSideLength, defaultTopSideLength } from '../utils/const';
|
|
9
9
|
import { FunnelPyramidSvg } from './funnel-svg';
|
|
10
10
|
import * as Styles from './funnel-chart.module.less';
|
|
11
|
-
export const FunnelChart = ({ sections, format, topSideLength = defaultTopSideLength, bottomSideLength = defaultBottomSideLength, popoverContent: PopoverContent, loading, className
|
|
11
|
+
export const FunnelChart = ({ sections, format, topSideLength = defaultTopSideLength, bottomSideLength = defaultBottomSideLength, popoverContent: PopoverContent, loading, className })=>{
|
|
12
12
|
const [popoverShown, setPopoverShown] = useState(undefined);
|
|
13
|
-
const colors = useMemo(()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const colors = useMemo(()=>sections.map((s)=>s.color), [
|
|
14
|
+
sections
|
|
15
|
+
]);
|
|
16
|
+
const hidePopover = ()=>setPopoverShown(undefined);
|
|
17
|
+
const pyramidTextsStyles = useMemo(()=>({
|
|
18
|
+
left: `${100 - topSideLength}%`
|
|
19
|
+
}), [
|
|
20
|
+
topSideLength
|
|
21
|
+
]);
|
|
22
|
+
return /*#__PURE__*/ _jsxs(Mask, {
|
|
23
|
+
className: classNames('h-100 bg-white border border-radius-2 p-3 of-hidden position-relative', className),
|
|
24
|
+
active: !!loading,
|
|
25
|
+
children: [
|
|
26
|
+
/*#__PURE__*/ _jsx("div", {
|
|
27
|
+
className: Styles.pyramidWrapper,
|
|
28
|
+
children: /*#__PURE__*/ _jsx(FunnelPyramidSvg, {
|
|
29
|
+
colors: colors,
|
|
30
|
+
topSideLength: topSideLength,
|
|
31
|
+
bottomSideLength: bottomSideLength
|
|
32
|
+
})
|
|
33
|
+
}),
|
|
34
|
+
/*#__PURE__*/ _jsx("div", {
|
|
35
|
+
className: classNames('d-f flex-column justify-content-around', Styles.pyramidBoxRight),
|
|
36
|
+
style: pyramidTextsStyles,
|
|
37
|
+
children: sections.map(({ id, title, value, color, prev, textClass, data }, ind)=>/*#__PURE__*/ _jsx(Stack, {
|
|
38
|
+
className: Styles.flex1,
|
|
39
|
+
justifyContent: "center",
|
|
40
|
+
alignItems: "center",
|
|
41
|
+
onMouseEnter: ()=>setPopoverShown(id),
|
|
42
|
+
onMouseLeave: hidePopover,
|
|
43
|
+
children: /*#__PURE__*/ _jsxs(Popover, {
|
|
44
|
+
className: "of-hidden",
|
|
45
|
+
trigger: /*#__PURE__*/ _jsx(Headline, {
|
|
46
|
+
size: "small",
|
|
47
|
+
className: classNames('m-x-2 m-b-0-i', textClass),
|
|
48
|
+
"data-cy": `marketing-funnel-section-${id}-value`,
|
|
49
|
+
children: formatValue(value, format)
|
|
50
|
+
}),
|
|
51
|
+
open: popoverShown === id,
|
|
52
|
+
direction: ind === 0 ? 'lt' : 'lb',
|
|
53
|
+
padding: "s",
|
|
54
|
+
width: "auto",
|
|
55
|
+
portal: true,
|
|
56
|
+
children: [
|
|
57
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
58
|
+
alignItems: "center",
|
|
59
|
+
justifyContent: "flex-start",
|
|
60
|
+
"data-cy": `marketing-funnel-popover-${id}-content`,
|
|
61
|
+
children: [
|
|
62
|
+
/*#__PURE__*/ _jsx(StatusLight, {
|
|
63
|
+
color: color
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ _jsx(BodyText, {
|
|
66
|
+
bold: true,
|
|
67
|
+
className: "m-r-half",
|
|
68
|
+
children: formatValue(value, format)
|
|
69
|
+
}),
|
|
70
|
+
/*#__PURE__*/ _jsx(BodyText, {
|
|
71
|
+
bold: true,
|
|
72
|
+
className: "m-r-1",
|
|
73
|
+
children: title
|
|
74
|
+
}),
|
|
75
|
+
/*#__PURE__*/ _jsx(StatDiff, {
|
|
76
|
+
value: value,
|
|
77
|
+
prev: prev,
|
|
78
|
+
size: "xsmall",
|
|
79
|
+
format: format
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
}),
|
|
83
|
+
!!PopoverContent && /*#__PURE__*/ _jsx(PopoverContent, {
|
|
84
|
+
id: id,
|
|
85
|
+
value: value,
|
|
86
|
+
text: formatValue(value, format),
|
|
87
|
+
data: data
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
})
|
|
91
|
+
}, title))
|
|
92
|
+
}),
|
|
93
|
+
/*#__PURE__*/ _jsx(Stack, {
|
|
94
|
+
className: Styles.pyramidBoxLeft,
|
|
95
|
+
direction: "column",
|
|
96
|
+
children: sections.map((s)=>/*#__PURE__*/ _jsxs(Stack, {
|
|
97
|
+
className: Styles.flex1,
|
|
98
|
+
justifyContent: "flex-start",
|
|
99
|
+
alignItems: "flex-end",
|
|
100
|
+
children: [
|
|
101
|
+
/*#__PURE__*/ _jsx(Eyebrow, {
|
|
102
|
+
size: "small",
|
|
103
|
+
className: classNames(Styles.statTitle, 'm-r-half'),
|
|
104
|
+
children: s.title
|
|
105
|
+
}),
|
|
106
|
+
/*#__PURE__*/ _jsx(Tooltip, {
|
|
107
|
+
direction: "t",
|
|
108
|
+
portal: true,
|
|
109
|
+
text: s.description,
|
|
110
|
+
children: /*#__PURE__*/ _jsx(Icon, {
|
|
111
|
+
name: "info",
|
|
112
|
+
className: "m-r-1",
|
|
113
|
+
size: "14px",
|
|
114
|
+
color: tokens.colorNeutral90
|
|
115
|
+
})
|
|
116
|
+
}),
|
|
117
|
+
/*#__PURE__*/ _jsx(StatDiff, {
|
|
118
|
+
value: s.value,
|
|
119
|
+
prev: s.prev,
|
|
120
|
+
size: "xsmall",
|
|
121
|
+
format: format
|
|
122
|
+
})
|
|
123
|
+
]
|
|
124
|
+
}, s.id))
|
|
125
|
+
})
|
|
126
|
+
]
|
|
127
|
+
});
|
|
17
128
|
};
|
|
129
|
+
|
|
18
130
|
//# sourceMappingURL=funnel-chart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/charts/funnel-chart/components/funnel-chart.tsx"],"sourcesContent":["import { useMemo, useState, FC } from 'react';\nimport classNames from 'classnames';\nimport {\n BodyText,\n Eyebrow,\n Headline,\n Icon,\n Mask,\n Popover,\n Stack,\n StatusLight,\n Tooltip,\n} from '@servicetitan/design-system';\nimport { tokens } from '@servicetitan/tokens/core';\nimport { formatValue } from '../../../../utils/formatters';\nimport { StatDiff } from '../../../stat/stat-card';\nimport { FunnelChartProps } from '../utils/interface';\nimport { defaultBottomSideLength, defaultTopSideLength } from '../utils/const';\nimport { FunnelPyramidSvg } from './funnel-svg';\nimport * as Styles from './funnel-chart.module.less';\n\nexport const FunnelChart: FC<FunnelChartProps> = ({\n sections,\n format,\n topSideLength = defaultTopSideLength,\n bottomSideLength = defaultBottomSideLength,\n popoverContent: PopoverContent,\n loading,\n className,\n}) => {\n const [popoverShown, setPopoverShown] = useState<number | undefined>(undefined);\n\n const colors = useMemo(() => sections.map(s => s.color), [sections]);\n const hidePopover = () => setPopoverShown(undefined);\n const pyramidTextsStyles = useMemo(\n () => ({ left: `${100 - topSideLength}%` }),\n [topSideLength]\n );\n\n return (\n <Mask\n className={classNames(\n 'h-100 bg-white border border-radius-2 p-3 of-hidden position-relative',\n className\n )}\n active={!!loading}\n >\n <div className={Styles.pyramidWrapper}>\n <FunnelPyramidSvg\n colors={colors}\n topSideLength={topSideLength}\n bottomSideLength={bottomSideLength}\n />\n </div>\n\n <div\n className={classNames(\n 'd-f flex-column justify-content-around',\n Styles.pyramidBoxRight\n )}\n style={pyramidTextsStyles}\n >\n {sections.map(({ id, title, value, color, prev, textClass, data }, ind) => (\n <Stack\n key={title}\n className={Styles.flex1}\n justifyContent=\"center\"\n alignItems=\"center\"\n onMouseEnter={() => setPopoverShown(id)}\n onMouseLeave={hidePopover}\n >\n <Popover\n className=\"of-hidden\"\n trigger={\n <Headline\n size=\"small\"\n className={classNames('m-x-2 m-b-0-i', textClass)}\n data-cy={`marketing-funnel-section-${id}-value`}\n >\n {formatValue(value, format)}\n </Headline>\n }\n open={popoverShown === id}\n direction={ind === 0 ? 'lt' : 'lb'}\n padding=\"s\"\n width=\"auto\"\n portal\n >\n <Stack\n alignItems=\"center\"\n justifyContent=\"flex-start\"\n data-cy={`marketing-funnel-popover-${id}-content`}\n >\n <StatusLight color={color} />\n <BodyText bold className=\"m-r-half\">\n {formatValue(value, format)}\n </BodyText>\n <BodyText bold className=\"m-r-1\">\n {title}\n </BodyText>\n <StatDiff value={value} prev={prev} size=\"xsmall\" format={format} />\n </Stack>\n\n {!!PopoverContent && (\n <PopoverContent\n id={id}\n value={value}\n text={formatValue(value, format)}\n data={data}\n />\n )}\n </Popover>\n </Stack>\n ))}\n </div>\n <Stack className={Styles.pyramidBoxLeft} direction=\"column\">\n {sections.map(s => (\n <Stack\n key={s.id}\n className={Styles.flex1}\n justifyContent=\"flex-start\"\n alignItems=\"flex-end\"\n >\n <Eyebrow size=\"small\" className={classNames(Styles.statTitle, 'm-r-half')}>\n {s.title}\n </Eyebrow>\n\n <Tooltip direction=\"t\" portal text={s.description}>\n <Icon\n name=\"info\"\n className=\"m-r-1\"\n size=\"14px\"\n color={tokens.colorNeutral90}\n />\n </Tooltip>\n\n <StatDiff value={s.value} prev={s.prev} size=\"xsmall\" format={format} />\n </Stack>\n ))}\n </Stack>\n </Mask>\n );\n};\n"],"names":["useMemo","useState","classNames","BodyText","Eyebrow","Headline","Icon","Mask","Popover","Stack","StatusLight","Tooltip","tokens","formatValue","StatDiff","defaultBottomSideLength","defaultTopSideLength","FunnelPyramidSvg","Styles","FunnelChart","sections","format","topSideLength","bottomSideLength","popoverContent","PopoverContent","loading","className","popoverShown","setPopoverShown","undefined","colors","map","s","color","hidePopover","pyramidTextsStyles","left","active","div","pyramidWrapper","pyramidBoxRight","style","id","title","value","prev","textClass","data","ind","flex1","justifyContent","alignItems","onMouseEnter","onMouseLeave","trigger","size","data-cy","open","direction","padding","width","portal","bold","text","pyramidBoxLeft","statTitle","description","name","colorNeutral90"],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const __esModule: true;
|
|
2
|
+
export const flex1: string;
|
|
3
|
+
export const pyramidBoxLeft: string;
|
|
4
|
+
export const pyramidBoxRight: string;
|
|
5
|
+
export const pyramidLine: string;
|
|
6
|
+
export const pyramidWrapper: string;
|
|
7
|
+
export const statTitle: string;
|
|
8
|
+
export const title: string;
|
|
9
|
+
|
|
@@ -2,9 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { tokens } from '@servicetitan/tokens/core';
|
|
4
4
|
import { defaultBottomSideLength, defaultTopSideLength } from '../utils/const';
|
|
5
|
-
const st = (v)
|
|
6
|
-
export const FunnelPyramidSvg = ({ colors, topSideLength = defaultTopSideLength, bottomSideLength = defaultBottomSideLength
|
|
7
|
-
const sections = useMemo(()
|
|
5
|
+
const st = (v)=>v.toFixed(2);
|
|
6
|
+
export const FunnelPyramidSvg = ({ colors, topSideLength = defaultTopSideLength, bottomSideLength = defaultBottomSideLength })=>{
|
|
7
|
+
const sections = useMemo(()=>{
|
|
8
8
|
if (!colors.length) {
|
|
9
9
|
return [];
|
|
10
10
|
}
|
|
@@ -12,7 +12,7 @@ export const FunnelPyramidSvg = ({ colors, topSideLength = defaultTopSideLength,
|
|
|
12
12
|
const yStep = 100 / len;
|
|
13
13
|
const lStep = (topSideLength - Math.min(bottomSideLength, topSideLength)) / (len * 2);
|
|
14
14
|
const xOffset = 100 - topSideLength;
|
|
15
|
-
return colors.map((color, ind)
|
|
15
|
+
return colors.map((color, ind)=>{
|
|
16
16
|
return {
|
|
17
17
|
yt: yStep * ind,
|
|
18
18
|
yb: ind === len - 1 ? 100 : yStep * (ind + 1),
|
|
@@ -20,15 +20,19 @@ export const FunnelPyramidSvg = ({ colors, topSideLength = defaultTopSideLength,
|
|
|
20
20
|
xtr: 100 - lStep * ind,
|
|
21
21
|
xbr: 100 - lStep * (ind + 1),
|
|
22
22
|
xbl: xOffset + lStep * (ind + 1),
|
|
23
|
-
c: color
|
|
23
|
+
c: color
|
|
24
24
|
};
|
|
25
25
|
});
|
|
26
|
-
}, [
|
|
27
|
-
|
|
26
|
+
}, [
|
|
27
|
+
colors,
|
|
28
|
+
topSideLength,
|
|
29
|
+
bottomSideLength
|
|
30
|
+
]);
|
|
31
|
+
const paths = useMemo(()=>{
|
|
28
32
|
if (!sections.length) {
|
|
29
33
|
return [];
|
|
30
34
|
}
|
|
31
|
-
return sections.map((s, ind)
|
|
35
|
+
return sections.map((s, ind)=>{
|
|
32
36
|
let path = '';
|
|
33
37
|
path += `M${st(s.xtl)},${st(s.yt)} `;
|
|
34
38
|
path += `L${st(s.xtr)},${st(s.yt)} `;
|
|
@@ -38,11 +42,57 @@ export const FunnelPyramidSvg = ({ colors, topSideLength = defaultTopSideLength,
|
|
|
38
42
|
return {
|
|
39
43
|
key: ind.toString(),
|
|
40
44
|
path,
|
|
41
|
-
color: s.c
|
|
45
|
+
color: s.c
|
|
42
46
|
};
|
|
43
47
|
});
|
|
44
|
-
}, [
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
}, [
|
|
49
|
+
sections
|
|
50
|
+
]);
|
|
51
|
+
const lines = useMemo(()=>sections.slice(1).map((s, ind)=>[
|
|
52
|
+
ind,
|
|
53
|
+
s.xtr,
|
|
54
|
+
s.yt
|
|
55
|
+
]), [
|
|
56
|
+
sections
|
|
57
|
+
]);
|
|
58
|
+
return /*#__PURE__*/ _jsxs("svg", {
|
|
59
|
+
width: "100%",
|
|
60
|
+
height: "100%",
|
|
61
|
+
preserveAspectRatio: "none",
|
|
62
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
63
|
+
children: [
|
|
64
|
+
/*#__PURE__*/ _jsx("svg", {
|
|
65
|
+
width: "100%",
|
|
66
|
+
height: "100%",
|
|
67
|
+
x: "0%",
|
|
68
|
+
y: "0",
|
|
69
|
+
viewBox: "0 0 100 100",
|
|
70
|
+
preserveAspectRatio: "none",
|
|
71
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
72
|
+
children: paths.map(({ key, path, color })=>/*#__PURE__*/ _jsx("path", {
|
|
73
|
+
d: path,
|
|
74
|
+
fill: color
|
|
75
|
+
}, key))
|
|
76
|
+
}),
|
|
77
|
+
/*#__PURE__*/ _jsx("svg", {
|
|
78
|
+
width: "100%",
|
|
79
|
+
height: "100%",
|
|
80
|
+
x: "0",
|
|
81
|
+
y: "0",
|
|
82
|
+
viewBox: "0 0 100 100",
|
|
83
|
+
preserveAspectRatio: "none",
|
|
84
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
85
|
+
children: lines.map(([id, x, y])=>/*#__PURE__*/ _jsx("line", {
|
|
86
|
+
x1: "0",
|
|
87
|
+
y1: st(y),
|
|
88
|
+
x2: st(x),
|
|
89
|
+
y2: st(y),
|
|
90
|
+
stroke: tokens.colorNeutral60,
|
|
91
|
+
strokeWidth: 0.5
|
|
92
|
+
}, id))
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
});
|
|
47
96
|
};
|
|
97
|
+
|
|
48
98
|
//# sourceMappingURL=funnel-svg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/charts/funnel-chart/components/funnel-svg.tsx"],"sourcesContent":["import { useMemo, FC } from 'react';\nimport { tokens } from '@servicetitan/tokens/core';\nimport { defaultBottomSideLength, defaultTopSideLength } from '../utils/const';\n\nconst st = (v: number) => v.toFixed(2);\n\nexport interface FunnelPyramidSvgProps {\n colors: string[];\n topSideLength?: number;\n bottomSideLength?: number;\n}\n\nexport const FunnelPyramidSvg: FC<FunnelPyramidSvgProps> = ({\n colors,\n topSideLength = defaultTopSideLength,\n bottomSideLength = defaultBottomSideLength,\n}) => {\n const sections = useMemo(() => {\n if (!colors.length) {\n return [];\n }\n\n const len = colors.length;\n const yStep = 100 / len;\n const lStep = (topSideLength - Math.min(bottomSideLength, topSideLength)) / (len * 2);\n const xOffset = 100 - topSideLength;\n\n return colors.map((color, ind) => {\n return {\n yt: yStep * ind,\n yb: ind === len - 1 ? 100 : yStep * (ind + 1),\n xtl: xOffset + lStep * ind,\n xtr: 100 - lStep * ind,\n xbr: 100 - lStep * (ind + 1),\n xbl: xOffset + lStep * (ind + 1),\n c: color,\n };\n });\n }, [colors, topSideLength, bottomSideLength]);\n\n const paths = useMemo(() => {\n if (!sections.length) {\n return [];\n }\n\n return sections.map((s, ind) => {\n let path = '';\n\n path += `M${st(s.xtl)},${st(s.yt)} `;\n path += `L${st(s.xtr)},${st(s.yt)} `;\n path += `L${st(s.xbr)},${st(s.yb)} `;\n path += `L${st(s.xbl)},${st(s.yb)} `;\n path += 'Z';\n\n return {\n key: ind.toString(),\n path,\n color: s.c,\n };\n });\n }, [sections]);\n\n const lines = useMemo(() => sections.slice(1).map((s, ind) => [ind, s.xtr, s.yt]), [sections]);\n\n return (\n <svg\n width=\"100%\"\n height=\"100%\"\n preserveAspectRatio=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n x=\"0%\"\n y=\"0\"\n viewBox=\"0 0 100 100\"\n preserveAspectRatio=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n {paths.map(({ key, path, color }) => (\n <path key={key} d={path} fill={color} />\n ))}\n </svg>\n <svg\n width=\"100%\"\n height=\"100%\"\n x=\"0\"\n y=\"0\"\n viewBox=\"0 0 100 100\"\n preserveAspectRatio=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n {lines.map(([id, x, y]) => (\n <line\n key={id}\n x1=\"0\"\n y1={st(y)}\n x2={st(x)}\n y2={st(y)}\n stroke={tokens.colorNeutral60}\n strokeWidth={0.5}\n />\n ))}\n </svg>\n </svg>\n );\n};\n"],"names":["useMemo","tokens","defaultBottomSideLength","defaultTopSideLength","st","v","toFixed","FunnelPyramidSvg","colors","topSideLength","bottomSideLength","sections","length","len","yStep","lStep","Math","min","xOffset","map","color","ind","yt","yb","xtl","xtr","xbr","xbl","c","paths","s","path","key","toString","lines","slice","svg","width","height","preserveAspectRatio","xmlns","x","y","viewBox","d","fill","id","line","x1","y1","x2","y2","stroke","colorNeutral60","strokeWidth"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/charts/funnel-chart/index.ts"],"sourcesContent":["export { FunnelChart } from './components/funnel-chart';\nexport * from './utils/interface';\n"],"names":["FunnelChart"],"mappings":"AAAA,SAASA,WAAW,QAAQ,4BAA4B;AACxD,cAAc,oBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/charts/funnel-chart/utils/const.ts"],"sourcesContent":["export const defaultTopSideLength = 66;\nexport const defaultBottomSideLength = 30;\n"],"names":["defaultTopSideLength","defaultBottomSideLength"],"mappings":"AAAA,OAAO,MAAMA,uBAAuB,GAAG;AACvC,OAAO,MAAMC,0BAA0B,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/charts/funnel-chart/utils/interface.ts"],"sourcesContent":["import { FC } from 'react';\nimport { NumberFormatter } from '../../../../utils/formatters';\n\nexport interface FunnelChartSection<T> {\n id: number;\n title: string;\n description: string;\n value: number;\n prev?: number;\n color: string;\n textClass?: string;\n data?: T;\n}\n\nexport type FunnelChartPopoverContentType<T = any> = FC<{\n id: number;\n value: number;\n text: string;\n data?: T;\n}>;\n\nexport interface FunnelChartProps<T = any> {\n sections: FunnelChartSection<T>[];\n format: NumberFormatter;\n popoverContent?: FunnelChartPopoverContentType<T>;\n topSideLength?: number;\n bottomSideLength?: number;\n loading?: boolean;\n className?: string;\n}\n"],"names":[],"mappings":"AAqBA,WAQC"}
|
|
@@ -13,24 +13,113 @@ import { MetricsTitle, XAxisLabels } from './stuff';
|
|
|
13
13
|
import { SvgBody, SvgBodyHover } from './svg-body';
|
|
14
14
|
import { HoverPopover } from './hover-popover';
|
|
15
15
|
import * as Styles from './body.module.less';
|
|
16
|
-
export const Body = provide({
|
|
17
|
-
|
|
16
|
+
export const Body = provide({
|
|
17
|
+
singletons: [
|
|
18
|
+
SvgStore
|
|
19
|
+
]
|
|
20
|
+
})(observer(({ classNameTitle })=>{
|
|
18
21
|
const [{ display, metrics, left, right, periods, resolution, setHoveredIndex }, svgStore] = useDependencies(LineChartStore, SvgStore);
|
|
19
|
-
useEffect(()
|
|
20
|
-
var
|
|
21
|
-
svgStore.init(periods.length, metrics, (
|
|
22
|
-
}, [
|
|
22
|
+
useEffect(()=>{
|
|
23
|
+
var _left_maxValue, _right_maxValue;
|
|
24
|
+
svgStore.init(periods.length, metrics, (_left_maxValue = left === null || left === void 0 ? void 0 : left.maxValue) !== null && _left_maxValue !== void 0 ? _left_maxValue : 0, (_right_maxValue = right === null || right === void 0 ? void 0 : right.maxValue) !== null && _right_maxValue !== void 0 ? _right_maxValue : 0);
|
|
25
|
+
}, [
|
|
26
|
+
svgStore,
|
|
27
|
+
periods,
|
|
28
|
+
metrics,
|
|
29
|
+
left,
|
|
30
|
+
right
|
|
31
|
+
]);
|
|
23
32
|
const [rect, ref] = useClientRect();
|
|
24
|
-
const onBarHover = useCallback((ind)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
const onBarHover = useCallback((ind)=>setHoveredIndex(ind, true), [
|
|
34
|
+
setHoveredIndex
|
|
35
|
+
]);
|
|
36
|
+
const onBarLeave = useCallback((ind)=>setHoveredIndex(ind, false), [
|
|
37
|
+
setHoveredIndex
|
|
38
|
+
]);
|
|
39
|
+
const labels = useMemo(()=>{
|
|
40
|
+
var _rect_width;
|
|
41
|
+
return display.xLabels ? getXLabels(periods, resolution, (_rect_width = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _rect_width !== void 0 ? _rect_width : 0) : [];
|
|
42
|
+
}, [
|
|
43
|
+
display,
|
|
44
|
+
periods,
|
|
45
|
+
resolution,
|
|
46
|
+
rect
|
|
47
|
+
]);
|
|
48
|
+
var _rect_width, _left_width, _right_width;
|
|
49
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
50
|
+
className: "d-f flex-column",
|
|
51
|
+
children: [
|
|
52
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
53
|
+
alignItems: "stretch",
|
|
54
|
+
children: [
|
|
55
|
+
left && /*#__PURE__*/ _jsx(Sidebar, {
|
|
56
|
+
settings: left,
|
|
57
|
+
classNameTitle: classNameTitle
|
|
58
|
+
}),
|
|
59
|
+
/*#__PURE__*/ _jsx(Stack.Item, {
|
|
60
|
+
fill: true,
|
|
61
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
62
|
+
ref: ref,
|
|
63
|
+
className: classNames(Styles.chartWrapper, 'border-bottom', {
|
|
28
64
|
'border-left': !!left && display.yLeft,
|
|
29
|
-
'border-right': !!right && display.yRight
|
|
30
|
-
}),
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
65
|
+
'border-right': !!right && display.yRight
|
|
66
|
+
}),
|
|
67
|
+
children: periods.length ? /*#__PURE__*/ _jsxs(Fragment, {
|
|
68
|
+
children: [
|
|
69
|
+
periods.length !== labels.length && /*#__PURE__*/ _jsx("div", {
|
|
70
|
+
className: Styles.labelBorders,
|
|
71
|
+
children: labels.map(([text, flex], ind)=>[
|
|
72
|
+
flex,
|
|
73
|
+
`${ind}${text}`
|
|
74
|
+
]).map(([flex, key])=>/*#__PURE__*/ _jsx("div", {
|
|
75
|
+
style: {
|
|
76
|
+
flex
|
|
77
|
+
}
|
|
78
|
+
}, key))
|
|
79
|
+
}),
|
|
80
|
+
/*#__PURE__*/ _jsx(SvgBody, {
|
|
81
|
+
horizontalGrid: display.yGrid,
|
|
82
|
+
metrics: metrics
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ _jsx(HoverPopover, {}),
|
|
85
|
+
/*#__PURE__*/ _jsx(SvgBodyHover, {
|
|
86
|
+
onValueHover: onBarHover,
|
|
87
|
+
onValueLeave: onBarLeave
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
}) : /*#__PURE__*/ _jsx(Stack, {
|
|
91
|
+
className: "h-100",
|
|
92
|
+
justifyContent: "center",
|
|
93
|
+
alignItems: "center",
|
|
94
|
+
children: "No Data"
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
}),
|
|
98
|
+
right && /*#__PURE__*/ _jsx(Sidebar, {
|
|
99
|
+
settings: right,
|
|
100
|
+
right: true,
|
|
101
|
+
classNameTitle: classNameTitle
|
|
102
|
+
})
|
|
103
|
+
]
|
|
104
|
+
}),
|
|
105
|
+
display.xLabels && /*#__PURE__*/ _jsx(XAxisLabels, {
|
|
106
|
+
labels: labels,
|
|
107
|
+
width: (_rect_width = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _rect_width !== void 0 ? _rect_width : 0,
|
|
108
|
+
left: (_left_width = left === null || left === void 0 ? void 0 : left.width) !== null && _left_width !== void 0 ? _left_width : 0,
|
|
109
|
+
right: (_right_width = right === null || right === void 0 ? void 0 : right.width) !== null && _right_width !== void 0 ? _right_width : 0,
|
|
110
|
+
labelsMerged: periods.length !== labels.length,
|
|
111
|
+
hasBars: !!metrics.filter((m)=>m.type === 'bar' || m.type === 'stacked-bar' || m.type === 'grouped-bar').length
|
|
112
|
+
}),
|
|
113
|
+
display.metricsTitlePosition === 'bottom' && /*#__PURE__*/ _jsx(Stack, {
|
|
114
|
+
direction: "row",
|
|
115
|
+
justifyContent: "center",
|
|
116
|
+
className: "p-3",
|
|
117
|
+
children: /*#__PURE__*/ _jsx(MetricsTitle, {
|
|
118
|
+
metrics: metrics
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
]
|
|
122
|
+
});
|
|
35
123
|
}));
|
|
124
|
+
|
|
36
125
|
//# sourceMappingURL=body.js.map
|