@servicetitan/marketing-ui 5.8.1 → 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.
- 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/funnel-chart.stories.d.ts +0 -1
- package/dist/components/charts/funnel-chart/funnel-chart.stories.d.ts.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.d.ts.map +1 -1
- package/dist/components/charts/line-chart/components/svg-bars.js +60 -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.d.ts.map +1 -1
- package/dist/components/charts/line-chart/stores/line-chart.store.js +98 -127
- package/dist/components/charts/line-chart/stores/line-chart.store.js.map +1 -1
- package/dist/components/charts/line-chart/stores/svg.store.d.ts.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.d.ts.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.d.ts.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.d.ts.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/pie-chart.stories.d.ts +0 -1
- package/dist/components/charts/pie-chart/pie-chart.stories.d.ts.map +1 -1
- package/dist/components/charts/pie-chart/utils/const.d.ts.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.d.ts.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-cards.stories.d.ts +0 -1
- package/dist/components/stat/stat-cards.stories.d.ts.map +1 -1
- package/dist/components/stat/stat-extended-card.js +76 -4
- package/dist/components/stat/stat-extended-card.js.map +1 -1
- package/dist/components/stat/stat-extended-card.stories.d.ts +0 -1
- package/dist/components/stat/stat-extended-card.stories.d.ts.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/action-button.stories.d.ts +0 -1
- package/dist/components/ui/action-button/action-button.stories.d.ts.map +1 -1
- 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/centered-spinner/centered-spinner.stories.d.ts +0 -1
- package/dist/components/ui/centered-spinner/centered-spinner.stories.d.ts.map +1 -1
- package/dist/components/ui/date-range-picker/date-range-picker.d.ts.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/date-range-picker/date-range-picker.stories.d.ts.map +1 -1
- 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/label-with-hint/label-with-hint.stories.d.ts +0 -1
- package/dist/components/ui/label-with-hint/label-with-hint.stories.d.ts.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-body.stories.d.ts +0 -1
- package/dist/components/ui/line-text/line-text-body.stories.d.ts.map +1 -1
- package/dist/components/ui/line-text/line-text-head.stories.d.ts +0 -1
- package/dist/components/ui/line-text/line-text-head.stories.d.ts.map +1 -1
- package/dist/components/ui/line-text/line-text.js +71 -25
- 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.d.ts.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/components/ui/title-popover/title-popover.stories.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/__tests__/format-big-numbers.test.d.ts +2 -0
- package/dist/utils/__tests__/format-big-numbers.test.d.ts.map +1 -0
- package/dist/utils/__tests__/formatters.test.d.ts +2 -0
- package/dist/utils/__tests__/formatters.test.d.ts.map +1 -0
- package/dist/utils/__tests__/helpers.test.d.ts +2 -0
- package/dist/utils/__tests__/helpers.test.d.ts.map +1 -0
- package/dist/utils/__tests__/string-case.test.d.ts +2 -0
- package/dist/utils/__tests__/string-case.test.d.ts.map +1 -0
- package/dist/utils/ads-texts.js +2 -1
- package/dist/utils/ads-texts.js.map +1 -1
- package/dist/utils/date/__tests__/date-range-picker.test.d.ts +2 -0
- package/dist/utils/date/__tests__/date-range-picker.test.d.ts.map +1 -0
- package/dist/utils/date/__tests__/date-tenant.test.d.ts +2 -0
- package/dist/utils/date/__tests__/date-tenant.test.d.ts.map +1 -0
- package/dist/utils/date/date-range-picker-options.d.ts.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.d.ts.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.d.ts.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.d.ts.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.d.ts.map +1 -1
- package/dist/utils/formatters.js +8 -7
- package/dist/utils/formatters.js.map +1 -1
- package/dist/utils/helpers.d.ts.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.d.ts +1 -5
- package/dist/utils/use-client-rect.d.ts.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/src/components/charts/funnel-chart/funnel-chart.stories.tsx +3 -2
- package/src/components/charts/line-chart/components/svg-bars.tsx +2 -0
- package/src/components/ui/action-button/action-button.stories.tsx +3 -2
- package/src/components/ui/centered-spinner/centered-spinner.stories.tsx +3 -2
- package/src/components/ui/date-range-picker/date-range-picker.stories.tsx +5 -6
- package/src/components/ui/date-range-picker/date-range-picker.tsx +2 -2
- package/src/components/ui/line-text/line-text-body.stories.tsx +3 -2
- package/src/components/ui/line-text/line-text-head.stories.tsx +3 -2
- package/src/components/ui/line-text/line-text.tsx +1 -1
- package/src/components/ui/title-popover/title-popover.stories.tsx +3 -2
- package/src/utils/date/__tests__/date-range-picker.test.ts +1 -1
- package/src/utils/use-client-rect.ts +1 -1
- 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 -48
- 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/date/__mocks__/date-mock.js +0 -19
- package/dist/utils/date/__mocks__/date-mock.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/charts/line-chart/utils/formatters.ts"],"sourcesContent":["import { formatMoney } from 'accounting';\nimport {\n LineChartDisplayValueFormat,\n LineChartDisplayValueFormatter,\n LineChartDisplayValueFormatterName,\n} from './interfaces';\n\nexport const formatters: Record<\n LineChartDisplayValueFormatterName,\n LineChartDisplayValueFormatter\n> = {\n number: (value: number) => Math.round(value).toLocaleString(),\n money: (value: number) => formatMoney(value, undefined, 0),\n moneyShort: (value: number) => {\n const postfixes = ['', 'K', 'M', 'B'];\n let val = value;\n\n for (let i = 0; i < postfixes.length; i++) {\n if (val < 1000 || i === postfixes.length - 1) {\n return formatMoney(Math.round(val), undefined, 0) + postfixes[i];\n }\n\n val = val / 1000;\n }\n\n return '';\n },\n};\n\nexport const getFormatter = (\n format?: LineChartDisplayValueFormat\n): LineChartDisplayValueFormatter =>\n format\n ? typeof format === 'string'\n ? formatters[format] || formatters.number\n : format\n : formatters.number;\n"],"names":["formatMoney","formatters","number","value","Math","round","toLocaleString","money","undefined","moneyShort","postfixes","val","i","length","getFormatter","format"],"mappings":"AAAA,SAASA,WAAW,QAAQ,aAAa;AAOzC,OAAO,MAAMC,aAGT;IACAC,QAAQ,CAACC,QAAkBC,KAAKC,KAAK,CAACF,OAAOG,cAAc;IAC3DC,OAAO,CAACJ,QAAkBH,YAAYG,OAAOK,WAAW;IACxDC,YAAY,CAACN;QACT,MAAMO,YAAY;YAAC;YAAI;YAAK;YAAK;SAAI;QACrC,IAAIC,MAAMR;QAEV,IAAK,IAAIS,IAAI,GAAGA,IAAIF,UAAUG,MAAM,EAAED,IAAK;YACvC,IAAID,MAAM,QAAQC,MAAMF,UAAUG,MAAM,GAAG,GAAG;gBAC1C,OAAOb,YAAYI,KAAKC,KAAK,CAACM,MAAMH,WAAW,KAAKE,SAAS,CAACE,EAAE;YACpE;YAEAD,MAAMA,MAAM;QAChB;QAEA,OAAO;IACX;AACJ,EAAE;AAEF,OAAO,MAAMG,eAAe,CACxBC,SAEAA,SACM,OAAOA,WAAW,WACdd,UAAU,CAACc,OAAO,IAAId,WAAWC,MAAM,GACvCa,SACJd,WAAWC,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/charts/line-chart/utils/interfaces.ts"],"sourcesContent":["import { ReactElement } from 'react';\n\nexport type LineChartResolution = 'hour' | 'day' | 'week' | 'month';\nexport type LineChartMetricType = 'line' | 'bar' | 'stacked-bar' | 'grouped-bar';\nexport type LineChartMetricsTitlePosition = 'top' | 'top-right' | 'bottom';\n\nexport interface LineChartMetricOpts {\n dashed?: boolean;\n}\n\nexport interface LineChartMetric {\n id: number;\n color: string;\n title: string;\n opacity?: number;\n isRight?: boolean;\n type?: LineChartMetricType;\n opts?: LineChartMetricOpts;\n}\n\nexport interface LineChartPeriod {\n from: Date;\n to?: Date;\n partial?: boolean;\n}\n\nexport type LineChartMetricValueOpts =\n | undefined\n | {\n color?: string;\n };\n\nexport interface LineChartMetricValues {\n metricId: number;\n values: number[];\n opts?: LineChartMetricValueOpts[];\n}\n\nexport interface LineChartData {\n periods: LineChartPeriod[];\n metricValues: LineChartMetricValues[];\n resolution: LineChartResolution;\n}\n\nexport type LineChartDisplayValueFormatterName = 'number' | 'money' | 'moneyShort';\nexport type LineChartDisplayValueFormatter = (val: number) => string;\nexport type LineChartDisplayValueFormat =\n | LineChartDisplayValueFormatter\n | LineChartDisplayValueFormatterName;\n\nexport interface LineChartDisplay {\n xLabels: boolean;\n yGrid: boolean;\n yLeft: boolean;\n yRight: boolean;\n yLeftFormat?: LineChartDisplayValueFormat;\n yRightFormat?: LineChartDisplayValueFormat;\n metricsTitlePosition?: LineChartMetricsTitlePosition;\n metricsLeftFormat?: LineChartDisplayValueFormat;\n metricsRightFormat?: LineChartDisplayValueFormat;\n}\n\nexport interface LineChartProps extends LineChartData {\n maxRange?: number;\n titleY?: string;\n maxRangeRight?: number;\n titleYRight?: string;\n\n metrics: LineChartMetric[];\n from?: Date;\n display?: Partial<LineChartDisplay>;\n className?: string;\n classNameTitle?: string;\n}\n\nexport interface LineChartCardProps extends LineChartProps {\n title: string;\n headerRight?: ReactElement;\n loading?: boolean;\n grayControls?: boolean;\n}\n"],"names":[],"mappings":"AA2EA,WAKC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/charts/line-chart/utils/internal-interfaces.ts"],"sourcesContent":["import { LineChartMetricOpts, LineChartMetricType, LineChartMetricValueOpts } from './interfaces';\n\nexport interface SideMetricsSettings {\n maxRange: number;\n maxValue: number;\n title: string;\n values: string[];\n width: number;\n}\n\nexport interface ChartMetric {\n id: number;\n color: string;\n title: string;\n isRight: boolean;\n type: LineChartMetricType;\n opts: LineChartMetricOpts;\n values: number[];\n opacity?: number;\n valuesOpts?: LineChartMetricValueOpts[];\n}\n\nexport type ChartXLabels = [string, number][];\n"],"names":[],"mappings":"AAsBA,WAA8C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../../../../src/components/charts/line-chart/utils/key.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../../../../src/components/charts/line-chart/utils/key.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,GAAI,KAAK,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,WAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/charts/line-chart/utils/key.ts"],"sourcesContent":["export const keyVal = (val: string | number, i: number) => `${val}-${i}`;\n"],"names":["keyVal","val","i"],"mappings":"AAAA,OAAO,MAAMA,SAAS,CAACC,KAAsBC,IAAc,GAAGD,IAAI,CAAC,EAAEC,GAAG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../../../../src/components/charts/line-chart/utils/labels.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAQrD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../../../../src/components/charts/line-chart/utils/labels.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAQrD,eAAO,MAAM,UAAU,GACnB,SAAS,eAAe,EAAE,EAC1B,YAAY,mBAAmB,EAC/B,OAAO,MAAM,KACd,YAgFF,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,MAAM,CACzC,mBAAmB,EACnB,CAAC,MAAM,EAAE,eAAe,KAAK,MAAM,CAYtC,CAAC"}
|
|
@@ -2,96 +2,100 @@ import moment from 'moment';
|
|
|
2
2
|
const xLabelFormats = {
|
|
3
3
|
hour: 'HH:mm',
|
|
4
4
|
day: 'MM/DD',
|
|
5
|
-
month: 'MMM'
|
|
5
|
+
month: 'MMM'
|
|
6
6
|
};
|
|
7
|
-
export const getXLabels = (periods, resolution, width)
|
|
7
|
+
export const getXLabels = (periods, resolution, width)=>{
|
|
8
8
|
let labels = [];
|
|
9
9
|
if (resolution === 'hour') {
|
|
10
10
|
if (width / periods.length < 76) {
|
|
11
11
|
let day = -1;
|
|
12
|
-
for (const p of periods)
|
|
12
|
+
for (const p of periods){
|
|
13
13
|
const d = p.from.getDay();
|
|
14
14
|
if (d === day) {
|
|
15
15
|
labels[labels.length - 1][1]++;
|
|
16
16
|
continue;
|
|
17
17
|
}
|
|
18
18
|
day = d;
|
|
19
|
-
labels.push([
|
|
19
|
+
labels.push([
|
|
20
|
+
moment(p.from).format(xLabelFormats.day),
|
|
21
|
+
1
|
|
22
|
+
]);
|
|
20
23
|
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var _a;
|
|
24
|
+
} else {
|
|
25
|
+
labels = periods.map((p)=>{
|
|
26
|
+
var _p_to;
|
|
25
27
|
return [
|
|
26
|
-
moment(p.from).format(xLabelFormats.hour) +
|
|
27
|
-
|
|
28
|
-
moment((_a = p.to) !== null && _a !== void 0 ? _a : p.from).format(xLabelFormats.hour),
|
|
29
|
-
1,
|
|
28
|
+
moment(p.from).format(xLabelFormats.hour) + ' - ' + moment((_p_to = p.to) !== null && _p_to !== void 0 ? _p_to : p.from).format(xLabelFormats.hour),
|
|
29
|
+
1
|
|
30
30
|
];
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
}
|
|
34
|
-
else if (resolution === 'day') {
|
|
33
|
+
} else if (resolution === 'day') {
|
|
35
34
|
if (width / periods.length < 40) {
|
|
36
35
|
let month = -1;
|
|
37
|
-
for (const p of periods)
|
|
36
|
+
for (const p of periods){
|
|
38
37
|
const m = p.from.getMonth();
|
|
39
38
|
if (m === month) {
|
|
40
39
|
labels[labels.length - 1][1]++;
|
|
41
40
|
continue;
|
|
42
41
|
}
|
|
43
42
|
month = m;
|
|
44
|
-
labels.push([
|
|
43
|
+
labels.push([
|
|
44
|
+
moment(p.from).format(xLabelFormats.month),
|
|
45
|
+
1
|
|
46
|
+
]);
|
|
45
47
|
}
|
|
48
|
+
} else {
|
|
49
|
+
labels = periods.map((p)=>[
|
|
50
|
+
moment(p.from).format(xLabelFormats.day),
|
|
51
|
+
1
|
|
52
|
+
]);
|
|
46
53
|
}
|
|
47
|
-
|
|
48
|
-
labels = periods.map(p => [moment(p.from).format(xLabelFormats.day), 1]);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else if (resolution === 'week') {
|
|
54
|
+
} else if (resolution === 'week') {
|
|
52
55
|
if (width / periods.length < 76) {
|
|
53
56
|
let month = -1;
|
|
54
|
-
for (const p of periods)
|
|
57
|
+
for (const p of periods){
|
|
55
58
|
const m = p.from.getMonth();
|
|
56
|
-
if (m === month ||
|
|
59
|
+
if (m === month || month > 0 && p.from.getDate() < 4) {
|
|
57
60
|
labels[labels.length - 1][1]++;
|
|
58
61
|
continue;
|
|
59
62
|
}
|
|
60
63
|
if (p.to && p.to.getDate() > 3) {
|
|
61
64
|
month = p.to.getMonth();
|
|
62
|
-
labels.push([
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
labels.push([
|
|
66
|
+
moment(p.to).format(xLabelFormats.month),
|
|
67
|
+
1
|
|
68
|
+
]);
|
|
69
|
+
} else {
|
|
65
70
|
month = m;
|
|
66
|
-
labels.push([
|
|
71
|
+
labels.push([
|
|
72
|
+
moment(p.from).format(xLabelFormats.month),
|
|
73
|
+
1
|
|
74
|
+
]);
|
|
67
75
|
}
|
|
68
76
|
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var _a;
|
|
77
|
+
} else {
|
|
78
|
+
labels = periods.map((p)=>{
|
|
79
|
+
var _p_to;
|
|
73
80
|
return [
|
|
74
|
-
moment(p.from).format(xLabelFormats.day) +
|
|
75
|
-
|
|
76
|
-
moment((_a = p.to) !== null && _a !== void 0 ? _a : p.from).format(xLabelFormats.day),
|
|
77
|
-
1,
|
|
81
|
+
moment(p.from).format(xLabelFormats.day) + ' - ' + moment((_p_to = p.to) !== null && _p_to !== void 0 ? _p_to : p.from).format(xLabelFormats.day),
|
|
82
|
+
1
|
|
78
83
|
];
|
|
79
84
|
});
|
|
80
85
|
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
} else if (resolution === 'month') {
|
|
87
|
+
labels = periods.map((p)=>[
|
|
88
|
+
moment(p.from).format(xLabelFormats.month),
|
|
89
|
+
1
|
|
90
|
+
]);
|
|
84
91
|
}
|
|
85
92
|
return labels;
|
|
86
93
|
};
|
|
87
94
|
export const periodDateTitleFormatter = {
|
|
88
|
-
hour: period
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
moment(period.to).format('HH:mm'),
|
|
93
|
-
day: period => moment(period.from).format('MMMM DD, YYYY'),
|
|
94
|
-
month: period => moment(period.from).format('MMMM YYYY'),
|
|
95
|
-
week: period => moment(period.from).format('MM/DD/YYYY') + '-' + moment(period.to).format('MM/DD/YYYY'),
|
|
95
|
+
hour: (period)=>moment(period.from).format('MM/DD') + ' ' + moment(period.from).format('HH:mm') + ' - ' + moment(period.to).format('HH:mm'),
|
|
96
|
+
day: (period)=>moment(period.from).format('MMMM DD, YYYY'),
|
|
97
|
+
month: (period)=>moment(period.from).format('MMMM YYYY'),
|
|
98
|
+
week: (period)=>moment(period.from).format('MM/DD/YYYY') + '-' + moment(period.to).format('MM/DD/YYYY')
|
|
96
99
|
};
|
|
100
|
+
|
|
97
101
|
//# sourceMappingURL=labels.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/charts/line-chart/utils/labels.ts"],"sourcesContent":["import moment from 'moment';\nimport { LineChartPeriod, LineChartResolution } from './interfaces';\nimport { ChartXLabels } from './internal-interfaces';\n\nconst xLabelFormats = {\n hour: 'HH:mm',\n day: 'MM/DD',\n month: 'MMM',\n};\n\nexport const getXLabels = (\n periods: LineChartPeriod[],\n resolution: LineChartResolution,\n width: number\n): ChartXLabels => {\n let labels: [string, number][] = [];\n\n if (resolution === 'hour') {\n if (width / periods.length < 76) {\n let day = -1;\n\n for (const p of periods) {\n const d = p.from.getDay();\n\n if (d === day) {\n labels[labels.length - 1][1]++;\n\n continue;\n }\n\n day = d;\n labels.push([moment(p.from).format(xLabelFormats.day), 1]);\n }\n } else {\n labels = periods.map(p => [\n moment(p.from).format(xLabelFormats.hour) +\n ' - ' +\n moment(p.to ?? p.from).format(xLabelFormats.hour),\n 1,\n ]);\n }\n } else if (resolution === 'day') {\n if (width / periods.length < 40) {\n let month = -1;\n\n for (const p of periods) {\n const m = p.from.getMonth();\n\n if (m === month) {\n labels[labels.length - 1][1]++;\n\n continue;\n }\n\n month = m;\n labels.push([moment(p.from).format(xLabelFormats.month), 1]);\n }\n } else {\n labels = periods.map(p => [moment(p.from).format(xLabelFormats.day), 1]);\n }\n } else if (resolution === 'week') {\n if (width / periods.length < 76) {\n let month = -1;\n\n for (const p of periods) {\n const m = p.from.getMonth();\n\n if (m === month || (month > 0 && p.from.getDate() < 4)) {\n labels[labels.length - 1][1]++;\n\n continue;\n }\n\n if (p.to && p.to.getDate() > 3) {\n month = p.to.getMonth();\n labels.push([moment(p.to).format(xLabelFormats.month), 1]);\n } else {\n month = m;\n labels.push([moment(p.from).format(xLabelFormats.month), 1]);\n }\n }\n } else {\n labels = periods.map(p => [\n moment(p.from).format(xLabelFormats.day) +\n ' - ' +\n moment(p.to ?? p.from).format(xLabelFormats.day),\n 1,\n ]);\n }\n } else if (resolution === 'month') {\n labels = periods.map(p => [moment(p.from).format(xLabelFormats.month), 1]);\n }\n\n return labels;\n};\n\nexport const periodDateTitleFormatter: Record<\n LineChartResolution,\n (period: LineChartPeriod) => string\n> = {\n hour: period =>\n moment(period.from).format('MM/DD') +\n ' ' +\n moment(period.from).format('HH:mm') +\n ' - ' +\n moment(period.to).format('HH:mm'),\n day: period => moment(period.from).format('MMMM DD, YYYY'),\n month: period => moment(period.from).format('MMMM YYYY'),\n week: period =>\n moment(period.from).format('MM/DD/YYYY') + '-' + moment(period.to).format('MM/DD/YYYY'),\n};\n"],"names":["moment","xLabelFormats","hour","day","month","getXLabels","periods","resolution","width","labels","length","p","d","from","getDay","push","format","map","to","m","getMonth","getDate","periodDateTitleFormatter","period","week"],"mappings":"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"}
|
|
@@ -5,12 +5,66 @@ import { BodyText, Stack, StatusLight } from '@servicetitan/design-system';
|
|
|
5
5
|
import { convertSessionsToPieces, radiusRelativeDefault } from '../utils/const';
|
|
6
6
|
import { Pie } from './pie';
|
|
7
7
|
import * as Styles from './pie-chart.module.less';
|
|
8
|
-
const PieTitles = ({ title, pieces })
|
|
9
|
-
return
|
|
8
|
+
const PieTitles = ({ title, pieces })=>{
|
|
9
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
10
|
+
className: classNames(Styles.titleWrapper, 'of-y-auto p-t-2'),
|
|
11
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
12
|
+
children: [
|
|
13
|
+
!!pieces.length && /*#__PURE__*/ _jsx(Stack.Item, {
|
|
14
|
+
className: "p-l-1 p-b-1",
|
|
15
|
+
children: /*#__PURE__*/ _jsx(BodyText, {
|
|
16
|
+
bold: true,
|
|
17
|
+
children: title
|
|
18
|
+
})
|
|
19
|
+
}),
|
|
20
|
+
pieces.map((piece)=>/*#__PURE__*/ _jsxs(Stack, {
|
|
21
|
+
alignItems: "center",
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ _jsx(StatusLight, {
|
|
24
|
+
color: piece.color
|
|
25
|
+
}),
|
|
26
|
+
/*#__PURE__*/ _jsx(BodyText, {
|
|
27
|
+
className: "c-neutral-90",
|
|
28
|
+
size: "medium",
|
|
29
|
+
children: piece.title
|
|
30
|
+
})
|
|
31
|
+
]
|
|
32
|
+
}, piece.title))
|
|
33
|
+
]
|
|
34
|
+
})
|
|
35
|
+
});
|
|
10
36
|
};
|
|
11
|
-
export const PieChart = ({ height, width, title, sections, popoverContent, content, radiusRelative = radiusRelativeDefault, popoverDirection = 'rb', hideTitles = false
|
|
12
|
-
const pieces = useMemo(()
|
|
13
|
-
|
|
14
|
-
|
|
37
|
+
export const PieChart = ({ height, width, title, sections, popoverContent, content, radiusRelative = radiusRelativeDefault, popoverDirection = 'rb', hideTitles = false })=>{
|
|
38
|
+
const pieces = useMemo(()=>convertSessionsToPieces(sections, radiusRelative), [
|
|
39
|
+
sections,
|
|
40
|
+
radiusRelative
|
|
41
|
+
]);
|
|
42
|
+
const style = useMemo(()=>({
|
|
43
|
+
height,
|
|
44
|
+
width
|
|
45
|
+
}), [
|
|
46
|
+
height,
|
|
47
|
+
width
|
|
48
|
+
]);
|
|
49
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
50
|
+
className: "d-f flex-row",
|
|
51
|
+
style: style,
|
|
52
|
+
children: [
|
|
53
|
+
/*#__PURE__*/ _jsx(Pie, {
|
|
54
|
+
title: title,
|
|
55
|
+
pieces: pieces,
|
|
56
|
+
content: content,
|
|
57
|
+
popoverContent: popoverContent,
|
|
58
|
+
popoverDirection: popoverDirection,
|
|
59
|
+
radiusRelative: radiusRelative,
|
|
60
|
+
hideTitles: hideTitles
|
|
61
|
+
}),
|
|
62
|
+
!hideTitles && /*#__PURE__*/ _jsx(PieTitles, {
|
|
63
|
+
title: title,
|
|
64
|
+
pieces: pieces
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
});
|
|
15
68
|
};
|
|
69
|
+
|
|
16
70
|
//# sourceMappingURL=pie-chart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/charts/pie-chart/components/pie-chart.tsx"],"sourcesContent":["import { useMemo, FC } from 'react';\nimport classNames from 'classnames';\nimport { BodyText, Stack, StatusLight } from '@servicetitan/design-system';\nimport { PieChartProps, PiePiece } from '../utils/interface';\nimport { convertSessionsToPieces, radiusRelativeDefault } from '../utils/const';\nimport { Pie } from './pie';\nimport * as Styles from './pie-chart.module.less';\n\nconst PieTitles: FC<{ title: string; pieces: PiePiece[] }> = ({ title, pieces }) => {\n return (\n <div className={classNames(Styles.titleWrapper, 'of-y-auto p-t-2')}>\n <div>\n {!!pieces.length && (\n <Stack.Item className=\"p-l-1 p-b-1\">\n <BodyText bold>{title}</BodyText>\n </Stack.Item>\n )}\n {pieces.map(piece => (\n <Stack key={piece.title} alignItems=\"center\">\n <StatusLight color={piece.color} />\n <BodyText className=\"c-neutral-90\" size=\"medium\">\n {piece.title}\n </BodyText>\n </Stack>\n ))}\n </div>\n </div>\n );\n};\n\nexport const PieChart: FC<PieChartProps> = ({\n height,\n width,\n title,\n sections,\n popoverContent,\n content,\n radiusRelative = radiusRelativeDefault,\n popoverDirection = 'rb',\n hideTitles = false,\n}) => {\n const pieces = useMemo(\n () => convertSessionsToPieces(sections, radiusRelative),\n [sections, radiusRelative]\n );\n const style = useMemo(() => ({ height, width }), [height, width]);\n\n return (\n <div className=\"d-f flex-row\" style={style}>\n <Pie\n title={title}\n pieces={pieces}\n content={content}\n popoverContent={popoverContent}\n popoverDirection={popoverDirection}\n radiusRelative={radiusRelative}\n hideTitles={hideTitles}\n />\n {!hideTitles && <PieTitles title={title} pieces={pieces} />}\n </div>\n );\n};\n"],"names":["useMemo","classNames","BodyText","Stack","StatusLight","convertSessionsToPieces","radiusRelativeDefault","Pie","Styles","PieTitles","title","pieces","div","className","titleWrapper","length","Item","bold","map","piece","alignItems","color","size","PieChart","height","width","sections","popoverContent","content","radiusRelative","popoverDirection","hideTitles","style"],"mappings":";AAAA,SAASA,OAAO,QAAY,QAAQ;AACpC,OAAOC,gBAAgB,aAAa;AACpC,SAASC,QAAQ,EAAEC,KAAK,EAAEC,WAAW,QAAQ,8BAA8B;AAE3E,SAASC,uBAAuB,EAAEC,qBAAqB,QAAQ,iBAAiB;AAChF,SAASC,GAAG,QAAQ,QAAQ;AAC5B,YAAYC,YAAY,0BAA0B;AAElD,MAAMC,YAAuD,CAAC,EAAEC,KAAK,EAAEC,MAAM,EAAE;IAC3E,qBACI,KAACC;QAAIC,WAAWZ,WAAWO,OAAOM,YAAY,EAAE;kBAC5C,cAAA,MAACF;;gBACI,CAAC,CAACD,OAAOI,MAAM,kBACZ,KAACZ,MAAMa,IAAI;oBAACH,WAAU;8BAClB,cAAA,KAACX;wBAASe,IAAI;kCAAEP;;;gBAGvBC,OAAOO,GAAG,CAACC,CAAAA,sBACR,MAAChB;wBAAwBiB,YAAW;;0CAChC,KAAChB;gCAAYiB,OAAOF,MAAME,KAAK;;0CAC/B,KAACnB;gCAASW,WAAU;gCAAeS,MAAK;0CACnCH,MAAMT,KAAK;;;uBAHRS,MAAMT,KAAK;;;;AAU3C;AAEA,OAAO,MAAMa,WAA8B,CAAC,EACxCC,MAAM,EACNC,KAAK,EACLf,KAAK,EACLgB,QAAQ,EACRC,cAAc,EACdC,OAAO,EACPC,iBAAiBvB,qBAAqB,EACtCwB,mBAAmB,IAAI,EACvBC,aAAa,KAAK,EACrB;IACG,MAAMpB,SAASX,QACX,IAAMK,wBAAwBqB,UAAUG,iBACxC;QAACH;QAAUG;KAAe;IAE9B,MAAMG,QAAQhC,QAAQ,IAAO,CAAA;YAAEwB;YAAQC;QAAM,CAAA,GAAI;QAACD;QAAQC;KAAM;IAEhE,qBACI,MAACb;QAAIC,WAAU;QAAemB,OAAOA;;0BACjC,KAACzB;gBACGG,OAAOA;gBACPC,QAAQA;gBACRiB,SAASA;gBACTD,gBAAgBA;gBAChBG,kBAAkBA;gBAClBD,gBAAgBA;gBAChBE,YAAYA;;YAEf,CAACA,4BAAc,KAACtB;gBAAUC,OAAOA;gBAAOC,QAAQA;;;;AAG7D,EAAE"}
|
|
@@ -4,52 +4,189 @@ import { tokens } from '@servicetitan/tokens/core';
|
|
|
4
4
|
import { BodyText, Popover, Stack, StatusLight } from '@servicetitan/design-system';
|
|
5
5
|
import { useClientRect } from '../../../../utils/use-client-rect';
|
|
6
6
|
const chartPadding = 8;
|
|
7
|
-
const px = (value)
|
|
8
|
-
const PiePieceSvg = ({ piece: { id, color, opacity, points, text, path }, selected })
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
const px = (value)=>`${value !== null && value !== void 0 ? value : 0}px`;
|
|
8
|
+
const PiePieceSvg = ({ piece: { id, color, opacity, points, text, path }, selected })=>points && path ? /*#__PURE__*/ _jsxs("g", {
|
|
9
|
+
id: id,
|
|
10
|
+
children: [
|
|
11
|
+
!!selected && /*#__PURE__*/ _jsx("path", {
|
|
12
|
+
d: path,
|
|
13
|
+
fill: tokens.colorWhite,
|
|
14
|
+
stroke: tokens.colorBlue200,
|
|
15
|
+
strokeOpacity: "50%",
|
|
16
|
+
strokeWidth: "3",
|
|
17
|
+
paintOrder: "stroke"
|
|
18
|
+
}),
|
|
19
|
+
/*#__PURE__*/ _jsx("path", {
|
|
20
|
+
d: path,
|
|
21
|
+
fill: color
|
|
22
|
+
}),
|
|
23
|
+
/*#__PURE__*/ _jsx("svg", {
|
|
24
|
+
x: points[4][0] - 10,
|
|
25
|
+
y: points[4][1] - (points[4][1] > 0 ? 3 : 1),
|
|
26
|
+
width: 20,
|
|
27
|
+
height: 6,
|
|
28
|
+
children: /*#__PURE__*/ _jsx("text", {
|
|
29
|
+
x: "50%",
|
|
30
|
+
y: "50%",
|
|
31
|
+
fontSize: 4,
|
|
32
|
+
fontWeight: 600,
|
|
33
|
+
fill: opacity > 0.3 ? tokens.colorWhite : tokens.colorBlack,
|
|
34
|
+
dominantBaseline: "middle",
|
|
35
|
+
textAnchor: "middle",
|
|
36
|
+
children: text
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
]
|
|
40
|
+
}) : null;
|
|
41
|
+
const PiePieceHover = ({ piece, onMouse })=>{
|
|
42
|
+
const onMouseEnter = useCallback(()=>onMouse(piece.id, true), [
|
|
43
|
+
onMouse,
|
|
44
|
+
piece.id
|
|
45
|
+
]);
|
|
46
|
+
const onMouseLeave = useCallback(()=>onMouse(piece.id, false), [
|
|
47
|
+
onMouse,
|
|
48
|
+
piece.id
|
|
49
|
+
]);
|
|
50
|
+
return /*#__PURE__*/ _jsx("path", {
|
|
51
|
+
d: piece.path,
|
|
52
|
+
fill: "white",
|
|
53
|
+
opacity: "0",
|
|
54
|
+
onMouseEnter: onMouseEnter,
|
|
55
|
+
onMouseLeave: onMouseLeave
|
|
56
|
+
});
|
|
13
57
|
};
|
|
14
|
-
const PieSvg = ({ pieces, selectedIndex, radiusRelative })
|
|
15
|
-
|
|
16
|
-
|
|
58
|
+
const PieSvg = ({ pieces, selectedIndex, radiusRelative })=>/*#__PURE__*/ _jsxs("svg", {
|
|
59
|
+
className: "position-absolute",
|
|
60
|
+
style: {
|
|
61
|
+
inset: px(chartPadding)
|
|
62
|
+
},
|
|
63
|
+
viewBox: `-${radiusRelative} -${radiusRelative} ` + `${radiusRelative * 2} ${radiusRelative * 2}`,
|
|
64
|
+
children: [
|
|
65
|
+
pieces.map((p, index)=>p.path ? /*#__PURE__*/ _jsx(PiePieceSvg, {
|
|
66
|
+
piece: p,
|
|
67
|
+
selected: index === selectedIndex
|
|
68
|
+
}, p.id) : null),
|
|
69
|
+
selectedIndex >= 0 && selectedIndex < pieces.length && /*#__PURE__*/ _jsx("use", {
|
|
70
|
+
xlinkHref: pieces[selectedIndex].id
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
const PieSvgHover = ({ pieces, onMouse, radiusRelative })=>/*#__PURE__*/ _jsx("svg", {
|
|
75
|
+
className: "position-absolute z-global-nav",
|
|
76
|
+
style: {
|
|
77
|
+
inset: px(chartPadding)
|
|
78
|
+
},
|
|
79
|
+
viewBox: `-${radiusRelative} -${radiusRelative} ` + `${radiusRelative * 2} ${radiusRelative * 2}`,
|
|
80
|
+
children: pieces.map((p)=>p.path ? /*#__PURE__*/ _jsx(PiePieceHover, {
|
|
81
|
+
piece: p,
|
|
82
|
+
onMouse: onMouse
|
|
83
|
+
}, p.id) : null)
|
|
84
|
+
});
|
|
85
|
+
export const Pie = ({ pieces, popoverContent: PopoverContent, content: PieContent, radiusRelative, hideTitles, popoverDirection })=>{
|
|
17
86
|
const [selectedIndex, setSelectedIndex] = useState(-1);
|
|
18
87
|
const [rect, ref] = useClientRect();
|
|
19
|
-
const onMouse = useCallback((id, isEnter)
|
|
20
|
-
setSelectedIndex(isEnter ? pieces.findIndex(p
|
|
21
|
-
}, [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
88
|
+
const onMouse = useCallback((id, isEnter)=>{
|
|
89
|
+
setSelectedIndex(isEnter ? pieces.findIndex((p)=>p.id === id) : -1);
|
|
90
|
+
}, [
|
|
91
|
+
pieces,
|
|
92
|
+
setSelectedIndex
|
|
93
|
+
]);
|
|
94
|
+
const container = useMemo(()=>{
|
|
95
|
+
var _rect_height;
|
|
96
|
+
const height = (_rect_height = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _rect_height !== void 0 ? _rect_height : 0;
|
|
25
97
|
return {
|
|
26
98
|
height,
|
|
27
99
|
internal: height ? height - chartPadding * 2 : 0,
|
|
28
|
-
styles: height
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
: {},
|
|
100
|
+
styles: height ? {
|
|
101
|
+
width: px(Math.max(250, height)),
|
|
102
|
+
overflow: 'hidden'
|
|
103
|
+
} : {}
|
|
34
104
|
};
|
|
35
|
-
}, [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
105
|
+
}, [
|
|
106
|
+
rect
|
|
107
|
+
]);
|
|
108
|
+
const triggersStyles = useMemo(()=>container.height ? pieces.map((p)=>p.points ? {
|
|
39
109
|
key: p.key,
|
|
40
|
-
top: px(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
110
|
+
top: px(container.height * (radiusRelative + p.points[4][1]) / (radiusRelative * 2)),
|
|
111
|
+
left: px(container.height * (radiusRelative + p.points[4][0]) / (radiusRelative * 2) + 20)
|
|
112
|
+
} : {
|
|
113
|
+
top: '',
|
|
114
|
+
left: ''
|
|
115
|
+
}) : [], [
|
|
116
|
+
pieces,
|
|
117
|
+
container,
|
|
118
|
+
radiusRelative
|
|
119
|
+
]);
|
|
120
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
121
|
+
ref: ref,
|
|
122
|
+
style: container.styles,
|
|
123
|
+
className: "position-relative",
|
|
124
|
+
children: pieces.every((p)=>!p.path) ? /*#__PURE__*/ _jsx(Stack, {
|
|
125
|
+
className: "h-100",
|
|
126
|
+
justifyContent: "center",
|
|
127
|
+
alignItems: "center",
|
|
128
|
+
children: "No Data"
|
|
129
|
+
}) : /*#__PURE__*/ _jsxs(Fragment, {
|
|
130
|
+
children: [
|
|
131
|
+
triggersStyles.filter((ts)=>!!ts.left && !!ts.top).map((ts, ind)=>{
|
|
132
|
+
var _pieces_ind, _pieces_ind1, _pieces_ind2;
|
|
133
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
134
|
+
style: ts,
|
|
135
|
+
className: "position-absolute",
|
|
136
|
+
children: (!!PopoverContent || !hideTitles) && /*#__PURE__*/ _jsx(Popover, {
|
|
137
|
+
portal: true,
|
|
138
|
+
trigger: /*#__PURE__*/ _jsx("span", {
|
|
139
|
+
children: " "
|
|
140
|
+
}),
|
|
141
|
+
open: selectedIndex === ind,
|
|
142
|
+
direction: popoverDirection,
|
|
143
|
+
padding: "s",
|
|
144
|
+
width: "auto",
|
|
145
|
+
children: selectedIndex === ind && /*#__PURE__*/ _jsxs(Stack, {
|
|
146
|
+
direction: "column",
|
|
147
|
+
"data-cy": `customer-lead-rate-section-${ts.key}-popover`,
|
|
148
|
+
children: [
|
|
149
|
+
!hideTitles && /*#__PURE__*/ _jsxs(Stack, {
|
|
150
|
+
alignItems: "center",
|
|
151
|
+
children: [
|
|
152
|
+
/*#__PURE__*/ _jsx(StatusLight, {
|
|
153
|
+
color: pieces[ind].color
|
|
154
|
+
}),
|
|
155
|
+
/*#__PURE__*/ _jsx(BodyText, {
|
|
156
|
+
size: "small",
|
|
157
|
+
bold: true,
|
|
158
|
+
children: pieces[ind].title
|
|
159
|
+
})
|
|
160
|
+
]
|
|
161
|
+
}),
|
|
162
|
+
!!PopoverContent && /*#__PURE__*/ _jsx(Stack.Item, {
|
|
163
|
+
className: "m-l-1",
|
|
164
|
+
children: /*#__PURE__*/ _jsx(PopoverContent, {
|
|
165
|
+
index: ind,
|
|
166
|
+
data: (_pieces_ind = pieces[ind]) === null || _pieces_ind === void 0 ? void 0 : _pieces_ind.data,
|
|
167
|
+
text: (_pieces_ind1 = pieces[ind]) === null || _pieces_ind1 === void 0 ? void 0 : _pieces_ind1.text,
|
|
168
|
+
value: (_pieces_ind2 = pieces[ind]) === null || _pieces_ind2 === void 0 ? void 0 : _pieces_ind2.value
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
]
|
|
172
|
+
})
|
|
173
|
+
})
|
|
174
|
+
}, ts.left + ts.top);
|
|
175
|
+
}),
|
|
176
|
+
!!PieContent && /*#__PURE__*/ _jsx(PieContent, {}),
|
|
177
|
+
/*#__PURE__*/ _jsx(PieSvg, {
|
|
178
|
+
pieces: pieces,
|
|
179
|
+
selectedIndex: selectedIndex,
|
|
180
|
+
radiusRelative: radiusRelative
|
|
181
|
+
}),
|
|
182
|
+
/*#__PURE__*/ _jsx(PieSvgHover, {
|
|
183
|
+
pieces: pieces,
|
|
184
|
+
onMouse: onMouse,
|
|
185
|
+
radiusRelative: radiusRelative
|
|
186
|
+
})
|
|
187
|
+
]
|
|
188
|
+
})
|
|
189
|
+
});
|
|
54
190
|
};
|
|
191
|
+
|
|
55
192
|
//# sourceMappingURL=pie.js.map
|