@skeletonizer/utils 2.2.4 → 2.3.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/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 +238 -699
- package/dist/utils.umd.js +2 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -63,6 +63,11 @@ It can be chained on a number value - in that case, it turns the integer into a
|
|
|
63
63
|
Turns the string or number value of the `SchemaItem` instance into a currency string of the provided locale and currency.
|
|
64
64
|
This can be used in combination with the `number` method to simulate prices in different currencies - eg. `new SchemaItem().number(10, 100).currency({ locale: 'en-US', currency: 'USD' })`.
|
|
65
65
|
|
|
66
|
+
### `currencyCode(lowercase?: boolean)`
|
|
67
|
+
Generates a random ISO 4217 currency code from a set of 10 common currencies (`USD`, `EUR`, `GBP`, `JPY`, `CNY`, `AUD`, `CAD`, `CHF`, `SEK`, `NZD`).
|
|
68
|
+
By default returns an uppercase code. Pass `true` for a lowercase code — eg. `new SchemaItem().currencyCode(true)` returns `'usd'`, `'eur'`, etc.
|
|
69
|
+
Return types are typed as literal unions, so TypeScript will narrow the result accordingly.
|
|
70
|
+
|
|
66
71
|
### `multiply(multiplier: number)`
|
|
67
72
|
Multiplies the current value of the `SchemaItem` instance by the `multiplier` parameter.
|
|
68
73
|
This can be used for chaining the `SchemaItem().foo()` methods if `foo` returns a number - ie `new SchemaItem().number(10, 100).multiply(5)`.
|
|
@@ -75,6 +80,21 @@ This can be used eg. for simulating dates of birth, dates of creation, etc.
|
|
|
75
80
|
Generates a random time of day, using the formatting specified by the `config` parameter.
|
|
76
81
|
It can be chained to the `date` method should you wish to further restrict available times (eg. by providing a min and max date to the `date` method that are on the same day within the desired time range).
|
|
77
82
|
|
|
83
|
+
### `format(formatStr: string)`
|
|
84
|
+
Formats a date value using a simplified format string (similar to `date-fns`).
|
|
85
|
+
If the value is already a `Date`, it is used directly; otherwise a random date is generated first.
|
|
86
|
+
Can be chained with the `date` method to control the date range — eg. `new SchemaItem().date({ isFuture: true }).format('yyyy-MM-dd')`.
|
|
87
|
+
|
|
88
|
+
Supported format tokens:
|
|
89
|
+
- `yyyy` — 4-digit year (eg. `2026`)
|
|
90
|
+
- `yy` — 2-digit year (eg. `26`)
|
|
91
|
+
- `MM` — zero-padded month (`01`–`12`)
|
|
92
|
+
- `dd` — zero-padded day (`01`–`31`)
|
|
93
|
+
- `HH` — zero-padded 24-hour hour (`00`–`23`)
|
|
94
|
+
- `hh` — zero-padded 12-hour hour (`01`–`12`)
|
|
95
|
+
- `mm` — zero-padded minutes (`00`–`59`)
|
|
96
|
+
- `ss` — zero-padded seconds (`00`–`59`)
|
|
97
|
+
|
|
78
98
|
### `uuid()`
|
|
79
99
|
Increments a global `uuid` variable and sets the current value of the `SchemaItem` instance to this new value.
|
|
80
100
|
This can be used eg. for simulating user ids, etc.
|
|
@@ -86,6 +106,11 @@ This can be used eg. for simulating whether a user is active, whether a product
|
|
|
86
106
|
### `symbol(val: string | number = 0)`
|
|
87
107
|
Creates a new unique symbol with the provided `val` as the description.
|
|
88
108
|
|
|
109
|
+
### `stringify()`
|
|
110
|
+
Converts the current value (number, boolean, or symbol) to its string representation.
|
|
111
|
+
This can be used eg. for converting a generated number or boolean to a string for display — ie. `new SchemaItem().number(1, 100).stringify()`.
|
|
112
|
+
For converting dates to strings, use the `format` method instead.
|
|
113
|
+
|
|
89
114
|
### `randomItem(items: R[])`
|
|
90
115
|
Sets the current value of the `SchemaItem` instance to a random item provided in the `items` parameter.
|
|
91
116
|
|
|
@@ -103,6 +128,16 @@ This can be used eg. for providing a specific (general) placeholder image that y
|
|
|
103
128
|
It can also be used for providing any specific class instances that you might be using in your app (eg. `moment` for dates, which may be used in the view, a specific `enum` value, a `UserModel` etc).
|
|
104
129
|
It allows you to provide your own (randomly generated) data, with type safety, for usage in skeleton config schema (eg. you could use it in conjunction with more realistic first names generated by `faker` or similar packages).
|
|
105
130
|
|
|
131
|
+
### `countryCode(config?: { iso?: 'iso2' | 'iso3'; lowercase?: boolean })`
|
|
132
|
+
Generates a random ISO 3166-1 country code from a set of 10 common countries (`US`, `GB`, `DE`, `FR`, `JP`, `CN`, `AU`, `CA`, `CH`, `SE`).
|
|
133
|
+
By default, returns an uppercase alpha-2 code (eg. `US`, `DE`). Use `{ iso: 'iso3' }` for alpha-3 codes (eg. `USA`, `DEU`) and `{ lowercase: true }` for lowercase output.
|
|
134
|
+
Return types are typed as literal unions depending on `iso` and `lowercase` options, so TypeScript will narrow the result accordingly.
|
|
135
|
+
This can be used eg. for simulating country selectors, locale-based displays, etc.
|
|
136
|
+
|
|
137
|
+
### `email()`
|
|
138
|
+
Generates a random email address composed of a lowercase lorem ipsum word, a random number, and one of 5 common domains (`gmail.com`, `outlook.com`, `yahoo.com`, `example.com`, `mail.com`).
|
|
139
|
+
This can be used eg. for simulating user email fields, contact forms, etc.
|
|
140
|
+
|
|
106
141
|
## TSchemaConfig
|
|
107
142
|
The `TSchemaConfig` type is the configuration object type being used to define the skeleton structure. It is used by all adapters in some shape or form.
|
|
108
143
|
The general shape is:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton.abstract.component.d.ts","sourceRoot":"","sources":["../../../src/components/skeleton.abstract.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"skeleton.abstract.component.d.ts","sourceRoot":"","sources":["../../../src/components/skeleton.abstract.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,8BAAsB,yBAAyB,CAAC,CAAC,SAAS,MAAM;IAC9D,SAAgB,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACjD,SAAgB,YAAY,EAAE,OAAO,CAAC;IAM/B,KAAK,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;CAGtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton.adapter.component.d.ts","sourceRoot":"","sources":["../../../src/components/skeleton.adapter.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"skeleton.adapter.component.d.ts","sourceRoot":"","sources":["../../../src/components/skeleton.adapter.component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAoB,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,qBAAa,wBAAwB,CAAC,CAAC,SAAS,MAAM;IAC7C,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAQ;IACvC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAM;IAGlC,WAAW,IAAI,IAAI;CAM3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton.directive.d.ts","sourceRoot":"","sources":["../../../src/directives/skeleton.directive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"skeleton.directive.d.ts","sourceRoot":"","sources":["../../../src/directives/skeleton.directive.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEzD,qBAAa,iBAAiB;IAC5B,gBAAuB,QAAQ,EAAE,MAAM,CAAuB;WAEhD,4BAA4B,CAAC,QAAQ,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,wBAAwB,GAAG,IAAI;IAsF/G,OAAO,CAAC,MAAM,CAAC,yBAAyB;IASxC,OAAO,CAAC,MAAM,CAAC,SAAS;IAIxB,OAAO,CAAC,MAAM,CAAC,QAAQ;CACxB"}
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,mBAAmB,SAAS,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TSchemaCountryCodeIso2, TSchemaCountryCodeIso3, TSchemaCurrencyCode } from './schema-item.model.types';
|
|
1
2
|
type TSchemaInstance<T> = InstanceType<typeof SchemaItem<T>>;
|
|
2
3
|
export declare class SchemaItem<T = never> {
|
|
3
4
|
#private;
|
|
@@ -18,6 +19,27 @@ export declare class SchemaItem<T = never> {
|
|
|
18
19
|
max: Date;
|
|
19
20
|
min: Date;
|
|
20
21
|
}>): TSchemaInstance<Date>;
|
|
22
|
+
stringify(this: TSchemaInstance<number | boolean | symbol>): TSchemaInstance<string>;
|
|
23
|
+
format(this: TSchemaInstance<Date | undefined>, formatStr: string): TSchemaInstance<string>;
|
|
24
|
+
currencyCode(this: TSchemaInstance<string | undefined>, lowercase: true): TSchemaInstance<Lowercase<TSchemaCurrencyCode>>;
|
|
25
|
+
currencyCode(this: TSchemaInstance<string | undefined>, lowercase?: false): TSchemaInstance<TSchemaCurrencyCode>;
|
|
26
|
+
countryCode(this: TSchemaInstance<string | undefined>, config: {
|
|
27
|
+
iso: 'iso3';
|
|
28
|
+
lowercase: true;
|
|
29
|
+
}): TSchemaInstance<Lowercase<TSchemaCountryCodeIso3>>;
|
|
30
|
+
countryCode(this: TSchemaInstance<string | undefined>, config: {
|
|
31
|
+
iso: 'iso3';
|
|
32
|
+
lowercase?: false;
|
|
33
|
+
}): TSchemaInstance<TSchemaCountryCodeIso3>;
|
|
34
|
+
countryCode(this: TSchemaInstance<string | undefined>, config: {
|
|
35
|
+
iso?: 'iso2';
|
|
36
|
+
lowercase: true;
|
|
37
|
+
}): TSchemaInstance<Lowercase<TSchemaCountryCodeIso2>>;
|
|
38
|
+
countryCode(this: TSchemaInstance<string | undefined>, config?: {
|
|
39
|
+
iso?: 'iso2';
|
|
40
|
+
lowercase?: false;
|
|
41
|
+
}): TSchemaInstance<TSchemaCountryCodeIso2>;
|
|
42
|
+
email(this: TSchemaInstance<string | undefined>): TSchemaInstance<string>;
|
|
21
43
|
timeOfDay(this: TSchemaInstance<Date | undefined>, config?: Partial<{
|
|
22
44
|
use12HourFormat: boolean;
|
|
23
45
|
showSeconds: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-item.model.d.ts","sourceRoot":"","sources":["../../../src/models/schema-item.model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema-item.model.d.ts","sourceRoot":"","sources":["../../../src/models/schema-item.model.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type TSchemaCurrencyCode = 'USD' | 'EUR' | 'GBP' | 'JPY' | 'CNY' | 'AUD' | 'CAD' | 'CHF' | 'SEK' | 'NZD';
|
|
2
|
+
export type TSchemaCountryCodeIso2 = 'US' | 'GB' | 'DE' | 'FR' | 'JP' | 'CN' | 'AU' | 'CA' | 'CH' | 'SE';
|
|
3
|
+
export type TSchemaCountryCodeIso3 = 'USA' | 'GBR' | 'DEU' | 'FRA' | 'JPN' | 'CHN' | 'AUS' | 'CAN' | 'CHE' | 'SWE';
|
|
4
|
+
//# sourceMappingURL=schema-item.model.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-item.model.types.d.ts","sourceRoot":"","sources":["../../../src/models/schema-item.model.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAChH,MAAM,MAAM,sBAAsB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AACzG,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.model.d.ts","sourceRoot":"","sources":["../../../src/models/schema.model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.model.d.ts","sourceRoot":"","sources":["../../../src/models/schema.model.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAIrE,qBAAa,MAAM,CAAC,CAAC,SAAS,MAAM;aAWhB,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAVhD,SAAgB,IAAI,EAAE,MAAM,CAAe;IAC3C,SAAgB,SAAS,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAEjD,IAAW,KAAK,IAAI,CAAC,CAEpB;IAED,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAI;gBAGN,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAMhD,OAAO,CAAC,MAAM,CAAC,YAAY;CAiB5B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './color-schema.types';
|
|
2
|
-
export * from './schema.types';
|
|
3
|
-
export * from './transformer.types';
|
|
1
|
+
export type * from './color-schema.types';
|
|
2
|
+
export type * from './schema.types';
|
|
3
|
+
export type * from './transformer.types';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,sBAAsB,CAAC;AAC1C,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,qBAAqB,CAAC"}
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
+
interface ICustomLeaf {
|
|
2
|
+
custom: boolean;
|
|
3
|
+
nested: {
|
|
4
|
+
deep: string;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
declare module '../transformer.types' {
|
|
8
|
+
interface ISchemaLeafTypes {
|
|
9
|
+
customLeaf: ICustomLeaf;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
1
12
|
export {};
|
|
2
13
|
//# sourceMappingURL=transformer.types.spec-d.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformer.types.spec-d.d.ts","sourceRoot":"","sources":["../../../../src/types/spec/transformer.types.spec-d.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"transformer.types.spec-d.d.ts","sourceRoot":"","sources":["../../../../src/types/spec/transformer.types.spec-d.ts"],"names":[],"mappings":"AAKA,UAAU,WAAW;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1B;AAED,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAU,gBAAgB;QACxB,UAAU,EAAE,WAAW,CAAC;KACzB;CACF"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { SchemaItem } from '../models';
|
|
2
|
-
export
|
|
2
|
+
export interface ISchemaLeafTypes {
|
|
3
|
+
date: Date;
|
|
4
|
+
}
|
|
5
|
+
type TSchemaLeaf = ISchemaLeafTypes[keyof ISchemaLeafTypes];
|
|
6
|
+
export type TSchemaTransformer<T> = T extends Array<infer Element> ? Array<TSchemaTransformer<Element>> : T extends boolean ? SchemaItem<boolean> : T extends TSchemaLeaf ? SchemaItem<T> : T extends object ? {
|
|
3
7
|
[K in keyof T]: TSchemaTransformer<T[K]>;
|
|
4
8
|
} : SchemaItem<T>;
|
|
9
|
+
export {};
|
|
5
10
|
//# sourceMappingURL=transformer.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformer.types.d.ts","sourceRoot":"","sources":["../../../src/types/transformer.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAC9B,CAAC,SAAS,KAAK,CAAC,MAAM,OAAO,CAAC,GAC1B,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,GAClC,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"transformer.types.d.ts","sourceRoot":"","sources":["../../../src/types/transformer.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,KAAK,WAAW,GAAG,gBAAgB,CAAC,MAAM,gBAAgB,CAAC,CAAC;AAE5D,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAC9B,CAAC,SAAS,KAAK,CAAC,MAAM,OAAO,CAAC,GAC1B,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,GAClC,CAAC,SAAS,OAAO,GACf,UAAU,CAAC,OAAO,CAAC,GACnB,CAAC,SAAS,WAAW,GACnB,UAAU,CAAC,CAAC,CAAC,GACb,CAAC,SAAS,MAAM,GACd;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC5C,UAAU,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/utils.mjs
CHANGED
|
@@ -1,700 +1,239 @@
|
|
|
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
|
-
"in",
|
|
238
|
-
"tortor",
|
|
239
|
-
"eget",
|
|
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.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 "img":
|
|
220
|
+
r.setAttribute(e.dataAttr, t.Image);
|
|
221
|
+
break;
|
|
222
|
+
case "video":
|
|
223
|
+
r.setAttribute(e.dataAttr, t.Video);
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}), r.setAttribute(e.dataAttr, t.WrapperElement);
|
|
228
|
+
}
|
|
229
|
+
static skeletonizedSpanGenerator(t, n) {
|
|
230
|
+
let r = document.createElement("span");
|
|
231
|
+
return r.innerHTML = t, r.setAttribute(e.dataAttr, n), r;
|
|
232
|
+
}
|
|
233
|
+
static isBrowser() {
|
|
234
|
+
return typeof document < "u";
|
|
235
|
+
}
|
|
236
|
+
static assertAs(e) {}
|
|
700
237
|
};
|
|
238
|
+
//#endregion
|
|
239
|
+
export { s as Schema, a as SchemaItem, c as SkeletonAbstractComponent, l as SkeletonAdapterComponent, u as SkeletonDirective };
|
package/dist/utils.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
`),
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`@skeletonizer/utils`]={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var 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.`.split(`(`),n=function(e){return e.Text=`text`,e.Input=`input`,e.Image=`image`,e.Video=`video`,e.WrapperElement=`wrapper-element`,e}({}),r=function(e){return e.PrimaryColor=`rgba(100, 100, 100, .6)`,e.SecondaryColor=`rgba(100, 100, 100, .3)`,e}({}),i=class{static daysInMs(e){return e*24*60*60*1e3}static dateBetween(e,t){return new Date(e.getTime()+Math.random()*(t.getTime()-e.getTime()))}},a=0,o=class e{get value(){return this.#e}#e;words(e){this.assertType();let t=``,n=0;for(;n<e;)t+=this.randomLoremWord()+` `,n++;return this.#e=t.trim(),this}paragraphs(e){this.assertType();let t=``,n=0;for(;n<e;){let r=50-Math.round(50*Math.random()*.2)*(Math.random()<.5?-1:1);t+=this.words(r).value,n!==e-1&&(t+=`
|
|
2
|
+
`),n++}return this.#e=t,this}number(e=0,t=1e3){return this.assertType(),this.#e=Math.ceil(Math.random()*(t-e))+e,this}float(e=0,t=1e3){return this.assertType(),this.#e=this.#e?this.#e+Math.random():Math.random()*(t-e)+e,this}currency(e){return this.assertType(),this.#e=new Intl.NumberFormat(e.locale,{...e.options,style:`currency`,currency:e.currency}).format(+this.#e),this}multiply(e){return this.assertType(),this.#e*=e,this}date(e={}){this.assertType();let t=e.max??new Date(`2100-01-01`),n=e.min??new Date(`1970-01-01`);return e.isFuture?n=new Date(Date.now()+i.daysInMs(1)):e.isPast&&(t=new Date(Date.now()-i.daysInMs(1))),this.#e=i.dateBetween(n,t),this}stringify(){let e=this.#e;this.assertType();let t=this;return t.#e=e.toString(),t}format(e){let t=this.#e??this.date().value;this.assertType();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;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}currencyCode(t=!1){let n=new e().randomItem([`USD`,`EUR`,`GBP`,`JPY`,`CNY`,`AUD`,`CAD`,`CHF`,`SEK`,`NZD`]);if(t){let t=n.value.toLowerCase();return new e().identical(t)}return n}countryCode(t){let n=t?.iso===`iso3`?[`USA`,`GBR`,`DEU`,`FRA`,`JPN`,`CHN`,`AUS`,`CAN`,`CHE`,`SWE`]:[`US`,`GB`,`DE`,`FR`,`JP`,`CN`,`AU`,`CA`,`CH`,`SE`],r=new e().randomItem(n);if(t?.lowercase){let t=r.value.toLowerCase();return new e().identical(t)}return r}email(){let t=new e().words(1).value.toLowerCase().replace(/[^a-z]/g,``),n=Math.floor(Math.random()*1e3),r=new e().randomItem([`gmail.com`,`outlook.com`,`yahoo.com`,`example.com`,`mail.com`]);return this.assertType(),this.#e=`${t}${n}@${r.value}`,this}timeOfDay(e={}){let t=this.#e??this.date().value;this.assertType();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;return a.#e=e.showSeconds?`${n}:${r}:${i}`:`${n}:${r}`,e.showAmPm&&(a.#e+=t.getUTCHours()>=12?` PM`:` AM`),a}uuid(){return a++,this.assertType(),this.#e=a,this}boolean(){return this.assertType(),this.#e=Math.random()<=.5,this}symbol(e=0){return this.assertType(),this.#e=Symbol(e),this}randomItem(e){return this.assertType(),this.#e=e[Math.floor(Math.random()*e.length)],this}prefix(e){return this.assertType(),this.#e=`${e}${this.#e}`,this}suffix(e){return this.assertType(),this.#e=`${this.#e}${e}`,this}identical(e){return this.assertType(),this.#e=e,this}assertType(){}randomLoremWord(){return t[Math.floor(Math.random()*t.length)]??`lorem`}},s=0,c=class e{get value(){return this.val}constructor(t){this.generator=t,this.uuid=s++,this.viewModel=this.generator(),this.val=e.modelToValue(this.viewModel)}static modelToValue(t){if(t instanceof o)return t.value;if(Array.isArray(t))return t.map(this.modelToValue);{let n={};return Object.keys(t).forEach(r=>{n[r]=e.modelToValue(t[r])}),n}}},l=class{proxy(e){return e instanceof c?e.value:e}},u=class{constructor(){this.config=null,this.viewModels=[]}setupModels(){if(this.config){let e=this.config.schemaGenerator;this.viewModels=Array.from({length:this.config.repeat},()=>new c(e))}}},d=class e{static{this.dataAttr=`data-skeletonizer`}static skeletonizeProjectedTemplate(t,i){if(!this.isBrowser())return;let a=i?.primaryColor??r.PrimaryColor,o=i?.secondaryColor??r.SecondaryColor;t.setAttribute(`style`,`--skeletonizer-primary-color: ${a}; --skeletonizer-secondary-color: ${o};`),Array.from(t.querySelectorAll(`*:not(svg, [data-skeletonizer])`)).forEach(t=>{let r=[`br`,`b`,`strong`,`i`,`em`,`mark`,`small`,`del`,`ins`,`sub`,`sup`],i=Array.from(t.childNodes).map(e=>e.nodeName.toLowerCase()).filter(e=>!r.includes(e)),a=i.length>0&&i.some(e=>e!==i[0]);t.childNodes.forEach(r=>{switch(r.nodeName.toLowerCase()){case`#text`:if(this.assertAs(r),r.wholeText.trim())if(a){let t=document.createElement(`span`);t.innerText=r.cloneNode().wholeText,t.innerText.length&&r.replaceWith(e.skeletonizedSpanGenerator(t.innerText,n.Text))}else t.innerHTML=e.skeletonizedSpanGenerator(t.innerHTML,n.Text).outerHTML;break;case`input`:r.setAttribute(e.dataAttr,n.Input);break;case`img`:r.setAttribute(e.dataAttr,n.Image);break;case`video`:r.setAttribute(e.dataAttr,n.Video);break}})}),t.setAttribute(e.dataAttr,n.WrapperElement)}static skeletonizedSpanGenerator(t,n){let r=document.createElement(`span`);return r.innerHTML=t,r.setAttribute(e.dataAttr,n),r}static isBrowser(){return typeof document<`u`}static assertAs(e){}};e.Schema=c,e.SchemaItem=o,e.SkeletonAbstractComponent=l,e.SkeletonAdapterComponent=u,e.SkeletonDirective=d});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skeletonizer/utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Utils for all skeletonizer packages",
|
|
5
5
|
"author": "Luka Varga",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"**/*.{ts,js}": "eslint --fix"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@vitest/coverage-istanbul": "4.
|
|
54
|
-
"sass": "^1.
|
|
53
|
+
"@vitest/coverage-istanbul": "4.1.4",
|
|
54
|
+
"sass": "^1.99.0",
|
|
55
55
|
"vite-plugin-dts": "^4.5.4",
|
|
56
|
-
"vitest": "4.
|
|
56
|
+
"vitest": "4.1.4"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "4c97174377cfb6beec7537eb4ad1b28214c47660"
|
|
59
59
|
}
|