@skeletonizer/utils 2.1.13 → 2.1.15
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/utils.mjs +76 -85
- package/dist/utils.umd.js +2 -2
- package/package.json +2 -2
package/dist/utils.mjs
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
throw TypeError(s);
|
|
3
|
-
};
|
|
4
|
-
var y = (s, e, t) => e.has(s) || f("Cannot " + t);
|
|
5
|
-
var n = (s, e, t) => (y(s, e, "read from private field"), t ? t.call(s) : e.get(s)), T = (s, e, t) => e.has(s) ? f("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(s) : e.set(s, t), r = (s, e, t, a) => (y(s, e, "write to private field"), a ? a.call(s, t) : e.set(s, t), t);
|
|
6
|
-
const M = [
|
|
1
|
+
const g = [
|
|
7
2
|
"Lorem",
|
|
8
3
|
"ipsum",
|
|
9
4
|
"dolor",
|
|
@@ -498,8 +493,8 @@ const M = [
|
|
|
498
493
|
"hendrerit",
|
|
499
494
|
"dolor."
|
|
500
495
|
];
|
|
501
|
-
var
|
|
502
|
-
class
|
|
496
|
+
var o = /* @__PURE__ */ ((i) => (i.Text = "text", i.Input = "input", i.Image = "image", i.Video = "video", i.WrapperElement = "wrapper-element", i))(o || {}), p = /* @__PURE__ */ ((i) => (i.PrimaryColor = "rgba(100, 100, 100, .6)", i.SecondaryColor = "rgba(100, 100, 100, .3)", i))(p || {});
|
|
497
|
+
class h {
|
|
503
498
|
static daysInMs(e) {
|
|
504
499
|
return e * 24 * 60 * 60 * 1e3;
|
|
505
500
|
}
|
|
@@ -507,123 +502,119 @@ class v {
|
|
|
507
502
|
return new Date(e.getTime() + Math.random() * (t.getTime() - e.getTime()));
|
|
508
503
|
}
|
|
509
504
|
}
|
|
510
|
-
let
|
|
511
|
-
|
|
512
|
-
class x {
|
|
513
|
-
constructor() {
|
|
514
|
-
T(this, i);
|
|
515
|
-
}
|
|
505
|
+
let v = 0;
|
|
506
|
+
class y {
|
|
516
507
|
get value() {
|
|
517
|
-
return
|
|
508
|
+
return this.#e;
|
|
518
509
|
}
|
|
510
|
+
#e;
|
|
519
511
|
words(e) {
|
|
520
512
|
this.assertType();
|
|
521
|
-
let t = "",
|
|
522
|
-
for (;
|
|
523
|
-
t += this.randomLoremWord() + " ",
|
|
524
|
-
return
|
|
513
|
+
let t = "", s = 0;
|
|
514
|
+
for (; s < e; )
|
|
515
|
+
t += this.randomLoremWord() + " ", s++;
|
|
516
|
+
return this.#e = t.trim(), this;
|
|
525
517
|
}
|
|
526
518
|
paragraphs(e) {
|
|
527
519
|
this.assertType();
|
|
528
|
-
let t = "",
|
|
529
|
-
const
|
|
530
|
-
for (;
|
|
531
|
-
const
|
|
532
|
-
t += this.words(
|
|
533
|
-
`),
|
|
520
|
+
let t = "", s = 0;
|
|
521
|
+
const n = 50;
|
|
522
|
+
for (; s < e; ) {
|
|
523
|
+
const u = n - Math.round(n * Math.random() * 0.2) * (Math.random() < 0.5 ? -1 : 1);
|
|
524
|
+
t += this.words(u).value, s !== e - 1 && (t += `
|
|
525
|
+
`), s++;
|
|
534
526
|
}
|
|
535
|
-
return
|
|
527
|
+
return this.#e = t, this;
|
|
536
528
|
}
|
|
537
529
|
number(e = 0, t = 1e3) {
|
|
538
|
-
return this.assertType(),
|
|
530
|
+
return this.assertType(), this.#e = Math.ceil(Math.random() * (t - e)) + e, this;
|
|
539
531
|
}
|
|
540
532
|
float(e = 0, t = 1e3) {
|
|
541
|
-
return this.assertType(),
|
|
533
|
+
return this.assertType(), this.#e = this.#e ? this.#e + Math.random() : Math.random() * (t - e) + e, this;
|
|
542
534
|
}
|
|
543
535
|
currency(e) {
|
|
544
|
-
return this.assertType(),
|
|
536
|
+
return this.assertType(), this.#e = new Intl.NumberFormat(
|
|
545
537
|
e.locale,
|
|
546
538
|
{ ...e.options, style: "currency", currency: e.currency }
|
|
547
|
-
).format(+
|
|
539
|
+
).format(+this.#e), this;
|
|
548
540
|
}
|
|
549
541
|
multiply(e) {
|
|
550
|
-
return this.assertType(),
|
|
542
|
+
return this.assertType(), this.#e *= e, this;
|
|
551
543
|
}
|
|
552
544
|
date(e = {}) {
|
|
553
545
|
this.assertType();
|
|
554
|
-
let t = e.max ?? /* @__PURE__ */ new Date("2100-01-01"),
|
|
555
|
-
return e.isFuture ?
|
|
546
|
+
let t = e.max ?? /* @__PURE__ */ new Date("2100-01-01"), s = e.min ?? /* @__PURE__ */ new Date("1970-01-01");
|
|
547
|
+
return e.isFuture ? s = new Date(Date.now() + h.daysInMs(1)) : e.isPast && (t = new Date(Date.now() - h.daysInMs(1))), this.#e = h.dateBetween(s, t), this;
|
|
556
548
|
}
|
|
557
549
|
timeOfDay(e = {}) {
|
|
558
|
-
const t =
|
|
550
|
+
const t = this.#e ?? this.date().value;
|
|
559
551
|
this.assertType();
|
|
560
|
-
const
|
|
561
|
-
return
|
|
552
|
+
const s = (e.use12HourFormat ? t.getUTCHours() % 12 : t.getUTCHours()).toString().padStart(2, "0"), n = t.getMinutes().toString().padStart(2, "0"), u = t.getSeconds().toString().padStart(2, "0"), l = this;
|
|
553
|
+
return l.#e = e.showSeconds ? `${s}:${n}:${u}` : `${s}:${n}`, e.showAmPm && (l.#e += t.getUTCHours() >= 12 ? " PM" : " AM"), l;
|
|
562
554
|
}
|
|
563
555
|
uuid() {
|
|
564
|
-
return
|
|
556
|
+
return v++, this.assertType(), this.#e = v, this;
|
|
565
557
|
}
|
|
566
558
|
boolean() {
|
|
567
|
-
return this.assertType(),
|
|
559
|
+
return this.assertType(), this.#e = Math.random() <= 0.5, this;
|
|
568
560
|
}
|
|
569
561
|
symbol(e = 0) {
|
|
570
|
-
return this.assertType(),
|
|
562
|
+
return this.assertType(), this.#e = Symbol(e), this;
|
|
571
563
|
}
|
|
572
564
|
randomItem(e) {
|
|
573
565
|
this.assertType();
|
|
574
566
|
const t = Math.floor(Math.random() * e.length);
|
|
575
|
-
return
|
|
567
|
+
return this.#e = e[t], this;
|
|
576
568
|
}
|
|
577
569
|
prefix(e) {
|
|
578
|
-
return this.assertType(),
|
|
570
|
+
return this.assertType(), this.#e = `${e}${this.#e}`, this;
|
|
579
571
|
}
|
|
580
572
|
suffix(e) {
|
|
581
|
-
return this.assertType(),
|
|
573
|
+
return this.assertType(), this.#e = `${this.#e}${e}`, this;
|
|
582
574
|
}
|
|
583
575
|
identical(e) {
|
|
584
|
-
return this.assertType(),
|
|
576
|
+
return this.assertType(), this.#e = e, this;
|
|
585
577
|
}
|
|
586
578
|
assertType() {
|
|
587
579
|
}
|
|
588
580
|
randomLoremWord() {
|
|
589
|
-
const e = Math.floor(Math.random() *
|
|
590
|
-
return
|
|
581
|
+
const e = Math.floor(Math.random() * g.length);
|
|
582
|
+
return g[e] ?? "lorem";
|
|
591
583
|
}
|
|
592
584
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
class h {
|
|
585
|
+
let T = 0;
|
|
586
|
+
class d {
|
|
596
587
|
constructor(e) {
|
|
597
|
-
this.generator = e, this.uuid =
|
|
588
|
+
this.generator = e, this.uuid = T++, this.viewModel = this.generator(), this.val = d.modelToValue(this.viewModel);
|
|
598
589
|
}
|
|
599
590
|
get value() {
|
|
600
591
|
return this.val;
|
|
601
592
|
}
|
|
602
593
|
static modelToValue(e) {
|
|
603
|
-
if (e instanceof
|
|
594
|
+
if (e instanceof y)
|
|
604
595
|
return e.value;
|
|
605
596
|
if (Array.isArray(e))
|
|
606
597
|
return e.map(this.modelToValue);
|
|
607
598
|
{
|
|
608
599
|
const t = {};
|
|
609
|
-
return Object.keys(e).forEach((
|
|
610
|
-
t[
|
|
611
|
-
e[
|
|
600
|
+
return Object.keys(e).forEach((s) => {
|
|
601
|
+
t[s] = d.modelToValue(
|
|
602
|
+
e[s]
|
|
612
603
|
);
|
|
613
604
|
}), t;
|
|
614
605
|
}
|
|
615
606
|
}
|
|
616
607
|
}
|
|
617
|
-
class
|
|
608
|
+
class M {
|
|
618
609
|
// when accessing skeletonized component properties / methods from within the view, they should be accessed via proxy method
|
|
619
610
|
// this is necessary to ensure:
|
|
620
611
|
// - that all properties / methods accessed from within skeletonized part of the view are a part of skeletonSchema
|
|
621
612
|
// - that typescript understands correct type of each property / method accessed from within the skeletonized part of the view
|
|
622
613
|
proxy(e) {
|
|
623
|
-
return e instanceof
|
|
614
|
+
return e instanceof d ? e.value : e;
|
|
624
615
|
}
|
|
625
616
|
}
|
|
626
|
-
class
|
|
617
|
+
class q {
|
|
627
618
|
constructor() {
|
|
628
619
|
this.config = null, this.viewModels = [];
|
|
629
620
|
}
|
|
@@ -631,18 +622,18 @@ class D {
|
|
|
631
622
|
setupModels() {
|
|
632
623
|
if (this.config) {
|
|
633
624
|
const e = this.config.schemaGenerator;
|
|
634
|
-
this.viewModels = Array.from({ length: this.config.repeat }, () => new
|
|
625
|
+
this.viewModels = Array.from({ length: this.config.repeat }, () => new d(e));
|
|
635
626
|
}
|
|
636
627
|
}
|
|
637
628
|
}
|
|
638
|
-
const
|
|
629
|
+
const r = class r {
|
|
639
630
|
static skeletonizeProjectedTemplate(e, t) {
|
|
640
|
-
const
|
|
631
|
+
const s = t?.primaryColor ?? p.PrimaryColor, n = t?.secondaryColor ?? p.SecondaryColor;
|
|
641
632
|
e.setAttribute(
|
|
642
633
|
"style",
|
|
643
|
-
`--skeletonizer-primary-color: ${
|
|
644
|
-
), Array.from(e.querySelectorAll("*:not(svg, [data-skeletonizer])")).forEach((
|
|
645
|
-
const
|
|
634
|
+
`--skeletonizer-primary-color: ${s}; --skeletonizer-secondary-color: ${n};`
|
|
635
|
+
), Array.from(e.querySelectorAll("*:not(svg, [data-skeletonizer])")).forEach((u) => {
|
|
636
|
+
const l = [
|
|
646
637
|
"br",
|
|
647
638
|
"b",
|
|
648
639
|
"strong",
|
|
@@ -654,51 +645,51 @@ const o = class o {
|
|
|
654
645
|
"ins",
|
|
655
646
|
"sub",
|
|
656
647
|
"sup"
|
|
657
|
-
],
|
|
658
|
-
|
|
659
|
-
switch (
|
|
648
|
+
], c = Array.from(u.childNodes).map((a) => a.nodeName.toLowerCase()).filter((a) => !l.includes(a)), f = c.length > 0 && c.some((a) => a !== c[0]);
|
|
649
|
+
u.childNodes.forEach((a) => {
|
|
650
|
+
switch (a.nodeName.toLowerCase()) {
|
|
660
651
|
case "#text": {
|
|
661
|
-
if (this.assertAs(
|
|
662
|
-
if (
|
|
663
|
-
const
|
|
664
|
-
|
|
665
|
-
|
|
652
|
+
if (this.assertAs(a), a.wholeText.trim())
|
|
653
|
+
if (f) {
|
|
654
|
+
const m = document.createElement("span");
|
|
655
|
+
m.innerText = a.cloneNode().wholeText, m.innerText.length && a.replaceWith(
|
|
656
|
+
r.skeletonizedSpanGenerator(m.innerText, o.Text)
|
|
666
657
|
);
|
|
667
658
|
} else {
|
|
668
|
-
const
|
|
669
|
-
|
|
659
|
+
const m = r.skeletonizedSpanGenerator(u.innerHTML, o.Text);
|
|
660
|
+
u.innerHTML = m.outerHTML;
|
|
670
661
|
}
|
|
671
662
|
break;
|
|
672
663
|
}
|
|
673
664
|
case "input": {
|
|
674
|
-
|
|
665
|
+
a.setAttribute(r.dataAttr, o.Input);
|
|
675
666
|
break;
|
|
676
667
|
}
|
|
677
668
|
case "img": {
|
|
678
|
-
|
|
669
|
+
a.setAttribute(r.dataAttr, o.Image);
|
|
679
670
|
break;
|
|
680
671
|
}
|
|
681
672
|
case "video": {
|
|
682
|
-
|
|
673
|
+
a.setAttribute(r.dataAttr, o.Video);
|
|
683
674
|
break;
|
|
684
675
|
}
|
|
685
676
|
}
|
|
686
677
|
});
|
|
687
|
-
}), e.setAttribute(
|
|
678
|
+
}), e.setAttribute(r.dataAttr, o.WrapperElement);
|
|
688
679
|
}
|
|
689
680
|
static skeletonizedSpanGenerator(e, t) {
|
|
690
|
-
const
|
|
691
|
-
return
|
|
681
|
+
const s = document.createElement("span");
|
|
682
|
+
return s.innerHTML = e, s.setAttribute(r.dataAttr, t), s;
|
|
692
683
|
}
|
|
693
684
|
static assertAs(e) {
|
|
694
685
|
}
|
|
695
686
|
};
|
|
696
|
-
|
|
697
|
-
let
|
|
687
|
+
r.dataAttr = "data-skeletonizer";
|
|
688
|
+
let b = r;
|
|
698
689
|
export {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
690
|
+
d as Schema,
|
|
691
|
+
y as SchemaItem,
|
|
692
|
+
M as SkeletonAbstractComponent,
|
|
693
|
+
q as SkeletonAdapterComponent,
|
|
694
|
+
b as SkeletonDirective
|
|
704
695
|
};
|
package/dist/utils.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
`),
|
|
1
|
+
(function(r,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(r=typeof globalThis<"u"?globalThis:r||self,m(r["@skeletonizer/utils"]={}))})(this,function(r){"use strict";const m=["Lorem","ipsum","dolor","sit","amet,","consectetur","adipiscing","elit.","Mauris","posuere","tincidunt","purus,","id","laoreet","mauris","cursus","nec.","Quisque","id","ante","id","tellus","aliquam","pulvinar","eget","eu","dolor.","Donec","egestas","dapibus","massa,","vel","finibus","lectus","congue","eu.","Morbi","quis","erat","condimentum,","molestie","ex","a,","sollicitudin","metus.","Vestibulum","orci","metus,","sagittis","a","sagittis","a,","varius","id","diam.","Cras","egestas","eros","vestibulum,","tempus","ipsum","pellentesque,","dictum","justo.","Quisque","sed","justo","metus.","Suspendisse","id","felis","vitae","nunc","auctor","tristique","eu","sit","amet","mi.","Ut","luctus","posuere","viverra.","Nunc","sed","augue","a","velit","sodales","iaculis.","Sed","at","arcu","non","massa","hendrerit","scelerisque.","Nunc","commodo","vulputate","vestibulum.","Duis","ut","leo","nisi.","Mauris","dignissim","quis","sem","non","blandit.","Suspendisse","id","elit","eget","leo","efficitur","maximus.","Ut","eu","auctor","ligula.","Nulla","in","leo","luctus,","tempor","justo","vitae,","condimentum","massa.","Quisque","venenatis","elementum","posuere.","Sed","bibendum","bibendum","enim,","in","faucibus","ante.","Aliquam","pretium","sapien","ac","eleifend","suscipit.","Duis","lacinia","justo","quis","diam","elementum,","vitae","fringilla","lectus","faucibus.","Integer","dictum","commodo","diam","a","tempus.","Aenean","elementum","egestas","quam,","eget","feugiat","ligula","imperdiet","vitae.","Morbi","mattis","dui","sed","elementum","mollis.","In","interdum","viverra","urna,","at","scelerisque","sapien.","Sed","molestie","blandit","risus","nec","ornare.","Integer","pharetra","massa","purus,","ut","fringilla","augue","sollicitudin","in.","Pellentesque","eu","leo","pharetra,","hendrerit","lectus","id,","dapibus","ipsum.","Quisque","tincidunt","euismod","venenatis.","Sed","lacus","ex,","pulvinar","at","dui","vitae,","condimentum","rutrum","eros.","Nunc","viverra","cursus","ante,","ac","dapibus","ligula","volutpat","nec.","Integer","commodo","in","tortor","eget","aliquet.","Nam","bibendum","lectus","vitae","ligula","interdum","scelerisque.","Morbi","sit","amet","augue","diam.","Etiam","purus","lorem,","sodales","sed","sodales","ac,","dignissim","a","tellus.","Nunc","vehicula","nibh","in","erat","rhoncus","ullamcorper.","Orci","varius","natoque","penatibus","et","magnis","dis","parturient","montes,","nascetur","ridiculus","mus.","Aliquam","augue","nunc,","fringilla","at","dictum","quis,","luctus","sit","amet","nisl.","Nam","lectus","felis,","egestas","nec","lacinia","non,","auctor","eget","lorem.","Nunc","vel","velit","quis","magna","hendrerit","volutpat","in","nec","leo.","Aenean","tempor","lectus","tortor,","nec","bibendum","elit","aliquam","at.","In","id","libero","tincidunt,","interdum","libero","sit","amet,","gravida","est.","Morbi","ut","ipsum","enim.","Duis","vel","posuere","ante.","Praesent","sollicitudin","lacus","sit","amet","luctus","euismod.","Phasellus","lorem","elit,","auctor","sed","risus","a,","faucibus","tempor","lacus.","Integer","id","tellus","ut","eros","congue","ornare.","Cras","vitae","ornare","sem.","Cras","tincidunt","arcu","efficitur","mauris","molestie,","eu","eleifend","eros","mattis.","Integer","id","diam","mauris.","Duis","suscipit","enim","risus,","non","dignissim","nulla","imperdiet","hendrerit.","Vestibulum","sed","dignissim","erat.","Aliquam","erat","volutpat.","Nunc","mattis","auctor","justo,","non","fringilla","dolor","blandit","a.","Donec","et","velit","tristique","lacus","varius","aliquam.","Praesent","ac","molestie","quam,","vitae","scelerisque","tellus.","Praesent","eleifend","sed","diam","in","gravida.","Donec","tristique","sapien","ante,","in","egestas","diam","porta","ac.","Proin","ac","justo","eleifend,","consequat","ante","vitae,","laoreet","augue.","Mauris","scelerisque","arcu","dolor,","quis","lobortis","risus","pellentesque","eu.","Praesent","in","enim","a","elit","feugiat","dapibus.","Duis","quis","bibendum","mi.","Vestibulum","lacinia,","sem","at","efficitur","volutpat,","velit","ligula","vulputate","nisi,","sit","amet","dapibus","risus","metus","sed","est.","Sed","in","venenatis","ante.","Pellentesque","vel","ipsum","pharetra,","efficitur","quam","ut,","hendrerit","dolor."];var o=(i=>(i.Text="text",i.Input="input",i.Image="image",i.Video="video",i.WrapperElement="wrapper-element",i))(o||{}),p=(i=>(i.PrimaryColor="rgba(100, 100, 100, .6)",i.SecondaryColor="rgba(100, 100, 100, .3)",i))(p||{});class g{static daysInMs(e){return e*24*60*60*1e3}static dateBetween(e,t){return new Date(e.getTime()+Math.random()*(t.getTime()-e.getTime()))}}let f=0;class y{get value(){return this.#e}#e;words(e){this.assertType();let t="",s=0;for(;s<e;)t+=this.randomLoremWord()+" ",s++;return this.#e=t.trim(),this}paragraphs(e){this.assertType();let t="",s=0;const l=50;for(;s<e;){const u=l-Math.round(l*Math.random()*.2)*(Math.random()<.5?-1:1);t+=this.words(u).value,s!==e-1&&(t+=`
|
|
2
|
+
`),s++}return this.#e=t,this}number(e=0,t=1e3){return this.assertType(),this.#e=Math.ceil(Math.random()*(t-e))+e,this}float(e=0,t=1e3){return this.assertType(),this.#e=this.#e?this.#e+Math.random():Math.random()*(t-e)+e,this}currency(e){return this.assertType(),this.#e=new Intl.NumberFormat(e.locale,{...e.options,style:"currency",currency:e.currency}).format(+this.#e),this}multiply(e){return this.assertType(),this.#e*=e,this}date(e={}){this.assertType();let t=e.max??new Date("2100-01-01"),s=e.min??new Date("1970-01-01");return e.isFuture?s=new Date(Date.now()+g.daysInMs(1)):e.isPast&&(t=new Date(Date.now()-g.daysInMs(1))),this.#e=g.dateBetween(s,t),this}timeOfDay(e={}){const t=this.#e??this.date().value;this.assertType();const s=(e.use12HourFormat?t.getUTCHours()%12:t.getUTCHours()).toString().padStart(2,"0"),l=t.getMinutes().toString().padStart(2,"0"),u=t.getSeconds().toString().padStart(2,"0"),c=this;return c.#e=e.showSeconds?`${s}:${l}:${u}`:`${s}:${l}`,e.showAmPm&&(c.#e+=t.getUTCHours()>=12?" PM":" AM"),c}uuid(){return f++,this.assertType(),this.#e=f,this}boolean(){return this.assertType(),this.#e=Math.random()<=.5,this}symbol(e=0){return this.assertType(),this.#e=Symbol(e),this}randomItem(e){this.assertType();const t=Math.floor(Math.random()*e.length);return this.#e=e[t],this}prefix(e){return this.assertType(),this.#e=`${e}${this.#e}`,this}suffix(e){return this.assertType(),this.#e=`${this.#e}${e}`,this}identical(e){return this.assertType(),this.#e=e,this}assertType(){}randomLoremWord(){const e=Math.floor(Math.random()*m.length);return m[e]??"lorem"}}let T=0;class d{constructor(e){this.generator=e,this.uuid=T++,this.viewModel=this.generator(),this.val=d.modelToValue(this.viewModel)}get value(){return this.val}static modelToValue(e){if(e instanceof y)return e.value;if(Array.isArray(e))return e.map(this.modelToValue);{const t={};return Object.keys(e).forEach(s=>{t[s]=d.modelToValue(e[s])}),t}}}class M{proxy(e){return e instanceof d?e.value:e}}class q{constructor(){this.config=null,this.viewModels=[]}setupModels(){if(this.config){const e=this.config.schemaGenerator;this.viewModels=Array.from({length:this.config.repeat},()=>new d(e))}}}const n=class n{static skeletonizeProjectedTemplate(e,t){const s=t?.primaryColor??p.PrimaryColor,l=t?.secondaryColor??p.SecondaryColor;e.setAttribute("style",`--skeletonizer-primary-color: ${s}; --skeletonizer-secondary-color: ${l};`),Array.from(e.querySelectorAll("*:not(svg, [data-skeletonizer])")).forEach(u=>{const c=["br","b","strong","i","em","mark","small","del","ins","sub","sup"],v=Array.from(u.childNodes).map(a=>a.nodeName.toLowerCase()).filter(a=>!c.includes(a)),A=v.length>0&&v.some(a=>a!==v[0]);u.childNodes.forEach(a=>{switch(a.nodeName.toLowerCase()){case"#text":{if(this.assertAs(a),a.wholeText.trim())if(A){const h=document.createElement("span");h.innerText=a.cloneNode().wholeText,h.innerText.length&&a.replaceWith(n.skeletonizedSpanGenerator(h.innerText,o.Text))}else{const h=n.skeletonizedSpanGenerator(u.innerHTML,o.Text);u.innerHTML=h.outerHTML}break}case"input":{a.setAttribute(n.dataAttr,o.Input);break}case"img":{a.setAttribute(n.dataAttr,o.Image);break}case"video":{a.setAttribute(n.dataAttr,o.Video);break}}})}),e.setAttribute(n.dataAttr,o.WrapperElement)}static skeletonizedSpanGenerator(e,t){const s=document.createElement("span");return s.innerHTML=e,s.setAttribute(n.dataAttr,t),s}static assertAs(e){}};n.dataAttr="data-skeletonizer";let b=n;r.Schema=d,r.SchemaItem=y,r.SkeletonAbstractComponent=M,r.SkeletonAdapterComponent=q,r.SkeletonDirective=b,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skeletonizer/utils",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.15",
|
|
4
4
|
"description": "Utils for all skeletonizer packages",
|
|
5
5
|
"author": "Luka Varga",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"vite-plugin-dts": "^4.5.4",
|
|
56
56
|
"vitest": "3.2.4"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "399e4168365d2667b4314b05c72860efceceb5e6"
|
|
59
59
|
}
|