@servicetitan/onboarding-ui 4.0.1 → 4.0.2

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 (67) hide show
  1. package/dist/address-suggestion-popover/components/address-suggestion-popover.d.ts +28 -0
  2. package/dist/address-suggestion-popover/components/address-suggestion-popover.d.ts.map +1 -0
  3. package/dist/address-suggestion-popover/components/address-suggestion-popover.js +57 -0
  4. package/dist/address-suggestion-popover/components/address-suggestion-popover.js.map +1 -0
  5. package/dist/address-suggestion-popover/index.d.ts +3 -0
  6. package/dist/address-suggestion-popover/index.d.ts.map +1 -0
  7. package/dist/address-suggestion-popover/index.js +3 -0
  8. package/dist/address-suggestion-popover/index.js.map +1 -0
  9. package/dist/address-suggestion-popover/utils/google-geocoder-suggestions-provider.d.ts +24 -0
  10. package/dist/address-suggestion-popover/utils/google-geocoder-suggestions-provider.d.ts.map +1 -0
  11. package/dist/address-suggestion-popover/utils/google-geocoder-suggestions-provider.js +121 -0
  12. package/dist/address-suggestion-popover/utils/google-geocoder-suggestions-provider.js.map +1 -0
  13. package/dist/address-suggestion-popover/utils/index.d.ts +2 -0
  14. package/dist/address-suggestion-popover/utils/index.d.ts.map +1 -0
  15. package/dist/address-suggestion-popover/utils/index.js +2 -0
  16. package/dist/address-suggestion-popover/utils/index.js.map +1 -0
  17. package/dist/company-profile/components/company-profile-form.js +51 -0
  18. package/dist/company-profile/components/company-profile-form.js.map +1 -0
  19. package/dist/company-profile/components/country-dropdown-input.js +19 -0
  20. package/dist/company-profile/components/country-dropdown-input.js.map +1 -0
  21. package/dist/company-profile/components/state-and-province-dropdown-input.js +55 -0
  22. package/dist/company-profile/components/state-and-province-dropdown-input.js.map +1 -0
  23. package/dist/company-profile/index.js +7 -0
  24. package/dist/company-profile/index.js.map +1 -0
  25. package/dist/company-profile/stores/__mocks__/company-profile-form-mock-data.js +29 -0
  26. package/dist/company-profile/stores/__mocks__/company-profile-form-mock-data.js.map +1 -0
  27. package/dist/company-profile/stores/company-profile-form.store.js +273 -0
  28. package/dist/company-profile/stores/company-profile-form.store.js.map +1 -0
  29. package/dist/company-profile/utils/validators.d.ts +2 -0
  30. package/dist/company-profile/utils/validators.d.ts.map +1 -0
  31. package/dist/company-profile/utils/validators.js +10 -0
  32. package/dist/company-profile/utils/validators.js.map +1 -0
  33. package/dist/contentful/index.d.ts +5 -0
  34. package/dist/contentful/index.d.ts.map +1 -0
  35. package/dist/contentful/index.js +5 -0
  36. package/dist/contentful/index.js.map +1 -0
  37. package/dist/contentful/interfaces.d.ts +36 -0
  38. package/dist/contentful/interfaces.d.ts.map +1 -0
  39. package/dist/contentful/interfaces.js +2 -0
  40. package/dist/contentful/interfaces.js.map +1 -0
  41. package/dist/contentful/marketing-carousel.store.d.ts +43 -0
  42. package/dist/contentful/marketing-carousel.store.d.ts.map +1 -0
  43. package/dist/contentful/marketing-carousel.store.js +193 -0
  44. package/dist/contentful/marketing-carousel.store.js.map +1 -0
  45. package/dist/contentful/utils.d.ts +8 -0
  46. package/dist/contentful/utils.d.ts.map +1 -0
  47. package/dist/contentful/utils.js +17 -0
  48. package/dist/contentful/utils.js.map +1 -0
  49. package/dist/country-helpers.d.ts +12 -0
  50. package/dist/country-helpers.d.ts.map +1 -0
  51. package/dist/country-helpers.js +46 -0
  52. package/dist/country-helpers.js.map +1 -0
  53. package/dist/hooks/index.d.ts +2 -0
  54. package/dist/hooks/index.d.ts.map +1 -0
  55. package/dist/hooks/index.js +2 -0
  56. package/dist/hooks/index.js.map +1 -0
  57. package/dist/hooks/use-scroll-to-error/index.d.ts +2 -0
  58. package/dist/hooks/use-scroll-to-error/index.d.ts.map +1 -0
  59. package/dist/hooks/use-scroll-to-error/index.js +2 -0
  60. package/dist/hooks/use-scroll-to-error/index.js.map +1 -0
  61. package/dist/hooks/use-scroll-to-error/use-scroll-to-error.d.ts +4 -0
  62. package/dist/hooks/use-scroll-to-error/use-scroll-to-error.d.ts.map +1 -0
  63. package/dist/hooks/use-scroll-to-error/use-scroll-to-error.js +28 -0
  64. package/dist/hooks/use-scroll-to-error/use-scroll-to-error.js.map +1 -0
  65. package/dist/index.js +4 -0
  66. package/dist/index.js.map +1 -0
  67. package/package.json +3 -3
@@ -0,0 +1,28 @@
1
+ import { FC } from 'react';
2
+ import { PopoverProps } from '@servicetitan/design-system';
3
+ export interface AddressModel {
4
+ street?: string;
5
+ unit?: string;
6
+ city?: string;
7
+ state?: string;
8
+ zip?: string;
9
+ country?: string;
10
+ latitude?: number;
11
+ longitude?: number;
12
+ locationType?: string;
13
+ }
14
+ export interface AddressSuggestionResult {
15
+ key: string;
16
+ title: string;
17
+ value: AddressModel;
18
+ }
19
+ export interface AddressSuggestionsProvider {
20
+ getSuggestions(address: AddressModel): Promise<AddressSuggestionResult[] | undefined | string>;
21
+ }
22
+ export interface AddressSuggestionPopoverProps extends PopoverProps {
23
+ currentAddress: AddressModel;
24
+ addressSuggestionsProvider: AddressSuggestionsProvider;
25
+ onSuggestionSelect(suggestion: AddressModel): void;
26
+ }
27
+ export declare const AddressSuggestionPopover: FC<AddressSuggestionPopoverProps>;
28
+ //# sourceMappingURL=address-suggestion-popover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-suggestion-popover.d.ts","sourceRoot":"","sources":["../../../src/address-suggestion-popover/components/address-suggestion-popover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAA6B,YAAY,EAAW,MAAM,6BAA6B,CAAC;AAK/F,MAAM,WAAW,YAAY;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,uBAAuB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,YAAY,CAAC;CACvB;AAOD,MAAM,WAAW,0BAA0B;IACvC,cAAc,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,uBAAuB,EAAE,GAAG,SAAS,GAAG,MAAM,CAAC,CAAC;CAClG;AAED,MAAM,WAAW,6BAA8B,SAAQ,YAAY;IAC/D,cAAc,EAAE,YAAY,CAAC;IAC7B,0BAA0B,EAAE,0BAA0B,CAAC;IACvD,kBAAkB,CAAC,UAAU,EAAE,YAAY,GAAG,IAAI,CAAC;CACtD;AAED,eAAO,MAAM,wBAAwB,EAAE,EAAE,CAAC,6BAA6B,CAsEtE,CAAC"}
@@ -0,0 +1,57 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __rest = (this && this.__rest) || function (s, e) {
11
+ var t = {};
12
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
+ t[p] = s[p];
14
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
+ t[p[i]] = s[p[i]];
18
+ }
19
+ return t;
20
+ };
21
+ import { jsx as _jsx } from "react/jsx-runtime";
22
+ import { useEffect, useState } from 'react';
23
+ import { useBoolean } from '@servicetitan/react-hooks';
24
+ import { BodyText, Button, Popover, Spinner } from '@servicetitan/design-system';
25
+ import { observer } from 'mobx-react';
26
+ import * as styles from './styles.module.less';
27
+ import { getCountry } from '../../country-helpers';
28
+ const withVerifiedCountryValue = (address) => {
29
+ var _a;
30
+ address.country = (_a = getCountry(address.country)) !== null && _a !== void 0 ? _a : address.country;
31
+ return address;
32
+ };
33
+ export const AddressSuggestionPopover = observer((_a) => {
34
+ var { portal = true, width = 'm', direction = 'l', padding = 's', currentAddress, addressSuggestionsProvider, onSuggestionSelect } = _a, restProps = __rest(_a, ["portal", "width", "direction", "padding", "currentAddress", "addressSuggestionsProvider", "onSuggestionSelect"]);
35
+ const [isLoading, { setFalse: disableLoading, setTrue: enabledLoading }] = useBoolean(true);
36
+ const [results, setResults] = useState(undefined);
37
+ useEffect(() => {
38
+ const bootstrap = () => __awaiter(void 0, void 0, void 0, function* () {
39
+ if (!restProps.open) {
40
+ return;
41
+ }
42
+ enabledLoading();
43
+ setResults(undefined);
44
+ try {
45
+ const results = yield addressSuggestionsProvider.getSuggestions(currentAddress);
46
+ setResults(results);
47
+ }
48
+ finally {
49
+ disableLoading();
50
+ }
51
+ });
52
+ bootstrap();
53
+ // eslint-disable-next-line react-hooks/exhaustive-deps
54
+ }, [restProps.open]);
55
+ return (_jsx(Popover, Object.assign({ portal: portal, width: width, direction: direction, padding: padding }, restProps, { children: isLoading ? (_jsx("div", Object.assign({ className: "d-f justify-content-center" }, { children: _jsx(Spinner, { size: "tiny" }) }))) : typeof results === 'string' || !(results === null || results === void 0 ? void 0 : results.length) ? (_jsx(BodyText, Object.assign({ className: "c-blue-400 ta-center", bold: true }, { children: typeof results === 'string' ? results : 'No suggestions' }))) : (results.map(result => (_jsx(Button, Object.assign({ full: true, fill: "subtle", className: styles.verifyAddressBtn, color: "primary", onClick: () => onSuggestionSelect(withVerifiedCountryValue(result.value)) }, { children: result.title }), result.key)))) })));
56
+ });
57
+ //# sourceMappingURL=address-suggestion-popover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-suggestion-popover.js","sourceRoot":"","sources":["../../../src/address-suggestion-popover/components/address-suggestion-popover.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAM,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAgB,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAoBnD,MAAM,wBAAwB,GAAG,CAAC,OAAqB,EAAgB,EAAE;;IACrE,OAAO,CAAC,OAAO,GAAG,MAAA,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,mCAAI,OAAO,CAAC,OAAO,CAAC;IACjE,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAYF,MAAM,CAAC,MAAM,wBAAwB,GAAsC,QAAQ,CAC/E,CAAC,EASA,EAAE,EAAE;QATJ,EACG,MAAM,GAAG,IAAI,EACb,KAAK,GAAG,GAAG,EACX,SAAS,GAAG,GAAG,EACf,OAAO,GAAG,GAAG,EACb,cAAc,EACd,0BAA0B,EAC1B,kBAAkB,OAErB,EADM,SAAS,cARf,iHASA,CADe;IAEZ,MAAM,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC5F,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GACvB,QAAQ,CAAoE,SAAS,CAAC,CA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G,EAAE,CACV,kBAAkB,CAAC,wBAAwB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,gBAG7D,MAAM,CAAC,KAAK,KATR,MAAM,CAAC,GAAG,CAUV,CACZ,CAAC,CACL,IACK,CACb,CAAC;AACN,CAAC,CACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './components/address-suggestion-popover';
2
+ export * from './utils';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/address-suggestion-popover/index.ts"],"names":[],"mappings":"AAAA,cAAc,yCAAyC,CAAC;AACxD,cAAc,SAAS,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './components/address-suggestion-popover';
2
+ export * from './utils';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/address-suggestion-popover/index.ts"],"names":[],"mappings":"AAAA,cAAc,yCAAyC,CAAC;AACxD,cAAc,SAAS,CAAC"}
@@ -0,0 +1,24 @@
1
+ /// <reference types="google.maps" />
2
+ import { AddressModel, AddressSuggestionsProvider } from '../components/address-suggestion-popover';
3
+ export declare class GoogleGeocoderSuggestionsProvider implements AddressSuggestionsProvider {
4
+ getSuggestions: (address: AddressModel) => Promise<{
5
+ key: string;
6
+ title: string;
7
+ value: {
8
+ street: string | undefined;
9
+ unit: string | undefined;
10
+ city: string | undefined;
11
+ state: string | undefined;
12
+ zip: string | undefined;
13
+ country: string | undefined;
14
+ latitude: number;
15
+ longitude: number;
16
+ locationType: google.maps.GeocoderLocationType;
17
+ };
18
+ }[] | undefined>;
19
+ private addressToString;
20
+ private composeSuggestionResult;
21
+ private getAddressComponentByType;
22
+ private getCity;
23
+ }
24
+ //# sourceMappingURL=google-geocoder-suggestions-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-geocoder-suggestions-provider.d.ts","sourceRoot":"","sources":["../../../src/address-suggestion-popover/utils/google-geocoder-suggestions-provider.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAEpG,qBAAa,iCAAkC,YAAW,0BAA0B;IAChF,cAAc,YAAmB,YAAY;;;;;;;;;;;;;;qBAa3C;IAEF,OAAO,CAAC,eAAe,CAiBrB;IAEF,OAAO,CAAC,uBAAuB,CAsC7B;IAEF,OAAO,CAAC,yBAAyB,CAO3B;IAEN,OAAO,CAAC,OAAO,CAuBb;CACL"}
@@ -0,0 +1,121 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export class GoogleGeocoderSuggestionsProvider {
11
+ constructor() {
12
+ Object.defineProperty(this, "getSuggestions", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: (address) => __awaiter(this, void 0, void 0, function* () {
17
+ if (!window.google) {
18
+ return;
19
+ }
20
+ const addressStr = this.addressToString(address);
21
+ const countryCode = address.country === 'Canada' ? 'ca' : 'us';
22
+ const params = {
23
+ address: addressStr,
24
+ region: countryCode,
25
+ };
26
+ const geocoder = new google.maps.Geocoder();
27
+ const { results } = yield geocoder.geocode(params);
28
+ return results.map(this.composeSuggestionResult);
29
+ })
30
+ });
31
+ Object.defineProperty(this, "addressToString", {
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true,
35
+ value: ({ street, unit, city, state, zip, country }) => {
36
+ const addressArray = [];
37
+ const appendPart = (prefix, part) => {
38
+ if (part) {
39
+ addressArray.push(prefix, part);
40
+ }
41
+ };
42
+ appendPart('', street);
43
+ appendPart(' ', unit ? '#' + unit : undefined);
44
+ appendPart(', ', city);
45
+ appendPart(', ', state);
46
+ appendPart(' ', zip);
47
+ appendPart(' ', country);
48
+ return addressArray.join();
49
+ }
50
+ });
51
+ Object.defineProperty(this, "composeSuggestionResult", {
52
+ enumerable: true,
53
+ configurable: true,
54
+ writable: true,
55
+ value: (result) => {
56
+ const streetParts = [];
57
+ const streetNumber = this.getAddressComponentByType(result.address_components, 'street_number');
58
+ if (streetNumber) {
59
+ streetParts.push(streetNumber);
60
+ }
61
+ const streetRoute = this.getAddressComponentByType(result.address_components, 'route', true);
62
+ if (streetRoute) {
63
+ streetParts.push(streetRoute);
64
+ }
65
+ return {
66
+ key: result.formatted_address,
67
+ title: result.formatted_address,
68
+ value: {
69
+ street: streetParts.length > 0 ? streetParts.join(' ') : undefined,
70
+ unit: this.getAddressComponentByType(result.address_components, 'subpremise'),
71
+ city: this.getCity(result.formatted_address, result.address_components),
72
+ state: this.getAddressComponentByType(result.address_components, 'administrative_area_level_1'),
73
+ zip: this.getAddressComponentByType(result.address_components, 'postal_code'),
74
+ country: this.getAddressComponentByType(result.address_components, 'country'),
75
+ latitude: result.geometry.location.lat(),
76
+ longitude: result.geometry.location.lng(),
77
+ locationType: result.geometry.location_type,
78
+ },
79
+ };
80
+ }
81
+ });
82
+ Object.defineProperty(this, "getAddressComponentByType", {
83
+ enumerable: true,
84
+ configurable: true,
85
+ writable: true,
86
+ value: (components, type, longName) => {
87
+ var _a;
88
+ return (_a = components.find(component => component.types.includes(type))) === null || _a === void 0 ? void 0 : _a[longName ? 'long_name' : 'short_name'];
89
+ }
90
+ });
91
+ Object.defineProperty(this, "getCity", {
92
+ enumerable: true,
93
+ configurable: true,
94
+ writable: true,
95
+ value: (address, components) => {
96
+ var _a, _b;
97
+ const getAsRegexpWithWordBounds = (text) => {
98
+ return new RegExp('\\b' + text + '\\b');
99
+ };
100
+ const locality = this.getAddressComponentByType(components, 'locality', true);
101
+ if (locality && getAsRegexpWithWordBounds(locality).test(address)) {
102
+ return locality;
103
+ }
104
+ const area3 = this.getAddressComponentByType(components, 'administrative_area_level_3');
105
+ if (area3 && getAsRegexpWithWordBounds(area3).test(address)) {
106
+ return area3;
107
+ }
108
+ const sublocality = this.getAddressComponentByType(components, 'sublocality');
109
+ if (sublocality && getAsRegexpWithWordBounds(sublocality).test(address)) {
110
+ return sublocality;
111
+ }
112
+ const neighborhood = this.getAddressComponentByType(components, 'neighborhood');
113
+ if (neighborhood && getAsRegexpWithWordBounds(neighborhood).test(address)) {
114
+ return neighborhood;
115
+ }
116
+ return (_b = (_a = locality !== null && locality !== void 0 ? locality : area3) !== null && _a !== void 0 ? _a : sublocality) !== null && _b !== void 0 ? _b : neighborhood;
117
+ }
118
+ });
119
+ }
120
+ }
121
+ //# sourceMappingURL=google-geocoder-suggestions-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-geocoder-suggestions-provider.js","sourceRoot":"","sources":["../../../src/address-suggestion-popover/utils/google-geocoder-suggestions-provider.ts"],"names":[],"mappings":";;;;;;;;;AAEA,MAAM,OAAO,iCAAiC;IAA9C;QACI;;;;mBAAiB,CAAO,OAAqB,EAAE,EAAE;gBAC7C,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;oBAChB,OAAO;iBACV;gBACD,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;gBACjD,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;gBAC/D,MAAM,MAAM,GAAG;oBACX,OAAO,EAAE,UAAU;oBACnB,MAAM,EAAE,WAAW;iBACtB,CAAC;gBACF,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAC5C,MAAM,EAAE,OAAO,EAAE,GAA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-0,0 +1,2 @@
1
+ export * from './google-geocoder-suggestions-provider';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/address-suggestion-popover/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './google-geocoder-suggestions-provider';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/address-suggestion-popover/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button, Form } from '@servicetitan/design-system';
3
+ import { MaskedInput } from '@servicetitan/form';
4
+ import { useBoolean } from '@servicetitan/react-hooks';
5
+ import { useDependencies } from '@servicetitan/react-ioc';
6
+ import classNames from 'classnames';
7
+ import { observer } from 'mobx-react';
8
+ import { useEffect } from 'react';
9
+ import { AddressSuggestionPopover, } from '../../address-suggestion-popover';
10
+ import { CompanyProfileFormStore } from '../stores/company-profile-form.store';
11
+ import { CountryDropdownInput } from './country-dropdown-input';
12
+ import { StateAndProvinceDropdownInput } from './state-and-province-dropdown-input';
13
+ export const CompanyProfileForm = observer(({ className, el: Element = Form, addressSuggestionsProvider }) => {
14
+ var _a;
15
+ const [{ form, showFormError, zipCodeMask, einOrBnMask, einOrBnInputProps, countries, countryAndRegionData, regionToCodeMap, phoneMask, suggestionAddressModel, applyAddressSuggestion, setNeedAddressValidation, withAddressValidation, },] = useDependencies(CompanyProfileFormStore);
16
+ const zipCodeOnChangeHandler = (zip) => {
17
+ form.$.address.$.companyZipCode.onChange(zip);
18
+ };
19
+ const einOrBnOnChangeHandler = (einOrBn) => {
20
+ form.$.einOrBn.onChange((einOrBn || '').replace(/[^0-9.]/g, ''));
21
+ };
22
+ const phoneOnChangeHandler = (phone) => {
23
+ form.$.adminPhone.onChange((phone || '').replace(/[^0-9.]/g, ''));
24
+ };
25
+ const countryOnChangeHandler = (event, data) => {
26
+ if (form.$.address.$.companyCountry.value &&
27
+ data.value !== form.$.address.$.companyCountry.value) {
28
+ form.$.address.$.companyStateCode.onChange('');
29
+ }
30
+ form.$.address.$.companyCountry.onChangeHandler(event, data);
31
+ };
32
+ const { companyName, address: { $: { companyStreetAddress, companyCity, companyCountry, companyStateCode, companyZipCode, isCompanyAddressVerified, }, hasFormError: addressHasFormError, }, adminPhone, einOrBn, } = form.$;
33
+ const zipCodeHasError = companyZipCode.hasError;
34
+ const [isAddressSuggestionsOpen, { setTrue: openAddressSuggestions, setFalse: closeAddressSuggestions },] = useBoolean(false);
35
+ useEffect(() => {
36
+ setNeedAddressValidation(!!addressSuggestionsProvider);
37
+ }, [setNeedAddressValidation, addressSuggestionsProvider]);
38
+ const showAddressValidation = withAddressValidation && !isCompanyAddressVerified.value;
39
+ return (_jsxs(Element, Object.assign({ size: "tiny", className: classNames(className, 'ta-left', 'p-x-6') }, { children: [_jsx(Form.Input, { label: "Company Name", placeholder: "Company Name", value: companyName.value, onChange: companyName.onChangeHandler, error: (companyName.dirty || showFormError) && companyName.hasError }), _jsxs("div", Object.assign({ className: classNames('d-f', {
40
+ 'gap-2': showAddressValidation,
41
+ }) }, { children: [_jsx(Form.Input, { className: "flex-grow-1", label: "Street Address", placeholder: "Street Address", value: companyStreetAddress.value, onChange: companyStreetAddress.onChangeHandler, error: (companyStreetAddress.dirty || showFormError) &&
42
+ (companyStreetAddress.hasError || addressHasFormError) }), _jsx(Form.Field, Object.assign({ label: '\u00a0' }, { children: showAddressValidation && (_jsx(AddressSuggestionPopover, { addressSuggestionsProvider: addressSuggestionsProvider, open: isAddressSuggestionsOpen, onClickOutside: closeAddressSuggestions, trigger: _jsx(Button, { "aria-label": "Open address suggestions", iconName: "place", outline: true, onClick: openAddressSuggestions, negative: addressHasFormError }), currentAddress: suggestionAddressModel, onSuggestionSelect: suggestedAddress => {
43
+ applyAddressSuggestion(suggestedAddress);
44
+ closeAddressSuggestions();
45
+ } })) }))] })), _jsxs(Form.Group, Object.assign({ width: "equal" }, { children: [_jsx(Form.Input, { fluid: true, label: "City", placeholder: "City", className: "p-r-0", width: "6", value: companyCity.value, onChange: companyCity.onChangeHandler, error: (companyCity.dirty || showFormError) && companyCity.hasError }), _jsx(StateAndProvinceDropdownInput, { width: "6", countryCode: (_a = companyCountry.value) !== null && _a !== void 0 ? _a : 'USA', fieldState: companyStateCode, error: (companyStateCode.dirty || showFormError) && companyStateCode.hasError, countryAndRegionData: countryAndRegionData, regionNameToCodeMap: regionToCodeMap })] })), _jsxs(Form.Group, Object.assign({ width: "equal" }, { children: [_jsx(MaskedInput, { fluid: true, label: "ZIP Code", placeholder: "ZIP Code", value: companyZipCode.value, onChange: zipCodeOnChangeHandler, mask: zipCodeMask, className: "p-r-0", maskChar: " ", error: (companyZipCode.dirty || showFormError) && zipCodeHasError, width: 6 }), _jsx(CountryDropdownInput, { width: "6", value: companyCountry.value, onChange: countryOnChangeHandler, error: (companyCountry.dirty || showFormError) && companyCountry.hasError, options: countries.map(x => ({
46
+ key: x,
47
+ value: x,
48
+ text: x === 'USA' ? 'United States' : x,
49
+ })) })] })), _jsxs(Form.Group, Object.assign({ width: "equal" }, { children: [_jsx(MaskedInput, { fluid: true, label: "Phone Number", placeholder: "Phone Number", value: adminPhone.value, onChange: phoneOnChangeHandler, error: (adminPhone.dirty || showFormError) && adminPhone.hasError, mask: phoneMask, width: 6 }), _jsx(MaskedInput, { fluid: true, label: einOrBnInputProps.label, placeholder: einOrBnInputProps.placeholder, value: einOrBn.value, onChange: einOrBnOnChangeHandler, mask: einOrBnMask, className: "p-r-0", maskChar: " ", error: (einOrBn.dirty || showFormError) && einOrBn.hasError, width: 6 })] }))] })));
50
+ });
51
+ //# sourceMappingURL=company-profile-form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"company-profile-form.js","sourceRoot":"","sources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function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { Form } from '@servicetitan/design-system';
14
+ import { observer } from 'mobx-react';
15
+ export const CountryDropdownInput = observer((props) => {
16
+ const { value, width, placeholder } = props, rest = __rest(props, ["value", "width", "placeholder"]);
17
+ return (_jsx(Form.Select, Object.assign({ fluid: true, search: true, width: width !== null && width !== void 0 ? width : '12', label: "Country", placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : 'Country', value: value }, rest)));
18
+ });
19
+ //# sourceMappingURL=country-dropdown-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"country-dropdown-input.js","sourceRoot":"","sources":["../../../src/company-profile/components/country-dropdown-input.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAqB,IAAI,EAAkB,MAAM,6BAA6B,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAQtC,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC,CAAC,KAA4B,EAAE,EAAE;IAC1E,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,KAAc,KAAK,EAAd,IAAI,UAAK,KAAK,EAA9C,iCAAsC,CAAQ,CAAC;IACrD,OAAO,CACH,KAAC,IAAI,CAAC,MAAM,kBACR,KAAK,QACL,MAAM,QACN,KAAK,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,EACpB,KAAK,EAAC,SAAS,EACf,WAAW,EAAE,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,SAAS,EACrC,KAAK,EAAE,KAAK,IACR,IAAI,EACV,CACL,CAAC;AACN,CAAC,CAAC,CAAC"}
@@ -0,0 +1,55 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { useEffect } from 'react';
14
+ import { Form } from '@servicetitan/design-system';
15
+ import { observer } from 'mobx-react';
16
+ const toTitleCase = (str) => str.replace(/\w\S*/g, txt => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());
17
+ export const StateAndProvinceDropdownInput = observer((props) => {
18
+ const { fieldState, regionNameToCodeMap, countryAndRegionData, countryCode, width, placeholder } = props, rest = __rest(props, ["fieldState", "regionNameToCodeMap", "countryAndRegionData", "countryCode", "width", "placeholder"]);
19
+ const { value, onChange, onChangeHandler } = fieldState;
20
+ useEffect(() => {
21
+ var _a;
22
+ /*
23
+ * requirement: convert any incoming state value that is a full state/province name
24
+ * to it's respective state code (e.g. 'Alabama' => 'AL')
25
+ * The incoming value may not have proper casing
26
+ * (salesforce data input through text input field not dropdown),
27
+ * so convert to proper casing to find value in map
28
+ * https://servicetitan.atlassian.net/browse/OX-948
29
+ */
30
+ if (value && value.length > 2) {
31
+ onChange((_a = regionNameToCodeMap.get(toTitleCase(value))) !== null && _a !== void 0 ? _a : ' ');
32
+ }
33
+ }, [onChange, regionNameToCodeMap, value]);
34
+ let americanRegionalData;
35
+ let canadianRegionalData;
36
+ countryAndRegionData.forEach((countryOption) => {
37
+ const data = countryOption.Regions.map((option) => ({
38
+ key: option.Code,
39
+ value: option.Code,
40
+ text: option.Name,
41
+ }));
42
+ if (countryOption.Country === 'US') {
43
+ americanRegionalData = data;
44
+ }
45
+ if (countryOption.Country === 'CA') {
46
+ canadianRegionalData = data;
47
+ }
48
+ });
49
+ const regionType = countryCode.toLowerCase() === 'canada' || countryCode.toLowerCase() === 'ca'
50
+ ? 'Province'
51
+ : 'State';
52
+ const options = regionType === 'Province' ? canadianRegionalData : americanRegionalData;
53
+ return (_jsx(Form.Select, Object.assign({ search: true, fluid: true, width: width !== null && width !== void 0 ? width : '12', label: regionType, placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : regionType, value: value, onChange: onChangeHandler, options: options }, rest)));
54
+ });
55
+ //# sourceMappingURL=state-and-province-dropdown-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-and-province-dropdown-input.js","sourceRoot":"","sources":["../../../src/company-profile/components/state-and-province-dropdown-input.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,IAAI,EAAqC,MAAM,6BAA6B,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAYtC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE,CAChC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAE5F,MAAM,CAAC,MAAM,6BAA6B,GAAG,QAAQ,CACjD,CAAC,KAAyC,EAAE,EAAE;IAC1C,MAAM,EACF,UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,EACX,KAAK,EACL,WAAW,KAEX,KAAK,EADF,IAAI,UACP,KAAK,EARH,oGAQL,CAAQ,CA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AAK,QACL,KAAK,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,EACpB,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,UAAU,EACtC,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,OAAQ,IACb,IAAI,EACV,CACL,CAAC;AACN,CAAC,CACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from './components/company-profile-form';
2
+ export * from './components/country-dropdown-input';
3
+ export * from './components/state-and-province-dropdown-input';
4
+ export * from './stores/company-profile-form.store';
5
+ export * from './stores/__mocks__/company-profile-form-mock-data';
6
+ export * from './utils/validators';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/company-profile/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,qCAAqC,CAAC;AACpD,cAAc,mDAAmD,CAAC;AAClE,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,29 @@
1
+ export const CompanyProfileFormCorrect = {
2
+ companyName: 'Wyatt Works',
3
+ adminPhone: '(310) 855-8585',
4
+ companyStreetAddress: '123 Main St.',
5
+ companyCountry: 'USA',
6
+ companyStateCode: 'CA',
7
+ companyCity: 'Glendale',
8
+ companyZipCode: '12345',
9
+ einOrBn: '',
10
+ };
11
+ export const CompanyProfileFormEmptyValues = {
12
+ companyName: '',
13
+ adminPhone: '',
14
+ companyStreetAddress: '',
15
+ companyCountry: '',
16
+ companyStateCode: '',
17
+ companyCity: '',
18
+ companyZipCode: '',
19
+ };
20
+ export const CompanyProfileFormCanadian = {
21
+ companyName: 'Wyatt Works',
22
+ adminPhone: '(310) 855-8585',
23
+ companyStreetAddress: '123 Main St.',
24
+ companyCountry: 'ca',
25
+ companyStateCode: 'CA',
26
+ companyCity: 'Glendale',
27
+ companyZipCode: '12345',
28
+ };
29
+ //# sourceMappingURL=company-profile-form-mock-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"company-profile-form-mock-data.js","sourceRoot":"","sources":["../../../../src/company-profile/stores/__mocks__/company-profile-form-mock-data.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,yBAAyB,GAAiB;IACnD,WAAW,EAAE,aAAa;IAC1B,UAAU,EAAE,gBAAgB;IAC5B,oBAAoB,EAAE,cAAc;IACpC,cAAc,EAAE,KAAK;IACrB,gBAAgB,EAAE,IAAI;IACtB,WAAW,EAAE,UAAU;IACvB,cAAc,EAAE,OAAO;IACvB,OAAO,EAAE,EAAE;CACd,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAiB;IACvD,WAAW,EAAE,EAAE;IACf,UAAU,EAAE,EAAE;IACd,oBAAoB,EAAE,EAAE;IACxB,cAAc,EAAE,EAAE;IAClB,gBAAgB,EAAE,EAAE;IACpB,WAAW,EAAE,EAAE;IACf,cAAc,EAAE,EAAE;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAiB;IACpD,WAAW,EAAE,aAAa;IAC1B,UAAU,EAAE,gBAAgB;IAC5B,oBAAoB,EAAE,cAAc;IACpC,cAAc,EAAE,IAAI;IACpB,gBAAgB,EAAE,IAAI;IACtB,WAAW,EAAE,UAAU;IACvB,cAAc,EAAE,OAAO;CAC1B,CAAC"}