@widergy/energy-ui 2.12.2 → 2.12.3
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/dist/components/EnergyThemeProvider/index.js +13 -36
- package/dist/components/Loading/constants.js +1 -2
- package/dist/components/Loading/index.js +13 -12
- package/dist/components/Loading/theme.js +4 -2
- package/dist/components/UTAlert/AlertHandler.js +75 -101
- package/dist/components/UTAlert/index.js +65 -87
- package/dist/components/UTAlert/theme.js +32 -32
- package/dist/components/UTAttachment/components/Preview/index.js +8 -9
- package/dist/components/UTAttachment/constants.js +7 -13
- package/dist/components/UTAttachment/index.js +159 -250
- package/dist/components/UTAttachment/layout.js +26 -27
- package/dist/components/UTAttachment/theme.js +4 -2
- package/dist/components/UTAttachment/utils.js +34 -117
- package/dist/components/UTAutocomplete/components/ListBox/index.js +13 -21
- package/dist/components/UTAutocomplete/components/ListBox/utils.js +9 -11
- package/dist/components/UTAutocomplete/constants.js +12 -23
- package/dist/components/UTAutocomplete/index.js +54 -94
- package/dist/components/UTAutocomplete/theme.js +6 -4
- package/dist/components/UTAvatar/constants.js +2 -3
- package/dist/components/UTAvatar/index.js +18 -17
- package/dist/components/UTBarChart/components/Bars/components/Bar/components/Rect/index.js +22 -22
- package/dist/components/UTBarChart/components/Bars/components/Bar/constants.js +1 -1
- package/dist/components/UTBarChart/components/Bars/components/Bar/index.js +21 -22
- package/dist/components/UTBarChart/components/Bars/constants.js +3 -6
- package/dist/components/UTBarChart/components/Bars/index.js +70 -80
- package/dist/components/UTBarChart/components/Legend/constants.js +12 -18
- package/dist/components/UTBarChart/components/Legend/index.js +75 -93
- package/dist/components/UTBarChart/components/Legend/utils.js +1 -5
- package/dist/components/UTBarChart/components/Levels/index.js +16 -14
- package/dist/components/UTBarChart/components/Levels/utils.js +25 -27
- package/dist/components/UTBarChart/components/LinearPlot/constants.js +3 -5
- package/dist/components/UTBarChart/components/LinearPlot/index.js +25 -20
- package/dist/components/UTBarChart/components/LinearPlot/utils.js +37 -39
- package/dist/components/UTBarChart/components/Pagination/constants.js +1 -2
- package/dist/components/UTBarChart/components/Pagination/index.js +20 -24
- package/dist/components/UTBarChart/components/XAxis/components/AxisElement/index.js +21 -32
- package/dist/components/UTBarChart/components/XAxis/components/Decoration/constants.js +2 -4
- package/dist/components/UTBarChart/components/XAxis/components/Decoration/index.js +20 -19
- package/dist/components/UTBarChart/components/XAxis/constants.js +1 -2
- package/dist/components/UTBarChart/components/XAxis/index.js +54 -65
- package/dist/components/UTBarChart/components/YAxis/AxisElement/index.js +12 -11
- package/dist/components/UTBarChart/components/YAxis/constants.js +1 -2
- package/dist/components/UTBarChart/components/YAxis/index.js +30 -37
- package/dist/components/UTBarChart/components/YAxis/utils.js +4 -6
- package/dist/components/UTBarChart/constants.js +4 -8
- package/dist/components/UTBarChart/hooks/use-dynamic-margins.js +23 -40
- package/dist/components/UTBarChart/index.js +152 -166
- package/dist/components/UTBarChart/theme.js +4 -2
- package/dist/components/UTBarChart/types.js +10 -19
- package/dist/components/UTBarChart/utils.js +107 -111
- package/dist/components/UTBreadcrumbs/constants.js +23 -31
- package/dist/components/UTBreadcrumbs/index.js +76 -101
- package/dist/components/UTBreadcrumbs/theme.js +4 -2
- package/dist/components/UTButton/constants.js +11 -17
- package/dist/components/UTButton/index.js +28 -31
- package/dist/components/UTButton/theme.js +23 -23
- package/dist/components/UTCBUInput/index.js +36 -40
- package/dist/components/UTCBUInput/theme.js +4 -2
- package/dist/components/UTCaptcha/index.js +19 -45
- package/dist/components/UTCard/components/UTCardFooter/index.js +15 -16
- package/dist/components/UTCard/index.js +85 -120
- package/dist/components/UTCard/theme.js +11 -12
- package/dist/components/UTCard/types.js +2 -3
- package/dist/components/UTCarousel/components/Button/index.js +13 -13
- package/dist/components/UTCarousel/components/Legend/index.js +13 -15
- package/dist/components/UTCarousel/components/Slider/component/Slide/index.js +16 -16
- package/dist/components/UTCarousel/components/Slider/constants.js +5 -10
- package/dist/components/UTCarousel/components/Slider/index.js +204 -273
- package/dist/components/UTCarousel/components/Slider/layout.js +67 -94
- package/dist/components/UTCarousel/index.js +14 -15
- package/dist/components/UTCarousel/theme.js +4 -2
- package/dist/components/UTCheckList/constants.js +1 -2
- package/dist/components/UTCheckList/index.js +72 -93
- package/dist/components/UTCheckList/theme.js +31 -31
- package/dist/components/UTCheckbox/constants.js +3 -6
- package/dist/components/UTCheckbox/index.js +32 -44
- package/dist/components/UTCheckbox/theme.js +35 -35
- package/dist/components/UTConsumptionBar/components/ConsumptionBarIndicator/index.js +9 -9
- package/dist/components/UTConsumptionBar/constants.js +3 -6
- package/dist/components/UTConsumptionBar/index.js +53 -80
- package/dist/components/UTCuit/index.js +109 -133
- package/dist/components/UTCuit/theme.js +51 -53
- package/dist/components/UTDatePicker/components/Day/constants.js +1 -2
- package/dist/components/UTDatePicker/components/Day/index.js +12 -12
- package/dist/components/UTDatePicker/constants.js +20 -31
- package/dist/components/UTDatePicker/index.js +60 -102
- package/dist/components/UTDatePicker/theme.js +5 -3
- package/dist/components/UTDatePicker/types.js +2 -3
- package/dist/components/UTDatePicker/utils.js +2 -6
- package/dist/components/UTDialog/constants.js +2 -4
- package/dist/components/UTDialog/index.js +38 -37
- package/dist/components/UTDialog/theme.js +4 -2
- package/dist/components/UTDialog/types.js +2 -3
- package/dist/components/UTDotMenu/index.js +39 -61
- package/dist/components/UTEmojiPicker/constants.js +6 -11
- package/dist/components/UTEmojiPicker/index.js +45 -65
- package/dist/components/UTEmojiPicker/theme.js +4 -2
- package/dist/components/UTEmojiPicker/utils.js +21 -51
- package/dist/components/UTExternalLink/constants.js +3 -5
- package/dist/components/UTExternalLink/index.js +18 -15
- package/dist/components/UTExternalLink/theme.js +8 -6
- package/dist/components/UTFileInput/constants.js +2 -4
- package/dist/components/UTFileInput/index.js +7 -31
- package/dist/components/UTFileInput/layout.js +68 -97
- package/dist/components/UTIconButton/index.js +49 -72
- package/dist/components/UTIconButton/theme.js +4 -2
- package/dist/components/UTImageRadio/components/ImageRadioCard/index.js +53 -58
- package/dist/components/UTImageRadio/constants.js +3 -6
- package/dist/components/UTImageRadio/index.js +39 -47
- package/dist/components/UTImageRadio/theme.js +11 -12
- package/dist/components/UTImageRadio/types.js +2 -3
- package/dist/components/UTImageRadio/utils.js +2 -6
- package/dist/components/UTLabel/constants.js +14 -20
- package/dist/components/UTLabel/index.js +18 -20
- package/dist/components/UTLabel/theme.js +15 -15
- package/dist/components/UTList/index.js +15 -18
- package/dist/components/UTLoading/index.js +15 -15
- package/dist/components/UTMap/components/GoogleMaps/constants.js +8 -11
- package/dist/components/UTMap/components/GoogleMaps/index.js +63 -91
- package/dist/components/UTMap/components/GoogleMaps/styles.js +2 -3
- package/dist/components/UTMap/constants.js +6 -12
- package/dist/components/UTMap/index.js +163 -198
- package/dist/components/UTMap/types.js +4 -6
- package/dist/components/UTMap/utils.js +29 -46
- package/dist/components/UTMap/withGoogleMapScript.js +18 -22
- package/dist/components/UTMenu/index.js +52 -69
- package/dist/components/UTMenu/theme.js +5 -3
- package/dist/components/UTMenu/utils.js +5 -11
- package/dist/components/UTModal/constants.js +9 -13
- package/dist/components/UTModal/index.js +26 -30
- package/dist/components/UTModal/theme.js +4 -2
- package/dist/components/UTPagination/components/PageSizeSelector/index.js +11 -10
- package/dist/components/UTPagination/components/PageSizeSelector/utils.js +7 -13
- package/dist/components/UTPagination/components/Pagination/components/NavigationButton/index.js +12 -12
- package/dist/components/UTPagination/components/Pagination/index.js +28 -39
- package/dist/components/UTPagination/components/Pagination/utils.js +8 -14
- package/dist/components/UTPagination/constants.js +3 -6
- package/dist/components/UTPagination/index.js +16 -17
- package/dist/components/UTPagination/theme.js +4 -2
- package/dist/components/UTPanel/index.js +38 -44
- package/dist/components/UTPasswordField/components/PasswordValidations/components/Error/index.js +13 -10
- package/dist/components/UTPasswordField/components/PasswordValidations/components/Validation/index.js +22 -19
- package/dist/components/UTPasswordField/components/PasswordValidations/index.js +63 -50
- package/dist/components/UTPasswordField/components/PasswordWarning/index.js +25 -26
- package/dist/components/UTPasswordField/index.js +26 -23
- package/dist/components/UTPasswordField/theme.js +4 -2
- package/dist/components/UTPhoneInput/constants.js +3 -6
- package/dist/components/UTPhoneInput/index.js +180 -205
- package/dist/components/UTPhoneInput/theme.js +77 -77
- package/dist/components/UTPieChart/components/ArrowLabel/constants.js +4 -8
- package/dist/components/UTPieChart/components/ArrowLabel/index.js +24 -23
- package/dist/components/UTPieChart/components/Legend/contants.js +3 -6
- package/dist/components/UTPieChart/components/Legend/index.js +27 -24
- package/dist/components/UTPieChart/constants.js +13 -26
- package/dist/components/UTPieChart/hooks/use-animated-value/index.js +15 -33
- package/dist/components/UTPieChart/index.js +73 -76
- package/dist/components/UTPieChart/theme.js +4 -2
- package/dist/components/UTPieChart/utils.js +4 -2
- package/dist/components/UTProgressBar/constants.js +2 -4
- package/dist/components/UTProgressBar/index.js +15 -17
- package/dist/components/UTProgressBar/theme.js +4 -2
- package/dist/components/UTProgressBar/types.js +2 -3
- package/dist/components/UTRadioGroup/index.js +56 -83
- package/dist/components/UTRadioGroup/theme.js +52 -52
- package/dist/components/UTRating/components/Circle/index.js +41 -56
- package/dist/components/UTRating/components/Faces/constants.js +2 -4
- package/dist/components/UTRating/components/Faces/index.js +34 -36
- package/dist/components/UTRating/components/Star/index.js +36 -40
- package/dist/components/UTRating/constants.js +4 -8
- package/dist/components/UTRating/index.js +31 -46
- package/dist/components/UTRating/theme.js +4 -2
- package/dist/components/UTRipple/Ripple.js +22 -39
- package/dist/components/UTRipple/index.js +18 -37
- package/dist/components/UTSelect/components/Option/index.js +13 -13
- package/dist/components/UTSelect/constants.js +4 -8
- package/dist/components/UTSelect/index.js +63 -85
- package/dist/components/UTSelect/stylesJS.js +2 -3
- package/dist/components/UTSelect/theme.js +6 -4
- package/dist/components/UTSelect/utils.js +3 -13
- package/dist/components/UTSidebar/components/ListOption/index.js +34 -49
- package/dist/components/UTSidebar/components/LogosContainer/components/DynamicIcon/index.js +8 -8
- package/dist/components/UTSidebar/components/LogosContainer/index.js +14 -14
- package/dist/components/UTSidebar/components/Option/constants.js +2 -3
- package/dist/components/UTSidebar/components/Option/index.js +28 -32
- package/dist/components/UTSidebar/components/Toggler/index.js +11 -11
- package/dist/components/UTSidebar/index.js +42 -53
- package/dist/components/UTSidebar/theme.js +4 -2
- package/dist/components/UTSidebar/types.js +5 -10
- package/dist/components/UTSkeleton/index.js +10 -36
- package/dist/components/UTStatus/constants.js +5 -9
- package/dist/components/UTStatus/index.js +16 -15
- package/dist/components/UTStatus/theme.js +66 -49
- package/dist/components/UTSwitch/constants.js +3 -6
- package/dist/components/UTSwitch/index.js +42 -57
- package/dist/components/UTSwitch/theme.js +4 -2
- package/dist/components/UTTable/components/ActionIcons/constants.js +1 -2
- package/dist/components/UTTable/components/ActionIcons/index.js +47 -85
- package/dist/components/UTTable/components/Cell/components/ActionButton/index.js +10 -12
- package/dist/components/UTTable/components/Cell/index.js +18 -23
- package/dist/components/UTTable/components/HeaderCell/constants.js +2 -3
- package/dist/components/UTTable/components/HeaderCell/index.js +23 -30
- package/dist/components/UTTable/components/HeaderCell/utils.js +3 -3
- package/dist/components/UTTable/components/PrimaryAction/index.js +12 -11
- package/dist/components/UTTable/components/ResponsiveCell/index.js +19 -20
- package/dist/components/UTTable/components/Status/index.js +18 -19
- package/dist/components/UTTable/components/TableFooter/components/PageSizeSelector/index.js +10 -9
- package/dist/components/UTTable/components/TableFooter/components/PageSizeSelector/utils.js +7 -13
- package/dist/components/UTTable/components/TableFooter/components/Pagination/components/NavigationButton/index.js +12 -12
- package/dist/components/UTTable/components/TableFooter/components/Pagination/index.js +21 -32
- package/dist/components/UTTable/components/TableFooter/components/Pagination/utils.js +8 -14
- package/dist/components/UTTable/components/TableFooter/constants.js +1 -2
- package/dist/components/UTTable/components/TableFooter/index.js +15 -15
- package/dist/components/UTTable/components/TableHeader/index.js +11 -11
- package/dist/components/UTTable/components/TableRow/constants.js +3 -6
- package/dist/components/UTTable/components/TableRow/index.js +82 -95
- package/dist/components/UTTable/components/TableRow/styles.module.scss +8 -1
- package/dist/components/UTTable/components/TableRow/utils.js +15 -0
- package/dist/components/UTTable/constants.js +26 -43
- package/dist/components/UTTable/hook.js +11 -26
- package/dist/components/UTTable/index.js +129 -220
- package/dist/components/UTTable/theme.js +17 -17
- package/dist/components/UTTable/types.js +4 -8
- package/dist/components/UTTable/utils.js +70 -74
- package/dist/components/UTTabs/components/TooltipTab/index.js +20 -30
- package/dist/components/UTTabs/constants.js +4 -8
- package/dist/components/UTTabs/index.js +57 -86
- package/dist/components/UTTabs/theme.js +4 -2
- package/dist/components/UTTabs/utils.js +1 -1
- package/dist/components/UTTextArea/constants.js +3 -6
- package/dist/components/UTTextArea/index.js +23 -23
- package/dist/components/UTTextArea/theme.js +4 -2
- package/dist/components/UTTextInput/constants.js +2 -3
- package/dist/components/UTTextInput/index.js +137 -165
- package/dist/components/UTTextInput/theme.js +6 -4
- package/dist/components/UTThirdPartyCookieChecker/index.js +17 -21
- package/dist/components/UTToggle/components/ToggleOption/index.js +16 -17
- package/dist/components/UTToggle/index.js +25 -26
- package/dist/components/UTToggle/theme.js +4 -2
- package/dist/components/UTTooltip/index.js +23 -30
- package/dist/components/UTTooltip/theme.js +4 -2
- package/dist/components/UTTopbar/components/Notifications/index.js +11 -14
- package/dist/components/UTTopbar/components/UserMenu/index.js +15 -15
- package/dist/components/UTTopbar/index.js +28 -31
- package/dist/components/UTTopbar/theme.js +4 -2
- package/dist/components/UTTopbar/types.js +5 -9
- package/dist/components/UTTouchableWithoutFeedback/index.js +14 -27
- package/dist/components/UTVirtualizedList/components/VirtualizedData/components/ListRow/constants.js +2 -4
- package/dist/components/UTVirtualizedList/components/VirtualizedData/components/ListRow/index.js +34 -31
- package/dist/components/UTVirtualizedList/components/VirtualizedData/components/ListRow/utils.js +4 -4
- package/dist/components/UTVirtualizedList/components/VirtualizedData/constants.js +6 -12
- package/dist/components/UTVirtualizedList/components/VirtualizedData/hooks/use-ledger.js +8 -18
- package/dist/components/UTVirtualizedList/components/VirtualizedData/hooks/use-virtualized-data.js +23 -47
- package/dist/components/UTVirtualizedList/components/VirtualizedData/index.js +31 -34
- package/dist/components/UTVirtualizedList/components/VirtualizedData/utils.js +81 -93
- package/dist/components/UTVirtualizedList/constants.js +4 -8
- package/dist/components/UTVirtualizedList/index.js +26 -38
- package/dist/components/UTWorkflowContainer/components/ActionButton/index.js +17 -21
- package/dist/components/UTWorkflowContainer/constants.js +3 -6
- package/dist/components/UTWorkflowContainer/hooks/use-previous.js +3 -3
- package/dist/components/UTWorkflowContainer/index.js +32 -51
- package/dist/components/UTWorkflowContainer/theme.js +60 -53
- package/dist/components/UTWorkflowContainer/types.js +2 -3
- package/dist/components/WithLoading/index.js +10 -15
- package/dist/components/WithTheme/index.js +10 -17
- package/dist/components/WithTheme/layout.js +22 -28
- package/dist/components/WithTouch/index.js +12 -19
- package/dist/constants/UTTable.js +2 -3
- package/dist/index.js +58 -58
- package/dist/theme.js +6 -5
- package/dist/types/commonTypes.js +3 -5
- package/dist/types/consumptionTypes.js +3 -5
- package/dist/types/formTypes.js +4 -7
- package/dist/types/tableTypes.js +2 -3
- package/dist/utils/classesUtils.js +5 -13
- package/dist/utils/componentUtils.js +10 -13
- package/dist/utils/helperFunctions.js +4 -4
- package/dist/utils/shadowUtils.js +13 -11
- package/dist/utils/useScreenSize.js +2 -3
- package/package.json +1 -1
|
@@ -15,130 +15,104 @@ var _withGoogleMapScript = _interopRequireDefault(require("./withGoogleMapScript
|
|
|
15
15
|
var _constants = require("./constants");
|
|
16
16
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
function _getRequireWildcardCache(
|
|
19
|
-
function _interopRequireWildcard(
|
|
20
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
21
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
22
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
23
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
24
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
25
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
26
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
27
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
28
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
29
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
30
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
31
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
32
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
33
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
34
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
35
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
36
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
18
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
19
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
37
20
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
38
|
-
function _toPropertyKey(
|
|
39
|
-
function _toPrimitive(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return _this.setState({
|
|
49
|
-
searchValue: event.target.value
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
_defineProperty(_assertThisInitialized(_this), "updateAddress", function (latLng, forcedAddress, changeValue) {
|
|
53
|
-
_this.setState({
|
|
21
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
22
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
23
|
+
class UTMap extends _react.PureComponent {
|
|
24
|
+
constructor(props) {
|
|
25
|
+
super(props);
|
|
26
|
+
_defineProperty(this, "handleSearchChange", event => this.setState({
|
|
27
|
+
searchValue: event.target.value
|
|
28
|
+
}));
|
|
29
|
+
_defineProperty(this, "updateAddress", (latLng, forcedAddress, changeValue) => {
|
|
30
|
+
this.setState({
|
|
54
31
|
searchValue: ''
|
|
55
32
|
});
|
|
56
33
|
// Update address on search box and complete field value on store
|
|
57
34
|
(0, _utils.retrieveAddressByCoords)({
|
|
58
35
|
address: forcedAddress,
|
|
59
36
|
location: latLng
|
|
60
|
-
},
|
|
61
|
-
|
|
37
|
+
}, address => {
|
|
38
|
+
this.setState({
|
|
62
39
|
searchValue: address.formatted_address
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
field
|
|
66
|
-
onChange
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
40
|
+
}, () => {
|
|
41
|
+
const {
|
|
42
|
+
field,
|
|
43
|
+
onChange
|
|
44
|
+
} = this.props;
|
|
45
|
+
const addressComponents = field.configuration.address_components;
|
|
46
|
+
const addressValue = {};
|
|
47
|
+
Object.keys(addressComponents).map(key => addressValue[addressComponents[key]] = (0, _utils.getValue)(address, latLng, key));
|
|
72
48
|
if (changeValue) onChange(addressValue);
|
|
73
49
|
});
|
|
74
50
|
});
|
|
75
51
|
});
|
|
76
|
-
_defineProperty(
|
|
52
|
+
_defineProperty(this, "updateMarker", latLng => {
|
|
77
53
|
// Add marker on screen
|
|
78
|
-
|
|
54
|
+
const newMarker = {
|
|
79
55
|
position: latLng,
|
|
80
56
|
defaultAnimation: 2,
|
|
81
57
|
key: Date.now()
|
|
82
58
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
markers
|
|
59
|
+
const markers = [...(this.props.singleMarker ? [] : [...this.state.markers]), newMarker];
|
|
60
|
+
this.setState({
|
|
61
|
+
markers
|
|
86
62
|
});
|
|
87
63
|
});
|
|
88
|
-
_defineProperty(
|
|
64
|
+
_defineProperty(this, "handleMapClick", event => {
|
|
89
65
|
// When user click on any place inside map
|
|
90
|
-
if (
|
|
91
|
-
if ((0, _utils.checkAddressIsValid)(event.latLng,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
} else if (
|
|
96
|
-
|
|
97
|
-
mapZoom:
|
|
66
|
+
if (this.props.disabled) return;
|
|
67
|
+
if ((0, _utils.checkAddressIsValid)(event.latLng, this.state.usePolygon, this.props.polygonPath)) {
|
|
68
|
+
this.props.onChange(null);
|
|
69
|
+
this.updateMarker(event.latLng);
|
|
70
|
+
this.updateAddress(event.latLng, null, true);
|
|
71
|
+
} else if (this.props.onLocationOutOfBoundsCallback) {
|
|
72
|
+
this.setState({
|
|
73
|
+
mapZoom: this.props.zoomAddressInvalid || 10
|
|
98
74
|
});
|
|
99
|
-
|
|
75
|
+
this.props.onLocationOutOfBoundsCallback();
|
|
100
76
|
}
|
|
101
77
|
});
|
|
102
|
-
_defineProperty(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
var nextMarkers = _this.state.markers.filter(function (marker) {
|
|
110
|
-
return marker.position !== targetMarker.latLng && marker.position.lat !== targetMarker.latLng.lat() && marker.position.lng !== targetMarker.latLng.lng();
|
|
111
|
-
});
|
|
112
|
-
_this.setState({
|
|
78
|
+
_defineProperty(this, "centerMap", latLng => this.setState({
|
|
79
|
+
center: latLng,
|
|
80
|
+
mapZoom: this.props.zoomAddressValid || _constants.ZOOM_ADDRESS_VALID
|
|
81
|
+
}));
|
|
82
|
+
_defineProperty(this, "handleMarkerRightClick", targetMarker => {
|
|
83
|
+
const nextMarkers = this.state.markers.filter(marker => marker.position !== targetMarker.latLng && marker.position.lat !== targetMarker.latLng.lat() && marker.position.lng !== targetMarker.latLng.lng());
|
|
84
|
+
this.setState({
|
|
113
85
|
markers: nextMarkers
|
|
114
86
|
});
|
|
115
87
|
});
|
|
116
|
-
_defineProperty(
|
|
88
|
+
_defineProperty(this, "handleMapMounted", mapRef => {
|
|
117
89
|
// When map is mounted on screen
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
input
|
|
121
|
-
field
|
|
90
|
+
this.map = mapRef;
|
|
91
|
+
const {
|
|
92
|
+
input,
|
|
93
|
+
field
|
|
94
|
+
} = this.props;
|
|
122
95
|
if (input.value) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
96
|
+
const addressComponents = field.configuration.address_components;
|
|
97
|
+
const latLng = new window.google.maps.LatLng(input.value[addressComponents[_constants.GMAP_PARAMS.latitude]], input.value[addressComponents[_constants.GMAP_PARAMS.longitude]]);
|
|
98
|
+
this.updateAddress(latLng, input.value[addressComponents[_constants.GMAP_PARAMS.formattedAddress]]);
|
|
126
99
|
return;
|
|
127
100
|
}
|
|
128
|
-
if (
|
|
101
|
+
if (this.props.useGeolocation) {
|
|
129
102
|
// We try to recover user actual position with navigator geolocation
|
|
130
|
-
(0, _utils.geolocation)(
|
|
103
|
+
(0, _utils.geolocation)(this.props.errors.retrieveLocationError).getCurrentPosition(userPosition => {
|
|
131
104
|
// If we can retrieve user position...
|
|
132
|
-
|
|
133
|
-
userLatitude
|
|
134
|
-
userLongitude
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
105
|
+
const {
|
|
106
|
+
latitude: userLatitude,
|
|
107
|
+
longitude: userLongitude
|
|
108
|
+
} = userPosition.coords;
|
|
109
|
+
const userLatLng = new window.google.maps.LatLng(userLatitude, userLongitude);
|
|
110
|
+
if ((0, _utils.checkAddressIsValid)(userLatLng, this.state.usePolygon, this.props.polygonPath)) {
|
|
111
|
+
const actualPosition = {
|
|
138
112
|
lat: userLatitude,
|
|
139
113
|
lng: userLongitude
|
|
140
114
|
};
|
|
141
|
-
|
|
115
|
+
this.setState({
|
|
142
116
|
center: actualPosition,
|
|
143
117
|
markers: [{
|
|
144
118
|
position: actualPosition,
|
|
@@ -146,133 +120,125 @@ var UTMap = /*#__PURE__*/function (_PureComponent) {
|
|
|
146
120
|
defaultAnimation: 2
|
|
147
121
|
}],
|
|
148
122
|
mapLoading: false
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
|
|
123
|
+
}, () => {
|
|
124
|
+
const latlng = new window.google.maps.LatLng(userLatitude, userLongitude);
|
|
125
|
+
this.updateAddress(latlng, null, true);
|
|
152
126
|
});
|
|
153
127
|
} else {
|
|
154
128
|
// In other case we set map on startLocation
|
|
155
|
-
|
|
156
|
-
|
|
129
|
+
const latlng = new window.google.maps.LatLng(this.state.center.lat, this.state.center.lng);
|
|
130
|
+
this.updateAddress(latlng, null, true);
|
|
157
131
|
}
|
|
158
132
|
},
|
|
159
133
|
// If we can't retrieve user position we set map on startLocation
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
134
|
+
() => {
|
|
135
|
+
const latlng = new window.google.maps.LatLng(this.state.center.lat, this.state.center.lng);
|
|
136
|
+
this.updateAddress(latlng, null, true);
|
|
163
137
|
});
|
|
164
138
|
}
|
|
165
139
|
});
|
|
166
|
-
_defineProperty(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
_defineProperty(_assertThisInitialized(_this), "handlePlacesChanged", function () {
|
|
175
|
-
if (_this.props.disabled) return;
|
|
176
|
-
var places = _this.searchBox.getPlaces();
|
|
177
|
-
var place = !(0, _array.isEmpty)(places) && (0, _utils.checkAddressIsValid)(places[0].geometry.location, _this.state.usePolygon, _this.props.polygonPath) && places[0];
|
|
140
|
+
_defineProperty(this, "handleBoundsChanged", () => this.setState({
|
|
141
|
+
center: this.map.getCenter()
|
|
142
|
+
}));
|
|
143
|
+
_defineProperty(this, "handleSearchBoxMounted", searchBoxRef => this.searchBox = searchBoxRef);
|
|
144
|
+
_defineProperty(this, "handlePlacesChanged", () => {
|
|
145
|
+
if (this.props.disabled) return;
|
|
146
|
+
const places = this.searchBox.getPlaces();
|
|
147
|
+
const place = !(0, _array.isEmpty)(places) && (0, _utils.checkAddressIsValid)(places[0].geometry.location, this.state.usePolygon, this.props.polygonPath) && places[0];
|
|
178
148
|
if (place) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
} else if (
|
|
149
|
+
this.props.onChange(null);
|
|
150
|
+
this.updateMarker(place.geometry.location);
|
|
151
|
+
this.updateAddress(place.geometry.location, place.formatted_address, true);
|
|
152
|
+
this.centerMap(place.geometry.location);
|
|
153
|
+
} else if (this.props.onLocationOutOfBoundsCallback) this.props.onLocationOutOfBoundsCallback();
|
|
184
154
|
});
|
|
185
|
-
|
|
155
|
+
this.state = {
|
|
186
156
|
markers: [],
|
|
187
157
|
mapLoading: true,
|
|
188
158
|
searchValue: '',
|
|
189
|
-
mapZoom:
|
|
190
|
-
usePolygon:
|
|
159
|
+
mapZoom: this.props.zoomInitial || _constants.ZOOM_INITIAL,
|
|
160
|
+
usePolygon: this.props.usePolygon && !(0, _array.isEmpty)(this.props.polygonPath),
|
|
191
161
|
invalidConfiguration: false
|
|
192
162
|
};
|
|
193
|
-
return _this;
|
|
194
163
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
lat: null,
|
|
201
|
-
lng: null
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
var _this$props3 = this.props,
|
|
205
|
-
input = _this$props3.input,
|
|
206
|
-
startLocation = _this$props3.startLocation,
|
|
207
|
-
field = _this$props3.field;
|
|
208
|
-
if (!(0, _utils.isValidConfiguration)(field)) {
|
|
209
|
-
this.setState({
|
|
210
|
-
invalidConfiguration: true,
|
|
211
|
-
mapLoading: false
|
|
212
|
-
});
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
if (input.value) {
|
|
216
|
-
startPosition.position.lat = input.value[field.configuration.address_components[_constants.GMAP_PARAMS.latitude]];
|
|
217
|
-
startPosition.position.lng = input.value[field.configuration.address_components[_constants.GMAP_PARAMS.longitude]];
|
|
218
|
-
this.setState({
|
|
219
|
-
center: startPosition.position,
|
|
220
|
-
markers: [startPosition],
|
|
221
|
-
mapLoading: false
|
|
222
|
-
});
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
if (startLocation && startLocation.position.lat && startLocation.position.lng) {
|
|
226
|
-
this.setState({
|
|
227
|
-
center: startLocation.position,
|
|
228
|
-
markers: [startLocation],
|
|
229
|
-
mapLoading: false
|
|
230
|
-
});
|
|
164
|
+
componentDidMount() {
|
|
165
|
+
const startPosition = {
|
|
166
|
+
position: {
|
|
167
|
+
lat: null,
|
|
168
|
+
lng: null
|
|
231
169
|
}
|
|
170
|
+
};
|
|
171
|
+
const {
|
|
172
|
+
input,
|
|
173
|
+
startLocation,
|
|
174
|
+
field
|
|
175
|
+
} = this.props;
|
|
176
|
+
if (!(0, _utils.isValidConfiguration)(field)) {
|
|
177
|
+
this.setState({
|
|
178
|
+
invalidConfiguration: true,
|
|
179
|
+
mapLoading: false
|
|
180
|
+
});
|
|
181
|
+
return;
|
|
232
182
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
className: this.props.className
|
|
243
|
-
}),
|
|
244
|
-
onMapClick: this.handleMapClick,
|
|
245
|
-
onMarkerRightClick: this.handleMarkerRightClick,
|
|
246
|
-
onMapMounted: this.handleMapMounted,
|
|
247
|
-
onSearchBoxMounted: this.handleSearchBoxMounted,
|
|
248
|
-
onPlacesChanged: this.handlePlacesChanged,
|
|
249
|
-
markers: this.state.markers,
|
|
250
|
-
center: this.state.center,
|
|
251
|
-
searchValue: this.state.searchValue,
|
|
252
|
-
onSearchChange: this.handleSearchChange,
|
|
253
|
-
zoom: this.state.mapZoom,
|
|
254
|
-
polygonPath: this.props.polygonPath,
|
|
255
|
-
usePolygon: this.state.usePolygon,
|
|
256
|
-
placeholder: this.props.placeholder,
|
|
257
|
-
disabled: this.props.disabled,
|
|
258
|
-
showOnlyMap: showOnlyMap,
|
|
259
|
-
colorPolygon: this.props.colorPolygon,
|
|
260
|
-
colorBorderPolygon: this.props.colorBorderPolygon
|
|
261
|
-
})) : this.state.mapLoading ? /*#__PURE__*/_react.default.createElement(_UTLabel.default, null, this.props.errors.retrievingLocation) : this.state.invalidConfiguration ? /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
262
|
-
colorTheme: "error",
|
|
263
|
-
variant: "small"
|
|
264
|
-
}, this.props.errors.invalidConfig) : /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
265
|
-
colorTheme: "error",
|
|
266
|
-
variant: "small"
|
|
267
|
-
}, this.props.errors.retrieveLocationError), !showOnlyMap && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
268
|
-
colorTheme: "error",
|
|
269
|
-
variant: "small",
|
|
270
|
-
className: _stylesModule.default.error
|
|
271
|
-
}, (0, _form.shouldShowErrors)(this.props.meta) ? this.props.meta.error : ''));
|
|
183
|
+
if (input.value) {
|
|
184
|
+
startPosition.position.lat = input.value[field.configuration.address_components[_constants.GMAP_PARAMS.latitude]];
|
|
185
|
+
startPosition.position.lng = input.value[field.configuration.address_components[_constants.GMAP_PARAMS.longitude]];
|
|
186
|
+
this.setState({
|
|
187
|
+
center: startPosition.position,
|
|
188
|
+
markers: [startPosition],
|
|
189
|
+
mapLoading: false
|
|
190
|
+
});
|
|
191
|
+
return;
|
|
272
192
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
193
|
+
if (startLocation && startLocation.position.lat && startLocation.position.lng) {
|
|
194
|
+
this.setState({
|
|
195
|
+
center: startLocation.position,
|
|
196
|
+
markers: [startLocation],
|
|
197
|
+
mapLoading: false
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
render() {
|
|
202
|
+
const {
|
|
203
|
+
showOnlyMap
|
|
204
|
+
} = this.props.field.configuration;
|
|
205
|
+
return /*#__PURE__*/_react.default.createElement("div", null, this.state.center ? /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_GoogleMaps.default, {
|
|
206
|
+
containerElement: /*#__PURE__*/_react.default.createElement("div", {
|
|
207
|
+
className: this.props.className
|
|
208
|
+
}),
|
|
209
|
+
mapElement: /*#__PURE__*/_react.default.createElement("div", {
|
|
210
|
+
className: this.props.className
|
|
211
|
+
}),
|
|
212
|
+
onMapClick: this.handleMapClick,
|
|
213
|
+
onMarkerRightClick: this.handleMarkerRightClick,
|
|
214
|
+
onMapMounted: this.handleMapMounted,
|
|
215
|
+
onSearchBoxMounted: this.handleSearchBoxMounted,
|
|
216
|
+
onPlacesChanged: this.handlePlacesChanged,
|
|
217
|
+
markers: this.state.markers,
|
|
218
|
+
center: this.state.center,
|
|
219
|
+
searchValue: this.state.searchValue,
|
|
220
|
+
onSearchChange: this.handleSearchChange,
|
|
221
|
+
zoom: this.state.mapZoom,
|
|
222
|
+
polygonPath: this.props.polygonPath,
|
|
223
|
+
usePolygon: this.state.usePolygon,
|
|
224
|
+
placeholder: this.props.placeholder,
|
|
225
|
+
disabled: this.props.disabled,
|
|
226
|
+
showOnlyMap: showOnlyMap,
|
|
227
|
+
colorPolygon: this.props.colorPolygon,
|
|
228
|
+
colorBorderPolygon: this.props.colorBorderPolygon
|
|
229
|
+
})) : this.state.mapLoading ? /*#__PURE__*/_react.default.createElement(_UTLabel.default, null, this.props.errors.retrievingLocation) : this.state.invalidConfiguration ? /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
230
|
+
colorTheme: "error",
|
|
231
|
+
variant: "small"
|
|
232
|
+
}, this.props.errors.invalidConfig) : /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
233
|
+
colorTheme: "error",
|
|
234
|
+
variant: "small"
|
|
235
|
+
}, this.props.errors.retrieveLocationError), !showOnlyMap && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
236
|
+
colorTheme: "error",
|
|
237
|
+
variant: "small",
|
|
238
|
+
className: _stylesModule.default.error
|
|
239
|
+
}, (0, _form.shouldShowErrors)(this.props.meta) ? this.props.meta.error : ''));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
276
242
|
UTMap.propTypes = _types.UTMapPropTypes;
|
|
277
243
|
UTMap.defaultProps = {
|
|
278
244
|
errors: {
|
|
@@ -287,5 +253,4 @@ UTMap.defaultProps = {
|
|
|
287
253
|
}
|
|
288
254
|
}
|
|
289
255
|
};
|
|
290
|
-
var _default = (0, _withGoogleMapScript.default)()(UTMap);
|
|
291
|
-
exports.default = _default;
|
|
256
|
+
var _default = exports.default = (0, _withGoogleMapScript.default)()(UTMap);
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.UTMapPropTypes = exports.GoogleMapsPropTypes = void 0;
|
|
7
7
|
var _propTypes = require("prop-types");
|
|
8
8
|
var _formTypes = require("../../types/formTypes");
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const coordinatePropType = (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.func]);
|
|
10
|
+
const UTMapPropTypes = exports.UTMapPropTypes = {
|
|
11
11
|
onChange: _propTypes.func.isRequired,
|
|
12
12
|
singleMarker: _propTypes.bool,
|
|
13
13
|
startLocation: (0, _propTypes.shape)({
|
|
@@ -37,8 +37,7 @@ var UTMapPropTypes = {
|
|
|
37
37
|
apiKey: _propTypes.string,
|
|
38
38
|
disabled: _propTypes.bool
|
|
39
39
|
};
|
|
40
|
-
exports.
|
|
41
|
-
var GoogleMapsPropTypes = {
|
|
40
|
+
const GoogleMapsPropTypes = exports.GoogleMapsPropTypes = {
|
|
42
41
|
onMapClick: _propTypes.func.isRequired,
|
|
43
42
|
onMarkerRightClick: _propTypes.func.isRequired,
|
|
44
43
|
center: (0, _propTypes.shape)({
|
|
@@ -66,5 +65,4 @@ var GoogleMapsPropTypes = {
|
|
|
66
65
|
searchValue: _propTypes.any,
|
|
67
66
|
zoom: _propTypes.number,
|
|
68
67
|
showOnlyMap: _propTypes.bool
|
|
69
|
-
};
|
|
70
|
-
exports.GoogleMapsPropTypes = GoogleMapsPropTypes;
|
|
68
|
+
};
|
|
@@ -6,72 +6,57 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.retrieveAddressByCoords = exports.isValidConfiguration = exports.getValue = exports.geolocation = exports.findAddressComponent = exports.checkAddressIsValid = void 0;
|
|
7
7
|
var _array = require("@widergy/web-utils/lib/array");
|
|
8
8
|
var _constants = require("./constants");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
-
var geolocation = function geolocation(message) {
|
|
16
|
-
return navigator.geolocation ? navigator.geolocation : {
|
|
17
|
-
getCurrentPosition: function getCurrentPosition(success, failure) {
|
|
18
|
-
failure(message);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
9
|
+
const geolocation = message => navigator.geolocation ? navigator.geolocation : {
|
|
10
|
+
getCurrentPosition(success, failure) {
|
|
11
|
+
failure(message);
|
|
12
|
+
}
|
|
21
13
|
};
|
|
22
14
|
exports.geolocation = geolocation;
|
|
23
|
-
|
|
15
|
+
const checkAddressIsValid = (latLng, usePolygon, polygon) => {
|
|
24
16
|
// Check if a position is included on Utility polygon or if utility hasn't setted a polygon
|
|
25
17
|
// To set map in this position
|
|
26
|
-
|
|
18
|
+
const utilityPolygon = new window.google.maps.Polygon({
|
|
27
19
|
paths: polygon
|
|
28
20
|
});
|
|
29
21
|
return !usePolygon || window.google.maps.geometry.poly.containsLocation(latLng, utilityPolygon);
|
|
30
22
|
};
|
|
31
23
|
exports.checkAddressIsValid = checkAddressIsValid;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
const retrieveAddressByCoords = (_ref, onAddressFoundCallback) => {
|
|
25
|
+
let {
|
|
26
|
+
location,
|
|
27
|
+
address
|
|
28
|
+
} = _ref;
|
|
29
|
+
const geocoder = new window.google.maps.Geocoder();
|
|
30
|
+
const parameters = address ? {
|
|
31
|
+
address
|
|
38
32
|
} : {
|
|
39
|
-
location
|
|
33
|
+
location
|
|
40
34
|
};
|
|
41
|
-
geocoder.geocode(parameters,
|
|
35
|
+
geocoder.geocode(parameters, (results, status) => {
|
|
42
36
|
if (status === 'OK') {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return type === _constants.ADDRESS_TYPES.street || type === _constants.ADDRESS_TYPES.route;
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
var finalAddress;
|
|
37
|
+
const addressResults = results.filter(result => result.types.some(type => type === _constants.ADDRESS_TYPES.street || type === _constants.ADDRESS_TYPES.route));
|
|
38
|
+
let finalAddress;
|
|
49
39
|
if (!(0, _array.isEmpty)(addressResults)) {
|
|
50
|
-
finalAddress = addressResults.find(
|
|
51
|
-
return elem.geometry.location_type === _constants.LOCATION_TYPES.rooftop;
|
|
52
|
-
}) || addressResults.find(function (elem) {
|
|
53
|
-
return elem.geometry.location_type === _constants.LOCATION_TYPES.rangeInterpolated;
|
|
54
|
-
}) || addressResults.find(function (elem) {
|
|
55
|
-
return elem.geometry.location_type === _constants.LOCATION_TYPES.geometricCenter;
|
|
56
|
-
});
|
|
40
|
+
finalAddress = addressResults.find(elem => elem.geometry.location_type === _constants.LOCATION_TYPES.rooftop) || addressResults.find(elem => elem.geometry.location_type === _constants.LOCATION_TYPES.rangeInterpolated) || addressResults.find(elem => elem.geometry.location_type === _constants.LOCATION_TYPES.geometricCenter);
|
|
57
41
|
} else if (!(0, _array.isEmpty)(results)) {
|
|
58
|
-
finalAddress =
|
|
59
|
-
|
|
60
|
-
|
|
42
|
+
finalAddress = {
|
|
43
|
+
...results[0],
|
|
44
|
+
...(address ? {
|
|
45
|
+
formatted_address: address
|
|
46
|
+
} : {})
|
|
47
|
+
};
|
|
61
48
|
}
|
|
62
49
|
if (finalAddress) onAddressFoundCallback(finalAddress);
|
|
63
50
|
}
|
|
64
51
|
});
|
|
65
52
|
};
|
|
66
53
|
exports.retrieveAddressByCoords = retrieveAddressByCoords;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return attribute.types.includes(component);
|
|
70
|
-
});
|
|
54
|
+
const findAddressComponent = (address, component) => {
|
|
55
|
+
const addrComponent = address.address_components.find(attribute => attribute.types.includes(component));
|
|
71
56
|
return addrComponent && addrComponent.long_name;
|
|
72
57
|
};
|
|
73
58
|
exports.findAddressComponent = findAddressComponent;
|
|
74
|
-
|
|
59
|
+
const getValue = (address, latLng, paramName) => {
|
|
75
60
|
switch (paramName) {
|
|
76
61
|
case _constants.GMAP_PARAMS.latitude:
|
|
77
62
|
return latLng.lat();
|
|
@@ -85,7 +70,5 @@ var getValue = function getValue(address, latLng, paramName) {
|
|
|
85
70
|
};
|
|
86
71
|
// configuration.address_components
|
|
87
72
|
exports.getValue = getValue;
|
|
88
|
-
|
|
89
|
-
return field && field.configuration && field.configuration.address_components && field.configuration.address_components[_constants.GMAP_PARAMS.latitude] && field.configuration.address_components[_constants.GMAP_PARAMS.longitude] && field.configuration.address_components[_constants.GMAP_PARAMS.formattedAddress];
|
|
90
|
-
};
|
|
73
|
+
const isValidConfiguration = field => field && field.configuration && field.configuration.address_components && field.configuration.address_components[_constants.GMAP_PARAMS.latitude] && field.configuration.address_components[_constants.GMAP_PARAMS.longitude] && field.configuration.address_components[_constants.GMAP_PARAMS.formattedAddress];
|
|
91
74
|
exports.isValidConfiguration = isValidConfiguration;
|
|
@@ -7,29 +7,25 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _withScriptjs = _interopRequireDefault(require("react-google-maps/lib/withScriptjs"));
|
|
9
9
|
var _types = require("./types");
|
|
10
|
-
var _excluded = ["apiKey"];
|
|
11
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
11
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}, props));
|
|
29
|
-
};
|
|
30
|
-
WithGoogleMap.propTypes = _types.UTMapPropTypes.propTypes;
|
|
31
|
-
return WithGoogleMap;
|
|
12
|
+
const WithGoogleMapScript = () => WrappedComponent => {
|
|
13
|
+
const Component = (0, _withScriptjs.default)(WrappedComponent);
|
|
14
|
+
const WithGoogleMap = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
apiKey,
|
|
17
|
+
...props
|
|
18
|
+
} = _ref;
|
|
19
|
+
return /*#__PURE__*/_react.default.createElement(Component, _extends({
|
|
20
|
+
googleMapURL: "https://maps.googleapis.com/maps/api/js?libraries=places,geometry&key=".concat(apiKey),
|
|
21
|
+
loadingElement: /*#__PURE__*/_react.default.createElement("div", {
|
|
22
|
+
style: {
|
|
23
|
+
height: "100%"
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
}, props));
|
|
32
27
|
};
|
|
28
|
+
WithGoogleMap.propTypes = _types.UTMapPropTypes.propTypes;
|
|
29
|
+
return WithGoogleMap;
|
|
33
30
|
};
|
|
34
|
-
var _default = WithGoogleMapScript;
|
|
35
|
-
exports.default = _default;
|
|
31
|
+
var _default = exports.default = WithGoogleMapScript;
|