@proprioo/salatim 22.0.0 → 23.2.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 +15 -0
- package/lib/energy/index.d.ts +2 -0
- package/lib/energy/index.js +5 -1
- package/lib/energy/index.js.map +1 -1
- package/lib/energy/src/Energy.d.ts +1 -0
- package/lib/energy/src/Energy.js +2 -4
- package/lib/energy/src/Energy.js.map +1 -1
- package/lib/energy/src/Energy.stories.js +3 -1
- package/lib/energy/src/Energy.stories.js.map +1 -1
- package/lib/energy/src/Energy.test.js +4 -3
- package/lib/energy/src/Energy.test.js.map +1 -1
- package/lib/energy/src/Energy.utils.d.ts +5 -4
- package/lib/energy/src/Energy.utils.js +101 -39
- package/lib/energy/src/Energy.utils.js.map +1 -1
- package/lib/energy/src/Energy.utils.test.js +75 -34
- package/lib/energy/src/Energy.utils.test.js.map +1 -1
- package/lib/energy/src/interfaces.d.ts +6 -0
- package/lib/energy/src/interfaces.js +2 -1
- package/lib/energy/src/interfaces.js.map +1 -1
- package/lib/index.js +330 -330
- package/lib/index.js.map +1 -1
- package/lib/ui/src/button/Button.d.ts +2 -2
- package/lib/ui/src/button/Button.js +26 -5
- package/lib/ui/src/button/Button.js.map +1 -1
- package/lib/ui/src/button/Button.stories.js +3 -3
- package/lib/ui/src/button/Button.stories.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/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { FC, MouseEvent,
|
|
1
|
+
import { FC, MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import { ButtonAppearance, ButtonSizes, ButtonTheme, IconPosition } from './Button.interfaces';
|
|
3
3
|
export interface ButtonProps {
|
|
4
4
|
label: string;
|
|
5
5
|
appearance?: ButtonAppearance;
|
|
6
6
|
disabled?: boolean;
|
|
7
|
-
icon?:
|
|
7
|
+
icon?: ReactNode;
|
|
8
8
|
iconPosition?: IconPosition;
|
|
9
9
|
id?: string;
|
|
10
10
|
rounded?: boolean;
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
22
|
var t = {};
|
|
4
23
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,17 +29,19 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
29
|
}
|
|
11
30
|
return t;
|
|
12
31
|
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
const react_1 =
|
|
33
|
+
const react_1 = __importStar(require("react"));
|
|
18
34
|
const Button_interfaces_1 = require("./Button.interfaces");
|
|
19
35
|
const Button_styles_1 = require("./Button.styles");
|
|
20
36
|
const Button = (_a) => {
|
|
21
37
|
var { appearance = Button_interfaces_1.ButtonAppearance.PRIMARY, icon, iconPosition = Button_interfaces_1.IconPosition.RIGHT, label, rounded = false, size = Button_interfaces_1.ButtonSizes.LARGE, theme = Button_interfaces_1.ButtonTheme.ORANGE } = _a, rest = __rest(_a, ["appearance", "icon", "iconPosition", "label", "rounded", "size", "theme"]);
|
|
22
38
|
return (react_1.default.createElement(Button_styles_1.Layout, Object.assign({}, Object.assign({ appearance, icon, iconPosition, rounded, size, theme }, rest), { "aria-label": label }),
|
|
23
|
-
icon && (react_1.default.createElement(Button_styles_1.IconWrapper, Object.assign({}, { appearance, iconPosition, size, theme }, { "data-test": iconPosition === Button_interfaces_1.IconPosition.LEFT ? 'icon-left' : 'icon-right' }), icon)
|
|
39
|
+
icon && (react_1.default.createElement(Button_styles_1.IconWrapper, Object.assign({}, { appearance, iconPosition, size, theme }, { "data-test": iconPosition === Button_interfaces_1.IconPosition.LEFT ? 'icon-left' : 'icon-right' }), (0, react_1.isValidElement)(icon)
|
|
40
|
+
? (0, react_1.cloneElement)(icon, {
|
|
41
|
+
'aria-hidden': true,
|
|
42
|
+
focusable: false
|
|
43
|
+
})
|
|
44
|
+
: icon)),
|
|
24
45
|
!rounded && react_1.default.createElement(Button_styles_1.LabelLayout, { "data-test": "label" }, label)));
|
|
25
46
|
};
|
|
26
47
|
exports.default = Button;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../../packages/ui/src/button/Button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../../packages/ui/src/button/Button.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAMe;AAEf,2DAK6B;AAC7B,mDAAmE;AAgBnE,MAAM,MAAM,GAAoB,CAAC,EASnB,EAAE,EAAE;QATe,EAC/B,UAAU,GAAG,oCAAgB,CAAC,OAAO,EACrC,IAAI,EACJ,YAAY,GAAG,gCAAY,CAAC,KAAK,EACjC,KAAK,EACL,OAAO,GAAG,KAAK,EACf,IAAI,GAAG,+BAAW,CAAC,KAAK,EACxB,KAAK,GAAG,+BAAW,CAAC,MAAM,OAEd,EADT,IAAI,cARwB,2EAShC,CADQ;IACU,OAAA,CACjB,8BAAC,sBAAM,oCACC,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,IAAK,IAAI,mBACvD,KAAK;QAEhB,IAAI,IAAI,CACP,8BAAC,2BAAW,oBACN,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,iBAE3C,YAAY,KAAK,gCAAY,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,KAGhE,IAAA,sBAAc,EAAC,IAAI,CAAC;YACnB,CAAC,CAAC,IAAA,oBAAY,EAAC,IAAI,EAAE;gBACjB,aAAa,EAAE,IAAI;gBACnB,SAAS,EAAE,KAAK;aACjB,CAAC;YACJ,CAAC,CAAC,IAAI,CACI,CACf;QACA,CAAC,OAAO,IAAI,8BAAC,2BAAW,iBAAW,OAAO,IAAE,KAAK,CAAe,CAC1D,CACV,CAAA;CAAA,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
|
@@ -8,13 +8,13 @@ const addon_actions_1 = require("@storybook/addon-actions");
|
|
|
8
8
|
const addon_knobs_1 = require("@storybook/addon-knobs");
|
|
9
9
|
const react_2 = require("@storybook/react");
|
|
10
10
|
const utils_1 = require("../../../utils");
|
|
11
|
-
const icons_1 = __importDefault(require("../icons"));
|
|
12
11
|
const Button_1 = __importDefault(require("./Button"));
|
|
13
12
|
const Button_interfaces_1 = require("./Button.interfaces");
|
|
14
|
-
const
|
|
13
|
+
const Arrow = (react_1.default.createElement("svg", { viewBox: "0 0 32 32" },
|
|
14
|
+
react_1.default.createElement("path", { fill: "currentColor", d: "M16.5 10a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13zm-.66 10.292-.965-.948 2.844-2.844-2.844-2.844.965-.948 3.775 3.792-3.775 3.792z" })));
|
|
15
15
|
const knobs = () => ({
|
|
16
16
|
disabled: (0, addon_knobs_1.boolean)('Disabled', false),
|
|
17
|
-
icon:
|
|
17
|
+
icon: Arrow,
|
|
18
18
|
iconPosition: (0, addon_knobs_1.select)('Icon position', Button_interfaces_1.IconPosition, Button_interfaces_1.IconPosition.RIGHT),
|
|
19
19
|
label: (0, addon_knobs_1.text)('Label', 'Click me please'),
|
|
20
20
|
rounded: (0, addon_knobs_1.boolean)('Rounded', false),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.stories.js","sourceRoot":"","sources":["../../../../packages/ui/src/button/Button.stories.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAE1B,4DAAkD;AAClD,wDAA+D;AAC/D,4CAA6C;AAE7C,0CAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"Button.stories.js","sourceRoot":"","sources":["../../../../packages/ui/src/button/Button.stories.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAE1B,4DAAkD;AAClD,wDAA+D;AAC/D,4CAA6C;AAE7C,0CAAwC;AACxC,sDAA8B;AAC9B,2DAK6B;AAE7B,MAAM,KAAK,GAAG,CACZ,uCAAK,OAAO,EAAC,WAAW;IACtB,wCACE,IAAI,EAAC,cAAc,EACnB,CAAC,EAAC,iIAAiI,GACnI,CACE,CACP,CAAC;AAEF,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,CAAC;IACnB,QAAQ,EAAE,IAAA,qBAAO,EAA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AAe,EAAE,GAAG,EAAE,CAAC,CAC1B,uCAAK,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC;IAClC,8BAAC,gBAAM,sCAAU,KAAK,EAAE,KAAI,UAAU,EAAE,oCAAgB,CAAC,aAAa,IAAI,CACtE,CACP,CAAC;KACD,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAClB,uCAAK,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC;IAClC,8BAAC,gBAAM,sCAAU,KAAK,EAAE,KAAI,UAAU,EAAE,oCAAgB,CAAC,KAAK,IAAI,CAC9D,CACP,CAAC,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,OAAS;AACtD,mCAA6C;AAApC,6GAAA,O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,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,EAAE,MAAM,EAAE,EAAE,EAAE,K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