Socket
Socket
Sign inDemoInstall

deleight

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deleight - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

65

dist/reftype/cjs/reftype.d.ts

@@ -50,5 +50,10 @@ /**

calc?: IMap<ICalc>;
self?: string;
ref?: new (ref: any, options?: IRefTypeOptions, parent?: RefType) => RefType;
iter?: new (ref: any, options?: IRefTypeOptions, parent?: RefType) => IterRefType;
item?: new (ref: any, options?: IRefTypeOptions, parent?: RefType) => RefType;
}
type IIndexToIndex = {
[key: number]: number;
};
/**

@@ -266,6 +271,3 @@ * Base class for all multivalue instances providing the `set`

*/
destructure(ref: string): {
parent: IMap<any>;
prop: string;
};
destructure(ref: string): any;
/**

@@ -367,3 +369,22 @@ * Returns the value pointed to by {@link ref} within {@link RefType#refs}

declare class IterRefType extends RefType {
/**
* Map of linked elements to the arrays of item reftypes created
* for them.
*/
items: WeakMap<Element, RefType[]>;
/**
* When this is `true`, all the items will be wrapped with an
* object containing both the item and its index in the created
* item reftypes for each item. Also the indices will be reactive.
* This can help in cases where the index forms part of the display
* but is less performant and memory-efficient.
*
* To specify `addIndex` in markup, wrap the ref path with `{}`, as in
* `<span>ite-r="{refPath}">item.prop</span>`
*
*/
addIndex?: boolean;
/**
* Map of linked elements to the templates created for them.
*/
templates: WeakMap<Element, Element | DocumentFragment>;

@@ -441,3 +462,3 @@ /**

*/
react(...refs: string[] | [IStrObject]): this;
react(...refs: string[] | [IStrObject]): void | this;
/**

@@ -502,3 +523,3 @@ * Reeacts on only the specified elements. This is useful when

*/
push(...items: any[]): void;
push(...items: any[]): any;
/**

@@ -515,3 +536,3 @@ * Reactively pops the wrapped array.

*/
pop(): void;
pop(): any;
/**

@@ -531,16 +552,26 @@ * Reactively splices the wrapped array.

*/
splice(start: number, deleteCount?: number, ...items: any[]): void;
splice(start: number, deleteCount?: number, ...items: any[]): any;
/**
* Sets the array item correctly and calls {@link IterRefType#react}
* Supports structural changes in the array which do not
* involve setting new values. We instead move array items along
* with their linked elements to new positions.
*
* The function operates in two modes:
* 1. `!swap`: move the item at {@link i1} to the {@link i2},
* shifting the other items appropriately..
*
* 3. `swap`: swaps the items at {@link i1} and {@link i2}.
* nothing is shifted.
*
* In both cases item indices will be updated to reflect their
* new positions if {@link IterRefType#addIndex} is `true`.
*
* @example
* import { IterRefType } from "deleight/reftype";
* const refs = [{ mercury: 1}, {venus: 2}, {earch: 3}, {mars: 4 }], options = { };
* const iterReftype = new IterRefType(refs, options);
* iterReftype.add(...document.querySelectorAll('ul'));
* iterReftype.set({0: { pluto: 9 }, 1: { uranus: 1 }}) // reactively set items.
*
* @param refs
*
* @param i1
* @param i2
* @param swap
*/
set(refs: IStrObject): this;
move(i1: number, i2: number, swap?: boolean): this;
/**

@@ -570,2 +601,2 @@ * Calls splice on the {@link IterRefType#refs} to ensure it behaves the

export { type ICalc, type IKey, type IMap, type IMultiValueReaction, type IReaction, type IReactions, type IRefTypeElement, type IRefTypeOptions, type IStrObject, IterRefType, MultiValue, RefType, addRef, options, react, setAttr, setProp };
export { type ICalc, type IIndexToIndex, type IKey, type IMap, type IMultiValueReaction, type IReaction, type IReactions, type IRefTypeElement, type IRefTypeOptions, type IStrObject, IterRefType, MultiValue, RefType, addRef, options, react, setAttr, setProp };

@@ -1,1 +0,1 @@

"use strict";class t{values;calc;constructor(t,e){this.values=t,e&&(this.calc=e)}set(t,e){return this.values[t]=e,this.calc?this.calc(...this.values.filter(((t,e)=>""!==t||!(e%2)))):this.values.join("")}}function e(t,e,s,i){let r,n;s.hasOwnProperty(t)?r=s[t]:s[t]=r=new Map,r.has(e)?n=r.get(e):r.set(e,n=new Set),n.add(i)}class s{refs;elements;options;parent;attrs;props;multiValues;children;hidden;constructor(t,e,s){this.refs=t,e&&(this.options=e),s&&(this.parent=s)}createMultiValue(e,s){const i=e.split(this.options?.sep?.multivalue||o.sep.multivalue),r=[];let n;for(let t=0;t<i.length;t+=2)n=i[t].trim(),r.push(n),i[t]=this.get(n);return{refs:r,values:new t(i,s)}}addValue(t,s,i,r){let n,h;const l=this.options?.sep?.calc||o.sep.calc;if((t=t.trim()).indexOf(l)>=0&&([n,t]=t.split(l,2),n=n.trim(),h=this.options?.calc?.[n]||o.calc[n],!h))throw new TypeError(`The calculation ${n} could not be found`);if(t=t.trim(),h||t.indexOf(this.options?.sep?.multivalue||o.sep.multivalue)>=0){const{refs:n,values:o}=this.createMultiValue(t,h),l={name:r,values:o};let f=0;for(let t of n)e(t,s,i,Object.assign({index:f},l)),f+=2}else e(t,s,i,r)}add(...t){const e=this.options?.suffix?.attr||o.suffix.attr,s=this.options?.suffix?.prop||o.suffix.prop,i=this.options?.attr?.text||o.attr.text,r=this.options?.attr?.ref||o.attr.ref,n=this.options?.attr?.iter||o.attr.iter,h=this.options?.attr?.closed||o.attr.closed,l={[r]:this.options?.ref||o.ref,[n]:this.options?.iter||o.iter};let f,a,p,d,c;for(let o of t){if(c=!1,!this.elements||!this.elements.includes(o)){for(d of[r,n])o.hasAttribute(d)&&(p=o.getAttribute(d),this.children||(this.children={}),this.children.hasOwnProperty(p)?f=this.children[p]:this.children[p]=f=new l[d](this.get(p),this.options,this),f.elements=[o],f.add(o),c=!0);if(c)continue}for(a of o.attributes)a.name!==h&&(a.name===i?(this.props||(this.props={}),this.addValue(o.textContent,o,this.props,"textContent")):a.name.endsWith(e)?(this.attrs||(this.attrs={}),this.addValue(a.value,o,this.attrs,a.name.slice(0,-e.length))):a.name.endsWith(s)&&(this.props||(this.props={}),this.addValue(a.value,o,this.props,a.name.slice(0,-s.length))));let t=o.firstElementChild;for(;t;)t.hasAttribute(h)||this.add(t),t=t.nextElementSibling}}remove(t){if(t){if(this.children)for(let e of Object.keys(this.children))e.startsWith(t)&&delete this.children[e];if(this.attrs)for(let e of Object.keys(this.attrs))e.startsWith(t)&&delete this.attrs[e];if(this.props)for(let e of Object.keys(this.props))e.startsWith(t)&&delete this.props[e]}else delete this.children,delete this.attrs,delete this.props;return this}react(...t){if(t.length){let e,s,h,o,l,f;for(f of(1===t.length&&"object"==typeof t[0]&&(e=t[0],t=Array.from(Object.keys(t[0]))),t)){if(l=e?e[f]:this.get(f),this.attrs)for([h,o]of Object.entries(this.attrs))h.startsWith(f)&&i(o,l,r);if(this.props)for([h,o]of Object.entries(this.props))h.startsWith(f)&&i(o,l,n);this.children?.hasOwnProperty(f)&&(void 0!==l?(s=this.children[f],s.refs=l,s.react()):(this.children[f].delete(),delete this.children[f]))}}else{if(null===this.refs&&!this.hidden)return this.hide();if(this.hidden&&null!==this.refs&&this.show(),this.attrs)for(let[t,e]of Object.entries(this.attrs))i(e,this.get(t),r);if(this.props)for(let[t,e]of Object.entries(this.props))i(e,this.get(t),n);if(this.children)for(let[t,e]of Object.entries(this.children))e.refs=this.get(t),e.react()}return this}set(t){let e;for(let[s,i]of Object.entries(t))e=this.destructure(s),e.parent[e.prop]=i,this.children?.hasOwnProperty(s)&&(this.children[s].refs=i);return this.react(t),this}delete(t){if(void 0===t){if(this.elements)for(let t of this.elements)t.remove()}else{const e=this.destructure(t);delete e.parent[e.prop],this.children?.hasOwnProperty(t)?this.children[t].delete():this.react({[t]:void 0})}return this.remove(t)}call(t,...e){const s=this.destructure(t),i=s.parent[s.prop](...e);return this.react({[t]:i}),i}destructure(t){if("string"!=typeof t||!t.trim())return null;const e=t.split(this.options?.sep?.ref||o.sep.ref);let s=this.refs,i=this.parent,r=e[0],n=s[r];for(;void 0===n&&i;)s=i.refs,n=s[r],i=i.parent;if(void 0!==n)for(let t=1;t<e.length&&(s=n,r=e[t],n=s[r],void 0!==n);t++);return{parent:s,prop:r}}get(t){if("string"!=typeof t||!t.trim())return"";const e=this.destructure(t);if(!e)return;const s=e.parent[e.prop];return void 0!==s?s:void 0}hide(){let t;for(t of(this.hidden=new Map,this.elements))this.hidden.set(t,t.style.display),t.style.display="none"}show(){if(this.hidden){for(let[t,e]of this.hidden.entries())t.style.display=e;delete this.hidden}}}function i(t,e,s){let i;for(let[r,n]of t.entries())for(i of n)"string"==typeof i?s(r,i,e):s(r,i.name,i.values.set(i.index,e))}function r(t,e,s){void 0!==s?t.setAttribute(e,s):t.removeAttribute(e)}function n(t,e,s){t[e]=s,void 0===s&&delete t[e]}class h extends s{items;templates;getTemplate(t,e){this.templates||(this.templates=new WeakMap);let s=this.templates.get(t);return s&&!e||(1===t.children.length?s=t.firstElementChild instanceof HTMLTemplateElement?t.firstElementChild.content:t.firstElementChild:(s=document.createDocumentFragment(),s.append(...t.childNodes)),this.templates.set(t,s)),s}add(...t){this.elements||(this.elements=[]),this.items||(this.items=new WeakMap);for(let e of t)this.elements.push(e),this.items.set(e,[]),this.getTemplate(e,!0);return this.reactOn(...t),this}react(...t){if(this.items||(this.items=new WeakMap),t.length){let e,s,i,r,n;1===t.length&&"object"==typeof t[0]&&(s=t[0],t=Array.from(Object.keys(s)));for(let h of t)for(r of(i=s?s[h]:this.get(h),this.elements))n=this.items.get(r),n.hasOwnProperty(h)&&(e=n[h],e.refs={item:i,index:"number"==typeof h?h:parseInt(h)},e.react())}else{let t;for(t of(this.items=new WeakMap,this.remove(),this.elements))t.textContent="",this.items.set(t,[]);for(let e of this.refs)for(t of this.elements)this.addChild(t,e)}return this}reactOn(...t){let e;for(e of(this.items||(this.items=new WeakMap),t))e.textContent="",this.items.set(e,[]);for(let s of this.refs)for(e of t)this.addChild(e,s)}createChild(t,e,i){const r=new(this.options?.ref||s)({index:e,item:i},this.options,this),n=this.templates.get(t);if(n instanceof Element){const t=n.cloneNode(!0);r.elements=[t],r.add(t)}else n instanceof DocumentFragment&&(r.elements=Array.from(n.cloneNode(!0).children),r.add(...r.elements));return r.react(),r}addChild(t,e,s){const i=this.items.get(t),r=this.createChild(t,i.length,e),n=void 0!==s&&t.children.length>s?t.children[s]:null;if(n)for(let e of r.elements)t.insertBefore(e,n);else t.append(...r.elements);i.push(r)}push(...t){let e;this.refs.push&&this.refs.push(...t);for(let s of t)for(e of this.elements)this.addChild(e,s)}pop(){let t;this.refs.pop&&this.refs.pop();for(let e of this.elements)t=this.items.get(e),t.at(-1).delete(),t.pop()}splice(t,e,...s){this.refs.splice&&this.refs.splice(t,e,...s);for(let i of this.elements){const r=this.items.get(i),n=s.map(((e,s)=>this.createChild(i,t+s,e)));for(let s=0;s<e;s++)r[t+s].delete();let h;r.splice(t,e,...n);const o=this.templates.get(i),l=(o instanceof DocumentFragment?o.children.length:1)*t;if(i.children.length>l){const t=i.children[l];for(let e of n)for(h of e.elements)i.insertBefore(h,t)}else for(let t of n)i.append(...t.elements)}}set(t){let e,s,i,r,n;for([e,i]of Object.entries(t))for(r of(s=parseInt(e),this.refs[s]=i,this.elements))n=this.items.get(r),n?.hasOwnProperty(e)&&(n[e].refs={item:i,index:parseInt(e)});return this.react(t),this}delete(t){if(void 0===t){if(this.refs.length=0,this.elements){for(let t of this.elements)t.remove();delete this.elements}return delete this.templates,delete this.items,this.remove()}this.splice("string"==typeof t?parseInt(t):t,1)}}const o={suffix:{attr:"-a",prop:"-p"},attr:{text:"t",ref:"re-f",iter:"ite-r",closed:"close-d"},sep:{ref:".",multivalue:"|",calc:":="},calc:{add(...t){let e=0;for(let s of t)"string"==typeof s&&(s=(s.indexOf(".")>=0?parseFloat:parseInt)(s.trim())),e+=s;return e}},ref:s,iter:h};exports.IterRefType=h,exports.MultiValue=t,exports.RefType=s,exports.addRef=e,exports.options=o,exports.react=i,exports.setAttr=r,exports.setProp=n;
"use strict";class e{values;calc;constructor(e,t){this.values=e,t&&(this.calc=t)}set(e,t){return this.values[e]=t,this.calc?this.calc(...this.values.filter(((e,t)=>""!==e||!(t%2)))):this.values.join("")}}function t(e,t,s,i){let r,n;s.hasOwnProperty(e)?r=s[e]:s[e]=r=new Map,r.has(t)?n=r.get(t):r.set(t,n=new Set),n.add(i)}class s{refs;elements;options;parent;attrs;props;multiValues;children;hidden;constructor(e,t,s){this.refs=e,t&&(this.options=t),s&&(this.parent=s)}createMultiValue(t,s){const i=t.split(this.options?.sep?.multivalue||l.sep.multivalue),r=[];let n;for(let e=0;e<i.length;e+=2)n=i[e].trim(),r.push(n),i[e]=this.get(n);return{refs:r,values:new e(i,s)}}addValue(e,s,i,r){let n,h;const o=this.options?.sep?.calc||l.sep.calc;if((e=e.trim()).indexOf(o)>=0&&([n,e]=e.split(o,2),n=n.trim(),h=this.options?.calc?.[n]||l.calc[n],!h))throw new TypeError(`The calculation ${n} could not be found`);if(e=e.trim(),h||e.indexOf(this.options?.sep?.multivalue||l.sep.multivalue)>=0){const{refs:n,values:l}=this.createMultiValue(e,h),o={name:r,values:l};let f=0;for(let e of n)t(e,s,i,Object.assign({index:f},o)),f+=2}else t(e,s,i,r)}add(...e){const t=this.options?.suffix?.attr||l.suffix.attr,s=this.options?.suffix?.prop||l.suffix.prop,i=this.options?.attr?.text||l.attr.text,r=this.options?.attr?.ref||l.attr.ref,n=this.options?.attr?.iter||l.attr.iter,o=this.options?.attr?.closed||l.attr.closed,f={[r]:this.options?.ref||l.ref,[n]:this.options?.iter||l.iter};let a,d,p,c,u,m;for(let l of e){if(u=!1,!this.elements||!this.elements.includes(l)){for(c of[r,n])l.hasAttribute(c)&&(p=l.getAttribute(c),c===n&&p.startsWith("{")&&p.endsWith("}")?(m=!0,p=p.slice(1,-1)):m=!1,this.children||(this.children={}),this.children.hasOwnProperty(p)?a=this.children[p]:this.children[p]=a=new f[c](this.get(p),this.options,this),m&&a instanceof h&&(a.addIndex=!0),a.elements=[l],a.add(l),u=!0);if(u)continue}for(d of l.attributes)d.name!==o&&(d.name===i?(this.props||(this.props={}),this.addValue(l.textContent,l,this.props,"textContent")):d.name.endsWith(t)?(this.attrs||(this.attrs={}),this.addValue(d.value,l,this.attrs,d.name.slice(0,-t.length))):d.name.endsWith(s)&&(this.props||(this.props={}),this.addValue(d.value,l,this.props,d.name.slice(0,-s.length))));let e=l.firstElementChild;for(;e;)e.hasAttribute(o)||this.add(e),e=e.nextElementSibling}}remove(e){if(e){if(this.children)for(let t of Object.keys(this.children))t.startsWith(e)&&delete this.children[t];if(this.attrs)for(let t of Object.keys(this.attrs))t.startsWith(e)&&delete this.attrs[t];if(this.props)for(let t of Object.keys(this.props))t.startsWith(e)&&delete this.props[t]}else delete this.children,delete this.attrs,delete this.props;return this}react(...e){if(null===this.refs&&!this.hidden)return this.hide();if(this.hidden&&null!==this.refs&&this.show(),e.length){let t,s,h,o,f,a;for(a of(1===e.length&&"object"==typeof e[0]&&(t=e[0],e=Array.from(Object.keys(e[0]))),this.hidden&&null!==this.refs&&this.show(),e)){if(f=t?t[a]:this.get(a),this.attrs)for([h,o]of Object.entries(this.attrs))h.startsWith(a)&&i(o,f,r);if(this.props)for([h,o]of Object.entries(this.props))h.startsWith(a)&&i(o,f,n);this.children?.hasOwnProperty(a)&&(s=this.children[a],void 0!==f?(s.refs=f,s.react()):(s.delete(),delete this.children[a])),a!==this.options?.self&&a!==l.self||(void 0!==f?this.react():this.delete())}}else{if(this.attrs)for(let[e,t]of Object.entries(this.attrs))i(t,this.get(e),r);if(this.props)for(let[e,t]of Object.entries(this.props))i(t,this.get(e),n);if(this.children)for(let[e,t]of Object.entries(this.children))t.refs=this.get(e),t.react()}return this}set(e){let t;for(let[s,i]of Object.entries(e))t=this.destructure(s),t.parent[t.prop]=i;return this.react(e),this}delete(e){if(void 0===e){if(this.elements)for(let e of this.elements)e.remove()}else{const t=this.destructure(e);delete t.parent[t.prop],this.children?.hasOwnProperty(e)?this.children[e].delete():this.react({[e]:void 0})}return this.remove(e)}call(e,...t){const s=this.destructure(e),i=s.parent[s.prop](...t);return this.react({[e]:i}),i}destructure(e){if("string"!=typeof e||!e.trim())return null;if(e===this.options?.self||e===l.self)return{parent:this,prop:"refs"};const t=e.split(this.options?.sep?.ref||l.sep.ref);let s=this.refs,i=this.parent,r=t[0],n=s[r];for(;void 0===n&&i;)s=i.refs,n=s[r],i=i.parent;if(void 0!==n)for(let e=1;e<t.length&&(s=n,r=t[e],n=s[r],void 0!==n);e++);return{parent:s,prop:r}}get(e){if("string"!=typeof e||!e.trim())return"";if(e===this.options?.self||e===l.self)return this.refs;const t=this.destructure(e);if(!t)return;const s=t.parent[t.prop];return void 0!==s?s:void 0}hide(){let e;for(e of(this.hidden=new Map,this.elements))this.hidden.set(e,e.style.display),e.style.display="none"}show(){if(this.hidden){for(let[e,t]of this.hidden.entries())e.style.display=t;delete this.hidden}}}function i(e,t,s){let i;for(let[r,n]of e.entries())for(i of n)"string"==typeof i?s(r,i,t):s(r,i.name,i.values.set(i.index,t))}function r(e,t,s){void 0!==s?e.setAttribute(t,s):e.removeAttribute(t)}function n(e,t,s){e[t]=s,void 0===s&&delete e[t]}class h extends s{items;addIndex;templates;getTemplate(e,t){this.templates||(this.templates=new WeakMap);let s=this.templates.get(e);return s&&!t||(1===e.children.length?s=e.firstElementChild instanceof HTMLTemplateElement?e.firstElementChild.content:e.firstElementChild:(s=document.createDocumentFragment(),s.append(...e.childNodes)),this.templates.set(e,s)),s}add(...e){this.elements||(this.elements=[]),this.items||(this.items=new WeakMap);for(let t of e)this.elements.push(t),this.items.set(t,[]),this.getTemplate(t,!0);return this.reactOn(...e),this}react(...e){if(null===this.refs&&!this.hidden)return this.hide();if(this.hidden&&null!==this.refs&&this.show(),this.items||(this.items=new WeakMap),e.length){let t,s,i,r,n;1===e.length&&"object"==typeof e[0]&&(s=e[0],e=Array.from(Object.keys(s)));for(let h of e)if(i=s?s[h]:this.get(h),h!==this.options?.self&&h!==l.self)for(r of this.elements)n=this.items.get(r),n.hasOwnProperty(h)&&(t=n[h],this.addIndex?t.refs={item:i,index:"number"==typeof h?h:parseInt(h)}:t.refs=i,t.react());else this.refs=i,this.react()}else{let e;for(e of(this.items=new WeakMap,this.remove(),this.elements))e.textContent="",this.items.set(e,[]);for(let t of this.refs)for(e of this.elements)this.addChild(e,t)}return this}reactOn(...e){if(null===this.refs&&!this.hidden)return this.hide();let t;for(t of(this.hidden&&null!==this.refs&&this.show(),this.items||(this.items=new WeakMap),e))t.textContent="",this.items.set(t,[]);for(let s of this.refs)for(t of e)this.addChild(t,s)}createChild(e,t,s){const i=new(this.options?.item||l.item)(this.addIndex?{index:t,item:s}:s,this.options,this),r=this.templates.get(e);if(r instanceof Element){const e=r.cloneNode(!0);i.elements=[e],i.add(e)}else r instanceof DocumentFragment&&(i.elements=Array.from(r.cloneNode(!0).children),i.add(...i.elements));return i.react(),i}addChild(e,t,s){const i=this.items.get(e),r=this.createChild(e,i.length,t),n=void 0!==s&&e.children.length>s?e.children[s]:null;if(n)for(let t of r.elements)e.insertBefore(t,n);else e.append(...r.elements);i.push(r)}push(...e){let t,s;this.refs.push&&(t=this.refs.push(...e));for(let t of e)for(s of this.elements)this.addChild(s,t);return t}pop(){let e,t;this.refs.pop&&(e=this.refs.pop());for(let e of this.elements)t=this.items.get(e),t.at(-1).delete(),t.pop();return e}splice(e,t,...s){let i;this.refs.splice&&(i=this.refs.splice(e,t,...s));for(let i of this.elements){const r=this.items.get(i),n=s.map(((t,s)=>this.createChild(i,e+s,t)));for(let s=0;s<t;s++)r[e+s].delete();if(r.splice(e,t,...n),this.addIndex)for(let t=e;t<r.length;t++)r[t].set({index:t+s.length});let h;const l=this.templates.get(i),o=(l instanceof DocumentFragment?l.children.length:1)*e;if(i.children.length>o){const e=i.children[o];for(let t of n)for(h of t.elements)i.insertBefore(h,e)}else for(let e of n)i.append(...e.elements)}return i}move(e,t,s){if(e===t)return;const i={[e]:t};let r,n,h;s&&(i[t]=e);const l=this.refs.slice();let o,f,a,d,p,c,u,m=0;for(let g of this.elements){for(c of(m++,r=this.items.get(g),o={},Object.keys(i)))o[c]=r[c];for(c of(f={},Object.values(i)))u=r[c],f[c]=u.elements.at(-1).nextSibling||[u.elements[0].parentNode];for([e,t]of Object.entries(i)){if("string"==typeof e&&(e=parseInt(e)),h=o[e],p=f[t],p instanceof Array)for(a of(d=p[0],h.elements))d.appendChild(a);else for(a of(d=p.parentNode,h.elements))d.insertBefore(a,p);if(s)1===m&&(this.refs[t]=l[e]),r[t]=h;else{if(this.addIndex)if(e>t)for(n=t;n<e;n++)r[n].set({index:n+1});else for(n=e+1;n<=t;n++)r[n].set({index:n-1});1===m&&this.refs.splice(t,0,...this.refs.splice(e,1)),r.splice(t,0,...r.splice(e,1))}this.addIndex&&h.set({index:t})}}return this}delete(e){if(void 0===e){if(this.refs.length=0,this.elements){for(let e of this.elements)e.remove();delete this.elements}return delete this.templates,delete this.items,this.remove()}this.splice("string"==typeof e?parseInt(e):e,1)}}const l={suffix:{attr:"-a",prop:"-p"},attr:{text:"t",ref:"re-f",iter:"ite-r",closed:"close-d"},sep:{ref:".",multivalue:"|",calc:":="},calc:{add(...e){let t=0;for(let s of e)"string"==typeof s&&(s=(s.indexOf(".")>=0?parseFloat:parseInt)(s.trim())),t+=s;return t}},ref:s,iter:h,item:s,self:"."};exports.IterRefType=h,exports.MultiValue=e,exports.RefType=s,exports.addRef=t,exports.options=l,exports.react=i,exports.setAttr=r,exports.setProp=n;

@@ -50,5 +50,10 @@ /**

calc?: IMap<ICalc>;
self?: string;
ref?: new (ref: any, options?: IRefTypeOptions, parent?: RefType) => RefType;
iter?: new (ref: any, options?: IRefTypeOptions, parent?: RefType) => IterRefType;
item?: new (ref: any, options?: IRefTypeOptions, parent?: RefType) => RefType;
}
type IIndexToIndex = {
[key: number]: number;
};
/**

@@ -266,6 +271,3 @@ * Base class for all multivalue instances providing the `set`

*/
destructure(ref: string): {
parent: IMap<any>;
prop: string;
};
destructure(ref: string): any;
/**

@@ -367,3 +369,22 @@ * Returns the value pointed to by {@link ref} within {@link RefType#refs}

declare class IterRefType extends RefType {
/**
* Map of linked elements to the arrays of item reftypes created
* for them.
*/
items: WeakMap<Element, RefType[]>;
/**
* When this is `true`, all the items will be wrapped with an
* object containing both the item and its index in the created
* item reftypes for each item. Also the indices will be reactive.
* This can help in cases where the index forms part of the display
* but is less performant and memory-efficient.
*
* To specify `addIndex` in markup, wrap the ref path with `{}`, as in
* `<span>ite-r="{refPath}">item.prop</span>`
*
*/
addIndex?: boolean;
/**
* Map of linked elements to the templates created for them.
*/
templates: WeakMap<Element, Element | DocumentFragment>;

@@ -441,3 +462,3 @@ /**

*/
react(...refs: string[] | [IStrObject]): this;
react(...refs: string[] | [IStrObject]): void | this;
/**

@@ -502,3 +523,3 @@ * Reeacts on only the specified elements. This is useful when

*/
push(...items: any[]): void;
push(...items: any[]): any;
/**

@@ -515,3 +536,3 @@ * Reactively pops the wrapped array.

*/
pop(): void;
pop(): any;
/**

@@ -531,16 +552,26 @@ * Reactively splices the wrapped array.

*/
splice(start: number, deleteCount?: number, ...items: any[]): void;
splice(start: number, deleteCount?: number, ...items: any[]): any;
/**
* Sets the array item correctly and calls {@link IterRefType#react}
* Supports structural changes in the array which do not
* involve setting new values. We instead move array items along
* with their linked elements to new positions.
*
* The function operates in two modes:
* 1. `!swap`: move the item at {@link i1} to the {@link i2},
* shifting the other items appropriately..
*
* 3. `swap`: swaps the items at {@link i1} and {@link i2}.
* nothing is shifted.
*
* In both cases item indices will be updated to reflect their
* new positions if {@link IterRefType#addIndex} is `true`.
*
* @example
* import { IterRefType } from "deleight/reftype";
* const refs = [{ mercury: 1}, {venus: 2}, {earch: 3}, {mars: 4 }], options = { };
* const iterReftype = new IterRefType(refs, options);
* iterReftype.add(...document.querySelectorAll('ul'));
* iterReftype.set({0: { pluto: 9 }, 1: { uranus: 1 }}) // reactively set items.
*
* @param refs
*
* @param i1
* @param i2
* @param swap
*/
set(refs: IStrObject): this;
move(i1: number, i2: number, swap?: boolean): this;
/**

@@ -570,2 +601,2 @@ * Calls splice on the {@link IterRefType#refs} to ensure it behaves the

export { type ICalc, type IKey, type IMap, type IMultiValueReaction, type IReaction, type IReactions, type IRefTypeElement, type IRefTypeOptions, type IStrObject, IterRefType, MultiValue, RefType, addRef, options, react, setAttr, setProp };
export { type ICalc, type IIndexToIndex, type IKey, type IMap, type IMultiValueReaction, type IReaction, type IReactions, type IRefTypeElement, type IRefTypeOptions, type IStrObject, IterRefType, MultiValue, RefType, addRef, options, react, setAttr, setProp };

@@ -1,1 +0,1 @@

class t{values;calc;constructor(t,e){this.values=t,e&&(this.calc=e)}set(t,e){return this.values[t]=e,this.calc?this.calc(...this.values.filter(((t,e)=>""!==t||!(e%2)))):this.values.join("")}}function e(t,e,s,i){let r,n;s.hasOwnProperty(t)?r=s[t]:s[t]=r=new Map,r.has(e)?n=r.get(e):r.set(e,n=new Set),n.add(i)}class s{refs;elements;options;parent;attrs;props;multiValues;children;hidden;constructor(t,e,s){this.refs=t,e&&(this.options=e),s&&(this.parent=s)}createMultiValue(e,s){const i=e.split(this.options?.sep?.multivalue||l.sep.multivalue),r=[];let n;for(let t=0;t<i.length;t+=2)n=i[t].trim(),r.push(n),i[t]=this.get(n);return{refs:r,values:new t(i,s)}}addValue(t,s,i,r){let n,h;const o=this.options?.sep?.calc||l.sep.calc;if((t=t.trim()).indexOf(o)>=0&&([n,t]=t.split(o,2),n=n.trim(),h=this.options?.calc?.[n]||l.calc[n],!h))throw new TypeError(`The calculation ${n} could not be found`);if(t=t.trim(),h||t.indexOf(this.options?.sep?.multivalue||l.sep.multivalue)>=0){const{refs:n,values:l}=this.createMultiValue(t,h),o={name:r,values:l};let f=0;for(let t of n)e(t,s,i,Object.assign({index:f},o)),f+=2}else e(t,s,i,r)}add(...t){const e=this.options?.suffix?.attr||l.suffix.attr,s=this.options?.suffix?.prop||l.suffix.prop,i=this.options?.attr?.text||l.attr.text,r=this.options?.attr?.ref||l.attr.ref,n=this.options?.attr?.iter||l.attr.iter,h=this.options?.attr?.closed||l.attr.closed,o={[r]:this.options?.ref||l.ref,[n]:this.options?.iter||l.iter};let f,a,p,d,c;for(let l of t){if(c=!1,!this.elements||!this.elements.includes(l)){for(d of[r,n])l.hasAttribute(d)&&(p=l.getAttribute(d),this.children||(this.children={}),this.children.hasOwnProperty(p)?f=this.children[p]:this.children[p]=f=new o[d](this.get(p),this.options,this),f.elements=[l],f.add(l),c=!0);if(c)continue}for(a of l.attributes)a.name!==h&&(a.name===i?(this.props||(this.props={}),this.addValue(l.textContent,l,this.props,"textContent")):a.name.endsWith(e)?(this.attrs||(this.attrs={}),this.addValue(a.value,l,this.attrs,a.name.slice(0,-e.length))):a.name.endsWith(s)&&(this.props||(this.props={}),this.addValue(a.value,l,this.props,a.name.slice(0,-s.length))));let t=l.firstElementChild;for(;t;)t.hasAttribute(h)||this.add(t),t=t.nextElementSibling}}remove(t){if(t){if(this.children)for(let e of Object.keys(this.children))e.startsWith(t)&&delete this.children[e];if(this.attrs)for(let e of Object.keys(this.attrs))e.startsWith(t)&&delete this.attrs[e];if(this.props)for(let e of Object.keys(this.props))e.startsWith(t)&&delete this.props[e]}else delete this.children,delete this.attrs,delete this.props;return this}react(...t){if(t.length){let e,s,h,l,o,f;for(f of(1===t.length&&"object"==typeof t[0]&&(e=t[0],t=Array.from(Object.keys(t[0]))),t)){if(o=e?e[f]:this.get(f),this.attrs)for([h,l]of Object.entries(this.attrs))h.startsWith(f)&&i(l,o,r);if(this.props)for([h,l]of Object.entries(this.props))h.startsWith(f)&&i(l,o,n);this.children?.hasOwnProperty(f)&&(void 0!==o?(s=this.children[f],s.refs=o,s.react()):(this.children[f].delete(),delete this.children[f]))}}else{if(null===this.refs&&!this.hidden)return this.hide();if(this.hidden&&null!==this.refs&&this.show(),this.attrs)for(let[t,e]of Object.entries(this.attrs))i(e,this.get(t),r);if(this.props)for(let[t,e]of Object.entries(this.props))i(e,this.get(t),n);if(this.children)for(let[t,e]of Object.entries(this.children))e.refs=this.get(t),e.react()}return this}set(t){let e;for(let[s,i]of Object.entries(t))e=this.destructure(s),e.parent[e.prop]=i,this.children?.hasOwnProperty(s)&&(this.children[s].refs=i);return this.react(t),this}delete(t){if(void 0===t){if(this.elements)for(let t of this.elements)t.remove()}else{const e=this.destructure(t);delete e.parent[e.prop],this.children?.hasOwnProperty(t)?this.children[t].delete():this.react({[t]:void 0})}return this.remove(t)}call(t,...e){const s=this.destructure(t),i=s.parent[s.prop](...e);return this.react({[t]:i}),i}destructure(t){if("string"!=typeof t||!t.trim())return null;const e=t.split(this.options?.sep?.ref||l.sep.ref);let s=this.refs,i=this.parent,r=e[0],n=s[r];for(;void 0===n&&i;)s=i.refs,n=s[r],i=i.parent;if(void 0!==n)for(let t=1;t<e.length&&(s=n,r=e[t],n=s[r],void 0!==n);t++);return{parent:s,prop:r}}get(t){if("string"!=typeof t||!t.trim())return"";const e=this.destructure(t);if(!e)return;const s=e.parent[e.prop];return void 0!==s?s:void 0}hide(){let t;for(t of(this.hidden=new Map,this.elements))this.hidden.set(t,t.style.display),t.style.display="none"}show(){if(this.hidden){for(let[t,e]of this.hidden.entries())t.style.display=e;delete this.hidden}}}function i(t,e,s){let i;for(let[r,n]of t.entries())for(i of n)"string"==typeof i?s(r,i,e):s(r,i.name,i.values.set(i.index,e))}function r(t,e,s){void 0!==s?t.setAttribute(e,s):t.removeAttribute(e)}function n(t,e,s){t[e]=s,void 0===s&&delete t[e]}class h extends s{items;templates;getTemplate(t,e){this.templates||(this.templates=new WeakMap);let s=this.templates.get(t);return s&&!e||(1===t.children.length?s=t.firstElementChild instanceof HTMLTemplateElement?t.firstElementChild.content:t.firstElementChild:(s=document.createDocumentFragment(),s.append(...t.childNodes)),this.templates.set(t,s)),s}add(...t){this.elements||(this.elements=[]),this.items||(this.items=new WeakMap);for(let e of t)this.elements.push(e),this.items.set(e,[]),this.getTemplate(e,!0);return this.reactOn(...t),this}react(...t){if(this.items||(this.items=new WeakMap),t.length){let e,s,i,r,n;1===t.length&&"object"==typeof t[0]&&(s=t[0],t=Array.from(Object.keys(s)));for(let h of t)for(r of(i=s?s[h]:this.get(h),this.elements))n=this.items.get(r),n.hasOwnProperty(h)&&(e=n[h],e.refs={item:i,index:"number"==typeof h?h:parseInt(h)},e.react())}else{let t;for(t of(this.items=new WeakMap,this.remove(),this.elements))t.textContent="",this.items.set(t,[]);for(let e of this.refs)for(t of this.elements)this.addChild(t,e)}return this}reactOn(...t){let e;for(e of(this.items||(this.items=new WeakMap),t))e.textContent="",this.items.set(e,[]);for(let s of this.refs)for(e of t)this.addChild(e,s)}createChild(t,e,i){const r=new(this.options?.ref||s)({index:e,item:i},this.options,this),n=this.templates.get(t);if(n instanceof Element){const t=n.cloneNode(!0);r.elements=[t],r.add(t)}else n instanceof DocumentFragment&&(r.elements=Array.from(n.cloneNode(!0).children),r.add(...r.elements));return r.react(),r}addChild(t,e,s){const i=this.items.get(t),r=this.createChild(t,i.length,e),n=void 0!==s&&t.children.length>s?t.children[s]:null;if(n)for(let e of r.elements)t.insertBefore(e,n);else t.append(...r.elements);i.push(r)}push(...t){let e;this.refs.push&&this.refs.push(...t);for(let s of t)for(e of this.elements)this.addChild(e,s)}pop(){let t;this.refs.pop&&this.refs.pop();for(let e of this.elements)t=this.items.get(e),t.at(-1).delete(),t.pop()}splice(t,e,...s){this.refs.splice&&this.refs.splice(t,e,...s);for(let i of this.elements){const r=this.items.get(i),n=s.map(((e,s)=>this.createChild(i,t+s,e)));for(let s=0;s<e;s++)r[t+s].delete();let h;r.splice(t,e,...n);const l=this.templates.get(i),o=(l instanceof DocumentFragment?l.children.length:1)*t;if(i.children.length>o){const t=i.children[o];for(let e of n)for(h of e.elements)i.insertBefore(h,t)}else for(let t of n)i.append(...t.elements)}}set(t){let e,s,i,r,n;for([e,i]of Object.entries(t))for(r of(s=parseInt(e),this.refs[s]=i,this.elements))n=this.items.get(r),n?.hasOwnProperty(e)&&(n[e].refs={item:i,index:parseInt(e)});return this.react(t),this}delete(t){if(void 0===t){if(this.refs.length=0,this.elements){for(let t of this.elements)t.remove();delete this.elements}return delete this.templates,delete this.items,this.remove()}this.splice("string"==typeof t?parseInt(t):t,1)}}const l={suffix:{attr:"-a",prop:"-p"},attr:{text:"t",ref:"re-f",iter:"ite-r",closed:"close-d"},sep:{ref:".",multivalue:"|",calc:":="},calc:{add(...t){let e=0;for(let s of t)"string"==typeof s&&(s=(s.indexOf(".")>=0?parseFloat:parseInt)(s.trim())),e+=s;return e}},ref:s,iter:h};export{h as IterRefType,t as MultiValue,s as RefType,e as addRef,l as options,i as react,r as setAttr,n as setProp};
class e{values;calc;constructor(e,t){this.values=e,t&&(this.calc=t)}set(e,t){return this.values[e]=t,this.calc?this.calc(...this.values.filter(((e,t)=>""!==e||!(t%2)))):this.values.join("")}}function t(e,t,s,i){let r,n;s.hasOwnProperty(e)?r=s[e]:s[e]=r=new Map,r.has(t)?n=r.get(t):r.set(t,n=new Set),n.add(i)}class s{refs;elements;options;parent;attrs;props;multiValues;children;hidden;constructor(e,t,s){this.refs=e,t&&(this.options=t),s&&(this.parent=s)}createMultiValue(t,s){const i=t.split(this.options?.sep?.multivalue||l.sep.multivalue),r=[];let n;for(let e=0;e<i.length;e+=2)n=i[e].trim(),r.push(n),i[e]=this.get(n);return{refs:r,values:new e(i,s)}}addValue(e,s,i,r){let n,h;const o=this.options?.sep?.calc||l.sep.calc;if((e=e.trim()).indexOf(o)>=0&&([n,e]=e.split(o,2),n=n.trim(),h=this.options?.calc?.[n]||l.calc[n],!h))throw new TypeError(`The calculation ${n} could not be found`);if(e=e.trim(),h||e.indexOf(this.options?.sep?.multivalue||l.sep.multivalue)>=0){const{refs:n,values:l}=this.createMultiValue(e,h),o={name:r,values:l};let f=0;for(let e of n)t(e,s,i,Object.assign({index:f},o)),f+=2}else t(e,s,i,r)}add(...e){const t=this.options?.suffix?.attr||l.suffix.attr,s=this.options?.suffix?.prop||l.suffix.prop,i=this.options?.attr?.text||l.attr.text,r=this.options?.attr?.ref||l.attr.ref,n=this.options?.attr?.iter||l.attr.iter,o=this.options?.attr?.closed||l.attr.closed,f={[r]:this.options?.ref||l.ref,[n]:this.options?.iter||l.iter};let a,d,p,c,m,u;for(let l of e){if(m=!1,!this.elements||!this.elements.includes(l)){for(c of[r,n])l.hasAttribute(c)&&(p=l.getAttribute(c),c===n&&p.startsWith("{")&&p.endsWith("}")?(u=!0,p=p.slice(1,-1)):u=!1,this.children||(this.children={}),this.children.hasOwnProperty(p)?a=this.children[p]:this.children[p]=a=new f[c](this.get(p),this.options,this),u&&a instanceof h&&(a.addIndex=!0),a.elements=[l],a.add(l),m=!0);if(m)continue}for(d of l.attributes)d.name!==o&&(d.name===i?(this.props||(this.props={}),this.addValue(l.textContent,l,this.props,"textContent")):d.name.endsWith(t)?(this.attrs||(this.attrs={}),this.addValue(d.value,l,this.attrs,d.name.slice(0,-t.length))):d.name.endsWith(s)&&(this.props||(this.props={}),this.addValue(d.value,l,this.props,d.name.slice(0,-s.length))));let e=l.firstElementChild;for(;e;)e.hasAttribute(o)||this.add(e),e=e.nextElementSibling}}remove(e){if(e){if(this.children)for(let t of Object.keys(this.children))t.startsWith(e)&&delete this.children[t];if(this.attrs)for(let t of Object.keys(this.attrs))t.startsWith(e)&&delete this.attrs[t];if(this.props)for(let t of Object.keys(this.props))t.startsWith(e)&&delete this.props[t]}else delete this.children,delete this.attrs,delete this.props;return this}react(...e){if(null===this.refs&&!this.hidden)return this.hide();if(this.hidden&&null!==this.refs&&this.show(),e.length){let t,s,h,o,f,a;for(a of(1===e.length&&"object"==typeof e[0]&&(t=e[0],e=Array.from(Object.keys(e[0]))),this.hidden&&null!==this.refs&&this.show(),e)){if(f=t?t[a]:this.get(a),this.attrs)for([h,o]of Object.entries(this.attrs))h.startsWith(a)&&i(o,f,r);if(this.props)for([h,o]of Object.entries(this.props))h.startsWith(a)&&i(o,f,n);this.children?.hasOwnProperty(a)&&(s=this.children[a],void 0!==f?(s.refs=f,s.react()):(s.delete(),delete this.children[a])),a!==this.options?.self&&a!==l.self||(void 0!==f?this.react():this.delete())}}else{if(this.attrs)for(let[e,t]of Object.entries(this.attrs))i(t,this.get(e),r);if(this.props)for(let[e,t]of Object.entries(this.props))i(t,this.get(e),n);if(this.children)for(let[e,t]of Object.entries(this.children))t.refs=this.get(e),t.react()}return this}set(e){let t;for(let[s,i]of Object.entries(e))t=this.destructure(s),t.parent[t.prop]=i;return this.react(e),this}delete(e){if(void 0===e){if(this.elements)for(let e of this.elements)e.remove()}else{const t=this.destructure(e);delete t.parent[t.prop],this.children?.hasOwnProperty(e)?this.children[e].delete():this.react({[e]:void 0})}return this.remove(e)}call(e,...t){const s=this.destructure(e),i=s.parent[s.prop](...t);return this.react({[e]:i}),i}destructure(e){if("string"!=typeof e||!e.trim())return null;if(e===this.options?.self||e===l.self)return{parent:this,prop:"refs"};const t=e.split(this.options?.sep?.ref||l.sep.ref);let s=this.refs,i=this.parent,r=t[0],n=s[r];for(;void 0===n&&i;)s=i.refs,n=s[r],i=i.parent;if(void 0!==n)for(let e=1;e<t.length&&(s=n,r=t[e],n=s[r],void 0!==n);e++);return{parent:s,prop:r}}get(e){if("string"!=typeof e||!e.trim())return"";if(e===this.options?.self||e===l.self)return this.refs;const t=this.destructure(e);if(!t)return;const s=t.parent[t.prop];return void 0!==s?s:void 0}hide(){let e;for(e of(this.hidden=new Map,this.elements))this.hidden.set(e,e.style.display),e.style.display="none"}show(){if(this.hidden){for(let[e,t]of this.hidden.entries())e.style.display=t;delete this.hidden}}}function i(e,t,s){let i;for(let[r,n]of e.entries())for(i of n)"string"==typeof i?s(r,i,t):s(r,i.name,i.values.set(i.index,t))}function r(e,t,s){void 0!==s?e.setAttribute(t,s):e.removeAttribute(t)}function n(e,t,s){e[t]=s,void 0===s&&delete e[t]}class h extends s{items;addIndex;templates;getTemplate(e,t){this.templates||(this.templates=new WeakMap);let s=this.templates.get(e);return s&&!t||(1===e.children.length?s=e.firstElementChild instanceof HTMLTemplateElement?e.firstElementChild.content:e.firstElementChild:(s=document.createDocumentFragment(),s.append(...e.childNodes)),this.templates.set(e,s)),s}add(...e){this.elements||(this.elements=[]),this.items||(this.items=new WeakMap);for(let t of e)this.elements.push(t),this.items.set(t,[]),this.getTemplate(t,!0);return this.reactOn(...e),this}react(...e){if(null===this.refs&&!this.hidden)return this.hide();if(this.hidden&&null!==this.refs&&this.show(),this.items||(this.items=new WeakMap),e.length){let t,s,i,r,n;1===e.length&&"object"==typeof e[0]&&(s=e[0],e=Array.from(Object.keys(s)));for(let h of e)if(i=s?s[h]:this.get(h),h!==this.options?.self&&h!==l.self)for(r of this.elements)n=this.items.get(r),n.hasOwnProperty(h)&&(t=n[h],this.addIndex?t.refs={item:i,index:"number"==typeof h?h:parseInt(h)}:t.refs=i,t.react());else this.refs=i,this.react()}else{let e;for(e of(this.items=new WeakMap,this.remove(),this.elements))e.textContent="",this.items.set(e,[]);for(let t of this.refs)for(e of this.elements)this.addChild(e,t)}return this}reactOn(...e){if(null===this.refs&&!this.hidden)return this.hide();let t;for(t of(this.hidden&&null!==this.refs&&this.show(),this.items||(this.items=new WeakMap),e))t.textContent="",this.items.set(t,[]);for(let s of this.refs)for(t of e)this.addChild(t,s)}createChild(e,t,s){const i=new(this.options?.item||l.item)(this.addIndex?{index:t,item:s}:s,this.options,this),r=this.templates.get(e);if(r instanceof Element){const e=r.cloneNode(!0);i.elements=[e],i.add(e)}else r instanceof DocumentFragment&&(i.elements=Array.from(r.cloneNode(!0).children),i.add(...i.elements));return i.react(),i}addChild(e,t,s){const i=this.items.get(e),r=this.createChild(e,i.length,t),n=void 0!==s&&e.children.length>s?e.children[s]:null;if(n)for(let t of r.elements)e.insertBefore(t,n);else e.append(...r.elements);i.push(r)}push(...e){let t,s;this.refs.push&&(t=this.refs.push(...e));for(let t of e)for(s of this.elements)this.addChild(s,t);return t}pop(){let e,t;this.refs.pop&&(e=this.refs.pop());for(let e of this.elements)t=this.items.get(e),t.at(-1).delete(),t.pop();return e}splice(e,t,...s){let i;this.refs.splice&&(i=this.refs.splice(e,t,...s));for(let i of this.elements){const r=this.items.get(i),n=s.map(((t,s)=>this.createChild(i,e+s,t)));for(let s=0;s<t;s++)r[e+s].delete();if(r.splice(e,t,...n),this.addIndex)for(let t=e;t<r.length;t++)r[t].set({index:t+s.length});let h;const l=this.templates.get(i),o=(l instanceof DocumentFragment?l.children.length:1)*e;if(i.children.length>o){const e=i.children[o];for(let t of n)for(h of t.elements)i.insertBefore(h,e)}else for(let e of n)i.append(...e.elements)}return i}move(e,t,s){if(e===t)return;const i={[e]:t};let r,n,h;s&&(i[t]=e);const l=this.refs.slice();let o,f,a,d,p,c,m,u=0;for(let g of this.elements){for(c of(u++,r=this.items.get(g),o={},Object.keys(i)))o[c]=r[c];for(c of(f={},Object.values(i)))m=r[c],f[c]=m.elements.at(-1).nextSibling||[m.elements[0].parentNode];for([e,t]of Object.entries(i)){if("string"==typeof e&&(e=parseInt(e)),h=o[e],p=f[t],p instanceof Array)for(a of(d=p[0],h.elements))d.appendChild(a);else for(a of(d=p.parentNode,h.elements))d.insertBefore(a,p);if(s)1===u&&(this.refs[t]=l[e]),r[t]=h;else{if(this.addIndex)if(e>t)for(n=t;n<e;n++)r[n].set({index:n+1});else for(n=e+1;n<=t;n++)r[n].set({index:n-1});1===u&&this.refs.splice(t,0,...this.refs.splice(e,1)),r.splice(t,0,...r.splice(e,1))}this.addIndex&&h.set({index:t})}}return this}delete(e){if(void 0===e){if(this.refs.length=0,this.elements){for(let e of this.elements)e.remove();delete this.elements}return delete this.templates,delete this.items,this.remove()}this.splice("string"==typeof e?parseInt(e):e,1)}}const l={suffix:{attr:"-a",prop:"-p"},attr:{text:"t",ref:"re-f",iter:"ite-r",closed:"close-d"},sep:{ref:".",multivalue:"|",calc:":="},calc:{add(...e){let t=0;for(let s of e)"string"==typeof s&&(s=(s.indexOf(".")>=0?parseFloat:parseInt)(s.trim())),t+=s;return t}},ref:s,iter:h,item:s,self:"."};export{h as IterRefType,e as MultiValue,s as RefType,t as addRef,l as options,i as react,r as setAttr,n as setProp};
{
"name": "deleight",
"version": "2.0.0",
"version": "2.0.1",
"description": "A group of 10 libraries for writing accessible and joyfully interactive web applications with traditional HTML, CSS and JavaScript.",

@@ -5,0 +5,0 @@ "type": "module",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc