ts-maps 0.0.0 → 0.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 (68) hide show
  1. package/README.md +154 -197
  2. package/dist/{coords-to-point.d.ts → core/coords-to-point.d.ts} +6 -4
  3. package/dist/{create-markers.d.ts → core/create-markers.d.ts} +2 -3
  4. package/dist/{create-regions.d.ts → core/create-regions.d.ts} +4 -1
  5. package/dist/{get-inset-for-point.d.ts → core/get-inset-for-point.d.ts} +18 -2
  6. package/dist/core/index.d.ts +24 -0
  7. package/dist/core/reposition-labels.d.ts +23 -0
  8. package/dist/{reposition-markers.d.ts → core/reposition-markers.d.ts} +3 -6
  9. package/dist/{set-scale.d.ts → core/set-scale.d.ts} +2 -2
  10. package/dist/{setup-container-events.d.ts → core/setup-container-events.d.ts} +2 -1
  11. package/dist/{setup-element-events.d.ts → core/setup-element-events.d.ts} +11 -4
  12. package/dist/{update-size.d.ts → core/update-size.d.ts} +2 -1
  13. package/dist/index.js +138 -56
  14. package/dist/map.d.ts +16 -10
  15. package/dist/maps/brasil.d.ts +1 -0
  16. package/dist/maps/brasil.js +7 -0
  17. package/dist/maps/canada.js +7 -0
  18. package/dist/maps/italy.js +7 -0
  19. package/dist/maps/spain.js +7 -0
  20. package/dist/maps/us-aea-en.d.ts +5 -0
  21. package/dist/maps/us-aea-en.js +7 -0
  22. package/dist/maps/us-lcc-en.d.ts +5 -0
  23. package/dist/maps/us-lcc-en.js +7 -0
  24. package/dist/maps/us-merc-en.d.ts +5 -0
  25. package/dist/maps/us-merc-en.js +7 -0
  26. package/dist/maps/us-mill-en.d.ts +5 -0
  27. package/dist/maps/us-mill-en.js +7 -0
  28. package/dist/maps/world-merc.js +7 -0
  29. package/dist/maps/world.js +7 -0
  30. package/dist/types.d.ts +16 -11
  31. package/dist/util/index.d.ts +25 -0
  32. package/dist/utils.d.ts +3 -1
  33. package/package.json +50 -6
  34. package/dist/brasil.d.ts +0 -1
  35. package/dist/reposition-labels.d.ts +0 -27
  36. package/dist/us-aea-en.d.ts +0 -266
  37. package/dist/us-lcc-en.d.ts +0 -266
  38. package/dist/us-merc-en.d.ts +0 -266
  39. package/dist/us-mill-en.d.ts +0 -266
  40. /package/dist/{base.d.ts → components/base.d.ts} +0 -0
  41. /package/dist/{interactable.d.ts → components/concerns/interactable.d.ts} +0 -0
  42. /package/dist/{line.d.ts → components/line.d.ts} +0 -0
  43. /package/dist/{marker.d.ts → components/marker.d.ts} +0 -0
  44. /package/dist/{region.d.ts → components/region.d.ts} +0 -0
  45. /package/dist/{tooltip.d.ts → components/tooltip.d.ts} +0 -0
  46. /package/dist/{apply-transform.d.ts → core/apply-transform.d.ts} +0 -0
  47. /package/dist/{create-lines.d.ts → core/create-lines.d.ts} +0 -0
  48. /package/dist/{create-series.d.ts → core/create-series.d.ts} +0 -0
  49. /package/dist/{get-marker-position.d.ts → core/get-marker-position.d.ts} +0 -0
  50. /package/dist/{reposition-lines.d.ts → core/reposition-lines.d.ts} +0 -0
  51. /package/dist/{resize.d.ts → core/resize.d.ts} +0 -0
  52. /package/dist/{set-focus.d.ts → core/set-focus.d.ts} +0 -0
  53. /package/dist/{setup-container-touch-events.d.ts → core/setup-container-touch-events.d.ts} +0 -0
  54. /package/dist/{setup-zoom-buttons.d.ts → core/setup-zoom-buttons.d.ts} +0 -0
  55. /package/dist/{events.d.ts → defaults/events.d.ts} +0 -0
  56. /package/dist/{options.d.ts → defaults/options.d.ts} +0 -0
  57. /package/dist/{canada.d.ts → maps/canada.d.ts} +0 -0
  58. /package/dist/{italy.d.ts → maps/italy.d.ts} +0 -0
  59. /package/dist/{spain.d.ts → maps/spain.d.ts} +0 -0
  60. /package/dist/{world-merc.d.ts → maps/world-merc.d.ts} +0 -0
  61. /package/dist/{world.d.ts → maps/world.d.ts} +0 -0
  62. /package/dist/{ordinal-scale.d.ts → scales/ordinal-scale.d.ts} +0 -0
  63. /package/dist/{base-element.d.ts → svg/base-element.d.ts} +0 -0
  64. /package/dist/{canvas-element.d.ts → svg/canvas-element.d.ts} +0 -0
  65. /package/dist/{image-element.d.ts → svg/image-element.d.ts} +0 -0
  66. /package/dist/{shape-element.d.ts → svg/shape-element.d.ts} +0 -0
  67. /package/dist/{text-element.d.ts → svg/text-element.d.ts} +0 -0
  68. /package/dist/{deep-merge.d.ts → util/deep-merge.d.ts} +0 -0
package/README.md CHANGED
@@ -1,248 +1,206 @@
1
- <p align="center"><img src="https://github.com/stacksjs/mail-server/blob/main/.github/art/cover.jpg?raw=true" alt="Social Card of this repo"></p>
1
+ <p align="center"><img src="https://github.com/stacksjs/ts-maps/blob/main/.github/art/cover.jpg?raw=true" alt="Social Card of ts-maps"></p>
2
2
 
3
3
  [![npm version][npm-version-src]][npm-version-href]
4
4
  [![GitHub Actions][github-actions-src]][github-actions-href]
5
5
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
6
- <!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] -->
7
- <!-- [![Codecov][codecov-src]][codecov-href] -->
8
6
 
9
- # The Post
7
+ # ts-maps
10
8
 
11
- > Finally a mail server that can be managed.
12
-
13
- Perfect for local development and testing environments. _Production-ready release coming soon!_
9
+ > Modern TypeScript library for creating stunning vector maps
14
10
 
15
11
  ## Features
16
12
 
17
- - 📨 **Mail Server** _lightweight, configurable, and extensible_
18
- - 🛠️ **Mail Utilities** _send, receive, and manage emails_
19
- - 📦 **Mail UI** _web interfaces for managing emails, including a component library_
20
- - 🤖 **CLI** _command-line interface for managing emails_
21
- - 🔒 **Security** _TLS support, authentication, and spam protection_
22
- - 🚀 **Performance** _optimized for high-throughput environments_
23
- - 🎯 **Modern** _built with TypeScript, zero dependencies_
24
- - 📝 **Logging** _detailed logging and monitoring capabilities_
13
+ - 🗺️ **Vector Maps**
14
+ - High-quality SVG-based interactive maps
15
+ - Multiple projection types (Mercator, Equal Earth)
16
+ - Built-in world maps and custom regions
25
17
 
26
- ## Install
18
+ - 📊 **Data Visualization**
19
+ - Choropleth maps with customizable scales
20
+ - Heat maps and bubble charts
21
+ - Interactive legends and tooltips
27
22
 
28
- ```bash
29
- bun install -d @stacksjs/post
30
- ```
23
+ - 🎯 **Framework Agnostic**
24
+ - Zero dependencies
25
+ - Works with any framework
26
+ - Official React and Vue bindings
31
27
 
32
- <!-- _Alternatively, you can install:_
28
+ - 🔒 **Type Safety**
29
+ - Full TypeScript support
30
+ - Strict types for better DX
31
+ - Comprehensive type definitions
32
+
33
+ ## Installation
33
34
 
34
35
  ```bash
35
- brew install post # wip
36
- pkgx install post # wip
37
- ``` -->
36
+ # Using npm
37
+ npm install ts-maps
38
38
 
39
- ## Get Started
39
+ # Using pnpm
40
+ pnpm add ts-maps
40
41
 
41
- There are two ways of using the mail server: _as a library or as a CLI._
42
+ # Using yarn
43
+ yarn add ts-maps
42
44
 
43
- ### Library Usage
45
+ # Using bun
46
+ bun add ts-maps
47
+ ```
44
48
 
45
- ```ts
46
- import { SMTPServer } from '@stacksjs/post'
49
+ ### Framework Bindings
47
50
 
48
- // Basic SMTP Server
49
- const server = new SMTPServer({
50
- secure: true,
51
- name: 'mail.example.com',
52
- banner: 'Welcome to My Mail Server',
53
- })
51
+ ```bash
52
+ # React
53
+ npm install ts-maps ts-maps-react
54
54
 
55
- server.listen(25)
56
-
57
- // Advanced Configuration
58
- const secureServer = new SMTPServer({
59
- // TLS Configuration
60
- secure: true,
61
- needsUpgrade: false,
62
- sniOptions: new Map([
63
- ['example.com', {
64
- key: fs.readFileSync('certs/example.com.key'),
65
- cert: fs.readFileSync('certs/example.com.cert')
66
- }]
67
- ]),
68
-
69
- // Authentication
70
- authMethods: ['PLAIN', 'LOGIN'],
71
- onAuth: (auth, session, callback) => {
72
- if (auth.username === 'user' && auth.password === 'pass')
73
- callback(null, { user: 'user' })
74
- else
75
- callback(new Error('Invalid credentials'))
76
- },
55
+ # Vue
56
+ npm install ts-maps ts-maps-vue
57
+ ```
77
58
 
78
- // Message Handling
79
- size: 1024 * 1024, // 1MB limit
80
- onData: (stream, session, callback) => {
81
- stream.pipe(process.stdout) // Echo message to console
82
- stream.on('end', callback)
59
+ ## Quick Start
60
+
61
+ ```typescript
62
+ import type { VectorMapOptions } from 'ts-maps'
63
+ import { VectorMap } from 'ts-maps'
64
+
65
+ // Create a map instance
66
+ const map = new VectorMap({
67
+ container: 'map',
68
+ map: 'world',
69
+ theme: 'light',
70
+ style: {
71
+ regions: {
72
+ fill: '#e4e4e4',
73
+ stroke: '#ffffff',
74
+ strokeWidth: 1,
75
+ },
76
+ hover: {
77
+ fill: '#2ca25f',
78
+ },
83
79
  },
84
-
85
- // Logging
86
- logger: {
87
- info: console.log,
88
- debug: console.debug,
89
- error: console.error
90
- }
91
80
  })
92
81
 
93
- secureServer.listen(465) // SMTPS port
82
+ // Add interactivity
83
+ map.on('regionClick', (event, region) => {
84
+ console.log(`Clicked: ${region.id}`)
85
+ })
94
86
  ```
95
87
 
96
- ### Event Handling
88
+ ### Data Visualization
97
89
 
98
- ```ts
99
- server.on('connect', (session) => {
100
- console.log('New connection from', session.remoteAddress)
101
- })
90
+ ```typescript
91
+ import type { DataVisualizationOptions } from 'ts-maps'
92
+ import { VectorMap } from 'ts-maps'
102
93
 
103
- server.on('error', (err) => {
104
- console.error('Server error:', err)
94
+ const map = new VectorMap({
95
+ container: 'map',
96
+ map: 'world',
105
97
  })
106
98
 
107
- server.on('close', () => {
108
- console.log('Server shutting down')
109
- })
99
+ // Add data visualization
100
+ const options: DataVisualizationOptions = {
101
+ scale: ['#e5f5f9', '#2ca25f'], // Color gradient from light blue to green
102
+ values: {
103
+ US: 100,
104
+ CA: 80,
105
+ GB: 65,
106
+ },
107
+ }
108
+
109
+ map.visualizeData(options)
110
110
  ```
111
111
 
112
- ### CLI Usage
112
+ ### React Component
113
+
114
+ ```tsx
115
+ import type { VectorMapProps } from 'ts-maps-react'
116
+ import { useVectorMap } from 'ts-maps-react'
117
+
118
+ function WorldMap() {
119
+ const { map, isLoading } = useVectorMap({
120
+ map: 'world',
121
+ theme: 'light',
122
+ })
123
+
124
+ return (
125
+ <div className="map-container">
126
+ {isLoading
127
+ ? (
128
+ <div>Loading...</div>
129
+ )
130
+ : (
131
+ <div id="map" />
132
+ )}
133
+ </div>
134
+ )
135
+ }
136
+ ```
113
137
 
114
- The Post CLI provides a comprehensive set of commands for managing your mail server:
138
+ ### Vue Component
115
139
 
116
- ```bash
117
- # Start the server
118
- post start # Start with default config
119
- post start --config custom # Use custom config file
120
- post start --port 25 # Specify port
121
- post start --secure # Start in TLS mode
122
-
123
- # Configuration
124
- post init # Create default config file
125
- post config show # Display current configuration
126
- post config set key=value # Update configuration
127
-
128
- # Monitoring
129
- post status # Show server status
130
- post logs # View server logs
131
- post logs --live # Live log streaming
132
- post stats # Show server statistics
133
-
134
- # User Management
135
- post users list # List all users
136
- post users add <email> # Add new user
137
- post users remove <email> # Remove user
138
- post users quota <email> # Show/set user quota
139
-
140
- # Queue Management
141
- post queue list # List queued messages
142
- post queue flush # Process all queued messages
143
- post queue remove <id> # Remove message from queue
144
-
145
- # Security
146
- post tls setup # Configure TLS certificates
147
- post tls renew # Renew certificates
148
- post blacklist add <ip> # Add IP to blacklist
149
- post whitelist add <ip> # Add IP to whitelist
150
-
151
- # Maintenance
152
- post backup # Create server backup
153
- post restore <file> # Restore from backup
154
- post cleanup # Clean old logs/messages
155
-
156
- # Advanced
157
- post test # Run server tests
158
- post benchmark # Run performance tests
159
- post debug # Start in debug mode
160
- ```
140
+ ```vue
141
+ <script setup lang="ts">
142
+ import type { VectorMapOptions } from 'ts-maps'
143
+ import { useVectorMap } from 'ts-maps-vue'
161
144
 
162
- ## Configuration
163
-
164
- The Mail Server can be configured using a `post.config.ts` _(or `post.config.js`)_ file:
165
-
166
- ```ts
167
- // post.config.ts
168
- export default {
169
- // Server Configuration
170
- server: {
171
- name: 'mail.example.com',
172
- secure: true,
173
- ports: {
174
- smtp: 25,
175
- smtps: 465,
176
- submission: 587
177
- }
178
- },
145
+ const { map, isLoading } = useVectorMap({
146
+ map: 'world',
147
+ theme: 'light',
148
+ })
149
+ </script>
150
+
151
+ <template>
152
+ <div class="map-container">
153
+ <div v-if="isLoading">
154
+ Loading...
155
+ </div>
156
+ <div v-else id="map" />
157
+ </div>
158
+ </template>
159
+ ```
179
160
 
180
- // TLS Configuration
181
- tls: {
182
- cert: '/path/to/cert.pem',
183
- key: '/path/to/key.pem',
184
- domains: ['example.com', 'mail.example.com']
185
- },
161
+ ## Documentation
186
162
 
187
- // Authentication
188
- auth: {
189
- methods: ['PLAIN', 'LOGIN'],
190
- database: 'sqlite://users.db'
191
- },
163
+ - [Introduction](https://ts-maps.dev/intro)
164
+ - [Installation](https://ts-maps.dev/install)
165
+ - [Usage Guide](https://ts-maps.dev/usage)
166
+ - [API Reference](https://ts-maps.dev/api)
167
+ - [Examples](https://ts-maps.dev/examples)
168
+ - [Playground](https://ts-maps.dev/playground)
192
169
 
193
- // Storage
194
- storage: {
195
- type: 'disk',
196
- path: '/var/mail',
197
- quota: '1GB'
198
- },
170
+ ## Development
199
171
 
200
- // Security
201
- security: {
202
- rateLimit: {
203
- window: '1h',
204
- max: 1000
205
- },
206
- spamProtection: true,
207
- dnsbl: ['zen.spamhaus.org']
208
- },
172
+ 1. Clone the repository:
209
173
 
210
- // Logging
211
- logging: {
212
- level: 'info',
213
- file: '/var/log/post.log',
214
- format: 'json'
215
- }
216
- }
174
+ ```bash
175
+ git clone https://github.com/stacksjs/ts-maps.git
176
+ cd ts-maps
217
177
  ```
218
178
 
219
- _Then run:_
179
+ 2. Install dependencies:
220
180
 
221
181
  ```bash
222
- post start
182
+ pnpm install
223
183
  ```
224
184
 
225
- To learn more, head over to the [documentation](https://the-post.sh/).
226
-
227
- ## Testing
185
+ 3. Start development:
228
186
 
229
187
  ```bash
230
- bun test
188
+ pnpm dev
231
189
  ```
232
190
 
233
191
  ## Changelog
234
192
 
235
- Please see our [releases](https://github.com/stacksjs/stacks/releases) page for more information on what has changed recently.
193
+ Please see our [releases](https://github.com/stacksjs/ts-maps/releases) page for more information on what has changed recently.
236
194
 
237
195
  ## Contributing
238
196
 
239
- Please review the [Contributing Guide](https://github.com/stacksjs/contributing) for details.
197
+ Please see [CONTRIBUTING](https://github.com/stacksjs/stacks/blob/main/.github/CONTRIBUTING.md) for details.
240
198
 
241
199
  ## Community
242
200
 
243
201
  For help, discussion about best practices, or any other conversation that would benefit from being searchable:
244
202
 
245
- [Discussions on GitHub](https://github.com/stacksjs/stacks/discussions)
203
+ [Discussions on GitHub](https://github.com/stacksjs/ts-maps/discussions)
246
204
 
247
205
  For casual chit-chat with others using this package:
248
206
 
@@ -250,9 +208,9 @@ For casual chit-chat with others using this package:
250
208
 
251
209
  ## Postcardware
252
210
 
253
- Two things are true: Stacks OSS will always stay open-source, and we do love to receive postcards from wherever Stacks is used! _We also publish them on our website. And thank you, Spatie_
211
+ “Software that is free, but hopes for a postcard.” We love receiving postcards from around the world showing where `ts-maps` is being used! We showcase them on our website too.
254
212
 
255
- Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094 🌎
213
+ Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎
256
214
 
257
215
  ## Sponsors
258
216
 
@@ -263,22 +221,21 @@ We would like to extend our thanks to the following sponsors for funding Stacks
263
221
 
264
222
  ## Credits
265
223
 
266
- - [Andris Reinman](https://github.com/andris9) _(Author of `nodemailer` & `smtp-server`)_
267
- - [Ralph Slooten](https://avatars.githubusercontent.com/u/1463435?s=64&v=4) _(Author of `mailtrap`)_
224
+ - [jsvectormap](https://github.com/themustafaomar/jsvectormap)
268
225
  - [Chris Breuer](https://github.com/chrisbbreuer)
269
- - [All Contributors](../../contributors)
226
+ - [All Contributors](https://github.com/stacksjs/ts-maps/contributors)
270
227
 
271
228
  ## License
272
229
 
273
- The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md) for more information.
230
+ The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/clarity/blob/main/LICENSE.md) for more information.
274
231
 
275
232
  Made with 💙
276
233
 
277
234
  <!-- Badges -->
278
- [npm-version-src]: https://img.shields.io/npm/v/@stacksjs/mail-server?style=flat-square
279
- [npm-version-href]: https://npmjs.com/package/@stacksjs/mail-server
280
- [github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/mail-server/ci.yml?style=flat-square&branch=main
281
- [github-actions-href]: https://github.com/stacksjs/mail-server/actions?query=workflow%3Aci
235
+ [npm-version-src]: https://img.shields.io/npm/v/@stacksjs/clarity?style=flat-square
236
+ [npm-version-href]: https://npmjs.com/package/@stacksjs/clarity
237
+ [github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/clarity/ci.yml?style=flat-square&branch=main
238
+ [github-actions-href]: https://github.com/stacksjs/clarity/actions?query=workflow%3Aci
282
239
 
283
- <!-- [codecov-src]: https://img.shields.io/codecov/c/gh/stacksjs/mail-server/main?style=flat-square
284
- [codecov-href]: https://codecov.io/gh/stacksjs/mail-server -->
240
+ <!-- [codecov-src]: https://img.shields.io/codecov/c/gh/stacksjs/clarity/main?style=flat-square
241
+ [codecov-href]: https://codecov.io/gh/stacksjs/clarity -->
@@ -16,11 +16,13 @@ export default function coordsToPoint(this: MapInterface, lat: number, lng: numb
16
16
  return false
17
17
  }
18
18
 
19
- const x = inset.leftLng + ((coords.x - inset.leftLng) / (inset.rightLng - inset.leftLng)) * inset.width
20
- const y = inset.topLat + ((coords.y - inset.topLat) / (inset.bottomLat - inset.topLat)) * inset.height
19
+ const { bbox } = inset
20
+
21
+ const x = (coords.x - bbox[0].x) / (bbox[1].x - bbox[0].x) * inset.width * this.scale
22
+ const y = (coords.y - bbox[0].y) / (bbox[1].y - bbox[0].y) * inset.height * this.scale
21
23
 
22
24
  return {
23
- x,
24
- y,
25
+ x: x + this.transX * this.scale + inset.left * this.scale,
26
+ y: y + this.transY * this.scale + inset.top * this.scale,
25
27
  }
26
28
  };
@@ -26,7 +26,7 @@ export default function createMarkers(
26
26
  {
27
27
  index,
28
28
  map: this,
29
- label: this.params.labels?.markers ? {} : undefined,
29
+ label: this.params.labels?.markers,
30
30
  labelsGroup: this._markerLabelsGroup,
31
31
  cx: point.x,
32
32
  cy: point.y,
@@ -34,14 +34,13 @@ export default function createMarkers(
34
34
  config,
35
35
  isRecentlyCreated,
36
36
  },
37
- merge(this.params.markerStyle || {}, { ...(config.style || {}) }, true),
37
+ merge({ initial: {} }, merge(this.params.markerStyle || {}, { ...(config.style || {}) }, true)),
38
38
  )
39
39
 
40
40
  if (this._markers?.[index]) {
41
41
  this.removeMarkers([index])
42
42
  }
43
43
 
44
- this._markers = this._markers || {}
45
44
  this._markers[index] = {
46
45
  _uid: uid,
47
46
  config,
@@ -6,14 +6,17 @@ export default function createRegions(this: MapInterface): void {
6
6
  map: this,
7
7
  code,
8
8
  path: this._mapData.paths[code].path,
9
- style: merge({}, this.params.regionStyle || {}),
9
+ style: merge({ initial: {} }, this.params.regionStyle || {}),
10
10
  labelStyle: this.params.regionLabelStyle,
11
11
  labelsGroup: this._regionLabelsGroup,
12
12
  label: this.params.labels?.regions ? {} : undefined,
13
13
  })
14
14
 
15
15
  this.regions[code] = {
16
+ config: this._mapData.paths[code],
16
17
  element: region,
18
+ path: this._mapData.paths[code].path,
19
+ name: code,
17
20
  } as RegionType
18
21
  }
19
22
  };
@@ -14,11 +14,27 @@ declare interface Inset {
14
14
  export default function getInsetForPoint(this: MapInterface, x: number, y: number): Inset | undefined {
15
15
  const insets = Map.maps[this.params.map.name].insets
16
16
 
17
+ if (!insets || insets.length === 0) {
18
+ return undefined
19
+ }
20
+
17
21
  for (let index = 0; index < insets.length; index++) {
18
- const [start, end] = insets[index].bbox
22
+ const inset = insets[index]
23
+
24
+ if (!inset || !inset.bbox || inset.bbox.length < 2) {
25
+ continue
26
+ }
27
+
28
+ const [start, end] = inset.bbox
29
+
30
+ if (!start || !end) {
31
+ continue
32
+ }
19
33
 
20
34
  if (x > start.x && x < end.x && y > start.y && y < end.y) {
21
- return insets[index]
35
+ return inset
22
36
  }
23
37
  }
38
+
39
+ return undefined
24
40
  };
@@ -0,0 +1,24 @@
1
+ declare interface CoreModule {
2
+ _setupContainerEvents: typeof _setupContainerEvents
3
+ _setupElementEvents: typeof _setupElementEvents
4
+ _setupZoomButtons: typeof _setupZoomButtons
5
+ _setupContainerTouchEvents: typeof _setupContainerTouchEvents
6
+ _createRegions: typeof _createRegions
7
+ _createLines: typeof _createLines
8
+ _createMarkers: typeof _createMarkers
9
+ _createSeries: typeof _createSeries
10
+ _applyTransform: typeof _applyTransform
11
+ _resize: typeof _resize
12
+ _setScale: typeof _setScale
13
+ setFocus: typeof setFocus
14
+ updateSize: typeof updateSize
15
+ coordsToPoint: typeof coordsToPoint
16
+ getInsetForPoint: typeof getInsetForPoint
17
+ getMarkerPosition: typeof getMarkerPosition
18
+ _repositionLines: typeof _repositionLines
19
+ _repositionMarkers: typeof _repositionMarkers
20
+ _repositionLabels: typeof _repositionLabels
21
+ }
22
+ declare const core: CoreModule;
23
+
24
+ export default core;
@@ -0,0 +1,23 @@
1
+ export default function repositionLabels(this: MapInterface): void {
2
+ const labels = this.params.labels || {}
3
+
4
+ if (labels.regions) {
5
+ for (const code in this.regions) {
6
+ const region = this.regions[code] as any
7
+
8
+ if (!region || !region.element || !region.element.label) {
9
+ continue
10
+ }
11
+ region.element.updateLabelPosition()
12
+ }
13
+ }
14
+
15
+ if (labels.markers) {
16
+ for (const index in this._markers) {
17
+ const marker = this._markers[index] as any
18
+ if (marker.element && typeof marker.element.updateLabelPosition === 'function') {
19
+ marker.element.updateLabelPosition()
20
+ }
21
+ }
22
+ }
23
+ };
@@ -4,7 +4,8 @@ export default function repositionMarkers(this: MapInterface): void {
4
4
 
5
5
  for (const index in this._markers) {
6
6
  const marker = this._markers[index] as any
7
- if (!marker || !marker.shape)
7
+
8
+ if (!marker || !marker.element || !marker.element.shape)
8
9
  continue
9
10
 
10
11
  const point = this.getMarkerPosition(marker.config)
@@ -13,14 +14,10 @@ export default function repositionMarkers(this: MapInterface): void {
13
14
  const cx = Number.isNaN(point.x) ? 0 : point.x
14
15
  const cy = Number.isNaN(point.y) ? 0 : point.y
15
16
 
16
- marker.shape.set({
17
+ marker.element.shape.set({
17
18
  cx,
18
19
  cy,
19
20
  })
20
-
21
- if (marker.label) {
22
- marker.updateLabelPosition()
23
- }
24
21
  }
25
22
  }
26
23
  };
@@ -16,8 +16,8 @@ export default function setScale(
16
16
  let transXDiff: number
17
17
  let transYStart: number
18
18
  let transYDiff: number
19
- let transX = this.transX
20
- let transY = this.transY
19
+ let transX: number = this.transX
20
+ let transY: number = this.transY
21
21
 
22
22
  const zoomMax = this.params.zoomMax ?? 8
23
23
  const zoomMin = this.params.zoomMin ?? 1
@@ -13,7 +13,8 @@ export default function setupContainerEvents(this: MapInterface): void {
13
13
  if (oldPageX !== undefined && oldPageY !== undefined) {
14
14
  this.transX -= (oldPageX - mouseEvent.pageX) / this.scale
15
15
  this.transY -= (oldPageY - mouseEvent.pageY) / this.scale
16
- this.canvas.applyTransformParams(this.scale, this.transX, this.transY)
16
+
17
+ this._applyTransform()
17
18
  }
18
19
  oldPageX = mouseEvent.pageX
19
20
  oldPageY = mouseEvent.pageY
@@ -39,6 +39,7 @@ export default function setupElementEvents(this: MapInterface): void {
39
39
  EventHandler.delegate(container, 'mouseover mouseout', '.jvm-element', ((e: Event) => {
40
40
  try {
41
41
  const data = parseEvent(this, (e.target as Element), true)
42
+
42
43
  const { showTooltip } = this.params
43
44
  const tooltip = this._tooltip
44
45
 
@@ -48,9 +49,10 @@ export default function setupElementEvents(this: MapInterface): void {
48
49
  }
49
50
 
50
51
  if (showTooltip && tooltip) {
51
- tooltip.text(data.tooltipText)
52
- tooltip.show(data.tooltipText)
53
- this._emit(data.event, [e, tooltip.getElement(), data.code])
52
+ this._emit(data.event, [data.event, tooltip, data.code])
53
+ if (!e.defaultPrevented) {
54
+ tooltip.show(data.tooltipText)
55
+ }
54
56
  }
55
57
  }
56
58
  else {
@@ -64,7 +66,11 @@ export default function setupElementEvents(this: MapInterface): void {
64
66
  }
65
67
  }
66
68
  catch (error) {
67
- console.error('Error in mouseover/mouseout handler:', error)
69
+ const errorMessage = error instanceof Error ? error.message : String(error)
70
+ console.warn('Skipping mouseover/mouseout event due to error:', errorMessage)
71
+ if (e.type === 'mouseout' && this._tooltip) {
72
+ this._tooltip.hide()
73
+ }
68
74
  }
69
75
  }) as EventListener)
70
76
 
@@ -95,6 +101,7 @@ export default function setupElementEvents(this: MapInterface): void {
95
101
  }
96
102
 
97
103
  this._emit(data.event, [
104
+ data.event,
98
105
  data.code,
99
106
  element.isSelected,
100
107
  data.type === 'region'