aio-popup 3.0.19 → 3.0.21

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.
Files changed (2) hide show
  1. package/index.js +1 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- function _defineProperty(t,e,o){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==typeof e?e:String(e)}function _toPrimitive(t,e){if("object"!=typeof t||null===t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var i=o.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}import t,{Component as e,createRef as o,useEffect as i}from"react";import*as s from"react-dom/server";import{Icon as r}from"@mdi/react";import{mdiClose as a,mdiChevronRight as l,mdiChevronLeft as n}from"@mdi/js";import p from"react-virtual-dom";import d from"jquery";import"./index.css";import{jsx as h}from"react/jsx-runtime";import{Fragment as m}from"react/jsx-runtime";import{jsxs as u}from"react/jsx-runtime";export default class c{constructor(t={}){_defineProperty(this,"render",()=>u(m,{children:[h(Popups,{rtl:this.rtl,getActions:({addModal:t,removeModal:e,getModals:o})=>{this._addModal=t,this._removeModal=e,this._getModals=o}}),h(AIOSnackeBar,{rtl:this.rtl,getActions:({add:t})=>{this._addSnakebar=t}})]})),_defineProperty(this,"getModals",()=>this._getModals()),_defineProperty(this,"addModal",(t={},e=!0)=>{void 0===t.id&&(t.id="popup"+Math.round(1e6*Math.random())),this._addModal(t,e)}),_defineProperty(this,"addConfirm",t=>{let{title:e,subtitle:o,text:i,buttons:s}=t,r={position:"center",attrs:{className:"aio-popup-confirm"},header:{title:e,subtitle:o},backdrop:{attrs:{className:"rsa-backdrop"}},body:{render:()=>i},footer:{buttons:s}};this.addModal(r)}),_defineProperty(this,"addPrompt",t=>{let{title:e,subtitle:o,text:i,submitText:s="تایید",canselText:r="بستن",onSubmit:a}=t,l={position:"center",attrs:{className:"aio-popup-prompt"},state:{temp:""},header:{title:e,subtitle:o},backdrop:{attrs:{className:"rsa-backdrop"}},body:{render:({state:t,setState:e})=>h("textarea",{placeholder:i,onChange:t=>e({temp:t.target.value}),children:t.temp})},footer:{buttons:[[r,{onClick:()=>this.removeModal()}],[s,({state:t,setState:e})=>({onClick:async({state:t})=>{!1!==await a(t.temp)?this.removeModal():e({temp:""})},disabled:!t.temp,className:"active"})]]}};this.addModal(l)}),_defineProperty(this,"removeModal",(t,e=!0)=>{this._removeModal&&this._removeModal(t,e)}),_defineProperty(this,"addAlert",(t={})=>{let{icon:e,type:o="",text:i="",subtext:s="",time:r=10,className:a,closeText:l="بستن"}=t;Alert({icon:e,type:o,text:i,subtext:s,time:r,className:a,closeText:l})}),_defineProperty(this,"addSnakebar",(t={})=>{let{text:e,index:o,type:i,subtext:s,action:r={},time:a=6,rtl:l}=t;this._addSnakebar({text:e,index:o,type:i,subtext:s,action:r,time:a,rtl:l})}),this.rtl=t.rtl}};class Popups extends e{constructor(t){super(t),this.dom=o();let{getActions:e=()=>{}}=t;this.state={modals:[]},e({removeModal:this.removeModal.bind(this),addModal:this.addModal.bind(this),getModals:()=>[...this.state.modals]})}change(t){let{onChange:e=()=>{}}=this.props;for(let o in t)this.state[o]=t[o];this.setState(t,()=>e({...this.state}))}addModal(t,e=!0){if("object"!=typeof t){console.error("aio-popup => addModal modal parameter to add is not an object");return}if(void 0===t.id){console.error("aio-popup => addModal missing modal id property");return}let{modals:o}=this.state,i=o.filter(({id:e})=>e!==t.id);i.push({...t,mounted:"popover"!==t.position&&!e}),this.change({modals:i})}async removeModal(t="last",e=!0){if("all"===t)this.change({modals:[]});else{let{modals:o}=this.state;if(!o.length)return;"last"===t&&(t=o[o.length-1].id),this.mount(t,!1),setTimeout(()=>{let{modals:e}=this.state,o=e.find(e=>e.id===t);o&&(o.onClose&&o.onClose(),this.change({modals:e.filter(e=>e.id!==t)}))},e?300:0)}}mount(t="last",e){try{let{modals:o}=this.state;"last"===t&&(t=o[o.length-1].id);let i=o.map(o=>o.id===t?{...o,mounted:e}:o);this.change({modals:i})}catch{return}}getModals(){let{modals:t}=this.state;return t.length?t.map((e,o)=>{let{popover:i,position:s,text:r,onSubmit:a,rtl:l=this.props.rtl,attrs:n={},backdrop:p,header:d,state:m,footer:u,closeType:c,body:_,id:$,mounted:g}=e;return h(Popup,{id:$,backdrop:p,footer:u,text:r,onSubmit:a,header:d,popover:i,state:m,position:s,rtl:l,attrs:n,closeType:c,body:_,index:o,isLast:o===t.length-1,mounted:g,onClose:()=>this.removeModal($),removeModal:this.removeModal.bind(this),onMount:()=>this.mount($,!0)},$)}):null}render(){return h(m,{children:this.getModals()})}}class Popup extends e{constructor(t){super(t),this.dom=o(),this.backdropDom=o(),this.state={popoverStyle:void 0,state:t.state}}async onClose(t){let{onClose:e}=this.props;e(t)}componentWillUnmount(){d(window).unbind("click",this.handleBackClick)}updatePopoverStyle(){let{position:t}=this.props;if("popover"===t){let e=this.getPopoverStyle();JSON.stringify(e)!==JSON.stringify(this.state.popoverStyle)&&this.setState({popoverStyle:e})}}componentDidMount(){let{popover:t={},position:e}=this.props;if(setTimeout(()=>{let{mounted:t,onMount:o}=this.props;this.setState({popoverStyle:"popover"===e?this.getPopoverStyle():{}}),t||o()},0),t.getTarget){this.dui="a"+Math.round(1e7*Math.random());t.getTarget().attr("data-uniq-id",this.dui)}d(window).unbind("click",this.handleBackClick),d(window).bind("click",d.proxy(this.handleBackClick,this))}handleBackClick(t){if(!this.dui)return;let{position:e="fullscreen"}=this.props,o=d(t.target);"popover"===e&&o.attr("data-uniq-id")!==this.dui&&!o.parents(`[data-uniq-id=${this.dui}]`).length&&this.onClose()}header_layout(){let{rtl:t,header:e}=this.props;if("object"!=typeof e)return!1;let{state:o}=this.state;return{html:h(ModalHeader,{rtl:t,header:e,handleClose:t=>this.onClose(t),state:o,setState:t=>this.setState({state:t})}),className:"of-visible"}}body_layout(){let{body:t={}}=this.props,{state:e}=this.state;return{flex:1,html:h(ModalBody,{body:t,state:e,setState:t=>this.setState({state:t}),handleClose:this.onClose.bind(this),updatePopoverStyle:()=>this.updatePopoverStyle()})}}footer_layout(){let{closeText:t,submitText:e,onSubmit:o,footer:i,type:s}=this.props,{state:r}=this.state,a=this.onClose.bind(this);return{html:h(ModalFooter,{closeText:t,submitText:e,onSubmit:o,footer:i,type:s,handleClose:a,state:r,setState:t=>this.setState({state:t})})}}getBackDropClassName(){let{rtl:t,position:e="fullscreen",backdrop:o,mounted:i}=this.props,s="aio-popup-backdrop";return o&&o.attrs&&o.attrs.className&&(s+=" "+o.attrs.className),s+=` aio-popup-position-${e}`,s+=t?" rtl":" ltr",i||(s+=" not-mounted"),s}backClick(t){if(this.isDown)return;t.stopPropagation();let e=d(t.target),{backdrop:o={}}=this.props;!1!==o.close&&e.hasClass("aio-popup-backdrop")&&this.onClose()}getPopoverStyle(){let{popover:t={},rtl:e,attrs:o={}}=this.props,{getTarget:i,pageSelector:s,fitHorizontal:r,fixStyle:a=t=>t}=t;if(!i)return{};let l=i();if(!l||!l.length)return{};let n=d(this.dom.current);return{...Align(n,l,{fixStyle:a,pageSelector:s,fitHorizontal:r,style:o.style,rtl:e}),position:"absolute"}}keyDown(t){let{isLast:e,removeModal:o}=this.props;if(e)27===t.keyCode&&o()}mouseUp(){setTimeout(()=>this.isDown=!1,0)}mouseDown(t){d(window).unbind("mouseup",this.mouseUp),d(window).bind("mouseup",d.proxy(this.mouseUp,this)),this.isDown=!0}render(){let{rtl:t,attrs:e={},backdrop:o={},mounted:i}=this.props,{popoverStyle:s}=this.state,r={...o?o.attrs:{},className:this.getBackDropClassName(),onClick:!1===o?void 0:t=>this.backClick(t)},a={...s,...e.style,flex:"none"},l="aio-popup"+(t?" rtl":" ltr")+(i?"":" not-mounted")+(e.className?" "+e.className:""),n="ontouchstart"in document.documentElement?"onTouchStart":"onMouseDown";return h("div",{...r,ref:this.backdropDom,onKeyDown:this.keyDown.bind(this),tabIndex:0,children:h(p,{layout:{attrs:{...e,ref:this.dom,style:void 0,className:void 0,"data-uniq-id":this.dui,[n]:this.mouseDown.bind(this)},className:l,style:a,column:[this.header_layout(),this.body_layout(),this.footer_layout()]}})})}}function ModalHeader({rtl:t,header:e,handleClose:o,state:i,setState:s}){if("object"!=typeof e)return null;let{title:d,subtitle:m,buttons:u=[],onClose:c,backButton:_,attrs:$={}}=e;function g(){c?c({state:i,setState:s}):o({state:i,setState:s})}let f="aio-popup-header"+($.className?" "+$.className:""),v=$.style;return h(p,{layout:{attrs:$,className:f,style:v,row:[function e(){if(!_||!1===c)return!1;let o,i;return t?(o=l,i={marginLeft:12}):(o=n,i={marginRight:12}),{html:h(r,{path:o,size:1}),align:"vh",onClick:()=>g(),style:i}}(),!!d&&(m?{flex:1,align:"v",column:[{html:d,className:"aio-popup-title"},{html:m,className:"aio-popup-subtitle"}]}:{flex:1,align:"v",html:d,className:"aio-popup-title"}),!!u.length&&{gap:6,align:"vh",row:()=>u.map(([t,e={}])=>{let{onClick:r=()=>{},className:a}=e,l={...e};return l.className="aio-popup-header-button"+(a?" "+a:""),l.onClick=()=>r({close:o,state:i,setState:s}),{html:h("button",{...l,children:t}),align:"vh"}})},!_&&!1!==c&&{html:h(r,{path:a,size:.8}),align:"vh",onClick:()=>g(),className:"aio-popup-header-close-button"}]}})}function ModalBody(t){let{handleClose:e,body:o,updatePopoverStyle:s,state:r,setState:a}=t,{render:l,attrs:n={}}=o,p="function"==typeof l?l({close:e,state:r,setState:a}):l;return i(()=>{s()},[p]),h("div",{...n,className:"aio-popup-body"+(n.className?" "+n.className:""),children:"function"==typeof l&&p})}function ModalFooter({footer:t,handleClose:e,state:o,setState:i}){if("object"!=typeof t)return null;let{attrs:s={},buttons:r=[]}=t,a;return h("div",{className:"aio-popup-footer"+(s.className?" "+s.className:""),style:s.style,children:r.length?r.map(([t,s={}])=>{let{onClick:r=()=>{},className:a}="function"==typeof s?s({state:o,setState:i}):s,l={...s};return l.className="aio-popup-footer-button"+(a?" "+a:""),l.onClick=()=>r({close:e,state:o,setState:i}),h("button",{...l,children:t})}):null})}function Alert(t={}){let{icon:e,type:o,text:i,subtext:r,time:a,className:l,closeText:n}=t,p={time:0,getId:()=>"aa"+Math.round(1e8*Math.random()),getBarRender:()=>`<div class='aio-popup-time-bar' style="width:${p.time}%;"></div>`,updateBarRender(){d(`.aio-popup-alert-container.${p.id} .aio-popup-time`).html(p.getBarRender())},getRender:()=>`
1
+ function _defineProperty(t,e,o){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==typeof e?e:String(e)}function _toPrimitive(t,e){if("object"!=typeof t||null===t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var i=o.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}import t,{Component as e,createRef as o,useEffect as i}from"react";import*as s from"react-dom/server";import{Icon as r}from"@mdi/react";import{mdiClose as a,mdiChevronRight as l,mdiChevronLeft as n}from"@mdi/js";import p from"react-virtual-dom";import d from"jquery";import"./index.css";import{jsx as h}from"react/jsx-runtime";import{Fragment as m}from"react/jsx-runtime";import{jsxs as u}from"react/jsx-runtime";export default class c{constructor(t={}){_defineProperty(this,"render",()=>u(m,{children:[h(Popups,{rtl:this.rtl,getActions:({addModal:t,removeModal:e,getModals:o})=>{this._addModal=t,this._removeModal=e,this._getModals=o}}),h(AIOSnackeBar,{rtl:this.rtl,getActions:({add:t})=>{this._addSnakebar=t}})]})),_defineProperty(this,"getModals",()=>this._getModals()),_defineProperty(this,"addModal",(t={},e=!0)=>{void 0===t.id&&(t.id="popup"+Math.round(1e6*Math.random())),this._addModal(t,e)}),_defineProperty(this,"addConfirm",t=>{let{title:e,subtitle:o,text:i,submitText:s="بله",canselText:r="خیر",onSubmit:a,onCansel:l=()=>{}}=t,n={position:"center",attrs:{className:"aio-popup-confirm"},header:{title:e,subtitle:o},backdrop:{attrs:{className:"rsa-backdrop"}},body:{render:()=>i},footer:{buttons:[[r,{onClick:()=>{l(),this.removeModal()}}],[s,{onClick:async()=>{!1!==await a()&&this.removeModal()},className:"active"}]]}};this.addModal(n)}),_defineProperty(this,"addPrompt",t=>{let{title:e,subtitle:o,text:i,submitText:s="تایید",canselText:r="بستن",onSubmit:a,onCansel:l=()=>{}}=t,n={position:"center",attrs:{className:"aio-popup-prompt"},state:{temp:""},header:{title:e,subtitle:o},backdrop:{attrs:{className:"rsa-backdrop"}},body:{render:({state:t,setState:e})=>h("textarea",{placeholder:i,value:t.temp,onChange:t=>e({temp:t.target.value})})},footer:{buttons:[[r,{onClick:()=>{l(),this.removeModal()}}],[s,({state:t,setState:e})=>({onClick:async({state:t})=>{!1!==await a(t.temp)?this.removeModal():e({temp:""})},disabled:!t.temp,className:"active"})]]}};this.addModal(n)}),_defineProperty(this,"removeModal",(t,e=!0)=>{this._removeModal&&this._removeModal(t,e)}),_defineProperty(this,"addAlert",(t={})=>{let{icon:e,type:o="",text:i="",subtext:s="",time:r=10,className:a,closeText:l="بستن"}=t;Alert({icon:e,type:o,text:i,subtext:s,time:r,className:a,closeText:l})}),_defineProperty(this,"addSnakebar",(t={})=>{let{text:e,index:o,type:i,subtext:s,action:r={},time:a=6,rtl:l}=t;this._addSnakebar({text:e,index:o,type:i,subtext:s,action:r,time:a,rtl:l})}),this.rtl=t.rtl}};class Popups extends e{constructor(t){super(t),this.dom=o();let{getActions:e=()=>{}}=t;this.state={modals:[]},e({removeModal:this.removeModal.bind(this),addModal:this.addModal.bind(this),getModals:()=>[...this.state.modals]})}change(t){let{onChange:e=()=>{}}=this.props;for(let o in t)this.state[o]=t[o];this.setState(t,()=>e({...this.state}))}addModal(t,e=!0){if("object"!=typeof t){console.error("aio-popup => addModal modal parameter to add is not an object");return}if(void 0===t.id){console.error("aio-popup => addModal missing modal id property");return}let{modals:o}=this.state,i=o.filter(({id:e})=>e!==t.id);i.push({...t,mounted:"popover"!==t.position&&!e}),this.change({modals:i})}async removeModal(t="last",e=!0){if("all"===t)this.change({modals:[]});else{let{modals:o}=this.state;if(!o.length)return;"last"===t&&(t=o[o.length-1].id),this.mount(t,!1),setTimeout(()=>{let{modals:e}=this.state,o=e.find(e=>e.id===t);o&&(o.onClose&&o.onClose(),this.change({modals:e.filter(e=>e.id!==t)}))},e?300:0)}}mount(t="last",e){try{let{modals:o}=this.state;"last"===t&&(t=o[o.length-1].id);let i=o.map(o=>o.id===t?{...o,mounted:e}:o);this.change({modals:i})}catch{return}}getModals(){let{modals:t}=this.state;return t.length?t.map((e,o)=>{let{popover:i,position:s,text:r,onSubmit:a,rtl:l=this.props.rtl,attrs:n={},backdrop:p,header:d,state:m,footer:u,closeType:c,body:_,id:$,mounted:g}=e;return h(Popup,{id:$,backdrop:p,footer:u,text:r,onSubmit:a,header:d,popover:i,state:m,position:s,rtl:l,attrs:n,closeType:c,body:_,index:o,isLast:o===t.length-1,mounted:g,onClose:()=>this.removeModal($),removeModal:this.removeModal.bind(this),onMount:()=>this.mount($,!0)},$)}):null}render(){return h(m,{children:this.getModals()})}}class Popup extends e{constructor(t){super(t),this.dom=o(),this.backdropDom=o(),this.state={popoverStyle:void 0,state:t.state}}async onClose(t){let{onClose:e}=this.props;e(t)}componentWillUnmount(){d(window).unbind("click",this.handleBackClick)}updatePopoverStyle(){let{position:t}=this.props;if("popover"===t){let e=this.getPopoverStyle();JSON.stringify(e)!==JSON.stringify(this.state.popoverStyle)&&this.setState({popoverStyle:e})}}componentDidMount(){let{popover:t={},position:e}=this.props;if(setTimeout(()=>{let{mounted:t,onMount:o}=this.props;this.setState({popoverStyle:"popover"===e?this.getPopoverStyle():{}}),t||o()},0),t.getTarget){this.dui="a"+Math.round(1e7*Math.random());t.getTarget().attr("data-uniq-id",this.dui)}d(window).unbind("click",this.handleBackClick),d(window).bind("click",d.proxy(this.handleBackClick,this))}handleBackClick(t){if(!this.dui)return;let{position:e="fullscreen"}=this.props,o=d(t.target);"popover"===e&&o.attr("data-uniq-id")!==this.dui&&!o.parents(`[data-uniq-id=${this.dui}]`).length&&this.onClose()}header_layout(){let{rtl:t,header:e}=this.props;if("object"!=typeof e)return!1;let{state:o}=this.state;return{html:h(ModalHeader,{rtl:t,header:e,handleClose:t=>this.onClose(t),state:o,setState:t=>this.setState({state:t})}),className:"of-visible"}}body_layout(){let{body:t={}}=this.props,{state:e}=this.state;return{flex:1,html:h(ModalBody,{body:t,state:e,setState:t=>this.setState({state:t}),handleClose:this.onClose.bind(this),updatePopoverStyle:()=>this.updatePopoverStyle()})}}footer_layout(){let{closeText:t,submitText:e,onSubmit:o,footer:i,type:s}=this.props,{state:r}=this.state,a=this.onClose.bind(this);return{html:h(ModalFooter,{closeText:t,submitText:e,onSubmit:o,footer:i,type:s,handleClose:a,state:r,setState:t=>this.setState({state:t})})}}getBackDropClassName(){let{rtl:t,position:e="fullscreen",backdrop:o,mounted:i}=this.props,s="aio-popup-backdrop";return o&&o.attrs&&o.attrs.className&&(s+=" "+o.attrs.className),s+=` aio-popup-position-${e}`,s+=t?" rtl":" ltr",i||(s+=" not-mounted"),s}backClick(t){if(this.isDown)return;t.stopPropagation();let e=d(t.target),{backdrop:o={}}=this.props;!1!==o.close&&e.hasClass("aio-popup-backdrop")&&this.onClose()}getPopoverStyle(){let{popover:t={},rtl:e,attrs:o={}}=this.props,{getTarget:i,pageSelector:s,fitHorizontal:r,fixStyle:a=t=>t}=t;if(!i)return{};let l=i();if(!l||!l.length)return{};let n=d(this.dom.current);return{...Align(n,l,{fixStyle:a,pageSelector:s,fitHorizontal:r,style:o.style,rtl:e}),position:"absolute"}}keyDown(t){let{isLast:e,removeModal:o}=this.props;if(e)27===t.keyCode&&o()}mouseUp(){setTimeout(()=>this.isDown=!1,0)}mouseDown(t){d(window).unbind("mouseup",this.mouseUp),d(window).bind("mouseup",d.proxy(this.mouseUp,this)),this.isDown=!0}render(){let{rtl:t,attrs:e={},backdrop:o={},mounted:i}=this.props,{popoverStyle:s}=this.state,r={...o?o.attrs:{},className:this.getBackDropClassName(),onClick:!1===o?void 0:t=>this.backClick(t)},a={...s,...e.style,flex:"none"},l="aio-popup"+(t?" rtl":" ltr")+(i?"":" not-mounted")+(e.className?" "+e.className:""),n="ontouchstart"in document.documentElement?"onTouchStart":"onMouseDown";return h("div",{...r,ref:this.backdropDom,onKeyDown:this.keyDown.bind(this),tabIndex:0,children:h(p,{layout:{attrs:{...e,ref:this.dom,style:void 0,className:void 0,"data-uniq-id":this.dui,[n]:this.mouseDown.bind(this)},className:l,style:a,column:[this.header_layout(),this.body_layout(),this.footer_layout()]}})})}}function ModalHeader({rtl:t,header:e,handleClose:o,state:i,setState:s}){if("object"!=typeof e)return null;let{title:d,subtitle:m,buttons:u=[],onClose:c,backButton:_,attrs:$={}}=e;function g(){c?c({state:i,setState:s}):o({state:i,setState:s})}let f="aio-popup-header"+($.className?" "+$.className:""),v=$.style;return h(p,{layout:{attrs:$,className:f,style:v,row:[function e(){if(!_||!1===c)return!1;let o,i;return t?(o=l,i={marginLeft:12}):(o=n,i={marginRight:12}),{html:h(r,{path:o,size:1}),align:"vh",onClick:()=>g(),style:i}}(),!!d&&(m?{flex:1,align:"v",column:[{html:d,className:"aio-popup-title"},{html:m,className:"aio-popup-subtitle"}]}:{flex:1,align:"v",html:d,className:"aio-popup-title"}),!!u.length&&{gap:6,align:"vh",row:()=>u.map(([t,e={}])=>{let{onClick:r=()=>{},className:a}=e,l={...e};return l.className="aio-popup-header-button"+(a?" "+a:""),l.onClick=()=>r({close:o,state:i,setState:s}),{html:h("button",{...l,children:t}),align:"vh"}})},!_&&!1!==c&&{html:h(r,{path:a,size:.8}),align:"vh",onClick:()=>g(),className:"aio-popup-header-close-button"}]}})}function ModalBody(t){let{handleClose:e,body:o,updatePopoverStyle:s,state:r,setState:a}=t,{render:l,attrs:n={}}=o,p="function"==typeof l?l({close:e,state:r,setState:a}):l;return i(()=>{s()},[p]),h("div",{...n,className:"aio-popup-body"+(n.className?" "+n.className:""),children:"function"==typeof l&&p})}function ModalFooter({footer:t,handleClose:e,state:o,setState:i}){if("object"!=typeof t)return null;let{attrs:s={},buttons:r=[]}=t,a;return h("div",{className:"aio-popup-footer"+(s.className?" "+s.className:""),style:s.style,children:r.length?r.map(([t,s={}])=>{let r="function"==typeof s?{...s({state:o,setState:i})}:{...s},{onClick:a=()=>{},className:l}=r;return r.className="aio-popup-footer-button"+(l?" "+l:""),r.onClick=()=>a({close:e,state:o,setState:i}),h("button",{...r,children:t})}):null})}function Alert(t={}){let{icon:e,type:o,text:i,subtext:r,time:a,className:l,closeText:n}=t,p={time:0,getId:()=>"aa"+Math.round(1e8*Math.random()),getBarRender:()=>`<div class='aio-popup-time-bar' style="width:${p.time}%;"></div>`,updateBarRender(){d(`.aio-popup-alert-container.${p.id} .aio-popup-time`).html(p.getBarRender())},getRender:()=>`
2
2
  <div class='aio-popup-alert-container ${p.id}${l?"aio-popup"+l:""}'>
3
3
  <div class='aio-popup-alert aio-popup-alert-${o}'>
4
4
  <div class='aio-popup-alert-header'>${p.getIcon()}</div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aio-popup",
3
- "version": "3.0.19",
3
+ "version": "3.0.21",
4
4
  "description": "handle all types of popup and modals in react",
5
5
  "main": "index.js",
6
6
  "scripts": {