@cashub/ui-elv 1.0.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 +28 -0
- package/Tab/TabList.js +167 -0
- package/Tab/TabPanel.js +49 -0
- package/Tab/TabTab.js +105 -0
- package/Tab/index.js +30 -0
- package/Tab/subComponent/TabContext.js +9 -0
- package/Tab/subComponent/TabListV2.js +25 -0
- package/Tab/subComponent/TabPanelV2.js +52 -0
- package/Tab/subComponent/TabTabV2.js +63 -0
- package/VerticalTab/TabList.js +27 -0
- package/VerticalTab/TabPanel.js +52 -0
- package/VerticalTab/TabTab.js +70 -0
- package/VerticalTab/VerticalTab.js +41 -0
- package/VerticalTab/index.js +16 -0
- package/VerticalTab/subComponent/TabContext.js +9 -0
- package/alert/Alert.js +29 -0
- package/alert/index.js +13 -0
- package/animate/Collapse.js +71 -0
- package/animate/Loader.js +58 -0
- package/animate/NumberCounter.js +51 -0
- package/animate/PulseRing.js +35 -0
- package/animate/Spinner.js +18 -0
- package/animate/index.js +41 -0
- package/assets/css/autocomplete.css +16 -0
- package/assets/css/font.css +4 -0
- package/assets/css/global.css +2 -0
- package/assets/font/helvetica/Helvetica.ttf +0 -0
- package/assets/font/nanumGothic/NanumGothic-Bold.ttf +0 -0
- package/assets/font/nanumGothic/NanumGothic-ExtraBold.ttf +0 -0
- package/assets/font/nanumGothic/NanumGothic-Regular.ttf +0 -0
- package/assets/icons/app-management.png +0 -0
- package/assets/icons/burger-black.png +0 -0
- package/assets/icons/burger-white.png +0 -0
- package/assets/icons/burger.png +0 -0
- package/assets/icons/file.svg +1 -0
- package/assets/icons/map_icon1.png +0 -0
- package/assets/icons/map_icon4.png +0 -0
- package/assets/images/bg-aside.png +0 -0
- package/assets/images/bg-chart-circle.png +0 -0
- package/assets/images/bg-chart-triangle.png +0 -0
- package/assets/images/cashub-logo-only.png +0 -0
- package/assets/images/default-user.jpg +0 -0
- package/assets/images/logo-cashub.png +0 -0
- package/assets/images/map.png +0 -0
- package/assets/images/qrcode.png +0 -0
- package/backdrop/BaseBackdrop.js +18 -0
- package/backdrop/LoadingBackdrop.js +17 -0
- package/backdrop/ModalBackdrop.js +15 -0
- package/backdrop/index.js +27 -0
- package/badge/Badge.js +26 -0
- package/badge/BadgeDot.js +18 -0
- package/badge/BadgeFill.js +49 -0
- package/badge/BadgeFillTriangle.js +147 -0
- package/badge/BadgeWithText.js +31 -0
- package/badge/index.js +41 -0
- package/billing/BarChart.js +51 -0
- package/billing/Grid.js +45 -0
- package/billing/Header2.js +25 -0
- package/billing/Header3.js +37 -0
- package/billing/Paragraph.js +33 -0
- package/billing/ParagraphGroup.js +22 -0
- package/billing/ParagraphText.js +26 -0
- package/billing/Section.js +50 -0
- package/billing/SectionBody.js +17 -0
- package/billing/SectionHeader.js +26 -0
- package/billing/__stories__/BarChart.stories.js_bak +46 -0
- package/billing/__stories__/Grid.stories.js_bak +57 -0
- package/billing/__stories__/Header2.stories.js_bak +62 -0
- package/billing/__stories__/Header3.stories.js_bak +69 -0
- package/billing/__stories__/Paragraph.stories.js_bak +84 -0
- package/billing/__stories__/ParagraphGroup.stories.js_bak +68 -0
- package/billing/__stories__/ParagraphText.stories.js_bak +64 -0
- package/billing/__stories__/Section.stories.js_bak +115 -0
- package/billing/__stories__/SectionBody.stories.js_bak +62 -0
- package/billing/__stories__/SectionHeader.stories.js-bak +68 -0
- package/breadcrumb/Breadcrumb.js +78 -0
- package/breadcrumb/index.js +13 -0
- package/button/Button.js +154 -0
- package/button/ButtonGroup.js +61 -0
- package/button/IconButton.js +72 -0
- package/button/ScrollToTopButton.js +54 -0
- package/button/index.js +34 -0
- package/callout/Callout.js +52 -0
- package/callout/index.js +13 -0
- package/chart/BarChart.js +148 -0
- package/chart/DoughnutChart.js +118 -0
- package/chart/LineChart.js +146 -0
- package/chart/SingleBarChart.js +42 -0
- package/chart/index.js +52 -0
- package/chart/utils/centerTextPlugin.js +62 -0
- package/chart/utils/customTooltip.js +94 -0
- package/chart/utils/htmlLegendPlugin.js +89 -0
- package/chart/utils/index.js +27 -0
- package/chart/utils/padEmptyChartBar.js +53 -0
- package/chart/utils/yAxisTopTitlePlugin.js +49 -0
- package/container/FlexContainer.js +40 -0
- package/container/index.js +13 -0
- package/cropper/Cropper.js +54 -0
- package/cropper/CropperModalHandler.js +41 -0
- package/cropper/index.js +20 -0
- package/cropper/subComponent/CropImageModal.js +79 -0
- package/datetimePicker/DatePicker.js +363 -0
- package/datetimePicker/DatePickerV2.js +407 -0
- package/datetimePicker/DatetimePicker.js +240 -0
- package/datetimePicker/DatetimePickerV2.js +395 -0
- package/datetimePicker/DatetimePickerV3.js +279 -0
- package/datetimePicker/TimeInput.js +56 -0
- package/datetimePicker/TimePicker.js +317 -0
- package/datetimePicker/TimePickerStyle.js +64 -0
- package/datetimePicker/TimePickerV2.js +208 -0
- package/datetimePicker/accordion/Month.js +254 -0
- package/datetimePicker/accordion/Year.js +284 -0
- package/datetimePicker/hooks/index.js +27 -0
- package/datetimePicker/hooks/useChangeNumber.js +42 -0
- package/datetimePicker/hooks/useDecrease.js +38 -0
- package/datetimePicker/hooks/useIncrease.js +38 -0
- package/datetimePicker/index.js +69 -0
- package/datetimePicker/provider/constant.js +43 -0
- package/datetimePicker/subComponent/Accordion.js +373 -0
- package/datetimePicker/subComponent/CustomTimeInput.js +47 -0
- package/datetimePicker/subComponent/DateTimePickerContext.js +9 -0
- package/datetimePicker/utils/GMTDate.js +15 -0
- package/datetimePicker/utils/pad.js +13 -0
- package/datetimePicker/utils/toUTC0.js +13 -0
- package/descriptionList/DescriptionDetail.js +28 -0
- package/descriptionList/DescriptionList.js +25 -0
- package/descriptionList/DescriptionTerm.js +14 -0
- package/descriptionList/index.js +27 -0
- package/divider/Divider.js +31 -0
- package/divider/index.js +13 -0
- package/dropdown/Dropdown.js +55 -0
- package/dropdown/DropdownButtonOption.js +43 -0
- package/dropdown/DropdownContent.js +90 -0
- package/dropdown/DropdownDivOption.js +26 -0
- package/dropdown/DropdownItem.js +26 -0
- package/dropdown/DropdownLinkOption.js +24 -0
- package/dropdown/DropdownToggle.js +38 -0
- package/dropdown/index.js +42 -0
- package/dropdown/subComponent/DropdownContext.js +9 -0
- package/dropzone/FileDropzone.js +479 -0
- package/dropzone/ImageDropzone.js +334 -0
- package/dropzone/index.js +20 -0
- package/dropzone/subComponent/Message.js +26 -0
- package/figure/IconFigure.js +42 -0
- package/figure/ImageFigure.js +38 -0
- package/figure/index.js +20 -0
- package/file/HiddenFileInput.js +15 -0
- package/file/index.js +13 -0
- package/form/Checkbox.js +166 -0
- package/form/Fieldset.js +18 -0
- package/form/FormItem.js +22 -0
- package/form/Input.js +66 -0
- package/form/Label.js +61 -0
- package/form/MutedText.js +21 -0
- package/form/PasswordInput.js +47 -0
- package/form/RadioButton.js +103 -0
- package/form/SearchSelect.js +181 -0
- package/form/Searchbox.js +98 -0
- package/form/Slider.js +46 -0
- package/form/SwitchButton.js +105 -0
- package/form/Textarea.js +41 -0
- package/form/TreeView.js +73 -0
- package/form/index.js +104 -0
- package/grid/Column.js +46 -0
- package/grid/Grid.js +35 -0
- package/grid/index.js +20 -0
- package/heading/Heading1.js +21 -0
- package/heading/Heading2.js +28 -0
- package/heading/Heading3.js +49 -0
- package/heading/index.js +27 -0
- package/helmet/Helmet.js +23 -0
- package/helmet/index.js +20 -0
- package/iconbox/ApplicationIconBox.js +81 -0
- package/iconbox/IconBox.js +67 -0
- package/iconbox/IconBoxV2.js +72 -0
- package/iconbox/index.js +27 -0
- package/iconbox/subComponent/IconBoxFigure.js +50 -0
- package/iconbox/subComponent/IconBoxImage.js +42 -0
- package/image/ImageFluid.js +17 -0
- package/image/UploadImage.js +250 -0
- package/image/index.js +20 -0
- package/index.js +568 -0
- package/jsoneditor/JsonEditor.js +142 -0
- package/jsoneditor/index.js +13 -0
- package/keyframe/Pulse.js +21 -0
- package/keyframe/Spin.js +13 -0
- package/layout/Aside.js +48 -0
- package/layout/AsideHeader.jsx +27 -0
- package/layout/Backdrop.js +23 -0
- package/layout/Container.js +39 -0
- package/layout/Footer.js +45 -0
- package/layout/Header.jsx +55 -0
- package/layout/Layout.jsx +84 -0
- package/layout/Logo.jsx +17 -0
- package/layout/MenuIcon.jsx +27 -0
- package/layout/Sidebar.jsx +271 -0
- package/layout/index.js +13 -0
- package/link/LinkSpan.js +69 -0
- package/link/index.js +13 -0
- package/map/GoogleMap.js +448 -0
- package/map/GoogleReverseGeolocation.js +200 -0
- package/map/LeafletMap.js +231 -0
- package/map/LeafletReverseGeolocation.js +101 -0
- package/map/index.js +34 -0
- package/map/subComponent/BasicLeafletMap.js +34 -0
- package/map/subComponent/GoogleMapContainer.js +29 -0
- package/map/subComponent/GoogleMapPopup.js +109 -0
- package/map/subComponent/GoogleMapWrapper.js +40 -0
- package/map/subComponent/LeafletDrawControl.js +127 -0
- package/map/subComponent/LeafletMapContainer.js +173 -0
- package/map/subComponent/MapSearchBoxControl.js +54 -0
- package/modal/StateModal.js +178 -0
- package/modal/TitleModal.js +250 -0
- package/modal/index.js +20 -0
- package/package.json +54 -0
- package/page/Disclaimer.js +128 -0
- package/page/index.js +13 -0
- package/paginate/Paginate.js +137 -0
- package/paginate/index.js +13 -0
- package/popover/Popover.js +91 -0
- package/popover/index.js +13 -0
- package/qrcode/QRCode.js +58 -0
- package/qrcode/QRCodeContainter.js +34 -0
- package/qrcode/index.js +20 -0
- package/ribbon/Ribbon.js +42 -0
- package/ribbon/index.js +13 -0
- package/section/Section.js +133 -0
- package/section/SectionBody.js +52 -0
- package/section/SectionHeader.js +70 -0
- package/section/SectionToolbar.js +18 -0
- package/section/SectionToolbarItem.js +17 -0
- package/section/index.js +41 -0
- package/select/InputSelect.js +270 -0
- package/select/Select.js +818 -0
- package/select/index.js +20 -0
- package/select/subComponent/Checkbox.js +48 -0
- package/select/subComponent/Footer.js +13 -0
- package/select/subComponent/ListBox.js +30 -0
- package/select/subComponent/Option.js +45 -0
- package/select/subComponent/OptionGroup.js +23 -0
- package/select/subComponent/Options.js +32 -0
- package/select/subComponent/SearchBox.js +58 -0
- package/select/subComponent/SelectedMultipleCount.js +39 -0
- package/select/subComponent/SelectedMultipleTags.js +54 -0
- package/select/subComponent/SelectedMultipleText.js +70 -0
- package/select/subComponent/SelectedSingle.js +17 -0
- package/styles/GlobalStyle.js +334 -0
- package/styles/config/breakpoint.style.js +13 -0
- package/styles/config/header.style.js +10 -0
- package/styles/config/sidebar.style.js +17 -0
- package/styles/index.js +20 -0
- package/styles/mixin/backgroundColor.js +44 -0
- package/styles/mixin/borderColor.js +37 -0
- package/styles/mixin/color.js +37 -0
- package/styles/mixin/colorOnBackground.js +37 -0
- package/styles/mixin/inputPlaceholder.js +30 -0
- package/styles/mixin/media.js +21 -0
- package/styles/mixin/rounded.js +30 -0
- package/styles/mixin/scrollbar.js +32 -0
- package/styles/theme/dark.theme.js +97 -0
- package/styles/theme/light.theme.js +97 -0
- package/styles/theme/white.theme.js +97 -0
- package/styles/themes.js +16 -0
- package/table/GridTable.js +336 -0
- package/table/ImageBox.js +45 -0
- package/table/InfiniteGridTable.js +403 -0
- package/table/PermissionTable.js +64 -0
- package/table/SimpleGridTable.js +143 -0
- package/table/Table.js +568 -0
- package/table/__mock__/columns.js +70 -0
- package/table/__mock__/data.js +536 -0
- package/table/hooks/index.js +20 -0
- package/table/hooks/useCalculateDataRange.js +28 -0
- package/table/hooks/useGenerateSort.js +39 -0
- package/table/index.js +48 -0
- package/table/subComponent/BaseTableHeadCell.js +62 -0
- package/table/subComponent/GridTableFooter.js +24 -0
- package/table/subComponent/GridTableHeadCell.js +20 -0
- package/table/subComponent/Resizer.js +77 -0
- package/table/subComponent/TableFooter.js +31 -0
- package/table/subComponent/TableFooterInfo.js +13 -0
- package/table/subComponent/TableFooterPager.js +33 -0
- package/table/subComponent/TableHeadCell.js +19 -0
- package/table/subComponent/TableSort.js +38 -0
- package/tagify/TagifyStyle.js +60 -0
- package/tagify/Tags.js +56 -0
- package/tagify/index.js +27 -0
- package/tagify/templates/getCreateButtonTemplate.js +18 -0
- package/text/Paragraph.js +86 -0
- package/text/index.js +13 -0
- package/timeline/Timeline.js +139 -0
- package/timeline/index.js +13 -0
- package/toast/CustomToastContainer.js +45 -0
- package/toast/MessageContainer.js +51 -0
- package/toast/index.js +36 -0
- package/toast/show.js +39 -0
- package/toast/style.css +1 -0
- package/tooltip/Tooltip.js +140 -0
- package/tooltip/index.js +13 -0
- package/treeView/TreeViewV2.js +38 -0
- package/treeView/TreeflexStyle.js +49 -0
- package/treeView/index.js +20 -0
- package/wizard/Wizard.js +251 -0
- package/wizard/index.js +13 -0
package/layout/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Layout", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Layout.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _Layout = _interopRequireDefault(require("./Layout"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
package/link/LinkSpan.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const LinkSpan = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
children,
|
|
13
|
+
...props
|
|
14
|
+
} = _ref;
|
|
15
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Link, {
|
|
16
|
+
...props,
|
|
17
|
+
children: children
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const Link = _styledComponents.default.span.attrs(props => {
|
|
21
|
+
return {
|
|
22
|
+
fontSize: props.fontSmall ? '1rem' : '1.5rem',
|
|
23
|
+
color: props.light ? 'var(--font-on-background)' : 'rgba(255, 255, 255, 0.5)',
|
|
24
|
+
borderColor: props.light ? 'var(--border-color)' : '#3e5fff'
|
|
25
|
+
};
|
|
26
|
+
})`
|
|
27
|
+
font-size: ${_ref2 => {
|
|
28
|
+
let {
|
|
29
|
+
fontSize
|
|
30
|
+
} = _ref2;
|
|
31
|
+
return fontSize;
|
|
32
|
+
}};
|
|
33
|
+
line-height: 1.5;
|
|
34
|
+
font-weight: 500;
|
|
35
|
+
color: ${_ref3 => {
|
|
36
|
+
let {
|
|
37
|
+
color
|
|
38
|
+
} = _ref3;
|
|
39
|
+
return color;
|
|
40
|
+
}};
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
position: relative;
|
|
43
|
+
display: inline-block;
|
|
44
|
+
|
|
45
|
+
&:after {
|
|
46
|
+
display: block;
|
|
47
|
+
content: '';
|
|
48
|
+
position: absolute;
|
|
49
|
+
bottom: 0;
|
|
50
|
+
top: 1rem;
|
|
51
|
+
left: 0;
|
|
52
|
+
width: 0%;
|
|
53
|
+
transition: width 0.3s ease;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&:hover {
|
|
57
|
+
&:after {
|
|
58
|
+
width: 100%;
|
|
59
|
+
border-bottom: 1px solid ${_ref4 => {
|
|
60
|
+
let {
|
|
61
|
+
borderColor
|
|
62
|
+
} = _ref4;
|
|
63
|
+
return borderColor;
|
|
64
|
+
}};
|
|
65
|
+
opacity: 0.75;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
`;
|
|
69
|
+
var _default = exports.default = LinkSpan;
|
package/link/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "LinkSpan", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _LinkSpan.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _LinkSpan = _interopRequireDefault(require("./LinkSpan"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
package/map/GoogleMap.js
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _server = require("react-dom/server");
|
|
9
|
+
var _markerclusterer = require("@googlemaps/markerclusterer");
|
|
10
|
+
var _GoogleMapWrapper = _interopRequireDefault(require("./subComponent/GoogleMapWrapper"));
|
|
11
|
+
var _GoogleMapContainer = _interopRequireDefault(require("./subComponent/GoogleMapContainer"));
|
|
12
|
+
var _GoogleMapPopup = _interopRequireDefault(require("./subComponent/GoogleMapPopup"));
|
|
13
|
+
var _map_icon = _interopRequireDefault(require("../assets/icons/map_icon1.png"));
|
|
14
|
+
var _map_icon2 = _interopRequireDefault(require("../assets/icons/map_icon4.png"));
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
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); }
|
|
18
|
+
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 && {}.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; }
|
|
19
|
+
const GoogleMap = _ref => {
|
|
20
|
+
let {
|
|
21
|
+
apiKey,
|
|
22
|
+
height = 512,
|
|
23
|
+
zoom = 10,
|
|
24
|
+
data = {
|
|
25
|
+
defaultPosition: null,
|
|
26
|
+
position: null,
|
|
27
|
+
locations: [],
|
|
28
|
+
message: null
|
|
29
|
+
},
|
|
30
|
+
geoFence = false,
|
|
31
|
+
geoFenceOptions = {},
|
|
32
|
+
onError,
|
|
33
|
+
customPopup,
|
|
34
|
+
checkPrimaryLocation
|
|
35
|
+
} = _ref;
|
|
36
|
+
const [hasError, setHasError] = (0, _react.useState)(true);
|
|
37
|
+
const [validLocations, setValidLocations] = (0, _react.useState)([]);
|
|
38
|
+
const [validBounds, setValidBounds] = (0, _react.useState)([]);
|
|
39
|
+
const handleError = (0, _react.useCallback)(errorCode => {
|
|
40
|
+
if (onError) {
|
|
41
|
+
onError(errorCode);
|
|
42
|
+
}
|
|
43
|
+
}, [onError]);
|
|
44
|
+
(0, _react.useEffect)(() => {
|
|
45
|
+
const {
|
|
46
|
+
defaultPosition,
|
|
47
|
+
position,
|
|
48
|
+
locations
|
|
49
|
+
} = data;
|
|
50
|
+
const validLocations = [];
|
|
51
|
+
const bounds = [];
|
|
52
|
+
if (!position && !defaultPosition) {
|
|
53
|
+
handleError('NO_COORDINATES');
|
|
54
|
+
setHasError(true);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
locations.forEach(location => {
|
|
58
|
+
let {
|
|
59
|
+
latitude,
|
|
60
|
+
longitude
|
|
61
|
+
} = location;
|
|
62
|
+
if (!latitude && latitude !== 0 || !longitude && longitude !== 0 || latitude === 0 && longitude === 0 || latitude === '0' && longitude === '0') {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// make sure coordinate in number type
|
|
67
|
+
latitude = Number(latitude);
|
|
68
|
+
longitude = Number(longitude);
|
|
69
|
+
if (Number.isNaN(latitude) || Number.isNaN(longitude)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// prevent duplicate LatLngBounds
|
|
74
|
+
if (!bounds.some(LatLng => {
|
|
75
|
+
return latitude === LatLng.lat && longitude === LatLng.lng;
|
|
76
|
+
})) {
|
|
77
|
+
bounds.push({
|
|
78
|
+
lat: latitude,
|
|
79
|
+
lng: longitude
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
validLocations.push({
|
|
83
|
+
...location,
|
|
84
|
+
latitude,
|
|
85
|
+
longitude
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// pass all checking
|
|
90
|
+
setHasError(false);
|
|
91
|
+
setValidLocations(validLocations);
|
|
92
|
+
setValidBounds(bounds);
|
|
93
|
+
}, [data, handleError]);
|
|
94
|
+
if (!hasError) {
|
|
95
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GoogleMapWrapper.default, {
|
|
96
|
+
apiKey: apiKey,
|
|
97
|
+
height: height,
|
|
98
|
+
zoom: zoom,
|
|
99
|
+
defaultPosition: data.defaultPosition,
|
|
100
|
+
position: data.position,
|
|
101
|
+
locations: validLocations,
|
|
102
|
+
message: data.message,
|
|
103
|
+
bounds: validBounds,
|
|
104
|
+
geoFence: geoFence,
|
|
105
|
+
geoFenceOptions: geoFenceOptions,
|
|
106
|
+
onError: handleError,
|
|
107
|
+
customPopup: customPopup,
|
|
108
|
+
checkPrimaryLocation: checkPrimaryLocation,
|
|
109
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Map, {})
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
|
|
113
|
+
};
|
|
114
|
+
const Map = _ref2 => {
|
|
115
|
+
let {
|
|
116
|
+
height,
|
|
117
|
+
zoom,
|
|
118
|
+
defaultPosition,
|
|
119
|
+
position,
|
|
120
|
+
locations,
|
|
121
|
+
message,
|
|
122
|
+
bounds,
|
|
123
|
+
geoFence,
|
|
124
|
+
geoFenceOptions,
|
|
125
|
+
customPopup,
|
|
126
|
+
checkPrimaryLocation
|
|
127
|
+
} = _ref2;
|
|
128
|
+
const ref = (0, _react.useRef)(null);
|
|
129
|
+
const [map, setMap] = (0, _react.useState)();
|
|
130
|
+
const [OverlappingMarkerSpiderfier, setOverlappingMarkerSpiderfier] = (0, _react.useState)(null);
|
|
131
|
+
const options = (0, _react.useMemo)(() => {
|
|
132
|
+
return {
|
|
133
|
+
zoom,
|
|
134
|
+
center: {
|
|
135
|
+
lat: 1,
|
|
136
|
+
lng: 1
|
|
137
|
+
},
|
|
138
|
+
scrollwheel: false,
|
|
139
|
+
zoomControl: true,
|
|
140
|
+
zoomControlOptions: {
|
|
141
|
+
position: window.google.maps.ControlPosition.LEFT_TOP
|
|
142
|
+
},
|
|
143
|
+
mapTypeControl: false,
|
|
144
|
+
scaleControl: false,
|
|
145
|
+
streetViewControl: false,
|
|
146
|
+
rotateControl: false,
|
|
147
|
+
fullscreenControl: false,
|
|
148
|
+
minZoom: 3,
|
|
149
|
+
maxZoom: 20,
|
|
150
|
+
restriction: {
|
|
151
|
+
latLngBounds: {
|
|
152
|
+
east: 179.9999,
|
|
153
|
+
north: 85,
|
|
154
|
+
south: -85,
|
|
155
|
+
west: -179.9999
|
|
156
|
+
},
|
|
157
|
+
strictBounds: true
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}, [zoom]);
|
|
161
|
+
|
|
162
|
+
// setup map
|
|
163
|
+
(0, _react.useEffect)(() => {
|
|
164
|
+
if (map) {
|
|
165
|
+
map.setOptions(options);
|
|
166
|
+
window.google.maps.event.addListenerOnce(map, 'idle', () => {
|
|
167
|
+
if (geoFence) {
|
|
168
|
+
map.setCenter({
|
|
169
|
+
lat: geoFenceOptions.latitude,
|
|
170
|
+
lng: geoFenceOptions.longitude
|
|
171
|
+
});
|
|
172
|
+
} else {
|
|
173
|
+
if (bounds.length === 1) {
|
|
174
|
+
// there is only one location, locate it
|
|
175
|
+
map.setCenter(bounds[0]);
|
|
176
|
+
} else if (locations.length > 0) {
|
|
177
|
+
// locate to the center of all coordinates on first load
|
|
178
|
+
const latLngBounds = new window.google.maps.LatLngBounds();
|
|
179
|
+
bounds.forEach(bound => {
|
|
180
|
+
latLngBounds.extend(bound);
|
|
181
|
+
});
|
|
182
|
+
map.fitBounds(latLngBounds);
|
|
183
|
+
const found = locations.find(location => {
|
|
184
|
+
return latLngBounds.contains({
|
|
185
|
+
lat: location.latitude,
|
|
186
|
+
lng: location.longitude
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// if center no contain any marker then locate to first location
|
|
191
|
+
if (!found) {
|
|
192
|
+
map.setCenter(bounds[0]);
|
|
193
|
+
}
|
|
194
|
+
} else {
|
|
195
|
+
map.setCenter({
|
|
196
|
+
lat: position && position.latitude || defaultPosition.latitude,
|
|
197
|
+
lng: position && position.longitude || defaultPosition.longitude
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
return () => {
|
|
203
|
+
window.google.maps.event.clearListeners(map, 'click');
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}, [map, options, locations, bounds, defaultPosition, position, geoFence, geoFenceOptions.latitude, geoFenceOptions.longitude]);
|
|
207
|
+
|
|
208
|
+
// render marker cluster
|
|
209
|
+
(0, _react.useEffect)(() => {
|
|
210
|
+
if (map && OverlappingMarkerSpiderfier && locations.length > 0) {
|
|
211
|
+
const markers = [];
|
|
212
|
+
|
|
213
|
+
// set up popup
|
|
214
|
+
const popup = new _GoogleMapPopup.default({
|
|
215
|
+
maxWidth: 400,
|
|
216
|
+
offset: 36
|
|
217
|
+
});
|
|
218
|
+
map.addListener('click', () => {
|
|
219
|
+
popup.setMap(null);
|
|
220
|
+
});
|
|
221
|
+
const oms = new OverlappingMarkerSpiderfier.default(map, {
|
|
222
|
+
markersWontMove: true,
|
|
223
|
+
markersWontHide: true,
|
|
224
|
+
basicFormatEvents: true
|
|
225
|
+
});
|
|
226
|
+
locations.forEach(location => {
|
|
227
|
+
const {
|
|
228
|
+
latitude,
|
|
229
|
+
longitude
|
|
230
|
+
} = location;
|
|
231
|
+
let icon;
|
|
232
|
+
if (checkPrimaryLocation && checkPrimaryLocation(location)) {
|
|
233
|
+
icon = {
|
|
234
|
+
url: _map_icon.default,
|
|
235
|
+
scaledSize: new window.google.maps.Size(40, 50)
|
|
236
|
+
};
|
|
237
|
+
} else {
|
|
238
|
+
icon = {
|
|
239
|
+
url: _map_icon2.default,
|
|
240
|
+
scaledSize: new window.google.maps.Size(40, 50)
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
const marker = new window.google.maps.Marker({
|
|
244
|
+
icon,
|
|
245
|
+
map,
|
|
246
|
+
position: {
|
|
247
|
+
lat: latitude,
|
|
248
|
+
lng: longitude
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
if (customPopup) {
|
|
252
|
+
marker.addListener('click', event => {
|
|
253
|
+
event.stop();
|
|
254
|
+
const coordinate = {
|
|
255
|
+
lat: latitude,
|
|
256
|
+
lng: longitude
|
|
257
|
+
};
|
|
258
|
+
popup.setMap(map);
|
|
259
|
+
popup.setPosition(coordinate);
|
|
260
|
+
popup.setContent((0, _server.renderToString)(customPopup(location)));
|
|
261
|
+
popup.draw();
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
markers.push(marker);
|
|
265
|
+
oms.addMarker(marker);
|
|
266
|
+
});
|
|
267
|
+
const markerClusterer = new _markerclusterer.MarkerClusterer({
|
|
268
|
+
map,
|
|
269
|
+
markers,
|
|
270
|
+
algorithm: new _markerclusterer.SuperClusterAlgorithm({
|
|
271
|
+
radius: 120
|
|
272
|
+
}),
|
|
273
|
+
onClusterClick: (event, cluster, map) => {
|
|
274
|
+
// fix: cluster marker spiderfier
|
|
275
|
+
// const targetPosition = cluster.markers[0].getPosition().toJSON();
|
|
276
|
+
// const isAllSamePosition = cluster.markers.every((marker) => {
|
|
277
|
+
// const position = marker.getPosition().toJSON();
|
|
278
|
+
// return (
|
|
279
|
+
// targetPosition.lat === position.lat &&
|
|
280
|
+
// targetPosition.lng === position.lng
|
|
281
|
+
// );
|
|
282
|
+
// });
|
|
283
|
+
// if (isAllSamePosition) {
|
|
284
|
+
// return;
|
|
285
|
+
// }
|
|
286
|
+
|
|
287
|
+
// fix: need to call twice to actually work
|
|
288
|
+
map.fitBounds(cluster.bounds);
|
|
289
|
+
map.fitBounds(cluster.bounds);
|
|
290
|
+
|
|
291
|
+
// check current view has marker, if not set view to first marker
|
|
292
|
+
const currentBounds = map.getBounds();
|
|
293
|
+
const found = cluster.markers.find(marker => {
|
|
294
|
+
return currentBounds.contains(marker.getPosition());
|
|
295
|
+
});
|
|
296
|
+
if (!found) {
|
|
297
|
+
map.setCenter(cluster.markers[0].getPosition());
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
return () => {
|
|
302
|
+
popup.setMap(null);
|
|
303
|
+
markerClusterer.setMap(null);
|
|
304
|
+
markers.forEach(marker => {
|
|
305
|
+
marker.setMap(null);
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
}, [map, OverlappingMarkerSpiderfier, locations, checkPrimaryLocation, customPopup]);
|
|
310
|
+
|
|
311
|
+
// geofencing
|
|
312
|
+
(0, _react.useEffect)(() => {
|
|
313
|
+
if (map && geoFence) {
|
|
314
|
+
const circle = new window.google.maps.Circle({
|
|
315
|
+
strokeColor: '#597EF7',
|
|
316
|
+
strokeOpacity: 0,
|
|
317
|
+
strokeWeight: 0,
|
|
318
|
+
fillColor: '#597EF7',
|
|
319
|
+
fillOpacity: 0.5,
|
|
320
|
+
center: {
|
|
321
|
+
lat: geoFenceOptions.latitude,
|
|
322
|
+
lng: geoFenceOptions.longitude
|
|
323
|
+
},
|
|
324
|
+
radius: geoFenceOptions.radius,
|
|
325
|
+
editable: geoFenceOptions.editable,
|
|
326
|
+
draggable: geoFenceOptions.editable
|
|
327
|
+
});
|
|
328
|
+
circle.setMap(map);
|
|
329
|
+
|
|
330
|
+
// add event listener
|
|
331
|
+
if (geoFenceOptions.eventHandlers) {
|
|
332
|
+
const {
|
|
333
|
+
click,
|
|
334
|
+
edit,
|
|
335
|
+
drag
|
|
336
|
+
} = geoFenceOptions.eventHandlers;
|
|
337
|
+
if (click) {
|
|
338
|
+
window.google.maps.event.addListener(circle, 'click', click);
|
|
339
|
+
}
|
|
340
|
+
if (edit) {
|
|
341
|
+
circle.addListener('radius_changed', () => {
|
|
342
|
+
const radius = circle.getRadius();
|
|
343
|
+
if (geoFenceOptions.minRadius && radius < geoFenceOptions.minRadius) {
|
|
344
|
+
circle.setRadius(geoFenceOptions.minRadius);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
edit(circle.getRadius());
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
if (drag) {
|
|
351
|
+
circle.addListener('center_changed', () => {
|
|
352
|
+
drag(circle.getCenter().toJSON());
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
let repositionButton;
|
|
357
|
+
if (geoFenceOptions.enabledReposition) {
|
|
358
|
+
repositionButton = document.createElement('button');
|
|
359
|
+
repositionButton.style.margin = 'var(--spacing-s)';
|
|
360
|
+
repositionButton.style.padding = 'var(--spacing-xs)';
|
|
361
|
+
repositionButton.style.boxShadow = 'rgba(0, 0, 0, 0.3) 0px 1px 4px -1px';
|
|
362
|
+
repositionButton.style.border = 'none';
|
|
363
|
+
repositionButton.style.borderRadius = '2px';
|
|
364
|
+
repositionButton.style.cursor = 'pointer';
|
|
365
|
+
repositionButton.style.backgroundColor = 'rgb(255, 255, 255)';
|
|
366
|
+
repositionButton.style.fontSize = '1rem';
|
|
367
|
+
repositionButton.textContent = 'Reposition';
|
|
368
|
+
repositionButton.title = 'Click to reposition the map to geofence';
|
|
369
|
+
repositionButton.type = 'button';
|
|
370
|
+
repositionButton.addEventListener('click', () => {
|
|
371
|
+
map.setCenter({
|
|
372
|
+
lat: geoFenceOptions.latitude,
|
|
373
|
+
lng: geoFenceOptions.longitude
|
|
374
|
+
});
|
|
375
|
+
});
|
|
376
|
+
const controlDiv = document.createElement('div');
|
|
377
|
+
controlDiv.appendChild(repositionButton);
|
|
378
|
+
map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(controlDiv);
|
|
379
|
+
}
|
|
380
|
+
return () => {
|
|
381
|
+
circle.setMap(null);
|
|
382
|
+
window.google.maps.event.clearListeners(circle, 'click');
|
|
383
|
+
window.google.maps.event.clearListeners(circle, 'radius_changed');
|
|
384
|
+
window.google.maps.event.clearListeners(circle, 'center_changed');
|
|
385
|
+
|
|
386
|
+
// remove reposition button if exist
|
|
387
|
+
const rightBottonControls = map.controls[google.maps.ControlPosition.RIGHT_BOTTOM];
|
|
388
|
+
if (rightBottonControls.getAt(0)) {
|
|
389
|
+
rightBottonControls.removeAt(0);
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
}, [map, geoFence, geoFenceOptions.latitude, geoFenceOptions.longitude, geoFenceOptions.radius, geoFenceOptions.minRadius, geoFenceOptions.editable, geoFenceOptions.eventHandlers]);
|
|
394
|
+
|
|
395
|
+
// show message
|
|
396
|
+
(0, _react.useEffect)(() => {
|
|
397
|
+
if (map && message) {
|
|
398
|
+
const messageContainer = document.createElement('p');
|
|
399
|
+
messageContainer.style.margin = 'var(--spacing-s)';
|
|
400
|
+
messageContainer.style.padding = 'var(--spacing-xs)';
|
|
401
|
+
messageContainer.style.boxShadow = 'var(--box-shadow)';
|
|
402
|
+
messageContainer.style.border = 'none';
|
|
403
|
+
messageContainer.style.borderRadius = 'var(--border-radius-s)';
|
|
404
|
+
messageContainer.style.cursor = 'pointer';
|
|
405
|
+
messageContainer.style.color = 'rgb(0, 0, 0)';
|
|
406
|
+
messageContainer.style.backgroundColor = 'rgb(255, 255, 255)';
|
|
407
|
+
messageContainer.style.fontSize = 'var(--font-body1)';
|
|
408
|
+
messageContainer.textContent = message;
|
|
409
|
+
const index = map.controls[window.google.maps.ControlPosition.CENTER].push(messageContainer);
|
|
410
|
+
return () => {
|
|
411
|
+
map.controls[window.google.maps.ControlPosition.CENTER].removeAt(index - 1);
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
}, [map, message]);
|
|
415
|
+
(0, _react.useEffect)(() => {
|
|
416
|
+
if (ref.current && !map) {
|
|
417
|
+
setMap(new window.google.maps.Map(ref.current, {}));
|
|
418
|
+
}
|
|
419
|
+
}, [map, options]);
|
|
420
|
+
(0, _react.useEffect)(() => {
|
|
421
|
+
if (map && !OverlappingMarkerSpiderfier) {
|
|
422
|
+
Promise.resolve().then(() => _interopRequireWildcard(require('overlapping-marker-spiderfier'))).then(module => {
|
|
423
|
+
setOverlappingMarkerSpiderfier(module);
|
|
424
|
+
}).catch(error => {
|
|
425
|
+
console.log(error);
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
}, [map, OverlappingMarkerSpiderfier]);
|
|
429
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GoogleMapContainer.default, {
|
|
430
|
+
ref: ref,
|
|
431
|
+
height: height,
|
|
432
|
+
tabIndex: "0",
|
|
433
|
+
onClick: event => {
|
|
434
|
+
event.target.focus();
|
|
435
|
+
},
|
|
436
|
+
onFocus: () => {
|
|
437
|
+
map.setOptions({
|
|
438
|
+
scrollwheel: true
|
|
439
|
+
});
|
|
440
|
+
},
|
|
441
|
+
onBlur: () => {
|
|
442
|
+
map.setOptions({
|
|
443
|
+
scrollwheel: false
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
};
|
|
448
|
+
var _default = exports.default = GoogleMap;
|