@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.
Files changed (184) hide show
  1. package/dist/components/ads/ads-stat.d.ts +3 -3
  2. package/dist/components/ads/ads-stat.d.ts.map +1 -1
  3. package/dist/components/ads/ads-stat.js +4 -4
  4. package/dist/components/ads/ads-stat.js.map +1 -1
  5. package/dist/components/charts/funnel-chart/components/funnel-chart.d.ts +2 -2
  6. package/dist/components/charts/funnel-chart/components/funnel-chart.d.ts.map +1 -1
  7. package/dist/components/charts/funnel-chart/components/funnel-chart.js +4 -4
  8. package/dist/components/charts/funnel-chart/components/funnel-chart.js.map +1 -1
  9. package/dist/components/charts/funnel-chart/components/funnel-svg.d.ts +2 -2
  10. package/dist/components/charts/funnel-chart/components/funnel-svg.d.ts.map +1 -1
  11. package/dist/components/charts/funnel-chart/components/funnel-svg.js +4 -4
  12. package/dist/components/charts/funnel-chart/components/funnel-svg.js.map +1 -1
  13. package/dist/components/charts/funnel-chart/funnel-chart.stories.d.ts +2 -2
  14. package/dist/components/charts/funnel-chart/funnel-chart.stories.d.ts.map +1 -1
  15. package/dist/components/charts/funnel-chart/funnel-chart.stories.js +5 -5
  16. package/dist/components/charts/funnel-chart/funnel-chart.stories.js.map +1 -1
  17. package/dist/components/charts/line-chart/components/body.d.ts +2 -2
  18. package/dist/components/charts/line-chart/components/body.d.ts.map +1 -1
  19. package/dist/components/charts/line-chart/components/body.js +12 -12
  20. package/dist/components/charts/line-chart/components/body.js.map +1 -1
  21. package/dist/components/charts/line-chart/components/body.module.less +1 -1
  22. package/dist/components/charts/line-chart/components/container.d.ts +2 -2
  23. package/dist/components/charts/line-chart/components/container.d.ts.map +1 -1
  24. package/dist/components/charts/line-chart/components/container.js +5 -5
  25. package/dist/components/charts/line-chart/components/container.js.map +1 -1
  26. package/dist/components/charts/line-chart/components/hover-popover.d.ts +2 -2
  27. package/dist/components/charts/line-chart/components/hover-popover.d.ts.map +1 -1
  28. package/dist/components/charts/line-chart/components/hover-popover.js +8 -8
  29. package/dist/components/charts/line-chart/components/hover-popover.js.map +1 -1
  30. package/dist/components/charts/line-chart/components/hover-popover.module.less +1 -1
  31. package/dist/components/charts/line-chart/components/sidebar.d.ts +2 -2
  32. package/dist/components/charts/line-chart/components/sidebar.d.ts.map +1 -1
  33. package/dist/components/charts/line-chart/components/sidebar.js +3 -3
  34. package/dist/components/charts/line-chart/components/sidebar.js.map +1 -1
  35. package/dist/components/charts/line-chart/components/sidebar.module.less +2 -2
  36. package/dist/components/charts/line-chart/components/stuff.d.ts +4 -4
  37. package/dist/components/charts/line-chart/components/stuff.d.ts.map +1 -1
  38. package/dist/components/charts/line-chart/components/stuff.js +6 -6
  39. package/dist/components/charts/line-chart/components/stuff.js.map +1 -1
  40. package/dist/components/charts/line-chart/components/svg-bars.d.ts +3 -3
  41. package/dist/components/charts/line-chart/components/svg-bars.d.ts.map +1 -1
  42. package/dist/components/charts/line-chart/components/svg-bars.js +9 -9
  43. package/dist/components/charts/line-chart/components/svg-bars.js.map +1 -1
  44. package/dist/components/charts/line-chart/components/svg-body.d.ts +3 -3
  45. package/dist/components/charts/line-chart/components/svg-body.d.ts.map +1 -1
  46. package/dist/components/charts/line-chart/components/svg-body.js +6 -6
  47. package/dist/components/charts/line-chart/components/svg-body.js.map +1 -1
  48. package/dist/components/charts/line-chart/components/svg-lines.d.ts +2 -2
  49. package/dist/components/charts/line-chart/components/svg-lines.d.ts.map +1 -1
  50. package/dist/components/charts/line-chart/components/svg-lines.js +5 -5
  51. package/dist/components/charts/line-chart/components/svg-lines.js.map +1 -1
  52. package/dist/components/charts/line-chart/line-chart.stories.d.ts +2 -2
  53. package/dist/components/charts/line-chart/line-chart.stories.d.ts.map +1 -1
  54. package/dist/components/charts/line-chart/line-chart.stories.js +7 -7
  55. package/dist/components/charts/line-chart/line-chart.stories.js.map +1 -1
  56. package/dist/components/charts/line-chart/stores/line-chart.store.js +5 -5
  57. package/dist/components/charts/line-chart/stores/line-chart.store.js.map +1 -1
  58. package/dist/components/charts/line-chart/stores/svg.store.js +2 -2
  59. package/dist/components/charts/line-chart/stores/svg.store.js.map +1 -1
  60. package/dist/components/charts/line-chart/utils/formatters.js +2 -2
  61. package/dist/components/charts/line-chart/utils/formatters.js.map +1 -1
  62. package/dist/components/charts/line-chart/utils/interfaces.d.ts +2 -2
  63. package/dist/components/charts/line-chart/utils/interfaces.d.ts.map +1 -1
  64. package/dist/components/charts/line-chart/utils/labels.js +16 -16
  65. package/dist/components/charts/line-chart/utils/labels.js.map +1 -1
  66. package/dist/components/charts/pie-chart/components/pie-chart.d.ts +2 -2
  67. package/dist/components/charts/pie-chart/components/pie-chart.d.ts.map +1 -1
  68. package/dist/components/charts/pie-chart/components/pie-chart.js +5 -5
  69. package/dist/components/charts/pie-chart/components/pie-chart.js.map +1 -1
  70. package/dist/components/charts/pie-chart/components/pie.d.ts +2 -2
  71. package/dist/components/charts/pie-chart/components/pie.d.ts.map +1 -1
  72. package/dist/components/charts/pie-chart/components/pie.js +15 -34
  73. package/dist/components/charts/pie-chart/components/pie.js.map +1 -1
  74. package/dist/components/charts/pie-chart/pie-chart.stories.d.ts +2 -2
  75. package/dist/components/charts/pie-chart/pie-chart.stories.d.ts.map +1 -1
  76. package/dist/components/charts/pie-chart/pie-chart.stories.js +3 -3
  77. package/dist/components/charts/pie-chart/pie-chart.stories.js.map +1 -1
  78. package/dist/components/charts/pie-chart/utils/const.js +1 -1
  79. package/dist/components/charts/pie-chart/utils/const.js.map +1 -1
  80. package/dist/components/charts/pie-chart/utils/interface.d.ts +2 -2
  81. package/dist/components/charts/pie-chart/utils/interface.d.ts.map +1 -1
  82. package/dist/components/image-cropper/image-cropper.d.ts +2 -2
  83. package/dist/components/image-cropper/image-cropper.d.ts.map +1 -1
  84. package/dist/components/image-cropper/image-cropper.js +4 -4
  85. package/dist/components/image-cropper/image-cropper.js.map +1 -1
  86. package/dist/components/image-cropper/image-cropper.stories.js +6 -9
  87. package/dist/components/image-cropper/image-cropper.stories.js.map +1 -1
  88. package/dist/components/stat/stat-card.d.ts +3 -3
  89. package/dist/components/stat/stat-card.d.ts.map +1 -1
  90. package/dist/components/stat/stat-card.js +10 -9
  91. package/dist/components/stat/stat-card.js.map +1 -1
  92. package/dist/components/stat/stat-card.module.less +7 -0
  93. package/dist/components/stat/stat-cards.stories.d.ts +2 -2
  94. package/dist/components/stat/stat-cards.stories.d.ts.map +1 -1
  95. package/dist/components/stat/stat-cards.stories.js +5 -5
  96. package/dist/components/stat/stat-cards.stories.js.map +1 -1
  97. package/dist/components/stat/stat-extended-card.d.ts.map +1 -1
  98. package/dist/components/stat/stat-extended-card.js +22 -2
  99. package/dist/components/stat/stat-extended-card.js.map +1 -1
  100. package/dist/components/stat/stat-extended-card.stories.d.ts +2 -2
  101. package/dist/components/stat/stat-extended-card.stories.d.ts.map +1 -1
  102. package/dist/components/stat/stat-extended-card.stories.js +4 -4
  103. package/dist/components/stat/stat-extended-card.stories.js.map +1 -1
  104. package/dist/components/ui/centered-spinner.d.ts +2 -2
  105. package/dist/components/ui/centered-spinner.d.ts.map +1 -1
  106. package/dist/components/ui/centered-spinner.js +2 -2
  107. package/dist/components/ui/centered-spinner.js.map +1 -1
  108. package/dist/components/ui/centered-spinner.stories.d.ts +2 -2
  109. package/dist/components/ui/centered-spinner.stories.d.ts.map +1 -1
  110. package/dist/components/ui/centered-spinner.stories.js +4 -4
  111. package/dist/components/ui/centered-spinner.stories.js.map +1 -1
  112. package/dist/components/ui/date-range-picker/date-range-picker.js +5 -5
  113. package/dist/components/ui/date-range-picker/date-range-picker.js.map +1 -1
  114. package/dist/components/ui/date-range-picker/date-range-picker.module.less +1 -1
  115. package/dist/components/ui/date-range-picker/date-range-picker.stories.js +3 -3
  116. package/dist/components/ui/date-range-picker/date-range-picker.stories.js.map +1 -1
  117. package/dist/components/ui/disabled-button.d.ts +2 -2
  118. package/dist/components/ui/disabled-button.d.ts.map +1 -1
  119. package/dist/components/ui/disabled-button.js +1 -1
  120. package/dist/components/ui/disabled-button.js.map +1 -1
  121. package/dist/components/ui/line-text/line-text-body.stories.d.ts +2 -2
  122. package/dist/components/ui/line-text/line-text-body.stories.d.ts.map +1 -1
  123. package/dist/components/ui/line-text/line-text-body.stories.js +3 -3
  124. package/dist/components/ui/line-text/line-text-body.stories.js.map +1 -1
  125. package/dist/components/ui/line-text/line-text-head.stories.d.ts +2 -2
  126. package/dist/components/ui/line-text/line-text-head.stories.d.ts.map +1 -1
  127. package/dist/components/ui/line-text/line-text-head.stories.js +3 -3
  128. package/dist/components/ui/line-text/line-text-head.stories.js.map +1 -1
  129. package/dist/components/ui/line-text/line-text.d.ts +3 -3
  130. package/dist/components/ui/line-text/line-text.d.ts.map +1 -1
  131. package/dist/components/ui/line-text/line-text.js +7 -7
  132. package/dist/components/ui/line-text/line-text.js.map +1 -1
  133. package/dist/utils/date/date-range-picker-options.js +2 -2
  134. package/dist/utils/date/date-range-picker-options.js.map +1 -1
  135. package/dist/utils/date/date-range-picker-state.js +1 -1
  136. package/dist/utils/date/date-range-picker-state.js.map +1 -1
  137. package/dist/utils/date/date.js +1 -1
  138. package/dist/utils/date/date.js.map +1 -1
  139. package/dist/utils/formatters.js +8 -8
  140. package/dist/utils/formatters.js.map +1 -1
  141. package/dist/utils/use-client-rect.js +6 -25
  142. package/dist/utils/use-client-rect.js.map +1 -1
  143. package/package.json +2 -2
  144. package/src/components/ads/ads-stat.tsx +3 -3
  145. package/src/components/charts/funnel-chart/components/funnel-chart.tsx +2 -2
  146. package/src/components/charts/funnel-chart/components/funnel-svg.tsx +2 -2
  147. package/src/components/charts/funnel-chart/funnel-chart.stories.tsx +2 -2
  148. package/src/components/charts/line-chart/components/body.module.less +1 -1
  149. package/src/components/charts/line-chart/components/body.tsx +5 -5
  150. package/src/components/charts/line-chart/components/container.tsx +2 -2
  151. package/src/components/charts/line-chart/components/hover-popover.module.less +1 -1
  152. package/src/components/charts/line-chart/components/hover-popover.tsx +4 -4
  153. package/src/components/charts/line-chart/components/sidebar.module.less +2 -2
  154. package/src/components/charts/line-chart/components/sidebar.tsx +2 -2
  155. package/src/components/charts/line-chart/components/stuff.tsx +5 -5
  156. package/src/components/charts/line-chart/components/svg-bars.tsx +3 -3
  157. package/src/components/charts/line-chart/components/svg-body.tsx +4 -4
  158. package/src/components/charts/line-chart/components/svg-lines.tsx +3 -3
  159. package/src/components/charts/line-chart/line-chart.stories.tsx +1 -1
  160. package/src/components/charts/line-chart/utils/interfaces.ts +2 -2
  161. package/src/components/charts/pie-chart/components/pie-chart.tsx +3 -9
  162. package/src/components/charts/pie-chart/components/pie.tsx +8 -8
  163. package/src/components/charts/pie-chart/pie-chart.stories.tsx +0 -1
  164. package/src/components/charts/pie-chart/utils/interface.ts +2 -2
  165. package/src/components/image-cropper/image-cropper.stories.tsx +8 -8
  166. package/src/components/image-cropper/image-cropper.tsx +2 -2
  167. package/src/components/stat/stat-card.module.less +7 -0
  168. package/src/components/stat/stat-card.module.less.d.ts +1 -0
  169. package/src/components/stat/stat-card.tsx +6 -4
  170. package/src/components/stat/stat-cards.stories.tsx +2 -2
  171. package/src/components/stat/stat-extended-card.stories.tsx +2 -2
  172. package/src/components/stat/stat-extended-card.tsx +5 -4
  173. package/src/components/ui/centered-spinner.stories.tsx +2 -2
  174. package/src/components/ui/centered-spinner.tsx +2 -6
  175. package/src/components/ui/date-range-picker/date-range-picker.module.less +1 -1
  176. package/src/components/ui/date-range-picker/date-range-picker.stories.tsx +2 -2
  177. package/src/components/ui/date-range-picker/date-range-picker.tsx +1 -1
  178. package/src/components/ui/disabled-button.tsx +2 -2
  179. package/src/components/ui/line-text/line-text-body.stories.tsx +2 -2
  180. package/src/components/ui/line-text/line-text-head.stories.tsx +2 -2
  181. package/src/components/ui/line-text/line-text.tsx +3 -11
  182. package/src/utils/__tests__/formatters.test.ts +1 -1
  183. package/src/utils/formatters.ts +1 -1
  184. package/src/utils/use-client-rect.ts +2 -2
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useMemo, useState } from 'react';
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: React.FC<{
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: React.FC<{
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: React.FC<{
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: React.FC<{
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: React.FC<{
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
- <React.Fragment>
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
- </React.Fragment>
205
+ </Fragment>
206
206
  )}
207
207
  </div>
208
208
  );
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import { PieChart } from './index';
3
2
 
4
3
  export default {
@@ -1,4 +1,4 @@
1
- import React from 'react';
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> = React.FC<{
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 React from 'react';
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: React.FC = () => {
11
- const [imageToEdit, setImageToEdit] = React.useState<File>();
12
- const [croppedImage, setCroppedImage] = React.useState<string>();
10
+ const BasicExample: FC = () => {
11
+ const [imageToEdit, setImageToEdit] = useState<File>();
12
+ const [croppedImage, setCroppedImage] = useState<string>();
13
13
 
14
- const imageCropper = React.useRef<ImageCropper>(null);
14
+ const imageCropper = useRef<ImageCropper>(null);
15
15
 
16
- const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
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
- <React.Fragment>
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
- </React.Fragment>
65
+ </Fragment>
66
66
  );
67
67
  };
68
68
 
@@ -1,4 +1,4 @@
1
- import React from 'react';
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 React.Component<ImageCropperProps> {
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;
@@ -2,6 +2,13 @@
2
2
 
3
3
  .stat-diff {
4
4
  white-space: nowrap;
5
+ span {
6
+ font-size: @typescale-0;
7
+ }
8
+ }
9
+
10
+ .stat-extended-diff {
11
+ margin-bottom: 2px;
5
12
  }
6
13
 
7
14
  .title {
@@ -1,4 +1,5 @@
1
1
  export const __esModule: true;
2
2
  export const statDiff: string;
3
+ export const statExtendedDiff: string;
3
4
  export const title: string;
4
5
 
@@ -1,4 +1,4 @@
1
- import React from 'react';
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: React.FC<StatDiffProps> = ({
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
- let text = absDiff === 0 ? '' : isIncrease ? '▲ ' : '▼ ';
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: React.FC<StatCardProps> = ({
106
+ export const StatCard: FC<StatCardProps> = ({
105
107
  title,
106
108
  description,
107
109
  value,
@@ -1,4 +1,4 @@
1
- import React from 'react';
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: () => React.ReactElement) => () => <div style={{ width: '400px' }}>{cb()}</div>;
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 React from 'react';
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: () => React.ReactElement) => () => <div style={{ width: '400px' }}>{cb()}</div>;
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 React, { FC } from 'react';
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-3 c-black">
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="m-l-1"
76
+ className={classNames(Styles.statExtendedDiff, 'm-l-1')}
76
77
  />
77
78
  ) : undefined}
78
79
  </Stack>
@@ -1,4 +1,4 @@
1
- import React from 'react';
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: () => React.ReactElement) => () =>
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 React from 'react';
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: React.FC<CenteredSpinnerPropsStrict> = ({
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"
@@ -13,7 +13,7 @@
13
13
  }
14
14
 
15
15
  .FormField__label {
16
- margin: 0;
16
+ margin: @spacing-0;
17
17
  }
18
18
 
19
19
  .DateRangeTrigger__shortLabel {
@@ -1,4 +1,4 @@
1
- import React from 'react';
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: React.FC) => () =>
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 React, { useMemo } from 'react';
1
+ import { useMemo } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { observer } from 'mobx-react';
4
4
  import { BodyText, Form, Stack } from '@servicetitan/design-system';
@@ -1,4 +1,4 @@
1
- import React from 'react';
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: React.FC<DisabledButtonProps> = props => {
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 React from 'react';
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: () => React.ReactElement) => () =>
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 React from 'react';
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: () => React.ReactElement) => () =>
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 React, { useMemo } from 'react';
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: React.FC<BodyTextLineProps> = ({
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: React.FC<HeadlineLineProps> = ({
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 (
@@ -35,7 +35,7 @@ describe('formatPercent', () => {
35
35
  [0, '0%'],
36
36
  [0.1, '10%'],
37
37
  [0.0011, '0.1%'],
38
- [0.9999, '99%'],
38
+ [0.9999, '100%'],
39
39
  ];
40
40
 
41
41
  tc.map(([value, result]) =>
@@ -7,7 +7,7 @@ const formatPercentValue = (value: number): string => {
7
7
  return '0';
8
8
  }
9
9
 
10
- const valueMain = value ? Math.abs(Math.floor(value)) : 0;
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 React, { useCallback, useEffect, useRef, useState } from 'react';
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 = React.useCallback(
44
+ const ref = useCallback(
45
45
  (node: HTMLElement | null) => {
46
46
  if (node !== null) {
47
47
  window.addEventListener('resize', handleResize);