From acf1729c02e64b84147e8e8710eee7e2f92fd095 Mon Sep 17 00:00:00 2001 From: hicodx Date: Sat, 17 Aug 2024 19:46:25 -0500 Subject: [PATCH] =?UTF-8?q?build=20del=20c=C3=B3digo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/index.js | 2 +- vite.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 1c9ffe6..d641d1e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -"use strict";var ce=Object.defineProperty,le=Object.defineProperties;var ue=Object.getOwnPropertyDescriptors;var U=Object.getOwnPropertySymbols;var fe=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable;var G=(n,e,t)=>e in n?ce(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,p=(n,e)=>{for(var t in e||(e={}))fe.call(e,t)&&G(n,t,e[t]);if(U)for(var t of U(e))de.call(e,t)&&G(n,t,e[t]);return n},V=(n,e)=>le(n,ue(e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("tabris");require("string-tocapitalize");function P(n){return new Proxy(n,{apply(t,r,s){return Reflect.construct(t,s)}})}function pe(n){const e={get(t,r,s){return Reflect.get(t,r,s)},apply(t,r,s){return typeof t.name=="string"&&typeof t.constructor=="function"?Reflect.construct(t,s):Reflect.apply(null,t,s)}};return new Proxy(n,e)}const x=class x{};x.LONG=3e3,x.MEDIUM=2100,x.SHORT=1500;let T=x;function H(n,e,t){return n.animate({opacity:1},{delay:e!=null?e:0,duration:t,easing:"ease-in"})}function N(n,e,t){return n.animate({opacity:0},{delay:e,duration:t,easing:"ease-out"})}function Q(n,e,t){return Promise.resolve(H(n,e,300)).then(()=>Promise.resolve(N(n,t,t)))}class he extends o.EventObject{}class Z{constructor(e={}){const t=[];let r,s,i=!1,u=!1,l=!1;const{width:c}=o.contentView.bounds,{screenWidth:d}=device,f=560,w={elevation:24,centerY:!0,padding:10,cornerRadius:5,opacity:0,background:"white",id:"modal-container"};f>d||f>c?Object.assign(w,{left:24,right:24}):Object.assign(w,{width:f});const _=new o.Composite({left:0,right:0,top:0,bottom:0,opacity:1,highlightOnTouch:!1,background:new o.Color(0,0,0,50)}).onTap(a=>a.preventDefault()),y=new o.Composite(w).appendTo(_);"title"in e&&y.append(new o.TextView({id:"modal-title",font:"medium 18px",padding:10,left:0,right:0,text:e.title.toCapitalize()}));const M=new o.Composite({top:"#modal-title",bottom:o.LayoutData.prev,right:0,left:0}),E=new o.ScrollView({layoutData:"stretchX"}).appendTo(M);y.onBoundsChanged(({value:a})=>{const{height:v}=o.contentView.bounds;vv?f-(f>v?20+f-v:0):f>a.height?a.height:f}),M.layoutData=p({},M.layoutData),E.layoutData="stretch")}),Object.defineProperty(this,"setButtonAccept",{configurable:!1,value:a=>(r||(r=J("accept",a)),r)}),Object.defineProperty(this,"setButtonCancel",{configurable:!1,value:a=>(s||(s=J("cancel",a)),s)}),Object.defineProperty(this,"addView",{configurable:!1,value:(...a)=>E.append(a)}),Object.defineProperty(this,"show",{configurable:!1,value:()=>{i||(i=!0,y.append(new o.Composite({layoutData:"stretchX",id:"buttons-modal",bottom:0}).append(t))),(!l||u)&&(l=!0,u=!1,y.append(M),o.contentView.append(_),H(y,0,100))}}),Object.defineProperty(this,"removeView",{configurable:!1,value:()=>E.children().dispose()}),Object.defineProperty(this,"removeButtons",{configurable:!1,value:()=>{r=s=null,t.forEach(a=>{a.dispose()})}}),Object.defineProperty(this,"remove",{configurable:!1,value:()=>{u||N(_,0,250).then(()=>{u=!0,l=!1,_.detach()})}});function J(a,v){const R=new o.Button({text:v,top:t.length===0?"prev() 20":"auto",right:t.length===0?0:"prev()",bottom:0,style:"text"}),K=new o.Listeners(R,a);return R.onTap(()=>K.trigger(new he)),t.push(R),K}}}let h=[];class O extends T{constructor(e,t){super(),this._message=o.TextView({textColor:"white",left:0,right:0}),this._modal=o.Composite({background:"black",padding:10,cornerRadius:10,bottom:30,opacity:0}).append(this._message);const r="12px";o.sizeMeasurement.measureTextsSync([{text:e,font:r}])[0].width>o.contentView.bounds.width-20?(this._modal.left=20,this._modal.right=20):this._modal.centerX=!0,this._message.text=e,this._message.font=r,Object.defineProperty(this,"show",{configurable:!1,value:()=>{if(h.length===1&&u(),h.length>0)h.push({element:this._modal,promise:()=>new Promise(c=>{c(l(this._modal))})});else{const c=l(this._modal);h.push({promise:()=>c,element:this._modal})}}});const u=()=>{if(h.length===0)return;const{promise:c,element:d}=h.at(0);c().then(()=>{h.shift(),d.dispose(),u()}).catch(console.log)};function l(c){return o.contentView.append(c),Q(c,0,t)}}static makeText(e,t=O.SHORT){return new O(e,t)}}const z=new Map;function me(n){return n instanceof Object&&n.constructor?n.constructor:n}function $(n){return z.get(me(n))}b.addListener=(n,e,t)=>{const{store:r}=$(n);r.has(n)||r.set(n,{event:{},listeners:new WeakMap}),r.get(n).event[e]=t};b.listener=(n,e)=>{const{instanceOf:t,store:r}=$(n);for(let{listeners:s,element:i,invoke:u}of t){if(!(e instanceof i))continue;const l=r.get(n);l&&(l.listeners.has(e)||l.listeners.set(e,s.map(c=>{const d=new o.Listeners(e,c);return d.addListener(f=>{for(let w of u)l.event[w](f.target,f)}),d})))}};function b(n,e){z.has(n)||z.set(n,V(p({},e),{store:new WeakMap}))}class Y extends o.Composite{constructor(e){super({id:e,top:o.Constraint.prev,right:0,left:0,height:56,highlightOnTouch:!0})}}class A extends o.Row{constructor(e){super({layoutData:"stretch",alignment:"centerY"}),this.id=e.id,this._setElements(e.image,e.text)}_setElements(e,t){const r="voir-img-ref-"+this.id,s="voir-text-ref-"+this.id;e&&this.append(o.ImageView({image:e,width:24,left:28,id:r}));const i=e?12:64;this.append(o.TextView({text:t,font:"20px sans-serif",left:i,id:s}))}}const ge=A,we=({children:n})=>new o.WidgetCollection(n),ye=(n,e)=>{console.warn("deprecated function [menuDrawer] use setMenuDrawer"),X(n,e)};function ee(){const n=o.drawer.find("#scrollableLayoutMenuDrawer"),e=n.length!==0?n.only():o.ScrollView({id:"scrollableLayoutMenuDrawer",top:o.Constraint.prev,left:0,right:0,bottom:0});return n.length===0&&o.drawer.append(e),e}function X(n,e){ee().append(n.map(t=>{const r=t instanceof A,s=t.id;return r&&(t.id=""),new Y(s).append(r?t:new A({image:t.image,text:t.text})).onTap(function(){typeof e=="function"&&e(this);const i=setTimeout(()=>(o.drawer.close(),clearTimeout(i)),100)})}))}function te(n){const e=ee(),t=o.drawer.find("#voirContentDrawer"),r=t.length===0?o.Composite({top:[o.Constraint.prev,15],left:0,right:0,id:"voirContentDrawer",padding:8}).append(n):t.only().append(n);t.length===0&&e.append(r)}const m=new Map,L=class L extends o.NavigationView{constructor(e){super(e),this._renderWidgetInDrawer=(()=>{let t=!1;return()=>{if(t)return;t=!0;const r=()=>{X(this.menuDrawer),te(this.contentDrawer),this.menuDrawer.forEach(s=>{b.listener(this,s.parent())})};this.drawerActionVisible&&r()}})()}set contentDrawer(e){this._contentDrawer=e}get contentDrawer(){return this._contentDrawer}set menuDrawer(e){this._dataMenuDrawer=e.toArray()}get menuDrawer(){return this._dataMenuDrawer}on(e,t,r){return typeof e=="string"&&L.events.includes(e)&&b.addListener(this,e,t),super.on(e,t,r)}_addChild(e){b.listener(this,e),e instanceof o.Page&&(m.set(e,{hidden:!1,actions:null,isDisposed:!1}),e.on("appear",()=>{this._renderWidgetInDrawer();const r=m.get(e);typeof r=="object"&&r.hidden&&(r.actions!==null&&this.append(r.actions),r.hidden=!1),m.size===1&&t(!0)}),e.on("disappear",()=>{var s;const r=m.get(e);t(!1),r.hidden||(r.hidden=!0,(s=r.actions)==null||s.forEach(i=>i.detach())),r.isDisposed&&m.delete(e)}),e.on("dispose",()=>{m.get(e).isDisposed=!0}));const t=r=>{this!=null&&this.drawerActionVisible&&(o.drawer.enabled=r)};return super._addChild(e)}append(...e){const t=super.append(...e);return setTimeout(()=>be(e),0),t}};L.events=["actionSelected","drawerItemSelected"];let D=L;function ve(n){const e=n.find(s=>s instanceof o.Page),t=n.filter(s=>s instanceof o.Action||s instanceof o.SearchAction?s.data.voirInitializedEvent=!0:!1),r=m.get(e);return e&&t.length&&r.actions===null&&(r.actions=t),r}function be(n){let e=n.length>1?n:Array.isArray(n[0])?n.shift():n;if(e.some(t=>Array.isArray(t)))throw new Error("error parameter");if(Array.isArray(e)&&e.length>0)return ve(e)}b(D,{instanceOf:[{element:o.Action,listeners:["select"],invoke:["actionSelected"]},{element:o.SearchAction,listeners:["select"],invoke:["actionSelected"]},{element:Y,listeners:["tap"],invoke:["drawerItemSelected"]}],nameEvents:["actionSelected","drawerItemSelected"]});const Pe=P(D),S="voir-native-preference";localStorage.getItem(S)||localStorage.setItem(S,"{}");const k=JSON.parse(localStorage.getItem(S)),I=(n,e)=>{k[n]=e,localStorage.setItem(S,JSON.stringify(k))},q=n=>k[n],ne=n=>n in k,C=(n,e,t)=>o.NativeObject.defineProperty(n,e,t),Ce={left:0,right:"10%"},F=n=>e=>n.onTap(e);class g extends o.Composite{set onSelect(e){F(this)(e)}get onSelect(){return F(this)}constructor(e){super(p({left:0,right:0,padding:10,top:"prev()",highlightOnTouch:!0},e)),ne(this.key)||I(this.key,this.value);const t=this.summary.length===0?!0:0,r={text:this.title.toCapitalize()};t?r.centerY=!0:r.top="prev()",this.append(new o.TextView(r)),this.summary.length>0&&this.append(new o.TextView(p({text:this.summary,top:["prev()",0]},Ce)))}}C(g.prototype,"title",{type:"string",default:""});C(g.prototype,"summary",{type:"string",default:""});C(g.prototype,"key",{type:"string",default:""});C(g.prototype,"value",{type:"string",default:""});class B extends g{constructor(e){var s;let t;const r=e.onSelect;e.onSelect=()=>t&&(t.checked=!t.checked),super(e),t=this._getButton({right:0,centerY:!0,checked:(s=q(this.key))!=null?s:this.value}),typeof t!="undefined"&&(this.addListener(t,r),this.append(t))}addListener(e,t){e.on("checkedChanged",r=>{I(this.key,e.checked),typeof t=="function"&&t.call(this,r)})}}class re extends B{constructor(e){super(e)}_getButton(e){return new o.CheckBox(e)}}const xe=P(re);class oe extends B{constructor(e){super(e)}_getButton(e){return new o.Switch(e)}}const De=P(oe);class se extends g{constructor(e){super(e)}}const Se=P(se);class ie extends o.Page{constructor(e){super(V(p({},e),{layoutData:"stretch"}))}}const ke=P(ie);class j extends B{_getButton(){}constructor(e){const t=e.onSelect;super(e),this.onSelect(()=>{const s=new Z({title:this.title.toCapitalize()});this.entries&&this.entries.length>0&&s.addView(...this.entries.map((i,u)=>{var c;const l=o.RadioButton({text:i.text,checked:(c=i.checked)!=null?c:parseInt(q(this.key))===u,layoutData:{top:[o.LayoutData.prev,5],left:0,right:0}}).onSelect(d=>{d.checked&&(I(this.key,u),typeof t=="function"&&t.call(this,d))});return i.id&&(l.id=i.id),l})),s.setButtonAccept(this.textButtonAccept.toUpperCase()).addListener(r.bind(s)),s.show()});function r(){this.remove()}}}const _e=P(j);C(j.prototype,"entries",{type:"any",default:[]});C(j.prototype,"textButtonAccept",{type:"string",default:"accept"});let W;o.contentView.on("addChild",({child:n})=>{n instanceof o.NavigationView&&!W&&(W=n)});function ae(...n){return W.append(...n)}class Me{constructor(){const e=[];if(typeof this.renderAction=="function"){const t=this.renderAction();t&&e.push(...Array.from(t))}ae(...e,this.render())}}const Ve=Object.freeze({Render:Me,factory(n){return pe(n)}});exports.$preference=k;exports.AbstractItemPreference=g;exports.AnimationTime=T;exports.CheckBoxPreference=xe;exports.CheckBoxPreferenceComponent=re;exports.Checked=B;exports.CoordinatePage=Pe;exports.CoordinatePageComponent=D;exports.DrawerMenu=we;exports.DrawerMenuItem=ge;exports.ListPreference=_e;exports.ListPreferenceComponent=j;exports.MenuAction=Y;exports.MenuItem=A;exports.Modal=Z;exports.PreferenceScreen=ke;exports.PreferenceScreenComponent=ie;exports.SwitchPreference=De;exports.SwitchPreferenceComponent=oe;exports.TextPreference=Se;exports.TextPreferenceComponent=se;exports.Toast=O;exports.Voir=Ve;exports.addView=ae;exports.animate=Q;exports.animateHidden=N;exports.animateShow=H;exports.existsKeyPreference=ne;exports.getValuePreference=q;exports.menuDrawer=ye;exports.name_key_pref=S;exports.setContentDrawer=te;exports.setMenuDrawer=X;exports.setPreference=I; +"use strict";var ye=Object.defineProperty,ve=Object.defineProperties;var be=Object.getOwnPropertyDescriptors;var oe=Object.getOwnPropertySymbols;var Ce=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var N=(n,t,e)=>t in n?ye(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,m=(n,t)=>{for(var e in t||(t={}))Ce.call(t,e)&&N(n,e,t[e]);if(oe)for(var e of oe(t))Pe.call(t,e)&&N(n,e,t[e]);return n},V=(n,t)=>ve(n,be(t));var u=(n,t,e)=>N(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("tabris");require("string-tocapitalize");function O(n){return new Proxy(n,{apply(e,r,s){return Reflect.construct(e,s)}})}function De(n){const t={get(e,r,s){return Reflect.get(e,r,s)},apply(e,r,s){return typeof e.name=="string"&&typeof e.constructor=="function"?Reflect.construct(e,s):Reflect.apply(null,e,s)}};return new Proxy(n,t)}const A=(n,t,e)=>o.NativeObject.defineProperty(n,t,e),xe=o.version.toString(),f=/(2\.9)\.*/.test(xe),w=f?o.ui.contentView:o.contentView;f&&(global.$=function(e,r){return r?new o.WidgetCollection(r):w.find(e)},Object.keys(o.Widget.prototype.gestures).forEach(t=>{const e="on"+t.toCapitalize();Object.defineProperty(o.Widget.prototype,e,{value:function(r){return this.on(t,r)}})}),Object.defineProperty(o.Widget.prototype,"onSelect",{get(){return t=>this.on("select",t)}}));const J={left:0,right:0,top:0,bottom:0},K={top:0,bottom:0},U={right:0,left:0},p={stretch:J,stretchX:U,stretchY:K,centerX:f?0:!0,centerY:f?0:!0};Object.defineProperty(o.Widget.prototype,"stretch",{set(n){return this.layoutData=J,!0},get(){return this.layoutData}});Object.defineProperty(o.Widget.prototype,"stretchX",{set(n){return this.layoutData=U,!0},get(){return this.layoutData}});Object.defineProperty(o.Widget.prototype,"stretchY",{set(n){return this.layoutData=K,!0},get(){return this.layoutData}});const _e=f?o.ui.statusBar:o.statusBar,Se=f?o.ui.navigationBar:o.navigationBar,k=f?o.ui.drawer:o.drawer,ke=f?function(t={}){return"placement"in t&&(t.placementPriority=t.placement==="overflow"?"low":t.placement==="default"?"normal":"high",delete t.placement),"placementChanged"in t&&(t.placementPriorityChanged=t.placementChanged,delete t.placementChanged),new o.Action(t)}:o.Action,ie=f?class extends o.Composite{constructor(e){super(e);u(this,"_initPrevent",!1)}get alignment(){return"alignment"}set alignment(e){this._alignment=e}set layoutData(e){super.layoutData=p[e]}_addChild(e){var r;return e.left=`prev() ${(r=e.left)!=null?r:0}`,e[this._alignment]=0,super._addChild(e)}}:o.Row,G=f?class{constructor(t,e){this.target=t,this.event=e}addListener(t){this.target.on(this.event,t)}trigger(t){return this.target.trigger(this.event,t)}}:o.Listeners,Oe=f?class{constructor(){}}:o.LayoutData;class E{}u(E,"LONG",3e3),u(E,"MEDIUM",2100),u(E,"SHORT",1500);function F(n,t,e){return n.animate({opacity:1},{delay:t!=null?t:0,duration:e,easing:"ease-in"})}function Q(n,t,e){return n.animate({opacity:0},{delay:t,duration:e,easing:"ease-out"})}function ae(n,t,e){return Promise.resolve(F(n,t,300)).then(()=>Promise.resolve(Q(n,e,e)))}class Ae extends o.EventObject{}class ce{constructor(t={}){const e=[];let r,s,i=!1,c=!1,h=!1;const{width:b}=w.bounds,{screenWidth:C}=tabris.device,d=560,g={elevation:24,centerY:p.centerY,padding:10,cornerRadius:5,opacity:0,background:"white",id:"modal-container"};d>C||d>b?Object.assign(g,{left:24,right:24}):Object.assign(g,{width:d});const P=new o.Composite(V(m({},p.stretch),{opacity:1,highlightOnTouch:!1,background:"rgba(0, 0, 0, 0.50)"})).onTap(l=>l.preventDefault()),a=new o.Composite(g).appendTo(P);"title"in t&&a.append(new o.TextView({id:"modal-title",font:"medium 18px",padding:10,left:0,right:0,text:t.title.toCapitalize()}));const v=new o.Composite(m({top:"#modal-title",bottom:"prev()"},p.stretchX)),X=new o.ScrollView({layoutData:p.stretchX,id:"modal_content_scrollable"}).appendTo(v);a.on("boundsChanged",({value:l})=>{const{height:_}=w.bounds;__?d-(d>_?20+d-_:0):d>l.height?l.height:d})),v.set(m({},v.layoutData)),X.set(p.stretch))}),Object.defineProperty(this,"setButtonAccept",{configurable:!1,value:l=>(r||(r=ne("accept",l)),r)}),Object.defineProperty(this,"setButtonCancel",{configurable:!1,value:l=>(s||(s=ne("cancel",l)),s)}),Object.defineProperty(this,"addView",{configurable:!1,value:(...l)=>X.append(l)}),Object.defineProperty(this,"show",{configurable:!1,value:()=>{i||(i=!0,a.append(new o.Composite({layoutData:p.stretchX,id:"buttons-modal",bottom:0}).append(e))),(!h||c)&&(h=!0,c=!1,a.append(v),w.append(P),F(a,0,100))}}),Object.defineProperty(this,"removeView",{configurable:!1,value:()=>X.children().dispose()}),Object.defineProperty(this,"removeButtons",{configurable:!1,value:()=>{r=s=null,e.forEach(l=>{l.dispose()})}}),Object.defineProperty(this,"remove",{configurable:!1,value:()=>{c||Q(P,0,250).then(()=>{c=!0,h=!1,P.detach()})}});function ne(l,_){const H=new o.Button({text:_,top:"#modal_content_scrollable",right:"prev()",bottom:0,style:"text"}),re=new G(H,l);return H.on("tap",()=>re.trigger(new Ae)),e.push(H),re}}}let D=[];class j extends E{constructor(e,r){var g,P;super();u(this,"show");u(this,"_message",new o.TextView({textColor:"white",left:0,right:0}));u(this,"_modal",new o.Composite({background:"black",padding:10,cornerRadius:10,bottom:30,opacity:0}).append(this._message));const s="12px",i=20,c=20,h=(P=(g=o.sizeMeasurement)==null?void 0:g.measureTextsSync([{text:e,font:s}]))!=null?P:[{width:-1,height:-1}];f&&this._modal.once("boundsChanged",({target:a,value:{width:v}})=>{v>w.bounds.width&&a.set({left:i,right:c,centerX:void 0})}),h[0].width>w.bounds.width-20?(this._modal.left=i,this._modal.right=c):this._modal.centerX=f?0:!0,this._message.text=e,this._message.font=s,Object.defineProperty(this,"show",{configurable:!1,value:()=>{if(D.length===1&&C(),D.length>0)D.push({element:this._modal,promise:()=>new Promise(a=>{a(d(this._modal))})});else{const a=d(this._modal);D.push({promise:()=>a,element:this._modal})}}});const C=()=>{if(D.length===0)return;const{promise:a,element:v}=D[0];a().then(()=>{D.shift(),v.dispose(),C()}).catch(console.log)};function d(a){return w.append(a),ae(a,0,r)}}static makeText(e,r=j.SHORT){return new j(e,r)}}const $=new Map;function Ve(n){return n instanceof Object&&n.constructor?n.constructor:n}function le(n){return $.get(Ve(n))}S.addListener=(n,t,e)=>{const{store:r}=le(n);r.has(n)||r.set(n,{event:{},listeners:new WeakMap}),r.get(n).event[t]=e};S.listener=(n,t)=>{const{instanceOf:e,store:r}=le(n);for(let{listeners:s,element:i,invoke:c}of e){if(!(t instanceof i))continue;const h=r.get(n);h&&(h.listeners.has(t)||h.listeners.set(t,s.map(b=>{const C=new G(t,b);return C.addListener(d=>{for(let g of c)h.event[g](d.target,d)}),C})))}};function S(n,t){$.has(n)||$.set(n,V(m({},t),{store:new WeakMap}))}class Z extends o.Composite{constructor(t){super({id:t,top:"prev()",right:0,left:0,height:56,highlightOnTouch:!0})}}class I extends ie{constructor(e){super({layoutData:"stretch",alignment:"centerY"});u(this,"text");u(this,"image");this.id=e.id,this._setElements(e.image,e.text)}_setElements(e,r){const s="voir-img-ref-"+this.id,i="voir-text-ref-"+this.id;e&&this.append(new o.ImageView({image:e,width:24,left:28,id:s}));const c=e?12:64;this.append(new o.TextView({text:r,font:"20px sans-serif",left:c,id:i}))}}const Ee=I,Me=({children:n},t)=>new o.WidgetCollection(n!=null?n:t),Be=(n,t)=>{console.warn("deprecated function [menuDrawer] use setMenuDrawer"),ee(n,t)};function ue(){const n=k.find("#scrollableLayoutMenuDrawer"),t=n.length!==0?n.first():new o.ScrollView({id:"scrollableLayoutMenuDrawer",top:"prev()",left:0,right:0,bottom:0});return n.length===0&&k.append(t),t}function ee(n,t){ue().append(n.map(e=>{const r=e instanceof I,s=e.id;return r&&(e.id=""),new Z(s).append(r?e:new I({image:e.image,text:e.text})).on("tap",function(){typeof t=="function"&&t(this);const i=setTimeout(()=>(k.close(),clearTimeout(i)),100)})}))}function de(n){const t=ue(),e=k.find("#voirContentDrawer"),r=e.length===0?new o.Composite({top:"prev() 15",left:0,right:0,id:"voirContentDrawer",padding:8}).append(n):e.first().append(n);e.length===0&&t.append(r)}const x=new Map,W=class W extends o.NavigationView{constructor(e){super(e);u(this,"onActionSelected");u(this,"onDrawerItemSelected");u(this,"_renderWidgetInDrawer",(()=>{let e=!1;return()=>{if(e)return;e=!0;const r=()=>{ee(this.menuDrawer),de(this.contentDrawer),this.menuDrawer.forEach(s=>{S.listener(this,s.parent())})};this.drawerActionVisible&&r()}})());this.$actions=[]}set contentDrawer(e){this._contentDrawer=e}get contentDrawer(){var e;return(e=this._contentDrawer)!=null?e:new o.WidgetCollection}set menuDrawer(e){this._dataMenuDrawer=e.toArray()}get menuDrawer(){var e;return(e=this._dataMenuDrawer)!=null?e:[]}on(e,r,s){return typeof e=="string"&&W.events.includes(e)&&S.addListener(this,e,r),super.on(e,r,s)}_addChild(e){S.listener(this,e),e instanceof o.Page&&(x.set(e,{hidden:!1,actions:null,isDisposed:!1}),e.on("appear",()=>{this._renderWidgetInDrawer();const s=x.get(e);typeof s=="object"&&s.hidden&&(s.actions!==null&&this.append(s.actions),s.hidden=!1),x.size===1&&r(!0)}),e.on("disappear",()=>{var i;const s=x.get(e);r(!1),s.hidden||(s.hidden=!0,(i=s.actions)==null||i.forEach(c=>c.detach())),s.isDisposed&&x.delete(e)}),e.on("dispose",()=>{x.get(e).isDisposed=!0}));const r=s=>{this!=null&&this.drawerActionVisible&&(k.enabled=s)};return typeof super._addChild=="function"?super._addChild(e):this}append(...e){const r=super.append(...e);return setTimeout(()=>Te(e),0),r}};u(W,"events",["actionSelected","drawerItemSelected"]);let B=W;function Le(n){const t=n.find(s=>s instanceof o.Page),e=n.filter(s=>s instanceof o.Action||s instanceof o.SearchAction?s.data.voirInitializedEvent=!0:!1),r=x.get(t);return t&&e.length&&r.actions===null&&(r.actions=e),r}function Te(n){let t=n.length>1?n:Array.isArray(n[0])?n.shift():n;if(t.some(e=>Array.isArray(e)))throw new Error("error parameter");if(Array.isArray(t)&&t.length>0)return Le(t)}S(B,{instanceOf:[{element:o.Action,listeners:["select"],invoke:["actionSelected"]},{element:o.SearchAction,listeners:["select"],invoke:["actionSelected"]},{element:Z,listeners:["tap"],invoke:["drawerItemSelected"]}],nameEvents:["actionSelected","drawerItemSelected"]});const je=O(B),L="voir-native-preference";localStorage.getItem(L)||localStorage.setItem(L,"{}");const T=JSON.parse(localStorage.getItem(L)),R=(n,t)=>{T[n]=t,localStorage.setItem(L,JSON.stringify(T))},te=n=>T[n],fe=n=>n in T,Ie={left:0,right:"10%"},se=n=>t=>n.on("tap",t),M=class M extends o.Composite{constructor(e){super(m({left:0,right:0,padding:10,top:"prev()",highlightOnTouch:!0},e));u(this,"_customEvent",{});fe(this.key)||R(this.key,this.value);const r=this.summary.length===0?!0:0,s={text:this.title.toCapitalize()};r?s.centerY=p.centerY:s.top="prev()",this.append(new o.TextView(s)),this.summary.length>0&&this.append(new o.TextView(m({text:this.summary,top:["prev()",0]},Ie)))}set onSelect(e){se(this)(e)}get onSelect(){return se(this)}on(e,r,s){if(typeof e=="string"&&M.typeEvents.includes(e))this._customEvent[e]=r;else if(e instanceof Object)for(let i in e)M.typeEvents.includes(i)&&(this._customEvent[i]=e[i]);return super.on(e,r,s)}};u(M,"typeEvents",["select"]);let y=M;A(y.prototype,"title",{type:"string",default:""});A(y.prototype,"summary",{type:"string",default:""});A(y.prototype,"key",{type:"string",default:""});A(y.prototype,"value",{type:"string",default:""});class Y extends y{constructor(t){var r;let e;t.onSelect=()=>e&&(e.checked=!e.checked),super(t),e=this._getButton({right:0,centerY:p.centerY,checked:(r=te(this.key))!=null?r:this.value}),typeof e!="undefined"&&(this.addListener(e),this.append(e))}addListener(t){t.on("checkedChanged",e=>{R(this.key,t.checked),typeof this._customEvent.select=="function"&&this._customEvent.select.call(this,e)})}_getButton(t){throw new Error("implements method")}}class he extends Y{constructor(t){super(t)}_getButton(t){return new o.CheckBox(t)}}const We=O(he);class pe extends Y{constructor(t){super(t)}_getButton(t){return new o.Switch(t)}}const Re=O(pe);class ge extends y{constructor(t){super(t)}}const Ye=O(ge);class me extends o.Page{constructor(t={}){super(V(m({},t),{layoutData:p.stretch}))}}const ze=O(me);class z extends Y{_getButton(){}constructor(t){super(t),this.onSelect(()=>{const r=new ce({title:this.title.toCapitalize()});this.entries&&this.entries.length>0&&r.addView(...this.entries.map((s,i)=>{var h;const c=new o.RadioButton({text:s.text,checked:(h=s.checked)!=null?h:parseInt(te(this.key))===i,top:"prev() 5",left:0,right:0}).onSelect(b=>{b.checked&&(R(this.key,i),typeof this._customEvent.select=="function"&&this._customEvent.select.call(this,b))});return s.id&&(c.id=s.id),c})),r.setButtonAccept(this.textButtonAccept.toUpperCase()).addListener(e.bind(r)),r.show()});function e(){this.remove()}}}const Xe=O(z);A(z.prototype,"entries",{type:"any",default:[]});A(z.prototype,"textButtonAccept",{type:"string",default:"accept"});let q;w.on("addChild",({child:n})=>{n instanceof o.NavigationView&&!q&&(q=n)});function we(...n){return q.append(...n)}class He{constructor(){const t=[];if(typeof this.renderAction=="function"){const e=this.renderAction();e&&t.push(...Array.from(e))}we(...t,this.render())}}const Ne=Object.freeze({Render:He,factory(n){return De(n)}});exports.$preference=T;exports.AbstractItemPreference=y;exports.Action=ke;exports.AnimationTime=E;exports.CheckBoxPreference=We;exports.CheckBoxPreferenceComponent=he;exports.Checked=Y;exports.CoordinatePage=je;exports.CoordinatePageComponent=B;exports.DrawerMenu=Me;exports.DrawerMenuItem=Ee;exports.LayoutData=Oe;exports.ListPreference=Xe;exports.ListPreferenceComponent=z;exports.Listeners=G;exports.MenuAction=Z;exports.MenuItem=I;exports.Modal=ce;exports.PreferenceScreen=ze;exports.PreferenceScreenComponent=me;exports.Row=ie;exports.SwitchPreference=Re;exports.SwitchPreferenceComponent=pe;exports.TextPreference=Ye;exports.TextPreferenceComponent=ge;exports.Toast=j;exports.Voir=Ne;exports.addView=we;exports.animate=ae;exports.animateHidden=Q;exports.animateShow=F;exports.contentView=w;exports.drawer=k;exports.existsKeyPreference=fe;exports.getValuePreference=te;exports.isVersion2=f;exports.layoutData=p;exports.menuDrawer=Be;exports.name_key_pref=L;exports.navigationBar=Se;exports.setContentDrawer=de;exports.setMenuDrawer=ee;exports.setPreference=R;exports.statusBar=_e;exports.stretch=J;exports.stretchX=U;exports.stretchY=K; diff --git a/vite.config.js b/vite.config.js index 69d2d80..742efd7 100644 --- a/vite.config.js +++ b/vite.config.js @@ -7,7 +7,7 @@ export default { target: 'es2015', outDir: 'dist', lib: { - entry: 'src/index.ts', + entry: 'src/index.js', formats: ['cjs'], fileName: 'index' },