@cashub/ui 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/Tab/Tab.js +9 -13
  2. package/Tab/TabList.js +14 -32
  3. package/Tab/TabPanel.js +21 -58
  4. package/Tab/TabTab.js +20 -40
  5. package/Tab/index.js +2 -10
  6. package/Tab/subComponent/TabContext.js +2 -5
  7. package/animate/Collapse.js +26 -53
  8. package/animate/Loader.js +21 -26
  9. package/animate/NumberCounter.js +22 -44
  10. package/animate/PulseRing.js +9 -21
  11. package/animate/Spinner.js +2 -10
  12. package/animate/index.js +5 -11
  13. package/backdrop/BaseBackdrop.js +2 -9
  14. package/backdrop/LoadingBackdrop.js +2 -9
  15. package/backdrop/ModalBackdrop.js +2 -9
  16. package/backdrop/index.js +3 -7
  17. package/badge/Badge.js +2 -11
  18. package/badge/BadgeDot.js +2 -10
  19. package/badge/BadgeFill.js +15 -20
  20. package/badge/BadgeWithText.js +6 -13
  21. package/badge/index.js +4 -9
  22. package/billing/BarChart.js +10 -17
  23. package/billing/Grid.js +11 -15
  24. package/billing/Header2.js +6 -9
  25. package/billing/Header3.js +9 -16
  26. package/billing/Paragraph.js +8 -14
  27. package/billing/ParagraphGroup.js +6 -9
  28. package/billing/ParagraphText.js +7 -12
  29. package/billing/Section.js +13 -23
  30. package/billing/SectionBody.js +5 -8
  31. package/billing/SectionHeader.js +7 -12
  32. package/breadcrumb/Breadcrumb.js +11 -21
  33. package/breadcrumb/index.js +1 -3
  34. package/button/Button.js +41 -38
  35. package/button/ButtonGroup.js +21 -18
  36. package/button/IconButton.js +29 -29
  37. package/button/ScrollToTopButton.js +12 -39
  38. package/button/index.js +4 -9
  39. package/callout/Callout.js +13 -26
  40. package/callout/index.js +1 -3
  41. package/chart/BarChart.js +28 -53
  42. package/chart/DoughnutChart.js +23 -62
  43. package/chart/LineChart.js +33 -55
  44. package/chart/SingleBarChart.js +11 -17
  45. package/chart/index.js +5 -12
  46. package/chart/utils/customTooltip.js +26 -43
  47. package/chart/utils/htmlLegendPlugin.js +24 -30
  48. package/chart/utils/index.js +3 -7
  49. package/chart/utils/padEmptyChartBar.js +24 -22
  50. package/container/FlexContainer.js +14 -12
  51. package/container/index.js +1 -3
  52. package/cropper/Cropper.js +21 -34
  53. package/cropper/CropperModalHandler.js +15 -21
  54. package/cropper/index.js +2 -5
  55. package/cropper/subComponent/CropImageModal.js +23 -58
  56. package/datetimePicker/DatePicker.js +103 -217
  57. package/datetimePicker/DatePickerV2.js +116 -221
  58. package/datetimePicker/DatetimePicker.js +27 -48
  59. package/datetimePicker/DatetimePickerV2.js +115 -231
  60. package/datetimePicker/TimeInput.js +9 -22
  61. package/datetimePicker/TimePicker.js +94 -151
  62. package/datetimePicker/TimePickerStyle.js +2 -9
  63. package/datetimePicker/accordion/Month.js +70 -90
  64. package/datetimePicker/accordion/Year.js +91 -135
  65. package/datetimePicker/hooks/index.js +3 -7
  66. package/datetimePicker/hooks/useChangeNumber.js +14 -27
  67. package/datetimePicker/hooks/useDecrease.js +19 -35
  68. package/datetimePicker/hooks/useIncrease.js +19 -35
  69. package/datetimePicker/index.js +7 -15
  70. package/datetimePicker/provider/constant.js +2 -3
  71. package/datetimePicker/subComponent/Accordion.js +108 -158
  72. package/datetimePicker/subComponent/CustomTimeInput.js +18 -48
  73. package/datetimePicker/subComponent/DateTimePickerContext.js +2 -5
  74. package/datetimePicker/utils/GMTDate.js +3 -7
  75. package/datetimePicker/utils/pad.js +2 -6
  76. package/datetimePicker/utils/toUTC0.js +3 -6
  77. package/descriptionList/DescriptionDetail.js +5 -10
  78. package/descriptionList/DescriptionList.js +5 -10
  79. package/descriptionList/DescriptionTerm.js +2 -9
  80. package/descriptionList/index.js +3 -7
  81. package/divider/Divider.js +9 -12
  82. package/divider/index.js +1 -3
  83. package/dropdown/Dropdown.js +28 -65
  84. package/dropdown/DropdownButtonOption.js +2 -9
  85. package/dropdown/DropdownContent.js +33 -64
  86. package/dropdown/DropdownDivOption.js +2 -9
  87. package/dropdown/DropdownItem.js +10 -16
  88. package/dropdown/DropdownLinkOption.js +2 -9
  89. package/dropdown/DropdownToggle.js +18 -38
  90. package/dropdown/index.js +6 -17
  91. package/dropdown/subComponent/DropdownContext.js +2 -5
  92. package/dropzone/FileDropzone.js +148 -302
  93. package/dropzone/ImageDropzone.js +96 -171
  94. package/dropzone/index.js +2 -5
  95. package/dropzone/subComponent/Message.js +7 -14
  96. package/figure/IconFigure.js +9 -16
  97. package/figure/ImageFigure.js +11 -17
  98. package/figure/index.js +2 -5
  99. package/file/HiddenFileInput.js +5 -14
  100. package/file/index.js +1 -3
  101. package/form/Checkbox.js +34 -43
  102. package/form/FormItem.js +2 -9
  103. package/form/Input.js +18 -15
  104. package/form/Label.js +20 -13
  105. package/form/MutedText.js +5 -10
  106. package/form/RadioButton.js +20 -32
  107. package/form/Searchbox.js +21 -65
  108. package/form/Slider.js +25 -0
  109. package/form/SwitchButton.js +34 -39
  110. package/form/Textarea.js +2 -11
  111. package/form/TreeView.js +64 -0
  112. package/form/index.js +16 -19
  113. package/grid/Column.js +17 -17
  114. package/grid/Grid.js +13 -14
  115. package/grid/index.js +2 -5
  116. package/heading/Heading1.js +5 -10
  117. package/heading/Heading2.js +9 -12
  118. package/heading/Heading3.js +21 -18
  119. package/heading/index.js +3 -7
  120. package/helmet/Helmet.js +6 -9
  121. package/helmet/index.js +2 -5
  122. package/iconbox/ApplicationIconBox.js +25 -31
  123. package/iconbox/IconBox.js +11 -24
  124. package/iconbox/IconBoxV2.js +14 -26
  125. package/iconbox/index.js +3 -7
  126. package/iconbox/subComponent/IconBoxFigure.js +25 -20
  127. package/iconbox/subComponent/IconBoxImage.js +15 -18
  128. package/image/ImageFluid.js +2 -10
  129. package/image/UploadImage.js +65 -113
  130. package/image/index.js +2 -5
  131. package/index.js +44 -130
  132. package/jsoneditor/JsonEditor.js +10 -32
  133. package/jsoneditor/index.js +1 -3
  134. package/keyframe/Pulse.js +2 -7
  135. package/keyframe/Spin.js +2 -7
  136. package/link/LinkSpan.js +22 -35
  137. package/link/index.js +1 -3
  138. package/map/GoogleMap.js +122 -175
  139. package/map/GoogleReverseGeolocation.js +79 -186
  140. package/map/LeafletMap.js +78 -132
  141. package/map/LeafletReverseGeolocation.js +49 -121
  142. package/map/index.js +4 -9
  143. package/map/subComponent/BasicLeafletMap.js +8 -14
  144. package/map/subComponent/GoogleMapContainer.js +5 -10
  145. package/map/subComponent/GoogleMapPopup.js +66 -123
  146. package/map/subComponent/GoogleMapWrapper.js +13 -32
  147. package/map/subComponent/GoogleMarkerSpiderfier.js +14 -24
  148. package/map/subComponent/LeafletDrawControl.js +47 -84
  149. package/map/subComponent/LeafletMapContainer.js +5 -10
  150. package/map/subComponent/MapSearchBoxControl.js +24 -70
  151. package/modal/StateModal.js +41 -100
  152. package/modal/TitleModal.js +89 -190
  153. package/modal/index.js +2 -5
  154. package/package.json +1 -1
  155. package/paginate/Paginate.js +40 -54
  156. package/paginate/index.js +1 -3
  157. package/popover/Popover.js +39 -87
  158. package/popover/index.js +1 -3
  159. package/qrcode/QRCode.js +10 -23
  160. package/qrcode/QRCodeContainter.js +8 -16
  161. package/qrcode/index.js +2 -5
  162. package/ribbon/Ribbon.js +4 -15
  163. package/ribbon/index.js +1 -3
  164. package/section/Section.js +57 -39
  165. package/section/SectionBody.js +15 -22
  166. package/section/SectionHeader.js +27 -27
  167. package/section/SectionToolbar.js +2 -9
  168. package/section/SectionToolbarItem.js +2 -9
  169. package/section/index.js +5 -11
  170. package/select/InputSelect.js +103 -215
  171. package/select/Select.js +204 -362
  172. package/select/index.js +2 -5
  173. package/select/subComponent/ListBox.js +9 -12
  174. package/select/subComponent/Option.js +8 -16
  175. package/select/subComponent/OptionGroup.js +2 -9
  176. package/select/subComponent/Options.js +5 -11
  177. package/select/subComponent/SearchBox.js +9 -29
  178. package/select/subComponent/SelectedMultiple.js +8 -16
  179. package/select/subComponent/SelectedSingle.js +2 -9
  180. package/styles/GlobalStyle.js +169 -91
  181. package/styles/config/breakpoint.style.js +2 -3
  182. package/styles/config/header.style.js +2 -3
  183. package/styles/config/sidebar.style.js +2 -3
  184. package/styles/index.js +2 -5
  185. package/styles/mixin/backgroundColor.js +17 -14
  186. package/styles/mixin/borderColor.js +17 -14
  187. package/styles/mixin/color.js +17 -14
  188. package/styles/mixin/colorOnBackground.js +17 -14
  189. package/styles/mixin/inputPlaceholder.js +3 -9
  190. package/styles/mixin/media.js +3 -11
  191. package/styles/mixin/rounded.js +13 -12
  192. package/styles/mixin/scrollbar.js +7 -13
  193. package/styles/theme/dark.theme.js +20 -20
  194. package/styles/theme/light.theme.js +20 -20
  195. package/styles/theme/white.theme.js +20 -20
  196. package/styles/themes.js +2 -8
  197. package/table/GridTable.js +105 -143
  198. package/table/ImageBox.js +8 -18
  199. package/table/PermissionTable.js +25 -25
  200. package/table/Table.js +137 -153
  201. package/table/__mock__/columns.js +2 -3
  202. package/table/__mock__/data.js +2 -3
  203. package/table/hooks/index.js +2 -5
  204. package/table/hooks/useCalculateDataRange.js +9 -36
  205. package/table/hooks/useGenerateSort.js +6 -17
  206. package/table/index.js +4 -9
  207. package/table/subComponent/BaseTableHeadCell.js +15 -21
  208. package/table/subComponent/GridTableFooter.js +5 -10
  209. package/table/subComponent/GridTableHeadCell.js +5 -10
  210. package/table/subComponent/Resizer.js +17 -44
  211. package/table/subComponent/TableFooter.js +5 -10
  212. package/table/subComponent/TableFooterInfo.js +2 -9
  213. package/table/subComponent/TableFooterPager.js +5 -12
  214. package/table/subComponent/TableHeadCell.js +2 -9
  215. package/table/subComponent/TableSort.js +13 -19
  216. package/tagify/TagifyStyle.js +2 -9
  217. package/tagify/Tags.js +15 -37
  218. package/tagify/index.js +2 -5
  219. package/text/Paragraph.js +25 -20
  220. package/text/index.js +1 -3
  221. package/timeline/Timeline.js +28 -37
  222. package/timeline/index.js +1 -3
  223. package/toast/CustomToastContainer.js +2 -9
  224. package/toast/MessageContainer.js +9 -18
  225. package/toast/index.js +3 -8
  226. package/toast/show.js +18 -28
  227. package/tooltip/Tooltip.js +48 -97
  228. package/tooltip/index.js +1 -3
  229. package/wizard/Wizard.js +63 -133
  230. package/wizard/index.js +1 -3
package/map/GoogleMap.js CHANGED
@@ -4,118 +4,72 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _react = require("react");
9
-
10
8
  var _server = require("react-dom/server");
11
-
12
9
  var _markerclusterer = require("@googlemaps/markerclusterer");
13
-
14
10
  var _GoogleMapWrapper = _interopRequireDefault(require("./subComponent/GoogleMapWrapper"));
15
-
16
11
  var _GoogleMapContainer = _interopRequireDefault(require("./subComponent/GoogleMapContainer"));
17
-
18
12
  var _GoogleMapPopup = _interopRequireDefault(require("./subComponent/GoogleMapPopup"));
19
-
20
13
  var _GoogleMarkerSpiderfier = _interopRequireDefault(require("./subComponent/GoogleMarkerSpiderfier"));
21
-
22
14
  var _map_icon = _interopRequireDefault(require("../assets/icons/map_icon1.png"));
23
-
24
15
  var _map_icon2 = _interopRequireDefault(require("../assets/icons/map_icon4.png"));
25
-
26
16
  var _jsxRuntime = require("react/jsx-runtime");
27
-
28
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
-
30
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
31
-
32
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
33
-
34
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
35
-
36
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
37
-
38
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
39
-
40
- 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); }
41
-
42
- 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; }
43
-
44
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
45
-
46
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
47
-
48
- var GoogleMap = function GoogleMap(_ref) {
49
- var apiKey = _ref.apiKey,
50
- _ref$height = _ref.height,
51
- height = _ref$height === void 0 ? 512 : _ref$height,
52
- _ref$zoom = _ref.zoom,
53
- zoom = _ref$zoom === void 0 ? 10 : _ref$zoom,
54
- _ref$data = _ref.data,
55
- data = _ref$data === void 0 ? {
56
- defaultPosition: null,
57
- position: null,
58
- locations: []
59
- } : _ref$data,
60
- _ref$geoFence = _ref.geoFence,
61
- geoFence = _ref$geoFence === void 0 ? false : _ref$geoFence,
62
- _ref$geoFenceOptions = _ref.geoFenceOptions,
63
- geoFenceOptions = _ref$geoFenceOptions === void 0 ? {} : _ref$geoFenceOptions,
64
- onError = _ref.onError,
65
- customPopup = _ref.customPopup,
66
- checkPrimaryLocation = _ref.checkPrimaryLocation;
67
-
68
- var _useState = (0, _react.useState)(true),
69
- _useState2 = _slicedToArray(_useState, 2),
70
- hasError = _useState2[0],
71
- setHasError = _useState2[1];
72
-
73
- var _useState3 = (0, _react.useState)([]),
74
- _useState4 = _slicedToArray(_useState3, 2),
75
- validLocations = _useState4[0],
76
- setValidLocations = _useState4[1];
77
-
78
- var _useState5 = (0, _react.useState)([]),
79
- _useState6 = _slicedToArray(_useState5, 2),
80
- validBounds = _useState6[0],
81
- setValidBounds = _useState6[1];
82
-
83
- var handleError = (0, _react.useCallback)(function (errorCode) {
18
+ const GoogleMap = _ref => {
19
+ let {
20
+ apiKey,
21
+ height = 512,
22
+ zoom = 10,
23
+ data = {
24
+ defaultPosition: null,
25
+ position: null,
26
+ locations: []
27
+ },
28
+ geoFence = false,
29
+ geoFenceOptions = {},
30
+ onError,
31
+ customPopup,
32
+ checkPrimaryLocation
33
+ } = _ref;
34
+ const [hasError, setHasError] = (0, _react.useState)(true);
35
+ const [validLocations, setValidLocations] = (0, _react.useState)([]);
36
+ const [validBounds, setValidBounds] = (0, _react.useState)([]);
37
+ const handleError = (0, _react.useCallback)(errorCode => {
84
38
  if (onError) {
85
39
  onError(errorCode);
86
40
  }
87
41
  }, [onError]);
88
- (0, _react.useEffect)(function () {
89
- var defaultPosition = data.defaultPosition,
90
- position = data.position,
91
- locations = data.locations;
92
- var validLocations = [];
93
- var bounds = [];
94
-
42
+ (0, _react.useEffect)(() => {
43
+ const {
44
+ defaultPosition,
45
+ position,
46
+ locations
47
+ } = data;
48
+ const validLocations = [];
49
+ const bounds = [];
95
50
  if (!position && !defaultPosition) {
96
51
  handleError('NO_COORDINATES');
97
52
  setHasError(true);
98
53
  return;
99
54
  }
100
-
101
- locations.forEach(function (location) {
102
- var latitude = location.latitude,
103
- longitude = location.longitude;
104
-
55
+ locations.forEach(location => {
56
+ let {
57
+ latitude,
58
+ longitude
59
+ } = location;
105
60
  if (!latitude && latitude !== 0 || !longitude && longitude !== 0 || latitude === 0 && longitude === 0 || latitude === '0' && longitude === '0') {
106
61
  return;
107
- } // make sure coordinate in number type
108
-
62
+ }
109
63
 
64
+ // make sure coordinate in number type
110
65
  latitude = Number(latitude);
111
66
  longitude = Number(longitude);
112
-
113
67
  if (Number.isNaN(latitude) || Number.isNaN(longitude)) {
114
68
  return;
115
- } // prevent duplicate LatLngBounds
116
-
69
+ }
117
70
 
118
- if (!bounds.some(function (LatLng) {
71
+ // prevent duplicate LatLngBounds
72
+ if (!bounds.some(LatLng => {
119
73
  return latitude === LatLng.lat && longitude === LatLng.lng;
120
74
  })) {
121
75
  bounds.push({
@@ -123,18 +77,18 @@ var GoogleMap = function GoogleMap(_ref) {
123
77
  lng: longitude
124
78
  });
125
79
  }
80
+ validLocations.push({
81
+ ...location,
82
+ latitude,
83
+ longitude
84
+ });
85
+ });
126
86
 
127
- validLocations.push(_objectSpread(_objectSpread({}, location), {}, {
128
- latitude: latitude,
129
- longitude: longitude
130
- }));
131
- }); // pass all checking
132
-
87
+ // pass all checking
133
88
  setHasError(false);
134
89
  setValidLocations(validLocations);
135
90
  setValidBounds(bounds);
136
91
  }, [data, handleError]);
137
-
138
92
  if (!hasError) {
139
93
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GoogleMapWrapper.default, {
140
94
  apiKey: apiKey,
@@ -152,31 +106,26 @@ var GoogleMap = function GoogleMap(_ref) {
152
106
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Map, {})
153
107
  });
154
108
  }
155
-
156
109
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
157
110
  };
158
-
159
- var Map = function Map(_ref2) {
160
- var height = _ref2.height,
161
- zoom = _ref2.zoom,
162
- defaultPosition = _ref2.defaultPosition,
163
- position = _ref2.position,
164
- locations = _ref2.locations,
165
- bounds = _ref2.bounds,
166
- geoFence = _ref2.geoFence,
167
- geoFenceOptions = _ref2.geoFenceOptions,
168
- customPopup = _ref2.customPopup,
169
- checkPrimaryLocation = _ref2.checkPrimaryLocation;
170
- var ref = (0, _react.useRef)(null);
171
-
172
- var _useState7 = (0, _react.useState)(),
173
- _useState8 = _slicedToArray(_useState7, 2),
174
- map = _useState8[0],
175
- setMap = _useState8[1];
176
-
177
- var options = (0, _react.useMemo)(function () {
111
+ const Map = _ref2 => {
112
+ let {
113
+ height,
114
+ zoom,
115
+ defaultPosition,
116
+ position,
117
+ locations,
118
+ bounds,
119
+ geoFence,
120
+ geoFenceOptions,
121
+ customPopup,
122
+ checkPrimaryLocation
123
+ } = _ref2;
124
+ const ref = (0, _react.useRef)(null);
125
+ const [map, setMap] = (0, _react.useState)();
126
+ const options = (0, _react.useMemo)(() => {
178
127
  return {
179
- zoom: zoom,
128
+ zoom,
180
129
  center: {
181
130
  lat: 1,
182
131
  lng: 1
@@ -203,29 +152,31 @@ var Map = function Map(_ref2) {
203
152
  strictBounds: true
204
153
  }
205
154
  };
206
- }, [zoom]); // setup map
155
+ }, [zoom]);
207
156
 
208
- (0, _react.useEffect)(function () {
157
+ // setup map
158
+ (0, _react.useEffect)(() => {
209
159
  if (map) {
210
160
  map.setOptions(options);
211
- window.google.maps.event.addListenerOnce(map, 'idle', function () {
161
+ window.google.maps.event.addListenerOnce(map, 'idle', () => {
212
162
  if (bounds.length === 1) {
213
163
  // there is only one location, locate it
214
164
  map.setCenter(bounds[0]);
215
165
  } else if (locations.length > 0) {
216
166
  // locate to the center of all coordinates on first load
217
- var latLngBounds = new window.google.maps.LatLngBounds();
218
- bounds.forEach(function (bound) {
167
+ const latLngBounds = new window.google.maps.LatLngBounds();
168
+ bounds.forEach(bound => {
219
169
  latLngBounds.extend(bound);
220
170
  });
221
171
  map.fitBounds(latLngBounds);
222
- var found = locations.find(function (location) {
172
+ const found = locations.find(location => {
223
173
  return latLngBounds.contains({
224
174
  lat: location.latitude,
225
175
  lng: location.longitude
226
176
  });
227
- }); // if center no contain any marker then locate to first location
177
+ });
228
178
 
179
+ // if center no contain any marker then locate to first location
229
180
  if (!found) {
230
181
  map.setCenter(bounds[0]);
231
182
  }
@@ -236,33 +187,36 @@ var Map = function Map(_ref2) {
236
187
  });
237
188
  }
238
189
  });
239
- return function () {
190
+ return () => {
240
191
  window.google.maps.event.clearListeners(map, 'click');
241
192
  };
242
193
  }
243
- }, [map, options, locations, bounds, defaultPosition, position]); // render marker cluster
194
+ }, [map, options, locations, bounds, defaultPosition, position]);
244
195
 
245
- (0, _react.useEffect)(function () {
196
+ // render marker cluster
197
+ (0, _react.useEffect)(() => {
246
198
  if (map && locations.length > 0) {
247
- var markers = []; // set up popup
199
+ const markers = [];
248
200
 
249
- var popup = new _GoogleMapPopup.default({
201
+ // set up popup
202
+ const popup = new _GoogleMapPopup.default({
250
203
  maxWidth: 400,
251
204
  offset: 36
252
205
  });
253
- map.addListener('click', function () {
206
+ map.addListener('click', () => {
254
207
  popup.setMap(null);
255
208
  });
256
- var oms = new _GoogleMarkerSpiderfier.default(map, {
209
+ const oms = new _GoogleMarkerSpiderfier.default(map, {
257
210
  markersWontMove: true,
258
211
  markersWontHide: true,
259
212
  basicFormatEvents: true
260
213
  });
261
- locations.forEach(function (location) {
262
- var latitude = location.latitude,
263
- longitude = location.longitude;
264
- var icon;
265
-
214
+ locations.forEach(location => {
215
+ const {
216
+ latitude,
217
+ longitude
218
+ } = location;
219
+ let icon;
266
220
  if (checkPrimaryLocation && checkPrimaryLocation(location)) {
267
221
  icon = {
268
222
  url: _map_icon.default,
@@ -274,20 +228,18 @@ var Map = function Map(_ref2) {
274
228
  scaledSize: new window.google.maps.Size(40, 50)
275
229
  };
276
230
  }
277
-
278
- var marker = new window.google.maps.Marker({
279
- icon: icon,
280
- map: map,
231
+ const marker = new window.google.maps.Marker({
232
+ icon,
233
+ map,
281
234
  position: {
282
235
  lat: latitude,
283
236
  lng: longitude
284
237
  }
285
238
  });
286
-
287
239
  if (customPopup) {
288
- marker.addListener('click', function (event) {
240
+ marker.addListener('click', event => {
289
241
  event.stop();
290
- var coordinate = {
242
+ const coordinate = {
291
243
  lat: latitude,
292
244
  lng: longitude
293
245
  };
@@ -297,17 +249,16 @@ var Map = function Map(_ref2) {
297
249
  popup.draw();
298
250
  });
299
251
  }
300
-
301
252
  markers.push(marker);
302
253
  oms.addMarker(marker);
303
254
  });
304
- var markerClusterer = new _markerclusterer.MarkerClusterer({
305
- map: map,
306
- markers: markers,
255
+ const markerClusterer = new _markerclusterer.MarkerClusterer({
256
+ map,
257
+ markers,
307
258
  algorithm: new _markerclusterer.SuperClusterAlgorithm({
308
259
  radius: 120
309
260
  }),
310
- onClusterClick: function onClusterClick(event, cluster, map) {
261
+ onClusterClick: (event, cluster, map) => {
311
262
  // fix: cluster marker spiderfier
312
263
  // const targetPosition = cluster.markers[0].getPosition().toJSON();
313
264
  // const isAllSamePosition = cluster.markers.every((marker) => {
@@ -320,33 +271,35 @@ var Map = function Map(_ref2) {
320
271
  // if (isAllSamePosition) {
321
272
  // return;
322
273
  // }
274
+
323
275
  // fix: need to call twice to actually work
324
276
  map.fitBounds(cluster.bounds);
325
- map.fitBounds(cluster.bounds); // check current view has marker, if not set view to first marker
277
+ map.fitBounds(cluster.bounds);
326
278
 
327
- var currentBounds = map.getBounds();
328
- var found = cluster.markers.find(function (marker) {
279
+ // check current view has marker, if not set view to first marker
280
+ const currentBounds = map.getBounds();
281
+ const found = cluster.markers.find(marker => {
329
282
  return currentBounds.contains(marker.getPosition());
330
283
  });
331
-
332
284
  if (!found) {
333
285
  map.setCenter(cluster.markers[0].getPosition());
334
286
  }
335
287
  }
336
288
  });
337
- return function () {
289
+ return () => {
338
290
  popup.setMap(null);
339
291
  markerClusterer.setMap(null);
340
- markers.forEach(function (marker) {
292
+ markers.forEach(marker => {
341
293
  marker.setMap(null);
342
294
  });
343
295
  };
344
296
  }
345
- }, [map, locations, checkPrimaryLocation, customPopup]); // geofencing
297
+ }, [map, locations, checkPrimaryLocation, customPopup]);
346
298
 
347
- (0, _react.useEffect)(function () {
299
+ // geofencing
300
+ (0, _react.useEffect)(() => {
348
301
  if (map && geoFence) {
349
- var circle = new window.google.maps.Circle({
302
+ const circle = new window.google.maps.Circle({
350
303
  strokeColor: '#597EF7',
351
304
  strokeOpacity: 0,
352
305
  strokeWeight: 0,
@@ -360,39 +313,35 @@ var Map = function Map(_ref2) {
360
313
  editable: geoFenceOptions.editable,
361
314
  draggable: geoFenceOptions.editable
362
315
  });
363
- circle.setMap(map); // add event listener
316
+ circle.setMap(map);
364
317
 
318
+ // add event listener
365
319
  if (geoFenceOptions.eventHandlers) {
366
- var _geoFenceOptions$even = geoFenceOptions.eventHandlers,
367
- click = _geoFenceOptions$even.click,
368
- edit = _geoFenceOptions$even.edit,
369
- drag = _geoFenceOptions$even.drag;
370
-
320
+ const {
321
+ click,
322
+ edit,
323
+ drag
324
+ } = geoFenceOptions.eventHandlers;
371
325
  if (click) {
372
326
  window.google.maps.event.addListener(circle, 'click', click);
373
327
  }
374
-
375
328
  if (edit) {
376
- circle.addListener('radius_changed', function () {
377
- var radius = circle.getRadius();
378
-
329
+ circle.addListener('radius_changed', () => {
330
+ const radius = circle.getRadius();
379
331
  if (geoFenceOptions.minRadius && radius < geoFenceOptions.minRadius) {
380
332
  circle.setRadius(geoFenceOptions.minRadius);
381
333
  return;
382
334
  }
383
-
384
335
  edit(circle.getRadius());
385
336
  });
386
337
  }
387
-
388
338
  if (drag) {
389
- circle.addListener('center_changed', function () {
339
+ circle.addListener('center_changed', () => {
390
340
  drag(circle.getCenter().toJSON());
391
341
  });
392
342
  }
393
343
  }
394
-
395
- return function () {
344
+ return () => {
396
345
  circle.setMap(null);
397
346
  window.google.maps.event.clearListeners(circle, 'click');
398
347
  window.google.maps.event.clearListeners(circle, 'radius_changed');
@@ -400,7 +349,7 @@ var Map = function Map(_ref2) {
400
349
  };
401
350
  }
402
351
  }, [map, geoFence, geoFenceOptions.latitude, geoFenceOptions.longitude, geoFenceOptions.radius, geoFenceOptions.minRadius, geoFenceOptions.editable, geoFenceOptions.eventHandlers]);
403
- (0, _react.useEffect)(function () {
352
+ (0, _react.useEffect)(() => {
404
353
  if (ref.current && !map) {
405
354
  setMap(new window.google.maps.Map(ref.current, {}));
406
355
  }
@@ -409,21 +358,19 @@ var Map = function Map(_ref2) {
409
358
  ref: ref,
410
359
  height: height,
411
360
  tabIndex: "0",
412
- onClick: function onClick(event) {
361
+ onClick: event => {
413
362
  event.target.focus();
414
363
  },
415
- onFocus: function onFocus() {
364
+ onFocus: () => {
416
365
  map.setOptions({
417
366
  scrollwheel: true
418
367
  });
419
368
  },
420
- onBlur: function onBlur() {
369
+ onBlur: () => {
421
370
  map.setOptions({
422
371
  scrollwheel: false
423
372
  });
424
373
  }
425
374
  });
426
375
  };
427
-
428
- var _default = GoogleMap;
429
- exports.default = _default;
376
+ var _default = exports.default = GoogleMap;