@skeletonizer/utils 2.2.5 → 2.4.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/README.md +35 -0
- package/dist/src/components/skeleton.abstract.component.d.ts.map +1 -1
- package/dist/src/components/skeleton.adapter.component.d.ts.map +1 -1
- package/dist/src/constants/enum.constants.d.ts +1 -0
- package/dist/src/constants/enum.constants.d.ts.map +1 -1
- package/dist/src/directives/skeleton.directive.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/models/schema-item.model.d.ts +22 -0
- package/dist/src/models/schema-item.model.d.ts.map +1 -1
- package/dist/src/models/schema-item.model.types.d.ts +4 -0
- package/dist/src/models/schema-item.model.types.d.ts.map +1 -0
- package/dist/src/models/schema.model.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +3 -3
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/spec/transformer.types.spec-d.d.ts +11 -0
- package/dist/src/types/spec/transformer.types.spec-d.d.ts.map +1 -1
- package/dist/src/types/transformer.types.d.ts +6 -1
- package/dist/src/types/transformer.types.d.ts.map +1 -1
- package/dist/utils.mjs +241 -699
- package/dist/utils.umd.js +2 -2
- package/package.json +5 -5
package/dist/utils.mjs
CHANGED
|
@@ -1,700 +1,242 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
"aliquet.",
|
|
241
|
-
"Nam",
|
|
242
|
-
"bibendum",
|
|
243
|
-
"lectus",
|
|
244
|
-
"vitae",
|
|
245
|
-
"ligula",
|
|
246
|
-
"interdum",
|
|
247
|
-
"scelerisque.",
|
|
248
|
-
"Morbi",
|
|
249
|
-
"sit",
|
|
250
|
-
"amet",
|
|
251
|
-
"augue",
|
|
252
|
-
"diam.",
|
|
253
|
-
"Etiam",
|
|
254
|
-
"purus",
|
|
255
|
-
"lorem,",
|
|
256
|
-
"sodales",
|
|
257
|
-
"sed",
|
|
258
|
-
"sodales",
|
|
259
|
-
"ac,",
|
|
260
|
-
"dignissim",
|
|
261
|
-
"a",
|
|
262
|
-
"tellus.",
|
|
263
|
-
"Nunc",
|
|
264
|
-
"vehicula",
|
|
265
|
-
"nibh",
|
|
266
|
-
"in",
|
|
267
|
-
"erat",
|
|
268
|
-
"rhoncus",
|
|
269
|
-
"ullamcorper.",
|
|
270
|
-
"Orci",
|
|
271
|
-
"varius",
|
|
272
|
-
"natoque",
|
|
273
|
-
"penatibus",
|
|
274
|
-
"et",
|
|
275
|
-
"magnis",
|
|
276
|
-
"dis",
|
|
277
|
-
"parturient",
|
|
278
|
-
"montes,",
|
|
279
|
-
"nascetur",
|
|
280
|
-
"ridiculus",
|
|
281
|
-
"mus.",
|
|
282
|
-
"Aliquam",
|
|
283
|
-
"augue",
|
|
284
|
-
"nunc,",
|
|
285
|
-
"fringilla",
|
|
286
|
-
"at",
|
|
287
|
-
"dictum",
|
|
288
|
-
"quis,",
|
|
289
|
-
"luctus",
|
|
290
|
-
"sit",
|
|
291
|
-
"amet",
|
|
292
|
-
"nisl.",
|
|
293
|
-
"Nam",
|
|
294
|
-
"lectus",
|
|
295
|
-
"felis,",
|
|
296
|
-
"egestas",
|
|
297
|
-
"nec",
|
|
298
|
-
"lacinia",
|
|
299
|
-
"non,",
|
|
300
|
-
"auctor",
|
|
301
|
-
"eget",
|
|
302
|
-
"lorem.",
|
|
303
|
-
"Nunc",
|
|
304
|
-
"vel",
|
|
305
|
-
"velit",
|
|
306
|
-
"quis",
|
|
307
|
-
"magna",
|
|
308
|
-
"hendrerit",
|
|
309
|
-
"volutpat",
|
|
310
|
-
"in",
|
|
311
|
-
"nec",
|
|
312
|
-
"leo.",
|
|
313
|
-
"Aenean",
|
|
314
|
-
"tempor",
|
|
315
|
-
"lectus",
|
|
316
|
-
"tortor,",
|
|
317
|
-
"nec",
|
|
318
|
-
"bibendum",
|
|
319
|
-
"elit",
|
|
320
|
-
"aliquam",
|
|
321
|
-
"at.",
|
|
322
|
-
"In",
|
|
323
|
-
"id",
|
|
324
|
-
"libero",
|
|
325
|
-
"tincidunt,",
|
|
326
|
-
"interdum",
|
|
327
|
-
"libero",
|
|
328
|
-
"sit",
|
|
329
|
-
"amet,",
|
|
330
|
-
"gravida",
|
|
331
|
-
"est.",
|
|
332
|
-
"Morbi",
|
|
333
|
-
"ut",
|
|
334
|
-
"ipsum",
|
|
335
|
-
"enim.",
|
|
336
|
-
"Duis",
|
|
337
|
-
"vel",
|
|
338
|
-
"posuere",
|
|
339
|
-
"ante.",
|
|
340
|
-
"Praesent",
|
|
341
|
-
"sollicitudin",
|
|
342
|
-
"lacus",
|
|
343
|
-
"sit",
|
|
344
|
-
"amet",
|
|
345
|
-
"luctus",
|
|
346
|
-
"euismod.",
|
|
347
|
-
"Phasellus",
|
|
348
|
-
"lorem",
|
|
349
|
-
"elit,",
|
|
350
|
-
"auctor",
|
|
351
|
-
"sed",
|
|
352
|
-
"risus",
|
|
353
|
-
"a,",
|
|
354
|
-
"faucibus",
|
|
355
|
-
"tempor",
|
|
356
|
-
"lacus.",
|
|
357
|
-
"Integer",
|
|
358
|
-
"id",
|
|
359
|
-
"tellus",
|
|
360
|
-
"ut",
|
|
361
|
-
"eros",
|
|
362
|
-
"congue",
|
|
363
|
-
"ornare.",
|
|
364
|
-
"Cras",
|
|
365
|
-
"vitae",
|
|
366
|
-
"ornare",
|
|
367
|
-
"sem.",
|
|
368
|
-
"Cras",
|
|
369
|
-
"tincidunt",
|
|
370
|
-
"arcu",
|
|
371
|
-
"efficitur",
|
|
372
|
-
"mauris",
|
|
373
|
-
"molestie,",
|
|
374
|
-
"eu",
|
|
375
|
-
"eleifend",
|
|
376
|
-
"eros",
|
|
377
|
-
"mattis.",
|
|
378
|
-
"Integer",
|
|
379
|
-
"id",
|
|
380
|
-
"diam",
|
|
381
|
-
"mauris.",
|
|
382
|
-
"Duis",
|
|
383
|
-
"suscipit",
|
|
384
|
-
"enim",
|
|
385
|
-
"risus,",
|
|
386
|
-
"non",
|
|
387
|
-
"dignissim",
|
|
388
|
-
"nulla",
|
|
389
|
-
"imperdiet",
|
|
390
|
-
"hendrerit.",
|
|
391
|
-
"Vestibulum",
|
|
392
|
-
"sed",
|
|
393
|
-
"dignissim",
|
|
394
|
-
"erat.",
|
|
395
|
-
"Aliquam",
|
|
396
|
-
"erat",
|
|
397
|
-
"volutpat.",
|
|
398
|
-
"Nunc",
|
|
399
|
-
"mattis",
|
|
400
|
-
"auctor",
|
|
401
|
-
"justo,",
|
|
402
|
-
"non",
|
|
403
|
-
"fringilla",
|
|
404
|
-
"dolor",
|
|
405
|
-
"blandit",
|
|
406
|
-
"a.",
|
|
407
|
-
"Donec",
|
|
408
|
-
"et",
|
|
409
|
-
"velit",
|
|
410
|
-
"tristique",
|
|
411
|
-
"lacus",
|
|
412
|
-
"varius",
|
|
413
|
-
"aliquam.",
|
|
414
|
-
"Praesent",
|
|
415
|
-
"ac",
|
|
416
|
-
"molestie",
|
|
417
|
-
"quam,",
|
|
418
|
-
"vitae",
|
|
419
|
-
"scelerisque",
|
|
420
|
-
"tellus.",
|
|
421
|
-
"Praesent",
|
|
422
|
-
"eleifend",
|
|
423
|
-
"sed",
|
|
424
|
-
"diam",
|
|
425
|
-
"in",
|
|
426
|
-
"gravida.",
|
|
427
|
-
"Donec",
|
|
428
|
-
"tristique",
|
|
429
|
-
"sapien",
|
|
430
|
-
"ante,",
|
|
431
|
-
"in",
|
|
432
|
-
"egestas",
|
|
433
|
-
"diam",
|
|
434
|
-
"porta",
|
|
435
|
-
"ac.",
|
|
436
|
-
"Proin",
|
|
437
|
-
"ac",
|
|
438
|
-
"justo",
|
|
439
|
-
"eleifend,",
|
|
440
|
-
"consequat",
|
|
441
|
-
"ante",
|
|
442
|
-
"vitae,",
|
|
443
|
-
"laoreet",
|
|
444
|
-
"augue.",
|
|
445
|
-
"Mauris",
|
|
446
|
-
"scelerisque",
|
|
447
|
-
"arcu",
|
|
448
|
-
"dolor,",
|
|
449
|
-
"quis",
|
|
450
|
-
"lobortis",
|
|
451
|
-
"risus",
|
|
452
|
-
"pellentesque",
|
|
453
|
-
"eu.",
|
|
454
|
-
"Praesent",
|
|
455
|
-
"in",
|
|
456
|
-
"enim",
|
|
457
|
-
"a",
|
|
458
|
-
"elit",
|
|
459
|
-
"feugiat",
|
|
460
|
-
"dapibus.",
|
|
461
|
-
"Duis",
|
|
462
|
-
"quis",
|
|
463
|
-
"bibendum",
|
|
464
|
-
"mi.",
|
|
465
|
-
"Vestibulum",
|
|
466
|
-
"lacinia,",
|
|
467
|
-
"sem",
|
|
468
|
-
"at",
|
|
469
|
-
"efficitur",
|
|
470
|
-
"volutpat,",
|
|
471
|
-
"velit",
|
|
472
|
-
"ligula",
|
|
473
|
-
"vulputate",
|
|
474
|
-
"nisi,",
|
|
475
|
-
"sit",
|
|
476
|
-
"amet",
|
|
477
|
-
"dapibus",
|
|
478
|
-
"risus",
|
|
479
|
-
"metus",
|
|
480
|
-
"sed",
|
|
481
|
-
"est.",
|
|
482
|
-
"Sed",
|
|
483
|
-
"in",
|
|
484
|
-
"venenatis",
|
|
485
|
-
"ante.",
|
|
486
|
-
"Pellentesque",
|
|
487
|
-
"vel",
|
|
488
|
-
"ipsum",
|
|
489
|
-
"pharetra,",
|
|
490
|
-
"efficitur",
|
|
491
|
-
"quam",
|
|
492
|
-
"ut,",
|
|
493
|
-
"hendrerit",
|
|
494
|
-
"dolor."
|
|
495
|
-
];
|
|
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 {
|
|
498
|
-
static daysInMs(e) {
|
|
499
|
-
return e * 24 * 60 * 60 * 1e3;
|
|
500
|
-
}
|
|
501
|
-
static dateBetween(e, t) {
|
|
502
|
-
return new Date(e.getTime() + Math.random() * (t.getTime() - e.getTime()));
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
let v = 0;
|
|
506
|
-
class y {
|
|
507
|
-
get value() {
|
|
508
|
-
return this.#e;
|
|
509
|
-
}
|
|
510
|
-
#e;
|
|
511
|
-
words(e) {
|
|
512
|
-
this.assertType();
|
|
513
|
-
let t = "", s = 0;
|
|
514
|
-
for (; s < e; )
|
|
515
|
-
t += this.randomLoremWord() + " ", s++;
|
|
516
|
-
return this.#e = t.trim(), this;
|
|
517
|
-
}
|
|
518
|
-
paragraphs(e) {
|
|
519
|
-
this.assertType();
|
|
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++;
|
|
526
|
-
}
|
|
527
|
-
return this.#e = t, this;
|
|
528
|
-
}
|
|
529
|
-
number(e = 0, t = 1e3) {
|
|
530
|
-
return this.assertType(), this.#e = Math.ceil(Math.random() * (t - e)) + e, this;
|
|
531
|
-
}
|
|
532
|
-
float(e = 0, t = 1e3) {
|
|
533
|
-
return this.assertType(), this.#e = this.#e ? this.#e + Math.random() : Math.random() * (t - e) + e, this;
|
|
534
|
-
}
|
|
535
|
-
currency(e) {
|
|
536
|
-
return this.assertType(), this.#e = new Intl.NumberFormat(
|
|
537
|
-
e.locale,
|
|
538
|
-
{ ...e.options, style: "currency", currency: e.currency }
|
|
539
|
-
).format(+this.#e), this;
|
|
540
|
-
}
|
|
541
|
-
multiply(e) {
|
|
542
|
-
return this.assertType(), this.#e *= e, this;
|
|
543
|
-
}
|
|
544
|
-
date(e = {}) {
|
|
545
|
-
this.assertType();
|
|
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;
|
|
548
|
-
}
|
|
549
|
-
timeOfDay(e = {}) {
|
|
550
|
-
const t = this.#e ?? this.date().value;
|
|
551
|
-
this.assertType();
|
|
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;
|
|
554
|
-
}
|
|
555
|
-
uuid() {
|
|
556
|
-
return v++, this.assertType(), this.#e = v, this;
|
|
557
|
-
}
|
|
558
|
-
boolean() {
|
|
559
|
-
return this.assertType(), this.#e = Math.random() <= 0.5, this;
|
|
560
|
-
}
|
|
561
|
-
symbol(e = 0) {
|
|
562
|
-
return this.assertType(), this.#e = Symbol(e), this;
|
|
563
|
-
}
|
|
564
|
-
randomItem(e) {
|
|
565
|
-
this.assertType();
|
|
566
|
-
const t = Math.floor(Math.random() * e.length);
|
|
567
|
-
return this.#e = e[t], this;
|
|
568
|
-
}
|
|
569
|
-
prefix(e) {
|
|
570
|
-
return this.assertType(), this.#e = `${e}${this.#e}`, this;
|
|
571
|
-
}
|
|
572
|
-
suffix(e) {
|
|
573
|
-
return this.assertType(), this.#e = `${this.#e}${e}`, this;
|
|
574
|
-
}
|
|
575
|
-
identical(e) {
|
|
576
|
-
return this.assertType(), this.#e = e, this;
|
|
577
|
-
}
|
|
578
|
-
assertType() {
|
|
579
|
-
}
|
|
580
|
-
randomLoremWord() {
|
|
581
|
-
const e = Math.floor(Math.random() * g.length);
|
|
582
|
-
return g[e] ?? "lorem";
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
let T = 0;
|
|
586
|
-
class d {
|
|
587
|
-
constructor(e) {
|
|
588
|
-
this.generator = e, this.uuid = T++, this.viewModel = this.generator(), this.val = d.modelToValue(this.viewModel);
|
|
589
|
-
}
|
|
590
|
-
get value() {
|
|
591
|
-
return this.val;
|
|
592
|
-
}
|
|
593
|
-
static modelToValue(e) {
|
|
594
|
-
if (e instanceof y)
|
|
595
|
-
return e.value;
|
|
596
|
-
if (Array.isArray(e))
|
|
597
|
-
return e.map(this.modelToValue);
|
|
598
|
-
{
|
|
599
|
-
const t = {};
|
|
600
|
-
return Object.keys(e).forEach((s) => {
|
|
601
|
-
t[s] = d.modelToValue(
|
|
602
|
-
e[s]
|
|
603
|
-
);
|
|
604
|
-
}), t;
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
class M {
|
|
609
|
-
// when accessing skeletonized component properties / methods from within the view, they should be accessed via proxy method
|
|
610
|
-
// this is necessary to ensure:
|
|
611
|
-
// - that all properties / methods accessed from within skeletonized part of the view are a part of skeletonSchema
|
|
612
|
-
// - that typescript understands correct type of each property / method accessed from within the skeletonized part of the view
|
|
613
|
-
proxy(e) {
|
|
614
|
-
return e instanceof d ? e.value : e;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
class q {
|
|
618
|
-
constructor() {
|
|
619
|
-
this.config = null, this.viewModels = [];
|
|
620
|
-
}
|
|
621
|
-
// the method should be called from within specific packages whenever the adapter component's config changes
|
|
622
|
-
setupModels() {
|
|
623
|
-
if (this.config) {
|
|
624
|
-
const e = this.config.schemaGenerator;
|
|
625
|
-
this.viewModels = Array.from({ length: this.config.repeat }, () => new d(e));
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
const r = class r {
|
|
630
|
-
static skeletonizeProjectedTemplate(e, t) {
|
|
631
|
-
if (!this.isBrowser())
|
|
632
|
-
return;
|
|
633
|
-
const s = t?.primaryColor ?? p.PrimaryColor, n = t?.secondaryColor ?? p.SecondaryColor;
|
|
634
|
-
e.setAttribute(
|
|
635
|
-
"style",
|
|
636
|
-
`--skeletonizer-primary-color: ${s}; --skeletonizer-secondary-color: ${n};`
|
|
637
|
-
), Array.from(e.querySelectorAll("*:not(svg, [data-skeletonizer])")).forEach((u) => {
|
|
638
|
-
const l = [
|
|
639
|
-
"br",
|
|
640
|
-
"b",
|
|
641
|
-
"strong",
|
|
642
|
-
"i",
|
|
643
|
-
"em",
|
|
644
|
-
"mark",
|
|
645
|
-
"small",
|
|
646
|
-
"del",
|
|
647
|
-
"ins",
|
|
648
|
-
"sub",
|
|
649
|
-
"sup"
|
|
650
|
-
], 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]);
|
|
651
|
-
u.childNodes.forEach((a) => {
|
|
652
|
-
switch (a.nodeName.toLowerCase()) {
|
|
653
|
-
case "#text": {
|
|
654
|
-
if (this.assertAs(a), a.wholeText.trim())
|
|
655
|
-
if (f) {
|
|
656
|
-
const m = document.createElement("span");
|
|
657
|
-
m.innerText = a.cloneNode().wholeText, m.innerText.length && a.replaceWith(
|
|
658
|
-
r.skeletonizedSpanGenerator(m.innerText, o.Text)
|
|
659
|
-
);
|
|
660
|
-
} else {
|
|
661
|
-
const m = r.skeletonizedSpanGenerator(u.innerHTML, o.Text);
|
|
662
|
-
u.innerHTML = m.outerHTML;
|
|
663
|
-
}
|
|
664
|
-
break;
|
|
665
|
-
}
|
|
666
|
-
case "input": {
|
|
667
|
-
a.setAttribute(r.dataAttr, o.Input);
|
|
668
|
-
break;
|
|
669
|
-
}
|
|
670
|
-
case "img": {
|
|
671
|
-
a.setAttribute(r.dataAttr, o.Image);
|
|
672
|
-
break;
|
|
673
|
-
}
|
|
674
|
-
case "video": {
|
|
675
|
-
a.setAttribute(r.dataAttr, o.Video);
|
|
676
|
-
break;
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
});
|
|
680
|
-
}), e.setAttribute(r.dataAttr, o.WrapperElement);
|
|
681
|
-
}
|
|
682
|
-
static skeletonizedSpanGenerator(e, t) {
|
|
683
|
-
const s = document.createElement("span");
|
|
684
|
-
return s.innerHTML = e, s.setAttribute(r.dataAttr, t), s;
|
|
685
|
-
}
|
|
686
|
-
static isBrowser() {
|
|
687
|
-
return typeof document < "u";
|
|
688
|
-
}
|
|
689
|
-
static assertAs(e) {
|
|
690
|
-
}
|
|
691
|
-
};
|
|
692
|
-
r.dataAttr = "data-skeletonizer";
|
|
693
|
-
let b = r;
|
|
694
|
-
export {
|
|
695
|
-
d as Schema,
|
|
696
|
-
y as SchemaItem,
|
|
697
|
-
M as SkeletonAbstractComponent,
|
|
698
|
-
q as SkeletonAdapterComponent,
|
|
699
|
-
b as SkeletonDirective
|
|
1
|
+
//#region src/constants/text.constants.ts
|
|
2
|
+
var e = /* @__PURE__ */ "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.".split("("), t = /* @__PURE__ */ function(e) {
|
|
3
|
+
return e.Text = "text", e.Input = "input", e.Select = "select", e.Image = "image", e.Video = "video", e.WrapperElement = "wrapper-element", e;
|
|
4
|
+
}({}), n = /* @__PURE__ */ function(e) {
|
|
5
|
+
return e.PrimaryColor = "rgba(100, 100, 100, .6)", e.SecondaryColor = "rgba(100, 100, 100, .3)", e;
|
|
6
|
+
}({}), r = class {
|
|
7
|
+
static daysInMs(e) {
|
|
8
|
+
return e * 24 * 60 * 60 * 1e3;
|
|
9
|
+
}
|
|
10
|
+
static dateBetween(e, t) {
|
|
11
|
+
return new Date(e.getTime() + Math.random() * (t.getTime() - e.getTime()));
|
|
12
|
+
}
|
|
13
|
+
}, i = 0, a = class t {
|
|
14
|
+
get value() {
|
|
15
|
+
return this.#e;
|
|
16
|
+
}
|
|
17
|
+
#e;
|
|
18
|
+
words(e) {
|
|
19
|
+
this.assertType();
|
|
20
|
+
let t = "", n = 0;
|
|
21
|
+
for (; n < e;) t += this.randomLoremWord() + " ", n++;
|
|
22
|
+
return this.#e = t.trim(), this;
|
|
23
|
+
}
|
|
24
|
+
paragraphs(e) {
|
|
25
|
+
this.assertType();
|
|
26
|
+
let t = "", n = 0;
|
|
27
|
+
for (; n < e;) {
|
|
28
|
+
let r = 50 - Math.round(50 * Math.random() * .2) * (Math.random() < .5 ? -1 : 1);
|
|
29
|
+
t += this.words(r).value, n !== e - 1 && (t += "\n"), n++;
|
|
30
|
+
}
|
|
31
|
+
return this.#e = t, this;
|
|
32
|
+
}
|
|
33
|
+
number(e = 0, t = 1e3) {
|
|
34
|
+
return this.assertType(), this.#e = Math.ceil(Math.random() * (t - e)) + e, this;
|
|
35
|
+
}
|
|
36
|
+
float(e = 0, t = 1e3) {
|
|
37
|
+
return this.assertType(), this.#e = this.#e ? this.#e + Math.random() : Math.random() * (t - e) + e, this;
|
|
38
|
+
}
|
|
39
|
+
currency(e) {
|
|
40
|
+
return this.assertType(), this.#e = new Intl.NumberFormat(e.locale, {
|
|
41
|
+
...e.options,
|
|
42
|
+
style: "currency",
|
|
43
|
+
currency: e.currency
|
|
44
|
+
}).format(+this.#e), this;
|
|
45
|
+
}
|
|
46
|
+
multiply(e) {
|
|
47
|
+
return this.assertType(), this.#e *= e, this;
|
|
48
|
+
}
|
|
49
|
+
date(e = {}) {
|
|
50
|
+
this.assertType();
|
|
51
|
+
let t = e.max ?? /* @__PURE__ */ new Date("2100-01-01"), n = e.min ?? /* @__PURE__ */ new Date("1970-01-01");
|
|
52
|
+
return e.isFuture ? n = new Date(Date.now() + r.daysInMs(1)) : e.isPast && (t = new Date(Date.now() - r.daysInMs(1))), this.#e = r.dateBetween(n, t), this;
|
|
53
|
+
}
|
|
54
|
+
stringify() {
|
|
55
|
+
let e = this.#e;
|
|
56
|
+
this.assertType();
|
|
57
|
+
let t = this;
|
|
58
|
+
return t.#e = e.toString(), t;
|
|
59
|
+
}
|
|
60
|
+
format(e) {
|
|
61
|
+
let t = this.#e ?? this.date().value;
|
|
62
|
+
this.assertType();
|
|
63
|
+
let n = t.getUTCFullYear().toString(), r = (t.getUTCMonth() + 1).toString().padStart(2, "0"), i = t.getUTCDate().toString().padStart(2, "0"), a = t.getUTCHours().toString().padStart(2, "0"), o = (t.getUTCHours() % 12 || 12).toString().padStart(2, "0"), s = t.getUTCMinutes().toString().padStart(2, "0"), c = t.getUTCSeconds().toString().padStart(2, "0"), l = this;
|
|
64
|
+
return l.#e = e.replace(/yyyy/g, n).replace(/yy/g, n.slice(-2)).replace(/MM/g, r).replace(/dd/g, i).replace(/HH/g, a).replace(/hh/g, o).replace(/mm/g, s).replace(/ss/g, c), l;
|
|
65
|
+
}
|
|
66
|
+
currencyCode(e = !1) {
|
|
67
|
+
let n = new t().randomItem([
|
|
68
|
+
"USD",
|
|
69
|
+
"EUR",
|
|
70
|
+
"GBP",
|
|
71
|
+
"JPY",
|
|
72
|
+
"CNY",
|
|
73
|
+
"AUD",
|
|
74
|
+
"CAD",
|
|
75
|
+
"CHF",
|
|
76
|
+
"SEK",
|
|
77
|
+
"NZD"
|
|
78
|
+
]);
|
|
79
|
+
if (e) {
|
|
80
|
+
let e = n.value.toLowerCase();
|
|
81
|
+
return new t().identical(e);
|
|
82
|
+
}
|
|
83
|
+
return n;
|
|
84
|
+
}
|
|
85
|
+
countryCode(e) {
|
|
86
|
+
let n = e?.iso === "iso3" ? [
|
|
87
|
+
"USA",
|
|
88
|
+
"GBR",
|
|
89
|
+
"DEU",
|
|
90
|
+
"FRA",
|
|
91
|
+
"JPN",
|
|
92
|
+
"CHN",
|
|
93
|
+
"AUS",
|
|
94
|
+
"CAN",
|
|
95
|
+
"CHE",
|
|
96
|
+
"SWE"
|
|
97
|
+
] : [
|
|
98
|
+
"US",
|
|
99
|
+
"GB",
|
|
100
|
+
"DE",
|
|
101
|
+
"FR",
|
|
102
|
+
"JP",
|
|
103
|
+
"CN",
|
|
104
|
+
"AU",
|
|
105
|
+
"CA",
|
|
106
|
+
"CH",
|
|
107
|
+
"SE"
|
|
108
|
+
], r = new t().randomItem(n);
|
|
109
|
+
if (e?.lowercase) {
|
|
110
|
+
let e = r.value.toLowerCase();
|
|
111
|
+
return new t().identical(e);
|
|
112
|
+
}
|
|
113
|
+
return r;
|
|
114
|
+
}
|
|
115
|
+
email() {
|
|
116
|
+
let e = new t().words(1).value.toLowerCase().replace(/[^a-z]/g, ""), n = Math.floor(Math.random() * 1e3), r = new t().randomItem([
|
|
117
|
+
"gmail.com",
|
|
118
|
+
"outlook.com",
|
|
119
|
+
"yahoo.com",
|
|
120
|
+
"example.com",
|
|
121
|
+
"mail.com"
|
|
122
|
+
]);
|
|
123
|
+
return this.assertType(), this.#e = `${e}${n}@${r.value}`, this;
|
|
124
|
+
}
|
|
125
|
+
timeOfDay(e = {}) {
|
|
126
|
+
let t = this.#e ?? this.date().value;
|
|
127
|
+
this.assertType();
|
|
128
|
+
let n = (e.use12HourFormat ? t.getUTCHours() % 12 : t.getUTCHours()).toString().padStart(2, "0"), r = t.getMinutes().toString().padStart(2, "0"), i = t.getSeconds().toString().padStart(2, "0"), a = this;
|
|
129
|
+
return a.#e = e.showSeconds ? `${n}:${r}:${i}` : `${n}:${r}`, e.showAmPm && (a.#e += t.getUTCHours() >= 12 ? " PM" : " AM"), a;
|
|
130
|
+
}
|
|
131
|
+
uuid() {
|
|
132
|
+
return i++, this.assertType(), this.#e = i, this;
|
|
133
|
+
}
|
|
134
|
+
boolean() {
|
|
135
|
+
return this.assertType(), this.#e = Math.random() <= .5, this;
|
|
136
|
+
}
|
|
137
|
+
symbol(e = 0) {
|
|
138
|
+
return this.assertType(), this.#e = Symbol(e), this;
|
|
139
|
+
}
|
|
140
|
+
randomItem(e) {
|
|
141
|
+
return this.assertType(), this.#e = e[Math.floor(Math.random() * e.length)], this;
|
|
142
|
+
}
|
|
143
|
+
prefix(e) {
|
|
144
|
+
return this.assertType(), this.#e = `${e}${this.#e}`, this;
|
|
145
|
+
}
|
|
146
|
+
suffix(e) {
|
|
147
|
+
return this.assertType(), this.#e = `${this.#e}${e}`, this;
|
|
148
|
+
}
|
|
149
|
+
identical(e) {
|
|
150
|
+
return this.assertType(), this.#e = e, this;
|
|
151
|
+
}
|
|
152
|
+
assertType() {}
|
|
153
|
+
randomLoremWord() {
|
|
154
|
+
return e[Math.floor(Math.random() * e.length)] ?? "lorem";
|
|
155
|
+
}
|
|
156
|
+
}, o = 0, s = class e {
|
|
157
|
+
get value() {
|
|
158
|
+
return this.val;
|
|
159
|
+
}
|
|
160
|
+
constructor(t) {
|
|
161
|
+
this.generator = t, this.uuid = o++, this.viewModel = this.generator(), this.val = e.modelToValue(this.viewModel);
|
|
162
|
+
}
|
|
163
|
+
static modelToValue(t) {
|
|
164
|
+
if (t instanceof a) return t.value;
|
|
165
|
+
if (Array.isArray(t)) return t.map(this.modelToValue);
|
|
166
|
+
{
|
|
167
|
+
let n = {};
|
|
168
|
+
return Object.keys(t).forEach((r) => {
|
|
169
|
+
n[r] = e.modelToValue(t[r]);
|
|
170
|
+
}), n;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}, c = class {
|
|
174
|
+
proxy(e) {
|
|
175
|
+
return e instanceof s ? e.value : e;
|
|
176
|
+
}
|
|
177
|
+
}, l = class {
|
|
178
|
+
constructor() {
|
|
179
|
+
this.config = null, this.viewModels = [];
|
|
180
|
+
}
|
|
181
|
+
setupModels() {
|
|
182
|
+
if (this.config) {
|
|
183
|
+
let e = this.config.schemaGenerator;
|
|
184
|
+
this.viewModels = Array.from({ length: this.config.repeat }, () => new s(e));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}, u = class e {
|
|
188
|
+
static {
|
|
189
|
+
this.dataAttr = "data-skeletonizer";
|
|
190
|
+
}
|
|
191
|
+
static skeletonizeProjectedTemplate(r, i) {
|
|
192
|
+
if (!this.isBrowser()) return;
|
|
193
|
+
let a = i?.primaryColor ?? n.PrimaryColor, o = i?.secondaryColor ?? n.SecondaryColor;
|
|
194
|
+
r.setAttribute("style", `--skeletonizer-primary-color: ${a}; --skeletonizer-secondary-color: ${o};`), Array.from(r.querySelectorAll("*:not(svg, [data-skeletonizer])")).forEach((n) => {
|
|
195
|
+
let r = [
|
|
196
|
+
"br",
|
|
197
|
+
"b",
|
|
198
|
+
"strong",
|
|
199
|
+
"i",
|
|
200
|
+
"em",
|
|
201
|
+
"mark",
|
|
202
|
+
"small",
|
|
203
|
+
"del",
|
|
204
|
+
"ins",
|
|
205
|
+
"sub",
|
|
206
|
+
"sup"
|
|
207
|
+
], i = Array.from(n.childNodes).map((e) => e.nodeName.toLowerCase()).filter((e) => !r.includes(e)), a = i.length > 0 && i.some((e) => e !== i[0]);
|
|
208
|
+
n.childNodes.forEach((r) => {
|
|
209
|
+
switch (r.nodeName.toLowerCase()) {
|
|
210
|
+
case "#text":
|
|
211
|
+
if (this.assertAs(r), r.wholeText.trim()) if (a) {
|
|
212
|
+
let n = document.createElement("span");
|
|
213
|
+
n.innerText = r.cloneNode().wholeText, n.innerText.length && r.replaceWith(e.skeletonizedSpanGenerator(n.innerText, t.Text));
|
|
214
|
+
} else n.innerHTML = e.skeletonizedSpanGenerator(n.innerHTML, t.Text).outerHTML;
|
|
215
|
+
break;
|
|
216
|
+
case "input":
|
|
217
|
+
r.setAttribute(e.dataAttr, t.Input);
|
|
218
|
+
break;
|
|
219
|
+
case "select":
|
|
220
|
+
r.setAttribute(e.dataAttr, t.Select);
|
|
221
|
+
break;
|
|
222
|
+
case "img":
|
|
223
|
+
r.setAttribute(e.dataAttr, t.Image);
|
|
224
|
+
break;
|
|
225
|
+
case "video":
|
|
226
|
+
r.setAttribute(e.dataAttr, t.Video);
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
}), r.setAttribute(e.dataAttr, t.WrapperElement);
|
|
231
|
+
}
|
|
232
|
+
static skeletonizedSpanGenerator(t, n) {
|
|
233
|
+
let r = document.createElement("span");
|
|
234
|
+
return r.innerHTML = t, r.setAttribute(e.dataAttr, n), r;
|
|
235
|
+
}
|
|
236
|
+
static isBrowser() {
|
|
237
|
+
return typeof document < "u";
|
|
238
|
+
}
|
|
239
|
+
static assertAs(e) {}
|
|
700
240
|
};
|
|
241
|
+
//#endregion
|
|
242
|
+
export { s as Schema, a as SchemaItem, c as SkeletonAbstractComponent, l as SkeletonAdapterComponent, u as SkeletonDirective };
|