@versatiles/svelte 2.0.0 → 2.1.0

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 (83) hide show
  1. package/dist/components/BBoxMap/BBoxMap.svelte +23 -12
  2. package/dist/components/BBoxMap/lib/bbox.d.ts +1 -1
  3. package/dist/components/BBoxMap/lib/bbox.js +19 -17
  4. package/dist/components/BasicMap/BasicMap.svelte +22 -9
  5. package/dist/components/BasicMap/BasicMap.svelte.d.ts +2 -1
  6. package/dist/components/MapEditor/MapEditor.svelte +51 -20
  7. package/dist/components/MapEditor/components/Dialog.svelte +92 -0
  8. package/dist/components/MapEditor/components/Dialog.svelte.d.ts +17 -0
  9. package/dist/components/MapEditor/components/DialogFile.svelte +112 -0
  10. package/dist/components/MapEditor/components/DialogFile.svelte.d.ts +6 -0
  11. package/dist/components/MapEditor/components/DialogShare.svelte +216 -0
  12. package/dist/components/MapEditor/components/DialogShare.svelte.d.ts +10 -0
  13. package/dist/components/MapEditor/components/Editor.svelte +16 -14
  14. package/dist/components/MapEditor/components/EditorFill.svelte +35 -3
  15. package/dist/components/MapEditor/components/EditorStroke.svelte +35 -3
  16. package/dist/components/MapEditor/components/EditorSymbol.svelte +85 -8
  17. package/dist/components/MapEditor/components/InputRow.svelte +2 -3
  18. package/dist/components/MapEditor/components/PanelFile.svelte +73 -0
  19. package/dist/components/MapEditor/components/PanelFile.svelte.d.ts +7 -0
  20. package/dist/components/MapEditor/components/PanelSymbolSelector.svelte +82 -0
  21. package/dist/components/MapEditor/components/PanelSymbolSelector.svelte.d.ts +8 -0
  22. package/dist/components/MapEditor/components/Sidebar.svelte +59 -103
  23. package/dist/components/MapEditor/components/Sidebar.svelte.d.ts +3 -3
  24. package/dist/components/MapEditor/components/SidebarPanel.svelte +26 -9
  25. package/dist/components/MapEditor/lib/element/abstract.d.ts +8 -4
  26. package/dist/components/MapEditor/lib/element/abstract.js +11 -2
  27. package/dist/components/MapEditor/lib/element/abstract_path.d.ts +3 -2
  28. package/dist/components/MapEditor/lib/element/abstract_path.js +6 -3
  29. package/dist/components/MapEditor/lib/element/circle.d.ts +25 -0
  30. package/dist/components/MapEditor/lib/element/circle.js +118 -0
  31. package/dist/components/MapEditor/lib/element/line.d.ts +2 -2
  32. package/dist/components/MapEditor/lib/element/line.js +1 -1
  33. package/dist/components/MapEditor/lib/element/marker.d.ts +4 -3
  34. package/dist/components/MapEditor/lib/element/marker.js +2 -2
  35. package/dist/components/MapEditor/lib/element/polygon.d.ts +2 -2
  36. package/dist/components/MapEditor/lib/element/polygon.js +2 -2
  37. package/dist/components/MapEditor/lib/element/types.d.ts +2 -3
  38. package/dist/components/MapEditor/lib/geometry_manager.d.ts +12 -29
  39. package/dist/components/MapEditor/lib/geometry_manager.js +44 -162
  40. package/dist/components/MapEditor/lib/geometry_manager_interactive.d.ts +33 -0
  41. package/dist/components/MapEditor/lib/geometry_manager_interactive.js +102 -0
  42. package/dist/components/MapEditor/lib/map_layer/abstract.d.ts +2 -2
  43. package/dist/components/MapEditor/lib/map_layer/abstract.js +25 -25
  44. package/dist/components/MapEditor/lib/map_layer/fill.js +5 -16
  45. package/dist/components/MapEditor/lib/map_layer/line.js +5 -17
  46. package/dist/components/MapEditor/lib/map_layer/symbol.js +1 -1
  47. package/dist/components/MapEditor/lib/selection.d.ts +11 -0
  48. package/dist/components/MapEditor/lib/selection.js +70 -0
  49. package/dist/components/MapEditor/lib/state/constants.js +5 -6
  50. package/dist/components/MapEditor/lib/state/history.d.ts +14 -0
  51. package/dist/components/MapEditor/lib/state/history.js +53 -0
  52. package/dist/components/MapEditor/lib/state/manager.d.ts +8 -10
  53. package/dist/components/MapEditor/lib/state/manager.js +24 -48
  54. package/dist/components/MapEditor/lib/state/reader.d.ts +6 -4
  55. package/dist/components/MapEditor/lib/state/reader.js +70 -18
  56. package/dist/components/MapEditor/lib/state/types.d.ts +19 -2
  57. package/dist/components/MapEditor/lib/state/utils.d.ts +2 -0
  58. package/dist/components/MapEditor/lib/state/utils.js +12 -0
  59. package/dist/components/MapEditor/lib/state/writer.d.ts +6 -4
  60. package/dist/components/MapEditor/lib/state/writer.js +59 -19
  61. package/dist/components/MapEditor/lib/symbols.d.ts +1 -1
  62. package/dist/components/MapEditor/lib/symbols.js +47 -28
  63. package/dist/components/MapEditor/lib/utils/event_handler.d.ts +10 -0
  64. package/dist/components/MapEditor/lib/utils/event_handler.js +39 -0
  65. package/dist/components/MapEditor/lib/utils/geometry.d.ts +12 -0
  66. package/dist/components/MapEditor/lib/utils/geometry.js +87 -0
  67. package/dist/components/MapEditor/lib/utils/types.d.ts +2 -0
  68. package/dist/components/MapEditor/lib/utils/types.js +1 -0
  69. package/dist/components/MapEditor/style/button.scss +115 -0
  70. package/dist/components/MapEditor/style/index.scss +3 -0
  71. package/dist/components/MapEditor/style/layout.scss +20 -0
  72. package/dist/components/MapEditor/style/other.scss +10 -0
  73. package/dist/utils/location.d.ts +1 -0
  74. package/dist/utils/location.js +181 -0
  75. package/dist/utils/map_style.d.ts +2 -2
  76. package/dist/utils/map_style.js +2 -2
  77. package/package.json +29 -29
  78. package/dist/components/MapEditor/components/SymbolSelector.svelte +0 -110
  79. package/dist/components/MapEditor/components/SymbolSelector.svelte.d.ts +0 -8
  80. package/dist/components/MapEditor/lib/utils.d.ts +0 -6
  81. package/dist/components/MapEditor/lib/utils.js +0 -23
  82. /package/dist/components/MapEditor/lib/{geocoder.d.ts → utils/geocoder.d.ts} +0 -0
  83. /package/dist/components/MapEditor/lib/{geocoder.js → utils/geocoder.js} +0 -0
@@ -38,3 +38,184 @@ export function getLanguage() {
38
38
  return null; // Fallback if no country can be determined
39
39
  }
40
40
  }
41
+ const countryBoundingBoxes = {
42
+ AF: [60.5, 29.3, 75.2, 38.5],
43
+ AO: [11.6, -18, 24.1, -4.4],
44
+ AL: [19.3, 39.6, 21.1, 42.7],
45
+ AE: [51.5, 22.4, 56.4, 26.1],
46
+ AR: [-73.5, -55.3, -53.6, -21.8],
47
+ AM: [43.5, 38.7, 46.6, 41.3],
48
+ AQ: [-180, -90, 180, -63.2],
49
+ TF: [68.7, -49.8, 70.6, -48.6],
50
+ AU: [113.3, -43.7, 153.6, -10.6],
51
+ AT: [9.4, 46.4, 17, 49.1],
52
+ AZ: [44.7, 38.2, 50.4, 41.9],
53
+ BI: [29, -4.5, 30.8, -2.3],
54
+ BE: [2.5, 49.5, 6.2, 51.5],
55
+ BJ: [0.7, 6.1, 3.8, 12.3],
56
+ BF: [-5.5, 9.6, 2.2, 15.2],
57
+ BD: [88, 20.6, 92.7, 26.5],
58
+ BG: [22.3, 41.2, 28.6, 44.3],
59
+ BS: [-79, 23.7, -77, 27.1],
60
+ BA: [15.7, 42.6, 19.6, 45.3],
61
+ BY: [23.1, 51.3, 32.7, 56.2],
62
+ BZ: [-89.3, 15.8, -88.1, 18.5],
63
+ BO: [-69.6, -22.9, -57.4, -9.7],
64
+ BR: [-74, -33.8, -34.7, 5.3],
65
+ BN: [114.2, 4, 115.5, 5.5],
66
+ BT: [88.8, 26.7, 92.2, 28.3],
67
+ BW: [19.8, -26.9, 29.5, -17.6],
68
+ CF: [14.4, 2.2, 27.4, 11.2],
69
+ CA: [-141, 41.6, -52.6, 83.3],
70
+ CH: [6, 45.7, 10.5, 47.9],
71
+ CL: [-75.7, -55.7, -66.9, -17.5],
72
+ CN: [73.6, 18.1, 135.1, 53.5],
73
+ CI: [-8.7, 4.3, -2.5, 10.6],
74
+ CM: [8.4, 1.7, 16.1, 12.9],
75
+ CD: [12.1, -13.3, 31.2, 5.3],
76
+ CG: [11, -5.1, 18.5, 3.8],
77
+ CO: [-79, -4.3, -66.8, 12.5],
78
+ CR: [-86, 8.2, -82.5, 11.3],
79
+ CU: [-85, 19.8, -74.1, 23.2],
80
+ CY: [32.2, 34.5, 34.1, 35.2],
81
+ CZ: [12.2, 48.5, 18.9, 51.2],
82
+ DE: [5.9, 47.3, 15.1, 55],
83
+ DJ: [41.6, 10.9, 43.4, 12.7],
84
+ DK: [8, 54.8, 12.7, 57.8],
85
+ DO: [-72, 17.5, -68.3, 19.9],
86
+ DZ: [-8.7, 19, 12, 37.2],
87
+ EC: [-81, -5, -75.2, 1.4],
88
+ EG: [24.7, 22, 36.9, 31.6],
89
+ ER: [36.3, 12.4, 43.1, 18],
90
+ ES: [-9.4, 35.9, 3.1, 43.8],
91
+ EE: [23.3, 57.4, 28.2, 59.7],
92
+ ET: [32.9, 3.4, 47.8, 15],
93
+ FI: [20.6, 59.8, 31.6, 70.2],
94
+ FJ: [-180, -18.3, 180, -16],
95
+ FK: [-61.2, -52.3, -57.7, -51.1],
96
+ FR: [-54.6, 2, 9.6, 51.2],
97
+ GA: [8.7, -4, 14.5, 2.4],
98
+ GB: [-7.6, 49.9, 1.7, 58.7],
99
+ GE: [39.9, 41, 46.7, 43.6],
100
+ GH: [-3.3, 4.7, 1.1, 11.1],
101
+ GN: [-15.2, 7.3, -7.8, 12.6],
102
+ GM: [-16.9, 13.1, -13.8, 13.9],
103
+ GW: [-16.7, 11, -13.7, 12.7],
104
+ GQ: [9.3, 1, 11.3, 2.3],
105
+ GR: [20.1, 34.9, 26.7, 41.9],
106
+ GL: [-73.3, 60, -12.2, 83.7],
107
+ GT: [-92.3, 13.7, -88.2, 17.9],
108
+ GY: [-61.5, 1.2, -56.5, 8.4],
109
+ HN: [-89.4, 12.9, -83.1, 16.1],
110
+ HR: [13.6, 42.4, 19.4, 46.6],
111
+ HT: [-74.5, 18, -71.6, 20],
112
+ HU: [16.2, 45.7, 22.8, 48.7],
113
+ ID: [95.2, -10.4, 141.1, 5.5],
114
+ IN: [68.1, 7.9, 97.5, 35.5],
115
+ IE: [-10, 51.6, -6, 55.2],
116
+ IR: [44.1, 25, 63.4, 39.8],
117
+ IQ: [38.7, 29, 48.6, 37.4],
118
+ IS: [-24.4, 63.4, -13.6, 66.6],
119
+ IL: [34.2, 29.5, 35.9, 33.3],
120
+ IT: [6.7, 36.6, 18.5, 47.2],
121
+ JM: [-78.4, 17.7, -76.1, 18.6],
122
+ JO: [34.9, 29.1, 39.2, 33.4],
123
+ JP: [129.4, 31, 145.6, 45.6],
124
+ KZ: [46.4, 40.6, 87.4, 55.4],
125
+ KE: [33.8, -4.7, 41.9, 5.6],
126
+ KG: [69.4, 39.2, 80.3, 43.3],
127
+ KH: [102.3, 10.4, 107.7, 14.6],
128
+ KR: [126.1, 34.3, 129.5, 38.7],
129
+ KW: [46.5, 28.5, 48.5, 30.1],
130
+ LA: [100.1, 13.8, 107.6, 22.5],
131
+ LB: [35.1, 33, 36.7, 34.7],
132
+ LR: [-11.5, 4.3, -7.5, 8.6],
133
+ LY: [9.3, 19.5, 25.2, 33.2],
134
+ LK: [79.6, 5.9, 81.8, 9.9],
135
+ LS: [26.9, -30.7, 29.4, -28.6],
136
+ LT: [21, 53.9, 26.6, 56.4],
137
+ LU: [5.6, 49.4, 6.3, 50.2],
138
+ LV: [21, 55.6, 28.2, 58],
139
+ MA: [-17.1, 21.4, -1.1, 35.8],
140
+ MD: [26.6, 45.4, 30.1, 48.5],
141
+ MG: [43.2, -25.7, 50.5, -12],
142
+ MX: [-117.2, 14.5, -86.8, 32.8],
143
+ MK: [20.4, 40.8, 23, 42.4],
144
+ ML: [-12.2, 10, 4.3, 25],
145
+ MM: [92.3, 9.9, 101.2, 28.4],
146
+ ME: [18.4, 41.8, 20.4, 43.6],
147
+ MN: [87.7, 41.5, 119.8, 52.1],
148
+ MZ: [30.1, -26.8, 40.8, -10.3],
149
+ MR: [-17.1, 14.6, -4.9, 27.4],
150
+ MW: [32.6, -16.9, 35.8, -9.2],
151
+ MY: [100, 0.7, 119.2, 7],
152
+ NA: [11.7, -29.1, 25.1, -16.9],
153
+ NC: [164, -22.4, 167.2, -20.1],
154
+ NE: [0.2, 11.6, 16, 23.5],
155
+ NG: [2.6, 4.2, 14.6, 13.9],
156
+ NI: [-87.7, 10.7, -83.1, 15.1],
157
+ NL: [3.3, 50.8, 7.1, 53.6],
158
+ NO: [4.9, 58, 31.3, 80.7],
159
+ NP: [80, 26.3, 88.2, 30.5],
160
+ NZ: [166.5, -46.7, 178.6, -34.4],
161
+ OM: [52, 16.6, 59.9, 26.4],
162
+ PK: [60.8, 23.6, 77.9, 37.2],
163
+ PA: [-83, 7.2, -77.2, 9.7],
164
+ PE: [-81.5, -18.4, -68.6, 0],
165
+ PH: [117.1, 5.5, 126.6, 18.6],
166
+ PG: [141, -10.7, 156.1, -2.5],
167
+ PL: [14, 49, 24.1, 54.9],
168
+ PR: [-67.3, 17.9, -65.5, 18.6],
169
+ KP: [124.2, 37.6, 130.8, 43],
170
+ PT: [-9.6, 36.8, -6.3, 42.3],
171
+ PY: [-62.7, -27.6, -54.2, -19.3],
172
+ QA: [50.7, 24.5, 51.7, 26.2],
173
+ RO: [20.2, 43.6, 29.7, 48.3],
174
+ RU: [-180, 41.1, 180, 81.3],
175
+ RW: [29, -3, 30.9, -1.1],
176
+ SA: [34.6, 16.3, 55.7, 32.2],
177
+ SD: [21.9, 8.6, 38.5, 22],
178
+ SS: [23.8, 3.5, 35.3, 12.3],
179
+ SN: [-17.7, 12.3, -11.4, 16.6],
180
+ SB: [156.4, -10.9, 162.4, -6.5],
181
+ SL: [-13.3, 6.7, -10.2, 10.1],
182
+ SV: [-90.1, 13.1, -87.7, 14.5],
183
+ SO: [40.9, -1.7, 51.2, 12.1],
184
+ RS: [18.8, 42.2, 23, 46.2],
185
+ SR: [-58.1, 1.8, -53.9, 6.1],
186
+ SK: [16.8, 47.7, 22.6, 49.6],
187
+ SI: [13.6, 45.4, 16.6, 46.9],
188
+ SE: [11, 55.3, 24, 69.2],
189
+ SZ: [30.6, -27.3, 32.1, -25.6],
190
+ SY: [35.7, 32.3, 42.4, 37.3],
191
+ TD: [13.5, 7.4, 23.9, 23.5],
192
+ TG: [-0.1, 5.9, 1.9, 11.1],
193
+ TH: [97.3, 5.6, 105.6, 20.5],
194
+ TJ: [67.4, 36.7, 75, 41],
195
+ TM: [52.5, 35.2, 66.6, 42.8],
196
+ TL: [124.9, -9.4, 127.4, -8.2],
197
+ TT: [-62, 10, -60.8, 10.9],
198
+ TN: [7.5, 30.3, 11.5, 37.4],
199
+ TR: [26, 35.8, 44.8, 42.2],
200
+ TW: [120.1, 21.9, 122, 25.3],
201
+ TZ: [29.3, -11.8, 40.4, -0.9],
202
+ UG: [29.5, -1.5, 35.1, 4.3],
203
+ UA: [22, 44.3, 40.1, 52.4],
204
+ UY: [-58.5, -35, -53.2, -30.1],
205
+ US: [-171.8, 18.9, -66.9, 71.4],
206
+ UZ: [55.9, 37.1, 73.1, 45.6],
207
+ VE: [-73.4, 0.7, -59.7, 12.2],
208
+ VN: [102.1, 8.5, 109.4, 23.4],
209
+ VU: [166.6, -16.6, 167.9, -14.6],
210
+ PS: [34.9, 31.3, 35.6, 32.6],
211
+ YE: [42.6, 12.5, 53.2, 19.1],
212
+ ZA: [16.3, -34.9, 32.9, -22],
213
+ ZM: [21.8, -18, 33.5, -8.2],
214
+ ZW: [25.2, -22.3, 32.9, -15.5]
215
+ };
216
+ export function getCountryBoundingBox() {
217
+ const countryCode = getCountryCode();
218
+ if (!countryCode)
219
+ return null;
220
+ return countryBoundingBoxes[countryCode] ?? null;
221
+ }
@@ -1,6 +1,6 @@
1
1
  import { type StyleBuilderOptions } from '@versatiles/style';
2
- export declare function getMapStyle(darkMode: boolean, styleOptions?: StyleBuilderOptions & {
2
+ export declare function getMapStyle(styleOptions?: StyleBuilderOptions & {
3
+ darkMode?: boolean;
3
4
  transitionDuration?: number;
4
- disableDarkMode?: boolean;
5
5
  }): import("maplibre-gl").StyleSpecification;
6
6
  export declare function isDarkMode(element?: HTMLElement): boolean;
@@ -1,7 +1,7 @@
1
1
  import { styles } from '@versatiles/style';
2
2
  import { getLanguage } from './location.js';
3
- export function getMapStyle(darkMode, styleOptions = {}) {
4
- darkMode = darkMode && !styleOptions.disableDarkMode;
3
+ export function getMapStyle(styleOptions = {}) {
4
+ const darkMode = styleOptions.darkMode ?? isDarkMode();
5
5
  const style = styles.colorful({
6
6
  baseUrl: 'https://tiles.versatiles.org',
7
7
  language: getLanguage(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versatiles/svelte",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "build": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json && vite build && npm run package",
@@ -13,12 +13,12 @@
13
13
  "prepack": "npm run build",
14
14
  "prepublishOnly": "npm run package",
15
15
  "preview": "vite preview",
16
- "screenshots": "npx tsx ./scripts/screenshots.ts",
17
16
  "release": "vrt release-npm",
18
- "test-integration": "playwright test",
19
- "test-unit": "vitest run",
17
+ "screenshots": "npx tsx ./scripts/screenshots.ts",
20
18
  "test-coverage": "vitest run --coverage",
21
- "test": "npm run test-unit && npm run test-integration",
19
+ "test-playwright": "./scripts/test_playwright.sh",
20
+ "test-unit": "vitest run",
21
+ "test": "npm run test-unit && npm run test-playwright",
22
22
  "upgrade": "vrt deps-upgrade"
23
23
  },
24
24
  "exports": {
@@ -36,45 +36,45 @@
36
36
  "!dist/BBoxMap/helpers/*"
37
37
  ],
38
38
  "peerDependencies": {
39
- "sass-embedded": "^1.86.3",
40
- "svelte": "^5.27.0"
39
+ "sass-embedded": "^1.89.2",
40
+ "svelte": "^5.28.6"
41
41
  },
42
42
  "devDependencies": {
43
- "@playwright/test": "^1.51.1",
43
+ "@playwright/test": "^1.53.2",
44
44
  "@sveltejs/adapter-static": "^3.0.8",
45
- "@sveltejs/kit": "^2.20.7",
46
- "@sveltejs/package": "^2.3.11",
47
- "@sveltejs/vite-plugin-svelte": "^5.0.3",
45
+ "@sveltejs/kit": "^2.22.2",
46
+ "@sveltejs/package": "^2.3.12",
47
+ "@sveltejs/vite-plugin-svelte": "^5.1.0",
48
48
  "@turf/turf": "^7.2.0",
49
49
  "@types/eslint": "^9.6.1",
50
- "@types/node": "^22.14.1",
50
+ "@types/node": "^22.15.34",
51
51
  "@versatiles/release-tool": "^2.4.2",
52
- "@vitest/coverage-v8": "^3.1.1",
52
+ "@vitest/coverage-v8": "^3.2.4",
53
53
  "cookie": "^1.0.2",
54
- "eslint": "^9.24.0",
55
- "eslint-config-prettier": "^10.1.2",
56
- "eslint-plugin-svelte": "^3.5.1",
54
+ "eslint": "^9.30.0",
55
+ "eslint-config-prettier": "^10.1.5",
56
+ "eslint-plugin-svelte": "^3.10.1",
57
57
  "geojson": "^0.5.0",
58
- "globals": "^16.0.0",
59
- "happy-dom": "^17.4.4",
60
- "prettier": "^3.5.3",
61
- "prettier-plugin-svelte": "^3.3.3",
58
+ "globals": "^16.3.0",
59
+ "happy-dom": "^17.6.3",
60
+ "prettier": "^3.6.2",
61
+ "prettier-plugin-svelte": "^3.4.0",
62
62
  "publint": "^0.3.12",
63
- "sass": "^1.86.3",
64
- "svelte": "^5.27.0",
65
- "svelte-check": "^4.1.6",
63
+ "sass": "^1.89.2",
64
+ "svelte": "^5.34.9",
65
+ "svelte-check": "^4.2.2",
66
66
  "svelte-preprocess": "^6.0.3",
67
- "tsx": "^4.19.3",
67
+ "tsx": "^4.20.3",
68
68
  "typescript": "^5.8.3",
69
- "typescript-eslint": "^8.30.1",
70
- "vite": "^6.2.6",
71
- "vitest": "^3.1.1"
69
+ "typescript-eslint": "^8.35.1",
70
+ "vite": "^6.3.5",
71
+ "vitest": "^3.1.3"
72
72
  },
73
73
  "svelte": "./dist/index.js",
74
74
  "types": "./dist/index.d.ts",
75
75
  "type": "module",
76
76
  "dependencies": {
77
- "@versatiles/style": "^5.6.0",
78
- "maplibre-gl": "^5.3.1"
77
+ "@versatiles/style": "^5.7.0",
78
+ "maplibre-gl": "^5.6.0"
79
79
  }
80
80
  }
@@ -1,110 +0,0 @@
1
- <script lang="ts">
2
- import type { Action } from 'svelte/action';
3
- import type { SymbolLibrary } from '../lib/symbols.js';
4
-
5
- let {
6
- symbolIndex = $bindable(),
7
- symbolLibrary
8
- }: { symbolIndex: number; symbolLibrary: SymbolLibrary } = $props();
9
-
10
- const drawIconHalo: Action<HTMLCanvasElement, number> = (canvas, index) =>
11
- symbolLibrary.drawSymbol(canvas, index, true);
12
-
13
- const drawIcon: Action<HTMLCanvasElement, number> = (canvas, index) =>
14
- symbolLibrary.drawSymbol(canvas, index);
15
-
16
- let dialog: HTMLDialogElement | null = null;
17
- </script>
18
-
19
- <button
20
- onclick={() => dialog?.showModal()}
21
- style="text-align: left; white-space: nowrap; overflow: hidden; padding: 1px"
22
- >
23
- {#key symbolIndex}
24
- <canvas
25
- width="40"
26
- height="40"
27
- use:drawIcon={symbolIndex}
28
- style="width:20px;height:20px;vertical-align:middle"
29
- ></canvas>
30
- {/key}
31
- {#if symbolIndex !== undefined}
32
- {symbolLibrary.getSymbol(symbolIndex)?.name}
33
- {:else}
34
- Select Symbol
35
- {/if}
36
- </button>
37
-
38
- <dialog class="modal" bind:this={dialog}>
39
- <button class="close" onclick={() => dialog?.close()}>&#x2715;</button>
40
- <div class="inner">
41
- {#each symbolLibrary.asList() as symbol (symbol.index)}
42
- <button class="icon" onclick={() => (symbolIndex = symbol.index)}
43
- ><canvas width="64" height="64" use:drawIconHalo={symbol.index}></canvas><br
44
- />{symbol.name}</button
45
- >
46
- {/each}
47
- </div>
48
- </dialog>
49
-
50
- <style>
51
- .modal {
52
- width: min(500px, 100vw);
53
- height: min(500px, 100vh);
54
- background-color: rgba(255, 255, 255, 0.5);
55
- backdrop-filter: blur(20px) brightness(0.85);
56
- box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.2);
57
- z-index: 10000;
58
- border: 0.5px solid rgba(0, 0, 0, 0.5);
59
- border-radius: 10px;
60
- box-sizing: border-box;
61
- padding: 20px;
62
-
63
- .inner {
64
- width: 100%;
65
- height: 100%;
66
- overflow-y: scroll;
67
- display: grid;
68
- grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
69
- row-gap: 10px;
70
- column-gap: 0px;
71
- justify-items: center;
72
-
73
- .icon {
74
- width: 48px;
75
- height: 48px;
76
- cursor: pointer;
77
- border: none;
78
- font-size: 0.6em;
79
- background: none;
80
- line-height: 1em;
81
- text-align: center;
82
- padding: 0;
83
-
84
- &:hover {
85
- background-color: rgba(0, 0, 0, 0.1);
86
- }
87
-
88
- canvas {
89
- display: inline-block;
90
- width: 32px;
91
- height: 32px;
92
- }
93
- }
94
- }
95
-
96
- .close {
97
- position: absolute;
98
- top: 0px;
99
- right: 0px;
100
- font-size: 20px;
101
- cursor: pointer;
102
- background: none;
103
- border: none;
104
- width: 25px;
105
- height: 25px;
106
- text-align: center;
107
- padding: 0;
108
- }
109
- }
110
- </style>
@@ -1,8 +0,0 @@
1
- import type { SymbolLibrary } from '../lib/symbols.js';
2
- type $$ComponentProps = {
3
- symbolIndex: number;
4
- symbolLibrary: SymbolLibrary;
5
- };
6
- declare const SymbolSelector: import("svelte").Component<$$ComponentProps, {}, "symbolIndex">;
7
- type SymbolSelector = ReturnType<typeof SymbolSelector>;
8
- export default SymbolSelector;
@@ -1,6 +0,0 @@
1
- import type { ElementPoint } from './element/types.js';
2
- import type { StateStyle } from './state/types.js';
3
- export declare function getMiddlePoint(p0: ElementPoint, p1: ElementPoint): ElementPoint;
4
- export declare function lat2mercator(lat: number): number;
5
- export declare function mercator2lat(y: number): number;
6
- export declare function removeDefaultFields(value: StateStyle, def: StateStyle): Partial<StateStyle> | undefined;
@@ -1,23 +0,0 @@
1
- export function getMiddlePoint(p0, p1) {
2
- const y0 = lat2mercator(p0[1]);
3
- const y1 = lat2mercator(p1[1]);
4
- return [(p0[0] + p1[0]) / 2, mercator2lat((y0 + y1) / 2)];
5
- }
6
- export function lat2mercator(lat) {
7
- return Math.log(Math.tan(Math.PI / 4 + (lat * Math.PI) / 360));
8
- }
9
- export function mercator2lat(y) {
10
- return ((2 * Math.atan(Math.exp(y)) - Math.PI / 2) * 180) / Math.PI;
11
- }
12
- export function removeDefaultFields(value, def) {
13
- const entries = Object.entries(value).filter(([k, v]) => {
14
- if (v === undefined)
15
- return false;
16
- if (v === def[k])
17
- return false;
18
- return true;
19
- });
20
- if (entries.length === 0)
21
- return undefined;
22
- return Object.fromEntries(entries);
23
- }