@servicetitan/marketing-ui 1.15.0 → 1.16.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/CHANGELOG.md +328 -0
- package/dist/components/ads/ads-stat.js +13 -18
- package/dist/components/ads/ads-stat.js.map +1 -1
- package/dist/components/charts/funnel-chart/components/funnel-chart.js +15 -41
- package/dist/components/charts/funnel-chart/components/funnel-chart.js.map +1 -1
- package/dist/components/charts/funnel-chart/components/funnel-svg.js +9 -16
- package/dist/components/charts/funnel-chart/components/funnel-svg.js.map +1 -1
- package/dist/components/charts/funnel-chart/funnel-chart.stories.js +11 -14
- package/dist/components/charts/funnel-chart/funnel-chart.stories.js.map +1 -1
- package/dist/components/charts/funnel-chart/index.js +2 -16
- package/dist/components/charts/funnel-chart/index.js.map +1 -1
- package/dist/components/charts/funnel-chart/utils/const.js +2 -5
- package/dist/components/charts/funnel-chart/utils/const.js.map +1 -1
- package/dist/components/charts/funnel-chart/utils/interface.js +1 -2
- package/dist/components/charts/line-chart/components/body.js +26 -51
- package/dist/components/charts/line-chart/components/body.js.map +1 -1
- package/dist/components/charts/line-chart/components/container.js +12 -15
- package/dist/components/charts/line-chart/components/container.js.map +1 -1
- package/dist/components/charts/line-chart/components/hover-popover.js +20 -45
- package/dist/components/charts/line-chart/components/hover-popover.js.map +1 -1
- package/dist/components/charts/line-chart/components/sidebar.js +9 -35
- package/dist/components/charts/line-chart/components/sidebar.js.map +1 -1
- package/dist/components/charts/line-chart/components/stuff.js +13 -41
- package/dist/components/charts/line-chart/components/stuff.js.map +1 -1
- package/dist/components/charts/line-chart/components/svg-bars.js +14 -17
- package/dist/components/charts/line-chart/components/svg-bars.js.map +1 -1
- package/dist/components/charts/line-chart/components/svg-body.js +15 -41
- package/dist/components/charts/line-chart/components/svg-body.js.map +1 -1
- package/dist/components/charts/line-chart/components/svg-lines.js +11 -33
- package/dist/components/charts/line-chart/components/svg-lines.js.map +1 -1
- package/dist/components/charts/line-chart/index.js +2 -14
- package/dist/components/charts/line-chart/index.js.map +1 -1
- package/dist/components/charts/line-chart/line-chart.stories.js +19 -27
- package/dist/components/charts/line-chart/line-chart.stories.js.map +1 -1
- package/dist/components/charts/line-chart/stores/line-chart.store.js +20 -23
- package/dist/components/charts/line-chart/stores/line-chart.store.js.map +1 -1
- package/dist/components/charts/line-chart/stores/svg.store.js +10 -13
- package/dist/components/charts/line-chart/stores/svg.store.js.map +1 -1
- package/dist/components/charts/line-chart/utils/const.js +2 -6
- package/dist/components/charts/line-chart/utils/const.js.map +1 -1
- package/dist/components/charts/line-chart/utils/formatters.js +7 -11
- package/dist/components/charts/line-chart/utils/formatters.js.map +1 -1
- package/dist/components/charts/line-chart/utils/interfaces.js +1 -2
- package/dist/components/charts/line-chart/utils/internal-interfaces.js +1 -2
- package/dist/components/charts/line-chart/utils/key.js +1 -5
- package/dist/components/charts/line-chart/utils/key.js.map +1 -1
- package/dist/components/charts/line-chart/utils/labels.js +19 -26
- package/dist/components/charts/line-chart/utils/labels.js.map +1 -1
- package/dist/components/charts/pie-chart/components/pie-chart.js +12 -38
- package/dist/components/charts/pie-chart/components/pie-chart.js.map +1 -1
- package/dist/components/charts/pie-chart/components/pie.js +20 -27
- package/dist/components/charts/pie-chart/components/pie.js.map +1 -1
- package/dist/components/charts/pie-chart/index.js +1 -5
- package/dist/components/charts/pie-chart/index.js.map +1 -1
- package/dist/components/charts/pie-chart/pie-chart.stories.js +11 -18
- package/dist/components/charts/pie-chart/pie-chart.stories.js.map +1 -1
- package/dist/components/charts/pie-chart/utils/const.js +4 -8
- package/dist/components/charts/pie-chart/utils/const.js.map +1 -1
- package/dist/components/charts/pie-chart/utils/interface.js +1 -2
- package/dist/components/image-cropper/image-cropper.js +17 -23
- package/dist/components/image-cropper/image-cropper.js.map +1 -1
- package/dist/components/image-cropper/image-cropper.stories.js +10 -14
- package/dist/components/image-cropper/image-cropper.stories.js.map +1 -1
- package/dist/components/stat/stat-card.js +15 -42
- package/dist/components/stat/stat-card.js.map +1 -1
- package/dist/components/stat/stat-cards.stories.js +10 -13
- package/dist/components/stat/stat-cards.stories.js.map +1 -1
- package/dist/components/stat/stat-extended-card.js +9 -35
- package/dist/components/stat/stat-extended-card.js.map +1 -1
- package/dist/components/stat/stat-extended-card.stories.js +8 -11
- package/dist/components/stat/stat-extended-card.stories.js.map +1 -1
- package/dist/components/ui/action-button/action-button.d.ts +14 -0
- package/dist/components/ui/action-button/action-button.d.ts.map +1 -0
- package/dist/components/ui/action-button/action-button.js +32 -0
- package/dist/components/ui/action-button/action-button.js.map +1 -0
- package/dist/components/ui/action-button/action-button.module.less +51 -0
- package/dist/components/ui/action-button/action-button.stories.d.ts +10 -0
- package/dist/components/ui/action-button/action-button.stories.d.ts.map +1 -0
- package/dist/components/ui/action-button/action-button.stories.js +11 -0
- package/dist/components/ui/action-button/action-button.stories.js.map +1 -0
- package/dist/components/ui/centered-spinner.js +5 -12
- package/dist/components/ui/centered-spinner.js.map +1 -1
- package/dist/components/ui/centered-spinner.stories.js +8 -11
- package/dist/components/ui/centered-spinner.stories.js.map +1 -1
- package/dist/components/ui/date-range-picker/date-range-picker.js +11 -36
- 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 +9 -12
- package/dist/components/ui/date-range-picker/date-range-picker.stories.js.map +1 -1
- package/dist/components/ui/disabled-button.js +4 -8
- package/dist/components/ui/disabled-button.js.map +1 -1
- package/dist/components/ui/line-text/index.js +1 -13
- package/dist/components/ui/line-text/index.js.map +1 -1
- package/dist/components/ui/line-text/line-text-body.stories.js +7 -10
- package/dist/components/ui/line-text/line-text-body.stories.js.map +1 -1
- package/dist/components/ui/line-text/line-text-head.stories.js +7 -10
- package/dist/components/ui/line-text/line-text-head.stories.js.map +1 -1
- package/dist/components/ui/line-text/line-text.js +15 -42
- package/dist/components/ui/line-text/line-text.js.map +1 -1
- package/dist/components/ui/title-popover/title-popover.d.ts +17 -0
- package/dist/components/ui/title-popover/title-popover.d.ts.map +1 -0
- package/dist/components/ui/title-popover/title-popover.js +96 -0
- package/dist/components/ui/title-popover/title-popover.js.map +1 -0
- package/dist/components/ui/title-popover/title-popover.module.less +10 -0
- package/dist/components/ui/title-popover/title-popover.stories.d.ts +11 -0
- package/dist/components/ui/title-popover/title-popover.stories.d.ts.map +1 -0
- package/dist/components/ui/title-popover/title-popover.stories.js +17 -0
- package/dist/components/ui/title-popover/title-popover.stories.js.map +1 -0
- package/dist/index.js +12 -24
- package/dist/index.js.map +1 -1
- package/dist/utils/ads-texts.js +1 -4
- package/dist/utils/ads-texts.js.map +1 -1
- package/dist/utils/date/__mocks__/date-mock.js +1 -5
- package/dist/utils/date/__mocks__/date-mock.js.map +1 -1
- package/dist/utils/date/date-range-picker-options.js +7 -12
- package/dist/utils/date/date-range-picker-options.js.map +1 -1
- package/dist/utils/date/date-range-picker-state.js +6 -10
- package/dist/utils/date/date-range-picker-state.js.map +1 -1
- package/dist/utils/date/date-tenant.js +1 -5
- package/dist/utils/date/date-tenant.js.map +1 -1
- package/dist/utils/date/date.js +3 -9
- package/dist/utils/date/date.js.map +1 -1
- package/dist/utils/date/index.js +4 -16
- package/dist/utils/date/index.js.map +1 -1
- package/dist/utils/format-big-numbers.js +1 -5
- package/dist/utils/format-big-numbers.js.map +1 -1
- package/dist/utils/formatters.js +13 -41
- package/dist/utils/formatters.js.map +1 -1
- package/dist/utils/helpers.js +2 -7
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/string-case.js +2 -7
- package/dist/utils/string-case.js.map +1 -1
- package/dist/utils/use-client-rect.js +7 -11
- package/dist/utils/use-client-rect.js.map +1 -1
- package/dist/utils/use-target-range-store.d.ts +7 -0
- package/dist/utils/use-target-range-store.d.ts.map +1 -0
- package/dist/utils/use-target-range-store.js +9 -0
- package/dist/utils/use-target-range-store.js.map +1 -0
- package/package.json +2 -2
- package/src/components/ui/action-button/action-button.module.less +51 -0
- package/src/components/ui/action-button/action-button.module.less.d.ts +9 -0
- package/src/components/ui/action-button/action-button.stories.tsx +19 -0
- package/src/components/ui/action-button/action-button.tsx +82 -0
- package/src/components/ui/title-popover/title-popover.module.less +10 -0
- package/src/components/ui/title-popover/title-popover.module.less.d.ts +3 -0
- package/src/components/ui/title-popover/title-popover.stories.tsx +28 -0
- package/src/components/ui/title-popover/title-popover.tsx +86 -0
- package/src/utils/use-target-range-store.ts +17 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ReactNode, FC, useRef } from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import {
|
|
4
|
+
Icon,
|
|
5
|
+
BodyText,
|
|
6
|
+
IconNameType,
|
|
7
|
+
Tooltip,
|
|
8
|
+
useFocusVisible,
|
|
9
|
+
} from '@servicetitan/design-system';
|
|
10
|
+
import * as Styles from './action-button.module.less';
|
|
11
|
+
|
|
12
|
+
export interface ActionButtonProps {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
iconName?: IconNameType;
|
|
15
|
+
hover?: 'primary' | 'negative' | 'none';
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
tooltip?: string;
|
|
18
|
+
qaPrefix?: string;
|
|
19
|
+
active?: boolean;
|
|
20
|
+
onClick?(): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const ActionButton: FC<ActionButtonProps> = ({
|
|
24
|
+
onClick,
|
|
25
|
+
disabled,
|
|
26
|
+
children,
|
|
27
|
+
iconName,
|
|
28
|
+
hover,
|
|
29
|
+
qaPrefix,
|
|
30
|
+
active,
|
|
31
|
+
tooltip,
|
|
32
|
+
}) => {
|
|
33
|
+
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
34
|
+
const { isFocusVisible, focusFunction, blurFunction } = useFocusVisible(buttonRef);
|
|
35
|
+
|
|
36
|
+
const handleClick = () => {
|
|
37
|
+
if (disabled) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (onClick) {
|
|
42
|
+
onClick();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const getButton = () => {
|
|
47
|
+
const classes = classnames(Styles.actionButton, qaPrefix, {
|
|
48
|
+
[Styles.primary]: hover === 'primary' && !disabled,
|
|
49
|
+
[Styles.negative]: hover === 'negative' && !disabled,
|
|
50
|
+
[Styles.active]: active && !disabled,
|
|
51
|
+
[Styles.disabled]: disabled,
|
|
52
|
+
[Styles.focusVisible]: isFocusVisible,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<button
|
|
57
|
+
type="button"
|
|
58
|
+
ref={buttonRef}
|
|
59
|
+
className={classes}
|
|
60
|
+
onClick={handleClick}
|
|
61
|
+
disabled={disabled}
|
|
62
|
+
onFocus={focusFunction}
|
|
63
|
+
onBlur={blurFunction}
|
|
64
|
+
>
|
|
65
|
+
{iconName && <Icon name={iconName} size="20px" className="m-r-1" />}
|
|
66
|
+
<BodyText className={classnames(Styles.text, `${qaPrefix}-text`)}>
|
|
67
|
+
{children}
|
|
68
|
+
</BodyText>
|
|
69
|
+
</button>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
if (!tooltip) {
|
|
74
|
+
return getButton();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<Tooltip text={tooltip} direction="l" el="div" className={`${qaPrefix}-tooltip`}>
|
|
79
|
+
{getButton()}
|
|
80
|
+
</Tooltip>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReactElement, useState } from 'react';
|
|
2
|
+
import { ActionButton } from '../action-button/action-button';
|
|
3
|
+
import { TitlePopover } from './title-popover';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Marketing UI/ui/TitlePopover',
|
|
7
|
+
component: TitlePopover,
|
|
8
|
+
parameters: {},
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const w = (style: { width?: string; height?: string }, cb: () => ReactElement) => () =>
|
|
12
|
+
<div style={style}>{cb()}</div>;
|
|
13
|
+
|
|
14
|
+
export const titlePopover = w({}, () => <TitlePopover text="Title text">Content</TitlePopover>);
|
|
15
|
+
export const titlePopoverToggle = w({}, () => {
|
|
16
|
+
const [isActive, setIsActive] = useState(true);
|
|
17
|
+
const title = isActive ? 'Entities' : 'Archived Entities';
|
|
18
|
+
return (
|
|
19
|
+
<TitlePopover text={title}>
|
|
20
|
+
<ActionButton hover="primary" active={isActive} onClick={() => setIsActive(true)}>
|
|
21
|
+
Entities
|
|
22
|
+
</ActionButton>
|
|
23
|
+
<ActionButton hover="primary" active={!isActive} onClick={() => setIsActive(false)}>
|
|
24
|
+
Archived Entities
|
|
25
|
+
</ActionButton>
|
|
26
|
+
</TitlePopover>
|
|
27
|
+
);
|
|
28
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { observer } from 'mobx-react';
|
|
3
|
+
import { createRef, Component } from 'react';
|
|
4
|
+
import { observable, action, makeObservable } from 'mobx';
|
|
5
|
+
import { Popover, Stack, BodyText, Icon } from '@servicetitan/design-system';
|
|
6
|
+
import * as Styles from './title-popover.module.less';
|
|
7
|
+
|
|
8
|
+
interface TitlePopoverProps {
|
|
9
|
+
text?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@observer
|
|
13
|
+
export class TitlePopover extends Component<TitlePopoverProps> {
|
|
14
|
+
@observable isOpen = false;
|
|
15
|
+
|
|
16
|
+
wrapElem = createRef<HTMLDivElement>();
|
|
17
|
+
|
|
18
|
+
constructor(props: TitlePopoverProps) {
|
|
19
|
+
super(props);
|
|
20
|
+
makeObservable(this);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@action
|
|
24
|
+
toggle = () => {
|
|
25
|
+
this.isOpen = !this.isOpen;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
@action
|
|
29
|
+
close = () => {
|
|
30
|
+
this.isOpen = false;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
@action
|
|
34
|
+
handleClick = (event: MouseEvent) => {
|
|
35
|
+
if (!this.wrapElem.current) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const isClickedInside = this.wrapElem.current.contains(event.target as Node);
|
|
40
|
+
|
|
41
|
+
if (!isClickedInside) {
|
|
42
|
+
this.close();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
componentDidMount() {
|
|
47
|
+
window.addEventListener('click', this.handleClick);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
componentWillUnmount() {
|
|
51
|
+
window.removeEventListener('click', this.handleClick);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
render() {
|
|
55
|
+
const { text, children } = this.props;
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div ref={this.wrapElem} className="qa-title-popover">
|
|
59
|
+
<Popover
|
|
60
|
+
className={classNames(Styles.popover, 'qa-title-popover')}
|
|
61
|
+
width="xs"
|
|
62
|
+
open={this.isOpen}
|
|
63
|
+
direction="br"
|
|
64
|
+
trigger={
|
|
65
|
+
<Stack
|
|
66
|
+
alignItems="center"
|
|
67
|
+
className="qa-title-popover-button cursor-pointer"
|
|
68
|
+
onClick={this.toggle}
|
|
69
|
+
>
|
|
70
|
+
<BodyText size="large" className="qa-title-popover-text">
|
|
71
|
+
{text}
|
|
72
|
+
</BodyText>
|
|
73
|
+
<Icon
|
|
74
|
+
name="expand_more"
|
|
75
|
+
size={20}
|
|
76
|
+
className="m-l-1 qa-title-popover-icon"
|
|
77
|
+
/>
|
|
78
|
+
</Stack>
|
|
79
|
+
}
|
|
80
|
+
>
|
|
81
|
+
{children}
|
|
82
|
+
</Popover>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useLocalStore } from 'mobx-react';
|
|
2
|
+
import { action } from 'mobx';
|
|
3
|
+
|
|
4
|
+
export type OptionalRange = Range | undefined;
|
|
5
|
+
|
|
6
|
+
export interface TargetRangeStore {
|
|
7
|
+
targetRange: OptionalRange;
|
|
8
|
+
setTargetRange: (range: OptionalRange) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const useTargetRangeStore = () =>
|
|
12
|
+
useLocalStore<TargetRangeStore>(() => ({
|
|
13
|
+
targetRange: undefined,
|
|
14
|
+
setTargetRange: action(function (this: TargetRangeStore, range: OptionalRange) {
|
|
15
|
+
this.targetRange = range;
|
|
16
|
+
}),
|
|
17
|
+
}));
|