@skeletonizer/vue 0.0.11-alpha.0 → 0.0.13-alpha.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.
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UnwrapNestedRefs } from 'vue';
|
|
2
|
+
import { SkeletonAbstractComponent, TSchemaConfig } from '@skeletonizer/utils';
|
|
3
|
+
|
|
4
|
+
export declare class SkeletonizerComponentComposable<T extends object> extends SkeletonAbstractComponent<T> {
|
|
5
|
+
skeletonConfig: TSchemaConfig<T>;
|
|
6
|
+
showSkeleton: boolean;
|
|
7
|
+
private constructor();
|
|
8
|
+
static generate<T extends object>(skeletonConfig: TSchemaConfig<T>, showSkeleton: boolean): UnwrapNestedRefs<SkeletonizerComponentComposable<T>>;
|
|
9
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
+
import { SkeletonizerComponentComposable } from './composables/skeletonizer.component.composable';
|
|
1
2
|
import { default as SkeletonizerSkeleton } from './components/SkeletonizerSkeleton.vue';
|
|
2
|
-
import { App } from 'vue';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
install: (app: App) => void;
|
|
6
|
-
};
|
|
7
|
-
export default _default;
|
|
8
|
-
export { SkeletonizerSkeleton };
|
|
4
|
+
export { SkeletonizerSkeleton, SkeletonizerComponentComposable };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
var
|
|
3
|
-
if (!e.has(
|
|
1
|
+
import { defineComponent as y, reactive as g, watch as M, resolveDirective as S, openBlock as m, createElementBlock as c, Fragment as T, renderList as k, withDirectives as D, renderSlot as d } from "vue";
|
|
2
|
+
var f = (s, e, t) => {
|
|
3
|
+
if (!e.has(s))
|
|
4
4
|
throw TypeError("Cannot " + t);
|
|
5
|
-
},
|
|
6
|
-
if (e.has(
|
|
5
|
+
}, p = (s, e, t) => (f(s, e, "read from private field"), t ? t.call(s) : e.get(s)), I = (s, e, t) => {
|
|
6
|
+
if (e.has(s))
|
|
7
7
|
throw TypeError("Cannot add the same private member more than once");
|
|
8
|
-
e instanceof WeakSet ? e.add(
|
|
9
|
-
},
|
|
10
|
-
const
|
|
8
|
+
e instanceof WeakSet ? e.add(s) : e.set(s, t);
|
|
9
|
+
}, u = (s, e, t, i) => (f(s, e, "write to private field"), i ? i.call(s, t) : e.set(s, t), t);
|
|
10
|
+
const h = [
|
|
11
11
|
"Lorem",
|
|
12
12
|
"ipsum",
|
|
13
13
|
"dolor",
|
|
@@ -502,8 +502,7 @@ const T = [
|
|
|
502
502
|
"hendrerit",
|
|
503
503
|
"dolor."
|
|
504
504
|
];
|
|
505
|
-
|
|
506
|
-
class v {
|
|
505
|
+
class l {
|
|
507
506
|
static daysInMs(e) {
|
|
508
507
|
return e * 24 * 60 * 60 * 1e3;
|
|
509
508
|
}
|
|
@@ -511,87 +510,96 @@ class v {
|
|
|
511
510
|
return new Date(e.getTime() + Math.random() * (t.getTime() - e.getTime()));
|
|
512
511
|
}
|
|
513
512
|
}
|
|
514
|
-
let
|
|
515
|
-
var
|
|
516
|
-
class
|
|
513
|
+
let v = 0;
|
|
514
|
+
var a;
|
|
515
|
+
class N {
|
|
517
516
|
constructor() {
|
|
518
|
-
|
|
517
|
+
I(this, a, void 0);
|
|
519
518
|
}
|
|
520
519
|
get value() {
|
|
521
|
-
return
|
|
520
|
+
return p(this, a);
|
|
522
521
|
}
|
|
523
522
|
words(e) {
|
|
524
523
|
this.assertType();
|
|
525
|
-
let t = "",
|
|
526
|
-
for (;
|
|
527
|
-
t += this.randomLoremWord() + " ",
|
|
528
|
-
return
|
|
524
|
+
let t = "", i = 0;
|
|
525
|
+
for (; i < e; )
|
|
526
|
+
t += this.randomLoremWord() + " ", i++;
|
|
527
|
+
return u(this, a, t.trim()), this;
|
|
529
528
|
}
|
|
530
529
|
paragraphs(e) {
|
|
531
530
|
this.assertType();
|
|
532
|
-
let t = "",
|
|
533
|
-
const
|
|
534
|
-
for (;
|
|
535
|
-
const
|
|
536
|
-
t += this.words(
|
|
537
|
-
`),
|
|
531
|
+
let t = "", i = 0;
|
|
532
|
+
const n = 50;
|
|
533
|
+
for (; i < e; ) {
|
|
534
|
+
const o = n - Math.round(n * Math.random() * 0.2) * (Math.random() < 0.5 ? -1 : 1);
|
|
535
|
+
t += this.words(o).value, i !== e - 1 && (t += `
|
|
536
|
+
`), i++;
|
|
538
537
|
}
|
|
539
|
-
return
|
|
538
|
+
return u(this, a, t), this;
|
|
540
539
|
}
|
|
541
540
|
number(e = 0, t = 1e3) {
|
|
542
|
-
return this.assertType(),
|
|
541
|
+
return this.assertType(), u(this, a, Math.ceil(Math.random() * (t - e)) + e), this;
|
|
543
542
|
}
|
|
544
543
|
multiply(e) {
|
|
545
|
-
return this.assertType(),
|
|
544
|
+
return this.assertType(), u(this, a, p(this, a) * e), this;
|
|
546
545
|
}
|
|
547
546
|
date(e = {}) {
|
|
548
547
|
this.assertType();
|
|
549
|
-
let t = e.max ?? /* @__PURE__ */ new Date("2100-01-01"),
|
|
550
|
-
return e.isFuture ?
|
|
548
|
+
let t = e.max ?? /* @__PURE__ */ new Date("2100-01-01"), i = e.min ?? /* @__PURE__ */ new Date("1970-01-01");
|
|
549
|
+
return e.isFuture ? i = new Date(Date.now() + l.daysInMs(1)) : e.isPast && (t = new Date(Date.now() - l.daysInMs(1))), u(this, a, l.dateBetween(i, t)), this;
|
|
551
550
|
}
|
|
552
551
|
uuid() {
|
|
553
|
-
return
|
|
552
|
+
return v++, this.assertType(), u(this, a, v), this;
|
|
554
553
|
}
|
|
555
554
|
boolean() {
|
|
556
|
-
return this.assertType(),
|
|
555
|
+
return this.assertType(), u(this, a, Math.random() <= 0.5), this;
|
|
557
556
|
}
|
|
558
557
|
symbol(e = 0) {
|
|
559
|
-
return this.assertType(),
|
|
558
|
+
return this.assertType(), u(this, a, Symbol(e)), this;
|
|
560
559
|
}
|
|
561
560
|
identical(e) {
|
|
562
|
-
return this.assertType(),
|
|
561
|
+
return this.assertType(), u(this, a, e), this;
|
|
563
562
|
}
|
|
564
563
|
assertType() {
|
|
565
564
|
}
|
|
566
565
|
randomLoremWord() {
|
|
567
|
-
const e = Math.floor(Math.random() *
|
|
568
|
-
return
|
|
566
|
+
const e = Math.floor(Math.random() * h.length);
|
|
567
|
+
return h[e] ?? "lorem";
|
|
569
568
|
}
|
|
570
569
|
}
|
|
571
|
-
|
|
572
|
-
class
|
|
570
|
+
a = /* @__PURE__ */ new WeakMap();
|
|
571
|
+
class r {
|
|
573
572
|
constructor(e) {
|
|
574
|
-
this.generator = e, this.viewModel = this.generator(), this.val =
|
|
573
|
+
this.generator = e, this.viewModel = this.generator(), this.val = r.modelToValue(this.viewModel);
|
|
575
574
|
}
|
|
576
575
|
get value() {
|
|
577
576
|
return this.val;
|
|
578
577
|
}
|
|
579
578
|
static modelToValue(e) {
|
|
580
|
-
if (e instanceof
|
|
579
|
+
if (e instanceof N)
|
|
581
580
|
return e.value;
|
|
582
581
|
if (Array.isArray(e))
|
|
583
582
|
return e.map(this.modelToValue);
|
|
584
583
|
{
|
|
585
584
|
const t = {};
|
|
586
|
-
return Object.keys(e).forEach((
|
|
587
|
-
t[
|
|
588
|
-
e[
|
|
585
|
+
return Object.keys(e).forEach((i) => {
|
|
586
|
+
t[i] = r.modelToValue(
|
|
587
|
+
e[i]
|
|
589
588
|
);
|
|
590
589
|
}), t;
|
|
591
590
|
}
|
|
592
591
|
}
|
|
593
592
|
}
|
|
594
|
-
class
|
|
593
|
+
class P {
|
|
594
|
+
// when accessing skeletonized component properties / methods from within the view, they should be accessed via proxy method
|
|
595
|
+
// this is necessary to ensure:
|
|
596
|
+
// - that all properties / methods accessed from within skeletonized part of the view are a part of skeletonSchema
|
|
597
|
+
// - that typescript understands correct type of each property / method accessed from within the skeletonized part of the view
|
|
598
|
+
proxy(e) {
|
|
599
|
+
return e instanceof r ? e.value : e;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
class A {
|
|
595
603
|
constructor() {
|
|
596
604
|
this.config = null, this.viewModels = [];
|
|
597
605
|
}
|
|
@@ -599,71 +607,11 @@ class L {
|
|
|
599
607
|
setupModels() {
|
|
600
608
|
if (this.config) {
|
|
601
609
|
const e = this.config.schemaGenerator;
|
|
602
|
-
this.viewModels = Array.from({ length: this.config.repeat }, () => new
|
|
610
|
+
this.viewModels = Array.from({ length: this.config.repeat }, () => new r(e));
|
|
603
611
|
}
|
|
604
612
|
}
|
|
605
613
|
}
|
|
606
|
-
const
|
|
607
|
-
static skeletonizeProjectedTemplate(e, t) {
|
|
608
|
-
const s = (t == null ? void 0 : t.primaryColor) ?? g.PrimaryColor, m = (t == null ? void 0 : t.secondaryColor) ?? g.SecondaryColor;
|
|
609
|
-
e.setAttribute(
|
|
610
|
-
"style",
|
|
611
|
-
`--skeletonizer-primary-color: ${s}; --skeletonizer-secondary-color: ${m};`
|
|
612
|
-
), Array.from(e.querySelectorAll("*:not(svg, [data-skeletonizer])")).forEach((u) => {
|
|
613
|
-
const h = [
|
|
614
|
-
"br",
|
|
615
|
-
"b",
|
|
616
|
-
"strong",
|
|
617
|
-
"i",
|
|
618
|
-
"em",
|
|
619
|
-
"mark",
|
|
620
|
-
"small",
|
|
621
|
-
"del",
|
|
622
|
-
"ins",
|
|
623
|
-
"sub",
|
|
624
|
-
"sup"
|
|
625
|
-
], c = Array.from(u.childNodes).map((a) => a.nodeName.toLowerCase()).filter((a) => !h.includes(a)), A = c.length > 0 && c.some((a) => a !== c[0]);
|
|
626
|
-
u.childNodes.forEach((a) => {
|
|
627
|
-
switch (a.nodeName.toLowerCase()) {
|
|
628
|
-
case "#text": {
|
|
629
|
-
if (this.assertAs(a), a.wholeText.trim())
|
|
630
|
-
if (A) {
|
|
631
|
-
const d = document.createElement("span");
|
|
632
|
-
d.innerText = a.cloneNode().wholeText, d.innerText.length && a.replaceWith(
|
|
633
|
-
o.skeletonizedSpanGenerator(d.innerText, l.Text)
|
|
634
|
-
);
|
|
635
|
-
} else {
|
|
636
|
-
const d = o.skeletonizedSpanGenerator(u.innerHTML, l.Text);
|
|
637
|
-
u.innerHTML = d.outerHTML;
|
|
638
|
-
}
|
|
639
|
-
break;
|
|
640
|
-
}
|
|
641
|
-
case "input": {
|
|
642
|
-
a.setAttribute(o.dataAttr, l.Input);
|
|
643
|
-
break;
|
|
644
|
-
}
|
|
645
|
-
case "img": {
|
|
646
|
-
a.setAttribute(o.dataAttr, l.Image);
|
|
647
|
-
break;
|
|
648
|
-
}
|
|
649
|
-
case "video": {
|
|
650
|
-
a.setAttribute(o.dataAttr, l.Video);
|
|
651
|
-
break;
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
});
|
|
655
|
-
}), e.setAttribute(o.dataAttr, l.WrapperElement);
|
|
656
|
-
}
|
|
657
|
-
static skeletonizedSpanGenerator(e, t) {
|
|
658
|
-
const s = document.createElement("span");
|
|
659
|
-
return s.innerHTML = e, s.setAttribute(o.dataAttr, t), s;
|
|
660
|
-
}
|
|
661
|
-
static assertAs(e) {
|
|
662
|
-
}
|
|
663
|
-
};
|
|
664
|
-
M.dataAttr = "data-skeletonizer";
|
|
665
|
-
let j = M;
|
|
666
|
-
const V = /* @__PURE__ */ S({
|
|
614
|
+
const j = /* @__PURE__ */ y({
|
|
667
615
|
__name: "SkeletonizerSkeleton",
|
|
668
616
|
props: {
|
|
669
617
|
config: {},
|
|
@@ -671,36 +619,38 @@ const V = /* @__PURE__ */ S({
|
|
|
671
619
|
scope: {},
|
|
672
620
|
colorSchema: {}
|
|
673
621
|
},
|
|
674
|
-
setup(
|
|
675
|
-
const e =
|
|
676
|
-
return
|
|
622
|
+
setup(s) {
|
|
623
|
+
const e = s, t = g(new A());
|
|
624
|
+
return M(
|
|
677
625
|
e.config,
|
|
678
|
-
(
|
|
679
|
-
t.config =
|
|
626
|
+
(i) => {
|
|
627
|
+
t.config = i, t.setupModels();
|
|
680
628
|
},
|
|
681
629
|
{ immediate: !0 }
|
|
682
|
-
), (
|
|
683
|
-
const
|
|
684
|
-
return
|
|
685
|
-
|
|
686
|
-
scope:
|
|
630
|
+
), (i, n) => {
|
|
631
|
+
const o = S("skeletonize");
|
|
632
|
+
return i.showSkeleton ? (m(!0), c(T, { key: 0 }, k(t.viewModels, (q, w) => D((m(), c("div", { key: w }, [
|
|
633
|
+
d(i.$slots, "default", {
|
|
634
|
+
scope: q.value
|
|
687
635
|
})
|
|
688
636
|
])), [
|
|
689
|
-
[
|
|
690
|
-
])), 128)) :
|
|
637
|
+
[o, e.colorSchema]
|
|
638
|
+
])), 128)) : d(i.$slots, "default", {
|
|
691
639
|
key: 1,
|
|
692
640
|
scope: e.scope
|
|
693
641
|
});
|
|
694
642
|
};
|
|
695
643
|
}
|
|
696
|
-
})
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
});
|
|
644
|
+
});
|
|
645
|
+
class b extends P {
|
|
646
|
+
constructor(e, t) {
|
|
647
|
+
super(), this.skeletonConfig = e, this.showSkeleton = t;
|
|
701
648
|
}
|
|
702
|
-
|
|
649
|
+
static generate(e, t) {
|
|
650
|
+
return g(new b(e, t));
|
|
651
|
+
}
|
|
652
|
+
}
|
|
703
653
|
export {
|
|
704
|
-
|
|
705
|
-
|
|
654
|
+
b as SkeletonizerComponentComposable,
|
|
655
|
+
j as SkeletonizerSkeleton
|
|
706
656
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(u,
|
|
2
|
-
`,document.head.appendChild(
|
|
3
|
-
`),
|
|
1
|
+
(function(u,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(u=typeof globalThis<"u"?globalThis:u||self,a(u.SkeletonizerVue={},u.Vue))})(this,function(u,a){"use strict";var p=document.createElement("style");p.textContent=`[data-skeletonizer=wrapper-element]{--skeletonizer-text-background: rgba(0, 0, 0, .2);display:contents;filter:grayscale(100%);pointer-events:none}[data-skeletonizer=wrapper-element] *{pointer-events:none}[data-skeletonizer=wrapper-element] [data-skeletonizer=text]{animation:text-animation 2s infinite ease-in-out;background:var(--skeletonizer-primary-color);border-radius:50px;color:#0000!important}@keyframes text-animation{0%{background:var(--skeletonizer-primary-color)}50%{background:var(--skeletonizer-secondary-color)}to{background:var(--skeletonizer-primary-color)}}
|
|
2
|
+
`,document.head.appendChild(p);var h=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},g=(s,e,t)=>(h(s,e,"read from private field"),t?t.call(s):e.get(s)),b=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},n=(s,e,t,i)=>(h(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t);const f=["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."];class l{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 v=0;var r;class y{constructor(){b(this,r,void 0)}get value(){return g(this,r)}words(e){this.assertType();let t="",i=0;for(;i<e;)t+=this.randomLoremWord()+" ",i++;return n(this,r,t.trim()),this}paragraphs(e){this.assertType();let t="",i=0;const c=50;for(;i<e;){const d=c-Math.round(c*Math.random()*.2)*(Math.random()<.5?-1:1);t+=this.words(d).value,i!==e-1&&(t+=`
|
|
3
|
+
`),i++}return n(this,r,t),this}number(e=0,t=1e3){return this.assertType(),n(this,r,Math.ceil(Math.random()*(t-e))+e),this}multiply(e){return this.assertType(),n(this,r,g(this,r)*e),this}date(e={}){this.assertType();let t=e.max??new Date("2100-01-01"),i=e.min??new Date("1970-01-01");return e.isFuture?i=new Date(Date.now()+l.daysInMs(1)):e.isPast&&(t=new Date(Date.now()-l.daysInMs(1))),n(this,r,l.dateBetween(i,t)),this}uuid(){return v++,this.assertType(),n(this,r,v),this}boolean(){return this.assertType(),n(this,r,Math.random()<=.5),this}symbol(e=0){return this.assertType(),n(this,r,Symbol(e)),this}identical(e){return this.assertType(),n(this,r,e),this}assertType(){}randomLoremWord(){const e=Math.floor(Math.random()*f.length);return f[e]??"lorem"}}r=new WeakMap;class o{constructor(e){this.generator=e,this.viewModel=this.generator(),this.val=o.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(i=>{t[i]=o.modelToValue(e[i])}),t}}}class k{proxy(e){return e instanceof o?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 o(e))}}}const w=a.defineComponent({__name:"SkeletonizerSkeleton",props:{config:{},showSkeleton:{type:Boolean},scope:{},colorSchema:{}},setup(s){const e=s,t=a.reactive(new q);return a.watch(e.config,i=>{t.config=i,t.setupModels()},{immediate:!0}),(i,c)=>{const d=a.resolveDirective("skeletonize");return i.showSkeleton?(a.openBlock(!0),a.createElementBlock(a.Fragment,{key:0},a.renderList(t.viewModels,(M,S)=>a.withDirectives((a.openBlock(),a.createElementBlock("div",{key:S},[a.renderSlot(i.$slots,"default",{scope:M.value})])),[[d,e.colorSchema]])),128)):a.renderSlot(i.$slots,"default",{key:1,scope:e.scope})}}});class m extends k{constructor(e,t){super(),this.skeletonConfig=e,this.showSkeleton=t}static generate(e,t){return a.reactive(new m(e,t))}}u.SkeletonizerComponentComposable=m,u.SkeletonizerSkeleton=w,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skeletonizer/vue",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13-alpha.0",
|
|
4
4
|
"description": "The way to skeletonize your Vue.js components",
|
|
5
5
|
"author": "Luka Varga",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"module": "./dist/skeletonizer-vue.js",
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
23
24
|
"import": "./dist/skeletonizer-vue.js",
|
|
24
25
|
"require": "./dist/skeletonizer-vue.umd.js"
|
|
25
26
|
}
|
|
@@ -79,5 +80,5 @@
|
|
|
79
80
|
"**/*.{scss,css}": "stylelint --fix",
|
|
80
81
|
"**/*.{ts,js,.vue}": "eslint --fix"
|
|
81
82
|
},
|
|
82
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "bd0b1ba7a8cbb5ca810407d296d27127b9be3dcd"
|
|
83
84
|
}
|