simplyflow 0.5.0 → 0.5.3
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/dist/simply.flow.js +66 -3
- package/dist/simply.flow.min.js +1 -1
- package/dist/simply.flow.min.js.map +4 -4
- package/package.json +1 -1
- package/src/flow.mjs +1 -0
- package/src/flow.mjs~ +14 -0
- package/src/model.mjs +18 -3
- package/src/render.mjs +54 -0
package/dist/simply.flow.js
CHANGED
|
@@ -1076,14 +1076,21 @@
|
|
|
1076
1076
|
* Creates a new datamodel, with a state property that contains
|
|
1077
1077
|
* all the data passed to this constructor
|
|
1078
1078
|
* @param state Object with all the data for this model
|
|
1079
|
+
* @throws Error if state is not set
|
|
1079
1080
|
*/
|
|
1080
1081
|
constructor(state) {
|
|
1082
|
+
if (!state) {
|
|
1083
|
+
throw new Error("no options set");
|
|
1084
|
+
}
|
|
1085
|
+
if (state.data == null || typeof state.data[Symbol.iterator] !== "function") {
|
|
1086
|
+
console.warn("SimplyFlowModel: options.data is not iterable");
|
|
1087
|
+
}
|
|
1081
1088
|
this.state = signal(state);
|
|
1082
1089
|
if (!this.state.options) {
|
|
1083
1090
|
this.state.options = {};
|
|
1084
1091
|
}
|
|
1085
|
-
this.effects = [{ current: state.data }];
|
|
1086
|
-
this.view =
|
|
1092
|
+
this.effects = [{ current: this.state.data }];
|
|
1093
|
+
this.view = this.state.data;
|
|
1087
1094
|
}
|
|
1088
1095
|
/**
|
|
1089
1096
|
* Adds an effect to run whenever a signal it depends on
|
|
@@ -1095,8 +1102,15 @@
|
|
|
1095
1102
|
* list. And the last effect added is set as this.view
|
|
1096
1103
|
*/
|
|
1097
1104
|
addEffect(fn) {
|
|
1105
|
+
if (!fn || typeof fn !== "function") {
|
|
1106
|
+
throw new Error("addEffect requires an effect function as its parameter", { cause: fn });
|
|
1107
|
+
}
|
|
1098
1108
|
const dataSignal = this.effects[this.effects.length - 1];
|
|
1099
|
-
|
|
1109
|
+
const connectedSignal = fn.call(this, dataSignal);
|
|
1110
|
+
if (!connectedSignal || !connectedSignal[Symbol.Signal]) {
|
|
1111
|
+
throw new Error("addEffect function parameter must return a Signal", { cause: fn });
|
|
1112
|
+
}
|
|
1113
|
+
this.view = connectedSignal;
|
|
1100
1114
|
this.effects.push(this.view);
|
|
1101
1115
|
}
|
|
1102
1116
|
};
|
|
@@ -1246,6 +1260,55 @@
|
|
|
1246
1260
|
};
|
|
1247
1261
|
}
|
|
1248
1262
|
|
|
1263
|
+
// src/render.mjs
|
|
1264
|
+
var SimplyRender = class extends HTMLElement {
|
|
1265
|
+
constructor() {
|
|
1266
|
+
super();
|
|
1267
|
+
}
|
|
1268
|
+
connectedCallback() {
|
|
1269
|
+
let templateId = this.getAttribute("rel");
|
|
1270
|
+
let template = document.getElementById(templateId);
|
|
1271
|
+
if (template) {
|
|
1272
|
+
let content = template.content.cloneNode(true);
|
|
1273
|
+
for (const node of content.childNodes) {
|
|
1274
|
+
const clone = node.cloneNode(true);
|
|
1275
|
+
if (clone.nodeType == document.ELEMENT_NODE) {
|
|
1276
|
+
clone.querySelectorAll("template").forEach(function(t) {
|
|
1277
|
+
t.setAttribute("simply-render", "");
|
|
1278
|
+
});
|
|
1279
|
+
if (this.attributes) {
|
|
1280
|
+
for (const attr of this.attributes) {
|
|
1281
|
+
if (attr.name != "rel") {
|
|
1282
|
+
clone.setAttribute(attr.name, attr.value);
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
this.parentNode.insertBefore(clone, this);
|
|
1288
|
+
}
|
|
1289
|
+
this.parentNode.removeChild(this);
|
|
1290
|
+
} else {
|
|
1291
|
+
const observe = () => {
|
|
1292
|
+
const observer = new MutationObserver(() => {
|
|
1293
|
+
template = document.getElementById(templateId);
|
|
1294
|
+
if (template) {
|
|
1295
|
+
observer.disconnect();
|
|
1296
|
+
this.replaceWith(this);
|
|
1297
|
+
}
|
|
1298
|
+
});
|
|
1299
|
+
observer.observe(globalThis.document, {
|
|
1300
|
+
subtree: true,
|
|
1301
|
+
childList: true
|
|
1302
|
+
});
|
|
1303
|
+
};
|
|
1304
|
+
observe();
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
};
|
|
1308
|
+
if (!customElements.get("simply-render")) {
|
|
1309
|
+
customElements.define("simply-render", SimplyRender);
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1249
1312
|
// src/flow.mjs
|
|
1250
1313
|
if (!globalThis.simply) {
|
|
1251
1314
|
globalThis.simply = {};
|
package/dist/simply.flow.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{var he=Object.defineProperty;var D=(e,t)=>{for(var n in t)he(e,n,{get:t[n],enumerable:!0})};var F={};D(F,{batch:()=>$,clockEffect:()=>Y,destroy:()=>H,effect:()=>X,signal:()=>T,throttledEffect:()=>y,trace:()=>me,untracked:()=>ye});var R=Symbol("iterate");Symbol.xRay||(Symbol.xRay=Symbol("xRay"));Symbol.Signal||(Symbol.Signal=Symbol("Signal"));var de={get:(e,t,n)=>{if(t===Symbol.xRay)return e;if(t===Symbol.Signal)return!0;let i=e?.[t];return z(n,t),typeof i=="function"?Array.isArray(e)?(...r)=>{let l=e.length,s=i.apply(n,r);return l!=e.length&&A(n,w("length",{was:l,now:e.length})),s}:e instanceof Set||e instanceof Map?(...r)=>{let l=e.size,s=i.apply(e,r);return l!=e.size&&A(n,w("size",{was:l,now:e.size})),["set","add","clear","delete"].includes(t)&&A(n,w({entries:{},forEach:{},has:{},keys:{},values:{},[Symbol.iterator]:{}})),s}:e instanceof HTMLElement||e instanceof Number||e instanceof String||e instanceof Boolean?i.bind(e):i.bind(n):i&&typeof i=="object"?T(i):i},set:(e,t,n,i)=>{n=n?.[Symbol.xRay]||n;let r=e[t];return r!==n&&(e[t]=n,A(i,w(t,{was:r,now:n}))),typeof r>"u"&&A(i,w(R,{})),!0},has:(e,t)=>{let n=m.get(e);return n&&z(n,t),Object.hasOwn(e,t)},deleteProperty:(e,t)=>{if(typeof e[t]<"u"){let n=e[t];delete e[t];let i=m.get(e);A(i,w(t,{delete:!0,was:n}))}return!0},defineProperty:(e,t,n)=>{if(typeof e[t]>"u"){let i=m.get(e);A(i,w(R,{}))}return Object.defineProperty(e,t,n)},ownKeys:e=>{let t=m.get(e);return z(t,R),Reflect.ownKeys(e)}},m=new WeakMap;function T(e){if(e[Symbol.Signal]){let t=e[Symbol.xRay];m.has(t)||m.set(t,e),e=t}else m.has(e)||m.set(e,new Proxy(e,de));return m.get(e)}function me(e,t){return Q(e,t).map(i=>({effect:i.effectType,fn:i.effectFunction,signal:m.get(i.effectFunction)}))}var C=new Set,E=0;function A(e,t={}){let n=[];if(t.forEach((i,r)=>{let l=Q(e,r);if(l?.length){for(let s of l)be(s,w(r,i));n=n.concat(l)}}),n=new Set(n.filter(Boolean)),n)if(E)C=C.union(n);else{let i=p[p.length-1];for(let r of Array.from(n))r!=i&&r?.needsUpdate&&r(),J(r)}}function w(e,t){let n=new Map;if(typeof e=="object")for(let i in e)n.set(i,e[i]);else n.set(e,t);return n}function be(e,t){e.context?t.forEach((n,i)=>{e.context.set(i,n)}):e.context=t,e.needsUpdate=!0}function J(e){delete e.context,delete e.needsUpdate}function z(e,t){let n=p[p.length-1];n&&ge(e,t,n)}var M=new WeakMap,B=new WeakMap;function Q(e,t){let n=M.get(e);return n?Array.from(n.get(t)||[]):[]}function ge(e,t,n){M.has(e)||M.set(e,new Map);let i=M.get(e);i.has(t)||i.set(t,new Set),i.get(t).add(n),B.has(n)||B.set(n,new Map);let r=B.get(n);r.has(t)||r.set(t,new Set),r.get(t).add(e)}function q(e){let t=B.get(e);t&&t.forEach(n=>{n.forEach(i=>{let r=M.get(i);r.has(n)&&r.get(n).delete(e)})})}var p=[],P=[],I=new WeakMap,S=[];function X(e){if(P.findIndex(i=>e==i)!==-1)throw new Error("Recursive update() call",{cause:e});P.push(e);let t=m.get(e);t||(t=T({current:null}),m.set(e,t));let n=function i(){if(S.findIndex(l=>l==t)!==-1)throw new Error("Cyclical dependency in update() call",{cause:e});q(i),i.effectFunction=e,i.effectType=X,p.push(i),S.push(t);let r;try{r=e(i,p,S)}finally{p.pop(),S.pop(),r instanceof Promise?r.then(l=>{t.current=l}):t.current=r}};return n.fn=e,I.set(t,n),n(),t}function H(e){let t=I.get(e)?.deref();if(!t)return;q(t);let n=t.fn;m.remove(n),I.delete(e)}function $(e){E++;let t;try{t=e()}finally{t instanceof Promise?t.then(()=>{E--,E||G()}):(E--,E||G())}return t}function G(){let e=Array.from(C);C=new Set;let t=p[p.length-1];for(let n of e)n!=t&&n?.needsUpdate&&n(),J(n)}function y(e,t){if(P.findIndex(s=>e==s)!==-1)throw new Error("Recursive update() call",{cause:e});P.push(e);let n=m.get(e);n||(n=T({current:null}),m.set(e,n));let i=!1,r=!0;return function s(){if(S.findIndex(c=>c==n)!==-1)throw new Error("Cyclical dependency in update() call",{cause:e});if(i&&i>Date.now()){r=!0;return}q(s),s.effectFunction=e,s.effectType=y,p.push(s),S.push(n);let a;try{a=e(s,p,S)}finally{r=!1,p.pop(),S.pop(),a instanceof Promise?a.then(c=>{n.current=c}):n.current=a}i=Date.now()+t,globalThis.setTimeout(()=>{r&&s()},t)}(),n}function Y(e,t){let n=m.get(e);n||(n=T({current:null}),m.set(e,n));let i=-1,r=!0;return function s(){if(i<t.time)if(r){q(s),s.effectFunction=e,s.effectType=Y,p.push(s),i=t.time;let a;try{a=e(s,p)}finally{p.pop(),a instanceof Promise?a.then(c=>{n.current=c}):n.current=a,r=!1}}else i=t.time;else r=!0}(),n}function ye(e){let t=p.slice();p=[];try{return e()}finally{p=t}}function Z(e,t){let n=e.value.innerHTML;typeof e.value=="string"&&(n=e.value,e.value={innerHTML:n}),n&&(n=n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),e.value.innerHTML=n),t(e)}function x(e,t){typeof e.value=="string"?e.value={}:delete e.value.innerHTML,t(e)}function te(e){if(e.templates?.length)Te.call(this,e);else if(Object.hasOwnProperty.call(this.options.renderers,e.element.tagName)){let t=this.options.renderers[e.element.tagName];t&&t.call(this,e)}else this.options.renderers["*"]&&this.options.renderers["*"].call(this,e);return e}function ne(e){return Array.isArray(e.value)?e.templates?.length?we.call(this,e):console.error("No templates found in",e.element):console.error("Value is not an array.",e.element,e.path,e.value),e}function ie(e){return typeof e.value!="object"||!e.value?console.error("Value is not an object.",e.element,e.path,e.value):e.templates?.length?Se.call(this,e):console.error("No templates found in",e.element),e}function we(e){let t=this.options.attribute,n=e.element.querySelectorAll(":scope > ["+t+"-key]"),i=0,r=0;e.list=e.value;for(let s of n){let a=parseInt(s.getAttribute(t+"-key"));if(a>i)e.index=i,e.element.insertBefore(this.applyTemplate(e),s);else if(a<i)s.remove();else{let c=Array.from(s.querySelectorAll(`[${t}]`));s.matches(`[${t}]`)&&c.unshift(s);let u=c.find(h=>{let b=h.getAttribute(t);return b.substr(0,5)!==":root"&&b.substr(0,e.path.length)!==e.path});if(!u&&s[Symbol.bindTemplate]){let h=this.findTemplate(e.templates,e.list[i]);h!=s[Symbol.bindTemplate]&&(u=!0,h||r++)}u&&(e.index=i,e.element.replaceChild(this.applyTemplate(e),s))}if(i++,i>=e.value.length)break}n=e.element.querySelectorAll(":scope > ["+t+"-key]");let l=n.length+r;if(l>e.value.length)for(;l>e.value.length;)e.element.querySelectorAll(":scope > :not(template)")?.[l-1]?.remove(),l--;else if(l<e.value.length)for(;l<e.value.length;)e.index=l,e.element.appendChild(this.applyTemplate(e)),l++}function Se(e){let t=this.options.attribute;e.list=e.value;let n=Array.from(e.element.querySelectorAll(":scope > ["+t+"-key]"));for(let i in e.list){e.index=i;let r=n.shift();if(!r){let s=this.applyTemplate(e);e.element.appendChild(s);continue}if(r.getAttribute[t+"-key"]!=i){n.unshift(r);let s=e.element.querySelector(":scope > ["+t+'-key="'+i+'"]');if(s)e.element.insertBefore(s,r),r=s,n=n.filter(a=>a!=s);else{let a=this.applyTemplate(e);e.element.insertBefore(a,r);continue}}if(this.findTemplate(e.templates,e.list[e.index])!=r[Symbol.bindTemplate]){let s=this.applyTemplate(e);e.element.replaceChild(s,r)}}for(;n.length;)n.shift().remove()}function Te(e){let t=e.element.querySelector(":scope > :not(template)"),n=this.findTemplate(e.templates,e.value);if(e.parent=Ae(e.element),t)if(n){if(t?.[Symbol.bindTemplate]!=n){let i=this.applyTemplate(e);e.element.replaceChild(i,t)}}else e.element.removeChild(t);else if(n){let i=this.applyTemplate(e);e.element.appendChild(i)}}function Ae(e,t){let n=e.parentElement?.closest(`[${t}-list],[${t}-map]`);return n?n.hasAttribute(`${t}-list`)?n.getAttribute(`${t}-list`)+".":n.getAttribute(`${t}-map`)+".":""}function re(e){let t=e.element,n=e.value;L(e),typeof n>"u"&&(n=""),t.type=="checkbox"||t.type=="radio"?N(t.value,n)?t.checked=!0:t.checked=!1:N(t.value,n)||(t.value=""+n)}function se(e){L(e),v(e.element,e.value,"value")}function U(e){let t=e.element,n=e.value;if(n===null&&(n=""),typeof n!="object")if(t.multiple){if(Array.isArray(n))for(let i of t.options)n.indexOf(i.value)===!1?i.selected=!1:i.selected=!0}else{let i=t.options.find(r=>N(r.value,n));i&&(i.selected=!0,i.setAttribute("selected",!0))}else n.options&&ve(t,n.options),n.selected&&U(Object.asssign({},e,{value:n.selected})),v(t,n,"name","id","selectedIndex","className")}function ee(e,t){t&&(typeof t!="object"?e.options.add(new Option(""+t)):t.text?e.options.add(new Option(t.text,t.value,t.defaultSelected,t.selected)):typeof t.value<"u"&&e.options.add(new Option(""+t.value,t.value,t.defaultSelected,t.selected)))}function ve(e,t){if(e.innerHTML="",Array.isArray(t))for(let n of t)ee(e,n);else if(t&&typeof t=="object")for(let n in t)ee(e,{text:t[n],value:n})}function le(e){L(e),v(e.element,e.value,"target","href","name","newwindow","nofollow")}function oe(e){v(e.element,e.value,"title","alt","src","id")}function ae(e){v(e.element,e.value,"title","src","id")}function fe(e){v(e.element,e.value,"content","id")}function L(e){let t=e.element,n=e.value;(typeof n>"u"||n==null)&&(n="");let i=""+n;if(typeof n!="object"||i.substring(0,8)!="[object "){t.innerHTML=i;return}v(t,n,"innerHTML","title","id","className")}function v(e,t,...n){if(!(!t||typeof t!="object"))for(let i of n)typeof t[i]>"u"||N(e[i],t[i])||(t[i]===null?e[i]="":e[i]=""+t[i])}function N(e,t){return e==":empty"&&!t||t==":empty"&&!e||""+e==""+t}Symbol.bindTemplate||(Symbol.bindTemplate=Symbol("bindTemplate"));var W=class{constructor(t){this.bindings=new Map;let n={escape_html:Z,fixed_content:x},i={container:document.body,attribute:"data-flow",transformers:n,render:{field:[te],list:[ne],map:[ie]},renderers:{INPUT:re,BUTTON:se,SELECT:U,A:le,IMG:oe,IFRAME:ae,META:fe,TEMPLATE:null,"*":L}};if(!t?.root)throw new Error("bind needs at least options.root set");this.options=Object.assign({},i,t),t.transformers&&(this.options.transformers=Object.assign({},n,t?.transformers));let r=this.options.attribute,l=[r+"-field",r+"-list",r+"-map"],s=r+"-transform",a=o=>{let f=l.find(d=>o.hasAttribute(d));return f||console.error("No matching attribute found",o,l),f},c=o=>{this.bindings.set(o,y(()=>{if(!o.isConnected){Me(o,this.getBindingPath(o)),H(this.bindings.get(o));return}let f={templates:o.querySelectorAll(":scope > template"),attribute:a(o)};f.path=this.getBindingPath(o),f.value=V(this.options.root,f.path),f.element=o,ke(o,f),u(f)},50))},u=o=>{let f;switch(o.attribute){case this.options.attribute+"-field":f=Array.from(this.options.render.field);break;case this.options.attribute+"-list":f=Array.from(this.options.render.list);break;case this.options.attribute+"-map":f=Array.from(this.options.render.map);break;default:throw new Error("no valid context attribute specified",o)}o.element.hasAttribute(s)&&o.element.getAttribute(s).split(" ").filter(Boolean).forEach(g=>{this.options.transformers[g]?f.push(this.options.transformers[g]):console.warn("No transformer with name "+g+" configured",{cause:o.element})});let d;for(let g of f)d=((k,ce)=>pe=>ce.call(this,pe,k))(d,g);d(o)},h=o=>{for(let f of o)this.bindings.get(f)||c(f)},b=o=>{let f=`[${r}-field],[${r}-list],[${r}-map]`;for(let d of o)if(d.type=="childList"&&d.addedNodes){for(let g of d.addedNodes)if(g instanceof HTMLElement){let k=Array.from(g.querySelectorAll(f));g.matches(f)&&k.unshift(g),k.length&&h(k)}}};this.observer=new MutationObserver(o=>{b(o)}),this.observer.observe(this.options.container,{subtree:!0,childList:!0});let j=this.options.container.querySelectorAll(":is(["+this.options.attribute+"-field],["+this.options.attribute+"-list],["+this.options.attribute+"-map]):not(template)");j.length&&h(j)}applyTemplate(t){let n=t.path,i=t.parent,r=t.templates,l=t.list,s=t.index,a=l?l[s]:t.value,c=this.findTemplate(r,a);if(!c){let o=new DocumentFragment;return o.innerHTML="<!-- no matching template -->",o}let u=c.content.cloneNode(!0);if(!u.children?.length)return u;if(u.children.length>1)throw new Error("template must contain a single root node",{cause:c});let h=this.options.attribute,b=[h+"-field",h+"-list",h+"-map"],j=u.querySelectorAll(`[${h}-field],[${h}-list],[${h}-map]`);for(let o of j){if(o.tagName=="TEMPLATE")continue;let f=b.find(g=>o.hasAttribute(g)),d=o.getAttribute(f);d=this.applyLinks(c.links,d),d.substring(0,6)==":root."?o.setAttribute(f,d.substring(6)):d==":value"&&s!=null?o.setAttribute(f,n+"."+s):s!=null?o.setAttribute(f,n+"."+s+"."+d):o.setAttribute(f,i+d)}return typeof s<"u"&&u.children[0].setAttribute(h+"-key",s),u.children[0][Symbol.bindTemplate]=c,u}parseLinks(t){let n={};t=t.split(";").map(i=>i.trim());for(let i of t)i=i.split("="),n[i[0].trim()]=i[1].trim();return n}applyLinks(t,n){for(let i in t){if(n.startsWith(i+"."))return t[i]+n.substr(i.length);if(n==i)return t[i]}return n}getBindingPath(t){let n=[this.options.attribute+"-field",this.options.attribute+"-list",this.options.attribute+"-map"];for(let i of n)if(t.hasAttribute(i))return t.getAttribute(i)}findTemplate(t,n){let i=a=>{let c=this.getBindingPath(a),u;c?c.substr(0,6)==":root."?u=V(this.options.root,c):u=V(n,c):u=n;let h=""+u,b=a.getAttribute(this.options.attribute+"-match");if(b){if(b===":empty"&&!u)return a;if(b===":notempty"&&u||h.match(b))return a}if(!b&&u!==null&&u!==void 0)return a},r=Array.from(t).find(i),l=null;r?.hasAttribute(this.options.attribute+"-link")&&(l=this.parseLinks(r.getAttribute(this.options.attribute+"-link")));let s=r?.getAttribute("rel");if(s){let a=document.querySelector("template#"+s);if(!a)throw new Error("Could not find template with id "+s);r=a}return r&&(r.links=l),r}destroy(){this.bindings.forEach(t=>{H(t)}),this.bindings=new Map,this.observer.disconnect()}};function ue(e){return new W(e)}var O=new Map;function ke(e,t){O.has(t.path)?O.get(t.path).push(t):O.set(t.path,[t])}function Me(e,t){let n=O.get(t);n&&(n=n.filter(i=>i.element==e),O.set(t,n))}function V(e,t){let n=t.split("."),i=e,r;for(r=n.shift();r&&i;)r=decodeURIComponent(r),i=i[r],r=n.shift();return i}var _={};D(_,{columns:()=>Ce,filter:()=>Be,model:()=>Le,paging:()=>je,scroll:()=>Pe,sort:()=>Oe});var K=class{constructor(t){this.state=T(t),this.state.options||(this.state.options={}),this.effects=[{current:t.data}],this.view=T(t.data)}addEffect(t){let n=this.effects[this.effects.length-1];this.view=t.call(this,n),this.effects.push(this.view)}};function Le(e){return new K(e)}function Oe(e={}){return function(t){return this.state.options.sort=Object.assign({direction:"asc",sortBy:null,sortFn:(n,i)=>{let r=this.state.options.sort,l=r.sortBy;if(!r.sortBy)return 0;let s=r.direction=="asc"?1:-1,a=r.direction=="asc"?-1:1;return typeof n?.[l]>"u"?typeof i?.[l]>"u"?0:s:typeof i?.[l]>"u"||n[l]<i[l]?a:n[l]>i[l]?s:0}},e),y(()=>{let n=this.state.options.sort;return n?.sortBy&&n?.direction?t.current.toSorted(n?.sortFn):t.current},50)}}function je(e={}){return function(t){return this.state.options.paging=Object.assign({page:1,pageSize:20,max:1},e),y(()=>$(()=>{let n=this.state.options.paging;n.pageSize||(n.pageSize=20),n.max=Math.ceil(this.state.data.length/n.pageSize),n.page=Math.max(1,Math.min(n.max,n.page));let i=(n.page-1)*n.pageSize,r=i+n.pageSize;return t.current.slice(i,r)}),50)}}function Be(e){if(!e?.name||typeof e.name!="string")throw new Error("filter requires options.name to be a string");if(!e.matches||typeof e.matches!="function")throw new Error("filter requires options.matches to be a function");return function(t){if(this.state.options[e.name])throw new Error("a filter with this name already exists on this model");return this.state.options[e.name]=e,y(()=>this.state.options[e.name].enabled?t.current.filter(this.state.options[e.name].matches.bind(this)):t.current,50)}}function Ce(e={}){if(!e||typeof e!="object"||Object.keys(e).length===0)throw new Error("columns requires options to be an object with at least one property");return function(t){return this.state.options.columns=e,y(()=>t.current.map(n=>{let i={};for(let r of Object.keys(this.state.options.columns))this.state.options.columns[r]?.hidden||(i[r]=n[r]);return i}),50)}}function Pe(e){return function(t){this.state.options.scroll=Object.assign({offset:0,rowHeight:26,rowCount:20,itemsPerRow:1,size:t.current.length},e);let n=this.state.options.scroll,i=n.scrollbar||n.container?.querySelector("[data-flow-scrollbar]");return i&&(n.container&&n.container.addEventListener("scroll",r=>{n.offset=Math.floor(n.container.scrollTop/(n.rowHeight*n.itemsPerRow))}),y(()=>{n.size=t.current.length*n.rowHeight,i.style.height=n.size+"px"},50)),y(()=>{n.container&&(n.rowCount=Math.ceil(n.container.getBoundingClientRect().height/n.rowHeight)),n.data=t.current;let r=Math.min(n.offset,t.current.length-1),l=r+n.rowCount;return l>t.current.length&&(l=t.current.length,r=l-n.rowCount),t.current.slice(r,l)},50)}}globalThis.simply||(globalThis.simply={});Object.assign(globalThis.simply,{bind:ue,flow:_,state:F});var Ue=globalThis.simply;})();
|
|
1
|
+
(()=>{var he=Object.defineProperty;var G=(e,t)=>{for(var n in t)he(e,n,{get:t[n],enumerable:!0})};var F={};G(F,{batch:()=>$,clockEffect:()=>Z,destroy:()=>q,effect:()=>Y,signal:()=>T,throttledEffect:()=>y,trace:()=>be,untracked:()=>we});var I=Symbol("iterate");Symbol.xRay||(Symbol.xRay=Symbol("xRay"));Symbol.Signal||(Symbol.Signal=Symbol("Signal"));var me={get:(e,t,n)=>{if(t===Symbol.xRay)return e;if(t===Symbol.Signal)return!0;let i=e?.[t];return R(n,t),typeof i=="function"?Array.isArray(e)?(...r)=>{let l=e.length,s=i.apply(n,r);return l!=e.length&&E(n,w("length",{was:l,now:e.length})),s}:e instanceof Set||e instanceof Map?(...r)=>{let l=e.size,s=i.apply(e,r);return l!=e.size&&E(n,w("size",{was:l,now:e.size})),["set","add","clear","delete"].includes(t)&&E(n,w({entries:{},forEach:{},has:{},keys:{},values:{},[Symbol.iterator]:{}})),s}:e instanceof HTMLElement||e instanceof Number||e instanceof String||e instanceof Boolean?i.bind(e):i.bind(n):i&&typeof i=="object"?T(i):i},set:(e,t,n,i)=>{n=n?.[Symbol.xRay]||n;let r=e[t];return r!==n&&(e[t]=n,E(i,w(t,{was:r,now:n}))),typeof r>"u"&&E(i,w(I,{})),!0},has:(e,t)=>{let n=m.get(e);return n&&R(n,t),Object.hasOwn(e,t)},deleteProperty:(e,t)=>{if(typeof e[t]<"u"){let n=e[t];delete e[t];let i=m.get(e);E(i,w(t,{delete:!0,was:n}))}return!0},defineProperty:(e,t,n)=>{if(typeof e[t]>"u"){let i=m.get(e);E(i,w(I,{}))}return Object.defineProperty(e,t,n)},ownKeys:e=>{let t=m.get(e);return R(t,I),Reflect.ownKeys(e)}},m=new WeakMap;function T(e){if(e[Symbol.Signal]){let t=e[Symbol.xRay];m.has(t)||m.set(t,e),e=t}else m.has(e)||m.set(e,new Proxy(e,me));return m.get(e)}function be(e,t){return X(e,t).map(i=>({effect:i.effectType,fn:i.effectFunction,signal:m.get(i.effectFunction)}))}var j=new Set,v=0;function E(e,t={}){let n=[];if(t.forEach((i,r)=>{let l=X(e,r);if(l?.length){for(let s of l)ge(s,w(r,i));n=n.concat(l)}}),n=new Set(n.filter(Boolean)),n)if(v)j=j.union(n);else{let i=p[p.length-1];for(let r of Array.from(n))r!=i&&r?.needsUpdate&&r(),Q(r)}}function w(e,t){let n=new Map;if(typeof e=="object")for(let i in e)n.set(i,e[i]);else n.set(e,t);return n}function ge(e,t){e.context?t.forEach((n,i)=>{e.context.set(i,n)}):e.context=t,e.needsUpdate=!0}function Q(e){delete e.context,delete e.needsUpdate}function R(e,t){let n=p[p.length-1];n&&ye(e,t,n)}var M=new WeakMap,C=new WeakMap;function X(e,t){let n=M.get(e);return n?Array.from(n.get(t)||[]):[]}function ye(e,t,n){M.has(e)||M.set(e,new Map);let i=M.get(e);i.has(t)||i.set(t,new Set),i.get(t).add(n),C.has(n)||C.set(n,new Map);let r=C.get(n);r.has(t)||r.set(t,new Set),r.get(t).add(e)}function P(e){let t=C.get(e);t&&t.forEach(n=>{n.forEach(i=>{let r=M.get(i);r.has(n)&&r.get(n).delete(e)})})}var p=[],N=[],z=new WeakMap,S=[];function Y(e){if(N.findIndex(i=>e==i)!==-1)throw new Error("Recursive update() call",{cause:e});N.push(e);let t=m.get(e);t||(t=T({current:null}),m.set(e,t));let n=function i(){if(S.findIndex(l=>l==t)!==-1)throw new Error("Cyclical dependency in update() call",{cause:e});P(i),i.effectFunction=e,i.effectType=Y,p.push(i),S.push(t);let r;try{r=e(i,p,S)}finally{p.pop(),S.pop(),r instanceof Promise?r.then(l=>{t.current=l}):t.current=r}};return n.fn=e,z.set(t,n),n(),t}function q(e){let t=z.get(e)?.deref();if(!t)return;P(t);let n=t.fn;m.remove(n),z.delete(e)}function $(e){v++;let t;try{t=e()}finally{t instanceof Promise?t.then(()=>{v--,v||J()}):(v--,v||J())}return t}function J(){let e=Array.from(j);j=new Set;let t=p[p.length-1];for(let n of e)n!=t&&n?.needsUpdate&&n(),Q(n)}function y(e,t){if(N.findIndex(s=>e==s)!==-1)throw new Error("Recursive update() call",{cause:e});N.push(e);let n=m.get(e);n||(n=T({current:null}),m.set(e,n));let i=!1,r=!0;return function s(){if(S.findIndex(c=>c==n)!==-1)throw new Error("Cyclical dependency in update() call",{cause:e});if(i&&i>Date.now()){r=!0;return}P(s),s.effectFunction=e,s.effectType=y,p.push(s),S.push(n);let a;try{a=e(s,p,S)}finally{r=!1,p.pop(),S.pop(),a instanceof Promise?a.then(c=>{n.current=c}):n.current=a}i=Date.now()+t,globalThis.setTimeout(()=>{r&&s()},t)}(),n}function Z(e,t){let n=m.get(e);n||(n=T({current:null}),m.set(e,n));let i=-1,r=!0;return function s(){if(i<t.time)if(r){P(s),s.effectFunction=e,s.effectType=Z,p.push(s),i=t.time;let a;try{a=e(s,p)}finally{p.pop(),a instanceof Promise?a.then(c=>{n.current=c}):n.current=a,r=!1}}else i=t.time;else r=!0}(),n}function we(e){let t=p.slice();p=[];try{return e()}finally{p=t}}function x(e,t){let n=e.value.innerHTML;typeof e.value=="string"&&(n=e.value,e.value={innerHTML:n}),n&&(n=n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),e.value.innerHTML=n),t(e)}function ee(e,t){typeof e.value=="string"?e.value={}:delete e.value.innerHTML,t(e)}function ne(e){if(e.templates?.length)Te.call(this,e);else if(Object.hasOwnProperty.call(this.options.renderers,e.element.tagName)){let t=this.options.renderers[e.element.tagName];t&&t.call(this,e)}else this.options.renderers["*"]&&this.options.renderers["*"].call(this,e);return e}function ie(e){return Array.isArray(e.value)?e.templates?.length?Se.call(this,e):console.error("No templates found in",e.element):console.error("Value is not an array.",e.element,e.path,e.value),e}function re(e){return typeof e.value!="object"||!e.value?console.error("Value is not an object.",e.element,e.path,e.value):e.templates?.length?Ee.call(this,e):console.error("No templates found in",e.element),e}function Se(e){let t=this.options.attribute,n=e.element.querySelectorAll(":scope > ["+t+"-key]"),i=0,r=0;e.list=e.value;for(let s of n){let a=parseInt(s.getAttribute(t+"-key"));if(a>i)e.index=i,e.element.insertBefore(this.applyTemplate(e),s);else if(a<i)s.remove();else{let c=Array.from(s.querySelectorAll(`[${t}]`));s.matches(`[${t}]`)&&c.unshift(s);let u=c.find(d=>{let b=d.getAttribute(t);return b.substr(0,5)!==":root"&&b.substr(0,e.path.length)!==e.path});if(!u&&s[Symbol.bindTemplate]){let d=this.findTemplate(e.templates,e.list[i]);d!=s[Symbol.bindTemplate]&&(u=!0,d||r++)}u&&(e.index=i,e.element.replaceChild(this.applyTemplate(e),s))}if(i++,i>=e.value.length)break}n=e.element.querySelectorAll(":scope > ["+t+"-key]");let l=n.length+r;if(l>e.value.length)for(;l>e.value.length;)e.element.querySelectorAll(":scope > :not(template)")?.[l-1]?.remove(),l--;else if(l<e.value.length)for(;l<e.value.length;)e.index=l,e.element.appendChild(this.applyTemplate(e)),l++}function Ee(e){let t=this.options.attribute;e.list=e.value;let n=Array.from(e.element.querySelectorAll(":scope > ["+t+"-key]"));for(let i in e.list){e.index=i;let r=n.shift();if(!r){let s=this.applyTemplate(e);e.element.appendChild(s);continue}if(r.getAttribute[t+"-key"]!=i){n.unshift(r);let s=e.element.querySelector(":scope > ["+t+'-key="'+i+'"]');if(s)e.element.insertBefore(s,r),r=s,n=n.filter(a=>a!=s);else{let a=this.applyTemplate(e);e.element.insertBefore(a,r);continue}}if(this.findTemplate(e.templates,e.list[e.index])!=r[Symbol.bindTemplate]){let s=this.applyTemplate(e);e.element.replaceChild(s,r)}}for(;n.length;)n.shift().remove()}function Te(e){let t=e.element.querySelector(":scope > :not(template)"),n=this.findTemplate(e.templates,e.value);if(e.parent=Ae(e.element),t)if(n){if(t?.[Symbol.bindTemplate]!=n){let i=this.applyTemplate(e);e.element.replaceChild(i,t)}}else e.element.removeChild(t);else if(n){let i=this.applyTemplate(e);e.element.appendChild(i)}}function Ae(e,t){let n=e.parentElement?.closest(`[${t}-list],[${t}-map]`);return n?n.hasAttribute(`${t}-list`)?n.getAttribute(`${t}-list`)+".":n.getAttribute(`${t}-map`)+".":""}function se(e){let t=e.element,n=e.value;L(e),typeof n>"u"&&(n=""),t.type=="checkbox"||t.type=="radio"?H(t.value,n)?t.checked=!0:t.checked=!1:H(t.value,n)||(t.value=""+n)}function le(e){L(e),A(e.element,e.value,"value")}function U(e){let t=e.element,n=e.value;if(n===null&&(n=""),typeof n!="object")if(t.multiple){if(Array.isArray(n))for(let i of t.options)n.indexOf(i.value)===!1?i.selected=!1:i.selected=!0}else{let i=t.options.find(r=>H(r.value,n));i&&(i.selected=!0,i.setAttribute("selected",!0))}else n.options&&ve(t,n.options),n.selected&&U(Object.asssign({},e,{value:n.selected})),A(t,n,"name","id","selectedIndex","className")}function te(e,t){t&&(typeof t!="object"?e.options.add(new Option(""+t)):t.text?e.options.add(new Option(t.text,t.value,t.defaultSelected,t.selected)):typeof t.value<"u"&&e.options.add(new Option(""+t.value,t.value,t.defaultSelected,t.selected)))}function ve(e,t){if(e.innerHTML="",Array.isArray(t))for(let n of t)te(e,n);else if(t&&typeof t=="object")for(let n in t)te(e,{text:t[n],value:n})}function oe(e){L(e),A(e.element,e.value,"target","href","name","newwindow","nofollow")}function ae(e){A(e.element,e.value,"title","alt","src","id")}function fe(e){A(e.element,e.value,"title","src","id")}function ue(e){A(e.element,e.value,"content","id")}function L(e){let t=e.element,n=e.value;(typeof n>"u"||n==null)&&(n="");let i=""+n;if(typeof n!="object"||i.substring(0,8)!="[object "){t.innerHTML=i;return}A(t,n,"innerHTML","title","id","className")}function A(e,t,...n){if(!(!t||typeof t!="object"))for(let i of n)typeof t[i]>"u"||H(e[i],t[i])||(t[i]===null?e[i]="":e[i]=""+t[i])}function H(e,t){return e==":empty"&&!t||t==":empty"&&!e||""+e==""+t}Symbol.bindTemplate||(Symbol.bindTemplate=Symbol("bindTemplate"));var V=class{constructor(t){this.bindings=new Map;let n={escape_html:x,fixed_content:ee},i={container:document.body,attribute:"data-flow",transformers:n,render:{field:[ne],list:[ie],map:[re]},renderers:{INPUT:se,BUTTON:le,SELECT:U,A:oe,IMG:ae,IFRAME:fe,META:ue,TEMPLATE:null,"*":L}};if(!t?.root)throw new Error("bind needs at least options.root set");this.options=Object.assign({},i,t),t.transformers&&(this.options.transformers=Object.assign({},n,t?.transformers));let r=this.options.attribute,l=[r+"-field",r+"-list",r+"-map"],s=r+"-transform",a=o=>{let f=l.find(h=>o.hasAttribute(h));return f||console.error("No matching attribute found",o,l),f},c=o=>{this.bindings.set(o,y(()=>{if(!o.isConnected){Le(o,this.getBindingPath(o)),q(this.bindings.get(o));return}let f={templates:o.querySelectorAll(":scope > template"),attribute:a(o)};f.path=this.getBindingPath(o),f.value=W(this.options.root,f.path),f.element=o,Me(o,f),u(f)},50))},u=o=>{let f;switch(o.attribute){case this.options.attribute+"-field":f=Array.from(this.options.render.field);break;case this.options.attribute+"-list":f=Array.from(this.options.render.list);break;case this.options.attribute+"-map":f=Array.from(this.options.render.map);break;default:throw new Error("no valid context attribute specified",o)}o.element.hasAttribute(s)&&o.element.getAttribute(s).split(" ").filter(Boolean).forEach(g=>{this.options.transformers[g]?f.push(this.options.transformers[g]):console.warn("No transformer with name "+g+" configured",{cause:o.element})});let h;for(let g of f)h=((k,pe)=>de=>pe.call(this,de,k))(h,g);h(o)},d=o=>{for(let f of o)this.bindings.get(f)||c(f)},b=o=>{let f=`[${r}-field],[${r}-list],[${r}-map]`;for(let h of o)if(h.type=="childList"&&h.addedNodes){for(let g of h.addedNodes)if(g instanceof HTMLElement){let k=Array.from(g.querySelectorAll(f));g.matches(f)&&k.unshift(g),k.length&&d(k)}}};this.observer=new MutationObserver(o=>{b(o)}),this.observer.observe(this.options.container,{subtree:!0,childList:!0});let O=this.options.container.querySelectorAll(":is(["+this.options.attribute+"-field],["+this.options.attribute+"-list],["+this.options.attribute+"-map]):not(template)");O.length&&d(O)}applyTemplate(t){let n=t.path,i=t.parent,r=t.templates,l=t.list,s=t.index,a=l?l[s]:t.value,c=this.findTemplate(r,a);if(!c){let o=new DocumentFragment;return o.innerHTML="<!-- no matching template -->",o}let u=c.content.cloneNode(!0);if(!u.children?.length)return u;if(u.children.length>1)throw new Error("template must contain a single root node",{cause:c});let d=this.options.attribute,b=[d+"-field",d+"-list",d+"-map"],O=u.querySelectorAll(`[${d}-field],[${d}-list],[${d}-map]`);for(let o of O){if(o.tagName=="TEMPLATE")continue;let f=b.find(g=>o.hasAttribute(g)),h=o.getAttribute(f);h=this.applyLinks(c.links,h),h.substring(0,6)==":root."?o.setAttribute(f,h.substring(6)):h==":value"&&s!=null?o.setAttribute(f,n+"."+s):s!=null?o.setAttribute(f,n+"."+s+"."+h):o.setAttribute(f,i+h)}return typeof s<"u"&&u.children[0].setAttribute(d+"-key",s),u.children[0][Symbol.bindTemplate]=c,u}parseLinks(t){let n={};t=t.split(";").map(i=>i.trim());for(let i of t)i=i.split("="),n[i[0].trim()]=i[1].trim();return n}applyLinks(t,n){for(let i in t){if(n.startsWith(i+"."))return t[i]+n.substr(i.length);if(n==i)return t[i]}return n}getBindingPath(t){let n=[this.options.attribute+"-field",this.options.attribute+"-list",this.options.attribute+"-map"];for(let i of n)if(t.hasAttribute(i))return t.getAttribute(i)}findTemplate(t,n){let i=a=>{let c=this.getBindingPath(a),u;c?c.substr(0,6)==":root."?u=W(this.options.root,c):u=W(n,c):u=n;let d=""+u,b=a.getAttribute(this.options.attribute+"-match");if(b){if(b===":empty"&&!u)return a;if(b===":notempty"&&u||d.match(b))return a}if(!b&&u!==null&&u!==void 0)return a},r=Array.from(t).find(i),l=null;r?.hasAttribute(this.options.attribute+"-link")&&(l=this.parseLinks(r.getAttribute(this.options.attribute+"-link")));let s=r?.getAttribute("rel");if(s){let a=document.querySelector("template#"+s);if(!a)throw new Error("Could not find template with id "+s);r=a}return r&&(r.links=l),r}destroy(){this.bindings.forEach(t=>{q(t)}),this.bindings=new Map,this.observer.disconnect()}};function ce(e){return new V(e)}var B=new Map;function Me(e,t){B.has(t.path)?B.get(t.path).push(t):B.set(t.path,[t])}function Le(e,t){let n=B.get(t);n&&(n=n.filter(i=>i.element==e),B.set(t,n))}function W(e,t){let n=t.split("."),i=e,r;for(r=n.shift();r&&i;)r=decodeURIComponent(r),i=i[r],r=n.shift();return i}var D={};G(D,{columns:()=>Ne,filter:()=>je,model:()=>Be,paging:()=>Ce,scroll:()=>Pe,sort:()=>Oe});var _=class{constructor(t){if(!t)throw new Error("no options set");(t.data==null||typeof t.data[Symbol.iterator]!="function")&&console.warn("SimplyFlowModel: options.data is not iterable"),this.state=T(t),this.state.options||(this.state.options={}),this.effects=[{current:this.state.data}],this.view=this.state.data}addEffect(t){if(!t||typeof t!="function")throw new Error("addEffect requires an effect function as its parameter",{cause:t});let n=this.effects[this.effects.length-1],i=t.call(this,n);if(!i||!i[Symbol.Signal])throw new Error("addEffect function parameter must return a Signal",{cause:t});this.view=i,this.effects.push(this.view)}};function Be(e){return new _(e)}function Oe(e={}){return function(t){return this.state.options.sort=Object.assign({direction:"asc",sortBy:null,sortFn:(n,i)=>{let r=this.state.options.sort,l=r.sortBy;if(!r.sortBy)return 0;let s=r.direction=="asc"?1:-1,a=r.direction=="asc"?-1:1;return typeof n?.[l]>"u"?typeof i?.[l]>"u"?0:s:typeof i?.[l]>"u"||n[l]<i[l]?a:n[l]>i[l]?s:0}},e),y(()=>{let n=this.state.options.sort;return n?.sortBy&&n?.direction?t.current.toSorted(n?.sortFn):t.current},50)}}function Ce(e={}){return function(t){return this.state.options.paging=Object.assign({page:1,pageSize:20,max:1},e),y(()=>$(()=>{let n=this.state.options.paging;n.pageSize||(n.pageSize=20),n.max=Math.ceil(this.state.data.length/n.pageSize),n.page=Math.max(1,Math.min(n.max,n.page));let i=(n.page-1)*n.pageSize,r=i+n.pageSize;return t.current.slice(i,r)}),50)}}function je(e){if(!e?.name||typeof e.name!="string")throw new Error("filter requires options.name to be a string");if(!e.matches||typeof e.matches!="function")throw new Error("filter requires options.matches to be a function");return function(t){if(this.state.options[e.name])throw new Error("a filter with this name already exists on this model");return this.state.options[e.name]=e,y(()=>this.state.options[e.name].enabled?t.current.filter(this.state.options[e.name].matches.bind(this)):t.current,50)}}function Ne(e={}){if(!e||typeof e!="object"||Object.keys(e).length===0)throw new Error("columns requires options to be an object with at least one property");return function(t){return this.state.options.columns=e,y(()=>t.current.map(n=>{let i={};for(let r of Object.keys(this.state.options.columns))this.state.options.columns[r]?.hidden||(i[r]=n[r]);return i}),50)}}function Pe(e){return function(t){this.state.options.scroll=Object.assign({offset:0,rowHeight:26,rowCount:20,itemsPerRow:1,size:t.current.length},e);let n=this.state.options.scroll,i=n.scrollbar||n.container?.querySelector("[data-flow-scrollbar]");return i&&(n.container&&n.container.addEventListener("scroll",r=>{n.offset=Math.floor(n.container.scrollTop/(n.rowHeight*n.itemsPerRow))}),y(()=>{n.size=t.current.length*n.rowHeight,i.style.height=n.size+"px"},50)),y(()=>{n.container&&(n.rowCount=Math.ceil(n.container.getBoundingClientRect().height/n.rowHeight)),n.data=t.current;let r=Math.min(n.offset,t.current.length-1),l=r+n.rowCount;return l>t.current.length&&(l=t.current.length,r=l-n.rowCount),t.current.slice(r,l)},50)}}var K=class extends HTMLElement{constructor(){super()}connectedCallback(){let t=this.getAttribute("rel"),n=document.getElementById(t);if(n){let i=n.content.cloneNode(!0);for(let r of i.childNodes){let l=r.cloneNode(!0);if(l.nodeType==document.ELEMENT_NODE&&(l.querySelectorAll("template").forEach(function(s){s.setAttribute("simply-render","")}),this.attributes))for(let s of this.attributes)s.name!="rel"&&l.setAttribute(s.name,s.value);this.parentNode.insertBefore(l,this)}this.parentNode.removeChild(this)}else(()=>{let r=new MutationObserver(()=>{n=document.getElementById(t),n&&(r.disconnect(),this.replaceWith(this))});r.observe(globalThis.document,{subtree:!0,childList:!0})})()}};customElements.get("simply-render")||customElements.define("simply-render",K);globalThis.simply||(globalThis.simply={});Object.assign(globalThis.simply,{bind:ce,flow:D,state:F});var _e=globalThis.simply;})();
|
|
2
2
|
//# sourceMappingURL=simply.flow.min.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/state.mjs", "../src/bind.transformers.mjs", "../src/bind.render.mjs", "../src/bind.mjs", "../src/model.mjs", "../src/flow.mjs"],
|
|
4
|
-
"sourcesContent": ["const iterate = Symbol('iterate')\nif (!Symbol.xRay) {\n Symbol.xRay = Symbol('xRay')\n}\nif (!Symbol.Signal) {\n Symbol.Signal = Symbol('Signal')\n}\n\nconst signalHandler = {\n get: (target, property, receiver) => {\n if (property===Symbol.xRay) {\n return target // don't notifyGet here, this is only called by set\n }\n if (property===Symbol.Signal) {\n return true\n }\n const value = target?.[property] // Reflect.get fails on a Set.\n notifyGet(receiver, property)\n if (typeof value === 'function') {\n if (Array.isArray(target)) {\n return (...args) => {\n let l = target.length\n // by binding the function to the receiver\n // all accesses in the function will be trapped\n // by the Proxy, so get/set/delete is all handled\n let result = value.apply(receiver, args)\n if (l != target.length) {\n notifySet(receiver, makeContext('length', { was: l, now: target.length }) )\n }\n return result\n }\n } else if (target instanceof Set || target instanceof Map) {\n return (...args) => {\n // node doesn't allow you to call set/map functions\n // bound to the receiver.. so using target instead\n // there are no properties to update anyway, except for size\n let s = target.size\n let result = value.apply(target, args)\n if (s != target.size) {\n notifySet(receiver, makeContext( 'size', { was: s, now: target.size }) )\n }\n // there is no efficient way to see if the function called\n // has actually changed the Set/Map, but by assuming the\n // 'setter' functions will change the results of the\n // 'getter' functions, effects should update correctly\n if (['set','add','clear','delete'].includes(property)) {\n notifySet(receiver, makeContext( { entries: {}, forEach: {}, has: {}, keys: {}, values: {}, [Symbol.iterator]: {} } ) )\n }\n return result\n }\n } else if (\n target instanceof HTMLElement\n || target instanceof Number\n || target instanceof String\n || target instanceof Boolean\n ) {\n return value.bind(target)\n } else {\n // support custom classes, hopefully\n return value.bind(receiver)\n }\n }\n if (value && typeof value == 'object') {\n //NOTE: get now returns a signal, set doesn't 'unsignal' the value set\n return signal(value)\n }\n return value\n },\n set: (target, property, value, receiver) => {\n value = value?.[Symbol.xRay] || value // unwraps signal\n let current = target[property]\n if (current!==value) {\n target[property] = value\n notifySet(receiver, makeContext(property, { was: current, now: value } ) )\n }\n if (typeof current === 'undefined') {\n notifySet(receiver, makeContext(iterate, {}))\n }\n return true\n },\n has: (target, property) => { // receiver is not part of the has() call\n let receiver = signals.get(target) // so retrieve it here\n if (receiver) {\n notifyGet(receiver, property)\n }\n return Object.hasOwn(target, property)\n },\n deleteProperty: (target, property) => {\n if (typeof target[property] !== 'undefined') {\n let current = target[property]\n delete target[property]\n let receiver = signals.get(target) // receiver is not part of the trap arguments, so retrieve it here\n notifySet(receiver, makeContext(property,{ delete: true, was: current }))\n }\n return true\n },\n defineProperty: (target, property, descriptor) => {\n if (typeof target[property] === 'undefined') {\n let receiver = signals.get(target) // receiver is not part of the trap arguments, so retrieve it here\n notifySet(receiver, makeContext(iterate, {}))\n }\n return Object.defineProperty(target, property, descriptor)\n },\n ownKeys: (target) => {\n let receiver = signals.get(target) // receiver is not part of the trap arguments, so retrieve it here\n notifyGet(receiver, iterate)\n return Reflect.ownKeys(target)\n }\n\n}\n\n/**\n * Keeps track of the return signal for an update function, as well\n * as signals connected to other objects. \n * Makes sure that a given object or function always uses the same\n * signal\n */\nconst signals = new WeakMap()\n\n/**\n * Creates a new signal proxy of the given object, that intercepts get/has and set/delete\n * to allow reactive functions to be triggered when signal values change.\n */\nexport function signal(v) {\n if (v[Symbol.Signal]) { // avoid wrapping a Signal inside a Signal\n let target = v[Symbol.xRay]\n if (!signals.has(target)) {\n signals.set(target, v)\n }\n v = target\n } else if (!signals.has(v)) {\n signals.set(v, new Proxy(v, signalHandler))\n }\n return signals.get(v)\n}\n\n/**\n * Lists all effects that are currently listening to changes in\n * the given signal and property\n * returns a list with \n * - effect: the effect function (effect, throttledEffect, clockEffect)\n * - fn: the user provided function to this effect function\n * - signal: the connectedSignal to this user provided function\n * @param Signal signal\n * @param string prop \n * @return array of { effect, fn, signal }\n */\nexport function trace(signal, prop) {\n const listeners = getListeners(signal, prop)\n return listeners.map(listener => {\n return {\n effect: listener.effectType,\n fn: listener.effectFunction,\n signal: signals.get(listener.effectFunction)\n }\n })\n}\n\nlet batchedListeners = new Set()\nlet batchMode = 0\n/**\n * Called when a signal changes a property (set/delete)\n * Triggers any reactor function that depends on this signal\n * to re-compute its values\n */\nfunction notifySet(self, context={}) {\n let listeners = []\n context.forEach((change, property) => {\n let propListeners = getListeners(self, property)\n if (propListeners?.length) {\n for (let listener of propListeners) {\n addContext(listener, makeContext(property,change))\n }\n listeners = listeners.concat(propListeners)\n }\n })\n listeners = new Set(listeners.filter(Boolean))\n if (listeners) {\n if (batchMode) {\n batchedListeners = batchedListeners.union(listeners)\n } else {\n const currentEffect = computeStack[computeStack.length-1]\n for (let listener of Array.from(listeners)) {\n if (listener!=currentEffect && listener?.needsUpdate) {\n listener()\n }\n clearContext(listener)\n }\n }\n }\n}\n\nfunction makeContext(property, change) {\n let context = new Map()\n if (typeof property === 'object') {\n for (let prop in property) {\n context.set(prop, property[prop])\n }\n } else {\n context.set(property, change)\n }\n return context\n}\n\nfunction addContext(listener, context) {\n if (!listener.context) {\n listener.context = context\n } else {\n context.forEach((change,property)=> {\n listener.context.set(property, change) // TODO: merge change if needed\n })\n }\n listener.needsUpdate = true\n}\n\nfunction clearContext(listener) {\n delete listener.context\n delete listener.needsUpdate\n}\n\n/**\n * Called when a signal property is accessed. If this happens\n * inside a reactor function--computeStack is not empty--\n * then it adds the current reactor (top of this stack) to its\n * listeners. These are later called if this property changes\n */\nfunction notifyGet(self, property) {\n let currentCompute = computeStack[computeStack.length-1]\n if (currentCompute) {\n // get was part of a react() function, so add it\n setListeners(self, property, currentCompute)\n }\n}\n\n/**\n * Keeps track of which update() functions are dependent on which\n * signal objects and which properties. Maps signals to update fns\n */\nconst listenersMap = new WeakMap()\n\n/**\n * Keeps track of which signals and properties are linked to which\n * update functions. Maps update functions and properties to signals\n */\nconst computeMap = new WeakMap()\n\n/**\n * Returns the update functions for a given signal and property\n */\nfunction getListeners(self, property) {\n let listeners = listenersMap.get(self)\n return listeners ? Array.from(listeners.get(property) || []) : []\n}\n\n/**\n * Adds an update function (compute) to the list of listeners on\n * the given signal (self) and property\n */\nfunction setListeners(self, property, compute) {\n if (!listenersMap.has(self)) {\n listenersMap.set(self, new Map())\n }\n let listeners = listenersMap.get(self)\n if (!listeners.has(property)) {\n listeners.set(property, new Set())\n }\n listeners.get(property).add(compute)\n\n if (!computeMap.has(compute)) {\n computeMap.set(compute, new Map())\n }\n let connectedSignals = computeMap.get(compute)\n if (!connectedSignals.has(property)) {\n connectedSignals.set(property, new Set)\n }\n connectedSignals.get(property).add(self)\n}\n\n/**\n * Removes alle listeners that trigger the given reactor function (compute)\n * This happens when a reactor is called, so that it can set new listeners\n * based on the current call (code path)\n */\nfunction clearListeners(compute) {\n let connectedSignals = computeMap.get(compute)\n if (connectedSignals) {\n connectedSignals.forEach(property => {\n property.forEach(s => {\n let listeners = listenersMap.get(s)\n if (listeners.has(property)) {\n listeners.get(property).delete(compute)\n }\n })\n })\n }\n}\n\n/**\n * The top most entry is the currently running update function, used\n * to automatically record signals used in an update function.\n */\nlet computeStack = []\n\n/**\n * Used for cycle detection: effectStack contains all running effect\n * functions. If the same function appears twice in this stack, there\n * is a recursive update call, which would cause an infinite loop.\n */\nconst effectStack = []\n\nconst effectMap = new WeakMap()\n/**\n * Used for cycle detection: signalStack contains all used signals. \n * If the same signal appears more than once, there is a cyclical \n * dependency between signals, which would cause an infinite loop.\n */\nconst signalStack = []\n\n/**\n * Runs the given function at once, and then whenever a signal changes that\n * is used by the given function (or at least signals used in the previous run).\n */\nexport function effect(fn) {\n if (effectStack.findIndex(f => fn==f)!==-1) {\n throw new Error('Recursive update() call', {cause:fn})\n }\n effectStack.push(fn)\n\n let connectedSignal = signals.get(fn)\n if (!connectedSignal) {\n connectedSignal = signal({\n current: null\n })\n signals.set(fn, connectedSignal)\n }\n\n // this is the function that is called automatically\n // whenever a signal dependency changes\n const computeEffect = function computeEffect() {\n if (signalStack.findIndex(s => s==connectedSignal)!==-1) {\n throw new Error('Cyclical dependency in update() call', { cause: fn})\n }\n // remove all dependencies (signals) from previous runs \n clearListeners(computeEffect)\n computeEffect.effectFunction = fn\n computeEffect.effectType = effect\n // record new dependencies on this run\n computeStack.push(computeEffect)\n // prevent recursion\n signalStack.push(connectedSignal)\n // call the actual update function\n let result\n try {\n result = fn(computeEffect, computeStack, signalStack)\n } finally {\n // stop recording dependencies\n computeStack.pop()\n // stop the recursion prevention\n signalStack.pop()\n if (result instanceof Promise) {\n result.then((result) => {\n connectedSignal.current = result\n })\n } else {\n connectedSignal.current = result\n }\n }\n }\n computeEffect.fn = fn\n effectMap.set(connectedSignal, computeEffect)\n\n // run the computEffect immediately upon creation\n computeEffect()\n return connectedSignal\n}\n\n\nexport function destroy(connectedSignal) {\n // find the computeEffect associated with this signal\n const computeEffect = effectMap.get(connectedSignal)?.deref()\n if (!computeEffect) {\n return\n }\n\n // remove all listeners for this effect\n clearListeners(computeEffect)\n\n // remove all references to connectedSignal\n let fn = computeEffect.fn\n signals.remove(fn)\n\n effectMap.delete(connectedSignal)\n\n // if no other references to connectedSignal exist, it will be garbage collected\n}\n\n/**\n * Inside a batch() call, any changes to signals do not trigger effects\n * immediately. Instead, immediately after finishing the batch() call,\n * these effects will be called. Effects that are triggered by multiple\n * signals are called only once.\n * @param Function fn batch() calls this function immediately\n * @result mixed the result of the fn() function call\n */\nexport function batch(fn) {\n batchMode++\n let result\n try {\n result = fn()\n } finally {\n if (result instanceof Promise) {\n result.then(() => {\n batchMode--\n if (!batchMode) {\n runBatchedListeners()\n }\n })\n } else {\n batchMode--\n if (!batchMode) {\n runBatchedListeners()\n }\n }\n }\n return result\n}\n\nfunction runBatchedListeners() {\n let copyBatchedListeners = Array.from(batchedListeners)\n batchedListeners = new Set()\n const currentEffect = computeStack[computeStack.length-1]\n for (let listener of copyBatchedListeners) {\n if (listener!=currentEffect && listener?.needsUpdate) {\n listener()\n }\n clearContext(listener)\n }\n}\n\n/**\n * A throttledEffect is run immediately once. And then only once\n * per throttleTime (in ms).\n * @param Function fn the effect function to run whenever a signal changes\n * @param int throttleTime in ms\n * @returns signal with the result of the effect function fn\n */\nexport function throttledEffect(fn, throttleTime) {\n if (effectStack.findIndex(f => fn==f)!==-1) {\n throw new Error('Recursive update() call', {cause:fn})\n }\n effectStack.push(fn)\n\n let connectedSignal = signals.get(fn)\n if (!connectedSignal) {\n connectedSignal = signal({\n current: null\n })\n signals.set(fn, connectedSignal)\n }\n\n let throttled = false\n let hasChange = true\n // this is the function that is called automatically\n // whenever a signal dependency changes\n const computeEffect = function computeEffect() {\n if (signalStack.findIndex(s => s==connectedSignal)!==-1) {\n throw new Error('Cyclical dependency in update() call', { cause: fn})\n }\n if (throttled && throttled>Date.now()) {\n hasChange = true\n return\n }\n // remove all dependencies (signals) from previous runs \n clearListeners(computeEffect)\n // record new dependencies on this run\n computeEffect.effectFunction = fn\n computeEffect.effectType = throttledEffect\n computeStack.push(computeEffect)\n // prevent recursion\n signalStack.push(connectedSignal)\n // call the actual update function\n let result\n try {\n result = fn(computeEffect, computeStack, signalStack)\n } finally {\n hasChange = false\n // stop recording dependencies\n computeStack.pop()\n // stop the recursion prevention\n signalStack.pop()\n if (result instanceof Promise) {\n result.then((result) => {\n connectedSignal.current = result\n })\n } else {\n connectedSignal.current = result\n }\n }\n throttled = Date.now()+throttleTime\n globalThis.setTimeout(() => {\n if (hasChange) {\n computeEffect()\n }\n }, throttleTime)\n }\n // run the computEffect immediately upon creation\n computeEffect()\n return connectedSignal\n}\n\n// refactor: Class clock() with an effect() method\n// keep track of effects per clock, and add clock property to the effect function\n// on notifySet add clock.effects to clock.needsUpdate list\n// on clock.tick() (or clock.time++) run only the clock.needsUpdate effects \n// (first create a copy and reset clock.needsUpdate, then run effects)\nexport function clockEffect(fn, clock) {\n let connectedSignal = signals.get(fn)\n if (!connectedSignal) {\n connectedSignal = signal({\n current: null\n })\n signals.set(fn, connectedSignal)\n }\n\n let lastTick = -1 // clock.time should start at 0 or larger\n let hasChanged = true // make sure the first run goes through\n // this is the function that is called automatically\n // whenever a signal dependency changes\n const computeEffect = function computeEffect() {\n if (lastTick < clock.time) {\n if (hasChanged) {\n // remove all dependencies (signals) from previous runs \n clearListeners(computeEffect)\n computeEffect.effectFunction = fn\n computeEffect.effectType = clockEffect\n // record new dependencies on this run\n computeStack.push(computeEffect)\n // make sure the clock.time signal is a dependency\n lastTick = clock.time\n // call the actual update function\n let result \n try {\n result = fn(computeEffect, computeStack)\n } finally {\n // stop recording dependencies\n computeStack.pop()\n if (result instanceof Promise) {\n result.then((result) => {\n connectedSignal.current = result\n })\n } else {\n connectedSignal.current = result\n }\n hasChanged = false\n }\n } else {\n lastTick = clock.time\n }\n } else {\n hasChanged = true\n }\n }\n // run the computEffect immediately upon creation\n computeEffect()\n return connectedSignal\n}\n\nexport function untracked(fn) {\n const remember = computeStack.slice()\n computeStack = []\n try {\n return fn()\n } finally {\n computeStack = remember\n }\n}", "export function escape_html(context, next) {\n let content = context.value.innerHTML\n if (typeof context.value == 'string') {\n content = context.value\n context.value = { innerHTML: content }\n }\n if (content) {\n content = content.replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''');\n context.value.innerHTML = content\n }\n next(context)\n}\n\nexport function fixed_content(context, next) {\n if (typeof context.value == 'string') {\n context.value = {}\n } else {\n delete context.value.innerHTML\n }\n next(context)\n}\n", "/*\n * Default renderers for data binding\n * Will be used unless overriden in the SimplyBind options parameter\n */\n\n/**\n * This function is used by default to render dom elements with the `data-flow-field` attribute.\n * It will switch to only switching in template content if the context has any templates.\n * Otherwise it will call the matching render function depending on the tagName of the\n * context.element\n */\nexport function field(context)\n{\n if (context.templates?.length) {\n fieldByTemplates.call(this, context)\n // TODO: check if existence of one or more templates must mean that\n // only the template rendering is applied, instead of also rendering attributes\n } else if (Object.hasOwnProperty.call(this.options.renderers, context.element.tagName)) {\n const renderer = this.options.renderers[context.element.tagName]\n if (renderer) {\n renderer.call(this, context)\n }\n } else if (this.options.renderers['*']) {\n this.options.renderers['*'].call(this, context)\n }\n return context\n}\n\n/**\n * This function is used by default to render DOM elements with the `data-flow-list` attribute.\n * The context.value must be an array. And context.templates must not be empty.\n */\nexport function list(context)\n{\n if (!Array.isArray(context.value)) {\n console.error('Value is not an array.', context.element, context.path, context.value)\n } else if (!context.templates?.length) {\n console.error('No templates found in', context.element)\n } else {\n arrayByTemplates.call(this, context)\n }\n return context\n}\n\n/**\n * This function is used by default to render DOM elements with the `data-flow-map` attribute.\n * The context.value must be a non-null object. And context.templates must not be empty.\n */\nexport function map(context)\n{\n if (typeof context.value != 'object' || !context.value) {\n console.error('Value is not an object.', context.element, context.path, context.value)\n } else if (!context.templates?.length) {\n console.error('No templates found in', context.element)\n } else {\n objectByTemplates.call(this, context)\n }\n return context\n}\n\n/**\n * Renders an array value by applying templates for each entry\n * Replaces or removes existing DOM children if needed\n * Reuses (doesn't touch) DOM children if template doesn't change\n * FIXME: this doesn't handle situations where there is no matching template\n * this messes up self healing. check renderObjectByTemplates for a better implementation\n */\nexport function arrayByTemplates(context)\n{\n const attribute = this.options.attribute\n\n let items = context.element.querySelectorAll(':scope > ['+attribute+'-key]')\n // do single merge strategy for now, in future calculate optimal merge strategy from a number\n // now just do a delete if a key <= last key, insert if a key >= last key\n let lastKey = 0\n let skipped = 0\n context.list = context.value\n for (let item of items) {\n let currentKey = parseInt(item.getAttribute(attribute+'-key'))\n if (currentKey>lastKey) {\n // insert before\n context.index = lastKey\n context.element.insertBefore(this.applyTemplate(context), item)\n } else if (currentKey<lastKey) {\n // remove this\n item.remove()\n } else {\n // check that all data-bind params start with current json path or ':root', otherwise replaceChild\n let bindings = Array.from(item.querySelectorAll(`[${attribute}]`))\n if (item.matches(`[${attribute}]`)) {\n bindings.unshift(item)\n }\n let needsReplacement = bindings.find(b => {\n let databind = b.getAttribute(attribute)\n return (databind.substr(0,5)!==':root' \n && databind.substr(0, context.path.length)!==context.path)\n })\n if (!needsReplacement) {\n if (item[Symbol.bindTemplate]) {\n let newTemplate = this.findTemplate(context.templates, context.list[lastKey])\n if (newTemplate != item[Symbol.bindTemplate]){\n needsReplacement = true\n if (!newTemplate) {\n skipped++\n }\n }\n }\n }\n if (needsReplacement) {\n context.index = lastKey\n context.element.replaceChild(this.applyTemplate(context), item)\n }\n }\n lastKey++\n if (lastKey>=context.value.length) {\n break\n }\n }\n items = context.element.querySelectorAll(':scope > ['+attribute+'-key]')\n let length = items.length + skipped\n if (length > context.value.length) {\n while (length > context.value.length) {\n let child = context.element.querySelectorAll(':scope > :not(template)')?.[length-1]\n child?.remove()\n length--\n }\n } else if (length < context.value.length ) {\n while (length < context.value.length) {\n context.index = length\n context.element.appendChild(this.applyTemplate(context))\n length++\n }\n }\n}\n\n/**\n * Renders an object value by applying templates for each entry (Object.entries)\n * Replaces,moves or removes existing DOM children if needed\n * Reuses (doesn't touch) DOM children if template doesn't change\n */\nexport function objectByTemplates(context)\n{\n const attribute = this.options.attribute\n context.list = context.value\n\n let items = Array.from(context.element.querySelectorAll(':scope > ['+attribute+'-key]'))\n for (let key in context.list) {\n context.index = key\n let item = items.shift()\n if (!item) { // more properties than rendered items\n let clone = this.applyTemplate(context)\n context.element.appendChild(clone)\n continue\n }\n if (item.getAttribute[attribute+'-key']!=key) { \n // next item doesn't match key\n items.unshift(item) // put item back for next cycle\n let outOfOrderItem = context.element.querySelector(':scope > ['+attribute+'-key=\"'+key+'\"]') //FIXME: escape key\n if (!outOfOrderItem) {\n let clone = this.applyTemplate(context)\n context.element.insertBefore(clone, item)\n continue // new template doesn't need replacement, so continue \n } else {\n context.element.insertBefore(outOfOrderItem, item)\n item = outOfOrderItem // check needsreplacement next\n items = items.filter(i => i!=outOfOrderItem)\n }\n }\n let newTemplate = this.findTemplate(context.templates, context.list[context.index])\n if (newTemplate != item[Symbol.bindTemplate]){\n let clone = this.applyTemplate(context)\n context.element.replaceChild(clone, item)\n }\n }\n // clean up remaining items\n while (items.length) {\n let item = items.shift()\n item.remove()\n }\n}\n\n/**\n * renders the contents of an html element by rendering\n * a matching template, once.\n */\nexport function fieldByTemplates(context)\n{\n const rendered = context.element.querySelector(':scope > :not(template)')\n const template = this.findTemplate(context.templates, context.value)\n context.parent = getParentPath(context.element)\n if (rendered) {\n if (template) {\n if (rendered?.[Symbol.bindTemplate] != template) {\n const clone = this.applyTemplate(context)\n context.element.replaceChild(clone, rendered)\n }\n } else {\n context.element.removeChild(rendered)\n }\n } else if (template) {\n const clone = this.applyTemplate(context)\n context.element.appendChild(clone)\n }\n}\n\nfunction getParentPath(el, attribute)\n{\n const parentEl = el.parentElement?.closest(`[${attribute}-list],[${attribute}-map]`)\n if (!parentEl) {\n return ''\n }\n if (parentEl.hasAttribute(`${attribute}-list`)) {\n return parentEl.getAttribute(`${attribute}-list`)+'.'\n }\n return parentEl.getAttribute(`${attribute}-map`)+'.'\n}\n\n/**\n * renders a single input type\n * for radio/checkbox inputs it only sets the checked attribute to true/false\n * if the value attribute matches the current value\n * for other inputs the value attribute is updated\n */\nexport function input(context)\n{\n const el = context.element\n let value = context.value\n\n element(context)\n if (typeof value == 'undefined') {\n value = ''\n }\n if (el.type=='checkbox' || el.type=='radio') {\n if (matchValue(el.value, value)) {\n el.checked = true\n } else {\n el.checked = false\n }\n } else if (!matchValue(el.value, value)) {\n el.value = ''+value\n }\n}\n\n/**\n * Sets the value of the button, doesn't touch the innerHTML\n */\nexport function button(context)\n{\n element(context)\n setProperties(context.element, context.value, 'value')\n}\n\n/**\n * Sets the selected attribute of select options\n */\nexport function select(context)\n{\n const el = context.element\n let value = context.value\n\n if (value === null) {\n value = ''\n }\n if (typeof value!='object') {\n if (el.multiple) {\n if (Array.isArray(value)) { //FIXME: cannot be true, since typeof != 'object'\n for (let option of el.options) {\n if (value.indexOf(option.value)===false) {\n option.selected = false\n } else {\n option.selected = true\n }\n }\n }\n } else {\n let option = el.options.find(o => matchValue(o.value,value))\n if (option) {\n option.selected = true\n option.setAttribute('selected', true)\n }\n }\n } else { // value is a non-null object\n if (value.options) {\n setSelectOptions(el, value.options)\n }\n if (value.selected) {\n select(Object.asssign({}, context, {value:value.selected}))\n }\n setProperties(el, value, 'name', 'id', 'selectedIndex', 'className') // allow innerHTML? if so call element instead\n }\n}\n\n/**\n * adds a single option to a select element. The option.text property is optional, if not set option.value is used.\n * @param select The select element\n * @param option An option descriptor, either a string, object with {text,value,defaultSelected,selected} properties or an Option object\n */\nexport function addOption(select, option)\n{\n if (!option) {\n return\n }\n if (typeof option !== 'object') {\n select.options.add(new Option(''+option))\n } else if (option.text) {\n select.options.add(new Option(option.text, option.value, option.defaultSelected, option.selected))\n } else if (typeof option.value != 'undefined') {\n select.options.add(new Option(''+option.value, option.value, option.defaultSelected, option.selected))\n }\n}\n\n/**\n * This function clears all existing options of a select element, and adds the specified options.\n */\nexport function setSelectOptions(select,options)\n{\n //@TODO: only update in case of changes?\n select.innerHTML = ''\n if (Array.isArray(options)) {\n for (const option of options) {\n addOption(select, option)\n }\n } else if (options && typeof options == 'object') {\n for (const option in options) {\n addOption(select, { text: options[option], value: option })\n }\n }\n}\n\n/**\n * Sets the innerHTML and href, id, title, target, name, newwindow, nofollow attributes of an anchor\n */\nexport function anchor(context)\n{\n element(context)\n setProperties(context.element, context.value, 'target', 'href', 'name', 'newwindow', 'nofollow')\n}\n\n/**\n * Sets the title, id, alt and src attributes of an image.\n */\nexport function image(context)\n{\n setProperties(context.element, context.value, 'title', 'alt', 'src', 'id')\n}\n\n/**\n * Sets the title, id and src attribute of an iframe\n */\nexport function iframe(context)\n{\n setProperties(context.element, context.value, 'title', 'src', 'id')\n}\n\n/**\n * Sets the content and id attribute of a meta element\n */\nexport function meta(context)\n{\n setProperties(context.element, context.value, 'content', 'id') \n}\n\n/**\n * sets the innerHTML and title and id properties of any HTML element\n */\nexport function element(context)\n{\n const el = context.element\n let value = context.value\n\n if (typeof value=='undefined' || value==null) {\n value = ''\n }\n let strValue = ''+value\n if (typeof value!='object' || strValue.substring(0,8)!='[object ') {\n el.innerHTML = strValue\n return\n }\n setProperties(el, value, 'innerHTML', 'title', 'id', 'className')\n}\n\n/**\n * Sets a list of properties on a dom element, equal to \n * the string value of a data object\n * only updates the dom element if the property doesn't match\n */\nexport function setProperties(el, data, ...properties) {\n if (!data || typeof data!=='object') {\n return\n }\n for (const property of properties) {\n if (typeof data[property] === 'undefined') {\n continue\n }\n if (matchValue(el[property], data[property])) {\n continue\n }\n if (data[property] === null) {\n el[property] = ''\n } else {\n el[property] = ''+data[property]\n }\n }\n}\n\n/**\n * Returns true if a matches b, either by having the\n * same string value, or matching string :empty against a falsy value\n */\nexport function matchValue(a,b)\n{\n if (a==':empty' && !b) {\n return true\n }\n if (b==':empty' && !a) {\n return true\n }\n if (''+a == ''+b) {\n return true\n }\n return false\n}\n", "import { throttledEffect, destroy } from './state.mjs'\nimport { escape_html, fixed_content } from './bind.transformers.mjs'\nimport * as render from './bind.render.mjs'\n\nif (!Symbol.bindTemplate) {\n Symbol.bindTemplate = Symbol('bindTemplate')\n}\n\n/**\n * Implements one way databinding, updating dom elements with matching attributes\n * to changes in signals (see state.mjs)\n * \n * @class\n */\nclass SimplyBind\n{\n \n /**\n * @param Object options - a set of options for this instance, options may include:\n * - root (signal) (required) - the root data object that contains al signals that can be bound\n * - container (HTMLElement) - the dom element to use as the root for all bindings\n * - attribute (string) - the prefix for the field, list and map attributes, e.g. 'data-bind'\n * - transformers (object name:function) - a map of transformer names and functions\n * - render (object with field, list and map properties)\n */\n constructor(options)\n {\n /**\n * A map of HTMLElements and the data bindings on each, in the form of \n * the connectedSignal returned by the (throttled)Effect.\n * @type {Map}\n * @public\n */\n this.bindings = new Map()\n\n const defaultTransformers = {\n escape_html,\n fixed_content\n }\n const defaultOptions = {\n container: document.body,\n attribute: 'data-flow',\n transformers: defaultTransformers,\n render: {\n field: [render.field],\n list: [render.list],\n map: [render.map]\n },\n renderers: {\n 'INPUT':render.input,\n 'BUTTON':render.button,\n 'SELECT':render.select,\n 'A':render.anchor,\n 'IMG':render.image,\n 'IFRAME':render.iframe,\n 'META':render.meta,\n 'TEMPLATE':null,\n '*':render.element\n }\n }\n if (!options?.root) {\n throw new Error('bind needs at least options.root set')\n }\n this.options = Object.assign({}, defaultOptions, options)\n if (options.transformers) {\n this.options.transformers = Object.assign({}, defaultTransformers, options?.transformers)\n }\n const attribute = this.options.attribute\n const bindAttributes = [attribute+'-field',attribute+'-list',attribute+'-map']\n const transformAttribute = attribute+'-transform'\n\n const getBindingAttribute = (el) => {\n const foundAttribute = bindAttributes.find(attr => el.hasAttribute(attr))\n if (!foundAttribute) {\n console.error('No matching attribute found',el,bindAttributes)\n }\n return foundAttribute\n }\n\n // sets up the effect that updates the element if its\n // data binding value changes\n const renderElement = (el) => {\n this.bindings.set(el, throttledEffect(() => {\n if (!el.isConnected) {\n // el is no longer part of this document\n untrack(el, this.getBindingPath(el))\n destroy(this.bindings.get(el))\n // doing this here instead of in a mutationobserver\n // allows an element to be temporary removed and then inserted\n // without the binding having to be reset\n return\n }\n let context = {\n templates: el.querySelectorAll(':scope > template'),\n attribute: getBindingAttribute(el)\n }\n context.path = this.getBindingPath(el)\n context.value = getValueByPath(this.options.root, context.path)\n context.element = el\n track(el, context)\n runTransformers(context)\n }, 50))\n }\n\n // finds and runs applicable transformers\n // creates a stack of transformers, calls the topmost\n // each transformer can opt to call the next or not\n // transformers should return the context object (possibly altered)\n const runTransformers = (context) => {\n let transformers\n switch(context.attribute) {\n case this.options.attribute+'-field':\n transformers = Array.from(this.options.render.field)\n break\n case this.options.attribute+'-list':\n transformers = Array.from(this.options.render.list)\n break\n case this.options.attribute+'-map':\n transformers = Array.from(this.options.render.map)\n break\n default:\n throw new Error('no valid context attribute specified',context)\n break\n }\n if (context.element.hasAttribute(transformAttribute)) {\n context.element.getAttribute(transformAttribute)\n .split(' ').filter(Boolean)\n .forEach(t => {\n if (this.options.transformers[t]) {\n transformers.push(this.options.transformers[t])\n } else {\n console.warn('No transformer with name '+t+' configured', {cause:context.element})\n }\n })\n }\n let next\n for (let transformer of transformers) {\n next = ((next, transformer) => {\n return (context) => {\n return transformer.call(this, context, next)\n }\n })(next, transformer)\n }\n next(context)\n }\n\n // given a set of elements with data bind attribute\n // this renders each of those elements\n const applyBindings = (bindings) => {\n for (let bindingEl of bindings) {\n if (!this.bindings.get(bindingEl)) { // bindingEl may have moved from somewhere else in this document\n renderElement(bindingEl)\n }\n }\n }\n\n // this handles the mutation observer changes\n // if any element is added, and has a data bind attribute\n // it applies that data binding\n const updateBindings = (changes) => {\n const selector = `[${attribute}-field],[${attribute}-list],[${attribute}-map]`\n for (const change of changes) {\n if (change.type==\"childList\" && change.addedNodes) {\n for (let node of change.addedNodes) {\n if (node instanceof HTMLElement) {\n let bindings = Array.from(node.querySelectorAll(selector))\n if (node.matches(selector)) {\n bindings.unshift(node)\n }\n if (bindings.length) {\n applyBindings(bindings)\n }\n }\n }\n }\n }\n }\n\n // this responds to elements getting added to the dom\n // and if any have data bind attributes, it applies those bindings\n this.observer = new MutationObserver((changes) => {\n updateBindings(changes)\n })\n\n this.observer.observe(this.options.container, {\n subtree: true,\n childList: true\n })\n\n // this finds elements with data binding attributes and applies those bindings\n // must come after setting up the observer, or included templates\n // won't trigger their own bindings\n const bindings = this.options.container.querySelectorAll(\n ':is(['+this.options.attribute+'-field]'+\n ',['+this.options.attribute+'-list]'+\n ',['+this.options.attribute+'-map]):not(template)'\n )\n if (bindings.length) {\n applyBindings(bindings)\n }\n\n }\n\n /**\n * Finds the first matching template and creates a new DocumentFragment\n * with the correct data bind attributes in it (prepends the current path)\n * @param Context context\n * @return DocumentFragment\n */\n applyTemplate(context)\n {\n const path = context.path\n const parent = context.parent\n const templates = context.templates\n const list = context.list\n const index = context.index\n const value = list ? list[index] : context.value\n\n let template = this.findTemplate(templates, value)\n if (!template) {\n let result = new DocumentFragment()\n result.innerHTML = '<!-- no matching template -->'\n return result\n }\n let clone = template.content.cloneNode(true)\n if (!clone.children?.length) {\n return clone\n }\n if (clone.children.length>1) {\n throw new Error('template must contain a single root node', { cause: template })\n }\n const attribute = this.options.attribute\n\n const attributes = [attribute+'-field',attribute+'-list',attribute+'-map']\n const bindings = clone.querySelectorAll(`[${attribute}-field],[${attribute}-list],[${attribute}-map]`)\n for (let binding of bindings) {\n if (binding.tagName=='TEMPLATE') {\n continue\n }\n const attr = attributes.find(attr => binding.hasAttribute(attr))\n let bind = binding.getAttribute(attr)\n bind = this.applyLinks(template.links, bind)\n if (bind.substring(0, ':root.'.length)==':root.') {\n binding.setAttribute(attr, bind.substring(':root.'.length))\n } else if (bind==':value' && index!=null) {\n binding.setAttribute(attr, path+'.'+index)\n } else if (index!=null) {\n binding.setAttribute(attr, path+'.'+index+'.'+bind)\n } else {\n binding.setAttribute(attr, parent+bind)\n }\n }\n if (typeof index !== 'undefined') {\n clone.children[0].setAttribute(attribute+'-key',index)\n }\n // keep track of the used template, so if that changes, the item can be updated\n clone.children[0][Symbol.bindTemplate] = template\n\n // return clone, not the firstChild, so that all whitespace is cloned as well\n return clone\n }\n\n parseLinks(links)\n {\n let result = {}\n links = links.split(';').map(link => link.trim())\n for (let link of links) {\n link = link.split('=')\n result[link[0].trim()] = link[1].trim()\n }\n return result\n }\n\n applyLinks(links, value)\n {\n for (let link in links) {\n if (value.startsWith(link+'.')) {\n return links[link] + value.substr(link.length)\n } else if (value==link) {\n return links[link]\n }\n }\n return value\n }\n\n /**\n * Returns the path referenced in either the field, list or map attribute\n * @param HTMLElement el\n * @return string The path referenced, or void\n */\n getBindingPath(el)\n {\n const attributes = [\n this.options.attribute+'-field', \n this.options.attribute+'-list',\n this.options.attribute+'-map'\n ]\n for (let attr of attributes) {\n if (el.hasAttribute(attr)) {\n return el.getAttribute(attr)\n }\n }\n }\n\n /**\n * Finds the first template from an array of templates that\n * matches the given value. \n */\n findTemplate(templates, value)\n {\n const templateMatches = t => {\n // find the value to match against (e.g. data-bind=\"foo\")\n let path = this.getBindingPath(t)\n let currentItem\n if (path) {\n if (path.substr(0,6)==':root.') {\n currentItem = getValueByPath(this.options.root, path)\n } else {\n currentItem = getValueByPath(value, path)\n }\n } else {\n currentItem = value\n }\n\n // then check the value against pattern, if set (e.g. data-bind-match=\"bar\")\n const strItem = ''+currentItem\n let matches = t.getAttribute(this.options.attribute+'-match')\n if (matches) {\n if (matches===':empty' && !currentItem) {\n return t\n } else if (matches===':notempty' && currentItem) {\n return t\n }\n if (strItem.match(matches)) {\n return t\n }\n }\n if (!matches && currentItem!==null && currentItem!==undefined) {\n //FIXME: this doesn't run templates in lists where list entry is null\n //which messes up the count\n //\n // no data-bind-match is set, so return this template\n return t\n }\n }\n let template = Array.from(templates).find(templateMatches)\n let links = null\n if (template?.hasAttribute(this.options.attribute+'-link')) {\n links = this.parseLinks(template.getAttribute(this.options.attribute+'-link'))\n }\n let rel = template?.getAttribute('rel')\n if (rel) {\n let replacement = document.querySelector('template#'+rel)\n if (!replacement) {\n throw new Error('Could not find template with id '+rel)\n }\n template = replacement\n }\n if (template) {\n template.links = links\n }\n return template\n }\n\n destroy()\n {\n this.bindings.forEach(binding => {\n destroy(binding)\n })\n this.bindings = new Map()\n this.observer.disconnect()\n }\n\n}\n\n/**\n * Returns a new instance of SimplyBind. This is the normal start\n * of a data bind flow\n */\nexport function bind(options)\n{\n return new SimplyBind(options)\n}\n\nconst tracking = new Map()\n\nexport function trace(path)\n{\n return tracking.get(path)\n}\n\nfunction track(el, context) {\n if (!tracking.has(context.path)) {\n tracking.set(context.path, [context])\n } else {\n tracking.get(context.path).push(context)\n }\n}\n\nfunction untrack(el, path) {\n let list = tracking.get(path)\n if (list) {\n list = list.filter(context => context.element == el)\n tracking.set(path, list)\n }\n}\n\n\n/**\n * Returns the value by walking the given path as a json pointer, starting at root\n * if you have a property with a '.' in its name urlencode the '.', e.g: %46\n * \n * @param HTMLElement root\n * @param string path e.g. 'foo.bar'\n * @return mixed the value found by walking the path from the root object or undefined\n */\nexport function getValueByPath(root, path)\n{\n let parts = path.split('.')\n let curr = root\n let part\n part = parts.shift()\n while (part && curr) {\n part = decodeURIComponent(part)\n curr = curr[part]\n part = parts.shift()\n }\n return curr\n}\n", "import {signal, effect, throttledEffect, batch} from './state.mjs'\n\n/**\n * This class implements a pluggable data model, where you can\n * add effects that are run only when either an option for that\n * effect changes, or when an effect earlier in the chain of\n * effects changes.\n */\nclass SimplyFlowModel {\n\n\t/**\n\t * Creates a new datamodel, with a state property that contains\n\t * all the data passed to this constructor\n\t * @param state\tObject with all the data for this model\n\t */\n\tconstructor(state) {\n\t\tthis.state = signal(state)\n\t\tif (!this.state.options) {\n\t\t\tthis.state.options = {}\n\t\t}\n\t\tthis.effects = [{current:state.data}]\n\t\tthis.view = signal(state.data)\n\t}\n\n\t/**\n\t * Adds an effect to run whenever a signal it depends on\n\t * changes. this.state is the usual signal.\n\t * The `fn` function param is not itself an effect, but must return\n\t * and effect function. `fn` takes one param, which is the data signal.\n\t * This signal will always have at least a `current` property.\n\t * The result of the effect function is pushed on to the this.effects\n\t * list. And the last effect added is set as this.view\n\t */\n\taddEffect(fn) {\n\t\tconst dataSignal = this.effects[this.effects.length-1]\n\t\tthis.view = fn.call(this, dataSignal)\n\t\tthis.effects.push(this.view)\n\t}\n}\n\nexport function model(options) {\n\treturn new SimplyFlowModel(options)\n}\n\n/**\n * Returns a function for model.addEffect that sorts the input data\n * \n * Options:\n * - direction (string) default 'asc' - change to 'desc' to sort in descending order\n * - sortBy (string) (optional) - used by the default sorting function to select the property to sort on\n * - sortFn (function) (required - set by default) - the sort function to use\n */\nexport function sort(options={}) {\n\treturn function(data) {\n\t\t// initialize the sort options, only gets called once\n\t\tthis.state.options.sort = Object.assign({\n\t\t\tdirection: 'asc',\n\t\t\tsortBy: null,\n\t\t\tsortFn: ((a,b) => {\n\t\t\t\tconst sort = this.state.options.sort\n\t\t\t\tconst sortBy = sort.sortBy\n\t\t\t\tif (!sort.sortBy) {\n\t\t\t\t\treturn 0\n\t\t\t\t}\n\t\t\t\tconst larger = sort.direction == 'asc' ? 1 : -1\n\t\t\t\tconst smaller = sort.direction == 'asc' ? -1 : 1\n\t\t\t\tif (typeof a?.[sortBy] === 'undefined') {\n\t\t\t\t\tif (typeof b?.[sortBy] === 'undefined') {\n\t\t\t\t\t\treturn 0\n\t\t\t\t\t}\n\t\t\t\t\treturn larger\n\t\t\t\t}\n\t\t\t\tif (typeof b?.[sortBy] === 'undefined') {\n\t\t\t\t\treturn smaller\n\t\t\t\t}\n\t\t\t\tif (a[sortBy]<b[sortBy]) {\n\t\t\t\t\treturn smaller\n\t\t\t\t} else if (a[sortBy]>b[sortBy]) {\n\t\t\t\t\treturn larger\n\t\t\t\t} else {\n\t\t\t\t\treturn 0\n\t\t\t\t}\n\t\t\t})\n\t\t}, options);\n\t\t// then return the effect, which is called when\n\t\t// either the data or the sort options change\n\t\treturn throttledEffect(() => {\n\t\t\tconst sort = this.state.options.sort\n\t\t\tif (sort?.sortBy && sort?.direction) {\n\t\t\t\treturn data.current.toSorted(sort?.sortFn)\n\t\t\t}\n\t\t\treturn data.current\n\t\t}, 50)\n\t}\n}\n\n/**\n * Returns a function for model.addEffect that implements paging\n * for the input data. It will return a slice of the data matching\n * the page and pageSize options.\n * \n * Options:\n * - page (int) default 1 - which page to show, starts at 1\n * - pageSize (int) default 20 - how many items in a single page\n * - max (int) (calculated) - how many pages in total\n */\nexport function paging(options={}) {\n\treturn function(data) {\n\t\t// initialize the paging options\n\t\tthis.state.options.paging = Object.assign({\n\t\t\tpage: 1,\n\t\t\tpageSize: 20,\n\t\t\tmax: 1\n\t\t}, options)\n\t\treturn throttledEffect(() => {\n\t\t\treturn batch(() => {\n\t\t\t\tconst paging = this.state.options.paging\n\t\t\t\tif (!paging.pageSize) {\n\t\t\t\t\tpaging.pageSize = 20\n\t\t\t\t}\n\t\t\t\tpaging.max = Math.ceil(this.state.data.length / paging.pageSize)\n\t\t\t\tpaging.page = Math.max(1, Math.min(paging.max, paging.page))\n\n\t\t\t\tconst start = (paging.page-1) * paging.pageSize\n\t\t\t\tconst end = start + paging.pageSize\n\t\t\t\treturn data.current.slice(start, end)\n\t\t\t})\n\t\t}, 50)\n\t}\n}\n\n/**\n * Returns a function for model.addEffect that filters rows from the data,\n * using a custom filter function `options.matches`\n * \n * Options:\n * - name (string) (required) - the name of this filter, must be unique\n * - matches (function) (required) - the filter function to apply to the data\n */\nexport function filter(options) {\n\tif (!options?.name || typeof options.name!=='string') {\n\t\tthrow new Error('filter requires options.name to be a string')\n\t}\n\tif (!options.matches || typeof options.matches!=='function') {\n\t\tthrow new Error('filter requires options.matches to be a function')\n\t}\n\treturn function(data) {\n\t\tif (this.state.options[options.name]) {\n\t\t\tthrow new Error('a filter with this name already exists on this model')\n\t\t}\n\t\tthis.state.options[options.name] = options\n\t\treturn throttledEffect(() => {\n\t\t\tif (this.state.options[options.name].enabled) {\n\t\t\t\treturn data.current.filter(this.state.options[options.name].matches.bind(this))\n\t\t\t}\n\t\t\treturn data.current\n\t\t}, 50)\n\t}\n}\n\n/**\n * Returns a function for model.addEffect that filters the data to only contain\n * columns (properties) that aren't hidden. Automatically runs again if any columns\n * hidden property changes.\n * \n * Options:\n * - columns (object) (required) - an object with properties describing each column. Each \n * property must be an object with an optional `hidden` property. If set to a truthy value,\n * and property in the dataset with the same name, will be filtered out.\n */\nexport function columns(options={}) {\n\tif (!options\n\t\t|| typeof options!=='object'\n\t\t|| Object.keys(options).length===0) {\n\t\tthrow new Error('columns requires options to be an object with at least one property')\n\t}\n\treturn function(data) {\n\t\tthis.state.options.columns = options\n\t\treturn throttledEffect(() => {\n\t\t\treturn data.current.map(input => {\n\t\t\t\tlet result = {}\n\t\t\t\tfor (let key of Object.keys(this.state.options.columns)) {\n\t\t\t\t\tif (!this.state.options.columns[key]?.hidden) {\n\t\t\t\t\t\tresult[key] = input[key]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn result\n\t\t\t})\n\t\t}, 50)\n\t}\n}\n\n/**\n * Returns a function for use with model.addEffect, with the given options set\n * as model.options.scroll. The effect will return a slice of the input data, which\n * makes it easy to render just a part (slice) of the whole data.\n * \n * Options are:\n * - offset (int) default 0 (optional) - the offset in the data to start the slice\n * - rowCount (int) default 20 (optional / calculated) - the number of rows in the slice\n * - rowHeight (int) default 26 (optional) - the height of a single row in pixels\n * - itemsPerRow (int) default 1 (optional) - the number of items on a single row\n * - size (int) default data.current.length (calculated) - how many rows inside data.current before slicing\n * - scrollbar (HTMLElement) defualt null (optional) - if set, an effect is added to update this elements \n * \t height if data.current.length changes\n * - container (HTMLElement) default null (optional) - if set, a scroll listener is added to this element, \n * which will update the options.offset signal and trigger the slice effect. It will also set the rowCount.\n */\nexport function scroll(options) {\n\n\treturn function(data) {\n\t\tthis.state.options.scroll = Object.assign({\n\t\t\toffset: 0,\n\t\t\trowHeight: 26,\n\t\t\trowCount: 20,\n\t\t\titemsPerRow: 1,\n\t\t\tsize: data.current.length\n\t\t}, options)\n\t\tconst scrollOptions = this.state.options.scroll\n\n\t\tconst scrollbar = scrollOptions.scrollbar \n\t\t\t|| scrollOptions.container?.querySelector('[data-flow-scrollbar]')\n\t\tif (scrollbar) {\n\t\t\tif (scrollOptions.container) {\n\t\t\t\tscrollOptions.container.addEventListener('scroll', (evt) => {\n\t\t\t\t\tscrollOptions.offset = Math.floor(scrollOptions.container.scrollTop\n\t\t\t\t\t\t/ (scrollOptions.rowHeight*scrollOptions.itemsPerRow)\n\t\t\t\t\t)\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tthrottledEffect(() => {\n\t\t\t\tscrollOptions.size = data.current.length * scrollOptions.rowHeight\n\t\t\t\tscrollbar.style.height = scrollOptions.size + 'px'\n\t\t\t}, 50)\n\t\t}\n\n\t\treturn throttledEffect(() => {\n\t\t\tif (scrollOptions.container) {\n\t\t\t\t//TODO: add a resize listener so that if the size of the container\n\t\t\t\t// changes, the rowCount is calculated again\n\t\t\t\tscrollOptions.rowCount = Math.ceil(\n\t\t\t\t\tscrollOptions.container.getBoundingClientRect().height \n\t\t\t\t\t/ scrollOptions.rowHeight\n\t\t\t\t)\n\t\t\t}\n\t\t\tscrollOptions.data = data.current\n\t\t\tlet start = Math.min(scrollOptions.offset, data.current.length-1)\n\t\t\tlet end = start + scrollOptions.rowCount\n\t\t\tif (end > data.current.length) {\n\t\t\t\tend = data.current.length\n\t\t\t\tstart = end - scrollOptions.rowCount\n\t\t\t}\n\t\t\treturn data.current.slice(start, end)\n\t\t}, 50)\n\t}\n}", "import { bind } from './bind.mjs'\nimport * as model from './model.mjs'\nimport * as state from './state.mjs'\n\nif (!globalThis.simply) {\n\tglobalThis.simply = {}\n}\nObject.assign(globalThis.simply, {\n\tbind,\n\tflow: model,\n\tstate\n})\n\nexport default globalThis.simply"],
|
|
5
|
-
"mappings": "kGAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,EAAA,gBAAAC,EAAA,YAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,oBAAAC,EAAA,UAAAC,GAAA,cAAAC,KAAA,IAAMC,EAAU,OAAO,SAAS,EAC3B,OAAO,OACR,OAAO,KAAO,OAAO,MAAM,GAE1B,OAAO,SACR,OAAO,OAAS,OAAO,QAAQ,GAGnC,IAAMC,GAAgB,CAClB,IAAK,CAACC,EAAQC,EAAUC,IAAa,CACjC,GAAID,IAAW,OAAO,KAClB,OAAOD,EAEX,GAAIC,IAAW,OAAO,OAClB,MAAO,GAEX,IAAME,EAAQH,IAASC,CAAQ,EAE/B,OADAG,EAAUF,EAAUD,CAAQ,EACxB,OAAOE,GAAU,WACb,MAAM,QAAQH,CAAM,EACb,IAAIK,IAAS,CAChB,IAAI,EAAIL,EAAO,OAIXM,EAASH,EAAM,MAAMD,EAAUG,CAAI,EACvC,OAAI,GAAKL,EAAO,QACZO,EAAUL,EAAWM,EAAY,SAAU,CAAE,IAAK,EAAG,IAAKR,EAAO,MAAO,CAAC,CAAE,EAExEM,CACX,EACON,aAAkB,KAAOA,aAAkB,IAC3C,IAAIK,IAAS,CAIhB,IAAII,EAAIT,EAAO,KACXM,EAASH,EAAM,MAAMH,EAAQK,CAAI,EACrC,OAAII,GAAKT,EAAO,MACZO,EAAUL,EAAUM,EAAa,OAAQ,CAAE,IAAKC,EAAG,IAAKT,EAAO,IAAK,CAAC,CAAE,EAMvE,CAAC,MAAM,MAAM,QAAQ,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EAAQV,EAAK,QAAQ,OACrBS,EAAQC,EAAMO,EAAc,UAEtBjB,EAAK,QAAQ,MAAMS,EAAOC,CAAG,CACrC,EAAG,EAAE,CACN,CACD,CC5PK,WAAW,SACf,WAAW,OAAS,CAAC,GAEtB,OAAO,OAAO,WAAW,OAAQ,CAChC,KAAAU,GACA,KAAMC,EACN,MAAAC,CACD,CAAC,EAED,IAAOC,GAAQ,WAAW",
|
|
6
|
-
"names": ["state_exports", "__export", "batch", "clockEffect", "destroy", "effect", "signal", "throttledEffect", "trace", "untracked", "iterate", "signalHandler", "target", "property", "receiver", "value", "notifyGet", "args", "result", "notifySet", "makeContext", "s", "current", "signals", "descriptor", "v", "prop", "getListeners", "listener", "batchedListeners", "batchMode", "self", "context", "listeners", "change", "propListeners", "addContext", "currentEffect", "computeStack", "clearContext", "currentCompute", "setListeners", "listenersMap", "computeMap", "compute", "connectedSignals", "clearListeners", "effectStack", "effectMap", "signalStack", "fn", "f", "connectedSignal", "computeEffect", "runBatchedListeners", "copyBatchedListeners", "throttleTime", "throttled", "hasChange", "clock", "lastTick", "hasChanged", "remember", "escape_html", "context", "next", "content", "fixed_content", "field", "context", "fieldByTemplates", "renderer", "list", "arrayByTemplates", "map", "objectByTemplates", "attribute", "items", "lastKey", "skipped", "item", "currentKey", "bindings", "needsReplacement", "b", "databind", "newTemplate", "length", "key", "clone", "outOfOrderItem", "i", "rendered", "template", "getParentPath", "el", "parentEl", "input", "value", "element", "matchValue", "button", "setProperties", "select", "option", "o", "setSelectOptions", "addOption", "options", "anchor", "image", "iframe", "meta", "strValue", "data", "properties", "property", "a", "SimplyBind", "options", "defaultTransformers", "escape_html", "fixed_content", "defaultOptions", "field", "list", "map", "input", "button", "select", "anchor", "image", "iframe", "meta", "element", "attribute", "bindAttributes", "transformAttribute", "getBindingAttribute", "el", "foundAttribute", "attr", "renderElement", "throttledEffect", "untrack", "destroy", "context", "getValueByPath", "track", "runTransformers", "transformers", "t", "next", "transformer", "applyBindings", "bindings", "bindingEl", "updateBindings", "changes", "selector", "change", "node", "path", "parent", "templates", "index", "value", "template", "result", "clone", "attributes", "binding", "bind", "links", "link", "templateMatches", "currentItem", "strItem", "matches", "rel", "replacement", "tracking", "track", "el", "context", "tracking", "untrack", "path", "list", "getValueByPath", "root", "parts", "curr", "part", "model_exports", "__export", "columns", "filter", "model", "paging", "scroll", "sort", "SimplyFlowModel", "state", "signal", "fn", "dataSignal", "model", "options", "sort", "data", "a", "b", "sortBy", "larger", "smaller", "throttledEffect", "paging", "batch", "start", "end", "filter", "columns", "input", "result", "key", "scroll", "scrollOptions", "scrollbar", "evt", "bind", "model_exports", "state_exports", "flow_default"]
|
|
3
|
+
"sources": ["../src/state.mjs", "../src/bind.transformers.mjs", "../src/bind.render.mjs", "../src/bind.mjs", "../src/model.mjs", "../src/render.mjs", "../src/flow.mjs"],
|
|
4
|
+
"sourcesContent": ["const iterate = Symbol('iterate')\nif (!Symbol.xRay) {\n Symbol.xRay = Symbol('xRay')\n}\nif (!Symbol.Signal) {\n Symbol.Signal = Symbol('Signal')\n}\n\nconst signalHandler = {\n get: (target, property, receiver) => {\n if (property===Symbol.xRay) {\n return target // don't notifyGet here, this is only called by set\n }\n if (property===Symbol.Signal) {\n return true\n }\n const value = target?.[property] // Reflect.get fails on a Set.\n notifyGet(receiver, property)\n if (typeof value === 'function') {\n if (Array.isArray(target)) {\n return (...args) => {\n let l = target.length\n // by binding the function to the receiver\n // all accesses in the function will be trapped\n // by the Proxy, so get/set/delete is all handled\n let result = value.apply(receiver, args)\n if (l != target.length) {\n notifySet(receiver, makeContext('length', { was: l, now: target.length }) )\n }\n return result\n }\n } else if (target instanceof Set || target instanceof Map) {\n return (...args) => {\n // node doesn't allow you to call set/map functions\n // bound to the receiver.. so using target instead\n // there are no properties to update anyway, except for size\n let s = target.size\n let result = value.apply(target, args)\n if (s != target.size) {\n notifySet(receiver, makeContext( 'size', { was: s, now: target.size }) )\n }\n // there is no efficient way to see if the function called\n // has actually changed the Set/Map, but by assuming the\n // 'setter' functions will change the results of the\n // 'getter' functions, effects should update correctly\n if (['set','add','clear','delete'].includes(property)) {\n notifySet(receiver, makeContext( { entries: {}, forEach: {}, has: {}, keys: {}, values: {}, [Symbol.iterator]: {} } ) )\n }\n return result\n }\n } else if (\n target instanceof HTMLElement\n || target instanceof Number\n || target instanceof String\n || target instanceof Boolean\n ) {\n return value.bind(target)\n } else {\n // support custom classes, hopefully\n return value.bind(receiver)\n }\n }\n if (value && typeof value == 'object') {\n //NOTE: get now returns a signal, set doesn't 'unsignal' the value set\n return signal(value)\n }\n return value\n },\n set: (target, property, value, receiver) => {\n value = value?.[Symbol.xRay] || value // unwraps signal\n let current = target[property]\n if (current!==value) {\n target[property] = value\n notifySet(receiver, makeContext(property, { was: current, now: value } ) )\n }\n if (typeof current === 'undefined') {\n notifySet(receiver, makeContext(iterate, {}))\n }\n return true\n },\n has: (target, property) => { // receiver is not part of the has() call\n let receiver = signals.get(target) // so retrieve it here\n if (receiver) {\n notifyGet(receiver, property)\n }\n return Object.hasOwn(target, property)\n },\n deleteProperty: (target, property) => {\n if (typeof target[property] !== 'undefined') {\n let current = target[property]\n delete target[property]\n let receiver = signals.get(target) // receiver is not part of the trap arguments, so retrieve it here\n notifySet(receiver, makeContext(property,{ delete: true, was: current }))\n }\n return true\n },\n defineProperty: (target, property, descriptor) => {\n if (typeof target[property] === 'undefined') {\n let receiver = signals.get(target) // receiver is not part of the trap arguments, so retrieve it here\n notifySet(receiver, makeContext(iterate, {}))\n }\n return Object.defineProperty(target, property, descriptor)\n },\n ownKeys: (target) => {\n let receiver = signals.get(target) // receiver is not part of the trap arguments, so retrieve it here\n notifyGet(receiver, iterate)\n return Reflect.ownKeys(target)\n }\n\n}\n\n/**\n * Keeps track of the return signal for an update function, as well\n * as signals connected to other objects. \n * Makes sure that a given object or function always uses the same\n * signal\n */\nconst signals = new WeakMap()\n\n/**\n * Creates a new signal proxy of the given object, that intercepts get/has and set/delete\n * to allow reactive functions to be triggered when signal values change.\n */\nexport function signal(v) {\n if (v[Symbol.Signal]) { // avoid wrapping a Signal inside a Signal\n let target = v[Symbol.xRay]\n if (!signals.has(target)) {\n signals.set(target, v)\n }\n v = target\n } else if (!signals.has(v)) {\n signals.set(v, new Proxy(v, signalHandler))\n }\n return signals.get(v)\n}\n\n/**\n * Lists all effects that are currently listening to changes in\n * the given signal and property\n * returns a list with \n * - effect: the effect function (effect, throttledEffect, clockEffect)\n * - fn: the user provided function to this effect function\n * - signal: the connectedSignal to this user provided function\n * @param Signal signal\n * @param string prop \n * @return array of { effect, fn, signal }\n */\nexport function trace(signal, prop) {\n const listeners = getListeners(signal, prop)\n return listeners.map(listener => {\n return {\n effect: listener.effectType,\n fn: listener.effectFunction,\n signal: signals.get(listener.effectFunction)\n }\n })\n}\n\nlet batchedListeners = new Set()\nlet batchMode = 0\n/**\n * Called when a signal changes a property (set/delete)\n * Triggers any reactor function that depends on this signal\n * to re-compute its values\n */\nfunction notifySet(self, context={}) {\n let listeners = []\n context.forEach((change, property) => {\n let propListeners = getListeners(self, property)\n if (propListeners?.length) {\n for (let listener of propListeners) {\n addContext(listener, makeContext(property,change))\n }\n listeners = listeners.concat(propListeners)\n }\n })\n listeners = new Set(listeners.filter(Boolean))\n if (listeners) {\n if (batchMode) {\n batchedListeners = batchedListeners.union(listeners)\n } else {\n const currentEffect = computeStack[computeStack.length-1]\n for (let listener of Array.from(listeners)) {\n if (listener!=currentEffect && listener?.needsUpdate) {\n listener()\n }\n clearContext(listener)\n }\n }\n }\n}\n\nfunction makeContext(property, change) {\n let context = new Map()\n if (typeof property === 'object') {\n for (let prop in property) {\n context.set(prop, property[prop])\n }\n } else {\n context.set(property, change)\n }\n return context\n}\n\nfunction addContext(listener, context) {\n if (!listener.context) {\n listener.context = context\n } else {\n context.forEach((change,property)=> {\n listener.context.set(property, change) // TODO: merge change if needed\n })\n }\n listener.needsUpdate = true\n}\n\nfunction clearContext(listener) {\n delete listener.context\n delete listener.needsUpdate\n}\n\n/**\n * Called when a signal property is accessed. If this happens\n * inside a reactor function--computeStack is not empty--\n * then it adds the current reactor (top of this stack) to its\n * listeners. These are later called if this property changes\n */\nfunction notifyGet(self, property) {\n let currentCompute = computeStack[computeStack.length-1]\n if (currentCompute) {\n // get was part of a react() function, so add it\n setListeners(self, property, currentCompute)\n }\n}\n\n/**\n * Keeps track of which update() functions are dependent on which\n * signal objects and which properties. Maps signals to update fns\n */\nconst listenersMap = new WeakMap()\n\n/**\n * Keeps track of which signals and properties are linked to which\n * update functions. Maps update functions and properties to signals\n */\nconst computeMap = new WeakMap()\n\n/**\n * Returns the update functions for a given signal and property\n */\nfunction getListeners(self, property) {\n let listeners = listenersMap.get(self)\n return listeners ? Array.from(listeners.get(property) || []) : []\n}\n\n/**\n * Adds an update function (compute) to the list of listeners on\n * the given signal (self) and property\n */\nfunction setListeners(self, property, compute) {\n if (!listenersMap.has(self)) {\n listenersMap.set(self, new Map())\n }\n let listeners = listenersMap.get(self)\n if (!listeners.has(property)) {\n listeners.set(property, new Set())\n }\n listeners.get(property).add(compute)\n\n if (!computeMap.has(compute)) {\n computeMap.set(compute, new Map())\n }\n let connectedSignals = computeMap.get(compute)\n if (!connectedSignals.has(property)) {\n connectedSignals.set(property, new Set)\n }\n connectedSignals.get(property).add(self)\n}\n\n/**\n * Removes alle listeners that trigger the given reactor function (compute)\n * This happens when a reactor is called, so that it can set new listeners\n * based on the current call (code path)\n */\nfunction clearListeners(compute) {\n let connectedSignals = computeMap.get(compute)\n if (connectedSignals) {\n connectedSignals.forEach(property => {\n property.forEach(s => {\n let listeners = listenersMap.get(s)\n if (listeners.has(property)) {\n listeners.get(property).delete(compute)\n }\n })\n })\n }\n}\n\n/**\n * The top most entry is the currently running update function, used\n * to automatically record signals used in an update function.\n */\nlet computeStack = []\n\n/**\n * Used for cycle detection: effectStack contains all running effect\n * functions. If the same function appears twice in this stack, there\n * is a recursive update call, which would cause an infinite loop.\n */\nconst effectStack = []\n\nconst effectMap = new WeakMap()\n/**\n * Used for cycle detection: signalStack contains all used signals. \n * If the same signal appears more than once, there is a cyclical \n * dependency between signals, which would cause an infinite loop.\n */\nconst signalStack = []\n\n/**\n * Runs the given function at once, and then whenever a signal changes that\n * is used by the given function (or at least signals used in the previous run).\n */\nexport function effect(fn) {\n if (effectStack.findIndex(f => fn==f)!==-1) {\n throw new Error('Recursive update() call', {cause:fn})\n }\n effectStack.push(fn)\n\n let connectedSignal = signals.get(fn)\n if (!connectedSignal) {\n connectedSignal = signal({\n current: null\n })\n signals.set(fn, connectedSignal)\n }\n\n // this is the function that is called automatically\n // whenever a signal dependency changes\n const computeEffect = function computeEffect() {\n if (signalStack.findIndex(s => s==connectedSignal)!==-1) {\n throw new Error('Cyclical dependency in update() call', { cause: fn})\n }\n // remove all dependencies (signals) from previous runs \n clearListeners(computeEffect)\n computeEffect.effectFunction = fn\n computeEffect.effectType = effect\n // record new dependencies on this run\n computeStack.push(computeEffect)\n // prevent recursion\n signalStack.push(connectedSignal)\n // call the actual update function\n let result\n try {\n result = fn(computeEffect, computeStack, signalStack)\n } finally {\n // stop recording dependencies\n computeStack.pop()\n // stop the recursion prevention\n signalStack.pop()\n if (result instanceof Promise) {\n result.then((result) => {\n connectedSignal.current = result\n })\n } else {\n connectedSignal.current = result\n }\n }\n }\n computeEffect.fn = fn\n effectMap.set(connectedSignal, computeEffect)\n\n // run the computEffect immediately upon creation\n computeEffect()\n return connectedSignal\n}\n\n\nexport function destroy(connectedSignal) {\n // find the computeEffect associated with this signal\n const computeEffect = effectMap.get(connectedSignal)?.deref()\n if (!computeEffect) {\n return\n }\n\n // remove all listeners for this effect\n clearListeners(computeEffect)\n\n // remove all references to connectedSignal\n let fn = computeEffect.fn\n signals.remove(fn)\n\n effectMap.delete(connectedSignal)\n\n // if no other references to connectedSignal exist, it will be garbage collected\n}\n\n/**\n * Inside a batch() call, any changes to signals do not trigger effects\n * immediately. Instead, immediately after finishing the batch() call,\n * these effects will be called. Effects that are triggered by multiple\n * signals are called only once.\n * @param Function fn batch() calls this function immediately\n * @result mixed the result of the fn() function call\n */\nexport function batch(fn) {\n batchMode++\n let result\n try {\n result = fn()\n } finally {\n if (result instanceof Promise) {\n result.then(() => {\n batchMode--\n if (!batchMode) {\n runBatchedListeners()\n }\n })\n } else {\n batchMode--\n if (!batchMode) {\n runBatchedListeners()\n }\n }\n }\n return result\n}\n\nfunction runBatchedListeners() {\n let copyBatchedListeners = Array.from(batchedListeners)\n batchedListeners = new Set()\n const currentEffect = computeStack[computeStack.length-1]\n for (let listener of copyBatchedListeners) {\n if (listener!=currentEffect && listener?.needsUpdate) {\n listener()\n }\n clearContext(listener)\n }\n}\n\n/**\n * A throttledEffect is run immediately once. And then only once\n * per throttleTime (in ms).\n * @param Function fn the effect function to run whenever a signal changes\n * @param int throttleTime in ms\n * @returns signal with the result of the effect function fn\n */\nexport function throttledEffect(fn, throttleTime) {\n if (effectStack.findIndex(f => fn==f)!==-1) {\n throw new Error('Recursive update() call', {cause:fn})\n }\n effectStack.push(fn)\n\n let connectedSignal = signals.get(fn)\n if (!connectedSignal) {\n connectedSignal = signal({\n current: null\n })\n signals.set(fn, connectedSignal)\n }\n\n let throttled = false\n let hasChange = true\n // this is the function that is called automatically\n // whenever a signal dependency changes\n const computeEffect = function computeEffect() {\n if (signalStack.findIndex(s => s==connectedSignal)!==-1) {\n throw new Error('Cyclical dependency in update() call', { cause: fn})\n }\n if (throttled && throttled>Date.now()) {\n hasChange = true\n return\n }\n // remove all dependencies (signals) from previous runs \n clearListeners(computeEffect)\n // record new dependencies on this run\n computeEffect.effectFunction = fn\n computeEffect.effectType = throttledEffect\n computeStack.push(computeEffect)\n // prevent recursion\n signalStack.push(connectedSignal)\n // call the actual update function\n let result\n try {\n result = fn(computeEffect, computeStack, signalStack)\n } finally {\n hasChange = false\n // stop recording dependencies\n computeStack.pop()\n // stop the recursion prevention\n signalStack.pop()\n if (result instanceof Promise) {\n result.then((result) => {\n connectedSignal.current = result\n })\n } else {\n connectedSignal.current = result\n }\n }\n throttled = Date.now()+throttleTime\n globalThis.setTimeout(() => {\n if (hasChange) {\n computeEffect()\n }\n }, throttleTime)\n }\n // run the computEffect immediately upon creation\n computeEffect()\n return connectedSignal\n}\n\n// refactor: Class clock() with an effect() method\n// keep track of effects per clock, and add clock property to the effect function\n// on notifySet add clock.effects to clock.needsUpdate list\n// on clock.tick() (or clock.time++) run only the clock.needsUpdate effects \n// (first create a copy and reset clock.needsUpdate, then run effects)\nexport function clockEffect(fn, clock) {\n let connectedSignal = signals.get(fn)\n if (!connectedSignal) {\n connectedSignal = signal({\n current: null\n })\n signals.set(fn, connectedSignal)\n }\n\n let lastTick = -1 // clock.time should start at 0 or larger\n let hasChanged = true // make sure the first run goes through\n // this is the function that is called automatically\n // whenever a signal dependency changes\n const computeEffect = function computeEffect() {\n if (lastTick < clock.time) {\n if (hasChanged) {\n // remove all dependencies (signals) from previous runs \n clearListeners(computeEffect)\n computeEffect.effectFunction = fn\n computeEffect.effectType = clockEffect\n // record new dependencies on this run\n computeStack.push(computeEffect)\n // make sure the clock.time signal is a dependency\n lastTick = clock.time\n // call the actual update function\n let result \n try {\n result = fn(computeEffect, computeStack)\n } finally {\n // stop recording dependencies\n computeStack.pop()\n if (result instanceof Promise) {\n result.then((result) => {\n connectedSignal.current = result\n })\n } else {\n connectedSignal.current = result\n }\n hasChanged = false\n }\n } else {\n lastTick = clock.time\n }\n } else {\n hasChanged = true\n }\n }\n // run the computEffect immediately upon creation\n computeEffect()\n return connectedSignal\n}\n\nexport function untracked(fn) {\n const remember = computeStack.slice()\n computeStack = []\n try {\n return fn()\n } finally {\n computeStack = remember\n }\n}", "export function escape_html(context, next) {\n let content = context.value.innerHTML\n if (typeof context.value == 'string') {\n content = context.value\n context.value = { innerHTML: content }\n }\n if (content) {\n content = content.replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''');\n context.value.innerHTML = content\n }\n next(context)\n}\n\nexport function fixed_content(context, next) {\n if (typeof context.value == 'string') {\n context.value = {}\n } else {\n delete context.value.innerHTML\n }\n next(context)\n}\n", "/*\n * Default renderers for data binding\n * Will be used unless overriden in the SimplyBind options parameter\n */\n\n/**\n * This function is used by default to render dom elements with the `data-flow-field` attribute.\n * It will switch to only switching in template content if the context has any templates.\n * Otherwise it will call the matching render function depending on the tagName of the\n * context.element\n */\nexport function field(context)\n{\n if (context.templates?.length) {\n fieldByTemplates.call(this, context)\n // TODO: check if existence of one or more templates must mean that\n // only the template rendering is applied, instead of also rendering attributes\n } else if (Object.hasOwnProperty.call(this.options.renderers, context.element.tagName)) {\n const renderer = this.options.renderers[context.element.tagName]\n if (renderer) {\n renderer.call(this, context)\n }\n } else if (this.options.renderers['*']) {\n this.options.renderers['*'].call(this, context)\n }\n return context\n}\n\n/**\n * This function is used by default to render DOM elements with the `data-flow-list` attribute.\n * The context.value must be an array. And context.templates must not be empty.\n */\nexport function list(context)\n{\n if (!Array.isArray(context.value)) {\n console.error('Value is not an array.', context.element, context.path, context.value)\n } else if (!context.templates?.length) {\n console.error('No templates found in', context.element)\n } else {\n arrayByTemplates.call(this, context)\n }\n return context\n}\n\n/**\n * This function is used by default to render DOM elements with the `data-flow-map` attribute.\n * The context.value must be a non-null object. And context.templates must not be empty.\n */\nexport function map(context)\n{\n if (typeof context.value != 'object' || !context.value) {\n console.error('Value is not an object.', context.element, context.path, context.value)\n } else if (!context.templates?.length) {\n console.error('No templates found in', context.element)\n } else {\n objectByTemplates.call(this, context)\n }\n return context\n}\n\n/**\n * Renders an array value by applying templates for each entry\n * Replaces or removes existing DOM children if needed\n * Reuses (doesn't touch) DOM children if template doesn't change\n * FIXME: this doesn't handle situations where there is no matching template\n * this messes up self healing. check renderObjectByTemplates for a better implementation\n */\nexport function arrayByTemplates(context)\n{\n const attribute = this.options.attribute\n\n let items = context.element.querySelectorAll(':scope > ['+attribute+'-key]')\n // do single merge strategy for now, in future calculate optimal merge strategy from a number\n // now just do a delete if a key <= last key, insert if a key >= last key\n let lastKey = 0\n let skipped = 0\n context.list = context.value\n for (let item of items) {\n let currentKey = parseInt(item.getAttribute(attribute+'-key'))\n if (currentKey>lastKey) {\n // insert before\n context.index = lastKey\n context.element.insertBefore(this.applyTemplate(context), item)\n } else if (currentKey<lastKey) {\n // remove this\n item.remove()\n } else {\n // check that all data-bind params start with current json path or ':root', otherwise replaceChild\n let bindings = Array.from(item.querySelectorAll(`[${attribute}]`))\n if (item.matches(`[${attribute}]`)) {\n bindings.unshift(item)\n }\n let needsReplacement = bindings.find(b => {\n let databind = b.getAttribute(attribute)\n return (databind.substr(0,5)!==':root' \n && databind.substr(0, context.path.length)!==context.path)\n })\n if (!needsReplacement) {\n if (item[Symbol.bindTemplate]) {\n let newTemplate = this.findTemplate(context.templates, context.list[lastKey])\n if (newTemplate != item[Symbol.bindTemplate]){\n needsReplacement = true\n if (!newTemplate) {\n skipped++\n }\n }\n }\n }\n if (needsReplacement) {\n context.index = lastKey\n context.element.replaceChild(this.applyTemplate(context), item)\n }\n }\n lastKey++\n if (lastKey>=context.value.length) {\n break\n }\n }\n items = context.element.querySelectorAll(':scope > ['+attribute+'-key]')\n let length = items.length + skipped\n if (length > context.value.length) {\n while (length > context.value.length) {\n let child = context.element.querySelectorAll(':scope > :not(template)')?.[length-1]\n child?.remove()\n length--\n }\n } else if (length < context.value.length ) {\n while (length < context.value.length) {\n context.index = length\n context.element.appendChild(this.applyTemplate(context))\n length++\n }\n }\n}\n\n/**\n * Renders an object value by applying templates for each entry (Object.entries)\n * Replaces,moves or removes existing DOM children if needed\n * Reuses (doesn't touch) DOM children if template doesn't change\n */\nexport function objectByTemplates(context)\n{\n const attribute = this.options.attribute\n context.list = context.value\n\n let items = Array.from(context.element.querySelectorAll(':scope > ['+attribute+'-key]'))\n for (let key in context.list) {\n context.index = key\n let item = items.shift()\n if (!item) { // more properties than rendered items\n let clone = this.applyTemplate(context)\n context.element.appendChild(clone)\n continue\n }\n if (item.getAttribute[attribute+'-key']!=key) { \n // next item doesn't match key\n items.unshift(item) // put item back for next cycle\n let outOfOrderItem = context.element.querySelector(':scope > ['+attribute+'-key=\"'+key+'\"]') //FIXME: escape key\n if (!outOfOrderItem) {\n let clone = this.applyTemplate(context)\n context.element.insertBefore(clone, item)\n continue // new template doesn't need replacement, so continue \n } else {\n context.element.insertBefore(outOfOrderItem, item)\n item = outOfOrderItem // check needsreplacement next\n items = items.filter(i => i!=outOfOrderItem)\n }\n }\n let newTemplate = this.findTemplate(context.templates, context.list[context.index])\n if (newTemplate != item[Symbol.bindTemplate]){\n let clone = this.applyTemplate(context)\n context.element.replaceChild(clone, item)\n }\n }\n // clean up remaining items\n while (items.length) {\n let item = items.shift()\n item.remove()\n }\n}\n\n/**\n * renders the contents of an html element by rendering\n * a matching template, once.\n */\nexport function fieldByTemplates(context)\n{\n const rendered = context.element.querySelector(':scope > :not(template)')\n const template = this.findTemplate(context.templates, context.value)\n context.parent = getParentPath(context.element)\n if (rendered) {\n if (template) {\n if (rendered?.[Symbol.bindTemplate] != template) {\n const clone = this.applyTemplate(context)\n context.element.replaceChild(clone, rendered)\n }\n } else {\n context.element.removeChild(rendered)\n }\n } else if (template) {\n const clone = this.applyTemplate(context)\n context.element.appendChild(clone)\n }\n}\n\nfunction getParentPath(el, attribute)\n{\n const parentEl = el.parentElement?.closest(`[${attribute}-list],[${attribute}-map]`)\n if (!parentEl) {\n return ''\n }\n if (parentEl.hasAttribute(`${attribute}-list`)) {\n return parentEl.getAttribute(`${attribute}-list`)+'.'\n }\n return parentEl.getAttribute(`${attribute}-map`)+'.'\n}\n\n/**\n * renders a single input type\n * for radio/checkbox inputs it only sets the checked attribute to true/false\n * if the value attribute matches the current value\n * for other inputs the value attribute is updated\n */\nexport function input(context)\n{\n const el = context.element\n let value = context.value\n\n element(context)\n if (typeof value == 'undefined') {\n value = ''\n }\n if (el.type=='checkbox' || el.type=='radio') {\n if (matchValue(el.value, value)) {\n el.checked = true\n } else {\n el.checked = false\n }\n } else if (!matchValue(el.value, value)) {\n el.value = ''+value\n }\n}\n\n/**\n * Sets the value of the button, doesn't touch the innerHTML\n */\nexport function button(context)\n{\n element(context)\n setProperties(context.element, context.value, 'value')\n}\n\n/**\n * Sets the selected attribute of select options\n */\nexport function select(context)\n{\n const el = context.element\n let value = context.value\n\n if (value === null) {\n value = ''\n }\n if (typeof value!='object') {\n if (el.multiple) {\n if (Array.isArray(value)) { //FIXME: cannot be true, since typeof != 'object'\n for (let option of el.options) {\n if (value.indexOf(option.value)===false) {\n option.selected = false\n } else {\n option.selected = true\n }\n }\n }\n } else {\n let option = el.options.find(o => matchValue(o.value,value))\n if (option) {\n option.selected = true\n option.setAttribute('selected', true)\n }\n }\n } else { // value is a non-null object\n if (value.options) {\n setSelectOptions(el, value.options)\n }\n if (value.selected) {\n select(Object.asssign({}, context, {value:value.selected}))\n }\n setProperties(el, value, 'name', 'id', 'selectedIndex', 'className') // allow innerHTML? if so call element instead\n }\n}\n\n/**\n * adds a single option to a select element. The option.text property is optional, if not set option.value is used.\n * @param select The select element\n * @param option An option descriptor, either a string, object with {text,value,defaultSelected,selected} properties or an Option object\n */\nexport function addOption(select, option)\n{\n if (!option) {\n return\n }\n if (typeof option !== 'object') {\n select.options.add(new Option(''+option))\n } else if (option.text) {\n select.options.add(new Option(option.text, option.value, option.defaultSelected, option.selected))\n } else if (typeof option.value != 'undefined') {\n select.options.add(new Option(''+option.value, option.value, option.defaultSelected, option.selected))\n }\n}\n\n/**\n * This function clears all existing options of a select element, and adds the specified options.\n */\nexport function setSelectOptions(select,options)\n{\n //@TODO: only update in case of changes?\n select.innerHTML = ''\n if (Array.isArray(options)) {\n for (const option of options) {\n addOption(select, option)\n }\n } else if (options && typeof options == 'object') {\n for (const option in options) {\n addOption(select, { text: options[option], value: option })\n }\n }\n}\n\n/**\n * Sets the innerHTML and href, id, title, target, name, newwindow, nofollow attributes of an anchor\n */\nexport function anchor(context)\n{\n element(context)\n setProperties(context.element, context.value, 'target', 'href', 'name', 'newwindow', 'nofollow')\n}\n\n/**\n * Sets the title, id, alt and src attributes of an image.\n */\nexport function image(context)\n{\n setProperties(context.element, context.value, 'title', 'alt', 'src', 'id')\n}\n\n/**\n * Sets the title, id and src attribute of an iframe\n */\nexport function iframe(context)\n{\n setProperties(context.element, context.value, 'title', 'src', 'id')\n}\n\n/**\n * Sets the content and id attribute of a meta element\n */\nexport function meta(context)\n{\n setProperties(context.element, context.value, 'content', 'id') \n}\n\n/**\n * sets the innerHTML and title and id properties of any HTML element\n */\nexport function element(context)\n{\n const el = context.element\n let value = context.value\n\n if (typeof value=='undefined' || value==null) {\n value = ''\n }\n let strValue = ''+value\n if (typeof value!='object' || strValue.substring(0,8)!='[object ') {\n el.innerHTML = strValue\n return\n }\n setProperties(el, value, 'innerHTML', 'title', 'id', 'className')\n}\n\n/**\n * Sets a list of properties on a dom element, equal to \n * the string value of a data object\n * only updates the dom element if the property doesn't match\n */\nexport function setProperties(el, data, ...properties) {\n if (!data || typeof data!=='object') {\n return\n }\n for (const property of properties) {\n if (typeof data[property] === 'undefined') {\n continue\n }\n if (matchValue(el[property], data[property])) {\n continue\n }\n if (data[property] === null) {\n el[property] = ''\n } else {\n el[property] = ''+data[property]\n }\n }\n}\n\n/**\n * Returns true if a matches b, either by having the\n * same string value, or matching string :empty against a falsy value\n */\nexport function matchValue(a,b)\n{\n if (a==':empty' && !b) {\n return true\n }\n if (b==':empty' && !a) {\n return true\n }\n if (''+a == ''+b) {\n return true\n }\n return false\n}\n", "import { throttledEffect, destroy } from './state.mjs'\nimport { escape_html, fixed_content } from './bind.transformers.mjs'\nimport * as render from './bind.render.mjs'\n\nif (!Symbol.bindTemplate) {\n Symbol.bindTemplate = Symbol('bindTemplate')\n}\n\n/**\n * Implements one way databinding, updating dom elements with matching attributes\n * to changes in signals (see state.mjs)\n * \n * @class\n */\nclass SimplyBind\n{\n \n /**\n * @param Object options - a set of options for this instance, options may include:\n * - root (signal) (required) - the root data object that contains al signals that can be bound\n * - container (HTMLElement) - the dom element to use as the root for all bindings\n * - attribute (string) - the prefix for the field, list and map attributes, e.g. 'data-bind'\n * - transformers (object name:function) - a map of transformer names and functions\n * - render (object with field, list and map properties)\n */\n constructor(options)\n {\n /**\n * A map of HTMLElements and the data bindings on each, in the form of \n * the connectedSignal returned by the (throttled)Effect.\n * @type {Map}\n * @public\n */\n this.bindings = new Map()\n\n const defaultTransformers = {\n escape_html,\n fixed_content\n }\n const defaultOptions = {\n container: document.body,\n attribute: 'data-flow',\n transformers: defaultTransformers,\n render: {\n field: [render.field],\n list: [render.list],\n map: [render.map]\n },\n renderers: {\n 'INPUT':render.input,\n 'BUTTON':render.button,\n 'SELECT':render.select,\n 'A':render.anchor,\n 'IMG':render.image,\n 'IFRAME':render.iframe,\n 'META':render.meta,\n 'TEMPLATE':null,\n '*':render.element\n }\n }\n if (!options?.root) {\n throw new Error('bind needs at least options.root set')\n }\n this.options = Object.assign({}, defaultOptions, options)\n if (options.transformers) {\n this.options.transformers = Object.assign({}, defaultTransformers, options?.transformers)\n }\n const attribute = this.options.attribute\n const bindAttributes = [attribute+'-field',attribute+'-list',attribute+'-map']\n const transformAttribute = attribute+'-transform'\n\n const getBindingAttribute = (el) => {\n const foundAttribute = bindAttributes.find(attr => el.hasAttribute(attr))\n if (!foundAttribute) {\n console.error('No matching attribute found',el,bindAttributes)\n }\n return foundAttribute\n }\n\n // sets up the effect that updates the element if its\n // data binding value changes\n const renderElement = (el) => {\n this.bindings.set(el, throttledEffect(() => {\n if (!el.isConnected) {\n // el is no longer part of this document\n untrack(el, this.getBindingPath(el))\n destroy(this.bindings.get(el))\n // doing this here instead of in a mutationobserver\n // allows an element to be temporary removed and then inserted\n // without the binding having to be reset\n return\n }\n let context = {\n templates: el.querySelectorAll(':scope > template'),\n attribute: getBindingAttribute(el)\n }\n context.path = this.getBindingPath(el)\n context.value = getValueByPath(this.options.root, context.path)\n context.element = el\n track(el, context)\n runTransformers(context)\n }, 50))\n }\n\n // finds and runs applicable transformers\n // creates a stack of transformers, calls the topmost\n // each transformer can opt to call the next or not\n // transformers should return the context object (possibly altered)\n const runTransformers = (context) => {\n let transformers\n switch(context.attribute) {\n case this.options.attribute+'-field':\n transformers = Array.from(this.options.render.field)\n break\n case this.options.attribute+'-list':\n transformers = Array.from(this.options.render.list)\n break\n case this.options.attribute+'-map':\n transformers = Array.from(this.options.render.map)\n break\n default:\n throw new Error('no valid context attribute specified',context)\n break\n }\n if (context.element.hasAttribute(transformAttribute)) {\n context.element.getAttribute(transformAttribute)\n .split(' ').filter(Boolean)\n .forEach(t => {\n if (this.options.transformers[t]) {\n transformers.push(this.options.transformers[t])\n } else {\n console.warn('No transformer with name '+t+' configured', {cause:context.element})\n }\n })\n }\n let next\n for (let transformer of transformers) {\n next = ((next, transformer) => {\n return (context) => {\n return transformer.call(this, context, next)\n }\n })(next, transformer)\n }\n next(context)\n }\n\n // given a set of elements with data bind attribute\n // this renders each of those elements\n const applyBindings = (bindings) => {\n for (let bindingEl of bindings) {\n if (!this.bindings.get(bindingEl)) { // bindingEl may have moved from somewhere else in this document\n renderElement(bindingEl)\n }\n }\n }\n\n // this handles the mutation observer changes\n // if any element is added, and has a data bind attribute\n // it applies that data binding\n const updateBindings = (changes) => {\n const selector = `[${attribute}-field],[${attribute}-list],[${attribute}-map]`\n for (const change of changes) {\n if (change.type==\"childList\" && change.addedNodes) {\n for (let node of change.addedNodes) {\n if (node instanceof HTMLElement) {\n let bindings = Array.from(node.querySelectorAll(selector))\n if (node.matches(selector)) {\n bindings.unshift(node)\n }\n if (bindings.length) {\n applyBindings(bindings)\n }\n }\n }\n }\n }\n }\n\n // this responds to elements getting added to the dom\n // and if any have data bind attributes, it applies those bindings\n this.observer = new MutationObserver((changes) => {\n updateBindings(changes)\n })\n\n this.observer.observe(this.options.container, {\n subtree: true,\n childList: true\n })\n\n // this finds elements with data binding attributes and applies those bindings\n // must come after setting up the observer, or included templates\n // won't trigger their own bindings\n const bindings = this.options.container.querySelectorAll(\n ':is(['+this.options.attribute+'-field]'+\n ',['+this.options.attribute+'-list]'+\n ',['+this.options.attribute+'-map]):not(template)'\n )\n if (bindings.length) {\n applyBindings(bindings)\n }\n\n }\n\n /**\n * Finds the first matching template and creates a new DocumentFragment\n * with the correct data bind attributes in it (prepends the current path)\n * @param Context context\n * @return DocumentFragment\n */\n applyTemplate(context)\n {\n const path = context.path\n const parent = context.parent\n const templates = context.templates\n const list = context.list\n const index = context.index\n const value = list ? list[index] : context.value\n\n let template = this.findTemplate(templates, value)\n if (!template) {\n let result = new DocumentFragment()\n result.innerHTML = '<!-- no matching template -->'\n return result\n }\n let clone = template.content.cloneNode(true)\n if (!clone.children?.length) {\n return clone\n }\n if (clone.children.length>1) {\n throw new Error('template must contain a single root node', { cause: template })\n }\n const attribute = this.options.attribute\n\n const attributes = [attribute+'-field',attribute+'-list',attribute+'-map']\n const bindings = clone.querySelectorAll(`[${attribute}-field],[${attribute}-list],[${attribute}-map]`)\n for (let binding of bindings) {\n if (binding.tagName=='TEMPLATE') {\n continue\n }\n const attr = attributes.find(attr => binding.hasAttribute(attr))\n let bind = binding.getAttribute(attr)\n bind = this.applyLinks(template.links, bind)\n if (bind.substring(0, ':root.'.length)==':root.') {\n binding.setAttribute(attr, bind.substring(':root.'.length))\n } else if (bind==':value' && index!=null) {\n binding.setAttribute(attr, path+'.'+index)\n } else if (index!=null) {\n binding.setAttribute(attr, path+'.'+index+'.'+bind)\n } else {\n binding.setAttribute(attr, parent+bind)\n }\n }\n if (typeof index !== 'undefined') {\n clone.children[0].setAttribute(attribute+'-key',index)\n }\n // keep track of the used template, so if that changes, the item can be updated\n clone.children[0][Symbol.bindTemplate] = template\n\n // return clone, not the firstChild, so that all whitespace is cloned as well\n return clone\n }\n\n parseLinks(links)\n {\n let result = {}\n links = links.split(';').map(link => link.trim())\n for (let link of links) {\n link = link.split('=')\n result[link[0].trim()] = link[1].trim()\n }\n return result\n }\n\n applyLinks(links, value)\n {\n for (let link in links) {\n if (value.startsWith(link+'.')) {\n return links[link] + value.substr(link.length)\n } else if (value==link) {\n return links[link]\n }\n }\n return value\n }\n\n /**\n * Returns the path referenced in either the field, list or map attribute\n * @param HTMLElement el\n * @return string The path referenced, or void\n */\n getBindingPath(el)\n {\n const attributes = [\n this.options.attribute+'-field', \n this.options.attribute+'-list',\n this.options.attribute+'-map'\n ]\n for (let attr of attributes) {\n if (el.hasAttribute(attr)) {\n return el.getAttribute(attr)\n }\n }\n }\n\n /**\n * Finds the first template from an array of templates that\n * matches the given value. \n */\n findTemplate(templates, value)\n {\n const templateMatches = t => {\n // find the value to match against (e.g. data-bind=\"foo\")\n let path = this.getBindingPath(t)\n let currentItem\n if (path) {\n if (path.substr(0,6)==':root.') {\n currentItem = getValueByPath(this.options.root, path)\n } else {\n currentItem = getValueByPath(value, path)\n }\n } else {\n currentItem = value\n }\n\n // then check the value against pattern, if set (e.g. data-bind-match=\"bar\")\n const strItem = ''+currentItem\n let matches = t.getAttribute(this.options.attribute+'-match')\n if (matches) {\n if (matches===':empty' && !currentItem) {\n return t\n } else if (matches===':notempty' && currentItem) {\n return t\n }\n if (strItem.match(matches)) {\n return t\n }\n }\n if (!matches && currentItem!==null && currentItem!==undefined) {\n //FIXME: this doesn't run templates in lists where list entry is null\n //which messes up the count\n //\n // no data-bind-match is set, so return this template\n return t\n }\n }\n let template = Array.from(templates).find(templateMatches)\n let links = null\n if (template?.hasAttribute(this.options.attribute+'-link')) {\n links = this.parseLinks(template.getAttribute(this.options.attribute+'-link'))\n }\n let rel = template?.getAttribute('rel')\n if (rel) {\n let replacement = document.querySelector('template#'+rel)\n if (!replacement) {\n throw new Error('Could not find template with id '+rel)\n }\n template = replacement\n }\n if (template) {\n template.links = links\n }\n return template\n }\n\n destroy()\n {\n this.bindings.forEach(binding => {\n destroy(binding)\n })\n this.bindings = new Map()\n this.observer.disconnect()\n }\n\n}\n\n/**\n * Returns a new instance of SimplyBind. This is the normal start\n * of a data bind flow\n */\nexport function bind(options)\n{\n return new SimplyBind(options)\n}\n\nconst tracking = new Map()\n\nexport function trace(path)\n{\n return tracking.get(path)\n}\n\nfunction track(el, context) {\n if (!tracking.has(context.path)) {\n tracking.set(context.path, [context])\n } else {\n tracking.get(context.path).push(context)\n }\n}\n\nfunction untrack(el, path) {\n let list = tracking.get(path)\n if (list) {\n list = list.filter(context => context.element == el)\n tracking.set(path, list)\n }\n}\n\n\n/**\n * Returns the value by walking the given path as a json pointer, starting at root\n * if you have a property with a '.' in its name urlencode the '.', e.g: %46\n * \n * @param HTMLElement root\n * @param string path e.g. 'foo.bar'\n * @return mixed the value found by walking the path from the root object or undefined\n */\nexport function getValueByPath(root, path)\n{\n let parts = path.split('.')\n let curr = root\n let part\n part = parts.shift()\n while (part && curr) {\n part = decodeURIComponent(part)\n curr = curr[part]\n part = parts.shift()\n }\n return curr\n}\n", "import {signal, effect, throttledEffect, batch} from './state.mjs'\n\n/**\n * This class implements a pluggable data model, where you can\n * add effects that are run only when either an option for that\n * effect changes, or when an effect earlier in the chain of\n * effects changes.\n */\nclass SimplyFlowModel {\n\n\t/**\n\t * Creates a new datamodel, with a state property that contains\n\t * all the data passed to this constructor\n\t * @param state\tObject with all the data for this model\n\t * @throws Error if state is not set\n\t */\n\tconstructor(state) {\n\t\tif (!state) {\n\t\t\tthrow new Error('no options set')\n\t\t}\n\t\tif (state.data==null || typeof state.data[Symbol.iterator] !== 'function') {\n\t\t\tconsole.warn('SimplyFlowModel: options.data is not iterable')\n\t\t}\n\t\tthis.state = signal(state)\n\t\tif (!this.state.options) {\n\t\t\tthis.state.options = {}\n\t\t}\n\t\tthis.effects = [{current:this.state.data}]\n\t\tthis.view = this.state.data\n\t}\n\n\t/**\n\t * Adds an effect to run whenever a signal it depends on\n\t * changes. this.state is the usual signal.\n\t * The `fn` function param is not itself an effect, but must return\n\t * and effect function. `fn` takes one param, which is the data signal.\n\t * This signal will always have at least a `current` property.\n\t * The result of the effect function is pushed on to the this.effects\n\t * list. And the last effect added is set as this.view\n\t */\n\taddEffect(fn) {\n\t\tif (!fn || typeof fn !=='function') {\n\t\t\tthrow new Error('addEffect requires an effect function as its parameter', { cause: fn })\n\t\t}\n\t\tconst dataSignal = this.effects[this.effects.length-1]\n\t\tconst connectedSignal = fn.call(this, dataSignal)\n\t\tif (!connectedSignal || !connectedSignal[Symbol.Signal]) {\n\t\t\tthrow new Error('addEffect function parameter must return a Signal', { cause: fn })\n\t\t}\n\t\tthis.view = connectedSignal\n\t\tthis.effects.push(this.view)\n\t}\n}\n\nexport function model(options) {\n\treturn new SimplyFlowModel(options)\n}\n\n/**\n * Returns a function for model.addEffect that sorts the input data\n * \n * Options:\n * - direction (string) default 'asc' - change to 'desc' to sort in descending order\n * - sortBy (string) (optional) - used by the default sorting function to select the property to sort on\n * - sortFn (function) (required - set by default) - the sort function to use\n */\nexport function sort(options={}) {\n\treturn function(data) {\n\t\t// initialize the sort options, only gets called once\n\t\tthis.state.options.sort = Object.assign({\n\t\t\tdirection: 'asc',\n\t\t\tsortBy: null,\n\t\t\tsortFn: ((a,b) => {\n\t\t\t\tconst sort = this.state.options.sort\n\t\t\t\tconst sortBy = sort.sortBy\n\t\t\t\tif (!sort.sortBy) {\n\t\t\t\t\treturn 0\n\t\t\t\t}\n\t\t\t\tconst larger = sort.direction == 'asc' ? 1 : -1\n\t\t\t\tconst smaller = sort.direction == 'asc' ? -1 : 1\n\t\t\t\tif (typeof a?.[sortBy] === 'undefined') {\n\t\t\t\t\tif (typeof b?.[sortBy] === 'undefined') {\n\t\t\t\t\t\treturn 0\n\t\t\t\t\t}\n\t\t\t\t\treturn larger\n\t\t\t\t}\n\t\t\t\tif (typeof b?.[sortBy] === 'undefined') {\n\t\t\t\t\treturn smaller\n\t\t\t\t}\n\t\t\t\tif (a[sortBy]<b[sortBy]) {\n\t\t\t\t\treturn smaller\n\t\t\t\t} else if (a[sortBy]>b[sortBy]) {\n\t\t\t\t\treturn larger\n\t\t\t\t} else {\n\t\t\t\t\treturn 0\n\t\t\t\t}\n\t\t\t})\n\t\t}, options);\n\t\t// then return the effect, which is called when\n\t\t// either the data or the sort options change\n\t\treturn throttledEffect(() => {\n\t\t\tconst sort = this.state.options.sort\n\t\t\tif (sort?.sortBy && sort?.direction) {\n\t\t\t\treturn data.current.toSorted(sort?.sortFn)\n\t\t\t}\n\t\t\treturn data.current\n\t\t}, 50)\n\t}\n}\n\n/**\n * Returns a function for model.addEffect that implements paging\n * for the input data. It will return a slice of the data matching\n * the page and pageSize options.\n * \n * Options:\n * - page (int) default 1 - which page to show, starts at 1\n * - pageSize (int) default 20 - how many items in a single page\n * - max (int) (calculated) - how many pages in total\n */\nexport function paging(options={}) {\n\treturn function(data) {\n\t\t// initialize the paging options\n\t\tthis.state.options.paging = Object.assign({\n\t\t\tpage: 1,\n\t\t\tpageSize: 20,\n\t\t\tmax: 1\n\t\t}, options)\n\t\treturn throttledEffect(() => {\n\t\t\treturn batch(() => {\n\t\t\t\tconst paging = this.state.options.paging\n\t\t\t\tif (!paging.pageSize) {\n\t\t\t\t\tpaging.pageSize = 20\n\t\t\t\t}\n\t\t\t\tpaging.max = Math.ceil(this.state.data.length / paging.pageSize)\n\t\t\t\tpaging.page = Math.max(1, Math.min(paging.max, paging.page))\n\n\t\t\t\tconst start = (paging.page-1) * paging.pageSize\n\t\t\t\tconst end = start + paging.pageSize\n\t\t\t\treturn data.current.slice(start, end)\n\t\t\t})\n\t\t}, 50)\n\t}\n}\n\n/**\n * Returns a function for model.addEffect that filters rows from the data,\n * using a custom filter function `options.matches`\n * \n * Options:\n * - name (string) (required) - the name of this filter, must be unique\n * - matches (function) (required) - the filter function to apply to the data\n * - enabled (bool) (required) - filter is applied only when enabled is set to true\n */\nexport function filter(options) {\n\tif (!options?.name || typeof options.name!=='string') {\n\t\tthrow new Error('filter requires options.name to be a string')\n\t}\n\tif (!options.matches || typeof options.matches!=='function') {\n\t\tthrow new Error('filter requires options.matches to be a function')\n\t}\n\treturn function(data) {\n\t\tif (this.state.options[options.name]) {\n\t\t\tthrow new Error('a filter with this name already exists on this model')\n\t\t}\n\t\tthis.state.options[options.name] = options\n\t\treturn throttledEffect(() => {\n\t\t\tif (this.state.options[options.name].enabled) {\n\t\t\t\treturn data.current.filter(this.state.options[options.name].matches.bind(this))\n\t\t\t}\n\t\t\treturn data.current\n\t\t}, 50)\n\t}\n}\n\n/**\n * Returns a function for model.addEffect that filters the data to only contain\n * columns (properties) that aren't hidden. Automatically runs again if any columns\n * hidden property changes.\n * \n * Options:\n * - columns (object) (required) - an object with properties describing each column. Each \n * property must be an object with an optional `hidden` property. If set to a truthy value,\n * and property in the dataset with the same name, will be filtered out.\n */\nexport function columns(options={}) {\n\tif (!options\n\t\t|| typeof options!=='object'\n\t\t|| Object.keys(options).length===0) {\n\t\tthrow new Error('columns requires options to be an object with at least one property')\n\t}\n\treturn function(data) {\n\t\tthis.state.options.columns = options\n\t\treturn throttledEffect(() => {\n\t\t\treturn data.current.map(input => {\n\t\t\t\tlet result = {}\n\t\t\t\tfor (let key of Object.keys(this.state.options.columns)) {\n\t\t\t\t\tif (!this.state.options.columns[key]?.hidden) {\n\t\t\t\t\t\tresult[key] = input[key]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn result\n\t\t\t})\n\t\t}, 50)\n\t}\n}\n\n/**\n * Returns a function for use with model.addEffect, with the given options set\n * as model.options.scroll. The effect will return a slice of the input data, which\n * makes it easy to render just a part (slice) of the whole data.\n * \n * Options are:\n * - offset (int) default 0 (optional) - the offset in the data to start the slice\n * - rowCount (int) default 20 (optional / calculated) - the number of rows in the slice\n * - rowHeight (int) default 26 (optional) - the height of a single row in pixels\n * - itemsPerRow (int) default 1 (optional) - the number of items on a single row\n * - size (int) default data.current.length (calculated) - how many rows inside data.current before slicing\n * - scrollbar (HTMLElement) defualt null (optional) - if set, an effect is added to update this elements \n * \t height if data.current.length changes\n * - container (HTMLElement) default null (optional) - if set, a scroll listener is added to this element, \n * which will update the options.offset signal and trigger the slice effect. It will also set the rowCount.\n */\nexport function scroll(options) {\n\n\treturn function(data) {\n\t\tthis.state.options.scroll = Object.assign({\n\t\t\toffset: 0,\n\t\t\trowHeight: 26,\n\t\t\trowCount: 20,\n\t\t\titemsPerRow: 1,\n\t\t\tsize: data.current.length\n\t\t}, options)\n\t\tconst scrollOptions = this.state.options.scroll\n\n\t\tconst scrollbar = scrollOptions.scrollbar \n\t\t\t|| scrollOptions.container?.querySelector('[data-flow-scrollbar]')\n\t\tif (scrollbar) {\n\t\t\tif (scrollOptions.container) {\n\t\t\t\tscrollOptions.container.addEventListener('scroll', (evt) => {\n\t\t\t\t\tscrollOptions.offset = Math.floor(scrollOptions.container.scrollTop\n\t\t\t\t\t\t/ (scrollOptions.rowHeight*scrollOptions.itemsPerRow)\n\t\t\t\t\t)\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tthrottledEffect(() => {\n\t\t\t\tscrollOptions.size = data.current.length * scrollOptions.rowHeight\n\t\t\t\tscrollbar.style.height = scrollOptions.size + 'px'\n\t\t\t}, 50)\n\t\t}\n\n\t\treturn throttledEffect(() => {\n\t\t\tif (scrollOptions.container) {\n\t\t\t\t//TODO: add a resize listener so that if the size of the container\n\t\t\t\t// changes, the rowCount is calculated again\n\t\t\t\tscrollOptions.rowCount = Math.ceil(\n\t\t\t\t\tscrollOptions.container.getBoundingClientRect().height \n\t\t\t\t\t/ scrollOptions.rowHeight\n\t\t\t\t)\n\t\t\t}\n\t\t\tscrollOptions.data = data.current\n\t\t\tlet start = Math.min(scrollOptions.offset, data.current.length-1)\n\t\t\tlet end = start + scrollOptions.rowCount\n\t\t\tif (end > data.current.length) {\n\t\t\t\tend = data.current.length\n\t\t\t\tstart = end - scrollOptions.rowCount\n\t\t\t}\n\t\t\treturn data.current.slice(start, end)\n\t\t}, 50)\n\t}\n}", "export class SimplyRender extends HTMLElement \n{\n constructor()\n {\n super()\n }\n\n connectedCallback()\n {\n let templateId = this.getAttribute(\"rel\")\n let template = document.getElementById(templateId)\n\n if (template) {\n let content = template.content.cloneNode(true)\n for (const node of content.childNodes) {\n const clone = node.cloneNode(true)\n if (clone.nodeType == document.ELEMENT_NODE) {\n clone.querySelectorAll(\"template\").forEach(function(t) {\n t.setAttribute(\"simply-render\", \"\") //FIXME: whats this?\n })\n if (this.attributes) {\n for (const attr of this.attributes) {\n if (attr.name!='rel') {\n clone.setAttribute(attr.name, attr.value)\n }\n }\n }\n }\n this.parentNode.insertBefore(clone, this)\n }\n this.parentNode.removeChild(this)\n } else {\n const observe = () => {\n const observer = new MutationObserver(() => {\n template = document.getElementById(templateId)\n if (template) {\n observer.disconnect()\n this.replaceWith(this) // trigger connectedCallback?\n }\n })\n observer.observe(globalThis.document, {\n subtree: true,\n childList: true,\n })\n }\n\n observe()\n }\n }\n}\n\nif (!customElements.get('simply-render')) {\n customElements.define('simply-render', SimplyRender);\n}", "import { bind } from './bind.mjs'\nimport * as model from './model.mjs'\nimport * as state from './state.mjs'\nimport './render.mjs'\n\nif (!globalThis.simply) {\n\tglobalThis.simply = {}\n}\nObject.assign(globalThis.simply, {\n\tbind,\n\tflow: model,\n\tstate\n})\n\nexport default globalThis.simply"],
|
|
5
|
+
"mappings": "kGAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,EAAA,gBAAAC,EAAA,YAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,oBAAAC,EAAA,UAAAC,GAAA,cAAAC,KAAA,IAAMC,EAAU,OAAO,SAAS,EAC3B,OAAO,OACR,OAAO,KAAO,OAAO,MAAM,GAE1B,OAAO,SACR,OAAO,OAAS,OAAO,QAAQ,GAGnC,IAAMC,GAAgB,CAClB,IAAK,CAACC,EAAQC,EAAUC,IAAa,CACjC,GAAID,IAAW,OAAO,KAClB,OAAOD,EAEX,GAAIC,IAAW,OAAO,OAClB,MAAO,GAEX,IAAME,EAAQH,IAASC,CAAQ,EAE/B,OADAG,EAAUF,EAAUD,CAAQ,EACxB,OAAOE,GAAU,WACb,MAAM,QAAQH,CAAM,EACb,IAAIK,IAAS,CAChB,IAAI,EAAIL,EAAO,OAIXM,EAASH,E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SAASC,EAAG,CACnDA,EAAE,aAAa,gBAAiB,EAAE,CACtC,CAAC,EACG,KAAK,YACL,QAAWC,KAAQ,KAAK,WAChBA,EAAK,MAAM,OACXF,EAAM,aAAaE,EAAK,KAAMA,EAAK,KAAK,EAKxD,KAAK,WAAW,aAAaF,EAAO,IAAI,CAC5C,CACA,KAAK,WAAW,YAAY,IAAI,CACpC,MACoB,IAAM,CAClB,IAAMG,EAAW,IAAI,iBAAiB,IAAM,CACxCN,EAAW,SAAS,eAAeD,CAAU,EACzCC,IACAM,EAAS,WAAW,EACpB,KAAK,YAAY,IAAI,EAE7B,CAAC,EACDA,EAAS,QAAQ,WAAW,SAAU,CAClC,QAAS,GACT,UAAW,EACf,CAAC,CACL,GAEQ,CAEhB,CACJ,EAEK,eAAe,IAAI,eAAe,GACnC,eAAe,OAAO,gBAAiBR,CAAY,EC/ClD,WAAW,SACf,WAAW,OAAS,CAAC,GAEtB,OAAO,OAAO,WAAW,OAAQ,CAChC,KAAAS,GACA,KAAMC,EACN,MAAAC,CACD,CAAC,EAED,IAAOC,GAAQ,WAAW",
|
|
6
|
+
"names": ["state_exports", "__export", "batch", "clockEffect", "destroy", "effect", "signal", "throttledEffect", "trace", "untracked", "iterate", "signalHandler", "target", "property", "receiver", "value", "notifyGet", "args", "result", "notifySet", "makeContext", "s", "current", "signals", "descriptor", "v", "prop", "getListeners", "listener", "batchedListeners", "batchMode", "self", "context", "listeners", "change", "propListeners", "addContext", "currentEffect", "computeStack", "clearContext", "currentCompute", "setListeners", "listenersMap", "computeMap", "compute", "connectedSignals", "clearListeners", "effectStack", "effectMap", "signalStack", "fn", "f", "connectedSignal", "computeEffect", "runBatchedListeners", "copyBatchedListeners", "throttleTime", "throttled", "hasChange", "clock", "lastTick", "hasChanged", "remember", "escape_html", "context", "next", "content", "fixed_content", "field", "context", "fieldByTemplates", "renderer", "list", "arrayByTemplates", "map", "objectByTemplates", "attribute", "items", "lastKey", "skipped", "item", "currentKey", "bindings", "needsReplacement", "b", "databind", "newTemplate", "length", "key", "clone", "outOfOrderItem", "i", "rendered", "template", "getParentPath", "el", "parentEl", "input", "value", "element", "matchValue", "button", "setProperties", "select", "option", "o", "setSelectOptions", "addOption", "options", "anchor", "image", "iframe", "meta", "strValue", "data", "properties", "property", "a", "SimplyBind", "options", "defaultTransformers", "escape_html", "fixed_content", "defaultOptions", "field", "list", "map", "input", "button", "select", "anchor", "image", "iframe", "meta", "element", "attribute", "bindAttributes", "transformAttribute", "getBindingAttribute", "el", "foundAttribute", "attr", "renderElement", "throttledEffect", "untrack", "destroy", "context", "getValueByPath", "track", "runTransformers", "transformers", "t", "next", "transformer", "applyBindings", "bindings", "bindingEl", "updateBindings", "changes", "selector", "change", "node", "path", "parent", "templates", "index", "value", "template", "result", "clone", "attributes", "binding", "bind", "links", "link", "templateMatches", "currentItem", "strItem", "matches", "rel", "replacement", "tracking", "track", "el", "context", "tracking", "untrack", "path", "list", "getValueByPath", "root", "parts", "curr", "part", "model_exports", "__export", "columns", "filter", "model", "paging", "scroll", "sort", "SimplyFlowModel", "state", "signal", "fn", "dataSignal", "connectedSignal", "model", "options", "sort", "data", "a", "b", "sortBy", "larger", "smaller", "throttledEffect", "paging", "batch", "start", "end", "filter", "columns", "input", "result", "key", "scroll", "scrollOptions", "scrollbar", "evt", "SimplyRender", "templateId", "template", "content", "node", "clone", "t", "attr", "observer", "bind", "model_exports", "state_exports", "flow_default"]
|
|
7
7
|
}
|
package/package.json
CHANGED
package/src/flow.mjs
CHANGED
package/src/flow.mjs~
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { bind } from './bind.mjs'
|
|
2
|
+
import * as model from './model.mjs'
|
|
3
|
+
import * as state from './state.mjs'
|
|
4
|
+
|
|
5
|
+
if (!globalThis.simply) {
|
|
6
|
+
globalThis.simply = {}
|
|
7
|
+
}
|
|
8
|
+
Object.assign(globalThis.simply, {
|
|
9
|
+
bind,
|
|
10
|
+
flow: model,
|
|
11
|
+
state
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
export default globalThis.simply
|
package/src/model.mjs
CHANGED
|
@@ -12,14 +12,21 @@ class SimplyFlowModel {
|
|
|
12
12
|
* Creates a new datamodel, with a state property that contains
|
|
13
13
|
* all the data passed to this constructor
|
|
14
14
|
* @param state Object with all the data for this model
|
|
15
|
+
* @throws Error if state is not set
|
|
15
16
|
*/
|
|
16
17
|
constructor(state) {
|
|
18
|
+
if (!state) {
|
|
19
|
+
throw new Error('no options set')
|
|
20
|
+
}
|
|
21
|
+
if (state.data==null || typeof state.data[Symbol.iterator] !== 'function') {
|
|
22
|
+
console.warn('SimplyFlowModel: options.data is not iterable')
|
|
23
|
+
}
|
|
17
24
|
this.state = signal(state)
|
|
18
25
|
if (!this.state.options) {
|
|
19
26
|
this.state.options = {}
|
|
20
27
|
}
|
|
21
|
-
this.effects = [{current:state.data}]
|
|
22
|
-
this.view =
|
|
28
|
+
this.effects = [{current:this.state.data}]
|
|
29
|
+
this.view = this.state.data
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
/**
|
|
@@ -32,8 +39,15 @@ class SimplyFlowModel {
|
|
|
32
39
|
* list. And the last effect added is set as this.view
|
|
33
40
|
*/
|
|
34
41
|
addEffect(fn) {
|
|
42
|
+
if (!fn || typeof fn !=='function') {
|
|
43
|
+
throw new Error('addEffect requires an effect function as its parameter', { cause: fn })
|
|
44
|
+
}
|
|
35
45
|
const dataSignal = this.effects[this.effects.length-1]
|
|
36
|
-
|
|
46
|
+
const connectedSignal = fn.call(this, dataSignal)
|
|
47
|
+
if (!connectedSignal || !connectedSignal[Symbol.Signal]) {
|
|
48
|
+
throw new Error('addEffect function parameter must return a Signal', { cause: fn })
|
|
49
|
+
}
|
|
50
|
+
this.view = connectedSignal
|
|
37
51
|
this.effects.push(this.view)
|
|
38
52
|
}
|
|
39
53
|
}
|
|
@@ -136,6 +150,7 @@ export function paging(options={}) {
|
|
|
136
150
|
* Options:
|
|
137
151
|
* - name (string) (required) - the name of this filter, must be unique
|
|
138
152
|
* - matches (function) (required) - the filter function to apply to the data
|
|
153
|
+
* - enabled (bool) (required) - filter is applied only when enabled is set to true
|
|
139
154
|
*/
|
|
140
155
|
export function filter(options) {
|
|
141
156
|
if (!options?.name || typeof options.name!=='string') {
|
package/src/render.mjs
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export class SimplyRender extends HTMLElement
|
|
2
|
+
{
|
|
3
|
+
constructor()
|
|
4
|
+
{
|
|
5
|
+
super()
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
connectedCallback()
|
|
9
|
+
{
|
|
10
|
+
let templateId = this.getAttribute("rel")
|
|
11
|
+
let template = document.getElementById(templateId)
|
|
12
|
+
|
|
13
|
+
if (template) {
|
|
14
|
+
let content = template.content.cloneNode(true)
|
|
15
|
+
for (const node of content.childNodes) {
|
|
16
|
+
const clone = node.cloneNode(true)
|
|
17
|
+
if (clone.nodeType == document.ELEMENT_NODE) {
|
|
18
|
+
clone.querySelectorAll("template").forEach(function(t) {
|
|
19
|
+
t.setAttribute("simply-render", "") //FIXME: whats this?
|
|
20
|
+
})
|
|
21
|
+
if (this.attributes) {
|
|
22
|
+
for (const attr of this.attributes) {
|
|
23
|
+
if (attr.name!='rel') {
|
|
24
|
+
clone.setAttribute(attr.name, attr.value)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
this.parentNode.insertBefore(clone, this)
|
|
30
|
+
}
|
|
31
|
+
this.parentNode.removeChild(this)
|
|
32
|
+
} else {
|
|
33
|
+
const observe = () => {
|
|
34
|
+
const observer = new MutationObserver(() => {
|
|
35
|
+
template = document.getElementById(templateId)
|
|
36
|
+
if (template) {
|
|
37
|
+
observer.disconnect()
|
|
38
|
+
this.replaceWith(this) // trigger connectedCallback?
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
observer.observe(globalThis.document, {
|
|
42
|
+
subtree: true,
|
|
43
|
+
childList: true,
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
observe()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!customElements.get('simply-render')) {
|
|
53
|
+
customElements.define('simply-render', SimplyRender);
|
|
54
|
+
}
|