@skerbis/nativecss 0.0.0-stage → 1.2.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 (192) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/LICENSE +28 -0
  3. package/README.md +145 -2
  4. package/dist/base.css +225 -0
  5. package/dist/browser-fixes.css +32 -0
  6. package/dist/colors.css +288 -0
  7. package/dist/components/accordion-split.css +269 -0
  8. package/dist/components/alert.css +179 -0
  9. package/dist/components/app-shell.css +266 -0
  10. package/dist/components/audio-player.css +697 -0
  11. package/dist/components/audio.css +35 -0
  12. package/dist/components/aurora.css +132 -0
  13. package/dist/components/avatar.css +102 -0
  14. package/dist/components/back-to-top.css +120 -0
  15. package/dist/components/backdrop.css +94 -0
  16. package/dist/components/badge.css +95 -0
  17. package/dist/components/breadcrumb.css +58 -0
  18. package/dist/components/card.css +721 -0
  19. package/dist/components/code-block.css +234 -0
  20. package/dist/components/combobox.css +103 -0
  21. package/dist/components/command-palette.css +351 -0
  22. package/dist/components/comments.css +243 -0
  23. package/dist/components/compare.css +218 -0
  24. package/dist/components/count-up.css +140 -0
  25. package/dist/components/countdown.css +74 -0
  26. package/dist/components/cover.css +45 -0
  27. package/dist/components/curtain.css +116 -0
  28. package/dist/components/dialog-close.css +44 -0
  29. package/dist/components/disclosure.css +37 -0
  30. package/dist/components/downloads.css +47 -0
  31. package/dist/components/dropdown.css +260 -0
  32. package/dist/components/dropzone.css +181 -0
  33. package/dist/components/effects.css +236 -0
  34. package/dist/components/empty-state.css +74 -0
  35. package/dist/components/events.css +165 -0
  36. package/dist/components/expand-panels.css +220 -0
  37. package/dist/components/filter.css +179 -0
  38. package/dist/components/floating-label.css +69 -0
  39. package/dist/components/footer.css +56 -0
  40. package/dist/components/hero.css +139 -0
  41. package/dist/components/hovercard.css +146 -0
  42. package/dist/components/input-group.css +67 -0
  43. package/dist/components/kbd.css +44 -0
  44. package/dist/components/leaders.css +99 -0
  45. package/dist/components/lightbox.css +165 -0
  46. package/dist/components/lists.css +221 -0
  47. package/dist/components/livesearch.css +106 -0
  48. package/dist/components/map.css +245 -0
  49. package/dist/components/marginnote.css +109 -0
  50. package/dist/components/marquee.css +119 -0
  51. package/dist/components/modal.css +385 -0
  52. package/dist/components/morph.css +317 -0
  53. package/dist/components/nav-drilldown.css +190 -0
  54. package/dist/components/nav-priority.css +157 -0
  55. package/dist/components/nav.css +600 -0
  56. package/dist/components/notification.css +290 -0
  57. package/dist/components/off-canvas.css +107 -0
  58. package/dist/components/overlay.css +122 -0
  59. package/dist/components/pagination.css +139 -0
  60. package/dist/components/pill-group.css +143 -0
  61. package/dist/components/placeholder.css +28 -0
  62. package/dist/components/preferences-fonts.css +65 -0
  63. package/dist/components/preferences.css +283 -0
  64. package/dist/components/pricing.css +220 -0
  65. package/dist/components/rating.css +121 -0
  66. package/dist/components/reveal-pin.css +165 -0
  67. package/dist/components/roadmap.css +173 -0
  68. package/dist/components/scroll-frames.css +97 -0
  69. package/dist/components/scroll-horizontal.css +141 -0
  70. package/dist/components/scroll-progress.css +63 -0
  71. package/dist/components/scroll-stack.css +363 -0
  72. package/dist/components/scroll-video.css +172 -0
  73. package/dist/components/scrolly.css +190 -0
  74. package/dist/components/search.css +52 -0
  75. package/dist/components/segmented.css +209 -0
  76. package/dist/components/select.css +186 -0
  77. package/dist/components/slideshow.css +441 -0
  78. package/dist/components/sortable.css +186 -0
  79. package/dist/components/sparkline.css +50 -0
  80. package/dist/components/spinner.css +50 -0
  81. package/dist/components/split.css +85 -0
  82. package/dist/components/spotlight.css +111 -0
  83. package/dist/components/stat.css +82 -0
  84. package/dist/components/stepper.css +217 -0
  85. package/dist/components/subnav.css +151 -0
  86. package/dist/components/table-sort.css +111 -0
  87. package/dist/components/tabs.css +304 -0
  88. package/dist/components/tag.css +130 -0
  89. package/dist/components/testimonial.css +188 -0
  90. package/dist/components/text-reveal.css +141 -0
  91. package/dist/components/theme-toggle.css +62 -0
  92. package/dist/components/tile.css +53 -0
  93. package/dist/components/timeline.css +211 -0
  94. package/dist/components/toolbar.css +139 -0
  95. package/dist/components/tooltip.css +89 -0
  96. package/dist/components/topbar.css +92 -0
  97. package/dist/components/video-bg.css +176 -0
  98. package/dist/components/video-card.css +145 -0
  99. package/dist/components/video-float.css +142 -0
  100. package/dist/components/video-player.css +1116 -0
  101. package/dist/components/video-text.css +91 -0
  102. package/dist/components/video.css +65 -0
  103. package/dist/fonts/README.md +29 -0
  104. package/dist/fonts/atkinson-hyperlegible-next/OFL.txt +93 -0
  105. package/dist/fonts/atkinson-hyperlegible-next/atkinson-hyperlegible-next.woff2 +0 -0
  106. package/dist/fonts/lexend/OFL.txt +93 -0
  107. package/dist/fonts/lexend/lexend.woff2 +0 -0
  108. package/dist/fonts/opendyslexic/OFL.txt +94 -0
  109. package/dist/fonts/opendyslexic/OpenDyslexic-Bold.woff2 +0 -0
  110. package/dist/fonts/opendyslexic/OpenDyslexic-Regular.woff2 +0 -0
  111. package/dist/helpers/a11y.css +71 -0
  112. package/dist/helpers/animations.css +206 -0
  113. package/dist/helpers/elevation.css +87 -0
  114. package/dist/helpers/float.css +135 -0
  115. package/dist/helpers/forms.css +503 -0
  116. package/dist/helpers/icons.css +130 -0
  117. package/dist/helpers/layout.css +549 -0
  118. package/dist/helpers/media.css +77 -0
  119. package/dist/helpers/reveal.css +172 -0
  120. package/dist/helpers/scroll-shadow.css +129 -0
  121. package/dist/helpers/scroll.css +163 -0
  122. package/dist/helpers/surfaces.css +87 -0
  123. package/dist/helpers/tables.css +85 -0
  124. package/dist/helpers/typography.css +347 -0
  125. package/dist/helpers/visibility.css +134 -0
  126. package/dist/integrations/fontawesome-font-display-fix.css +67 -0
  127. package/dist/integrations/webawesome-bridge.css +195 -0
  128. package/dist/js/audio-player.js +942 -0
  129. package/dist/js/backdrop.js +119 -0
  130. package/dist/js/code-block.js +238 -0
  131. package/dist/js/combobox.js +382 -0
  132. package/dist/js/command-fallback.js +35 -0
  133. package/dist/js/command-palette.js +477 -0
  134. package/dist/js/compare.js +73 -0
  135. package/dist/js/content-observer.js +82 -0
  136. package/dist/js/count-up.js +150 -0
  137. package/dist/js/countdown.js +185 -0
  138. package/dist/js/dialog-light-dismiss.js +123 -0
  139. package/dist/js/dismiss.js +144 -0
  140. package/dist/js/downloads.js +181 -0
  141. package/dist/js/dropdown.js +300 -0
  142. package/dist/js/dropzone.js +304 -0
  143. package/dist/js/events.js +501 -0
  144. package/dist/js/filter.js +177 -0
  145. package/dist/js/hero-video-motion.js +37 -0
  146. package/dist/js/hide-on-scroll-fallback.js +102 -0
  147. package/dist/js/hovercard.js +228 -0
  148. package/dist/js/icon.js +166 -0
  149. package/dist/js/ics.js +290 -0
  150. package/dist/js/lightbox.js +144 -0
  151. package/dist/js/livesearch.js +253 -0
  152. package/dist/js/map.js +625 -0
  153. package/dist/js/marquee.js +108 -0
  154. package/dist/js/modal-router.js +298 -0
  155. package/dist/js/nav-drilldown.js +250 -0
  156. package/dist/js/nav-priority.js +221 -0
  157. package/dist/js/nav.js +242 -0
  158. package/dist/js/ncss-container.js +117 -0
  159. package/dist/js/notification.js +372 -0
  160. package/dist/js/page-transitions-quiet.js +44 -0
  161. package/dist/js/preferences-early.js +51 -0
  162. package/dist/js/preferences.js +346 -0
  163. package/dist/js/reveal.js +79 -0
  164. package/dist/js/scroll-frames.js +284 -0
  165. package/dist/js/scroll-horizontal.js +121 -0
  166. package/dist/js/scroll-stack-fallback.js +250 -0
  167. package/dist/js/scroll-video.js +332 -0
  168. package/dist/js/scrolly.js +109 -0
  169. package/dist/js/slideshow.js +416 -0
  170. package/dist/js/sortable.js +530 -0
  171. package/dist/js/sparkline.js +199 -0
  172. package/dist/js/spotlight.js +104 -0
  173. package/dist/js/subnav.js +163 -0
  174. package/dist/js/table-sort.js +312 -0
  175. package/dist/js/tabs.js +243 -0
  176. package/dist/js/text-reveal.js +108 -0
  177. package/dist/js/theme-toggle-early.js +28 -0
  178. package/dist/js/theme-toggle.js +135 -0
  179. package/dist/js/toolbar.js +130 -0
  180. package/dist/js/tooltip.js +214 -0
  181. package/dist/js/video-bg.js +193 -0
  182. package/dist/js/video-card.js +80 -0
  183. package/dist/js/video-float.js +119 -0
  184. package/dist/js/video-player.js +1267 -0
  185. package/dist/js/view-transitions.js +118 -0
  186. package/dist/js/wa-close-on-scroll.js +56 -0
  187. package/dist/ncss.css +165 -0
  188. package/dist/page-transitions.css +150 -0
  189. package/dist/reset.css +196 -0
  190. package/dist/theme.css +112 -0
  191. package/dist/tokens.css +238 -0
  192. package/package.json +52 -4
package/dist/js/map.js ADDED
@@ -0,0 +1,625 @@
1
+ /**
2
+ * ncss - <ncss-map>: interaktive Karte mit MapLibre GL (vendor/maplibre/, BSD-3-Clause).
3
+ * Light-DOM-Custom-Element, Styles in components/map.css. Datenschutz zuerst: per Attribut
4
+ * "proxy" laufen ALLE Anfragen der Karte (Stil, Kacheln, Schriften, Symbole) über den eigenen
5
+ * Server - Besucher verbinden sich dann nie direkt mit Dritten.
6
+ *
7
+ * <ncss-map lat="53.48" lng="13.26" zoom="12" label="Tollensesee"
8
+ * proxy="/proxy/ofm/" consent>
9
+ * <p><strong>Tollensesee</strong>, Mecklenburg-Vorpommern</p>
10
+ * <p><a href="https://www.openstreetmap.org/?mlat=53.48&amp;mlon=13.26#map=12/53.48/13.26">
11
+ * In OpenStreetMap öffnen</a></p>
12
+ * </ncss-map>
13
+ *
14
+ * Attribute:
15
+ * lat, lng Mittelpunkt (und Position der Markierung), Dezimalgrad
16
+ * zoom="14" Zoomstufe 0-22
17
+ * label="…" Name des Orts: Beschriftung der Markierung und der Karte
18
+ * marker="off" keine Markierung (Default: an)
19
+ * style-url="…" MapLibre-Stil (JSON-URL). Default: OpenFreeMap "liberty"
20
+ * (https://tiles.openfreemap.org/styles/liberty)
21
+ * style-url-dark="…" Stil im Dunkelmodus. Default: OpenFreeMap "dark", aber nur wenn
22
+ * auch style-url fehlt - ein eigener style-url gilt sonst für beide Modi
23
+ * proxy="…" schreibt jede Anfrage von MapLibre um (transformRequest), zwei Formen:
24
+ * Präfix: proxy="/proxy/ofm/"
25
+ * https://tiles.openfreemap.org/planet/1/0/0.pbf
26
+ * -> /proxy/ofm/planet/1/0/0.pbf (Origin wird ersetzt)
27
+ * Vorlage: proxy="/proxy?url={url}"
28
+ * -> /proxy?url=https%3A%2F%2Ftiles.openfreemap.org%2F…
29
+ * Platzhalter: {url} (komplette URL, URL-kodiert),
30
+ * {host} (z.B. tiles.openfreemap.org), {path} (Pfad +
31
+ * Query ohne führenden Schrägstrich)
32
+ * Relative Angaben gelten relativ zur SEITE.
33
+ * proxy-origins="…" nur diese Origins umschreiben (Leerzeichen/Komma getrennt, z.B.
34
+ * "tiles.openfreemap.org" oder "https://tiles.openfreemap.org").
35
+ * Default: jede fremde Origin (alles außer der Seite und dem Proxy selbst)
36
+ * vendor="…" Ordner mit maplibre-gl.mjs/.css (relativ zur Seite). Default:
37
+ * ../../vendor/maplibre/ relativ zu DIESER Datei (document.currentScript,
38
+ * wie bei <ncss-icon>) - als ES-Modul geladen das Attribut setzen
39
+ * consent Zwei-Klick-Modus: Hinweis + Button "Karte anzeigen", geladen wird erst
40
+ * nach dem Klick. Automatisch an, wenn das Gerät "Datensparen" (Save-Data)
41
+ * meldet. consent="off" schaltet auch das ab
42
+ * privacy-url="…" Link "Datenschutz" im Zwei-Klick-Hinweis
43
+ * view3d Gebäude in 3D und geneigte Kamera (Stile mit OpenMapTiles-Schema)
44
+ * fallback="below" Ersatzinhalt nach dem Laden sichtbar UNTER der Karte lassen (Default:
45
+ * visuell versteckt, für Screenreader und Tastatur weiter da)
46
+ * data-label-<key> jeden Text überschreiben, Schlüssel siehe TEXTS unten (show, note,
47
+ * noteproxy, privacy, error, map, canvas, marker, zoomin, zoomout,
48
+ * compass, attribution, winhelp, machelp, mobilehelp). In note steht
49
+ * {host} für den Kartenserver. Sprache nach <html lang> (Deutsch/Englisch)
50
+ *
51
+ * Ersatzinhalt: was im Element steht (Adresse, Link zu OpenStreetMap), ist ohne JS, vor dem
52
+ * Laden und bei einem Fehler sichtbar - das Element ist nie leer. Erst wenn die Karte fertig
53
+ * gezeichnet ist, liegt sie darüber; der Ersatzinhalt bleibt im Accessibility Tree und wird bei
54
+ * Tastatur-Fokus wieder eingeblendet.
55
+ *
56
+ * Laden: MapLibre (~1.1 MB) kommt erst, wenn die Karte in die Nähe des Viewports scrollt
57
+ * (IntersectionObserver) bzw. nach dem Klick im Zwei-Klick-Modus.
58
+ *
59
+ * Bedienung: Tab auf die Karte, Pfeiltasten verschieben, +/- zoomen, Umschalt + Pfeile
60
+ * drehen/neigen (MapLibre). cooperativeGestures: Mausrad zoomt nur mit Strg/⌘, auf Touch
61
+ * verschieben zwei Finger - die Seite scrollt normal weiter. "Bewegung reduzieren"
62
+ * (prefers-reduced-motion ODER <html data-motion="reduce">): keine Kamerafahrten.
63
+ *
64
+ * Dunkelmodus: folgt <html data-theme-resolved> / data-theme (sonst prefers-color-scheme) und
65
+ * wechselt live, auch auf das Event ncss-preferences-change.
66
+ *
67
+ * Events (bubbles): ncss-map-consent (Klick auf "Karte anzeigen"), ncss-map-load (detail.map),
68
+ * ncss-map-error (detail.error), ncss-map-theme (detail.dark, detail.style).
69
+ * Öffentlich: el.map (MapLibre-Instanz, nach dem Laden), el.show() (lädt sofort).
70
+ *
71
+ * Benötigt: components/map.css + vendor/maplibre/. Keine anderen ncss-Scripts.
72
+ */
73
+ (function () {
74
+ "use strict";
75
+
76
+ if (typeof customElements === "undefined" || customElements.get("ncss-map")) return;
77
+ if (typeof URL !== "function" || typeof Promise !== "function") return;
78
+
79
+ var script = document.currentScript;
80
+ var DEFAULT_VENDOR = script && script.src ? new URL("../../vendor/maplibre/", script.src).href : null;
81
+ var OFM = "https://tiles.openfreemap.org/styles/";
82
+ var root = document.documentElement;
83
+
84
+ var TEXTS = {
85
+ de: {
86
+ show: "Karte anzeigen",
87
+ note: "Die Karte lädt erst nach deinem Klick. Dabei verbindet sich dein Browser mit {host} und überträgt deine IP-Adresse.",
88
+ noteproxy: "Die Karte lädt erst nach deinem Klick. Die Kartendaten holt unser Server - dein Browser verbindet sich dabei nicht mit Dritten.",
89
+ privacy: "Datenschutz",
90
+ error: "Die Karte konnte nicht geladen werden.",
91
+ map: "Karte",
92
+ canvas: "Interaktive Karte. Pfeiltasten verschieben, Plus und Minus zoomen.",
93
+ marker: "Standort",
94
+ zoomin: "Vergrößern",
95
+ zoomout: "Verkleinern",
96
+ compass: "Nach Norden ausrichten",
97
+ attribution: "Quellenangaben",
98
+ winhelp: "Strg + Mausrad zum Zoomen",
99
+ machelp: "⌘ + Mausrad zum Zoomen",
100
+ mobilehelp: "Mit zwei Fingern verschieben"
101
+ },
102
+ en: {
103
+ show: "Show map",
104
+ note: "The map loads only after you click. Your browser then connects to {host} and transmits your IP address.",
105
+ noteproxy: "The map loads only after you click. Our server fetches the map data - your browser does not connect to third parties.",
106
+ privacy: "Privacy",
107
+ error: "The map could not be loaded.",
108
+ map: "Map",
109
+ canvas: "Interactive map. Arrow keys pan, plus and minus zoom.",
110
+ marker: "Location",
111
+ zoomin: "Zoom in",
112
+ zoomout: "Zoom out",
113
+ compass: "Reset bearing to north",
114
+ attribution: "Toggle attribution",
115
+ winhelp: "Use Ctrl + scroll to zoom the map",
116
+ machelp: "Use ⌘ + scroll to zoom the map",
117
+ mobilehelp: "Use two fingers to move the map"
118
+ }
119
+ };
120
+
121
+ var libs = {}; // vendor-URL -> Promise(MapLibre-Modul), einmal pro Seite
122
+ var sheets = {}; // vendor-URL -> Promise (CSS geladen)
123
+
124
+ var motionQuery = window.matchMedia ? matchMedia("(prefers-reduced-motion: reduce)") : null;
125
+ var darkQuery = window.matchMedia ? matchMedia("(prefers-color-scheme: dark)") : null;
126
+
127
+ function reducedMotion() {
128
+ var m = root.getAttribute("data-motion");
129
+ if (m === "reduce") return true;
130
+ if (m === "full") return false;
131
+ return !!(motionQuery && motionQuery.matches);
132
+ }
133
+
134
+ function isDark() {
135
+ var r = root.getAttribute("data-theme-resolved");
136
+ if (r === "dark" || r === "light") return r === "dark";
137
+ var t = root.getAttribute("data-theme");
138
+ if (t === "dark" || t === "light") return t === "dark";
139
+ return !!(darkQuery && darkQuery.matches);
140
+ }
141
+
142
+ function saveData() {
143
+ return !!(navigator.connection && navigator.connection.saveData === true);
144
+ }
145
+
146
+ function num(v, fallback) {
147
+ var n = parseFloat(v);
148
+ return isFinite(n) ? n : fallback;
149
+ }
150
+
151
+ // MapLibre-CSS in den Unter-Layer components.maplibre: Regeln aus components/map.css
152
+ // (Layer components bzw. unlayered) gewinnen dann ohne Spezifitäts-Kampf. Als
153
+ // Constructable Stylesheet (CSSOM, kein Inline-<style> - CSP-freundlich); ohne
154
+ // adoptedStyleSheets ein normales <link>.
155
+ function loadCss(vendor) {
156
+ if (sheets[vendor]) return sheets[vendor];
157
+ var href = vendor + "maplibre-gl.css";
158
+ var canAdopt = "adoptedStyleSheets" in document && typeof CSSStyleSheet === "function" && "replace" in CSSStyleSheet.prototype;
159
+ sheets[vendor] = canAdopt
160
+ ? fetch(href, { credentials: "same-origin" })
161
+ .then(function (res) {
162
+ if (!res.ok) throw new Error("CSS " + res.status);
163
+ return res.text();
164
+ })
165
+ .then(function (css) {
166
+ var sheet = new CSSStyleSheet();
167
+ return sheet.replace("@layer components.maplibre {\n" + css + "\n}").then(function () {
168
+ document.adoptedStyleSheets = document.adoptedStyleSheets.concat(sheet);
169
+ });
170
+ })
171
+ : new Promise(function (resolve, reject) {
172
+ var link = document.createElement("link");
173
+ link.rel = "stylesheet";
174
+ link.href = href;
175
+ link.onload = resolve;
176
+ link.onerror = reject;
177
+ document.head.appendChild(link);
178
+ });
179
+ sheets[vendor].catch(function () {
180
+ delete sheets[vendor];
181
+ });
182
+ return sheets[vendor];
183
+ }
184
+
185
+ function loadLib(vendor) {
186
+ if (!libs[vendor]) {
187
+ // import() funktioniert auch aus einem klassischen Script; maplibre-gl.mjs lädt
188
+ // shared + worker relativ zu sich selbst.
189
+ libs[vendor] = Promise.all([import(vendor + "maplibre-gl.mjs"), loadCss(vendor)]).then(function (r) {
190
+ return r[0];
191
+ });
192
+ libs[vendor].catch(function () {
193
+ delete libs[vendor];
194
+ });
195
+ }
196
+ return libs[vendor];
197
+ }
198
+
199
+ function originOf(entry) {
200
+ entry = entry.trim();
201
+ if (!entry) return null;
202
+ try {
203
+ return new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(entry) ? entry : "https://" + entry).origin;
204
+ } catch (e) {
205
+ return null;
206
+ }
207
+ }
208
+
209
+ // Liefert url -> umgeschriebene URL (oder dieselbe), null ohne Proxy.
210
+ function rewriter(proxy, originsAttr) {
211
+ if (!proxy) return null;
212
+ var template = /\{(url|host|path)\}/.test(proxy);
213
+ var proxyOrigin;
214
+ try {
215
+ proxyOrigin = new URL(template ? proxy.replace(/\{(url|host|path)\}/g, "") : proxy, document.baseURI).origin;
216
+ } catch (e) {
217
+ return null;
218
+ }
219
+ var only = originsAttr
220
+ ? originsAttr
221
+ .split(/[\s,]+/)
222
+ .map(originOf)
223
+ .filter(Boolean)
224
+ : null;
225
+ return function (url) {
226
+ var u;
227
+ try {
228
+ u = new URL(url, document.baseURI);
229
+ } catch (e) {
230
+ return url;
231
+ }
232
+ if (u.protocol !== "https:" && u.protocol !== "http:") return url; // data:, blob:
233
+ if (only) {
234
+ if (only.indexOf(u.origin) < 0) return url;
235
+ } else if (u.origin === location.origin || u.origin === proxyOrigin) {
236
+ return url;
237
+ }
238
+ var path = (u.pathname + u.search).replace(/^\//, "");
239
+ var out = template
240
+ ? proxy
241
+ .replace(/\{url\}/g, encodeURIComponent(u.href))
242
+ .replace(/\{host\}/g, u.host)
243
+ .replace(/\{path\}/g, path)
244
+ : proxy.replace(/\/?$/, "/") + path;
245
+ // absolut, sonst löst der Worker relativ zu seiner eigenen (Blob-)Adresse auf
246
+ return new URL(out, document.baseURI).href;
247
+ };
248
+ }
249
+
250
+ // 3D-Gebäude (fill-extrusion aus render_height des OpenMapTiles-Schemas)
251
+ function add3d(map) {
252
+ var style = map.getStyle();
253
+ if (!style || !style.sources || !style.sources.openmaptiles) return;
254
+ if (style.layers.some(function (l) { return l.type === "fill-extrusion"; })) return;
255
+ var flat = style.layers.filter(function (l) {
256
+ return l["source-layer"] === "building" && l.type === "fill";
257
+ });
258
+ var color = flat[0] ? map.getPaintProperty(flat[0].id, "fill-color") : null;
259
+ var firstSymbol = style.layers.filter(function (l) { return l.type === "symbol"; })[0];
260
+ map.addLayer(
261
+ {
262
+ id: "ncss-map-building-3d",
263
+ type: "fill-extrusion",
264
+ source: "openmaptiles",
265
+ "source-layer": "building",
266
+ minzoom: 14,
267
+ filter: ["!=", ["get", "hide_3d"], true],
268
+ paint: {
269
+ "fill-extrusion-color": typeof color === "string" ? color : "#d9d4ce",
270
+ "fill-extrusion-height": ["interpolate", ["linear"], ["zoom"], 14, 0, 15.5, ["coalesce", ["get", "render_height"], 6]],
271
+ "fill-extrusion-base": ["coalesce", ["get", "render_min_height"], 0],
272
+ "fill-extrusion-opacity": 0.85
273
+ }
274
+ },
275
+ firstSymbol && firstSymbol.id
276
+ );
277
+ flat.forEach(function (l) {
278
+ map.setLayoutProperty(l.id, "visibility", "none");
279
+ });
280
+ }
281
+
282
+ customElements.define(
283
+ "ncss-map",
284
+ class extends HTMLElement {
285
+ static get observedAttributes() {
286
+ return ["lat", "lng", "zoom", "label", "style-url", "style-url-dark", "marker"];
287
+ }
288
+
289
+ connectedCallback() {
290
+ if (this._setup) return;
291
+ this._setup = true;
292
+ var self = this;
293
+ var lang = ((this.closest("[lang]") || root).getAttribute("lang") || "de").slice(0, 2) === "en" ? "en" : "de";
294
+ this._t = function (key) {
295
+ return self.getAttribute("data-label-" + key) || TEXTS[lang][key];
296
+ };
297
+
298
+ // Ersatzinhalt einsammeln (oder ein vorhandenes .ncss-map-fallback nutzen)
299
+ var fb = this.querySelector(":scope > .ncss-map-fallback");
300
+ if (!fb) {
301
+ fb = document.createElement("div");
302
+ fb.className = "ncss-map-fallback";
303
+ while (this.firstChild) fb.appendChild(this.firstChild);
304
+ this.appendChild(fb);
305
+ }
306
+ this._fallback = fb;
307
+
308
+ var consentAttr = this.getAttribute("consent");
309
+ var consent = consentAttr !== null && consentAttr !== "off" && consentAttr !== "false";
310
+ if (consentAttr !== "off" && saveData()) consent = true;
311
+
312
+ if (consent || typeof IntersectionObserver === "undefined") {
313
+ this._showConsent(consent);
314
+ } else {
315
+ this._state("idle");
316
+ this._io = new IntersectionObserver(
317
+ function (entries) {
318
+ if (entries.some(function (e) { return e.isIntersecting; })) self._load();
319
+ },
320
+ { rootMargin: "300px 0px" }
321
+ );
322
+ this._io.observe(this);
323
+ }
324
+ }
325
+
326
+ disconnectedCallback() {
327
+ // Nur aufräumen, wenn das Element wirklich weg ist (nicht beim Verschieben im DOM)
328
+ var self = this;
329
+ queueMicrotask(function () {
330
+ if (!self.isConnected) self._teardown();
331
+ });
332
+ }
333
+
334
+ attributeChangedCallback(name) {
335
+ if (!this.map) return;
336
+ if (name === "style-url" || name === "style-url-dark") return this._applyTheme(true);
337
+ if (name === "label") return this._applyLabels();
338
+ if (name === "marker") return this._applyMarker();
339
+ var center = this._center();
340
+ if (!center) return;
341
+ var cam = { center: center, zoom: num(this.getAttribute("zoom"), this.map.getZoom()) };
342
+ if (reducedMotion()) this.map.jumpTo(cam);
343
+ else this.map.easeTo(cam);
344
+ if (this._marker) this._marker.setLngLat(center);
345
+ }
346
+
347
+ get map() {
348
+ return this._map || null;
349
+ }
350
+
351
+ show() {
352
+ this._load();
353
+ }
354
+
355
+ _state(s) {
356
+ this.setAttribute("data-state", s);
357
+ }
358
+
359
+ _emit(type, detail) {
360
+ this.dispatchEvent(new CustomEvent("ncss-map-" + type, { bubbles: true, detail: detail || {} }));
361
+ }
362
+
363
+ _center() {
364
+ var lat = num(this.getAttribute("lat"), NaN);
365
+ var lng = num(this.getAttribute("lng"), NaN);
366
+ if (!isFinite(lat) || !isFinite(lng) || Math.abs(lat) > 90 || Math.abs(lng) > 180) return null;
367
+ return [lng, lat];
368
+ }
369
+
370
+ // Aktueller Stil; setzt nebenbei data-dark, wenn der dunkle Stil gilt (für die
371
+ // dunklen Bedienelemente in components/map.css)
372
+ _styleUrl() {
373
+ var light = this.getAttribute("style-url");
374
+ var dark = this.getAttribute("style-url-dark");
375
+ if (!light) {
376
+ light = OFM + "liberty";
377
+ if (!dark) dark = OFM + "dark";
378
+ }
379
+ var useDark = !!(isDark() && dark);
380
+ if (this._map) this.toggleAttribute("data-dark", useDark);
381
+ return new URL(useDark ? dark : light, document.baseURI).href;
382
+ }
383
+
384
+ _showConsent(withNote) {
385
+ var self = this;
386
+ this._state("consent");
387
+ var box = document.createElement("div");
388
+ box.className = "ncss-map-consent";
389
+ if (withNote) {
390
+ var note = document.createElement("p");
391
+ note.className = "ncss-map-note";
392
+ var host;
393
+ try {
394
+ host = new URL(this._styleUrl()).host;
395
+ } catch (e) {
396
+ host = "";
397
+ }
398
+ note.textContent = this.getAttribute("proxy") ? this._t("noteproxy") : this._t("note").replace("{host}", host);
399
+ var privacy = this.getAttribute("privacy-url");
400
+ if (privacy) {
401
+ var a = document.createElement("a");
402
+ a.href = privacy;
403
+ a.textContent = this._t("privacy");
404
+ note.appendChild(document.createTextNode(" "));
405
+ note.appendChild(a);
406
+ }
407
+ box.appendChild(note);
408
+ }
409
+ var btn = document.createElement("button");
410
+ btn.type = "button";
411
+ btn.className = "ncss-map-show";
412
+ btn.textContent = this._t("show");
413
+ btn.addEventListener("click", function () {
414
+ self._emit("consent");
415
+ self._load(true);
416
+ });
417
+ box.appendChild(btn);
418
+ this._consent = box;
419
+ this.appendChild(box);
420
+ }
421
+
422
+ _load(fromClick) {
423
+ if (this._loading) return;
424
+ this._loading = true;
425
+ if (this._io) {
426
+ this._io.disconnect();
427
+ this._io = null;
428
+ }
429
+ var self = this;
430
+ var center = this._center();
431
+ var vendor = this.getAttribute("vendor");
432
+ vendor = vendor ? new URL(vendor.replace(/\/?$/, "/"), document.baseURI).href : DEFAULT_VENDOR;
433
+ if (!center || !vendor) {
434
+ return this._fail(new Error(center ? "vendor path unknown (set the vendor attribute)" : "lat/lng missing"));
435
+ }
436
+ this._state("loading");
437
+
438
+ var stage = document.createElement("div");
439
+ stage.className = "ncss-map-stage";
440
+ stage.setAttribute("role", "region");
441
+ this._stage = stage;
442
+ this._applyLabels();
443
+ this.insertBefore(stage, this._fallback);
444
+ var hadFocus = fromClick && this._consent && this._consent.contains(document.activeElement);
445
+
446
+ loadLib(vendor)
447
+ .then(function (ml) {
448
+ if (!self.isConnected || self._stage !== stage) return;
449
+ self._create(ml, stage, center, hadFocus);
450
+ })
451
+ .catch(function (e) {
452
+ self._fail(e);
453
+ });
454
+ }
455
+
456
+ _create(ml, stage, center, focusAfter) {
457
+ var self = this;
458
+ var reduce = reducedMotion();
459
+ var t = this._t;
460
+ var rewrite = rewriter(this.getAttribute("proxy"), this.getAttribute("proxy-origins"));
461
+ var view3d = this.hasAttribute("view3d") && this.getAttribute("view3d") !== "off";
462
+ this._dark = isDark();
463
+ this._currentStyle = this._styleUrl();
464
+
465
+ var map = new ml.Map({
466
+ container: stage,
467
+ style: this._currentStyle,
468
+ center: center,
469
+ zoom: num(this.getAttribute("zoom"), 14),
470
+ cooperativeGestures: true,
471
+ attributionControl: { compact: true },
472
+ fadeDuration: reduce ? 0 : 300,
473
+ maxPitch: view3d ? 60 : 0,
474
+ pitch: view3d && reduce ? 55 : 0,
475
+ bearing: view3d && reduce ? -20 : 0,
476
+ dragRotate: view3d,
477
+ pitchWithRotate: view3d,
478
+ touchPitch: view3d,
479
+ transformRequest: rewrite
480
+ ? function (url) {
481
+ return { url: rewrite(url) };
482
+ }
483
+ : undefined,
484
+ locale: {
485
+ "Map.Title": t("canvas"),
486
+ "Marker.Title": t("marker"),
487
+ "NavigationControl.ZoomIn": t("zoomin"),
488
+ "NavigationControl.ZoomOut": t("zoomout"),
489
+ "NavigationControl.ResetBearing": t("compass"),
490
+ "AttributionControl.ToggleAttribution": t("attribution"),
491
+ "CooperativeGesturesHandler.WindowsHelpText": t("winhelp"),
492
+ "CooperativeGesturesHandler.MacHelpText": t("machelp"),
493
+ "CooperativeGesturesHandler.MobileHelpText": t("mobilehelp")
494
+ }
495
+ });
496
+ this._map = map;
497
+ this._styleUrl(); // data-dark
498
+ if (!view3d) map.touchZoomRotate.disableRotation();
499
+
500
+ // "Bewegung reduzieren" auch für <html data-motion="reduce"> (MapLibre selbst
501
+ // kennt nur die Systemeinstellung): Kamerafahrten werden zu Sprüngen.
502
+ ["easeTo", "flyTo"].forEach(function (fn) {
503
+ var orig = map[fn];
504
+ map[fn] = function (opts, data) {
505
+ if (reducedMotion()) opts = Object.assign({}, opts, { duration: 0, animate: false });
506
+ return orig.call(map, opts, data);
507
+ };
508
+ });
509
+
510
+ map.addControl(new ml.NavigationControl({ showCompass: view3d, visualizePitch: view3d }), "top-right");
511
+ this._ml = ml;
512
+ this._applyMarker();
513
+
514
+ var tilted = false;
515
+ map.on("style.load", function () {
516
+ if (view3d) {
517
+ add3d(map);
518
+ if (!tilted && !reducedMotion()) map.easeTo({ pitch: 55, bearing: -20, zoom: map.getZoom() + 0.3, duration: 2400 });
519
+ tilted = true;
520
+ }
521
+ });
522
+ map.once("load", function () {
523
+ self._state("ready");
524
+ if (self._consent) {
525
+ self._consent.remove();
526
+ self._consent = null;
527
+ }
528
+ if (focusAfter) map.getCanvas().focus();
529
+ self._emit("load", { map: map });
530
+ });
531
+ map.on("error", function (e) {
532
+ var err = (e && e.error) || e;
533
+ // Vor dem ersten Zeichnen (Stil nicht ladbar): Ersatzinhalt zeigen. Danach sind
534
+ // einzelne Kachel-Fehler kein Grund, die Karte wegzunehmen.
535
+ if (self.getAttribute("data-state") === "loading" && !map.isStyleLoaded()) self._fail(err);
536
+ else console.warn("ncss-map:", (err && err.message) || err);
537
+ });
538
+
539
+ this._onTheme = function () {
540
+ self._applyTheme(false);
541
+ };
542
+ this._mo = new MutationObserver(this._onTheme);
543
+ this._mo.observe(root, { attributes: true, attributeFilter: ["data-theme", "data-theme-resolved"] });
544
+ if (darkQuery && darkQuery.addEventListener) darkQuery.addEventListener("change", this._onTheme);
545
+ document.addEventListener("ncss-preferences-change", this._onTheme);
546
+ }
547
+
548
+ _applyLabels() {
549
+ var label = (this.getAttribute("label") || "").trim();
550
+ if (this._stage) this._stage.setAttribute("aria-label", this._t("map") + (label ? ": " + label : ""));
551
+ if (this._pin) this._pin.setAttribute("aria-label", label || this._t("marker"));
552
+ }
553
+
554
+ _applyMarker() {
555
+ var off = this.getAttribute("marker") === "off" || this.getAttribute("marker") === "false";
556
+ if (off && this._marker) {
557
+ this._marker.remove();
558
+ this._marker = this._pin = null;
559
+ } else if (!off && !this._marker && this._map) {
560
+ var pin = document.createElement("div");
561
+ pin.className = "ncss-map-marker";
562
+ pin.setAttribute("role", "img");
563
+ // Die Tropfenform sitzt in einem Kind: MapLibre positioniert das Element per
564
+ // transform, eine Drehung direkt daran würde die Verschiebung mitdrehen.
565
+ pin.appendChild(document.createElement("span")).className = "ncss-map-pin";
566
+ this._pin = pin;
567
+ this._marker = new this._ml.Marker({ element: pin, anchor: "bottom" }).setLngLat(this._center() || this._map.getCenter()).addTo(this._map);
568
+ // MapLibre setzt role="button"/tabindex nur bei Popups - sicherheitshalber nicht fokussierbar
569
+ pin.removeAttribute("tabindex");
570
+ pin.setAttribute("role", "img");
571
+ }
572
+ this._applyLabels();
573
+ }
574
+
575
+ _applyTheme(force) {
576
+ if (!this._map) return;
577
+ var dark = isDark();
578
+ var url = this._styleUrl();
579
+ if (!force && dark === this._dark) return;
580
+ this._dark = dark;
581
+ if (url === this._currentStyle) return;
582
+ this._currentStyle = url;
583
+ this._map.setStyle(url);
584
+ this._emit("theme", { dark: dark, style: url });
585
+ }
586
+
587
+ _fail(err) {
588
+ console.warn("ncss-map:", (err && err.message) || err);
589
+ this._teardown(true);
590
+ this._state("error");
591
+ if (!this._fallback.querySelector(".ncss-map-error")) {
592
+ var p = document.createElement("p");
593
+ p.className = "ncss-map-error";
594
+ p.setAttribute("role", "status");
595
+ p.textContent = this._t("error");
596
+ this._fallback.insertBefore(p, this._fallback.firstChild);
597
+ }
598
+ this._emit("error", { error: err });
599
+ }
600
+
601
+ _teardown(keepSetup) {
602
+ if (this._io) this._io.disconnect();
603
+ if (this._mo) this._mo.disconnect();
604
+ if (this._onTheme) {
605
+ if (darkQuery && darkQuery.removeEventListener) darkQuery.removeEventListener("change", this._onTheme);
606
+ document.removeEventListener("ncss-preferences-change", this._onTheme);
607
+ }
608
+ if (this._map) {
609
+ try {
610
+ this._map.remove();
611
+ } catch (e) {}
612
+ }
613
+ if (this._stage) this._stage.remove();
614
+ if (this._consent) this._consent.remove();
615
+ this.removeAttribute("data-dark");
616
+ this._io = this._mo = this._onTheme = this._map = this._stage = this._consent = this._marker = this._pin = null;
617
+ this._loading = false;
618
+ if (!keepSetup) {
619
+ this._setup = false;
620
+ this.removeAttribute("data-state");
621
+ }
622
+ }
623
+ }
624
+ );
625
+ })();