redgin 0.1.10 → 0.1.11
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 +3 -3
- package/dist/redgin.min.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,20 +16,20 @@
|
|
|
16
16
|
### Plug & Play, Import directly from cdn
|
|
17
17
|
|
|
18
18
|
```js
|
|
19
|
-
|
|
19
|
+
import { RedGin } from 'https://cdn.jsdelivr.net/gh/josnin/redgin@v0.1.9/dist/redgin.min.js'
|
|
20
20
|
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
### Or Install using NPM
|
|
24
24
|
|
|
25
25
|
```js
|
|
26
|
-
|
|
26
|
+
npm i redgin
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
#### then import the library, helpers
|
|
30
30
|
|
|
31
31
|
```js
|
|
32
|
-
|
|
32
|
+
import { Redgin } from 'redgin'
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
|
package/dist/redgin.min.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var D=Object.defineProperty;var L=(s,t,e)=>t in s?D(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var d=(s,t,e)=>(L(s,typeof t!="symbol"?t+"":t,e),e);var x=()=>crypto.randomUUID().split("-")[0],
|
|
2
|
-
DOM already provided built-in props reflection for this attribute.`);break}}return t};function B(s,t){if(t===void 0||t.name!="propReflect")return;let{type:e,value:o,serializerFn:n,deserializerFn:i}=t,l=this.constructor.observedAttributes,w=u(s),r=
|
|
1
|
+
var D=Object.defineProperty;var L=(s,t,e)=>t in s?D(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var d=(s,t,e)=>(L(s,typeof t!="symbol"?t+"":t,e),e);var x=()=>crypto.randomUUID().split("-")[0],v=s=>s.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),u=s=>s.replace(/-./g,t=>t[1].toUpperCase());function S(s){let t=[];for(let e of h.reg)t.push(e.call(this,s));return t.filter(e=>e===!0).length>0}var m=class{static define(t){m.reg.push(t)}},h=m;d(h,"reg",[]);var p={},b=class extends HTMLElement{};customElements.get("in-watch")||customElements.define("in-watch",b);var _=(s,t)=>{let e=document.createElement("in-watch"),o=x();for(let n of s)Object.hasOwn(p,n)||(p[n]={}),p[n][o]=t;return e.dataset.watch__=o,e.outerHTML};function T(s){let t=u(s),e=!1;if(Object.hasOwn(p,t)){for(let o of Object.keys(p[t]))if(this.shadowRoot){let n=this.shadowRoot.querySelector(`[data-watch__="${o}"]`);n&&(n.innerHTML=p[t][o]?p[t][o].call(this):this[t],e=!0)}}return e}h.define(T);var A=()=>crypto.randomUUID().split("-")[0];var U=[],f;(function(s){s[s.ADD=0]="ADD",s[s.REMOVE=1]="REMOVE"})(f||(f={}));var j=(s,t)=>{let e=A();return U.push([s,t,e]),`data-evt__=${e}`};function I(s,t,e){let o={detail:t,composed:!0},n=new CustomEvent(s,{...o,...e});this.shadowRoot&&this.shadowRoot.dispatchEvent(n)}function E(s){for(let t of U){let[e,o,n]=t;if(this.shadowRoot){let i=this.shadowRoot.querySelector(`[data-evt__="${n}"]`);i&&(s===f.ADD?i.addEventListener(e,o):i.removeEventListener(e,o))}}}function R(){E.call(this,f.ADD)}function O(){E.call(this,f.REMOVE)}function $(s,t){for(let e of c.reg)e.call(this,s,t)}var y=class{static define(t){y.reg.push(t)}},c=y;d(c,"reg",[]);var P=["^class$","^style$","^className$","^classList$","^id$","^dataset$","^data-","^aria-"],g=["disabled"],k=s=>{let t=!0;for(let e of P){let o=new RegExp(e,"g");if(s.match(o)){t=!1,console.error(`Please remove attribute '${s}' in the observedAttributes,
|
|
2
|
+
DOM already provided built-in props reflection for this attribute.`);break}}return t};function B(s,t){if(t===void 0||t.name!="propReflect")return;let{type:e,value:o,serializerFn:n,deserializerFn:i}=t,l=this.constructor.observedAttributes,w=u(s),r=v(s);if(l===void 0||!l.includes(r)){console.error(`Unable to apply propReflect '${w}' for attribute '${r}',
|
|
3
3
|
Please add '${r}' in the observedAttributes of ${this.constructor.name} component`);return}!k(r)||Object.defineProperty(this,w,{configurable:!0,set(a){if(i)return i.call(this,r,e,o,a);(e===Boolean||typeof a=="boolean"||g.includes(r))&&a===!0?this.setAttribute(r,""):(e===Boolean||g.includes(r))&&a===!1?this.removeAttribute(r):([Object,Array].includes(e)||["object","array"].includes(typeof a))&&a?this.setAttribute(r,JSON.stringify(a)):([String,Number].includes(e)||["string","number"].includes(typeof a))&&a?this.setAttribute(r,a):this.removeAttribute(r)},get(){if(n)return n.call(this,r,e,o);if(r in g||e===Boolean||typeof o=="boolean")return this.hasAttribute(r);if(([String,Array,Object].includes(e)||["number","string","array","object"].includes(typeof o))&&!this.hasAttribute(r))return o;if((e===String||typeof o=="string")&&this.hasAttribute(r))return this.getAttribute(r);if((e===Number||typeof o=="number")&&this.hasAttribute(r))return Number(this.getAttribute(r));if(([Array,Object].includes(e)||["array","object"].includes(typeof o))&&this.hasAttribute(r))return JSON.parse(this.getAttribute(r))}})}function M(s,t){return{value:s,...t,name:"propReflect"}}c.define(B);function N(s,t){if(t===void 0||t.name!="getset")return;let{value:e,forWatch:o}=t;this[`#${s}`]=e,Object.defineProperty(this,s,{configurable:!0,set(n){this[`#${s}`]=n,o&&this.updateContents(s)},get(){return this[`#${s}`]}})}function q(s,t){return{value:s,...{forWatch:!0},...t,name:"getset"}}c.define(N);var F={mode:"open",delegatesFocus:!0},H=[],K=[` /* Custom elements are display: inline by default,
|
|
4
4
|
* so setting their width or height will have no effect
|
|
5
5
|
*/
|
|
6
6
|
:host { display: block; }
|
|
7
|
-
`],C=class extends HTMLElement{constructor(){super(),this.attachShadow(F)}connectedCallback(){this._onInit(),this._onDoUpdate()}attributeChangedCallback(t,e,o){if(e===o)return;this.updateContents(t)&&this._onUpdated()}disconnectedCallback(){O.call(this)}updateContents(t){return
|
|
7
|
+
`],C=class extends HTMLElement{constructor(){super(),this.attachShadow(F)}connectedCallback(){this._onInit(),this._onDoUpdate()}attributeChangedCallback(t,e,o){if(e===o)return;this.updateContents(t)&&this._onUpdated()}disconnectedCallback(){O.call(this)}updateContents(t){return S.call(this,t)}setEventListeners(){R.call(this)}setPropsBehavior(){let t=Object.getOwnPropertyNames(this).filter(e=>e!="styles");for(let e of t){let o=this[e];$.call(this,e,o)}}getStyles(t){let e=[],o=[],n=this.shadowRoot?.adoptedStyleSheets;for(let i of t)if(i.startsWith("<link"))e.push(i);else if(i.startsWith("@import")||!n){let l=document.createElement("style");l.innerHTML=i,e.push(l.outerHTML)}else{let l=new CSSStyleSheet;l.replaceSync(i),o.push(l)}return this.shadowRoot&&o.length>0&&(this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,...o]),e.join("")}_onInit(){this.setPropsBehavior(),this.shadowRoot&&(this.shadowRoot.innerHTML=`
|
|
8
8
|
${this.getStyles(H)}
|
|
9
9
|
${this.getStyles(K)}
|
|
10
10
|
${this.getStyles(this.styles)}
|
|
11
11
|
${this.render()}
|
|
12
|
-
`),this.onInit()}_onDoUpdate(){let t=Object.getOwnPropertyNames(this).filter(e=>e!="styles");for(let e of t)this.updateContents(e)&&this._onUpdated();this.onDoUpdate()}_onUpdated(){this.setEventListeners(),this.onUpdated()}onInit(){}onDoUpdate(){}onUpdated(){}styles=[];render(){return""}};export{C as RedGin,F as attachShadow,h as customDirectives,c as customPropsBehavior,K as defaultStyles,I as emit,j as event,q as getset,H as injectStyles,M as propReflect,_ as watch};
|
|
12
|
+
`),this.onInit()}_onDoUpdate(){let t=Object.getOwnPropertyNames(this).filter(e=>e!="styles");for(let e of t)this.updateContents(e)&&this._onUpdated();this.setEventListeners(),this.onDoUpdate()}_onUpdated(){this.setEventListeners(),this.onUpdated()}onInit(){}onDoUpdate(){}onUpdated(){}styles=[];render(){return""}};export{C as RedGin,F as attachShadow,h as customDirectives,c as customPropsBehavior,K as defaultStyles,I as emit,j as event,q as getset,H as injectStyles,M as propReflect,_ as watch};
|
|
13
13
|
//# sourceMappingURL=redgin.min.js.map
|