@birdapi/velinstyle 1.0.0 → 1.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.
- package/README.de.md +12 -8
- package/README.md +12 -8
- package/cli/cli-manifest.json +1 -1
- package/cli/docgen/extract-a11y.js +4 -2
- package/cli/index.js +4 -2
- package/components/index.js +2 -0
- package/components/runtime/component-loaders.js +2 -0
- package/components/velin-data-table.js +361 -0
- package/components/velin-form-summary.js +348 -0
- package/core/a11y/component-contracts.json +18 -1
- package/core/highlight/languages/go.js +28 -0
- package/core/highlight/languages/python.js +29 -0
- package/core/highlight/languages/rust.js +32 -0
- package/core/highlight/languages/yaml.js +23 -0
- package/core/highlight/registry.js +13 -2
- package/core/meta/build.js +1 -1
- package/dist/chunks/attributes-353XDOAX.js +391 -0
- package/dist/chunks/chunk-ERF5YVP4.js +253 -0
- package/dist/chunks/chunk-QVHYL3R4.js +111 -0
- package/dist/chunks/go-HZ6XTFCK.js +31 -0
- package/dist/chunks/highlight-IBDX4XWS.js +37 -0
- package/dist/chunks/python-BMPKDKNO.js +32 -0
- package/dist/chunks/runtime-entry.js +1 -1
- package/dist/chunks/rust-2BWKI2MN.js +35 -0
- package/dist/chunks/velin-code-block-ITCLIC6T.js +132 -0
- package/dist/chunks/velin-data-table-KK7IDGTP.js +302 -0
- package/dist/chunks/velin-form-summary-XRQ7COQH.js +273 -0
- package/dist/chunks/velin-lightbox-NXA3U2FM.js +149 -0
- package/dist/chunks/yaml-O67LEQYT.js +26 -0
- package/dist/llms.txt +2 -2
- package/dist/search-index.json +28 -2
- package/dist/velin-agent.json +31 -5
- package/dist/velinstyle-components.iife.js +742 -4
- package/dist/velinstyle-components.js +744 -4
- package/dist/velinstyle-components.min.js +85 -85
- package/dist/velinstyle.css +129 -0
- package/dist/velinstyle.d.ts +2 -0
- package/dist/velinstyle.min.css +1 -1
- package/package.json +8 -2
- package/src/base/wc-placeholder.css +7 -0
- package/src/components/data-table.css +93 -0
- package/src/components/form-validation.css +40 -0
- package/src/velinstyle.css +1 -0
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import {
|
|
2
|
+
disconnectInViewObserver,
|
|
3
|
+
observeInView
|
|
4
|
+
} from "./chunk-7MCGPHVC.js";
|
|
5
|
+
import {
|
|
6
|
+
lazyDefine
|
|
7
|
+
} from "./chunk-QVHYL3R4.js";
|
|
8
|
+
|
|
9
|
+
// core/motion/effects.js
|
|
10
|
+
var VISIBLE_CLASS = "velin-in-view";
|
|
11
|
+
var EFFECT_MAP = {
|
|
12
|
+
reveal: ["velin-animate-on-scroll"],
|
|
13
|
+
fade: ["velin-animate-on-scroll", "velin-animate-on-scroll--fade"],
|
|
14
|
+
slide: ["velin-animate-on-scroll", "velin-animate-on-scroll--slide-up"],
|
|
15
|
+
"slide-up": ["velin-animate-on-scroll", "velin-animate-on-scroll--slide-up"],
|
|
16
|
+
"slide-down": ["velin-animate-on-scroll", "velin-animate-on-scroll--slide-down"],
|
|
17
|
+
"slide-left": ["velin-animate-on-scroll", "velin-animate-on-scroll--slide-left"],
|
|
18
|
+
"slide-right": ["velin-animate-on-scroll", "velin-animate-on-scroll--slide-right"],
|
|
19
|
+
scale: ["velin-animate-on-scroll", "velin-animate-on-scroll--scale"],
|
|
20
|
+
parallax: ["velin-parallax"],
|
|
21
|
+
"parallax-slow": ["velin-parallax", "velin-parallax--slow"],
|
|
22
|
+
hover: ["velin-animate-hover"],
|
|
23
|
+
"hover-lift": ["velin-animate-hover"],
|
|
24
|
+
flip: ["velin-animate-scale-in"],
|
|
25
|
+
blur: ["velin-animate-fade-in"]
|
|
26
|
+
};
|
|
27
|
+
function applyEffects(el, attrs = {}) {
|
|
28
|
+
const classes = /* @__PURE__ */ new Set();
|
|
29
|
+
for (const [name, value] of Object.entries(attrs)) {
|
|
30
|
+
if (value === "false" || value === "off") continue;
|
|
31
|
+
const mapped = EFFECT_MAP[name];
|
|
32
|
+
if (mapped) mapped.forEach((c) => classes.add(c));
|
|
33
|
+
if (name === "slide" && value && value !== "true" && value !== "") {
|
|
34
|
+
const key = `slide-${value}`;
|
|
35
|
+
EFFECT_MAP[key]?.forEach((c) => classes.add(c));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
classes.forEach((c) => el.classList.add(c));
|
|
39
|
+
if (!el.classList.contains("velin-animate-on-scroll") && attrs.reveal !== void 0) {
|
|
40
|
+
el.classList.add("velin-animate-on-scroll");
|
|
41
|
+
}
|
|
42
|
+
return [...classes];
|
|
43
|
+
}
|
|
44
|
+
function markVisible(el) {
|
|
45
|
+
el.classList.add(VISIBLE_CLASS);
|
|
46
|
+
el.dataset.velinVisible = "true";
|
|
47
|
+
}
|
|
48
|
+
function prefersReducedMotion() {
|
|
49
|
+
return typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// core/motion/stagger.js
|
|
53
|
+
var STAGGER_ATTR = "velin-stagger";
|
|
54
|
+
function applyStagger(listEl, value = "true") {
|
|
55
|
+
const base = value === "true" || value === "" ? 60 : parseInt(value, 10) || 60;
|
|
56
|
+
const children = [...listEl.children];
|
|
57
|
+
children.forEach((child, i) => {
|
|
58
|
+
child.style.setProperty("--velin-stagger-delay", `${i * base}ms`);
|
|
59
|
+
child.classList.add("velin-stagger-item");
|
|
60
|
+
});
|
|
61
|
+
listEl.classList.add("velin-stagger");
|
|
62
|
+
}
|
|
63
|
+
function enhanceStagger(root = document) {
|
|
64
|
+
root.querySelectorAll(`[${STAGGER_ATTR}]`).forEach((el) => {
|
|
65
|
+
if (el.dataset.velinStaggerDone) return;
|
|
66
|
+
el.dataset.velinStaggerDone = "1";
|
|
67
|
+
applyStagger(el, el.getAttribute(STAGGER_ATTR) || "true");
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// core/motion/scroll.js
|
|
72
|
+
function smoothScrollTo(target, options = {}) {
|
|
73
|
+
const reduced = typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
74
|
+
const el = typeof target === "string" ? document.querySelector(target) : target;
|
|
75
|
+
if (!el) return;
|
|
76
|
+
el.scrollIntoView({
|
|
77
|
+
behavior: reduced || options.instant ? "auto" : "smooth",
|
|
78
|
+
block: options.block || "start",
|
|
79
|
+
inline: options.inline || "nearest"
|
|
80
|
+
});
|
|
81
|
+
if (el.tabIndex < 0 && !el.hasAttribute("tabindex")) {
|
|
82
|
+
el.setAttribute("tabindex", "-1");
|
|
83
|
+
}
|
|
84
|
+
el.focus({ preventScroll: true });
|
|
85
|
+
}
|
|
86
|
+
function bindSmoothScroll(root = document) {
|
|
87
|
+
root.querySelectorAll("[velin-scroll]").forEach((link) => {
|
|
88
|
+
if (link.dataset.velinScrollBound) return;
|
|
89
|
+
link.dataset.velinScrollBound = "1";
|
|
90
|
+
link.addEventListener("click", (e) => {
|
|
91
|
+
const href = link.getAttribute("href");
|
|
92
|
+
if (!href || !href.startsWith("#")) return;
|
|
93
|
+
const target = document.querySelector(href);
|
|
94
|
+
if (!target) return;
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
smoothScrollTo(target);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// core/motion/index.js
|
|
102
|
+
var MOTION_ATTRS = ["velin-reveal", "velin-fade", "velin-slide", "velin-scale", "velin-parallax", "velin-hover"];
|
|
103
|
+
var teardownFns = [];
|
|
104
|
+
function initMotion(options = {}) {
|
|
105
|
+
const root = options.root || (typeof document !== "undefined" ? document : null);
|
|
106
|
+
if (!root) return () => {
|
|
107
|
+
};
|
|
108
|
+
const selector = options.selector || [
|
|
109
|
+
"[velin-reveal]",
|
|
110
|
+
"[velin-fade]",
|
|
111
|
+
"[velin-slide]",
|
|
112
|
+
"[velin-scale]",
|
|
113
|
+
"[velin-parallax]",
|
|
114
|
+
"[velin-hover]",
|
|
115
|
+
".velin-animate-on-scroll"
|
|
116
|
+
].join(",");
|
|
117
|
+
const elements = root.querySelectorAll(selector);
|
|
118
|
+
const reduced = prefersReducedMotion();
|
|
119
|
+
for (const el of elements) {
|
|
120
|
+
if (el.dataset.velinMotionInit) continue;
|
|
121
|
+
el.dataset.velinMotionInit = "1";
|
|
122
|
+
const attrs = {};
|
|
123
|
+
for (const name of MOTION_ATTRS) {
|
|
124
|
+
if (el.hasAttribute(name)) attrs[name.replace("velin-", "")] = el.getAttribute(name) || "true";
|
|
125
|
+
}
|
|
126
|
+
applyEffects(el, attrs);
|
|
127
|
+
if (reduced) {
|
|
128
|
+
markVisible(el);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const stop = observeInView(el, (node) => markVisible(node));
|
|
132
|
+
teardownFns.push(stop);
|
|
133
|
+
}
|
|
134
|
+
enhanceStagger(root);
|
|
135
|
+
bindSmoothScroll(root);
|
|
136
|
+
return () => {
|
|
137
|
+
teardownFns.forEach((fn) => fn());
|
|
138
|
+
teardownFns = [];
|
|
139
|
+
disconnectInViewObserver();
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// core/attributes/registry.js
|
|
144
|
+
var registry = /* @__PURE__ */ new Map();
|
|
145
|
+
function registerAttribute(name, handler) {
|
|
146
|
+
registry.set(name, handler);
|
|
147
|
+
}
|
|
148
|
+
function getAttributeHandler(name) {
|
|
149
|
+
return registry.get(name);
|
|
150
|
+
}
|
|
151
|
+
function bridgeComponent(el, tag, attrs = {}) {
|
|
152
|
+
el.setAttribute("data-velin-component", tag);
|
|
153
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
154
|
+
if (v != null) el.setAttribute(k, v);
|
|
155
|
+
}
|
|
156
|
+
return lazyDefine(tag);
|
|
157
|
+
}
|
|
158
|
+
function registerBuiltins() {
|
|
159
|
+
registerAttribute("velin-modal", {
|
|
160
|
+
enhance(el) {
|
|
161
|
+
bridgeComponent(el, "velin-modal", { open: el.getAttribute("velin-modal") || "" });
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
registerAttribute("velin-tabs", { enhance: (el) => bridgeComponent(el, "velin-tabs") });
|
|
165
|
+
registerAttribute("velin-accordion", { enhance: (el) => bridgeComponent(el, "velin-accordion") });
|
|
166
|
+
registerAttribute("velin-tooltip", {
|
|
167
|
+
enhance(el) {
|
|
168
|
+
const tip = el.getAttribute("velin-tooltip") || el.getAttribute("title") || "";
|
|
169
|
+
if (tip && el.hasAttribute("title")) el.removeAttribute("title");
|
|
170
|
+
if (el.tagName === "VELIN-TOOLTIP" || el.tagName === "VELIN-TOOLTIP-WC") {
|
|
171
|
+
el.setAttribute("content", tip);
|
|
172
|
+
return lazyDefine("velin-tooltip");
|
|
173
|
+
}
|
|
174
|
+
const wc = document.createElement("velin-tooltip");
|
|
175
|
+
wc.setAttribute("content", tip);
|
|
176
|
+
const parent = el.parentElement;
|
|
177
|
+
if (parent) {
|
|
178
|
+
parent.insertBefore(wc, el);
|
|
179
|
+
wc.appendChild(el);
|
|
180
|
+
}
|
|
181
|
+
return lazyDefine("velin-tooltip");
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
registerAttribute("velin-copy", {
|
|
185
|
+
enhance(el) {
|
|
186
|
+
const text = el.getAttribute("velin-copy") || el.textContent?.trim() || "";
|
|
187
|
+
if (!el.querySelector("velin-copy")) {
|
|
188
|
+
const wc = document.createElement("velin-copy");
|
|
189
|
+
wc.setAttribute("value", text);
|
|
190
|
+
if (el.tagName === "BUTTON") {
|
|
191
|
+
wc.append(...el.childNodes);
|
|
192
|
+
el.replaceWith(wc);
|
|
193
|
+
return lazyDefine("velin-copy");
|
|
194
|
+
}
|
|
195
|
+
el.appendChild(wc);
|
|
196
|
+
}
|
|
197
|
+
return lazyDefine("velin-copy");
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
registerAttribute("velin-counter", {
|
|
201
|
+
enhance(el) {
|
|
202
|
+
bridgeComponent(el, "velin-counter", {
|
|
203
|
+
value: el.getAttribute("velin-counter") || "0"
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
registerAttribute("velin-notify", {
|
|
208
|
+
async enhance(el) {
|
|
209
|
+
await lazyDefine("velin-toast");
|
|
210
|
+
el.addEventListener("click", () => {
|
|
211
|
+
const msg = el.getAttribute("velin-notify") || el.textContent || "";
|
|
212
|
+
document.dispatchEvent(
|
|
213
|
+
new CustomEvent("velin-toast-show", { detail: { message: msg, variant: el.dataset.variant || "info" } })
|
|
214
|
+
);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
registerAttribute("velin-theme", {
|
|
219
|
+
enhance(el) {
|
|
220
|
+
const theme = el.getAttribute("velin-theme") || "toggle";
|
|
221
|
+
if (theme === "toggle") {
|
|
222
|
+
if (!el.querySelector("velin-theme-toggle")) {
|
|
223
|
+
el.appendChild(document.createElement("velin-theme-toggle"));
|
|
224
|
+
}
|
|
225
|
+
return lazyDefine("velin-theme-toggle");
|
|
226
|
+
}
|
|
227
|
+
document.documentElement.setAttribute("data-velin-theme", theme);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
registerAttribute("velin-scroll-top", {
|
|
231
|
+
enhance(el) {
|
|
232
|
+
const raw = el.getAttribute("velin-scroll-top");
|
|
233
|
+
const threshold = raw && raw !== "true" ? raw : "300";
|
|
234
|
+
if (el.tagName === "VELIN-SCROLL-TOP") {
|
|
235
|
+
if (raw && raw !== "true") el.setAttribute("threshold", threshold);
|
|
236
|
+
return lazyDefine("velin-scroll-top");
|
|
237
|
+
}
|
|
238
|
+
let wc = document.querySelector("velin-scroll-top");
|
|
239
|
+
if (!wc) {
|
|
240
|
+
wc = document.createElement("velin-scroll-top");
|
|
241
|
+
wc.setAttribute("threshold", threshold);
|
|
242
|
+
(el === document.body || el === document.documentElement ? document.body : el).appendChild(wc);
|
|
243
|
+
}
|
|
244
|
+
return lazyDefine("velin-scroll-top");
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
registerAttribute("velin-progress", {
|
|
248
|
+
enhance(el) {
|
|
249
|
+
const ring = el.hasAttribute("ring");
|
|
250
|
+
if (ring) return bridgeComponent(el, "velin-progress-ring");
|
|
251
|
+
el.classList.add("velin-progress");
|
|
252
|
+
const val = parseInt(el.getAttribute("velin-progress") || "0", 10);
|
|
253
|
+
el.setAttribute("role", "progressbar");
|
|
254
|
+
el.setAttribute("aria-valuenow", String(val));
|
|
255
|
+
el.style.setProperty("--velin-progress", `${Math.min(100, val)}%`);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
registerAttribute("velin-search", {
|
|
259
|
+
async enhance(el) {
|
|
260
|
+
if (el.tagName !== "VELIN-SEARCH") {
|
|
261
|
+
const host = document.createElement("velin-search");
|
|
262
|
+
host.setAttribute("index", el.getAttribute("data-search-index") || "/search-index.json");
|
|
263
|
+
el.replaceWith(host);
|
|
264
|
+
host.appendChild(el);
|
|
265
|
+
}
|
|
266
|
+
return lazyDefine("velin-search");
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
registerAttribute("velin-lazy", {
|
|
270
|
+
enhance(el) {
|
|
271
|
+
if (el.tagName === "IMG") {
|
|
272
|
+
el.loading = "lazy";
|
|
273
|
+
el.decoding = "async";
|
|
274
|
+
if (el.hasAttribute("velin-skeleton") || el.dataset.velinSkeleton) {
|
|
275
|
+
el.classList.add("velin-skeleton", "velin-skeleton--image");
|
|
276
|
+
el.addEventListener("load", () => el.classList.remove("velin-skeleton", "velin-skeleton--image"), { once: true });
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
registerAttribute("velin-skeleton", {
|
|
282
|
+
enhance(el) {
|
|
283
|
+
const variant = el.getAttribute("velin-skeleton") || "text";
|
|
284
|
+
el.classList.add("velin-skeleton", `velin-skeleton--${variant}`);
|
|
285
|
+
const hasText = Boolean(el.textContent?.trim()) && el.children.length > 0;
|
|
286
|
+
if (!hasText && !el.textContent?.trim()) {
|
|
287
|
+
el.setAttribute("aria-hidden", "true");
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
registerAttribute("velin-loading", {
|
|
292
|
+
enhance(el) {
|
|
293
|
+
el.classList.add("velin-spinner");
|
|
294
|
+
el.setAttribute("aria-busy", "true");
|
|
295
|
+
el.setAttribute("role", "status");
|
|
296
|
+
if (!el.getAttribute("aria-label")?.trim()) {
|
|
297
|
+
el.setAttribute("aria-label", "Loading");
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
registerAttribute("velin-grid", {
|
|
302
|
+
enhance(el) {
|
|
303
|
+
const cols = el.getAttribute("velin-grid") || "auto";
|
|
304
|
+
el.classList.add("velin-grid");
|
|
305
|
+
if (cols !== "auto") el.style.setProperty("--velin-grid-cols", cols);
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
registerAttribute("velin-anchor", {
|
|
309
|
+
enhance(el) {
|
|
310
|
+
if (!el.id && el.getAttribute("velin-anchor")) el.id = el.getAttribute("velin-anchor");
|
|
311
|
+
el.setAttribute("tabindex", "-1");
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
registerAttribute("velin-code", {
|
|
315
|
+
async enhance(el) {
|
|
316
|
+
const lang = el.getAttribute("velin-code") || el.getAttribute("language") || el.getAttribute("data-language") || "";
|
|
317
|
+
el.classList.add("velin-code-block");
|
|
318
|
+
if (lang && lang !== "true") {
|
|
319
|
+
el.dataset.language = lang;
|
|
320
|
+
if (!el.getAttribute("language")) el.setAttribute("language", lang);
|
|
321
|
+
}
|
|
322
|
+
if (!el.querySelector("[data-velin-copy]")) {
|
|
323
|
+
const btn = document.createElement("button");
|
|
324
|
+
btn.type = "button";
|
|
325
|
+
btn.className = "velin-code-block__copy velin-btn velin-btn--sm";
|
|
326
|
+
btn.textContent = "Copy";
|
|
327
|
+
btn.setAttribute("data-velin-copy", "");
|
|
328
|
+
btn.setAttribute("velin-copy", el.querySelector("code")?.textContent || el.textContent || "");
|
|
329
|
+
el.style.position = "relative";
|
|
330
|
+
el.appendChild(btn);
|
|
331
|
+
}
|
|
332
|
+
await lazyDefine("velin-copy");
|
|
333
|
+
const { initHighlight, highlightElement } = await import("./highlight-IBDX4XWS.js");
|
|
334
|
+
const immediate = el.getAttribute("data-velin-highlight") === "immediate" || typeof matchMedia !== "undefined" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
335
|
+
if (immediate) {
|
|
336
|
+
await highlightElement(el);
|
|
337
|
+
} else {
|
|
338
|
+
initHighlight(el, { root: el });
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
registerAttribute("velin-quote", {
|
|
343
|
+
enhance(el) {
|
|
344
|
+
if (el.tagName === "BLOCKQUOTE" || el.tagName === "Q") {
|
|
345
|
+
el.classList.add("velin-quote");
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
registerAttribute("velin-highlight", {
|
|
350
|
+
enhance(el) {
|
|
351
|
+
el.classList.add("velin-highlight");
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
for (const motion of ["velin-reveal", "velin-fade", "velin-slide", "velin-scale", "velin-parallax", "velin-hover", "velin-stagger", "velin-scroll"]) {
|
|
355
|
+
registerAttribute(motion, { enhance() {
|
|
356
|
+
} });
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
registerBuiltins();
|
|
360
|
+
var enhanced = /* @__PURE__ */ new WeakSet();
|
|
361
|
+
async function bootAttributes(root = document) {
|
|
362
|
+
const selector = [...registry.keys()].map((a) => `[${a}]`).join(",");
|
|
363
|
+
const elements = root.querySelectorAll(selector);
|
|
364
|
+
for (const el of elements) {
|
|
365
|
+
if (enhanced.has(el)) continue;
|
|
366
|
+
for (const attr of registry.keys()) {
|
|
367
|
+
if (!el.hasAttribute(attr)) continue;
|
|
368
|
+
const handler = registry.get(attr);
|
|
369
|
+
if (handler?.enhance) await handler.enhance(el);
|
|
370
|
+
}
|
|
371
|
+
enhanced.add(el);
|
|
372
|
+
}
|
|
373
|
+
initMotion({ root });
|
|
374
|
+
if (typeof HTMLElement !== "undefined") {
|
|
375
|
+
const { bindDeclarativeSearch } = await import("./velin-search-FDHEMCSO.js");
|
|
376
|
+
bindDeclarativeSearch(root);
|
|
377
|
+
if (!document.querySelector("velin-announcer")) {
|
|
378
|
+
const { getAnnouncer } = await import("./a11y-utils-IRC7LOPF.js");
|
|
379
|
+
getAnnouncer();
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function listRegisteredAttributes() {
|
|
384
|
+
return [...registry.keys()];
|
|
385
|
+
}
|
|
386
|
+
export {
|
|
387
|
+
bootAttributes,
|
|
388
|
+
getAttributeHandler,
|
|
389
|
+
listRegisteredAttributes,
|
|
390
|
+
registerAttribute
|
|
391
|
+
};
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import {
|
|
2
|
+
observeInView
|
|
3
|
+
} from "./chunk-7MCGPHVC.js";
|
|
4
|
+
import {
|
|
5
|
+
lexJs
|
|
6
|
+
} from "./chunk-M5CHQVP6.js";
|
|
7
|
+
|
|
8
|
+
// core/highlight/registry.js
|
|
9
|
+
var languages = /* @__PURE__ */ new Map();
|
|
10
|
+
var loading = /* @__PURE__ */ new Map();
|
|
11
|
+
var LAZY_LOADERS = {
|
|
12
|
+
js: () => import("./js-MNSNYTJU.js"),
|
|
13
|
+
javascript: () => import("./js-MNSNYTJU.js"),
|
|
14
|
+
ts: () => import("./typescript-JT3CCYWL.js"),
|
|
15
|
+
typescript: () => import("./typescript-JT3CCYWL.js"),
|
|
16
|
+
html: () => import("./html-ZODC4DLQ.js"),
|
|
17
|
+
xml: () => import("./html-ZODC4DLQ.js"),
|
|
18
|
+
css: () => import("./css-MQ5YU77P.js"),
|
|
19
|
+
json: () => import("./json-VEM2HFH3.js"),
|
|
20
|
+
md: () => import("./markdown-E7OPGS3S.js"),
|
|
21
|
+
markdown: () => import("./markdown-E7OPGS3S.js"),
|
|
22
|
+
shell: () => import("./shell-QTRK4U4E.js"),
|
|
23
|
+
bash: () => import("./shell-QTRK4U4E.js"),
|
|
24
|
+
sh: () => import("./shell-QTRK4U4E.js"),
|
|
25
|
+
sql: () => import("./sql-PPWLHGJ2.js"),
|
|
26
|
+
text: () => import("./plain-LJJDC5TN.js"),
|
|
27
|
+
plain: () => import("./plain-LJJDC5TN.js"),
|
|
28
|
+
txt: () => import("./plain-LJJDC5TN.js"),
|
|
29
|
+
markup: () => import("./html-ZODC4DLQ.js"),
|
|
30
|
+
console: () => import("./plain-LJJDC5TN.js"),
|
|
31
|
+
php: () => import("./php-MLL7T3LT.js"),
|
|
32
|
+
blade: () => import("./blade-LIQLVKZQ.js"),
|
|
33
|
+
python: () => import("./python-BMPKDKNO.js"),
|
|
34
|
+
py: () => import("./python-BMPKDKNO.js"),
|
|
35
|
+
yaml: () => import("./yaml-O67LEQYT.js"),
|
|
36
|
+
yml: () => import("./yaml-O67LEQYT.js"),
|
|
37
|
+
go: () => import("./go-HZ6XTFCK.js"),
|
|
38
|
+
golang: () => import("./go-HZ6XTFCK.js"),
|
|
39
|
+
rust: () => import("./rust-2BWKI2MN.js"),
|
|
40
|
+
rs: () => import("./rust-2BWKI2MN.js")
|
|
41
|
+
};
|
|
42
|
+
function normalizeLanguage(name) {
|
|
43
|
+
const n = (name || "").trim().toLowerCase();
|
|
44
|
+
if (!n) return "";
|
|
45
|
+
if (n.startsWith("language-")) return normalizeLanguage(n.slice(9));
|
|
46
|
+
const map = {
|
|
47
|
+
javascript: "js",
|
|
48
|
+
jsx: "js",
|
|
49
|
+
typescript: "ts",
|
|
50
|
+
tsx: "ts",
|
|
51
|
+
markup: "html",
|
|
52
|
+
xml: "html",
|
|
53
|
+
svg: "html",
|
|
54
|
+
bash: "shell",
|
|
55
|
+
sh: "shell",
|
|
56
|
+
zsh: "shell",
|
|
57
|
+
md: "markdown",
|
|
58
|
+
plaintext: "text",
|
|
59
|
+
"plain-text": "text",
|
|
60
|
+
yml: "yaml",
|
|
61
|
+
toml: "text",
|
|
62
|
+
ini: "text",
|
|
63
|
+
php8: "php",
|
|
64
|
+
py: "python",
|
|
65
|
+
python3: "python",
|
|
66
|
+
golang: "go",
|
|
67
|
+
rs: "rust"
|
|
68
|
+
};
|
|
69
|
+
return map[n] || n;
|
|
70
|
+
}
|
|
71
|
+
function registerLanguage(name, lexerFn) {
|
|
72
|
+
languages.set(normalizeLanguage(name), lexerFn);
|
|
73
|
+
}
|
|
74
|
+
function getLanguage(name) {
|
|
75
|
+
return languages.get(normalizeLanguage(name));
|
|
76
|
+
}
|
|
77
|
+
async function lazyLoadLanguage(name) {
|
|
78
|
+
const key = normalizeLanguage(name);
|
|
79
|
+
if (!key) return void 0;
|
|
80
|
+
if (languages.has(key)) return languages.get(key);
|
|
81
|
+
if (loading.has(key)) return loading.get(key);
|
|
82
|
+
const loader = LAZY_LOADERS[key];
|
|
83
|
+
if (!loader) return void 0;
|
|
84
|
+
const p = loader().then((mod) => {
|
|
85
|
+
const fn = mod.default;
|
|
86
|
+
languages.set(key, fn);
|
|
87
|
+
loading.delete(key);
|
|
88
|
+
return fn;
|
|
89
|
+
});
|
|
90
|
+
loading.set(key, p);
|
|
91
|
+
return p;
|
|
92
|
+
}
|
|
93
|
+
function listLanguages() {
|
|
94
|
+
return [.../* @__PURE__ */ new Set([...languages.keys(), ...Object.keys(LAZY_LOADERS)])];
|
|
95
|
+
}
|
|
96
|
+
registerLanguage("js", lexJs);
|
|
97
|
+
|
|
98
|
+
// core/highlight/render.js
|
|
99
|
+
var ESC = { "&": "&", "<": "<", ">": ">", '"': """ };
|
|
100
|
+
function escapeHtml(s) {
|
|
101
|
+
return s.replace(/[&<>"]/g, (c) => ESC[c] || c);
|
|
102
|
+
}
|
|
103
|
+
function renderTokens(tokens) {
|
|
104
|
+
return tokens.map((t) => {
|
|
105
|
+
const type = t.type === "plain" ? "" : t.type;
|
|
106
|
+
const cls = type ? `velin-token velin-token--${type}` : "velin-token";
|
|
107
|
+
return `<span class="${cls}">${escapeHtml(t.value)}</span>`;
|
|
108
|
+
}).join("");
|
|
109
|
+
}
|
|
110
|
+
function applyHighlight(codeEl, tokens) {
|
|
111
|
+
codeEl.innerHTML = renderTokens(tokens);
|
|
112
|
+
codeEl.classList.add("velin-syntax-ready");
|
|
113
|
+
codeEl.closest("pre")?.classList.add("velin-syntax-ready");
|
|
114
|
+
codeEl.closest(".velin-code-block")?.classList.add("velin-syntax-ready");
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// core/highlight/highlight.js
|
|
118
|
+
function resolveLanguage(el) {
|
|
119
|
+
const pre = el.tagName === "PRE" ? el : el.closest("pre");
|
|
120
|
+
const code = el.tagName === "CODE" ? el : pre?.querySelector("code") || el;
|
|
121
|
+
const host = pre || code;
|
|
122
|
+
const fromAttr = host.getAttribute("language") || host.getAttribute("data-language") || host.getAttribute("velin-code") || "";
|
|
123
|
+
if (fromAttr && fromAttr !== "true") return normalizeLanguage(fromAttr);
|
|
124
|
+
const cls = code?.className || "";
|
|
125
|
+
const langMatch = cls.match(/\blanguage-([\w-]+)\b/i);
|
|
126
|
+
if (langMatch) return normalizeLanguage(langMatch[1]);
|
|
127
|
+
return "";
|
|
128
|
+
}
|
|
129
|
+
function getSourceText(el) {
|
|
130
|
+
const code = el.tagName === "CODE" ? el : el.querySelector("code");
|
|
131
|
+
const target = code || el;
|
|
132
|
+
if (target.dataset.velinSource != null) return target.dataset.velinSource;
|
|
133
|
+
const html = target.innerHTML;
|
|
134
|
+
if (html && /<|>|&/.test(html)) {
|
|
135
|
+
const ta = document.createElement("textarea");
|
|
136
|
+
ta.innerHTML = html.replace(/<br\s*\/?>/gi, "\n");
|
|
137
|
+
if (ta.value) return ta.value;
|
|
138
|
+
}
|
|
139
|
+
return target.textContent || "";
|
|
140
|
+
}
|
|
141
|
+
async function highlightElement(el, options = {}) {
|
|
142
|
+
if (el.dataset.velinHighlighted === "1") return;
|
|
143
|
+
const pre = el.tagName === "PRE" ? el : el.closest("pre") || el;
|
|
144
|
+
const codeEl = el.tagName === "CODE" ? el : pre.querySelector("code") || document.createElement("code");
|
|
145
|
+
if (!pre.querySelector("code") && codeEl !== el) {
|
|
146
|
+
const text = getSourceText(pre);
|
|
147
|
+
codeEl.textContent = text;
|
|
148
|
+
pre.textContent = "";
|
|
149
|
+
pre.appendChild(codeEl);
|
|
150
|
+
}
|
|
151
|
+
if (!codeEl.dataset.velinSource) {
|
|
152
|
+
codeEl.dataset.velinSource = codeEl.textContent || "";
|
|
153
|
+
}
|
|
154
|
+
const lang = options.language || resolveLanguage(pre);
|
|
155
|
+
if (!lang) return;
|
|
156
|
+
pre.classList.add("velin-syntax-pending");
|
|
157
|
+
codeEl.classList.add("velin-syntax-pending");
|
|
158
|
+
let lexer = options.lexer || getLanguage(lang);
|
|
159
|
+
if (!lexer) lexer = await lazyLoadLanguage(lang);
|
|
160
|
+
if (!lexer) {
|
|
161
|
+
lexer = getLanguage("text") || await lazyLoadLanguage("text");
|
|
162
|
+
}
|
|
163
|
+
const source = codeEl.dataset.velinSource || getSourceText(codeEl) || "";
|
|
164
|
+
if (!lexer) {
|
|
165
|
+
codeEl.textContent = source;
|
|
166
|
+
pre.classList.remove("velin-syntax-pending");
|
|
167
|
+
codeEl.classList.remove("velin-syntax-pending");
|
|
168
|
+
pre.classList.add("velin-syntax-ready");
|
|
169
|
+
codeEl.classList.add("velin-syntax-ready");
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
try {
|
|
173
|
+
const tokens = lexer(source);
|
|
174
|
+
applyHighlight(codeEl, tokens);
|
|
175
|
+
codeEl.dataset.velinHighlighted = "1";
|
|
176
|
+
pre.dataset.velinHighlighted = "1";
|
|
177
|
+
} catch (err) {
|
|
178
|
+
console.warn("[velin-highlight]", lang, err);
|
|
179
|
+
codeEl.textContent = source;
|
|
180
|
+
}
|
|
181
|
+
pre.classList.remove("velin-syntax-pending");
|
|
182
|
+
codeEl.classList.remove("velin-syntax-pending");
|
|
183
|
+
pre.classList.add("velin-syntax-ready");
|
|
184
|
+
codeEl.classList.add("velin-syntax-ready");
|
|
185
|
+
}
|
|
186
|
+
async function highlightAll(root = document) {
|
|
187
|
+
const blocks = root.querySelectorAll(
|
|
188
|
+
'pre[velin-code], pre[data-language], pre code[class*="language-"], [velin-code-block] pre, .velin-doc-example__code pre'
|
|
189
|
+
);
|
|
190
|
+
await Promise.all([...blocks].map((el) => highlightElement(el)));
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// core/highlight/observe.js
|
|
194
|
+
function initHighlight(root = document, options = {}) {
|
|
195
|
+
if (typeof document === "undefined") return () => {
|
|
196
|
+
};
|
|
197
|
+
const selector = options.selector || [
|
|
198
|
+
"pre[velin-code]",
|
|
199
|
+
"pre[language]",
|
|
200
|
+
"pre[data-language]",
|
|
201
|
+
'pre code[class*="language-"]',
|
|
202
|
+
"velin-code-block pre",
|
|
203
|
+
".velin-doc-example__code pre"
|
|
204
|
+
].join(",");
|
|
205
|
+
const nodes = root.querySelectorAll(selector);
|
|
206
|
+
const teardowns = [];
|
|
207
|
+
const reduced = typeof matchMedia !== "undefined" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
208
|
+
for (const node of nodes) {
|
|
209
|
+
const pre = node.tagName === "PRE" ? node : node.closest("pre");
|
|
210
|
+
if (!pre || pre.dataset.velinObserve === "1") continue;
|
|
211
|
+
pre.dataset.velinObserve = "1";
|
|
212
|
+
if (reduced || options.immediate) {
|
|
213
|
+
void highlightElement(pre);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
pre.classList.add("velin-syntax-pending");
|
|
217
|
+
const stop = observeInView(pre, async (el) => {
|
|
218
|
+
await highlightElement(el);
|
|
219
|
+
});
|
|
220
|
+
teardowns.push(stop);
|
|
221
|
+
}
|
|
222
|
+
return () => teardowns.forEach((fn) => fn());
|
|
223
|
+
}
|
|
224
|
+
var observeCodeBlocks = initHighlight;
|
|
225
|
+
|
|
226
|
+
// core/highlight/index.js
|
|
227
|
+
var velinSyntax = {
|
|
228
|
+
highlightElement,
|
|
229
|
+
highlightAll,
|
|
230
|
+
initHighlight,
|
|
231
|
+
observeCodeBlocks,
|
|
232
|
+
registerLanguage,
|
|
233
|
+
lazyLoadLanguage,
|
|
234
|
+
listLanguages
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export {
|
|
238
|
+
normalizeLanguage,
|
|
239
|
+
registerLanguage,
|
|
240
|
+
getLanguage,
|
|
241
|
+
lazyLoadLanguage,
|
|
242
|
+
listLanguages,
|
|
243
|
+
escapeHtml,
|
|
244
|
+
renderTokens,
|
|
245
|
+
applyHighlight,
|
|
246
|
+
resolveLanguage,
|
|
247
|
+
getSourceText,
|
|
248
|
+
highlightElement,
|
|
249
|
+
highlightAll,
|
|
250
|
+
initHighlight,
|
|
251
|
+
observeCodeBlocks,
|
|
252
|
+
velinSyntax
|
|
253
|
+
};
|