@mint-ui/map 0.1.1-beta → 0.1.2-beta

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 (34) hide show
  1. package/dist/components/mint-map/MintMap.d.ts +2 -2
  2. package/dist/components/mint-map/MintMap.js +69 -49
  3. package/dist/components/mint-map/core/MintMapController.d.ts +1 -1
  4. package/dist/components/mint-map/core/MintMapController.js +3 -1
  5. package/dist/components/mint-map/core/MintMapCore.d.ts +1 -1
  6. package/dist/components/mint-map/core/MintMapCore.js +3 -1
  7. package/dist/components/mint-map/core/advanced/MapBuildingProjection.js +4 -4
  8. package/dist/components/mint-map/core/advanced/index.d.ts +1 -0
  9. package/dist/components/mint-map/core/hooks/index.d.ts +1 -0
  10. package/dist/components/mint-map/core/index.d.ts +7 -7
  11. package/dist/components/mint-map/core/provider/MintMapProvider.d.ts +2 -2
  12. package/dist/components/mint-map/core/provider/MintMapProvider.js +1 -1
  13. package/dist/components/mint-map/core/provider/index.d.ts +1 -0
  14. package/dist/components/mint-map/core/util/index.d.ts +3 -0
  15. package/dist/components/mint-map/core/util/waiting.d.ts +1 -1
  16. package/dist/components/mint-map/core/util/waiting.js +33 -0
  17. package/dist/components/mint-map/core/wrapper/MapControlWrapper.d.ts +1 -1
  18. package/dist/components/mint-map/core/wrapper/MapControlWrapper.js +3 -1
  19. package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.d.ts +1 -1
  20. package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.js +3 -1
  21. package/dist/components/mint-map/core/wrapper/MapPolygonWrapper.d.ts +1 -1
  22. package/dist/components/mint-map/core/wrapper/MapPolygonWrapper.js +3 -1
  23. package/dist/components/mint-map/core/wrapper/MapPolylineWrapper.d.ts +1 -1
  24. package/dist/components/mint-map/core/wrapper/MapPolylineWrapper.js +3 -1
  25. package/dist/components/mint-map/core/wrapper/index.d.ts +4 -0
  26. package/dist/components/mint-map/google/GoogleMintMapController.d.ts +2 -2
  27. package/dist/components/mint-map/google/GoogleMintMapController.js +431 -0
  28. package/dist/components/mint-map/index.d.ts +3 -1
  29. package/dist/components/mint-map/naver/NaverMintMapController.d.ts +2 -2
  30. package/dist/components/mint-map/naver/NaverMintMapController.js +427 -0
  31. package/dist/index.es.js +1095 -197
  32. package/dist/index.js +32 -9
  33. package/dist/index.umd.js +1109 -195
  34. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  /// <reference types="navermaps" />
2
2
  /// <reference types="google.maps" />
3
3
  import { PropsWithChildren } from "react";
4
- import MintMapController from "./core/MintMapController";
4
+ import { MintMapController } from "./core/MintMapController";
5
5
  export declare type MapType = 'naver' | 'google';
6
6
  export declare type MapVendorType = naver.maps.Map | google.maps.Map;
7
7
  export interface MintMapProps extends MintMapEvents {
@@ -78,4 +78,4 @@ export declare class Polygon extends Drawable {
78
78
  constructor(options: PolygonOptions);
79
79
  getCenter(): Position;
80
80
  }
81
- export default function MintMap({ mapType, children, ...props }: PropsWithChildren<MintMapProps>): JSX.Element;
81
+ export declare function MintMap({ mapType, children, ...props }: PropsWithChildren<MintMapProps>): JSX.Element;
@@ -9,27 +9,11 @@ var MintMap_module = require('./MintMap.module.scss.js');
9
9
  var MintMapCore = require('./core/MintMapCore.js');
10
10
  var MintMapProvider = require('./core/provider/MintMapProvider.js');
11
11
  var calculate = require('./core/util/calculate.js');
12
+ var NaverMintMapController = require('./naver/NaverMintMapController.js');
13
+ var GoogleMintMapController = require('./google/GoogleMintMapController.js');
12
14
 
13
15
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
16
 
15
- function _interopNamespace(e) {
16
- if (e && e.__esModule) return e;
17
- var n = Object.create(null);
18
- if (e) {
19
- Object.keys(e).forEach(function (k) {
20
- if (k !== 'default') {
21
- var d = Object.getOwnPropertyDescriptor(e, k);
22
- Object.defineProperty(n, k, d.get ? d : {
23
- enumerable: true,
24
- get: function () { return e[k]; }
25
- });
26
- }
27
- });
28
- }
29
- n["default"] = e;
30
- return Object.freeze(n);
31
- }
32
-
33
17
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
34
18
  var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
35
19
 
@@ -44,6 +28,56 @@ var Position = function () {
44
28
  return Position;
45
29
  }();
46
30
 
31
+ var Bounds = function () {
32
+ function Bounds(nw, se) {
33
+ this.nw = nw;
34
+ this.se = se;
35
+ }
36
+
37
+ Bounds.prototype.getCenter = function () {
38
+ return new Position(this.nw.lat + (this.se.lat - this.nw.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
39
+ };
40
+
41
+ Bounds.prototype.includes = function (positions) {
42
+ for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
43
+ var pos = positions_1[_i];
44
+
45
+ if (this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng) {
46
+ return false;
47
+ }
48
+ }
49
+
50
+ return true;
51
+ };
52
+
53
+ Bounds.prototype.includesOnlyOnePoint = function (positions) {
54
+ for (var _i = 0, positions_2 = positions; _i < positions_2.length; _i++) {
55
+ var pos = positions_2[_i];
56
+
57
+ if (!(this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng)) {
58
+ return true;
59
+ }
60
+ }
61
+
62
+ return false;
63
+ };
64
+
65
+ Bounds.prototype.intersects = function (positions) {
66
+ return calculate.PolygonCalculator.intersects([this.nw, this.se], positions);
67
+ };
68
+
69
+ return Bounds;
70
+ }();
71
+
72
+ var Offset = function () {
73
+ function Offset(x, y) {
74
+ this.x = x;
75
+ this.y = y;
76
+ }
77
+
78
+ return Offset;
79
+ }();
80
+
47
81
  var Drawable = function () {
48
82
  function Drawable() {}
49
83
 
@@ -101,8 +135,6 @@ var Polygon = function (_super) {
101
135
  }(Drawable);
102
136
  var cn = classNames__default["default"].bind(MintMap_module);
103
137
  function MintMap(_a) {
104
- var _this = this;
105
-
106
138
  var mapType = _a.mapType,
107
139
  children = _a.children,
108
140
  props = tslib.__rest(_a, ["mapType", "children"]);
@@ -114,36 +146,26 @@ function MintMap(_a) {
114
146
  React.useEffect(function () {
115
147
  if (mapType && mapType.length > 0) {
116
148
  setController(undefined);
117
-
118
- (function () {
119
- return tslib.__awaiter(_this, void 0, void 0, function () {
120
- var moduleName, controllerModule, newController;
121
- return tslib.__generator(this, function (_a) {
122
- switch (_a.label) {
123
- case 0:
124
- moduleName = getMapModulePrefix(mapType);
125
- return [4, (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })("./".concat(mapType, "/").concat(moduleName, "MintMapController"))];
126
-
127
- case 1:
128
- controllerModule = _a.sent();
129
- newController = new controllerModule.default(tslib.__assign({
130
- mapType: mapType
131
- }, props));
132
- newController.loadMapApi().then(function () {
133
- setController(newController);
134
- });
135
- return [2];
136
- }
137
- });
149
+ var newController_1 = mapType === 'naver' ? new NaverMintMapController.NaverMintMapController(tslib.__assign({
150
+ mapType: mapType
151
+ }, props)) : mapType === 'google' ? new GoogleMintMapController.GoogleMintMapController(tslib.__assign({
152
+ mapType: mapType
153
+ }, props)) : null;
154
+
155
+ if (newController_1) {
156
+ newController_1.loadMapApi().then(function () {
157
+ setController(newController_1);
138
158
  });
139
- })();
159
+ } else {
160
+ throw new Error("Not Supported Map type ".concat(mapType));
161
+ }
140
162
  } else {
141
163
  setController(undefined);
142
164
  }
143
165
  }, [mapType]);
144
- return React__default["default"].createElement(React__default["default"].Fragment, null, controller ? React__default["default"].createElement(MintMapProvider["default"], {
166
+ return React__default["default"].createElement(React__default["default"].Fragment, null, controller ? React__default["default"].createElement(MintMapProvider.MintMapProvider, {
145
167
  controller: controller
146
- }, React__default["default"].createElement(MintMapCore, tslib.__assign({
168
+ }, React__default["default"].createElement(MintMapCore.MintMapCore, tslib.__assign({
147
169
  mapType: mapType
148
170
  }, props), children)) : React__default["default"].createElement(PointLoading, {
149
171
  text: "Loading"
@@ -194,13 +216,11 @@ function PointLoading(_a) {
194
216
  }, "".concat(text, " ").concat(pointString)));
195
217
  }
196
218
 
197
- var getMapModulePrefix = function (mapType) {
198
- return mapType.substring(0, 1).toUpperCase() + mapType.substring(1).toLowerCase();
199
- };
200
-
219
+ exports.Bounds = Bounds;
201
220
  exports.Drawable = Drawable;
202
221
  exports.Marker = Marker;
222
+ exports.MintMap = MintMap;
223
+ exports.Offset = Offset;
203
224
  exports.Polygon = Polygon;
204
225
  exports.Polyline = Polyline;
205
226
  exports.Position = Position;
206
- exports["default"] = MintMap;
@@ -1,5 +1,5 @@
1
1
  import { Bounds, Drawable, MapType, MapVendorType, Marker, MarkerOptions, MintMapProps, Polygon, PolygonOptions, Polyline, PolylineOptions, Position } from "../MintMap";
2
- export default abstract class MintMapController {
2
+ export declare abstract class MintMapController {
3
3
  abstract type: MapType;
4
4
  abstract map: MapVendorType | null;
5
5
  abstract scriptUrl: string;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var tslib = require('tslib');
4
6
 
5
7
  var MintMapController = function () {
@@ -53,4 +55,4 @@ var MintMapController = function () {
53
55
  return MintMapController;
54
56
  }();
55
57
 
56
- module.exports = MintMapController;
58
+ exports.MintMapController = MintMapController;
@@ -1,3 +1,3 @@
1
1
  import { PropsWithChildren } from "react";
2
2
  import { MintMapProps } from "../MintMap";
3
- export default function MintMapCore({ onLoad, visible, children }: PropsWithChildren<MintMapProps>): JSX.Element;
3
+ export declare function MintMapCore({ onLoad, visible, children }: PropsWithChildren<MintMapProps>): JSX.Element;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var tslib = require('tslib');
4
6
  var classNames = require('classnames/bind');
5
7
  var React = require('react');
@@ -66,4 +68,4 @@ function MintMapCore(_a) {
66
68
  }));
67
69
  }
68
70
 
69
- module.exports = MintMapCore;
71
+ exports.MintMapCore = MintMapCore;
@@ -126,13 +126,13 @@ function MapBuildingProjection(props) {
126
126
 
127
127
  setBasePolygon(base);
128
128
  }, [props]);
129
- return React__default["default"].createElement(React__default["default"].Fragment, null, basePolygon && React__default["default"].createElement(MapPolygonWrapper, tslib.__assign({}, basePolygon, {
129
+ return React__default["default"].createElement(React__default["default"].Fragment, null, basePolygon && React__default["default"].createElement(MapPolygonWrapper.MapPolygonWrapper, tslib.__assign({}, basePolygon, {
130
130
  lineColor: lineColor,
131
131
  lineOpacity: lineOpacity,
132
132
  fillColor: fillColor,
133
133
  fillOpacity: fillOpacity
134
134
  })), wallPolygons.current && wallPolygons.current.map(function (poly, idx) {
135
- return React__default["default"].createElement(MapPolygonWrapper, tslib.__assign({
135
+ return React__default["default"].createElement(MapPolygonWrapper.MapPolygonWrapper, tslib.__assign({
136
136
  key: "walls-".concat(idx)
137
137
  }, poly, {
138
138
  lineColor: lineColor,
@@ -140,12 +140,12 @@ function MapBuildingProjection(props) {
140
140
  fillColor: fillColor,
141
141
  fillOpacity: fillOpacity
142
142
  }));
143
- }), roofPolygon.current && React__default["default"].createElement(MapPolygonWrapper, tslib.__assign({}, roofPolygon.current, {
143
+ }), roofPolygon.current && React__default["default"].createElement(MapPolygonWrapper.MapPolygonWrapper, tslib.__assign({}, roofPolygon.current, {
144
144
  lineColor: lineColor,
145
145
  lineOpacity: lineOpacity,
146
146
  fillColor: fillColor,
147
147
  fillOpacity: fillOpacity
148
- })), titlePosition.current && React__default["default"].createElement(MapMarkerWrapper, tslib.__assign({}, titlePosition.current), titleElement ? titleElement : React__default["default"].createElement("div", {
148
+ })), titlePosition.current && React__default["default"].createElement(MapMarkerWrapper.MapMarkerWrapper, tslib.__assign({}, titlePosition.current), titleElement ? titleElement : React__default["default"].createElement("div", {
149
149
  style: {
150
150
  width: '150px',
151
151
  height: '30px',
@@ -0,0 +1 @@
1
+ export * from './MapBuildingProjection';
@@ -0,0 +1 @@
1
+ export * from "./MarkerMovingHook";
@@ -1,7 +1,7 @@
1
- export { default as MintMapController } from "./MintMapController";
2
- export { default as MapControlWrapper } from './wrapper/MapControlWrapper';
3
- export { default as MapMarkerWrapper } from './wrapper/MapMarkerWrapper';
4
- export { default as MapPolygonWrapper } from './wrapper/MapPolygonWrapper';
5
- export { default as MapPolylineWrapper } from './wrapper/MapPolylineWrapper';
6
- export { default as MintMapProvider } from "./provider/MintMapProvider";
7
- export { MapBuildingProjection } from "./advanced/MapBuildingProjection";
1
+ export * from "./MintMapCore";
2
+ export * from "./MintMapController";
3
+ export * from "./advanced";
4
+ export * from "./hooks";
5
+ export * from "./provider";
6
+ export * from './util';
7
+ export * from './wrapper';
@@ -1,8 +1,8 @@
1
1
  import { PropsWithChildren } from "react";
2
- import MintMapController from "../MintMapController";
2
+ import { MintMapController } from "../MintMapController";
3
3
  interface MintMapProviderProps {
4
4
  controller: MintMapController;
5
5
  }
6
- export default function MintMapProvider({ controller, children }: PropsWithChildren<MintMapProviderProps>): JSX.Element;
6
+ export declare function MintMapProvider({ controller, children }: PropsWithChildren<MintMapProviderProps>): JSX.Element;
7
7
  export declare function useMintMapController(): MintMapController;
8
8
  export {};
@@ -26,5 +26,5 @@ function useMintMapController() {
26
26
  return controller;
27
27
  }
28
28
 
29
- exports["default"] = MintMapProvider;
29
+ exports.MintMapProvider = MintMapProvider;
30
30
  exports.useMintMapController = useMintMapController;
@@ -0,0 +1 @@
1
+ export * from "./MintMapProvider";
@@ -0,0 +1,3 @@
1
+ export * from './animation';
2
+ export * from './calculate';
3
+ export * from './waiting';
@@ -1 +1 @@
1
- export default function waiting(evaluation: () => boolean, timeoutSeconds?: number): Promise<boolean>;
1
+ export declare function waiting(evaluation: () => boolean, timeoutSeconds?: number): Promise<boolean>;
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+
7
+ function waiting(evaluation, timeoutSeconds) {
8
+ return tslib.__awaiter(this, void 0, void 0, function () {
9
+ var max;
10
+ return tslib.__generator(this, function (_a) {
11
+ max = (timeoutSeconds || 5) * 1000;
12
+ return [2, new Promise(function (resolve) {
13
+ var start = new Date().getTime();
14
+ var inter = setInterval(function () {
15
+ var time = new Date().getTime();
16
+
17
+ if (time - start > max) {
18
+ clearInterval(inter);
19
+ resolve(false);
20
+ return;
21
+ }
22
+
23
+ if (evaluation()) {
24
+ clearInterval(inter);
25
+ resolve(true);
26
+ }
27
+ }, 100);
28
+ })];
29
+ });
30
+ });
31
+ }
32
+
33
+ exports.waiting = waiting;
@@ -7,5 +7,5 @@ export interface MapControlWrapperProps {
7
7
  positionHorizontal?: AlignHorizontal;
8
8
  positionVertical?: AlignVertical;
9
9
  }
10
- export default function MapControlWrapper({ width, height, positionHorizontal, positionVertical, children }: PropsWithChildren<MapControlWrapperProps>): JSX.Element;
10
+ export declare function MapControlWrapper({ width, height, positionHorizontal, positionVertical, children }: PropsWithChildren<MapControlWrapperProps>): JSX.Element;
11
11
  export {};
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var React = require('react');
4
6
  var classNames = require('classnames/bind');
5
7
  var MintMapWrapper_module = require('./MintMapWrapper.module.scss.js');
@@ -74,4 +76,4 @@ function MapControlWrapper(_a) {
74
76
  }, children);
75
77
  }
76
78
 
77
- module.exports = MapControlWrapper;
79
+ exports.MapControlWrapper = MapControlWrapper;
@@ -20,4 +20,4 @@ export interface MapMarkerWrapperProps extends MarkerOptions {
20
20
  endAnimationClassName?: string;
21
21
  movingAnimation?: MapMarkerMoving;
22
22
  }
23
- export default function MapMarkerWrapper({ startAnimationClassName, endAnimationClassName, topOnClick, topOnHover, movingAnimation, children, ...options }: PropsWithChildren<MapMarkerWrapperProps>): JSX.Element;
23
+ export declare function MapMarkerWrapper({ startAnimationClassName, endAnimationClassName, topOnClick, topOnHover, movingAnimation, children, ...options }: PropsWithChildren<MapMarkerWrapperProps>): JSX.Element;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var tslib = require('tslib');
4
6
  var React = require('react');
5
7
  var reactDom = require('react-dom');
@@ -160,4 +162,4 @@ function MapMarkerWrapper(_a) {
160
162
  return reactDom.createPortal(children, divElement);
161
163
  }
162
164
 
163
- module.exports = MapMarkerWrapper;
165
+ exports.MapMarkerWrapper = MapMarkerWrapper;
@@ -2,4 +2,4 @@ import { PropsWithChildren } from "react";
2
2
  import { PolygonOptions } from "../../MintMap";
3
3
  export interface MapPolygonWrapperProps extends PolygonOptions {
4
4
  }
5
- export default function MapPolygonWrapper({ children, ...options }: PropsWithChildren<MapPolygonWrapperProps>): JSX.Element;
5
+ export declare function MapPolygonWrapper({ children, ...options }: PropsWithChildren<MapPolygonWrapperProps>): JSX.Element;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var tslib = require('tslib');
4
6
  var React = require('react');
5
7
  var MintMapProvider = require('../provider/MintMapProvider.js');
@@ -36,4 +38,4 @@ function MapPolygonWrapper(_a) {
36
38
  return React__default["default"].createElement(React__default["default"].Fragment, null, options && children);
37
39
  }
38
40
 
39
- module.exports = MapPolygonWrapper;
41
+ exports.MapPolygonWrapper = MapPolygonWrapper;
@@ -2,4 +2,4 @@ import { PropsWithChildren } from "react";
2
2
  import { PolylineOptions } from "../../MintMap";
3
3
  export interface MapPolylineWrapperProps extends PolylineOptions {
4
4
  }
5
- export default function MapPolylineWrapper({ children, ...options }: PropsWithChildren<MapPolylineWrapperProps>): JSX.Element;
5
+ export declare function MapPolylineWrapper({ children, ...options }: PropsWithChildren<MapPolylineWrapperProps>): JSX.Element;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var tslib = require('tslib');
4
6
  var React = require('react');
5
7
  var MintMapProvider = require('../provider/MintMapProvider.js');
@@ -36,4 +38,4 @@ function MapPolylineWrapper(_a) {
36
38
  return React__default["default"].createElement(React__default["default"].Fragment, null, options && children);
37
39
  }
38
40
 
39
- module.exports = MapPolylineWrapper;
41
+ exports.MapPolylineWrapper = MapPolylineWrapper;
@@ -0,0 +1,4 @@
1
+ export * from './MapControlWrapper';
2
+ export * from './MapMarkerWrapper';
3
+ export * from './MapPolygonWrapper';
4
+ export * from './MapPolylineWrapper';
@@ -1,7 +1,7 @@
1
1
  /// <reference types="google.maps" />
2
- import MintMapController from "../core/MintMapController";
2
+ import { MintMapController } from "../core/MintMapController";
3
3
  import { Bounds, Drawable, MapType, MapVendorType, Marker, MarkerOptions, MintMapProps, Polygon, PolygonOptions, Polyline, PolylineOptions, Position } from "../MintMap";
4
- export default class GoogleMintMapController extends MintMapController {
4
+ export declare class GoogleMintMapController extends MintMapController {
5
5
  type: MapType;
6
6
  map: google.maps.Map | null;
7
7
  scriptUrl: string;