@maplat/ui 0.10.6 → 0.11.1
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/LICENSE +223 -223
- package/README.md +128 -91
- package/assets/locales/de/translation.json +71 -0
- package/{locales → assets/locales}/en/translation.json +70 -64
- package/{locales → assets/locales}/ja/translation.json +70 -64
- package/{locales → assets/locales}/ko/translation.json +71 -65
- package/assets/locales/vi/translation.json +71 -0
- package/{locales → assets/locales}/zh/translation.json +71 -65
- package/{locales → assets/locales}/zh-TW/translation.json +71 -65
- package/assets/parts/attr.png +0 -0
- package/assets/parts/border.png +0 -0
- package/assets/parts/compass.png +0 -0
- package/assets/parts/gps.png +0 -0
- package/assets/parts/help.png +0 -0
- package/assets/parts/hide_marker.png +0 -0
- package/assets/parts/home.png +0 -0
- package/assets/parts/marker_list.png +0 -0
- package/assets/parts/share.png +0 -0
- package/dist/absolute_url.d.ts +1 -0
- package/dist/assets/locales/de/translation.json +71 -0
- package/dist/assets/locales/en/translation.json +70 -64
- package/dist/assets/locales/ja/translation.json +70 -64
- package/dist/assets/locales/ko/translation.json +71 -65
- package/dist/assets/locales/vi/translation.json +71 -0
- package/dist/assets/locales/zh/translation.json +71 -65
- package/dist/assets/locales/zh-TW/translation.json +71 -65
- package/dist/contextmenu.d.ts +5 -0
- package/dist/function.d.ts +2 -0
- package/dist/icons.d.ts +7 -0
- package/dist/index.d.ts +65 -0
- package/dist/maplat-ui.es.js +33551 -0
- package/dist/maplat-ui.umd.js +4934 -0
- package/dist/maplat_control.d.ts +55 -0
- package/dist/pointer_images.d.ts +2 -0
- package/dist/swiper_ex.d.ts +2 -0
- package/dist/types.d.ts +185 -0
- package/dist/ui_init.d.ts +4 -0
- package/dist/ui_marker.d.ts +9 -0
- package/dist/ui_utils.d.ts +9 -0
- package/less/bootstrap.less +7010 -7010
- package/less/contextmenu.css +8 -0
- package/less/font-awesome.less +51 -31
- package/less/iziToast.less +1732 -1732
- package/less/maplat-specific.less +1038 -652
- package/less/swiper4.css +715 -0
- package/less/ui.less +11 -11
- package/less/ui_packed.less +10 -10
- package/package.json +80 -79
- package/src/{absolute_url.js → absolute_url.ts} +1 -1
- package/src/contextmenu/base.ts +170 -0
- package/src/contextmenu/constants.ts +66 -0
- package/src/contextmenu/cssVars.ts +13 -0
- package/src/contextmenu/helpers/dom.ts +295 -0
- package/src/contextmenu/helpers/mix.ts +120 -0
- package/src/contextmenu/html.ts +161 -0
- package/src/contextmenu/internal.ts +293 -0
- package/src/contextmenu.ts +40 -0
- package/src/function.ts +36 -0
- package/src/icons.ts +46 -0
- package/src/index.ts +521 -0
- package/src/maplat_control.ts +629 -0
- package/src/pointer_images.ts +101 -0
- package/src/{service-worker.js → service-worker/index.ts} +5 -6
- package/src/swiper_augment.d.ts +13 -0
- package/src/{swiper_ex.js → swiper_ex.ts} +14 -10
- package/src/types.d.ts +31 -0
- package/src/types.ts +202 -0
- package/src/ui_init.ts +1175 -0
- package/src/ui_marker.ts +376 -0
- package/src/ui_utils.ts +87 -0
- package/dist/assets/fonts/a8c0074cf70b152b56105e6c4b227bd8.woff +0 -0
- package/dist/assets/fonts/cfeff2e898a64ebe7e6b5ec078b174c3.woff +0 -0
- package/dist/assets/images/09c3ce5a86d600e24f8e85de3a019853.png +0 -0
- package/dist/assets/images/0beac2cb41dfab43ddfd9df80b32b85d.png +0 -0
- package/dist/assets/images/1354b4f40dd58bb0f2a4871cb4ff81d8.png +0 -0
- package/dist/assets/images/2a61e310e46b50b5f8ddd5e905ba9db9.png +0 -0
- package/dist/assets/images/3131423d782cd3ea89a81247065e7f9d.png +0 -0
- package/dist/assets/images/41b2cf0fa604d3f196ca52337d238219.jpg +0 -0
- package/dist/assets/images/558bc7e8b9b6c5f41a7141cddb8cdb5e.png +0 -0
- package/dist/assets/images/56f7003805ed02f8a21199947651db2e.png +0 -0
- package/dist/assets/images/5ba349e3596aca094c41c56966b45dc7.png +0 -0
- package/dist/assets/images/6111b8076a2cf81c73f0e46f41a3af60.png +0 -0
- package/dist/assets/images/6345ee67d554fbfbf484ba4035ad19d9.jpg +0 -0
- package/dist/assets/images/649fce122b354de2ac725ba5f2661955.png +0 -0
- package/dist/assets/images/6a580287dea82c2fb9b214321a375145.png +0 -0
- package/dist/assets/images/6c5dba7f7d76e74c3a8c7c5b1c3fc544.png +0 -0
- package/dist/assets/images/6e1f2f2f6fed3c5cddeb925e7ae75aba.png +0 -0
- package/dist/assets/images/799a0177b0dc540682fa4a2e349a8f4f.png +0 -0
- package/dist/assets/images/7bef6f357e921c43f4f800cfcb757872.png +0 -0
- package/dist/assets/images/7d9d643a903df6f57b8b7386316021e5.png +0 -0
- package/dist/assets/images/7df82bae917b68159f84998182f2fdc6.png +0 -0
- package/dist/assets/images/8e5d0335f6598b8d874ba23ea9fb295f.png +0 -0
- package/dist/assets/images/90c32e751366be22777f3fe40a53fe06.png +0 -0
- package/dist/assets/images/9247459937b9c882303962e42bd8d989.png +0 -0
- package/dist/assets/images/927c34e7b9b2f95c82ba477993117eaf.png +0 -0
- package/dist/assets/images/95e9ca8285131f8ccb6da5052093173c.png +0 -0
- package/dist/assets/images/9a243e0cb0fc43e2a016d5d3aaa330d5.png +0 -0
- package/dist/assets/images/9ac6d81f417d6a5626b7c8d5a087c32b.png +0 -0
- package/dist/assets/images/9d3a01c866095b8b3e8e63f9cf11dd51.png +0 -0
- package/dist/assets/images/9df733bcb29a746cb16b47eedea9fc3a.png +0 -0
- package/dist/assets/images/acc6eab0ba9c470ae20fb4b74135e865.png +0 -0
- package/dist/assets/images/b9ae27f0a01228380dff76a33b605707.jpg +0 -0
- package/dist/assets/images/ba48b220f61a6e1028f1854326f43acd.png +0 -0
- package/dist/assets/images/bf67cc860289b85c0402a4d4f890a3bd.png +0 -0
- package/dist/assets/images/c49f2344772e33256ba24d64b59b20d1.png +0 -0
- package/dist/assets/images/ca6b77b234b18e7bb9b1ccda774da286.png +0 -0
- package/dist/assets/images/cd213169df16398b0017450e31788d73.png +0 -0
- package/dist/assets/images/f101a0974972eeab41189185a5c5b225.png +0 -0
- package/dist/assets/images/f115726e6249018905cca51653e1262c.png +0 -0
- package/dist/assets/images/f7acb820d978ab2dd69e8bf695c574d1.png +0 -0
- package/dist/assets/images/ffea4dd10bf2506aa1e0cd4c61426b42.png +0 -0
- package/dist/assets/maplat.css +0 -19
- package/dist/assets/maplat.css.map +0 -1
- package/dist/assets/maplat.js +0 -3
- package/dist/assets/maplat.js.LICENSE.txt +0 -43
- package/dist/assets/maplat.js.map +0 -1
- package/dist/index.html +0 -125
- package/dist/service-worker.js +0 -3
- package/dist/service-worker.js.LICENSE.txt +0 -1
- package/dist/service-worker.js.map +0 -1
- package/fonts/clarenbd-webfont.woff +0 -0
- package/fonts/fontawesome-webfont.woff +0 -0
- package/legacy/bootstrap-native.js +0 -1935
- package/legacy/detect-element-resize.js +0 -153
- package/legacy/iziToast.js +0 -1301
- package/legacy/page.js +0 -1153
- package/legacy/qrcode.js +0 -616
- package/legacy/sprintf.js +0 -285
- package/less/font-face.less +0 -11
- package/less/font-face_packed.less +0 -11
- package/parts/attr.png +0 -0
- package/parts/blue_marker.png +0 -0
- package/parts/bluedot.png +0 -0
- package/parts/bluedot_small.png +0 -0
- package/parts/bluedot_transparent.png +0 -0
- package/parts/border.png +0 -0
- package/parts/compass.png +0 -0
- package/parts/defaultpin.png +0 -0
- package/parts/defaultpin_selected.png +0 -0
- package/parts/gps.png +0 -0
- package/parts/gsi.jpg +0 -0
- package/parts/gsi_ortho.jpg +0 -0
- package/parts/help.png +0 -0
- package/parts/hide_marker.png +0 -0
- package/parts/home.png +0 -0
- package/parts/osm.jpg +0 -0
- package/parts/red_marker.png +0 -0
- package/parts/redcircle.png +0 -0
- package/parts/share.png +0 -0
- package/src/contextmenu.js +0 -29
- package/src/freeze_locales.js +0 -337
- package/src/function.js +0 -22
- package/src/index.js +0 -1778
- package/src/index_packed.js +0 -8
- package/src/maplat_control.js +0 -808
- package/src/pointer_images.js +0 -81
- /package/{parts → assets/parts}/Maplat.png +0 -0
- /package/{parts → assets/parts}/all_right_reserved.png +0 -0
- /package/{parts → assets/parts}/basemap.png +0 -0
- /package/{parts → assets/parts}/cc0.png +0 -0
- /package/{parts → assets/parts}/cc_by-nc-nd.png +0 -0
- /package/{parts → assets/parts}/cc_by-nc-sa.png +0 -0
- /package/{parts → assets/parts}/cc_by-nc.png +0 -0
- /package/{parts → assets/parts}/cc_by-nd.png +0 -0
- /package/{parts → assets/parts}/cc_by-sa.png +0 -0
- /package/{parts → assets/parts}/cc_by.png +0 -0
- /package/{parts → assets/parts}/favicon.png +0 -0
- /package/{parts → assets/parts}/fullscreen.png +0 -0
- /package/{parts → assets/parts}/loading.png +0 -0
- /package/{parts → assets/parts}/loading_image.png +0 -0
- /package/{parts → assets/parts}/minus.png +0 -0
- /package/{parts → assets/parts}/no_image.png +0 -0
- /package/{parts → assets/parts}/overlay.png +0 -0
- /package/{parts → assets/parts}/pd.png +0 -0
- /package/{parts → assets/parts}/plus.png +0 -0
- /package/{parts → assets/parts}/slider.png +0 -0
package/less/ui.less
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
@import
|
|
2
|
-
|
|
3
|
-
.maplat {
|
|
4
|
-
@import url('bootstrap.less');
|
|
5
|
-
@import url('iziToast.less');
|
|
6
|
-
@import (less) url('
|
|
7
|
-
|
|
8
|
-
@import url('font-awesome.less');
|
|
9
|
-
@import url('maplat-specific.less');
|
|
10
|
-
@import (less) url('
|
|
11
|
-
}
|
|
1
|
+
@import url('../node_modules/@maplat/core/dist/maplat_core.css');
|
|
2
|
+
|
|
3
|
+
.maplat {
|
|
4
|
+
@import url('bootstrap.less');
|
|
5
|
+
@import url('iziToast.less');
|
|
6
|
+
@import (less) url('./swiper4.css');
|
|
7
|
+
|
|
8
|
+
@import url('font-awesome.less');
|
|
9
|
+
@import url('maplat-specific.less');
|
|
10
|
+
@import (less) url('contextmenu.css');
|
|
11
|
+
}
|
package/less/ui_packed.less
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
@import (less) url('../node_modules/@maplat/core/dist/
|
|
2
|
-
|
|
3
|
-
.maplat {
|
|
4
|
-
@import url('bootstrap.less');
|
|
5
|
-
@import url('iziToast.less');
|
|
6
|
-
@import (less) url('
|
|
7
|
-
|
|
8
|
-
@import url('font-awesome.less');
|
|
9
|
-
@import url('maplat-specific.less');
|
|
10
|
-
@import (less) url('../node_modules/ol-contextmenu/dist/ol-contextmenu.css');
|
|
1
|
+
@import (less) url('../node_modules/@maplat/core/dist/maplat_core.css');
|
|
2
|
+
|
|
3
|
+
.maplat {
|
|
4
|
+
@import url('bootstrap.less');
|
|
5
|
+
@import url('iziToast.less');
|
|
6
|
+
@import (less) url('./swiper4.css');
|
|
7
|
+
|
|
8
|
+
@import url('font-awesome.less');
|
|
9
|
+
@import url('maplat-specific.less');
|
|
10
|
+
@import (less) url('../node_modules/ol-contextmenu/dist/ol-contextmenu.css');
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,34 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maplat/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Maplat is the cool Historical Map/Illustrated Map Viewer.\nIt can transform each map coordinates with nonlinear but homeomorphic projection and makes possible that the maps can collaborate with GPS/accurate maps, without distorting original maps.",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/maplat-ui.umd.js",
|
|
7
|
+
"module": "dist/maplat-ui.es.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
7
9
|
"files": [
|
|
8
10
|
"src/",
|
|
9
|
-
"dist
|
|
11
|
+
"dist/*.js",
|
|
12
|
+
"dist/*.d.ts",
|
|
13
|
+
"dist/assets/locales/",
|
|
10
14
|
"legacy/",
|
|
11
15
|
"less/",
|
|
12
|
-
"
|
|
13
|
-
"fonts/",
|
|
14
|
-
"locales/"
|
|
16
|
+
"assets/"
|
|
15
17
|
],
|
|
16
|
-
"scripts": {
|
|
17
|
-
"server": "cross-env NODE_OPTIONS=--openssl-legacy-provider webpack-cli serve --config ./webpack_config/webpack.config.standard.dev.js --mode=development",
|
|
18
|
-
"server:packed": "cross-env NODE_OPTIONS=--openssl-legacy-provider npm run freeze && cross-env NODE_OPTIONS=--openssl-legacy-provider webpack-cli serve --config ./webpack_config/webpack.config.packed.dev.js --mode=development",
|
|
19
|
-
"build": "npm run build:standard && npm run build:packed",
|
|
20
|
-
"build:standard": "cross-env NODE_OPTIONS=--openssl-legacy-provider webpack --color --progress --config ./webpack_config/webpack.config.standard.js",
|
|
21
|
-
"build:packed": "cross-env NODE_OPTIONS=--openssl-legacy-provider npm run freeze && cross-env NODE_OPTIONS=--openssl-legacy-provider webpack --config ./webpack_config/webpack.config.packed.js",
|
|
22
|
-
"zip": "gulp zip",
|
|
23
|
-
"test": "jest",
|
|
24
|
-
"preversion": "npm run lint",
|
|
25
|
-
"version": "npm run build && npm run zip && git add -A",
|
|
26
|
-
"freeze": "node bin/freezer.js",
|
|
27
|
-
"lint": "npm run lint:eslint && npm run lint:prettier",
|
|
28
|
-
"lint:eslint": "eslint \"{src,spec}/**/*.js\" --fix",
|
|
29
|
-
"lint:prettier": "prettier \"./{src,spec}/**/*.js\" --write",
|
|
30
|
-
"git_switch": "gulp git_switch"
|
|
31
|
-
},
|
|
32
18
|
"repository": {
|
|
33
19
|
"type": "git",
|
|
34
20
|
"url": "git+https://github.com/code4history/Maplat.git"
|
|
@@ -43,64 +29,79 @@
|
|
|
43
29
|
"url": "https://github.com/code4history/Maplat/issues"
|
|
44
30
|
},
|
|
45
31
|
"homepage": "https://github.com/code4history/Maplat/wiki",
|
|
32
|
+
"engines": {
|
|
33
|
+
"npm": "use-pnpm-please",
|
|
34
|
+
"pnpm": ">=9.0.0"
|
|
35
|
+
},
|
|
46
36
|
"dependencies": {
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
37
|
+
"@c4h/chuci": "0.2.4",
|
|
38
|
+
"@c4h/weiwudi": "^0.2.0",
|
|
39
|
+
"@maplat/core": "0.12.1",
|
|
40
|
+
"@maplat/transform": "^0.4.0",
|
|
41
|
+
"@turf/turf": "^7.3.1",
|
|
42
|
+
"@types/page": "^1.11.9",
|
|
43
|
+
"bootstrap.native": "^5.1.6",
|
|
44
|
+
"page": "^1.11.6",
|
|
45
|
+
"qrcode": "^1.5.4",
|
|
46
|
+
"swiper": "^6.8.4",
|
|
47
|
+
"tiny-emitter": "^2.1.0",
|
|
48
|
+
"workbox-core": "^7.4.0",
|
|
49
|
+
"workbox-expiration": "^7.4.0",
|
|
50
|
+
"workbox-precaching": "^7.4.0",
|
|
51
|
+
"workbox-routing": "^7.4.0",
|
|
52
|
+
"workbox-strategies": "^7.4.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"mapbox-gl": "^1.0.0 || ^2.0.0 || ^3.0.0",
|
|
56
|
+
"maplibre-gl": "^3.0.0 || ^4.0.0",
|
|
57
|
+
"ol": "^9.0.0 || ^10.0.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"@
|
|
60
|
-
"@
|
|
61
|
-
"@
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"eslint
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"webpack-cli": "^4.9.2",
|
|
93
|
-
"webpack-dev-server": "^4.11.1",
|
|
94
|
-
"workbox-build": "^6.5.4",
|
|
95
|
-
"workbox-cli": "^6.5.4",
|
|
96
|
-
"workbox-core": "^6.5.4",
|
|
97
|
-
"workbox-expiration": "^6.5.4",
|
|
98
|
-
"workbox-precaching": "^6.5.4",
|
|
99
|
-
"workbox-routing": "^6.5.4",
|
|
100
|
-
"workbox-strategies": "^6.5.4",
|
|
101
|
-
"workbox-webpack-plugin": "^6.5.4"
|
|
60
|
+
"@eslint/js": "^9.39.2",
|
|
61
|
+
"@types/node": "^20.19.27",
|
|
62
|
+
"@types/ol": "^6.5.3",
|
|
63
|
+
"@types/qrcode": "^1.5.6",
|
|
64
|
+
"concurrently": "^9.2.1",
|
|
65
|
+
"cross-env": "^10.1.0",
|
|
66
|
+
"esbuild": "^0.27.2",
|
|
67
|
+
"eslint": "^9.39.2",
|
|
68
|
+
"eslint-config-prettier": "^9.1.2",
|
|
69
|
+
"globals": "^16.5.0",
|
|
70
|
+
"jsdom": "^24.1.3",
|
|
71
|
+
"less": "^4.5.1",
|
|
72
|
+
"ol": "^10.7.0",
|
|
73
|
+
"prettier": "^3.7.4",
|
|
74
|
+
"typescript": "^5.9.3",
|
|
75
|
+
"typescript-eslint": "^8.50.1",
|
|
76
|
+
"vite": "^6.4.1",
|
|
77
|
+
"vite-plugin-dts": "^4.5.4",
|
|
78
|
+
"vitest": "^3.2.4",
|
|
79
|
+
"workbox-build": "^7.4.0",
|
|
80
|
+
"workbox-window": "^7.4.0"
|
|
81
|
+
},
|
|
82
|
+
"overrides": {
|
|
83
|
+
"@babel/traverse": "7.23.2",
|
|
84
|
+
"glob-parent": "5.1.2",
|
|
85
|
+
"axios": "1.6.0",
|
|
86
|
+
"minimist": "1.2.8",
|
|
87
|
+
"glob": "^11.0.0",
|
|
88
|
+
"rimraf": "^6.0.0",
|
|
89
|
+
"inflight": "npm:inflight-purged@^2.0.0",
|
|
90
|
+
"@types/minimatch": "^5.1.2",
|
|
91
|
+
"source-map": "^0.7.4",
|
|
92
|
+
"sourcemap-codec": "^1.4.8"
|
|
102
93
|
},
|
|
103
|
-
"
|
|
104
|
-
"
|
|
94
|
+
"scripts": {
|
|
95
|
+
"dev": "concurrently \"pnpm watch:sw\" \"vite --host\"",
|
|
96
|
+
"build:sw": "esbuild src/service-worker/index.ts --bundle --outfile=dist/service-worker.js --format=iife --define:self.__WB_MANIFEST=[] && node -e \"require('fs').copyFileSync('dist/service-worker.js', 'public/service-worker.js')\"",
|
|
97
|
+
"watch:sw": "esbuild src/service-worker/index.ts --bundle --outfile=public/service-worker.js --format=iife --define:self.__WB_MANIFEST=[] --watch",
|
|
98
|
+
"build": "pnpm build:sw && cross-env BUILD_MODE=package tsc && cross-env BUILD_MODE=package vite build",
|
|
99
|
+
"build:demo": "pnpm build:sw && vite build",
|
|
100
|
+
"preview": "vite preview",
|
|
101
|
+
"test": "vitest",
|
|
102
|
+
"typecheck": "tsc --noEmit",
|
|
103
|
+
"lint": "pnpm lint:eslint && pnpm lint:prettier",
|
|
104
|
+
"lint:eslint": "eslint \"{src,spec,demo}/**/*.{ts,js}\" --fix",
|
|
105
|
+
"lint:prettier": "prettier \"./{src,spec,demo}/**/*.{ts,js}\" --write"
|
|
105
106
|
}
|
|
106
|
-
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/* Fork from ol-comtextmenu 4.1.0
|
|
2
|
+
* https://github.com/jonataswalker/ol-contextmenu/tree/4.1.0
|
|
3
|
+
* (c) Jonatas Walker
|
|
4
|
+
* @license MIT
|
|
5
|
+
**/
|
|
6
|
+
|
|
7
|
+
import { CSS_VARS, DEFAULT_OPTIONS, DEFAULT_ITEMS } from "./constants";
|
|
8
|
+
import Control from "ol/control/Control";
|
|
9
|
+
import { Internal } from "./internal";
|
|
10
|
+
import { Html } from "./html";
|
|
11
|
+
import { assert, mergeOptions } from "./helpers/mix";
|
|
12
|
+
import { ContextMenuOptions, ContextMenuItem } from "../types";
|
|
13
|
+
//import './sass/main.scss';
|
|
14
|
+
|
|
15
|
+
export const createContainer = (hidden: boolean, width: number) => {
|
|
16
|
+
const container = document.createElement("div");
|
|
17
|
+
const ul = document.createElement("ul");
|
|
18
|
+
const klasses = [CSS_VARS.container, CSS_VARS.unselectable];
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
21
|
+
hidden && klasses.push(CSS_VARS.hidden);
|
|
22
|
+
container.className = klasses.join(" ");
|
|
23
|
+
container.style.width = `${parseInt(String(width), 10)}px`;
|
|
24
|
+
container.appendChild(ul);
|
|
25
|
+
return container;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @class Base
|
|
30
|
+
* @extends {ol.control.Control}
|
|
31
|
+
*/
|
|
32
|
+
export default class Base extends Control {
|
|
33
|
+
options: ContextMenuOptions;
|
|
34
|
+
container: HTMLElement;
|
|
35
|
+
disabled: boolean;
|
|
36
|
+
Internal: Internal;
|
|
37
|
+
Html: Html;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @constructor
|
|
41
|
+
* @param {object|undefined} opt_options Options.
|
|
42
|
+
*/
|
|
43
|
+
constructor(opt_options: ContextMenuOptions = {}) {
|
|
44
|
+
assert(
|
|
45
|
+
typeof opt_options == "object",
|
|
46
|
+
"@param `opt_options` should be object type!"
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
const options = mergeOptions(DEFAULT_OPTIONS, opt_options) as any;
|
|
51
|
+
const container = createContainer(true, options.width!);
|
|
52
|
+
super({ element: container });
|
|
53
|
+
|
|
54
|
+
this.options = options;
|
|
55
|
+
this.container = container;
|
|
56
|
+
this.disabled = false;
|
|
57
|
+
this.Internal = new Internal(this);
|
|
58
|
+
this.Html = new Html(this);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Remove all elements from the menu.
|
|
63
|
+
*/
|
|
64
|
+
clear() {
|
|
65
|
+
Object.keys(this.Internal.items).forEach(
|
|
66
|
+
this.Html.removeMenuEntry,
|
|
67
|
+
this.Html
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Close the menu programmatically.
|
|
73
|
+
*/
|
|
74
|
+
close() {
|
|
75
|
+
this.Internal.closeMenu();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Enable menu
|
|
80
|
+
*/
|
|
81
|
+
enable() {
|
|
82
|
+
this.disabled = false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Disable menu
|
|
87
|
+
*/
|
|
88
|
+
disable() {
|
|
89
|
+
this.disabled = true;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @return {Array} Returns default items
|
|
94
|
+
*/
|
|
95
|
+
getDefaultItems() {
|
|
96
|
+
return DEFAULT_ITEMS;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @return {Number} Returns how many items
|
|
101
|
+
*/
|
|
102
|
+
countItems() {
|
|
103
|
+
return Object.keys(this.Internal.items).length;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Add items to the menu. This pushes each item in the provided array
|
|
108
|
+
* to the end of the menu.
|
|
109
|
+
* @param {Array} arr Array.
|
|
110
|
+
*/
|
|
111
|
+
extend(arr: ContextMenuItem[]) {
|
|
112
|
+
assert(Array.isArray(arr), "@param `arr` should be an Array.");
|
|
113
|
+
arr.forEach(this.push, this);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
isOpen() {
|
|
117
|
+
return this.Internal.opened;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Update the menu's position.
|
|
122
|
+
*/
|
|
123
|
+
updatePosition(pixel: number[]) {
|
|
124
|
+
assert(Array.isArray(pixel), "@param `pixel` should be an Array.");
|
|
125
|
+
|
|
126
|
+
if (this.isOpen()) {
|
|
127
|
+
this.Internal.positionContainer(pixel);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Remove the last item of the menu.
|
|
133
|
+
*/
|
|
134
|
+
pop() {
|
|
135
|
+
const keys = Object.keys(this.Internal.items);
|
|
136
|
+
this.Html.removeMenuEntry(keys[keys.length - 1]);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Insert the provided item at the end of the menu.
|
|
141
|
+
* @param {Object|String} item Item.
|
|
142
|
+
*/
|
|
143
|
+
push(item: ContextMenuItem | string) {
|
|
144
|
+
// assert(isDefAndNotNull(item), '@param `item` must be informed.');
|
|
145
|
+
this.Html.addMenuEntry(item as ContextMenuItem);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Remove the first item of the menu.
|
|
150
|
+
*/
|
|
151
|
+
shift() {
|
|
152
|
+
this.Html.removeMenuEntry(Object.keys(this.Internal.items)[0]);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Not supposed to be used on app.
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
setMap(map: import("ol").Map) {
|
|
160
|
+
Control.prototype.setMap.call(this, map);
|
|
161
|
+
|
|
162
|
+
if (map) {
|
|
163
|
+
// let's start since now we have the map
|
|
164
|
+
this.Internal.init(map);
|
|
165
|
+
} else {
|
|
166
|
+
// I'm removed from the map - remove listeners
|
|
167
|
+
this.Internal.removeListeners();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import cssVars from "./cssVars";
|
|
2
|
+
|
|
3
|
+
export const CSS_VARS = cssVars;
|
|
4
|
+
|
|
5
|
+
export const EVENT_TYPE = {
|
|
6
|
+
/**
|
|
7
|
+
* Triggered before context menu is open.
|
|
8
|
+
*/
|
|
9
|
+
BEFOREOPEN: "beforeopen",
|
|
10
|
+
/**
|
|
11
|
+
* Triggered when context menu is open.
|
|
12
|
+
*/
|
|
13
|
+
OPEN: "open",
|
|
14
|
+
/**
|
|
15
|
+
* Triggered when context menu is closed.
|
|
16
|
+
*/
|
|
17
|
+
CLOSE: "close",
|
|
18
|
+
/**
|
|
19
|
+
* Internal. Triggered when a menu entry is added.
|
|
20
|
+
*/
|
|
21
|
+
ADD_MENU_ENTRY: "add-menu-entry",
|
|
22
|
+
/**
|
|
23
|
+
* Internal.
|
|
24
|
+
*/
|
|
25
|
+
CONTEXTMENU: "contextmenu",
|
|
26
|
+
/**
|
|
27
|
+
* Internal.
|
|
28
|
+
*/
|
|
29
|
+
HOVER: "mouseover"
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const DEFAULT_OPTIONS = {
|
|
33
|
+
width: 150,
|
|
34
|
+
scrollAt: 4,
|
|
35
|
+
eventType: EVENT_TYPE.CONTEXTMENU,
|
|
36
|
+
defaultItems: true
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const DEFAULT_ITEMS = [
|
|
40
|
+
{
|
|
41
|
+
text: "Zoom In",
|
|
42
|
+
classname: `${cssVars.zoomIn} ${cssVars.icon}`,
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
callback: (obj: any, map: any) => {
|
|
45
|
+
const view = map.getView();
|
|
46
|
+
view.animate({
|
|
47
|
+
zoom: +view.getZoom() + 1,
|
|
48
|
+
duration: 700,
|
|
49
|
+
center: obj.coordinate
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
text: "Zoom Out",
|
|
55
|
+
classname: `${cssVars.zoomOut} ${cssVars.icon}`,
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
callback: (obj: any, map: any) => {
|
|
58
|
+
const view = map.getView();
|
|
59
|
+
view.animate({
|
|
60
|
+
zoom: +view.getZoom() - 1,
|
|
61
|
+
duration: 700,
|
|
62
|
+
center: obj.coordinate
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const namespace = "ol-ctx-menu";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
namespace,
|
|
5
|
+
container: `${namespace}-container`,
|
|
6
|
+
separator: `${namespace}-separator`,
|
|
7
|
+
submenu: `${namespace}-submenu`,
|
|
8
|
+
hidden: `${namespace}-hidden`,
|
|
9
|
+
icon: `${namespace}-icon`,
|
|
10
|
+
zoomIn: `${namespace}-zoom-in`,
|
|
11
|
+
zoomOut: `${namespace}-zoom-out`,
|
|
12
|
+
unselectable: "ol-unselectable"
|
|
13
|
+
};
|