waibu-maps 1.0.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.
Files changed (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/bajo/.alias +1 -0
  4. package/bajo/config.json +10 -0
  5. package/bajoI18N/resource/en-US.json +17 -0
  6. package/bajoI18N/resource/id.json +19 -0
  7. package/package.json +34 -0
  8. package/waibuBootstrap/theme/component/factory/control-attribution.js +29 -0
  9. package/waibuBootstrap/theme/component/factory/control-buttons-item.js +14 -0
  10. package/waibuBootstrap/theme/component/factory/control-buttons.js +67 -0
  11. package/waibuBootstrap/theme/component/factory/control-center-position.js +28 -0
  12. package/waibuBootstrap/theme/component/factory/control-draw.js +43 -0
  13. package/waibuBootstrap/theme/component/factory/control-fullscreen.js +26 -0
  14. package/waibuBootstrap/theme/component/factory/control-geolocate.js +27 -0
  15. package/waibuBootstrap/theme/component/factory/control-group-button.js +15 -0
  16. package/waibuBootstrap/theme/component/factory/control-group-menu.js +45 -0
  17. package/waibuBootstrap/theme/component/factory/control-group.js +94 -0
  18. package/waibuBootstrap/theme/component/factory/control-image.js +43 -0
  19. package/waibuBootstrap/theme/component/factory/control-loader.js +27 -0
  20. package/waibuBootstrap/theme/component/factory/control-logo.js +50 -0
  21. package/waibuBootstrap/theme/component/factory/control-mouse-pos.js +78 -0
  22. package/waibuBootstrap/theme/component/factory/control-navigation.js +29 -0
  23. package/waibuBootstrap/theme/component/factory/control-ruler.js +47 -0
  24. package/waibuBootstrap/theme/component/factory/control-scale.js +27 -0
  25. package/waibuBootstrap/theme/component/factory/control-search.js +159 -0
  26. package/waibuBootstrap/theme/component/factory/control-zbp.js +70 -0
  27. package/waibuBootstrap/theme/component/factory/control.js +42 -0
  28. package/waibuBootstrap/theme/component/factory/layer-geojson.js +103 -0
  29. package/waibuBootstrap/theme/component/factory/layer-html-cluster.js +124 -0
  30. package/waibuBootstrap/theme/component/factory/map/options.js +44 -0
  31. package/waibuBootstrap/theme/component/factory/map.js +139 -0
  32. package/waibuBootstrap/theme/component/factory/script.js +20 -0
  33. package/waibuBootstrap/theme/component/factory/template.js +10 -0
  34. package/waibuBootstrap/theme/component/wmaps-base.js +40 -0
  35. package/waibuMpa/partial/menu.html +10 -0
  36. package/waibuMpa/route/default-style.js +13 -0
  37. package/waibuMpa/route/wmaps.js +13 -0
  38. package/waibuMpa/template/default-style.json +20 -0
  39. package/waibuMpa/template/wmaps.js +320 -0
  40. package/waibuStatic/asset/css/control-buttons.css +3 -0
  41. package/waibuStatic/asset/css/control-center-position.css +17 -0
  42. package/waibuStatic/asset/css/control-loader.css +7 -0
  43. package/waibuStatic/asset/css/control-mouse-position.css +21 -0
  44. package/waibuStatic/asset/css/control-ruler.css +12 -0
  45. package/waibuStatic/asset/css/control-search.css +25 -0
  46. package/waibuStatic/asset/css/wmaps.css +150 -0
  47. package/waibuStatic/asset/font/noto_sans_regular.pbf +0 -0
  48. package/waibuStatic/asset/image/center.svg +25 -0
  49. package/waibuStatic/asset/image/ruler.svg +4 -0
  50. package/waibuStatic/asset/js/control-buttons.js +98 -0
  51. package/waibuStatic/asset/js/control-center-position.js +19 -0
  52. package/waibuStatic/asset/js/control-mouse-position.js +47 -0
  53. package/waibuStatic/asset/js/control-ruler.js +204 -0
  54. package/waibuStatic/asset/js/donut-chart.js +58 -0
  55. package/waibuStatic/asset/js/lib/worker-timers.js +243 -0
  56. package/waibuStatic/virtual.json +7 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Ardhi Lukianto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # waibu-maps
package/bajo/.alias ADDED
@@ -0,0 +1 @@
1
+ wmaps
@@ -0,0 +1,10 @@
1
+ {
2
+ "waibu": {
3
+ "prefix": "wmaps"
4
+ },
5
+ "mapOptions": {
6
+ "center": [106.8229, -6.1944],
7
+ "zoom": 7
8
+ },
9
+ "dependencies": ["bajo-spatial"]
10
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "dirE": "E",
3
+ "dirW": "W",
4
+ "dirN": "N",
5
+ "dirS": "S",
6
+ "mapControl": {
7
+ "csrc": "Search",
8
+ "navigation-control": "Navigation",
9
+ "crlr": "Measurement",
10
+ "scale-control": "Map Scale",
11
+ "attribution-control": "Attribution",
12
+ "fullscreen-control": "Fullscreen",
13
+ "geolocate-control": "Geolocate",
14
+ "czbp": "Zoom/Bearing/Pitch",
15
+ "cmp": "Mouse Position"
16
+ }
17
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "Lng": "Bjr",
3
+ "Lat": "Ltg",
4
+ "dirE": "T",
5
+ "dirW": "B",
6
+ "dirN": "U",
7
+ "dirS": "S",
8
+ "mapControl": {
9
+ "csrc": "Search",
10
+ "navigation-control": "Navigation",
11
+ "crlr": "Measurement",
12
+ "scale-control": "Map Scale",
13
+ "attribution-control": "Attribution",
14
+ "fullscreen-control": "Fullscreen",
15
+ "geolocate-control": "Geolocate",
16
+ "czbp": "Zoom/Bearing/Pitch",
17
+ "cmp": "Mouse Position"
18
+ }
19
+ }
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "waibu-maps",
3
+ "version": "1.0.1",
4
+ "description": "Maps for Waibu MPA",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "type": "module",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/ardhi/waibu-maps.git"
13
+ },
14
+ "keywords": [
15
+ "maps",
16
+ "waibu",
17
+ "web",
18
+ "webserver",
19
+ "bajo",
20
+ "framework",
21
+ "fastify",
22
+ "modular"
23
+ ],
24
+ "author": "Ardhi Lukianto <ardhi@lukianto.com>",
25
+ "license": "MIT",
26
+ "bugs": {
27
+ "url": "https://github.com/ardhi/waibu-maps/issues"
28
+ },
29
+ "homepage": "https://github.com/ardhi/waibu-maps#readme",
30
+ "dependencies": {
31
+ "maplibre-gl": "^4.7.1",
32
+ "terra-draw": "^1.0.0-beta.8"
33
+ }
34
+ }
@@ -0,0 +1,29 @@
1
+ import control from './control.js'
2
+
3
+ async function controlAttribution () {
4
+ const WmapsControl = await control.call(this)
5
+
6
+ return class WmapsControlAttribution extends WmapsControl {
7
+ constructor (options) {
8
+ super(options)
9
+ this.params.noTag = true
10
+ }
11
+
12
+ async build () {
13
+ const { jsonStringify } = this.plugin.app.waibuMpa
14
+ const { isString } = this.plugin.app.bajo.lib._
15
+ const opts = {
16
+ compact: !this.params.attr.noCompact
17
+ }
18
+ if (isString(this.params.attr.text)) opts.customAttribution = this.params.attr.text
19
+ opts.position = this.ctrlPos.includes(this.params.attr.position) ? this.params.attr.position : 'bottom-right'
20
+ opts.classSelector = 'maplibregl-ctrl-attrib'
21
+ this.block.control.push(`
22
+ await wmaps.createControlNative('AttributionControl', ${jsonStringify(opts, true)})
23
+ `)
24
+ this.params.html = this.writeBlock()
25
+ }
26
+ }
27
+ }
28
+
29
+ export default controlAttribution
@@ -0,0 +1,14 @@
1
+ import wmapsBase from '../wmaps-base.js'
2
+
3
+ async function controlButtonsItem () {
4
+ const WmapsBase = await wmapsBase.call(this)
5
+
6
+ return class WmapsControlButtonsItem extends WmapsBase {
7
+ constructor (options) {
8
+ super(options)
9
+ this.params.tag = 'div'
10
+ }
11
+ }
12
+ }
13
+
14
+ export default controlButtonsItem
@@ -0,0 +1,67 @@
1
+ import control from './control.js'
2
+
3
+ async function controlButtons () {
4
+ const WmapsControl = await control.call(this)
5
+
6
+ return class WmapsControlButtons extends WmapsControl {
7
+ static scripts = [
8
+ ...super.scripts,
9
+ 'waibuMaps.asset:/js/control-buttons.js'
10
+ ]
11
+
12
+ static css = [
13
+ ...super.css,
14
+ 'waibuMaps.asset:/css/control-buttons.css'
15
+ ]
16
+
17
+ constructor (options) {
18
+ super(options)
19
+ this.params.noTag = true
20
+ }
21
+
22
+ async build () {
23
+ const { generateId } = this.plugin.app.bajo
24
+ const { routePath } = this.plugin.app.waibu
25
+ const { jsonStringify } = this.plugin.app.waibuMpa
26
+ const { isEmpty, isString, pick, camelCase } = this.plugin.app.bajo.lib._
27
+ const { $ } = this.component
28
+ const pos = this.ctrlPos.includes(this.params.attr.position) ? this.params.attr.position : 'top-right'
29
+ const items = []
30
+ $(`<div>${this.params.html}</div>`).find('div').each(function () {
31
+ const attrs = {}
32
+ for (const k in this.attribs) {
33
+ attrs[camelCase(k)] = this.attribs[k]
34
+ }
35
+ const opts = { id: attrs.id ?? generateId('alpha') }
36
+ if (attrs.minZoom) opts.minZoom = Number(attrs.minZoom) || 0
37
+ if (attrs.class) opts.class = attrs.class
38
+ if (attrs.dropdown) {
39
+ opts.fn = attrs.dropdown
40
+ opts.fnParams = opts.id
41
+ opts.dropdown = true
42
+ } else if (attrs.openTab) {
43
+ opts.url = attrs.openTab
44
+ opts.tab = true
45
+ } else if (attrs.openUrl) {
46
+ opts.url = attrs.openTab
47
+ } else if (isString(attrs.dataBsTarget)) {
48
+ opts.attrib = pick(attrs, ['dataBsTarget', 'dataBsToggle', 'ariaControls'])
49
+ } else if (attrs.fn) {
50
+ opts.fn = attrs.fn
51
+ }
52
+ if (isString(attrs.imageUrl)) opts.imageUrl = routePath(attrs.imageUrl)
53
+ opts.icon = $(this).find('i').prop('class')
54
+ items.push(opts)
55
+ })
56
+ this.params.html = ''
57
+ if (!isEmpty(items)) {
58
+ this.block.control.push(`
59
+ map.addControl(new ControlButtons(_.merge(${jsonStringify({ items, position: pos }, true)}, { scopeId: this.$store.map.id }))${pos ? `, '${pos}'` : ''})
60
+ `)
61
+ this.params.html = this.writeBlock()
62
+ }
63
+ }
64
+ }
65
+ }
66
+
67
+ export default controlButtons
@@ -0,0 +1,28 @@
1
+ import control from './control.js'
2
+ const storeKey = 'mapControl.centerPos'
3
+
4
+ async function controlCenterPosition () {
5
+ const WmapsControl = await control.call(this)
6
+
7
+ return class WmapsControlCenterPosition extends WmapsControl {
8
+ static scripts = [
9
+ ...super.scripts,
10
+ 'waibuMaps.asset:/js/control-center-position.js'
11
+ ]
12
+
13
+ static css = [
14
+ ...super.css,
15
+ 'waibuMaps.asset:/css/control-center-position.css'
16
+ ]
17
+
18
+ constructor (options) {
19
+ super(options)
20
+ this.params.noTag = true
21
+ this.params.html = `<div class="childmap maplibregl-ctrl-center" x-data>
22
+ <div x-show="$store.mapControl ? $store.${storeKey} : true"></div>
23
+ </div>`
24
+ }
25
+ }
26
+ }
27
+
28
+ export default controlCenterPosition
@@ -0,0 +1,43 @@
1
+ import control from './control.js'
2
+
3
+ async function controlDraw () {
4
+ const WmapsControl = await control.call(this)
5
+
6
+ return class WmapsControlDraw extends WmapsControl {
7
+ static scripts = [
8
+ ...super.scripts,
9
+ 'waibuMaps.virtual:/terra-draw/terra-draw.umd.js'
10
+ ]
11
+
12
+ constructor (options) {
13
+ super(options)
14
+ this.params.noTag = true
15
+ }
16
+
17
+ async build () {
18
+ const { isString } = this.plugin.app.bajo.lib._
19
+ const opts = {}
20
+ if (['imperial', 'metric', 'nautical'].includes(this.params.attr.unit)) opts.unit = this.params.attr.unit
21
+ if (isString(this.params.attr.maxWidth) && Number(this.params.attr.maxWidth)) opts.maxWidth = Number(this.params.attr.maxWidth)
22
+ // const pos = ctrlPos.includes(this.params.attr.position) ? this.params.attr.position : 'top-left'
23
+ this.block.control.push(`<script>
24
+ draw = new terraDraw.TerraDraw({
25
+ adapter: new terraDraw.TerraDrawMapLibreGLAdapter({
26
+ map,
27
+ lib: maplibregl
28
+ }),
29
+ modes: [new terraDraw.TerraDrawFreehandMode()]
30
+ })
31
+ this.draw = draw
32
+ this.draw.start()
33
+ this.draw.setMode('freehand')
34
+ `)
35
+ this.block.nonReactive(`
36
+ let draw
37
+ `)
38
+ this.params.html = this.writeBlock()
39
+ }
40
+ }
41
+ }
42
+
43
+ export default controlDraw
@@ -0,0 +1,26 @@
1
+ import control from './control.js'
2
+
3
+ async function controlFullscreen () {
4
+ const WmapsControl = await control.call(this)
5
+
6
+ return class WmapsControlFullscreen extends WmapsControl {
7
+ constructor (options) {
8
+ super(options)
9
+ this.params.noTag = true
10
+ }
11
+
12
+ async build () {
13
+ const { jsonStringify } = this.plugin.app.waibuMpa
14
+ const { isString } = this.plugin.app.bajo.lib._
15
+ const opts = {}
16
+ if (isString(this.params.attr.container)) opts.container = this.params.attr.container
17
+ opts.position = this.ctrlPos.includes(this.params.attr.position) ? this.params.attr.position : 'bottom-right'
18
+ this.block.control.push(`
19
+ await wmaps.createControlNative('FullscreenControl', ${jsonStringify(opts, true)})
20
+ `)
21
+ this.params.html = this.writeBlock()
22
+ }
23
+ }
24
+ }
25
+
26
+ export default controlFullscreen
@@ -0,0 +1,27 @@
1
+ import control from './control.js'
2
+
3
+ async function controlGeolocate () {
4
+ const WmapsControl = await control.call(this)
5
+
6
+ return class WmapsControlGeolocate extends WmapsControl {
7
+ constructor (options) {
8
+ super(options)
9
+ this.params.noTag = true
10
+ }
11
+
12
+ async build () {
13
+ const { jsonStringify } = this.plugin.app.waibuMpa
14
+ const { set } = this.plugin.app.bajo.lib._
15
+ const opts = {}
16
+ if (this.params.attr.highAccuracy) set(opts, 'positionOptions.enableHighAccuracy', true)
17
+ if (this.params.attr.trackUserLocation) opts.trackUserLocation = true
18
+ opts.position = this.ctrlPos.includes(this.params.attr.position) ? this.params.attr.position : 'bottom-right'
19
+ this.block.control.push(`
20
+ await wmaps.createControlNative('GeolocateControl', ${jsonStringify(opts, true)})
21
+ `)
22
+ this.params.html = this.writeBlock()
23
+ }
24
+ }
25
+ }
26
+
27
+ export default controlGeolocate
@@ -0,0 +1,15 @@
1
+ import wmapsBase from '../wmaps-base.js'
2
+ const prefix = 'cgrb'
3
+
4
+ async function controlGroupButton () {
5
+ const WmapsBase = await wmapsBase.call(this)
6
+
7
+ return class WmapsControlGroupButton extends WmapsBase {
8
+ constructor (options) {
9
+ super(options)
10
+ this.component.normalizeAttr(this.params, { tag: 'button', cls: `control-group-button ${prefix}`, autoId: true })
11
+ }
12
+ }
13
+ }
14
+
15
+ export default controlGroupButton
@@ -0,0 +1,45 @@
1
+ import wmapsBase from '../wmaps-base.js'
2
+ const prefix = 'cgrm'
3
+
4
+ async function controlGroupMenu () {
5
+ const WmapsBase = await wmapsBase.call(this)
6
+
7
+ return class WmapsControlGroupMenu extends WmapsBase {
8
+ constructor (options) {
9
+ super(options)
10
+ this.component.normalizeAttr(this.params, { tag: 'button', cls: `control-group-menu ${prefix}`, autoId: true })
11
+ this.params.attr.class.push('dropdown', 'dropstart')
12
+ }
13
+
14
+ async build () {
15
+ const { $ } = this.component
16
+ const { fastGlob } = this.plugin.app.bajo.lib
17
+ const { isString } = this.plugin.app.bajo.lib._
18
+ const { routePath } = this.plugin.app.waibu
19
+ let icon
20
+ let image = ''
21
+ const items = []
22
+ $(`<div>${this.params.html}</div>`).children().each(function () {
23
+ if (this.name === 'i') icon = $(this).prop('class')
24
+ else items.push($(this).prop('outerHTML'))
25
+ })
26
+ if (isString(this.params.attr.image)) {
27
+ if (this.params.attr.image === 'logo') {
28
+ let logo = 'waibu'
29
+ const files = await fastGlob(`${this.plugin.app.main.dir.pkg}/bajo/logo.*`)
30
+ if (files.length > 0) logo = 'main'
31
+ image = routePath(`waibuMpa:/logo/${logo}`)
32
+ } else image = routePath(this.params.attr.image)
33
+ }
34
+ this.params.html = `
35
+ <div class="var">
36
+ <div class="icon">${icon}</div>
37
+ <div class="image">${image}</div>
38
+ <div class="html">${items.join('\n')}</div>
39
+ </div>
40
+ `
41
+ }
42
+ }
43
+ }
44
+
45
+ export default controlGroupMenu
@@ -0,0 +1,94 @@
1
+ import control from './control.js'
2
+ const prefix = 'cgr'
3
+
4
+ async function controlGroup () {
5
+ const WmapsControl = await control.call(this)
6
+
7
+ return class WmapsControlGroup extends WmapsControl {
8
+ constructor (options) {
9
+ super(options)
10
+ this.params.noTag = true
11
+ }
12
+
13
+ async build () {
14
+ const { generateId } = this.plugin.app.bajo
15
+ const { jsonStringify, minify } = this.plugin.app.waibuMpa
16
+ const { isString, trim } = this.plugin.app.bajo.lib._
17
+ const { $ } = this.component
18
+ const tpl = await this.component.buildSentence(this.loadTemplate('waibuMaps.partial:/menu.html', { escape: true }), {}, { minify: true })
19
+ const id = isString(this.params.attr.id) ? this.params.attr.id : generateId('alpha')
20
+ const opts = {}
21
+ opts.position = this.ctrlPos.includes(this.params.attr.position) ? this.params.attr.position : 'top-left'
22
+ opts.class = prefix + ' maplibregl-ctrl-group'
23
+ const items = []
24
+ const params = []
25
+ $(`<div>${this.params.html}</div>`).find('button[class^="control-group-"]').each(function () {
26
+ const vars = $(this).find('.var').length
27
+ if (vars > 0) {
28
+ params.push({
29
+ image: $(this).find('.var .image').text() ?? '',
30
+ icon: $(this).find('.var .icon').text() ?? '',
31
+ html: $(this).find('.var .html').prop('innerHTML') ?? '',
32
+ wrapper: $(this).html('{%= cmp %}').prop('outerHTML') ?? ''
33
+ })
34
+ } else {
35
+ const item = trim($(this).removeAttr('octag').prop('outerHTML'))
36
+ items.push(item)
37
+ }
38
+ })
39
+ for (const param of params) {
40
+ for (const type of ['html', 'wrapper']) {
41
+ param[type] = await minify(param[type])
42
+ }
43
+ }
44
+ for (const idx in items) {
45
+ items[idx] = await minify(items[idx])
46
+ }
47
+ this.readBlock()
48
+ this.block.reactive.push(`
49
+ ${prefix}MenuTpl: _.template('${tpl}')
50
+ `, `
51
+ async ${prefix}Trigger (evt) {
52
+ const el = evt.target.closest('button')
53
+ if (!el) return
54
+ const menu = el.querySelector('.dropdown-menu')
55
+ if (!menu) return
56
+ if (menu.children.length > 0) return
57
+ await wmpa.addComponent('<c:' + el.getAttribute('component') + '/>', menu)
58
+ }
59
+ `, `
60
+ async ${prefix}Builder (params) {
61
+ const items = []
62
+ for (const param of params) {
63
+ const args = {
64
+ click: '',
65
+ image: param.image,
66
+ icon: param.icon,
67
+ html: param.html
68
+ }
69
+ if (param.wrapper.includes('component=')) {
70
+ args.html = ''
71
+ args.click = '${prefix}Trigger'
72
+ }
73
+ const wfn = _.template(param.wrapper)
74
+ const inner = this.${prefix}MenuTpl(args)
75
+ const outer = wfn({ cmp: inner })
76
+ items.push(wmpa.createComponentFromHtml(outer))
77
+ }
78
+ return items
79
+ }
80
+ `)
81
+ this.block.control.push({
82
+ id,
83
+ group: true,
84
+ content: `
85
+ await wmaps.createControl(_.merge(${jsonStringify(opts, true)}, { builder: this.${prefix}Builder, params: ${jsonStringify(params, true)} }))
86
+ `
87
+ })
88
+
89
+ this.params.html = this.writeBlock()
90
+ }
91
+ }
92
+ }
93
+
94
+ export default controlGroup
@@ -0,0 +1,43 @@
1
+ import control from './control.js'
2
+ const prefix = 'cimg'
3
+
4
+ async function controlImage () {
5
+ const WmapsControl = await control.call(this)
6
+
7
+ return class WmapsControlImage extends WmapsControl {
8
+ constructor (options) {
9
+ super(options)
10
+ this.params.noTag = true
11
+ }
12
+
13
+ async build () {
14
+ const { routePath } = this.plugin.app.waibu
15
+ const { jsonStringify, groupAttrs, attribsStringify } = this.plugin.app.waibuMpa
16
+ const { isString, isEmpty } = this.plugin.app.bajo.lib._
17
+ const opts = {}
18
+ opts.position = this.ctrlPos.includes(this.params.attr.position) ? this.params.attr.position : 'top-left'
19
+ const group = groupAttrs(this.params.attr, ['img'])
20
+ const img = group.img ?? {}
21
+ opts.class = prefix + (isEmpty(img.class) ? '' : (' ' + img.class.join(' ')))
22
+ const url = isString(this.params.attr.url) ? routePath(this.params.attr.url) : null
23
+ let animate = '@mouseenter="$el.style.opacity = 1" @mouseleave="$el.style.opacity = 0.3" '
24
+ if (this.params.attr.noAnimate) animate = ''
25
+ this.block.reactive.push(`
26
+ async ${prefix}Builder () {
27
+ const body = ['<c:${url ? `a url="${url}"` : 'div'}><c:img ${attribsStringify(img)} ']
28
+ body.push('${animate}')
29
+ body.push('/></c:${url ? 'a' : 'div'}>')
30
+ return await wmpa.createComponent(body)
31
+ }
32
+ `)
33
+
34
+ this.block.control.push(`
35
+ await wmaps.createControl(_.merge(${jsonStringify(opts, true)}, { builder: this.${prefix}Builder }))
36
+ `)
37
+
38
+ this.params.html = this.writeBlock()
39
+ }
40
+ }
41
+ }
42
+
43
+ export default controlImage
@@ -0,0 +1,27 @@
1
+ import control from './control.js'
2
+
3
+ async function controlLoader () {
4
+ const WmapsControl = await control.call(this)
5
+
6
+ return class WmapsControlLoader extends WmapsControl {
7
+ constructor (options) {
8
+ super(options)
9
+ this.params.noTag = true
10
+ }
11
+
12
+ async build () {
13
+ const { groupAttrs, attribsStringify } = this.plugin.app.waibuMpa
14
+ const group = groupAttrs(this.params.attr, ['progress'])
15
+ const attr = group.progress ?? {}
16
+ attr.value = '100'
17
+ attr.strip = 'animated'
18
+ if (!attr.height) attr.height = 3
19
+ if (!attr.background) attr.background = 'color:danger'
20
+ this.params.html = await this.component.buildSentence(`<c:div class="childmap maplibregl-ctrl-loader">
21
+ <c:progress ${attribsStringify(attr)} x-show="$store.wmpa.loading"/>
22
+ </c:div>`)
23
+ }
24
+ }
25
+ }
26
+
27
+ export default controlLoader
@@ -0,0 +1,50 @@
1
+ import control from './control.js'
2
+ const prefix = 'clogo'
3
+
4
+ async function controlLogo () {
5
+ const WmapsControl = await control.call(this)
6
+
7
+ return class WmapsControlLogo extends WmapsControl {
8
+ constructor (options) {
9
+ super(options)
10
+ this.params.noTag = true
11
+ }
12
+
13
+ async build () {
14
+ const { fastGlob } = this.plugin.app.bajo.lib
15
+ const { routePath } = this.plugin.app.waibu
16
+ const { jsonStringify, groupAttrs, attribsStringify } = this.plugin.app.waibuMpa
17
+ const opts = { class: prefix }
18
+ opts.position = this.ctrlPos.includes(this.params.attr.position) ? this.params.attr.position : 'top-left'
19
+ const group = groupAttrs(this.params.attr, ['img'])
20
+ const img = group.img ?? {}
21
+ let logo = 'waibu'
22
+ const files = await fastGlob(`${this.plugin.app.main.dir.pkg}/bajo/logo.*`)
23
+ if (files.length > 0) logo = 'main'
24
+ img.src = routePath(`waibuMpa:/logo/${logo}`)
25
+ let animate = '@mouseenter="$el.style.opacity = 1" @mouseleave="$el.style.opacity = 0.3" '
26
+ if (this.params.attr.noAnimate) {
27
+ animate = ''
28
+ } else {
29
+ img.style = img.style ?? {}
30
+ img.style.opacity = 0.3
31
+ }
32
+ this.block.reactive.push(`
33
+ async ${prefix}Builder () {
34
+ const body = ['<c:a href="#" @click="wbs.appLauncher(\\'user - fullscreen darkmode language\\')">']
35
+ body.push('<c:img ${attribsStringify(img)} ${animate} />')
36
+ body.push('</c:a>')
37
+ return await wmpa.createComponent(body)
38
+ }
39
+ `)
40
+
41
+ this.block.control.push(`
42
+ await wmaps.createControl(_.merge(${jsonStringify(opts, true)}, { builder: this.${prefix}Builder }))
43
+ `)
44
+
45
+ this.params.html = this.writeBlock()
46
+ }
47
+ }
48
+ }
49
+
50
+ export default controlLogo