jrs-react 1.2.27 → 1.2.28

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/build/index.es.js CHANGED
@@ -27,7 +27,7 @@ import*as e from"react";import t,{useState as n}from"react";import r from"styled
27
27
  position: absolute;
28
28
  top: 0;
29
29
  left: 0;
30
- `;function Ze({id:e="jr-mask"}){return t.createElement(Ye,{id:e,className:"jr-mask"},t.createElement("div",{id:`${e}-msg`}),t.createElement("div",{className:"cs-loader-inner"},t.createElement("label",null,"●"),t.createElement("label",null,"●"),t.createElement("label",null,"●"),t.createElement("label",null,"●"),t.createElement("label",null,"●"),t.createElement("label",null,"●")))}function et({id:e="jr-mask"}){return t.createElement(Qe,{id:e},t.createElement("div",{id:`${e}-msg`},"MSG"),t.createElement("div",{className:"cs-loader-inner"},t.createElement("label",null,"●"),t.createElement("label",null,"●"),t.createElement("label",null,"●"),t.createElement("label",null,"●"),t.createElement("label",null,"●"),t.createElement("label",null,"●")))}class tt extends Ke{msg=[];#e=0;#t;get msgIndex(){return this.#e++}addMsg(e){const t=this.msgIndex;return this.msg.push({i:t,msg:!0!==e?e:null}),this.renderMsg(),()=>{this.removeMsg(t)}}removeMsg(e){this.msg=this.msg.filter((t=>t.i!=e)),this.renderMsg()}renderMsg(){this.msgDiv?.removeAllHijos(),this.msg.length?(this.msgDiv&&(this.msgDiv.html=this.msg[this.msg.length-1].msg),this.run()):this.stop()}run=()=>{this.yo.showModal?.()??this.display()};display(){this.yo.style.display="flex"}stop(){this.yo.close?.()??this.hide()}hide(){this.yo.style.display="none"}}function nt(e,t="jr-mask"){const n=document.getElementById(t);if(n){const r=document.getElementById(`${t}-msg`);return n.maskDiv||(n.maskDiv=new tt({yo:n,msgDiv:r?new Ke({yo:r}):null,listeners:{keydown(e){"Escape"===e.key&&e.preventDefault()}}})),n.maskDiv.addMsg(e)}}const rt=He.create({authorization:`Bearer ${localStorage.getItem("accessToken")}`,timeout:12e4,maxBodyLength:104857600,maxContentLength:104857600});r.div`
30
+ `;function Ze({id:e="jr-mask"}){return t.createElement(Ye,{id:e,className:"jr-mask"},t.createElement("div",{id:`${e}-msg`}),t.createElement("div",{className:"cs-loader-inner"},t.createElement("label",null,"●"),t.createElement("label",null,"●"),t.createElement("label",null,"●"),t.createElement("label",null,"●"),t.createElement("label",null,"●"),t.createElement("label",null,"●")))}function et({id:e="jr-mask"}){return t.createElement(Qe,{id:e},t.createElement("div",{id:`${e}-msg`},"MSG"),t.createElement("div",{className:"cs-loader-inner"},t.createElement("label",null,"●"),t.createElement("label",null,"●"),t.createElement("label",null,"●"),t.createElement("label",null,"●"),t.createElement("label",null,"●"),t.createElement("label",null,"●")))}class tt extends Ke{msg=[];#e=0;#t;get msgIndex(){return this.#e++}addMsg(e){const t=this.msgIndex;return this.msg.push({i:t,msg:!0!==e?e:null}),this.renderMsg(),()=>{this.removeMsg(t)}}removeMsg(e){this.msg=this.msg.filter((t=>t.i!=e)),this.renderMsg()}renderMsg(){this.msgDiv?.removeAllHijos(),this.msg.length?(this.msgDiv&&(this.msgDiv.html=this.msg[this.msg.length-1].msg),this.run()):this.stop()}run=()=>{this.yo.showModal?.()??this.display()};display(){this.yo.style.display="flex"}stop(){this.yo.close?.()??this.hide()}hide(){this.yo.style.display="none"}}function nt(e,t="jr-mask"){const n=document.getElementById(t);if(n){const r=document.getElementById(`${t}-msg`);return n.maskDiv||(n.maskDiv=new tt({yo:n,msgDiv:r?new Ke({yo:r}):null,listeners:{keydown(e){"Escape"===e.key&&e.preventDefault()}}})),n.maskDiv.addMsg(e)}console.warn(`Mask id ${t} not found.`)}const rt=He.create({authorization:`Bearer ${localStorage.getItem("accessToken")}`,timeout:12e4,maxBodyLength:104857600,maxContentLength:104857600});r.div`
31
31
  border:2px solid red;
32
32
  `;class ot extends t.Component{#n=["get","post","put","patch","delete","download"];constructor(e){super(e),void 0===this.props.value&&void 0!==this.props.initValue&&void 0===this.props.onChange&&(this.state={value:e.initValue,rawValue:JSON.parse(JSON.stringify(e.initValue))})}componentDidMount(){this.#n.filter((e=>this[e]&&this.props[e]&&this.props[e].autoRun)).forEach((e=>{this[e]()}))}get(e={}){const t=Object.assign({method:"get",updateValue:!0},this.props.get,e);this.submit(t)}post(e={}){e=Object.assign({method:"post",updateValue:!1},this.props.post,e),this.submit(e)}put(e={}){e=Object.assign({method:"put",updateValue:!1},this.props.put,e),this.submit(e)}delete(e={}){e=Object.assign({method:"delete",updateValue:!1},this.props.delete,e),this.submit(e)}get from(){return void 0===this.props.value?"state":"props"}get isDirty(){return this.state?.isDirty}set isDirty(e){this.setState({isDirty:e})}get rawValue(){return this.state?.rawValue}setRawValue(e){this.setState({rawValue:null!=e?JSON.parse(JSON.stringify(e)):null})}reset(){this.setValue(this.rawValue,!0)}setValue(e,t=!1){this.props.onChange?this.props.onChange(e):this.setState({value:e}),t&&this.setRawValue(e),this.isDirty=!t}setRes(e,t,n){if(e&&n.updateValue){const e=n.formatValue?.bind(this)(t.data)??t.data;t.data=e,this.setValue(e,!0)}else n.updateValue&&this.setValue(null,!0)}#r(e,t){const n=e.shift();return 0==e.length?t?.[n]:null!=t?.[n]?this.#r(e,t[n]):void 0}getValue(e){if(e){const t=e.split(".");return this.#r(t,this[this.from]?.value)}return qe(this[this.from]?.value,this,null,null)}getSubmitValue(){return this.getValue()}getAxiosParams({url:e,method:t,value:n,extraValue:r,sendValue:o,transformValue:s,...i}){const a=r?.bind?.(this)()??r;let l=n?.bind?.(this)({...this.getSubmitValue(),...a})??null==n?{...this.getSubmitValue(),...a}:{...n,...a};s&&(l=s.bind(this)(l));const c={authorization:`Bearer ${localStorage.getItem("accessToken")}`};let h={};const d={};return"get"==t?((null==o||o)&&(h.params=l),h.headers=c):"delete"==t?((null==o||o)&&(h.data=l),h.headers=c):(h=null==o||o?l:null,d.headers=c),{url:We(e,l),method:t,params1:h,params2:d,payload:l}}reload(){Xe("reload 還沒有做 ")}submit(e){let t;e.mask&&(e.removeMaskFunction=nt(e.mask,this.maskId??"jr-mask")),(()=>{if(Array.isArray(e.url))return t=[],Promise.allSettled(e.url.map((n=>{const r="object"==typeof n?n:{url:n},o=Object.assign(e,r),{url:s,method:i,params1:a,params2:l,payload:c}=this.getAxiosParams(o);return t.push(c),rt[i](s,a,l)})));{const{url:n,method:r,params1:o,params2:s,payload:i}=this.getAxiosParams(e);return t=i,rt[r](n,o,s)}})().then((n=>{this.handleResponse(n,t,e)})).catch((n=>{this.handleResponse(n,t,e)})).finally((()=>{e.removeMaskFunction?.()}))}handleResponse=(e,t,n)=>{Array.isArray(e)?e=e.map(((e,n)=>(e.value?e.value.payload=t[n]:e.reason&&(e.reason.payload=t[n]),e))):e.payload=t;const r=(e=n?.response?.bind(this)(e,t)??e).status>=200&&e.status<=299;this.setRes(r,e,n),this.showMessage(r,r?n.successMessage:n.failedMessage),n.callback?.bind(this)(r,e,t)};showMessage(e,t){Xe("success",e),Xe("message",t)}renderer(){}render(){return this.renderer()}}const st=({tag:e,config:n,me:r,className:o})=>{if("function"==typeof n){let s;const i=function(e){s=e},a=n.bind(r)({setStyle:i});return t.createElement(e,{className:o,style:s},a)}if("string"==typeof n)return t.createElement(e,{className:o},n)},it=r.div`
33
33
  position:relative;
package/build/index.js CHANGED
@@ -27,7 +27,7 @@
27
27
  position: absolute;
28
28
  top: 0;
29
29
  left: 0;
30
- `;class rt extends Qe{msg=[];#e=0;#t;get msgIndex(){return this.#e++}addMsg(e){const t=this.msgIndex;return this.msg.push({i:t,msg:!0!==e?e:null}),this.renderMsg(),()=>{this.removeMsg(t)}}removeMsg(e){this.msg=this.msg.filter((t=>t.i!=e)),this.renderMsg()}renderMsg(){this.msgDiv?.removeAllHijos(),this.msg.length?(this.msgDiv&&(this.msgDiv.html=this.msg[this.msg.length-1].msg),this.run()):this.stop()}run=()=>{this.yo.showModal?.()??this.display()};display(){this.yo.style.display="flex"}stop(){this.yo.close?.()??this.hide()}hide(){this.yo.style.display="none"}}function nt(e,t="jr-mask"){const r=document.getElementById(t);if(r){const n=document.getElementById(`${t}-msg`);return r.maskDiv||(r.maskDiv=new rt({yo:r,msgDiv:n?new Qe({yo:n}):null,listeners:{keydown(e){"Escape"===e.key&&e.preventDefault()}}})),r.maskDiv.addMsg(e)}}const ot=Je.create({authorization:`Bearer ${localStorage.getItem("accessToken")}`,timeout:12e4,maxBodyLength:104857600,maxContentLength:104857600});a.default.div`
30
+ `;class rt extends Qe{msg=[];#e=0;#t;get msgIndex(){return this.#e++}addMsg(e){const t=this.msgIndex;return this.msg.push({i:t,msg:!0!==e?e:null}),this.renderMsg(),()=>{this.removeMsg(t)}}removeMsg(e){this.msg=this.msg.filter((t=>t.i!=e)),this.renderMsg()}renderMsg(){this.msgDiv?.removeAllHijos(),this.msg.length?(this.msgDiv&&(this.msgDiv.html=this.msg[this.msg.length-1].msg),this.run()):this.stop()}run=()=>{this.yo.showModal?.()??this.display()};display(){this.yo.style.display="flex"}stop(){this.yo.close?.()??this.hide()}hide(){this.yo.style.display="none"}}function nt(e,t="jr-mask"){const r=document.getElementById(t);if(r){const n=document.getElementById(`${t}-msg`);return r.maskDiv||(r.maskDiv=new rt({yo:r,msgDiv:n?new Qe({yo:n}):null,listeners:{keydown(e){"Escape"===e.key&&e.preventDefault()}}})),r.maskDiv.addMsg(e)}console.warn(`Mask id ${t} not found.`)}const ot=Je.create({authorization:`Bearer ${localStorage.getItem("accessToken")}`,timeout:12e4,maxBodyLength:104857600,maxContentLength:104857600});a.default.div`
31
31
  border:2px solid red;
32
32
  `;class st extends s.default.Component{#r=["get","post","put","patch","delete","download"];constructor(e){super(e),void 0===this.props.value&&void 0!==this.props.initValue&&void 0===this.props.onChange&&(this.state={value:e.initValue,rawValue:JSON.parse(JSON.stringify(e.initValue))})}componentDidMount(){this.#r.filter((e=>this[e]&&this.props[e]&&this.props[e].autoRun)).forEach((e=>{this[e]()}))}get(e={}){const t=Object.assign({method:"get",updateValue:!0},this.props.get,e);this.submit(t)}post(e={}){e=Object.assign({method:"post",updateValue:!1},this.props.post,e),this.submit(e)}put(e={}){e=Object.assign({method:"put",updateValue:!1},this.props.put,e),this.submit(e)}delete(e={}){e=Object.assign({method:"delete",updateValue:!1},this.props.delete,e),this.submit(e)}get from(){return void 0===this.props.value?"state":"props"}get isDirty(){return this.state?.isDirty}set isDirty(e){this.setState({isDirty:e})}get rawValue(){return this.state?.rawValue}setRawValue(e){this.setState({rawValue:null!=e?JSON.parse(JSON.stringify(e)):null})}reset(){this.setValue(this.rawValue,!0)}setValue(e,t=!1){this.props.onChange?this.props.onChange(e):this.setState({value:e}),t&&this.setRawValue(e),this.isDirty=!t}setRes(e,t,r){if(e&&r.updateValue){const e=r.formatValue?.bind(this)(t.data)??t.data;t.data=e,this.setValue(e,!0)}else r.updateValue&&this.setValue(null,!0)}#n(e,t){const r=e.shift();return 0==e.length?t?.[r]:null!=t?.[r]?this.#n(e,t[r]):void 0}getValue(e){if(e){const t=e.split(".");return this.#n(t,this[this.from]?.value)}return Ge(this[this.from]?.value,this,null,null)}getSubmitValue(){return this.getValue()}getAxiosParams({url:e,method:t,value:r,extraValue:n,sendValue:o,transformValue:s,...i}){const a=n?.bind?.(this)()??n;let l=r?.bind?.(this)({...this.getSubmitValue(),...a})??null==r?{...this.getSubmitValue(),...a}:{...r,...a};s&&(l=s.bind(this)(l));const c={authorization:`Bearer ${localStorage.getItem("accessToken")}`};let d={};const u={};return"get"==t?((null==o||o)&&(d.params=l),d.headers=c):"delete"==t?((null==o||o)&&(d.data=l),d.headers=c):(d=null==o||o?l:null,u.headers=c),{url:Ke(e,l),method:t,params1:d,params2:u,payload:l}}reload(){qe("reload 還沒有做 ")}submit(e){let t;e.mask&&(e.removeMaskFunction=nt(e.mask,this.maskId??"jr-mask")),(()=>{if(Array.isArray(e.url))return t=[],Promise.allSettled(e.url.map((r=>{const n="object"==typeof r?r:{url:r},o=Object.assign(e,n),{url:s,method:i,params1:a,params2:l,payload:c}=this.getAxiosParams(o);return t.push(c),ot[i](s,a,l)})));{const{url:r,method:n,params1:o,params2:s,payload:i}=this.getAxiosParams(e);return t=i,ot[n](r,o,s)}})().then((r=>{this.handleResponse(r,t,e)})).catch((r=>{this.handleResponse(r,t,e)})).finally((()=>{e.removeMaskFunction?.()}))}handleResponse=(e,t,r)=>{Array.isArray(e)?e=e.map(((e,r)=>(e.value?e.value.payload=t[r]:e.reason&&(e.reason.payload=t[r]),e))):e.payload=t;const n=(e=r?.response?.bind(this)(e,t)??e).status>=200&&e.status<=299;this.setRes(n,e,r),this.showMessage(n,n?r.successMessage:r.failedMessage),r.callback?.bind(this)(n,e,t)};showMessage(e,t){qe("success",e),qe("message",t)}renderer(){}render(){return this.renderer()}}const it=({tag:e,config:t,me:r,className:n})=>{if("function"==typeof t){let o;const i=function(e){o=e},a=t.bind(r)({setStyle:i});return s.default.createElement(e,{className:n,style:o},a)}if("string"==typeof t)return s.default.createElement(e,{className:n},t)},at=a.default.div`
33
33
  position:relative;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jrs-react",
3
- "version": "1.2.27",
3
+ "version": "1.2.28",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.es.js",
@@ -236,5 +236,7 @@ export function showMask(msg,maskId='jr-mask'){
236
236
  })
237
237
  }
238
238
  return jrMask.maskDiv.addMsg(msg)
239
+ }else{
240
+ console.warn(`Mask id ${maskId} not found.`)
239
241
  }
240
242
  }