@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.
- package/Tab/Tab.js +9 -13
- package/Tab/TabList.js +14 -32
- package/Tab/TabPanel.js +21 -58
- package/Tab/TabTab.js +20 -40
- package/Tab/index.js +2 -10
- package/Tab/subComponent/TabContext.js +2 -5
- package/animate/Collapse.js +26 -53
- package/animate/Loader.js +21 -26
- package/animate/NumberCounter.js +22 -44
- package/animate/PulseRing.js +9 -21
- package/animate/Spinner.js +2 -10
- package/animate/index.js +5 -11
- package/backdrop/BaseBackdrop.js +2 -9
- package/backdrop/LoadingBackdrop.js +2 -9
- package/backdrop/ModalBackdrop.js +2 -9
- package/backdrop/index.js +3 -7
- package/badge/Badge.js +2 -11
- package/badge/BadgeDot.js +2 -10
- package/badge/BadgeFill.js +15 -20
- package/badge/BadgeWithText.js +6 -13
- package/badge/index.js +4 -9
- package/billing/BarChart.js +10 -17
- package/billing/Grid.js +11 -15
- package/billing/Header2.js +6 -9
- package/billing/Header3.js +9 -16
- package/billing/Paragraph.js +8 -14
- package/billing/ParagraphGroup.js +6 -9
- package/billing/ParagraphText.js +7 -12
- package/billing/Section.js +13 -23
- package/billing/SectionBody.js +5 -8
- package/billing/SectionHeader.js +7 -12
- package/breadcrumb/Breadcrumb.js +11 -21
- package/breadcrumb/index.js +1 -3
- package/button/Button.js +41 -38
- package/button/ButtonGroup.js +21 -18
- package/button/IconButton.js +29 -29
- package/button/ScrollToTopButton.js +12 -39
- package/button/index.js +4 -9
- package/callout/Callout.js +13 -26
- package/callout/index.js +1 -3
- package/chart/BarChart.js +28 -53
- package/chart/DoughnutChart.js +23 -62
- package/chart/LineChart.js +33 -55
- package/chart/SingleBarChart.js +11 -17
- package/chart/index.js +5 -12
- package/chart/utils/customTooltip.js +26 -43
- package/chart/utils/htmlLegendPlugin.js +24 -30
- package/chart/utils/index.js +3 -7
- package/chart/utils/padEmptyChartBar.js +24 -22
- package/container/FlexContainer.js +14 -12
- package/container/index.js +1 -3
- package/cropper/Cropper.js +21 -34
- package/cropper/CropperModalHandler.js +15 -21
- package/cropper/index.js +2 -5
- package/cropper/subComponent/CropImageModal.js +23 -58
- package/datetimePicker/DatePicker.js +103 -217
- package/datetimePicker/DatePickerV2.js +116 -221
- package/datetimePicker/DatetimePicker.js +27 -48
- package/datetimePicker/DatetimePickerV2.js +115 -231
- package/datetimePicker/TimeInput.js +9 -22
- package/datetimePicker/TimePicker.js +94 -151
- package/datetimePicker/TimePickerStyle.js +2 -9
- package/datetimePicker/accordion/Month.js +70 -90
- package/datetimePicker/accordion/Year.js +91 -135
- package/datetimePicker/hooks/index.js +3 -7
- package/datetimePicker/hooks/useChangeNumber.js +14 -27
- package/datetimePicker/hooks/useDecrease.js +19 -35
- package/datetimePicker/hooks/useIncrease.js +19 -35
- package/datetimePicker/index.js +7 -15
- package/datetimePicker/provider/constant.js +2 -3
- package/datetimePicker/subComponent/Accordion.js +108 -158
- package/datetimePicker/subComponent/CustomTimeInput.js +18 -48
- package/datetimePicker/subComponent/DateTimePickerContext.js +2 -5
- package/datetimePicker/utils/GMTDate.js +3 -7
- package/datetimePicker/utils/pad.js +2 -6
- package/datetimePicker/utils/toUTC0.js +3 -6
- package/descriptionList/DescriptionDetail.js +5 -10
- package/descriptionList/DescriptionList.js +5 -10
- package/descriptionList/DescriptionTerm.js +2 -9
- package/descriptionList/index.js +3 -7
- package/divider/Divider.js +9 -12
- package/divider/index.js +1 -3
- package/dropdown/Dropdown.js +28 -65
- package/dropdown/DropdownButtonOption.js +2 -9
- package/dropdown/DropdownContent.js +33 -64
- package/dropdown/DropdownDivOption.js +2 -9
- package/dropdown/DropdownItem.js +10 -16
- package/dropdown/DropdownLinkOption.js +2 -9
- package/dropdown/DropdownToggle.js +18 -38
- package/dropdown/index.js +6 -17
- package/dropdown/subComponent/DropdownContext.js +2 -5
- package/dropzone/FileDropzone.js +148 -302
- package/dropzone/ImageDropzone.js +96 -171
- package/dropzone/index.js +2 -5
- package/dropzone/subComponent/Message.js +7 -14
- package/figure/IconFigure.js +9 -16
- package/figure/ImageFigure.js +11 -17
- package/figure/index.js +2 -5
- package/file/HiddenFileInput.js +5 -14
- package/file/index.js +1 -3
- package/form/Checkbox.js +34 -43
- package/form/FormItem.js +2 -9
- package/form/Input.js +18 -15
- package/form/Label.js +20 -13
- package/form/MutedText.js +5 -10
- package/form/RadioButton.js +20 -32
- package/form/Searchbox.js +21 -65
- package/form/Slider.js +25 -0
- package/form/SwitchButton.js +34 -39
- package/form/Textarea.js +2 -11
- package/form/TreeView.js +64 -0
- package/form/index.js +16 -19
- package/grid/Column.js +17 -17
- package/grid/Grid.js +13 -14
- package/grid/index.js +2 -5
- package/heading/Heading1.js +5 -10
- package/heading/Heading2.js +9 -12
- package/heading/Heading3.js +21 -18
- package/heading/index.js +3 -7
- package/helmet/Helmet.js +6 -9
- package/helmet/index.js +2 -5
- package/iconbox/ApplicationIconBox.js +25 -31
- package/iconbox/IconBox.js +11 -24
- package/iconbox/IconBoxV2.js +14 -26
- package/iconbox/index.js +3 -7
- package/iconbox/subComponent/IconBoxFigure.js +25 -20
- package/iconbox/subComponent/IconBoxImage.js +15 -18
- package/image/ImageFluid.js +2 -10
- package/image/UploadImage.js +65 -113
- package/image/index.js +2 -5
- package/index.js +44 -130
- package/jsoneditor/JsonEditor.js +10 -32
- package/jsoneditor/index.js +1 -3
- package/keyframe/Pulse.js +2 -7
- package/keyframe/Spin.js +2 -7
- package/link/LinkSpan.js +22 -35
- package/link/index.js +1 -3
- package/map/GoogleMap.js +122 -175
- package/map/GoogleReverseGeolocation.js +79 -186
- package/map/LeafletMap.js +78 -132
- package/map/LeafletReverseGeolocation.js +49 -121
- package/map/index.js +4 -9
- package/map/subComponent/BasicLeafletMap.js +8 -14
- package/map/subComponent/GoogleMapContainer.js +5 -10
- package/map/subComponent/GoogleMapPopup.js +66 -123
- package/map/subComponent/GoogleMapWrapper.js +13 -32
- package/map/subComponent/GoogleMarkerSpiderfier.js +14 -24
- package/map/subComponent/LeafletDrawControl.js +47 -84
- package/map/subComponent/LeafletMapContainer.js +5 -10
- package/map/subComponent/MapSearchBoxControl.js +24 -70
- package/modal/StateModal.js +41 -100
- package/modal/TitleModal.js +89 -190
- package/modal/index.js +2 -5
- package/package.json +1 -1
- package/paginate/Paginate.js +40 -54
- package/paginate/index.js +1 -3
- package/popover/Popover.js +39 -87
- package/popover/index.js +1 -3
- package/qrcode/QRCode.js +10 -23
- package/qrcode/QRCodeContainter.js +8 -16
- package/qrcode/index.js +2 -5
- package/ribbon/Ribbon.js +4 -15
- package/ribbon/index.js +1 -3
- package/section/Section.js +57 -39
- package/section/SectionBody.js +15 -22
- package/section/SectionHeader.js +27 -27
- package/section/SectionToolbar.js +2 -9
- package/section/SectionToolbarItem.js +2 -9
- package/section/index.js +5 -11
- package/select/InputSelect.js +103 -215
- package/select/Select.js +204 -362
- package/select/index.js +2 -5
- package/select/subComponent/ListBox.js +9 -12
- package/select/subComponent/Option.js +8 -16
- package/select/subComponent/OptionGroup.js +2 -9
- package/select/subComponent/Options.js +5 -11
- package/select/subComponent/SearchBox.js +9 -29
- package/select/subComponent/SelectedMultiple.js +8 -16
- package/select/subComponent/SelectedSingle.js +2 -9
- package/styles/GlobalStyle.js +169 -91
- package/styles/config/breakpoint.style.js +2 -3
- package/styles/config/header.style.js +2 -3
- package/styles/config/sidebar.style.js +2 -3
- package/styles/index.js +2 -5
- package/styles/mixin/backgroundColor.js +17 -14
- package/styles/mixin/borderColor.js +17 -14
- package/styles/mixin/color.js +17 -14
- package/styles/mixin/colorOnBackground.js +17 -14
- package/styles/mixin/inputPlaceholder.js +3 -9
- package/styles/mixin/media.js +3 -11
- package/styles/mixin/rounded.js +13 -12
- package/styles/mixin/scrollbar.js +7 -13
- package/styles/theme/dark.theme.js +20 -20
- package/styles/theme/light.theme.js +20 -20
- package/styles/theme/white.theme.js +20 -20
- package/styles/themes.js +2 -8
- package/table/GridTable.js +105 -143
- package/table/ImageBox.js +8 -18
- package/table/PermissionTable.js +25 -25
- package/table/Table.js +137 -153
- package/table/__mock__/columns.js +2 -3
- package/table/__mock__/data.js +2 -3
- package/table/hooks/index.js +2 -5
- package/table/hooks/useCalculateDataRange.js +9 -36
- package/table/hooks/useGenerateSort.js +6 -17
- package/table/index.js +4 -9
- package/table/subComponent/BaseTableHeadCell.js +15 -21
- package/table/subComponent/GridTableFooter.js +5 -10
- package/table/subComponent/GridTableHeadCell.js +5 -10
- package/table/subComponent/Resizer.js +17 -44
- package/table/subComponent/TableFooter.js +5 -10
- package/table/subComponent/TableFooterInfo.js +2 -9
- package/table/subComponent/TableFooterPager.js +5 -12
- package/table/subComponent/TableHeadCell.js +2 -9
- package/table/subComponent/TableSort.js +13 -19
- package/tagify/TagifyStyle.js +2 -9
- package/tagify/Tags.js +15 -37
- package/tagify/index.js +2 -5
- package/text/Paragraph.js +25 -20
- package/text/index.js +1 -3
- package/timeline/Timeline.js +28 -37
- package/timeline/index.js +1 -3
- package/toast/CustomToastContainer.js +2 -9
- package/toast/MessageContainer.js +9 -18
- package/toast/index.js +3 -8
- package/toast/show.js +18 -28
- package/tooltip/Tooltip.js +48 -97
- package/tooltip/index.js +1 -3
- package/wizard/Wizard.js +63 -133
- 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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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)(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
}
|
|
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
|
-
}
|
|
116
|
-
|
|
69
|
+
}
|
|
117
70
|
|
|
118
|
-
|
|
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
|
-
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
|
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]);
|
|
155
|
+
}, [zoom]);
|
|
207
156
|
|
|
208
|
-
|
|
157
|
+
// setup map
|
|
158
|
+
(0, _react.useEffect)(() => {
|
|
209
159
|
if (map) {
|
|
210
160
|
map.setOptions(options);
|
|
211
|
-
window.google.maps.event.addListenerOnce(map, 'idle',
|
|
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
|
-
|
|
218
|
-
bounds.forEach(
|
|
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
|
-
|
|
172
|
+
const found = locations.find(location => {
|
|
223
173
|
return latLngBounds.contains({
|
|
224
174
|
lat: location.latitude,
|
|
225
175
|
lng: location.longitude
|
|
226
176
|
});
|
|
227
|
-
});
|
|
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
|
|
190
|
+
return () => {
|
|
240
191
|
window.google.maps.event.clearListeners(map, 'click');
|
|
241
192
|
};
|
|
242
193
|
}
|
|
243
|
-
}, [map, options, locations, bounds, defaultPosition, position]);
|
|
194
|
+
}, [map, options, locations, bounds, defaultPosition, position]);
|
|
244
195
|
|
|
245
|
-
|
|
196
|
+
// render marker cluster
|
|
197
|
+
(0, _react.useEffect)(() => {
|
|
246
198
|
if (map && locations.length > 0) {
|
|
247
|
-
|
|
199
|
+
const markers = [];
|
|
248
200
|
|
|
249
|
-
|
|
201
|
+
// set up popup
|
|
202
|
+
const popup = new _GoogleMapPopup.default({
|
|
250
203
|
maxWidth: 400,
|
|
251
204
|
offset: 36
|
|
252
205
|
});
|
|
253
|
-
map.addListener('click',
|
|
206
|
+
map.addListener('click', () => {
|
|
254
207
|
popup.setMap(null);
|
|
255
208
|
});
|
|
256
|
-
|
|
209
|
+
const oms = new _GoogleMarkerSpiderfier.default(map, {
|
|
257
210
|
markersWontMove: true,
|
|
258
211
|
markersWontHide: true,
|
|
259
212
|
basicFormatEvents: true
|
|
260
213
|
});
|
|
261
|
-
locations.forEach(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
-
|
|
279
|
-
|
|
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',
|
|
240
|
+
marker.addListener('click', event => {
|
|
289
241
|
event.stop();
|
|
290
|
-
|
|
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
|
-
|
|
305
|
-
map
|
|
306
|
-
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:
|
|
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);
|
|
277
|
+
map.fitBounds(cluster.bounds);
|
|
326
278
|
|
|
327
|
-
|
|
328
|
-
|
|
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
|
|
289
|
+
return () => {
|
|
338
290
|
popup.setMap(null);
|
|
339
291
|
markerClusterer.setMap(null);
|
|
340
|
-
markers.forEach(
|
|
292
|
+
markers.forEach(marker => {
|
|
341
293
|
marker.setMap(null);
|
|
342
294
|
});
|
|
343
295
|
};
|
|
344
296
|
}
|
|
345
|
-
}, [map, locations, checkPrimaryLocation, customPopup]);
|
|
297
|
+
}, [map, locations, checkPrimaryLocation, customPopup]);
|
|
346
298
|
|
|
347
|
-
|
|
299
|
+
// geofencing
|
|
300
|
+
(0, _react.useEffect)(() => {
|
|
348
301
|
if (map && geoFence) {
|
|
349
|
-
|
|
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);
|
|
316
|
+
circle.setMap(map);
|
|
364
317
|
|
|
318
|
+
// add event listener
|
|
365
319
|
if (geoFenceOptions.eventHandlers) {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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',
|
|
377
|
-
|
|
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',
|
|
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)(
|
|
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:
|
|
361
|
+
onClick: event => {
|
|
413
362
|
event.target.focus();
|
|
414
363
|
},
|
|
415
|
-
onFocus:
|
|
364
|
+
onFocus: () => {
|
|
416
365
|
map.setOptions({
|
|
417
366
|
scrollwheel: true
|
|
418
367
|
});
|
|
419
368
|
},
|
|
420
|
-
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;
|