jails-js 5.0.0-beta.13 โ 5.0.0-beta.14
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/.editorconfig +2 -0
- package/README.md +114 -48
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/logo.svg +29 -0
- package/package.json +4 -2
- package/src/component.ts +22 -25
- package/src/index.ts +5 -4
- package/src/template-system.ts +10 -14
- package/src/utils/index.ts +8 -8
- package/src/utils/pubsub.ts +5 -10
- package/tsconfig.json +105 -12
- package/types/component.d.ts +32 -0
- package/types/element.d.ts +311 -0
- package/types/index.d.ts +5 -0
- package/types/index.ts +41 -0
- package/types/template-system.d.ts +1 -0
- package/types/utils/events.d.ts +3 -0
- package/types/utils/index.d.ts +8 -0
- package/types/utils/pubsub.d.ts +2 -0
package/.editorconfig
CHANGED
package/README.md
CHANGED
@@ -1,88 +1,154 @@
|
|
1
1
|
<p align="center">
|
2
|
-
<img src="
|
2
|
+
<img src="./logo.svg" width="120" />
|
3
3
|
</p>
|
4
4
|
|
5
|
-
>
|
5
|
+
<h1 align="center">Jails - A Functional Component Library</h1>
|
6
6
|
|
7
|
-
|
7
|
+
<p align="center"><em>Jails is a component library to <br />add javascript behavior to Web Apps as close as possible to vanilla</em></p>
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
<p align="center">
|
10
|
+
<a href="https://jails-org.github.io/">https://jails-org.github.io/</a>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<div align="center">
|
14
|
+
<img src="https://badge.fury.io/js/jails-js.svg" alt="NPM Jails Version" />
|
15
|
+
<img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="MIT License" />
|
16
|
+
</div>
|
13
17
|
|
18
|
+
<br />
|
19
|
+
<br />
|
14
20
|
<br />
|
15
21
|
|
16
|
-
|
17
|
-
|
22
|
+
## Motivation
|
23
|
+
|
24
|
+
Jails was created to add a minimal layer of abstraction to build components for web applications without moving away from web standards and bringing good old technics to address complexities from modern apps like:
|
25
|
+
|
26
|
+
- **Decoupled** - Back-end agnostic, can be used with any back-end framework or language, does not import styles and does not mix html in the code.
|
27
|
+
- **Lightweight** - It's a very lightweight library (~9kb gzipped) and it makes your application progressively lite by keeping html away from your javascript code and therefore smaller bundles.
|
28
|
+
- **Interoperability** - It can be integrated and work with any other vanilla ui or behavioral libraries, so you don't have to wait for a Jails chartjs library in order to use, just integrate it in your app without pain.
|
29
|
+
|
30
|
+
<br />
|
31
|
+
<br />
|
32
|
+
|
33
|
+
## Best Scenarios to use
|
34
|
+
|
35
|
+
**Jails is better suited for SSR ( Static Site Rendered ):**
|
36
|
+
|
37
|
+
- Wordpress
|
38
|
+
- Laravel
|
39
|
+
- Ruby on Rails
|
40
|
+
- Node Backend with a Template System:
|
41
|
+
- Pug, Liquid, Nunjucks, Handlebars etc.
|
42
|
+
|
43
|
+
**Or SSG ( Static Site Generated ) like:**
|
44
|
+
|
45
|
+
- Hugo
|
46
|
+
- Astro
|
47
|
+
- Jekill
|
48
|
+
...etc
|
49
|
+
|
50
|
+
... Any site you can add a script tag on it =). So if you already have a engine that renders your html, Jails can be a good way to create an elegant event driven system.
|
51
|
+
|
52
|
+
<br />
|
53
|
+
<br />
|
54
|
+
|
55
|
+
## Demos & Docs
|
56
|
+
|
57
|
+
- [Online Examples & Playground](https://stackblitz.com/@Javiani/collections/jails-organization)
|
58
|
+
- [Documentation](https://jails-org.github.io/#/)
|
59
|
+
|
60
|
+
<br />
|
61
|
+
<br />
|
18
62
|
|
19
|
-
---
|
20
63
|
## Code Show
|
21
64
|
|
22
|
-
**index.
|
65
|
+
**components/ui-range/index.html**
|
23
66
|
|
24
67
|
```html
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
68
|
+
...
|
69
|
+
<ui-range class="range">
|
70
|
+
<label>Weight: <strong class="number">75</strong> kg</label><br />
|
71
|
+
<input type="range" name="weight" min="10" max="200" value="75" />
|
72
|
+
</ui-range>
|
73
|
+
...
|
29
74
|
```
|
30
75
|
|
31
|
-
**components/range/index.js**
|
76
|
+
**components/ui-range/index.js**
|
32
77
|
|
33
78
|
```js
|
34
|
-
export default function
|
79
|
+
export default function uirange ({ main, elm }) {
|
35
80
|
|
36
|
-
|
81
|
+
const number = elm.querySelector('.number')
|
37
82
|
|
38
|
-
|
39
|
-
|
40
|
-
|
83
|
+
main( _ =>[
|
84
|
+
register
|
85
|
+
])
|
41
86
|
|
42
|
-
|
43
|
-
|
44
|
-
|
87
|
+
const register = ({ on }) => {
|
88
|
+
on('input', 'input[type=range]', update )
|
89
|
+
}
|
45
90
|
|
46
|
-
|
47
|
-
|
48
|
-
|
91
|
+
const update = event => {
|
92
|
+
number.innerText = event.target.value
|
93
|
+
}
|
49
94
|
})
|
50
95
|
```
|
51
96
|
|
52
97
|
### With State Management
|
53
98
|
|
54
|
-
|
55
|
-
<x-range class="range">
|
56
|
-
<template>
|
57
|
-
<label>Weight: <strong class="number">{{ number }}</strong> kg</label><br />
|
58
|
-
<input type="range" name="weight" min="10" max="200" value="75" data-static />
|
59
|
-
</template>
|
60
|
-
</x-range>
|
61
|
-
```
|
62
|
-
|
63
|
-
**components/range/index.js**
|
99
|
+
**components/ui-range/index.js**
|
64
100
|
|
65
101
|
```js
|
66
|
-
export default function
|
102
|
+
export default function uirange ({ main, state }) {
|
67
103
|
|
68
|
-
|
69
|
-
|
70
|
-
|
104
|
+
main( _ =>[
|
105
|
+
register
|
106
|
+
])
|
71
107
|
|
72
|
-
|
73
|
-
|
74
|
-
|
108
|
+
const register = ({ on }) => {
|
109
|
+
on('input', 'input[type=range]', update )
|
110
|
+
}
|
75
111
|
|
76
|
-
|
77
|
-
|
78
|
-
|
112
|
+
const update = event => {
|
113
|
+
state.set({ number: event.target.value }) // or
|
114
|
+
// state.set( s => s.number = event.target.value ) // If you need to use the previous state
|
115
|
+
}
|
79
116
|
})
|
80
117
|
|
81
118
|
export const model = {
|
82
|
-
|
119
|
+
number: 75
|
83
120
|
}
|
84
121
|
```
|
122
|
+
|
123
|
+
**components/ui-range/index.html**
|
124
|
+
|
125
|
+
```html
|
126
|
+
...
|
127
|
+
<ui-range class="range">
|
128
|
+
<label>Weight: <strong class="number" v-html="number">75</strong> kg</label
|
129
|
+
><br />
|
130
|
+
<input type="range" name="weight" min="10" max="200" value="75" html-static />
|
131
|
+
</ui-range>
|
132
|
+
|
133
|
+
// Or using template tags
|
134
|
+
|
135
|
+
<ui-range class="range">
|
136
|
+
<template>
|
137
|
+
<label>Weight: <strong class="number">{number}</strong> kg</label><br />
|
138
|
+
<input
|
139
|
+
type="range"
|
140
|
+
name="weight"
|
141
|
+
min="10"
|
142
|
+
max="200"
|
143
|
+
value="75"
|
144
|
+
html-static
|
145
|
+
/>
|
146
|
+
</template>
|
147
|
+
</ui-range>
|
148
|
+
```
|
149
|
+
|
85
150
|
<br />
|
86
151
|
|
87
152
|
## License
|
153
|
+
|
88
154
|
[MIT](http://opensource.org/licenses/MIT)
|
package/dist/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("jails",[],t):"object"==typeof exports?exports.jails=t():e.jails=t()}(self,(()=>(()=>{var e={641:function(e,t){!function(e){"use strict";function t(e){var n,r,a=new Error(e);return n=a,r=t.prototype,Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,a}function n(e,n,r){var a=n.slice(0,r).split(/\n/),o=a.length,i=a[o-1].length+1;throw t(e+=" at line "+o+" col "+i+":\n\n "+n.split(/\n/)[o-1]+"\n "+Array(i).join(" ")+"^")}t.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});var r=new Function("return this")().Promise,a=!1;try{a=new Function("return (async function(){}).constructor")()}catch(e){if(!(e instanceof SyntaxError))throw e}var o=function(e,t){return"(function(){ try{ return "+e+" }catch(err) { return "+t+"} })()"};function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function s(e,t,n){for(var r in t)i(t,r)&&(null==t[r]||"object"!=typeof t[r]||"storage"!==r&&"prefixes"!==r||n?e[r]=t[r]:e[r]=s({},t[r]));return e}var c=/^async +/,l=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,u=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,d=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,f=/[.*+\-?^${}()|[\]\\]/g;function p(e){return f.test(e)?e.replace(f,"\\$&"):e}function m(e,r){r.rmWhitespace&&(e=e.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),l.lastIndex=0,u.lastIndex=0,d.lastIndex=0;var a=r.prefixes,o=[a.h,a.b,a.i,a.r,a.c,a.e].reduce((function(e,t){return e&&t?e+"|"+p(t):t?p(t):e}),""),i=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+p(r.tags[1])+")","g"),s=new RegExp("([^]*?)"+p(r.tags[0])+"(-|_)?\\s*("+o+")?\\s*","g"),f=0,m=!1;function h(t,a){var o,p={f:[]},h=0,v="c";function g(t){var a=e.slice(f,t),o=a.trim();if("f"===v)"safe"===o?p.raw=!0:r.async&&c.test(o)?(o=o.replace(c,""),p.f.push([o,"",!0])):p.f.push([o,""]);else if("fp"===v)p.f[p.f.length-1][1]+=o;else if("err"===v){if(o){var i=a.search(/\S/);n("invalid syntax",e,f+i)}}else p[v]=o;f=t+1}for("h"===a||"b"===a||"c"===a?v="n":"r"===a&&(p.raw=!0,a="i"),i.lastIndex=f;null!==(o=i.exec(e));){var b=o[1],y=o[2],x=o[3],A=o[4],N=o[5],S=o.index;if(b)"("===b?(0===h&&("n"===v?(g(S),v="p"):"f"===v&&(g(S),v="fp")),h++):")"===b?0==--h&&"c"!==v&&(g(S),v="err"):0===h&&"|"===b?(g(S),v="f"):"=>"===b&&(g(S),f+=1,v="res");else if(y)if("/*"===y){var _=e.indexOf("*/",i.lastIndex);-1===_&&n("unclosed comment",e,o.index),i.lastIndex=_+2}else"'"===y?(u.lastIndex=o.index,u.exec(e)?i.lastIndex=u.lastIndex:n("unclosed string",e,o.index)):'"'===y?(d.lastIndex=o.index,d.exec(e)?i.lastIndex=d.lastIndex:n("unclosed string",e,o.index)):"`"===y&&(l.lastIndex=o.index,l.exec(e)?i.lastIndex=l.lastIndex:n("unclosed string",e,o.index));else if(x)return g(S),f=S+o[0].length,s.lastIndex=f,m=N,A&&"h"===a&&(a="s"),p.t=a,p}return n("unclosed tag",e,t),p}var v=function o(i,l){i.b=[],i.d=[];var u,d=!1,p=[];function v(e,t){e&&(e=function(e,t,n,r){var a,o;return"string"==typeof t.autoTrim?a=o=t.autoTrim:Array.isArray(t.autoTrim)&&(a=t.autoTrim[1],o=t.autoTrim[0]),(n||!1===n)&&(a=n),(r||!1===r)&&(o=r),"slurp"===a&&"slurp"===o?e.trim():("_"===a||"slurp"===a?e=String.prototype.trimLeft?e.trimLeft():e.replace(/^[\s\uFEFF\xA0]+/,""):"-"!==a&&"nl"!==a||(e=e.replace(/^(?:\n|\r|\r\n)/,"")),"_"===o||"slurp"===o?e=String.prototype.trimRight?e.trimRight():e.replace(/[\s\uFEFF\xA0]+$/,""):"-"!==o&&"nl"!==o||(e=e.replace(/(?:\n|\r|\r\n)$/,"")),e)}(e,r,m,t))&&(e=e.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),p.push(e))}for(;null!==(u=s.exec(e));){var g,b=u[1],y=u[2],x=u[3]||"";for(var A in a)if(a[A]===x){g=A;break}v(b,y),f=u.index+u[0].length,g||n("unrecognized tag type: "+x,e,f);var N=h(u.index,g),S=N.t;if("h"===S){var _=N.n||"";r.async&&c.test(_)&&(N.a=!0,N.n=_.replace(c,"")),N=o(N),p.push(N)}else if("c"===S){if(i.n===N.n)return d?(d.d=p,i.b.push(d)):i.d=p,i;n("Helper start and end don't match",e,u.index+u[0].length)}else if("b"===S){d?(d.d=p,i.b.push(d)):i.d=p;var w=N.n||"";r.async&&c.test(w)&&(N.a=!0,N.n=w.replace(c,"")),d=N,p=[]}else if("s"===S){var E=N.n||"";r.async&&c.test(E)&&(N.a=!0,N.n=E.replace(c,"")),p.push(N)}else p.push(N)}if(!l)throw t('unclosed helper "'+i.n+'"');return v(e.slice(f,e.length),!1),i.d=p,i}({f:[]},!0);if(r.plugins)for(var g=0;g<r.plugins.length;g++){var b=r.plugins[g];b.processAST&&(v.d=b.processAST(v.d,r))}return v.d}function h(e,t){var n=m(e,t),r="var tR='';"+(t.useWith?"with("+t.varName+"||{}){":"")+x(n,t)+"if(cb){cb(null,tR)} return tR"+(t.useWith?"}":"");if(t.plugins)for(var a=0;a<t.plugins.length;a++){var o=t.plugins[a];o.processFnString&&(r=o.processFnString(r,t))}return r}function v(e,t){for(var n=0;n<t.length;n++){var r=t[n][0],a=t[n][1];e=(t[n][2]?"await ":"")+"c.l('F','"+r+"')("+e,a&&(e+=","+a),e+=")"}return e}function g(e,t,n,r,a,o){var i="{exec:"+(a?"async ":"")+y(n,t,e)+",params:["+r+"]";return o&&(i+=",name:'"+o+"'"),a&&(i+=",async:true"),i+"}"}function b(e,t){for(var n="[",r=0;r<e.length;r++){var a=e[r];n+=g(t,a.res||"",a.d,a.p||"",a.a,a.n),r<e.length&&(n+=",")}return n+"]"}function y(e,t,n){return"function("+t+"){var tR='';"+x(e,n)+"return tR}"}function x(e,t){for(var n=0,r=e.length,a="";n<r;n++){var i=e[n];if("string"==typeof i)a+="tR+='"+i+"';";else{i.c=o(i.c||"",""),i.p=o(i.p||"","");var s=i.t,c=i.c,l=i.f,u=i.n||"",d=i.p,f=i.res||"",p=i.b,m=!!i.a;if("i"===s){t.defaultFilter&&(c="c.l('F','"+t.defaultFilter+"')("+c+")");var h=v(c,l);!i.raw&&t.autoEscape&&(h="c.l('F','e')("+h+")"),a+="tR+="+h+";"}else if("h"===s)if(t.storage.nativeHelpers.get(u))a+=t.storage.nativeHelpers.get(u)(i,t);else{var y=(m?"await ":"")+"c.l('H','"+u+"')("+g(t,f,i.d,d,m);y+=p?","+b(p,t):",[]",a+="tR+="+v(y+=",c)",l)+";"}else"s"===s?a+="tR+="+v((m?"await ":"")+"c.l('H','"+u+"')({params:["+d+"]},[],c)",l)+";":"e"===s&&(a+=c+"\n")}}return a}var A=function(){function e(e){this.cache=e}return e.prototype.define=function(e,t){this.cache[e]=t},e.prototype.get=function(e){return this.cache[e]},e.prototype.remove=function(e){delete this.cache[e]},e.prototype.reset=function(){this.cache={}},e.prototype.load=function(e){s(this.cache,e,!0)},e}();function N(e,n,r,a){if(n&&n.length>0)throw t((a?"Native":"")+"Helper '"+e+"' doesn't accept blocks");if(r&&r.length>0)throw t((a?"Native":"")+"Helper '"+e+"' doesn't accept filters")}var S={"&":"&","<":"<",">":">",'"':""","'":"'"};function _(e){return S[e]}var w=new A({}),E=new A({each:function(e,t){var n="",r=e.params[0];if(N("each",t,!1),e.async)return new Promise((function(t){!function e(t,n,r,a,o){r(t[n],n).then((function(i){a+=i,n===t.length-1?o(a):e(t,n+1,r,a,o)}))}(r,0,e.exec,n,t)}));for(var a=0;a<r.length;a++)n+=e.exec(r[a],a);return n},foreach:function(e,t){var n=e.params[0];if(N("foreach",t,!1),e.async)return new Promise((function(t){!function e(t,n,r,a,o,i){a(n[r],t[n[r]]).then((function(s){o+=s,r===n.length-1?i(o):e(t,n,r+1,a,o,i)}))}(n,Object.keys(n),0,e.exec,"",t)}));var r="";for(var a in n)i(n,a)&&(r+=e.exec(a,n[a]));return r},include:function(e,n,r){N("include",n,!1);var a=r.storage.templates.get(e.params[0]);if(!a)throw t('Could not fetch template "'+e.params[0]+'"');return a(e.params[1],r)},extends:function(e,n,r){var a=e.params[1]||{};a.content=e.exec();for(var o=0;o<n.length;o++){var i=n[o];a[i.name]=i.exec()}var s=r.storage.templates.get(e.params[0]);if(!s)throw t('Could not fetch template "'+e.params[0]+'"');return s(a,r)},useScope:function(e,t){return N("useScope",t,!1),e.exec(e.params[0])}}),T=new A({if:function(e,t){N("if",!1,e.f,!0);var n="if("+e.p+"){"+x(e.d,t)+"}";if(e.b)for(var r=0;r<e.b.length;r++){var a=e.b[r];"else"===a.n?n+="else{"+x(a.d,t)+"}":"elif"===a.n&&(n+="else if("+a.p+"){"+x(a.d,t)+"}")}return n},try:function(e,n){if(N("try",!1,e.f,!0),!e.b||1!==e.b.length||"catch"!==e.b[0].n)throw t("native helper 'try' only accepts 1 block, 'catch'");var r="try{"+x(e.d,n)+"}",a=e.b[0];return r+"catch"+(a.res?"("+a.res+")":"")+"{"+x(a.d,n)+"}"},block:function(e,t){return N("block",e.b,e.f,!0),"if(!"+t.varName+"["+e.p+"]){tR+=("+y(e.d,"",t)+")()}else{tR+="+t.varName+"["+e.p+"]}"}}),C=new A({e:function(e){var t=String(e);return/[&<>"']/.test(t)?t.replace(/[&<>"']/g,_):t}}),O={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function(e,n){if("H"===e){var r=this.storage.helpers.get(n);if(r)return r;throw t("Can't find helper '"+n+"'")}if("F"===e){var a=this.storage.filters.get(n);if(a)return a;throw t("Can't find filter '"+n+"'")}},async:!1,storage:{helpers:E,nativeHelpers:T,filters:C,templates:w},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function R(e,t){var n={};return s(n,O),t&&s(n,t),e&&s(n,e),n.l.bind(n),n}function $(e,n){var r=R(n||{}),o=Function;if(r.async){if(!a)throw t("This environment doesn't support async/await");o=a}try{return new o(r.varName,"c","cb",h(e,r))}catch(n){throw n instanceof SyntaxError?t("Bad template syntax\n\n"+n.message+"\n"+Array(n.message.length+1).join("=")+"\n"+h(e,r)):n}}function I(e,t){var n;return t.cache&&t.name&&t.storage.templates.get(t.name)?t.storage.templates.get(t.name):(n="function"==typeof e?e:$(e,t),t.cache&&t.name&&t.storage.templates.define(t.name,n),n)}O.l.bind(O),e.compile=$,e.compileScope=x,e.compileScopeIntoFunction=y,e.compileToString=h,e.defaultConfig=O,e.filters=C,e.getConfig=R,e.helpers=E,e.nativeHelpers=T,e.parse=m,e.render=function(e,n,a,o){var i=R(a||{});if(!i.async)return I(e,i)(n,i);if(!o){if("function"==typeof r)return new r((function(t,r){try{t(I(e,i)(n,i))}catch(e){r(e)}}));throw t("Please provide a callback function, this env doesn't support Promises")}try{I(e,i)(n,i,o)}catch(e){return o(e)}},e.templates=w,Object.defineProperty(e,"__esModule",{value:!0})}(t)}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{components:()=>k,default:()=>H,templates:()=>P});var e=n(641);const t={...e.defaultConfig,tags:["{","}"],useWith:!0};e.filters.define("JSON",((e,t,n)=>{const r=t.constructor==String?"$key":"$index",a={$index:t};return a[n]=e,a[r]=t,JSON.stringify(a)}));const a=(e,t,n)=>{t.parentNode?.insertBefore(e,t),t.parentNode?.insertBefore(n,t.nextSibling)},o=document.createElement("textarea"),i=e=>requestAnimationFrame?requestAnimationFrame(e):setTimeout(e,1e3/60),s=e=>JSON.parse(JSON.stringify(e)),c=(n,r)=>{if(!n.getAttribute("tplid")){const o="xxxxxxxx".replace(/[xy]/g,(e=>{const t=8*Math.random()|0;return("x"==e?t:3&t|8).toString(8)}));n.setAttribute("tplid",o),r[o]=function(n){const r=document.createElement("template");r.innerHTML=n.outerHTML.replace(/<\/?template[^>]*>/g,""),(e=>{const t=Array.from(e.querySelectorAll("[html-for],[html-if],[html-foreach]")).reverse();t.length&&t.forEach((e=>{if(e.getAttribute("html-foreach")){const t=(e.getAttribute("html-foreach")||"").match(/(.*)\sin\s(.*)/)||"",n=t[1],r=t[2];e.removeAttribute("html-foreach"),e.setAttribute("scope",`{${n} | JSON($key, '${n}')}`);const o=document.createTextNode(`{@foreach(${r}) => $key, ${n}}`),i=document.createTextNode("{/foreach}");a(o,e,i)}else if(e.getAttribute("html-for")){const t=(e.getAttribute("html-for")||"").match(/(.*)\sin\s(.*)/)||"",n=t[1],r=t[2];e.removeAttribute("html-for"),e.setAttribute("scope",`{${n} | JSON($index, '${n}')}`);const o=document.createTextNode(`{@each(${r}) => ${n}, $index}`),i=document.createTextNode("{/each}");a(o,e,i)}else if(e.getAttribute("html-if")){const t=e.getAttribute("html-if");e.removeAttribute("html-if");const n=document.createTextNode(`{@if (${t}) }`),r=document.createTextNode("{/if}");a(n,e,r)}}))})(r.content);const o=u(r.innerHTML.replace(/html-(selected|checked|readonly|disabled|autoplay)=\"(.*)\"/g,"{@if ($2) }$1{/if}").replace(/html-/g,"")),i=(0,e.compile)(o,t);return e=>i(e,t)}(n)}},l=(e,t,n)=>Array.from(e.querySelectorAll("*")).filter((e=>e.tagName.toLowerCase()in t)).reverse().map((e=>(Array.from(e.querySelectorAll("template")).map((e=>l(e.content,t,n))),c(e,n),e))),u=e=>(o.innerHTML=e,o.value);var d,f="undefined"==typeof document?void 0:document,p=!!f&&"content"in f.createElement("template"),m=!!f&&f.createRange&&"createContextualFragment"in f.createRange();function h(e,t){var n,r,a=e.nodeName,o=t.nodeName;return a===o||(n=a.charCodeAt(0),r=o.charCodeAt(0),n<=90&&r>=97?a===o.toUpperCase():r<=90&&n>=97&&o===a.toUpperCase())}function v(e,t,n){e[n]!==t[n]&&(e[n]=t[n],e[n]?e.setAttribute(n,""):e.removeAttribute(n))}var g={OPTION:function(e,t){var n=e.parentNode;if(n){var r=n.nodeName.toUpperCase();"OPTGROUP"===r&&(r=(n=n.parentNode)&&n.nodeName.toUpperCase()),"SELECT"!==r||n.hasAttribute("multiple")||(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),n.selectedIndex=-1)}v(e,t,"selected")},INPUT:function(e,t){v(e,t,"checked"),v(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var n=t.value;e.value!==n&&(e.value=n);var r=e.firstChild;if(r){var a=r.nodeValue;if(a==n||!n&&a==e.placeholder)return;r.nodeValue=n}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var n,r,a=-1,o=0,i=e.firstChild;i;)if("OPTGROUP"===(r=i.nodeName&&i.nodeName.toUpperCase()))i=(n=i).firstChild;else{if("OPTION"===r){if(i.hasAttribute("selected")){a=o;break}o++}!(i=i.nextSibling)&&n&&(i=n.nextSibling,n=null)}e.selectedIndex=a}}};function b(){}function y(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}const x=function(e,t,n){if(n||(n={}),"string"==typeof t)if("#document"===e.nodeName||"HTML"===e.nodeName||"BODY"===e.nodeName){var r=t;(t=f.createElement("html")).innerHTML=r}else a=(a=t).trim(),t=p?function(e){var t=f.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}(a):m?function(e){return d||(d=f.createRange()).selectNode(f.body),d.createContextualFragment(e).childNodes[0]}(a):function(e){var t=f.createElement("body");return t.innerHTML=e,t.childNodes[0]}(a);var a,o=n.getNodeKey||y,i=n.onBeforeNodeAdded||b,s=n.onNodeAdded||b,c=n.onBeforeElUpdated||b,l=n.onElUpdated||b,u=n.onBeforeNodeDiscarded||b,v=n.onNodeDiscarded||b,x=n.onBeforeElChildrenUpdated||b,A=!0===n.childrenOnly,N=Object.create(null),S=[];function _(e){S.push(e)}function w(e,t){if(1===e.nodeType)for(var n=e.firstChild;n;){var r=void 0;t&&(r=o(n))?_(r):(v(n),n.firstChild&&w(n,t)),n=n.nextSibling}}function E(e,t,n){!1!==u(e)&&(t&&t.removeChild(e),v(e),w(e,n))}function T(e){s(e);for(var t=e.firstChild;t;){var n=t.nextSibling,r=o(t);if(r){var a=N[r];a&&h(t,a)?(t.parentNode.replaceChild(a,t),C(a,t)):T(t)}else T(t);t=n}}function C(e,t,n){var r=o(t);if(r&&delete N[r],!n){if(!1===c(e,t))return;if(function(e,t){var n,r,a,o,i=t.attributes;if(11!==t.nodeType&&11!==e.nodeType){for(var s=i.length-1;s>=0;s--)r=(n=i[s]).name,a=n.namespaceURI,o=n.value,a?(r=n.localName||r,e.getAttributeNS(a,r)!==o&&("xmlns"===n.prefix&&(r=n.name),e.setAttributeNS(a,r,o))):e.getAttribute(r)!==o&&e.setAttribute(r,o);for(var c=e.attributes,l=c.length-1;l>=0;l--)r=(n=c[l]).name,(a=n.namespaceURI)?(r=n.localName||r,t.hasAttributeNS(a,r)||e.removeAttributeNS(a,r)):t.hasAttribute(r)||e.removeAttribute(r)}}(e,t),l(e),!1===x(e,t))return}"TEXTAREA"!==e.nodeName?function(e,t){var n,r,a,s,c,l=t.firstChild,u=e.firstChild;e:for(;l;){for(s=l.nextSibling,n=o(l);u;){if(a=u.nextSibling,l.isSameNode&&l.isSameNode(u)){l=s,u=a;continue e}r=o(u);var d=u.nodeType,p=void 0;if(d===l.nodeType&&(1===d?(n?n!==r&&((c=N[n])?a===c?p=!1:(e.insertBefore(c,u),r?_(r):E(u,e,!0),u=c):p=!1):r&&(p=!1),(p=!1!==p&&h(u,l))&&C(u,l)):3!==d&&8!=d||(p=!0,u.nodeValue!==l.nodeValue&&(u.nodeValue=l.nodeValue))),p){l=s,u=a;continue e}r?_(r):E(u,e,!0),u=a}if(n&&(c=N[n])&&h(c,l))e.appendChild(c),C(c,l);else{var m=i(l);!1!==m&&(m&&(l=m),l.actualize&&(l=l.actualize(e.ownerDocument||f)),e.appendChild(l),T(l))}l=s,u=a}!function(e,t,n){for(;t;){var r=t.nextSibling;(n=o(t))?_(n):E(t,e,!0),t=r}}(e,u,r);var v=g[e.nodeName];v&&v(e,t)}(e,t):g.TEXTAREA(e,t)}!function e(t){if(1===t.nodeType||11===t.nodeType)for(var n=t.firstChild;n;){var r=o(n);r&&(N[r]=n),e(n),n=n.nextSibling}}(e);var O,R,$=e,I=$.nodeType,j=t.nodeType;if(!A)if(1===I)1===j?h(e,t)||(v(e),$=function(e,t){for(var n=e.firstChild;n;){var r=n.nextSibling;t.appendChild(n),n=r}return t}(e,(O=t.nodeName,(R=t.namespaceURI)&&"http://www.w3.org/1999/xhtml"!==R?f.createElementNS(R,O):f.createElement(O)))):$=t;else if(3===I||8===I){if(j===I)return $.nodeValue!==t.nodeValue&&($.nodeValue=t.nodeValue),$;$=t}if($===t)v(e);else{if(t.isSameNode&&t.isSameNode($))return;if(C($,t,A),S)for(var F=0,P=S.length;F<P;F++){var k=N[S[F]];k&&E(k,k.parentNode,!1)}}return!A&&$!==e&&e.parentNode&&($.actualize&&($=$.actualize(e.ownerDocument||f)),e.parentNode.replaceChild($,e)),$},A="CustomEvent"in window&&"function"==typeof window.CustomEvent?(e,t)=>new CustomEvent(e,t):(e,t)=>{const n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!0,!0,t),n},N=(e,t)=>function(n){const r=this,a=n.detail||{};e.__events[t].forEach((e=>{e.handler.apply(r,[n].concat(a.args))}))},S=(e,t)=>{e.__events[t]&&e.__events[t].listener&&(e.removeEventListener(t,e.__events[t].listener,"focus"==t||"blur"==t||"mouseenter"==t||"mouseleave"==t),delete e.__events[t])},_=(e,t,n)=>function(r){const a=this,o=r.detail||{};let i=r.target;for(;i&&(i.matches(t)&&(r.delegateTarget=i,n.apply(a,[r].concat(o.args))),i!==e);)i=i.parentNode},w=(e,t,n)=>{e.dispatchEvent(A(t,{bubbles:!0,detail:n}))},E={},T={},C=(e,t)=>{T[e]=Object.assign({},T[e],t),E[e]&&E[e].forEach((e=>e(t)))},O=(e,t)=>{E[e]=E[e]||[],E[e].push(t),e in T&&t(T[e])},R=e=>{E[e.name]=(E[e.name]||[]).filter((t=>t!=e.method)),E[e.name].length||(delete E[e.name],delete T[e.name])};const $=e=>({main:e=>e,unmount:e=>e,onupdate:e=>e,view:e.view?e.view:e=>e}),I=(e,t)=>({onNodeAdded:F(e,t),onElUpdated:F(e,t),onBeforeElChildrenUpdated:j,onBeforeElUpdated:j,getNodeKey:e=>!(1!==e.nodeType||!e.getAttribute("tplid"))&&(e.dataset.key||e.getAttribute("tplid"))}),j=e=>{if("static"in e.dataset)return!1},F=(e,t)=>n=>{if(1===n.nodeType&&n.getAttribute&&n.getAttribute("scope")){const r=JSON.parse((n.getAttribute("scope")||"").replace(/\'/g,'"'));Array.from(n.querySelectorAll("[tplid]")).map((n=>{const a=Object.assign({},e.base.state.get(),r);t.onupdate(a),n.base.render(a)})),n.removeAttribute("scope")}return n},P={},k={},H={register(e,t,n={}){k[e]={name:e,module:t,dependencies:n}},start(){const e=document.body;l(e,k,P),U()}},U=()=>{Object.values(k).forEach((e=>{const{name:t,module:n,dependencies:r}=e,a=function(e,t,n,r){return class extends HTMLElement{base;options;__events;constructor(){super();const{base:a,options:o}=function(e,{module:t,dependencies:n,templates:r,components:a}){const o=$(t);l(e,a,r);const c=e.getAttribute("tplid"),u=c?r[c]:null,d={data:t.model?s(t.model):{}},f={template:u,elm:e,dependencies:n,publish:C,subscribe:O,unsubscribe:R,main(e){o.main=e},unmount(e){o.unmount=e},onupdate(e){o.onupdate=e},on(t,n,r){((e,t,n,r)=>{if(e.__events=e.__events||{},e.__events[t]=e.__events[t]||[],!e.__events[t].length){const n=N(e,t);e.addEventListener(t,n,"focus"==t||"blur"==t||"mouseenter"==t||"mouseleave"==t),e.__events[t].listener=n}n.call?e.__events[t].push({handler:n,callback:n}):e.__events[t].push({handler:_(e,n,r),callback:r})})(e,t,n,r)},off(t,n){((e,t,n)=>{if(n&&e.__events[t]&&e.__events[t].length){var r=e.__events[t];e.__events[t]=e.__events[t].filter((function(e){return e.callback!=n})),e.__events[t].listener=r.listener,e.__events[t].length||S(e,t)}else S(e,t)})(e,t,n)},trigger(t,n,r){n.constructor===String?Array.from(e.querySelectorAll(n)).forEach((e=>w(e,t,{args:r}))):w(e,t,{args:n})},emit:(...t)=>{w(e,t.shift(),{args:t})},state:{set(e){if(e.constructor===Function){const t=s(d.data);e(t),f.render(t)}else f.render(e);return new Promise((e=>i((t=>i(e)))))},get:()=>s(d.data)},render(t=d.data){if(!document.body.contains(e))return;d.data=Object.assign(d.data,t);const n=s(d.data),r=f.template(o.view(n));x(e,r,I(e,o)),i((t=>{Array.from(e.querySelectorAll("[tplid]")).forEach((e=>{e.options.onupdate(n),e.base.render(n)}))}))}};return{base:f,options:o}}(this,{module:e,dependencies:t,templates:n,components:r});this.base=a,this.options=o,e.default(a)}connectedCallback(){this.base.render(),this.options.main().forEach((e=>e(this.base)))}disconnectedCallback(){this.options.unmount(this.base),delete this.options,delete this.base,delete this.__events}attributeChangedCallback(){}}}(n,r,P,k);customElements.define(t,a)}))}})(),r})()));
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("jails",[],t):"object"==typeof exports?exports.jails=t():e.jails=t()}(self,(()=>(()=>{var e={492:(e,t,n)=>{"use strict";var r;n.r(t),n.d(t,{default:()=>f});var a="undefined"==typeof document?void 0:document,i=!!a&&"content"in a.createElement("template"),o=!!a&&a.createRange&&"createContextualFragment"in a.createRange();function s(e,t){var n,r,a=e.nodeName,i=t.nodeName;return a===i||(n=a.charCodeAt(0),r=i.charCodeAt(0),n<=90&&r>=97?a===i.toUpperCase():r<=90&&n>=97&&i===a.toUpperCase())}function l(e,t,n){e[n]!==t[n]&&(e[n]=t[n],e[n]?e.setAttribute(n,""):e.removeAttribute(n))}var c={OPTION:function(e,t){var n=e.parentNode;if(n){var r=n.nodeName.toUpperCase();"OPTGROUP"===r&&(r=(n=n.parentNode)&&n.nodeName.toUpperCase()),"SELECT"!==r||n.hasAttribute("multiple")||(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),n.selectedIndex=-1)}l(e,t,"selected")},INPUT:function(e,t){l(e,t,"checked"),l(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var n=t.value;e.value!==n&&(e.value=n);var r=e.firstChild;if(r){var a=r.nodeValue;if(a==n||!n&&a==e.placeholder)return;r.nodeValue=n}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var n,r,a=-1,i=0,o=e.firstChild;o;)if("OPTGROUP"===(r=o.nodeName&&o.nodeName.toUpperCase()))o=(n=o).firstChild;else{if("OPTION"===r){if(o.hasAttribute("selected")){a=i;break}i++}!(o=o.nextSibling)&&n&&(o=n.nextSibling,n=null)}e.selectedIndex=a}}};function u(){}function d(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}const f=function(e,t,n){if(n||(n={}),"string"==typeof t)if("#document"===e.nodeName||"HTML"===e.nodeName||"BODY"===e.nodeName){var l=t;(t=a.createElement("html")).innerHTML=l}else f=(f=t).trim(),t=i?function(e){var t=a.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}(f):o?function(e){return r||(r=a.createRange()).selectNode(a.body),r.createContextualFragment(e).childNodes[0]}(f):function(e){var t=a.createElement("body");return t.innerHTML=e,t.childNodes[0]}(f);var f,p=n.getNodeKey||d,m=n.onBeforeNodeAdded||u,h=n.onNodeAdded||u,v=n.onBeforeElUpdated||u,g=n.onElUpdated||u,b=n.onBeforeNodeDiscarded||u,y=n.onNodeDiscarded||u,x=n.onBeforeElChildrenUpdated||u,_=!0===n.childrenOnly,A=Object.create(null),N=[];function T(e){N.push(e)}function S(e,t){if(1===e.nodeType)for(var n=e.firstChild;n;){var r=void 0;t&&(r=p(n))?T(r):(y(n),n.firstChild&&S(n,t)),n=n.nextSibling}}function E(e,t,n){!1!==b(e)&&(t&&t.removeChild(e),y(e),S(e,n))}function w(e){h(e);for(var t=e.firstChild;t;){var n=t.nextSibling,r=p(t);if(r){var a=A[r];a&&s(t,a)?(t.parentNode.replaceChild(a,t),C(a,t)):w(t)}else w(t);t=n}}function C(e,t,n){var r=p(t);if(r&&delete A[r],!n){if(!1===v(e,t))return;if(function(e,t){var n,r,a,i,o=t.attributes;if(11!==t.nodeType&&11!==e.nodeType){for(var s=o.length-1;s>=0;s--)r=(n=o[s]).name,a=n.namespaceURI,i=n.value,a?(r=n.localName||r,e.getAttributeNS(a,r)!==i&&("xmlns"===n.prefix&&(r=n.name),e.setAttributeNS(a,r,i))):e.getAttribute(r)!==i&&e.setAttribute(r,i);for(var l=e.attributes,c=l.length-1;c>=0;c--)r=(n=l[c]).name,(a=n.namespaceURI)?(r=n.localName||r,t.hasAttributeNS(a,r)||e.removeAttributeNS(a,r)):t.hasAttribute(r)||e.removeAttribute(r)}}(e,t),g(e),!1===x(e,t))return}"TEXTAREA"!==e.nodeName?function(e,t){var n,r,i,o,l,u=t.firstChild,d=e.firstChild;e:for(;u;){for(o=u.nextSibling,n=p(u);d;){if(i=d.nextSibling,u.isSameNode&&u.isSameNode(d)){u=o,d=i;continue e}r=p(d);var f=d.nodeType,h=void 0;if(f===u.nodeType&&(1===f?(n?n!==r&&((l=A[n])?i===l?h=!1:(e.insertBefore(l,d),r?T(r):E(d,e,!0),d=l):h=!1):r&&(h=!1),(h=!1!==h&&s(d,u))&&C(d,u)):3!==f&&8!=f||(h=!0,d.nodeValue!==u.nodeValue&&(d.nodeValue=u.nodeValue))),h){u=o,d=i;continue e}r?T(r):E(d,e,!0),d=i}if(n&&(l=A[n])&&s(l,u))e.appendChild(l),C(l,u);else{var v=m(u);!1!==v&&(v&&(u=v),u.actualize&&(u=u.actualize(e.ownerDocument||a)),e.appendChild(u),w(u))}u=o,d=i}!function(e,t,n){for(;t;){var r=t.nextSibling;(n=p(t))?T(n):E(t,e,!0),t=r}}(e,d,r);var g=c[e.nodeName];g&&g(e,t)}(e,t):c.TEXTAREA(e,t)}!function e(t){if(1===t.nodeType||11===t.nodeType)for(var n=t.firstChild;n;){var r=p(n);r&&(A[r]=n),e(n),n=n.nextSibling}}(e);var O,j,F=e,I=F.nodeType,P=t.nodeType;if(!_)if(1===I)1===P?s(e,t)||(y(e),F=function(e,t){for(var n=e.firstChild;n;){var r=n.nextSibling;t.appendChild(n),n=r}return t}(e,(O=t.nodeName,(j=t.namespaceURI)&&"http://www.w3.org/1999/xhtml"!==j?a.createElementNS(j,O):a.createElement(O)))):F=t;else if(3===I||8===I){if(P===I)return F.nodeValue!==t.nodeValue&&(F.nodeValue=t.nodeValue),F;F=t}if(F===t)y(e);else{if(t.isSameNode&&t.isSameNode(F))return;if(C(F,t,_),N)for(var R=0,$=N.length;R<$;R++){var M=A[N[R]];M&&E(M,M.parentNode,!1)}}return!_&&F!==e&&e.parentNode&&(F.actualize&&(F=F.actualize(e.ownerDocument||a)),e.parentNode.replaceChild(F,e)),F}},565:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(n(492)),i=n(502),o=n(139),s=n(119);t.default=function(e,{module:t,dependencies:n,templates:r,components:u}){const d=l(t);(0,i.buildtemplates)(e,u,r);const f=e.getAttribute("tplid"),p=f?r[f]:null,m={data:t.model?(0,i.dup)(t.model):{}},h={template:p,elm:e,dependencies:n,publish:s.publish,subscribe:s.subscribe,main(e){d.main=e},unmount(e){d.unmount=e},onupdate(e){d.onupdate=e},on(t,n,r){(0,o.on)(e,t,n,r)},off(t,n){(0,o.off)(e,t,n)},trigger(t,n,r){n.constructor===String?Array.from(e.querySelectorAll(n)).forEach((e=>(0,o.trigger)(e,t,{args:r}))):(0,o.trigger)(e,t,{args:n})},emit:(...t)=>{(0,o.trigger)(e,t.shift(),{args:t})},state:{set(e){if(e.constructor===Function){const t=(0,i.dup)(m.data);e(t),h.render(t)}else h.render(e);return new Promise((e=>(0,i.rAF)((t=>(0,i.rAF)(e)))))},get:()=>(0,i.dup)(m.data)},render(t=m.data){if(!document.body.contains(e))return;m.data=Object.assign(m.data,t);const n=(0,i.dup)(m.data),r=h.template(d.view(n));(0,a.default)(e,r,c(e,d)),(0,i.rAF)((t=>{Array.from(e.querySelectorAll("[tplid]")).forEach((e=>{e.options.onupdate(n),e.base.render(n)}))}))}};return{base:h,options:d}};const l=e=>({main:e=>e,unmount:e=>e,onupdate:e=>e,view:e.view?e.view:e=>e}),c=(e,t)=>({onNodeAdded:d(e,t),onElUpdated:d(e,t),onBeforeElChildrenUpdated:u,onBeforeElUpdated:u,getNodeKey:e=>!(1!==e.nodeType||!e.getAttribute("tplid"))&&(e.dataset.key||e.getAttribute("tplid"))}),u=e=>{if("static"in e.dataset||"html-static"in e.attributes)return!1},d=(e,t)=>n=>{if(1===n.nodeType&&n.getAttribute&&n.getAttribute("scope")){const r=JSON.parse((n.getAttribute("scope")||"").replace(/\'/g,'"'));Array.from(n.querySelectorAll("[tplid]")).map((n=>{const a=Object.assign({},e.base.state.get(),r);t.onupdate(a),n.base.render(a)})),n.removeAttribute("scope")}return n}},747:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(n(565));t.default=function(e,t,n,r){return class extends HTMLElement{constructor(){super();const{base:i,options:o}=(0,a.default)(this,{module:e,dependencies:t,templates:n,components:r});this.base=i,this.options=o,e.default(i)}connectedCallback(){this.base.render(),this.options.main().forEach((e=>e(this.base)))}disconnectedCallback(){this.options.unmount(this.base),delete this.options,delete this.base,delete this.__events}attributeChangedCallback(){}}}},341:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(502),i=r(n(747)),o={},s={};t.default={register(e,t,n){s[e]={name:e,module:t,dependencies:n}},start(){const e=document.body;(0,a.buildtemplates)(e,s,o),l()}};const l=()=>{Object.values(s).forEach((e=>{const{name:t,module:n,dependencies:r}=e,a=(0,i.default)(n,r,o,s);customElements.define(t,a)}))}},585:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(641),a=n(502);r.defaultConfig.tags=["{","}"],r.defaultConfig.useWith=!0,t.default=function(e){const t=document.createElement("template");t.innerHTML=e.outerHTML.replace(/<\/?template[^>]*>/g,""),i(t.content);const n=(0,a.decodeHtmlEntities)(t.innerHTML.replace(/html-(selected|checked|readonly|disabled|autoplay)=\"(.*)\"/g,"{@if ($2) }$1{/if}").replace(/html-/g,"")),o=(0,r.compile)(n,r.defaultConfig);return e=>o(e,r.defaultConfig)};const i=e=>{const t=Array.from(e.querySelectorAll("[html-for],[html-if],[html-foreach]")).reverse();return t.length&&t.forEach((e=>{if(e.getAttribute("html-foreach")){const t=(e.getAttribute("html-foreach")||"").match(/(.*)\sin\s(.*)/)||"",n=t[1],r=t[2];e.removeAttribute("html-foreach"),e.setAttribute("scope",`{${n} | JSON($key, '${n}')}`);const a=document.createTextNode(`{@foreach(${r}) => $key, ${n}}`),i=document.createTextNode("{/foreach}");o(a,e,i)}else if(e.getAttribute("html-for")){const t=(e.getAttribute("html-for")||"").match(/(.*)\sin\s(.*)/)||"",n=t[1],r=t[2];e.removeAttribute("html-for"),e.setAttribute("scope",`{${n} | JSON($index, '${n}')}`);const a=document.createTextNode(`{@each(${r}) => ${n}, $index}`),i=document.createTextNode("{/each}");o(a,e,i)}else if(e.getAttribute("html-if")){const t=e.getAttribute("html-if");e.removeAttribute("html-if");const n=document.createTextNode(`{@if (${t}) }`),r=document.createTextNode("{/if}");o(n,e,r)}})),e};r.filters.define("JSON",((e,t,n)=>{const r=t.constructor==String?"$key":"$index",a={$index:t};return a[n]=e,a[r]=t,JSON.stringify(a)}));const o=(e,t,n)=>{var r,a;null===(r=t.parentNode)||void 0===r||r.insertBefore(e,t),null===(a=t.parentNode)||void 0===a||a.insertBefore(n,t.nextSibling)}},139:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.trigger=t.off=t.on=void 0;const n="CustomEvent"in window&&"function"==typeof window.CustomEvent?(e,t)=>new CustomEvent(e,t):(e,t)=>{const n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!0,!0,t),n},r=(e,t)=>function(n){const r=this,a=n.detail||{};e.__events[t].forEach((e=>{e.handler.apply(r,[n].concat(a.args))}))},a=(e,t)=>{e.__events[t]&&e.__events[t].listener&&(e.removeEventListener(t,e.__events[t].listener,"focus"==t||"blur"==t||"mouseenter"==t||"mouseleave"==t),delete e.__events[t])},i=(e,t,n)=>function(r){const a=this,i=r.detail||{};let o=r.target;for(;o&&(o.matches(t)&&(r.delegateTarget=o,n.apply(a,[r].concat(i.args))),o!==e);)o=o.parentNode};t.on=(e,t,n,a)=>{if(e.__events=e.__events||{},e.__events[t]=e.__events[t]||[],!e.__events[t].length){const n=r(e,t);e.addEventListener(t,n,"focus"==t||"blur"==t||"mouseenter"==t||"mouseleave"==t),e.__events[t].listener=n}n.call?e.__events[t].push({handler:n,callback:n}):e.__events[t].push({handler:i(e,n,a),callback:a})},t.off=(e,t,n)=>{if(n&&e.__events[t]&&e.__events[t].length){var r=e.__events[t];e.__events[t]=e.__events[t].filter((function(e){return e.callback!=n})),e.__events[t].listener=r.listener,e.__events[t].length||a(e,t)}else a(e,t)},t.trigger=(e,t,r)=>{e.dispatchEvent(n(t,{bubbles:!0,detail:r}))}},502:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.decodeHtmlEntities=t.buildtemplates=t.createTemplateId=t.dup=t.stripTemplateTag=t.uuid=t.rAF=void 0;const a=r(n(585)),i=document.createElement("textarea");t.rAF=e=>requestAnimationFrame?requestAnimationFrame(e):setTimeout(e,1e3/60),t.uuid=()=>"xxxxxxxx".replace(/[xy]/g,(e=>{const t=8*Math.random()|0;return("x"==e?t:3&t|8).toString(8)})),t.stripTemplateTag=e=>{Array.from(e.querySelectorAll("template")).forEach((e=>{var n;null===(n=e.parentNode)||void 0===n||n.replaceChild(e.content,e),(0,t.stripTemplateTag)(e.content)}))},t.dup=e=>JSON.parse(JSON.stringify(e)),t.createTemplateId=(e,n)=>{if(!e.getAttribute("tplid")){const r=(0,t.uuid)();e.setAttribute("tplid",r),n[r]=(0,a.default)(e)}},t.buildtemplates=(e,n,r)=>Array.from(e.querySelectorAll("*")).filter((e=>e.tagName.toLowerCase()in n)).reverse().map((e=>(Array.from(e.querySelectorAll("template")).map((e=>(0,t.buildtemplates)(e.content,n,r))),(0,t.createTemplateId)(e,r),e))),t.decodeHtmlEntities=e=>(i.innerHTML=e,i.value)},119:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.subscribe=t.publish=void 0;const n={},r={};t.publish=(e,t)=>{r[e]=Object.assign({},r[e],t),n[e]&&n[e].forEach((e=>e(t)))},t.subscribe=(e,t)=>(n[e]=n[e]||[],n[e].push(t),e in r&&t(r[e]),()=>{n[e]=n[e].filter((e=>e!=t))})},641:function(e,t){!function(e){"use strict";function t(e){var n,r,a=new Error(e);return n=a,r=t.prototype,Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,a}function n(e,n,r){var a=n.slice(0,r).split(/\n/),i=a.length,o=a[i-1].length+1;throw t(e+=" at line "+i+" col "+o+":\n\n "+n.split(/\n/)[i-1]+"\n "+Array(o).join(" ")+"^")}t.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});var r=new Function("return this")().Promise,a=!1;try{a=new Function("return (async function(){}).constructor")()}catch(e){if(!(e instanceof SyntaxError))throw e}var i=function(e,t){return"(function(){ try{ return "+e+" }catch(err) { return "+t+"} })()"};function o(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function s(e,t,n){for(var r in t)o(t,r)&&(null==t[r]||"object"!=typeof t[r]||"storage"!==r&&"prefixes"!==r||n?e[r]=t[r]:e[r]=s({},t[r]));return e}var l=/^async +/,c=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,u=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,d=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,f=/[.*+\-?^${}()|[\]\\]/g;function p(e){return f.test(e)?e.replace(f,"\\$&"):e}function m(e,r){r.rmWhitespace&&(e=e.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),c.lastIndex=0,u.lastIndex=0,d.lastIndex=0;var a=r.prefixes,i=[a.h,a.b,a.i,a.r,a.c,a.e].reduce((function(e,t){return e&&t?e+"|"+p(t):t?p(t):e}),""),o=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+p(r.tags[1])+")","g"),s=new RegExp("([^]*?)"+p(r.tags[0])+"(-|_)?\\s*("+i+")?\\s*","g"),f=0,m=!1;function h(t,a){var i,p={f:[]},h=0,v="c";function g(t){var a=e.slice(f,t),i=a.trim();if("f"===v)"safe"===i?p.raw=!0:r.async&&l.test(i)?(i=i.replace(l,""),p.f.push([i,"",!0])):p.f.push([i,""]);else if("fp"===v)p.f[p.f.length-1][1]+=i;else if("err"===v){if(i){var o=a.search(/\S/);n("invalid syntax",e,f+o)}}else p[v]=i;f=t+1}for("h"===a||"b"===a||"c"===a?v="n":"r"===a&&(p.raw=!0,a="i"),o.lastIndex=f;null!==(i=o.exec(e));){var b=i[1],y=i[2],x=i[3],_=i[4],A=i[5],N=i.index;if(b)"("===b?(0===h&&("n"===v?(g(N),v="p"):"f"===v&&(g(N),v="fp")),h++):")"===b?0==--h&&"c"!==v&&(g(N),v="err"):0===h&&"|"===b?(g(N),v="f"):"=>"===b&&(g(N),f+=1,v="res");else if(y)if("/*"===y){var T=e.indexOf("*/",o.lastIndex);-1===T&&n("unclosed comment",e,i.index),o.lastIndex=T+2}else"'"===y?(u.lastIndex=i.index,u.exec(e)?o.lastIndex=u.lastIndex:n("unclosed string",e,i.index)):'"'===y?(d.lastIndex=i.index,d.exec(e)?o.lastIndex=d.lastIndex:n("unclosed string",e,i.index)):"`"===y&&(c.lastIndex=i.index,c.exec(e)?o.lastIndex=c.lastIndex:n("unclosed string",e,i.index));else if(x)return g(N),f=N+i[0].length,s.lastIndex=f,m=A,_&&"h"===a&&(a="s"),p.t=a,p}return n("unclosed tag",e,t),p}var v=function i(o,c){o.b=[],o.d=[];var u,d=!1,p=[];function v(e,t){e&&(e=function(e,t,n,r){var a,i;return"string"==typeof t.autoTrim?a=i=t.autoTrim:Array.isArray(t.autoTrim)&&(a=t.autoTrim[1],i=t.autoTrim[0]),(n||!1===n)&&(a=n),(r||!1===r)&&(i=r),"slurp"===a&&"slurp"===i?e.trim():("_"===a||"slurp"===a?e=String.prototype.trimLeft?e.trimLeft():e.replace(/^[\s\uFEFF\xA0]+/,""):"-"!==a&&"nl"!==a||(e=e.replace(/^(?:\n|\r|\r\n)/,"")),"_"===i||"slurp"===i?e=String.prototype.trimRight?e.trimRight():e.replace(/[\s\uFEFF\xA0]+$/,""):"-"!==i&&"nl"!==i||(e=e.replace(/(?:\n|\r|\r\n)$/,"")),e)}(e,r,m,t))&&(e=e.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),p.push(e))}for(;null!==(u=s.exec(e));){var g,b=u[1],y=u[2],x=u[3]||"";for(var _ in a)if(a[_]===x){g=_;break}v(b,y),f=u.index+u[0].length,g||n("unrecognized tag type: "+x,e,f);var A=h(u.index,g),N=A.t;if("h"===N){var T=A.n||"";r.async&&l.test(T)&&(A.a=!0,A.n=T.replace(l,"")),A=i(A),p.push(A)}else if("c"===N){if(o.n===A.n)return d?(d.d=p,o.b.push(d)):o.d=p,o;n("Helper start and end don't match",e,u.index+u[0].length)}else if("b"===N){d?(d.d=p,o.b.push(d)):o.d=p;var S=A.n||"";r.async&&l.test(S)&&(A.a=!0,A.n=S.replace(l,"")),d=A,p=[]}else if("s"===N){var E=A.n||"";r.async&&l.test(E)&&(A.a=!0,A.n=E.replace(l,"")),p.push(A)}else p.push(A)}if(!c)throw t('unclosed helper "'+o.n+'"');return v(e.slice(f,e.length),!1),o.d=p,o}({f:[]},!0);if(r.plugins)for(var g=0;g<r.plugins.length;g++){var b=r.plugins[g];b.processAST&&(v.d=b.processAST(v.d,r))}return v.d}function h(e,t){var n=m(e,t),r="var tR='';"+(t.useWith?"with("+t.varName+"||{}){":"")+x(n,t)+"if(cb){cb(null,tR)} return tR"+(t.useWith?"}":"");if(t.plugins)for(var a=0;a<t.plugins.length;a++){var i=t.plugins[a];i.processFnString&&(r=i.processFnString(r,t))}return r}function v(e,t){for(var n=0;n<t.length;n++){var r=t[n][0],a=t[n][1];e=(t[n][2]?"await ":"")+"c.l('F','"+r+"')("+e,a&&(e+=","+a),e+=")"}return e}function g(e,t,n,r,a,i){var o="{exec:"+(a?"async ":"")+y(n,t,e)+",params:["+r+"]";return i&&(o+=",name:'"+i+"'"),a&&(o+=",async:true"),o+"}"}function b(e,t){for(var n="[",r=0;r<e.length;r++){var a=e[r];n+=g(t,a.res||"",a.d,a.p||"",a.a,a.n),r<e.length&&(n+=",")}return n+"]"}function y(e,t,n){return"function("+t+"){var tR='';"+x(e,n)+"return tR}"}function x(e,t){for(var n=0,r=e.length,a="";n<r;n++){var o=e[n];if("string"==typeof o)a+="tR+='"+o+"';";else{o.c=i(o.c||"",""),o.p=i(o.p||"","");var s=o.t,l=o.c,c=o.f,u=o.n||"",d=o.p,f=o.res||"",p=o.b,m=!!o.a;if("i"===s){t.defaultFilter&&(l="c.l('F','"+t.defaultFilter+"')("+l+")");var h=v(l,c);!o.raw&&t.autoEscape&&(h="c.l('F','e')("+h+")"),a+="tR+="+h+";"}else if("h"===s)if(t.storage.nativeHelpers.get(u))a+=t.storage.nativeHelpers.get(u)(o,t);else{var y=(m?"await ":"")+"c.l('H','"+u+"')("+g(t,f,o.d,d,m);y+=p?","+b(p,t):",[]",a+="tR+="+v(y+=",c)",c)+";"}else"s"===s?a+="tR+="+v((m?"await ":"")+"c.l('H','"+u+"')({params:["+d+"]},[],c)",c)+";":"e"===s&&(a+=l+"\n")}}return a}var _=function(){function e(e){this.cache=e}return e.prototype.define=function(e,t){this.cache[e]=t},e.prototype.get=function(e){return this.cache[e]},e.prototype.remove=function(e){delete this.cache[e]},e.prototype.reset=function(){this.cache={}},e.prototype.load=function(e){s(this.cache,e,!0)},e}();function A(e,n,r,a){if(n&&n.length>0)throw t((a?"Native":"")+"Helper '"+e+"' doesn't accept blocks");if(r&&r.length>0)throw t((a?"Native":"")+"Helper '"+e+"' doesn't accept filters")}var N={"&":"&","<":"<",">":">",'"':""","'":"'"};function T(e){return N[e]}var S=new _({}),E=new _({each:function(e,t){var n="",r=e.params[0];if(A("each",t,!1),e.async)return new Promise((function(t){!function e(t,n,r,a,i){r(t[n],n).then((function(o){a+=o,n===t.length-1?i(a):e(t,n+1,r,a,i)}))}(r,0,e.exec,n,t)}));for(var a=0;a<r.length;a++)n+=e.exec(r[a],a);return n},foreach:function(e,t){var n=e.params[0];if(A("foreach",t,!1),e.async)return new Promise((function(t){!function e(t,n,r,a,i,o){a(n[r],t[n[r]]).then((function(s){i+=s,r===n.length-1?o(i):e(t,n,r+1,a,i,o)}))}(n,Object.keys(n),0,e.exec,"",t)}));var r="";for(var a in n)o(n,a)&&(r+=e.exec(a,n[a]));return r},include:function(e,n,r){A("include",n,!1);var a=r.storage.templates.get(e.params[0]);if(!a)throw t('Could not fetch template "'+e.params[0]+'"');return a(e.params[1],r)},extends:function(e,n,r){var a=e.params[1]||{};a.content=e.exec();for(var i=0;i<n.length;i++){var o=n[i];a[o.name]=o.exec()}var s=r.storage.templates.get(e.params[0]);if(!s)throw t('Could not fetch template "'+e.params[0]+'"');return s(a,r)},useScope:function(e,t){return A("useScope",t,!1),e.exec(e.params[0])}}),w=new _({if:function(e,t){A("if",!1,e.f,!0);var n="if("+e.p+"){"+x(e.d,t)+"}";if(e.b)for(var r=0;r<e.b.length;r++){var a=e.b[r];"else"===a.n?n+="else{"+x(a.d,t)+"}":"elif"===a.n&&(n+="else if("+a.p+"){"+x(a.d,t)+"}")}return n},try:function(e,n){if(A("try",!1,e.f,!0),!e.b||1!==e.b.length||"catch"!==e.b[0].n)throw t("native helper 'try' only accepts 1 block, 'catch'");var r="try{"+x(e.d,n)+"}",a=e.b[0];return r+"catch"+(a.res?"("+a.res+")":"")+"{"+x(a.d,n)+"}"},block:function(e,t){return A("block",e.b,e.f,!0),"if(!"+t.varName+"["+e.p+"]){tR+=("+y(e.d,"",t)+")()}else{tR+="+t.varName+"["+e.p+"]}"}}),C=new _({e:function(e){var t=String(e);return/[&<>"']/.test(t)?t.replace(/[&<>"']/g,T):t}}),O={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function(e,n){if("H"===e){var r=this.storage.helpers.get(n);if(r)return r;throw t("Can't find helper '"+n+"'")}if("F"===e){var a=this.storage.filters.get(n);if(a)return a;throw t("Can't find filter '"+n+"'")}},async:!1,storage:{helpers:E,nativeHelpers:w,filters:C,templates:S},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function j(e,t){var n={};return s(n,O),t&&s(n,t),e&&s(n,e),n.l.bind(n),n}function F(e,n){var r=j(n||{}),i=Function;if(r.async){if(!a)throw t("This environment doesn't support async/await");i=a}try{return new i(r.varName,"c","cb",h(e,r))}catch(n){throw n instanceof SyntaxError?t("Bad template syntax\n\n"+n.message+"\n"+Array(n.message.length+1).join("=")+"\n"+h(e,r)):n}}function I(e,t){var n;return t.cache&&t.name&&t.storage.templates.get(t.name)?t.storage.templates.get(t.name):(n="function"==typeof e?e:F(e,t),t.cache&&t.name&&t.storage.templates.define(t.name,n),n)}O.l.bind(O),e.compile=F,e.compileScope=x,e.compileScopeIntoFunction=y,e.compileToString=h,e.defaultConfig=O,e.filters=C,e.getConfig=j,e.helpers=E,e.nativeHelpers=w,e.parse=m,e.render=function(e,n,a,i){var o=j(a||{});if(!o.async)return I(e,o)(n,o);if(!i){if("function"==typeof r)return new r((function(t,r){try{t(I(e,o)(n,o))}catch(e){r(e)}}));throw t("Please provide a callback function, this env doesn't support Promises")}try{I(e,o)(n,o,i)}catch(e){return i(e)}},e.templates=S,Object.defineProperty(e,"__esModule",{value:!0})}(t)}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}return n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(341)})()));
|
2
2
|
//# sourceMappingURL=index.js.map
|