@proprioo/salatim 23.1.0 → 23.3.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 +13 -0
- package/lib/energy/index.d.ts +1 -1
- package/lib/energy/index.js +3 -2
- package/lib/energy/index.js.map +1 -1
- package/lib/index.js +285 -285
- package/lib/index.js.map +1 -1
- package/lib/ui/src/input/Input.d.ts +11 -9
- package/lib/ui/src/input/Input.js +11 -2
- package/lib/ui/src/input/Input.js.map +1 -1
- package/lib/ui/src/inputBase/InputBase.d.ts +16 -14
- package/lib/ui/src/inputBase/InputBase.js +12 -2
- package/lib/ui/src/inputBase/InputBase.js.map +1 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +4 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/src/gmaps.d.ts +0 -24
- package/lib/utils/src/gmaps.js +1 -28
- package/lib/utils/src/gmaps.js.map +1 -1
- package/lib/utils/src/gmaps.test.js +0 -136
- package/lib/utils/src/gmaps.test.js.map +1 -1
- package/lib/utils/src/props.d.ts +2 -2
- package/package.json +1 -1
|
@@ -16,23 +16,25 @@ export interface CustomInputEvent {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
export interface InputProps {
|
|
19
|
-
id: string;
|
|
20
19
|
disabled: boolean;
|
|
21
20
|
focused: boolean;
|
|
21
|
+
id: string;
|
|
22
22
|
type: InputType;
|
|
23
|
-
|
|
24
|
-
inputElement?: Component<InputProps> | FC<InputProps>;
|
|
23
|
+
dataTest?: string;
|
|
25
24
|
gmap?: GMapProps;
|
|
25
|
+
inputElement?: Component<InputProps> | FC<InputProps>;
|
|
26
|
+
max?: number;
|
|
27
|
+
maxLength?: number;
|
|
28
|
+
min?: number;
|
|
29
|
+
minLength?: number;
|
|
26
30
|
name?: string;
|
|
27
|
-
|
|
31
|
+
phoneWithFlags?: boolean;
|
|
28
32
|
required?: boolean;
|
|
29
|
-
min?: number;
|
|
30
|
-
max?: number;
|
|
31
33
|
style?: CSSProperties;
|
|
32
|
-
|
|
33
|
-
handleFocus(): void;
|
|
34
|
+
value?: nullOrString;
|
|
34
35
|
handleBlur(): void;
|
|
35
|
-
|
|
36
|
+
handleFocus(): void;
|
|
37
|
+
handleOnChange(event: ChangeEvent<HTMLInputElement> | CustomInputEvent): void;
|
|
36
38
|
}
|
|
37
39
|
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
38
40
|
export default Input;
|
|
@@ -31,10 +31,19 @@ var InputType;
|
|
|
31
31
|
InputType["TEXT"] = "text";
|
|
32
32
|
})(InputType = exports.InputType || (exports.InputType = {}));
|
|
33
33
|
const Input = (0, react_1.forwardRef)((props, ref) => {
|
|
34
|
-
const {
|
|
34
|
+
const { dataTest, disabled, focused, gmap, id, inputElement, max, maxLength, min, minLength, name, required = false, style, type, value, handleBlur, handleFocus, handleOnChange } = props;
|
|
35
35
|
return (react_1.default.createElement(react_1.Fragment, null, inputElement ? (
|
|
36
36
|
// tslint:disable-next-line: no-any
|
|
37
|
-
(0, react_1.createElement)(inputElement, Object.assign({}, props))) : (react_1.default.createElement(Input_styles_1.InputLayout, Object.assign({
|
|
37
|
+
(0, react_1.createElement)(inputElement, Object.assign({}, props))) : (react_1.default.createElement(Input_styles_1.InputLayout, Object.assign({ autoComplete: 'off', "data-test": dataTest || `input-${type}`, value: value === null ? '' : value }, Object.assign(Object.assign({ disabled,
|
|
38
|
+
id,
|
|
39
|
+
max,
|
|
40
|
+
maxLength,
|
|
41
|
+
min,
|
|
42
|
+
minLength,
|
|
43
|
+
name,
|
|
44
|
+
ref,
|
|
45
|
+
required,
|
|
46
|
+
type }, gmap), (focused && { style })), { onBlur: handleBlur, onChange: (event) => handleOnChange(event), onFocus: handleFocus })))));
|
|
38
47
|
});
|
|
39
48
|
exports.default = Input;
|
|
40
49
|
//# sourceMappingURL=Input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../../packages/ui/src/input/Input.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,+CAOe;AAMf,iDAA6C;AAE7C,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,8BAAiB,CAAA;IACjB,kCAAqB,CAAA;IACrB,wBAAW,CAAA;IACX,0BAAa,CAAA;AACf,CAAC,EANW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAMpB;
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../../packages/ui/src/input/Input.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,+CAOe;AAMf,iDAA6C;AAE7C,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,8BAAiB,CAAA;IACjB,kCAAqB,CAAA;IACrB,wBAAW,CAAA;IACX,0BAAa,CAAA;AACf,CAAC,EANW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAMpB;AAiCD,MAAM,KAAK,GAAG,IAAA,kBAAU,EAAkB,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACvD,MAAM,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,EAAE,EACF,YAAY,EACZ,GAAG,EACH,SAAS,EACT,GAAG,EACH,SAAS,EACT,IAAI,EACJ,QAAQ,GAAG,KAAK,EAChB,KAAK,EACL,IAAI,EACJ,KAAK,EACL,UAAU,EACV,WAAW,EACX,cAAc,EACf,GAAG,KAAK,CAAC;IAEV,OAAO,CACL,8BAAC,gBAAQ,QACN,YAAY,CAAC,CAAC,CAAC;IACd,mCAAmC;IACnC,IAAA,qBAAa,EAAC,YAAmB,oBAAO,KAAK,EAAG,CACjD,CAAC,CAAC,CAAC,CACF,8BAAC,0BAAW,kBACV,YAAY,EAAE,KAAK,eACR,QAAQ,IAAI,SAAS,IAAI,EAAE,EACtC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,kCAEhC,QAAQ;QACR,EAAE;QACF,GAAG;QACH,SAAS;QACT,GAAG;QACH,SAAS;QACT,IAAI;QACJ,GAAG;QACH,QAAQ;QACR,IAAI,IACD,IAAI,GACJ,CAAC,OAAO,IAAI,EAAE,KAAK,EAAE,CAAC,KAE3B,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,CAAC,KAAoC,EAAE,EAAE,CACjD,cAAc,CAAC,KAAK,CAAC,EAEvB,OAAO,EAAE,WAAW,IACpB,CACH,CACQ,CACZ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,kBAAe,KAAK,CAAC"}
|
|
@@ -6,13 +6,12 @@ import { OptionProps } from '../option/Option';
|
|
|
6
6
|
import { InputColors } from './InputBaseEnum';
|
|
7
7
|
export declare const ZINDEX_OPEN = 10;
|
|
8
8
|
export interface GMapProps {
|
|
9
|
-
|
|
10
|
-
role: 'combobox';
|
|
9
|
+
'aria-activedescendant': string | undefined;
|
|
11
10
|
'aria-autocomplete': 'list';
|
|
12
11
|
'aria-expanded': boolean;
|
|
13
|
-
'
|
|
12
|
+
autoComplete: 'off';
|
|
14
13
|
disabled: boolean;
|
|
15
|
-
|
|
14
|
+
role: 'combobox';
|
|
16
15
|
value: string | undefined;
|
|
17
16
|
onBlur: React.FocusEventHandler;
|
|
18
17
|
onChange(event: {
|
|
@@ -20,26 +19,29 @@ export interface GMapProps {
|
|
|
20
19
|
value: string;
|
|
21
20
|
};
|
|
22
21
|
}): void;
|
|
22
|
+
onKeyDown: React.KeyboardEventHandler;
|
|
23
23
|
}
|
|
24
24
|
export interface InputBaseProps extends GenericInputProps {
|
|
25
|
-
value?: nullOrString;
|
|
26
25
|
displayField?: ReactElement;
|
|
27
|
-
inputElement?: Component<InputProps> | FC<InputProps>;
|
|
28
26
|
field?: ReactElement;
|
|
29
|
-
type?: InputType;
|
|
30
|
-
options?: OptionProps[];
|
|
31
27
|
gmap?: GMapProps;
|
|
32
|
-
name?: string;
|
|
33
|
-
min?: number;
|
|
34
|
-
max?: number;
|
|
35
|
-
suffix?: string;
|
|
36
28
|
id?: string;
|
|
29
|
+
inputElement?: Component<InputProps> | FC<InputProps>;
|
|
30
|
+
max?: number;
|
|
31
|
+
maxLength?: number;
|
|
32
|
+
min?: number;
|
|
33
|
+
minLength?: number;
|
|
34
|
+
name?: string;
|
|
35
|
+
options?: OptionProps[];
|
|
36
|
+
outline?: InputColors;
|
|
37
|
+
phoneWithFlags?: boolean;
|
|
37
38
|
selectOnFocus?: boolean;
|
|
39
|
+
suffix?: string;
|
|
40
|
+
type?: InputType;
|
|
41
|
+
value?: nullOrString;
|
|
38
42
|
onBlur?(): void;
|
|
39
43
|
onChange?(value: string): void;
|
|
40
44
|
onFocus?(): void;
|
|
41
|
-
phoneWithFlags?: boolean;
|
|
42
|
-
outline?: InputColors;
|
|
43
45
|
}
|
|
44
46
|
declare const InputBase: FC<InputBaseProps>;
|
|
45
47
|
export default InputBase;
|
|
@@ -30,7 +30,7 @@ const Alert_1 = __importDefault(require("../icons/Alert"));
|
|
|
30
30
|
const Input_1 = __importStar(require("../input/Input"));
|
|
31
31
|
const InputBase_styles_1 = require("./InputBase.styles");
|
|
32
32
|
exports.ZINDEX_OPEN = 10;
|
|
33
|
-
const InputBase = ({
|
|
33
|
+
const InputBase = ({ dataTest, disabled, displayField, error, field, focused: initialFocused = false, gmap, label, id, inputElement, max, maxLength, min, minLength, name, outline, phoneWithFlags = false, required, selectOnFocus, suffix, type = Input_1.InputType.TEXT, value, zIndex, onBlur, onChange, onFocus }) => {
|
|
34
34
|
var _a;
|
|
35
35
|
const inputRef = (0, react_1.useRef)(null);
|
|
36
36
|
const htmlId = (0, react_1.useMemo)(() => id || `input-${(0, react_id_generator_1.default)()}`, []);
|
|
@@ -68,12 +68,22 @@ const InputBase = ({ disabled, id, inputElement, displayField, error, label, typ
|
|
|
68
68
|
handleOnChange,
|
|
69
69
|
name, gmap: Object.assign(Object.assign({}, gmap), { onBlur: (0, hokkaido_1.compose)(gmap && gmap.onBlur, handleBlur) }), min,
|
|
70
70
|
max,
|
|
71
|
+
minLength,
|
|
72
|
+
maxLength,
|
|
71
73
|
suffix,
|
|
72
74
|
phoneWithFlags });
|
|
73
75
|
(0, react_1.useEffect)(() => {
|
|
74
76
|
setFocused(initialFocused);
|
|
75
77
|
}, [initialFocused]);
|
|
76
|
-
return (react_1.default.createElement(InputBase_styles_1.Layout, {
|
|
78
|
+
return (react_1.default.createElement(InputBase_styles_1.Layout, Object.assign({}, {
|
|
79
|
+
disabled,
|
|
80
|
+
error,
|
|
81
|
+
focused,
|
|
82
|
+
notched,
|
|
83
|
+
outline,
|
|
84
|
+
phoneWithFlags,
|
|
85
|
+
zIndex
|
|
86
|
+
}),
|
|
77
87
|
react_1.default.createElement(InputBase_styles_1.LabelLayout, { htmlFor: htmlId, suffixLength: (suffix === null || suffix === void 0 ? void 0 : suffix.length) || 0 }, label),
|
|
78
88
|
react_1.default.createElement(InputBase_styles_1.InsideLayout, { disabled: disabled },
|
|
79
89
|
react_1.default.createElement(InputBase_styles_1.FieldSetLayout, null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputBase.js","sourceRoot":"","sources":["../../../../packages/ui/src/inputBase/InputBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAUe;AACf,4EAAwC;AAExC,iDAAuE;AAGvE,2DAAsD;AACtD,wDAAgF;AAEhF,yDAO4B;AAGf,QAAA,WAAW,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"InputBase.js","sourceRoot":"","sources":["../../../../packages/ui/src/inputBase/InputBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAUe;AACf,4EAAwC;AAExC,iDAAuE;AAGvE,2DAAsD;AACtD,wDAAgF;AAEhF,yDAO4B;AAGf,QAAA,WAAW,GAAG,EAAE,CAAC;AAsC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M,EAAE,KAAK;yBACd,GACD,CACW;gBACd,YAAY,CAAC,CAAC,CAAC,CACd,8BAAC,gBAAQ,QAAE,YAAY,CAAY,CACpC,CAAC,CAAC,CAAC,CACF,8BAAC,gBAAQ;oBACN,MAAM,IAAI,8BAAC,yBAAM,iBAAW,cAAc,IAAE,MAAM,CAAU;oBAC7D,8BAAC,eAAK,kBACJ,GAAG,EAAE,QAAQ,oCAER,UAAU,KACb,YAAY,KAEd,CACO,CACZ,CACc;YAChB,KAAK,IAAI,8BAAC,gBAAQ,QAAE,KAAK,CAAY;YACrC,KAAK,IAAI,8BAAC,eAAS,OAAG,CACV,CACR,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC"}
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -14,3 +14,4 @@ export { default as scrollbar } from './src/scrollbars';
|
|
|
14
14
|
export { createAction, ActionsWithPayload, ActionsWithoutPayload, ActionsUnion } from './src/actions';
|
|
15
15
|
export { isTouchDevice, useMobileDevice, useSmartphoneDevice, useSmallSmartphoneDevice } from './src/responsive';
|
|
16
16
|
export { resetCssButton } from './src/reset';
|
|
17
|
+
export { getGeoSearchSuggestions, GoogleSearchType } from './src/gmaps';
|
package/lib/utils/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resetCssButton = exports.useSmallSmartphoneDevice = exports.useSmartphoneDevice = exports.useMobileDevice = exports.isTouchDevice = exports.createAction = exports.scrollbar = exports.convertPxToRem = exports.shadows = exports.Row = exports.radius = exports.paragraphs = exports.Line = exports.fonts = exports.IntegralCFFont = exports.ArchivoFont = exports.Container = exports.colors = exports.breakpoints = exports.resetId = void 0;
|
|
6
|
+
exports.GoogleSearchType = exports.getGeoSearchSuggestions = exports.resetCssButton = exports.useSmallSmartphoneDevice = exports.useSmartphoneDevice = exports.useMobileDevice = exports.isTouchDevice = exports.createAction = exports.scrollbar = exports.convertPxToRem = exports.shadows = exports.Row = exports.radius = exports.paragraphs = exports.Line = exports.fonts = exports.IntegralCFFont = exports.ArchivoFont = exports.Container = exports.colors = exports.breakpoints = exports.resetId = void 0;
|
|
7
7
|
var react_id_generator_1 = require("react-id-generator");
|
|
8
8
|
Object.defineProperty(exports, "resetId", { enumerable: true, get: function () { return react_id_generator_1.resetId; } });
|
|
9
9
|
var breakpoints_1 = require("./src/breakpoints");
|
|
@@ -39,4 +39,7 @@ Object.defineProperty(exports, "useSmartphoneDevice", { enumerable: true, get: f
|
|
|
39
39
|
Object.defineProperty(exports, "useSmallSmartphoneDevice", { enumerable: true, get: function () { return responsive_1.useSmallSmartphoneDevice; } });
|
|
40
40
|
var reset_1 = require("./src/reset");
|
|
41
41
|
Object.defineProperty(exports, "resetCssButton", { enumerable: true, get: function () { return reset_1.resetCssButton; } });
|
|
42
|
+
var gmaps_1 = require("./src/gmaps");
|
|
43
|
+
Object.defineProperty(exports, "getGeoSearchSuggestions", { enumerable: true, get: function () { return gmaps_1.getGeoSearchSuggestions; } });
|
|
44
|
+
Object.defineProperty(exports, "GoogleSearchType", { enumerable: true, get: function () { return gmaps_1.GoogleSearchType; } });
|
|
42
45
|
//# sourceMappingURL=index.js.map
|
package/lib/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../packages/utils/index.ts"],"names":[],"mappings":";;;;;;AAAA,yDAA6C;AAApC,6GAAA,OAAO,OAAA;AAChB,iDAA2D;AAAlD,2HAAA,OAAO,OAAe;AAC/B,uCAAiD;AAAxC,iHAAA,OAAO,OAAU;AAC1B,6CAAuD;AAA9C,uHAAA,OAAO,OAAa;AAC7B,qCAA4E;AAAnE,oGAAA,WAAW,OAAA;AAAE,uGAAA,cAAc,OAAA;AAAE,+GAAA,OAAO,OAA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AACf,iHAAA,mBAAmB,OAAA;AACnB,sHAAA,wBAAwB,OAAA;AAE1B,qCAA6C;AAApC,uGAAA,cAAc,OAAA;AACvB,qCAAwE;AAA/D,gHAAA,uBAAuB,OAAA;AAAE,yGAAA,gBAAgB,OAAA"}
|
package/lib/utils/src/gmaps.d.ts
CHANGED
|
@@ -1,26 +1,4 @@
|
|
|
1
|
-
/// <reference types="googlemaps" />
|
|
2
|
-
/// <reference types="google.maps" />
|
|
3
1
|
import { Suggestion } from 'react-places-autocomplete';
|
|
4
|
-
export declare const POSTAL_CODE: string;
|
|
5
|
-
export declare const LOCALITY: string;
|
|
6
|
-
export declare const STREET_NUMBER: string;
|
|
7
|
-
export declare const STREET: string;
|
|
8
|
-
export declare const POSTAL_TOWN: string;
|
|
9
|
-
export declare type GeocoderResult = google.maps.GeocoderResult;
|
|
10
|
-
export declare type GeocoderAddressComponent = google.maps.GeocoderAddressComponent;
|
|
11
|
-
export declare type GeocoderType = GeocoderAddressComponent | null;
|
|
12
|
-
export interface Location {
|
|
13
|
-
lat: number;
|
|
14
|
-
lng: number;
|
|
15
|
-
}
|
|
16
|
-
export interface GeocoderResultFormatted {
|
|
17
|
-
address: string;
|
|
18
|
-
location: Location;
|
|
19
|
-
postalCode: GeocoderType;
|
|
20
|
-
city: GeocoderType;
|
|
21
|
-
street: GeocoderType;
|
|
22
|
-
streetNumber: GeocoderType;
|
|
23
|
-
}
|
|
24
2
|
export declare enum GoogleSearchType {
|
|
25
3
|
ADMINISTRATIVE_AREA_LEVEL_1 = "administrative_area_level_1",
|
|
26
4
|
ADMINISTRATIVE_AREA_LEVEL_2 = "administrative_area_level_2",
|
|
@@ -29,6 +7,4 @@ export declare enum GoogleSearchType {
|
|
|
29
7
|
POSTAL_CODE = "postal_code",
|
|
30
8
|
SUBLOCALITY = "sublocality"
|
|
31
9
|
}
|
|
32
|
-
export declare const getAddressComponent: (addressComponents: GeocoderAddressComponent[], componentType: string) => GeocoderType;
|
|
33
|
-
export declare const getFormattedAddressComponent: ({ address_components, formatted_address, geometry }: GeocoderResult) => GeocoderResultFormatted;
|
|
34
10
|
export declare const getGeoSearchSuggestions: (suggestions: Suggestion[]) => Suggestion[];
|
package/lib/utils/src/gmaps.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGeoSearchSuggestions = exports.
|
|
4
|
-
exports.POSTAL_CODE = 'postal_code';
|
|
5
|
-
exports.LOCALITY = 'locality';
|
|
6
|
-
exports.STREET_NUMBER = 'street_number';
|
|
7
|
-
exports.STREET = 'route';
|
|
8
|
-
exports.POSTAL_TOWN = 'postal_town';
|
|
3
|
+
exports.getGeoSearchSuggestions = exports.GoogleSearchType = void 0;
|
|
9
4
|
var GoogleSearchType;
|
|
10
5
|
(function (GoogleSearchType) {
|
|
11
6
|
GoogleSearchType["ADMINISTRATIVE_AREA_LEVEL_1"] = "administrative_area_level_1";
|
|
@@ -15,32 +10,10 @@ var GoogleSearchType;
|
|
|
15
10
|
GoogleSearchType["POSTAL_CODE"] = "postal_code";
|
|
16
11
|
GoogleSearchType["SUBLOCALITY"] = "sublocality"; // submunicipality
|
|
17
12
|
})(GoogleSearchType = exports.GoogleSearchType || (exports.GoogleSearchType = {}));
|
|
18
|
-
const getAddressComponent = (addressComponents, componentType) => {
|
|
19
|
-
if (addressComponents.length > 0) {
|
|
20
|
-
const addressComponent = addressComponents.filter(({ types }) => types[0] === componentType);
|
|
21
|
-
if (addressComponent.length === 0) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
return addressComponent[0];
|
|
25
|
-
}
|
|
26
|
-
return null;
|
|
27
|
-
};
|
|
28
|
-
exports.getAddressComponent = getAddressComponent;
|
|
29
|
-
const getFormattedAddressComponent = ({ address_components, formatted_address, geometry }) => ({
|
|
30
|
-
address: formatted_address,
|
|
31
|
-
location: geometry.location.toJSON(),
|
|
32
|
-
postalCode: (0, exports.getAddressComponent)(address_components, exports.POSTAL_CODE),
|
|
33
|
-
street: (0, exports.getAddressComponent)(address_components, exports.STREET),
|
|
34
|
-
streetNumber: (0, exports.getAddressComponent)(address_components, exports.STREET_NUMBER),
|
|
35
|
-
city: (0, exports.getAddressComponent)(address_components, exports.LOCALITY) ||
|
|
36
|
-
(0, exports.getAddressComponent)(address_components, exports.POSTAL_TOWN)
|
|
37
|
-
});
|
|
38
|
-
exports.getFormattedAddressComponent = getFormattedAddressComponent;
|
|
39
13
|
const getGeoSearchSuggestions = (suggestions) => suggestions.filter(({ types }) => types.some(type => [
|
|
40
14
|
GoogleSearchType.ADMINISTRATIVE_AREA_LEVEL_1,
|
|
41
15
|
GoogleSearchType.ADMINISTRATIVE_AREA_LEVEL_2,
|
|
42
16
|
GoogleSearchType.LOCALITY,
|
|
43
|
-
GoogleSearchType.NEIGHBORHOOD,
|
|
44
17
|
GoogleSearchType.POSTAL_CODE,
|
|
45
18
|
GoogleSearchType.SUBLOCALITY
|
|
46
19
|
].includes(type)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gmaps.js","sourceRoot":"","sources":["../../../packages/utils/src/gmaps.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"gmaps.js","sourceRoot":"","sources":["../../../packages/utils/src/gmaps.ts"],"names":[],"mappings":";;;AAEA,IAAY,gBAOX;AAPD,WAAY,gBAAgB;IAC1B,+EAA2D,CAAA;IAC3D,+EAA2D,CAAA;IAC3D,yCAAqB,CAAA;IACrB,iDAA6B,CAAA;IAC7B,+CAA2B,CAAA;IAC3B,+CAA2B,CAAA,CAAC,kBAAkB;AAChD,CAAC,EAPW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAO3B;AAEM,MAAM,uBAAuB,GAAG,CACrC,WAAyB,EACX,EAAE,CAChB,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAC/B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAChB;IACE,gBAAgB,CAAC,2BAA2B;IAC5C,gBAAgB,CAAC,2BAA2B;IAC5C,gBAAgB,CAAC,QAAQ;IACzB,gBAAgB,CAAC,WAAW;IAC5B,gBAAgB,CAAC,WAAW;CAC7B,CAAC,QAAQ,CAAC,IAAwB,CAAC,CACrC,CACF,CAAC;AAbS,QAAA,uBAAuB,2BAahC"}
|
|
@@ -1,40 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const gmaps_1 = require("./gmaps");
|
|
4
|
-
const defaultPlace = {
|
|
5
|
-
address_components: [
|
|
6
|
-
{ long_name: '16', short_name: '16', types: ['street_number'] },
|
|
7
|
-
{
|
|
8
|
-
long_name: 'Rue de la Banque',
|
|
9
|
-
short_name: 'Rue de la Banque',
|
|
10
|
-
types: ['route']
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
long_name: 'Paris',
|
|
14
|
-
short_name: 'Paris',
|
|
15
|
-
types: ['locality', 'political']
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
long_name: 'Arrondissement de Paris',
|
|
19
|
-
short_name: 'Arrondissement de Paris',
|
|
20
|
-
types: ['administrative_area_level_2', 'political']
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
long_name: 'Île-de-France',
|
|
24
|
-
short_name: 'Île-de-France',
|
|
25
|
-
types: ['administrative_area_level_1', 'political']
|
|
26
|
-
},
|
|
27
|
-
{ long_name: 'France', short_name: 'FR', types: ['country', 'political'] },
|
|
28
|
-
{ long_name: '75002', short_name: '75002', types: ['postal_code'] }
|
|
29
|
-
],
|
|
30
|
-
formatted_address: '16 Rue de la Banque, 75002 Paris, France',
|
|
31
|
-
geometry: {
|
|
32
|
-
location: new google.maps.LatLng(0, 0),
|
|
33
|
-
bounds: new google.maps.LatLngBounds(),
|
|
34
|
-
location_type: google.maps.GeocoderLocationType.APPROXIMATE,
|
|
35
|
-
viewport: new google.maps.LatLngBounds()
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
4
|
const MOCK_SUGGESTIONS = [
|
|
39
5
|
{
|
|
40
6
|
description: '3ème Arrondissement, Paris, France',
|
|
@@ -76,108 +42,6 @@ const MOCK_SUGGESTIONS = [
|
|
|
76
42
|
id: '1'
|
|
77
43
|
}
|
|
78
44
|
];
|
|
79
|
-
describe('getAddressComponent', () => {
|
|
80
|
-
it('should return null on empty address components', () => {
|
|
81
|
-
expect((0, gmaps_1.getAddressComponent)([], gmaps_1.STREET)).toEqual(null);
|
|
82
|
-
});
|
|
83
|
-
it('should return null with not found component', () => {
|
|
84
|
-
expect((0, gmaps_1.getAddressComponent)(defaultPlace.address_components, 'appartement')).toEqual(null);
|
|
85
|
-
});
|
|
86
|
-
it('should return component type', () => {
|
|
87
|
-
expect((0, gmaps_1.getAddressComponent)(defaultPlace.address_components, gmaps_1.STREET)).toEqual({
|
|
88
|
-
long_name: 'Rue de la Banque',
|
|
89
|
-
short_name: 'Rue de la Banque',
|
|
90
|
-
types: ['route']
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
describe('getFormattedAddressComponent', () => {
|
|
95
|
-
it('should return object', () => {
|
|
96
|
-
expect((0, gmaps_1.getFormattedAddressComponent)(defaultPlace)).toEqual({
|
|
97
|
-
address: '16 Rue de la Banque, 75002 Paris, France',
|
|
98
|
-
city: {
|
|
99
|
-
long_name: 'Paris',
|
|
100
|
-
short_name: 'Paris',
|
|
101
|
-
types: ['locality', 'political']
|
|
102
|
-
},
|
|
103
|
-
location: { lat: 0, lng: 0 },
|
|
104
|
-
postalCode: {
|
|
105
|
-
long_name: '75002',
|
|
106
|
-
short_name: '75002',
|
|
107
|
-
types: ['postal_code']
|
|
108
|
-
},
|
|
109
|
-
street: {
|
|
110
|
-
long_name: 'Rue de la Banque',
|
|
111
|
-
short_name: 'Rue de la Banque',
|
|
112
|
-
types: ['route']
|
|
113
|
-
},
|
|
114
|
-
streetNumber: {
|
|
115
|
-
long_name: '16',
|
|
116
|
-
short_name: '16',
|
|
117
|
-
types: ['street_number']
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
it('should return null street_number', () => {
|
|
122
|
-
const [, ...rest] = defaultPlace.address_components;
|
|
123
|
-
const place = Object.assign(Object.assign({}, defaultPlace), { address_components: rest });
|
|
124
|
-
expect((0, gmaps_1.getFormattedAddressComponent)(place)).toEqual({
|
|
125
|
-
address: '16 Rue de la Banque, 75002 Paris, France',
|
|
126
|
-
city: {
|
|
127
|
-
long_name: 'Paris',
|
|
128
|
-
short_name: 'Paris',
|
|
129
|
-
types: ['locality', 'political']
|
|
130
|
-
},
|
|
131
|
-
location: { lat: 0, lng: 0 },
|
|
132
|
-
postalCode: {
|
|
133
|
-
long_name: '75002',
|
|
134
|
-
short_name: '75002',
|
|
135
|
-
types: ['postal_code']
|
|
136
|
-
},
|
|
137
|
-
street: {
|
|
138
|
-
long_name: 'Rue de la Banque',
|
|
139
|
-
short_name: 'Rue de la Banque',
|
|
140
|
-
types: ['route']
|
|
141
|
-
},
|
|
142
|
-
streetNumber: null
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
it('should fallback to postal_town when no locality is returned', () => {
|
|
146
|
-
const components = defaultPlace.address_components.filter(({ types }) => !types.includes(gmaps_1.LOCALITY));
|
|
147
|
-
const place = Object.assign(Object.assign({}, defaultPlace), { address_components: [
|
|
148
|
-
...components,
|
|
149
|
-
{
|
|
150
|
-
long_name: 'Paris',
|
|
151
|
-
short_name: 'Paris',
|
|
152
|
-
types: [gmaps_1.POSTAL_TOWN]
|
|
153
|
-
}
|
|
154
|
-
] });
|
|
155
|
-
expect((0, gmaps_1.getFormattedAddressComponent)(place)).toEqual({
|
|
156
|
-
address: '16 Rue de la Banque, 75002 Paris, France',
|
|
157
|
-
city: {
|
|
158
|
-
long_name: 'Paris',
|
|
159
|
-
short_name: 'Paris',
|
|
160
|
-
types: ['postal_town']
|
|
161
|
-
},
|
|
162
|
-
location: { lat: 0, lng: 0 },
|
|
163
|
-
postalCode: {
|
|
164
|
-
long_name: '75002',
|
|
165
|
-
short_name: '75002',
|
|
166
|
-
types: ['postal_code']
|
|
167
|
-
},
|
|
168
|
-
street: {
|
|
169
|
-
long_name: 'Rue de la Banque',
|
|
170
|
-
short_name: 'Rue de la Banque',
|
|
171
|
-
types: ['route']
|
|
172
|
-
},
|
|
173
|
-
streetNumber: {
|
|
174
|
-
long_name: '16',
|
|
175
|
-
short_name: '16',
|
|
176
|
-
types: ['street_number']
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
45
|
describe('getGeoSearchSuggestions', () => {
|
|
182
46
|
it('should return only accepted types', () => {
|
|
183
47
|
expect((0, gmaps_1.getGeoSearchSuggestions)(MOCK_SUGGESTIONS)).toEqual([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gmaps.test.js","sourceRoot":"","sources":["../../../packages/utils/src/gmaps.test.ts"],"names":[],"mappings":";;AAEA,
|
|
1
|
+
{"version":3,"file":"gmaps.test.js","sourceRoot":"","sources":["../../../packages/utils/src/gmaps.test.ts"],"names":[],"mappings":";;AAEA,mCAAkD;AAElD,MAAM,gBAAgB,GAAiB;IACrC;QACE,WAAW,EAAE,oCAAoC;QACjD,OAAO,EAAE,6BAA6B;QACtC,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,CAAC;QACR,mBAAmB,EAAE;YACnB,QAAQ,EAAE,qBAAqB;YAC/B,aAAa,EAAE,eAAe;SAC/B;QACD,iBAAiB,EAAE;YACjB,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;YACxB,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;SAC1B;QACD,KAAK,EAAE;YACL,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,qBAAqB,EAAE;YAC3C,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