@skeletonizer/vue 0.0.5-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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Luka Varga
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # skeletonizer
2
+
3
+ This template should help get you started developing with Vue 3 in Vite.
4
+
5
+ ## Recommended IDE Setup
6
+
7
+ [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
8
+
9
+ ## Type Support for `.vue` Imports in TS
10
+
11
+ TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
12
+
13
+ If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
14
+
15
+ 1. Disable the built-in TypeScript Extension
16
+ 1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette
17
+ 2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
18
+ 2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
19
+
20
+ ## Customize configuration
21
+
22
+ See [Vite Configuration Reference](https://vitejs.dev/config/).
23
+
24
+ ## Project Setup
25
+
26
+ ```sh
27
+ npm install
28
+ ```
29
+
30
+ ### Compile and Hot-Reload for Development
31
+
32
+ ```sh
33
+ npm run dev
34
+ ```
35
+
36
+ ### Type-Check, Compile and Minify for Production
37
+
38
+ ```sh
39
+ npm run build
40
+ ```
41
+
42
+ ### Run Unit Tests with [Vitest](https://vitest.dev/)
43
+
44
+ ```sh
45
+ npm run test:unit
46
+ ```
package/dist/main.css ADDED
@@ -0,0 +1 @@
1
+ [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)}}
@@ -0,0 +1,706 @@
1
+ import { defineComponent as S, reactive as D, watch as z, resolveDirective as C, openBlock as f, createElementBlock as b, Fragment as I, renderList as N, withDirectives as x, renderSlot as y } from "vue";
2
+ var w = (i, e, t) => {
3
+ if (!e.has(i))
4
+ throw TypeError("Cannot " + t);
5
+ }, q = (i, e, t) => (w(i, e, "read from private field"), t ? t.call(i) : e.get(i)), P = (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) => (w(i, e, "write to private field"), s ? s.call(i, t) : e.set(i, t), t);
10
+ const T = [
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 || {}), g = /* @__PURE__ */ ((i) => (i.PrimaryColor = "rgba(100, 100, 100, .6)", i.SecondaryColor = "rgba(100, 100, 100, .3)", i))(g || {});
506
+ class v {
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 k = 0;
515
+ var r;
516
+ class E {
517
+ constructor() {
518
+ P(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 m = 50;
534
+ for (; s < e; ) {
535
+ const u = m - Math.round(m * 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() + v.daysInMs(1)) : e.isPast && (t = new Date(Date.now() - v.daysInMs(1))), n(this, r, v.dateBetween(s, t)), this;
551
+ }
552
+ uuid() {
553
+ return k++, this.assertType(), n(this, r, k), 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() * T.length);
568
+ return T[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 E)
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 L {
595
+ constructor() {
596
+ this.config = null, this.viewModels = [];
597
+ }
598
+ // the method should be called from within specific packages whenever the adapter component's config changes
599
+ setupModels() {
600
+ if (this.config) {
601
+ const e = this.config.schemaGenerator;
602
+ this.viewModels = Array.from({ length: this.config.repeat }, () => new p(e));
603
+ }
604
+ }
605
+ }
606
+ const M = class o {
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({
667
+ __name: "SkeletonizerSkeleton",
668
+ props: {
669
+ config: {},
670
+ showSkeleton: { type: Boolean },
671
+ scope: {},
672
+ colorSchema: {}
673
+ },
674
+ setup(i) {
675
+ const e = i, t = D(new L());
676
+ return z(
677
+ e.config,
678
+ (s) => {
679
+ t.config = s, t.setupModels();
680
+ },
681
+ { immediate: !0 }
682
+ ), (s, m) => {
683
+ const u = C("skeletonize");
684
+ return s.showSkeleton ? (f(!0), b(I, { key: 0 }, N(t.viewModels, (h, c) => x((f(), b("div", { key: c }, [
685
+ y(s.$slots, "default", {
686
+ scope: h.value
687
+ })
688
+ ])), [
689
+ [u, e.colorSchema]
690
+ ])), 128)) : y(s.$slots, "default", {
691
+ key: 1,
692
+ scope: e.scope
693
+ });
694
+ };
695
+ }
696
+ }), B = {
697
+ install: (i) => {
698
+ i.component("SkeletonizerSkeleton", V), i.directive("skeletonize", (e, t) => {
699
+ j.skeletonizeProjectedTemplate(e, t.value);
700
+ });
701
+ }
702
+ };
703
+ export {
704
+ V as SkeletonizerSkeleton,
705
+ B as default
706
+ };
@@ -0,0 +1,3 @@
1
+ (function(u,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],r):(u=typeof globalThis<"u"?globalThis:u||self,r(u.SkeletonizerVue={},u.Vue))})(this,function(u,r){"use strict";var k=document.createElement("style");k.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(k);var y=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},q=(i,e,t)=>(y(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)},o=(i,e,t,s)=>(y(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 w=0;var n;class z{constructor(){A(this,n,void 0)}get value(){return q(this,n)}words(e){this.assertType();let t="",s=0;for(;s<e;)t+=this.randomLoremWord()+" ",s++;return o(this,n,t.trim()),this}paragraphs(e){this.assertType();let t="",s=0;const d=50;for(;s<e;){const l=d-Math.round(d*Math.random()*.2)*(Math.random()<.5?-1:1);t+=this.words(l).value,s!==e-1&&(t+=`
3
+ `),s++}return o(this,n,t),this}number(e=0,t=1e3){return this.assertType(),o(this,n,Math.ceil(Math.random()*(t-e))+e),this}multiply(e){return this.assertType(),o(this,n,q(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))),o(this,n,f.dateBetween(s,t)),this}uuid(){return w++,this.assertType(),o(this,n,w),this}boolean(){return this.assertType(),o(this,n,Math.random()<=.5),this}symbol(e=0){return this.assertType(),o(this,n,Symbol(e)),this}identical(e){return this.assertType(),o(this,n,e),this}assertType(){}randomLoremWord(){const e=Math.floor(Math.random()*T.length);return T[e]??"lorem"}}n=new WeakMap;class g{constructor(e){this.generator=e,this.viewModel=this.generator(),this.val=g.modelToValue(this.viewModel)}get value(){return this.val}static modelToValue(e){if(e instanceof z)return e.value;if(Array.isArray(e))return e.map(this.modelToValue);{const t={};return Object.keys(e).forEach(s=>{t[s]=g.modelToValue(e[s])}),t}}}class x{constructor(){this.config=null,this.viewModels=[]}setupModels(){if(this.config){const e=this.config.schemaGenerator;this.viewModels=Array.from({length:this.config.repeat},()=>new g(e))}}}const M=class c{static skeletonizeProjectedTemplate(e,t){const s=(t==null?void 0:t.primaryColor)??v.PrimaryColor,d=(t==null?void 0:t.secondaryColor)??v.SecondaryColor;e.setAttribute("style",`--skeletonizer-primary-color: ${s}; --skeletonizer-secondary-color: ${d};`),Array.from(e.querySelectorAll("*:not(svg, [data-skeletonizer])")).forEach(l=>{const b=["br","b","strong","i","em","mark","small","del","ins","sub","sup"],p=Array.from(l.childNodes).map(a=>a.nodeName.toLowerCase()).filter(a=>!b.includes(a)),I=p.length>0&&p.some(a=>a!==p[0]);l.childNodes.forEach(a=>{switch(a.nodeName.toLowerCase()){case"#text":{if(this.assertAs(a),a.wholeText.trim())if(I){const h=document.createElement("span");h.innerText=a.cloneNode().wholeText,h.innerText.length&&a.replaceWith(c.skeletonizedSpanGenerator(h.innerText,m.Text))}else{const h=c.skeletonizedSpanGenerator(l.innerHTML,m.Text);l.innerHTML=h.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){}};M.dataAttr="data-skeletonizer";let C=M;const S=r.defineComponent({__name:"SkeletonizerSkeleton",props:{config:{},showSkeleton:{type:Boolean},scope:{},colorSchema:{}},setup(i){const e=i,t=r.reactive(new x);return r.watch(e.config,s=>{t.config=s,t.setupModels()},{immediate:!0}),(s,d)=>{const l=r.resolveDirective("skeletonize");return s.showSkeleton?(r.openBlock(!0),r.createElementBlock(r.Fragment,{key:0},r.renderList(t.viewModels,(b,p)=>r.withDirectives((r.openBlock(),r.createElementBlock("div",{key:p},[r.renderSlot(s.$slots,"default",{scope:b.value})])),[[l,e.colorSchema]])),128)):r.renderSlot(s.$slots,"default",{key:1,scope:e.scope})}}}),D={install:i=>{i.component("SkeletonizerSkeleton",S),i.directive("skeletonize",(e,t)=>{C.skeletonizeProjectedTemplate(e,t.value)})}};u.SkeletonizerSkeleton=S,u.default=D,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@skeletonizer/vue",
3
+ "version": "0.0.5-alpha.0",
4
+ "description": "The way to skeletonize your Vue.js components",
5
+ "author": "Luka Varga",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/lukaVarga/skeletonizer.git"
10
+ },
11
+ "homepage": "https://github.com/lukaVarga/skeletonizer/tree/master/packages/vue",
12
+ "keywords": [
13
+ "skeleton",
14
+ "Vue.js",
15
+ "skeletonizer",
16
+ "ui",
17
+ "loading"
18
+ ],
19
+ "main": "./dist/skeletonizer-vue.umd.js",
20
+ "module": "./dist/skeletonizer-vue.js",
21
+ "exports": {
22
+ ".": {
23
+ "import": "./dist/skeletonizer-vue.js",
24
+ "require": "./dist/skeletonizer-vue.umd.js"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "scripts": {
34
+ "dev": "vite",
35
+ "build": "vite build",
36
+ "build-watch": "vite build --watch",
37
+ "preview": "vite preview",
38
+ "test": "vitest run",
39
+ "test-browser-run": "vitest --browser.name=chrome",
40
+ "test-watch": "vitest",
41
+ "coverage": "vitest run --coverage",
42
+ "coverage-watch": "vitest --coverage",
43
+ "type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
44
+ "style-lint": "stylelint '**/*.?(css|scss|vue)' --color",
45
+ "style-lintfix": "stylelint '**/*.?(css|scss|vue)' --color --fix",
46
+ "lint": "eslint --ext .ts,.vue,.js src/ && npm run style-lint",
47
+ "lintfix": "npm run style-lintfix && eslint --ext .ts,.vue,.js src/ --fix",
48
+ "lint-staged": "lint-staged"
49
+ },
50
+ "dependencies": {
51
+ "@skeletonizer/utils": "^0.0.5-alpha.0"
52
+ },
53
+ "peerDependencies": {
54
+ "vue": "^3.3.4"
55
+ },
56
+ "devDependencies": {
57
+ "@tsconfig/node18": "^2.0.1",
58
+ "@types/jsdom": "^21.1.6",
59
+ "@types/node": "^20.12.3",
60
+ "@vitejs/plugin-vue": "^5.0.4",
61
+ "@vitest/browser": "^1.4.0",
62
+ "@vue/test-utils": "^2.4.5",
63
+ "@vue/tsconfig": "^0.5.1",
64
+ "eslint-plugin-vue": "^9.24.0",
65
+ "jsdom": "^24.0.0",
66
+ "npm-run-all": "^4.1.5",
67
+ "sass": "^1.72.0",
68
+ "typescript": "^5.4.3",
69
+ "vite": "^5.2.7",
70
+ "vitest": "1.4.0",
71
+ "vue": "^3.4.21",
72
+ "vue-eslint-parser": "^9.4.2",
73
+ "vue-tsc": "^1.8.27",
74
+ "webdriverio": "^8.35.1"
75
+ },
76
+ "lint-staged": {
77
+ "**/*.{scss,css}": "stylelint --fix",
78
+ "**/*.{ts,js,.vue}": "eslint --fix"
79
+ },
80
+ "gitHead": "eef7254cd88a7657d4997055be5c44420d7616b9"
81
+ }