@cashub/ui-elv 1.0.2 → 1.0.4

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 (310) hide show
  1. package/datetimePicker/index.js +2 -37
  2. package/esm/Tab/Tab.js +21 -0
  3. package/esm/Tab/TabList.js +160 -0
  4. package/esm/Tab/TabPanel.js +42 -0
  5. package/esm/Tab/TabTab.js +98 -0
  6. package/esm/Tab/index.js +23 -0
  7. package/esm/Tab/subComponent/TabContext.js +3 -0
  8. package/esm/Tab/subComponent/TabListV2.js +18 -0
  9. package/esm/Tab/subComponent/TabPanelV2.js +45 -0
  10. package/esm/Tab/subComponent/TabTabV2.js +56 -0
  11. package/esm/VerticalTab/TabList.js +20 -0
  12. package/esm/VerticalTab/TabPanel.js +45 -0
  13. package/esm/VerticalTab/TabTab.js +63 -0
  14. package/esm/VerticalTab/VerticalTab.js +34 -0
  15. package/esm/VerticalTab/index.js +9 -0
  16. package/esm/VerticalTab/subComponent/TabContext.js +3 -0
  17. package/esm/alert/Alert.js +22 -0
  18. package/esm/alert/index.js +1 -0
  19. package/esm/animate/Collapse.js +65 -0
  20. package/esm/animate/Loader.js +51 -0
  21. package/esm/animate/NumberCounter.js +45 -0
  22. package/esm/animate/PulseRing.js +26 -0
  23. package/esm/animate/Spinner.js +11 -0
  24. package/esm/animate/index.js +5 -0
  25. package/esm/assets/css/autocomplete.css +16 -0
  26. package/esm/assets/css/font.css +4 -0
  27. package/esm/assets/css/global.css +2 -0
  28. package/esm/assets/font/helvetica/Helvetica.ttf +0 -0
  29. package/esm/assets/font/nanumGothic/NanumGothic-Bold.ttf +0 -0
  30. package/esm/assets/font/nanumGothic/NanumGothic-ExtraBold.ttf +0 -0
  31. package/esm/assets/font/nanumGothic/NanumGothic-Regular.ttf +0 -0
  32. package/esm/assets/icons/app-management.png +0 -0
  33. package/esm/assets/icons/burger-black.png +0 -0
  34. package/esm/assets/icons/burger-white.png +0 -0
  35. package/esm/assets/icons/burger.png +0 -0
  36. package/esm/assets/icons/file.svg +1 -0
  37. package/esm/assets/icons/map_icon1.png +0 -0
  38. package/esm/assets/icons/map_icon4.png +0 -0
  39. package/esm/assets/images/bg-aside.png +0 -0
  40. package/esm/assets/images/bg-chart-circle.png +0 -0
  41. package/esm/assets/images/bg-chart-triangle.png +0 -0
  42. package/esm/assets/images/cashub-logo-only.png +0 -0
  43. package/esm/assets/images/default-user.jpg +0 -0
  44. package/esm/assets/images/logo-cashub.png +0 -0
  45. package/esm/assets/images/map.png +0 -0
  46. package/esm/assets/images/qrcode.png +0 -0
  47. package/esm/backdrop/BaseBackdrop.js +11 -0
  48. package/esm/backdrop/LoadingBackdrop.js +10 -0
  49. package/esm/backdrop/ModalBackdrop.js +8 -0
  50. package/esm/backdrop/index.js +3 -0
  51. package/esm/badge/Badge.js +19 -0
  52. package/esm/badge/BadgeDot.js +11 -0
  53. package/esm/badge/BadgeFill.js +42 -0
  54. package/esm/badge/BadgeFillTriangle.js +138 -0
  55. package/esm/badge/BadgeWithText.js +24 -0
  56. package/esm/badge/index.js +5 -0
  57. package/esm/billing/BarChart.js +45 -0
  58. package/esm/billing/Grid.js +38 -0
  59. package/esm/billing/Header2.js +19 -0
  60. package/esm/billing/Header3.js +31 -0
  61. package/esm/billing/Paragraph.js +27 -0
  62. package/esm/billing/ParagraphGroup.js +16 -0
  63. package/esm/billing/ParagraphText.js +20 -0
  64. package/esm/billing/Section.js +44 -0
  65. package/esm/billing/SectionBody.js +11 -0
  66. package/esm/billing/SectionHeader.js +20 -0
  67. package/esm/billing/__stories__/BarChart.stories.js_bak +46 -0
  68. package/esm/billing/__stories__/Grid.stories.js_bak +57 -0
  69. package/esm/billing/__stories__/Header2.stories.js_bak +62 -0
  70. package/esm/billing/__stories__/Header3.stories.js_bak +69 -0
  71. package/esm/billing/__stories__/Paragraph.stories.js_bak +84 -0
  72. package/esm/billing/__stories__/ParagraphGroup.stories.js_bak +68 -0
  73. package/esm/billing/__stories__/ParagraphText.stories.js_bak +64 -0
  74. package/esm/billing/__stories__/Section.stories.js_bak +115 -0
  75. package/esm/billing/__stories__/SectionBody.stories.js_bak +62 -0
  76. package/esm/billing/__stories__/SectionHeader.stories.js-bak +68 -0
  77. package/esm/breadcrumb/Breadcrumb.js +71 -0
  78. package/esm/breadcrumb/index.js +1 -0
  79. package/esm/button/Button.js +145 -0
  80. package/esm/button/ButtonGroup.js +54 -0
  81. package/esm/button/IconButton.js +64 -0
  82. package/esm/button/ScrollToTopButton.js +47 -0
  83. package/esm/button/index.js +4 -0
  84. package/esm/callout/Callout.js +45 -0
  85. package/esm/callout/index.js +1 -0
  86. package/esm/chart/BarChart.js +147 -0
  87. package/esm/chart/DoughnutChart.js +110 -0
  88. package/esm/chart/LineChart.js +140 -0
  89. package/esm/chart/SingleBarChart.js +35 -0
  90. package/esm/chart/index.js +5 -0
  91. package/esm/chart/utils/centerTextPlugin.js +56 -0
  92. package/esm/chart/utils/customTooltip.js +84 -0
  93. package/esm/chart/utils/customTooltipLifecyclePlugin.js +16 -0
  94. package/esm/chart/utils/htmlLegendPlugin.js +83 -0
  95. package/esm/chart/utils/index.js +3 -0
  96. package/esm/chart/utils/padEmptyChartBar.js +47 -0
  97. package/esm/chart/utils/tooltipElement.js +17 -0
  98. package/esm/chart/utils/xAxisLabelTooltipPlugin.js +101 -0
  99. package/esm/chart/utils/yAxisTopTitlePlugin.js +43 -0
  100. package/esm/container/FlexContainer.js +33 -0
  101. package/esm/container/index.js +1 -0
  102. package/esm/cropper/Cropper.js +47 -0
  103. package/esm/cropper/CropperModalHandler.js +34 -0
  104. package/esm/cropper/index.js +2 -0
  105. package/esm/cropper/subComponent/CropImageModal.js +72 -0
  106. package/{datetimePicker/DatetimePicker.js → esm/datetimePicker/DatetimePickerV3.js} +63 -31
  107. package/esm/datetimePicker/TimeInput.js +49 -0
  108. package/esm/datetimePicker/TimePickerStyle.js +58 -0
  109. package/esm/datetimePicker/TimePickerV2.js +199 -0
  110. package/esm/datetimePicker/accordion/Month.js +245 -0
  111. package/esm/datetimePicker/accordion/Year.js +275 -0
  112. package/esm/datetimePicker/index.js +4 -0
  113. package/esm/datetimePicker/provider/constant.js +38 -0
  114. package/esm/datetimePicker/subComponent/DateTimePickerContext.js +3 -0
  115. package/esm/datetimePicker/utils/GMTDate.js +9 -0
  116. package/esm/datetimePicker/utils/pad.js +7 -0
  117. package/esm/datetimePicker/utils/toUTC0.js +7 -0
  118. package/esm/descriptionList/DescriptionDetail.js +21 -0
  119. package/esm/descriptionList/DescriptionList.js +18 -0
  120. package/esm/descriptionList/DescriptionTerm.js +7 -0
  121. package/esm/descriptionList/index.js +3 -0
  122. package/esm/divider/Divider.js +24 -0
  123. package/esm/divider/index.js +1 -0
  124. package/esm/dropdown/Dropdown.js +48 -0
  125. package/esm/dropdown/DropdownButtonOption.js +36 -0
  126. package/esm/dropdown/DropdownContent.js +83 -0
  127. package/esm/dropdown/DropdownDivOption.js +19 -0
  128. package/esm/dropdown/DropdownItem.js +19 -0
  129. package/esm/dropdown/DropdownLinkOption.js +17 -0
  130. package/esm/dropdown/DropdownToggle.js +31 -0
  131. package/esm/dropdown/index.js +11 -0
  132. package/esm/dropdown/subComponent/DropdownContext.js +3 -0
  133. package/esm/dropzone/FileDropzone.js +472 -0
  134. package/esm/dropzone/ImageDropzone.js +327 -0
  135. package/esm/dropzone/index.js +2 -0
  136. package/esm/dropzone/subComponent/Message.js +19 -0
  137. package/esm/figure/IconFigure.js +35 -0
  138. package/esm/figure/ImageFigure.js +31 -0
  139. package/esm/figure/index.js +2 -0
  140. package/esm/file/HiddenFileInput.js +8 -0
  141. package/esm/file/index.js +1 -0
  142. package/esm/form/Checkbox.js +157 -0
  143. package/esm/form/Fieldset.js +11 -0
  144. package/esm/form/FormItem.js +15 -0
  145. package/esm/form/Input.js +59 -0
  146. package/esm/form/Label.js +54 -0
  147. package/esm/form/MutedText.js +14 -0
  148. package/esm/form/PasswordInput.js +40 -0
  149. package/esm/form/RadioButton.js +94 -0
  150. package/esm/form/SearchSelect.js +174 -0
  151. package/esm/form/Searchbox.js +91 -0
  152. package/esm/form/Slider.js +39 -0
  153. package/esm/form/SwitchButton.js +97 -0
  154. package/esm/form/Textarea.js +34 -0
  155. package/esm/form/TreeView.js +66 -0
  156. package/esm/form/index.js +14 -0
  157. package/esm/grid/Column.js +39 -0
  158. package/esm/grid/Grid.js +28 -0
  159. package/esm/grid/index.js +2 -0
  160. package/esm/heading/Heading1.js +14 -0
  161. package/esm/heading/Heading2.js +21 -0
  162. package/esm/heading/Heading3.js +42 -0
  163. package/esm/heading/index.js +3 -0
  164. package/esm/helmet/Helmet.js +17 -0
  165. package/esm/helmet/index.js +3 -0
  166. package/esm/iconbox/ApplicationIconBox.js +74 -0
  167. package/esm/iconbox/IconBox.js +60 -0
  168. package/esm/iconbox/IconBoxV2.js +63 -0
  169. package/esm/iconbox/index.js +3 -0
  170. package/esm/iconbox/subComponent/IconBoxFigure.js +43 -0
  171. package/esm/iconbox/subComponent/IconBoxImage.js +35 -0
  172. package/esm/image/ImageFluid.js +10 -0
  173. package/esm/image/UploadImage.js +243 -0
  174. package/esm/image/index.js +2 -0
  175. package/esm/index.js +47 -0
  176. package/esm/keyframe/Pulse.js +15 -0
  177. package/esm/keyframe/Spin.js +7 -0
  178. package/esm/layout/Aside.js +39 -0
  179. package/esm/layout/AsideHeader.jsx +27 -0
  180. package/esm/layout/Backdrop.js +16 -0
  181. package/esm/layout/Container.js +30 -0
  182. package/esm/layout/Footer.js +36 -0
  183. package/esm/layout/Header.jsx +55 -0
  184. package/esm/layout/Layout.jsx +84 -0
  185. package/esm/layout/Logo.jsx +17 -0
  186. package/esm/layout/MenuIcon.jsx +27 -0
  187. package/esm/layout/Sidebar.jsx +271 -0
  188. package/esm/layout/index.js +1 -0
  189. package/esm/link/LinkSpan.js +62 -0
  190. package/esm/link/index.js +1 -0
  191. package/esm/map/GoogleMap.js +439 -0
  192. package/esm/map/GoogleReverseGeolocation.js +193 -0
  193. package/esm/map/LeafletMap.js +224 -0
  194. package/esm/map/LeafletReverseGeolocation.js +94 -0
  195. package/esm/map/index.js +4 -0
  196. package/esm/map/subComponent/BasicLeafletMap.js +27 -0
  197. package/esm/map/subComponent/GoogleMapContainer.js +22 -0
  198. package/esm/map/subComponent/GoogleMapPopup.js +103 -0
  199. package/esm/map/subComponent/GoogleMapWrapper.js +34 -0
  200. package/esm/map/subComponent/LeafletDrawControl.js +116 -0
  201. package/esm/map/subComponent/LeafletMapContainer.js +166 -0
  202. package/esm/map/subComponent/MapSearchBoxControl.js +47 -0
  203. package/esm/modal/StateModal.js +169 -0
  204. package/esm/modal/TitleModal.js +241 -0
  205. package/esm/modal/index.js +2 -0
  206. package/esm/page/Disclaimer.js +121 -0
  207. package/esm/page/index.js +1 -0
  208. package/esm/paginate/Paginate.js +129 -0
  209. package/esm/paginate/index.js +1 -0
  210. package/esm/popover/Popover.js +82 -0
  211. package/esm/popover/index.js +1 -0
  212. package/esm/qrcode/QRCode.js +51 -0
  213. package/esm/qrcode/QRCodeContainter.js +27 -0
  214. package/esm/qrcode/index.js +2 -0
  215. package/esm/ribbon/Ribbon.js +35 -0
  216. package/esm/ribbon/index.js +1 -0
  217. package/esm/section/Section.js +126 -0
  218. package/esm/section/SectionBody.js +43 -0
  219. package/esm/section/SectionHeader.js +61 -0
  220. package/esm/section/SectionToolbar.js +11 -0
  221. package/esm/section/SectionToolbarItem.js +10 -0
  222. package/esm/section/index.js +5 -0
  223. package/esm/select/InputSelect.js +263 -0
  224. package/esm/select/Select.js +811 -0
  225. package/esm/select/index.js +2 -0
  226. package/esm/select/subComponent/Checkbox.js +40 -0
  227. package/esm/select/subComponent/Footer.js +6 -0
  228. package/esm/select/subComponent/ListBox.js +23 -0
  229. package/esm/select/subComponent/Option.js +37 -0
  230. package/esm/select/subComponent/OptionGroup.js +16 -0
  231. package/esm/select/subComponent/Options.js +25 -0
  232. package/esm/select/subComponent/SearchBox.js +51 -0
  233. package/esm/select/subComponent/SelectedMultipleCount.js +32 -0
  234. package/esm/select/subComponent/SelectedMultipleTags.js +47 -0
  235. package/esm/select/subComponent/SelectedMultipleText.js +63 -0
  236. package/esm/select/subComponent/SelectedSingle.js +10 -0
  237. package/esm/styles/GlobalStyle.js +328 -0
  238. package/esm/styles/config/breakpoint.style.js +7 -0
  239. package/esm/styles/config/header.style.js +4 -0
  240. package/esm/styles/config/sidebar.style.js +11 -0
  241. package/esm/styles/index.js +2 -0
  242. package/esm/styles/mixin/backgroundColor.js +38 -0
  243. package/esm/styles/mixin/borderColor.js +31 -0
  244. package/esm/styles/mixin/color.js +31 -0
  245. package/esm/styles/mixin/colorOnBackground.js +31 -0
  246. package/esm/styles/mixin/inputPlaceholder.js +24 -0
  247. package/esm/styles/mixin/media.js +15 -0
  248. package/esm/styles/mixin/rounded.js +24 -0
  249. package/esm/styles/mixin/scrollbar.js +26 -0
  250. package/esm/styles/theme/dark.theme.js +91 -0
  251. package/esm/styles/theme/light.theme.js +91 -0
  252. package/esm/styles/theme/white.theme.js +91 -0
  253. package/esm/styles/themes.js +9 -0
  254. package/esm/table/GridTable.js +329 -0
  255. package/esm/table/ImageBox.js +38 -0
  256. package/esm/table/InfiniteGridTable.js +396 -0
  257. package/esm/table/PermissionTable.js +57 -0
  258. package/esm/table/SimpleGridTable.js +136 -0
  259. package/esm/table/Table.js +559 -0
  260. package/esm/table/__mock__/columns.js +64 -0
  261. package/esm/table/__mock__/data.js +530 -0
  262. package/esm/table/hooks/index.js +2 -0
  263. package/esm/table/hooks/useCalculateDataRange.js +22 -0
  264. package/esm/table/hooks/useGenerateSort.js +32 -0
  265. package/esm/table/index.js +6 -0
  266. package/esm/table/subComponent/BaseTableHeadCell.js +54 -0
  267. package/esm/table/subComponent/GridTableFooter.js +17 -0
  268. package/esm/table/subComponent/GridTableHeadCell.js +13 -0
  269. package/esm/table/subComponent/Resizer.js +70 -0
  270. package/esm/table/subComponent/TableFooter.js +24 -0
  271. package/esm/table/subComponent/TableFooterInfo.js +6 -0
  272. package/esm/table/subComponent/TableFooterPager.js +26 -0
  273. package/esm/table/subComponent/TableHeadCell.js +12 -0
  274. package/esm/table/subComponent/TableSort.js +31 -0
  275. package/esm/tagify/TagifyStyle.js +54 -0
  276. package/esm/tagify/Tags.js +49 -0
  277. package/esm/tagify/index.js +3 -0
  278. package/esm/tagify/templates/getCreateButtonTemplate.js +12 -0
  279. package/esm/text/Paragraph.js +79 -0
  280. package/esm/text/index.js +1 -0
  281. package/esm/timeline/Timeline.js +132 -0
  282. package/esm/timeline/index.js +1 -0
  283. package/esm/toast/CustomToastContainer.js +38 -0
  284. package/esm/toast/MessageContainer.js +44 -0
  285. package/esm/toast/index.js +3 -0
  286. package/esm/toast/show.js +29 -0
  287. package/esm/toast/style.css +1 -0
  288. package/esm/tooltip/Tooltip.js +133 -0
  289. package/esm/tooltip/index.js +1 -0
  290. package/esm/treeView/TreeViewV2.js +32 -0
  291. package/esm/treeView/TreeflexStyle.js +43 -0
  292. package/esm/treeView/index.js +2 -0
  293. package/esm/wizard/Wizard.js +244 -0
  294. package/esm/wizard/index.js +1 -0
  295. package/helmet/index.js +3 -7
  296. package/index.js +0 -12
  297. package/layout/Sidebar.jsx +1 -1
  298. package/package.json +5 -4
  299. package/datetimePicker/DatePicker.js +0 -363
  300. package/datetimePicker/DatePickerV2.js +0 -407
  301. package/datetimePicker/DatetimePickerV2.js +0 -395
  302. package/datetimePicker/TimePicker.js +0 -317
  303. package/datetimePicker/hooks/index.js +0 -27
  304. package/datetimePicker/hooks/useChangeNumber.js +0 -42
  305. package/datetimePicker/hooks/useDecrease.js +0 -38
  306. package/datetimePicker/hooks/useIncrease.js +0 -38
  307. package/datetimePicker/subComponent/Accordion.js +0 -373
  308. package/datetimePicker/subComponent/CustomTimeInput.js +0 -47
  309. package/jsoneditor/JsonEditor.js +0 -142
  310. package/jsoneditor/index.js +0 -13
@@ -0,0 +1,224 @@
1
+ import { useCallback, useEffect, useState, useRef } from 'react';
2
+ import L from 'leaflet';
3
+ import { Marker, Popup, useMapEvents, FeatureGroup, Circle } from 'react-leaflet';
4
+ import MarkerClusterGroup from 'react-leaflet-markercluster';
5
+ import 'leaflet/dist/leaflet.css';
6
+ import 'react-leaflet-markercluster/dist/styles.min.css';
7
+ import BasicLeafletMap from './subComponent/BasicLeafletMap';
8
+ import LeafletDrawControl from './subComponent/LeafletDrawControl';
9
+ import PrimaryMapIcon from '../assets/icons/map_icon1.png';
10
+ import MapIcon from '../assets/icons/map_icon4.png';
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ const LeafletMap = _ref => {
13
+ let {
14
+ height = 512,
15
+ zoom = 10,
16
+ data = {
17
+ defaultPosition: null,
18
+ position: null,
19
+ locations: []
20
+ },
21
+ geoFence = false,
22
+ geoFenceOptions = {},
23
+ onError,
24
+ customPopup,
25
+ checkPrimaryLocation
26
+ } = _ref;
27
+ const [hasError, setHasError] = useState(true);
28
+ const [validLocations, setValidLocations] = useState([]);
29
+ const [validBound, setValidBound] = useState([]);
30
+ const [markers, setMarkers] = useState([]);
31
+ const drawControlRef = useRef();
32
+ const handleError = useCallback(errorCode => {
33
+ if (onError) {
34
+ onError(errorCode);
35
+ }
36
+ }, [onError]);
37
+ const handleMountedDrawControl = useCallback(control => {
38
+ drawControlRef.current = control;
39
+ if (geoFenceOptions.editable) {
40
+ drawControlRef.current.enableEdit();
41
+ }
42
+ }, [geoFenceOptions.editable]);
43
+ const handleEditResizeDraw = useCallback(event => {
44
+ const {
45
+ minRadius,
46
+ eventHandlers
47
+ } = geoFenceOptions;
48
+ const radius = event.layer.getRadius();
49
+ if (minRadius && radius < minRadius) {
50
+ event.layer.setRadius(minRadius);
51
+ return;
52
+ }
53
+ const tooltips = event.target._panes.popupPane.getElementsByClassName('leaflet-draw-tooltip');
54
+ for (let index = 0; index < tooltips.length; index += 1) {
55
+ tooltips[index].textContent = `Radius: ${parseInt(radius, 10)}`;
56
+ }
57
+ if (eventHandlers.edit) {
58
+ eventHandlers.edit(radius);
59
+ }
60
+ }, [geoFenceOptions]);
61
+ const handleEditMoveDraw = useCallback(event => {
62
+ const {
63
+ eventHandlers
64
+ } = geoFenceOptions;
65
+ if (eventHandlers.drag) {
66
+ eventHandlers.drag(event.layer.getLatLng());
67
+ }
68
+ }, [geoFenceOptions]);
69
+ useEffect(() => {
70
+ const {
71
+ defaultPosition,
72
+ position,
73
+ locations
74
+ } = data;
75
+ const arrLatLngs = [];
76
+ const bounds = [];
77
+ const markers = [];
78
+ if (!position && !defaultPosition) {
79
+ handleError('NO_COORDINATES');
80
+ setHasError(true);
81
+ return;
82
+ }
83
+ locations.forEach((location, index) => {
84
+ const {
85
+ latitude,
86
+ longitude
87
+ } = location;
88
+ if (!latitude && latitude !== 0 || !longitude && longitude !== 0 || latitude === 0 && longitude === 0 || latitude === '0' && longitude === '0') {
89
+ return;
90
+ }
91
+
92
+ // prevent duplicate LatLngBounds
93
+ if (!bounds.some(LatLng => {
94
+ return latitude === LatLng[0] && longitude === LatLng[1];
95
+ })) {
96
+ bounds.push([latitude, longitude]);
97
+ }
98
+ arrLatLngs.push([latitude, longitude]);
99
+ let popupContent = null;
100
+ if (customPopup) {
101
+ popupContent = /*#__PURE__*/_jsx(Popup, {
102
+ maxWidth: 400,
103
+ closeButton: false,
104
+ children: customPopup(location)
105
+ });
106
+ }
107
+ let Icon = L.icon({
108
+ iconUrl: MapIcon,
109
+ iconSize: [40, 50]
110
+ });
111
+ if (checkPrimaryLocation && checkPrimaryLocation(location)) {
112
+ Icon = L.icon({
113
+ iconUrl: PrimaryMapIcon,
114
+ iconSize: [40, 50]
115
+ });
116
+ }
117
+ markers.push(/*#__PURE__*/_jsx(Marker, {
118
+ position: [latitude, longitude],
119
+ icon: Icon,
120
+ children: popupContent
121
+ }, index));
122
+ });
123
+
124
+ // pass all checking
125
+ setHasError(false);
126
+ setValidLocations(arrLatLngs);
127
+ setValidBound(bounds);
128
+ setMarkers(markers);
129
+ }, [data, handleError, customPopup, checkPrimaryLocation]);
130
+ useEffect(() => {
131
+ if (drawControlRef.current && geoFenceOptions.editable) {
132
+ drawControlRef.current.enableEdit();
133
+ }
134
+ }, [geoFenceOptions.editable]);
135
+ if (!hasError) {
136
+ return /*#__PURE__*/_jsxs(BasicLeafletMap, {
137
+ height: height,
138
+ zoom: zoom,
139
+ children: [/*#__PURE__*/_jsx(MapInteractor, {
140
+ zoom: zoom,
141
+ locations: validLocations,
142
+ bounds: validBound,
143
+ markers: markers,
144
+ defaultPosition: data.defaultPosition,
145
+ position: data.position
146
+ }), markers.length > 0 && /*#__PURE__*/_jsx(MarkerClusterGroup, {
147
+ maxClusterRadius: 120,
148
+ iconCreateFunction: cluster => {
149
+ return L.divIcon({
150
+ html: `<div><span>${cluster.getChildCount()}</span></div>`,
151
+ className: 'marker-cluster',
152
+ iconSize: L.point(40, 40)
153
+ });
154
+ },
155
+ children: markers
156
+ }), geoFence && /*#__PURE__*/_jsxs(FeatureGroup, {
157
+ children: [/*#__PURE__*/_jsx(LeafletDrawControl, {
158
+ draw: false,
159
+ edit: {
160
+ edit: false,
161
+ remove: false
162
+ },
163
+ onMounted: handleMountedDrawControl,
164
+ onEditResize: handleEditResizeDraw,
165
+ onEditMove: handleEditMoveDraw
166
+ }), /*#__PURE__*/_jsx(Circle, {
167
+ center: [geoFenceOptions.latitude, geoFenceOptions.longitude],
168
+ radius: geoFenceOptions.radius,
169
+ pathOptions: {
170
+ stroke: false,
171
+ fillColor: 'var(--color-primary)',
172
+ fillOpacity: 0.5
173
+ }
174
+ })]
175
+ })]
176
+ });
177
+ }
178
+ return /*#__PURE__*/_jsx("div", {});
179
+ };
180
+ const MapInteractor = _ref2 => {
181
+ let {
182
+ zoom,
183
+ locations,
184
+ bounds,
185
+ markers,
186
+ defaultPosition,
187
+ position
188
+ } = _ref2;
189
+ const map = useMapEvents({
190
+ click: event => {
191
+ event.originalEvent.stopPropagation();
192
+ },
193
+ focus: () => {
194
+ map.scrollWheelZoom.enable();
195
+ },
196
+ blur: () => {
197
+ map.scrollWheelZoom.disable();
198
+ }
199
+ });
200
+ useEffect(() => {
201
+ if (bounds.length === 1) {
202
+ map.setView(bounds[0]);
203
+ } else if (locations.length > 0) {
204
+ map.fitBounds(bounds);
205
+
206
+ // check current view has marker, if not set view to first marker
207
+ const currentBounds = map.getBounds();
208
+ const found = locations.find(LatLng => {
209
+ const tmpLat = parseFloat(LatLng[0]);
210
+ const tmpLng = parseFloat(LatLng[1]);
211
+ if (Number.isNaN(tmpLat) || Number.isNaN(tmpLng)) return false;
212
+ return currentBounds.contains([tmpLat, tmpLng]);
213
+ });
214
+ if (!found) {
215
+ map.setView(locations[0]);
216
+ }
217
+ } else {
218
+ map.setView([position && position.latitude || defaultPosition.latitude, position && position.longitude || defaultPosition.longitude]);
219
+ }
220
+ map.setZoom(zoom);
221
+ }, [map, zoom, locations, bounds, markers, defaultPosition, position]);
222
+ return null;
223
+ };
224
+ export default LeafletMap;
@@ -0,0 +1,94 @@
1
+ import { useState, useMemo, useEffect } from 'react';
2
+ import L from 'leaflet';
3
+ import { Marker, useMapEvents } from 'react-leaflet';
4
+ import BasicLeafletMap from './subComponent/BasicLeafletMap';
5
+ import MapSearchBoxControl from './subComponent/MapSearchBoxControl';
6
+ import MapIcon from '../assets/icons/map_icon4.png';
7
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
8
+ const LeafletReverseGeolocation = _ref => {
9
+ let {
10
+ children,
11
+ defaultLatlng,
12
+ changeLatlng,
13
+ onChoose,
14
+ onSearch,
15
+ onError
16
+ } = _ref;
17
+ const [markerLatLng, setMarkerLatLng] = useState(defaultLatlng);
18
+ const Icon = useMemo(() => {
19
+ return L.icon({
20
+ iconUrl: MapIcon,
21
+ iconSize: [40, 50]
22
+ });
23
+ }, []);
24
+ const handleChangeLatlng = latlng => {
25
+ setMarkerLatLng(latlng);
26
+ changeLatlng(latlng);
27
+ };
28
+ const confirmChooseLocation = async callback => {
29
+ if (markerLatLng.lat && markerLatLng.lng) {
30
+ try {
31
+ const address = await onChoose(markerLatLng);
32
+ if (address) {
33
+ callback({
34
+ address
35
+ });
36
+ } else {
37
+ callback({
38
+ error: 'ReverseGeo'
39
+ });
40
+ }
41
+ } catch (error) {
42
+ callback(error);
43
+ }
44
+ } else {
45
+ callback({
46
+ error: 'PleaseChooseLocation'
47
+ });
48
+ }
49
+ };
50
+ const Map = /*#__PURE__*/_jsxs(BasicLeafletMap, {
51
+ height: 500,
52
+ zoom: 10,
53
+ scrollWheelZoom: true,
54
+ children: [markerLatLng.lat && markerLatLng.lng && /*#__PURE__*/_jsx(Marker, {
55
+ position: [markerLatLng.lat, markerLatLng.lng],
56
+ icon: Icon
57
+ }), /*#__PURE__*/_jsx(MapInteractor, {
58
+ changeLatlng: handleChangeLatlng
59
+ }), /*#__PURE__*/_jsx(MapSearchBoxControl, {
60
+ changeLatlng: handleChangeLatlng,
61
+ onSearch: onSearch,
62
+ onError: onError
63
+ })]
64
+ });
65
+ return /*#__PURE__*/_jsx(_Fragment, {
66
+ children: children(Map, confirmChooseLocation)
67
+ });
68
+ };
69
+ const MapInteractor = _ref2 => {
70
+ let {
71
+ changeLatlng
72
+ } = _ref2;
73
+ const map = useMapEvents({
74
+ click: event => {
75
+ const {
76
+ lat,
77
+ lng
78
+ } = event.latlng;
79
+ changeLatlng({
80
+ lat: lat.toString(),
81
+ lng: lng.toString()
82
+ });
83
+ }
84
+ });
85
+ useEffect(() => {
86
+ const bounds = L.latLngBounds([[90, 180], [-90, -180]]);
87
+ const wantedZoom = map.getBoundsZoom(bounds, true);
88
+ const center = bounds.getCenter();
89
+ map.setView(center);
90
+ map.setZoom(wantedZoom);
91
+ }, [map]);
92
+ return null;
93
+ };
94
+ export default LeafletReverseGeolocation;
@@ -0,0 +1,4 @@
1
+ export { default as LeafletMap } from './LeafletMap';
2
+ export { default as LeafletReverseGeolocation } from './LeafletReverseGeolocation';
3
+ export { default as GoogleMap } from './GoogleMap';
4
+ export { default as GoogleReverseGeolocation } from './GoogleReverseGeolocation';
@@ -0,0 +1,27 @@
1
+ import LeafletMapContainer from './LeafletMapContainer';
2
+ import { TileLayer } from 'react-leaflet';
3
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
+ const BasicLeafletMap = _ref => {
5
+ let {
6
+ height,
7
+ zoom,
8
+ scrollWheelZoom = false,
9
+ children
10
+ } = _ref;
11
+ return /*#__PURE__*/_jsxs(LeafletMapContainer, {
12
+ height: height,
13
+ center: [1, 1],
14
+ zoom: zoom,
15
+ scrollWheelZoom: scrollWheelZoom,
16
+ maxBounds: [[-90, -180], [90, 180]],
17
+ children: [/*#__PURE__*/_jsx(TileLayer, {
18
+ attribution: "Map data \xA9 <a href=\"https://www.openstreetmap.org/\">OpenStreetMap</a> contributors",
19
+ url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
20
+ minZoom: 3,
21
+ maxZoom: 20,
22
+ noWrap: true,
23
+ bounds: [[-90, -180], [90, 180]]
24
+ }), children]
25
+ });
26
+ };
27
+ export default BasicLeafletMap;
@@ -0,0 +1,22 @@
1
+ import styled from 'styled-components';
2
+ const GoogleMapContainer = styled.div`
3
+ height: ${_ref => {
4
+ let {
5
+ height
6
+ } = _ref;
7
+ return height;
8
+ }}px;
9
+ border: 1px solid transparent;
10
+ border-radius: var(--border-radius);
11
+
12
+ &:focus {
13
+ border-color: var(--border-color);
14
+ box-shadow: var(--box-shadow);
15
+ }
16
+
17
+ .google-popup-content-wrapper {
18
+ position: absolute;
19
+ transform: translate(-50%, -100%);
20
+ }
21
+ `;
22
+ export default GoogleMapContainer;
@@ -0,0 +1,103 @@
1
+ // custom popup
2
+ // https://developers.google.com/maps/documentation/javascript/examples/overlay-popup
3
+ class GoogleMapPopup {
4
+ constructor(options) {
5
+ // wrap class to prevent cannot reference maps during runtime
6
+ // because google map library will load after render map only
7
+ class MapPopup extends window.google.maps.OverlayView {
8
+ position;
9
+ containerDiv;
10
+ offset = 16;
11
+ justRendered = false;
12
+ constructor() {
13
+ let {
14
+ maxWidth,
15
+ offset
16
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
17
+ super();
18
+
19
+ // This zero-height div is positioned at the bottom of the tip.
20
+ this.containerDiv = document.createElement('div');
21
+ this.containerDiv.classList.add('google-popup-content-wrapper');
22
+ if (maxWidth) {
23
+ this.containerDiv.style.maxWidth = `${maxWidth}px`;
24
+ }
25
+ if (offset) {
26
+ this.offset = offset;
27
+ }
28
+
29
+ // Optionally stop clicks, etc., from bubbling up to the map.
30
+ MapPopup.preventMapHitsAndGesturesFrom(this.containerDiv);
31
+ }
32
+ /** Called when the popup is added to the map. */
33
+ onAdd() {
34
+ this.getPanes().floatPane.appendChild(this.containerDiv);
35
+ this.justRendered = true;
36
+ }
37
+ /** Called when the popup is removed from the map. */
38
+ onRemove() {
39
+ if (this.containerDiv.parentElement) {
40
+ this.containerDiv.parentElement.removeChild(this.containerDiv);
41
+ this.justRendered = false;
42
+ }
43
+ }
44
+ /** Called each frame when the popup needs to draw itself. */
45
+ draw() {
46
+ if (this.position) {
47
+ const divPosition = this.getProjection().fromLatLngToDivPixel(this.position);
48
+
49
+ // On the first render, if we go beyond the map, pan the map
50
+ if (this.justRendered) {
51
+ this.fitMap();
52
+ this.justRendered = false;
53
+ }
54
+ this.containerDiv.style.left = `${divPosition.x}px`;
55
+ this.containerDiv.style.top = `${divPosition.y - this.offset}px`;
56
+ }
57
+ }
58
+ setPosition(position) {
59
+ this.position = position;
60
+ }
61
+ setContent(content) {
62
+ if (!content) return;
63
+ if (typeof content === 'object') {
64
+ this.containerDiv.replaceChildren(content);
65
+ } else {
66
+ this.containerDiv.innerHTML = content;
67
+ }
68
+ }
69
+ fitMap() {
70
+ const projection = this.getProjection();
71
+ const {
72
+ offsetWidth,
73
+ offsetHeight
74
+ } = this.containerDiv;
75
+ const halfWidth = offsetWidth / 2;
76
+ const {
77
+ offsetTop,
78
+ offsetLeft
79
+ } = this.containerDiv;
80
+
81
+ // Calculate the coordinates of the four corners of the container
82
+ // because container use transform for position(-50%, -100%), so we need to subtract them
83
+ const topLeft = new window.google.maps.Point(offsetLeft - halfWidth, offsetTop - offsetHeight);
84
+ const topRight = new window.google.maps.Point(offsetLeft + offsetWidth - halfWidth, offsetTop - offsetHeight);
85
+ const bottomLeft = new window.google.maps.Point(offsetLeft - halfWidth, offsetTop + offsetHeight - offsetHeight);
86
+ const bottomRight = new window.google.maps.Point(offsetLeft + offsetWidth - halfWidth, offsetTop + offsetHeight - offsetHeight);
87
+ const northWest = projection.fromDivPixelToLatLng(topLeft);
88
+ const northEast = projection.fromDivPixelToLatLng(topRight);
89
+ const southWest = projection.fromDivPixelToLatLng(bottomLeft);
90
+ const southEast = projection.fromDivPixelToLatLng(bottomRight);
91
+ const popupBound = new window.google.maps.LatLngBounds();
92
+ popupBound.extend(northWest);
93
+ popupBound.extend(northEast);
94
+ popupBound.extend(southWest);
95
+ popupBound.extend(southEast);
96
+ popupBound.extend(this.position);
97
+ this.map.fitBounds(popupBound);
98
+ }
99
+ }
100
+ return new MapPopup(options);
101
+ }
102
+ }
103
+ export default GoogleMapPopup;
@@ -0,0 +1,34 @@
1
+ import { cloneElement } from 'react';
2
+ import { Wrapper, Status } from '@googlemaps/react-wrapper';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ const GoogleMapWrapper = _ref => {
5
+ let {
6
+ children,
7
+ apiKey,
8
+ onError,
9
+ ...props
10
+ } = _ref;
11
+ const render = status => {
12
+ switch (status) {
13
+ case Status.LOADING:
14
+ return /*#__PURE__*/_jsx("div", {});
15
+ case Status.FAILURE:
16
+ onError(status);
17
+ return /*#__PURE__*/_jsx("div", {});
18
+ default:
19
+ break;
20
+ }
21
+ };
22
+ return /*#__PURE__*/_jsx(Wrapper, {
23
+ apiKey: apiKey,
24
+ render: render,
25
+ style: {
26
+ position: 'relative'
27
+ },
28
+ children: /*#__PURE__*/cloneElement(children, {
29
+ ...props,
30
+ onError
31
+ })
32
+ });
33
+ };
34
+ export default GoogleMapWrapper;
@@ -0,0 +1,116 @@
1
+ import { useEffect, useRef, useCallback } from 'react';
2
+ import L, { Control } from 'leaflet';
3
+ import Draw from 'leaflet-draw'; // eslint-disable-line
4
+ import 'leaflet-draw/dist/leaflet.draw.css';
5
+ import { useLeafletContext } from '@react-leaflet/core';
6
+ import isEqual from 'fast-deep-equal';
7
+ const eventHandlers = {
8
+ onEdited: 'draw:edited',
9
+ onDrawStart: 'draw:drawstart',
10
+ onDrawStop: 'draw:drawstop',
11
+ onDrawVertex: 'draw:drawvertex',
12
+ onEditStart: 'draw:editstart',
13
+ onEditMove: 'draw:editmove',
14
+ onEditResize: 'draw:editresize',
15
+ onEditVertex: 'draw:editvertex',
16
+ onEditStop: 'draw:editstop',
17
+ onDeleted: 'draw:deleted',
18
+ onDeleteStart: 'draw:deletestart',
19
+ onDeleteStop: 'draw:deletestop'
20
+ };
21
+ L.drawLocal.edit.handlers.edit.tooltip = {
22
+ text: 'Drag handles or markers to edit features.',
23
+ subtext: null
24
+ };
25
+ const LeafletDrawControl = props => {
26
+ const {
27
+ map,
28
+ layerContainer
29
+ } = useLeafletContext();
30
+ const drawRef = useRef();
31
+ const propsRef = useRef(props);
32
+ const onDrawCreate = useCallback(event => {
33
+ const container = layerContainer;
34
+ container.addLayer(event.layer);
35
+ }, [layerContainer]);
36
+ const enableEdit = useCallback(() => {
37
+ // programatically enable edit mode
38
+ // https://github.com/Leaflet/Leaflet.draw/issues/129
39
+ const editHandler = drawRef.current._toolbars.edit.getModeHandlers()[0].handler;
40
+ // this is hacky but needed otherwise enabling the edit mode will fail
41
+ // when the code attempts to fire map events for edit start etc
42
+ editHandler._map = map;
43
+ editHandler.enable();
44
+ }, [map]);
45
+ useEffect(() => {
46
+ // if rendered and all props no change prevent render again
47
+ if (drawRef.current && props.draw !== undefined && isEqual(props.draw, propsRef.current.draw) && isEqual(props.edit, propsRef.current.edit) && props.position === propsRef.current.position) {
48
+ return;
49
+ }
50
+
51
+ // add event listener
52
+ for (const key in eventHandlers) {
53
+ map.on(eventHandlers[key], evt => {
54
+ const handlers = Object.keys(eventHandlers).filter(handler => eventHandlers[handler] === evt.type);
55
+ if (handlers.length === 1) {
56
+ const [handler] = handlers;
57
+ props[handler] && props[handler](evt);
58
+ }
59
+ });
60
+ }
61
+
62
+ // add create draw event listener
63
+ map.on(L.Draw.Event.CREATED, onDrawCreate);
64
+
65
+ // create draw element and render on map
66
+ drawRef.current = createDrawElement(props, layerContainer);
67
+ map.addControl(drawRef.current);
68
+ drawRef.current.enableEdit = enableEdit;
69
+ if (props.onMounted) {
70
+ props.onMounted(drawRef.current);
71
+ }
72
+ return () => {
73
+ drawRef.current.remove(map);
74
+ drawRef.current = null;
75
+ map.off(L.Draw.Event.CREATED, onDrawCreate);
76
+ for (const key in eventHandlers) {
77
+ if (props[key]) {
78
+ map.off(eventHandlers[key], props[key]);
79
+ }
80
+ }
81
+ };
82
+ }, [props, map, layerContainer, onDrawCreate, enableEdit]);
83
+ return null;
84
+ };
85
+ const createDrawElement = (props, layerContainer) => {
86
+ const {
87
+ draw,
88
+ edit,
89
+ position
90
+ } = props;
91
+ const options = {
92
+ edit: {
93
+ featureGroup: layerContainer
94
+ }
95
+ };
96
+ if (draw !== undefined) {
97
+ if (typeof draw === 'object') {
98
+ options.draw = {
99
+ ...draw
100
+ };
101
+ } else {
102
+ options.draw = draw;
103
+ }
104
+ }
105
+ if (edit) {
106
+ options.edit = {
107
+ ...options.edit,
108
+ ...edit
109
+ };
110
+ }
111
+ if (position) {
112
+ options.position = position;
113
+ }
114
+ return new Control.Draw(options);
115
+ };
116
+ export default LeafletDrawControl;