jails.stdlib 1.0.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 +21 -0
- package/README.md +22 -0
- package/build.js +34 -0
- package/cancelable/README.md +41 -0
- package/cancelable/index.d.ts +1 -0
- package/cancelable/index.js +16 -0
- package/cancelable/index.ts +18 -0
- package/cancelable/index.umd.js +1 -0
- package/debounce/README.md +21 -0
- package/debounce/index.d.ts +1 -0
- package/debounce/index.js +11 -0
- package/debounce/index.ts +8 -0
- package/debounce/index.umd.js +1 -0
- package/delay/README.md +17 -0
- package/delay/index.d.ts +1 -0
- package/delay/index.js +6 -0
- package/delay/index.ts +6 -0
- package/delay/index.umd.js +1 -0
- package/form-validation/index.d.ts +18 -0
- package/form-validation/index.js +119 -0
- package/form-validation/index.ts +198 -0
- package/form-validation/index.umd.js +1 -0
- package/form-validation/readme.md +117 -0
- package/import-css/README.md +22 -0
- package/import-css/index.d.ts +1 -0
- package/import-css/index.js +7 -0
- package/import-css/index.ts +11 -0
- package/import-css/index.umd.js +1 -0
- package/import-html/README.md +18 -0
- package/import-html/index.d.ts +4 -0
- package/import-html/index.js +4 -0
- package/import-html/index.ts +4 -0
- package/import-html/index.umd.js +1 -0
- package/import-js/README.md +22 -0
- package/import-js/index.d.ts +5 -0
- package/import-js/index.js +7 -0
- package/import-js/index.ts +15 -0
- package/import-js/index.umd.js +1 -0
- package/is-touch/README.md +18 -0
- package/is-touch/index.d.ts +1 -0
- package/is-touch/index.js +4 -0
- package/is-touch/index.ts +4 -0
- package/is-touch/index.umd.js +1 -0
- package/is-visible/README.md +24 -0
- package/is-visible/index.d.ts +7 -0
- package/is-visible/index.js +11 -0
- package/is-visible/index.ts +20 -0
- package/is-visible/index.umd.js +1 -0
- package/lazyload-image/README.md +28 -0
- package/lazyload-image/index.d.ts +1 -0
- package/lazyload-image/index.js +235 -0
- package/lazyload-image/index.ts +3 -0
- package/lazyload-image/index.umd.js +1 -0
- package/messenger/README.md +109 -0
- package/messenger/index.d.ts +9 -0
- package/messenger/index.js +39 -0
- package/messenger/index.ts +38 -0
- package/messenger/index.umd.js +1 -0
- package/mfe/README.md +90 -0
- package/mfe/index.d.ts +11 -0
- package/mfe/index.js +99 -0
- package/mfe/index.ts +141 -0
- package/mfe/index.umd.js +1 -0
- package/outlet/README.md +46 -0
- package/outlet/index.d.ts +6 -0
- package/outlet/index.js +550 -0
- package/outlet/index.ts +101 -0
- package/outlet/index.umd.js +1 -0
- package/package.json +25 -0
- package/querystring/README.md +19 -0
- package/querystring/index.d.ts +1 -0
- package/querystring/index.js +9 -0
- package/querystring/index.ts +9 -0
- package/querystring/index.umd.js +1 -0
- package/router/README.md +23 -0
- package/router/index.d.ts +1 -0
- package/router/index.js +134 -0
- package/router/index.ts +3 -0
- package/router/index.umd.js +1 -0
- package/storage/README.md +34 -0
- package/storage/index.d.ts +12 -0
- package/storage/index.js +39 -0
- package/storage/index.ts +45 -0
- package/storage/index.umd.js +1 -0
- package/store/README.md +44 -0
- package/store/index.d.ts +1 -0
- package/store/index.js +50 -0
- package/store/index.ts +1 -0
- package/store/index.umd.js +1 -0
- package/third-party/README.md +44 -0
- package/third-party/index.d.ts +8 -0
- package/third-party/index.js +15 -0
- package/third-party/index.ts +30 -0
- package/third-party/index.umd.js +1 -0
- package/throttle/README.md +21 -0
- package/throttle/index.d.ts +1 -0
- package/throttle/index.js +9 -0
- package/throttle/index.ts +10 -0
- package/throttle/index.umd.js +1 -0
- package/tsconfig.json +14 -0
- package/vite-env.d.ts +1 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# <form-validation />
|
|
2
|
+
|
|
3
|
+
For validations and masks. It's a `<form />` element child.
|
|
4
|
+
|
|
5
|
+
[Example on StackBlitz](https://stackblitz.com/edit/jails-form-validation?file=index.ts)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
##### Model
|
|
10
|
+
The local component state to be used on html template
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
form: {
|
|
14
|
+
errors: {}, // A set of errors of each field: e.g form.errors.username : 'Username is required'
|
|
15
|
+
values: {}, // A set of values of each field: e.g form.values.username : 'John Doe'
|
|
16
|
+
touched: {}, // A set of touched fields : e.g form.touched.username : true | false
|
|
17
|
+
focused: {}, // A set of focused fields: e.g form.focused.username: true | false
|
|
18
|
+
isValid: false // The state of the <form-validation> : true | false
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
##### Events
|
|
23
|
+
|
|
24
|
+
###### `form-validation:submit`
|
|
25
|
+
Fired when form is **valid**, provides a `formData` instance of input values and raw data with key and value pairs with names and values of form inputs.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
on('form-validation:submit', ({ formData, data }) => {})
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
##### `form-validation:error`
|
|
32
|
+
Fired when form is **invalid**, provides a map with errors fields.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
on('form-validation:error', ({ errors }) => {})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Usage
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
##### main.ts
|
|
45
|
+
```ts
|
|
46
|
+
import * as formValidation from 'jails.std/form-validation'
|
|
47
|
+
import rules from './my-custom-rules'
|
|
48
|
+
|
|
49
|
+
jails.register('form-validation', formValidation, { ...rules })
|
|
50
|
+
jails.start()
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**IMPORTANT:** You have to provide a configuration file with your own set of validations and masks. Explained later.
|
|
54
|
+
|
|
55
|
+
##### index.html
|
|
56
|
+
|
|
57
|
+
```html
|
|
58
|
+
<form novalidate>
|
|
59
|
+
|
|
60
|
+
<form-validation>
|
|
61
|
+
|
|
62
|
+
<div class="form-group">
|
|
63
|
+
<label>Username*</label>
|
|
64
|
+
<input type="text" name="username" data-validation="required" html-value="form.values.username" />
|
|
65
|
+
<p html-if="form.errors.username" html-inner="form.errors.username"></p>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<div class="form-group">
|
|
69
|
+
<label>Email*</label>
|
|
70
|
+
<input type="email" name="email" data-validation="required email" html-value="form.values.email" />
|
|
71
|
+
<p html-if="form.errors.email" html-inner="form.errors.email"></p>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<div class="form-group">
|
|
75
|
+
<label>Age</label>
|
|
76
|
+
<input type="text" name="age" data-mask="age" html-value="form.values.age" />
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<button type="submit">Send</button>
|
|
80
|
+
|
|
81
|
+
</form-validation>
|
|
82
|
+
|
|
83
|
+
</form>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
##### my-custom-rules/index.ts
|
|
87
|
+
```ts
|
|
88
|
+
export default {
|
|
89
|
+
|
|
90
|
+
validations : {
|
|
91
|
+
|
|
92
|
+
required(value, input, form) {
|
|
93
|
+
if (!value) return { ok: false, message: 'This field is required'}
|
|
94
|
+
return { ok: true }
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
email(value, input, form) {
|
|
98
|
+
if (!value) return { ok: true }
|
|
99
|
+
if (!value.match(/(.*)@(.*)\.\w{2,}/)) return { ok: false, message: 'Invalid email' }
|
|
100
|
+
return { ok: true }
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
number(value, input, form) {
|
|
104
|
+
if (value.match(/\D/g)) return { ok: false, message:'This field takes only number' }
|
|
105
|
+
return { ok: true }
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
masks: {
|
|
110
|
+
number(value, input, form) {
|
|
111
|
+
return value.replace(/\D/, '')
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
To see how to inject this dependency, go back to the [usage](#usage) section.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
# importCss
|
|
3
|
+
```ts
|
|
4
|
+
importCss( url: string ) : Promise<Event>
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Returns a promise when Css is loaded
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { importCss } from 'jails.std/import-css'
|
|
14
|
+
|
|
15
|
+
importCss('https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css')
|
|
16
|
+
.then( (event) => {
|
|
17
|
+
console.log(event, 'swiper css loaded')
|
|
18
|
+
})
|
|
19
|
+
.catch( (event) => {
|
|
20
|
+
console.error('error on loading swiper css')
|
|
21
|
+
})
|
|
22
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const importCss: (url: string, options?: any) => Promise<unknown>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
export const importCss = ( url: string, options = null ) => {
|
|
3
|
+
return new Promise((resolve, reject) => {
|
|
4
|
+
const link = document.createElement('link')
|
|
5
|
+
link.rel = 'stylesheet'
|
|
6
|
+
link.href = url
|
|
7
|
+
link.onload = resolve
|
|
8
|
+
link.onerror = reject
|
|
9
|
+
document.head.appendChild(link)
|
|
10
|
+
})
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module!="undefined"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(e=typeof globalThis!="undefined"?globalThis:e||self,n(e["import-css"]={}))})(this,(function(e){"use strict";const n=(o,d=null)=>new Promise((i,s)=>{const t=document.createElement("link");t.rel="stylesheet",t.href=o,t.onload=i,t.onerror=s,document.head.appendChild(t)});e.importCss=n,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
# importHtml
|
|
3
|
+
```ts
|
|
4
|
+
importHtml( url: string, options?: fetchOptions ) : Promise<Response, string>
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Returns a promise when Html is loaded. It accepts options from `fetch` api.
|
|
8
|
+
|
|
9
|
+
### Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { importHtml } from 'jails.std/import-html'
|
|
13
|
+
|
|
14
|
+
importHtml('https://html-mock.fly.dev/tag/table?class=table%20table-bordered')
|
|
15
|
+
.then( ({ response: Response, html: string }) => {
|
|
16
|
+
console.log({ response, html })
|
|
17
|
+
})
|
|
18
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["import-html"]={}))})(this,(function(e){"use strict";const t=(i,o=null)=>fetch(i,o).then(n=>n.text().then(f=>({response:n,html:f})));e.importHtml=t,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
# importJs
|
|
3
|
+
```ts
|
|
4
|
+
importJs( url: string, options? = { async = true } ) : Promise<Event>
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Returns a promise when script is loaded
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { importJs } from 'jails.std/import-js'
|
|
14
|
+
|
|
15
|
+
importJs('https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js')
|
|
16
|
+
.then( (event) => {
|
|
17
|
+
console.log(event, 'swiper js loaded')
|
|
18
|
+
})
|
|
19
|
+
.catch( (event) => {
|
|
20
|
+
console.error(event, 'error on loading swiper js')
|
|
21
|
+
})
|
|
22
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
export const importJs = ( url:string, { async = true }: Options = {} as Options ) => {
|
|
3
|
+
return new Promise((resolve, reject) => {
|
|
4
|
+
const script = document.createElement('script')
|
|
5
|
+
script.src = url
|
|
6
|
+
script.async = async
|
|
7
|
+
script.onload = resolve
|
|
8
|
+
script.onerror = reject
|
|
9
|
+
document.head.appendChild(script)
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type Options = {
|
|
14
|
+
async?:true
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["import-js"]={}))})(this,(function(e){"use strict";const t=(o,{async:i=!0}={})=>new Promise((r,s)=>{const n=document.createElement("script");n.src=o,n.async=i,n.onload=r,n.onerror=s,document.head.appendChild(n)});e.importJs=t,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
# isTouch
|
|
3
|
+
```ts
|
|
4
|
+
isTouch() : boolean
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A simple version to detect if device has touch. It checks if it has `touchstart` in window.
|
|
8
|
+
|
|
9
|
+
### Usage
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { isTouch } from 'jails.std/is-touch'
|
|
13
|
+
|
|
14
|
+
async function main () {
|
|
15
|
+
console.log( isTouch() ) // true if there's touchstart on window, or false otherwise.
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isTouch: () => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["is-touch"]={}))})(this,(function(e){"use strict";const t=()=>"ontouchstart"in window;e.isTouch=t,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
# isVisible
|
|
3
|
+
```ts
|
|
4
|
+
isVisible( target: HTMLElement, { root = null, rootMargin :'0px', threshold: 0 }?: IntersectionObserverOptions )
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A simple version of Intersection Observer API, that only handles the case where the callback is fired once for a specific `HTMLElement`.
|
|
8
|
+
It also wraps it in `Promise` so it can be used with `await` for more convinience.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import { isVisible } from 'jails.std/is-visible'
|
|
15
|
+
|
|
16
|
+
async function main () {
|
|
17
|
+
|
|
18
|
+
const element = document.querySelector('#target')
|
|
19
|
+
await isVisible( element )
|
|
20
|
+
|
|
21
|
+
console.log('Element is visible!')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const v = (e, { root: n = null, rootMargin: o = "0px", threshold: i = 0 } = {}) => new Promise((c, b) => {
|
|
2
|
+
const r = new IntersectionObserver((s) => {
|
|
3
|
+
s.forEach((t) => {
|
|
4
|
+
t.isIntersecting && (c(s), r.unobserve(e));
|
|
5
|
+
});
|
|
6
|
+
}, { root: n, rootMargin: o, threshold: i });
|
|
7
|
+
r.observe(e);
|
|
8
|
+
});
|
|
9
|
+
export {
|
|
10
|
+
v as isVisible
|
|
11
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
export const isVisible = ( target:HTMLElement, { root = null, rootMargin = '0px', threshold = 0 }: Options = {} as Options) => {
|
|
3
|
+
return new Promise((resolve, reject) => {
|
|
4
|
+
const observer = new IntersectionObserver((entries) => {
|
|
5
|
+
entries.forEach( entry => {
|
|
6
|
+
if( entry.isIntersecting ) {
|
|
7
|
+
resolve(entries)
|
|
8
|
+
observer.unobserve( target)
|
|
9
|
+
}
|
|
10
|
+
})
|
|
11
|
+
}, { root, rootMargin, threshold })
|
|
12
|
+
observer.observe( target )
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type Options = {
|
|
17
|
+
root?: HTMLElement
|
|
18
|
+
rootMargin?: string
|
|
19
|
+
threshold?: number
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,i){typeof exports=="object"&&typeof module!="undefined"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(e=typeof globalThis!="undefined"?globalThis:e||self,i(e["is-visible"]={}))})(this,(function(e){"use strict";const i=(n,{root:t=null,rootMargin:r="0px",threshold:f=0}={})=>new Promise((u,b)=>{const s=new IntersectionObserver(o=>{o.forEach(d=>{d.isIntersecting&&(u(o),s.unobserve(n))})},{root:t,rootMargin:r,threshold:f});s.observe(n)});e.isVisible=i,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# lazyload-image
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
LazyLoad ( options: LazyLoadOptions ): LazyLoadInstance
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A package to deal with lazy loading images.
|
|
8
|
+
It's in fact the [vanilla-lazyload](https://github.com/verlok/vanilla-lazyload) library, so anything you need to know it's on their documentation.
|
|
9
|
+
|
|
10
|
+
### Usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
|
|
14
|
+
import { Lazyload } from 'jails.std/lazyload-image'
|
|
15
|
+
|
|
16
|
+
function main () {
|
|
17
|
+
|
|
18
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
19
|
+
new Lazyload({
|
|
20
|
+
elements_selector: 'img[data-src]'
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<img data-src="some/image/resource/image.png" alt="Some image" />
|
|
28
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Lazyload: import("vanilla-lazyload").ILazyLoad;
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
const _ = typeof window != "undefined", S = _ && !("onscroll" in window) || typeof navigator != "undefined" && /(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent), J = _ && window.devicePixelRatio > 1, be = { elements_selector: ".lazy", container: S || _ ? document : null, threshold: 300, thresholds: null, data_src: "src", data_srcset: "srcset", data_sizes: "sizes", data_bg: "bg", data_bg_hidpi: "bg-hidpi", data_bg_multi: "bg-multi", data_bg_multi_hidpi: "bg-multi-hidpi", data_bg_set: "bg-set", data_poster: "poster", class_applied: "applied", class_loading: "loading", class_loaded: "loaded", class_error: "error", class_entered: "entered", class_exited: "exited", unobserve_completed: !0, unobserve_entered: !1, cancel_on_exit: !0, callback_enter: null, callback_exit: null, callback_applied: null, callback_loading: null, callback_loaded: null, callback_error: null, callback_finish: null, callback_cancel: null, use_native: !1, restore_on_error: !1 }, P = (e) => Object.assign({}, be, e), H = function(e, t) {
|
|
2
|
+
let n;
|
|
3
|
+
const s = "LazyLoad::Initialized", a = new e(t);
|
|
4
|
+
try {
|
|
5
|
+
n = new CustomEvent(s, { detail: { instance: a } });
|
|
6
|
+
} catch (l) {
|
|
7
|
+
n = document.createEvent("CustomEvent"), n.initCustomEvent(s, !1, !1, { instance: a });
|
|
8
|
+
}
|
|
9
|
+
window.dispatchEvent(n);
|
|
10
|
+
}, he = (e, t) => {
|
|
11
|
+
if (t) if (t.length) for (let n, s = 0; n = t[s]; s += 1) H(e, n);
|
|
12
|
+
else H(e, t);
|
|
13
|
+
}, r = "src", O = "srcset", C = "sizes", U = "poster", p = "llOriginalAttrs", q = "data", M = "loading", K = "loaded", Q = "applied", me = "entered", z = "error", W = "native", X = "data-", Y = "ll-status", o = (e, t) => e.getAttribute(X + t), fe = (e, t, n) => {
|
|
14
|
+
const s = X + t;
|
|
15
|
+
n !== null ? e.setAttribute(s, n) : e.removeAttribute(s);
|
|
16
|
+
}, v = (e) => o(e, Y), $ = (e, t) => fe(e, Y, t), I = (e) => $(e, null), N = (e) => v(e) === null, pe = (e) => v(e) === M, ve = (e) => v(e) === z, R = (e) => v(e) === W, Ee = [M, K, Q, z], Ie = (e) => Ee.indexOf(v(e)) >= 0, u = (e, t, n, s) => {
|
|
17
|
+
e && typeof e == "function" && (s === void 0 ? n === void 0 ? e(t) : e(t, n) : e(t, n, s));
|
|
18
|
+
}, h = (e, t) => {
|
|
19
|
+
_ && t !== "" && e.classList.add(t);
|
|
20
|
+
}, c = (e, t) => {
|
|
21
|
+
_ && t !== "" && e.classList.remove(t);
|
|
22
|
+
}, ke = (e) => {
|
|
23
|
+
e.llTempImage = document.createElement("IMG");
|
|
24
|
+
}, Ae = (e) => {
|
|
25
|
+
delete e.llTempImage;
|
|
26
|
+
}, Z = (e) => e.llTempImage, k = (e, t) => {
|
|
27
|
+
if (!t) return;
|
|
28
|
+
const n = t._observer;
|
|
29
|
+
n && n.unobserve(e);
|
|
30
|
+
}, ye = (e) => {
|
|
31
|
+
e.disconnect();
|
|
32
|
+
}, Le = (e, t, n) => {
|
|
33
|
+
t.unobserve_entered && k(e, n);
|
|
34
|
+
}, T = (e, t) => {
|
|
35
|
+
e && (e.loadingCount += t);
|
|
36
|
+
}, we = (e) => {
|
|
37
|
+
e && (e.toLoadCount -= 1);
|
|
38
|
+
}, ee = (e, t) => {
|
|
39
|
+
e && (e.toLoadCount = t);
|
|
40
|
+
}, xe = (e) => e.loadingCount > 0, Oe = (e) => e.toLoadCount > 0, te = (e) => {
|
|
41
|
+
let t = [];
|
|
42
|
+
for (let n, s = 0; n = e.children[s]; s += 1) n.tagName === "SOURCE" && t.push(n);
|
|
43
|
+
return t;
|
|
44
|
+
}, D = (e, t) => {
|
|
45
|
+
const n = e.parentNode;
|
|
46
|
+
n && n.tagName === "PICTURE" && te(n).forEach(t);
|
|
47
|
+
}, ne = (e, t) => {
|
|
48
|
+
te(e).forEach(t);
|
|
49
|
+
}, A = [r], se = [r, U], f = [r, O, C], ae = [q], y = (e) => !!e[p], le = (e) => e[p], oe = (e) => delete e[p], b = (e, t) => {
|
|
50
|
+
if (y(e)) return;
|
|
51
|
+
const n = {};
|
|
52
|
+
t.forEach(((s) => {
|
|
53
|
+
n[s] = e.getAttribute(s);
|
|
54
|
+
})), e[p] = n;
|
|
55
|
+
}, Ce = (e) => {
|
|
56
|
+
y(e) || (e[p] = { backgroundImage: e.style.backgroundImage });
|
|
57
|
+
}, g = (e, t) => {
|
|
58
|
+
if (!y(e)) return;
|
|
59
|
+
const n = le(e);
|
|
60
|
+
t.forEach(((s) => {
|
|
61
|
+
((a, l, i) => {
|
|
62
|
+
i ? a.setAttribute(l, i) : a.removeAttribute(l);
|
|
63
|
+
})(e, s, n[s]);
|
|
64
|
+
}));
|
|
65
|
+
}, Me = (e) => {
|
|
66
|
+
if (!y(e)) return;
|
|
67
|
+
const t = le(e);
|
|
68
|
+
e.style.backgroundImage = t.backgroundImage;
|
|
69
|
+
}, ce = (e, t, n) => {
|
|
70
|
+
h(e, t.class_applied), $(e, Q), n && (t.unobserve_completed && k(e, t), u(t.callback_applied, e, n));
|
|
71
|
+
}, re = (e, t, n) => {
|
|
72
|
+
h(e, t.class_loading), $(e, M), n && (T(n, 1), u(t.callback_loading, e, n));
|
|
73
|
+
}, d = (e, t, n) => {
|
|
74
|
+
n && e.setAttribute(t, n);
|
|
75
|
+
}, V = (e, t) => {
|
|
76
|
+
d(e, C, o(e, t.data_sizes)), d(e, O, o(e, t.data_srcset)), d(e, r, o(e, t.data_src));
|
|
77
|
+
}, ze = (e, t) => {
|
|
78
|
+
D(e, ((n) => {
|
|
79
|
+
b(n, f), V(n, t);
|
|
80
|
+
})), b(e, f), V(e, t);
|
|
81
|
+
}, Ne = (e, t) => {
|
|
82
|
+
b(e, A), d(e, r, o(e, t.data_src));
|
|
83
|
+
}, Re = (e, t) => {
|
|
84
|
+
ne(e, ((n) => {
|
|
85
|
+
b(n, A), d(n, r, o(n, t.data_src));
|
|
86
|
+
})), b(e, se), d(e, U, o(e, t.data_poster)), d(e, r, o(e, t.data_src)), e.load();
|
|
87
|
+
}, Te = (e, t) => {
|
|
88
|
+
b(e, ae), d(e, q, o(e, t.data_src));
|
|
89
|
+
}, De = (e, t, n) => {
|
|
90
|
+
const s = o(e, t.data_bg), a = o(e, t.data_bg_hidpi), l = J && a ? a : s;
|
|
91
|
+
l && (e.style.backgroundImage = `url("${l}")`, Z(e).setAttribute(r, l), re(e, t, n));
|
|
92
|
+
}, Ge = (e, t, n) => {
|
|
93
|
+
const s = o(e, t.data_bg_multi), a = o(e, t.data_bg_multi_hidpi), l = J && a ? a : s;
|
|
94
|
+
l && (e.style.backgroundImage = l, ce(e, t, n));
|
|
95
|
+
}, He = (e, t, n) => {
|
|
96
|
+
const s = o(e, t.data_bg_set);
|
|
97
|
+
if (!s) return;
|
|
98
|
+
let a = s.split("|").map(((l) => `image-set(${l})`));
|
|
99
|
+
e.style.backgroundImage = a.join(), ce(e, t, n);
|
|
100
|
+
}, ie = { IMG: ze, IFRAME: Ne, VIDEO: Re, OBJECT: Te }, Ve = (e, t) => {
|
|
101
|
+
const n = ie[e.tagName];
|
|
102
|
+
n && n(e, t);
|
|
103
|
+
}, je = (e, t, n) => {
|
|
104
|
+
const s = ie[e.tagName];
|
|
105
|
+
s && (s(e, t), re(e, t, n));
|
|
106
|
+
}, Be = ["IMG", "IFRAME", "VIDEO", "OBJECT"], Fe = (e) => Be.indexOf(e.tagName) > -1, de = (e, t) => {
|
|
107
|
+
!t || xe(t) || Oe(t) || u(e.callback_finish, t);
|
|
108
|
+
}, j = (e, t, n) => {
|
|
109
|
+
e.addEventListener(t, n), e.llEvLisnrs[t] = n;
|
|
110
|
+
}, Se = (e, t, n) => {
|
|
111
|
+
e.removeEventListener(t, n);
|
|
112
|
+
}, G = (e) => !!e.llEvLisnrs, Je = (e, t, n) => {
|
|
113
|
+
G(e) || (e.llEvLisnrs = {});
|
|
114
|
+
const s = e.tagName === "VIDEO" ? "loadeddata" : "load";
|
|
115
|
+
j(e, s, t), j(e, "error", n);
|
|
116
|
+
}, L = (e) => {
|
|
117
|
+
if (!G(e)) return;
|
|
118
|
+
const t = e.llEvLisnrs;
|
|
119
|
+
for (let n in t) {
|
|
120
|
+
const s = t[n];
|
|
121
|
+
Se(e, n, s);
|
|
122
|
+
}
|
|
123
|
+
delete e.llEvLisnrs;
|
|
124
|
+
}, _e = (e, t, n) => {
|
|
125
|
+
Ae(e), T(n, -1), we(n), c(e, t.class_loading), t.unobserve_completed && k(e, n);
|
|
126
|
+
}, Pe = (e, t, n, s) => {
|
|
127
|
+
const a = R(t);
|
|
128
|
+
_e(t, n, s), h(t, n.class_loaded), $(t, K), u(n.callback_loaded, t, s), a || de(n, s);
|
|
129
|
+
}, Ue = (e, t, n, s) => {
|
|
130
|
+
const a = R(t);
|
|
131
|
+
_e(t, n, s), h(t, n.class_error), $(t, z), u(n.callback_error, t, s), n.restore_on_error && g(t, f), a || de(n, s);
|
|
132
|
+
}, w = (e, t, n) => {
|
|
133
|
+
const s = Z(e) || e;
|
|
134
|
+
G(s) || Je(s, ((a) => {
|
|
135
|
+
Pe(0, e, t, n), L(s);
|
|
136
|
+
}), ((a) => {
|
|
137
|
+
Ue(0, e, t, n), L(s);
|
|
138
|
+
}));
|
|
139
|
+
}, x = (e, t, n) => {
|
|
140
|
+
Fe(e) ? ((s, a, l) => {
|
|
141
|
+
w(s, a, l), je(s, a, l);
|
|
142
|
+
})(e, t, n) : ((s, a, l) => {
|
|
143
|
+
ke(s), w(s, a, l), Ce(s), De(s, a, l), Ge(s, a, l), He(s, a, l);
|
|
144
|
+
})(e, t, n);
|
|
145
|
+
}, qe = (e, t, n) => {
|
|
146
|
+
e.setAttribute("loading", "lazy"), w(e, t, n), Ve(e, t), $(e, W);
|
|
147
|
+
}, B = (e) => {
|
|
148
|
+
e.removeAttribute(r), e.removeAttribute(O), e.removeAttribute(C);
|
|
149
|
+
}, Ke = (e) => {
|
|
150
|
+
D(e, ((t) => {
|
|
151
|
+
B(t);
|
|
152
|
+
})), B(e);
|
|
153
|
+
}, ue = (e) => {
|
|
154
|
+
D(e, ((t) => {
|
|
155
|
+
g(t, f);
|
|
156
|
+
})), g(e, f);
|
|
157
|
+
}, Qe = (e) => {
|
|
158
|
+
ne(e, ((t) => {
|
|
159
|
+
g(t, A);
|
|
160
|
+
})), g(e, se), e.load();
|
|
161
|
+
}, We = (e) => {
|
|
162
|
+
g(e, A);
|
|
163
|
+
}, Xe = (e) => {
|
|
164
|
+
g(e, ae);
|
|
165
|
+
}, Ye = { IMG: ue, IFRAME: We, VIDEO: Qe, OBJECT: Xe }, Ze = (e, t) => {
|
|
166
|
+
((n) => {
|
|
167
|
+
const s = Ye[n.tagName];
|
|
168
|
+
s ? s(n) : Me(n);
|
|
169
|
+
})(e), ((n, s) => {
|
|
170
|
+
N(n) || R(n) || (c(n, s.class_entered), c(n, s.class_exited), c(n, s.class_applied), c(n, s.class_loading), c(n, s.class_loaded), c(n, s.class_error));
|
|
171
|
+
})(e, t), I(e), oe(e);
|
|
172
|
+
}, et = (e, t, n, s) => {
|
|
173
|
+
n.cancel_on_exit && pe(e) && e.tagName === "IMG" && (L(e), Ke(e), ue(e), c(e, n.class_loading), T(s, -1), I(e), u(n.callback_cancel, e, t, s));
|
|
174
|
+
}, tt = (e, t, n, s) => {
|
|
175
|
+
const a = Ie(e);
|
|
176
|
+
$(e, me), h(e, n.class_entered), c(e, n.class_exited), Le(e, n, s), u(n.callback_enter, e, t, s), a || x(e, n, s);
|
|
177
|
+
}, nt = (e, t, n, s) => {
|
|
178
|
+
N(e) || (h(e, n.class_exited), et(e, t, n, s), u(n.callback_exit, e, t, s));
|
|
179
|
+
}, st = ["IMG", "IFRAME", "VIDEO"], ge = (e) => e.use_native && "loading" in HTMLImageElement.prototype, at = (e, t, n) => {
|
|
180
|
+
e.forEach(((s) => {
|
|
181
|
+
st.indexOf(s.tagName) !== -1 && qe(s, t, n);
|
|
182
|
+
})), ee(n, 0);
|
|
183
|
+
}, lt = (e) => e.isIntersecting || e.intersectionRatio > 0, ot = (e, t) => {
|
|
184
|
+
t.forEach(((n) => {
|
|
185
|
+
e.observe(n);
|
|
186
|
+
}));
|
|
187
|
+
}, ct = (e, t) => {
|
|
188
|
+
ye(e), ot(e, t);
|
|
189
|
+
}, rt = (e, t) => {
|
|
190
|
+
ge(e) || (t._observer = new IntersectionObserver(((n) => {
|
|
191
|
+
((s, a, l) => {
|
|
192
|
+
s.forEach(((i) => lt(i) ? tt(i.target, i, a, l) : nt(i.target, i, a, l)));
|
|
193
|
+
})(n, e, t);
|
|
194
|
+
}), ((n) => ({ root: n.container === document ? null : n.container, rootMargin: n.thresholds || n.threshold + "px" }))(e)));
|
|
195
|
+
}, $e = (e) => Array.prototype.slice.call(e), E = (e) => e.container.querySelectorAll(e.elements_selector), it = (e) => $e(e).filter(N), dt = (e) => ve(e), _t = (e) => $e(e).filter(dt), F = (e, t) => it(e || E(t)), ut = (e, t) => {
|
|
196
|
+
_t(E(e)).forEach(((n) => {
|
|
197
|
+
c(n, e.class_error), I(n);
|
|
198
|
+
})), t.update();
|
|
199
|
+
}, gt = (e, t) => {
|
|
200
|
+
_ && (t._onlineHandler = () => {
|
|
201
|
+
ut(e, t);
|
|
202
|
+
}, window.addEventListener("online", t._onlineHandler));
|
|
203
|
+
}, $t = (e) => {
|
|
204
|
+
_ && window.removeEventListener("online", e._onlineHandler);
|
|
205
|
+
}, m = function(e, t) {
|
|
206
|
+
const n = P(e);
|
|
207
|
+
this._settings = n, this.loadingCount = 0, rt(n, this), gt(n, this), this.update(t);
|
|
208
|
+
};
|
|
209
|
+
m.prototype = { update: function(e) {
|
|
210
|
+
const t = this._settings, n = F(e, t);
|
|
211
|
+
ee(this, n.length), S ? this.loadAll(n) : ge(t) ? at(n, t, this) : ct(this._observer, n);
|
|
212
|
+
}, destroy: function() {
|
|
213
|
+
this._observer && this._observer.disconnect(), $t(this), E(this._settings).forEach(((e) => {
|
|
214
|
+
oe(e);
|
|
215
|
+
})), delete this._observer, delete this._settings, delete this._onlineHandler, delete this.loadingCount, delete this.toLoadCount;
|
|
216
|
+
}, loadAll: function(e) {
|
|
217
|
+
const t = this._settings;
|
|
218
|
+
F(e, t).forEach(((n) => {
|
|
219
|
+
k(n, this), x(n, t, this);
|
|
220
|
+
}));
|
|
221
|
+
}, restoreAll: function() {
|
|
222
|
+
const e = this._settings;
|
|
223
|
+
E(e).forEach(((t) => {
|
|
224
|
+
Ze(t, e);
|
|
225
|
+
}));
|
|
226
|
+
} }, m.load = (e, t) => {
|
|
227
|
+
const n = P(t);
|
|
228
|
+
x(e, n);
|
|
229
|
+
}, m.resetStatus = (e) => {
|
|
230
|
+
I(e);
|
|
231
|
+
}, _ && he(m, window.lazyLoadOptions);
|
|
232
|
+
const bt = m;
|
|
233
|
+
export {
|
|
234
|
+
bt as Lazyload
|
|
235
|
+
};
|