@servicetitan/marketing-ui 5.9.0 → 5.10.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.
Files changed (163) hide show
  1. package/dist/components/ads/ads-stat.js +21 -10
  2. package/dist/components/ads/ads-stat.js.map +1 -1
  3. package/dist/components/charts/funnel-chart/components/funnel-chart.js +118 -6
  4. package/dist/components/charts/funnel-chart/components/funnel-chart.js.map +1 -1
  5. package/dist/components/charts/funnel-chart/components/funnel-chart.module.less.d.ts +9 -0
  6. package/dist/components/charts/funnel-chart/components/funnel-svg.js +62 -12
  7. package/dist/components/charts/funnel-chart/components/funnel-svg.js.map +1 -1
  8. package/dist/components/charts/funnel-chart/index.js +1 -0
  9. package/dist/components/charts/funnel-chart/index.js.map +1 -1
  10. package/dist/components/charts/funnel-chart/utils/const.js +1 -0
  11. package/dist/components/charts/funnel-chart/utils/const.js.map +1 -1
  12. package/dist/components/charts/funnel-chart/utils/interface.js +2 -1
  13. package/dist/components/charts/funnel-chart/utils/interface.js.map +1 -1
  14. package/dist/components/charts/line-chart/components/body.js +105 -16
  15. package/dist/components/charts/line-chart/components/body.js.map +1 -1
  16. package/dist/components/charts/line-chart/components/body.module.less.d.ts +4 -0
  17. package/dist/components/charts/line-chart/components/container.js +12 -4
  18. package/dist/components/charts/line-chart/components/container.js.map +1 -1
  19. package/dist/components/charts/line-chart/components/hover-popover.js +56 -13
  20. package/dist/components/charts/line-chart/components/hover-popover.js.map +1 -1
  21. package/dist/components/charts/line-chart/components/hover-popover.module.less.d.ts +5 -0
  22. package/dist/components/charts/line-chart/components/sidebar.js +35 -5
  23. package/dist/components/charts/line-chart/components/sidebar.js.map +1 -1
  24. package/dist/components/charts/line-chart/components/sidebar.module.less.d.ts +13 -0
  25. package/dist/components/charts/line-chart/components/stuff.js +73 -32
  26. package/dist/components/charts/line-chart/components/stuff.js.map +1 -1
  27. package/dist/components/charts/line-chart/components/stuff.module.less.d.ts +6 -0
  28. package/dist/components/charts/line-chart/components/svg-bars.js +58 -26
  29. package/dist/components/charts/line-chart/components/svg-bars.js.map +1 -1
  30. package/dist/components/charts/line-chart/components/svg-body.js +52 -11
  31. package/dist/components/charts/line-chart/components/svg-body.js.map +1 -1
  32. package/dist/components/charts/line-chart/components/svg-lines.js +46 -27
  33. package/dist/components/charts/line-chart/components/svg-lines.js.map +1 -1
  34. package/dist/components/charts/line-chart/components/svg.module.less.d.ts +5 -0
  35. package/dist/components/charts/line-chart/index.js +1 -0
  36. package/dist/components/charts/line-chart/index.js.map +1 -1
  37. package/dist/components/charts/line-chart/stores/line-chart.store.js +98 -137
  38. package/dist/components/charts/line-chart/stores/line-chart.store.js.map +1 -1
  39. package/dist/components/charts/line-chart/stores/svg.store.js +66 -108
  40. package/dist/components/charts/line-chart/stores/svg.store.js.map +1 -1
  41. package/dist/components/charts/line-chart/utils/const.js +8 -7
  42. package/dist/components/charts/line-chart/utils/const.js.map +1 -1
  43. package/dist/components/charts/line-chart/utils/formatters.js +13 -11
  44. package/dist/components/charts/line-chart/utils/formatters.js.map +1 -1
  45. package/dist/components/charts/line-chart/utils/interfaces.js +2 -1
  46. package/dist/components/charts/line-chart/utils/interfaces.js.map +1 -1
  47. package/dist/components/charts/line-chart/utils/internal-interfaces.js +2 -1
  48. package/dist/components/charts/line-chart/utils/internal-interfaces.js.map +1 -1
  49. package/dist/components/charts/line-chart/utils/key.js +2 -1
  50. package/dist/components/charts/line-chart/utils/key.js.map +1 -1
  51. package/dist/components/charts/line-chart/utils/labels.js +50 -46
  52. package/dist/components/charts/line-chart/utils/labels.js.map +1 -1
  53. package/dist/components/charts/pie-chart/components/pie-chart.js +60 -6
  54. package/dist/components/charts/pie-chart/components/pie-chart.js.map +1 -1
  55. package/dist/components/charts/pie-chart/components/pie-chart.module.less.d.ts +3 -0
  56. package/dist/components/charts/pie-chart/components/pie.js +176 -39
  57. package/dist/components/charts/pie-chart/components/pie.js.map +1 -1
  58. package/dist/components/charts/pie-chart/index.js +2 -0
  59. package/dist/components/charts/pie-chart/index.js.map +1 -1
  60. package/dist/components/charts/pie-chart/utils/const.js +55 -39
  61. package/dist/components/charts/pie-chart/utils/const.js.map +1 -1
  62. package/dist/components/charts/pie-chart/utils/interface.js +2 -1
  63. package/dist/components/charts/pie-chart/utils/interface.js.map +1 -1
  64. package/dist/components/image-cropper/image-cropper.js +74 -88
  65. package/dist/components/image-cropper/image-cropper.js.map +1 -1
  66. package/dist/components/stat/stat-card.js +68 -22
  67. package/dist/components/stat/stat-card.js.map +1 -1
  68. package/dist/components/stat/stat-card.module.less.d.ts +5 -0
  69. package/dist/components/stat/stat-extended-card.js +76 -4
  70. package/dist/components/stat/stat-extended-card.js.map +1 -1
  71. package/dist/components/ui/action-button/action-button.js +33 -7
  72. package/dist/components/ui/action-button/action-button.js.map +1 -1
  73. package/dist/components/ui/action-button/action-button.module.less.d.ts +9 -0
  74. package/dist/components/ui/action-button/index.js +1 -0
  75. package/dist/components/ui/action-button/index.js.map +1 -1
  76. package/dist/components/ui/centered-spinner/centered-spinner.js +20 -2
  77. package/dist/components/ui/centered-spinner/centered-spinner.js.map +1 -1
  78. package/dist/components/ui/date-range-picker/date-range-picker.js +71 -35
  79. package/dist/components/ui/date-range-picker/date-range-picker.js.map +1 -1
  80. package/dist/components/ui/date-range-picker/date-range-picker.module.less.d.ts +4 -0
  81. package/dist/components/ui/disabled-button.js +12 -3
  82. package/dist/components/ui/disabled-button.js.map +1 -1
  83. package/dist/components/ui/label-with-hint/label-with-hint.js +23 -1
  84. package/dist/components/ui/label-with-hint/label-with-hint.js.map +1 -1
  85. package/dist/components/ui/line-text/index.js +1 -0
  86. package/dist/components/ui/line-text/index.js.map +1 -1
  87. package/dist/components/ui/line-text/line-text.js +71 -12
  88. package/dist/components/ui/line-text/line-text.js.map +1 -1
  89. package/dist/components/ui/line-text/line-text.module.less.d.ts +6 -0
  90. package/dist/components/ui/title-popover/index.js +1 -0
  91. package/dist/components/ui/title-popover/index.js.map +1 -1
  92. package/dist/components/ui/title-popover/title-popover.js +78 -69
  93. package/dist/components/ui/title-popover/title-popover.js.map +1 -1
  94. package/dist/components/ui/title-popover/title-popover.module.less.d.ts +3 -0
  95. package/dist/index.js +3 -1
  96. package/dist/index.js.map +1 -1
  97. package/dist/utils/ads-texts.js +2 -1
  98. package/dist/utils/ads-texts.js.map +1 -1
  99. package/dist/utils/date/date-range-picker-options.js +90 -68
  100. package/dist/utils/date/date-range-picker-options.js.map +1 -1
  101. package/dist/utils/date/date-range-picker-state.js +42 -43
  102. package/dist/utils/date/date-range-picker-state.js.map +1 -1
  103. package/dist/utils/date/date-tenant.js +4 -6
  104. package/dist/utils/date/date-tenant.js.map +1 -1
  105. package/dist/utils/date/date.js +5 -9
  106. package/dist/utils/date/date.js.map +1 -1
  107. package/dist/utils/date/index.js +1 -0
  108. package/dist/utils/date/index.js.map +1 -1
  109. package/dist/utils/format-big-numbers.js +11 -6
  110. package/dist/utils/format-big-numbers.js.map +1 -1
  111. package/dist/utils/formatters.js +8 -7
  112. package/dist/utils/formatters.js.map +1 -1
  113. package/dist/utils/helpers.js +9 -12
  114. package/dist/utils/helpers.js.map +1 -1
  115. package/dist/utils/marketing-parner-handlers.js +9 -12
  116. package/dist/utils/marketing-parner-handlers.js.map +1 -1
  117. package/dist/utils/string-case.js +1 -0
  118. package/dist/utils/string-case.js.map +1 -1
  119. package/dist/utils/use-client-rect.js +19 -19
  120. package/dist/utils/use-client-rect.js.map +1 -1
  121. package/dist/utils/use-target-range-store.js +7 -6
  122. package/dist/utils/use-target-range-store.js.map +1 -1
  123. package/package.json +11 -11
  124. package/dist/components/charts/funnel-chart/funnel-chart.stories.js +0 -76
  125. package/dist/components/charts/funnel-chart/funnel-chart.stories.js.map +0 -1
  126. package/dist/components/charts/line-chart/line-chart.stories.js +0 -225
  127. package/dist/components/charts/line-chart/line-chart.stories.js.map +0 -1
  128. package/dist/components/charts/pie-chart/pie-chart.stories.js +0 -22
  129. package/dist/components/charts/pie-chart/pie-chart.stories.js.map +0 -1
  130. package/dist/components/image-cropper/image-cropper.stories.js +0 -39
  131. package/dist/components/image-cropper/image-cropper.stories.js.map +0 -1
  132. package/dist/components/stat/stat-cards.stories.js +0 -16
  133. package/dist/components/stat/stat-cards.stories.js.map +0 -1
  134. package/dist/components/stat/stat-extended-card.stories.js +0 -12
  135. package/dist/components/stat/stat-extended-card.stories.js.map +0 -1
  136. package/dist/components/ui/action-button/action-button.stories.js +0 -11
  137. package/dist/components/ui/action-button/action-button.stories.js.map +0 -1
  138. package/dist/components/ui/centered-spinner/centered-spinner.stories.js +0 -12
  139. package/dist/components/ui/centered-spinner/centered-spinner.stories.js.map +0 -1
  140. package/dist/components/ui/date-range-picker/date-range-picker.stories.js +0 -18
  141. package/dist/components/ui/date-range-picker/date-range-picker.stories.js.map +0 -1
  142. package/dist/components/ui/label-with-hint/label-with-hint.stories.js +0 -12
  143. package/dist/components/ui/label-with-hint/label-with-hint.stories.js.map +0 -1
  144. package/dist/components/ui/line-text/line-text-body.stories.js +0 -11
  145. package/dist/components/ui/line-text/line-text-body.stories.js.map +0 -1
  146. package/dist/components/ui/line-text/line-text-head.stories.js +0 -11
  147. package/dist/components/ui/line-text/line-text-head.stories.js.map +0 -1
  148. package/dist/components/ui/title-popover/title-popover.stories.js +0 -17
  149. package/dist/components/ui/title-popover/title-popover.stories.js.map +0 -1
  150. package/dist/utils/__tests__/format-big-numbers.test.js +0 -16
  151. package/dist/utils/__tests__/format-big-numbers.test.js.map +0 -1
  152. package/dist/utils/__tests__/formatters.test.js +0 -45
  153. package/dist/utils/__tests__/formatters.test.js.map +0 -1
  154. package/dist/utils/__tests__/helpers.test.js +0 -31
  155. package/dist/utils/__tests__/helpers.test.js.map +0 -1
  156. package/dist/utils/__tests__/string-case.test.js +0 -20
  157. package/dist/utils/__tests__/string-case.test.js.map +0 -1
  158. package/dist/utils/date/__mocks__/date-mock.js +0 -19
  159. package/dist/utils/date/__mocks__/date-mock.js.map +0 -1
  160. package/dist/utils/date/__tests__/date-range-picker.test.js +0 -93
  161. package/dist/utils/date/__tests__/date-range-picker.test.js.map +0 -1
  162. package/dist/utils/date/__tests__/date-tenant.test.js +0 -29
  163. 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 _a, _b;
8
- const titleText = (_a = props.title) !== null && _a !== void 0 ? _a : camelCaseToTitleCase(props.stat);
9
- const hintText = (_b = props.description) !== null && _b !== void 0 ? _b : adsStatDescriptions[props.stat];
10
- return _jsx(StatCard, { ...props, title: titleText, description: hintText });
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 _a, _b;
14
- const titleText = (_a = props.title) !== null && _a !== void 0 ? _a : camelCaseToTitleCase(props.stat);
15
- const hintText = (_b = props.description) !== null && _b !== void 0 ? _b : adsStatDescriptions[props.stat];
16
- return _jsx(StatExtendedCard, { ...props, title: titleText, description: hintText });
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,"file":"ads-stat.js","sourceRoot":"","sources":["../../../src/components/ads/ads-stat.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAiB,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAyB,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAe,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAO/D,MAAM,CAAC,MAAM,sBAAsB,GAAgC,KAAK,CAAC,EAAE;;IACvE,MAAM,SAAS,GAAG,MAAA,KAAK,CAAC,KAAK,mCAAI,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG,MAAA,KAAK,CAAC,WAAW,mCAAI,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEtE,OAAO,KAAC,QAAQ,OAAK,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,GAAI,CAAC;AAC5E,CAAC,CAAC;AAQF,MAAM,CAAC,MAAM,8BAA8B,GAAwC,KAAK,CAAC,EAAE;;IACvF,MAAM,SAAS,GAAG,MAAA,KAAK,CAAC,KAAK,mCAAI,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG,MAAA,KAAK,CAAC,WAAW,mCAAI,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEtE,OAAO,KAAC,gBAAgB,OAAK,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,GAAI,CAAC;AACpF,CAAC,CAAC"}
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, } from '@servicetitan/design-system';
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(() => sections.map(s => s.color), [sections]);
14
- const hidePopover = () => setPopoverShown(undefined);
15
- const pyramidTextsStyles = useMemo(() => ({ left: `${100 - topSideLength}%` }), [topSideLength]);
16
- return (_jsxs(Mask, { className: classNames('h-100 bg-white border border-radius-2 p-3 of-hidden position-relative', className), active: !!loading, children: [_jsx("div", { className: Styles.pyramidWrapper, children: _jsx(FunnelPyramidSvg, { colors: colors, topSideLength: topSideLength, bottomSideLength: bottomSideLength }) }), _jsx("div", { className: classNames('d-f flex-column justify-content-around', Styles.pyramidBoxRight), style: pyramidTextsStyles, children: sections.map(({ id, title, value, color, prev, textClass, data }, ind) => (_jsx(Stack, { className: Styles.flex1, justifyContent: "center", alignItems: "center", onMouseEnter: () => setPopoverShown(id), onMouseLeave: hidePopover, children: _jsxs(Popover, { className: "of-hidden", trigger: _jsx(Headline, { size: "small", className: classNames('m-x-2 m-b-0-i', textClass), "data-cy": `marketing-funnel-section-${id}-value`, children: formatValue(value, format) }), open: popoverShown === id, direction: ind === 0 ? 'lt' : 'lb', padding: "s", width: "auto", portal: true, children: [_jsxs(Stack, { alignItems: "center", justifyContent: "flex-start", "data-cy": `marketing-funnel-popover-${id}-content`, children: [_jsx(StatusLight, { color: color }), _jsx(BodyText, { bold: true, className: "m-r-half", children: formatValue(value, format) }), _jsx(BodyText, { bold: true, className: "m-r-1", children: title }), _jsx(StatDiff, { value: value, prev: prev, size: "xsmall", format: format })] }), !!PopoverContent && (_jsx(PopoverContent, { id: id, value: value, text: formatValue(value, format), data: data }))] }) }, title))) }), _jsx(Stack, { className: Styles.pyramidBoxLeft, direction: "column", children: sections.map(s => (_jsxs(Stack, { className: Styles.flex1, justifyContent: "flex-start", alignItems: "flex-end", children: [_jsx(Eyebrow, { size: "small", className: classNames(Styles.statTitle, 'm-r-half'), children: s.title }), _jsx(Tooltip, { direction: "t", portal: true, text: s.description, children: _jsx(Icon, { name: "info", className: "m-r-1", size: "14px", color: tokens.colorNeutral90 }) }), _jsx(StatDiff, { value: s.value, prev: s.prev, size: "xsmall", format: format })] }, s.id))) })] }));
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,"file":"funnel-chart.js","sourceRoot":"","sources":["../../../../../src/components/charts/funnel-chart/components/funnel-chart.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAM,MAAM,OAAO,CAAC;AAC9C,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EACH,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,KAAK,EACL,WAAW,EACX,OAAO,GACV,MAAM,6BAA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o, 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":";AAAA,SAASA,OAAO,EAAEC,QAAQ,QAAY,QAAQ;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MAAM;gCAACE,MAAM/B,EAAEkC,WAAW;0CAC7C,cAAA,KAAC7D;oCACG8D,MAAK;oCACLzC,WAAU;oCACV6B,MAAK;oCACLtB,OAAOtB,OAAOyD,cAAc;;;0CAIpC,KAACvD;gCAAS+B,OAAOZ,EAAEY,KAAK;gCAAEC,MAAMb,EAAEa,IAAI;gCAAEU,MAAK;gCAASnC,QAAQA;;;uBAlBzDY,EAAEU,EAAE;;;;AAwBjC,EAAE"}
@@ -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) => v.toFixed(2);
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
- }, [colors, topSideLength, bottomSideLength]);
27
- const paths = useMemo(() => {
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
- }, [sections]);
45
- const lines = useMemo(() => sections.slice(1).map((s, ind) => [ind, s.xtr, s.yt]), [sections]);
46
- return (_jsxs("svg", { width: "100%", height: "100%", preserveAspectRatio: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("svg", { width: "100%", height: "100%", x: "0%", y: "0", viewBox: "0 0 100 100", preserveAspectRatio: "none", xmlns: "http://www.w3.org/2000/svg", children: paths.map(({ key, path, color }) => (_jsx("path", { d: path, fill: color }, key))) }), _jsx("svg", { width: "100%", height: "100%", x: "0", y: "0", viewBox: "0 0 100 100", preserveAspectRatio: "none", xmlns: "http://www.w3.org/2000/svg", children: lines.map(([id, x, y]) => (_jsx("line", { x1: "0", y1: st(y), x2: st(x), y2: st(y), stroke: tokens.colorNeutral60, strokeWidth: 0.5 }, id))) })] }));
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,"file":"funnel-svg.js","sourceRoot":"","sources":["../../../../../src/components/charts/funnel-chart/components/funnel-svg.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAM,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE/E,MAAM,EAAE,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAQvC,MAAM,CAAC,MAAM,gBAAgB,GAA8B,CAAC,EACxD,MAAM,EACN,aAAa,GAAG,oBAAoB,EACpC,gBAAgB,GAAG,uBAAuB,GAC7C,EAAE,EA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,EAAC,aAAa,EACrB,mBAAmB,EAAC,MAAM,EAC1B,KAAK,EAAC,4BAA4B,YAEjC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CACjC,eAAgB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,IAAzB,GAAG,CAA0B,CAC3C,CAAC,GACA,EACN,cACI,KAAK,EAAC,MAAM,EACZ,MAAM,EAAC,MAAM,EACb,CAAC,EAAC,GAAG,EACL,CAAC,EAAC,GAAG,EACL,OAAO,EAAC,aAAa,EACrB,mBAAmB,EAAC,MAAM,EAC1B,KAAK,EAAC,4BAA4B,YAEjC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CACvB,eAEI,EAAE,EAAC,GAAG,EACN,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EACT,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EACT,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EACT,MAAM,EAAE,MAAM,CAAC,cAAc,EAC7B,WAAW,EAAE,GAAG,IANX,EAAE,CAOT,CACL,CAAC,GACA,IACJ,CACT,CAAC;AACN,CAAC,CAAC"}
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":";AAAA,SAASA,OAAO,QAAY,QAAQ;AACpC,SAASC,MAAM,QAAQ,4BAA4B;AACnD,SAASC,uBAAuB,EAAEC,oBAAoB,QAAQ,iBAAiB;AAE/E,MAAMC,KAAK,CAACC,IAAcA,EAAEC,OAAO,CAAC;AAQpC,OAAO,MAAMC,mBAA8C,CAAC,EACxDC,MAAM,EACNC,gBAAgBN,oBAAoB,EACpCO,mBAAmBR,uBAAuB,EAC7C;IACG,MAAMS,WAAWX,QAAQ;QACrB,IAAI,CAACQ,OAAOI,MAAM,EAAE;YAChB,OAAO,EAAE;QACb;QAEA,MAAMC,MAAML,OAAOI,MAAM;QACzB,MAAME,QAAQ,MAAMD;QACpB,MAAME,QAAQ,AAACN,CAAAA,gBAAgBO,KAAKC,GAAG,CAACP,kBAAkBD,cAAa,IAAMI,CAAAA,MAAM,CAAA;QACnF,MAAMK,UAAU,MAAMT;QAEtB,OAAOD,OAAOW,GAAG,CAAC,CAACC,OAAOC;YACtB,OAAO;gBACHC,IAAIR,QAAQO;gBACZE,IAAIF,QAAQR,MAAM,IAAI,MAAMC,QAASO,CAAAA,MAAM,CAAA;gBAC3CG,KAAKN,UAAUH,QAAQM;gBACvBI,KAAK,MAAMV,QAAQM;gBACnBK,KAAK,MAAMX,QAASM,CAAAA,MAAM,CAAA;gBAC1BM,KAAKT,UAAUH,QAASM,CAAAA,MAAM,CAAA;gBAC9BO,GAAGR;YACP;QACJ;IACJ,GAAG;QAACZ;QAAQC;QAAeC;KAAiB;IAE5C,MAAMmB,QAAQ7B,QAAQ;QAClB,IAAI,CAACW,SAASC,MAAM,EAAE;YAClB,OAAO,EAAE;QAC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gBACRJ,qBAAoB;gBACpBC,OAAM;0BAELN,MAAMf,GAAG,CAAC,CAAC,CAAC2B,IAAIL,GAAGC,EAAE,iBAClB,KAACK;wBAEGC,IAAG;wBACHC,IAAI7C,GAAGsC;wBACPQ,IAAI9C,GAAGqC;wBACPU,IAAI/C,GAAGsC;wBACPU,QAAQnD,OAAOoD,cAAc;wBAC7BC,aAAa;uBANRR;;;;AAY7B,EAAE"}
@@ -1,3 +1,4 @@
1
1
  export { FunnelChart } from './components/funnel-chart';
2
2
  export * from './utils/interface';
3
+
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/charts/funnel-chart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,cAAc,mBAAmB,CAAC"}
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,3 +1,4 @@
1
1
  export const defaultTopSideLength = 66;
2
2
  export const defaultBottomSideLength = 30;
3
+
3
4
  //# sourceMappingURL=const.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../../src/components/charts/funnel-chart/utils/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC"}
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,2 +1,3 @@
1
- export {};
1
+ export { };
2
+
2
3
  //# sourceMappingURL=interface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../../src/components/charts/funnel-chart/utils/interface.ts"],"names":[],"mappings":""}
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({ singletons: [SvgStore] })(observer(({ classNameTitle }) => {
17
- var _a, _b, _c;
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 _a, _b;
21
- svgStore.init(periods.length, metrics, (_a = left === null || left === void 0 ? void 0 : left.maxValue) !== null && _a !== void 0 ? _a : 0, (_b = right === null || right === void 0 ? void 0 : right.maxValue) !== null && _b !== void 0 ? _b : 0);
22
- }, [svgStore, periods, metrics, left, right]);
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) => setHoveredIndex(ind, true), [setHoveredIndex]);
25
- const onBarLeave = useCallback((ind) => setHoveredIndex(ind, false), [setHoveredIndex]);
26
- const labels = useMemo(() => { var _a; return (display.xLabels ? getXLabels(periods, resolution, (_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0) : []); }, [display, periods, resolution, rect]);
27
- return (_jsxs("div", { className: "d-f flex-column", children: [_jsxs(Stack, { alignItems: "stretch", children: [left && _jsx(Sidebar, { settings: left, classNameTitle: classNameTitle }), _jsx(Stack.Item, { fill: true, children: _jsx("div", { ref: ref, className: classNames(Styles.chartWrapper, 'border-bottom', {
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
- }), children: periods.length ? (_jsxs(Fragment, { children: [periods.length !== labels.length && (_jsx("div", { className: Styles.labelBorders, children: labels
31
- .map(([text, flex], ind) => [flex, `${ind}${text}`])
32
- .map(([flex, key]) => (_jsx("div", { style: { flex } }, key))) })), _jsx(SvgBody, { horizontalGrid: display.yGrid, metrics: metrics }), _jsx(HoverPopover, {}), _jsx(SvgBodyHover, { onValueHover: onBarHover, onValueLeave: onBarLeave })] })) : (_jsx(Stack, { className: "h-100", justifyContent: "center", alignItems: "center", children: "No Data" })) }) }), right && _jsx(Sidebar, { settings: right, right: true, classNameTitle: classNameTitle })] }), display.xLabels && (_jsx(XAxisLabels, { labels: labels, width: (_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0, left: (_b = left === null || left === void 0 ? void 0 : left.width) !== null && _b !== void 0 ? _b : 0, right: (_c = right === null || right === void 0 ? void 0 : right.width) !== null && _c !== void 0 ? _c : 0, labelsMerged: periods.length !== labels.length, hasBars: !!metrics.filter(m => m.type === 'bar' ||
33
- m.type === 'stacked-bar' ||
34
- m.type === 'grouped-bar').length })), display.metricsTitlePosition === 'bottom' && (_jsx(Stack, { direction: "row", justifyContent: "center", className: "p-3", children: _jsx(MetricsTitle, { metrics: metrics }) }))] }));
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