@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/ics.js ADDED
@@ -0,0 +1,290 @@
1
+ /**
2
+ * ncss - ICS-Parser (iCalendar, RFC 5545). Reine Datenfunktion, kein DOM-Zugriff -
3
+ * eigenständig nutzbar, wird von events.js für data-ics="..." konsumiert. Kein Vendor/
4
+ * keine Abhängigkeit (kein npm-Paket wie ical.js) - passt zu "kein Build-Schritt,
5
+ * selbst gehostet, kein Wildwuchs" und deckt bewusst nur ab, was ein Termin-Widget
6
+ * wirklich braucht, nicht die volle RFC-5545-Fläche.
7
+ *
8
+ * Abgedeckt: VEVENT (UID, SUMMARY, DTSTART, DTEND, LOCATION, DESCRIPTION, URL), Zeilen-
9
+ * Unfolding (fortgesetzte Zeilen beginnen mit Leerzeichen/Tab), Wert-Escaping (\\n, \\,,
10
+ * \\;, \\\\), ganztägige Termine (VALUE=DATE), UTC-Zeiten ("Z"-Suffix). RRULE-Teilmenge:
11
+ * FREQ=DAILY/WEEKLY/MONTHLY/YEARLY, INTERVAL, COUNT, UNTIL, BYDAY (nur einfache
12
+ * Wochentags-Liste, kein Ordinal-Präfix wie "2MO"), EXDATE.
13
+ *
14
+ * NICHT abgedeckt (bewusste Grenze, siehe Doku): TZID-Zeitzonenkonvertierung (Zeiten
15
+ * ohne "Z"-Suffix werden als lokale Wanduhrzeit übernommen, keine Konvertierung),
16
+ * BYMONTHDAY/BYSETPOS/BYWEEKNO, verschachtelte RECURRENCE-ID-Ausnahmen (nur EXDATE).
17
+ * Deckt die weit überwiegende Mehrheit realer Kalender-Exports (Google/Outlook/Apple)
18
+ * für einfache und regelmäßig wiederkehrende Termine ab.
19
+ */
20
+ (function (global) {
21
+ "use strict";
22
+
23
+ var MAX_OCCURRENCES_PER_RULE = 366;
24
+ var WEEKDAY_INDEX = { SU: 0, MO: 1, TU: 2, WE: 3, TH: 4, FR: 5, SA: 6 };
25
+
26
+ function unfold(text) {
27
+ return text.replace(/\r\n/g, "\n").replace(/\n[ \t]/g, "");
28
+ }
29
+
30
+ function unescapeValue(value) {
31
+ return value
32
+ .replace(/\\n/gi, "\n")
33
+ .replace(/\\,/g, ",")
34
+ .replace(/\\;/g, ";")
35
+ .replace(/\\\\/g, "\\");
36
+ }
37
+
38
+ function parseLine(line) {
39
+ var colonIndex = line.indexOf(":");
40
+ if (colonIndex === -1) {
41
+ return null;
42
+ }
43
+ var head = line.slice(0, colonIndex);
44
+ var value = line.slice(colonIndex + 1);
45
+ var parts = head.split(";");
46
+ var name = parts[0].toUpperCase();
47
+ var params = {};
48
+ for (var i = 1; i < parts.length; i++) {
49
+ var eq = parts[i].indexOf("=");
50
+ if (eq !== -1) {
51
+ params[parts[i].slice(0, eq).toUpperCase()] = parts[i].slice(eq + 1);
52
+ }
53
+ }
54
+ return { name: name, params: params, value: value };
55
+ }
56
+
57
+ function parseDate(value, params) {
58
+ var isDate = params.VALUE === "DATE" || /^\d{8}$/.test(value);
59
+ if (isDate) {
60
+ var y = +value.slice(0, 4);
61
+ var mo = +value.slice(4, 6) - 1;
62
+ var d = +value.slice(6, 8);
63
+ return { date: new Date(y, mo, d), allDay: true };
64
+ }
65
+ var utc = /Z$/.test(value);
66
+ var m = /^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})/.exec(value);
67
+ if (!m) {
68
+ return null;
69
+ }
70
+ var year = +m[1], month = +m[2] - 1, day = +m[3], hh = +m[4], mm = +m[5], ss = +m[6];
71
+ var dt = utc
72
+ ? new Date(Date.UTC(year, month, day, hh, mm, ss))
73
+ : new Date(year, month, day, hh, mm, ss);
74
+ return { date: dt, allDay: false };
75
+ }
76
+
77
+ function parseRRule(value) {
78
+ var rule = {};
79
+ var pairs = value.split(";");
80
+ for (var i = 0; i < pairs.length; i++) {
81
+ var eq = pairs[i].indexOf("=");
82
+ if (eq === -1) continue;
83
+ rule[pairs[i].slice(0, eq).toUpperCase()] = pairs[i].slice(eq + 1);
84
+ }
85
+ return rule;
86
+ }
87
+
88
+ function addInterval(date, freq, interval) {
89
+ var next = new Date(date.getTime());
90
+ if (freq === "DAILY") {
91
+ next.setDate(next.getDate() + interval);
92
+ } else if (freq === "WEEKLY") {
93
+ next.setDate(next.getDate() + 7 * interval);
94
+ } else if (freq === "MONTHLY") {
95
+ next.setMonth(next.getMonth() + interval);
96
+ } else if (freq === "YEARLY") {
97
+ next.setFullYear(next.getFullYear() + interval);
98
+ } else {
99
+ return null;
100
+ }
101
+ return next;
102
+ }
103
+
104
+ /* WEEKLY+BYDAY läuft Woche für Woche (nicht Tag für Tag) - eine Woche ist die
105
+ natürliche Schrittweite von RRULE INTERVAL bei FREQ=WEEKLY, unabhängig davon, wie
106
+ viele BYDAY-Wochentage pro Woche einschlagen. Tag-für-Tag-Stepping (erster Anlauf)
107
+ bräuchte eine Sonderbehandlung für INTERVAL>1 mitten in der Iteration - Woche-für-
108
+ Woche vermeidet das strukturell. */
109
+ function expandWeeklyByDay(start, rule, interval, byDay, untilDate) {
110
+ var occurrences = [];
111
+ var weekStart = new Date(start.getTime());
112
+ weekStart.setHours(0, 0, 0, 0);
113
+ weekStart.setDate(weekStart.getDate() - weekStart.getDay());
114
+ var weekIndex = 0;
115
+
116
+ while (occurrences.length < MAX_OCCURRENCES_PER_RULE && weekIndex < MAX_OCCURRENCES_PER_RULE) {
117
+ var thisWeekStart = new Date(weekStart.getTime());
118
+ thisWeekStart.setDate(thisWeekStart.getDate() + weekIndex * 7 * interval);
119
+ if (untilDate && thisWeekStart.getTime() > untilDate.getTime()) break;
120
+
121
+ for (var d = 0; d < byDay.length; d++) {
122
+ var occ = new Date(thisWeekStart.getTime());
123
+ occ.setDate(occ.getDate() + byDay[d]);
124
+ occ.setHours(start.getHours(), start.getMinutes(), start.getSeconds(), start.getMilliseconds());
125
+ if (occ.getTime() < start.getTime()) continue;
126
+ if (untilDate && occ.getTime() > untilDate.getTime()) continue;
127
+ occurrences.push(occ);
128
+ }
129
+ weekIndex++;
130
+ }
131
+
132
+ occurrences.sort(function (a, b) {
133
+ return a.getTime() - b.getTime();
134
+ });
135
+ return occurrences;
136
+ }
137
+
138
+ function expandRecurrence(start, durationMs, rule, exdates, windowEnd) {
139
+ var freq = rule.FREQ;
140
+ if (!freq) {
141
+ return [];
142
+ }
143
+ var interval = rule.INTERVAL ? parseInt(rule.INTERVAL, 10) : 1;
144
+ var count = rule.COUNT ? parseInt(rule.COUNT, 10) : null;
145
+ var until = rule.UNTIL ? parseDate(rule.UNTIL, {}) : null;
146
+ var untilDate = until ? until.date : null;
147
+ var hasBound = count !== null || untilDate !== null;
148
+ var byDay = null;
149
+ if (rule.BYDAY) {
150
+ byDay = rule.BYDAY
151
+ .split(",")
152
+ .map(function (token) {
153
+ return WEEKDAY_INDEX[token.replace(/^[+-]?\d+/, "")];
154
+ })
155
+ .filter(function (d) {
156
+ return d !== undefined;
157
+ });
158
+ }
159
+
160
+ var candidates;
161
+ if (freq === "WEEKLY" && byDay && byDay.length) {
162
+ candidates = expandWeeklyByDay(start, rule, interval, byDay, untilDate);
163
+ if (!hasBound && windowEnd) {
164
+ candidates = candidates.filter(function (d) {
165
+ return d.getTime() <= windowEnd.getTime();
166
+ });
167
+ }
168
+ if (count !== null) {
169
+ candidates = candidates.slice(0, count);
170
+ }
171
+ } else {
172
+ candidates = [];
173
+ var cursor = new Date(start.getTime());
174
+ while (candidates.length < MAX_OCCURRENCES_PER_RULE) {
175
+ if (untilDate && cursor.getTime() > untilDate.getTime()) break;
176
+ if (count !== null && candidates.length >= count) break;
177
+ if (!hasBound && windowEnd && cursor.getTime() > windowEnd.getTime()) break;
178
+ candidates.push(new Date(cursor.getTime()));
179
+ var next = addInterval(cursor, freq, interval);
180
+ if (!next) break;
181
+ cursor = next;
182
+ }
183
+ }
184
+
185
+ var filtered = candidates.filter(function (occStart) {
186
+ var key = occStart.toISOString().slice(0, 16);
187
+ return exdates.indexOf(key) === -1;
188
+ });
189
+
190
+ return filtered.map(function (occStart) {
191
+ return { start: occStart, end: durationMs !== null ? new Date(occStart.getTime() + durationMs) : null };
192
+ });
193
+ }
194
+
195
+ function parse(icsText, options) {
196
+ options = options || {};
197
+ var windowEnd = options.windowEnd || null;
198
+ var text = unfold(icsText);
199
+ var lines = text.split("\n");
200
+ var events = [];
201
+ var current = null;
202
+
203
+ for (var i = 0; i < lines.length; i++) {
204
+ var line = lines[i];
205
+ if (!line) continue;
206
+ if (line === "BEGIN:VEVENT") {
207
+ current = { exdates: [] };
208
+ continue;
209
+ }
210
+ if (line === "END:VEVENT") {
211
+ if (current) events.push(current);
212
+ current = null;
213
+ continue;
214
+ }
215
+ if (!current) continue;
216
+
217
+ var field = parseLine(line);
218
+ if (!field) continue;
219
+ var value = unescapeValue(field.value);
220
+
221
+ if (field.name === "UID") {
222
+ current.uid = value;
223
+ } else if (field.name === "SUMMARY") {
224
+ current.title = value;
225
+ } else if (field.name === "LOCATION") {
226
+ current.location = value;
227
+ } else if (field.name === "DESCRIPTION") {
228
+ current.description = value;
229
+ } else if (field.name === "URL") {
230
+ current.url = value;
231
+ } else if (field.name === "DTSTART") {
232
+ current.dtstart = parseDate(field.value, field.params);
233
+ } else if (field.name === "DTEND") {
234
+ current.dtend = parseDate(field.value, field.params);
235
+ } else if (field.name === "RRULE") {
236
+ current.rrule = parseRRule(value);
237
+ } else if (field.name === "EXDATE") {
238
+ value.split(",").forEach(function (v) {
239
+ var parsed = parseDate(v.trim(), field.params);
240
+ if (parsed) current.exdates.push(parsed.date.toISOString().slice(0, 16));
241
+ });
242
+ }
243
+ }
244
+
245
+ var normalized = [];
246
+ events.forEach(function (raw, index) {
247
+ if (!raw.dtstart) return;
248
+ var start = raw.dtstart.date;
249
+ var allDay = raw.dtstart.allDay;
250
+ var end = raw.dtend ? raw.dtend.date : null;
251
+ var durationMs = end ? end.getTime() - start.getTime() : null;
252
+ var baseId = raw.uid || "ics-" + index;
253
+
254
+ if (raw.rrule) {
255
+ var occs = expandRecurrence(start, durationMs, raw.rrule, raw.exdates, windowEnd);
256
+ occs.forEach(function (occ, occIndex) {
257
+ normalized.push({
258
+ id: baseId + "-" + occIndex,
259
+ title: raw.title || "",
260
+ start: occ.start,
261
+ end: occ.end,
262
+ allDay: allDay,
263
+ location: raw.location || null,
264
+ description: raw.description || null,
265
+ url: raw.url || null
266
+ });
267
+ });
268
+ } else {
269
+ normalized.push({
270
+ id: baseId,
271
+ title: raw.title || "",
272
+ start: start,
273
+ end: end,
274
+ allDay: allDay,
275
+ location: raw.location || null,
276
+ description: raw.description || null,
277
+ url: raw.url || null
278
+ });
279
+ }
280
+ });
281
+
282
+ normalized.sort(function (a, b) {
283
+ return a.start.getTime() - b.start.getTime();
284
+ });
285
+
286
+ return normalized;
287
+ }
288
+
289
+ global.NcssICS = { parse: parse };
290
+ })(window);
@@ -0,0 +1,144 @@
1
+ /**
2
+ * ncss - Lightbox-Galerie: blättert durch alle Links mit demselben data-ncss-lightbox-Wert
3
+ * (siehe components/lightbox.css). Ein einziges <dialog> pro Seite, erst beim ersten Klick
4
+ * erzeugt, mit den Klassen der vorhandenen Modal-Lightbox (.ncss-modal--fullscreen
5
+ * --dark) - Animation, Backdrop, Fokus-Trap und Esc kommen von dort bzw. vom nativen
6
+ * <dialog>.
7
+ *
8
+ * Bedienung: Pfeiltasten, Vor/Zurück-Buttons, Wischen (Zeigergeste, > 50px), Klick neben
9
+ * das Bild schließt. Fokus kehrt nach dem Schließen zum auslösenden Link zurück.
10
+ * Bildunterschrift: data-caption, sonst alt des Vorschaubildes. Das jeweils nächste Bild
11
+ * wird vorgeladen.
12
+ *
13
+ * Texte: Deutsch/Englisch nach <html lang> (wie events.js/downloads.js), einzeln
14
+ * überschreibbar per data-lightbox-close/-prev/-next/-label/-of am <html>.
15
+ *
16
+ * Mit gedrückter Strg/Cmd/Shift-Taste oder Mittelklick bleibt der Link ein normaler Link
17
+ * (neuer Tab etc.) - die Lightbox greift nur beim einfachen Klick.
18
+ */
19
+ (function () {
20
+ "use strict";
21
+
22
+ if (typeof HTMLDialogElement === "undefined" || typeof HTMLDialogElement.prototype.showModal !== "function") {
23
+ return;
24
+ }
25
+
26
+ var TEXTS = {
27
+ de: { close: "Schließen", prev: "Vorheriges Bild", next: "Nächstes Bild", label: "Bildansicht", of: "von" },
28
+ en: { close: "Close", prev: "Previous image", next: "Next image", label: "Image viewer", of: "of" }
29
+ };
30
+ var root = document.documentElement;
31
+ var lang = (root.getAttribute("lang") || "de").slice(0, 2) === "en" ? "en" : "de";
32
+ function text(key) {
33
+ return root.getAttribute("data-lightbox-" + key) || TEXTS[lang][key];
34
+ }
35
+
36
+ var dialog, img, caption, count;
37
+ var items = [];
38
+ var index = 0;
39
+ var opener = null;
40
+
41
+ function button(cls, label, iconClass) {
42
+ return '<button type="button" class="' + cls + '" aria-label="' + label + '">' +
43
+ '<span class="ncss-icon ' + iconClass + '" aria-hidden="true"></span></button>';
44
+ }
45
+
46
+ function build() {
47
+ dialog = document.createElement("dialog");
48
+ dialog.className = "ncss-modal ncss-modal--fullscreen ncss-modal--dark ncss-lightbox";
49
+ dialog.setAttribute("aria-label", text("label"));
50
+ dialog.innerHTML =
51
+ '<figure class="ncss-lightbox-figure"><img alt=""></figure>' +
52
+ '<div class="ncss-lightbox-bar"><span class="ncss-lightbox-caption" aria-live="polite"></span>' +
53
+ '<span class="ncss-lightbox-count"></span></div>' +
54
+ button("ncss-dialog-close", text("close"), "ncss-icon-close") +
55
+ button("ncss-lightbox-prev", text("prev"), "ncss-icon-chevron-down") +
56
+ button("ncss-lightbox-next", text("next"), "ncss-icon-chevron-down");
57
+ document.body.appendChild(dialog);
58
+ img = dialog.querySelector("img");
59
+ caption = dialog.querySelector(".ncss-lightbox-caption");
60
+ count = dialog.querySelector(".ncss-lightbox-count");
61
+
62
+ dialog.querySelector(".ncss-dialog-close").addEventListener("click", function () { dialog.close(); });
63
+ dialog.querySelector(".ncss-lightbox-prev").addEventListener("click", function () { show(index - 1); });
64
+ dialog.querySelector(".ncss-lightbox-next").addEventListener("click", function () { show(index + 1); });
65
+ dialog.addEventListener("keydown", function (event) {
66
+ if (event.key === "ArrowLeft") {
67
+ event.preventDefault();
68
+ show(index - 1);
69
+ } else if (event.key === "ArrowRight") {
70
+ event.preventDefault();
71
+ show(index + 1);
72
+ }
73
+ });
74
+ // Klick auf die freie Fläche neben dem Bild schließt (wie ein Backdrop-Klick).
75
+ dialog.addEventListener("click", function (event) {
76
+ if (event.target === dialog || event.target.classList.contains("ncss-lightbox-figure")) {
77
+ dialog.close();
78
+ }
79
+ });
80
+ dialog.addEventListener("close", function () {
81
+ root.style.overflow = "";
82
+ if (opener) {
83
+ opener.focus();
84
+ }
85
+ });
86
+ var startX = null;
87
+ dialog.addEventListener("pointerdown", function (event) {
88
+ startX = event.isPrimary ? event.clientX : null;
89
+ });
90
+ dialog.addEventListener("pointerup", function (event) {
91
+ if (startX === null) {
92
+ return;
93
+ }
94
+ var dx = event.clientX - startX;
95
+ startX = null;
96
+ if (Math.abs(dx) > 50) {
97
+ show(index + (dx < 0 ? 1 : -1));
98
+ }
99
+ });
100
+ img.addEventListener("load", function () { img.classList.remove("is-loading"); });
101
+ }
102
+
103
+ function show(i) {
104
+ if (items.length === 0) {
105
+ return;
106
+ }
107
+ index = (i + items.length) % items.length;
108
+ var link = items[index];
109
+ var thumb = link.querySelector("img");
110
+ var label = link.getAttribute("data-caption") || (thumb ? thumb.alt : "") || "";
111
+ img.classList.add("is-loading");
112
+ img.src = link.href;
113
+ img.alt = label;
114
+ caption.textContent = label;
115
+ count.textContent = index + 1 + " " + text("of") + " " + items.length;
116
+ if (items.length > 1) {
117
+ new Image().src = items[(index + 1) % items.length].href;
118
+ }
119
+ }
120
+
121
+ document.addEventListener("click", function (event) {
122
+ var link = event.target.closest("a[data-ncss-lightbox]");
123
+ if (!link || event.button !== 0 || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) {
124
+ return;
125
+ }
126
+ event.preventDefault();
127
+ if (!dialog) {
128
+ build();
129
+ }
130
+ var group = link.getAttribute("data-ncss-lightbox");
131
+ items = Array.prototype.filter.call(document.querySelectorAll("a[data-ncss-lightbox]"), function (a) {
132
+ return a.getAttribute("data-ncss-lightbox") === group;
133
+ });
134
+ opener = link;
135
+ if (items.length < 2) {
136
+ dialog.setAttribute("data-single", "");
137
+ } else {
138
+ dialog.removeAttribute("data-single");
139
+ }
140
+ show(items.indexOf(link));
141
+ root.style.overflow = "hidden";
142
+ dialog.showModal();
143
+ });
144
+ })();
@@ -0,0 +1,253 @@
1
+ /**
2
+ * ncss - Live-Suche: Vorschläge während der Eingabe für [data-ncss-livesearch]-Formulare
3
+ * (siehe components/livesearch.css). WAI-ARIA Combobox + Listbox: der Fokus bleibt im
4
+ * Eingabefeld, aria-activedescendant zeigt auf die gewählte Option.
5
+ *
6
+ * Tastatur: Pfeil runter/hoch wählt, Enter öffnet die gewählte Option (ohne Auswahl:
7
+ * normales Absenden = Ergebnisseite), Esc schließt die Liste, Klick daneben ebenso.
8
+ *
9
+ * Attribute am <form>:
10
+ * data-ncss-livesearch="URL" Endpoint (Pflicht)
11
+ * data-param="q" Name des Suchparameters (Default "q")
12
+ * data-min="2" Mindestlänge der Eingabe
13
+ * data-delay="180" Wartezeit nach dem letzten Tastendruck (ms)
14
+ * data-mode="client" Endpoint ist eine STATISCHE JSON-Datei: einmal laden,
15
+ * im Browser filtern (kleine Datenmengen, ohne Server-Logik)
16
+ *
17
+ * Antwort-Format (JSON) - im Server-Modus bereits gefiltert, im Client-Modus komplett:
18
+ * {
19
+ * "groups": [
20
+ * { "label": "Seiten", "items": [ { "title": "...", "url": "...", "text": "..." } ] }
21
+ * ],
22
+ * "all": "/suche/?q=..." (optional, Link "Alle Ergebnisse anzeigen")
23
+ * }
24
+ *
25
+ * Texte: Deutsch/Englisch nach <html lang> (wie events.js/downloads.js), einzeln
26
+ * überschreibbar per data-text-empty/-all/-status am <form> ("{n}" und "{q}" als
27
+ * Platzhalter). Treffer-Markierung per <mark>, alle Inhalte werden escaped.
28
+ */
29
+ (function () {
30
+ "use strict";
31
+
32
+ if (typeof window.fetch !== "function" || typeof window.AbortController !== "function") {
33
+ return;
34
+ }
35
+
36
+ var TEXTS = {
37
+ de: { empty: "Keine Treffer für „{q}“.", all: "Alle Ergebnisse anzeigen", status: "{n} Treffer, mit Pfeiltasten auswählen", none: "Keine Treffer" },
38
+ en: { empty: "No results for “{q}”.", all: "Show all results", status: "{n} results, use arrow keys to choose", none: "No results" }
39
+ };
40
+ var lang = (document.documentElement.getAttribute("lang") || "de").slice(0, 2) === "en" ? "en" : "de";
41
+ var counter = 0;
42
+
43
+ function escapeHtml(value) {
44
+ return String(value).replace(/[&<>"']/g, function (c) {
45
+ return { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[c];
46
+ });
47
+ }
48
+ function terms(query) {
49
+ return query.trim().toLowerCase().split(/\s+/).filter(function (t) { return t.length > 1; });
50
+ }
51
+ function highlight(value, query) {
52
+ var html = escapeHtml(value);
53
+ terms(query).forEach(function (term) {
54
+ var re = new RegExp("(" + escapeHtml(term).replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + ")", "gi");
55
+ html = html.replace(re, "<mark>$1</mark>");
56
+ });
57
+ return html;
58
+ }
59
+
60
+ function init(form) {
61
+ var input = form.querySelector('input[type="search"], input[type="text"]');
62
+ var box = form.querySelector(".ncss-livesearch-results");
63
+ if (!input || !box) {
64
+ return;
65
+ }
66
+ function text(key) {
67
+ return form.getAttribute("data-text-" + key) || TEXTS[lang][key];
68
+ }
69
+ var endpoint = form.getAttribute("data-ncss-livesearch");
70
+ var param = form.getAttribute("data-param") || "q";
71
+ var min = parseInt(form.getAttribute("data-min"), 10) || 2;
72
+ var delay = parseInt(form.getAttribute("data-delay"), 10) || 180;
73
+ var clientMode = form.getAttribute("data-mode") === "client";
74
+ var id = box.id || (box.id = "ncss-livesearch-" + ++counter);
75
+ var options = [];
76
+ var active = -1;
77
+ var timer = null;
78
+ var controller = null;
79
+ var cache = {};
80
+ var dataset = null;
81
+
82
+ input.setAttribute("role", "combobox");
83
+ input.setAttribute("aria-autocomplete", "list");
84
+ input.setAttribute("aria-expanded", "false");
85
+ input.setAttribute("aria-controls", id);
86
+ input.setAttribute("autocomplete", "off");
87
+ box.setAttribute("role", "listbox");
88
+ var status = document.createElement("p");
89
+ status.className = "ncss-visually-hidden";
90
+ status.setAttribute("role", "status");
91
+ form.appendChild(status);
92
+
93
+ function close() {
94
+ box.hidden = true;
95
+ input.setAttribute("aria-expanded", "false");
96
+ input.removeAttribute("aria-activedescendant");
97
+ active = -1;
98
+ }
99
+ function select(i) {
100
+ options.forEach(function (o) { o.setAttribute("aria-selected", "false"); });
101
+ active = i;
102
+ if (i < 0 || !options[i]) {
103
+ input.removeAttribute("aria-activedescendant");
104
+ return;
105
+ }
106
+ options[i].setAttribute("aria-selected", "true");
107
+ input.setAttribute("aria-activedescendant", options[i].id);
108
+ options[i].scrollIntoView({ block: "nearest" });
109
+ }
110
+ function render(data, query) {
111
+ var html = "";
112
+ var n = 0;
113
+ (data.groups || []).forEach(function (group, g) {
114
+ if (!group.items || group.items.length === 0) {
115
+ return;
116
+ }
117
+ var gid = id + "-g" + g;
118
+ html += '<p class="ncss-livesearch-group" id="' + gid + '">' + escapeHtml(group.label || "") + "</p>";
119
+ html += '<ul class="ncss-livesearch-list" role="group" aria-labelledby="' + gid + '">';
120
+ group.items.forEach(function (item) {
121
+ html += '<li class="ncss-livesearch-option" role="option" aria-selected="false" id="' + id + "-o" + n++ + '">' +
122
+ '<a href="' + escapeHtml(item.url) + '" tabindex="-1"><span class="ncss-livesearch-title">' + highlight(item.title || "", query) + "</span>" +
123
+ (item.text ? '<span class="ncss-livesearch-text">' + highlight(item.text, query) + "</span>" : "") + "</a></li>";
124
+ });
125
+ html += "</ul>";
126
+ });
127
+ if (n === 0) {
128
+ html = '<p class="ncss-livesearch-empty">' + escapeHtml(text("empty").replace("{q}", query)) + "</p>";
129
+ } else if (data.all) {
130
+ html += '<p class="ncss-livesearch-footer"><a href="' + escapeHtml(data.all) + '">' + escapeHtml(text("all")) + "</a></p>";
131
+ }
132
+ box.innerHTML = html;
133
+ box.hidden = false;
134
+ input.setAttribute("aria-expanded", "true");
135
+ options = Array.prototype.slice.call(box.querySelectorAll('[role="option"]'));
136
+ active = -1;
137
+ status.textContent = n === 0 ? text("none") : text("status").replace("{n}", n);
138
+ }
139
+ // Client-Modus: komplette Liste einmal laden, dann hier filtern (alle Begriffe müssen
140
+ // in Titel oder Text vorkommen).
141
+ function filter(data, query) {
142
+ var list = terms(query);
143
+ return {
144
+ all: data.all,
145
+ groups: (data.groups || []).map(function (group) {
146
+ return {
147
+ label: group.label,
148
+ items: (group.items || []).filter(function (item) {
149
+ var hay = ((item.title || "") + " " + (item.text || "")).toLowerCase();
150
+ return list.every(function (t) { return hay.indexOf(t) !== -1; });
151
+ })
152
+ };
153
+ })
154
+ };
155
+ }
156
+ function load(url) {
157
+ if (controller) {
158
+ controller.abort();
159
+ }
160
+ controller = new AbortController();
161
+ form.setAttribute("aria-busy", "true");
162
+ return fetch(url, { signal: controller.signal, headers: { Accept: "application/json" } })
163
+ .then(function (response) { return response.ok ? response.json() : Promise.reject(response.status); })
164
+ .finally(function () { form.removeAttribute("aria-busy"); });
165
+ }
166
+ function search() {
167
+ var query = input.value.trim();
168
+ if (query.length < min) {
169
+ close();
170
+ return;
171
+ }
172
+ if (clientMode) {
173
+ (dataset ? Promise.resolve(dataset) : load(endpoint).then(function (d) { dataset = d; return d; }))
174
+ .then(function (d) { if (input.value.trim() === query) { render(filter(d, query), query); } })
175
+ .catch(function () {});
176
+ return;
177
+ }
178
+ if (cache[query]) {
179
+ render(cache[query], query);
180
+ return;
181
+ }
182
+ var url = endpoint + (endpoint.indexOf("?") < 0 ? "?" : "&") + encodeURIComponent(param) + "=" + encodeURIComponent(query);
183
+ load(url)
184
+ .then(function (data) {
185
+ cache[query] = data;
186
+ if (input.value.trim() === query) {
187
+ render(data, query);
188
+ }
189
+ })
190
+ .catch(function () {});
191
+ }
192
+
193
+ input.addEventListener("input", function () {
194
+ window.clearTimeout(timer);
195
+ timer = window.setTimeout(search, delay);
196
+ });
197
+ input.addEventListener("keydown", function (event) {
198
+ if (event.key === "ArrowDown") {
199
+ event.preventDefault();
200
+ if (box.hidden) {
201
+ search();
202
+ return;
203
+ }
204
+ select(Math.min(active + 1, options.length - 1));
205
+ } else if (event.key === "ArrowUp" && !box.hidden) {
206
+ event.preventDefault();
207
+ select(Math.max(active - 1, -1));
208
+ } else if (event.key === "Enter" && !box.hidden && active >= 0 && options[active]) {
209
+ event.preventDefault();
210
+ options[active].querySelector("a").click();
211
+ } else if (event.key === "Escape" && !box.hidden) {
212
+ // nur die Liste schließen, nicht einen umgebenden <dialog>
213
+ event.preventDefault();
214
+ event.stopPropagation();
215
+ close();
216
+ }
217
+ });
218
+ document.addEventListener("click", function (event) {
219
+ if (!form.contains(event.target)) {
220
+ close();
221
+ }
222
+ });
223
+ }
224
+
225
+ // Dynamische Inhalte (htmx, fetch+innerHTML, REDAXO-Frontend-Editing): scan() ist
226
+ // idempotent - bereits verarbeitete Elemente merkt sich ein WeakSet, bewusst KEIN
227
+ // data-Attribut (per innerHTML kopiertes Markup trüge sonst eine veraltete Markierung
228
+ // mit). Läuft beim Laden und bei jedem "ncss-content-change"-Event (detail.root = neu
229
+ // eingefügtes Element, ohne Angabe das ganze Dokument), siehe js/content-observer.js.
230
+ var SELECTOR = "[data-ncss-livesearch]";
231
+ var seen = new WeakSet();
232
+ function scan(root) {
233
+ if (!root || !root.querySelectorAll) return;
234
+ var list = Array.prototype.slice.call(root.querySelectorAll(SELECTOR));
235
+ if (root.matches && root.matches(SELECTOR)) list.unshift(root);
236
+ list.forEach(function (el) {
237
+ if (seen.has(el)) return;
238
+ seen.add(el);
239
+ init(el);
240
+ });
241
+ }
242
+ document.addEventListener("ncss-content-change", function (event) {
243
+ scan((event.detail && event.detail.root) || document);
244
+ });
245
+ function scanDocument() {
246
+ scan(document);
247
+ }
248
+ if (document.readyState === "loading") {
249
+ document.addEventListener("DOMContentLoaded", scanDocument);
250
+ } else {
251
+ scanDocument();
252
+ }
253
+ })();