diff --git a/assets/build/frontend/media.field.restrictions.asset.php b/assets/build/frontend/media.field.restrictions.asset.php index b652f2850..902452816 100644 --- a/assets/build/frontend/media.field.restrictions.asset.php +++ b/assets/build/frontend/media.field.restrictions.asset.php @@ -1 +1 @@ - array('wp-i18n'), 'version' => '2fa8b05f10aab57b1eae'); + array('wp-i18n'), 'version' => '3a8ed91056d8ec80b043'); diff --git a/assets/build/frontend/media.field.restrictions.js b/assets/build/frontend/media.field.restrictions.js index 5b26954a1..8b1a4c801 100644 --- a/assets/build/frontend/media.field.restrictions.js +++ b/assets/build/frontend/media.field.restrictions.js @@ -1 +1 @@ -(()=>{"use strict";const{AdvancedRestriction:t}=JetFormBuilderAbstract;function e(){t.call(this),this.watchedAttrs.push("max_files"),this.isSupported=function(t){return"file"===t?.type},this.validate=function(){var t;const{max_files:e}=this.reporting.input.attrs;let{current:i}=this.reporting.input.value;return i=null!==(t=i?.length)&&void 0!==t?t:0,!i||i<=e.value.current},this.getRawMessage=function(){return this.getMessageBySlug("max_files")}}e.prototype=Object.create(t.prototype);const i=e,{AdvancedRestriction:r}=JetFormBuilderAbstract;function n(){r.call(this)}n.prototype=Object.create(r.prototype),n.prototype.file=null,n.prototype.setFile=function(t){this.file=t};const o=n;function s(){o.call(this),this.watchedAttrs.push("max_size"),this.validate=function(){const{max_size:t}=this.reporting.input.attrs;return this.file.size(i,r)=>{e.setFile(t),e.validatePromise().then(i).catch(()=>r(e))});r.push((i,r)=>{Promise.allSettled(e.map(t=>new Promise(t))).then(e=>{const n=e.filter(({status:t})=>"rejected"===t).map(({reason:t,value:e})=>null!=t?t:e);n.length?r({file:t,rejected:n}):i()})})}if(!r?.length)return Promise.resolve();const n=await f(r);for(const t of i){const i=e.getFileNode(t.name).querySelector(".jet-form-builder-file-upload__file-invalid-marker"),[r={}]=n.filter(({file:e})=>e===t);i.style.display=r?.rejected?.length?"block":"none",i.title=r?.rejected?.length?r?.rejected[0].getMessage():""}return Boolean(n.length)?Promise.reject("validate is wrong"):Promise.resolve()};const g=h,m=window.wp.i18n,{Filter:y}=JetFormBuilderAbstract,{Kb_In_Bytes:b,Mb_In_Bytes:_,Gb_In_Bytes:j,Tb_In_Bytes:v}=JetFormBuilderConst,{getLanguage:B}=JetFormBuilderFunctions,F={[(0,m._x)("TB","unit symbol","jet-form-builder")]:v,[(0,m._x)("GB","unit symbol","jet-form-builder")]:j,[(0,m._x)("MB","unit symbol","jet-form-builder")]:_,[(0,m._x)("KB","unit symbol","jet-form-builder")]:b,[(0,m._x)("B","unit symbol","jet-form-builder")]:1},x=B();function w(){y.call(this),this.getSlug=function(){return"sizeFormat"},this.apply=function(t){if(t=+t,Number.isNaN(t)||0===t)return"0 B";for(const[e,i]of Object.entries(F))if(!(t{"use strict";const{AdvancedRestriction:t}=JetFormBuilderAbstract;function e(){t.call(this),this.watchedAttrs.push("max_files"),this.isSupported=function(t){return"file"===t?.type},this.validate=function(){var t;const{max_files:e}=this.reporting.input.attrs;let{current:i}=this.reporting.input.value;return i=null!==(t=i?.length)&&void 0!==t?t:0,!i||i<=e.value.current},this.getRawMessage=function(){return this.getMessageBySlug("max_files")}}e.prototype=Object.create(t.prototype);const i=e,{AdvancedRestriction:r}=JetFormBuilderAbstract;function n(){r.call(this)}n.prototype=Object.create(r.prototype),n.prototype.file=null,n.prototype.setFile=function(t){this.file=t};const o=n;function s(){o.call(this),this.watchedAttrs.push("max_size"),this.validate=function(){const{max_size:t}=this.reporting.input.attrs;return this.file.size<=t.value.current},this.getRawMessage=function(){return this.getMessageBySlug("file_max_size")}}s.prototype=Object.create(o.prototype);const l=s;function u(){o.call(this),this.watchedAttrs.push("file_ext"),this.isSupported=function(t,e){const{file_ext:i=!1}=e.input.attrs;return!1!==i},this.validate=function(){const{file_ext:t}=this.reporting.input.attrs;return t.value.current.includes(this.file.type)},this.getRawMessage=function(){return this.getMessageBySlug("file_ext")}}u.prototype=Object.create(o.prototype);const c=u,{applyFilters:a}=JetPlugins.hooks;let p=[];const{allRejected:f}=JetFormBuilderFunctions,{AdvancedRestriction:d}=JetFormBuilderAbstract;function h(){d.call(this),this.isSupported=function(t){return"file"===t?.type},this.getRawMessage=function(){return""}}h.prototype=Object.create(d.prototype),h.prototype.singleFileRestrictions=[],h.prototype.setReporting=function(t){d.prototype.setReporting.call(this,t),this.singleFileRestrictions=function(t){p.length||(p=a("jet.fb.restrictions.file",[l,c]));const e=[];for(const i of p){const r=new i;r.isSupported(t.getNode(),t)&&(r.setReporting(t),r.onReady(),e.push(r))}return e}(t)},h.prototype.validatePromise=async function(){var t;const e=this.reporting.input.callable,i=Array.from(null!==(t=this.reporting.input.value?.current)&&void 0!==t?t:[]),r=[];for(const t of i){if(!(t instanceof File))continue;const e=this.singleFileRestrictions.map(e=>(i,r)=>{e.setFile(t),e.validatePromise().then(i).catch(()=>r(e))});r.push((i,r)=>{Promise.allSettled(e.map(t=>new Promise(t))).then(e=>{const n=e.filter(({status:t})=>"rejected"===t).map(({reason:t,value:e})=>null!=t?t:e);n.length?r({file:t,rejected:n}):i()})})}if(!r?.length)return Promise.resolve();const n=await f(r);for(const t of i){const i=e.getFileNode(t.name).querySelector(".jet-form-builder-file-upload__file-invalid-marker"),[r={}]=n.filter(({file:e})=>e===t);i.style.display=r?.rejected?.length?"block":"none",i.title=r?.rejected?.length?r?.rejected[0].getMessage():""}return Boolean(n.length)?Promise.reject("validate is wrong"):Promise.resolve()};const g=h,m=window.wp.i18n,{Filter:y}=JetFormBuilderAbstract,{Kb_In_Bytes:b,Mb_In_Bytes:_,Gb_In_Bytes:j,Tb_In_Bytes:v}=JetFormBuilderConst,{getLanguage:B}=JetFormBuilderFunctions,F={[(0,m._x)("TB","unit symbol","jet-form-builder")]:v,[(0,m._x)("GB","unit symbol","jet-form-builder")]:j,[(0,m._x)("MB","unit symbol","jet-form-builder")]:_,[(0,m._x)("KB","unit symbol","jet-form-builder")]:b,[(0,m._x)("B","unit symbol","jet-form-builder")]:1},x=B();function w(){y.call(this),this.getSlug=function(){return"sizeFormat"},this.apply=function(t){if(t=+t,Number.isNaN(t)||0===t)return"0 B";for(const[e,i]of Object.entries(F))if(!(tis_advanced_form(); + if ( self::FORMAT_ADVANCED === $type ) { + return true; + } + + if ( '' === $type || 'inherit' === $type ) { + return $this->is_advanced_form(); + } + + return false; } public function is_advanced_form(): bool {