@nebularstreams/libmui 0.1.2 → 0.1.4
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/libui.cjs.js +1 -1
- package/dist/libui.cjs.js.map +1 -1
- package/dist/libui.esm.js +1 -1
- package/dist/libui.esm.js.map +1 -1
- package/package.json +1 -1
- package/rollup.config.js +2 -0
package/dist/libui.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"mithril";export{default as m}from"mithril";function t(e,t,a){const n=("function"==typeof e?e(t):e)||{};return a&&(n.initialParams=a),n}const a=({currentIndex:e},t)=>e===t,n={view:({attrs:t})=>e(`i.icon.${t.pack||"fas"}.fa-${t.icon||"cog"}${t.size?".fa-"+t.size+"x":""}`,{title:t.icontitle||void 0,role:"presentation",onclick:t.onclick||null,...t.iconClass&&{class:t.iconClass}})},i={view:({attrs:t,state:a,children:i})=>e(t.download||t.link?"a.button":"button",{...t.link&&{href:t.link},...t.download&&{download:t.download},...t.target&&{target:t.target},"aria-label":t["aria-label"]||t.title||t.text,title:t.title||t["aria-label"],class:(t.class||"")+(a.busy?" busy":""),...a.error&&{"data-error":a.error.message},...t.onclick&&{onclick:n=>{clearTimeout(a.debounce),a.debounce=setTimeout((()=>{const i=t.onclick(n,t);i&&i.then&&i.catch&&(a.busy=!0,e.redraw(),i.then((()=>{a.busy=!1,e.redraw()})).catch((t=>{a.busy=!1,a.error=t,e.redraw()})))}),25)}}},[...t.icon&&!t.right?[e(n,t)]:[],...t.text?[e("span.pad-1.pad-h",{class:t.textClass||null},t.text)]:[],...t.icon&&t.right?[e(n,t)]:[],...i])},l={view:({attrs:t,state:a,children:i})=>e(t.download||t.link?"a.button":"button",{...t.link&&{href:t.link},...t.download&&{rel:"nofollow",download:t.download},...t.target&&{target:t.target},"aria-label":t["aria-label"]||t.title||t.text,title:t.title||t["aria-label"],class:(t.class||"")+(a.busy?" busy":""),...a.error&&{"data-error":a.error.message},...t.onClick&&{onclick:n=>{clearTimeout(a.debounce),a.debounce=setTimeout((()=>{const i=t.onClick(n,t);i&&i.then&&i.catch&&(a.busy=!0,e.redraw(),i.then((()=>{a.busy=!1,e.redraw()})).catch((t=>{a.busy=!1,a.error=t,e.redraw()})))}),25)}}},[...t.icon&&!t.right?[e(n,t)]:[],...t.text?[e("span.pad-1.pad-h",{class:t.textClass||null},t.text)]:[],...t.icon&&t.right?[e(n,t)]:[],...i])},r={view:({attrs:t,children:a})=>e(".flexcol.flexcenter.al-center.grows.emptywidget",{...t.class&&{class:t.class},...t.key&&{key:t.key},role:"presentation"},[e(n,t),...t.message?[e(".marg-2.marg-v",{role:"status",class:t.size>4?"font-150":"font-100","aria-label":t.message},t.message.split("\n").map(((t,a,n)=>1===n.length?t:e("p.msg"+a,t))))]:[],...a?[e(".flexcol.additional",a)]:[]])},o=(t,a,n,i)=>{const l=a.currentIndex,r=a.currentParams;-1===n?Object.assign(a,{current:null,currentIndex:-1,currentParams:[]}):Object.assign(a,{current:t.items[n]||null,currentIndex:a.current?n:-1,currentParams:i||[]}),t.onSelected&&t.onSelected(a.current,a.currentParams,a.currentIndex!==l,r),e.redraw()},s={oninit:({attrs:e,state:t})=>{(t=e.state||t).setItem=(a,...n)=>o(e,e.state||t,a,n);const a=!isNaN(t.currentIndex)?t.currentIndex:e.selected,n=e.items&&e.items.length?void 0!==a&&e.items[a]?a:e.noinitial?-1:0:-1,i=-1!==n?e.items[n]:null;Object.assign(t,{currentIndex:n,current:i})},onupdate:({attrs:e,state:t})=>{(e.state||t).setItem=(a,...n)=>o(e,e.state||t,a,n)},view:({attrs:n,state:o})=>{o=n.state||o;const{current:s}=o;return e((n.element||"widget")+".selector"+(n.horizontal?".flexrow":".flexcol")+(n.className?"."+n.className:""),{...n.key&&{key:n.key},class:(o.current?"hascurrent":"empty")+(n.class?" "+n.class:"")},[...n.hideonly&&!(n.items.length>1)||n.hidesel?[]:[e("nav.toolbar.fullwidth"+(n.horizontal?".flexcol":".flexrow"),{"aria-label":n["aria-label"]||n.title||"selector",class:n.toolbarClass},n.items.map(((t,n)=>e(i,{class:(t.class?t.class+" ":"")+(a(o,n)?"accent":"nel"),icon:t.icon||null,...t.title&&{title:t.title},...t["aria-label"]&&{"aria-label":t["aria-label"]},...t.text&&{text:t.text},onclick:()=>{Date.now()-o.clickts<200||(o.clickts=Date.now(),o.bodyHidden=!1,o.setItem(n))}}))))],...s?[...n.toggle&&!o.bodyHidden?[e(l,{class:"selectornotch "+(o.bodyHidden?"bodyhidden":"bodyshown"),icon:o.bodyHidden?"caret-up":"caret-down",title:o.bodyHidden?"expand panel":"contract panel",onClick:()=>{o.bodyHidden=!o.bodyHidden,e.redraw()}})]:[],...n.toggle&&o.bodyHidden?[]:[e(".grows.flexcol.ohidden",{class:n.bodyClass,role:"presentation"},[e(s.widget,t(s.attrs,n,o.currentParams),s.children)])],...n.closeButton?[e(i,{class:"closebutton absolute toright",icon:"times",onclick:()=>{o.setItem(-1)},"aria-label":"close item"})]:[]]:e(r,n)])}},c={info:"info",error:"exclamation-triangle",success:"check"};const d=new function(t=5e3,a){let n,l=[];function r(){const o=a||document.getElementById("notification-container");if(l.length){const a=l.splice(0,1)[0];!function(t,a){e.render(t,e(i,{class:"notification "+a.type,text:a.text,icon:c[a.type]||"info",size:1,role:"status",onclick:r}))}(o,a),clearTimeout(n),n=setTimeout(r,a.timer||t)}else e.render(o,""),n=null}return{add:(e,t)=>{l.push({text:e,type:t}),n||r()},clear:()=>{l=[],r()}}};function u(e,t,a,n,i){return{...e&&{view:e},...t&&{oninit:t},...a&&{oncreate:a},...i&&{onupdate:i},...n&&{onremove:n}}}const m={};const p=u((({attrs:t,state:a,children:n})=>{const{nofold:i,cardid:r,size:o,title:s,action:c,collapsedAction:d,collapsedClass:u,expandedClass:p,cols:h,element:v,busy:g,expandedView:f,collapsedView:w,titleWidget:y,titleAttrs:b,titleClass:x,bodyClass:k,titleExpanded:M,titleCollapsed:C}=t,I=!i&&(r?!m[r]:!!a.collapsed),E=I?w?w(t,a):[]:f?f(t,a):n||[],L=y?e(y,b||{}):s?e("span.ellipsis.ohidden.unfold",s):void 0,T=g?"fa-sync":"fa-caret-down "+(I?"iscollapsed":"isexpanded");return E.length||!t.skipEmpty?e(v||"ul",{class:"cardie ohidden noshrink "+(h?"flexcol ":"flexrow wrap ")+(t.class?" "+t.class:"")+(i?" expanded":" "+(I?"collapsed "+(u||""):"expanded "+(p||"")))+(o?" marg-"+o:" marg-2")+(y?" withwidget":"")+(g?" busycard":"")},[...L?[e(".title.grows.fabf.flexrow.pointer.unfold",i?{class:x||"pad-2"}:{class:`${x||"pad-2"} ${T||""}`,title:I?C||"Click to expand the options":M||C||"Click to collapse the options",onclick:n=>{n.target.classList.contains("unfold")&&(n.shiftKey&&t.onShiftOpen?t.onShiftOpen():t.cardid?function(e,t=0){if(e){const[a,n]=e.split("-");t&&a&&n&&Object.keys(m).forEach((e=>{e.startsWith(a+"-")&&(m[e]=0)})),m[e]=t}}(r,I):a.collapsed=!a.collapsed,e.redraw())}},!c||!i&&I?d&&I?[e(l,d),L]:L:[e(l,c),L])]:[],...E.length?[e(".flexbreak"),e(".cardiebody.fadein-filter.grows",{class:(h?"flexcol ":"flexrow wrap")+" "+(k||"")},...E)]:[],...t.alwaysView?[t.alwaysView({attrs:t,state:a})]:[]]):[]}),(({attrs:e,state:t})=>{e.cardid||(t.collapsed=!e.nofold&&(e.cardid?!m[e.cardid]:!!e.collapsed))}),void 0,void 0,void 0),h=(e,t,a=!1)=>{if(a||"number"===e.type){const a=e.float?Number.parseFloat(t):Number.parseInt(t,10);return Number.isNaN(a)?void 0:a}return t},v=(e,t,a)=>{const n=t.hasOwnProperty("value")?t.value:e.value;return h(e,n,a)},g={view:t=>{const{attrs:a,state:n}=t;return n.attrs=a,e(".input-static.w-100.ellipsis",{class:(a.onDrag?"withdrag ":"")+(a.staticClass||"grows"),...a.staticTitle&&{title:a.staticTitle},...a.onDrag||{onclick:a.onClick},oncreate:({dom:e,state:n})=>{if(a.onDrag&&!a.readonly){const a=n.hammer=new Hammer.Manager(e,{touchAction:"pan-y"}),i=new Hammer.Pan({direction:Hammer.DIRECTION_VERTICAL}),l=new Hammer.Tap;a.add([i,l]),a.on("tap",(()=>t.state.attrs.onClick())),a.on("panup",(e=>t.state.attrs.onDrag(-1,e.srcEvent))),a.on("pandown",(e=>t.state.attrs.onDrag(1,e.srcEvent))),a.on("panend pancancel",(e=>t.state.attrs.onDrag(0,e.srcEvent)))}a.focus&&e.focus()},onremove:({state:e})=>{e.hammer&&e.hammer.destroy()}},a.value)}},f={view:({attrs:t,state:a})=>{const n=t=>{a.value&&a.showInput&&delete a.showInput,delete a.value,t&&e.redraw()};return e(".textfield.flexcol.relative",{class:(t.label?"witharia":"")+(t.containerClass?" "+t.containerClass:""),...t.label&&{"aria-label":t.label}},[!t.staticField||!t.readonly&&a.showInput?!a.multi&&!t.alwaysmulti||t.type&&"text"!==t.type?e("input.w-100",{...t.id&&{id:t.id},type:t.type||"text",...void 0!==t.max&&{max:t.max},...void 0!==t.min&&{min:t.min},...t.step>0&&{step:t.step},...t.maxlength&&{maxlength:t.maxlength},class:(t.class||"")+(t.validator?a.isValid?" bg-ok":" bg-error":""),...t.title&&{title:t.title},value:v(t,a),placeholder:t.hint||"",oninput:e=>{a.value=h(t,e.target.value),e.fromoninput=!0,t.validator&&(a.isValid=t.validator(a.value)),t.onchange&&(t.oninput||t.onchange)(a.value,e)},onchange:e=>{t.onchange&&(t.validator&&(a.isValid=t.validator(a.value)),e.enterPressed=a.enterPressed,delete a.enterPressed,t.onchange(h(t,e.target.value),e),t.staticField?n(!0):delete a.value)},onblur:()=>{a.showInput&&n(!0)},onkeyup:e=>{a.showInput&&("Escape"===e.key?n(!0):"Enter"===e.key&&(a.value!==t.value&&a.value||(t.onchange(t.value,e),n(!0))))},onkeypress:e=>{a.showInput||"Enter"!==e.key||t.onenter&&t.onenter(e.target.value,e)}}):e("textarea.w-100",{class:t.class,value:v(t,a),...t.title&&{title:t.title},placeholder:t.hint||"",oninput:e=>{a.value=h(t,e.target.value),t.validator&&(a.isValid=t.validator(a.value)),t.onchange&&(t.oninput||t.onchange)(a.value,e,!0)},onchange:e=>{if(t.onchange){t.validator&&(a.isValid=t.validator(a.value));const i=h(t,e.target.value);n(!1),t.onchange(i,e,!0)}},onblur:()=>{a.showInput&&n(!0)},onkeyup:e=>{"Escape"===e.key&&a.showInput&&n(!1)}}):e(g,{readonly:t.readonly,staticClass:(a.dragging?"accent ":"")+(t.staticClass||""),staticTitle:t.staticTitle||t.draginc&&"Click then drag up and down to modify value, or just click to enter a custom value",value:t.displayTitle||v(t,a),focus:t.focus,...t.draginc&&!t.readonly&&{onDrag:(n,i)=>{if(n){a.dragging=!0;let e=v(t,a,!0);if(Number.isNaN(e)||void 0===e)return;e+=n*t.draginc,void 0!==t.max&&e>t.max&&(e=t.max),void 0!==t.min&&e<t.min&&(e=t.min),a.value="number"===t.type?e:String(e),t.onchange(a.value,i)}else delete a.dragging,delete a.value,e.redraw()}},...t.readonly||{onClick:()=>{a.showInput=!0,a.value=t.value,e.redraw()}}}),e(".span.actions.absolute.right.bottom",[...!t.multi||t.alwaysmulti||t.type&&"text"!==t.type?[]:[e(l,{icon:a.multi?"angle-double-up":"angle-double-down",class:"pad-2 transp",onClick:()=>{a.multi=!a.multi,e.redraw()}})],...t.actions?t.actions.map((t=>e(l,{...t,class:"transp pad-2"}))):[],...t.action?[e(l,{...t.action,class:"transp pad-2"})]:[]])])},oninit:({attrs:e,state:t})=>{if(e.staticField&&e.draginc){const a=v(e,t,!0);t.showInput=Number.isNaN(a)||null==a}}},w=u((({attrs:t,children:a})=>a.length?e(".notice.cardie.flexcol.pad-3",{class:t.class||"marg-2 font-75"},e(".flexrow",[...t.icon?[e(n,t)]:[],e(".pad-2.pad-h",t.text)]),...a):e(".notice.cardie.flexrow.pad-3",{class:t.class||"marg-2 font-75",onclick:t.onClick},[...t.icon?[e(n,t)]:[],e(".pad-2.pad-h",t.text)]))),y=u((({attrs:t,state:a})=>e((t.unit||"")+".flexrow"+(t.subline?" withsubline":""),{class:t.class,text:t.text,title:t.title||null,onclick:()=>{a.checked=!a.checked,t.onchange&&t.onchange(a.checked),e.redraw()}},t.right?[...t.text?[e("span.grows.caption",t.subline?{"data-subline":t.subline}:{},t.text)]:[],e(n,{iconClass:"pad-2 pad-h",icon:a.checked?"toggle-on":"toggle-off"})]:[e(n,{iconClass:"pad-2 pad-h",icon:a.checked?"toggle-on":"toggle-off"}),...t.text?[e("span.grows.caption",t.subline?{"data-subline":t.subline}:{},t.text)]:[]])),(({attrs:e,state:t})=>{t.checked=t.original=e.checked}),null,null,(({attrs:t,state:a})=>{t.checked!==a.original&&(a.checked=a.original=t.checked,e.redraw())}));let b;function x(e){"function"==typeof b&&(b(),b=void 0),e.style.display="none",delete k.redraw}function k(t,a=!1,n=".modal-content"){const i=document.getElementById("modal-container");if(i.classList.toggle("iscustom",".modal-content"!==n),a&&(b=a,i.onclick=e=>{"modal-container"===e.target.id&&x(i)}),!t)return delete k.redraw,void(null===t?i.style.display="none":x(i));i.style.display="flex",k.redraw=()=>{e.render(i,e(n,{role:"alertdialog","aria-labelledby":"modaltitle","aria-modal":!0},["function"==typeof t?t():t]))},k.redraw()}function M(){const e=document.getElementById("modal-container");return"none"!==e.style.display&&(x(e),!0)}function C(t,a,n,l){return new Promise((r=>{function o(e){k(null);try{r(e)}catch(e){}}const s=((e,t)=>{const a=[];if(t)for(const e of Object.keys(t))t[e]&&a.push("."+e);return(e||"")+a.join("")})(".popup.flexcol",{".favlist":(l=l||{}).favlist,".isfav":t&&t.classList.contains("isfav"),".isplay":t&&t.classList.contains("selected")});k(e({view:()=>e(s,{onclick:e=>{if("INPUT"===e.target.nodeName)return;const n=e.target.getAttribute("data-action");n?o({domItem:t,item:a,action:n}):k(null)}},[...a.title?[e("h3",{id:"modaltitle"},a.title)]:[],...n.map((n=>"text"===n.type?e("input.action",{value:n.value||"",type:"text",placeholder:n.hint||"",oncreate:({dom:e})=>e.focus(),onkeyup:e=>{27===e.keyCode&&o({domItem:t,item:a,action:n})},onchange:e=>{e.target.blur(),o({domItem:t,item:a,action:n,value:e.target.value})}}):e(i,{...n,onclick:()=>o({domItem:t,item:a,action:n})},n.caption)))])}),!0)}))}const I=window.structuredClone?window.structuredClone:e=>JSON.parse(JSON.stringify(e));function E(e,t,a,n,i={}){setTimeout((()=>C(document.body,{title:e},[{type:"text",hint:a,value:t}]).then((({value:e})=>(i.refreshKey=String(Date.now()),n(e))))),100)}const L=[["Lights and Fog",null,["amblight","l0","l1","l2","l3","fog"],0],["Face and Accessories",null,["facekit"],1],["Particle settings",null,["particles"],2],["Video Segmentation","common",["segcam","mask","green"],3,!0],["Video Effects",null,["fxconfig"],9],["Video Plane","val",["xvideo","yvideo","zvideo","rvideo","svideo","video"],4],["Main Camera","val",["ypos","xpos","zoom","yaw","pitch","roll","ai"],5],["Drone Camera","val",["free"],6],["Followed Agent","val",["track"],10],["Game Camera","val",["orbit","track","ocam"],7,void 0,!0],["Transition Speed","val",["spd"],8]],T=u((({attrs:t})=>e("h2.marg-2.no-marg-bottom",t.title))),N=u((({attrs:t})=>{const{type:a="changes",meta:n,onInput:i,title:r,options:o}=t,s=n.title?.trim().length&&n.description?.trim().length,c=o&&o.embedded;return e(".flexcol.grows.ohidden.fadein",[...t.title?[e(T,{title:r})]:[],e(".flexrow.wrap.grows.pad-3.propsgroup.scrolly",[...t.notice?[e(w,{class:"marg-1 marg-v withbottommargin font-75 col-12",size:1,icon:"info-circle",text:t.notice})]:[],e(".witharia.col-12.pad-1.pad-v",{"aria-label":a+" name"},e(f,{class:"pad-2 pad-xh "+(s?"valid":"invalid"),value:n.title,maxlength:64,onchange:t=>{n.title=t,e.redraw()}})),...c?[]:[e(".col-12.witharia.pad-1.pad-v",{"aria-label":"description"},e(f,{class:"pad-2 pad-xh "+(n.description?"valid":"invalid"),value:n.description,maxlength:240,multi:!0,alwaysmulti:!0,onchange:t=>{n.description=t,e.redraw()}})),e(".col-8.witharia.pad-1.pad-v",{"aria-label":"tags"},e(f,{class:"pad-2 pad-xh",value:n.tags,maxlength:128,onchange:e=>{n.tags=e.toLowerCase().split(" ").join(",").split(",").filter((e=>e.length)).join(",")}})),e(".col-4.witharia.pad-1.pad-v",{"aria-label":"youtube video"},e(f,{class:"pad-2 pad-xh",value:n.ytref||"",hint:"YouTube ID",maxlength:16,onchange:e=>{(e=e.trim())?-1===e.indexOf(" ")&&(n.ytref=e.trim()):delete n.ytref}}))],e(".col-4.witharia.pad-1.pad-v",{"aria-label":"content attribution"},e(f,{class:"pad-2 pad-xh",value:n.author,hint:"author name",maxlength:128,onchange:e=>{n.author=e}})),e(".col-4.witharia.pad-1.pad-v",{"aria-label":"license or author link"},e(f,{class:"pad-2 pad-xh",hint:"https://...",value:n.link,maxlength:128,onchange:e=>{n.link=e}})),e(".col-4.witharia.pad-1.pad-v",{"aria-label":"source domain"},e(f,{class:"pad-2 pad-xh",value:n.source,hint:"example.com",maxlength:128,onchange:e=>{n.source=e}})),e(".col-12.al-right.marg-2.marg-v",e(l,{class:"noshrink accentbutton unitheightsmall col-4",text:"save "+a,onClick:()=>{n.title?.trim().length&&(c||n.description?.trim().length)?(k(null),i(n)):d.add("Information is incomplete or invalid")}}))])])})),D=u((({attrs:t})=>{const{parameters:a,preset:n,presetComponents:i,types:r,globalData:o,fetcher:s}=t,c=[],u=[],m=r?L:L.filter((e=>{const[,t,i,l,r]=e,s=t?n[t]:n,d=r?o:a,m=t?d[t]:d;let p=!1;if(i.length){for(const e of i)s&&void 0!==s[e]&&(p=c[l]=!0),void 0!==m[e]&&(p=u[l]=!0);return p}return p=!0,u[l]=!!m,c[l]=!!s,p}));return e("ul.flexrow.wrap.userdialog",m.length?m.map((m=>{const[p,h,v,g,f,w]=m,b=r?void 0:h?n[h]:n,x=f?o:a,k=r?void 0:h?x[h]:x,M=r||c[g],C=u[g];return[...i?[e(y,{title:`Include ${m[0]} in snapshots`,class:"grows unitheightsmall"+(i[g]?" accent":""),checked:!!i[g],onchange:a=>{i[g]=!i[g],e.redraw(),t.redraw&&t.redraw()}}),e(".grows",{class:M?"avail":"unavail"},p)]:[],...t.types?[]:[e(l,{class:"col-3"+(C?"avail":"unavail"),icon:"sync",title:`Copy ${p} from current state`,onClick:()=>{if(v.length){h&&!n[h]&&(n[h]={});const e=h?n[h]:n;for(const t of v)if(void 0!==k[t]){const a=w&&s?s(e[t],g):k[t];e[t]=I(a)}}else if(0===v.length&&h&&void 0!==k){const e=w&&s?s(k,g):k;n[h]=I(e)}t.redraw&&t.redraw(),d.add(`updated ${p} from current scene`)}}),e(l,{class:"col-3 "+(M?"":"disabled text-lo"),icon:"trash",title:`Delete ${p} in preset`,onClick:()=>M&&(()=>{if(v.length)for(const e of v)delete b[e];else 0===v.length&&h&&delete n[h];t.redraw&&t.redraw()})()})],e(".flexbreak")]})):e("h3","Preset is Empty"))}));var P=Object.freeze({__proto__:null,choose:function(e,t={icon:"circle",onSelect:()=>{}}){const{icon:a,title:n,field:i,onSelect:l,parser:r=e=>e}=t,o=e.map(((e,t)=>({icon:i&&e.icon||a,caption:r(i?e[i]:e,e),onClick:a=>l(e,a,t)})));Array.isArray(e)&&!e.length?d.add("No items available"):C(document.body,{title:n},o).then((({action:e})=>e.onClick()))},promptEntity:(t,a,n,i={})=>new Promise(((l,r)=>{k(e(N,{meta:t,type:n,title:a,options:i,onInput:e=>l(e)}),(()=>{r(new Error("cancelled"))}))})),promptName:E,promptOptions:function(t,a,n={}){const{title:i,field:l,icon:r,textNew:o,textHint:s,resolve:c}=n,u=Array.isArray(t)?t.map((e=>({icon:r,caption:l?e[l]:e,onClick:t=>a(e,t)}))):Object.keys(t).map((e=>({icon:t[e].icon||r,caption:t[e].caption||e,onClick:n=>a(c&&void 0!==t[e].value?t[e].value:t[e],n)})));Array.isArray(t)&&!t.length?d.add("No items available"):C(document.body,{title:i},[...o&&!l?[{icon:"plus",caption:o,onClick:()=>E(o,"",s,(t=>{t&&t&&t.trim()&&(a(t),e.redraw())}))}]:[],...u]).then((({action:e})=>e.onClick())).finally((()=>{}))},promptPreset:(t,a,n={})=>new Promise(((i,l)=>{k((()=>e(D,{...n,preset:t,parameters:a,redraw:()=>k.redraw()})),(()=>{l(new Error("cancelled"))}))}))});const S=u((({attrs:t,children:a})=>e(".separator",{class:t.class||"mini",...t.onClick&&{onclick:t.onClick}},[e("span.grows",t.text),...a||[]]))),O=!!navigator.userAgent.match(/iPhone|iPad|iPod/i);let z,V=!1;function j(e,t,a){return Math.min(Math.max(e,t),a)}function A(e,t,a,n){if(a-t<=0)return t;if(n<=0)return j(e,t,a);const i=Math.ceil((a-t)/n);return j(t+Math.round(i*(e-t)/(a-t))*n,t,a)}function H(){let t,a,n,i,l,r,o,s,c,d=0,u=!1,m=!1,p=4,h=1,v=0,g=10,f=0,w=1,y="horizontal";function b(e,t){let a,n;"vertical"===y?(a=r.bottom-r.top,n=r.bottom-t):(a=r.right-r.left,n=e-r.left),n=j(n,0,a);const i=A(n/a*(g-v)+v,v,g,w);return z(i),i}function x(t,n,i){return m?function(t,n){u=o=!0,r=a.getBoundingClientRect();const i=b(t,n);i!==f&&(f=i,c&&!1!==c(f)&&e.redraw())}(t,n):(l=i,u=!0,o=!1,r=a.getBoundingClientRect(),void(s||l.target.requestPointerLock()));var l,s}function k(e,t,a){return o?b(e,t):function(e,t,a){const n=a.shiftKey?p:a.metaKey||a.ctrlKey?4*p:h;let i,l;i="vertical"===y?a.movementY||0:a.movementX||0;let r=w>0?w:(g-v)/100;if(i<0)l=Math.max(f+r*n*i,v);else{if(!(i>0))return f;l=Math.min(f+r*n*i,g)}return l=A(l,v,g,w),z(l),l}(0,0,a)}function M(e){2!==d&&(d=1,0===e.button&&(window.addEventListener("mousemove",C),window.addEventListener("mouseup",I),x(e.clientX,e.clientY,e)))}function C(e){e.preventDefault(),D(e.clientX,e.clientY,e)}function I(e){window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",I),P(e.clientX,e.clientY,e)}function E(e){if(1===d)return;t.addEventListener("touchmove",L),t.addEventListener("touchend",T);const a=e.changedTouches[0];x(a.clientX,a.clientY,e)}function L(e){e.preventDefault();const t=e.changedTouches[0];D(t.clientX,t.clientY,e)}function T(e){t.removeEventListener("touchmove",L),t.removeEventListener("touchend",T);const a=e.changedTouches[0];P(a.clientX,a.clientY,a)}function N(t){const a=t.keyCode;let n;if(33===a){t.preventDefault();let e=Math.max((g-v)/10,w);e<=0&&(e=1),n=A(f+e,v,g,w)}else if(34===a){t.preventDefault();let e=Math.max((g-v)/10,w);e<=0&&(e=1),n=A(f-e,v,g,w)}else if(35===a)t.preventDefault(),n=g;else if(36===a)t.preventDefault(),n=v;else if(37===a||40===a){t.preventDefault();let e=(w>0?w:(g-v)/10)*(t.shiftKey?.25:t.ctrlKey||t.metaKey?4:1);n=Math.max(f-e,v)}else if(38===a||39===a){t.preventDefault();let e=(w>0?w:(g-v)/10)*(t.shiftKey?.25:t.ctrlKey||t.metaKey?4:1);n=Math.min(f+e,g)}else 48===a&&(n=(g+v)/2);"number"==typeof n&&n!==f&&(f=n,z(f),s&&!1!==s(f)&&e.redraw())}function D(t,a,n){if(!u)return;const i=k(t,a,n);i!==f&&(f=i,c&&!1!==c(f)&&e.redraw())}function P(t,a,n){u&&(u=!1,f=k(t,a,n),s&&!1!==s(f)&&e.redraw(),o||document.exitPointerLock(),setTimeout((function(){u||(d=0)}),350))}function S(e){let t=(e-v)/(g-v);return"vertical"===y&&(t=1-t),String(100*t)+"%"}function z(e){const t=S(e),a=S(g-e+v);"vertical"===y?(l.style.top=t,n.style.height=t,i.style.height=a):(l.style.left=t,n.style.width=a,i.style.width=t)}function H(e){v=e.min,g=e.max,w="number"!=typeof e.step||Number.isNaN(e.step)?1:j(e.step,0,g-v),y="vertical"===e.orientation?"vertical":"horizontal",s=e.onchange,c=e.ondrag,"number"==typeof e.value&&(f=j(e.value,v,g)),m=!e.relative,p=e.factor&&e.factor[0]||4,h=e.factor&&e.factor[1]||1}return{oncreate:({attrs:e,dom:r})=>{O&&!V&&(window.addEventListener("touchmove",(function(){})),V=!0),H(e),t=r,a=t.querySelector(".mithril-range-bar"),n=a.querySelector(".mithril-range-bar-0"),i=a.querySelector(".mithril-range-bar-1"),l=a.querySelector(".mithril-range-handle"),t.addEventListener("mousedown",M),t.addEventListener("touchstart",E),t.addEventListener("keydown",N)},onremove:function(){window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",I),t.removeEventListener("mousedown",M),t.removeEventListener("touchstart",E),t.removeEventListener("touchmove",L),t.removeEventListener("touchend",T),t.removeEventListener("keydown",N)},view:function({attrs:t,children:a}){H(t),f=A(f,v,g,w);const n={class:"mithril-range nokey"+(t.relative?" isrelative ":" ")+(0===f?"atzero":f<0?"belowzero":"overzero")+(null!=t.class?" "+t.class:""),tabIndex:"0",role:"slider","aria-valuemin":String(v),"aria-valuemax":String(g),"aria-valuenow":String(f),"aria-orientation":y};t.id&&(n.id=t.id),t.ariaLabelledby&&(n["aria-labelledby"]=t.ariaLabelledby),t.disabled&&(n.style={pointerEvents:"none"},n["aria-disabled"]="true");const i=S(f),l=S(g-f+v);let r,o,s;return"vertical"===y?(r={top:i},o={height:i},s={height:l}):(r={left:i},o={width:l},s={width:i}),e("div",n,e("div",{class:"mithril-range-bar nokey"},e("div",{class:"mithril-range-bar-0 nokey",style:o}),e("div",{class:"mithril-range-bar-1 nokey",style:s}),e("div",{class:"mithril-range-handle nokey",style:r},a)),!!t.name&&e("input",{type:"hidden",name:t.name,value:String(f)}))}}}exports.quantize=A;const K=t=>{const a=t.value>t.curMax?Math.ceil(t.value/t.curMax):1,n=t.curMin<0&&t.value<t.curMin?Math.abs(Math.ceil(t.value/t.curMin)):1,i=Math.min(Math.max(n,a),t.maxMultiplier);t.curMultiplier!==i&&(t.curMultiplier=i,e.redraw())},F=e=>e.value>=e.curMax*e.curMultiplier*.9&&e.maxMultiplier>1&&e.curMultiplier<=e.maxMultiplier-1?(e.curMultiplier++,!0):e.curMin<0?$(e):void 0,$=e=>{if(e.value<=e.curMin*e.curMultiplier*.9&&e.maxMultiplier>1&&e.curMultiplier<=e.maxMultiplier-1)return e.curMultiplier++,!0},Y={oninit:({attrs:e,state:t})=>{Object.assign(t,{value:e.value||0,initial:e.value||0,curMax:e.max,curMin:e.min,curMultiplier:1,maxMultiplier:e.multiplier||1,id:"I"+Date.now()}),t.maxMultiplier>1&&(t.value>e.max?t.curMultiplier=Math.ceil(t.value/e.max):e.min<0&&t.value<e.min&&(t.curMultiplier=Math.abs(Math.ceil(t.value/e.min))))},onupdate:({attrs:t,state:a})=>{const n=t.multiplier||1,i=t.value||0;a.curMax!==t.max||a.maxMultiplier!==n?(Object.assign(a,{curMax:t.max,curMin:t.min,maxMultiplier:n,value:t.value,initial:i}),F(a)||(clearTimeout(a.timer),a.timer=setTimeout(K,1e3,a)),e.redraw()):a.initial!==i&&(Object.assign(a,{value:i,initial:i}),clearTimeout(z),z=setTimeout((()=>e.redraw()),50))},view:({attrs:t,state:a})=>e(".range.flexcol.control.relative"+(t.multiplier>1?".withmultiplier":""),{...t.class&&{class:t.class},title:t.hint||"Click, then use arrows to finetune value if needed"},[...t.title?[e("label",{class:"rangelabel",htmlFor:a.id},t.title)]:[],e(H,{onchange:n=>{a.value=n;!F(a)&&a.curMultiplier>1&&(clearTimeout(a.timer),a.timer=setTimeout(K,1e3,a)),t.onchange?t.onchange(n):e.redraw()},ondrag:e=>e!==a.value&&(a.value=e,t.ondrag&&t.ondrag(e),!0),value:a.value||0,min:(t.min||0)*a.curMultiplier,max:a.curMax*a.curMultiplier||100,step:t.step||1,relative:t.relative,factor:t.factor},[e(".currentval",t.parser?t.parser(a.value,t.step<1):a.value?t.step<1?a.value.toFixed(2):""+Math.floor(a.value):"")])])},X={view:({attrs:t,state:a})=>e(Y,{value:t.value||0,min:t.min||0,max:t.max||100,step:t.step||.1,class:(t.disabled?"disabled ":"")+(t.class||""),title:t.title,multiplier:t.multiplier,hint:t.hint,parser:t.parser,relative:t.relative,factor:t.factor,getLabel:e=>e?""+e:"default",ondrag:e=>(a.changed=!0,a.value=e,t.onchange&&t.onchange(e,!0),!0),onchange:e=>(t.auto0?e=0:t.autoValue&&(e=t.autoValue),a.changed=!0,a.value=e,t.onchange&&t.onchange(e,!1),!0)})};export{i as Button,l as ButtonNew,p as CardieWidget,r as Empty,n as Icon,f as InputWidget,w as NoticeWidget,P as OverflowUtils,X as RangeWidget,s as Selector,S as Separator,y as SwitchWidget,M as clearModal,k as popupMessage};
|
|
1
|
+
import e from"mithril";export{default as m}from"mithril";function t(e,t,a){const n=("function"==typeof e?e(t):e)||{};return a&&(n.initialParams=a),n}const a=({currentIndex:e},t)=>e===t,n={view:({attrs:t})=>e(`i.icon.${t.pack||"fas"}.fa-${t.icon||"cog"}${t.size?".fa-"+t.size+"x":""}`,{title:t.icontitle||void 0,role:"presentation",onclick:t.onclick||null,...t.iconClass&&{class:t.iconClass}})},i={view:({attrs:t,state:a,children:i})=>e(t.download||t.link?"a.button":"button",{...t.link&&{href:t.link},...t.download&&{download:t.download},...t.target&&{target:t.target},"aria-label":t["aria-label"]||t.title||t.text,title:t.title||t["aria-label"],class:(t.class||"")+(a.busy?" busy":""),...a.error&&{"data-error":a.error.message},...t.onclick&&{onclick:n=>{clearTimeout(a.debounce),a.debounce=setTimeout((()=>{const i=t.onclick(n,t);i&&i.then&&i.catch&&(a.busy=!0,e.redraw(),i.then((()=>{a.busy=!1,e.redraw()})).catch((t=>{a.busy=!1,a.error=t,e.redraw()})))}),25)}}},[...t.icon&&!t.right?[e(n,t)]:[],...t.text?[e("span.pad-1.pad-h",{class:t.textClass||null},t.text)]:[],...t.icon&&t.right?[e(n,t)]:[],...i])},l={view:({attrs:t,state:a,children:i})=>e(t.download||t.link?"a.button":"button",{...t.link&&{href:t.link},...t.download&&{rel:"nofollow",download:t.download},...t.target&&{target:t.target},"aria-label":t["aria-label"]||t.title||t.text,title:t.title||t["aria-label"],class:(t.class||"")+(a.busy?" busy":""),...a.error&&{"data-error":a.error.message},...t.onClick&&{onclick:n=>{clearTimeout(a.debounce),a.debounce=setTimeout((()=>{const i=t.onClick(n,t);i&&i.then&&i.catch&&(a.busy=!0,e.redraw(),i.then((()=>{a.busy=!1,e.redraw()})).catch((t=>{a.busy=!1,a.error=t,e.redraw()})))}),25)}}},[...t.icon&&!t.right?[e(n,t)]:[],...t.text?[e("span.pad-1.pad-h",{class:t.textClass||null},t.text)]:[],...t.icon&&t.right?[e(n,t)]:[],...i])},r={view:({attrs:t,children:a})=>e(".flexcol.flexcenter.al-center.grows.emptywidget",{...t.class&&{class:t.class},...t.key&&{key:t.key},role:"presentation"},[e(n,t),...t.message?[e(".marg-2.marg-v",{role:"status",class:t.size>4?"font-150":"font-100","aria-label":t.message},t.message.split("\n").map(((t,a,n)=>1===n.length?t:e("p.msg"+a,t))))]:[],...a?[e(".flexcol.additional",a)]:[]])},o=(t,a,n,i)=>{const l=a.currentIndex,r=a.currentParams;-1===n?Object.assign(a,{current:null,currentIndex:-1,currentParams:[]}):Object.assign(a,{current:t.items[n]||null,currentIndex:a.current?n:-1,currentParams:i||[]}),t.onSelected&&t.onSelected(a.current,a.currentParams,a.currentIndex!==l,r),e.redraw()},s={oninit:({attrs:e,state:t})=>{(t=e.state||t).setItem=(a,...n)=>o(e,e.state||t,a,n);const a=!isNaN(t.currentIndex)?t.currentIndex:e.selected,n=e.items&&e.items.length?void 0!==a&&e.items[a]?a:e.noinitial?-1:0:-1,i=-1!==n?e.items[n]:null;Object.assign(t,{currentIndex:n,current:i})},onupdate:({attrs:e,state:t})=>{(e.state||t).setItem=(a,...n)=>o(e,e.state||t,a,n)},view:({attrs:n,state:o})=>{o=n.state||o;const{current:s}=o;return e((n.element||"widget")+".selector"+(n.horizontal?".flexrow":".flexcol")+(n.className?"."+n.className:""),{...n.key&&{key:n.key},class:(o.current?"hascurrent":"empty")+(n.class?" "+n.class:"")},[...n.hideonly&&!(n.items.length>1)||n.hidesel?[]:[e("nav.toolbar.fullwidth"+(n.horizontal?".flexcol":".flexrow"),{"aria-label":n["aria-label"]||n.title||"selector",class:n.toolbarClass},n.items.map(((t,n)=>e(i,{class:(t.class?t.class+" ":"")+(a(o,n)?"accent":"nel"),icon:t.icon||null,...t.title&&{title:t.title},...t["aria-label"]&&{"aria-label":t["aria-label"]},...t.text&&{text:t.text},onclick:()=>{Date.now()-o.clickts<200||(o.clickts=Date.now(),o.bodyHidden=!1,o.setItem(n))}}))))],...s?[...n.toggle&&!o.bodyHidden?[e(l,{class:"selectornotch "+(o.bodyHidden?"bodyhidden":"bodyshown"),icon:o.bodyHidden?"caret-up":"caret-down",title:o.bodyHidden?"expand panel":"contract panel",onClick:()=>{o.bodyHidden=!o.bodyHidden,e.redraw()}})]:[],...n.toggle&&o.bodyHidden?[]:[e(".grows.flexcol.ohidden",{class:n.bodyClass,role:"presentation"},[e(s.widget,t(s.attrs,n,o.currentParams),s.children)])],...n.closeButton?[e(i,{class:"closebutton absolute toright",icon:"times",onclick:()=>{o.setItem(-1)},"aria-label":"close item"})]:[]]:e(r,n)])}},c={info:"info",error:"exclamation-triangle",success:"check"};const d=new function(t=5e3,a){let n,l=[];function r(){const o=a||document.getElementById("notification-container");if(l.length){const a=l.splice(0,1)[0];!function(t,a){e.render(t,e(i,{class:"notification "+a.type,text:a.text,icon:c[a.type]||"info",size:1,role:"status",onclick:r}))}(o,a),clearTimeout(n),n=setTimeout(r,a.timer||t)}else e.render(o,""),n=null}return{add:(e,t)=>{l.push({text:e,type:t}),n||r()},clear:()=>{l=[],r()}}};function u(e,t,a,n,i){return{...e&&{view:e},...t&&{oninit:t},...a&&{oncreate:a},...i&&{onupdate:i},...n&&{onremove:n}}}const p={};const h=u((({attrs:t,state:a,children:n})=>{const{nofold:i,cardid:r,size:o,title:s,action:c,collapsedAction:d,collapsedClass:u,expandedClass:m,cols:h,element:v,busy:g,expandedView:f,collapsedView:w,titleWidget:y,titleAttrs:b,titleClass:x,bodyClass:k,titleExpanded:M,titleCollapsed:C}=t,I=!i&&(r?!p[r]:!!a.collapsed),E=I?w?w(t,a):[]:f?f(t,a):n||[],L=y?e(y,b||{}):s?e("span.ellipsis.ohidden.unfold",s):void 0,T=g?"fa-sync":"fa-caret-down "+(I?"iscollapsed":"isexpanded");return E.length||!t.skipEmpty?e(v||"ul",{class:"cardie ohidden noshrink "+(h?"flexcol ":"flexrow wrap ")+(t.class?" "+t.class:"")+(i?" expanded":" "+(I?"collapsed "+(u||""):"expanded "+(m||"")))+(o?" marg-"+o:" marg-2")+(y?" withwidget":"")+(g?" busycard":"")},[...L?[e(".title.grows.fabf.flexrow.pointer.unfold",i?{class:x||"pad-2"}:{class:`${x||"pad-2"} ${T||""}`,title:I?C||"Click to expand the options":M||C||"Click to collapse the options",onclick:n=>{n.target.classList.contains("unfold")&&(n.shiftKey&&t.onShiftOpen?t.onShiftOpen():t.cardid?function(e,t=0){if(e){const[a,n]=e.split("-");t&&a&&n&&Object.keys(p).forEach((e=>{e.startsWith(a+"-")&&(p[e]=0)})),p[e]=t}}(r,I):a.collapsed=!a.collapsed,e.redraw())}},!c||!i&&I?d&&I?[e(l,d),L]:L:[e(l,c),L])]:[],...E.length?[e(".flexbreak"),e(".cardiebody.fadein-filter.grows",{class:(h?"flexcol ":"flexrow wrap")+" "+(k||"")},...E)]:[],...t.alwaysView?[t.alwaysView({attrs:t,state:a})]:[]]):[]}),(({attrs:e,state:t})=>{e.cardid||(t.collapsed=!e.nofold&&(e.cardid?!p[e.cardid]:!!e.collapsed))}),void 0,void 0,void 0),v=(e,t,a=!1)=>{if(a||"number"===e.type){const a=e.float?Number.parseFloat(t):Number.parseInt(t,10);return Number.isNaN(a)?void 0:a}return t},g=(e,t,a)=>{const n=t.hasOwnProperty("value")?t.value:e.value;return v(e,n,a)},f={view:t=>{const{attrs:a,state:n}=t;return n.attrs=a,e(".input-static.w-100.ellipsis",{class:(a.onDrag?"withdrag ":"")+(a.staticClass||"grows"),...a.staticTitle&&{title:a.staticTitle},...a.onDrag||{onclick:a.onClick},oncreate:({dom:e,state:n})=>{if(a.onDrag&&!a.readonly){const a=n.hammer=new Hammer.Manager(e,{touchAction:"pan-y"}),i=new Hammer.Pan({direction:Hammer.DIRECTION_VERTICAL}),l=new Hammer.Tap;a.add([i,l]),a.on("tap",(()=>t.state.attrs.onClick())),a.on("panup",(e=>t.state.attrs.onDrag(-1,e.srcEvent))),a.on("pandown",(e=>t.state.attrs.onDrag(1,e.srcEvent))),a.on("panend pancancel",(e=>t.state.attrs.onDrag(0,e.srcEvent)))}a.focus&&e.focus()},onremove:({state:e})=>{e.hammer&&e.hammer.destroy()}},a.value)}},w={view:({attrs:t,state:a})=>{const n=t=>{a.value&&a.showInput&&delete a.showInput,delete a.value,t&&e.redraw()};return e(".textfield.flexcol.relative",{class:(t.label?"witharia":"")+(t.containerClass?" "+t.containerClass:""),...t.label&&{"aria-label":t.label}},[!t.staticField||!t.readonly&&a.showInput?!a.multi&&!t.alwaysmulti||t.type&&"text"!==t.type?e("input.w-100",{...t.id&&{id:t.id},type:t.type||"text",...void 0!==t.max&&{max:t.max},...void 0!==t.min&&{min:t.min},...t.step>0&&{step:t.step},...t.maxlength&&{maxlength:t.maxlength},class:(t.class||"")+(t.validator?a.isValid?" bg-ok":" bg-error":""),...t.title&&{title:t.title},value:g(t,a),placeholder:t.hint||"",oninput:e=>{a.value=v(t,e.target.value),e.fromoninput=!0,t.validator&&(a.isValid=t.validator(a.value)),t.onchange&&(t.oninput||t.onchange)(a.value,e)},onchange:e=>{t.onchange&&(t.validator&&(a.isValid=t.validator(a.value)),e.enterPressed=a.enterPressed,delete a.enterPressed,t.onchange(v(t,e.target.value),e),t.staticField?n(!0):delete a.value)},onblur:()=>{a.showInput&&n(!0)},onkeyup:e=>{a.showInput&&("Escape"===e.key?n(!0):"Enter"===e.key&&(a.value!==t.value&&a.value||(t.onchange(t.value,e),n(!0))))},onkeypress:e=>{a.showInput||"Enter"!==e.key||t.onenter&&t.onenter(e.target.value,e)}}):e("textarea.w-100",{class:t.class,value:g(t,a),...t.title&&{title:t.title},placeholder:t.hint||"",oninput:e=>{a.value=v(t,e.target.value),t.validator&&(a.isValid=t.validator(a.value)),t.onchange&&(t.oninput||t.onchange)(a.value,e,!0)},onchange:e=>{if(t.onchange){t.validator&&(a.isValid=t.validator(a.value));const i=v(t,e.target.value);n(!1),t.onchange(i,e,!0)}},onblur:()=>{a.showInput&&n(!0)},onkeyup:e=>{"Escape"===e.key&&a.showInput&&n(!1)}}):e(f,{readonly:t.readonly,staticClass:(a.dragging?"accent ":"")+(t.staticClass||""),staticTitle:t.staticTitle||t.draginc&&"Click then drag up and down to modify value, or just click to enter a custom value",value:t.displayTitle||g(t,a),focus:t.focus,...t.draginc&&!t.readonly&&{onDrag:(n,i)=>{if(n){a.dragging=!0;let e=g(t,a,!0);if(Number.isNaN(e)||void 0===e)return;e+=n*t.draginc,void 0!==t.max&&e>t.max&&(e=t.max),void 0!==t.min&&e<t.min&&(e=t.min),a.value="number"===t.type?e:String(e),t.onchange(a.value,i)}else delete a.dragging,delete a.value,e.redraw()}},...t.readonly||{onClick:()=>{a.showInput=!0,a.value=t.value,e.redraw()}}}),e(".span.actions.absolute.right.bottom",[...!t.multi||t.alwaysmulti||t.type&&"text"!==t.type?[]:[e(l,{icon:a.multi?"angle-double-up":"angle-double-down",class:"pad-2 transp",onClick:()=>{a.multi=!a.multi,e.redraw()}})],...t.actions?t.actions.map((t=>e(l,{...t,class:"transp pad-2"}))):[],...t.action?[e(l,{...t.action,class:"transp pad-2"})]:[]])])},oninit:({attrs:e,state:t})=>{if(e.staticField&&e.draginc){const a=g(e,t,!0);t.showInput=Number.isNaN(a)||null==a}}},y=u((({attrs:t,children:a})=>a.length?e(".notice.cardie.flexcol.pad-3",{class:t.class||"marg-2 font-75"},e(".flexrow",[...t.icon?[e(n,t)]:[],e(".pad-2.pad-h",t.text)]),...a):e(".notice.cardie.flexrow.pad-3",{class:t.class||"marg-2 font-75",onclick:t.onClick},[...t.icon?[e(n,t)]:[],e(".pad-2.pad-h",t.text)]))),b=u((({attrs:t,state:a})=>e((t.unit||"")+".flexrow"+(t.subline?" withsubline":""),{class:t.class,text:t.text,title:t.title||null,onclick:()=>{a.checked=!a.checked,t.onchange&&t.onchange(a.checked),e.redraw()}},t.right?[...t.text?[e("span.grows.caption",t.subline?{"data-subline":t.subline}:{},t.text)]:[],e(n,{iconClass:"pad-2 pad-h",icon:a.checked?"toggle-on":"toggle-off"})]:[e(n,{iconClass:"pad-2 pad-h",icon:a.checked?"toggle-on":"toggle-off"}),...t.text?[e("span.grows.caption",t.subline?{"data-subline":t.subline}:{},t.text)]:[]])),(({attrs:e,state:t})=>{t.checked=t.original=e.checked}),null,null,(({attrs:t,state:a})=>{t.checked!==a.original&&(a.checked=a.original=t.checked,e.redraw())}));let x;function k(e){"function"==typeof x&&(x(),x=void 0),e.style.display="none",delete M.redraw}function M(t,a=!1,n=".modal-content"){const i=document.getElementById("modal-container");if(i.classList.toggle("iscustom",".modal-content"!==n),a&&(x=a,i.onclick=e=>{"modal-container"===e.target.id&&k(i)}),!t)return delete M.redraw,void(null===t?i.style.display="none":k(i));i.style.display="flex",M.redraw=()=>{e.render(i,e(n,{role:"alertdialog","aria-labelledby":"modaltitle","aria-modal":!0},["function"==typeof t?t():t]))},M.redraw()}function C(){const e=document.getElementById("modal-container");return"none"!==e.style.display&&(k(e),!0)}function I(t,a,n,l){return new Promise((r=>{function o(e){M(null);try{r(e)}catch(e){}}const s=((e,t)=>{const a=[];if(t)for(const e of Object.keys(t))t[e]&&a.push("."+e);return(e||"")+a.join("")})(".popup.flexcol",{".favlist":(l=l||{}).favlist,".isfav":t&&t.classList.contains("isfav"),".isplay":t&&t.classList.contains("selected")});M(e({view:()=>e(s,{onclick:e=>{if("INPUT"===e.target.nodeName)return;const n=e.target.getAttribute("data-action");n?o({domItem:t,item:a,action:n}):M(null)}},[...a.title?[e("h3",{id:"modaltitle"},a.title)]:[],...n.map((n=>"text"===n.type?e("input.action",{value:n.value||"",type:"text",placeholder:n.hint||"",oncreate:({dom:e})=>e.focus(),onkeyup:e=>{27===e.keyCode&&o({domItem:t,item:a,action:n})},onchange:e=>{e.target.blur(),o({domItem:t,item:a,action:n,value:e.target.value})}}):e(i,{...n,onclick:()=>o({domItem:t,item:a,action:n})},n.caption)))])}),!0)}))}const E=window.structuredClone?window.structuredClone:e=>JSON.parse(JSON.stringify(e));function L(e,t,a,n,i={}){setTimeout((()=>I(document.body,{title:e},[{type:"text",hint:a,value:t}]).then((({value:e})=>(i.refreshKey=String(Date.now()),n(e))))),100)}const T=[["Lights and Fog",null,["amblight","l0","l1","l2","l3","fog"],0],["Face and Accessories",null,["facekit"],1],["Particle settings",null,["particles"],2],["Video Segmentation","common",["segcam","mask","green"],3,!0],["Video Effects",null,["fxconfig"],9],["Video Plane","val",["xvideo","yvideo","zvideo","rvideo","svideo","video"],4],["Main Camera","val",["ypos","xpos","zoom","yaw","pitch","roll","ai"],5],["Drone Camera","val",["free"],6],["Followed Agent","val",["track"],10],["Game Camera","val",["orbit","track","ocam"],7,void 0,!0],["Transition Speed","val",["spd"],8]],N=u((({attrs:t})=>e("h2.marg-2.no-marg-bottom",t.title))),D=u((({attrs:t})=>{const{type:a="changes",meta:n,onInput:i,title:r,options:o}=t,s=n.title?.trim().length&&n.description?.trim().length,c=o&&o.embedded;return e(".flexcol.grows.ohidden.fadein",[...t.title?[e(N,{title:r})]:[],e(".flexrow.wrap.grows.pad-3.propsgroup.scrolly",[...t.notice?[e(y,{class:"marg-1 marg-v withbottommargin font-75 col-12",size:1,icon:"info-circle",text:t.notice})]:[],e(".witharia.col-12.pad-1.pad-v",{"aria-label":a+" name"},e(w,{class:"pad-2 pad-xh "+(s?"valid":"invalid"),value:n.title,maxlength:64,onchange:t=>{n.title=t,e.redraw()}})),...c?[]:[e(".col-12.witharia.pad-1.pad-v",{"aria-label":"description"},e(w,{class:"pad-2 pad-xh "+(n.description?"valid":"invalid"),value:n.description,maxlength:240,multi:!0,alwaysmulti:!0,onchange:t=>{n.description=t,e.redraw()}})),e(".col-8.witharia.pad-1.pad-v",{"aria-label":"tags"},e(w,{class:"pad-2 pad-xh",value:n.tags,maxlength:128,onchange:e=>{n.tags=e.toLowerCase().split(" ").join(",").split(",").filter((e=>e.length)).join(",")}})),e(".col-4.witharia.pad-1.pad-v",{"aria-label":"youtube video"},e(w,{class:"pad-2 pad-xh",value:n.ytref||"",hint:"YouTube ID",maxlength:16,onchange:e=>{(e=e.trim())?-1===e.indexOf(" ")&&(n.ytref=e.trim()):delete n.ytref}}))],e(".col-4.witharia.pad-1.pad-v",{"aria-label":"content attribution"},e(w,{class:"pad-2 pad-xh",value:n.author,hint:"author name",maxlength:128,onchange:e=>{n.author=e}})),e(".col-4.witharia.pad-1.pad-v",{"aria-label":"license or author link"},e(w,{class:"pad-2 pad-xh",hint:"https://...",value:n.link,maxlength:128,onchange:e=>{n.link=e}})),e(".col-4.witharia.pad-1.pad-v",{"aria-label":"source domain"},e(w,{class:"pad-2 pad-xh",value:n.source,hint:"example.com",maxlength:128,onchange:e=>{n.source=e}})),e(".col-12.al-right.marg-2.marg-v",e(l,{class:"noshrink accentbutton unitheightsmall col-4",text:"save "+a,onClick:()=>{n.title?.trim().length&&(c||n.description?.trim().length)?(M(null),i(n)):d.add("Information is incomplete or invalid")}}))])])})),P=u((({attrs:t})=>{const{parameters:a,preset:n,presetComponents:i,types:r,globalData:o,fetcher:s}=t,c=[],u=[],m=r?T:T.filter((e=>{const[,t,i,l,r]=e,s=t?n[t]:n,d=r?o:a,m=t?d[t]:d;let p=!1;if(i.length){for(const e of i)s&&void 0!==s[e]&&(p=c[l]=!0),void 0!==m[e]&&(p=u[l]=!0);return p}return p=!0,u[l]=!!m,c[l]=!!s,p}));return e("ul.flexrow.wrap.userdialog",m.length?m.map((m=>{const[p,h,v,g,f,w]=m,y=r?void 0:h?n[h]:n,x=f?o:a,k=r?void 0:h?x[h]:x,M=r||c[g],C=u[g];return[...i?[e(b,{title:`Include ${m[0]} in snapshots`,class:"grows unitheightsmall"+(i[g]?" accent":""),checked:!!i[g],onchange:a=>{i[g]=!i[g],e.redraw(),t.redraw&&t.redraw()}}),e(".grows",{class:M?"avail":"unavail"},p)]:[],...t.types?[]:[e(l,{class:"col-3"+(C?"avail":"unavail"),icon:"sync",title:`Copy ${p} from current state`,onClick:()=>{if(v.length){h&&!n[h]&&(n[h]={});const e=h?n[h]:n;for(const t of v)if(void 0!==k[t]){const a=w&&s?s(e[t],g):k[t];e[t]=E(a)}}else if(0===v.length&&h&&void 0!==k){const e=w&&s?s(k,g):k;n[h]=E(e)}t.redraw&&t.redraw(),d.add(`updated ${p} from current scene`)}}),e(l,{class:"col-3 "+(M?"":"disabled text-lo"),icon:"trash",title:`Delete ${p} in preset`,onClick:()=>M&&(()=>{if(v.length)for(const e of v)delete y[e];else 0===v.length&&h&&delete n[h];t.redraw&&t.redraw()})()})],e(".flexbreak")]})):e("h3","Preset is Empty"))}));var S=Object.freeze({__proto__:null,choose:function(e,t={icon:"circle",onSelect:()=>{}}){const{icon:a,title:n,field:i,onSelect:l,parser:r=e=>e}=t,o=e.map(((e,t)=>({icon:i&&e.icon||a,caption:r(i?e[i]:e,e),onClick:a=>l(e,a,t)})));Array.isArray(e)&&!e.length?d.add("No items available"):I(document.body,{title:n},o).then((({action:e})=>e.onClick()))},promptEntity:(t,a,n,i={})=>new Promise(((l,r)=>{M(e(D,{meta:t,type:n,title:a,options:i,onInput:e=>l(e)}),(()=>{r(new Error("cancelled"))}))})),promptName:L,promptOptions:function(t,a,n={}){const{title:i,field:l,icon:r,textNew:o,textHint:s,resolve:c}=n,u=Array.isArray(t)?t.map((e=>({icon:r,caption:l?e[l]:e,onClick:t=>a(e,t)}))):Object.keys(t).map((e=>({icon:t[e].icon||r,caption:t[e].caption||e,onClick:n=>a(c&&void 0!==t[e].value?t[e].value:t[e],n)})));Array.isArray(t)&&!t.length?d.add("No items available"):I(document.body,{title:i},[...o&&!l?[{icon:"plus",caption:o,onClick:()=>L(o,"",s,(t=>{t&&t&&t.trim()&&(a(t),e.redraw())}))}]:[],...u]).then((({action:e})=>e.onClick())).finally((()=>{}))},promptPreset:(t,a,n={})=>new Promise(((i,l)=>{M((()=>e(P,{...n,preset:t,parameters:a,redraw:()=>M.redraw()})),(()=>{l(new Error("cancelled"))}))}))});const O=u((({attrs:t,children:a})=>e(".separator",{class:t.class||"mini",...t.onClick&&{onclick:t.onClick}},[e("span.grows",t.text),...a||[]]))),z=!!navigator.userAgent.match(/iPhone|iPad|iPod/i);let V,j=!1;function A(e,t,a){return Math.min(Math.max(e,t),a)}function H(e,t,a,n){if(a-t<=0)return t;if(n<=0)return A(e,t,a);const i=Math.ceil((a-t)/n);return A(t+Math.round(i*(e-t)/(a-t))*n,t,a)}function K(){let t,a,n,i,l,r,o,s,c,d=0,u=!1,m=!1,p=4,h=1,v=0,g=10,f=0,w=1,y="horizontal";function b(e,t){let a,n;"vertical"===y?(a=r.bottom-r.top,n=r.bottom-t):(a=r.right-r.left,n=e-r.left),n=A(n,0,a);const i=H(n/a*(g-v)+v,v,g,w);return O(i),i}function x(t,n,i){return m?function(t,n){u=o=!0,r=a.getBoundingClientRect();const i=b(t,n);i!==f&&(f=i,c&&!1!==c(f)&&e.redraw())}(t,n):(l=i,u=!0,o=!1,r=a.getBoundingClientRect(),void(s||l.target.requestPointerLock()));var l,s}function k(e,t,a){return o?b(e,t):function(e,t,a){const n=a.shiftKey?p:a.metaKey||a.ctrlKey?4*p:h;let i,l;i="vertical"===y?a.movementY||0:a.movementX||0;let r=w>0?w:(g-v)/100;if(i<0)l=Math.max(f+r*n*i,v);else{if(!(i>0))return f;l=Math.min(f+r*n*i,g)}return l=H(l,v,g,w),O(l),l}(0,0,a)}function M(e){2!==d&&(d=1,0===e.button&&(window.addEventListener("mousemove",C),window.addEventListener("mouseup",I),x(e.clientX,e.clientY,e)))}function C(e){e.preventDefault(),D(e.clientX,e.clientY,e)}function I(e){window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",I),P(e.clientX,e.clientY,e)}function E(e){if(1===d)return;t.addEventListener("touchmove",L),t.addEventListener("touchend",T);const a=e.changedTouches[0];x(a.clientX,a.clientY,e)}function L(e){e.preventDefault();const t=e.changedTouches[0];D(t.clientX,t.clientY,e)}function T(e){t.removeEventListener("touchmove",L),t.removeEventListener("touchend",T);const a=e.changedTouches[0];P(a.clientX,a.clientY,a)}function N(t){const a=t.keyCode;let n;if(33===a){t.preventDefault();let e=Math.max((g-v)/10,w);e<=0&&(e=1),n=H(f+e,v,g,w)}else if(34===a){t.preventDefault();let e=Math.max((g-v)/10,w);e<=0&&(e=1),n=H(f-e,v,g,w)}else if(35===a)t.preventDefault(),n=g;else if(36===a)t.preventDefault(),n=v;else if(37===a||40===a){t.preventDefault();let e=(w>0?w:(g-v)/10)*(t.shiftKey?.25:t.ctrlKey||t.metaKey?4:1);n=Math.max(f-e,v)}else if(38===a||39===a){t.preventDefault();let e=(w>0?w:(g-v)/10)*(t.shiftKey?.25:t.ctrlKey||t.metaKey?4:1);n=Math.min(f+e,g)}else 48===a&&(n=(g+v)/2);"number"==typeof n&&n!==f&&(f=n,O(f),s&&!1!==s(f)&&e.redraw())}function D(t,a,n){if(!u)return;const i=k(t,a,n);i!==f&&(f=i,c&&!1!==c(f)&&e.redraw())}function P(t,a,n){u&&(u=!1,f=k(t,a,n),s&&!1!==s(f)&&e.redraw(),o||document.exitPointerLock(),setTimeout((function(){u||(d=0)}),350))}function S(e){let t=(e-v)/(g-v);return"vertical"===y&&(t=1-t),String(100*t)+"%"}function O(e){const t=S(e),a=S(g-e+v);"vertical"===y?(l.style.top=t,n.style.height=t,i.style.height=a):(l.style.left=t,n.style.width=a,i.style.width=t)}function V(e){v=e.min,g=e.max,w="number"!=typeof e.step||Number.isNaN(e.step)?1:A(e.step,0,g-v),y="vertical"===e.orientation?"vertical":"horizontal",s=e.onchange,c=e.ondrag,"number"==typeof e.value&&(f=A(e.value,v,g)),m=!e.relative,p=e.factor&&e.factor[0]||4,h=e.factor&&e.factor[1]||1}return{oncreate:({attrs:e,dom:r})=>{z&&!j&&(window.addEventListener("touchmove",(function(){})),j=!0),V(e),t=r,a=t.querySelector(".mithril-range-bar"),n=a.querySelector(".mithril-range-bar-0"),i=a.querySelector(".mithril-range-bar-1"),l=a.querySelector(".mithril-range-handle"),t.addEventListener("mousedown",M),t.addEventListener("touchstart",E),t.addEventListener("keydown",N)},onremove:function(){window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",I),t.removeEventListener("mousedown",M),t.removeEventListener("touchstart",E),t.removeEventListener("touchmove",L),t.removeEventListener("touchend",T),t.removeEventListener("keydown",N)},view:function({attrs:t,children:a}){V(t),f=H(f,v,g,w);const n={class:"mithril-range nokey"+(t.relative?" isrelative ":" ")+(0===f?"atzero":f<0?"belowzero":"overzero")+(null!=t.class?" "+t.class:""),tabIndex:"0",role:"slider","aria-valuemin":String(v),"aria-valuemax":String(g),"aria-valuenow":String(f),"aria-orientation":y};t.id&&(n.id=t.id),t.ariaLabelledby&&(n["aria-labelledby"]=t.ariaLabelledby),t.disabled&&(n.style={pointerEvents:"none"},n["aria-disabled"]="true");const i=S(f),l=S(g-f+v);let r,o,s;return"vertical"===y?(r={top:i},o={height:i},s={height:l}):(r={left:i},o={width:l},s={width:i}),e("div",n,e("div",{class:"mithril-range-bar nokey"},e("div",{class:"mithril-range-bar-0 nokey",style:o}),e("div",{class:"mithril-range-bar-1 nokey",style:s}),e("div",{class:"mithril-range-handle nokey",style:r},a)),!!t.name&&e("input",{type:"hidden",name:t.name,value:String(f)}))}}}exports.quantize=H;const F=t=>{const a=t.value>t.curMax?Math.ceil(t.value/t.curMax):1,n=t.curMin<0&&t.value<t.curMin?Math.abs(Math.ceil(t.value/t.curMin)):1,i=Math.min(Math.max(n,a),t.maxMultiplier);t.curMultiplier!==i&&(t.curMultiplier=i,e.redraw())},$=e=>e.value>=e.curMax*e.curMultiplier*.9&&e.maxMultiplier>1&&e.curMultiplier<=e.maxMultiplier-1?(e.curMultiplier++,!0):e.curMin<0?Y(e):void 0,Y=e=>{if(e.value<=e.curMin*e.curMultiplier*.9&&e.maxMultiplier>1&&e.curMultiplier<=e.maxMultiplier-1)return e.curMultiplier++,!0},B={oninit:({attrs:e,state:t})=>{Object.assign(t,{value:e.value||0,initial:e.value||0,curMax:e.max,curMin:e.min,curMultiplier:1,maxMultiplier:e.multiplier||1,id:"I"+Date.now()}),t.maxMultiplier>1&&(t.value>e.max?t.curMultiplier=Math.ceil(t.value/e.max):e.min<0&&t.value<e.min&&(t.curMultiplier=Math.abs(Math.ceil(t.value/e.min))))},onupdate:({attrs:t,state:a})=>{const n=t.multiplier||1,i=t.value||0;a.curMax!==t.max||a.maxMultiplier!==n?(Object.assign(a,{curMax:t.max,curMin:t.min,maxMultiplier:n,value:t.value,initial:i}),$(a)||(clearTimeout(a.timer),a.timer=setTimeout(F,1e3,a)),e.redraw()):a.initial!==i&&(Object.assign(a,{value:i,initial:i}),clearTimeout(V),V=setTimeout((()=>e.redraw()),50))},view:({attrs:t,state:a})=>e(".range.flexcol.control.relative"+(t.multiplier>1?".withmultiplier":""),{...t.class&&{class:t.class},title:t.hint||"Click, then use arrows to finetune value if needed"},[...t.title?[e("label",{class:"rangelabel",htmlFor:a.id},t.title)]:[],e(K,{onchange:n=>{a.value=n;!$(a)&&a.curMultiplier>1&&(clearTimeout(a.timer),a.timer=setTimeout(F,1e3,a)),t.onchange?t.onchange(n):e.redraw()},ondrag:e=>e!==a.value&&(a.value=e,t.ondrag&&t.ondrag(e),!0),value:a.value||0,min:(t.min||0)*a.curMultiplier,max:a.curMax*a.curMultiplier||100,step:t.step||1,relative:t.relative,factor:t.factor},[e(".currentval",t.parser?t.parser(a.value,t.step<1):a.value?t.step<1?a.value.toFixed(2):""+Math.floor(a.value):"")])])},X={view:({attrs:t,state:a})=>e(B,{value:t.value||0,min:t.min||0,max:t.max||100,step:t.step||.1,class:(t.disabled?"disabled ":"")+(t.class||""),title:t.title,multiplier:t.multiplier,hint:t.hint,parser:t.parser,relative:t.relative,factor:t.factor,getLabel:e=>e?""+e:"default",ondrag:e=>(a.changed=!0,a.value=e,t.onchange&&t.onchange(e,!0),!0),onchange:e=>(t.auto0?e=0:t.autoValue&&(e=t.autoValue),a.changed=!0,a.value=e,t.onchange&&t.onchange(e,!1),!0)})};function q(e,t){m.route(document.getElementById(e),t.default||"/",t.routes)}export{i as Button,l as ButtonNew,h as CardieWidget,r as Empty,n as Icon,w as InputWidget,y as NoticeWidget,S as OverflowUtils,X as RangeWidget,s as Selector,O as Separator,b as SwitchWidget,C as clearModal,u as defineWidget,M as popupMessage,q as startApp};
|
|
2
2
|
//# sourceMappingURL=libui.esm.js.map
|