@servicetitan/marketing-ui 1.6.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 +4 -4
- 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 +4 -4
- 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 +4 -4
- 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 +5 -5
- 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 +12 -12
- package/dist/components/charts/line-chart/components/body.js.map +1 -1
- package/dist/components/charts/line-chart/components/body.module.less +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 +5 -5
- 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 +8 -8
- package/dist/components/charts/line-chart/components/hover-popover.js.map +1 -1
- package/dist/components/charts/line-chart/components/hover-popover.module.less +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 +3 -3
- package/dist/components/charts/line-chart/components/sidebar.js.map +1 -1
- package/dist/components/charts/line-chart/components/sidebar.module.less +2 -2
- 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 +6 -6
- 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 +9 -9
- 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 +6 -6
- 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 +5 -5
- 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 +7 -7
- package/dist/components/charts/line-chart/line-chart.stories.js.map +1 -1
- package/dist/components/charts/line-chart/stores/line-chart.store.js +5 -5
- package/dist/components/charts/line-chart/stores/line-chart.store.js.map +1 -1
- package/dist/components/charts/line-chart/stores/svg.store.js +2 -2
- package/dist/components/charts/line-chart/stores/svg.store.js.map +1 -1
- package/dist/components/charts/line-chart/utils/formatters.js +2 -2
- package/dist/components/charts/line-chart/utils/formatters.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/line-chart/utils/labels.js +16 -16
- package/dist/components/charts/line-chart/utils/labels.js.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 +5 -5
- 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 +15 -34
- 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 +3 -3
- package/dist/components/charts/pie-chart/pie-chart.stories.js.map +1 -1
- package/dist/components/charts/pie-chart/utils/const.js +1 -1
- package/dist/components/charts/pie-chart/utils/const.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 +4 -4
- package/dist/components/image-cropper/image-cropper.js.map +1 -1
- package/dist/components/image-cropper/image-cropper.stories.js +6 -9
- 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 +10 -9
- package/dist/components/stat/stat-card.js.map +1 -1
- package/dist/components/stat/stat-card.module.less +7 -0
- 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 +5 -5
- 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.js +22 -2
- package/dist/components/stat/stat-extended-card.js.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 +4 -4
- 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 +2 -2
- 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 +4 -4
- package/dist/components/ui/centered-spinner.stories.js.map +1 -1
- package/dist/components/ui/date-range-picker/date-range-picker.js +5 -5
- 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 +1 -1
- package/dist/components/ui/date-range-picker/date-range-picker.stories.js +3 -3
- 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 +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 +3 -3
- 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 +3 -3
- 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 +7 -7
- package/dist/components/ui/line-text/line-text.js.map +1 -1
- package/dist/utils/date/date-range-picker-options.js +2 -2
- package/dist/utils/date/date-range-picker-options.js.map +1 -1
- package/dist/utils/date/date-range-picker-state.js +1 -1
- package/dist/utils/date/date-range-picker-state.js.map +1 -1
- package/dist/utils/date/date.js +1 -1
- package/dist/utils/date/date.js.map +1 -1
- package/dist/utils/formatters.js +8 -8
- package/dist/utils/formatters.js.map +1 -1
- package/dist/utils/use-client-rect.js +6 -25
- 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.module.less +1 -1
- package/src/components/charts/line-chart/components/body.tsx +5 -5
- package/src/components/charts/line-chart/components/container.tsx +2 -2
- package/src/components/charts/line-chart/components/hover-popover.module.less +1 -1
- package/src/components/charts/line-chart/components/hover-popover.tsx +4 -4
- package/src/components/charts/line-chart/components/sidebar.module.less +2 -2
- package/src/components/charts/line-chart/components/sidebar.tsx +2 -2
- package/src/components/charts/line-chart/components/stuff.tsx +5 -5
- 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.module.less +7 -0
- package/src/components/stat/stat-card.module.less.d.ts +1 -0
- package/src/components/stat/stat-card.tsx +6 -4
- 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 +5 -4
- 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.module.less +1 -1
- 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/__tests__/formatters.test.ts +1 -1
- package/src/utils/formatters.ts +1 -1
- package/src/utils/use-client-rect.ts +2 -2
|
@@ -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,
|
|
@@ -55,7 +55,8 @@ export const StatDiff: React.FC<StatDiffProps> = ({
|
|
|
55
55
|
}) => {
|
|
56
56
|
const percents = format === 'percent';
|
|
57
57
|
const [absDiff, diffPercent, isIncrease] = calculateDiff(value ?? 0, prev ?? 0, percents);
|
|
58
|
-
|
|
58
|
+
const diff = absDiff === 0 ? '' : isIncrease ? '▲ ' : '▼ ';
|
|
59
|
+
let text = '';
|
|
59
60
|
|
|
60
61
|
if (percents) {
|
|
61
62
|
text += formatDifferencePercentage(absDiff, isIncrease);
|
|
@@ -80,6 +81,7 @@ export const StatDiff: React.FC<StatDiffProps> = ({
|
|
|
80
81
|
)}
|
|
81
82
|
size={size ?? 'small'}
|
|
82
83
|
>
|
|
84
|
+
<span>{diff}</span>
|
|
83
85
|
{value === undefined ? '\u00A0' : text}
|
|
84
86
|
</BodyText>
|
|
85
87
|
);
|
|
@@ -101,7 +103,7 @@ export interface StatCardProps {
|
|
|
101
103
|
className?: string;
|
|
102
104
|
}
|
|
103
105
|
|
|
104
|
-
export const StatCard:
|
|
106
|
+
export const StatCard: FC<StatCardProps> = ({
|
|
105
107
|
title,
|
|
106
108
|
description,
|
|
107
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,8 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { BodyText, Icon, Headline, Eyebrow, Stack, Tooltip } from '@servicetitan/design-system';
|
|
4
4
|
import { formatValue } from '../../utils/formatters';
|
|
5
5
|
import { StatDiff } from './stat-card';
|
|
6
|
+
import * as Styles from './stat-card.module.less';
|
|
6
7
|
|
|
7
8
|
export interface StatExtendedCardProps {
|
|
8
9
|
title: string;
|
|
@@ -54,11 +55,11 @@ export const StatExtendedCard: FC<StatExtendedCardProps> = ({
|
|
|
54
55
|
</Tooltip>
|
|
55
56
|
)}
|
|
56
57
|
</Stack>
|
|
57
|
-
<Eyebrow size="small" className="m-t-
|
|
58
|
+
<Eyebrow size="small" className="m-t-2 c-black">
|
|
58
59
|
{title2}
|
|
59
60
|
</Eyebrow>
|
|
60
61
|
|
|
61
|
-
<Stack justifyContent="space-between">
|
|
62
|
+
<Stack justifyContent="space-between" className="m-t-half">
|
|
62
63
|
<Stack alignItems="flex-end" className="flex-grow-1 flex-basis-0">
|
|
63
64
|
<Headline className="m-b-0-i m-r-half fw-normal-i" size="xlarge">
|
|
64
65
|
{formatValue(value, format)}
|
|
@@ -72,7 +73,7 @@ export const StatExtendedCard: FC<StatExtendedCardProps> = ({
|
|
|
72
73
|
format={format}
|
|
73
74
|
inverted={inverted}
|
|
74
75
|
neutral={neutral}
|
|
75
|
-
className=
|
|
76
|
+
className={classNames(Styles.statExtendedDiff, 'm-l-1')}
|
|
76
77
|
/>
|
|
77
78
|
) : undefined}
|
|
78
79
|
</Stack>
|
|
@@ -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"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import { DateRangePicker } from './date-range-picker';
|
|
3
3
|
import { DateRangePickerState, DateRangePickerOptionsTenantAds } from '../../../utils/date';
|
|
4
4
|
|
|
@@ -11,7 +11,7 @@ export default {
|
|
|
11
11
|
const tz = { UtcOffset: 0 };
|
|
12
12
|
const state = DateRangePickerState.createWithOptions(DateRangePickerOptionsTenantAds.create(tz));
|
|
13
13
|
|
|
14
|
-
const w = (style: { width?: string; height?: string }, Component:
|
|
14
|
+
const w = (style: { width?: string; height?: string }, Component: FC) => () =>
|
|
15
15
|
(
|
|
16
16
|
<div style={style}>
|
|
17
17
|
<Component />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import { Button, ButtonProps, Tooltip } from '@servicetitan/design-system';
|
|
3
3
|
|
|
4
4
|
interface DisabledButtonProps extends Omit<ButtonProps, 'disabled'> {
|
|
@@ -14,7 +14,7 @@ interface DisabledButtonProps extends Omit<ButtonProps, 'disabled'> {
|
|
|
14
14
|
* <DisabledButton disabled="This button is disabled">knock knock</Button>
|
|
15
15
|
* )
|
|
16
16
|
*/
|
|
17
|
-
export const DisabledButton:
|
|
17
|
+
export const DisabledButton: FC<DisabledButtonProps> = props => {
|
|
18
18
|
return props.disabled && props.disabled !== true ? (
|
|
19
19
|
<Tooltip text={props.disabled}>
|
|
20
20
|
<Button {...props} disabled />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
import { BodyTextLine } from './line-text';
|
|
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 }, cb: () =>
|
|
10
|
+
const w = (style: { width?: string }, cb: () => ReactElement) => () =>
|
|
11
11
|
<div style={style}>{cb()}</div>;
|
|
12
12
|
|
|
13
13
|
export const bodyTextLineUnlimited = w({}, () => <BodyTextLine>just a simple text</BodyTextLine>);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
import { HeadlineLine } from './line-text';
|
|
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 }, cb: () =>
|
|
10
|
+
const w = (style: { width?: string }, cb: () => ReactElement) => () =>
|
|
11
11
|
<div style={style}>{cb()}</div>;
|
|
12
12
|
|
|
13
13
|
export const headlineLineUnlimited = w({}, () => <HeadlineLine>just a simple text</HeadlineLine>);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo, FC } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import {
|
|
4
4
|
BodyText,
|
|
@@ -30,11 +30,7 @@ export interface BodyTextLineProps extends BodyTextPropsStrict {
|
|
|
30
30
|
children?: string;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export const BodyTextLine:
|
|
34
|
-
children,
|
|
35
|
-
wrapperClassName,
|
|
36
|
-
...props
|
|
37
|
-
}) => {
|
|
33
|
+
export const BodyTextLine: FC<BodyTextLineProps> = ({ children, wrapperClassName, ...props }) => {
|
|
38
34
|
const [ref1, ref2, limited] = useLimited();
|
|
39
35
|
|
|
40
36
|
return (
|
|
@@ -79,11 +75,7 @@ export interface HeadlineLineProps extends HeadlinePropsStrict {
|
|
|
79
75
|
children?: string;
|
|
80
76
|
}
|
|
81
77
|
|
|
82
|
-
export const HeadlineLine:
|
|
83
|
-
children,
|
|
84
|
-
wrapperClassName,
|
|
85
|
-
...props
|
|
86
|
-
}) => {
|
|
78
|
+
export const HeadlineLine: FC<HeadlineLineProps> = ({ children, wrapperClassName, ...props }) => {
|
|
87
79
|
const [ref1, ref2, limited] = useLimited();
|
|
88
80
|
|
|
89
81
|
return (
|
package/src/utils/formatters.ts
CHANGED
|
@@ -7,7 +7,7 @@ const formatPercentValue = (value: number): string => {
|
|
|
7
7
|
return '0';
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
const valueMain = value ? Math.abs(Math.
|
|
10
|
+
const valueMain = value ? Math.abs(Math.round(value)) : 0;
|
|
11
11
|
|
|
12
12
|
if (valueMain > 0) {
|
|
13
13
|
return accounting.formatNumber(valueMain, 0);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
export const useClientRect = (): [
|
|
4
4
|
DOMRect | null,
|
|
@@ -41,7 +41,7 @@ export const useClientRect = (): [
|
|
|
41
41
|
return () => clearTimeout(to);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
const ref =
|
|
44
|
+
const ref = useCallback(
|
|
45
45
|
(node: HTMLElement | null) => {
|
|
46
46
|
if (node !== null) {
|
|
47
47
|
window.addEventListener('resize', handleResize);
|