@servicetitan/mpa-components 0.1.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 (141) hide show
  1. package/lib/components/settings/company-details/company-details-form.stories.d.ts +9 -0
  2. package/lib/components/settings/company-details/company-details-form.stories.d.ts.map +1 -0
  3. package/lib/components/settings/company-details/company-details-form.stories.js +45 -0
  4. package/lib/components/settings/company-details/company-details-form.stories.js.map +1 -0
  5. package/lib/components/settings/company-details/index.d.ts +20 -0
  6. package/lib/components/settings/company-details/index.d.ts.map +1 -0
  7. package/lib/components/settings/company-details/index.js +11 -0
  8. package/lib/components/settings/company-details/index.js.map +1 -0
  9. package/lib/components/settings/company-email-footer/company-email-footer.stories.d.ts +9 -0
  10. package/lib/components/settings/company-email-footer/company-email-footer.stories.d.ts.map +1 -0
  11. package/lib/components/settings/company-email-footer/company-email-footer.stories.js +38 -0
  12. package/lib/components/settings/company-email-footer/company-email-footer.stories.js.map +1 -0
  13. package/lib/components/settings/company-email-footer/index.d.ts +11 -0
  14. package/lib/components/settings/company-email-footer/index.d.ts.map +1 -0
  15. package/lib/components/settings/company-email-footer/index.js +10 -0
  16. package/lib/components/settings/company-email-footer/index.js.map +1 -0
  17. package/lib/components/settings/company-email-reply-to/company-email-reply-to.stories.d.ts +9 -0
  18. package/lib/components/settings/company-email-reply-to/company-email-reply-to.stories.d.ts.map +1 -0
  19. package/lib/components/settings/company-email-reply-to/company-email-reply-to.stories.js +36 -0
  20. package/lib/components/settings/company-email-reply-to/company-email-reply-to.stories.js.map +1 -0
  21. package/lib/components/settings/company-email-reply-to/index.d.ts +7 -0
  22. package/lib/components/settings/company-email-reply-to/index.d.ts.map +1 -0
  23. package/lib/components/settings/company-email-reply-to/index.js +12 -0
  24. package/lib/components/settings/company-email-reply-to/index.js.map +1 -0
  25. package/lib/components/settings/company-email-sender/company-email-sender.module.less +7 -0
  26. package/lib/components/settings/company-email-sender/company-email-sender.stories.d.ts +9 -0
  27. package/lib/components/settings/company-email-sender/company-email-sender.stories.d.ts.map +1 -0
  28. package/lib/components/settings/company-email-sender/company-email-sender.stories.js +38 -0
  29. package/lib/components/settings/company-email-sender/company-email-sender.stories.js.map +1 -0
  30. package/lib/components/settings/company-email-sender/index.d.ts +12 -0
  31. package/lib/components/settings/company-email-sender/index.d.ts.map +1 -0
  32. package/lib/components/settings/company-email-sender/index.js +29 -0
  33. package/lib/components/settings/company-email-sender/index.js.map +1 -0
  34. package/lib/components/settings/company-trade-checkbox/company-trade-checkbox.module.less +13 -0
  35. package/lib/components/settings/company-trade-checkbox/index.d.ts +10 -0
  36. package/lib/components/settings/company-trade-checkbox/index.d.ts.map +1 -0
  37. package/lib/components/settings/company-trade-checkbox/index.js +14 -0
  38. package/lib/components/settings/company-trade-checkbox/index.js.map +1 -0
  39. package/lib/components/settings/company-trades-picker/company-trades-picker.stories.d.ts +10 -0
  40. package/lib/components/settings/company-trades-picker/company-trades-picker.stories.d.ts.map +1 -0
  41. package/lib/components/settings/company-trades-picker/company-trades-picker.stories.js +68 -0
  42. package/lib/components/settings/company-trades-picker/company-trades-picker.stories.js.map +1 -0
  43. package/lib/components/settings/company-trades-picker/index.d.ts +19 -0
  44. package/lib/components/settings/company-trades-picker/index.d.ts.map +1 -0
  45. package/lib/components/settings/company-trades-picker/index.js +16 -0
  46. package/lib/components/settings/company-trades-picker/index.js.map +1 -0
  47. package/lib/components/settings/double-opt-in/double-opt-in.module.less +3 -0
  48. package/lib/components/settings/double-opt-in/double-opt-in.stories.d.ts +9 -0
  49. package/lib/components/settings/double-opt-in/double-opt-in.stories.d.ts.map +1 -0
  50. package/lib/components/settings/double-opt-in/double-opt-in.stories.js +42 -0
  51. package/lib/components/settings/double-opt-in/double-opt-in.stories.js.map +1 -0
  52. package/lib/components/settings/double-opt-in/index.d.ts +16 -0
  53. package/lib/components/settings/double-opt-in/index.d.ts.map +1 -0
  54. package/lib/components/settings/double-opt-in/index.js +23 -0
  55. package/lib/components/settings/double-opt-in/index.js.map +1 -0
  56. package/lib/components/settings/email-preview/email-preview.d.ts +13 -0
  57. package/lib/components/settings/email-preview/email-preview.d.ts.map +1 -0
  58. package/lib/components/settings/email-preview/email-preview.js +9 -0
  59. package/lib/components/settings/email-preview/email-preview.js.map +1 -0
  60. package/lib/components/settings/email-preview/email-preview.module.less +62 -0
  61. package/lib/components/settings/email-preview/opt-in-email-preview.d.ts +10 -0
  62. package/lib/components/settings/email-preview/opt-in-email-preview.d.ts.map +1 -0
  63. package/lib/components/settings/email-preview/opt-in-email-preview.js +10 -0
  64. package/lib/components/settings/email-preview/opt-in-email-preview.js.map +1 -0
  65. package/lib/components/settings/email-preview/opt-out-email-preview.d.ts +9 -0
  66. package/lib/components/settings/email-preview/opt-out-email-preview.d.ts.map +1 -0
  67. package/lib/components/settings/email-preview/opt-out-email-preview.js +9 -0
  68. package/lib/components/settings/email-preview/opt-out-email-preview.js.map +1 -0
  69. package/lib/components/settings/index.d.ts +10 -0
  70. package/lib/components/settings/index.d.ts.map +1 -0
  71. package/lib/components/settings/index.js +10 -0
  72. package/lib/components/settings/index.js.map +1 -0
  73. package/lib/components/settings/logo-picker/index.d.ts +32 -0
  74. package/lib/components/settings/logo-picker/index.d.ts.map +1 -0
  75. package/lib/components/settings/logo-picker/index.js +88 -0
  76. package/lib/components/settings/logo-picker/index.js.map +1 -0
  77. package/lib/components/settings/logo-picker/logo-picker.module.less +21 -0
  78. package/lib/components/settings/logo-picker/logo-picker.stories.d.ts +9 -0
  79. package/lib/components/settings/logo-picker/logo-picker.stories.d.ts.map +1 -0
  80. package/lib/components/settings/logo-picker/logo-picker.stories.js +13 -0
  81. package/lib/components/settings/logo-picker/logo-picker.stories.js.map +1 -0
  82. package/lib/components/settings/opt-out-message/index.d.ts +17 -0
  83. package/lib/components/settings/opt-out-message/index.d.ts.map +1 -0
  84. package/lib/components/settings/opt-out-message/index.js +22 -0
  85. package/lib/components/settings/opt-out-message/index.js.map +1 -0
  86. package/lib/components/settings/opt-out-message/opt-out-message.module.less +20 -0
  87. package/lib/components/settings/opt-out-message/opt-out-message.stories.d.ts +9 -0
  88. package/lib/components/settings/opt-out-message/opt-out-message.stories.d.ts.map +1 -0
  89. package/lib/components/settings/opt-out-message/opt-out-message.stories.js +44 -0
  90. package/lib/components/settings/opt-out-message/opt-out-message.stories.js.map +1 -0
  91. package/lib/components/settings/settings-section/index.d.ts +11 -0
  92. package/lib/components/settings/settings-section/index.d.ts.map +1 -0
  93. package/lib/components/settings/settings-section/index.js +6 -0
  94. package/lib/components/settings/settings-section/index.js.map +1 -0
  95. package/lib/index.d.ts +3 -0
  96. package/lib/index.d.ts.map +1 -0
  97. package/lib/index.js +3 -0
  98. package/lib/index.js.map +1 -0
  99. package/lib/utils/helpers.d.ts +7 -0
  100. package/lib/utils/helpers.d.ts.map +1 -0
  101. package/lib/utils/helpers.js +24 -0
  102. package/lib/utils/helpers.js.map +1 -0
  103. package/package.json +36 -0
  104. package/src/components/settings/company-details/company-details-form.stories.tsx +39 -0
  105. package/src/components/settings/company-details/index.tsx +157 -0
  106. package/src/components/settings/company-email-footer/company-email-footer.stories.tsx +26 -0
  107. package/src/components/settings/company-email-footer/index.tsx +79 -0
  108. package/src/components/settings/company-email-reply-to/company-email-reply-to.stories.tsx +23 -0
  109. package/src/components/settings/company-email-reply-to/index.tsx +38 -0
  110. package/src/components/settings/company-email-sender/company-email-sender.module.less +7 -0
  111. package/src/components/settings/company-email-sender/company-email-sender.module.less.d.ts +3 -0
  112. package/src/components/settings/company-email-sender/company-email-sender.stories.tsx +26 -0
  113. package/src/components/settings/company-email-sender/index.tsx +129 -0
  114. package/src/components/settings/company-trade-checkbox/company-trade-checkbox.module.less +13 -0
  115. package/src/components/settings/company-trade-checkbox/company-trade-checkbox.module.less.d.ts +4 -0
  116. package/src/components/settings/company-trade-checkbox/index.tsx +43 -0
  117. package/src/components/settings/company-trades-picker/company-trades-picker.stories.tsx +78 -0
  118. package/src/components/settings/company-trades-picker/index.tsx +78 -0
  119. package/src/components/settings/double-opt-in/double-opt-in.module.less +3 -0
  120. package/src/components/settings/double-opt-in/double-opt-in.module.less.d.ts +3 -0
  121. package/src/components/settings/double-opt-in/double-opt-in.stories.tsx +28 -0
  122. package/src/components/settings/double-opt-in/index.tsx +143 -0
  123. package/src/components/settings/email-preview/email-preview.module.less +62 -0
  124. package/src/components/settings/email-preview/email-preview.module.less.d.ts +8 -0
  125. package/src/components/settings/email-preview/email-preview.tsx +69 -0
  126. package/src/components/settings/email-preview/opt-in-email-preview.tsx +30 -0
  127. package/src/components/settings/email-preview/opt-out-email-preview.tsx +31 -0
  128. package/src/components/settings/index.ts +9 -0
  129. package/src/components/settings/logo-picker/index.tsx +256 -0
  130. package/src/components/settings/logo-picker/logo-picker.module.less +21 -0
  131. package/src/components/settings/logo-picker/logo-picker.module.less.d.ts +4 -0
  132. package/src/components/settings/logo-picker/logo-picker.stories.tsx +21 -0
  133. package/src/components/settings/opt-out-message/index.tsx +154 -0
  134. package/src/components/settings/opt-out-message/opt-out-message.module.less +20 -0
  135. package/src/components/settings/opt-out-message/opt-out-message.module.less.d.ts +5 -0
  136. package/src/components/settings/opt-out-message/opt-out-message.stories.tsx +31 -0
  137. package/src/components/settings/settings-section/index.tsx +35 -0
  138. package/src/index.ts +3 -0
  139. package/src/utils/helpers.ts +31 -0
  140. package/tsconfig.json +11 -0
  141. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,20 @@
1
+ @import (reference) '~@servicetitan/tokens/dist/tokens.less';
2
+
3
+ .out-out-message {
4
+ hr {
5
+ margin: @spacing-2 @spacing-0;
6
+ border: 0;
7
+ border-bottom: 1px solid @color-neutral-50;
8
+ }
9
+ }
10
+
11
+ .button-input {
12
+ width: 160px;
13
+ }
14
+
15
+ .input {
16
+ width: @spacing-5;
17
+ margin-left: @spacing-1;
18
+ margin-right: @spacing-1;
19
+ margin-bottom: @spacing-0;
20
+ }
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ declare const _default: {
3
+ title: string;
4
+ component: import("react").FC<import(".").OptOutMessageProps>;
5
+ parameters: {};
6
+ };
7
+ export default _default;
8
+ export declare const OptOutMessage: (() => JSX.Element) & import("@servicetitan/react-ioc/dist/provide").WrappedComponent<() => JSX.Element>;
9
+ //# sourceMappingURL=opt-out-message.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opt-out-message.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/settings/opt-out-message/opt-out-message.stories.tsx"],"names":[],"mappings":";;;;;;AAKA,wBAIE;AAeF,eAAO,MAAM,aAAa,0GAMxB,CAAC"}
@@ -0,0 +1,44 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { CheckboxFieldState, InputFieldState } from '@servicetitan/form';
9
+ import { injectable, provide, useDependencies } from '@servicetitan/react-ioc';
10
+ import { FormState } from 'formstate';
11
+ import { OptOutMessage as Component } from '.';
12
+ export default {
13
+ title: 'MPA Components/settings/OptOutMessage',
14
+ component: Component,
15
+ parameters: {},
16
+ };
17
+ let OptOutStore = class OptOutStore {
18
+ constructor() {
19
+ Object.defineProperty(this, "form", {
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true,
23
+ value: new FormState({
24
+ subjectLine: new InputFieldState('Good bye'),
25
+ header: new InputFieldState('Opt out of emails'),
26
+ body: new InputFieldState('Sorry to see you go!'),
27
+ buttonText: new InputFieldState('Bye'),
28
+ monthsLimit: new InputFieldState(6),
29
+ enabled: new CheckboxFieldState(true),
30
+ autoSuppressionEnabled: new CheckboxFieldState(true),
31
+ })
32
+ });
33
+ }
34
+ };
35
+ OptOutStore = __decorate([
36
+ injectable()
37
+ ], OptOutStore);
38
+ export const OptOutMessage = provide({
39
+ singletons: [OptOutStore],
40
+ })(() => {
41
+ const [store] = useDependencies(OptOutStore);
42
+ return _jsx(Component, { formState: store.form.$ }, void 0);
43
+ });
44
+ //# sourceMappingURL=opt-out-message.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opt-out-message.stories.js","sourceRoot":"","sources":["../../../../src/components/settings/opt-out-message/opt-out-message.stories.tsx"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,aAAa,IAAI,SAAS,EAAE,MAAM,GAAG,CAAC;AAE/C,eAAe;IACX,KAAK,EAAE,uCAAuC;IAC9C,SAAS,EAAE,SAAS;IACpB,UAAU,EAAE,EAAE;CACjB,CAAC;AAGF,IAAM,WAAW,GAAjB,MAAM,WAAW;IAAjB;QACI;;;;mBAAO,IAAI,SAAS,CAAC;gBACjB,WAAW,EAAE,IAAI,eAAe,CAAC,UAAU,CAAC;gBAC5C,MAAM,EAAE,IAAI,eAAe,CAAC,mBAAmB,CAAC;gBAChD,IAAI,EAAE,IAAI,eAAe,CAAC,sBAAsB,CAAC;gBACjD,UAAU,EAAE,IAAI,eAAe,CAAC,KAAK,CAAC;gBACtC,WAAW,EAAE,IAAI,eAAe,CAAC,CAAC,CAAC;gBACnC,OAAO,EAAE,IAAI,kBAAkB,CAAC,IAAI,CAAC;gBACrC,sBAAsB,EAAE,IAAI,kBAAkB,CAAC,IAAI,CAAC;aACvD,CAAC;WAAC;IACP,CAAC;CAAA,CAAA;AAVK,WAAW;IADhB,UAAU,EAAE;GACP,WAAW,CAUhB;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC;IACjC,UAAU,EAAE,CAAC,WAAW,CAAC;CAC5B,CAAC,CAAC,GAAG,EAAE;IACJ,MAAM,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAE7C,OAAO,KAAC,SAAS,IAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,WAAI,CAAC;AAClD,CAAC,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { ReactNode, FC } from 'react';
2
+ interface SectionProps {
3
+ title: string;
4
+ text?: JSX.Element | string;
5
+ children: ReactNode;
6
+ qaPrefix?: string;
7
+ className?: string;
8
+ }
9
+ export declare const SettingsSection: FC<SectionProps>;
10
+ export {};
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/settings/settings-section/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAKtC,UAAU,YAAY;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;IAC5B,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,YAAY,CAoB5C,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import classNames from 'classnames';
3
+ import { observer } from 'mobx-react';
4
+ import { Text, Card, Layout } from '@servicetitan/design-system';
5
+ export const SettingsSection = observer(({ title, text, children, qaPrefix, className = '' }) => (_jsxs(Layout, Object.assign({ type: "support", direction: "left", className: classNames(qaPrefix, className) }, { children: [_jsxs(Layout.Section, { children: [_jsx(Text, Object.assign({ size: 3, bold: true, className: `${qaPrefix}-title` }, { children: title }), void 0), text && (_jsx(Text, Object.assign({ size: 2, subdued: true, className: `${qaPrefix}-text` }, { children: text }), void 0))] }, void 0), _jsx(Layout.Section, { children: _jsx(Card, Object.assign({ raised: true }, { children: _jsx(Card.Section, Object.assign({ className: `${qaPrefix}-content` }, { children: children }), void 0) }), void 0) }, void 0)] }), void 0)));
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/settings/settings-section/index.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAUjE,MAAM,CAAC,MAAM,eAAe,GAAqB,QAAQ,CACrD,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,GAAG,EAAE,EAAgB,EAAE,EAAE,CAAC,CACnE,MAAC,MAAM,kBAAC,IAAI,EAAC,SAAS,EAAC,SAAS,EAAC,MAAM,EAAC,SAAS,EAAE,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,iBAC9E,MAAC,MAAM,CAAC,OAAO,eACX,KAAC,IAAI,kBAAC,IAAI,EAAE,CAAC,EAAE,IAAI,QAAC,SAAS,EAAE,GAAG,QAAQ,QAAQ,gBAC7C,KAAK,YACH,EACN,IAAI,IAAI,CACL,KAAC,IAAI,kBAAC,IAAI,EAAE,CAAC,EAAE,OAAO,QAAC,SAAS,EAAE,GAAG,QAAQ,OAAO,gBAC/C,IAAI,YACF,CACV,YACY,EACjB,KAAC,MAAM,CAAC,OAAO,cACX,KAAC,IAAI,kBAAC,MAAM,sBACR,KAAC,IAAI,CAAC,OAAO,kBAAC,SAAS,EAAE,GAAG,QAAQ,UAAU,gBAAG,QAAQ,YAAgB,YACtE,WACM,aACZ,CACZ,CACJ,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './components/settings';
2
+ export * from './utils/helpers';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AAEtC,cAAc,iBAAiB,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './components/settings';
2
+ export * from './utils/helpers';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AAEtC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare const formatBytes: (bytes: number | undefined, decimals?: number, isBinary?: boolean) => string;
2
+ export declare const getImageSize: (url: string) => Promise<{
3
+ width: number;
4
+ height: number;
5
+ }>;
6
+ export declare const convertDomainName: (value: string) => string;
7
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAAW,MAAM,GAAG,SAAS,kDAYpD,CAAC;AAEF,eAAO,MAAM,YAAY,QAAS,MAAM;WACR,MAAM;YAAU,MAAM;EAarD,CAAC;AAEF,eAAO,MAAM,iBAAiB,UAAW,MAAM,WAA0C,CAAC"}
@@ -0,0 +1,24 @@
1
+ export const formatBytes = (bytes, decimals = 2, isBinary = true) => {
2
+ if (!bytes) {
3
+ return '0 Bytes';
4
+ }
5
+ const k = isBinary ? 1024 : 1000;
6
+ const dm = Math.max(0, decimals);
7
+ const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
8
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
9
+ return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
10
+ };
11
+ export const getImageSize = (url) => {
12
+ return new Promise((resolve, reject) => {
13
+ const image = document.createElement('img');
14
+ image.onload = () => {
15
+ resolve({ width: image.width, height: image.height });
16
+ };
17
+ image.onerror = () => {
18
+ reject(undefined);
19
+ };
20
+ image.src = url;
21
+ });
22
+ };
23
+ export const convertDomainName = (value) => value.toLowerCase().replace(/ /g, '');
24
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAyB,EAAE,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,IAAI,EAAE,EAAE;IACpF,IAAI,CAAC,KAAK,EAAE;QACR,OAAO,SAAS,CAAC;KACpB;IAED,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACjC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAEhD,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAEpD,OAAO,GAAG,UAAU,CAAC,CAAC,KAAK,GAAG,SAAA,CAAC,EAAI,CAAC,CAAA,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACrE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,EAAE;IACxC,OAAO,IAAI,OAAO,CAAoC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtE,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAE5C,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE;YAChB,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1D,CAAC,CAAC;QAEF,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE;YACjB,MAAM,CAAC,SAAS,CAAC,CAAC;QACtB,CAAC,CAAC;QAEF,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC;IACpB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@servicetitan/mpa-components",
3
+ "version": "0.1.0",
4
+ "description": "",
5
+ "main": "./lib/index.js",
6
+ "typings": "./lib/index.d.ts",
7
+ "dependencies": {
8
+ "classnames": "~2.3.1",
9
+ "lodash": "4.17.21"
10
+ },
11
+ "peerDependencies": {
12
+ "@servicetitan/confirm": "~21.4.1",
13
+ "@servicetitan/design-system": "~10.1.1",
14
+ "@servicetitan/form": "~21.4.1",
15
+ "@servicetitan/react-ioc": "~14.1.1",
16
+ "@servicetitan/tokens": "~10.1.1",
17
+ "formstate": "~2.0.0",
18
+ "mobx": "~6.3.2",
19
+ "mobx-react": "~7.2.0",
20
+ "moment": "~2.29.1",
21
+ "react": "~17.0.2"
22
+ },
23
+ "devDependencies": {
24
+ "@testing-library/react": "^12.0.0",
25
+ "@types/history": "~4.7.7",
26
+ "@types/lodash": "^4.14.182",
27
+ "@types/react": "~17.0.15"
28
+ },
29
+ "publishConfig": {
30
+ "access": "restricted"
31
+ },
32
+ "cli": {
33
+ "webpack": false
34
+ },
35
+ "gitHead": "a8a8a8e9b672a2d45847991df0e23036e3810482"
36
+ }
@@ -0,0 +1,39 @@
1
+ import { InputFieldState } from '@servicetitan/form';
2
+ import { injectable, provide, useDependencies } from '@servicetitan/react-ioc';
3
+ import { FormState } from 'formstate';
4
+
5
+ import { CompanyDetails as Component } from '.';
6
+ import { LogoPicker } from '../logo-picker/logo-picker.stories';
7
+
8
+ @injectable()
9
+ class DetailsStore {
10
+ form = new FormState({
11
+ companyName: new InputFieldState('Acme Inc'),
12
+ tagline: new InputFieldState('Ayo! The Acme rules'),
13
+ street: new InputFieldState('Backed st.'),
14
+ unit: new InputFieldState('123'),
15
+ city: new InputFieldState('Glendale'),
16
+ state: new InputFieldState('CA'),
17
+ zipCode: new InputFieldState('91203'),
18
+ companyEmail: new InputFieldState('info@acme.com'),
19
+ yearEstablished: new InputFieldState(1999),
20
+ });
21
+ }
22
+
23
+ export const CompanyDetails = provide({ singletons: [DetailsStore] })(() => {
24
+ const [store] = useDependencies(DetailsStore);
25
+
26
+ return (
27
+ <Component
28
+ formState={store.form.$}
29
+ logoPicker={<LogoPicker />}
30
+ handleCompanyEmailBlur={() => alert('company email blurred')}
31
+ />
32
+ );
33
+ });
34
+
35
+ export default {
36
+ title: 'MPA Components/settings/CompanyDetails',
37
+ component: CompanyDetails,
38
+ parameters: {},
39
+ };
@@ -0,0 +1,157 @@
1
+ import { FC, Fragment, ReactNode } from 'react';
2
+ import { observer } from 'mobx-react';
3
+
4
+ import { Form, Link } from '@servicetitan/design-system';
5
+ import { NumberInput, InputFieldState } from '@servicetitan/form';
6
+
7
+ import { SettingsSection } from '../settings-section';
8
+ export interface CompanyDetailsProps {
9
+ formState: {
10
+ city: InputFieldState<string>;
11
+ companyEmail: InputFieldState<string>;
12
+ companyName: InputFieldState<string>;
13
+ state: InputFieldState<string>;
14
+ street: InputFieldState<string>;
15
+ tagline: InputFieldState<string>;
16
+ unit: InputFieldState<string>;
17
+ yearEstablished: InputFieldState<number>;
18
+ zipCode: InputFieldState<string>;
19
+ };
20
+ logoPicker?: ReactNode;
21
+ sectionDescription?: string | JSX.Element;
22
+ handleCompanyEmailBlur?: () => void;
23
+ }
24
+
25
+ const DEFAULT_SECTION_DESCRIPTION = (
26
+ <Fragment>
27
+ Enter these details as you would like them to appear in your campaign. Much of this info can
28
+ be utilized as&nbsp;
29
+ <Link
30
+ href="https://help.servicetitan.com/Content/Marketing/merge-tags.htm"
31
+ target="_blank"
32
+ primary
33
+ className="qa-settings-company-details-merge-tags"
34
+ >
35
+ merge tags
36
+ </Link>
37
+ .
38
+ </Fragment>
39
+ );
40
+
41
+ export const CompanyDetails: FC<CompanyDetailsProps> = observer(
42
+ ({
43
+ formState,
44
+ logoPicker,
45
+ sectionDescription = DEFAULT_SECTION_DESCRIPTION,
46
+ handleCompanyEmailBlur = () => {},
47
+ }: CompanyDetailsProps) => {
48
+ return (
49
+ <SettingsSection
50
+ qaPrefix="qa-settings-company-details"
51
+ title="Company Details"
52
+ text={sectionDescription}
53
+ >
54
+ <Form className="m-b-0-i">
55
+ <Form.Input
56
+ className="m-b-2-i qa-settings-company-details-company-name"
57
+ value={formState.companyName.value}
58
+ onChange={formState.companyName.onChangeHandler}
59
+ error={formState.companyName.hasError}
60
+ label="Company Name"
61
+ placeholder="Enter company name"
62
+ fluid
63
+ />
64
+ <Form.Input
65
+ className="m-b-2-i qa-settings-company-details-tagline"
66
+ value={formState.tagline.value}
67
+ onChange={formState.tagline.onChangeHandler}
68
+ error={formState.tagline.hasError}
69
+ label="Tagline / Slogan"
70
+ placeholder="ex: Trusted since 1956"
71
+ fluid
72
+ />
73
+ <Form.Group className="m-b-2-i">
74
+ <Form.Input
75
+ width={8}
76
+ className="m-b-0-i qa-settings-company-details-address"
77
+ value={formState.street.value}
78
+ onChange={formState.street.onChangeHandler}
79
+ error={formState.street.hasError}
80
+ label="Street Address"
81
+ placeholder="801 N Brand Blvd"
82
+ />
83
+ <Form.Input
84
+ width={4}
85
+ className="m-b-0-i qa-settings-company-details-address"
86
+ value={formState.unit.value}
87
+ onChange={formState.unit.onChangeHandler}
88
+ error={formState.unit.hasError}
89
+ label="Suite, Unit, etc"
90
+ />
91
+ </Form.Group>
92
+ <Form.Group widths="equal" className="m-b-2-i">
93
+ <Form.Input
94
+ className="m-b-0-i qa-settings-company-details-city"
95
+ value={formState.city.value}
96
+ onChange={formState.city.onChangeHandler}
97
+ error={formState.city.hasError}
98
+ label="City"
99
+ placeholder="Glendale"
100
+ fluid
101
+ />
102
+ <Form.Input
103
+ className="m-b-0-i qa-settings-company-details-state"
104
+ value={formState.state.value}
105
+ onChange={formState.state.onChangeHandler}
106
+ error={formState.state.hasError}
107
+ label="State"
108
+ placeholder="CA"
109
+ fluid
110
+ />
111
+ <Form.Input
112
+ className="m-b-0-i qa-settings-company-details-zip-code"
113
+ value={formState.zipCode.value}
114
+ onChange={formState.zipCode.onChangeHandler}
115
+ error={formState.zipCode.hasError}
116
+ label="Zip Code"
117
+ placeholder="91203"
118
+ fluid
119
+ maxLength={7}
120
+ />
121
+ </Form.Group>
122
+ <Form.Group className="m-b-2-i">
123
+ <Form.Input
124
+ width={8}
125
+ className="m-b-0-i qa-settings-company-details-company-email"
126
+ value={formState.companyEmail.value}
127
+ onChange={formState.companyEmail.onChangeHandler}
128
+ error={formState.companyEmail.hasError}
129
+ onBlur={handleCompanyEmailBlur}
130
+ label="Company Email"
131
+ placeholder="hello@yourcompany.com"
132
+ fluid
133
+ />
134
+ <Form.Field
135
+ label="Year Established"
136
+ className="qa-settings-company-details-company-email"
137
+ width={4}
138
+ error={formState.yearEstablished.hasError}
139
+ >
140
+ <NumberInput
141
+ value={formState.yearEstablished.value}
142
+ onChange={formState.yearEstablished.onChange}
143
+ emptyValue={undefined}
144
+ min={1}
145
+ max={2099}
146
+ useEmptyThousandsSeparator
147
+ placeholder="1950"
148
+ fluid
149
+ />
150
+ </Form.Field>
151
+ </Form.Group>
152
+ {logoPicker}
153
+ </Form>
154
+ </SettingsSection>
155
+ );
156
+ }
157
+ );
@@ -0,0 +1,26 @@
1
+ import { InputFieldState } from '@servicetitan/form';
2
+ import { injectable, provide, useDependencies } from '@servicetitan/react-ioc';
3
+ import { FormState } from 'formstate';
4
+
5
+ import { CompanyEmailFooter as Component } from '.';
6
+
7
+ export default {
8
+ title: 'MPA Components/settings/CompanyEmailFooter',
9
+ component: Component,
10
+ parameters: {},
11
+ };
12
+
13
+ @injectable()
14
+ class CompanyEmailStore {
15
+ form = new FormState({
16
+ legalCopy: new InputFieldState('Legal copy example'),
17
+ license: new InputFieldState('License'),
18
+ copyrightText: new InputFieldState('Copyritght 2022'),
19
+ });
20
+ }
21
+
22
+ export const CompanyEmailFooter = provide({ singletons: [CompanyEmailStore] })(() => {
23
+ const [store] = useDependencies(CompanyEmailStore);
24
+
25
+ return <Component formState={store.form.$} />;
26
+ });
@@ -0,0 +1,79 @@
1
+ import { FC, Fragment } from 'react';
2
+ import { observer } from 'mobx-react';
3
+
4
+ import { Form, Text } from '@servicetitan/design-system';
5
+ import { InputFieldState } from '@servicetitan/form';
6
+
7
+ import { SettingsSection } from '../settings-section';
8
+
9
+ export interface CompanyEmailFooterProps {
10
+ formState: {
11
+ legalCopy: InputFieldState<string>;
12
+ license: InputFieldState<string>;
13
+ copyrightText: InputFieldState<string>;
14
+ };
15
+ }
16
+
17
+ export const CompanyEmailFooter: FC<CompanyEmailFooterProps> = observer(
18
+ ({ formState: { legalCopy, license, copyrightText } }) => {
19
+ return (
20
+ <SettingsSection
21
+ title="Footer"
22
+ text={`Your footer will be partially generated from the Company Details section above.
23
+ Please enter the additional info so that it is CAN-SPAM compliant.`}
24
+ qaPrefix="qa-settings-footer"
25
+ >
26
+ <Form className="m-b-0-i">
27
+ <Form.TextArea
28
+ className="m-b-2-i qa-settings-footer-legal-copy"
29
+ label={
30
+ <Fragment>
31
+ Legal Copy&nbsp;
32
+ <Text inline size={2} subdued>
33
+ (optional)
34
+ </Text>
35
+ </Fragment>
36
+ }
37
+ placeholder="Enter legal copy here"
38
+ value={legalCopy.value}
39
+ onChange={legalCopy.onChangeHandler}
40
+ />
41
+ <Form.Group className="m-b-0-i">
42
+ <Form.Input
43
+ width={6}
44
+ className="m-b-0-i qa-settings-footer-lic"
45
+ value={license.value}
46
+ onChange={license.onChangeHandler}
47
+ label={
48
+ <Fragment>
49
+ LIC #&nbsp;
50
+ <Text inline size={2} subdued>
51
+ (optional)
52
+ </Text>
53
+ </Fragment>
54
+ }
55
+ placeholder="XYZ12345"
56
+ fluid
57
+ />
58
+ <Form.Input
59
+ width={6}
60
+ className="m-b-0-i qa-settings-footer-copyright-text"
61
+ value={copyrightText.value}
62
+ onChange={copyrightText.onChangeHandler}
63
+ label={
64
+ <Fragment>
65
+ Copyright Text&nbsp;
66
+ <Text inline size={2} subdued>
67
+ (optional)
68
+ </Text>
69
+ </Fragment>
70
+ }
71
+ placeholder="© 2022, all right reserved"
72
+ fluid
73
+ />
74
+ </Form.Group>
75
+ </Form>
76
+ </SettingsSection>
77
+ );
78
+ }
79
+ );
@@ -0,0 +1,23 @@
1
+ import { InputFieldState } from '@servicetitan/form';
2
+ import { injectable, provide, useDependencies } from '@servicetitan/react-ioc';
3
+ import { FormState } from 'formstate';
4
+
5
+ import { CompanyEmailReplyTo as Component } from '.';
6
+
7
+ export default {
8
+ title: 'MPA Components/settings/CompanyEmailReplyTo',
9
+ component: Component,
10
+ parameters: {},
11
+ };
12
+
13
+ @injectable()
14
+ class CompanyEmailReplyToStore {
15
+ form = new FormState({
16
+ replyToEmail: new InputFieldState('info@acme.com'),
17
+ });
18
+ }
19
+
20
+ export const CompanyEmailReplyTo = provide({ singletons: [CompanyEmailReplyToStore] })(() => {
21
+ const [store] = useDependencies(CompanyEmailReplyToStore);
22
+ return <Component replyToEmail={store.form.$.replyToEmail} />;
23
+ });
@@ -0,0 +1,38 @@
1
+ import { FC, useCallback } from 'react';
2
+ import { observer } from 'mobx-react';
3
+
4
+ import { InputFieldState } from '@servicetitan/form';
5
+ import { Form } from '@servicetitan/design-system';
6
+
7
+ import { SettingsSection } from '../settings-section';
8
+
9
+ export interface CompanyEmailReplyToProps {
10
+ replyToEmail: InputFieldState<string>;
11
+ }
12
+
13
+ export const CompanyEmailReplyTo: FC<CompanyEmailReplyToProps> = observer(({ replyToEmail }) => {
14
+ const handleReplyToBlur = useCallback(() => {
15
+ replyToEmail.validate();
16
+ }, [replyToEmail]);
17
+
18
+ return (
19
+ <SettingsSection
20
+ title="Reply-To"
21
+ text="This is where emails will be sent if someone replies to one of your emails."
22
+ qaPrefix="qa-settings-reply-to"
23
+ >
24
+ <Form className="m-b-0-i">
25
+ <Form.Input
26
+ className="m-b-0-i qa-settings-reply-to-email-address"
27
+ value={replyToEmail.value}
28
+ onChange={replyToEmail.onChangeHandler}
29
+ error={replyToEmail.hasError}
30
+ onBlur={handleReplyToBlur}
31
+ label="Reply-to Email Address"
32
+ placeholder="info@yourcompany.com"
33
+ fluid
34
+ />
35
+ </Form>
36
+ </SettingsSection>
37
+ );
38
+ });
@@ -0,0 +1,7 @@
1
+ @import (reference) '~@servicetitan/tokens/dist/tokens.less';
2
+
3
+ .domain {
4
+ height: 40px;
5
+ display: flex;
6
+ align-items: center;
7
+ }
@@ -0,0 +1,3 @@
1
+ export const __esModule: true;
2
+ export const domain: string;
3
+
@@ -0,0 +1,26 @@
1
+ import { InputFieldState } from '@servicetitan/form';
2
+ import { injectable, provide, useDependencies } from '@servicetitan/react-ioc';
3
+ import { FormState } from 'formstate';
4
+
5
+ import { CompanyEmailSender as Component } from '.';
6
+
7
+ export default {
8
+ title: 'MPA Components/settings/CompanyEmailSender',
9
+ component: Component,
10
+ parameters: {},
11
+ };
12
+
13
+ @injectable()
14
+ class CompanyEmailSenderStore {
15
+ form = new FormState({
16
+ senderEmail: new InputFieldState('email@acme.com'),
17
+ senderName: new InputFieldState('Pinky & Brain'),
18
+ senderDomain: new InputFieldState('acme'),
19
+ });
20
+ }
21
+
22
+ export const CompanyEmailSender = provide({ singletons: [CompanyEmailSenderStore] })(() => {
23
+ const [store] = useDependencies(CompanyEmailSenderStore);
24
+
25
+ return <Component formState={store.form.$} senderTld="com" />;
26
+ });