@noirmd/previewer 2.0.1 → 2.0.3
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/dist/NReditor.cjs +1076 -96
- package/dist/NReditor.cjs.map +1 -1
- package/dist/NReditor.d.cts +3 -1
- package/dist/NReditor.d.ts +3 -1
- package/dist/NReditor.js +1076 -96
- package/dist/NReditor.js.map +1 -1
- package/dist/accordion.css +85 -0
- package/dist/carousel.css +121 -0
- package/dist/chat.css +182 -0
- package/dist/countdown.css +83 -0
- package/dist/diff.css +94 -0
- package/dist/editor.css +218 -4
- package/dist/hover3d.css +157 -0
- package/dist/hovergallery.css +110 -0
- package/dist/index.cjs +572 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +572 -4
- package/dist/index.js.map +1 -1
- package/dist/kbd.css +63 -0
- package/dist/modal.css +3 -0
- package/dist/react.cjs +964 -7
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +27 -1
- package/dist/react.d.ts +27 -1
- package/dist/react.js +962 -7
- package/dist/react.js.map +1 -1
- package/dist/richlist.css +110 -0
- package/dist/stat.css +107 -0
- package/dist/vanilla.cjs +572 -4
- package/dist/vanilla.cjs.map +1 -1
- package/dist/vanilla.css +11 -1
- package/dist/vanilla.js +572 -4
- package/dist/vanilla.js.map +1 -1
- package/dist/variables.css +2 -0
- package/dist/vue.cjs +572 -4
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.js +572 -4
- package/dist/vue.js.map +1 -1
- package/editor.css +218 -4
- package/package.json +4 -1
package/dist/vanilla.css
CHANGED
|
@@ -29,4 +29,14 @@
|
|
|
29
29
|
@import './list.css';
|
|
30
30
|
@import './blockquote.css';
|
|
31
31
|
@import './toc.css';
|
|
32
|
-
@import './slide.css';
|
|
32
|
+
@import './slide.css';
|
|
33
|
+
@import './kbd.css';
|
|
34
|
+
@import './accordion.css';
|
|
35
|
+
@import './carousel.css';
|
|
36
|
+
@import './countdown.css';
|
|
37
|
+
@import './diff.css';
|
|
38
|
+
@import './hover3d.css';
|
|
39
|
+
@import './hovergallery.css';
|
|
40
|
+
@import './chat.css';
|
|
41
|
+
@import './richlist.css';
|
|
42
|
+
@import './stat.css';
|
package/dist/vanilla.js
CHANGED
|
@@ -11580,6 +11580,553 @@ var slideDirective = ({
|
|
|
11580
11580
|
};
|
|
11581
11581
|
var slide_default = slideDirective;
|
|
11582
11582
|
|
|
11583
|
+
// vanilla/directives/keys.ts
|
|
11584
|
+
var keysDirective = ({ props, slots }) => {
|
|
11585
|
+
const wrap = document.createElement("div");
|
|
11586
|
+
wrap.className = "nr-keys";
|
|
11587
|
+
if (props.class) wrap.classList.add(...props.class.split(/\s+/).filter(Boolean));
|
|
11588
|
+
if (props.style) wrap.setAttribute("style", props.style);
|
|
11589
|
+
const sizeClass = props.size ? ` nr-kbd--${props.size}` : "";
|
|
11590
|
+
const parts = (slots.default || "").split("+").map((p) => p.trim()).filter(Boolean);
|
|
11591
|
+
parts.forEach((part, i) => {
|
|
11592
|
+
if (i > 0) {
|
|
11593
|
+
const sep = document.createElement("span");
|
|
11594
|
+
sep.className = "nr-keys__sep";
|
|
11595
|
+
sep.textContent = "+";
|
|
11596
|
+
wrap.appendChild(sep);
|
|
11597
|
+
}
|
|
11598
|
+
const kbd = document.createElement("kbd");
|
|
11599
|
+
kbd.className = `nr-kbd${sizeClass}`;
|
|
11600
|
+
kbd.textContent = part;
|
|
11601
|
+
wrap.appendChild(kbd);
|
|
11602
|
+
});
|
|
11603
|
+
return wrap;
|
|
11604
|
+
};
|
|
11605
|
+
var keys_default = keysDirective;
|
|
11606
|
+
|
|
11607
|
+
// vanilla/directives/accordion.ts
|
|
11608
|
+
var accordionCounter = 0;
|
|
11609
|
+
var accordionItemDirective = ({ props, renderSlot }) => {
|
|
11610
|
+
const item = document.createElement("div");
|
|
11611
|
+
item.className = "nr-accordion__item";
|
|
11612
|
+
if (props.class) item.classList.add(...props.class.split(/\s+/).filter(Boolean));
|
|
11613
|
+
if (props.style) item.setAttribute("style", props.style);
|
|
11614
|
+
const input = document.createElement("input");
|
|
11615
|
+
input.type = "radio";
|
|
11616
|
+
input.className = "nr-accordion__input";
|
|
11617
|
+
if (props.checked === "true" || props.checked === "") input.checked = true;
|
|
11618
|
+
if (props.value) input.value = props.value;
|
|
11619
|
+
input.setAttribute("aria-label", props.title || "Accordion item");
|
|
11620
|
+
const title = document.createElement("div");
|
|
11621
|
+
title.className = "nr-accordion__title";
|
|
11622
|
+
title.textContent = props.title || "";
|
|
11623
|
+
const content = document.createElement("div");
|
|
11624
|
+
content.className = "nr-accordion__content";
|
|
11625
|
+
content.appendChild(renderSlot("default"));
|
|
11626
|
+
item.append(input, title, content);
|
|
11627
|
+
return item;
|
|
11628
|
+
};
|
|
11629
|
+
var accordionDirective = ({ props, renderSlot }) => {
|
|
11630
|
+
const wrap = document.createElement("div");
|
|
11631
|
+
wrap.className = "nr-accordion";
|
|
11632
|
+
if (props.class) wrap.classList.add(...props.class.split(/\s+/).filter(Boolean));
|
|
11633
|
+
if (props.style) wrap.setAttribute("style", props.style);
|
|
11634
|
+
wrap.appendChild(renderSlot("default"));
|
|
11635
|
+
const mode = props.mode === "checkbox" ? "checkbox" : "radio";
|
|
11636
|
+
const group = `nr-acc-${++accordionCounter}`;
|
|
11637
|
+
wrap.querySelectorAll(".nr-accordion__input").forEach((input) => {
|
|
11638
|
+
input.type = mode;
|
|
11639
|
+
if (mode === "radio") input.name = group;
|
|
11640
|
+
});
|
|
11641
|
+
return wrap;
|
|
11642
|
+
};
|
|
11643
|
+
var accordion_default = accordionDirective;
|
|
11644
|
+
|
|
11645
|
+
// vanilla/directives/carousel.ts
|
|
11646
|
+
var IMG_RE = /!\[([^\]]*)\]\(([^)]+)\)/g;
|
|
11647
|
+
var carouselDirective = ({ props, slots }) => {
|
|
11648
|
+
const images = [];
|
|
11649
|
+
const raw = slots.default || "";
|
|
11650
|
+
let m;
|
|
11651
|
+
IMG_RE.lastIndex = 0;
|
|
11652
|
+
while ((m = IMG_RE.exec(raw)) !== null) {
|
|
11653
|
+
images.push({ src: m[2].split("#")[0].trim(), alt: m[1].trim() || "carousel image" });
|
|
11654
|
+
}
|
|
11655
|
+
if (images.length === 0) {
|
|
11656
|
+
return document.createDocumentFragment();
|
|
11657
|
+
}
|
|
11658
|
+
const wrap = document.createElement("div");
|
|
11659
|
+
wrap.className = "nr-carousel";
|
|
11660
|
+
wrap.tabIndex = 0;
|
|
11661
|
+
wrap.setAttribute("aria-label", "Image carousel");
|
|
11662
|
+
if (props.class) wrap.classList.add(...props.class.split(/\s+/).filter(Boolean));
|
|
11663
|
+
if (props.style) wrap.setAttribute("style", props.style);
|
|
11664
|
+
if (props.width) wrap.style.width = props.width;
|
|
11665
|
+
if (props.float) {
|
|
11666
|
+
if (props.float === "left" || props.float === "right") {
|
|
11667
|
+
wrap.style.float = props.float;
|
|
11668
|
+
if (!props.width) wrap.style.maxWidth = "50%";
|
|
11669
|
+
wrap.style.marginInlineStart = props.float === "right" ? "1rem" : "";
|
|
11670
|
+
wrap.style.marginInlineEnd = props.float === "left" ? "1rem" : "";
|
|
11671
|
+
} else if (props.float === "center") {
|
|
11672
|
+
wrap.style.marginInline = "auto";
|
|
11673
|
+
}
|
|
11674
|
+
}
|
|
11675
|
+
const viewport = document.createElement("div");
|
|
11676
|
+
viewport.className = "nr-carousel__viewport";
|
|
11677
|
+
if (props.height) viewport.style.height = props.height;
|
|
11678
|
+
if (props.aspect) viewport.style.aspectRatio = props.aspect;
|
|
11679
|
+
const track = document.createElement("div");
|
|
11680
|
+
track.className = "nr-carousel__track";
|
|
11681
|
+
const items = [];
|
|
11682
|
+
for (const img of images) {
|
|
11683
|
+
const item = document.createElement("div");
|
|
11684
|
+
item.className = "nr-carousel__item";
|
|
11685
|
+
const el = document.createElement("img");
|
|
11686
|
+
el.src = img.src;
|
|
11687
|
+
el.alt = img.alt;
|
|
11688
|
+
el.loading = "lazy";
|
|
11689
|
+
item.appendChild(el);
|
|
11690
|
+
track.appendChild(item);
|
|
11691
|
+
items.push(item);
|
|
11692
|
+
}
|
|
11693
|
+
viewport.appendChild(track);
|
|
11694
|
+
wrap.appendChild(viewport);
|
|
11695
|
+
const total = items.length;
|
|
11696
|
+
let index = 0;
|
|
11697
|
+
const goTo = (i) => {
|
|
11698
|
+
index = (i % total + total) % total;
|
|
11699
|
+
track.style.transform = `translateX(-${index * 100}%)`;
|
|
11700
|
+
items.forEach((it, j) => it.classList.toggle("nr-carousel__item--active", j === index));
|
|
11701
|
+
dots.forEach((d, j) => d.classList.toggle("nr-carousel__dot--active", j === index));
|
|
11702
|
+
};
|
|
11703
|
+
const prev = document.createElement("button");
|
|
11704
|
+
prev.className = "nr-carousel__nav nr-carousel__nav--prev";
|
|
11705
|
+
prev.setAttribute("aria-label", "Previous slide");
|
|
11706
|
+
prev.textContent = "\u276E";
|
|
11707
|
+
prev.addEventListener("click", () => goTo(index - 1));
|
|
11708
|
+
const next = document.createElement("button");
|
|
11709
|
+
next.className = "nr-carousel__nav nr-carousel__nav--next";
|
|
11710
|
+
next.setAttribute("aria-label", "Next slide");
|
|
11711
|
+
next.textContent = "\u276F";
|
|
11712
|
+
next.addEventListener("click", () => goTo(index + 1));
|
|
11713
|
+
const dots = [];
|
|
11714
|
+
const dotsBox = document.createElement("div");
|
|
11715
|
+
dotsBox.className = "nr-carousel__dots";
|
|
11716
|
+
images.forEach((_, i) => {
|
|
11717
|
+
const dot = document.createElement("button");
|
|
11718
|
+
dot.className = "nr-carousel__dot";
|
|
11719
|
+
dot.setAttribute("aria-label", `Go to slide ${i + 1}`);
|
|
11720
|
+
dot.addEventListener("click", () => goTo(i));
|
|
11721
|
+
dotsBox.appendChild(dot);
|
|
11722
|
+
dots.push(dot);
|
|
11723
|
+
});
|
|
11724
|
+
wrap.append(prev, next, dotsBox);
|
|
11725
|
+
wrap.addEventListener("keydown", (e) => {
|
|
11726
|
+
if (e.key === "ArrowLeft") {
|
|
11727
|
+
e.preventDefault();
|
|
11728
|
+
goTo(index - 1);
|
|
11729
|
+
} else if (e.key === "ArrowRight") {
|
|
11730
|
+
e.preventDefault();
|
|
11731
|
+
goTo(index + 1);
|
|
11732
|
+
}
|
|
11733
|
+
});
|
|
11734
|
+
goTo(0);
|
|
11735
|
+
return wrap;
|
|
11736
|
+
};
|
|
11737
|
+
var carousel_default = carouselDirective;
|
|
11738
|
+
|
|
11739
|
+
// vanilla/directives/countdown.ts
|
|
11740
|
+
var DEFAULT_LABELS = ["days", "hours", "min", "sec"];
|
|
11741
|
+
var countdownDirective = ({ props }) => {
|
|
11742
|
+
const wrap = document.createElement("div");
|
|
11743
|
+
wrap.className = "nr-countdown";
|
|
11744
|
+
if (props.class) wrap.classList.add(...props.class.split(/\s+/).filter(Boolean));
|
|
11745
|
+
if (props.style) wrap.setAttribute("style", props.style);
|
|
11746
|
+
const labelParts = (props.labels || "").split("|").map((s) => s.trim());
|
|
11747
|
+
const labels = DEFAULT_LABELS.map((label, i) => labelParts[i] || label);
|
|
11748
|
+
const digits = parseInt(props.digits || "2", 10);
|
|
11749
|
+
const targetTime = props.target ? new Date(props.target).getTime() : NaN;
|
|
11750
|
+
const hasTarget = !Number.isNaN(targetTime);
|
|
11751
|
+
const blocks = [];
|
|
11752
|
+
const compute = () => {
|
|
11753
|
+
if (hasTarget) {
|
|
11754
|
+
const diff2 = Math.max(0, targetTime - Date.now());
|
|
11755
|
+
return [
|
|
11756
|
+
Math.floor(diff2 / 864e5),
|
|
11757
|
+
Math.floor(diff2 / 36e5) % 24,
|
|
11758
|
+
Math.floor(diff2 / 6e4) % 60,
|
|
11759
|
+
Math.floor(diff2 / 1e3) % 60
|
|
11760
|
+
];
|
|
11761
|
+
}
|
|
11762
|
+
return [
|
|
11763
|
+
parseInt(props.days || "0", 10),
|
|
11764
|
+
parseInt(props.hours || "0", 10),
|
|
11765
|
+
parseInt(props.min || "0", 10),
|
|
11766
|
+
parseInt(props.sec || "0", 10)
|
|
11767
|
+
];
|
|
11768
|
+
};
|
|
11769
|
+
const render = () => {
|
|
11770
|
+
const values = compute();
|
|
11771
|
+
blocks.forEach((block, i) => {
|
|
11772
|
+
const v = String(values[i]);
|
|
11773
|
+
block.value.style.setProperty("--value", v);
|
|
11774
|
+
block.value.setAttribute("aria-label", v);
|
|
11775
|
+
block.value.textContent = v;
|
|
11776
|
+
});
|
|
11777
|
+
};
|
|
11778
|
+
labels.forEach((label) => {
|
|
11779
|
+
const block = document.createElement("div");
|
|
11780
|
+
block.className = "nr-countdown__block";
|
|
11781
|
+
const value = document.createElement("span");
|
|
11782
|
+
value.className = "nr-countdown__value";
|
|
11783
|
+
value.style.setProperty("--digits", String(digits));
|
|
11784
|
+
value.setAttribute("aria-live", "polite");
|
|
11785
|
+
value.setAttribute("aria-label", "0");
|
|
11786
|
+
value.textContent = "0";
|
|
11787
|
+
const labelEl = document.createElement("span");
|
|
11788
|
+
labelEl.className = "nr-countdown__label";
|
|
11789
|
+
labelEl.textContent = label;
|
|
11790
|
+
block.append(value, labelEl);
|
|
11791
|
+
wrap.appendChild(block);
|
|
11792
|
+
blocks.push({ value });
|
|
11793
|
+
});
|
|
11794
|
+
render();
|
|
11795
|
+
if (hasTarget) setInterval(render, 1e3);
|
|
11796
|
+
return wrap;
|
|
11797
|
+
};
|
|
11798
|
+
var countdown_default = countdownDirective;
|
|
11799
|
+
|
|
11800
|
+
// vanilla/directives/diff.ts
|
|
11801
|
+
var IMG_RE2 = /!\[([^\]]*)\]\(([^)]+)\)/g;
|
|
11802
|
+
var diffDirective = ({ props, slots }) => {
|
|
11803
|
+
let before = (props.before || "").split("#")[0].trim();
|
|
11804
|
+
let after = (props.after || "").split("#")[0].trim();
|
|
11805
|
+
if (!before || !after) {
|
|
11806
|
+
const urls = [];
|
|
11807
|
+
const raw = slots.default || "";
|
|
11808
|
+
let m;
|
|
11809
|
+
IMG_RE2.lastIndex = 0;
|
|
11810
|
+
while ((m = IMG_RE2.exec(raw)) !== null) {
|
|
11811
|
+
urls.push(m[2].split("#")[0].trim());
|
|
11812
|
+
}
|
|
11813
|
+
if (!before && urls.length > 0) before = urls[0];
|
|
11814
|
+
if (!after && urls.length > 1) after = urls[1];
|
|
11815
|
+
}
|
|
11816
|
+
if (!before || !after) {
|
|
11817
|
+
return document.createDocumentFragment();
|
|
11818
|
+
}
|
|
11819
|
+
const figure = document.createElement("figure");
|
|
11820
|
+
figure.className = "nr-diff";
|
|
11821
|
+
figure.tabIndex = 0;
|
|
11822
|
+
figure.setAttribute("aria-label", "Image comparison slider");
|
|
11823
|
+
if (props.class) figure.classList.add(...props.class.split(/\s+/).filter(Boolean));
|
|
11824
|
+
if (props.style) figure.setAttribute("style", props.style);
|
|
11825
|
+
if (props.aspect) figure.style.aspectRatio = props.aspect;
|
|
11826
|
+
if (props.height) figure.style.height = props.height;
|
|
11827
|
+
if (props.width) figure.style.width = props.width;
|
|
11828
|
+
if (props.float) {
|
|
11829
|
+
if (props.float === "left" || props.float === "right") {
|
|
11830
|
+
figure.style.float = props.float;
|
|
11831
|
+
if (!props.width) figure.style.maxWidth = "50%";
|
|
11832
|
+
figure.style.marginInlineStart = props.float === "right" ? "1rem" : "";
|
|
11833
|
+
figure.style.marginInlineEnd = props.float === "left" ? "1rem" : "";
|
|
11834
|
+
} else if (props.float === "center") {
|
|
11835
|
+
figure.style.marginInline = "auto";
|
|
11836
|
+
}
|
|
11837
|
+
}
|
|
11838
|
+
const beforeItem = document.createElement("div");
|
|
11839
|
+
beforeItem.className = "nr-diff__item nr-diff__item--before";
|
|
11840
|
+
beforeItem.setAttribute("role", "img");
|
|
11841
|
+
beforeItem.tabIndex = 0;
|
|
11842
|
+
const beforeImg = document.createElement("img");
|
|
11843
|
+
beforeImg.src = before;
|
|
11844
|
+
beforeImg.alt = "before";
|
|
11845
|
+
beforeItem.appendChild(beforeImg);
|
|
11846
|
+
const afterItem = document.createElement("div");
|
|
11847
|
+
afterItem.className = "nr-diff__item nr-diff__item--after";
|
|
11848
|
+
afterItem.setAttribute("role", "img");
|
|
11849
|
+
const afterImg = document.createElement("img");
|
|
11850
|
+
afterImg.src = after;
|
|
11851
|
+
afterImg.alt = "after";
|
|
11852
|
+
afterItem.appendChild(afterImg);
|
|
11853
|
+
const resizer = document.createElement("div");
|
|
11854
|
+
resizer.className = "nr-diff__resizer";
|
|
11855
|
+
resizer.setAttribute("aria-label", "Drag to compare");
|
|
11856
|
+
resizer.title = "Drag to compare";
|
|
11857
|
+
figure.append(beforeItem, afterItem, resizer);
|
|
11858
|
+
let pos = 50;
|
|
11859
|
+
const applyPos = () => {
|
|
11860
|
+
figure.style.setProperty("--nr-diff-pos", `${pos}%`);
|
|
11861
|
+
};
|
|
11862
|
+
const setPosFromClientX = (clientX) => {
|
|
11863
|
+
const rect = figure.getBoundingClientRect();
|
|
11864
|
+
if (rect.width === 0) return;
|
|
11865
|
+
pos = Math.min(100, Math.max(0, (clientX - rect.left) / rect.width * 100));
|
|
11866
|
+
applyPos();
|
|
11867
|
+
};
|
|
11868
|
+
resizer.addEventListener("pointerdown", (e) => {
|
|
11869
|
+
e.preventDefault();
|
|
11870
|
+
resizer.setPointerCapture(e.pointerId);
|
|
11871
|
+
setPosFromClientX(e.clientX);
|
|
11872
|
+
});
|
|
11873
|
+
resizer.addEventListener("pointermove", (e) => {
|
|
11874
|
+
if (e.buttons & 1) setPosFromClientX(e.clientX);
|
|
11875
|
+
});
|
|
11876
|
+
resizer.addEventListener("pointerup", (e) => {
|
|
11877
|
+
if (resizer.hasPointerCapture(e.pointerId)) {
|
|
11878
|
+
resizer.releasePointerCapture(e.pointerId);
|
|
11879
|
+
}
|
|
11880
|
+
});
|
|
11881
|
+
figure.addEventListener("click", (e) => {
|
|
11882
|
+
if (e.target === resizer) return;
|
|
11883
|
+
setPosFromClientX(e.clientX);
|
|
11884
|
+
});
|
|
11885
|
+
figure.addEventListener("keydown", (e) => {
|
|
11886
|
+
if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;
|
|
11887
|
+
e.preventDefault();
|
|
11888
|
+
pos = Math.min(100, Math.max(0, pos + (e.key === "ArrowRight" ? 5 : -5)));
|
|
11889
|
+
applyPos();
|
|
11890
|
+
});
|
|
11891
|
+
applyPos();
|
|
11892
|
+
return figure;
|
|
11893
|
+
};
|
|
11894
|
+
var diff_default = diffDirective;
|
|
11895
|
+
|
|
11896
|
+
// vanilla/directives/hover3d.ts
|
|
11897
|
+
var hover3dDirective = ({ props, renderSlot }) => {
|
|
11898
|
+
const container = document.createElement("div");
|
|
11899
|
+
container.className = "nr-hover-3d";
|
|
11900
|
+
if (props.class) container.classList.add(...props.class.split(/\s+/).filter(Boolean));
|
|
11901
|
+
if (props.style) container.setAttribute("style", props.style);
|
|
11902
|
+
const stage = document.createElement("div");
|
|
11903
|
+
stage.className = "nr-hover-3d__stage";
|
|
11904
|
+
stage.appendChild(renderSlot("default"));
|
|
11905
|
+
container.appendChild(stage);
|
|
11906
|
+
for (let i = 0; i < 8; i++) {
|
|
11907
|
+
container.appendChild(document.createElement("div"));
|
|
11908
|
+
}
|
|
11909
|
+
return container;
|
|
11910
|
+
};
|
|
11911
|
+
var hover3d_default = hover3dDirective;
|
|
11912
|
+
|
|
11913
|
+
// vanilla/directives/hovergallery.ts
|
|
11914
|
+
var IMG_RE3 = /!\[([^\]]*)\]\(([^)]+)\)/g;
|
|
11915
|
+
var hovergalleryDirective = ({ props, slots }) => {
|
|
11916
|
+
const images = [];
|
|
11917
|
+
const raw = slots.default || "";
|
|
11918
|
+
let m;
|
|
11919
|
+
IMG_RE3.lastIndex = 0;
|
|
11920
|
+
while ((m = IMG_RE3.exec(raw)) !== null) {
|
|
11921
|
+
images.push({ src: m[2].split("#")[0].trim(), alt: m[1].trim() || "gallery image" });
|
|
11922
|
+
}
|
|
11923
|
+
if (images.length === 0) {
|
|
11924
|
+
return document.createDocumentFragment();
|
|
11925
|
+
}
|
|
11926
|
+
const figure = document.createElement("figure");
|
|
11927
|
+
figure.className = "nr-hover-gallery";
|
|
11928
|
+
if (props.aspect) figure.style.aspectRatio = props.aspect;
|
|
11929
|
+
if (props.class) figure.classList.add(...props.class.split(/\s+/).filter(Boolean));
|
|
11930
|
+
if (props.style) figure.setAttribute("style", props.style);
|
|
11931
|
+
for (const img of images) {
|
|
11932
|
+
const el = document.createElement("img");
|
|
11933
|
+
el.src = img.src;
|
|
11934
|
+
el.alt = img.alt;
|
|
11935
|
+
el.loading = "lazy";
|
|
11936
|
+
figure.appendChild(el);
|
|
11937
|
+
}
|
|
11938
|
+
return figure;
|
|
11939
|
+
};
|
|
11940
|
+
var hovergallery_default = hovergalleryDirective;
|
|
11941
|
+
|
|
11942
|
+
// vanilla/directives/chat.ts
|
|
11943
|
+
var chatItemDirective = ({ props, renderSlot }) => {
|
|
11944
|
+
const side = props.side === "end" ? "end" : "start";
|
|
11945
|
+
const wrap = document.createElement("div");
|
|
11946
|
+
wrap.className = `nr-chat nr-chat--${side}`;
|
|
11947
|
+
if (props.class) wrap.classList.add(...props.class.split(/\s+/).filter(Boolean));
|
|
11948
|
+
if (props.style) wrap.setAttribute("style", props.style);
|
|
11949
|
+
const header = document.createElement("div");
|
|
11950
|
+
header.className = "nr-chat__header";
|
|
11951
|
+
if (props.name) {
|
|
11952
|
+
const name = document.createElement("span");
|
|
11953
|
+
name.className = "nr-chat__name";
|
|
11954
|
+
name.textContent = props.name;
|
|
11955
|
+
header.appendChild(name);
|
|
11956
|
+
}
|
|
11957
|
+
if (props.time) {
|
|
11958
|
+
const time = document.createElement("time");
|
|
11959
|
+
time.className = "nr-chat__time";
|
|
11960
|
+
time.textContent = props.time;
|
|
11961
|
+
header.appendChild(time);
|
|
11962
|
+
}
|
|
11963
|
+
if (header.childNodes.length > 0) wrap.appendChild(header);
|
|
11964
|
+
if (props.avatar) {
|
|
11965
|
+
const avatar = document.createElement("div");
|
|
11966
|
+
avatar.className = "nr-chat__avatar";
|
|
11967
|
+
const img = document.createElement("img");
|
|
11968
|
+
img.src = props.avatar;
|
|
11969
|
+
img.alt = props.name || "avatar";
|
|
11970
|
+
avatar.appendChild(img);
|
|
11971
|
+
wrap.appendChild(avatar);
|
|
11972
|
+
}
|
|
11973
|
+
const bubble = document.createElement("div");
|
|
11974
|
+
bubble.className = `nr-chat__bubble${props.color ? ` nr-chat__bubble--${props.color}` : ""}`;
|
|
11975
|
+
bubble.appendChild(renderSlot("default"));
|
|
11976
|
+
wrap.appendChild(bubble);
|
|
11977
|
+
if (props.footer) {
|
|
11978
|
+
const footer = document.createElement("div");
|
|
11979
|
+
footer.className = "nr-chat__footer";
|
|
11980
|
+
footer.textContent = props.footer;
|
|
11981
|
+
wrap.appendChild(footer);
|
|
11982
|
+
}
|
|
11983
|
+
return wrap;
|
|
11984
|
+
};
|
|
11985
|
+
var chatDirective = ({ props, renderSlot }) => {
|
|
11986
|
+
const wrap = document.createElement("div");
|
|
11987
|
+
wrap.className = "nr-chat";
|
|
11988
|
+
if (props.class) wrap.classList.add(...props.class.split(/\s+/).filter(Boolean));
|
|
11989
|
+
if (props.style) wrap.setAttribute("style", props.style);
|
|
11990
|
+
wrap.appendChild(renderSlot("default"));
|
|
11991
|
+
return wrap;
|
|
11992
|
+
};
|
|
11993
|
+
var chat_default = chatDirective;
|
|
11994
|
+
|
|
11995
|
+
// vanilla/directives/events.ts
|
|
11996
|
+
function parseEventProp(eventProp) {
|
|
11997
|
+
if (!eventProp) return [];
|
|
11998
|
+
const bindings = [];
|
|
11999
|
+
for (const part of eventProp.split(";")) {
|
|
12000
|
+
const trimmed = part.trim();
|
|
12001
|
+
if (!trimmed) continue;
|
|
12002
|
+
const idx = trimmed.indexOf(":");
|
|
12003
|
+
if (idx === -1) continue;
|
|
12004
|
+
const eventName = trimmed.slice(0, idx).trim().replace(/^on/i, "");
|
|
12005
|
+
const fnName = trimmed.slice(idx + 1).trim();
|
|
12006
|
+
if (eventName && fnName) bindings.push({ eventName, fnName });
|
|
12007
|
+
}
|
|
12008
|
+
return bindings;
|
|
12009
|
+
}
|
|
12010
|
+
function bindEventProp(el, eventProp) {
|
|
12011
|
+
for (const { eventName, fnName } of parseEventProp(eventProp)) {
|
|
12012
|
+
el.addEventListener(eventName, (e) => {
|
|
12013
|
+
const fn = window[fnName];
|
|
12014
|
+
if (typeof fn === "function") {
|
|
12015
|
+
fn.call(el, e);
|
|
12016
|
+
}
|
|
12017
|
+
});
|
|
12018
|
+
}
|
|
12019
|
+
}
|
|
12020
|
+
|
|
12021
|
+
// vanilla/directives/richlist.ts
|
|
12022
|
+
var richlistItemDirective = ({ props, renderSlot }) => {
|
|
12023
|
+
const li = document.createElement("li");
|
|
12024
|
+
li.className = "nr-richlist__item";
|
|
12025
|
+
if (props.class) li.classList.add(...props.class.split(/\s+/).filter(Boolean));
|
|
12026
|
+
if (props.style) li.setAttribute("style", props.style);
|
|
12027
|
+
if (props.image) {
|
|
12028
|
+
const thumb = document.createElement("div");
|
|
12029
|
+
thumb.className = "nr-richlist__thumb";
|
|
12030
|
+
const img = document.createElement("img");
|
|
12031
|
+
img.src = props.image;
|
|
12032
|
+
img.alt = props.title || "list item";
|
|
12033
|
+
img.loading = "lazy";
|
|
12034
|
+
thumb.appendChild(img);
|
|
12035
|
+
li.appendChild(thumb);
|
|
12036
|
+
}
|
|
12037
|
+
if (props.title || props.subtitle) {
|
|
12038
|
+
const main = document.createElement("div");
|
|
12039
|
+
main.className = "nr-richlist__main";
|
|
12040
|
+
if (props.title) {
|
|
12041
|
+
const title = document.createElement("div");
|
|
12042
|
+
title.className = "nr-richlist__title";
|
|
12043
|
+
title.textContent = props.title;
|
|
12044
|
+
main.appendChild(title);
|
|
12045
|
+
}
|
|
12046
|
+
if (props.subtitle) {
|
|
12047
|
+
const subtitle = document.createElement("div");
|
|
12048
|
+
subtitle.className = "nr-richlist__subtitle";
|
|
12049
|
+
subtitle.textContent = props.subtitle;
|
|
12050
|
+
main.appendChild(subtitle);
|
|
12051
|
+
}
|
|
12052
|
+
li.appendChild(main);
|
|
12053
|
+
}
|
|
12054
|
+
const descFrag = renderSlot("default");
|
|
12055
|
+
if (descFrag.childNodes.length > 0) {
|
|
12056
|
+
const desc = document.createElement("p");
|
|
12057
|
+
desc.className = "nr-richlist__desc";
|
|
12058
|
+
desc.appendChild(descFrag);
|
|
12059
|
+
li.appendChild(desc);
|
|
12060
|
+
}
|
|
12061
|
+
const actions = [
|
|
12062
|
+
{ icon: props.icon, url: props.url, event: props.event },
|
|
12063
|
+
{ icon: props.icon2, url: props.url2, event: props.event2 }
|
|
12064
|
+
].filter((a) => !!a.icon);
|
|
12065
|
+
if (actions.length > 0) {
|
|
12066
|
+
const actionsDiv = document.createElement("div");
|
|
12067
|
+
actionsDiv.className = "nr-richlist__actions";
|
|
12068
|
+
for (const { icon, url, event } of actions) {
|
|
12069
|
+
const btn = document.createElement("button");
|
|
12070
|
+
btn.className = "nr-richlist__action";
|
|
12071
|
+
btn.type = "button";
|
|
12072
|
+
btn.setAttribute("aria-label", icon);
|
|
12073
|
+
btn.appendChild(createIcon(icon));
|
|
12074
|
+
if (event) {
|
|
12075
|
+
bindEventProp(btn, event);
|
|
12076
|
+
} else if (url) {
|
|
12077
|
+
btn.addEventListener("click", () => window.open(url, "_blank"));
|
|
12078
|
+
}
|
|
12079
|
+
actionsDiv.appendChild(btn);
|
|
12080
|
+
}
|
|
12081
|
+
li.appendChild(actionsDiv);
|
|
12082
|
+
}
|
|
12083
|
+
return li;
|
|
12084
|
+
};
|
|
12085
|
+
var richlistDirective = ({ props, renderSlot }) => {
|
|
12086
|
+
const ul = document.createElement("ul");
|
|
12087
|
+
ul.className = "nr-richlist";
|
|
12088
|
+
if (props.class) ul.classList.add(...props.class.split(/\s+/).filter(Boolean));
|
|
12089
|
+
if (props.style) ul.setAttribute("style", props.style);
|
|
12090
|
+
ul.appendChild(renderSlot("default"));
|
|
12091
|
+
return ul;
|
|
12092
|
+
};
|
|
12093
|
+
var richlist_default = richlistDirective;
|
|
12094
|
+
|
|
12095
|
+
// vanilla/directives/stat.ts
|
|
12096
|
+
var statDirective = ({ props }) => {
|
|
12097
|
+
const colorClass = props.color ? ` nr-stat--${props.color}` : "";
|
|
12098
|
+
const stat = document.createElement("div");
|
|
12099
|
+
stat.className = `nr-stat${colorClass}`;
|
|
12100
|
+
if (props.class) stat.classList.add(...props.class.split(/\s+/).filter(Boolean));
|
|
12101
|
+
if (props.style) stat.setAttribute("style", props.style);
|
|
12102
|
+
if (props.icon) {
|
|
12103
|
+
const figure = document.createElement("div");
|
|
12104
|
+
figure.className = "nr-stat__figure";
|
|
12105
|
+
figure.appendChild(createIcon(props.icon));
|
|
12106
|
+
stat.appendChild(figure);
|
|
12107
|
+
}
|
|
12108
|
+
if (props.title) {
|
|
12109
|
+
const title = document.createElement("div");
|
|
12110
|
+
title.className = "nr-stat__title";
|
|
12111
|
+
title.textContent = props.title;
|
|
12112
|
+
stat.appendChild(title);
|
|
12113
|
+
}
|
|
12114
|
+
if (props.value) {
|
|
12115
|
+
const value = document.createElement("div");
|
|
12116
|
+
value.className = "nr-stat__value";
|
|
12117
|
+
value.textContent = props.value;
|
|
12118
|
+
stat.appendChild(value);
|
|
12119
|
+
}
|
|
12120
|
+
if (props.desc) {
|
|
12121
|
+
const desc = document.createElement("div");
|
|
12122
|
+
desc.className = "nr-stat__desc";
|
|
12123
|
+
desc.textContent = props.desc;
|
|
12124
|
+
stat.appendChild(desc);
|
|
12125
|
+
}
|
|
12126
|
+
return stat;
|
|
12127
|
+
};
|
|
12128
|
+
var stat_default = statDirective;
|
|
12129
|
+
|
|
11583
12130
|
// vanilla/directives/index.ts
|
|
11584
12131
|
var directiveRegistry = {
|
|
11585
12132
|
// Admonitions
|
|
@@ -11602,7 +12149,21 @@ var directiveRegistry = {
|
|
|
11602
12149
|
custom: wrapper_default,
|
|
11603
12150
|
raw: wrapper_default,
|
|
11604
12151
|
// Animation
|
|
11605
|
-
slide: slide_default
|
|
12152
|
+
slide: slide_default,
|
|
12153
|
+
// New components
|
|
12154
|
+
keys: keys_default,
|
|
12155
|
+
accordion: accordion_default,
|
|
12156
|
+
"accordion-item": accordionItemDirective,
|
|
12157
|
+
carousel: carousel_default,
|
|
12158
|
+
countdown: countdown_default,
|
|
12159
|
+
diff: diff_default,
|
|
12160
|
+
"hover-3d": hover3d_default,
|
|
12161
|
+
"hover-gallery": hovergallery_default,
|
|
12162
|
+
chat: chat_default,
|
|
12163
|
+
"chat-item": chatItemDirective,
|
|
12164
|
+
richlist: richlist_default,
|
|
12165
|
+
"richlist-item": richlistItemDirective,
|
|
12166
|
+
stat: stat_default
|
|
11606
12167
|
};
|
|
11607
12168
|
var directives_default = directiveRegistry;
|
|
11608
12169
|
|
|
@@ -11657,11 +12218,18 @@ function renderTokensInner(tokens, ctx) {
|
|
|
11657
12218
|
function processElements(elements, ctx, allElements) {
|
|
11658
12219
|
const fragment = document.createDocumentFragment();
|
|
11659
12220
|
let i = 0;
|
|
12221
|
+
const BATCHED_DIRECTIVES = {
|
|
12222
|
+
card: "nr-card-grid",
|
|
12223
|
+
"card-m": "nr-card-grid",
|
|
12224
|
+
"card-b": "nr-card-grid",
|
|
12225
|
+
stat: "nr-stat-grid"
|
|
12226
|
+
};
|
|
12227
|
+
const isBatched = (directive) => !!directive && directive.type === "directive" && Object.prototype.hasOwnProperty.call(BATCHED_DIRECTIVES, directive.directiveType);
|
|
11660
12228
|
while (i < elements.length) {
|
|
11661
12229
|
const el = elements[i];
|
|
11662
|
-
if (
|
|
12230
|
+
if (isBatched(el)) {
|
|
11663
12231
|
const cards = [];
|
|
11664
|
-
while (i < elements.length &&
|
|
12232
|
+
while (i < elements.length && isBatched(elements[i])) {
|
|
11665
12233
|
cards.push(elements[i]);
|
|
11666
12234
|
i++;
|
|
11667
12235
|
}
|
|
@@ -11672,7 +12240,7 @@ function processElements(elements, ctx, allElements) {
|
|
|
11672
12240
|
}
|
|
11673
12241
|
} else {
|
|
11674
12242
|
const grid = document.createElement("div");
|
|
11675
|
-
grid.className =
|
|
12243
|
+
grid.className = BATCHED_DIRECTIVES[cards[0].directiveType];
|
|
11676
12244
|
for (const card of cards) {
|
|
11677
12245
|
const rendered = renderElement(card, ctx, allElements);
|
|
11678
12246
|
if (rendered) grid.appendChild(rendered);
|