@skeletonizer/vue 0.0.17-alpha.0 → 0.0.18-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.
@@ -1,678 +1,6 @@
1
- import { defineComponent as z, reactive as T, watch as C, resolveDirective as x, openBlock as f, createElementBlock as b, Fragment as I, renderList as N, withDirectives as P, renderSlot as y } from "vue";
2
- var M = (i, e, t) => {
3
- if (!e.has(i))
4
- throw TypeError("Cannot " + t);
5
- }, q = (i, e, t) => (M(i, e, "read from private field"), t ? t.call(i) : e.get(i)), E = (i, e, t) => {
6
- if (e.has(i))
7
- throw TypeError("Cannot add the same private member more than once");
8
- e instanceof WeakSet ? e.add(i) : e.set(i, t);
9
- }, n = (i, e, t, s) => (M(i, e, "write to private field"), s ? s.call(i, t) : e.set(i, t), t);
10
- const k = [
11
- "Lorem",
12
- "ipsum",
13
- "dolor",
14
- "sit",
15
- "amet,",
16
- "consectetur",
17
- "adipiscing",
18
- "elit.",
19
- "Mauris",
20
- "posuere",
21
- "tincidunt",
22
- "purus,",
23
- "id",
24
- "laoreet",
25
- "mauris",
26
- "cursus",
27
- "nec.",
28
- "Quisque",
29
- "id",
30
- "ante",
31
- "id",
32
- "tellus",
33
- "aliquam",
34
- "pulvinar",
35
- "eget",
36
- "eu",
37
- "dolor.",
38
- "Donec",
39
- "egestas",
40
- "dapibus",
41
- "massa,",
42
- "vel",
43
- "finibus",
44
- "lectus",
45
- "congue",
46
- "eu.",
47
- "Morbi",
48
- "quis",
49
- "erat",
50
- "condimentum,",
51
- "molestie",
52
- "ex",
53
- "a,",
54
- "sollicitudin",
55
- "metus.",
56
- "Vestibulum",
57
- "orci",
58
- "metus,",
59
- "sagittis",
60
- "a",
61
- "sagittis",
62
- "a,",
63
- "varius",
64
- "id",
65
- "diam.",
66
- "Cras",
67
- "egestas",
68
- "eros",
69
- "vestibulum,",
70
- "tempus",
71
- "ipsum",
72
- "pellentesque,",
73
- "dictum",
74
- "justo.",
75
- "Quisque",
76
- "sed",
77
- "justo",
78
- "metus.",
79
- "Suspendisse",
80
- "id",
81
- "felis",
82
- "vitae",
83
- "nunc",
84
- "auctor",
85
- "tristique",
86
- "eu",
87
- "sit",
88
- "amet",
89
- "mi.",
90
- "Ut",
91
- "luctus",
92
- "posuere",
93
- "viverra.",
94
- "Nunc",
95
- "sed",
96
- "augue",
97
- "a",
98
- "velit",
99
- "sodales",
100
- "iaculis.",
101
- "Sed",
102
- "at",
103
- "arcu",
104
- "non",
105
- "massa",
106
- "hendrerit",
107
- "scelerisque.",
108
- "Nunc",
109
- "commodo",
110
- "vulputate",
111
- "vestibulum.",
112
- "Duis",
113
- "ut",
114
- "leo",
115
- "nisi.",
116
- "Mauris",
117
- "dignissim",
118
- "quis",
119
- "sem",
120
- "non",
121
- "blandit.",
122
- "Suspendisse",
123
- "id",
124
- "elit",
125
- "eget",
126
- "leo",
127
- "efficitur",
128
- "maximus.",
129
- "Ut",
130
- "eu",
131
- "auctor",
132
- "ligula.",
133
- "Nulla",
134
- "in",
135
- "leo",
136
- "luctus,",
137
- "tempor",
138
- "justo",
139
- "vitae,",
140
- "condimentum",
141
- "massa.",
142
- "Quisque",
143
- "venenatis",
144
- "elementum",
145
- "posuere.",
146
- "Sed",
147
- "bibendum",
148
- "bibendum",
149
- "enim,",
150
- "in",
151
- "faucibus",
152
- "ante.",
153
- "Aliquam",
154
- "pretium",
155
- "sapien",
156
- "ac",
157
- "eleifend",
158
- "suscipit.",
159
- "Duis",
160
- "lacinia",
161
- "justo",
162
- "quis",
163
- "diam",
164
- "elementum,",
165
- "vitae",
166
- "fringilla",
167
- "lectus",
168
- "faucibus.",
169
- "Integer",
170
- "dictum",
171
- "commodo",
172
- "diam",
173
- "a",
174
- "tempus.",
175
- "Aenean",
176
- "elementum",
177
- "egestas",
178
- "quam,",
179
- "eget",
180
- "feugiat",
181
- "ligula",
182
- "imperdiet",
183
- "vitae.",
184
- "Morbi",
185
- "mattis",
186
- "dui",
187
- "sed",
188
- "elementum",
189
- "mollis.",
190
- "In",
191
- "interdum",
192
- "viverra",
193
- "urna,",
194
- "at",
195
- "scelerisque",
196
- "sapien.",
197
- "Sed",
198
- "molestie",
199
- "blandit",
200
- "risus",
201
- "nec",
202
- "ornare.",
203
- "Integer",
204
- "pharetra",
205
- "massa",
206
- "purus,",
207
- "ut",
208
- "fringilla",
209
- "augue",
210
- "sollicitudin",
211
- "in.",
212
- "Pellentesque",
213
- "eu",
214
- "leo",
215
- "pharetra,",
216
- "hendrerit",
217
- "lectus",
218
- "id,",
219
- "dapibus",
220
- "ipsum.",
221
- "Quisque",
222
- "tincidunt",
223
- "euismod",
224
- "venenatis.",
225
- "Sed",
226
- "lacus",
227
- "ex,",
228
- "pulvinar",
229
- "at",
230
- "dui",
231
- "vitae,",
232
- "condimentum",
233
- "rutrum",
234
- "eros.",
235
- "Nunc",
236
- "viverra",
237
- "cursus",
238
- "ante,",
239
- "ac",
240
- "dapibus",
241
- "ligula",
242
- "volutpat",
243
- "nec.",
244
- "Integer",
245
- "commodo",
246
- "in",
247
- "tortor",
248
- "eget",
249
- "aliquet.",
250
- "Nam",
251
- "bibendum",
252
- "lectus",
253
- "vitae",
254
- "ligula",
255
- "interdum",
256
- "scelerisque.",
257
- "Morbi",
258
- "sit",
259
- "amet",
260
- "augue",
261
- "diam.",
262
- "Etiam",
263
- "purus",
264
- "lorem,",
265
- "sodales",
266
- "sed",
267
- "sodales",
268
- "ac,",
269
- "dignissim",
270
- "a",
271
- "tellus.",
272
- "Nunc",
273
- "vehicula",
274
- "nibh",
275
- "in",
276
- "erat",
277
- "rhoncus",
278
- "ullamcorper.",
279
- "Orci",
280
- "varius",
281
- "natoque",
282
- "penatibus",
283
- "et",
284
- "magnis",
285
- "dis",
286
- "parturient",
287
- "montes,",
288
- "nascetur",
289
- "ridiculus",
290
- "mus.",
291
- "Aliquam",
292
- "augue",
293
- "nunc,",
294
- "fringilla",
295
- "at",
296
- "dictum",
297
- "quis,",
298
- "luctus",
299
- "sit",
300
- "amet",
301
- "nisl.",
302
- "Nam",
303
- "lectus",
304
- "felis,",
305
- "egestas",
306
- "nec",
307
- "lacinia",
308
- "non,",
309
- "auctor",
310
- "eget",
311
- "lorem.",
312
- "Nunc",
313
- "vel",
314
- "velit",
315
- "quis",
316
- "magna",
317
- "hendrerit",
318
- "volutpat",
319
- "in",
320
- "nec",
321
- "leo.",
322
- "Aenean",
323
- "tempor",
324
- "lectus",
325
- "tortor,",
326
- "nec",
327
- "bibendum",
328
- "elit",
329
- "aliquam",
330
- "at.",
331
- "In",
332
- "id",
333
- "libero",
334
- "tincidunt,",
335
- "interdum",
336
- "libero",
337
- "sit",
338
- "amet,",
339
- "gravida",
340
- "est.",
341
- "Morbi",
342
- "ut",
343
- "ipsum",
344
- "enim.",
345
- "Duis",
346
- "vel",
347
- "posuere",
348
- "ante.",
349
- "Praesent",
350
- "sollicitudin",
351
- "lacus",
352
- "sit",
353
- "amet",
354
- "luctus",
355
- "euismod.",
356
- "Phasellus",
357
- "lorem",
358
- "elit,",
359
- "auctor",
360
- "sed",
361
- "risus",
362
- "a,",
363
- "faucibus",
364
- "tempor",
365
- "lacus.",
366
- "Integer",
367
- "id",
368
- "tellus",
369
- "ut",
370
- "eros",
371
- "congue",
372
- "ornare.",
373
- "Cras",
374
- "vitae",
375
- "ornare",
376
- "sem.",
377
- "Cras",
378
- "tincidunt",
379
- "arcu",
380
- "efficitur",
381
- "mauris",
382
- "molestie,",
383
- "eu",
384
- "eleifend",
385
- "eros",
386
- "mattis.",
387
- "Integer",
388
- "id",
389
- "diam",
390
- "mauris.",
391
- "Duis",
392
- "suscipit",
393
- "enim",
394
- "risus,",
395
- "non",
396
- "dignissim",
397
- "nulla",
398
- "imperdiet",
399
- "hendrerit.",
400
- "Vestibulum",
401
- "sed",
402
- "dignissim",
403
- "erat.",
404
- "Aliquam",
405
- "erat",
406
- "volutpat.",
407
- "Nunc",
408
- "mattis",
409
- "auctor",
410
- "justo,",
411
- "non",
412
- "fringilla",
413
- "dolor",
414
- "blandit",
415
- "a.",
416
- "Donec",
417
- "et",
418
- "velit",
419
- "tristique",
420
- "lacus",
421
- "varius",
422
- "aliquam.",
423
- "Praesent",
424
- "ac",
425
- "molestie",
426
- "quam,",
427
- "vitae",
428
- "scelerisque",
429
- "tellus.",
430
- "Praesent",
431
- "eleifend",
432
- "sed",
433
- "diam",
434
- "in",
435
- "gravida.",
436
- "Donec",
437
- "tristique",
438
- "sapien",
439
- "ante,",
440
- "in",
441
- "egestas",
442
- "diam",
443
- "porta",
444
- "ac.",
445
- "Proin",
446
- "ac",
447
- "justo",
448
- "eleifend,",
449
- "consequat",
450
- "ante",
451
- "vitae,",
452
- "laoreet",
453
- "augue.",
454
- "Mauris",
455
- "scelerisque",
456
- "arcu",
457
- "dolor,",
458
- "quis",
459
- "lobortis",
460
- "risus",
461
- "pellentesque",
462
- "eu.",
463
- "Praesent",
464
- "in",
465
- "enim",
466
- "a",
467
- "elit",
468
- "feugiat",
469
- "dapibus.",
470
- "Duis",
471
- "quis",
472
- "bibendum",
473
- "mi.",
474
- "Vestibulum",
475
- "lacinia,",
476
- "sem",
477
- "at",
478
- "efficitur",
479
- "volutpat,",
480
- "velit",
481
- "ligula",
482
- "vulputate",
483
- "nisi,",
484
- "sit",
485
- "amet",
486
- "dapibus",
487
- "risus",
488
- "metus",
489
- "sed",
490
- "est.",
491
- "Sed",
492
- "in",
493
- "venenatis",
494
- "ante.",
495
- "Pellentesque",
496
- "vel",
497
- "ipsum",
498
- "pharetra,",
499
- "efficitur",
500
- "quam",
501
- "ut,",
502
- "hendrerit",
503
- "dolor."
504
- ];
505
- var l = /* @__PURE__ */ ((i) => (i.Text = "text", i.Input = "input", i.Image = "image", i.Video = "video", i.WrapperElement = "wrapper-element", i))(l || {}), v = /* @__PURE__ */ ((i) => (i.PrimaryColor = "rgba(100, 100, 100, .6)", i.SecondaryColor = "rgba(100, 100, 100, .3)", i))(v || {});
506
- class g {
507
- static daysInMs(e) {
508
- return e * 24 * 60 * 60 * 1e3;
509
- }
510
- static dateBetween(e, t) {
511
- return new Date(e.getTime() + Math.random() * (t.getTime() - e.getTime()));
512
- }
513
- }
514
- let w = 0;
515
- var r;
516
- class L {
517
- constructor() {
518
- E(this, r, void 0);
519
- }
520
- get value() {
521
- return q(this, r);
522
- }
523
- words(e) {
524
- this.assertType();
525
- let t = "", s = 0;
526
- for (; s < e; )
527
- t += this.randomLoremWord() + " ", s++;
528
- return n(this, r, t.trim()), this;
529
- }
530
- paragraphs(e) {
531
- this.assertType();
532
- let t = "", s = 0;
533
- const c = 50;
534
- for (; s < e; ) {
535
- const u = c - Math.round(c * Math.random() * 0.2) * (Math.random() < 0.5 ? -1 : 1);
536
- t += this.words(u).value, s !== e - 1 && (t += `
537
- `), s++;
538
- }
539
- return n(this, r, t), this;
540
- }
541
- number(e = 0, t = 1e3) {
542
- return this.assertType(), n(this, r, Math.ceil(Math.random() * (t - e)) + e), this;
543
- }
544
- multiply(e) {
545
- return this.assertType(), n(this, r, q(this, r) * e), this;
546
- }
547
- date(e = {}) {
548
- this.assertType();
549
- let t = e.max ?? /* @__PURE__ */ new Date("2100-01-01"), s = e.min ?? /* @__PURE__ */ new Date("1970-01-01");
550
- return e.isFuture ? s = new Date(Date.now() + g.daysInMs(1)) : e.isPast && (t = new Date(Date.now() - g.daysInMs(1))), n(this, r, g.dateBetween(s, t)), this;
551
- }
552
- uuid() {
553
- return w++, this.assertType(), n(this, r, w), this;
554
- }
555
- boolean() {
556
- return this.assertType(), n(this, r, Math.random() <= 0.5), this;
557
- }
558
- symbol(e = 0) {
559
- return this.assertType(), n(this, r, Symbol(e)), this;
560
- }
561
- identical(e) {
562
- return this.assertType(), n(this, r, e), this;
563
- }
564
- assertType() {
565
- }
566
- randomLoremWord() {
567
- const e = Math.floor(Math.random() * k.length);
568
- return k[e] ?? "lorem";
569
- }
570
- }
571
- r = /* @__PURE__ */ new WeakMap();
572
- class p {
573
- constructor(e) {
574
- this.generator = e, this.viewModel = this.generator(), this.val = p.modelToValue(this.viewModel);
575
- }
576
- get value() {
577
- return this.val;
578
- }
579
- static modelToValue(e) {
580
- if (e instanceof L)
581
- return e.value;
582
- if (Array.isArray(e))
583
- return e.map(this.modelToValue);
584
- {
585
- const t = {};
586
- return Object.keys(e).forEach((s) => {
587
- t[s] = p.modelToValue(
588
- e[s]
589
- );
590
- }), t;
591
- }
592
- }
593
- }
594
- class j {
595
- // when accessing skeletonized component properties / methods from within the view, they should be accessed via proxy method
596
- // this is necessary to ensure:
597
- // - that all properties / methods accessed from within skeletonized part of the view are a part of skeletonSchema
598
- // - that typescript understands correct type of each property / method accessed from within the skeletonized part of the view
599
- proxy(e) {
600
- return e instanceof p ? e.value : e;
601
- }
602
- }
603
- class V {
604
- constructor() {
605
- this.config = null, this.viewModels = [];
606
- }
607
- // the method should be called from within specific packages whenever the adapter component's config changes
608
- setupModels() {
609
- if (this.config) {
610
- const e = this.config.schemaGenerator;
611
- this.viewModels = Array.from({ length: this.config.repeat }, () => new p(e));
612
- }
613
- }
614
- }
615
- const S = class o {
616
- static skeletonizeProjectedTemplate(e, t) {
617
- const s = (t == null ? void 0 : t.primaryColor) ?? v.PrimaryColor, c = (t == null ? void 0 : t.secondaryColor) ?? v.SecondaryColor;
618
- e.setAttribute(
619
- "style",
620
- `--skeletonizer-primary-color: ${s}; --skeletonizer-secondary-color: ${c};`
621
- ), Array.from(e.querySelectorAll("*:not(svg, [data-skeletonizer])")).forEach((u) => {
622
- const h = [
623
- "br",
624
- "b",
625
- "strong",
626
- "i",
627
- "em",
628
- "mark",
629
- "small",
630
- "del",
631
- "ins",
632
- "sub",
633
- "sup"
634
- ], m = Array.from(u.childNodes).map((a) => a.nodeName.toLowerCase()).filter((a) => !h.includes(a)), D = m.length > 0 && m.some((a) => a !== m[0]);
635
- u.childNodes.forEach((a) => {
636
- switch (a.nodeName.toLowerCase()) {
637
- case "#text": {
638
- if (this.assertAs(a), a.wholeText.trim())
639
- if (D) {
640
- const d = document.createElement("span");
641
- d.innerText = a.cloneNode().wholeText, d.innerText.length && a.replaceWith(
642
- o.skeletonizedSpanGenerator(d.innerText, l.Text)
643
- );
644
- } else {
645
- const d = o.skeletonizedSpanGenerator(u.innerHTML, l.Text);
646
- u.innerHTML = d.outerHTML;
647
- }
648
- break;
649
- }
650
- case "input": {
651
- a.setAttribute(o.dataAttr, l.Input);
652
- break;
653
- }
654
- case "img": {
655
- a.setAttribute(o.dataAttr, l.Image);
656
- break;
657
- }
658
- case "video": {
659
- a.setAttribute(o.dataAttr, l.Video);
660
- break;
661
- }
662
- }
663
- });
664
- }), e.setAttribute(o.dataAttr, l.WrapperElement);
665
- }
666
- static skeletonizedSpanGenerator(e, t) {
667
- const s = document.createElement("span");
668
- return s.innerHTML = e, s.setAttribute(o.dataAttr, t), s;
669
- }
670
- static assertAs(e) {
671
- }
672
- };
673
- S.dataAttr = "data-skeletonizer";
674
- let W = S;
675
- const B = /* @__PURE__ */ z({
1
+ import { defineComponent as m, reactive as l, watch as S, resolveDirective as u, openBlock as r, createElementBlock as s, Fragment as d, renderList as v, withDirectives as f, renderSlot as i } from "vue";
2
+ import { SkeletonAdapterComponent as h, SkeletonAbstractComponent as w, SkeletonDirective as z } from "@skeletonizer/utils";
3
+ const g = /* @__PURE__ */ m({
676
4
  __name: "SkeletonizerSkeleton",
677
5
  props: {
678
6
  config: {},
@@ -680,46 +8,46 @@ const B = /* @__PURE__ */ z({
680
8
  scope: {},
681
9
  colorSchema: {}
682
10
  },
683
- setup(i) {
684
- const e = i, t = T(new V());
685
- return C(
11
+ setup(n) {
12
+ const e = n, t = l(new h());
13
+ return S(
686
14
  e.config,
687
- (s) => {
688
- t.config = s, t.setupModels();
15
+ (o) => {
16
+ t.config = o, t.setupModels();
689
17
  },
690
18
  { immediate: !0 }
691
- ), (s, c) => {
692
- const u = x("skeletonize");
693
- return s.showSkeleton ? (f(!0), b(I, { key: 0 }, N(t.viewModels, (h, m) => P((f(), b("div", { key: m }, [
694
- y(s.$slots, "default", {
695
- scope: h.value
19
+ ), (o, y) => {
20
+ const a = u("skeletonize");
21
+ return o.showSkeleton ? (r(!0), s(d, { key: 0 }, v(t.viewModels, (k, p) => f((r(), s("div", { key: p }, [
22
+ i(o.$slots, "default", {
23
+ scope: k.value
696
24
  })
697
25
  ])), [
698
- [u, e.colorSchema]
699
- ])), 128)) : y(s.$slots, "default", {
26
+ [a, e.colorSchema]
27
+ ])), 128)) : i(o.$slots, "default", {
700
28
  key: 1,
701
29
  scope: e.scope
702
30
  });
703
31
  };
704
32
  }
705
33
  });
706
- class A extends j {
34
+ class c extends w {
707
35
  constructor(e, t) {
708
36
  super(), this.skeletonConfig = e, this.showSkeleton = t;
709
37
  }
710
38
  static generate(e, t) {
711
- return T(new A(e, t));
39
+ return l(new c(e, t));
712
40
  }
713
41
  }
714
- const H = {
715
- install: (i) => {
716
- i.component("SkeletonizerSkeleton", B), i.directive("skeletonize", (e, t) => {
717
- W.skeletonizeProjectedTemplate(e, t.value);
42
+ const B = {
43
+ install: (n) => {
44
+ n.component("SkeletonizerSkeleton", g), n.directive("skeletonize", (e, t) => {
45
+ z.skeletonizeProjectedTemplate(e, t.value);
718
46
  });
719
47
  }
720
48
  };
721
49
  export {
722
- A as SkeletonizerComponentComposable,
723
- H as SkeletonizerPlugin,
724
- B as SkeletonizerSkeleton
50
+ c as SkeletonizerComponentComposable,
51
+ B as SkeletonizerPlugin,
52
+ g as SkeletonizerSkeleton
725
53
  };
@@ -1,3 +1,2 @@
1
- (function(o,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],r):(o=typeof globalThis<"u"?globalThis:o||self,r(o.SkeletonizerVue={},o.Vue))})(this,function(o,r){"use strict";var y=document.createElement("style");y.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(y);var q=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},w=(i,e,t)=>(q(i,e,"read from private field"),t?t.call(i):e.get(i)),A=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},u=(i,e,t,s)=>(q(i,e,"write to private field"),s?s.call(i,t):e.set(i,t),t);const T=["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 m=(i=>(i.Text="text",i.Input="input",i.Image="image",i.Video="video",i.WrapperElement="wrapper-element",i))(m||{}),v=(i=>(i.PrimaryColor="rgba(100, 100, 100, .6)",i.SecondaryColor="rgba(100, 100, 100, .3)",i))(v||{});class f{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 M=0;var n;class x{constructor(){A(this,n,void 0)}get value(){return w(this,n)}words(e){this.assertType();let t="",s=0;for(;s<e;)t+=this.randomLoremWord()+" ",s++;return u(this,n,t.trim()),this}paragraphs(e){this.assertType();let t="",s=0;const p=50;for(;s<e;){const l=p-Math.round(p*Math.random()*.2)*(Math.random()<.5?-1:1);t+=this.words(l).value,s!==e-1&&(t+=`
3
- `),s++}return u(this,n,t),this}number(e=0,t=1e3){return this.assertType(),u(this,n,Math.ceil(Math.random()*(t-e))+e),this}multiply(e){return this.assertType(),u(this,n,w(this,n)*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()+f.daysInMs(1)):e.isPast&&(t=new Date(Date.now()-f.daysInMs(1))),u(this,n,f.dateBetween(s,t)),this}uuid(){return M++,this.assertType(),u(this,n,M),this}boolean(){return this.assertType(),u(this,n,Math.random()<=.5),this}symbol(e=0){return this.assertType(),u(this,n,Symbol(e)),this}identical(e){return this.assertType(),u(this,n,e),this}assertType(){}randomLoremWord(){const e=Math.floor(Math.random()*T.length);return T[e]??"lorem"}}n=new WeakMap;class d{constructor(e){this.generator=e,this.viewModel=this.generator(),this.val=d.modelToValue(this.viewModel)}get value(){return this.val}static modelToValue(e){if(e instanceof x)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 C{proxy(e){return e instanceof d?e.value:e}}class D{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 S=class c{static skeletonizeProjectedTemplate(e,t){const s=(t==null?void 0:t.primaryColor)??v.PrimaryColor,p=(t==null?void 0:t.secondaryColor)??v.SecondaryColor;e.setAttribute("style",`--skeletonizer-primary-color: ${s}; --skeletonizer-secondary-color: ${p};`),Array.from(e.querySelectorAll("*:not(svg, [data-skeletonizer])")).forEach(l=>{const k=["br","b","strong","i","em","mark","small","del","ins","sub","sup"],h=Array.from(l.childNodes).map(a=>a.nodeName.toLowerCase()).filter(a=>!k.includes(a)),N=h.length>0&&h.some(a=>a!==h[0]);l.childNodes.forEach(a=>{switch(a.nodeName.toLowerCase()){case"#text":{if(this.assertAs(a),a.wholeText.trim())if(N){const g=document.createElement("span");g.innerText=a.cloneNode().wholeText,g.innerText.length&&a.replaceWith(c.skeletonizedSpanGenerator(g.innerText,m.Text))}else{const g=c.skeletonizedSpanGenerator(l.innerHTML,m.Text);l.innerHTML=g.outerHTML}break}case"input":{a.setAttribute(c.dataAttr,m.Input);break}case"img":{a.setAttribute(c.dataAttr,m.Image);break}case"video":{a.setAttribute(c.dataAttr,m.Video);break}}})}),e.setAttribute(c.dataAttr,m.WrapperElement)}static skeletonizedSpanGenerator(e,t){const s=document.createElement("span");return s.innerHTML=e,s.setAttribute(c.dataAttr,t),s}static assertAs(e){}};S.dataAttr="data-skeletonizer";let I=S;const z=r.defineComponent({__name:"SkeletonizerSkeleton",props:{config:{},showSkeleton:{type:Boolean},scope:{},colorSchema:{}},setup(i){const e=i,t=r.reactive(new D);return r.watch(e.config,s=>{t.config=s,t.setupModels()},{immediate:!0}),(s,p)=>{const l=r.resolveDirective("skeletonize");return s.showSkeleton?(r.openBlock(!0),r.createElementBlock(r.Fragment,{key:0},r.renderList(t.viewModels,(k,h)=>r.withDirectives((r.openBlock(),r.createElementBlock("div",{key:h},[r.renderSlot(s.$slots,"default",{scope:k.value})])),[[l,e.colorSchema]])),128)):r.renderSlot(s.$slots,"default",{key:1,scope:e.scope})}}});class b extends C{constructor(e,t){super(),this.skeletonConfig=e,this.showSkeleton=t}static generate(e,t){return r.reactive(new b(e,t))}}const P={install:i=>{i.component("SkeletonizerSkeleton",z),i.directive("skeletonize",(e,t)=>{I.skeletonizeProjectedTemplate(e,t.value)})}};o.SkeletonizerComponentComposable=b,o.SkeletonizerPlugin=P,o.SkeletonizerSkeleton=z,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
1
+ (function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@skeletonizer/utils")):typeof define=="function"&&define.amd?define(["exports","vue","@skeletonizer/utils"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.SkeletonizerVue={},t.Vue,t.SkeletonizerUtils))})(this,function(t,e,l){"use strict";var a=document.createElement("style");a.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(a);const c=e.defineComponent({__name:"SkeletonizerSkeleton",props:{config:{},showSkeleton:{type:Boolean},scope:{},colorSchema:{}},setup(i){const n=i,o=e.reactive(new l.SkeletonAdapterComponent);return e.watch(n.config,r=>{o.config=r,o.setupModels()},{immediate:!0}),(r,u)=>{const d=e.resolveDirective("skeletonize");return r.showSkeleton?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(o.viewModels,(p,m)=>e.withDirectives((e.openBlock(),e.createElementBlock("div",{key:m},[e.renderSlot(r.$slots,"default",{scope:p.value})])),[[d,n.colorSchema]])),128)):e.renderSlot(r.$slots,"default",{key:1,scope:n.scope})}}});class s extends l.SkeletonAbstractComponent{constructor(n,o){super(),this.skeletonConfig=n,this.showSkeleton=o}static generate(n,o){return e.reactive(new s(n,o))}}const k={install:i=>{i.component("SkeletonizerSkeleton",c),i.directive("skeletonize",(n,o)=>{l.SkeletonDirective.skeletonizeProjectedTemplate(n,o.value)})}};t.SkeletonizerComponentComposable=s,t.SkeletonizerPlugin=k,t.SkeletonizerSkeleton=c,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skeletonizer/vue",
3
- "version": "0.0.17-alpha.0",
3
+ "version": "0.0.18-alpha.0",
4
4
  "description": "The way to skeletonize your Vue.js components",
5
5
  "author": "Luka Varga",
6
6
  "license": "MIT",
@@ -78,5 +78,5 @@
78
78
  "**/*.{scss,css}": "stylelint --fix",
79
79
  "**/*.{ts,js,.vue}": "eslint --fix"
80
80
  },
81
- "gitHead": "0515cda9f5aa78ea76f86a2a2f72fc8c04688277"
81
+ "gitHead": "df7b44bcab02f415fbae5d3676de5df2b5011d05"
82
82
  }