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