@servicetitan/marketing-ui 1.8.0 → 1.9.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.d.ts +3 -3
- package/dist/components/ads/ads-stat.d.ts.map +1 -1
- package/dist/components/ads/ads-stat.js.map +1 -1
- package/dist/components/charts/funnel-chart/components/funnel-chart.d.ts +2 -2
- package/dist/components/charts/funnel-chart/components/funnel-chart.d.ts.map +1 -1
- package/dist/components/charts/funnel-chart/components/funnel-chart.js.map +1 -1
- package/dist/components/charts/funnel-chart/components/funnel-svg.d.ts +2 -2
- package/dist/components/charts/funnel-chart/components/funnel-svg.d.ts.map +1 -1
- package/dist/components/charts/funnel-chart/components/funnel-svg.js.map +1 -1
- package/dist/components/charts/funnel-chart/funnel-chart.stories.d.ts +2 -2
- package/dist/components/charts/funnel-chart/funnel-chart.stories.d.ts.map +1 -1
- package/dist/components/charts/funnel-chart/funnel-chart.stories.js.map +1 -1
- package/dist/components/charts/line-chart/components/body.d.ts +2 -2
- package/dist/components/charts/line-chart/components/body.d.ts.map +1 -1
- package/dist/components/charts/line-chart/components/body.js +2 -2
- package/dist/components/charts/line-chart/components/body.js.map +1 -1
- package/dist/components/charts/line-chart/components/container.d.ts +2 -2
- package/dist/components/charts/line-chart/components/container.d.ts.map +1 -1
- package/dist/components/charts/line-chart/components/container.js.map +1 -1
- package/dist/components/charts/line-chart/components/hover-popover.d.ts +2 -2
- package/dist/components/charts/line-chart/components/hover-popover.d.ts.map +1 -1
- package/dist/components/charts/line-chart/components/hover-popover.js +2 -2
- package/dist/components/charts/line-chart/components/hover-popover.js.map +1 -1
- package/dist/components/charts/line-chart/components/sidebar.d.ts +2 -2
- package/dist/components/charts/line-chart/components/sidebar.d.ts.map +1 -1
- package/dist/components/charts/line-chart/components/sidebar.js.map +1 -1
- package/dist/components/charts/line-chart/components/stuff.d.ts +4 -4
- package/dist/components/charts/line-chart/components/stuff.d.ts.map +1 -1
- package/dist/components/charts/line-chart/components/stuff.js.map +1 -1
- package/dist/components/charts/line-chart/components/svg-bars.d.ts +3 -3
- package/dist/components/charts/line-chart/components/svg-bars.d.ts.map +1 -1
- package/dist/components/charts/line-chart/components/svg-bars.js.map +1 -1
- package/dist/components/charts/line-chart/components/svg-body.d.ts +3 -3
- package/dist/components/charts/line-chart/components/svg-body.d.ts.map +1 -1
- package/dist/components/charts/line-chart/components/svg-body.js.map +1 -1
- package/dist/components/charts/line-chart/components/svg-lines.d.ts +2 -2
- package/dist/components/charts/line-chart/components/svg-lines.d.ts.map +1 -1
- package/dist/components/charts/line-chart/components/svg-lines.js.map +1 -1
- package/dist/components/charts/line-chart/line-chart.stories.d.ts +2 -2
- package/dist/components/charts/line-chart/line-chart.stories.d.ts.map +1 -1
- package/dist/components/charts/line-chart/line-chart.stories.js.map +1 -1
- package/dist/components/charts/line-chart/utils/interfaces.d.ts +2 -2
- package/dist/components/charts/line-chart/utils/interfaces.d.ts.map +1 -1
- package/dist/components/charts/pie-chart/components/pie-chart.d.ts +2 -2
- package/dist/components/charts/pie-chart/components/pie-chart.d.ts.map +1 -1
- package/dist/components/charts/pie-chart/components/pie-chart.js +1 -1
- package/dist/components/charts/pie-chart/components/pie-chart.js.map +1 -1
- package/dist/components/charts/pie-chart/components/pie.d.ts +2 -2
- package/dist/components/charts/pie-chart/components/pie.d.ts.map +1 -1
- package/dist/components/charts/pie-chart/components/pie.js +2 -21
- package/dist/components/charts/pie-chart/components/pie.js.map +1 -1
- package/dist/components/charts/pie-chart/pie-chart.stories.d.ts +2 -2
- package/dist/components/charts/pie-chart/pie-chart.stories.d.ts.map +1 -1
- package/dist/components/charts/pie-chart/pie-chart.stories.js.map +1 -1
- package/dist/components/charts/pie-chart/utils/interface.d.ts +2 -2
- package/dist/components/charts/pie-chart/utils/interface.d.ts.map +1 -1
- package/dist/components/image-cropper/image-cropper.d.ts +2 -2
- package/dist/components/image-cropper/image-cropper.d.ts.map +1 -1
- package/dist/components/image-cropper/image-cropper.js +2 -2
- package/dist/components/image-cropper/image-cropper.js.map +1 -1
- package/dist/components/image-cropper/image-cropper.stories.js +5 -8
- package/dist/components/image-cropper/image-cropper.stories.js.map +1 -1
- package/dist/components/stat/stat-card.d.ts +3 -3
- package/dist/components/stat/stat-card.d.ts.map +1 -1
- package/dist/components/stat/stat-card.js.map +1 -1
- package/dist/components/stat/stat-cards.stories.d.ts +2 -2
- package/dist/components/stat/stat-cards.stories.d.ts.map +1 -1
- package/dist/components/stat/stat-cards.stories.js.map +1 -1
- package/dist/components/stat/stat-extended-card.d.ts.map +1 -1
- package/dist/components/stat/stat-extended-card.stories.d.ts +2 -2
- package/dist/components/stat/stat-extended-card.stories.d.ts.map +1 -1
- package/dist/components/stat/stat-extended-card.stories.js.map +1 -1
- package/dist/components/ui/centered-spinner.d.ts +2 -2
- package/dist/components/ui/centered-spinner.d.ts.map +1 -1
- package/dist/components/ui/centered-spinner.js +1 -1
- package/dist/components/ui/centered-spinner.js.map +1 -1
- package/dist/components/ui/centered-spinner.stories.d.ts +2 -2
- package/dist/components/ui/centered-spinner.stories.d.ts.map +1 -1
- package/dist/components/ui/centered-spinner.stories.js.map +1 -1
- package/dist/components/ui/date-range-picker/date-range-picker.js.map +1 -1
- package/dist/components/ui/date-range-picker/date-range-picker.stories.js.map +1 -1
- package/dist/components/ui/disabled-button.d.ts +2 -2
- package/dist/components/ui/disabled-button.d.ts.map +1 -1
- package/dist/components/ui/disabled-button.js.map +1 -1
- package/dist/components/ui/line-text/line-text-body.stories.d.ts +2 -2
- package/dist/components/ui/line-text/line-text-body.stories.d.ts.map +1 -1
- package/dist/components/ui/line-text/line-text-body.stories.js.map +1 -1
- package/dist/components/ui/line-text/line-text-head.stories.d.ts +2 -2
- package/dist/components/ui/line-text/line-text-head.stories.d.ts.map +1 -1
- package/dist/components/ui/line-text/line-text-head.stories.js.map +1 -1
- package/dist/components/ui/line-text/line-text.d.ts +3 -3
- package/dist/components/ui/line-text/line-text.d.ts.map +1 -1
- package/dist/components/ui/line-text/line-text.js.map +1 -1
- package/dist/utils/use-client-rect.js +2 -21
- package/dist/utils/use-client-rect.js.map +1 -1
- package/package.json +2 -2
- package/src/components/ads/ads-stat.tsx +3 -3
- package/src/components/charts/funnel-chart/components/funnel-chart.tsx +2 -2
- package/src/components/charts/funnel-chart/components/funnel-svg.tsx +2 -2
- package/src/components/charts/funnel-chart/funnel-chart.stories.tsx +2 -2
- package/src/components/charts/line-chart/components/body.tsx +4 -4
- package/src/components/charts/line-chart/components/container.tsx +2 -2
- package/src/components/charts/line-chart/components/hover-popover.tsx +4 -4
- package/src/components/charts/line-chart/components/sidebar.tsx +2 -2
- package/src/components/charts/line-chart/components/stuff.tsx +4 -4
- package/src/components/charts/line-chart/components/svg-bars.tsx +3 -3
- package/src/components/charts/line-chart/components/svg-body.tsx +4 -4
- package/src/components/charts/line-chart/components/svg-lines.tsx +3 -3
- package/src/components/charts/line-chart/line-chart.stories.tsx +1 -1
- package/src/components/charts/line-chart/utils/interfaces.ts +2 -2
- package/src/components/charts/pie-chart/components/pie-chart.tsx +3 -9
- package/src/components/charts/pie-chart/components/pie.tsx +8 -8
- package/src/components/charts/pie-chart/pie-chart.stories.tsx +0 -1
- package/src/components/charts/pie-chart/utils/interface.ts +2 -2
- package/src/components/image-cropper/image-cropper.stories.tsx +8 -8
- package/src/components/image-cropper/image-cropper.tsx +2 -2
- package/src/components/stat/stat-card.tsx +3 -3
- package/src/components/stat/stat-cards.stories.tsx +2 -2
- package/src/components/stat/stat-extended-card.stories.tsx +2 -2
- package/src/components/stat/stat-extended-card.tsx +1 -1
- package/src/components/ui/centered-spinner.stories.tsx +2 -2
- package/src/components/ui/centered-spinner.tsx +2 -6
- package/src/components/ui/date-range-picker/date-range-picker.stories.tsx +2 -2
- package/src/components/ui/date-range-picker/date-range-picker.tsx +1 -1
- package/src/components/ui/disabled-button.tsx +2 -2
- package/src/components/ui/line-text/line-text-body.stories.tsx +2 -2
- package/src/components/ui/line-text/line-text-head.stories.tsx +2 -2
- package/src/components/ui/line-text/line-text.tsx +3 -11
- package/src/utils/use-client-rect.ts +2 -2
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
3
|
exports.useClientRect = void 0;
|
|
23
|
-
const react_1 =
|
|
4
|
+
const react_1 = require("react");
|
|
24
5
|
const useClientRect = () => {
|
|
25
6
|
const element = (0, react_1.useRef)(null);
|
|
26
7
|
const [rect, setRect] = (0, react_1.useState)(null);
|
|
@@ -51,7 +32,7 @@ const useClientRect = () => {
|
|
|
51
32
|
}, 0);
|
|
52
33
|
return () => clearTimeout(to);
|
|
53
34
|
});
|
|
54
|
-
const ref = react_1.
|
|
35
|
+
const ref = (0, react_1.useCallback)((node) => {
|
|
55
36
|
if (node !== null) {
|
|
56
37
|
window.addEventListener('resize', handleResize);
|
|
57
38
|
setRect(node.getBoundingClientRect());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-client-rect.js","sourceRoot":"","sources":["../../src/utils/use-client-rect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-client-rect.js","sourceRoot":"","sources":["../../src/utils/use-client-rect.ts"],"names":[],"mappings":";;;AAAA,iCAAiE;AAE1D,MAAM,aAAa,GAAG,GAI3B,EAAE;IACA,MAAM,OAAO,GAAG,IAAA,cAAM,EAAqB,IAAI,CAAC,CAAC;IACjD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAiB,IAAI,CAAC,CAAC;IAEvD,MAAM,YAAY,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAClC,IAAI,OAAO,CAAC,OAAO,EAAE;YACjB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAAC;SACpD;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,IAAI,CAAC,IAAI,EAAE;YACP,OAAO;SACV;QAED;;;WAGG;QACH,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE;;YACvB,MAAM,OAAO,GAAG,MAAA,OAAO,CAAC,OAAO,0CAAE,qBAAqB,EAAE,CAAC;YAEzD,IACI,OAAO;gBACP,IAAI;gBACJ,CAAC,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK;oBACzB,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;oBAC9B,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;oBACpB,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,EAC3B;gBACE,OAAO,CAAC,OAAO,CAAC,CAAC;aACpB;QACL,CAAC,EAAE,CAAC,CAAC,CAAC;QAEN,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,IAAA,mBAAW,EACnB,CAAC,IAAwB,EAAE,EAAE;QACzB,IAAI,IAAI,KAAK,IAAI,EAAE;YACf,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YAChD,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;SACzC;aAAM;YACH,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACnD,OAAO,CAAC,IAAI,CAAC,CAAC;SACjB;QACD,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAC3B,CAAC,EACD,CAAC,YAAY,CAAC,CACjB,CAAC;IAEF,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC,CAAC;AAxDW,QAAA,aAAa,iBAwDxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/marketing-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Marketing UI component and utils",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"less": true,
|
|
51
51
|
"webpack": false
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "3c8665339ec145e4faccdc601d2d1864ad2dda5a"
|
|
54
54
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import { StatCard, StatCardProps } from '../stat/stat-card';
|
|
3
3
|
import { StatExtendedCard, StatExtendedCardProps } from '../stat/stat-extended-card';
|
|
4
4
|
import { adsStatDescriptions, AdsStatType } from '../../utils/ads-texts';
|
|
@@ -9,7 +9,7 @@ interface AdsPerformanceStatProps extends Omit<StatCardProps, 'title'> {
|
|
|
9
9
|
title?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const AdsPerformanceStatCard:
|
|
12
|
+
export const AdsPerformanceStatCard: FC<AdsPerformanceStatProps> = props => {
|
|
13
13
|
const titleText = props.title ?? camelCaseToTitleCase(props.stat);
|
|
14
14
|
const hintText = props.description ?? adsStatDescriptions[props.stat];
|
|
15
15
|
|
|
@@ -22,7 +22,7 @@ interface AdsPerformanceStatExtendedProps extends Omit<StatExtendedCardProps, 't
|
|
|
22
22
|
title2: string;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export const AdsPerformanceStatExtendedCard:
|
|
25
|
+
export const AdsPerformanceStatExtendedCard: FC<AdsPerformanceStatExtendedProps> = props => {
|
|
26
26
|
const titleText = props.title ?? camelCaseToTitleCase(props.stat);
|
|
27
27
|
const hintText = props.description ?? adsStatDescriptions[props.stat];
|
|
28
28
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo, useState, FC } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import {
|
|
4
4
|
BodyText,
|
|
@@ -19,7 +19,7 @@ import { defaultBottomSideLength, defaultTopSideLength } from '../utils/const';
|
|
|
19
19
|
import { FunnelPyramidSvg } from './funnel-svg';
|
|
20
20
|
import * as Styles from './funnel-chart.module.less';
|
|
21
21
|
|
|
22
|
-
export const FunnelChart:
|
|
22
|
+
export const FunnelChart: FC<FunnelChartProps> = ({
|
|
23
23
|
sections,
|
|
24
24
|
format,
|
|
25
25
|
topSideLength = defaultTopSideLength,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo, FC } from 'react';
|
|
2
2
|
import tokens from '@servicetitan/tokens';
|
|
3
3
|
import { defaultBottomSideLength, defaultTopSideLength } from '../utils/const';
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ export interface FunnelPyramidSvgProps {
|
|
|
10
10
|
bottomSideLength?: number;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const FunnelPyramidSvg:
|
|
13
|
+
export const FunnelPyramidSvg: FC<FunnelPyramidSvgProps> = ({
|
|
14
14
|
colors,
|
|
15
15
|
topSideLength = defaultTopSideLength,
|
|
16
16
|
bottomSideLength = defaultBottomSideLength,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
import { FunnelChart, FunnelChartPopoverContentType, FunnelChartSection } from './index';
|
|
3
3
|
import { BodyText } from '@servicetitan/design-system';
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
component: FunnelChart,
|
|
8
8
|
parameters: {},
|
|
9
9
|
};
|
|
10
|
-
const w = (cb: () =>
|
|
10
|
+
const w = (cb: () => ReactElement) => () =>
|
|
11
11
|
<div style={{ height: '300px', width: '420px' }}>{cb()}</div>;
|
|
12
12
|
|
|
13
13
|
const sections3 = (): FunnelChartSection<{ info: string[] }>[] => [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useCallback, useEffect, useMemo, FC, Fragment } from 'react';
|
|
2
2
|
import { observer } from 'mobx-react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { Stack } from '@servicetitan/design-system';
|
|
@@ -15,7 +15,7 @@ import { SvgBody, SvgBodyHover } from './svg-body';
|
|
|
15
15
|
import { HoverPopover } from './hover-popover';
|
|
16
16
|
import * as Styles from './body.module.less';
|
|
17
17
|
|
|
18
|
-
export const Body:
|
|
18
|
+
export const Body: FC<{ classNameTitle?: string }> = provide({ singletons: [SvgStore] })(
|
|
19
19
|
observer(({ classNameTitle }) => {
|
|
20
20
|
const [{ display, metrics, left, right, periods, resolution, setHoveredIndex }, svgStore] =
|
|
21
21
|
useDependencies(LineChartStore, SvgStore);
|
|
@@ -53,7 +53,7 @@ export const Body: React.FC<{ classNameTitle?: string }> = provide({ singletons:
|
|
|
53
53
|
})}
|
|
54
54
|
>
|
|
55
55
|
{periods.length ? (
|
|
56
|
-
<
|
|
56
|
+
<Fragment>
|
|
57
57
|
{periods.length !== labels.length && (
|
|
58
58
|
<div className={Styles.labelBorders}>
|
|
59
59
|
{labels
|
|
@@ -70,7 +70,7 @@ export const Body: React.FC<{ classNameTitle?: string }> = provide({ singletons:
|
|
|
70
70
|
onValueHover={onBarHover}
|
|
71
71
|
onValueLeave={onBarLeave}
|
|
72
72
|
/>
|
|
73
|
-
</
|
|
73
|
+
</Fragment>
|
|
74
74
|
) : (
|
|
75
75
|
<Stack
|
|
76
76
|
className="h-100"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useEffect, FC } from 'react';
|
|
2
2
|
import { observer } from 'mobx-react';
|
|
3
3
|
import { provide, useDependencies } from '@servicetitan/react-ioc';
|
|
4
4
|
import { LineChartProps } from '../utils/interfaces';
|
|
5
5
|
import { LineChartStore } from '../stores/line-chart.store';
|
|
6
6
|
import { Body } from './body';
|
|
7
7
|
|
|
8
|
-
export const LineChart:
|
|
8
|
+
export const LineChart: FC<LineChartProps> = provide({
|
|
9
9
|
singletons: [LineChartStore],
|
|
10
10
|
})(
|
|
11
11
|
observer(props => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useCallback, useMemo, FC, Fragment } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { observer } from 'mobx-react';
|
|
4
4
|
import { useDependencies } from '@servicetitan/react-ioc';
|
|
@@ -10,7 +10,7 @@ import { periodDateTitleFormatter } from '../utils/labels';
|
|
|
10
10
|
import * as Styles from './hover-popover.module.less';
|
|
11
11
|
import { ColorTag } from './stuff';
|
|
12
12
|
|
|
13
|
-
export const HoverPopover:
|
|
13
|
+
export const HoverPopover: FC = observer(() => {
|
|
14
14
|
const [{ periods, resolution, hoveredIndex, metrics, display }, svgStore] = useDependencies(
|
|
15
15
|
LineChartStore,
|
|
16
16
|
SvgStore
|
|
@@ -42,7 +42,7 @@ export const HoverPopover: React.FC = observer(() => {
|
|
|
42
42
|
const partialWeek = !!period.partial;
|
|
43
43
|
|
|
44
44
|
return (
|
|
45
|
-
<
|
|
45
|
+
<Fragment>
|
|
46
46
|
<div
|
|
47
47
|
className={Styles.line}
|
|
48
48
|
style={{ left: svgStore.fpx(svgStore.periodX(hoveredIndex)) + '%' }}
|
|
@@ -73,6 +73,6 @@ export const HoverPopover: React.FC = observer(() => {
|
|
|
73
73
|
)
|
|
74
74
|
)}
|
|
75
75
|
</div>
|
|
76
|
-
</
|
|
76
|
+
</Fragment>
|
|
77
77
|
);
|
|
78
78
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { Stack } from '@servicetitan/design-system';
|
|
4
4
|
import * as Styles from './sidebar.module.less';
|
|
@@ -12,7 +12,7 @@ interface SidebarProps {
|
|
|
12
12
|
right?: boolean;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const Sidebar:
|
|
15
|
+
export const Sidebar: FC<SidebarProps> = ({ settings, right, className, classNameTitle }) => {
|
|
16
16
|
const sidebarTitle = settings.title ? (
|
|
17
17
|
<Stack.Item
|
|
18
18
|
className={classNames(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CSSProperties, useMemo, FC } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { BodyText, Stack } from '@servicetitan/design-system';
|
|
4
4
|
import * as Styles from './stuff.module.less';
|
|
@@ -13,7 +13,7 @@ interface ColorTagProps {
|
|
|
13
13
|
dashed?: boolean;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const ColorTag:
|
|
16
|
+
export const ColorTag: FC<ColorTagProps> = ({ label, color, className, small, dashed }) => (
|
|
17
17
|
<Stack alignItems="center" className={className}>
|
|
18
18
|
<div
|
|
19
19
|
style={
|
|
@@ -39,7 +39,7 @@ interface MetricsTitleProps {
|
|
|
39
39
|
metrics: LineChartMetric[];
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
export const MetricsTitle:
|
|
42
|
+
export const MetricsTitle: FC<MetricsTitleProps> = ({ metrics }) => (
|
|
43
43
|
<Stack alignItems="center">
|
|
44
44
|
{metrics.map(m => (
|
|
45
45
|
<ColorTag
|
|
@@ -53,7 +53,7 @@ export const MetricsTitle: React.FC<MetricsTitleProps> = ({ metrics }) => (
|
|
|
53
53
|
</Stack>
|
|
54
54
|
);
|
|
55
55
|
|
|
56
|
-
export const XAxisLabels:
|
|
56
|
+
export const XAxisLabels: FC<{
|
|
57
57
|
labels: ChartXLabels;
|
|
58
58
|
width: number;
|
|
59
59
|
left: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import { observer } from 'mobx-react';
|
|
3
3
|
import { useDependencies } from '@servicetitan/react-ioc';
|
|
4
4
|
import { ChartMetric } from '../utils/internal-interfaces';
|
|
@@ -10,7 +10,7 @@ interface SvgBarsProps {
|
|
|
10
10
|
isStackedBarChart?: boolean;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const SvgBars:
|
|
13
|
+
export const SvgBars: FC<SvgBarsProps> = observer(({ metrics, isStackedBarChart }) => {
|
|
14
14
|
const [store] = useDependencies(SvgStore);
|
|
15
15
|
const { fpx, fpy, barWidth, length } = store;
|
|
16
16
|
const barWidthHalf = barWidth / 2;
|
|
@@ -65,7 +65,7 @@ interface SvgBarsHoverProps {
|
|
|
65
65
|
onLeave(ind: number): void;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
export const SvgBarsHover:
|
|
68
|
+
export const SvgBarsHover: FC<SvgBarsHoverProps> = observer(({ onHover, onLeave }) => {
|
|
69
69
|
const [store] = useDependencies(SvgStore);
|
|
70
70
|
const { fpx, fpy, barWidth, length } = store;
|
|
71
71
|
const barWidthHalf = barWidth / 2;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import { observer } from 'mobx-react';
|
|
3
3
|
import tokens from '@servicetitan/tokens';
|
|
4
4
|
import { useDependencies } from '@servicetitan/react-ioc';
|
|
@@ -11,7 +11,7 @@ import { SvgBars, SvgBarsHover } from './svg-bars';
|
|
|
11
11
|
import { SvgLines } from './svg-lines';
|
|
12
12
|
import * as Styles from './svg.module.less';
|
|
13
13
|
|
|
14
|
-
const SvgGrid:
|
|
14
|
+
const SvgGrid: FC = () => {
|
|
15
15
|
const lines = [];
|
|
16
16
|
|
|
17
17
|
for (let i = 1; i <= 10; i += 1) {
|
|
@@ -39,7 +39,7 @@ interface SvgBodyProps {
|
|
|
39
39
|
metrics: ChartMetric[];
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
export const SvgBody:
|
|
42
|
+
export const SvgBody: FC<SvgBodyProps> = observer(({ horizontalGrid, metrics }) => {
|
|
43
43
|
const [{ key }] = useDependencies(SvgStore);
|
|
44
44
|
const barMetrics = metrics.filter(m => m.type === 'bar');
|
|
45
45
|
const stackedBarMetrics = metrics.filter(m => m.type === 'stacked-bar');
|
|
@@ -71,7 +71,7 @@ interface SvgBodyHoverProps {
|
|
|
71
71
|
onValueLeave(ind: number): void;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
export const SvgBodyHover:
|
|
74
|
+
export const SvgBodyHover: FC<SvgBodyHoverProps> = ({ onValueHover, onValueLeave }) => (
|
|
75
75
|
<svg className={Styles.svgHover} viewBox="0 0 100 100" preserveAspectRatio="none">
|
|
76
76
|
<SvgBarsHover onHover={onValueHover} onLeave={onValueLeave} />
|
|
77
77
|
</svg>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo, FC } from 'react';
|
|
2
2
|
import { observer } from 'mobx-react';
|
|
3
3
|
import { useDependencies } from '@servicetitan/react-ioc';
|
|
4
4
|
import { ChartMetric } from '../utils/internal-interfaces';
|
|
@@ -11,7 +11,7 @@ interface SvgLineProps {
|
|
|
11
11
|
dashed: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const SvgLine:
|
|
14
|
+
const SvgLine: FC<SvgLineProps> = ({ color, points, dashed }) => (
|
|
15
15
|
<path
|
|
16
16
|
className={Styles.line}
|
|
17
17
|
d={points.map(([px, py], ind) => (ind === 0 ? 'M' : 'L') + `${px} ${py}`).join(' ')}
|
|
@@ -26,7 +26,7 @@ interface SvgLinesProps {
|
|
|
26
26
|
metrics: ChartMetric[];
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export const SvgLines:
|
|
29
|
+
export const SvgLines: FC<SvgLinesProps> = observer(({ metrics }) => {
|
|
30
30
|
const [store] = useDependencies(SvgStore);
|
|
31
31
|
|
|
32
32
|
const lines = useMemo(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
|
|
3
3
|
export type LineChartResolution = 'hour' | 'day' | 'week' | 'month';
|
|
4
4
|
export type LineChartMetricType = 'line' | 'bar' | 'stacked-bar';
|
|
@@ -74,7 +74,7 @@ export interface LineChartProps extends LineChartData {
|
|
|
74
74
|
|
|
75
75
|
export interface LineChartCardProps extends LineChartProps {
|
|
76
76
|
title: string;
|
|
77
|
-
headerRight?:
|
|
77
|
+
headerRight?: ReactElement;
|
|
78
78
|
loading?: boolean;
|
|
79
79
|
grayControls?: boolean;
|
|
80
80
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo, FC } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { BodyText, Stack, StatusLight } from '@servicetitan/design-system';
|
|
4
4
|
import { PieChartProps, PiePiece } from '../utils/interface';
|
|
@@ -6,7 +6,7 @@ import { convertSessionsToPieces } from '../utils/const';
|
|
|
6
6
|
import { Pie } from './pie';
|
|
7
7
|
import * as Styles from './pie-chart.module.less';
|
|
8
8
|
|
|
9
|
-
const PieTitles:
|
|
9
|
+
const PieTitles: FC<{ title: string; pieces: PiePiece[] }> = ({ title, pieces }) => {
|
|
10
10
|
return (
|
|
11
11
|
<div className={classNames(Styles.titleWrapper, 'of-y-auto p-t-2')}>
|
|
12
12
|
<div>
|
|
@@ -28,13 +28,7 @@ const PieTitles: React.FC<{ title: string; pieces: PiePiece[] }> = ({ title, pie
|
|
|
28
28
|
);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
export const PieChart:
|
|
32
|
-
height,
|
|
33
|
-
width,
|
|
34
|
-
title,
|
|
35
|
-
sections,
|
|
36
|
-
popoverContent,
|
|
37
|
-
}) => {
|
|
31
|
+
export const PieChart: FC<PieChartProps> = ({ height, width, title, sections, popoverContent }) => {
|
|
38
32
|
const pieces = useMemo(() => convertSessionsToPieces(sections), [sections]);
|
|
39
33
|
const style = useMemo(() => ({ height, width }), [height, width]);
|
|
40
34
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useCallback, useMemo, useState, FC, Fragment } from 'react';
|
|
2
2
|
import tokens from '@servicetitan/tokens';
|
|
3
3
|
import { BodyText, Popover, Stack, StatusLight } from '@servicetitan/design-system';
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ import { PieChartPopoverContentType, PiePiece } from '../utils/interface';
|
|
|
9
9
|
const chartPadding = 8;
|
|
10
10
|
const px = (value?: number) => `${value ?? 0}px`;
|
|
11
11
|
|
|
12
|
-
const PiePieceSvg:
|
|
12
|
+
const PiePieceSvg: FC<{
|
|
13
13
|
piece: PiePiece;
|
|
14
14
|
selected?: boolean;
|
|
15
15
|
}> = ({ piece: { id, color, opacity, points, text, path }, selected }) =>
|
|
@@ -48,7 +48,7 @@ const PiePieceSvg: React.FC<{
|
|
|
48
48
|
</g>
|
|
49
49
|
) : null;
|
|
50
50
|
|
|
51
|
-
const PiePieceHover:
|
|
51
|
+
const PiePieceHover: FC<{
|
|
52
52
|
piece: PiePiece;
|
|
53
53
|
onMouse(id: string, isEnter: boolean): void;
|
|
54
54
|
}> = ({ piece, onMouse }) => {
|
|
@@ -66,7 +66,7 @@ const PiePieceHover: React.FC<{
|
|
|
66
66
|
);
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
const PieSvg:
|
|
69
|
+
const PieSvg: FC<{
|
|
70
70
|
pieces: PiePiece[];
|
|
71
71
|
selectedIndex: number;
|
|
72
72
|
}> = ({ pieces, selectedIndex }) => (
|
|
@@ -87,7 +87,7 @@ const PieSvg: React.FC<{
|
|
|
87
87
|
</svg>
|
|
88
88
|
);
|
|
89
89
|
|
|
90
|
-
const PieSvgHover:
|
|
90
|
+
const PieSvgHover: FC<{
|
|
91
91
|
pieces: PiePiece[];
|
|
92
92
|
onMouse(id: string, isEnter: boolean): void;
|
|
93
93
|
}> = ({ pieces, onMouse }) => (
|
|
@@ -104,7 +104,7 @@ const PieSvgHover: React.FC<{
|
|
|
104
104
|
</svg>
|
|
105
105
|
);
|
|
106
106
|
|
|
107
|
-
export const Pie:
|
|
107
|
+
export const Pie: FC<{
|
|
108
108
|
title: string;
|
|
109
109
|
pieces: PiePiece[];
|
|
110
110
|
popoverContent?: PieChartPopoverContentType;
|
|
@@ -163,7 +163,7 @@ export const Pie: React.FC<{
|
|
|
163
163
|
No Data
|
|
164
164
|
</Stack>
|
|
165
165
|
) : (
|
|
166
|
-
<
|
|
166
|
+
<Fragment>
|
|
167
167
|
{triggersStyles
|
|
168
168
|
.filter(ts => !!ts.left && !!ts.top)
|
|
169
169
|
.map((ts, ind) => (
|
|
@@ -202,7 +202,7 @@ export const Pie: React.FC<{
|
|
|
202
202
|
|
|
203
203
|
<PieSvg pieces={pieces} selectedIndex={selectedIndex} />
|
|
204
204
|
<PieSvgHover pieces={pieces} onMouse={onMouse} />
|
|
205
|
-
</
|
|
205
|
+
</Fragment>
|
|
206
206
|
)}
|
|
207
207
|
</div>
|
|
208
208
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
|
|
3
3
|
export interface PieChartSection<T> {
|
|
4
4
|
title: string;
|
|
@@ -7,7 +7,7 @@ export interface PieChartSection<T> {
|
|
|
7
7
|
data?: T;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export type PieChartPopoverContentType<T = any> =
|
|
10
|
+
export type PieChartPopoverContentType<T = any> = FC<{
|
|
11
11
|
index: number;
|
|
12
12
|
value: number;
|
|
13
13
|
data?: T;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC, ChangeEvent, useRef, useState, Fragment } from 'react';
|
|
2
2
|
import { ImageCropper } from './image-cropper';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
@@ -7,13 +7,13 @@ export default {
|
|
|
7
7
|
parameters: {},
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
const BasicExample:
|
|
11
|
-
const [imageToEdit, setImageToEdit] =
|
|
12
|
-
const [croppedImage, setCroppedImage] =
|
|
10
|
+
const BasicExample: FC = () => {
|
|
11
|
+
const [imageToEdit, setImageToEdit] = useState<File>();
|
|
12
|
+
const [croppedImage, setCroppedImage] = useState<string>();
|
|
13
13
|
|
|
14
|
-
const imageCropper =
|
|
14
|
+
const imageCropper = useRef<ImageCropper>(null);
|
|
15
15
|
|
|
16
|
-
const handleFileChange = (e:
|
|
16
|
+
const handleFileChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
17
17
|
const file = e.target.files?.[0];
|
|
18
18
|
if (!file) {
|
|
19
19
|
return;
|
|
@@ -38,7 +38,7 @@ const BasicExample: React.FC = () => {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
return (
|
|
41
|
-
<
|
|
41
|
+
<Fragment>
|
|
42
42
|
<input type="file" accept="image/png, image/jpeg" onChange={handleFileChange} />
|
|
43
43
|
{imageToEdit && (
|
|
44
44
|
<div style={{ marginTop: 30 }}>
|
|
@@ -62,7 +62,7 @@ const BasicExample: React.FC = () => {
|
|
|
62
62
|
</div>
|
|
63
63
|
</div>
|
|
64
64
|
)}
|
|
65
|
-
</
|
|
65
|
+
</Fragment>
|
|
66
66
|
);
|
|
67
67
|
};
|
|
68
68
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Component } from 'react';
|
|
2
2
|
import { observable, action, makeObservable } from 'mobx';
|
|
3
3
|
import { observer } from 'mobx-react';
|
|
4
4
|
import ReactCrop, { Crop } from 'react-image-crop';
|
|
@@ -13,7 +13,7 @@ interface ImageCropperProps {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
@observer
|
|
16
|
-
export class ImageCropper extends
|
|
16
|
+
export class ImageCropper extends Component<ImageCropperProps> {
|
|
17
17
|
@observable private src?: string;
|
|
18
18
|
@observable private crop?: Crop;
|
|
19
19
|
@observable private image?: HTMLImageElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import {
|
|
4
4
|
BodyText,
|
|
@@ -44,7 +44,7 @@ interface StatDiffProps {
|
|
|
44
44
|
className?: string;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
export const StatDiff:
|
|
47
|
+
export const StatDiff: FC<StatDiffProps> = ({
|
|
48
48
|
value,
|
|
49
49
|
prev,
|
|
50
50
|
size,
|
|
@@ -103,7 +103,7 @@ export interface StatCardProps {
|
|
|
103
103
|
className?: string;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
export const StatCard:
|
|
106
|
+
export const StatCard: FC<StatCardProps> = ({
|
|
107
107
|
title,
|
|
108
108
|
description,
|
|
109
109
|
value,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
import { StatCard } from './stat-card';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
parameters: {},
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
const w = (cb: () =>
|
|
10
|
+
const w = (cb: () => ReactElement) => () => <div style={{ width: '400px' }}>{cb()}</div>;
|
|
11
11
|
|
|
12
12
|
export const statCardNumber = w(() => <StatCard title="number" value={133} prev={1000} />);
|
|
13
13
|
export const statCardMoney = w(() => <StatCard title="money" value={10000} prev={11000} money />);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
import { StatExtendedCard } from './stat-extended-card';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
parameters: {},
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
const w = (cb: () =>
|
|
10
|
+
const w = (cb: () => ReactElement) => () => <div style={{ width: '400px' }}>{cb()}</div>;
|
|
11
11
|
|
|
12
12
|
export const statCardMoneyWithPrev = w(() => (
|
|
13
13
|
<StatExtendedCard
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
import { CenteredSpinner } from './centered-spinner';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
parameters: {},
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
const w = (style: { width?: string; height?: string }, cb: () =>
|
|
10
|
+
const w = (style: { width?: string; height?: string }, cb: () => ReactElement) => () =>
|
|
11
11
|
<div style={style}>{cb()}</div>;
|
|
12
12
|
|
|
13
13
|
export const centeredSpinnerTiny = w({}, () => <CenteredSpinner size="tiny" />);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import { BodyText, Stack, Spinner } from '@servicetitan/design-system';
|
|
4
4
|
|
|
@@ -9,11 +9,7 @@ export interface CenteredSpinnerPropsStrict {
|
|
|
9
9
|
info?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const CenteredSpinner:
|
|
13
|
-
size,
|
|
14
|
-
className,
|
|
15
|
-
info,
|
|
16
|
-
}) => {
|
|
12
|
+
export const CenteredSpinner: FC<CenteredSpinnerPropsStrict> = ({ size, className, info }) => {
|
|
17
13
|
return (
|
|
18
14
|
<Stack
|
|
19
15
|
justifyContent="center"
|